!function(e){"use strict";function t(t){let a=JSON.parse(lpacDPSCalendarConfig),n={altInput:!0,altFormat:a.dateFormat,dateFormat:"Y-m-d",disable:function(e,t){let a=t[e].availableDays;if(a.length<1)return;let n=Object.keys(a);return[function(e){return!n.includes(e.getDay().toString())},...t[e].maxedDates,...t[e].offDays]}(t,a),locale:{firstDayOfWeek:a.firstDayOfWeek,weekdays:{shorthand:a.locale.weekdaysShorthand,longhand:a.locale.weekdaysLonghand},months:{shorthand:a.locale.monthsShorthand,longhand:a.locale.monthsLonghand}},onChange:function(a,n,r){let i=document.querySelector(`#lpac_dps_${t}_time`);if(null!==i&&!(i.length<1)){var l,c;l={date:n,dayIndex:a[0].getDay(),orderType:t},c=t,jQuery(".dps-time-field").addClass("processing").block({message:null,overlayCSS:{background:"#fff",opacity:.6}}),wp.ajax.post("lpac_dps_get_times",{selectedDate:l}).done(t=>{"set_manually"===t?function(t){let a=document.querySelector(`#lpac_dps_${t}_time`),n=document.createElement("input");n.setAttribute("type","text"),n.setAttribute("class","input-text form-control input"),n.setAttribute("name",`lpac_dps_${t}_time`),n.setAttribute("id",`lpac_dps_${t}_time`),a.replaceWith(n);let r=document.querySelector(`#lpac_dps_${t}_time_field .woocommerce-input-wrapper`);r&&r.lastChild.classList.contains("flatpickr-mobile")&&r.removeChild(r.lastChild);let i=JSON.parse(lpacDPSGeneralConfig).time.timeFormat;e(`#lpac_dps_${t}_time`).flatpickr({noCalendar:!0,enableTime:!0,dateFormat:"12hr"===i?"h:i K":"H:i",time_24hr:"24hr"===i}),document.querySelector(`#lpac_dps_${t}_time`).addEventListener("change",function(){jQuery(document.body).trigger("update_checkout")}),document.dispatchEvent(new CustomEvent("dps:time_field_replaced"))}(c):function(e,t){let a=document.querySelector(`#lpac_dps_${t}_time`);if("SELECT"===a.tagName)a.innerHTML=e;else{let n=document.createElement("select");n.setAttribute("class","input-text form-control input"),n.setAttribute("name",`lpac_dps_${t}_time`),n.setAttribute("id",`lpac_dps_${t}_time`),n.innerHTML=e,a.replaceWith(n)}let n=document.querySelector(`#lpac_dps_${t}_time_field  .woocommerce-input-wrapper`);n&&n.lastChild.classList.contains("flatpickr-mobile")&&n.removeChild(n.lastChild),document.querySelector(`#lpac_dps_${t}_time`).addEventListener("change",function(){jQuery(document.body).trigger("update_checkout")}),document.dispatchEvent(new CustomEvent("dps:time_field_replaced"))}(t,c),jQuery(".dps-time-field").removeClass("processing").unblock({message:null,overlayCSS:{background:"#fff",opacity:.6}}),jQuery(document.body).trigger("update_checkout")}).fail(function(e){console.error(e),console.error(e.responseJSON)})}}},r=a[t].minDaysIncludeCurrentDay,i=a[t].maxDaysIncludeCurrentDay;return a[t].minDaysInFuture?n.minDate=new Date().fp_incr(r?a[t].minDaysInFuture+1:a[t].minDaysInFuture):n.minDate="today",a[t].maxDaysInFuture?n.maxDate=new Date().fp_incr(i?a[t].maxDaysInFuture+1:a[t].maxDaysInFuture):n.maxDate="today",n}e(document).ready(function(){e("#lpac_dps_delivery_date").flatpickr(t("delivery")),e("#lpac_dps_pickup_date").flatpickr(t("pickup"));let a=JSON.parse(lpacDPSGeneralConfig).time.timeFormat;e("#lpac_dps_delivery_time").flatpickr({noCalendar:!0,enableTime:!0,dateFormat:"12hr"===a?"h:i K":"H:i",time_24hr:"24hr"===a}),e("#lpac_dps_pickup_time").flatpickr({noCalendar:!0,enableTime:!0,dateFormat:"12hr"===a?"h:i K":"H:i",time_24hr:"24hr"===a})})}(jQuery);