@influence-society-web/yuna-frontend 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,7 +4,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
4
4
|
<span class='flatpickr-weekday'>
|
|
5
5
|
`+b.join("</span><span class='flatpickr-weekday'>")+`
|
|
6
6
|
</span>
|
|
7
|
-
`}}function w(){e.calendarContainer.classList.add("hasWeeks");var f=Ee("div","flatpickr-weekwrapper");f.appendChild(Ee("span","flatpickr-weekday",e.l10n.weekAbbreviation));var b=Ee("div","flatpickr-weeks");return f.appendChild(b),{weekWrapper:f,weekNumbers:b}}function _(f,b){b===void 0&&(b=!0);var M=b?f:f-e.currentMonth;M<0&&e._hidePrevMonthArrow===!0||M>0&&e._hideNextMonthArrow===!0||(e.currentMonth+=M,(e.currentMonth<0||e.currentMonth>11)&&(e.currentYear+=e.currentMonth>11?1:-1,e.currentMonth=(e.currentMonth+12)%12,Le("onYearChange"),ne()),H(),Le("onMonthChange"),fo())}function k(f,b){if(f===void 0&&(f=!0),b===void 0&&(b=!0),e.input.value="",e.altInput!==void 0&&(e.altInput.value=""),e.mobileInput!==void 0&&(e.mobileInput.value=""),e.selectedDates=[],e.latestSelectedDateObj=void 0,b===!0&&(e.currentYear=e._initialDate.getFullYear(),e.currentMonth=e._initialDate.getMonth()),e.config.enableTime===!0){var M=Ma(e.config),x=M.hours,j=M.minutes,q=M.seconds;E(x,j,q)}e.redraw(),f&&Le("onChange")}function S(){e.isOpen=!1,e.isMobile||(e.calendarContainer!==void 0&&e.calendarContainer.classList.remove("open"),e._input!==void 0&&e._input.classList.remove("active")),Le("onClose")}function B(){e.config!==void 0&&Le("onDestroy");for(var f=e._handlers.length;f--;)e._handlers[f].remove();if(e._handlers=[],e.mobileInput)e.mobileInput.parentNode&&e.mobileInput.parentNode.removeChild(e.mobileInput),e.mobileInput=void 0;else if(e.calendarContainer&&e.calendarContainer.parentNode)if(e.config.static&&e.calendarContainer.parentNode){var b=e.calendarContainer.parentNode;if(b.lastChild&&b.removeChild(b.lastChild),b.parentNode){for(;b.firstChild;)b.parentNode.insertBefore(b.firstChild,b);b.parentNode.removeChild(b)}}else e.calendarContainer.parentNode.removeChild(e.calendarContainer);e.altInput&&(e.input.type="text",e.altInput.parentNode&&e.altInput.parentNode.removeChild(e.altInput),delete e.altInput),e.input&&(e.input.type=e.input._type,e.input.classList.remove("flatpickr-input"),e.input.removeAttribute("readonly")),["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(M){try{delete e[M]}catch{}})}function A(f){return e.calendarContainer.contains(f)}function V(f){if(e.isOpen&&!e.config.inline){var b=Ht(f),M=A(b),x=b===e.input||b===e.altInput||e.element.contains(b)||f.path&&f.path.indexOf&&(~f.path.indexOf(e.input)||~f.path.indexOf(e.altInput)),j=!x&&!M&&!A(f.relatedTarget),q=!e.config.ignoredFocusElements.some(function(pe){return pe.contains(b)});j&&q&&(e.config.allowInput&&e.setDate(e._input.value,!1,e.config.altInput?e.config.altFormat:e.config.dateFormat),e.timeContainer!==void 0&&e.minuteElement!==void 0&&e.hourElement!==void 0&&e.input.value!==""&&e.input.value!==void 0&&l(),e.close(),e.config&&e.config.mode==="range"&&e.selectedDates.length===1&&e.clear(!1))}}function Q(f){if(!(!f||e.config.minDate&&f<e.config.minDate.getFullYear()||e.config.maxDate&&f>e.config.maxDate.getFullYear())){var b=f,M=e.currentYear!==b;e.currentYear=b||e.currentYear,e.config.maxDate&&e.currentYear===e.config.maxDate.getFullYear()?e.currentMonth=Math.min(e.config.maxDate.getMonth(),e.currentMonth):e.config.minDate&&e.currentYear===e.config.minDate.getFullYear()&&(e.currentMonth=Math.max(e.config.minDate.getMonth(),e.currentMonth)),M&&(e.redraw(),Le("onYearChange"),ne())}}function z(f,b){var M;b===void 0&&(b=!0);var x=e.parseDate(f,void 0,b);if(e.config.minDate&&x&&Bt(x,e.config.minDate,b!==void 0?b:!e.minDateHasTime)<0||e.config.maxDate&&x&&Bt(x,e.config.maxDate,b!==void 0?b:!e.maxDateHasTime)>0)return!1;if(!e.config.enable&&e.config.disable.length===0)return!0;if(x===void 0)return!1;for(var j=!!e.config.enable,q=(M=e.config.enable)!==null&&M!==void 0?M:e.config.disable,pe=0,X=void 0;pe<q.length;pe++){if(X=q[pe],typeof X=="function"&&X(x))return j;if(X instanceof Date&&x!==void 0&&X.getTime()===x.getTime())return j;if(typeof X=="string"){var ve=e.parseDate(X,void 0,!0);return ve&&ve.getTime()===x.getTime()?j:!j}else if(typeof X=="object"&&x!==void 0&&X.from&&X.to&&x.getTime()>=X.from.getTime()&&x.getTime()<=X.to.getTime())return j}return!j}function $(f){return e.daysContainer!==void 0?f.className.indexOf("hidden")===-1&&f.className.indexOf("flatpickr-disabled")===-1&&e.daysContainer.contains(f):!1}function re(f){var b=f.target===e._input,M=e._input.value.trimEnd()!==Na();b&&M&&!(f.relatedTarget&&A(f.relatedTarget))&&e.setDate(e._input.value,!0,f.target===e.altInput?e.config.altFormat:e.config.dateFormat)}function ue(f){var b=Ht(f),M=e.config.wrap?n.contains(b):b===e._input,x=e.config.allowInput,j=e.isOpen&&(!x||!M),q=e.config.inline&&M&&!x;if(f.keyCode===13&&M){if(x)return e.setDate(e._input.value,!0,b===e.altInput?e.config.altFormat:e.config.dateFormat),e.close(),b.blur();e.open()}else if(A(b)||j||q){var pe=!!e.timeContainer&&e.timeContainer.contains(b);switch(f.keyCode){case 13:pe?(f.preventDefault(),l(),xa()):Lc(f);break;case 27:f.preventDefault(),xa();break;case 8:case 46:M&&!e.config.allowInput&&(f.preventDefault(),e.clear());break;case 37:case 39:if(!pe&&!M){f.preventDefault();var X=o();if(e.daysContainer!==void 0&&(x===!1||X&&$(X))){var ve=f.keyCode===39?1:-1;f.ctrlKey?(f.stopPropagation(),_(ve),N(Me(1),0)):N(void 0,ve)}}else e.hourElement&&e.hourElement.focus();break;case 38:case 40:f.preventDefault();var J=f.keyCode===40?1:-1;e.daysContainer&&b.$i!==void 0||b===e.input||b===e.altInput?f.ctrlKey?(f.stopPropagation(),Q(e.currentYear-J),N(Me(1),0)):pe||N(void 0,J*7):b===e.currentYearElement?Q(e.currentYear-J):e.config.enableTime&&(!pe&&e.hourElement&&e.hourElement.focus(),l(f),e._debouncedChange());break;case 9:if(pe){var se=[e.hourElement,e.minuteElement,e.secondElement,e.amPM].concat(e.pluginElements).filter(function(Yt){return Yt}),Te=se.indexOf(b);if(Te!==-1){var an=se[Te+(f.shiftKey?-1:1)];f.preventDefault(),(an||e._input).focus()}}else!e.config.noCalendar&&e.daysContainer&&e.daysContainer.contains(b)&&f.shiftKey&&(f.preventDefault(),e._input.focus());break;default:break}}if(e.amPM!==void 0&&b===e.amPM)switch(f.key){case e.l10n.amPM[0].charAt(0):case e.l10n.amPM[0].charAt(0).toLowerCase():e.amPM.textContent=e.l10n.amPM[0],p(),yn();break;case e.l10n.amPM[1].charAt(0):case e.l10n.amPM[1].charAt(0).toLowerCase():e.amPM.textContent=e.l10n.amPM[1],p(),yn();break}(M||A(b))&&Le("onKeyDown",f)}function ye(f,b){if(b===void 0&&(b="flatpickr-day"),!(e.selectedDates.length!==1||f&&(!f.classList.contains(b)||f.classList.contains("flatpickr-disabled")))){for(var M=f?f.dateObj.getTime():e.days.firstElementChild.dateObj.getTime(),x=e.parseDate(e.selectedDates[0],void 0,!0).getTime(),j=Math.min(M,e.selectedDates[0].getTime()),q=Math.max(M,e.selectedDates[0].getTime()),pe=!1,X=0,ve=0,J=j;J<q;J+=Sd.DAY)z(new Date(J),!0)||(pe=pe||J>j&&J<q,J<x&&(!X||J>X)?X=J:J>x&&(!ve||J<ve)&&(ve=J));var se=Array.from(e.rContainer.querySelectorAll("*:nth-child(-n+"+e.config.showMonths+") > ."+b));se.forEach(function(Te){var an=Te.dateObj,Yt=an.getTime(),Xr=X>0&&Yt<X||ve>0&&Yt>ve;if(Xr){Te.classList.add("notAllowed"),["inRange","startRange","endRange"].forEach(function(br){Te.classList.remove(br)});return}else if(pe&&!Xr)return;["startRange","inRange","endRange","notAllowed"].forEach(function(br){Te.classList.remove(br)}),f!==void 0&&(f.classList.add(M<=e.selectedDates[0].getTime()?"startRange":"endRange"),x<M&&Yt===x?Te.classList.add("startRange"):x>M&&Yt===x&&Te.classList.add("endRange"),Yt>=X&&(ve===0||Yt<=ve)&&Md(Yt,x,M)&&Te.classList.add("inRange"))})}}function we(){e.isOpen&&!e.config.static&&!e.config.inline&&Nn()}function xe(f,b){if(b===void 0&&(b=e._positionElement),e.isMobile===!0){if(f){f.preventDefault();var M=Ht(f);M&&M.blur()}e.mobileInput!==void 0&&(e.mobileInput.focus(),e.mobileInput.click()),Le("onOpen");return}else if(e._input.disabled||e.config.inline)return;var x=e.isOpen;e.isOpen=!0,x||(e.calendarContainer.classList.add("open"),e._input.classList.add("active"),Le("onOpen"),Nn(b)),e.config.enableTime===!0&&e.config.noCalendar===!0&&e.config.allowInput===!1&&(f===void 0||!e.timeContainer.contains(f.relatedTarget))&&setTimeout(function(){return e.hourElement.select()},50)}function $e(f){return function(b){var M=e.config["_"+f+"Date"]=e.parseDate(b,e.config.dateFormat),x=e.config["_"+(f==="min"?"max":"min")+"Date"];M!==void 0&&(e[f==="min"?"minDateHasTime":"maxDateHasTime"]=M.getHours()>0||M.getMinutes()>0||M.getSeconds()>0),e.selectedDates&&(e.selectedDates=e.selectedDates.filter(function(j){return z(j)}),!e.selectedDates.length&&f==="min"&&y(M),yn()),e.daysContainer&&(mo(),M!==void 0?e.currentYearElement[f]=M.getFullYear().toString():e.currentYearElement.removeAttribute(f),e.currentYearElement.disabled=!!x&&M!==void 0&&x.getFullYear()===M.getFullYear())}}function tt(){var f=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],b=ct(ct({},JSON.parse(JSON.stringify(n.dataset||{}))),t),M={};e.config.parseDate=b.parseDate,e.config.formatDate=b.formatDate,Object.defineProperty(e.config,"enable",{get:function(){return e.config._enable},set:function(se){e.config._enable=Oc(se)}}),Object.defineProperty(e.config,"disable",{get:function(){return e.config._disable},set:function(se){e.config._disable=Oc(se)}});var x=b.mode==="time";if(!b.dateFormat&&(b.enableTime||x)){var j=je.defaultConfig.dateFormat||Qn.dateFormat;M.dateFormat=b.noCalendar||x?"H:i"+(b.enableSeconds?":S":""):j+" H:i"+(b.enableSeconds?":S":"")}if(b.altInput&&(b.enableTime||x)&&!b.altFormat){var q=je.defaultConfig.altFormat||Qn.altFormat;M.altFormat=b.noCalendar||x?"h:i"+(b.enableSeconds?":S K":" K"):q+(" h:i"+(b.enableSeconds?":S":"")+" K")}Object.defineProperty(e.config,"minDate",{get:function(){return e.config._minDate},set:$e("min")}),Object.defineProperty(e.config,"maxDate",{get:function(){return e.config._maxDate},set:$e("max")});var pe=function(se){return function(Te){e.config[se==="min"?"_minTime":"_maxTime"]=e.parseDate(Te,"H:i:S")}};Object.defineProperty(e.config,"minTime",{get:function(){return e.config._minTime},set:pe("min")}),Object.defineProperty(e.config,"maxTime",{get:function(){return e.config._maxTime},set:pe("max")}),b.mode==="time"&&(e.config.noCalendar=!0,e.config.enableTime=!0),Object.assign(e.config,M,b);for(var X=0;X<f.length;X++)e.config[f[X]]=e.config[f[X]]===!0||e.config[f[X]]==="true";va.filter(function(se){return e.config[se]!==void 0}).forEach(function(se){e.config[se]=Da(e.config[se]||[]).map(a)}),e.isMobile=!e.config.disableMobile&&!e.config.inline&&e.config.mode==="single"&&!e.config.disable.length&&!e.config.enable&&!e.config.weekNumbers&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);for(var X=0;X<e.config.plugins.length;X++){var ve=e.config.plugins[X](e)||{};for(var J in ve)va.indexOf(J)>-1?e.config[J]=Da(ve[J]).map(a).concat(e.config[J]):typeof b[J]>"u"&&(e.config[J]=ve[J])}b.altInputClass||(e.config.altInputClass=Wt().className+" "+e.config.altInputClass),Le("onParseConfig")}function Wt(){return e.config.wrap?n.querySelector("[data-input]"):n}function er(){typeof e.config.locale!="object"&&typeof je.l10ns[e.config.locale]>"u"&&e.config.errorHandler(new Error("flatpickr: invalid locale "+e.config.locale)),e.l10n=ct(ct({},je.l10ns.default),typeof e.config.locale=="object"?e.config.locale:e.config.locale!=="default"?je.l10ns[e.config.locale]:void 0),Ln.D="("+e.l10n.weekdays.shorthand.join("|")+")",Ln.l="("+e.l10n.weekdays.longhand.join("|")+")",Ln.M="("+e.l10n.months.shorthand.join("|")+")",Ln.F="("+e.l10n.months.longhand.join("|")+")",Ln.K="("+e.l10n.amPM[0]+"|"+e.l10n.amPM[1]+"|"+e.l10n.amPM[0].toLowerCase()+"|"+e.l10n.amPM[1].toLowerCase()+")";var f=ct(ct({},t),JSON.parse(JSON.stringify(n.dataset||{})));f.time_24hr===void 0&&je.defaultConfig.time_24hr===void 0&&(e.config.time_24hr=e.l10n.time_24hr),e.formatDate=Rc(e),e.parseDate=Ea({config:e.config,l10n:e.l10n})}function Nn(f){if(typeof e.config.position=="function")return void e.config.position(e,f);if(e.calendarContainer!==void 0){Le("onPreCalendarPosition");var b=f||e._positionElement,M=Array.prototype.reduce.call(e.calendarContainer.children,function(Jd,Xd){return Jd+Xd.offsetHeight},0),x=e.calendarContainer.offsetWidth,j=e.config.position.split(" "),q=j[0],pe=j.length>1?j[1]:null,X=b.getBoundingClientRect(),ve=window.innerHeight-X.bottom,J=q==="above"||q!=="below"&&ve<M&&X.top>M,se=window.pageYOffset+X.top+(J?-M-2:b.offsetHeight+2);if(st(e.calendarContainer,"arrowTop",!J),st(e.calendarContainer,"arrowBottom",J),!e.config.inline){var Te=window.pageXOffset+X.left,an=!1,Yt=!1;pe==="center"?(Te-=(x-X.width)/2,an=!0):pe==="right"&&(Te-=x-X.width,Yt=!0),st(e.calendarContainer,"arrowLeft",!an&&!Yt),st(e.calendarContainer,"arrowCenter",an),st(e.calendarContainer,"arrowRight",Yt);var Xr=window.document.body.offsetWidth-(window.pageXOffset+X.right),br=Te+x>window.document.body.offsetWidth,zd=Xr+x>window.document.body.offsetWidth;if(st(e.calendarContainer,"rightMost",br),!e.config.static)if(e.calendarContainer.style.top=se+"px",!br)e.calendarContainer.style.left=Te+"px",e.calendarContainer.style.right="auto";else if(!zd)e.calendarContainer.style.left="auto",e.calendarContainer.style.right=Xr+"px";else{var Oa=Jr();if(Oa===void 0)return;var Vd=window.document.body.offsetWidth,qd=Math.max(0,Vd/2-x/2),Wd=".flatpickr-calendar.centerMost:before",Gd=".flatpickr-calendar.centerMost:after",Kd=Oa.cssRules.length,Zd="{left:"+X.left+"px;right:auto;}";st(e.calendarContainer,"rightMost",!1),st(e.calendarContainer,"centerMost",!0),Oa.insertRule(Wd+","+Gd+Zd,Kd),e.calendarContainer.style.left=qd+"px",e.calendarContainer.style.right="auto"}}}}function Jr(){for(var f=null,b=0;b<document.styleSheets.length;b++){var M=document.styleSheets[b];if(M.cssRules){try{M.cssRules}catch{continue}f=M;break}}return f??ho()}function ho(){var f=document.createElement("style");return document.head.appendChild(f),f.sheet}function mo(){e.config.noCalendar||e.isMobile||(ne(),fo(),H())}function xa(){e._input.focus(),window.navigator.userAgent.indexOf("MSIE")!==-1||navigator.msMaxTouchPoints!==void 0?setTimeout(e.close,0):e.close()}function Lc(f){f.preventDefault(),f.stopPropagation();var b=function(se){return se.classList&&se.classList.contains("flatpickr-day")&&!se.classList.contains("flatpickr-disabled")&&!se.classList.contains("notAllowed")},M=Pc(Ht(f),b);if(M!==void 0){var x=M,j=e.latestSelectedDateObj=new Date(x.dateObj.getTime()),q=(j.getMonth()<e.currentMonth||j.getMonth()>e.currentMonth+e.config.showMonths-1)&&e.config.mode!=="range";if(e.selectedDateElem=x,e.config.mode==="single")e.selectedDates=[j];else if(e.config.mode==="multiple"){var pe=La(j);pe?e.selectedDates.splice(parseInt(pe),1):e.selectedDates.push(j)}else e.config.mode==="range"&&(e.selectedDates.length===2&&e.clear(!1,!1),e.latestSelectedDateObj=j,e.selectedDates.push(j),Bt(j,e.selectedDates[0],!0)!==0&&e.selectedDates.sort(function(se,Te){return se.getTime()-Te.getTime()}));if(p(),q){var X=e.currentYear!==j.getFullYear();e.currentYear=j.getFullYear(),e.currentMonth=j.getMonth(),X&&(Le("onYearChange"),ne()),Le("onMonthChange")}if(fo(),H(),yn(),!q&&e.config.mode!=="range"&&e.config.showMonths===1?Se(x):e.selectedDateElem!==void 0&&e.hourElement===void 0&&e.selectedDateElem&&e.selectedDateElem.focus(),e.hourElement!==void 0&&e.hourElement!==void 0&&e.hourElement.focus(),e.config.closeOnSelect){var ve=e.config.mode==="single"&&!e.config.enableTime,J=e.config.mode==="range"&&e.selectedDates.length===2&&!e.config.enableTime;(ve||J)&&xa()}O()}}var po={locale:[er,D],showMonths:[L,s,v],minDate:[K],maxDate:[K],positionElement:[Hc],clickOpens:[function(){e.config.clickOpens===!0?(I(e._input,"focus",e.open),I(e._input,"click",e.open)):(e._input.removeEventListener("focus",e.open),e._input.removeEventListener("click",e.open))}]};function Nd(f,b){if(f!==null&&typeof f=="object"){Object.assign(e.config,f);for(var M in f)po[M]!==void 0&&po[M].forEach(function(x){return x()})}else e.config[f]=b,po[f]!==void 0?po[f].forEach(function(x){return x()}):va.indexOf(f)>-1&&(e.config[f]=Da(b));e.redraw(),yn(!0)}function Nc(f,b){var M=[];if(f instanceof Array)M=f.map(function(x){return e.parseDate(x,b)});else if(f instanceof Date||typeof f=="number")M=[e.parseDate(f,b)];else if(typeof f=="string")switch(e.config.mode){case"single":case"time":M=[e.parseDate(f,b)];break;case"multiple":M=f.split(e.config.conjunction).map(function(x){return e.parseDate(x,b)});break;case"range":M=f.split(e.l10n.rangeSeparator).map(function(x){return e.parseDate(x,b)});break;default:break}else e.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(f)));e.selectedDates=e.config.allowInvalidPreload?M:M.filter(function(x){return x instanceof Date&&z(x,!1)}),e.config.mode==="range"&&e.selectedDates.sort(function(x,j){return x.getTime()-j.getTime()})}function Od(f,b,M){if(b===void 0&&(b=!1),M===void 0&&(M=e.config.dateFormat),f!==0&&!f||f instanceof Array&&f.length===0)return e.clear(b);Nc(f,M),e.latestSelectedDateObj=e.selectedDates[e.selectedDates.length-1],e.redraw(),K(void 0,b),y(),e.selectedDates.length===0&&e.clear(!1),yn(b),b&&Le("onChange")}function Oc(f){return f.slice().map(function(b){return typeof b=="string"||typeof b=="number"||b instanceof Date?e.parseDate(b,void 0,!0):b&&typeof b=="object"&&b.from&&b.to?{from:e.parseDate(b.from,void 0),to:e.parseDate(b.to,void 0)}:b}).filter(function(b){return b})}function Hd(){e.selectedDates=[],e.now=e.parseDate(e.config.now)||new Date;var f=e.config.defaultDate||((e.input.nodeName==="INPUT"||e.input.nodeName==="TEXTAREA")&&e.input.placeholder&&e.input.value===e.input.placeholder?null:e.input.value);f&&Nc(f,e.config.dateFormat),e._initialDate=e.selectedDates.length>0?e.selectedDates[0]:e.config.minDate&&e.config.minDate.getTime()>e.now.getTime()?e.config.minDate:e.config.maxDate&&e.config.maxDate.getTime()<e.now.getTime()?e.config.maxDate:e.now,e.currentYear=e._initialDate.getFullYear(),e.currentMonth=e._initialDate.getMonth(),e.selectedDates.length>0&&(e.latestSelectedDateObj=e.selectedDates[0]),e.config.minTime!==void 0&&(e.config.minTime=e.parseDate(e.config.minTime,"H:i")),e.config.maxTime!==void 0&&(e.config.maxTime=e.parseDate(e.config.maxTime,"H:i")),e.minDateHasTime=!!e.config.minDate&&(e.config.minDate.getHours()>0||e.config.minDate.getMinutes()>0||e.config.minDate.getSeconds()>0),e.maxDateHasTime=!!e.config.maxDate&&(e.config.maxDate.getHours()>0||e.config.maxDate.getMinutes()>0||e.config.maxDate.getSeconds()>0)}function Bd(){if(e.input=Wt(),!e.input){e.config.errorHandler(new Error("Invalid input element specified"));return}e.input._type=e.input.type,e.input.type="text",e.input.classList.add("flatpickr-input"),e._input=e.input,e.config.altInput&&(e.altInput=Ee(e.input.nodeName,e.config.altInputClass),e._input=e.altInput,e.altInput.placeholder=e.input.placeholder,e.altInput.disabled=e.input.disabled,e.altInput.required=e.input.required,e.altInput.tabIndex=e.input.tabIndex,e.altInput.type="text",e.input.setAttribute("type","hidden"),!e.config.static&&e.input.parentNode&&e.input.parentNode.insertBefore(e.altInput,e.input.nextSibling)),e.config.allowInput||e._input.setAttribute("readonly","readonly"),Hc()}function Hc(){e._positionElement=e.config.positionElement||e._input}function Yd(){var f=e.config.enableTime?e.config.noCalendar?"time":"datetime-local":"date";e.mobileInput=Ee("input",e.input.className+" flatpickr-mobile"),e.mobileInput.tabIndex=1,e.mobileInput.type=f,e.mobileInput.disabled=e.input.disabled,e.mobileInput.required=e.input.required,e.mobileInput.placeholder=e.input.placeholder,e.mobileFormatStr=f==="datetime-local"?"Y-m-d\\TH:i:S":f==="date"?"Y-m-d":"H:i:S",e.selectedDates.length>0&&(e.mobileInput.defaultValue=e.mobileInput.value=e.formatDate(e.selectedDates[0],e.mobileFormatStr)),e.config.minDate&&(e.mobileInput.min=e.formatDate(e.config.minDate,"Y-m-d")),e.config.maxDate&&(e.mobileInput.max=e.formatDate(e.config.maxDate,"Y-m-d")),e.input.getAttribute("step")&&(e.mobileInput.step=String(e.input.getAttribute("step"))),e.input.type="hidden",e.altInput!==void 0&&(e.altInput.type="hidden");try{e.input.parentNode&&e.input.parentNode.insertBefore(e.mobileInput,e.input.nextSibling)}catch{}I(e.mobileInput,"change",function(b){e.setDate(Ht(b).value,!1,e.mobileFormatStr),Le("onChange"),Le("onClose")})}function Fd(f){if(e.isOpen===!0)return e.close();e.open(f)}function Le(f,b){if(e.config!==void 0){var M=e.config[f];if(M!==void 0&&M.length>0)for(var x=0;M[x]&&x<M.length;x++)M[x](e.selectedDates,e.input.value,e,b);f==="onChange"&&(e.input.dispatchEvent(Aa("change")),e.input.dispatchEvent(Aa("input")))}}function Aa(f){var b=document.createEvent("Event");return b.initEvent(f,!0,!0),b}function La(f){for(var b=0;b<e.selectedDates.length;b++){var M=e.selectedDates[b];if(M instanceof Date&&Bt(M,f)===0)return""+b}return!1}function $d(f){return e.config.mode!=="range"||e.selectedDates.length<2?!1:Bt(f,e.selectedDates[0])>=0&&Bt(f,e.selectedDates[1])<=0}function fo(){e.config.noCalendar||e.isMobile||!e.monthNav||(e.yearElements.forEach(function(f,b){var M=new Date(e.currentYear,e.currentMonth,1);M.setMonth(e.currentMonth+b),e.config.showMonths>1||e.config.monthSelectorType==="static"?e.monthElements[b].textContent=uo(M.getMonth(),e.config.shorthandCurrentMonth,e.l10n)+" ":e.monthsDropdownContainer.value=M.getMonth().toString(),f.value=M.getFullYear().toString()}),e._hidePrevMonthArrow=e.config.minDate!==void 0&&(e.currentYear===e.config.minDate.getFullYear()?e.currentMonth<=e.config.minDate.getMonth():e.currentYear<e.config.minDate.getFullYear()),e._hideNextMonthArrow=e.config.maxDate!==void 0&&(e.currentYear===e.config.maxDate.getFullYear()?e.currentMonth+1>e.config.maxDate.getMonth():e.currentYear>e.config.maxDate.getFullYear()))}function Na(f){var b=f||(e.config.altInput?e.config.altFormat:e.config.dateFormat);return e.selectedDates.map(function(M){return e.formatDate(M,b)}).filter(function(M,x,j){return e.config.mode!=="range"||e.config.enableTime||j.indexOf(M)===x}).join(e.config.mode!=="range"?e.config.conjunction:e.l10n.rangeSeparator)}function yn(f){f===void 0&&(f=!0),e.mobileInput!==void 0&&e.mobileFormatStr&&(e.mobileInput.value=e.latestSelectedDateObj!==void 0?e.formatDate(e.latestSelectedDateObj,e.mobileFormatStr):""),e.input.value=Na(e.config.dateFormat),e.altInput!==void 0&&(e.altInput.value=Na(e.config.altFormat)),f!==!1&&Le("onValueUpdate")}function jd(f){var b=Ht(f),M=e.prevMonthNav.contains(b),x=e.nextMonthNav.contains(b);M||x?_(M?-1:1):e.yearElements.indexOf(b)>=0?b.select():b.classList.contains("arrowUp")?e.changeYear(e.currentYear+1):b.classList.contains("arrowDown")&&e.changeYear(e.currentYear-1)}function Ud(f){f.preventDefault();var b=f.type==="keydown",M=Ht(f),x=M;e.amPM!==void 0&&M===e.amPM&&(e.amPM.textContent=e.l10n.amPM[Ot(e.amPM.textContent===e.l10n.amPM[0])]);var j=parseFloat(x.getAttribute("min")),q=parseFloat(x.getAttribute("max")),pe=parseFloat(x.getAttribute("step")),X=parseInt(x.value,10),ve=f.delta||(b?f.which===38?1:-1:0),J=X+pe*ve;if(typeof x.value<"u"&&x.value.length===2){var se=x===e.hourElement,Te=x===e.minuteElement;J<j?(J=q+J+Ot(!se)+(Ot(se)&&Ot(!e.amPM)),Te&&ie(void 0,-1,e.hourElement)):J>q&&(J=x===e.hourElement?J-q-Ot(!e.amPM):j,Te&&ie(void 0,1,e.hourElement)),e.amPM&&se&&(pe===1?J+X===23:Math.abs(J-X)>pe)&&(e.amPM.textContent=e.l10n.amPM[Ot(e.amPM.textContent===e.l10n.amPM[0])]),x.value=at(J)}}return i(),e}function Zr(n,t){for(var e=Array.prototype.slice.call(n).filter(function(a){return a instanceof HTMLElement}),r=[],i=0;i<e.length;i++){var o=e[i];try{if(o.getAttribute("data-fp-omit")!==null)continue;o._flatpickr!==void 0&&(o._flatpickr.destroy(),o._flatpickr=void 0),o._flatpickr=Om(o,t||{}),r.push(o._flatpickr)}catch(a){console.error(a)}}return r.length===1?r[0]:r}typeof HTMLElement<"u"&&typeof HTMLCollection<"u"&&typeof NodeList<"u"&&(HTMLCollection.prototype.flatpickr=NodeList.prototype.flatpickr=function(n){return Zr(this,n)},HTMLElement.prototype.flatpickr=function(n){return Zr([this],n)});var je=function(n,t){return typeof n=="string"?Zr(window.document.querySelectorAll(n),t):n instanceof Node?Zr([n],t):Zr(n,t)};je.defaultConfig={};je.l10ns={en:ct({},wa),default:ct({},wa)};je.localize=function(n){je.l10ns.default=ct(ct({},je.l10ns.default),n)};je.setDefaults=function(n){je.defaultConfig=ct(ct({},je.defaultConfig),n)};je.parseDate=Ea({});je.formatDate=Rc({});je.compareDates=Bt;typeof jQuery<"u"&&typeof jQuery.fn<"u"&&(jQuery.fn.flatpickr=function(n){return Zr(this,n)});Date.prototype.fp_incr=function(n){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+(typeof n=="string"?parseInt(n,10):n))};typeof window<"u"&&(window.flatpickr=je);var kd=je;var Ca=class{constructor(t,e){this.dateInputEl=t;R(this,"minDate");R(this,"maxDate");R(this,"defaultReservationDays");R(this,"hasPrices",!1);R(this,"prices",{});R(this,"availability",{});R(this,"disabledDates",[]);R(this,"selectedStartDate");R(this,"selectedEndDate");R(this,"config");R(this,"instance");R(this,"destroyInstance");R(this,"currentDate");R(this,"handleResize",()=>{let t=this.isMobileDevice();(t&&this.config.grid!==1||!t&&this.config.grid!==2)&&(this.config.grid=t?1:2,this.config.calendars=t?1:2,this.destroyInstance&&this.destroyInstance(),this.initialize())});this.isMobileDevice()&&(e.grid=1,e.calendars=1),this.dateInputEl=t,this.defaultReservationDays=e.defaultReservationDays??3,this.config={type:e.type,showPrices:e.showPrices??!1,defaultReservationDays:this.defaultReservationDays,grid:e.grid??2,calendars:e.calendars??2,darkMode:e.darkMode??!0,tooltip:e.tooltip??!0,repick:e.repick??!1,minDays:e.minDays??1,defaultStartDate:e.defaultStartDate??W.getCurrentDate(),defaultEndDate:e.defaultEndDate??W.getCurrentDate()},this.currentDate=W.getCurrentDate(),this.selectedStartDate=this.config.defaultStartDate,this.selectedEndDate=this.config.defaultEndDate}isMobileDevice(){return window.innerWidth<=768}initialize(){switch(window.addEventListener("resize",this.handleResize),this.config.type){case"easepick":this.initEasepickCalendar();break;case"flatpickr":this.initFlatpickrCalendar();break;default:throw new Error(`Unsupported calendar type: ${this.config.type}`)}}setMinimumDate(t){this.minDate=t}setMaximumDate(t){this.maxDate=t}setStartDate(t){let e=W.toJSDate(t),r=W.toJSDate(this.selectedEndDate);this.selectedStartDate=t,this.instance instanceof ya.Core?this.instance.setStartDate(new me(t.toString())):this.config.type==="flatpickr"&&this.instance.setDate([e,r],!0)}setEndDate(t){let e=W.toJSDate(this.selectedStartDate),r=W.toJSDate(t);this.selectedEndDate=t,this.instance instanceof ya.Core?this.instance.setEndDate(new me(t.toString())):this.config.type==="flatpickr"&&this.instance.setDate([e,r],!0)}setDateRange(t,e){if(this.config.type==="flatpickr"){this.selectedStartDate=t,this.selectedEndDate=e;let r=W.toJSDate(t),i=W.toJSDate(e);this.instance.setDate([r,i],!0);return}this.setStartDate(t),this.setEndDate(e)}getSelectedDates(){return{startDate:this.selectedStartDate,endDate:this.selectedEndDate}}includePrices(t=!0){this.hasPrices=t}setPrices(t){this.prices=t}setAvailability(t){this.availability=t,this.disabledDates=Object.keys(t).filter(e=>!t[e])}initEasepickCalendar(){let t={element:this.dateInputEl,css:["https://cdn.jsdelivr.net/npm/@easepick/bundle@1.2.1/dist/index.css"],zIndex:10,format:rd,grid:this.config.grid,calendars:this.config.calendars,header:"",lang:document.documentElement.lang,RangePlugin:{tooltip:this.config.tooltip,repick:this.config.repick,startDate:new me(this.config.defaultStartDate.toString()),endDate:new me(this.config.defaultEndDate.toString()),tooltipNumber:r=>r-1,locale:{one:"nuit",other:"nuits"}},LockPlugin:{minDate:new me(this.minDate.toString()),minDays:this.config.minDays,selectForward:!0},AmpPlugin:{darkMode:this.config.darkMode},plugins:[ga,fa,pa],setup:r=>{r.on("view",i=>{let{view:o,date:a,target:s}=i.detail,l=a?a.format("YYYY-MM-DD"):null;if(o==="CalendarDay"&&l&&this.prices[l]){let u=this.prices[l],h=s.querySelector(`.${sa}`)||document.createElement("span");h.className=sa,h.textContent=`${u.toLocaleString(qe,{style:"currency",currency:"EUR",maximumFractionDigits:0})}`,h.style.color="#c64509",h.style.fontWeight="bold",h.style.fontSize="10px",s.append(h)}}),r.on("select",i=>{let{start:o,end:a}=i.detail;this.selectedStartDate=W.fromString(o.format("YYYY-MM-DD")),this.selectedEndDate=W.fromString(a.format("YYYY-MM-DD"));let s={startDate:o.format("YYYY-MM-DD").toString(),endDate:a.format("YYYY-MM-DD").toString()};ot("date:changed",s)})}},e=new ya.create(t);this.instance=e,this.destroyInstance=()=>e.destroy()}initFlatpickrCalendar(){let t=document.createElement("link");t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.css",document.head.appendChild(t);let e={mode:"range",showMonths:this.config.calendars,minDate:this.minDate.toString(),defaultDate:[this.config.defaultStartDate.toString(),this.config.defaultEndDate.toString()],shorthandCurrentMonth:!0,monthSelectorType:"static",inline:!1,dateFormat:id,lang:document.documentElement.lang,zIndex:10,disable:this.disabledDates,onChange:i=>{if(i.length===2){this.selectedStartDate=W.fromJSDate(i[0]),this.selectedEndDate=W.fromJSDate(i[1]);let o={startDate:this.selectedStartDate.toString(),endDate:this.selectedEndDate.toString()};ot("date:changed",o);let a=G("label",this.dateInputEl);if(a){let s=this.formatDate(i[0]),l=this.formatDate(i[1]);a.textContent=`${s} - ${l}`}}else io()},onDayCreate:async(i,o,a,s)=>{let l=s.dateObj,u=W.fromJSDate(l),h=W.formatForAPI(u);if(this.prices[h]){let p=this.prices[h],y=document.createElement("span");y.style.marginTop="2px",y.style.color="#c64509",y.style.fontSize="10px",y.style.fontWeight="bold",y.className=sa,y.textContent=`${p.toLocaleString(qe,{style:"currency",currency:"EUR",maximumFractionDigits:0})}`,s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.justifyContent="center",s.style.lineHeight="1.1",s.appendChild(y)}}},r=kd(this.dateInputEl,e);this.instance=r,this.destroyInstance=()=>r.destroy()}destroy(){window.removeEventListener("resize",this.handleResize),this.destroyInstance&&this.destroyInstance()}formatDate(t){let e=W.fromJSDate(t),r=e.year,i=String(e.month).padStart(2,"0"),o=String(e.day).padStart(2,"0");return qe==="en-US"?`${r}/${i}/${o}`:qe==="fr-FR"||qe==="de-DE"?`${o}/${i}/${r}`:`${r}/${i}/${o}`}};var Sa=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"nightsCountElement");R(this,"startDateElement");R(this,"endDateElement");R(this,"dateElement");R(this,"roomsWrapperElement");R(this,"roomElementTemplate");R(this,"addRoomElement");R(this,"rooms",[]);R(this,"includePrices",od);R(this,"populateCalendarInput",async()=>{if(!this.dateElement){console.error("Date element not found");return}let t=new Ca(this.dateElement,{type:"flatpickr",showPrices:!0,defaultReservationDays:3,grid:2,calendars:2,darkMode:!1,tooltip:!0,repick:!1,minDays:1,defaultStartDate:this.parentComponent.state.startDate||Jn,defaultEndDate:this.parentComponent.state.endDate||yr});if(t.setMinimumDate(Jn),t.setMaximumDate(yr),t.includePrices(this.includePrices),this.includePrices){let e=await Ed([this.parentComponent.apartmentProperties.enterpriseId]);t.setPrices(e)}return t.initialize(),t});Zn("date:changed",e=>{this.parentComponent.state.startDate=W.fromString(e.startDate),this.parentComponent.state.endDate=W.fromString(e.endDate),et.startDate=this.parentComponent.state.startDate.toString(),et.endDate=this.parentComponent.state.endDate.toString()}),this.element=G("details-box"),this.nightsCountElement=G("nights",this.element),this.startDateElement=G("start-date",this.element),this.endDateElement=G("end-date",this.element),this.dateElement=G("date-element",this.element),this.roomsWrapperElement=G("room-box-wrapper",this.element),this.roomElementTemplate=G("room-box",this.element),this.addRoomElement=G("add-room-button",this.element)}init(){console.log("Initialize DetailsSection"),this.updateDOM(),this.populateCalendarInput()}updateDOM(){Tt(()=>{this.startDateElement.textContent=this.parentComponent.state.startDate?W.formatForDisplay(this.parentComponent.state.startDate):"?"}),Tt(()=>{this.endDateElement.textContent=this.parentComponent.state.endDate?W.formatForDisplay(this.parentComponent.state.endDate):"?"}),Tt(()=>{this.nightsCountElement.textContent=`${this.parentComponent.state.nightsCount} ${Fe("night").toLowerCase()}${this.parentComponent.state.nightsCount>1?"s":""}`}),Tt(()=>{let t=document.createDocumentFragment();this.parentComponent.state.rooms.forEach((e,r)=>{let i=on(this.roomElementTemplate,!0),o=G("room",i);o.textContent=`${Fe("apartment")} ${r+1}`;let a=G("categories-wrapper",i),s=G("age-category",a),l=document.createDocumentFragment();e.forEach(u=>{let h=on(s,!0),p=G("category-name",h);p.textContent=u.name;let y=G("input",h);ao(y,u.value.toString()),kt(h,"click",E=>{switch(E.preventDefault(),ld(E.target)){case"decrement":(this.computations().hasOccupants&&u.isAdult?this.computations().totalAdults>1:u.value>0)&&(u.value-=1);break;case"increment":this.computations().hasCapacity&&(u.value+=1);break}},{once:!1}),l.appendChild(h)}),a.innerHTML="",a.appendChild(l),t.appendChild(i)}),this.roomsWrapperElement.innerHTML="",this.roomsWrapperElement.appendChild(t),this.parentComponent.state.rooms.length===this.parentComponent.apartmentProperties.availableRooms&&this.addRoomElement.classList.add("hide")}),kt(this.addRoomElement,"click",t=>{if(t.preventDefault(),this.parentComponent.state.rooms.length<this.parentComponent.apartmentProperties.availableRooms){let e=this.parentComponent.state._ageCategories.map(r=>{let i=r.classification.toLowerCase()==="adult",o=i?Fe("adults"):Fe("children");return{isAdult:i,ageCategoryId:r.id,name:o,value:0}});this.parentComponent.state.rooms.push(e)}})}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t)}computations(){let t=this.parentComponent.state.rooms.some(o=>o.some(a=>a.value>0)),r=this.parentComponent.state.rooms.reduce((o,a)=>o+a.reduce((s,l)=>s+l.value,0),0)<this.parentComponent.apartmentProperties.capacity,i=this.parentComponent.state.rooms.reduce((o,a)=>o+a.filter(s=>s.isAdult).reduce((s,l)=>s+l.value,0),0);return{hasOccupants:t,hasCapacity:r,totalAdults:i}}};var Pd=(n,t)=>{let e={method:"POST",headers:te.headers,body:JSON.stringify(t)};return Ge("/images/getUrls",e,n)};function Id(n){return n.ImageUrls.map(t=>({url:t.Url,imageId:t.ImageId}))}var xc=Ve({}),Rd={width:160,height:160};async function xd(n,t){if(t.every(i=>xc.value[i]))return t.map(i=>xc.value[i]).flat();let e=await Pd(n,{Images:t.map(i=>({ImageId:i,Width:Rd.width,Height:Rd.height,ResizeMode:"Cover"}))}),r=Id(e);return r.forEach(i=>{xc.value[i.imageId]=i}),r}var Ta=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"productsWrapperElement");R(this,"productTemplateElement");R(this,"showMoreButtonElement");this.element=G("options-box"),this.productsWrapperElement=G("options-list",this.element),this.productTemplateElement=G("option-wrapper",this.element),this.showMoreButtonElement=G("more-button",this.element)}init(){try{if(!this.parentComponent.reservableService)throw new Error("Reservable service is not initialized");this.updateDOM()}catch(t){console.error("Error initializing OptionsSection:",t)}}refresh(){try{}catch(t){console.error("Error refreshing OptionsSection:",t)}}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t)}updateDOM(){let t=document.createDocumentFragment();this.parentComponent.state.products.sort((r,i)=>{if(r.ordering!==i.ordering)return(r.ordering??0)-(i.ordering??0);let o=r.name,a=i.name;return o<a?-1:o>a?1:(r.ordering===i.ordering,0)}).forEach((r,i)=>{let o=on(this.productTemplateElement,!0);o.removeAttribute("id");let a=G("name",o);a.textContent=r.name||"";let s=G("price",o);s.textContent=r.price.toLocaleString(qe,{style:"currency",currency:"EUR"});let l=G("label",o);l.textContent=Fe(`chargingMode:${r.chargingMode}`),xd(this.parentComponent.apartmentProperties.enterpriseId,r.imageIds).then(h=>{let p=G("image",o);p.src=h[0].url});let u=G("checkbox",o);kt(u,"change",()=>{let h=oo(u);r.selected=h==="true",this.parentComponent.state.products=[...this.parentComponent.state.products]}),o.classList.toggle("hide",i>3),t.appendChild(o)}),Mc(this.productsWrapperElement),this.productsWrapperElement.appendChild(t),kt(this.showMoreButtonElement,"click",()=>{let r=this.showMoreProducts(3);this.showMoreButtonElement.classList.toggle("hide",!r)})}showMoreProducts(t=4){let e=this.productsWrapperElement.querySelectorAll(`${cd(this.productTemplateElement)}.hide`);return e.forEach((r,i)=>{i<t&&r.classList.toggle("hide",!1)}),e.length>t}};var Ad=(n,t)=>{let e=`${te.bookingEngine_url}/reservationGroups/create`,r={method:"POST",headers:te.headers,body:JSON.stringify(t)};return fetch(e,r).then(o=>o.json())};var ka=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"modalContent");R(this,"modalBg");R(this,"openModalBtn");R(this,"closeModalBtn");R(this,"fNameInput");R(this,"lNameInput");R(this,"emailInput");R(this,"phoneInput");R(this,"countryInput");R(this,"notesInput");R(this,"submitPaymentBtn");R(this,"customer",null);this.element=G("payment-modal"),this.modalContent=G("modal-content",this.element),this.modalBg=G("modal-bg",this.element),this.openModalBtn=G("open-modal"),this.closeModalBtn=G("close-modal"),this.fNameInput=G("fname-input",this.element),this.lNameInput=G("lname-input",this.element),this.emailInput=G("email-input",this.element),this.phoneInput=G("phone-input",this.element),this.countryInput=G("country-input",this.element),this.notesInput=G("notes-input",this.element),this.submitPaymentBtn=G("submit-payment",this.element)}init(){console.log("Initialize PaymentModal"),this.updateDOM()}updateDOM(){kt(this.openModalBtn,"click",()=>{this.toggleVisibility(!0),this.element.scrollIntoView({behavior:"smooth"})}),kt(this.submitPaymentBtn,"click",t=>{t.preventDefault(),this.handleSubmit()})}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t),t?(this.element.style.display="flex",this.element.style.opacity="1",this.modalContent.style.opacity="1",this.element.querySelectorAll("div").forEach(e=>{e.style.opacity="1"})):(this.element.style.opacity="0",this.element.style.display="none")}validateInputs(){if(!this.fNameInput.value||!this.lNameInput.value||!this.emailInput.value||!this.phoneInput.value||!this.countryInput.value)throw new Error("First name, last name, email, phone, and nationality are required.");if(!this.emailInput.checkValidity())throw new Error("Invalid email format.");if(!this.phoneInput.checkValidity())throw new Error("Invalid phone number format. Only numbers and spaces are allowed.");if(!this.countryInput.value)throw new Error("Country is required.")}async handleSubmit(){if(!this.parentComponent.state.startDate||!this.parentComponent.state.endDate)throw new Error("Start date and end date are required to submit the payment form.");try{this.validateInputs()}catch(s){console.error("Validation error:",s),alert(s instanceof Error?s.message:"An unexpected error occurred.");return}let{startDate:t,endDate:e}=this.parentComponent.state;this.customer={Email:this.emailInput.value,FirstName:this.fNameInput.value,LastName:this.lNameInput.value,Telephone:this.phoneInput.value,NationalityCode:this.countryInput.value,SendMarketingEmails:!1};let r={Client:te.bookingEngineClient,HotelId:this.parentComponent.apartmentProperties.enterpriseId,Customer:this.customer,Reservations:this.parentComponent.state.rooms.map(s=>({RoomCategoryId:this.parentComponent.apartmentProperties.categoryId,StartUtc:W.formatForAPI(t.toString()),EndUtc:W.formatForAPI(e.toString()),VoucherCode:this.parentComponent.state.couponCode||void 0,RateId:this.parentComponent.state.selectedRateId||"",AdultCount:s.filter(l=>l.isAdult).reduce((l,u)=>l+u.value,0),ChildCount:s.filter(l=>!l.isAdult).reduce((l,u)=>l+u.value,0),ProductIds:this.parentComponent.state.selectedProducts.map(l=>l.id),Notes:this.notesInput.value||""}))};console.log("Payload for reservation group:",r);let i=JSON.stringify(r,null,2);console.log("JSON Payload:",i);let o=this.submitPaymentBtn.textContent?.trim()??Fe("proceedToPayment");this.submitPaymentBtn.textContent=Fe("completePayment"),this.submitPaymentBtn.classList.add("is-disabled");let a=await Ad(this.parentComponent.apartmentProperties.enterpriseId,r);if(console.log("Reservation Response:",a),"PaymentRequestId"in a&&a.PaymentRequestId){let s=new URL(window.location.href);s.pathname="/reservation-confirmee";let l=`https://app.mews.com/navigator/payment-requests/detail/${a.PaymentRequestId}?returnUrl=${btoa(s.toString())}`;console.log("Payment URL:",l),window.open(l,"_blank")}else{this.submitPaymentBtn.classList.remove("is-disabled"),this.submitPaymentBtn.textContent=o;let s="Message"in a&&a.Message?a.Message:"Payment request could not be created. Please try again later or contact Support.";console.error("Payment Request ID is missing in the response:",a),alert(s);return}}};var Ld=(n,t)=>{let e=`${te.bookingEngine_url}/vouchers/validate`,r={method:"POST",headers:te.headers,body:JSON.stringify(t)};return An(e,r,n)};var Pa=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"summaryItemElement");R(this,"itemNameElement");R(this,"itemRowTemplateElement");R(this,"totalPriceElement");R(this,"taxElement");R(this,"submitElement");R(this,"couponInputElement");R(this,"couponApplyElement");R(this,"statusTextElement");Zn("loading:start",e=>Wr(!0,e)),Zn("loading:end",e=>Wr(!1,e)),this.element=G("summary-box"),this.summaryItemElement=G("summary-item",this.element),this.itemNameElement=G("name",this.summaryItemElement),this.itemRowTemplateElement=G("row",this.summaryItemElement),this.totalPriceElement=G("total",this.element),this.taxElement=G("tax",this.element),this.submitElement=G("submit",this.element),this.couponInputElement=G("coupon-input",this.element),this.couponApplyElement=G("apply-coupon",this.element),this.statusTextElement=G("status-text",this.element)}init(){this.updateDOM(),ot("loading:end",this.element)}refresh(){ot("loading:end",this.element)}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t),Array.from(this.element.children).forEach(e=>{e instanceof HTMLDivElement&&e.classList.toggle("hide",!t)})}updateDOM(){kt(this.couponInputElement,"input",()=>{this.parentComponent.state.couponCode=oo(this.couponInputElement)}),kt(this.couponApplyElement,"click",async t=>{t.preventDefault(),ot("loading:start",this.element),Ld(this.parentComponent.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,HotelId:this.parentComponent.apartmentProperties.enterpriseId,VoucherCode:this.parentComponent.state.couponCode}).then(async e=>{let{IsValid:r}=e;if(this.statusTextElement.textContent=r?Fe("couponValid"):Fe("couponInvalid"),this.statusTextElement.style.color=r?"#1bcb00":"#f44900",r)try{ot("loading:start",this.element),await this.parentComponent.fetchReservationPricing(),console.log("Reservation pricing updated with voucher code")}catch(i){console.error("Error updating reservation pricing with voucher code:",i),this.statusTextElement.textContent=Fe("couponError"),this.statusTextElement.style.color="#f44900"}}).catch(e=>{console.error("Error validating coupon:",e),this.statusTextElement.textContent=Fe("couponError"),this.statusTextElement.style.color="#f44900"}).finally(()=>{ot("loading:end",this.element),this.statusTextElement.classList.toggle("hide",!1)})}),Tt(()=>{this.couponInputElement.value!==this.parentComponent.state.couponCode&&ao(this.couponInputElement,this.parentComponent.state.couponCode);let t=document.createDocumentFragment(),e=this.parentComponent.state.rates.find(s=>s.id===this.parentComponent.state.selectedRateId)?.price;this.itemNameElement.textContent=`${e?.AverageAmountPerTimeUnit?.GrossValue?.toLocaleString(qe,{style:"currency",currency:"EUR"})}/ ${Fe("night")}`;let r=e?.TotalAmount?.Breakdown?.Items?.reduce((s,l)=>s+(l.TaxValue||0),0)||0;this.taxElement.textContent=r>0?r.toLocaleString(qe,{style:"currency",currency:"EUR"}):"--",t.appendChild(this.itemNameElement);let i=on(this.itemRowTemplateElement,!0),o=G("label",i),a=G("price",i);o.textContent=`${this.parentComponent.state.nightsCount} ${Fe("night").toLowerCase()}${this.parentComponent.state.nightsCount>1?"s":""}`,a.textContent=e?.TotalAmount?.GrossValue?.toLocaleString?.(qe,{style:"currency",currency:"EUR"})??null,t.appendChild(i),this.parentComponent.state.selectedProducts.forEach(s=>{let l=on(this.itemRowTemplateElement,!0),u=G("label",l);u.textContent=s.name||"";let h=G("price",l),p=()=>{switch(s.chargingMode){case"Once":return s.price||0;case"PerTimeUnit":return s.price*this.parentComponent.state.nightsCount||0;case"PerPersonPerTimeUnit":return s.price*this.parentComponent.state.nightsCount*this.parentComponent.state.adultsCount||0;default:return console.warn(`Unknown charging mode: ${s.chargingMode}`),s.price}};h.textContent=p().toLocaleString(qe,{style:"currency",currency:"EUR"}),t.appendChild(l)}),this.summaryItemElement.innerHTML="",this.summaryItemElement.appendChild(t),this.totalPriceElement.textContent=this.parentComponent.state.totalPrice.toLocaleString(qe,{style:"currency",currency:"EUR"})})}};var Ia=class{constructor(t){this.parentComponent=t;R(this,"state",null);R(this,"element");R(this,"tariffsWrapperElement");R(this,"tariffTemplateElement");this.element=G("offer-box"),this.tariffsWrapperElement=G("offers-list",this.element),this.tariffTemplateElement=G("offer-wrapper",this.element)}init(){this.updateDOM()}refresh(){}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t)}updateDOM(){Tt(()=>{let t=document.createDocumentFragment();this.parentComponent.state.rates.sort((r,i)=>{let o=r.price?.AverageAmountPerTimeUnit?.GrossValue||0,a=i.price?.AverageAmountPerTimeUnit?.GrossValue||0;return o-a}).forEach(r=>{let i=on(this.tariffTemplateElement,!0);i.removeAttribute("id");let o=G("name",i);o.textContent=r.name;let a=G("description",i);a.textContent=r.description;let s=G("price",i),l=r.price?.AverageAmountPerTimeUnit?.GrossValue||0;s.textContent=l.toLocaleString(qe,{style:"currency",currency:"EUR"});let u=this.parentComponent.state._rates.find(T=>T.id===r.id),h=G("label",i),p=G("discount-badge",i),y=G("discount-label",p);if(u)if(h.textContent=u.shortName,u.pricing?.DependentRatePricing){let T=u.pricing?.DependentRatePricing.RelativeAdjustment*100;T===0?p.classList.add("hide"):y.textContent=`${T>0?"+":""}${T}%`}else p.classList.add("hide");else h.classList.add("hide"),p.classList.add("hide");let E=G("radio-input",i);E.value=r.id,r.id===this.parentComponent.state.selectedRateId&&E.previousElementSibling.classList.add("w--redirected-checked"),kt(E,"change",()=>{E.checked&&(this.parentComponent.state.selectedRateId=r.id)}),t.appendChild(i)}),this.tariffsWrapperElement.innerHTML="",this.tariffsWrapperElement.appendChild(t)})}};var Ra=class{constructor(t){R(this,"apartmentProperties");R(this,"enterpriseInstance");R(this,"reservableService");R(this,"detailsSection");R(this,"optionsSection");R(this,"tariffsSection");R(this,"summarySection");R(this,"paymentModal");R(this,"state",Kn({startDate:null,endDate:null,rooms:[],couponCode:"",_hotel:null,_availabilities:null,_rates:[],_servicePricing:null,_reservationPricing:null,_ageCategories:[],products:[],nightsCount:gn(()=>!this.state.startDate||!this.state.endDate?0:this.state.startDate.until(this.state.endDate).days),selectedProducts:gn(()=>this.state.products.filter(t=>t.selected)),rates:gn(()=>this.state._servicePricing?.Rates?this.state._servicePricing.Rates.map(t=>{let e=this.state._servicePricing?.RateGroups?.find(o=>o.Id===t.RateGroupId),i=this.state._servicePricing?.CategoryPrices.find(o=>o.CategoryId===this.apartmentProperties.categoryId)?.OccupancyPrices.find(o=>{let a=this.state.rooms.flat(),s=Object.groupBy(a,u=>u.ageCategoryId),l={};return Object.entries(s).map(([u,h])=>{let p=h?.reduce((y,E)=>y+E.value,0);return l[u]=p||0,{ageCategoryId:u,totalPersons:p}}),o.Occupancies.every(u=>{let h=l[u.AgeCategoryId];return h===void 0||u.PersonCount===h})})?.RateGroupPrices?.find(o=>o.MinRateId===t.Id);return{id:t.Id,name:We(t.Name),description:We(t.Description),isPrivate:t.IsPrivate,currencyCode:t.CurrencyCode,ordering:t.Ordering,groupId:e?.Id??"",groupOrdering:e?.Ordering||0,price:i?.MinPrice,selected:!1}}).filter(t=>t.price!==void 0&&t.price.TotalAmount?.GrossValue!==void 0&&t.price.TotalAmount?.GrossValue>0):[]),selectedRateId:null,be_pricing:null,totalStayPrice:gn(()=>{let t=this.state.rates.find(e=>e.id===this.state.selectedRateId)?.price;return t&&t.TotalAmount?.GrossValue||0}),adultsCount:gn(()=>this.state.rooms.reduce((t,e)=>t+e.reduce((r,i)=>r+(i.isAdult?i.value:0),0),0)),childrenCount:gn(()=>this.state.rooms.reduce((t,e)=>t+e.reduce((r,i)=>r+(i.isAdult?0:i.value),0),0)),isAvailable:gn(()=>{if(!this.state._availabilities)return!1;let{categoryId:t}=this.apartmentProperties,e=this.state._availabilities.CategoryAvailabilities.find(r=>r.CategoryId===t);return e?e.Availabilities.slice(0,-1).every(r=>r>0):!1}),productsTotalPrice:gn(()=>this.state.selectedProducts.reduce((e,r)=>{let i=0;switch(r.chargingMode){case"Once":i=r.price||0;break;case"PerTimeUnit":i=r.price*this.state.nightsCount||0;break;case"PerPersonPerTimeUnit":i=r.price*this.state.nightsCount*this.state.adultsCount||0;break;default:console.warn(`Unknown charging mode: ${r.chargingMode}`),i=r.price}return e+i},0)),totalPrice:gn(()=>this.state.totalStayPrice+this.state.productsTotalPrice)}));Zn("loading:start",e=>Wr(!0,e)),Zn("loading:end",e=>Wr(!1,e)),this.apartmentProperties=t}init(){ot("loading:start",document.body);let t=et.startDate?W.safeParsePlainDate(et.startDate):Jn,e=et.endDate?W.safeParsePlainDate(et.endDate):yr;(t||e)&&this.updateDateRange(t,e),this.fetchAPIData().then(()=>{this.parseAPIData().then(()=>{let r=this.state._rates.find(i=>i.isDefault||i.isBaseRate);console.log("#=> Default Rate:",r),this.state.selectedRateId=r?.id||this.state.rates.find(i=>i.ordering===0&&i.groupOrdering===0)?.id||this.state.rates[0].id,this.detailsSection=new Sa(this),this.detailsSection.init(),this.optionsSection=new Ta(this),this.optionsSection.toggleVisibility(!0),this.optionsSection.init(),this.tariffsSection=new Ia(this),this.tariffsSection.toggleVisibility(!0),this.tariffsSection.init(),this.summarySection=new Pa(this),this.summarySection.toggleVisibility(!0),this.summarySection.init(),this.paymentModal=new ka(this),this.paymentModal.toggleVisibility(!1),this.paymentModal.init(),this.initPricingButler(),this.initAvailabilityPricingUpdater(),ot("loading:end",document.body)}).catch(r=>{console.error("Error initializing reservation component",r),alert("An error occurred. Please try again later.")})}),console.log("#=> State:",this.state)}initPricingButler(){Tt(()=>{if(this.state.rooms.length===0){console.error("\u{1F9EE} No rooms set, skipping pricing update.");return}let{startDate:t,endDate:e}=this.state;if(!t||!e){console.warn("Start date or end date is not set, skipping pricing update.");return}if(W.isBefore(t,e)){console.warn("Start date is after or equal to end date, skipping pricing update.");return}(0,Ac.default)(async()=>{let r=W.formatForAPI(t),i=W.formatForAPI(e),o={Client:te.bookingEngineClient,HotelId:this.apartmentProperties.enterpriseId,StartUtc:r,EndUtc:i,RoomCategoryId:this.apartmentProperties.categoryId,ProductIds:this.state.selectedProducts.map(s=>s.id),VoucherCode:this.state.couponCode||void 0,Occupancies:this.state.rooms.map(s=>({OccupancyData:s.map(l=>({AgeCategoryId:l.ageCategoryId,PersonCount:l.value}))}))},a=await ra(this.apartmentProperties.enterpriseId,o);this.state.be_pricing=a},500)()})}initAvailabilityPricingUpdater(){let t=(0,Ac.default)(async(e,r)=>{try{let i=W.formatForAPI(e.toString()),o=W.formatForAPI(r.toString());if(i>o){console.error("StartUtc is after EndUtc, cannot proceed with API requests.");return}let a=await uc(this.apartmentProperties.enterpriseId,{EnterpriseId:this.apartmentProperties.enterpriseId,CategoryIds:[this.apartmentProperties.categoryId],StartUtc:i,EndUtc:o,ServiceId:this.reservableService?.getService()?.id||"",Client:te.bookingEngineClient,LanguageCode:"fr-FR"});this.state._availabilities=a;let s=await ia(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,EnterpriseId:this.apartmentProperties.enterpriseId,StartUtc:i,EndUtc:o,ServiceId:this.reservableService?.getService()?.id||"",CategoryIds:[this.apartmentProperties.categoryId],CurrencyCode:"EUR"});this.state._servicePricing=s,ot("loading:end",document.body)}catch(i){console.error("Error updating availability and pricing data:",i)}},500);Tt(()=>{ot("loading:start",document.body);let{startDate:e}=this.state,{endDate:r}=this.state;if(!e||!r){console.warn("Start date or end date is not set, skipping availability and pricing updates.");return}if(W.isBefore(e,r)){console.warn("Start date is after or equal to end date, skipping API requests.");return}t(e,r)}),Tt(()=>{ot("loading:start",document.body);let{_availabilities:e,_servicePricing:r,isAvailable:i}=this.state,o=G("banner-box");if(o&&o.classList.toggle("hide",i),this.optionsSection&&this.optionsSection.toggleVisibility(i),this.tariffsSection&&this.tariffsSection.toggleVisibility(i),this.summarySection&&this.summarySection.toggleVisibility(i),r&&!this.state.selectedRateId&&this.state.rates.length>0){let a=this.state._rates.find(s=>s.isDefault||s.isBaseRate);this.state.selectedRateId=a?.id||this.state.rates.find(s=>s.ordering===0&&s.groupOrdering===0)?.id||this.state.rates[0].id}e&&r&&this.refreshUIComponents()})}findCurrentCategoryPrice(t,e){return t.find(r=>r.CategoryId===e)}async fetchAPIData(){if(console.log("#=> Fetching API data for reservation component..."),this.enterpriseInstance=new Gr(this.apartmentProperties.enterpriseId),await this.enterpriseInstance.initServices().then(()=>{this.reservableService=this.enterpriseInstance.reservableService}),await this.reservableService?.initAgeCategories(),this.state._ageCategories=this.reservableService?.getAgeCategories()||[],(et.rooms==null||et.rooms<1)&&(et.rooms=1),et.rooms)for(let a=0;a<et.rooms;a++){let s=this.state._ageCategories.map(l=>{let u=l.classification.toLowerCase()==="adult",h=u?Fe("adults"):Fe("children"),p=a===0&&u?et.guests||1:0;return{isAdult:u,ageCategoryId:l.id,name:h,value:p}});this.state.rooms.push(s)}let t=await Fu(this.apartmentProperties.enterpriseId);if(this.state._hotel=t,!this.state.startDate||!this.state.endDate){console.warn("Start date or end date is not set, skipping availability and pricing requests.");return}if(W.isBefore(this.state.startDate,this.state.endDate)){console.warn(`this.state.startDate {${this.state.startDate}} is after or equal to this.state.endDate {${this.state.endDate}}, skipping API requests.`);return}let e=W.formatForAPI(this.state.startDate),r=W.formatForAPI(this.state.endDate),i=await uc(this.apartmentProperties.enterpriseId,{EnterpriseId:this.apartmentProperties.enterpriseId,CategoryIds:[this.apartmentProperties.categoryId],StartUtc:e,EndUtc:r,ServiceId:this.reservableService?.getService()?.id||"",Client:te.bookingEngineClient,LanguageCode:"fr-FR"});this.state._availabilities=i;let o=await ia(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,EnterpriseId:this.apartmentProperties.enterpriseId,StartUtc:e,EndUtc:r,ServiceId:this.reservableService?.getService()?.id||"",CategoryIds:[this.apartmentProperties.categoryId],CurrencyCode:"EUR",voucherCode:this.state.couponCode||void 0});if(this.state._servicePricing=o,this.state.rooms.length===0){console.error("\u{1F9EE} No rooms set, skipping reservation pricing request.");return}try{let a=await ra(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,HotelId:this.apartmentProperties.enterpriseId,StartUtc:e,EndUtc:r,RoomCategoryId:this.apartmentProperties.categoryId,ProductIds:this.state.selectedProducts.map(s=>s.id),VoucherCode:this.state.couponCode||void 0,Occupancies:this.state.rooms.map(s=>({OccupancyData:s.filter(l=>l.value>0).map(l=>({AgeCategoryId:l.ageCategoryId,PersonCount:l.value}))}))});this.state._reservationPricing=a}catch(a){console.error("Error fetching reservation pricing:",a)}if(this.reservableService&&this.reservableService.getService()!=null){let a=this.reservableService.getService()?.id;console.log("loading rates for serviceId:",a),this.state._rates=await aa(this.apartmentProperties.enterpriseId,a),console.log("#=> Rates loaded:",this.state._rates)}else console.warn("No reservable service found, rates will not be loaded.")}async parseAPIData(){this.state.products=this.state._hotel?.Products.map(t=>({id:t.Id,name:We(t.Name),description:We(t.Description),categoryId:t.CategoryId,ordering:t.Ordering,imageIds:[t.ImageId],price:t.Prices.EUR,chargingMode:t.ChargingMode,selected:!1}))||[]}refreshUIComponents(){if(this.state.rates.length>0&&!this.state.selectedRateId){let e=this.state._rates.find(r=>r.isDefault||r.isBaseRate);this.state.selectedRateId=e?.id||this.state.rates.find(r=>r.ordering===0&&r.groupOrdering===0)?.id||this.state.rates[0].id}let t=G("banner-box");t&&t.classList.toggle("hide",this.state.isAvailable),this.optionsSection&&(this.optionsSection.toggleVisibility(this.state.isAvailable),this.optionsSection.refresh()),this.tariffsSection&&(this.tariffsSection.toggleVisibility(this.state.isAvailable),this.tariffsSection.refresh()),this.summarySection&&(this.summarySection.toggleVisibility(this.state.isAvailable),this.summarySection.refresh()),ot("loading:end",document.body)}async fetchReservationPricing(){if(!this.state.startDate||!this.state.endDate){console.warn("Start date or end date is not set, cannot fetch reservation pricing");return}if(W.isBefore(this.state.startDate,this.state.endDate)){console.warn("Start date is after or equal to end date, cannot fetch reservation pricing");return}if(this.state.rooms.length===0){console.error("No rooms set, cannot fetch reservation pricing");return}try{let t=W.formatForAPI(this.state.startDate),e=W.formatForAPI(this.state.endDate),r=await ia(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,EnterpriseId:this.apartmentProperties.enterpriseId,StartUtc:t,EndUtc:e,ServiceId:this.reservableService?.getService()?.id||"",CategoryIds:[this.apartmentProperties.categoryId],CurrencyCode:"EUR",voucherCode:this.state.couponCode||void 0});this.state._servicePricing=r;let i=await ra(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,HotelId:this.apartmentProperties.enterpriseId,StartUtc:t,EndUtc:e,RoomCategoryId:this.apartmentProperties.categoryId,ProductIds:this.state.selectedProducts.map(o=>o.id),VoucherCode:this.state.couponCode||void 0,Occupancies:this.state.rooms.map(o=>({OccupancyData:o.filter(a=>a.value>0).map(a=>({AgeCategoryId:a.ageCategoryId,PersonCount:a.value}))}))});return this.state._reservationPricing=i,this.state.be_pricing=i,this.refreshUIComponents(),this.scrollToTariffsSection(),i}catch(t){throw console.error("Error fetching reservation pricing:",t),t}}updateDateRange(t,e){if(this.state.startDate=t,this.state.endDate=e,et.startDate=t?t.toString():null,et.endDate=e?e.toString():null,t&&e){let r=t.until(e).days;document.querySelectorAll("[data-nights-count]").forEach(s=>{s.textContent=r.toString()}),document.querySelectorAll("[data-start-date]").forEach(s=>{s.textContent=t.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"})}),document.querySelectorAll("[data-end-date]").forEach(s=>{s.textContent=e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"})})}return{startDate:t,endDate:e}}handleDateChange(t,e){return t&&e&&Ie.PlainDate.compare(t,e)>=0?(console.warn("Invalid date range: start date must be before end date"),!1):(this.updateDateRange(t,e),!0)}scrollToTariffsSection(){let t=document.getElementById("tariff-section");t&&setTimeout(()=>{t.scrollIntoView({behavior:"smooth",block:"start"})},300)}};function Bm(){try{let n=window.WebflowCMSData_apartment;console.log("#=> Properties",n),new Ra(n).init()}catch(n){console.error("Error initializing reservation component",n)}}window.Webflow||(window.Webflow=[]);window.Webflow.push(async()=>{Bm()});})();
|
|
7
|
+
`}}function w(){e.calendarContainer.classList.add("hasWeeks");var f=Ee("div","flatpickr-weekwrapper");f.appendChild(Ee("span","flatpickr-weekday",e.l10n.weekAbbreviation));var b=Ee("div","flatpickr-weeks");return f.appendChild(b),{weekWrapper:f,weekNumbers:b}}function _(f,b){b===void 0&&(b=!0);var M=b?f:f-e.currentMonth;M<0&&e._hidePrevMonthArrow===!0||M>0&&e._hideNextMonthArrow===!0||(e.currentMonth+=M,(e.currentMonth<0||e.currentMonth>11)&&(e.currentYear+=e.currentMonth>11?1:-1,e.currentMonth=(e.currentMonth+12)%12,Le("onYearChange"),ne()),H(),Le("onMonthChange"),fo())}function k(f,b){if(f===void 0&&(f=!0),b===void 0&&(b=!0),e.input.value="",e.altInput!==void 0&&(e.altInput.value=""),e.mobileInput!==void 0&&(e.mobileInput.value=""),e.selectedDates=[],e.latestSelectedDateObj=void 0,b===!0&&(e.currentYear=e._initialDate.getFullYear(),e.currentMonth=e._initialDate.getMonth()),e.config.enableTime===!0){var M=Ma(e.config),x=M.hours,j=M.minutes,q=M.seconds;E(x,j,q)}e.redraw(),f&&Le("onChange")}function S(){e.isOpen=!1,e.isMobile||(e.calendarContainer!==void 0&&e.calendarContainer.classList.remove("open"),e._input!==void 0&&e._input.classList.remove("active")),Le("onClose")}function B(){e.config!==void 0&&Le("onDestroy");for(var f=e._handlers.length;f--;)e._handlers[f].remove();if(e._handlers=[],e.mobileInput)e.mobileInput.parentNode&&e.mobileInput.parentNode.removeChild(e.mobileInput),e.mobileInput=void 0;else if(e.calendarContainer&&e.calendarContainer.parentNode)if(e.config.static&&e.calendarContainer.parentNode){var b=e.calendarContainer.parentNode;if(b.lastChild&&b.removeChild(b.lastChild),b.parentNode){for(;b.firstChild;)b.parentNode.insertBefore(b.firstChild,b);b.parentNode.removeChild(b)}}else e.calendarContainer.parentNode.removeChild(e.calendarContainer);e.altInput&&(e.input.type="text",e.altInput.parentNode&&e.altInput.parentNode.removeChild(e.altInput),delete e.altInput),e.input&&(e.input.type=e.input._type,e.input.classList.remove("flatpickr-input"),e.input.removeAttribute("readonly")),["_showTimeInput","latestSelectedDateObj","_hideNextMonthArrow","_hidePrevMonthArrow","__hideNextMonthArrow","__hidePrevMonthArrow","isMobile","isOpen","selectedDateElem","minDateHasTime","maxDateHasTime","days","daysContainer","_input","_positionElement","innerContainer","rContainer","monthNav","todayDateElem","calendarContainer","weekdayContainer","prevMonthNav","nextMonthNav","monthsDropdownContainer","currentMonthElement","currentYearElement","navigationCurrentMonth","selectedDateElem","config"].forEach(function(M){try{delete e[M]}catch{}})}function A(f){return e.calendarContainer.contains(f)}function V(f){if(e.isOpen&&!e.config.inline){var b=Ht(f),M=A(b),x=b===e.input||b===e.altInput||e.element.contains(b)||f.path&&f.path.indexOf&&(~f.path.indexOf(e.input)||~f.path.indexOf(e.altInput)),j=!x&&!M&&!A(f.relatedTarget),q=!e.config.ignoredFocusElements.some(function(pe){return pe.contains(b)});j&&q&&(e.config.allowInput&&e.setDate(e._input.value,!1,e.config.altInput?e.config.altFormat:e.config.dateFormat),e.timeContainer!==void 0&&e.minuteElement!==void 0&&e.hourElement!==void 0&&e.input.value!==""&&e.input.value!==void 0&&l(),e.close(),e.config&&e.config.mode==="range"&&e.selectedDates.length===1&&e.clear(!1))}}function Q(f){if(!(!f||e.config.minDate&&f<e.config.minDate.getFullYear()||e.config.maxDate&&f>e.config.maxDate.getFullYear())){var b=f,M=e.currentYear!==b;e.currentYear=b||e.currentYear,e.config.maxDate&&e.currentYear===e.config.maxDate.getFullYear()?e.currentMonth=Math.min(e.config.maxDate.getMonth(),e.currentMonth):e.config.minDate&&e.currentYear===e.config.minDate.getFullYear()&&(e.currentMonth=Math.max(e.config.minDate.getMonth(),e.currentMonth)),M&&(e.redraw(),Le("onYearChange"),ne())}}function z(f,b){var M;b===void 0&&(b=!0);var x=e.parseDate(f,void 0,b);if(e.config.minDate&&x&&Bt(x,e.config.minDate,b!==void 0?b:!e.minDateHasTime)<0||e.config.maxDate&&x&&Bt(x,e.config.maxDate,b!==void 0?b:!e.maxDateHasTime)>0)return!1;if(!e.config.enable&&e.config.disable.length===0)return!0;if(x===void 0)return!1;for(var j=!!e.config.enable,q=(M=e.config.enable)!==null&&M!==void 0?M:e.config.disable,pe=0,X=void 0;pe<q.length;pe++){if(X=q[pe],typeof X=="function"&&X(x))return j;if(X instanceof Date&&x!==void 0&&X.getTime()===x.getTime())return j;if(typeof X=="string"){var ve=e.parseDate(X,void 0,!0);return ve&&ve.getTime()===x.getTime()?j:!j}else if(typeof X=="object"&&x!==void 0&&X.from&&X.to&&x.getTime()>=X.from.getTime()&&x.getTime()<=X.to.getTime())return j}return!j}function $(f){return e.daysContainer!==void 0?f.className.indexOf("hidden")===-1&&f.className.indexOf("flatpickr-disabled")===-1&&e.daysContainer.contains(f):!1}function re(f){var b=f.target===e._input,M=e._input.value.trimEnd()!==Na();b&&M&&!(f.relatedTarget&&A(f.relatedTarget))&&e.setDate(e._input.value,!0,f.target===e.altInput?e.config.altFormat:e.config.dateFormat)}function ue(f){var b=Ht(f),M=e.config.wrap?n.contains(b):b===e._input,x=e.config.allowInput,j=e.isOpen&&(!x||!M),q=e.config.inline&&M&&!x;if(f.keyCode===13&&M){if(x)return e.setDate(e._input.value,!0,b===e.altInput?e.config.altFormat:e.config.dateFormat),e.close(),b.blur();e.open()}else if(A(b)||j||q){var pe=!!e.timeContainer&&e.timeContainer.contains(b);switch(f.keyCode){case 13:pe?(f.preventDefault(),l(),xa()):Lc(f);break;case 27:f.preventDefault(),xa();break;case 8:case 46:M&&!e.config.allowInput&&(f.preventDefault(),e.clear());break;case 37:case 39:if(!pe&&!M){f.preventDefault();var X=o();if(e.daysContainer!==void 0&&(x===!1||X&&$(X))){var ve=f.keyCode===39?1:-1;f.ctrlKey?(f.stopPropagation(),_(ve),N(Me(1),0)):N(void 0,ve)}}else e.hourElement&&e.hourElement.focus();break;case 38:case 40:f.preventDefault();var J=f.keyCode===40?1:-1;e.daysContainer&&b.$i!==void 0||b===e.input||b===e.altInput?f.ctrlKey?(f.stopPropagation(),Q(e.currentYear-J),N(Me(1),0)):pe||N(void 0,J*7):b===e.currentYearElement?Q(e.currentYear-J):e.config.enableTime&&(!pe&&e.hourElement&&e.hourElement.focus(),l(f),e._debouncedChange());break;case 9:if(pe){var se=[e.hourElement,e.minuteElement,e.secondElement,e.amPM].concat(e.pluginElements).filter(function(Yt){return Yt}),Te=se.indexOf(b);if(Te!==-1){var an=se[Te+(f.shiftKey?-1:1)];f.preventDefault(),(an||e._input).focus()}}else!e.config.noCalendar&&e.daysContainer&&e.daysContainer.contains(b)&&f.shiftKey&&(f.preventDefault(),e._input.focus());break;default:break}}if(e.amPM!==void 0&&b===e.amPM)switch(f.key){case e.l10n.amPM[0].charAt(0):case e.l10n.amPM[0].charAt(0).toLowerCase():e.amPM.textContent=e.l10n.amPM[0],p(),yn();break;case e.l10n.amPM[1].charAt(0):case e.l10n.amPM[1].charAt(0).toLowerCase():e.amPM.textContent=e.l10n.amPM[1],p(),yn();break}(M||A(b))&&Le("onKeyDown",f)}function ye(f,b){if(b===void 0&&(b="flatpickr-day"),!(e.selectedDates.length!==1||f&&(!f.classList.contains(b)||f.classList.contains("flatpickr-disabled")))){for(var M=f?f.dateObj.getTime():e.days.firstElementChild.dateObj.getTime(),x=e.parseDate(e.selectedDates[0],void 0,!0).getTime(),j=Math.min(M,e.selectedDates[0].getTime()),q=Math.max(M,e.selectedDates[0].getTime()),pe=!1,X=0,ve=0,J=j;J<q;J+=Sd.DAY)z(new Date(J),!0)||(pe=pe||J>j&&J<q,J<x&&(!X||J>X)?X=J:J>x&&(!ve||J<ve)&&(ve=J));var se=Array.from(e.rContainer.querySelectorAll("*:nth-child(-n+"+e.config.showMonths+") > ."+b));se.forEach(function(Te){var an=Te.dateObj,Yt=an.getTime(),Xr=X>0&&Yt<X||ve>0&&Yt>ve;if(Xr){Te.classList.add("notAllowed"),["inRange","startRange","endRange"].forEach(function(br){Te.classList.remove(br)});return}else if(pe&&!Xr)return;["startRange","inRange","endRange","notAllowed"].forEach(function(br){Te.classList.remove(br)}),f!==void 0&&(f.classList.add(M<=e.selectedDates[0].getTime()?"startRange":"endRange"),x<M&&Yt===x?Te.classList.add("startRange"):x>M&&Yt===x&&Te.classList.add("endRange"),Yt>=X&&(ve===0||Yt<=ve)&&Md(Yt,x,M)&&Te.classList.add("inRange"))})}}function we(){e.isOpen&&!e.config.static&&!e.config.inline&&Nn()}function xe(f,b){if(b===void 0&&(b=e._positionElement),e.isMobile===!0){if(f){f.preventDefault();var M=Ht(f);M&&M.blur()}e.mobileInput!==void 0&&(e.mobileInput.focus(),e.mobileInput.click()),Le("onOpen");return}else if(e._input.disabled||e.config.inline)return;var x=e.isOpen;e.isOpen=!0,x||(e.calendarContainer.classList.add("open"),e._input.classList.add("active"),Le("onOpen"),Nn(b)),e.config.enableTime===!0&&e.config.noCalendar===!0&&e.config.allowInput===!1&&(f===void 0||!e.timeContainer.contains(f.relatedTarget))&&setTimeout(function(){return e.hourElement.select()},50)}function $e(f){return function(b){var M=e.config["_"+f+"Date"]=e.parseDate(b,e.config.dateFormat),x=e.config["_"+(f==="min"?"max":"min")+"Date"];M!==void 0&&(e[f==="min"?"minDateHasTime":"maxDateHasTime"]=M.getHours()>0||M.getMinutes()>0||M.getSeconds()>0),e.selectedDates&&(e.selectedDates=e.selectedDates.filter(function(j){return z(j)}),!e.selectedDates.length&&f==="min"&&y(M),yn()),e.daysContainer&&(mo(),M!==void 0?e.currentYearElement[f]=M.getFullYear().toString():e.currentYearElement.removeAttribute(f),e.currentYearElement.disabled=!!x&&M!==void 0&&x.getFullYear()===M.getFullYear())}}function tt(){var f=["wrap","weekNumbers","allowInput","allowInvalidPreload","clickOpens","time_24hr","enableTime","noCalendar","altInput","shorthandCurrentMonth","inline","static","enableSeconds","disableMobile"],b=ct(ct({},JSON.parse(JSON.stringify(n.dataset||{}))),t),M={};e.config.parseDate=b.parseDate,e.config.formatDate=b.formatDate,Object.defineProperty(e.config,"enable",{get:function(){return e.config._enable},set:function(se){e.config._enable=Oc(se)}}),Object.defineProperty(e.config,"disable",{get:function(){return e.config._disable},set:function(se){e.config._disable=Oc(se)}});var x=b.mode==="time";if(!b.dateFormat&&(b.enableTime||x)){var j=je.defaultConfig.dateFormat||Qn.dateFormat;M.dateFormat=b.noCalendar||x?"H:i"+(b.enableSeconds?":S":""):j+" H:i"+(b.enableSeconds?":S":"")}if(b.altInput&&(b.enableTime||x)&&!b.altFormat){var q=je.defaultConfig.altFormat||Qn.altFormat;M.altFormat=b.noCalendar||x?"h:i"+(b.enableSeconds?":S K":" K"):q+(" h:i"+(b.enableSeconds?":S":"")+" K")}Object.defineProperty(e.config,"minDate",{get:function(){return e.config._minDate},set:$e("min")}),Object.defineProperty(e.config,"maxDate",{get:function(){return e.config._maxDate},set:$e("max")});var pe=function(se){return function(Te){e.config[se==="min"?"_minTime":"_maxTime"]=e.parseDate(Te,"H:i:S")}};Object.defineProperty(e.config,"minTime",{get:function(){return e.config._minTime},set:pe("min")}),Object.defineProperty(e.config,"maxTime",{get:function(){return e.config._maxTime},set:pe("max")}),b.mode==="time"&&(e.config.noCalendar=!0,e.config.enableTime=!0),Object.assign(e.config,M,b);for(var X=0;X<f.length;X++)e.config[f[X]]=e.config[f[X]]===!0||e.config[f[X]]==="true";va.filter(function(se){return e.config[se]!==void 0}).forEach(function(se){e.config[se]=Da(e.config[se]||[]).map(a)}),e.isMobile=!e.config.disableMobile&&!e.config.inline&&e.config.mode==="single"&&!e.config.disable.length&&!e.config.enable&&!e.config.weekNumbers&&/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);for(var X=0;X<e.config.plugins.length;X++){var ve=e.config.plugins[X](e)||{};for(var J in ve)va.indexOf(J)>-1?e.config[J]=Da(ve[J]).map(a).concat(e.config[J]):typeof b[J]>"u"&&(e.config[J]=ve[J])}b.altInputClass||(e.config.altInputClass=Wt().className+" "+e.config.altInputClass),Le("onParseConfig")}function Wt(){return e.config.wrap?n.querySelector("[data-input]"):n}function er(){typeof e.config.locale!="object"&&typeof je.l10ns[e.config.locale]>"u"&&e.config.errorHandler(new Error("flatpickr: invalid locale "+e.config.locale)),e.l10n=ct(ct({},je.l10ns.default),typeof e.config.locale=="object"?e.config.locale:e.config.locale!=="default"?je.l10ns[e.config.locale]:void 0),Ln.D="("+e.l10n.weekdays.shorthand.join("|")+")",Ln.l="("+e.l10n.weekdays.longhand.join("|")+")",Ln.M="("+e.l10n.months.shorthand.join("|")+")",Ln.F="("+e.l10n.months.longhand.join("|")+")",Ln.K="("+e.l10n.amPM[0]+"|"+e.l10n.amPM[1]+"|"+e.l10n.amPM[0].toLowerCase()+"|"+e.l10n.amPM[1].toLowerCase()+")";var f=ct(ct({},t),JSON.parse(JSON.stringify(n.dataset||{})));f.time_24hr===void 0&&je.defaultConfig.time_24hr===void 0&&(e.config.time_24hr=e.l10n.time_24hr),e.formatDate=Rc(e),e.parseDate=Ea({config:e.config,l10n:e.l10n})}function Nn(f){if(typeof e.config.position=="function")return void e.config.position(e,f);if(e.calendarContainer!==void 0){Le("onPreCalendarPosition");var b=f||e._positionElement,M=Array.prototype.reduce.call(e.calendarContainer.children,function(Jd,Xd){return Jd+Xd.offsetHeight},0),x=e.calendarContainer.offsetWidth,j=e.config.position.split(" "),q=j[0],pe=j.length>1?j[1]:null,X=b.getBoundingClientRect(),ve=window.innerHeight-X.bottom,J=q==="above"||q!=="below"&&ve<M&&X.top>M,se=window.pageYOffset+X.top+(J?-M-2:b.offsetHeight+2);if(st(e.calendarContainer,"arrowTop",!J),st(e.calendarContainer,"arrowBottom",J),!e.config.inline){var Te=window.pageXOffset+X.left,an=!1,Yt=!1;pe==="center"?(Te-=(x-X.width)/2,an=!0):pe==="right"&&(Te-=x-X.width,Yt=!0),st(e.calendarContainer,"arrowLeft",!an&&!Yt),st(e.calendarContainer,"arrowCenter",an),st(e.calendarContainer,"arrowRight",Yt);var Xr=window.document.body.offsetWidth-(window.pageXOffset+X.right),br=Te+x>window.document.body.offsetWidth,zd=Xr+x>window.document.body.offsetWidth;if(st(e.calendarContainer,"rightMost",br),!e.config.static)if(e.calendarContainer.style.top=se+"px",!br)e.calendarContainer.style.left=Te+"px",e.calendarContainer.style.right="auto";else if(!zd)e.calendarContainer.style.left="auto",e.calendarContainer.style.right=Xr+"px";else{var Oa=Jr();if(Oa===void 0)return;var Vd=window.document.body.offsetWidth,qd=Math.max(0,Vd/2-x/2),Wd=".flatpickr-calendar.centerMost:before",Gd=".flatpickr-calendar.centerMost:after",Kd=Oa.cssRules.length,Zd="{left:"+X.left+"px;right:auto;}";st(e.calendarContainer,"rightMost",!1),st(e.calendarContainer,"centerMost",!0),Oa.insertRule(Wd+","+Gd+Zd,Kd),e.calendarContainer.style.left=qd+"px",e.calendarContainer.style.right="auto"}}}}function Jr(){for(var f=null,b=0;b<document.styleSheets.length;b++){var M=document.styleSheets[b];if(M.cssRules){try{M.cssRules}catch{continue}f=M;break}}return f??ho()}function ho(){var f=document.createElement("style");return document.head.appendChild(f),f.sheet}function mo(){e.config.noCalendar||e.isMobile||(ne(),fo(),H())}function xa(){e._input.focus(),window.navigator.userAgent.indexOf("MSIE")!==-1||navigator.msMaxTouchPoints!==void 0?setTimeout(e.close,0):e.close()}function Lc(f){f.preventDefault(),f.stopPropagation();var b=function(se){return se.classList&&se.classList.contains("flatpickr-day")&&!se.classList.contains("flatpickr-disabled")&&!se.classList.contains("notAllowed")},M=Pc(Ht(f),b);if(M!==void 0){var x=M,j=e.latestSelectedDateObj=new Date(x.dateObj.getTime()),q=(j.getMonth()<e.currentMonth||j.getMonth()>e.currentMonth+e.config.showMonths-1)&&e.config.mode!=="range";if(e.selectedDateElem=x,e.config.mode==="single")e.selectedDates=[j];else if(e.config.mode==="multiple"){var pe=La(j);pe?e.selectedDates.splice(parseInt(pe),1):e.selectedDates.push(j)}else e.config.mode==="range"&&(e.selectedDates.length===2&&e.clear(!1,!1),e.latestSelectedDateObj=j,e.selectedDates.push(j),Bt(j,e.selectedDates[0],!0)!==0&&e.selectedDates.sort(function(se,Te){return se.getTime()-Te.getTime()}));if(p(),q){var X=e.currentYear!==j.getFullYear();e.currentYear=j.getFullYear(),e.currentMonth=j.getMonth(),X&&(Le("onYearChange"),ne()),Le("onMonthChange")}if(fo(),H(),yn(),!q&&e.config.mode!=="range"&&e.config.showMonths===1?Se(x):e.selectedDateElem!==void 0&&e.hourElement===void 0&&e.selectedDateElem&&e.selectedDateElem.focus(),e.hourElement!==void 0&&e.hourElement!==void 0&&e.hourElement.focus(),e.config.closeOnSelect){var ve=e.config.mode==="single"&&!e.config.enableTime,J=e.config.mode==="range"&&e.selectedDates.length===2&&!e.config.enableTime;(ve||J)&&xa()}O()}}var po={locale:[er,D],showMonths:[L,s,v],minDate:[K],maxDate:[K],positionElement:[Hc],clickOpens:[function(){e.config.clickOpens===!0?(I(e._input,"focus",e.open),I(e._input,"click",e.open)):(e._input.removeEventListener("focus",e.open),e._input.removeEventListener("click",e.open))}]};function Nd(f,b){if(f!==null&&typeof f=="object"){Object.assign(e.config,f);for(var M in f)po[M]!==void 0&&po[M].forEach(function(x){return x()})}else e.config[f]=b,po[f]!==void 0?po[f].forEach(function(x){return x()}):va.indexOf(f)>-1&&(e.config[f]=Da(b));e.redraw(),yn(!0)}function Nc(f,b){var M=[];if(f instanceof Array)M=f.map(function(x){return e.parseDate(x,b)});else if(f instanceof Date||typeof f=="number")M=[e.parseDate(f,b)];else if(typeof f=="string")switch(e.config.mode){case"single":case"time":M=[e.parseDate(f,b)];break;case"multiple":M=f.split(e.config.conjunction).map(function(x){return e.parseDate(x,b)});break;case"range":M=f.split(e.l10n.rangeSeparator).map(function(x){return e.parseDate(x,b)});break;default:break}else e.config.errorHandler(new Error("Invalid date supplied: "+JSON.stringify(f)));e.selectedDates=e.config.allowInvalidPreload?M:M.filter(function(x){return x instanceof Date&&z(x,!1)}),e.config.mode==="range"&&e.selectedDates.sort(function(x,j){return x.getTime()-j.getTime()})}function Od(f,b,M){if(b===void 0&&(b=!1),M===void 0&&(M=e.config.dateFormat),f!==0&&!f||f instanceof Array&&f.length===0)return e.clear(b);Nc(f,M),e.latestSelectedDateObj=e.selectedDates[e.selectedDates.length-1],e.redraw(),K(void 0,b),y(),e.selectedDates.length===0&&e.clear(!1),yn(b),b&&Le("onChange")}function Oc(f){return f.slice().map(function(b){return typeof b=="string"||typeof b=="number"||b instanceof Date?e.parseDate(b,void 0,!0):b&&typeof b=="object"&&b.from&&b.to?{from:e.parseDate(b.from,void 0),to:e.parseDate(b.to,void 0)}:b}).filter(function(b){return b})}function Hd(){e.selectedDates=[],e.now=e.parseDate(e.config.now)||new Date;var f=e.config.defaultDate||((e.input.nodeName==="INPUT"||e.input.nodeName==="TEXTAREA")&&e.input.placeholder&&e.input.value===e.input.placeholder?null:e.input.value);f&&Nc(f,e.config.dateFormat),e._initialDate=e.selectedDates.length>0?e.selectedDates[0]:e.config.minDate&&e.config.minDate.getTime()>e.now.getTime()?e.config.minDate:e.config.maxDate&&e.config.maxDate.getTime()<e.now.getTime()?e.config.maxDate:e.now,e.currentYear=e._initialDate.getFullYear(),e.currentMonth=e._initialDate.getMonth(),e.selectedDates.length>0&&(e.latestSelectedDateObj=e.selectedDates[0]),e.config.minTime!==void 0&&(e.config.minTime=e.parseDate(e.config.minTime,"H:i")),e.config.maxTime!==void 0&&(e.config.maxTime=e.parseDate(e.config.maxTime,"H:i")),e.minDateHasTime=!!e.config.minDate&&(e.config.minDate.getHours()>0||e.config.minDate.getMinutes()>0||e.config.minDate.getSeconds()>0),e.maxDateHasTime=!!e.config.maxDate&&(e.config.maxDate.getHours()>0||e.config.maxDate.getMinutes()>0||e.config.maxDate.getSeconds()>0)}function Bd(){if(e.input=Wt(),!e.input){e.config.errorHandler(new Error("Invalid input element specified"));return}e.input._type=e.input.type,e.input.type="text",e.input.classList.add("flatpickr-input"),e._input=e.input,e.config.altInput&&(e.altInput=Ee(e.input.nodeName,e.config.altInputClass),e._input=e.altInput,e.altInput.placeholder=e.input.placeholder,e.altInput.disabled=e.input.disabled,e.altInput.required=e.input.required,e.altInput.tabIndex=e.input.tabIndex,e.altInput.type="text",e.input.setAttribute("type","hidden"),!e.config.static&&e.input.parentNode&&e.input.parentNode.insertBefore(e.altInput,e.input.nextSibling)),e.config.allowInput||e._input.setAttribute("readonly","readonly"),Hc()}function Hc(){e._positionElement=e.config.positionElement||e._input}function Yd(){var f=e.config.enableTime?e.config.noCalendar?"time":"datetime-local":"date";e.mobileInput=Ee("input",e.input.className+" flatpickr-mobile"),e.mobileInput.tabIndex=1,e.mobileInput.type=f,e.mobileInput.disabled=e.input.disabled,e.mobileInput.required=e.input.required,e.mobileInput.placeholder=e.input.placeholder,e.mobileFormatStr=f==="datetime-local"?"Y-m-d\\TH:i:S":f==="date"?"Y-m-d":"H:i:S",e.selectedDates.length>0&&(e.mobileInput.defaultValue=e.mobileInput.value=e.formatDate(e.selectedDates[0],e.mobileFormatStr)),e.config.minDate&&(e.mobileInput.min=e.formatDate(e.config.minDate,"Y-m-d")),e.config.maxDate&&(e.mobileInput.max=e.formatDate(e.config.maxDate,"Y-m-d")),e.input.getAttribute("step")&&(e.mobileInput.step=String(e.input.getAttribute("step"))),e.input.type="hidden",e.altInput!==void 0&&(e.altInput.type="hidden");try{e.input.parentNode&&e.input.parentNode.insertBefore(e.mobileInput,e.input.nextSibling)}catch{}I(e.mobileInput,"change",function(b){e.setDate(Ht(b).value,!1,e.mobileFormatStr),Le("onChange"),Le("onClose")})}function Fd(f){if(e.isOpen===!0)return e.close();e.open(f)}function Le(f,b){if(e.config!==void 0){var M=e.config[f];if(M!==void 0&&M.length>0)for(var x=0;M[x]&&x<M.length;x++)M[x](e.selectedDates,e.input.value,e,b);f==="onChange"&&(e.input.dispatchEvent(Aa("change")),e.input.dispatchEvent(Aa("input")))}}function Aa(f){var b=document.createEvent("Event");return b.initEvent(f,!0,!0),b}function La(f){for(var b=0;b<e.selectedDates.length;b++){var M=e.selectedDates[b];if(M instanceof Date&&Bt(M,f)===0)return""+b}return!1}function $d(f){return e.config.mode!=="range"||e.selectedDates.length<2?!1:Bt(f,e.selectedDates[0])>=0&&Bt(f,e.selectedDates[1])<=0}function fo(){e.config.noCalendar||e.isMobile||!e.monthNav||(e.yearElements.forEach(function(f,b){var M=new Date(e.currentYear,e.currentMonth,1);M.setMonth(e.currentMonth+b),e.config.showMonths>1||e.config.monthSelectorType==="static"?e.monthElements[b].textContent=uo(M.getMonth(),e.config.shorthandCurrentMonth,e.l10n)+" ":e.monthsDropdownContainer.value=M.getMonth().toString(),f.value=M.getFullYear().toString()}),e._hidePrevMonthArrow=e.config.minDate!==void 0&&(e.currentYear===e.config.minDate.getFullYear()?e.currentMonth<=e.config.minDate.getMonth():e.currentYear<e.config.minDate.getFullYear()),e._hideNextMonthArrow=e.config.maxDate!==void 0&&(e.currentYear===e.config.maxDate.getFullYear()?e.currentMonth+1>e.config.maxDate.getMonth():e.currentYear>e.config.maxDate.getFullYear()))}function Na(f){var b=f||(e.config.altInput?e.config.altFormat:e.config.dateFormat);return e.selectedDates.map(function(M){return e.formatDate(M,b)}).filter(function(M,x,j){return e.config.mode!=="range"||e.config.enableTime||j.indexOf(M)===x}).join(e.config.mode!=="range"?e.config.conjunction:e.l10n.rangeSeparator)}function yn(f){f===void 0&&(f=!0),e.mobileInput!==void 0&&e.mobileFormatStr&&(e.mobileInput.value=e.latestSelectedDateObj!==void 0?e.formatDate(e.latestSelectedDateObj,e.mobileFormatStr):""),e.input.value=Na(e.config.dateFormat),e.altInput!==void 0&&(e.altInput.value=Na(e.config.altFormat)),f!==!1&&Le("onValueUpdate")}function jd(f){var b=Ht(f),M=e.prevMonthNav.contains(b),x=e.nextMonthNav.contains(b);M||x?_(M?-1:1):e.yearElements.indexOf(b)>=0?b.select():b.classList.contains("arrowUp")?e.changeYear(e.currentYear+1):b.classList.contains("arrowDown")&&e.changeYear(e.currentYear-1)}function Ud(f){f.preventDefault();var b=f.type==="keydown",M=Ht(f),x=M;e.amPM!==void 0&&M===e.amPM&&(e.amPM.textContent=e.l10n.amPM[Ot(e.amPM.textContent===e.l10n.amPM[0])]);var j=parseFloat(x.getAttribute("min")),q=parseFloat(x.getAttribute("max")),pe=parseFloat(x.getAttribute("step")),X=parseInt(x.value,10),ve=f.delta||(b?f.which===38?1:-1:0),J=X+pe*ve;if(typeof x.value<"u"&&x.value.length===2){var se=x===e.hourElement,Te=x===e.minuteElement;J<j?(J=q+J+Ot(!se)+(Ot(se)&&Ot(!e.amPM)),Te&&ie(void 0,-1,e.hourElement)):J>q&&(J=x===e.hourElement?J-q-Ot(!e.amPM):j,Te&&ie(void 0,1,e.hourElement)),e.amPM&&se&&(pe===1?J+X===23:Math.abs(J-X)>pe)&&(e.amPM.textContent=e.l10n.amPM[Ot(e.amPM.textContent===e.l10n.amPM[0])]),x.value=at(J)}}return i(),e}function Zr(n,t){for(var e=Array.prototype.slice.call(n).filter(function(a){return a instanceof HTMLElement}),r=[],i=0;i<e.length;i++){var o=e[i];try{if(o.getAttribute("data-fp-omit")!==null)continue;o._flatpickr!==void 0&&(o._flatpickr.destroy(),o._flatpickr=void 0),o._flatpickr=Om(o,t||{}),r.push(o._flatpickr)}catch(a){console.error(a)}}return r.length===1?r[0]:r}typeof HTMLElement<"u"&&typeof HTMLCollection<"u"&&typeof NodeList<"u"&&(HTMLCollection.prototype.flatpickr=NodeList.prototype.flatpickr=function(n){return Zr(this,n)},HTMLElement.prototype.flatpickr=function(n){return Zr([this],n)});var je=function(n,t){return typeof n=="string"?Zr(window.document.querySelectorAll(n),t):n instanceof Node?Zr([n],t):Zr(n,t)};je.defaultConfig={};je.l10ns={en:ct({},wa),default:ct({},wa)};je.localize=function(n){je.l10ns.default=ct(ct({},je.l10ns.default),n)};je.setDefaults=function(n){je.defaultConfig=ct(ct({},je.defaultConfig),n)};je.parseDate=Ea({});je.formatDate=Rc({});je.compareDates=Bt;typeof jQuery<"u"&&typeof jQuery.fn<"u"&&(jQuery.fn.flatpickr=function(n){return Zr(this,n)});Date.prototype.fp_incr=function(n){return new Date(this.getFullYear(),this.getMonth(),this.getDate()+(typeof n=="string"?parseInt(n,10):n))};typeof window<"u"&&(window.flatpickr=je);var kd=je;var Ca=class{constructor(t,e){this.dateInputEl=t;R(this,"minDate");R(this,"maxDate");R(this,"defaultReservationDays");R(this,"hasPrices",!1);R(this,"prices",{});R(this,"availability",{});R(this,"disabledDates",[]);R(this,"selectedStartDate");R(this,"selectedEndDate");R(this,"config");R(this,"instance");R(this,"destroyInstance");R(this,"currentDate");R(this,"handleResize",()=>{let t=this.isMobileDevice();(t&&this.config.grid!==1||!t&&this.config.grid!==2)&&(this.config.grid=t?1:2,this.config.calendars=t?1:2,this.destroyInstance&&this.destroyInstance(),this.initialize())});this.isMobileDevice()&&(e.grid=1,e.calendars=1),this.dateInputEl=t,this.defaultReservationDays=e.defaultReservationDays??3,this.config={type:e.type,showPrices:e.showPrices??!1,defaultReservationDays:this.defaultReservationDays,grid:e.grid??2,calendars:e.calendars??2,darkMode:e.darkMode??!0,tooltip:e.tooltip??!0,repick:e.repick??!1,minDays:e.minDays??1,defaultStartDate:e.defaultStartDate??W.getCurrentDate(),defaultEndDate:e.defaultEndDate??W.getCurrentDate()},this.currentDate=W.getCurrentDate(),this.selectedStartDate=this.config.defaultStartDate,this.selectedEndDate=this.config.defaultEndDate}isMobileDevice(){return window.innerWidth<=768}initialize(){switch(window.addEventListener("resize",this.handleResize),this.config.type){case"easepick":this.initEasepickCalendar();break;case"flatpickr":this.initFlatpickrCalendar();break;default:throw new Error(`Unsupported calendar type: ${this.config.type}`)}}setMinimumDate(t){this.minDate=t}setMaximumDate(t){this.maxDate=t}setStartDate(t){let e=W.toJSDate(t),r=W.toJSDate(this.selectedEndDate);this.selectedStartDate=t,this.instance instanceof ya.Core?this.instance.setStartDate(new me(t.toString())):this.config.type==="flatpickr"&&this.instance.setDate([e,r],!0)}setEndDate(t){let e=W.toJSDate(this.selectedStartDate),r=W.toJSDate(t);this.selectedEndDate=t,this.instance instanceof ya.Core?this.instance.setEndDate(new me(t.toString())):this.config.type==="flatpickr"&&this.instance.setDate([e,r],!0)}setDateRange(t,e){if(this.config.type==="flatpickr"){this.selectedStartDate=t,this.selectedEndDate=e;let r=W.toJSDate(t),i=W.toJSDate(e);this.instance.setDate([r,i],!0);return}this.setStartDate(t),this.setEndDate(e)}getSelectedDates(){return{startDate:this.selectedStartDate,endDate:this.selectedEndDate}}includePrices(t=!0){this.hasPrices=t}setPrices(t){this.prices=t}setAvailability(t){this.availability=t,this.disabledDates=Object.keys(t).filter(e=>!t[e])}initEasepickCalendar(){let t={element:this.dateInputEl,css:["https://cdn.jsdelivr.net/npm/@easepick/bundle@1.2.1/dist/index.css"],zIndex:10,format:rd,grid:this.config.grid,calendars:this.config.calendars,header:"",lang:document.documentElement.lang,RangePlugin:{tooltip:this.config.tooltip,repick:this.config.repick,startDate:new me(this.config.defaultStartDate.toString()),endDate:new me(this.config.defaultEndDate.toString()),tooltipNumber:r=>r-1,locale:{one:"nuit",other:"nuits"}},LockPlugin:{minDate:new me(this.minDate.toString()),minDays:this.config.minDays,selectForward:!0},AmpPlugin:{darkMode:this.config.darkMode},plugins:[ga,fa,pa],setup:r=>{r.on("view",i=>{let{view:o,date:a,target:s}=i.detail,l=a?a.format("YYYY-MM-DD"):null;if(o==="CalendarDay"&&l&&this.prices[l]){let u=this.prices[l],h=s.querySelector(`.${sa}`)||document.createElement("span");h.className=sa,h.textContent=`${u.toLocaleString(qe,{style:"currency",currency:"EUR",maximumFractionDigits:0})}`,h.style.color="#c64509",h.style.fontWeight="bold",h.style.fontSize="10px",s.append(h)}}),r.on("select",i=>{let{start:o,end:a}=i.detail;this.selectedStartDate=W.fromString(o.format("YYYY-MM-DD")),this.selectedEndDate=W.fromString(a.format("YYYY-MM-DD"));let s={startDate:o.format("YYYY-MM-DD").toString(),endDate:a.format("YYYY-MM-DD").toString()};ot("date:changed",s)})}},e=new ya.create(t);this.instance=e,this.destroyInstance=()=>e.destroy()}initFlatpickrCalendar(){let t=document.createElement("link");t.rel="stylesheet",t.href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.css",document.head.appendChild(t);let e={mode:"range",showMonths:this.config.calendars,minDate:this.minDate.toString(),defaultDate:[this.config.defaultStartDate.toString(),this.config.defaultEndDate.toString()],shorthandCurrentMonth:!0,monthSelectorType:"static",inline:!1,dateFormat:id,lang:document.documentElement.lang,zIndex:10,disable:this.disabledDates,onChange:i=>{if(i.length===2){this.selectedStartDate=W.fromJSDate(i[0]),this.selectedEndDate=W.fromJSDate(i[1]);let o={startDate:this.selectedStartDate.toString(),endDate:this.selectedEndDate.toString()};ot("date:changed",o);let a=G("label",this.dateInputEl);if(a){let s=this.formatDate(i[0]),l=this.formatDate(i[1]);a.textContent=`${s} - ${l}`}}else io()},onDayCreate:async(i,o,a,s)=>{let l=s.dateObj,u=W.fromJSDate(l),h=W.formatForAPI(u);if(this.prices[h]){let p=this.prices[h],y=document.createElement("span");y.style.marginTop="2px",y.style.color="#c64509",y.style.fontSize="10px",y.style.fontWeight="bold",y.className=sa,y.textContent=`${p.toLocaleString(qe,{style:"currency",currency:"EUR",maximumFractionDigits:0})}`,s.style.display="flex",s.style.flexDirection="column",s.style.alignItems="center",s.style.justifyContent="center",s.style.lineHeight="1.1",s.appendChild(y)}}},r=kd(this.dateInputEl,e);this.instance=r,this.destroyInstance=()=>r.destroy()}destroy(){window.removeEventListener("resize",this.handleResize),this.destroyInstance&&this.destroyInstance()}formatDate(t){let e=W.fromJSDate(t),r=e.year,i=String(e.month).padStart(2,"0"),o=String(e.day).padStart(2,"0");return qe==="en-US"?`${r}/${i}/${o}`:qe==="fr-FR"||qe==="de-DE"?`${o}/${i}/${r}`:`${r}/${i}/${o}`}};var Sa=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"nightsCountElement");R(this,"startDateElement");R(this,"endDateElement");R(this,"dateElement");R(this,"roomsWrapperElement");R(this,"roomElementTemplate");R(this,"addRoomElement");R(this,"rooms",[]);R(this,"includePrices",od);R(this,"populateCalendarInput",async()=>{if(!this.dateElement){console.error("Date element not found");return}let t=new Ca(this.dateElement,{type:"flatpickr",showPrices:!0,defaultReservationDays:3,grid:2,calendars:2,darkMode:!1,tooltip:!0,repick:!1,minDays:1,defaultStartDate:this.parentComponent.state.startDate||Jn,defaultEndDate:this.parentComponent.state.endDate||yr});if(t.setMinimumDate(Jn),t.setMaximumDate(yr),t.includePrices(this.includePrices),this.includePrices){let e=await Ed([this.parentComponent.apartmentProperties.enterpriseId]);t.setPrices(e)}return t.initialize(),t});Zn("date:changed",e=>{this.parentComponent.state.startDate=W.fromString(e.startDate),this.parentComponent.state.endDate=W.fromString(e.endDate),et.startDate=this.parentComponent.state.startDate.toString(),et.endDate=this.parentComponent.state.endDate.toString()}),this.element=G("details-box"),this.nightsCountElement=G("nights",this.element),this.startDateElement=G("start-date",this.element),this.endDateElement=G("end-date",this.element),this.dateElement=G("date-element",this.element),this.roomsWrapperElement=G("room-box-wrapper",this.element),this.roomElementTemplate=G("room-box",this.element),this.addRoomElement=G("add-room-button",this.element)}init(){console.log("Initialize DetailsSection"),this.updateDOM(),this.populateCalendarInput()}updateDOM(){Tt(()=>{this.startDateElement.textContent=this.parentComponent.state.startDate?W.formatForDisplay(this.parentComponent.state.startDate):"?"}),Tt(()=>{this.endDateElement.textContent=this.parentComponent.state.endDate?W.formatForDisplay(this.parentComponent.state.endDate):"?"}),Tt(()=>{this.nightsCountElement.textContent=`${this.parentComponent.state.nightsCount} ${Fe("night").toLowerCase()}${this.parentComponent.state.nightsCount>1?"s":""}`}),Tt(()=>{let t=document.createDocumentFragment();this.parentComponent.state.rooms.forEach((e,r)=>{let i=on(this.roomElementTemplate,!0),o=G("room",i);o.textContent=`${Fe("apartment")} ${r+1}`;let a=G("categories-wrapper",i),s=G("age-category",a),l=document.createDocumentFragment();e.forEach(u=>{let h=on(s,!0),p=G("category-name",h);p.textContent=u.name;let y=G("input",h);ao(y,u.value.toString()),kt(h,"click",E=>{switch(E.preventDefault(),ld(E.target)){case"decrement":(this.computations().hasOccupants&&u.isAdult?this.computations().totalAdults>1:u.value>0)&&(u.value-=1);break;case"increment":this.computations().hasCapacity&&(u.value+=1);break}},{once:!1}),l.appendChild(h)}),a.innerHTML="",a.appendChild(l),t.appendChild(i)}),this.roomsWrapperElement.innerHTML="",this.roomsWrapperElement.appendChild(t),this.parentComponent.state.rooms.length===this.parentComponent.apartmentProperties.availableRooms&&this.addRoomElement.classList.add("hide")}),kt(this.addRoomElement,"click",t=>{if(t.preventDefault(),this.parentComponent.state.rooms.length<this.parentComponent.apartmentProperties.availableRooms){let e=this.parentComponent.state._ageCategories.map(r=>{let i=r.classification.toLowerCase()==="adult",o=i?Fe("adults"):Fe("children");return{isAdult:i,ageCategoryId:r.id,name:o,value:0}});this.parentComponent.state.rooms.push(e)}})}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t)}computations(){let t=this.parentComponent.state.rooms.some(o=>o.some(a=>a.value>0)),r=this.parentComponent.state.rooms.reduce((o,a)=>o+a.reduce((s,l)=>s+l.value,0),0)<this.parentComponent.apartmentProperties.capacity,i=this.parentComponent.state.rooms.reduce((o,a)=>o+a.filter(s=>s.isAdult).reduce((s,l)=>s+l.value,0),0);return{hasOccupants:t,hasCapacity:r,totalAdults:i}}};var Pd=(n,t)=>{let e={method:"POST",headers:te.headers,body:JSON.stringify(t)};return Ge("/images/getUrls",e,n)};function Id(n){return n.ImageUrls.map(t=>({url:t.Url,imageId:t.ImageId}))}var xc=Ve({}),Rd={width:160,height:160};async function xd(n,t){if(t.every(i=>xc.value[i]))return t.map(i=>xc.value[i]).flat();let e=await Pd(n,{Images:t.map(i=>({ImageId:i,Width:Rd.width,Height:Rd.height,ResizeMode:"Cover"}))}),r=Id(e);return r.forEach(i=>{xc.value[i.imageId]=i}),r}var Ta=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"productsWrapperElement");R(this,"productTemplateElement");R(this,"showMoreButtonElement");this.element=G("options-box"),this.productsWrapperElement=G("options-list",this.element),this.productTemplateElement=G("option-wrapper",this.element),this.showMoreButtonElement=G("more-button",this.element)}init(){try{if(!this.parentComponent.reservableService)throw new Error("Reservable service is not initialized");this.updateDOM()}catch(t){console.error("Error initializing OptionsSection:",t)}}refresh(){try{}catch(t){console.error("Error refreshing OptionsSection:",t)}}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t)}updateDOM(){let t=document.createDocumentFragment();this.parentComponent.state.products.sort((r,i)=>{if(r.ordering!==i.ordering)return(r.ordering??0)-(i.ordering??0);let o=r.name,a=i.name;return o<a?-1:o>a?1:(r.ordering===i.ordering,0)}).forEach((r,i)=>{let o=on(this.productTemplateElement,!0);o.removeAttribute("id");let a=G("name",o);a.textContent=r.name||"";let s=G("price",o);s.textContent=r.price.toLocaleString(qe,{style:"currency",currency:"EUR"});let l=G("label",o);l.textContent=Fe(`chargingMode:${r.chargingMode}`),xd(this.parentComponent.apartmentProperties.enterpriseId,r.imageIds).then(h=>{let p=G("image",o);p.src=h[0].url});let u=G("checkbox",o);kt(u,"change",()=>{let h=oo(u);r.selected=h==="true",this.parentComponent.state.products=[...this.parentComponent.state.products]}),o.classList.toggle("hide",i>3),t.appendChild(o)}),Mc(this.productsWrapperElement),this.productsWrapperElement.appendChild(t),kt(this.showMoreButtonElement,"click",()=>{let r=this.showMoreProducts(3);this.showMoreButtonElement.classList.toggle("hide",!r)})}showMoreProducts(t=4){let e=this.productsWrapperElement.querySelectorAll(`${cd(this.productTemplateElement)}.hide`);return e.forEach((r,i)=>{i<t&&r.classList.toggle("hide",!1)}),e.length>t}};var Ad=(n,t)=>{let e=`${te.bookingEngine_url}/reservationGroups/create`,r={method:"POST",headers:te.headers,body:JSON.stringify(t)};return fetch(e,r).then(o=>o.json())};var ka=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"modalContent");R(this,"modalBg");R(this,"openModalBtn");R(this,"closeModalBtn");R(this,"fNameInput");R(this,"lNameInput");R(this,"emailInput");R(this,"phoneInput");R(this,"countryInput");R(this,"notesInput");R(this,"submitPaymentBtn");R(this,"customer",null);this.element=G("payment-modal"),this.modalContent=G("modal-content",this.element),this.modalBg=G("modal-bg",this.element),this.openModalBtn=G("open-modal"),this.closeModalBtn=G("close-modal"),this.fNameInput=G("fname-input",this.element),this.lNameInput=G("lname-input",this.element),this.emailInput=G("email-input",this.element),this.phoneInput=G("phone-input",this.element),this.countryInput=G("country-input",this.element),this.notesInput=G("notes-input",this.element),this.submitPaymentBtn=G("submit-payment",this.element)}init(){console.log("Initialize PaymentModal"),this.updateDOM()}updateDOM(){kt(this.openModalBtn,"click",()=>{this.toggleVisibility(!0),this.element.scrollIntoView({behavior:"smooth"})}),kt(this.submitPaymentBtn,"click",t=>{t.preventDefault(),this.handleSubmit()})}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t),t?(this.element.style.display="flex",this.element.style.opacity="1",this.modalContent.style.opacity="1",this.element.querySelectorAll("div").forEach(e=>{e.style.opacity="1"})):(this.element.style.opacity="0",this.element.style.display="none")}validateInputs(){if(!this.fNameInput.value||!this.lNameInput.value||!this.emailInput.value||!this.phoneInput.value||!this.countryInput.value)throw new Error("First name, last name, email, phone, and nationality are required.");if(!this.emailInput.checkValidity())throw new Error("Invalid email format.");if(!this.phoneInput.checkValidity())throw new Error("Invalid phone number format. Only numbers and spaces are allowed.");if(!this.countryInput.value)throw new Error("Country is required.")}async handleSubmit(){if(!this.parentComponent.state.startDate||!this.parentComponent.state.endDate)throw new Error("Start date and end date are required to submit the payment form.");try{this.validateInputs()}catch(s){console.error("Validation error:",s),alert(s instanceof Error?s.message:"An unexpected error occurred.");return}let{startDate:t,endDate:e}=this.parentComponent.state;this.customer={Email:this.emailInput.value,FirstName:this.fNameInput.value,LastName:this.lNameInput.value,Telephone:this.phoneInput.value,NationalityCode:this.countryInput.value,SendMarketingEmails:!1};let r={Client:te.bookingEngineClient,HotelId:this.parentComponent.apartmentProperties.enterpriseId,Customer:this.customer,Reservations:this.parentComponent.state.rooms.map(s=>({RoomCategoryId:this.parentComponent.apartmentProperties.categoryId,StartUtc:W.formatForAPI(t.toString()),EndUtc:W.formatForAPI(e.toString()),VoucherCode:this.parentComponent.state.couponCode||void 0,RateId:this.parentComponent.state.selectedRateId||"",AdultCount:s.filter(l=>l.isAdult).reduce((l,u)=>l+u.value,0),ChildCount:s.filter(l=>!l.isAdult).reduce((l,u)=>l+u.value,0),ProductIds:this.parentComponent.state.selectedProducts.map(l=>l.id),Notes:this.notesInput.value||""}))};console.log("Payload for reservation group:",r);let i=JSON.stringify(r,null,2);console.log("JSON Payload:",i);let o=this.submitPaymentBtn.textContent?.trim()??Fe("proceedToPayment");this.submitPaymentBtn.textContent=Fe("completePayment"),this.submitPaymentBtn.classList.add("is-disabled");let a=await Ad(this.parentComponent.apartmentProperties.enterpriseId,r);if(console.log("Reservation Response:",a),"PaymentRequestId"in a&&a.PaymentRequestId){let s=new URL(window.location.href);s.pathname="/reservation-confirmee";let l=`https://app.mews.com/navigator/payment-requests/detail/${a.PaymentRequestId}?returnUrl=${btoa(s.toString())}`;console.log("Payment URL:",l),window.open(l,"_blank")}else{this.submitPaymentBtn.classList.remove("is-disabled"),this.submitPaymentBtn.textContent=o;let s="Message"in a&&a.Message?a.Message:"Payment request could not be created. Please try again later or contact Support.";console.error("Payment Request ID is missing in the response:",a),alert(s);return}}};var Ld=(n,t)=>{let e=`${te.bookingEngine_url}/vouchers/validate`,r={method:"POST",headers:te.headers,body:JSON.stringify(t)};return An(e,r,n)};var Pa=class{constructor(t){this.parentComponent=t;R(this,"element");R(this,"summaryItemElement");R(this,"itemNameElement");R(this,"itemRowTemplateElement");R(this,"totalPriceElement");R(this,"taxElement");R(this,"submitElement");R(this,"couponInputElement");R(this,"couponApplyElement");R(this,"statusTextElement");Zn("loading:start",e=>Wr(!0,e)),Zn("loading:end",e=>Wr(!1,e)),this.element=G("summary-box"),this.summaryItemElement=G("summary-item",this.element),this.itemNameElement=G("name",this.summaryItemElement),this.itemRowTemplateElement=G("row",this.summaryItemElement),this.totalPriceElement=G("total",this.element),this.taxElement=G("tax",this.element),this.submitElement=G("submit",this.element),this.couponInputElement=G("coupon-input",this.element),this.couponApplyElement=G("apply-coupon",this.element),this.statusTextElement=G("status-text",this.element)}init(){this.updateDOM(),ot("loading:end",this.element)}refresh(){ot("loading:end",this.element)}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t),Array.from(this.element.children).forEach(e=>{e instanceof HTMLDivElement&&e.classList.toggle("hide",!t)})}updateDOM(){kt(this.couponInputElement,"input",()=>{this.parentComponent.state.couponCode=oo(this.couponInputElement)}),kt(this.couponApplyElement,"click",async t=>{t.preventDefault(),ot("loading:start",this.element),Ld(this.parentComponent.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,HotelId:this.parentComponent.apartmentProperties.enterpriseId,VoucherCode:this.parentComponent.state.couponCode}).then(async e=>{let{IsValid:r}=e;if(this.statusTextElement.textContent=r?Fe("couponValid"):Fe("couponInvalid"),this.statusTextElement.style.color=r?"#1bcb00":"#f44900",r)try{ot("loading:start",this.element),await this.parentComponent.fetchReservationPricing(),console.log("Reservation pricing updated with voucher code")}catch(i){console.error("Error updating reservation pricing with voucher code:",i),this.statusTextElement.textContent=Fe("couponError"),this.statusTextElement.style.color="#f44900"}}).catch(e=>{console.error("Error validating coupon:",e),this.statusTextElement.textContent=Fe("couponError"),this.statusTextElement.style.color="#f44900"}).finally(()=>{ot("loading:end",this.element),this.statusTextElement.classList.toggle("hide",!1)})}),Tt(()=>{this.couponInputElement.value!==this.parentComponent.state.couponCode&&ao(this.couponInputElement,this.parentComponent.state.couponCode);let t=document.createDocumentFragment(),e=this.parentComponent.state.rates.find(s=>s.id===this.parentComponent.state.selectedRateId)?.price;this.itemNameElement.textContent=`${e?.AverageAmountPerTimeUnit?.GrossValue?.toLocaleString(qe,{style:"currency",currency:"EUR"})}/ ${Fe("night")}`;let r=e?.TotalAmount?.Breakdown?.Items?.reduce((s,l)=>s+(l.TaxValue||0),0)||0;this.taxElement.textContent=r>0?r.toLocaleString(qe,{style:"currency",currency:"EUR"}):"--",t.appendChild(this.itemNameElement);let i=on(this.itemRowTemplateElement,!0),o=G("label",i),a=G("price",i);o.textContent=`${this.parentComponent.state.nightsCount} ${Fe("night").toLowerCase()}${this.parentComponent.state.nightsCount>1?"s":""}`,a.textContent=e?.TotalAmount?.GrossValue?.toLocaleString?.(qe,{style:"currency",currency:"EUR"})??null,t.appendChild(i),this.parentComponent.state.selectedProducts.forEach(s=>{let l=on(this.itemRowTemplateElement,!0),u=G("label",l);u.textContent=s.name||"";let h=G("price",l),p=()=>{switch(s.chargingMode){case"Once":return s.price||0;case"PerTimeUnit":return s.price*this.parentComponent.state.nightsCount||0;case"PerPersonPerTimeUnit":return s.price*this.parentComponent.state.nightsCount*this.parentComponent.state.adultsCount||0;default:return console.warn(`Unknown charging mode: ${s.chargingMode}`),s.price}};h.textContent=p().toLocaleString(qe,{style:"currency",currency:"EUR"}),t.appendChild(l)}),this.summaryItemElement.innerHTML="",this.summaryItemElement.appendChild(t),this.totalPriceElement.textContent=this.parentComponent.state.totalPrice.toLocaleString(qe,{style:"currency",currency:"EUR"})})}};var Ia=class{constructor(t){this.parentComponent=t;R(this,"state",null);R(this,"element");R(this,"tariffsWrapperElement");R(this,"tariffTemplateElement");this.element=G("offer-box"),this.tariffsWrapperElement=G("offers-list",this.element),this.tariffTemplateElement=G("offer-wrapper",this.element)}init(){this.updateDOM()}refresh(){}toggleVisibility(t=!0){this.element.classList.toggle("hide",!t)}updateDOM(){Tt(()=>{let t=document.createDocumentFragment();this.parentComponent.state.rates.sort((r,i)=>{let o=r.price?.AverageAmountPerTimeUnit?.GrossValue||0,a=i.price?.AverageAmountPerTimeUnit?.GrossValue||0;return o-a}).forEach(r=>{let i=on(this.tariffTemplateElement,!0);i.removeAttribute("id");let o=G("name",i);o.textContent=r.name;let a=G("description",i);a.textContent=r.description;let s=G("price",i),l=r.price?.AverageAmountPerTimeUnit?.GrossValue||0;s.textContent=l.toLocaleString(qe,{style:"currency",currency:"EUR"});let u=this.parentComponent.state._rates.find(T=>T.id===r.id),h=G("label",i),p=G("discount-badge",i),y=G("discount-label",p);if(u)if(h.textContent=u.shortName,u.pricing?.DependentRatePricing){let T=u.pricing?.DependentRatePricing.RelativeAdjustment*100;T===0?p.classList.add("hide"):y.textContent=`${T>0?"+":""}${T}%`}else p.classList.add("hide");else h.classList.add("hide"),p.classList.add("hide");let E=G("radio-input",i);E.value=r.id,r.id===this.parentComponent.state.selectedRateId&&E.previousElementSibling.classList.add("w--redirected-checked"),kt(E,"change",()=>{E.checked&&(this.parentComponent.state.selectedRateId=r.id)}),t.appendChild(i)}),this.tariffsWrapperElement.innerHTML="",this.tariffsWrapperElement.appendChild(t)})}};var Ra=class{constructor(t){R(this,"apartmentProperties");R(this,"enterpriseInstance");R(this,"reservableService");R(this,"detailsSection");R(this,"optionsSection");R(this,"tariffsSection");R(this,"summarySection");R(this,"paymentModal");R(this,"state",Kn({startDate:null,endDate:null,rooms:[],couponCode:"",_hotel:null,_availabilities:null,_rates:[],_servicePricing:null,_reservationPricing:null,_ageCategories:[],products:[],nightsCount:gn(()=>!this.state.startDate||!this.state.endDate?0:this.state.startDate.until(this.state.endDate).days),selectedProducts:gn(()=>this.state.products.filter(t=>t.selected)),rates:gn(()=>this.state._servicePricing?.Rates?this.state._servicePricing.Rates.map(t=>{let e=this.state._servicePricing?.RateGroups?.find(o=>o.Id===t.RateGroupId),i=this.state._servicePricing?.CategoryPrices.find(o=>o.CategoryId===this.apartmentProperties.categoryId)?.OccupancyPrices.find(o=>{let a=this.state.rooms.flat(),s=Object.groupBy(a,u=>u.ageCategoryId),l={};return Object.entries(s).map(([u,h])=>{let p=h?.reduce((y,E)=>y+E.value,0);return l[u]=p||0,{ageCategoryId:u,totalPersons:p}}),o.Occupancies.every(u=>{let h=l[u.AgeCategoryId];return h===void 0||u.PersonCount===h})})?.RateGroupPrices?.find(o=>o.MinRateId===t.Id);return{id:t.Id,name:We(t.Name),description:We(t.Description),isPrivate:t.IsPrivate,currencyCode:t.CurrencyCode,ordering:t.Ordering,groupId:e?.Id??"",groupOrdering:e?.Ordering||0,price:i?.MinPrice,selected:!1}}).filter(t=>t.price!==void 0&&t.price.TotalAmount?.GrossValue!==void 0&&t.price.TotalAmount?.GrossValue>0):[]),selectedRateId:null,be_pricing:null,totalStayPrice:gn(()=>{let t=this.state.rates.find(e=>e.id===this.state.selectedRateId)?.price;return t&&t.TotalAmount?.GrossValue||0}),adultsCount:gn(()=>this.state.rooms.reduce((t,e)=>t+e.reduce((r,i)=>r+(i.isAdult?i.value:0),0),0)),childrenCount:gn(()=>this.state.rooms.reduce((t,e)=>t+e.reduce((r,i)=>r+(i.isAdult?0:i.value),0),0)),isAvailable:gn(()=>{if(!this.state._availabilities)return!1;let{categoryId:t}=this.apartmentProperties,e=this.state._availabilities.CategoryAvailabilities.find(r=>r.CategoryId===t);return e?e.Availabilities.slice(0,-1).every(r=>r>0):!1}),productsTotalPrice:gn(()=>this.state.selectedProducts.reduce((e,r)=>{let i=0;switch(r.chargingMode){case"Once":i=r.price||0;break;case"PerTimeUnit":i=r.price*this.state.nightsCount||0;break;case"PerPersonPerTimeUnit":i=r.price*this.state.nightsCount*this.state.adultsCount||0;break;default:console.warn(`Unknown charging mode: ${r.chargingMode}`),i=r.price}return e+i},0)),totalPrice:gn(()=>this.state.totalStayPrice+this.state.productsTotalPrice)}));Zn("loading:start",e=>Wr(!0,e)),Zn("loading:end",e=>Wr(!1,e)),this.apartmentProperties=t}init(){ot("loading:start",document.body);let t=et.startDate?W.safeParsePlainDate(et.startDate):Jn,e=et.endDate?W.safeParsePlainDate(et.endDate):yr;(t||e)&&this.updateDateRange(t,e),this.fetchAPIData().then(()=>{this.parseAPIData().then(()=>{let r=this.state._rates.find(i=>i.isDefault||i.isBaseRate);console.log("#=> Default Rate:",r),this.state.selectedRateId=r?.id||this.state.rates.find(i=>i.ordering===0&&i.groupOrdering===0)?.id||this.state.rates[0].id,this.detailsSection=new Sa(this),this.detailsSection.init(),this.optionsSection=new Ta(this),this.optionsSection.toggleVisibility(!0),this.optionsSection.init(),this.tariffsSection=new Ia(this),this.tariffsSection.toggleVisibility(!0),this.tariffsSection.init(),this.summarySection=new Pa(this),this.summarySection.toggleVisibility(!0),this.summarySection.init(),this.paymentModal=new ka(this),this.paymentModal.toggleVisibility(!1),this.paymentModal.init(),this.initPricingButler(),this.initAvailabilityPricingUpdater(),ot("loading:end",document.body)}).catch(r=>{console.error("Error initializing reservation component",r),alert("An error occurred. Please try again later.")})}),console.log("#=> State:",this.state)}initPricingButler(){Tt(()=>{if(this.state.rooms.length===0){console.error("\u{1F9EE} No rooms set, skipping pricing update.");return}let{startDate:t,endDate:e}=this.state;if(!t||!e){console.warn("Start date or end date is not set, skipping pricing update.");return}if(W.isBefore(t,e)){console.warn("Start date is after or equal to end date, skipping pricing update.");return}(0,Ac.default)(async()=>{let r=W.formatForAPI(t),i=W.formatForAPI(e),o={Client:te.bookingEngineClient,HotelId:this.apartmentProperties.enterpriseId,StartUtc:r,EndUtc:i,RoomCategoryId:this.apartmentProperties.categoryId,ProductIds:this.state.selectedProducts.map(s=>s.id),VoucherCode:this.state.couponCode||void 0,Occupancies:this.state.rooms.map(s=>({OccupancyData:s.map(l=>({AgeCategoryId:l.ageCategoryId,PersonCount:l.value}))}))},a=await ra(this.apartmentProperties.enterpriseId,o);this.state.be_pricing=a},500)()})}initAvailabilityPricingUpdater(){let t=(0,Ac.default)(async(e,r)=>{try{let i=W.formatForAPI(e.toString()),o=W.formatForAPI(r.toString());if(i>o){console.error("StartUtc is after EndUtc, cannot proceed with API requests.");return}let a=await uc(this.apartmentProperties.enterpriseId,{EnterpriseId:this.apartmentProperties.enterpriseId,CategoryIds:[this.apartmentProperties.categoryId],StartUtc:i,EndUtc:o,ServiceId:this.reservableService?.getService()?.id||"",Client:te.bookingEngineClient,LanguageCode:"fr-FR"});this.state._availabilities=a;let s=await ia(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,EnterpriseId:this.apartmentProperties.enterpriseId,StartUtc:i,EndUtc:o,ServiceId:this.reservableService?.getService()?.id||"",CategoryIds:[this.apartmentProperties.categoryId],CurrencyCode:"EUR"});this.state._servicePricing=s,ot("loading:end",document.body)}catch(i){console.error("Error updating availability and pricing data:",i)}},500);Tt(()=>{ot("loading:start",document.body);let{startDate:e}=this.state,{endDate:r}=this.state;if(!e||!r){console.warn("Start date or end date is not set, skipping availability and pricing updates.");return}if(W.isBefore(e,r)){console.warn("Start date is after or equal to end date, skipping API requests.");return}t(e,r)}),Tt(()=>{ot("loading:start",document.body);let{_availabilities:e,_servicePricing:r,isAvailable:i}=this.state,o=G("banner-box");if(o&&o.classList.toggle("hide",i),this.optionsSection&&this.optionsSection.toggleVisibility(i),this.tariffsSection&&this.tariffsSection.toggleVisibility(i),this.summarySection&&this.summarySection.toggleVisibility(i),r&&!this.state.selectedRateId&&this.state.rates.length>0){let a=this.state._rates.find(s=>s.isDefault||s.isBaseRate);this.state.selectedRateId=a?.id||this.state.rates.find(s=>s.ordering===0&&s.groupOrdering===0)?.id||this.state.rates[0].id}e&&r&&this.refreshUIComponents()})}findCurrentCategoryPrice(t,e){return t.find(r=>r.CategoryId===e)}async fetchAPIData(){if(console.log("#=> Fetching API data for reservation component..."),this.enterpriseInstance=new Gr(this.apartmentProperties.enterpriseId),await this.enterpriseInstance.initServices().then(()=>{this.reservableService=this.enterpriseInstance.reservableService}),await this.reservableService?.initAgeCategories(),this.state._ageCategories=this.reservableService?.getAgeCategories()||[],(et.rooms==null||et.rooms<1)&&(et.rooms=1),et.rooms)for(let a=0;a<et.rooms;a++){let s=this.state._ageCategories.map(l=>{let u=l.classification.toLowerCase()==="adult",h=u?Fe("adults"):Fe("children"),p=a===0&&u?et.guests||1:0;return{isAdult:u,ageCategoryId:l.id,name:h,value:p}});this.state.rooms.push(s)}let t=await Fu(this.apartmentProperties.enterpriseId);if(this.state._hotel=t,!this.state.startDate||!this.state.endDate){console.warn("Start date or end date is not set, skipping availability and pricing requests.");return}if(W.isBefore(this.state.startDate,this.state.endDate)){console.warn(`this.state.startDate {${this.state.startDate}} is after or equal to this.state.endDate {${this.state.endDate}}, skipping API requests.`);return}let e=W.formatForAPI(this.state.startDate),r=W.formatForAPI(this.state.endDate),i=await uc(this.apartmentProperties.enterpriseId,{EnterpriseId:this.apartmentProperties.enterpriseId,CategoryIds:[this.apartmentProperties.categoryId],StartUtc:e,EndUtc:r,ServiceId:this.reservableService?.getService()?.id||"",Client:te.bookingEngineClient,LanguageCode:"fr-FR"});this.state._availabilities=i;let o=await ia(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,EnterpriseId:this.apartmentProperties.enterpriseId,StartUtc:e,EndUtc:r,ServiceId:this.reservableService?.getService()?.id||"",CategoryIds:[this.apartmentProperties.categoryId],CurrencyCode:"EUR",voucherCode:this.state.couponCode||void 0});if(this.state._servicePricing=o,this.state.rooms.length===0){console.error("\u{1F9EE} No rooms set, skipping reservation pricing request.");return}try{let a=await ra(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,HotelId:this.apartmentProperties.enterpriseId,StartUtc:e,EndUtc:r,RoomCategoryId:this.apartmentProperties.categoryId,ProductIds:this.state.selectedProducts.map(s=>s.id),VoucherCode:this.state.couponCode||void 0,Occupancies:this.state.rooms.map(s=>({OccupancyData:s.filter(l=>l.value>0).map(l=>({AgeCategoryId:l.ageCategoryId,PersonCount:l.value}))}))});this.state._reservationPricing=a}catch(a){console.error("Error fetching reservation pricing:",a)}if(this.reservableService&&this.reservableService.getService()!=null){let a=this.reservableService.getService()?.id;console.log("loading rates for serviceId:",a),this.state._rates=await aa(this.apartmentProperties.enterpriseId,a),console.log("#=> Rates loaded:",this.state._rates)}else console.warn("No reservable service found, rates will not be loaded.")}async parseAPIData(){this.state.products=this.state._hotel?.Products.map(t=>({id:t.Id,name:We(t.Name),description:We(t.Description),categoryId:t.CategoryId,ordering:t.Ordering,imageIds:[t.ImageId],price:t.Prices.EUR,chargingMode:t.ChargingMode,selected:!1}))||[]}refreshUIComponents(){if(this.state.rates.length>0&&!this.state.selectedRateId){let e=this.state._rates.find(r=>r.isDefault||r.isBaseRate);this.state.selectedRateId=e?.id||this.state.rates.find(r=>r.ordering===0&&r.groupOrdering===0)?.id||this.state.rates[0].id}let t=G("banner-box");t&&t.classList.toggle("hide",this.state.isAvailable),this.optionsSection&&(this.optionsSection.toggleVisibility(this.state.isAvailable),this.optionsSection.refresh()),this.tariffsSection&&(this.tariffsSection.toggleVisibility(this.state.isAvailable),this.tariffsSection.refresh()),this.summarySection&&(this.summarySection.toggleVisibility(this.state.isAvailable),this.summarySection.refresh()),ot("loading:end",document.body)}async fetchReservationPricing(){if(!this.state.startDate||!this.state.endDate){console.warn("Start date or end date is not set, cannot fetch reservation pricing");return}if(W.isBefore(this.state.startDate,this.state.endDate)){console.warn("Start date is after or equal to end date, cannot fetch reservation pricing");return}if(this.state.rooms.length===0){console.error("No rooms set, cannot fetch reservation pricing");return}try{let t=W.formatForAPI(this.state.startDate),e=W.formatForAPI(this.state.endDate),r=await ia(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,EnterpriseId:this.apartmentProperties.enterpriseId,StartUtc:t,EndUtc:e,ServiceId:this.reservableService?.getService()?.id||"",CategoryIds:[this.apartmentProperties.categoryId],CurrencyCode:"EUR",voucherCode:this.state.couponCode||void 0});this.state._servicePricing=r;let i=await ra(this.apartmentProperties.enterpriseId,{Client:te.bookingEngineClient,HotelId:this.apartmentProperties.enterpriseId,StartUtc:t,EndUtc:e,RoomCategoryId:this.apartmentProperties.categoryId,ProductIds:this.state.selectedProducts.map(o=>o.id),VoucherCode:this.state.couponCode||void 0,Occupancies:this.state.rooms.map(o=>({OccupancyData:o.filter(a=>a.value>0).map(a=>({AgeCategoryId:a.ageCategoryId,PersonCount:a.value}))}))});return this.state._reservationPricing=i,this.state.be_pricing=i,this.refreshUIComponents(),i}catch(t){throw console.error("Error fetching reservation pricing:",t),t}}updateDateRange(t,e){if(this.state.startDate=t,this.state.endDate=e,et.startDate=t?t.toString():null,et.endDate=e?e.toString():null,t&&e){let r=t.until(e).days;document.querySelectorAll("[data-nights-count]").forEach(s=>{s.textContent=r.toString()}),document.querySelectorAll("[data-start-date]").forEach(s=>{s.textContent=t.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"})}),document.querySelectorAll("[data-end-date]").forEach(s=>{s.textContent=e.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric"})})}return{startDate:t,endDate:e}}handleDateChange(t,e){return t&&e&&Ie.PlainDate.compare(t,e)>=0?(console.warn("Invalid date range: start date must be before end date"),!1):(this.updateDateRange(t,e),!0)}scrollToTariffsSection(){let t=document.getElementById("tariff-section");t&&setTimeout(()=>{t.scrollIntoView({behavior:"smooth",block:"start"})},300)}};function Bm(){try{let n=window.WebflowCMSData_apartment;console.log("#=> Properties",n),new Ra(n).init()}catch(n){console.error("Error initializing reservation component",n)}}window.Webflow||(window.Webflow=[]);window.Webflow.push(async()=>{Bm()});})();
|
|
8
8
|
/*! Bundled license information:
|
|
9
9
|
|
|
10
10
|
@vue/shared/dist/shared.esm-bundler.js:
|