!function(m){"use strict";m(function(){function a(e){m(e).datepicker({changeMonth:!0,changeYear:!0,defaultDate:s,firstDay:l,monthNames:n.split(","),monthNamesShort:n.split(","),dayNames:i.split(","),dayNamesShort:d.split(","),dayNamesMin:r.split(","),dateFormat:"yy-mm-dd",beforeShow:function(){m("#ui-datepicker-div").hasClass("wcs-datepicker-pop")||m("#ui-datepicker-div").addClass("wcs-datepicker-pop")},onClose:function(){m("#ui-datepicker-div").hasClass("wcs-datepicker-pop")&&m("#ui-datepicker-div").removeClass("wcs-datepicker-pop")}})}function e(){var e=Handlebars.compile(p);m("#wcs-canceled__holder").append(e()),a("input[name='wcs-canceled-days[]']")}function t(){var e=Handlebars.compile(o);m("#wcs-repeat__holder").append(e()),a("input[name='wcs-repeat-dates[]']")}var s=new Date(m('input[name="wcs-timestamp"]').val()+"T"+(10<=m('select[name="wcs-hour"]').val()?m('select[name="wcs-hour"]').val():"0"+m('select[name="wcs-hour"]').val())+":"+(10<=parseInt(m('select[name="wcs-minutes"]').val())?m('select[name="wcs-minutes"]').val():"0"+m('select[name="wcs-minutes"]').val())+":00Z"),c=s.getTimezoneOffset();s.setMinutes(s.getMinutes()+c);var n=m("#wcs-datepicker").data("wcs-months"),i=m("#wcs-datepicker").data("wcs-days"),d=m("#wcs-datepicker").data("wcs-days-short"),r=m("#wcs-datepicker").data("wcs-days-min"),l=m("#wcs-datepicker").data("wcs-firstday");m("#wcs-datepicker").datepicker({dateFormat:"yy-mm-dd",altField:'input[name="wcs-date"]',changeMonth:!0,changeYear:!0,defaultDate:s,firstDay:l,beforeShow:function(e,a){m("#ui-datepicker-div").addClass("wcs-datepicker-pop")},onClose:function(e,a){m("#ui-datepicker-div").removeClass("wcs-datepicker-pop")},monthNames:n.split(","),monthNamesShort:n.split(","),dayNames:i.split(","),dayNamesShort:d.split(","),dayNamesMin:r.split(",")}),m("#wcs-datepicker-ending").datepicker({dateFormat:"yy-mm-dd",changeMonth:!0,changeYear:!0,beforeShow:function(e,a){m("#ui-datepicker-div").addClass("wcs-datepicker-pop")},onClose:function(e,a){m("#ui-datepicker-div").removeClass("wcs-datepicker-pop")}}),m("body").on("click","#wcs-until a",function(e){e.preventDefault(),m(this).next("input").val("")}),m(".repeat_until").datepicker({dateFormat:"yy-mm-dd",changeMonth:!0,changeYear:!0,beforeShow:function(e,a){m("#ui-datepicker-div").addClass("wcs-datepicker-pop")},onClose:function(e,a){m("#ui-datepicker-div").removeClass("wcs-datepicker-pop")}});var p=m("#wcs-canceled-item").html(),o=m("#wcs-repeat-date-item").html();m("#add-repeat").on("click",t),m("#add-canceled").on("click",e),m("body").on("click",".wcs-canceled-repeat",function(e){var a;e.preventDefault(),confirm("Are you sure?")&&m(this).parents(".wcs-canceled__item").remove()}),m("body").on("click",".wcs-delete-repeat",function(e){var a;console.log("te"),e.preventDefault(),confirm("Are you sure?")&&m(this).parents(".wcs-repeat__item").remove()}),a("input[name='wcs-canceled-days[]']"),a("input[name='wcs-repeat-dates[]']");var u=m("#wcs-duration");m(".slider",u).slider({value:u.data("wcs-value"),step:5,min:5,max:1440,slide:function(e,a){var t=" ",s=a.value;1===Math.floor(a.value/60)&&(t=Math.floor(a.value/60)+" "+u.data("wcs-units-hour")),2<=Math.floor(a.value/60)&&Math.floor(a.value/60)<=24&&(t=Math.floor(a.value/60)+" "+u.data("wcs-units-hours")),s=0<(s-=60*Math.floor(a.value/60))?s+" "+u.data("wcs-units-minutes"):"",m(this).siblings(".slider_value").children("strong").text(t),m(this).siblings(".slider_value").children("em").text(s),m(this).siblings("input[type=hidden]").val(a.value)}}),m("#wrapper__wcs_action_page").dependsOn({"input[name*=_wcs_action_call]":{values:["0"]}}),m("#wrapper__wcs_repeat_days").dependsOn({"select[name*=wcs-interval]":{values:["2",2]}}),m("#wrapper__wcs_action_custom").dependsOn({"input[name*=_wcs_action_call]":{values:["1"]}}),m("#wrapper__wcs_action_email").dependsOn({"input[name*=_wcs_action_call]":{values:["2"]}}),m("#wcs-canceled").dependsOn({"select[name*=wcs-status]":{values:["2"]}}),m("#wcs-until").dependsOn({"select[name*=wcs-interval]":{values:["1","2","3","4","5",1,2,3,4,5]}}),m("#wcs-duration-container").dependsOn({"input[name*=wcs_multiday]":{checked:!1}}),m(".wcs-admin-metabox-time--ending").dependsOn({"input[name*=wcs_multiday]":{checked:!0}}),m("#wcs-repeat-dates").dependsOn({"select[name*=wcs-interval]":{values:["6",6]}}),m("#wcs-repeat-container").dependsOn({"input[name*=wcs_multiday]":{checked:!1}})})}(jQuery);