@wernfried/daterangepicker 5.2.4 → 5.2.6
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.
- package/README.md +8 -8
- package/dist/cjs/daterangepicker.cjs +2370 -2367
- package/dist/cjs/daterangepicker.cjs.map +1 -1
- package/dist/cjs/daterangepicker.min.cjs +1 -1
- package/dist/cjs/daterangepicker.min.cjs.map +1 -1
- package/dist/esm/daterangepicker.js +11 -8
- package/dist/esm/daterangepicker.js.map +1 -1
- package/dist/esm/daterangepicker.min.js +1 -1
- package/dist/esm/daterangepicker.min.js.map +1 -1
- package/dist/global/daterangepicker.js +11 -8
- package/dist/global/daterangepicker.js.map +1 -1
- package/dist/global/daterangepicker.min.js +1 -1
- package/dist/global/daterangepicker.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("luxon");class L{#e=null;#t=null;constructor(i,e,l){if(typeof i=="string"&&document.querySelectorAll(i).length>1)throw new RangeError("Option 'element' must match to one element only");this.parentEl="body",this.element=i instanceof HTMLElement?i:document.querySelector(i),this.isInputText=this.element instanceof HTMLInputElement&&this.element.type==="text",this.#e=o.DateTime.now().startOf("day"),this.#t=o.DateTime.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initalMonth=o.DateTime.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=o.DateTime.now().minus({year:100}).year,this.maxYear=o.DateTime.now().plus({year:100}).year,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.showLabel=!this.isInputText,this.timePicker=!1;const a=new Intl.DateTimeFormat(o.DateTime.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=o.Duration.fromObject({minutes:1}),this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.isInvalidDate=null,this.isInvalidTime=null,this.isCustomDate=null,this.onOutsideClick="apply",this.opens=this.element?.classList.contains("pull-right")?"left":"right",this.drops=this.element?.classList.contains("dropup")?"up":"down",this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.weekendClasses="weekend",this.weekendDayClasses="weekend-day",this.todayClasses="today",this.altInput=null,this.altFormat=null,this.externalStyle=null,this.ranges={},this.locale={direction:"ltr",format:o.DateTime.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:o.Info.weekdays("short"),monthNames:o.Info.months("long"),firstDay:o.Info.getStartOfWeek(),durationFormat:null},this.element==null)return;this.callback=function(){},this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof e!="object"||e===null)&&(e={});let r={};const t=Array.from(this.element.attributes).filter(s=>s.name.startsWith("data-"));for(let s of t){const c=s.name.replace(/^data-/g,"").replace(/-([a-z])/g,function(g){return g[1].toUpperCase()});if(!Object.keys(this).concat(["startDate","endDate"]).includes(c)||Object.keys(e).includes(c))continue;let d=o.DateTime.fromISO(s.value);const p=["startDate","endDate","minDate","maxDate","initalMonth"].includes(c);r[c]=d.isValid&&p?d:JSON.parse(s.value)}if(e={...r,...e},typeof e.singleDatePicker=="boolean"&&(this.singleDatePicker=e.singleDatePicker),!this.singleDatePicker&&typeof e.singleMonthView=="boolean"?this.singleMonthView=e.singleMonthView:this.singleMonthView=!1,e.externalStyle!==null){const s=window.getComputedStyle(document.body);s&&typeof s[Symbol.iterator]=="function"&&[...s].some(c=>c.startsWith("--bulma-"))&&(this.externalStyle="bulma")}if(typeof e.template=="string"||e.template instanceof HTMLElement)this.container=typeof e.template=="string"?I(e.template):e.template;else{let s=['<div class="daterangepicker">','<div class="ranges"></div>','<div class="drp-calendar left">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time start-time"></tr>',this.singleMonthView?'<tr class="calendar-time end-time"></tr>':"","</tfoot>","</table>","</div>"];s.push('<div class="drp-calendar right">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",this.singleMonthView?"":'<tr class="calendar-time end-time"></tr>',"</tfoot>","</table>","</div>"),s.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?s.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):s.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),s.push("</div></div>"),e.template=s.join(""),this.container=I(e.template)}if(this.parentEl=document.querySelector(typeof e.parentEl=="string"?e.parentEl:this.parentEl),this.parentEl.appendChild(this.container),typeof e.timePicker=="boolean"&&(this.timePicker=e.timePicker),this.timePicker&&(this.locale.format=o.DateTime.DATETIME_SHORT),typeof e.locale=="object"){for(let s of["separator","applyLabel","cancelLabel","weekLabel"])typeof e.locale[s]=="string"&&(this.locale[s]=e.locale[s]);if(typeof e.locale.direction=="string"&&(["rtl","ltr"].includes(e.locale.direction)?this.locale.direction=e.locale.direction:console.error("Option 'options.locale.direction' must be 'rtl' or 'ltr'")),["string","object"].includes(typeof e.locale.format)&&(this.locale.format=e.locale.format),Array.isArray(e.locale.daysOfWeek)&&(e.locale.daysOfWeek.some(s=>typeof s!="string")?console.error("Option 'options.locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=e.locale.daysOfWeek.slice()),Array.isArray(e.locale.monthNames)&&(e.locale.monthNames.some(s=>typeof s!="string")?console.error("Option 'locale.monthNames' must be an array of strings"):this.locale.monthNames=e.locale.monthNames.slice()),typeof e.locale.firstDay=="number"&&(this.locale.firstDay=e.locale.firstDay),typeof e.locale.customRangeLabel=="string"){var h=document.createElement("textarea");h.innerHTML=e.locale.customRangeLabel;var f=h.value;this.locale.customRangeLabel=f}["string","object","function"].includes(typeof e.locale.durationFormat)&&e.locale.durationFormat!=null&&(this.locale.durationFormat=e.locale.durationFormat)}this.container.classList.add(this.locale.direction);for(let s of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel"])typeof e[s]=="boolean"&&(this[s]=e[s]);for(let s of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof e[s]=="string"?this[s]=e[s]:["weekendClasses","weekendDayClasses","todayClasses"].includes(s)&&e[s]===null&&(this[s]=e[s]);for(let s of["minYear","maxYear"])typeof e[s]=="number"&&(this[s]=e[s]);for(let s of["isInvalidDate","isInvalidTime","isCustomDate"])typeof e[s]=="function"?this[s]=e[s]:this[s]=function(){return!1};if(!this.singleDatePicker){for(let s of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof e[s])&&(o.Duration.isDuration(e[s])&&e[s].isValid?this[s]=e[s]:o.Duration.fromISO(e[s]).isValid?this[s]=o.Duration.fromISO(e[s]):typeof e[s]=="number"&&o.Duration.fromObject({seconds:e[s]}).isValid?this[s]=o.Duration.fromObject({seconds:e[s]}):e[s]===null?this[s]=null:console.error(`Option '${key}' is not valid`));this.minSpan&&this.maxSpan&&this.minSpan>this.maxSpan&&(this.minSpan=null,this.maxSpan=null,console.warn("Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'")),this.defaultSpan&&this.minSpan&&this.minSpan>this.defaultSpan?(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'")):this.defaultSpan&&this.maxSpan&&this.maxSpan<this.defaultSpan&&(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'"))}if(this.timePicker){if(["string","object","number"].includes(typeof e.timePickerStepSize)){let s;o.Duration.isDuration(e.timePickerStepSize)&&e.timePickerStepSize.isValid?s=e.timePickerStepSize:o.Duration.fromISO(e.timePickerStepSize).isValid?s=o.Duration.fromISO(e.timePickerStepSize):typeof e.timePickerStepSize=="number"&&o.Duration.fromObject({seconds:e.timePickerStepSize}).isValid?s=o.Duration.fromObject({seconds:e.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),s=this.timePickerStepSize);var n=[];for(let c of["minutes","seconds"])n.push(...[1,2,3,4,5,6,10,12,15,20,30].map(d=>o.Duration.fromObject({[c]:d})));n.push(...[1,2,3,4,6].map(c=>o.Duration.fromObject({hours:c}))),this.timePicker24Hour&&n.push(...[8,12].map(c=>o.Duration.fromObject({hours:c}))),n.some(c=>s.rescale().equals(c))?this.timePickerStepSize=s.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(s.toObject())} is not valid`)}this.maxSpan&&this.timePickerStepSize>this.maxSpan&&console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`),this.timePickerOpts={showMinutes:this.timePickerStepSize<o.Duration.fromObject({hours:1}),showSeconds:this.timePickerStepSize<o.Duration.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=o.Duration.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=o.Duration.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let s of["startDate","endDate","minDate","maxDate","initalMonth"])if(!(s==="endDate"&&this.singleDatePicker)){if(typeof e[s]=="object")o.DateTime.isDateTime(e[s])&&e[s].isValid?this[s]=e[s]:e[s]instanceof Date?this[s]=o.DateTime.fromJSDate(e[s]):e[s]===null?this[s]=null:console.error(`Option '${s}' must be a luxon.DateTime or Date or string`);else if(typeof e[s]=="string"){const c=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format);if(o.DateTime.fromISO(e[s]).isValid)this[s]=o.DateTime.fromISO(e[s]);else if(o.DateTime.fromFormat(e[s],c,{locale:o.DateTime.now().locale}).isValid)this[s]=o.DateTime.fromFormat(e[s],c,{locale:o.DateTime.now().locale});else{const d=o.DateTime.fromFormat(e[s],c,{locale:o.DateTime.now().locale}).invalidExplanation;console.error(`Option '${s}' is not a valid string: ${d}`)}}}if(this.isInputText&&this.element.value!=""){const s=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof e.startDate>"u"){const c=o.DateTime.fromFormat(this.element.value,s,{locale:o.DateTime.now().locale});c.isValid?this.#e=c:console.error(`Value "${this.element.value}" in <input> is not a valid string: ${c.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof e.startDate>"u"&&typeof e.endDate>"u"){const c=this.element.value.split(this.locale.separator);if(c.length===2){const d=o.DateTime.fromFormat(c[0],s,{locale:o.DateTime.now().locale}),p=o.DateTime.fromFormat(c[1],s,{locale:o.DateTime.now().locale});d.isValid&&p.isValid?(this.#e=d,this.#t=p):console.error(`Value in <input> is not a valid string: ${d.invalidExplanation} - ${p.invalidExplanation}`)}else console.error(`Value "${this.element.value}" in <input> is not a valid string`)}}if(this.singleDatePicker?this.#t=this.#e:this.#t<this.#e&&console.error(`Option 'endDate' ${this.#t} must not be earlier than 'startDate' ${this.#e}`),this.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day")),this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),!this.#e&&this.initalMonth)this.#t=null,this.timePicker&&console.error("Option 'initalMonth' works only with 'timePicker: false'");else{const s=this.validateInput(null,!1);if(s!=null){let c=s.startDate;if(c.length>0)if(c.some(d=>d.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#e}" violates ${c.find(d=>d.reason.startsWith("isInvalid")).reason}`);else{const d=c.filter(p=>p.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#e} to ${d}`),this.#e=d}if(!this.singleDatePicker&&(c=s.endDate.filter(d=>d.new!=null),c.length>0))if(c.some(d=>d.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#t}" violates ${c.find(d=>d.reason.startsWith("isInvalid")).reason}`);else{const d=c.filter(p=>p.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#t} to ${d}`),this.#t=d}}}if(this.singleDatePicker)if(typeof e.altInput=="string"){const s=document.querySelector(e.altInput);this.altInput=s instanceof HTMLInputElement&&s.type==="text"?s:null}else e.altInput instanceof HTMLElement&&(this.altInput=e.altInput instanceof HTMLInputElement&&e.altInput.type==="text"?e.altInput:null);else if(!this.singleDatePicker&&Array.isArray(e.altInput)&&e.altInput.length===2){this.altInput=[];for(let s of e.altInput){const c=typeof s=="string"?document.querySelector(s):s;c instanceof HTMLInputElement&&c.type==="text"&&this.altInput.push(c)}this.altInput.length!==2&&(this.altInput=null)}else e.altInput!=null&&console.warn(`Option 'altInput' ${JSON.stringify(e.altInput)} is not valid`);if(e.altInput&&["function","string"].includes(typeof e.altFormat)&&(this.altFormat=e.altFormat),typeof e.opens=="string"&&(["left","right","center"].includes(e.opens)?this.opens=e.opens:console.error("Option 'options.opens' must be 'left', 'right' or 'center'")),typeof e.drops=="string"&&(["up","down","auto"].includes(e.drops)?this.drops=e.drops:console.error("Option 'options.drops' must be 'up', 'down' or 'auto'")),Array.isArray(e.buttonClasses)?this.buttonClasses=e.buttonClasses.join(" "):typeof e.buttonClasses=="string"&&(this.buttonClasses=e.buttonClasses),typeof e.onOutsideClick=="string"&&(["cancel","apply"].includes(e.onOutsideClick)?this.onOutsideClick=e.onOutsideClick:console.error("Option 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let s=this.locale.firstDay;for(;s>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),s--}if(!this.singleDatePicker&&typeof e.ranges=="object"){for(let s in e.ranges){let c,d;if(["string","object"].includes(typeof e.ranges[s][0])&&(o.DateTime.isDateTime(e.ranges[s][0])&&e.ranges[s][0].isValid?c=e.ranges[s][0]:e.ranges[s][0]instanceof Date?c=o.DateTime.fromJSDate(e.ranges[s][0]):typeof e.ranges[s][0]=="string"&&o.DateTime.fromISO(e.ranges[s][0]).isValid?c=o.DateTime.fromISO(e.ranges[s][0]):console.error(`Option ranges['${s}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof e.ranges[s][1])&&(o.DateTime.isDateTime(e.ranges[s][1])&&e.ranges[s][1].isValid?d=e.ranges[s][1]:e.ranges[s][1]instanceof Date?d=o.DateTime.fromJSDate(e.ranges[s][1]):typeof e.ranges[s][1]=="string"&&o.DateTime.fromISO(e.ranges[s][1]).isValid?d=o.DateTime.fromISO(e.ranges[s][1]):console.error(`Option ranges['${s}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(c==null||d==null)){var h=document.createElement("textarea");h.innerHTML=s,this.ranges[h.value]=[c,d]}}var u="<ul>";for(let s in this.ranges)u+=`<li data-range-key="${s}">${s}</li>`;this.showCustomRangeLabel&&(u+=`<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`),u+="</ul>",this.container.querySelector(".ranges").prepend(I(u)),this.container.classList.add("show-ranges")}typeof l=="function"&&(this.callback=l),this.timePicker||this.container.querySelectorAll(".calendar-time").forEach(s=>{s.style.display="none"}),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.classList.add("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.classList.add("single"),this.container.querySelector(".drp-calendar.left").classList.add("single"),this.container.querySelector(".drp-calendar.left").style.display="",this.container.querySelector(".drp-calendar.right").style.display="none",!this.timePicker&&this.autoApply&&this.container.classList.add("auto-apply")),(this.singleDatePicker||!Object.keys(this.ranges).length||this.alwaysShowCalendars)&&this.container.classList.add("show-calendar"),this.container.classList.add(`opens${this.opens}`),this.container.querySelectorAll(".applyBtn, .cancelBtn").forEach(s=>{s.classList.add(...this.buttonClasses.split(" "))}),this.applyButtonClasses.length&&this.container.querySelector(".applyBtn").classList.add(...this.applyButtonClasses.split(" ")),this.cancelButtonClasses.length&&this.container.querySelector(".cancelBtn").classList.add(...this.cancelButtonClasses.split(" ")),this.container.querySelector(".applyBtn").innerHTML=this.locale.applyLabel,this.container.querySelector(".cancelBtn").innerHTML=this.locale.cancelLabel,this.addListener(".drp-calendar","click",".prev",this.clickPrev.bind(this)),this.addListener(".drp-calendar","click",".next",this.clickNext.bind(this)),this.addListener(".drp-calendar","mousedown","td.available",this.clickDate.bind(this)),this.addListener(".drp-calendar","mouseenter","td.available",this.hoverDate.bind(this)),this.addListener(".drp-calendar","change","select.yearselect,select.monthselect",this.monthOrYearChanged.bind(this)),this.addListener(".drp-calendar","change","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.addListener(".ranges","click","li",this.clickRange.bind(this)),this.addListener(".ranges","mouseenter","li",this.hoverRange.bind(this)),this.addListener(".ranges","mouseleave","li",this.leaveRange.bind(this)),this.addListener(".drp-buttons","click","button.applyBtn",this.clickApply.bind(this)),this.addListener(".drp-buttons","click","button.cancelBtn",this.clickCancel.bind(this)),this.element.matches("input")||this.element.matches("button")?(this.element.addEventListener("click",this.#a),this.element.addEventListener("focus",this.#a),this.element.addEventListener("keyup",this.#o),this.element.addEventListener("keydown",this.#h)):(this.element.addEventListener("click",this.#n),this.element.addEventListener("keydown",this.#n)),this.updateElement()}get startDate(){return this.timePicker?this.#e:this.#e.startOf("day")}get endDate(){return this.singleDatePicker?null:this.timePicker?this.#t:this.#t.endOf("day")}set startDate(i){this.#e=i}set endDate(i){this.#t=i}#i={onViolate:{type:"violate",param:(i,e)=>({...i,cancelable:!0})},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker"},onBeforeRenderCalendar:{type:"beforeRenderCalendar"},onShow:{type:"show"},onBeforeHide:{type:"beforeHide",param:{cancelable:!0}},onHide:{type:"hide"},onShowCalendar:{type:"showCalendar"},onHideCalendar:{type:"hideCalendar"},onOutsideClick:{type:"outsideClick",param:{cancelable:!0}},onDateChange:{type:"dateChange",param:i=>i},onTimeChange:{type:"timeChange",param:i=>i},onApply:{type:"apply"},onCancel:{type:"cancel"},onInputChange:{type:"inputChange"},onMonthViewChange:{type:"monthViewChange",param:(i,e)=>({left:this.leftCalendar.month.startOf("month"),right:this.singleMonthView||this.singleDatePicker?null:this.rightCalendar.month.startOf("month")})}};get events(){return this.#i}#s=this.outsideClick.bind(this);#l=this.move.bind(this);#r=i=>{const e=i.target.closest('[data-toggle="dropdown"]');e&&document.contains(e)&&this.#s(i)};#a=this.show.bind(this);#o=this.elementChanged.bind(this);#h=this.keydown.bind(this);#n=this.toggle.bind(this);setStartDate(i,e=!0){if(!this.singleDatePicker)return setRange(i,this.#t,e);const l=this.#e;let a=this.parseDate(i);if(a.equals(l))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const t=!this.#e.hasSame(a,"month");return this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),e&&this.updateView(t),r}setEndDate(i,e=!0){return this.singleDatePicker?null:setRange(this.#e,i,e)}setRange(i,e,l=!0){if(this.singleDatePicker)return;this.#t||(this.#t=this.#e);const a=[this.#e,this.#t];let r=[this.parseDate(i),this.parseDate(e)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const t=this.validateInput([r[0],r[1]],!0);if(t!=null)if(t.newDate!=null)r[0]=t.newDate.startDate,r[1]=t.newDate.endDate;else return t;const h=!this.#e.hasSame(r[0],"month")||!this.#t.hasSame(r[1],"month");return this.#e=r[0],this.#t=r[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),l&&this.updateView(h),t}parseDate(i){if(typeof i=="object"){if(o.DateTime.isDateTime(i)&&i.isValid)return i;if(i instanceof Date)return o.DateTime.fromJSDate(i);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof i=="string"){const e=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format);if(o.DateTime.fromISO(i).isValid)return o.DateTime.fromISO(i);if(o.DateTime.fromFormat(i,e,{locale:o.DateTime.now().locale}).isValid)return o.DateTime.fromFormat(i,e,{locale:o.DateTime.now().locale});{const l=o.DateTime.fromFormat(i,e,{locale:o.DateTime.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${l}`)}}}formatDate(i,e=this.locale.format){if(typeof e=="object")return i.toLocaleString(e);if(o.Settings.defaultLocale===null){const l=o.DateTime.now().locale;return i.toFormat(e,{locale:l})}else return i.toFormat(e)}updateLabel(){if(this.showLabel){let i=this.formatDate(this.#e);this.singleDatePicker||(i+=this.locale.separator,this.#t&&(i+=this.formatDate(this.#t))),this.container.querySelector(".drp-selected").innerHTML=i}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#t){this.container.querySelector(".drp-duration-label").innerHTML="";return}if(typeof this.locale.durationFormat=="function")this.container.querySelector(".drp-duration-label").innerHTML=this.locale.durationFormat(this.#e,this.#t);else{let i=this.#t.plus({milliseconds:1}).diff(this.#e).rescale().set({milliseconds:0});this.timePicker||(i=i.set({seconds:0,minutes:0,hours:0})),i=i.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.querySelector(".drp-duration-label").innerHTML=i.toHuman(this.locale.durationFormat):this.container.querySelector(".drp-duration-label").innerHTML=i.toFormat(this.locale.durationFormat)}}}validateInput(i,e=!1){let l=i==null?this.#e:i[0],a=i==null?this.#t:i[1];if(l==null)return null;let r={startDate:[]},t={old:l,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const n=this.timePickerStepSize.as("seconds");l=o.DateTime.fromSeconds(n*Math.round(l.toSeconds()/n)),t.new=l,t.new.equals(t.old)||r.startDate.push(t)}else l=l.startOf("day");const h=this.timePicker?this.timePickerStepSize.as("seconds"):o.Duration.fromObject({days:1}).as("seconds");this.minDate&&l<this.minDate?(t={old:l,reason:"minDate"},l=l.plus({seconds:Math.trunc(this.minDate.diff(l).as("seconds")/h)*h}),l<this.minDate&&(l=l.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=l,t.new.equals(t.old)||r.startDate.push(t)):this.maxDate&&l>this.maxDate&&(t={old:l,reason:"maxDate"},l=l.minus({seconds:Math.trunc(l.diff(this.maxDate).as("seconds")/h)*h}),l>this.maxDate&&(l=l.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=l,t.new.equals(t.old)||r.startDate.push(t));let f=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&f.push("minute"),this.timePickerOpts.showSeconds&&f.push("second"),this.timePicker24Hour||f.push("ampm")),this.isInvalidDate(l)&&r.startDate.push({old:l,reason:"isInvalidDate"}),this.timePicker)for(let n of f)this.isInvalidTime(l,n,"start")&&r.startDate.push({old:l,reason:"isInvalidTime",unit:n});if(this.singleDatePicker){if(r.startDate.length==0)return null;if(e){let n={startDate:l};const u=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:n});return u.defaultPrevented&&(r.newDate=u.newDate),r}else return r}if(a==null)return null;if(r.endDate=[],t={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const n=this.timePickerStepSize.as("seconds");a=o.DateTime.fromSeconds(n*Math.round(a.toSeconds()/n)),t.new=a,t.new.equals(t.old)||r.endDate.push(t)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(t={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/h)*h}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t)):this.minDate&&a<this.minDate&&(t={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/h)*h}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t)),this.maxSpan){const n=l.plus(this.maxSpan);a>n&&(t={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(n.diff(a).as("seconds")/h)*h}),a>n&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t))}if(this.minSpan){const n=l.plus(this.defaultSpan??this.minSpan);a<n&&(t={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(n.diff(a).as("seconds")/h)*h}),a<n&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t))}if(this.isInvalidDate(a)&&r.endDate.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let n of f)this.isInvalidTime(a,n,"end")&&r.endDate.push({old:a,reason:"isInvalidTime",unit:n});if(r.startDate.length==0&&r.endDate.length==0)return null;if(e){let n={startDate:l,endDate:a};const u=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:n});return u.defaultPrevented&&(r.newDate=u.newDate),r}else return r}updateView(i){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.container.querySelector(".calendar-time.end-time select").disabled=!this.#t,this.container.querySelector(".calendar-time.end-time select").classList.toggle("disabled",!this.#t)),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(i),this.setApplyBtnState()}updateMonthsInView(){if(this.#t){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month"))&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#e.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#t.hasSame(this.#e,"month")?this.rightCalendar.month=this.#t.startOf("month"):this.rightCalendar.month=this.#e.startOf("month").plus({month:1}))}else!this.#e&&this.initalMonth?(this.leftCalendar.month=this.initalMonth,this.singleMonthView||(this.rightCalendar.month=this.initalMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#e,"month")&&!this.rightCalendar.month.hasSame(this.#e,"month")&&(this.leftCalendar.month=this.#e.startOf("month"),this.rightCalendar.month=this.#e.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(i){if(this.timePicker){var e,l,a;this.#t?(e=parseInt(this.container.querySelector(".start-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10)),l=0,this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10)))):(e=parseInt(this.container.querySelector(".end-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10)),l=0,this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:e,minute:l,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:e,minute:l,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),i&&this.triggerEvent(this.#i.onMonthViewChange),this.container.querySelectorAll(".ranges li").forEach(r=>{r.classList.remove("active")}),this.#t!=null&&this.calculateChosenLabel()}renderCalendar(i){if(i==="right"&&this.singleMonthView)return;var t=i==="left"?this.leftCalendar:this.rightCalendar;t.month==null&&!this.#e&&this.initalMonth&&(t.month=this.initalMonth.startOf("month"));const e=t.month.startOf("month"),l=t.month.endOf("month").startOf("day");var a=t.month.startOf("month").minus({day:1});const r={hour:t.month.hour,minute:t.month.minute,second:t.month.second};var t=[];t.firstDay=e,t.lastDay=l;for(var h=0;h<6;h++)t[h]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let y=0,D=-1;y<42;y++,a=a.plus({day:1}))y%7===0&&D++,t[D][y%7]=a.set(r);i==="left"?this.leftCalendar.calendar=t:this.rightCalendar.calendar=t;var f=i==="left"?this.minDate:this.#e,n=this.maxDate,u="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(u+="<th></th>"),(!f||f<t.firstDay)&&(!this.linkedCalendars||i==="left")?u+='<th class="prev available"><span></span></th>':u+="<th></th>";var s=`${this.locale.monthNames[t.firstDay.month-1]} ${t.firstDay.year}`;if(this.showDropdowns){const y=(n&&n.year)??this.maxYear,D=(f&&f.year)??this.minYear;let P=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var c=`${P}<select class="monthselect">`,d=1;d<=12;d++)c+=`<option value="${d}"${d===t.firstDay.month?" selected":""}`,(f&&t.firstDay.set({month:d})<f.startOf("month")||n&&t.firstDay.set({month:d})>n.endOf("month"))&&(c+=" disabled"),c+=`>${this.locale.monthNames[d-1]}</option>`;c+="</select>",this.externalStyle==="bulma"&&(c+="</div>"),P=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var p=`${P}<select class="yearselect">`,g=D;g<=y;g++)p+=`<option value="${g}"${g===t.firstDay.year?" selected":""}>${g}</option>`;p+="</select>",this.externalStyle==="bulma"&&(p+="</div>"),s=c+p}u+='<th colspan="5" class="month">'+s+"</th>",(!n||n>t.lastDay.endOf("day"))&&(!this.linkedCalendars||i==="right"||this.singleDatePicker||this.singleMonthView)?u+='<th class="next available"><span></span></th>':u+="<th></th>",u+="</tr>",u+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(u+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[y,D]of this.locale.daysOfWeek.entries())u+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&o.Info.getWeekendWeekdays().includes(y+1)&&(u+=` class="${this.weekendDayClasses}"`),u+=`>${D}</th>`;if(u+="</tr>",this.container.querySelector(`.drp-calendar.${i} .calendar-table thead`).innerHTML=u,u="",this.#t==null&&this.maxSpan){var S=this.#e.plus(this.maxSpan).endOf("day");(!n||S<n)&&(n=S)}var C;this.#t==null&&this.minSpan&&(C=this.#e.plus(this.minSpan).startOf("day"));for(let y=0;y<6;y++){u+="<tr>",this.showISOWeekNumbers?u+=`<td class="week">${t[y][0].weekNumber}</td>`:this.showWeekNumbers&&(u+=`<td class="week">${t[y][0].localWeekNumber}</td>`);for(let D=0;D<7;D++){var k=[];this.todayClasses&&this.todayClasses.length&&t[y][D].hasSame(o.DateTime.now(),"day")&&k.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&o.Info.getWeekendWeekdays().includes(t[y][D].weekday)&&k.push(this.weekendClasses),t[y][D].month!=t[1][1].month&&k.push("off","ends"),this.minDate&&t[y][D].startOf("day")<this.minDate.startOf("day")&&k.push("off","disabled"),n&&t[y][D].startOf("day")>n.startOf("day")&&k.push("off","disabled"),C&&t[y][D].startOf("day")>this.#e.startOf("day")&&t[y][D].startOf("day")<C.startOf("day")&&k.push("off","disabled"),this.isInvalidDate(t[y][D])&&k.push("off","disabled"),this.#e!=null&&t[y][D].hasSame(this.#e,"day")&&k.push("active","start-date"),this.#t!=null&&t[y][D].hasSame(this.#t,"day")&&k.push("active","end-date"),this.#t!=null&&t[y][D]>this.#e&&t[y][D]<this.#t&&k.push("in-range");var w=this.isCustomDate(t[y][D]);w!==!1&&(typeof w=="string"?k.push(w):k.push(...w)),k.includes("disabled")||k.push("available"),u+=`<td class="${k.join(" ")}" data-title="r${y}c${D}">${t[y][D].day}</td>`}u+="</tr>"}this.container.querySelector(`.drp-calendar.${i} .calendar-table tbody`).innerHTML=u}renderTimePicker(i){if(i==="end"&&!this.#t)return;var e,l,a,r=this.maxDate;let t="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(t+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#e.plus(this.maxSpan)<this.maxDate)&&(r=this.#e.plus(this.maxSpan)),this.minSpan&&i==="end"&&(l=this.#e.plus(this.defaultSpan??this.minSpan)),i==="start")e=this.#e,a=this.minDate;else if(i==="end"){e=this.#t,a=this.#e;let d=this.container.querySelector(".drp-calendar .calendar-time.end-time");d.innerHTML!=""&&(e=e.set({hour:isNaN(e.hour)?d.querySelector(".hourselect option:selected").value:e.hour,minute:isNaN(e.minute)?d.querySelector(".minuteselect option:selected").value:e.minute,second:isNaN(e.second)?d.querySelector(".secondselect option:selected").value:e.second})),e<this.#e&&(e=this.#e),r&&e>r&&(e=r)}t+='<th colspan="7">',this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="hourselect">';const h=e.toFormat("a",{locale:"en-US"});let f=0;this.timePicker24Hour||(f=h==="AM"?1:13);for(var n=f;n<=f+23;n+=this.timePickerOpts.hourStep){let d=e.set({hour:n%24}),p=!1;if(a&&d.set({minute:59})<a&&(p=!0),r&&d.set({minute:0})>r&&(p=!0),l&&d.endOf("hour")<l&&(p=!0),!p&&this.isInvalidTime(d,this.singleDatePicker?null:i,"hour")&&(p=!0),this.timePicker24Hour)!p&&n==e.hour?t+=`<option value="${n}" selected>${n}</option>`:p?t+=`<option value="${n}" disabled class="disabled">${n}</option>`:t+=`<option value="${n}">${n}</option>`;else{const g=o.DateTime.fromFormat(`${n%24}`,"H").toFormat("h"),S=o.DateTime.fromFormat(`${n%24}`,"H").toFormat("a",{locale:"en-US"});h==S?!p&&n==e.hour?t+=`<option ampm="${S}" value="${n%24}" selected>${g}</option>`:p?t+=`<option ampm="${S}" value="${n%24}" disabled class="disabled">${g}</option>`:t+=`<option ampm="${S}" value="${n%24}">${g}</option>`:t+=`<option ampm="${S}" hidden="hidden" value="${n%24}">${g}</option>`}}if(t+="</select>",this.externalStyle==="bulma"&&(t+="</div>"),this.timePickerOpts.showMinutes){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="minuteselect">';for(var n=0;n<60;n+=this.timePickerOpts.minuteStep){var u=n<10?"0"+n:n;let p=e.set({minute:n}),g=!1;a&&p.set({second:59})<a&&(g=!0),r&&p.set({second:0})>r&&(g=!0),l&&p.endOf("minute")<l&&(g=!0),!g&&this.isInvalidTime(p,this.singleDatePicker?null:i,"minute")&&(g=!0),e.minute==n&&!g?t+=`<option value="${n}" selected>${u}</option>`:g?t+=`<option value="${n}" disabled class="disabled">${u}</option>`:t+=`<option value="${n}">${u}</option>`}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(this.timePickerOpts.showSeconds){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="secondselect">';for(var n=0;n<60;n+=this.timePickerOpts.secondStep){var u=n<10?"0"+n:n;let g=e.set({second:n}),S=!1;a&&g<a&&(S=!0),r&&g>r&&(S=!0),l&&g<l&&(S=!0),!S&&this.isInvalidTime(g,this.singleDatePicker?null:i,"second")&&(S=!0),e.second==n&&!S?t+=`<option value="${n}" selected>${u}</option>`:S?t+=`<option value="${n}" disabled class="disabled">${u}</option>`:t+=`<option value="${n}">${u}</option>`}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="ampmselect">';var s="",c="";let d=!1;a&&e.startOf("day")<a&&(d=!0),r&&e.endOf("day")>r&&(d=!0),l&&e.startOf("day")<l&&(d=!0),d?(s=' disabled class="disabled "',c=' disabled class="disabled"'):this.isInvalidTime(e,this.singleDatePicker?null:i,"ampm")&&(e.toFormat("a",{locale:"en-US"})==="AM"?c=' disabled class="disabled"':s=' disabled class="disabled"'),t+=`<option value="AM"${s}`,e.toFormat("a",{locale:"en-US"})==="AM"&&(t+=" selected"),t+=`>${o.Info.meridiems()[0]}</option><option value="PM"${c}`,e.toFormat("a",{locale:"en-US"})==="PM"&&(t+=" selected"),t+=`>${o.Info.meridiems()[1]}</option>`,t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}t+="</div></th>",this.container.querySelector(`.drp-calendar .calendar-time.${i}-time`).innerHTML=t}setApplyBtnState(){const i=this.singleDatePicker||this.#t&&this.#e<=this.#t;this.container.querySelector("button.applyBtn").disabled=!i}move(){let i={top:0,left:0},e,l,a=this.drops,r=window.innerWidth;switch(this.parentEl.matches("body")||(i={top:v(this.parentEl).top-this.parentEl.scrollTop(),left:v(this.parentEl).left-this.parentEl.scrollLeft()},r=this.parentEl[0].clientWidth+v(this.parentEl).left),this.drops){case"auto":e=v(this.element).top+b(this.element)-i.top,e+b(this.container)>=this.parentEl.scrollHeight&&(e=v(this.element).top-b(this.container)-i.top,a="up");break;case"up":e=v(this.element).top-b(this.container)-i.top;break;case"down":e=v(this.element).top+b(this.element)-i.top;break;default:console.error(`Option drops '${a}' not defined`);break}for(const[h,f]of Object.entries({top:0,left:0,right:"auto"}))this.container.style[h]=typeof f=="number"&&f>0?`${f}px`:f;const t=T(this.container);switch(this.container.classList.toggle("drop-up",a==="up"),this.opens){case"left":const h=r-v(this.element).left-T(this.element);if(t+h>window.innerWidth)for(const[f,n]of Object.entries({top:e,right:"auto",left:9}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else for(const[f,n]of Object.entries({top:e,right:h,left:"auto"}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;break;case"center":if(l=v(this.element).left-i.left+T(this.element)/2-t/2,l<0)for(const[f,n]of Object.entries({top:e,right:"auto",left:9}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else if(l+t>window.innerWidth)for(const[f,n]of Object.entries({top:e,left:"auto",right:0}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else for(const[f,n]of Object.entries({top:e,left:l,right:"auto"}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;break;case"right":if(l=v(this.element).left-i.left,l+t>window.innerWidth)for(const[f,n]of Object.entries({top:e,left:"auto",right:0}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else for(const[f,n]of Object.entries({top:`${e}px`,left:l,right:"auto"}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;break;default:console.error(`Option opens '${this.opens}' not defined`);break}}show(){this.isShowing||(document.addEventListener("mousedown",this.#s),document.addEventListener("touchend",this.#s),document.addEventListener("click",this.#r),document.addEventListener("focusin",this.#s),window.addEventListener("resize",this.#l),this.oldStartDate=this.#e,this.oldEndDate=this.#t,this.updateView(!1),this.container.style.display="block",this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){!this.isShowing||(this.#t||(this.#e=this.oldStartDate,this.#t=this.oldEndDate),(!this.#e.equals(this.oldStartDate)||!this.#t.equals(this.oldEndDate))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented)||(document.removeEventListener("mousedown",this.#s),document.removeEventListener("touchend",this.#s),document.removeEventListener("focusin",this.#s),document.removeEventListener("click",this.#r),window.removeEventListener("resize",this.#l),this.container.style.display="none",this.triggerEvent(this.#i.onHide),this.isShowing=!1)}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.classList.add("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.classList.remove("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(i){const e=i.target;function l(r,t){let h=r.parentElement;for(;h;){if(h==t)return h;h=h.parentElement}return null}i.type==="focusin"||l(e,this.element)||l(e,this.container)||e.closest(".calendar-table")||this.triggerEvent(this.#i.onOutsideClick).defaultPrevented||(this.onOutsideClick==="cancel"&&(this.#e=this.oldStartDate,this.#t=this.oldEndDate),this.hide())}clickPrev(i){i.target.closest(".drp-calendar").classList.contains("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(i){i.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(i){if(!i.target.classList.contains("available"))return;let e=i.target.dataset.title;const l=e.substring(1,2),a=e.substring(3,4);var t=i.target(closest,".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[l][a]:this.rightCalendar.calendar[l][a];const h=this.leftCalendar,f=this.rightCalendar,n=this.#e,u=this.initalMonth;this.#t||this.container.querySelectorAll(".drp-calendar tbody td").forEach(s=>{if(s.classList.contains("week"))return;const c=s.dataset.title,d=c.substring(1,2),p=c.substring(3,4),S=s.closest(".drp-calendar").classList.contains("left")?h.calendar[d][p]:f.calendar[d][p];!n&&u?s.classList.remove("in-range"):s.classList.toggle("in-range",S>n&&S<t||S.hasSame(t,"day"))})}hoverRange(i){const e=i.target.dataset.rangeKey,l=[this.#e,this.#t],a=this.ranges[e]??[this.#e,this.#t],r=this.leftCalendar,t=this.rightCalendar;this.container.querySelectorAll(".drp-calendar tbody td").forEach(h=>{if(h.classList.contains("week"))return;const f=h.dataset.ttitle,n=f.substring(1,2),u=f.substring(3,4),c=h.closest(".drp-calendar").classList.contains("left")?r.calendar[n][u]:t.calendar[n][u];h.classList.toggle("start-hover",c.hasSame(a[0],"day")),h.classList.toggle("start-date",c.hasSame(l[0],"day")),h.classList.toggle("end-hover",c.hasSame(a[1],"day")),h.classList.toggle("end-date",l[1]!=null&&c.hasSame(l[1],"day")),h.classList.toggle("range-hover",c.startOf("day")>=a[0].startOf("day")&&c.startOf("day")<=a[1].startOf("day")),h.classList.toggle("in-range",c.startOf("day")>=l[0].startOf("day")&&l[1]!=null&&c.startOf("day")<=l[1].startOf("day"))})}leaveRange(){this.container.querySelectorAll(".drp-calendar tbody td").forEach(i=>{i.classList.contains("week")||(i.classList.remove("start-hover"),i.classList.remove("end-hover"),i.classList.remove("range-hover"))})}clickRange(i){let e=i.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{let l=this.ranges[e];const a=!this.#e.hasSame(l[0],"month")||!this.#t.hasSame(l[1],"month");this.#e=l[0],this.#t=l[1],this.timePicker||(this.#e.startOf("day"),this.#t.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented&&this.updateView(a),this.clickApply()}}clickDate(i){if(!i.target.classList.contains("available"))return;let e=i.target.dataset.title,l=e.substring(1,2),a=e.substring(3,4),t=i.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[l][a]:this.rightCalendar.calendar[l][a],h;if(this.#t||!this.#e||t<this.#e.startOf("day")){if(this.timePicker){let f=parseInt(this.container.querySelector(".start-time .hourselect").value,10);isNaN(f)&&(f=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10));let n=0;this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10)));let u=0;this.timePickerOpts.showSeconds&&(u=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(u)&&(u=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10))),t=t.set({hour:f,minute:n,second:u})}else t=t.startOf("day");this.#t=null,this.#e=t,h="start"}else if(!this.#t&&t<this.#e)this.#t=this.#e,h="end";else{if(this.timePicker){let f=parseInt(this.container.querySelector(".end-time .hourselect").value,10);isNaN(f)&&(f=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10));let n=0;this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10)));let u=0;this.timePickerOpts.showSeconds&&(u=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(u)&&(u=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10))),t=t.set({hour:f,minute:n,second:u})}else t=t.endOf("day");this.#t=t,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),h="end"}this.singleDatePicker&&(this.#t=this.#e,!this.timePicker&&this.autoApply&&this.clickApply(),h=null),this.updateView(!1),i.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,{side:h})}calculateChosenLabel(){if(Object.keys(this.ranges).length===0)return;let i=!0,e=this.timePicker?"hour":"day";this.timePicker&&(this.timePickerOpts.showMinutes?e="minute":this.timePickerOpts.showSeconds&&(e="second"));for(const[l,[a,r]]of Object.entries(this.ranges))if(this.#e.startOf(e).equals(a.startOf(e))&&this.#t.startOf(e).equals(r.startOf(e))){i=!1;const t=this.container.querySelector(`.ranges li[data-range-key="${l}"]`);this.chosenLabel=l,t.classList.add("active");break}if(i){if(this.showCustomRangeLabel){const l=this.container.querySelector(".ranges li:last-child");this.chosenLabel=l.dataset.rangeKey,l.classList.add("active")}else this.chosenLabel=null;this.showCalendars()}}timeChanged(i){const e=i.target.closest(".calendar-time"),l=e.classList.contains("start-time")?"start":"end";var a=parseInt(e.querySelector(".hourselect").value,10);if(isNaN(a)&&(a=parseInt(e.querySelector(".hourselect option:last-child").value,10)),!this.timePicker24Hour){const h=e.querySelector(".ampmselect").value;if(h==null&&e.querySelector(".ampmselect option:last-child").value,h!=o.DateTime.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){e.querySelectorAll(".hourselect > option").forEach(n=>{n.hidden=!n.hidden});const f=o.DateTime.fromFormat(`${a}`,"H").toFormat("h");a=o.DateTime.fromFormat(`${f}${h}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(e.querySelector(".minuteselect").value,10),isNaN(r)&&(r=parseInt(e.querySelector(".minuteselect option:last-child").value,10)));var t=0;this.timePickerOpts.showSeconds&&(t=parseInt(e.querySelector(".secondselect").value,10),isNaN(t)&&(t=parseInt(e.querySelector(".secondselect option:last-child").value,10))),l==="start"?(this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:t})),this.singleDatePicker?this.#t=this.#e:this.#t&&this.#t.hasSame(this.#e,"day")&&this.#t<this.#e&&(this.#t=this.#e)):this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:t})),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,{side:this.singleDatePicker?null:l})}monthOrYearChanged(i){const e=i.target.closest(".drp-calendar").classList.contains("left"),l=e?"left":"right",a=this.container.querySelector(`.drp-calendar.${l}`);let r=parseInt(a.querySelector(".monthselect").value,10),t=a.querySelector(".yearselect").value,h=!1;e||(t<this.#e.year||t==this.#e.year&&r<this.#e.month)&&(r=this.#e.month,t=this.#e.year),this.minDate&&(t<this.minDate.year||t==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,t=this.minDate.year),this.maxDate&&(t>this.maxDate.year||t==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,t=this.maxDate.year),e?(h=!o.DateTime.fromObject({year:t,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:t,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(h=!o.DateTime.fromObject({year:t,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:t,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(h)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#e=this.oldStartDate,this.#t=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.isInputText||!this.element.value.length)return;const i=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format),e=this.element.value.split(this.locale.separator);let l=!1;if(this.singleDatePicker){let a=o.DateTime.fromFormat(this.element.value,i,{locale:o.DateTime.now().locale});const r=this.#e;if(!a.isValid||r.equals(a))return;const t=this.validateInput([a,null],!0);if(t!=null)if(t.newDate!=null)a=t.newDate.startDate;else return;l=!this.#e.hasSame(a,"month"),this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else if(!this.singleDatePicker&&e.length===2){const a=[0,1].map(h=>o.DateTime.fromFormat(e[h],i,{locale:o.DateTime.now().locale})),r=[this.#e,this.#t];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const t=this.validateInput([a[0],a[1]],!0);if(t!=null)if(t.newDate!=null)a[0]=t.newDate.startDate,a[1]=t.newDate.endDate;else return;l=!this.#e.hasSame(a[0],"month")||!this.#t.hasSame(a[1],"month"),this.#e=a[0],this.#t=a[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else return;this.updateView(l),this.updateElement(),this.triggerEvent(this.#i.onInputChange)}keydown(i){[9,11].includes(i.keyCode)&&this.hide(),i.keyCode===27&&(i.preventDefault(),i.stopPropagation(),this.hide())}updateElement(){if(!(this.#e==null&&this.initalMonth))if(this.isInputText){let i=this.formatDate(this.#e);this.singleDatePicker||(i+=this.locale.separator,this.#t&&(i+=this.formatDate(this.#t))),this.updateAltInput(),i!==this.element.value&&(this.element.value=i,this.element.dispatchEvent(new Event("change",{bubbles:!0})))}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.altFormat==null){let i="day";this.timePicker&&(this.timePickerOpts.showSeconds?i="second":this.timePickerOpts.showMinutes?i="minute":i="hour");const e=this.#e.toISO({format:"basic",precision:i,includeOffset:!1});if((this.singleDatePicker?this.altInput:this.altInput[0]).value=e,!this.singleDatePicker&&this.#t){const l=this.#t.toISO({format:"basic",precision:i,includeOffset:!1});this.altInput[1].value=l}}else{const i=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);if((this.singleDatePicker?this.altInput:this.altInput[0]).value=i,!this.singleDatePicker&&this.#t){const e=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);this.altInput[1].value=e}}}remove(){this.element.removeEventListener("click",this.#a),this.element.removeEventListener("focus",this.#a),this.element.removeEventListener("keyup",this.#o),this.element.removeEventListener("keydown",this.#h),this.element.removeEventListener("click",this.#n),this.element.removeEventListener("keydown",this.#n),this.container.remove()}triggerEvent(i,...e){if(e.length===0){const l=new x(this,i);return this.element.dispatchEvent(l),l}else{const l=new x(this,i,...e);return this.element.dispatchEvent(l),l}}addListener(i,e,l,a){this.container.querySelectorAll(i).forEach(r=>{r.addEventListener(e,function(t){const h=t.target.closest(l);h&&r.contains(h)&&a.call(h,t)})})}}function I(m){const i=document.createElement("template");return i.innerHTML=m.trim(),i.content.firstElementChild}class x extends Event{#e;constructor(i,e,l={}){let a={};e.param&&(a=typeof e.param=="function"?e.param():e.param),a={...a,...l},super(e.type,a),this.#e=i;for(const[r,t]of Object.entries(a))Object.getOwnPropertyNames(Event.prototype).includes(r)||(this[r]=t)}get picker(){return this.#e}}function v(m){const i=m.getBoundingClientRect();return{top:i.top+window.scrollY,left:i.left+window.scrollX}}function T(m,i=!1){if(!i)return m.offsetWidth;const e=getComputedStyle(m);return m.offsetWidth+parseFloat(e.marginLeft)+parseFloat(e.marginRight)}function b(m,i=!1){if(!i)return m.offsetHeight;const e=getComputedStyle(m);return m.offsetHeight+parseFloat(e.marginTop)+parseFloat(e.marginBottom)}function O(m,i,e){return typeof m=="string"?O(document.querySelectorAll(m),i,e):(m instanceof HTMLElement&&(m=[m]),(m instanceof NodeList||m instanceof HTMLCollection)&&(m=Array.from(m)),m==null?new L(null,i||{},e):(m.forEach(l=>{l._daterangepicker&&typeof l._daterangepicker.remove=="function"&&l._daterangepicker.remove(),l._daterangepicker=new L(l,i||{},e)}),m.length===1?m[0]:m))}function E(m){return typeof m=="string"&&(m=document.querySelector(m)),m instanceof HTMLElement?m._daterangepicker:void 0}window.jQuery?.fn&&(jQuery.fn.daterangepicker=function(m,i){return this.each(function(){O(this,m,i)})});function $(m){m?.fn&&(m.fn.daterangepicker=function(i,e){return this.each(function(){O(this,i,e)})})}Object.defineProperty(window,"jQuery",{configurable:!0,set(m){this._jQuery=m,$(m)},get(){return this._jQuery}}),exports.DateRangePicker=L,exports.daterangepicker=O,exports.getDateRangePicker=E;
|
|
1
|
+
"use strict";var o=require("luxon");class L{#e=null;#t=null;constructor(i,e,l){if(typeof i=="string"&&document.querySelectorAll(i).length>1)throw new RangeError("Option 'element' must match to one element only");this.parentEl="body",this.element=i instanceof HTMLElement?i:document.querySelector(i),this.isInputText=this.element instanceof HTMLInputElement&&this.element.type==="text",this.#e=o.DateTime.now().startOf("day"),this.#t=o.DateTime.now().plus({day:1}).startOf("day"),this.minDate=null,this.maxDate=null,this.maxSpan=null,this.minSpan=null,this.defaultSpan=null,this.initalMonth=o.DateTime.now().startOf("month"),this.autoApply=!1,this.singleDatePicker=!1,this.singleMonthView=!1,this.showDropdowns=!1,this.minYear=o.DateTime.now().minus({year:100}).year,this.maxYear=o.DateTime.now().plus({year:100}).year,this.showWeekNumbers=!1,this.showISOWeekNumbers=!1,this.showCustomRangeLabel=!0,this.showLabel=!this.isInputText,this.timePicker=!1;const a=new Intl.DateTimeFormat(o.DateTime.now().locale,{hour:"numeric"}).resolvedOptions();if(this.timePicker24Hour=!a.hour12,this.timePickerStepSize=o.Duration.fromObject({minutes:1}),this.linkedCalendars=!0,this.autoUpdateInput=!0,this.alwaysShowCalendars=!1,this.isInvalidDate=null,this.isInvalidTime=null,this.isCustomDate=null,this.onOutsideClick="apply",this.opens=this.element?.classList.contains("pull-right")?"left":"right",this.drops=this.element?.classList.contains("dropup")?"up":"down",this.buttonClasses="btn btn-sm",this.applyButtonClasses="btn-primary",this.cancelButtonClasses="btn-default",this.weekendClasses="weekend",this.weekendDayClasses="weekend-day",this.todayClasses="today",this.altInput=null,this.altFormat=null,this.externalStyle=null,this.ranges={},this.locale={direction:"ltr",format:o.DateTime.DATE_SHORT,separator:" - ",applyLabel:"Apply",cancelLabel:"Cancel",weekLabel:"W",customRangeLabel:"Custom Range",daysOfWeek:o.Info.weekdays("short"),monthNames:o.Info.months("long"),firstDay:o.Info.getStartOfWeek(),durationFormat:null},this.element==null)return;this.callback=null,this.isShowing=!1,this.leftCalendar={},this.rightCalendar={},(typeof e!="object"||e===null)&&(e={});let r={};const t=Array.from(this.element.attributes).filter(s=>s.name.startsWith("data-"));for(let s of t){const c=s.name.replace(/^data-/g,"").replace(/-([a-z])/g,function(g){return g[1].toUpperCase()});if(!Object.keys(this).concat(["startDate","endDate"]).includes(c)||Object.keys(e).includes(c))continue;let d=o.DateTime.fromISO(s.value);const p=["startDate","endDate","minDate","maxDate","initalMonth"].includes(c);r[c]=d.isValid&&p?d:JSON.parse(s.value)}if(e={...r,...e},typeof e.singleDatePicker=="boolean"&&(this.singleDatePicker=e.singleDatePicker),!this.singleDatePicker&&typeof e.singleMonthView=="boolean"?this.singleMonthView=e.singleMonthView:this.singleMonthView=!1,e.externalStyle!==null){const s=window.getComputedStyle(document.body);s&&typeof s[Symbol.iterator]=="function"&&[...s].some(c=>c.startsWith("--bulma-"))&&(this.externalStyle="bulma")}if(typeof e.template=="string"||e.template instanceof HTMLElement)this.container=typeof e.template=="string"?I(e.template):e.template;else{let s=['<div class="daterangepicker">','<div class="ranges"></div>','<div class="drp-calendar left">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",'<tr class="calendar-time start-time"></tr>',this.singleMonthView?'<tr class="calendar-time end-time"></tr>':"","</tfoot>","</table>","</div>"];s.push('<div class="drp-calendar right">','<table class="calendar-table">',"<thead></thead>","<tbody></tbody>","<tfoot>",this.singleMonthView?"":'<tr class="calendar-time end-time"></tr>',"</tfoot>","</table>","</div>"),s.push('<div class="drp-buttons">','<div class="drp-duration-label"></div>','<div class="drp-selected"></div>'),this.externalStyle==="bulma"?s.push('<div class="buttons">','<button class="cancelBtn button is-small" type="button"></button>','<button class="applyBtn button is-small" disabled type="button"></button>',"</div>"):s.push("<div>",'<button class="cancelBtn" type="button"></button>','<button class="applyBtn" disabled type="button"></button>',"</div>"),s.push("</div></div>"),e.template=s.join(""),this.container=I(e.template)}if(this.parentEl=document.querySelector(typeof e.parentEl=="string"?e.parentEl:this.parentEl),this.parentEl.appendChild(this.container),typeof e.timePicker=="boolean"&&(this.timePicker=e.timePicker),this.timePicker&&(this.locale.format=o.DateTime.DATETIME_SHORT),typeof e.locale=="object"){for(let s of["separator","applyLabel","cancelLabel","weekLabel"])typeof e.locale[s]=="string"&&(this.locale[s]=e.locale[s]);if(typeof e.locale.direction=="string"&&(["rtl","ltr"].includes(e.locale.direction)?this.locale.direction=e.locale.direction:console.error("Option 'options.locale.direction' must be 'rtl' or 'ltr'")),["string","object"].includes(typeof e.locale.format)&&(this.locale.format=e.locale.format),Array.isArray(e.locale.daysOfWeek)&&(e.locale.daysOfWeek.some(s=>typeof s!="string")?console.error("Option 'options.locale.daysOfWeek' must be an array of strings"):this.locale.daysOfWeek=e.locale.daysOfWeek.slice()),Array.isArray(e.locale.monthNames)&&(e.locale.monthNames.some(s=>typeof s!="string")?console.error("Option 'locale.monthNames' must be an array of strings"):this.locale.monthNames=e.locale.monthNames.slice()),typeof e.locale.firstDay=="number"&&(this.locale.firstDay=e.locale.firstDay),typeof e.locale.customRangeLabel=="string"){var h=document.createElement("textarea");h.innerHTML=e.locale.customRangeLabel;var f=h.value;this.locale.customRangeLabel=f}["string","object","function"].includes(typeof e.locale.durationFormat)&&e.locale.durationFormat!=null&&(this.locale.durationFormat=e.locale.durationFormat)}this.container.classList.add(this.locale.direction);for(let s of["timePicker24Hour","showWeekNumbers","showISOWeekNumbers","showDropdowns","linkedCalendars","showCustomRangeLabel","alwaysShowCalendars","autoApply","autoUpdateInput","showLabel"])typeof e[s]=="boolean"&&(this[s]=e[s]);for(let s of["applyButtonClasses","cancelButtonClasses","weekendClasses","weekendDayClasses","todayClasses"])typeof e[s]=="string"?this[s]=e[s]:["weekendClasses","weekendDayClasses","todayClasses"].includes(s)&&e[s]===null&&(this[s]=e[s]);for(let s of["minYear","maxYear"])typeof e[s]=="number"&&(this[s]=e[s]);for(let s of["isInvalidDate","isInvalidTime","isCustomDate"])typeof e[s]=="function"?this[s]=e[s]:this[s]=function(){return!1};if(!this.singleDatePicker){for(let s of["minSpan","maxSpan","defaultSpan"])["string","number","object"].includes(typeof e[s])&&(o.Duration.isDuration(e[s])&&e[s].isValid?this[s]=e[s]:o.Duration.fromISO(e[s]).isValid?this[s]=o.Duration.fromISO(e[s]):typeof e[s]=="number"&&o.Duration.fromObject({seconds:e[s]}).isValid?this[s]=o.Duration.fromObject({seconds:e[s]}):e[s]===null?this[s]=null:console.error(`Option '${key}' is not valid`));this.minSpan&&this.maxSpan&&this.minSpan>this.maxSpan&&(this.minSpan=null,this.maxSpan=null,console.warn("Ignore option 'minSpan' and 'maxSpan', because 'minSpan' must be smaller than 'maxSpan'")),this.defaultSpan&&this.minSpan&&this.minSpan>this.defaultSpan?(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be greater than 'minSpan'")):this.defaultSpan&&this.maxSpan&&this.maxSpan<this.defaultSpan&&(this.defaultSpan=null,console.warn("Ignore option 'defaultSpan', because 'defaultSpan' must be smaller than 'maxSpan'"))}if(this.timePicker){if(["string","object","number"].includes(typeof e.timePickerStepSize)){let s;o.Duration.isDuration(e.timePickerStepSize)&&e.timePickerStepSize.isValid?s=e.timePickerStepSize:o.Duration.fromISO(e.timePickerStepSize).isValid?s=o.Duration.fromISO(e.timePickerStepSize):typeof e.timePickerStepSize=="number"&&o.Duration.fromObject({seconds:e.timePickerStepSize}).isValid?s=o.Duration.fromObject({seconds:e.timePickerStepSize}):(console.error("Option 'timePickerStepSize' is not valid"),s=this.timePickerStepSize);var n=[];for(let c of["minutes","seconds"])n.push(...[1,2,3,4,5,6,10,12,15,20,30].map(d=>o.Duration.fromObject({[c]:d})));n.push(...[1,2,3,4,6].map(c=>o.Duration.fromObject({hours:c}))),this.timePicker24Hour&&n.push(...[8,12].map(c=>o.Duration.fromObject({hours:c}))),n.some(c=>s.rescale().equals(c))?this.timePickerStepSize=s.rescale():console.error(`Option 'timePickerStepSize' ${JSON.stringify(s.toObject())} is not valid`)}this.maxSpan&&this.timePickerStepSize>this.maxSpan&&console.error(`Option 'timePickerStepSize' ${JSON.stringify(this.timePickerStepSize.toObject())} must be smaller than 'maxSpan'`),this.timePickerOpts={showMinutes:this.timePickerStepSize<o.Duration.fromObject({hours:1}),showSeconds:this.timePickerStepSize<o.Duration.fromObject({minutes:1}),hourStep:this.timePickerStepSize>=o.Duration.fromObject({hours:1})?this.timePickerStepSize.hours:1,minuteStep:this.timePickerStepSize>=o.Duration.fromObject({minutes:1})?this.timePickerStepSize.minutes:1,secondStep:this.timePickerStepSize.seconds}}for(let s of["startDate","endDate","minDate","maxDate","initalMonth"])if(!(s==="endDate"&&this.singleDatePicker)){if(typeof e[s]=="object")o.DateTime.isDateTime(e[s])&&e[s].isValid?this[s]=e[s]:e[s]instanceof Date?this[s]=o.DateTime.fromJSDate(e[s]):e[s]===null?this[s]=null:console.error(`Option '${s}' must be a luxon.DateTime or Date or string`);else if(typeof e[s]=="string"){const c=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format);if(o.DateTime.fromISO(e[s]).isValid)this[s]=o.DateTime.fromISO(e[s]);else if(o.DateTime.fromFormat(e[s],c,{locale:o.DateTime.now().locale}).isValid)this[s]=o.DateTime.fromFormat(e[s],c,{locale:o.DateTime.now().locale});else{const d=o.DateTime.fromFormat(e[s],c,{locale:o.DateTime.now().locale}).invalidExplanation;console.error(`Option '${s}' is not a valid string: ${d}`)}}}if(this.isInputText&&this.element.value!=""){const s=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format);if(this.singleDatePicker&&typeof e.startDate>"u"){const c=o.DateTime.fromFormat(this.element.value,s,{locale:o.DateTime.now().locale});c.isValid?this.#e=c:console.error(`Value "${this.element.value}" in <input> is not a valid string: ${c.invalidExplanation}`)}else if(!this.singleDatePicker&&typeof e.startDate>"u"&&typeof e.endDate>"u"){const c=this.element.value.split(this.locale.separator);if(c.length===2){const d=o.DateTime.fromFormat(c[0],s,{locale:o.DateTime.now().locale}),p=o.DateTime.fromFormat(c[1],s,{locale:o.DateTime.now().locale});d.isValid&&p.isValid?(this.#e=d,this.#t=p):console.error(`Value in <input> is not a valid string: ${d.invalidExplanation} - ${p.invalidExplanation}`)}else console.error(`Value "${this.element.value}" in <input> is not a valid string`)}}if(this.singleDatePicker?this.#t=this.#e:this.#t<this.#e&&console.error(`Option 'endDate' ${this.#t} must not be earlier than 'startDate' ${this.#e}`),this.timePicker||(this.minDate&&(this.minDate=this.minDate.startOf("day")),this.maxDate&&(this.maxDate=this.maxDate.endOf("day")),this.#e&&(this.#e=this.#e.startOf("day")),this.#t&&(this.#t=this.#t.endOf("day"))),!this.#e&&this.initalMonth)this.#t=null,this.timePicker&&console.error("Option 'initalMonth' works only with 'timePicker: false'");else{const s=this.validateInput(null,!1);if(s!=null){let c=s.startDate;if(c.length>0)if(c.some(d=>d.reason.startsWith("isInvalid")))console.error(`Value of startDate "${this.#e}" violates ${c.find(d=>d.reason.startsWith("isInvalid")).reason}`);else{const d=c.filter(p=>p.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting startDate from ${this.#e} to ${d}`),this.#e=d}if(!this.singleDatePicker&&(c=s.endDate.filter(d=>d.new!=null),c.length>0))if(c.some(d=>d.reason.startsWith("isInvalid")))console.error(`Value of endDate "${this.#t}" violates ${c.find(d=>d.reason.startsWith("isInvalid")).reason}`);else{const d=c.filter(p=>p.new!=null).at(-1).new;typeof process<"u"&&process.env.JEST_WORKER_ID==null&&console.warn(`Correcting endDate from ${this.#t} to ${d}`),this.#t=d}}}if(this.singleDatePicker)if(typeof e.altInput=="string"){const s=document.querySelector(e.altInput);this.altInput=s instanceof HTMLInputElement&&s.type==="text"?s:null}else e.altInput instanceof HTMLElement&&(this.altInput=e.altInput instanceof HTMLInputElement&&e.altInput.type==="text"?e.altInput:null);else if(!this.singleDatePicker&&Array.isArray(e.altInput)&&e.altInput.length===2){this.altInput=[];for(let s of e.altInput){const c=typeof s=="string"?document.querySelector(s):s;c instanceof HTMLInputElement&&c.type==="text"&&this.altInput.push(c)}this.altInput.length!==2&&(this.altInput=null)}else e.altInput!=null&&console.warn(`Option 'altInput' ${JSON.stringify(e.altInput)} is not valid`);if(e.altInput&&["function","string"].includes(typeof e.altFormat)&&(this.altFormat=e.altFormat),typeof e.opens=="string"&&(["left","right","center"].includes(e.opens)?this.opens=e.opens:console.error("Option 'options.opens' must be 'left', 'right' or 'center'")),typeof e.drops=="string"&&(["up","down","auto"].includes(e.drops)?this.drops=e.drops:console.error("Option 'options.drops' must be 'up', 'down' or 'auto'")),Array.isArray(e.buttonClasses)?this.buttonClasses=e.buttonClasses.join(" "):typeof e.buttonClasses=="string"&&(this.buttonClasses=e.buttonClasses),typeof e.onOutsideClick=="string"&&(["cancel","apply"].includes(e.onOutsideClick)?this.onOutsideClick=e.onOutsideClick:console.error("Option 'options.onOutsideClick' must be 'cancel' or 'apply'")),this.locale.firstDay!=1){let s=this.locale.firstDay;for(;s>1;)this.locale.daysOfWeek.push(this.locale.daysOfWeek.shift()),s--}if(!this.singleDatePicker&&typeof e.ranges=="object"){for(let s in e.ranges){let c,d;if(["string","object"].includes(typeof e.ranges[s][0])&&(o.DateTime.isDateTime(e.ranges[s][0])&&e.ranges[s][0].isValid?c=e.ranges[s][0]:e.ranges[s][0]instanceof Date?c=o.DateTime.fromJSDate(e.ranges[s][0]):typeof e.ranges[s][0]=="string"&&o.DateTime.fromISO(e.ranges[s][0]).isValid?c=o.DateTime.fromISO(e.ranges[s][0]):console.error(`Option ranges['${s}'] is not am array of valid ISO-8601 string or luxon.DateTime or Date`)),["string","object"].includes(typeof e.ranges[s][1])&&(o.DateTime.isDateTime(e.ranges[s][1])&&e.ranges[s][1].isValid?d=e.ranges[s][1]:e.ranges[s][1]instanceof Date?d=o.DateTime.fromJSDate(e.ranges[s][1]):typeof e.ranges[s][1]=="string"&&o.DateTime.fromISO(e.ranges[s][1]).isValid?d=o.DateTime.fromISO(e.ranges[s][1]):console.error(`Option ranges['${s}'] is not a valid ISO-8601 string or luxon.DateTime or Date`)),!(c==null||d==null)){var h=document.createElement("textarea");h.innerHTML=s,this.ranges[h.value]=[c,d]}}var u="<ul>";for(let s in this.ranges)u+=`<li data-range-key="${s}">${s}</li>`;this.showCustomRangeLabel&&(u+=`<li data-range-key="${this.locale.customRangeLabel}">${this.locale.customRangeLabel}</li>`),u+="</ul>",this.container.querySelector(".ranges").prepend(I(u)),this.container.classList.add("show-ranges")}typeof l=="function"&&(this.callback=l),this.timePicker||this.container.querySelectorAll(".calendar-time").forEach(s=>{s.style.display="none"}),this.timePicker&&this.autoApply&&(this.autoApply=!1),this.autoApply&&this.container.classList.add("auto-apply"),(this.singleDatePicker||this.singleMonthView)&&(this.container.classList.add("single"),this.container.querySelector(".drp-calendar.left").classList.add("single"),this.container.querySelector(".drp-calendar.left").style.display="",this.container.querySelector(".drp-calendar.right").style.display="none",!this.timePicker&&this.autoApply&&this.container.classList.add("auto-apply")),(this.singleDatePicker||!Object.keys(this.ranges).length||this.alwaysShowCalendars)&&this.container.classList.add("show-calendar"),this.container.classList.add(`opens${this.opens}`),this.container.querySelectorAll(".applyBtn, .cancelBtn").forEach(s=>{s.classList.add(...this.buttonClasses.split(" "))}),this.applyButtonClasses.length&&this.container.querySelector(".applyBtn").classList.add(...this.applyButtonClasses.split(" ")),this.cancelButtonClasses.length&&this.container.querySelector(".cancelBtn").classList.add(...this.cancelButtonClasses.split(" ")),this.container.querySelector(".applyBtn").innerHTML=this.locale.applyLabel,this.container.querySelector(".cancelBtn").innerHTML=this.locale.cancelLabel,this.addListener(".drp-calendar","click",".prev",this.clickPrev.bind(this)),this.addListener(".drp-calendar","click",".next",this.clickNext.bind(this)),this.addListener(".drp-calendar","mousedown","td.available",this.clickDate.bind(this)),this.addListener(".drp-calendar","mouseenter","td.available",this.hoverDate.bind(this)),this.addListener(".drp-calendar","change","select.yearselect,select.monthselect",this.monthOrYearChanged.bind(this)),this.addListener(".drp-calendar","change","select.hourselect,select.minuteselect,select.secondselect,select.ampmselect",this.timeChanged.bind(this)),this.addListener(".ranges","click","li",this.clickRange.bind(this)),this.addListener(".ranges","mouseenter","li",this.hoverRange.bind(this)),this.addListener(".ranges","mouseleave","li",this.leaveRange.bind(this)),this.addListener(".drp-buttons","click","button.applyBtn",this.clickApply.bind(this)),this.addListener(".drp-buttons","click","button.cancelBtn",this.clickCancel.bind(this)),this.element.matches("input")||this.element.matches("button")?(this.element.addEventListener("click",this.#a),this.element.addEventListener("focus",this.#a),this.element.addEventListener("keyup",this.#o),this.element.addEventListener("keydown",this.#h)):(this.element.addEventListener("click",this.#n),this.element.addEventListener("keydown",this.#n)),this.updateElement()}get startDate(){return this.timePicker?this.#e:this.#e?.startOf("day")??null}get endDate(){return this.singleDatePicker?null:(this.timePicker?this.#t:this.#t?.endOf("day"))??null}set startDate(i){this.#e=i}set endDate(i){this.#t=i}#i={onViolate:{type:"violate",param:(i,e)=>({...i,cancelable:!0})},onBeforeRenderTimePicker:{type:"beforeRenderTimePicker"},onBeforeRenderCalendar:{type:"beforeRenderCalendar"},onShow:{type:"show"},onBeforeHide:{type:"beforeHide",param:{cancelable:!0}},onHide:{type:"hide"},onShowCalendar:{type:"showCalendar"},onHideCalendar:{type:"hideCalendar"},onOutsideClick:{type:"outsideClick",param:{cancelable:!0}},onDateChange:{type:"dateChange",param:i=>i},onTimeChange:{type:"timeChange",param:i=>i},onApply:{type:"apply"},onCancel:{type:"cancel"},onInputChange:{type:"inputChange"},onMonthViewChange:{type:"monthViewChange",param:(i,e)=>({left:this.leftCalendar.month.startOf("month"),right:this.singleMonthView||this.singleDatePicker?null:this.rightCalendar.month.startOf("month")})}};get events(){return this.#i}#s=this.outsideClick.bind(this);#l=this.move.bind(this);#r=i=>{const e=i.target.closest('[data-toggle="dropdown"]');e&&document.contains(e)&&this.#s(i)};#a=this.show.bind(this);#o=this.elementChanged.bind(this);#h=this.keydown.bind(this);#n=this.toggle.bind(this);setStartDate(i,e=!0){if(!this.singleDatePicker)return setRange(i,this.#t,e);const l=this.#e;let a=this.parseDate(i);if(a.equals(l))return null;const r=this.validateInput([a,null],!0);if(r!=null)if(r.newDate!=null)a=r.newDate.startDate;else return r;const t=!this.#e.hasSame(a,"month");return this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),e&&this.updateView(t),r}setEndDate(i,e=!0){return this.singleDatePicker?null:setRange(this.#e,i,e)}setRange(i,e,l=!0){if(this.singleDatePicker)return;this.#t||(this.#t=this.#e);const a=[this.#e,this.#t];let r=[this.parseDate(i),this.parseDate(e)];if(a[0].equals(r[0])&&a[1].equals(r[1])||r[0]>r[1])return;const t=this.validateInput([r[0],r[1]],!0);if(t!=null)if(t.newDate!=null)r[0]=t.newDate.startDate,r[1]=t.newDate.endDate;else return t;const h=!this.#e.hasSame(r[0],"month")||!this.#t.hasSame(r[1],"month");return this.#e=r[0],this.#t=r[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day")),this.updateElement(),l&&this.updateView(h),t}parseDate(i){if(typeof i=="object"){if(o.DateTime.isDateTime(i)&&i.isValid)return i;if(i instanceof Date)return o.DateTime.fromJSDate(i);throw RangeError("Value must be a luxon.DateTime or Date or string")}else if(typeof i=="string"){const e=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format);if(o.DateTime.fromISO(i).isValid)return o.DateTime.fromISO(i);if(o.DateTime.fromFormat(i,e,{locale:o.DateTime.now().locale}).isValid)return o.DateTime.fromFormat(i,e,{locale:o.DateTime.now().locale});{const l=o.DateTime.fromFormat(i,e,{locale:o.DateTime.now().locale}).invalidExplanation;throw RangeError(`Value is not a valid string: ${l}`)}}}formatDate(i,e=this.locale.format){if(i===null)return null;if(typeof e=="object")return i.toLocaleString(e);if(o.Settings.defaultLocale===null){const l=o.DateTime.now().locale;return i.toFormat(e,{locale:l})}else return i.toFormat(e)}updateLabel(){if(this.showLabel){let i=this.formatDate(this.#e);this.singleDatePicker||(i+=this.locale.separator,this.#t&&(i+=this.formatDate(this.#t))),this.container.querySelector(".drp-selected").innerHTML=i}if(!(this.singleDatePicker||this.locale.durationFormat==null)){if(!this.#t){this.container.querySelector(".drp-duration-label").innerHTML="";return}if(typeof this.locale.durationFormat=="function")this.container.querySelector(".drp-duration-label").innerHTML=this.locale.durationFormat(this.#e,this.#t);else{let i=this.#t.plus({milliseconds:1}).diff(this.#e).rescale().set({milliseconds:0});this.timePicker||(i=i.set({seconds:0,minutes:0,hours:0})),i=i.removeZeros(),typeof this.locale.durationFormat=="object"?this.container.querySelector(".drp-duration-label").innerHTML=i.toHuman(this.locale.durationFormat):this.container.querySelector(".drp-duration-label").innerHTML=i.toFormat(this.locale.durationFormat)}}}validateInput(i,e=!1){let l=i==null?this.#e:i[0],a=i==null?this.#t:i[1];if(l==null)return null;let r={startDate:[]},t={old:l,reason:this.timePicker?"timePickerStepSize":"timePicker"};if(this.timePicker){const n=this.timePickerStepSize.as("seconds");l=o.DateTime.fromSeconds(n*Math.round(l.toSeconds()/n)),t.new=l,t.new.equals(t.old)||r.startDate.push(t)}else l=l.startOf("day");const h=this.timePicker?this.timePickerStepSize.as("seconds"):o.Duration.fromObject({days:1}).as("seconds");this.minDate&&l<this.minDate?(t={old:l,reason:"minDate"},l=l.plus({seconds:Math.trunc(this.minDate.diff(l).as("seconds")/h)*h}),l<this.minDate&&(l=l.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=l,t.new.equals(t.old)||r.startDate.push(t)):this.maxDate&&l>this.maxDate&&(t={old:l,reason:"maxDate"},l=l.minus({seconds:Math.trunc(l.diff(this.maxDate).as("seconds")/h)*h}),l>this.maxDate&&(l=l.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=l,t.new.equals(t.old)||r.startDate.push(t));let f=["hour"];if(this.timePicker&&(this.timePickerOpts.showMinutes&&f.push("minute"),this.timePickerOpts.showSeconds&&f.push("second"),this.timePicker24Hour||f.push("ampm")),this.isInvalidDate(l)&&r.startDate.push({old:l,reason:"isInvalidDate"}),this.timePicker)for(let n of f)this.isInvalidTime(l,n,"start")&&r.startDate.push({old:l,reason:"isInvalidTime",unit:n});if(this.singleDatePicker){if(r.startDate.length==0)return null;if(e){let n={startDate:l};const u=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:n});return u.defaultPrevented&&(r.newDate=u.newDate),r}else return r}if(a==null)return null;if(r.endDate=[],t={old:a,reason:this.timePicker?"stepSize":"timePicker"},this.timePicker){const n=this.timePickerStepSize.as("seconds");a=o.DateTime.fromSeconds(n*Math.round(a.toSeconds()/n)),t.new=a,t.new.equals(t.old)||r.endDate.push(t)}else a=a.endOf("day");if(this.maxDate&&a>this.maxDate?(t={old:a,reason:"maxDate"},a=a.minus({seconds:Math.trunc(a.diff(this.maxDate).as("seconds")/h)*h}),a>this.maxDate&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t)):this.minDate&&a<this.minDate&&(t={old:a,reason:"minDate"},a=a.plus({seconds:Math.trunc(this.minDate.diff(a).as("seconds")/h)*h}),a<this.minDate&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t)),this.maxSpan){const n=l.plus(this.maxSpan);a>n&&(t={old:a,reason:"maxSpan"},a=a.minus({seconds:Math.trunc(n.diff(a).as("seconds")/h)*h}),a>n&&(a=a.minus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t))}if(this.minSpan){const n=l.plus(this.defaultSpan??this.minSpan);a<n&&(t={old:a,reason:"minSpan"},a=a.plus({seconds:Math.trunc(n.diff(a).as("seconds")/h)*h}),a<n&&(a=a.plus(this.timePicker?this.timePickerStepSize:{days:1})),t.new=a,t.new.equals(t.old)||r.endDate.push(t))}if(this.isInvalidDate(a)&&r.endDate.push({old:a,reason:"isInvalidDate"}),this.timePicker)for(let n of f)this.isInvalidTime(a,n,"end")&&r.endDate.push({old:a,reason:"isInvalidTime",unit:n});if(r.startDate.length==0&&r.endDate.length==0)return null;if(e){let n={startDate:l,endDate:a};const u=this.triggerEvent(this.#i.onViolate,{violation:r,newDate:n});return u.defaultPrevented&&(r.newDate=u.newDate),r}else return r}updateView(i){this.timePicker&&(this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.container.querySelector(".calendar-time.end-time select").disabled=!this.#t,this.container.querySelector(".calendar-time.end-time select").classList.toggle("disabled",!this.#t)),this.updateLabel(),this.updateMonthsInView(),this.updateCalendars(i),this.setApplyBtnState()}updateMonthsInView(){if(this.#t){if(!this.singleDatePicker&&this.leftCalendar.month&&this.rightCalendar.month&&(this.#e.hasSame(this.leftCalendar.month,"month")||this.#e.hasSame(this.rightCalendar.month,"month"))&&(this.#t.hasSame(this.leftCalendar.month,"month")||this.#t.hasSame(this.rightCalendar.month,"month")))return;this.leftCalendar.month=this.#e.startOf("month"),this.singleMonthView||(!this.linkedCalendars&&!this.#t.hasSame(this.#e,"month")?this.rightCalendar.month=this.#t.startOf("month"):this.rightCalendar.month=this.#e.startOf("month").plus({month:1}))}else!this.#e&&this.initalMonth?(this.leftCalendar.month=this.initalMonth,this.singleMonthView||(this.rightCalendar.month=this.initalMonth.plus({month:1}))):!this.leftCalendar.month.hasSame(this.#e,"month")&&!this.rightCalendar.month.hasSame(this.#e,"month")&&(this.leftCalendar.month=this.#e.startOf("month"),this.rightCalendar.month=this.#e.startOf("month").plus({month:1}));this.maxDate&&this.linkedCalendars&&!this.singleDatePicker&&!this.singleMonthView&&this.rightCalendar.month>this.maxDate&&(this.rightCalendar.month=this.maxDate.startOf("month"),this.leftCalendar.month=this.maxDate.startOf("month").minus({month:1}))}updateCalendars(i){if(this.timePicker){var e,l,a;this.#t?(e=parseInt(this.container.querySelector(".start-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10)),l=0,this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10)))):(e=parseInt(this.container.querySelector(".end-time .hourselect").value,10),isNaN(e)&&(e=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10)),l=0,this.timePickerOpts.showMinutes&&(l=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(l)&&(l=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10))),a=0,this.timePickerOpts.showSeconds&&(a=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(a)&&(a=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10)))),this.leftCalendar.month=this.leftCalendar.month.set({hour:e,minute:l,second:a}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:e,minute:l,second:a}))}else this.leftCalendar.month=this.leftCalendar.month.set({hour:0,minute:0,second:0}),this.singleMonthView||(this.rightCalendar.month=this.rightCalendar.month.set({hour:0,minute:0,second:0}));this.triggerEvent(this.#i.onBeforeRenderCalendar),this.renderCalendar("left"),this.renderCalendar("right"),i&&this.triggerEvent(this.#i.onMonthViewChange),this.container.querySelectorAll(".ranges li").forEach(r=>{r.classList.remove("active")}),this.#t!=null&&this.calculateChosenLabel()}renderCalendar(i){if(i==="right"&&this.singleMonthView)return;var t=i==="left"?this.leftCalendar:this.rightCalendar;t.month==null&&!this.#e&&this.initalMonth&&(t.month=this.initalMonth.startOf("month"));const e=t.month.startOf("month"),l=t.month.endOf("month").startOf("day");var a=t.month.startOf("month").minus({day:1});const r={hour:t.month.hour,minute:t.month.minute,second:t.month.second};var t=[];t.firstDay=e,t.lastDay=l;for(var h=0;h<6;h++)t[h]=[];for(;a.weekday!=this.locale.firstDay;)a=a.minus({day:1});for(let y=0,D=-1;y<42;y++,a=a.plus({day:1}))y%7===0&&D++,t[D][y%7]=a.set(r);i==="left"?this.leftCalendar.calendar=t:this.rightCalendar.calendar=t;var f=i==="left"?this.minDate:this.#e,n=this.maxDate,u="<tr>";(this.showWeekNumbers||this.showISOWeekNumbers)&&(u+="<th></th>"),(!f||f<t.firstDay)&&(!this.linkedCalendars||i==="left")?u+='<th class="prev available"><span></span></th>':u+="<th></th>";var s=`${this.locale.monthNames[t.firstDay.month-1]} ${t.firstDay.year}`;if(this.showDropdowns){const y=(n&&n.year)??this.maxYear,D=(f&&f.year)??this.minYear;let P=this.externalStyle==="bulma"?'<div class="select is-small mr-1">':"";for(var c=`${P}<select class="monthselect">`,d=1;d<=12;d++)c+=`<option value="${d}"${d===t.firstDay.month?" selected":""}`,(f&&t.firstDay.set({month:d})<f.startOf("month")||n&&t.firstDay.set({month:d})>n.endOf("month"))&&(c+=" disabled"),c+=`>${this.locale.monthNames[d-1]}</option>`;c+="</select>",this.externalStyle==="bulma"&&(c+="</div>"),P=this.externalStyle==="bulma"?'<div class="select is-small ml-1">':"";for(var p=`${P}<select class="yearselect">`,g=D;g<=y;g++)p+=`<option value="${g}"${g===t.firstDay.year?" selected":""}>${g}</option>`;p+="</select>",this.externalStyle==="bulma"&&(p+="</div>"),s=c+p}u+='<th colspan="5" class="month">'+s+"</th>",(!n||n>t.lastDay.endOf("day"))&&(!this.linkedCalendars||i==="right"||this.singleDatePicker||this.singleMonthView)?u+='<th class="next available"><span></span></th>':u+="<th></th>",u+="</tr>",u+="<tr>",(this.showWeekNumbers||this.showISOWeekNumbers)&&(u+=`<th class="week">${this.locale.weekLabel}</th>`);for(let[y,D]of this.locale.daysOfWeek.entries())u+="<th",this.weekendDayClasses&&this.weekendDayClasses.length&&o.Info.getWeekendWeekdays().includes(y+1)&&(u+=` class="${this.weekendDayClasses}"`),u+=`>${D}</th>`;if(u+="</tr>",this.container.querySelector(`.drp-calendar.${i} .calendar-table thead`).innerHTML=u,u="",this.#t==null&&this.maxSpan){var S=this.#e.plus(this.maxSpan).endOf("day");(!n||S<n)&&(n=S)}var C;this.#t==null&&this.minSpan&&(C=this.#e.plus(this.minSpan).startOf("day"));for(let y=0;y<6;y++){u+="<tr>",this.showISOWeekNumbers?u+=`<td class="week">${t[y][0].weekNumber}</td>`:this.showWeekNumbers&&(u+=`<td class="week">${t[y][0].localWeekNumber}</td>`);for(let D=0;D<7;D++){var k=[];this.todayClasses&&this.todayClasses.length&&t[y][D].hasSame(o.DateTime.now(),"day")&&k.push(this.todayClasses),this.weekendClasses&&this.weekendClasses.length&&o.Info.getWeekendWeekdays().includes(t[y][D].weekday)&&k.push(this.weekendClasses),t[y][D].month!=t[1][1].month&&k.push("off","ends"),this.minDate&&t[y][D].startOf("day")<this.minDate.startOf("day")&&k.push("off","disabled"),n&&t[y][D].startOf("day")>n.startOf("day")&&k.push("off","disabled"),C&&t[y][D].startOf("day")>this.#e.startOf("day")&&t[y][D].startOf("day")<C.startOf("day")&&k.push("off","disabled"),this.isInvalidDate(t[y][D])&&k.push("off","disabled"),this.#e!=null&&t[y][D].hasSame(this.#e,"day")&&k.push("active","start-date"),this.#t!=null&&t[y][D].hasSame(this.#t,"day")&&k.push("active","end-date"),this.#t!=null&&t[y][D]>this.#e&&t[y][D]<this.#t&&k.push("in-range");var w=this.isCustomDate(t[y][D]);w!==!1&&(typeof w=="string"?k.push(w):k.push(...w)),k.includes("disabled")||k.push("available"),u+=`<td class="${k.join(" ")}" data-title="r${y}c${D}">${t[y][D].day}</td>`}u+="</tr>"}this.container.querySelector(`.drp-calendar.${i} .calendar-table tbody`).innerHTML=u}renderTimePicker(i){if(i==="end"&&!this.#t)return;var e,l,a,r=this.maxDate;let t="";if((this.showWeekNumbers||this.showISOWeekNumbers)&&(t+="<th></th>"),this.maxSpan&&(!this.maxDate||this.#e.plus(this.maxSpan)<this.maxDate)&&(r=this.#e.plus(this.maxSpan)),this.minSpan&&i==="end"&&(l=this.#e.plus(this.defaultSpan??this.minSpan)),i==="start")e=this.#e,a=this.minDate;else if(i==="end"){e=this.#t,a=this.#e;let d=this.container.querySelector(".drp-calendar .calendar-time.end-time");d.innerHTML!=""&&(e=e.set({hour:isNaN(e.hour)?d.querySelector(".hourselect option:selected").value:e.hour,minute:isNaN(e.minute)?d.querySelector(".minuteselect option:selected").value:e.minute,second:isNaN(e.second)?d.querySelector(".secondselect option:selected").value:e.second})),e<this.#e&&(e=this.#e),r&&e>r&&(e=r)}t+='<th colspan="7">',this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="hourselect">';const h=e.toFormat("a",{locale:"en-US"});let f=0;this.timePicker24Hour||(f=h==="AM"?1:13);for(var n=f;n<=f+23;n+=this.timePickerOpts.hourStep){let d=e.set({hour:n%24}),p=!1;if(a&&d.set({minute:59})<a&&(p=!0),r&&d.set({minute:0})>r&&(p=!0),l&&d.endOf("hour")<l&&(p=!0),!p&&this.isInvalidTime(d,this.singleDatePicker?null:i,"hour")&&(p=!0),this.timePicker24Hour)!p&&n==e.hour?t+=`<option value="${n}" selected>${n}</option>`:p?t+=`<option value="${n}" disabled class="disabled">${n}</option>`:t+=`<option value="${n}">${n}</option>`;else{const g=o.DateTime.fromFormat(`${n%24}`,"H").toFormat("h"),S=o.DateTime.fromFormat(`${n%24}`,"H").toFormat("a",{locale:"en-US"});h==S?!p&&n==e.hour?t+=`<option ampm="${S}" value="${n%24}" selected>${g}</option>`:p?t+=`<option ampm="${S}" value="${n%24}" disabled class="disabled">${g}</option>`:t+=`<option ampm="${S}" value="${n%24}">${g}</option>`:t+=`<option ampm="${S}" hidden="hidden" value="${n%24}">${g}</option>`}}if(t+="</select>",this.externalStyle==="bulma"&&(t+="</div>"),this.timePickerOpts.showMinutes){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="minuteselect">';for(var n=0;n<60;n+=this.timePickerOpts.minuteStep){var u=n<10?"0"+n:n;let p=e.set({minute:n}),g=!1;a&&p.set({second:59})<a&&(g=!0),r&&p.set({second:0})>r&&(g=!0),l&&p.endOf("minute")<l&&(g=!0),!g&&this.isInvalidTime(p,this.singleDatePicker?null:i,"minute")&&(g=!0),e.minute==n&&!g?t+=`<option value="${n}" selected>${u}</option>`:g?t+=`<option value="${n}" disabled class="disabled">${u}</option>`:t+=`<option value="${n}">${u}</option>`}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(this.timePickerOpts.showSeconds){t+=" : ",this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="secondselect">';for(var n=0;n<60;n+=this.timePickerOpts.secondStep){var u=n<10?"0"+n:n;let g=e.set({second:n}),S=!1;a&&g<a&&(S=!0),r&&g>r&&(S=!0),l&&g<l&&(S=!0),!S&&this.isInvalidTime(g,this.singleDatePicker?null:i,"second")&&(S=!0),e.second==n&&!S?t+=`<option value="${n}" selected>${u}</option>`:S?t+=`<option value="${n}" disabled class="disabled">${u}</option>`:t+=`<option value="${n}">${u}</option>`}t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}if(!this.timePicker24Hour){this.externalStyle==="bulma"&&(t+='<div class="select is-small mx-1">'),t+='<select class="ampmselect">';var s="",c="";let d=!1;a&&e.startOf("day")<a&&(d=!0),r&&e.endOf("day")>r&&(d=!0),l&&e.startOf("day")<l&&(d=!0),d?(s=' disabled class="disabled "',c=' disabled class="disabled"'):this.isInvalidTime(e,this.singleDatePicker?null:i,"ampm")&&(e.toFormat("a",{locale:"en-US"})==="AM"?c=' disabled class="disabled"':s=' disabled class="disabled"'),t+=`<option value="AM"${s}`,e.toFormat("a",{locale:"en-US"})==="AM"&&(t+=" selected"),t+=`>${o.Info.meridiems()[0]}</option><option value="PM"${c}`,e.toFormat("a",{locale:"en-US"})==="PM"&&(t+=" selected"),t+=`>${o.Info.meridiems()[1]}</option>`,t+="</select>",this.externalStyle==="bulma"&&(t+="</div>")}t+="</div></th>",this.container.querySelector(`.drp-calendar .calendar-time.${i}-time`).innerHTML=t}setApplyBtnState(){const i=this.singleDatePicker||this.#t&&this.#e<=this.#t;this.container.querySelector("button.applyBtn").disabled=!i}move(){let i={top:0,left:0},e,l,a=this.drops,r=window.innerWidth;switch(this.parentEl.matches("body")||(i={top:v(this.parentEl).top-this.parentEl.scrollTop(),left:v(this.parentEl).left-this.parentEl.scrollLeft()},r=this.parentEl[0].clientWidth+v(this.parentEl).left),this.drops){case"auto":e=v(this.element).top+b(this.element)-i.top,e+b(this.container)>=this.parentEl.scrollHeight&&(e=v(this.element).top-b(this.container)-i.top,a="up");break;case"up":e=v(this.element).top-b(this.container)-i.top;break;case"down":e=v(this.element).top+b(this.element)-i.top;break;default:console.error(`Option drops '${a}' not defined`);break}for(const[h,f]of Object.entries({top:0,left:0,right:"auto"}))this.container.style[h]=typeof f=="number"&&f>0?`${f}px`:f;const t=T(this.container);switch(this.container.classList.toggle("drop-up",a==="up"),this.opens){case"left":const h=r-v(this.element).left-T(this.element);if(t+h>window.innerWidth)for(const[f,n]of Object.entries({top:e,right:"auto",left:9}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else for(const[f,n]of Object.entries({top:e,right:h,left:"auto"}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;break;case"center":if(l=v(this.element).left-i.left+T(this.element)/2-t/2,l<0)for(const[f,n]of Object.entries({top:e,right:"auto",left:9}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else if(l+t>window.innerWidth)for(const[f,n]of Object.entries({top:e,left:"auto",right:0}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else for(const[f,n]of Object.entries({top:e,left:l,right:"auto"}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;break;case"right":if(l=v(this.element).left-i.left,l+t>window.innerWidth)for(const[f,n]of Object.entries({top:e,left:"auto",right:0}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;else for(const[f,n]of Object.entries({top:`${e}px`,left:l,right:"auto"}))this.container.style[f]=typeof n=="number"&&n>0?`${n}px`:n;break;default:console.error(`Option opens '${this.opens}' not defined`);break}}show(){this.isShowing||(document.addEventListener("mousedown",this.#s),document.addEventListener("touchend",this.#s),document.addEventListener("click",this.#r),document.addEventListener("focusin",this.#s),window.addEventListener("resize",this.#l),this.oldStartDate=this.#e,this.oldEndDate=this.#t,this.updateView(!1),this.container.style.display="block",this.move(),this.triggerEvent(this.#i.onShow),this.isShowing=!0)}hide(){!this.isShowing||(this.#t||(this.#e=this.oldStartDate,this.#t=this.oldEndDate),typeof this.callback=="function"&&(this.#e&&!this.#e.equals(this.oldStartDate??o.DateTime)||this.#t&&!this.singleDatePicker&&!this.#t.equals(this.oldEndDate??o.DateTime))&&this.callback(this.startDate,this.endDate,this.chosenLabel),this.updateElement(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented)||(document.removeEventListener("mousedown",this.#s),document.removeEventListener("touchend",this.#s),document.removeEventListener("focusin",this.#s),document.removeEventListener("click",this.#r),window.removeEventListener("resize",this.#l),this.container.style.display="none",this.triggerEvent(this.#i.onHide),this.isShowing=!1)}toggle(){this.isShowing?this.hide():this.show()}showCalendars(){this.container.classList.add("show-calendar"),this.move(),this.triggerEvent(this.#i.onShowCalendar)}hideCalendars(){this.container.classList.remove("show-calendar"),this.triggerEvent(this.#i.onHideCalendar)}outsideClick(i){const e=i.target;function l(r,t){let h=r.parentElement;for(;h;){if(h==t)return h;h=h.parentElement}return null}i.type==="focusin"||l(e,this.element)||l(e,this.container)||e.closest(".calendar-table")||this.triggerEvent(this.#i.onOutsideClick).defaultPrevented||(this.onOutsideClick==="cancel"&&(this.#e=this.oldStartDate,this.#t=this.oldEndDate),this.hide())}clickPrev(i){i.target.closest(".drp-calendar").classList.contains("left")?(this.leftCalendar.month=this.leftCalendar.month.minus({month:1}),this.linkedCalendars&&!this.singleMonthView&&(this.rightCalendar.month=this.rightCalendar.month.minus({month:1}))):this.rightCalendar.month=this.rightCalendar.month.minus({month:1}),this.updateCalendars(!0)}clickNext(i){i.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.month=this.leftCalendar.month.plus({month:1}):(this.rightCalendar.month=this.rightCalendar.month.plus({month:1}),this.linkedCalendars&&(this.leftCalendar.month=this.leftCalendar.month.plus({month:1}))),this.updateCalendars(!0)}hoverDate(i){if(!i.target.classList.contains("available"))return;let e=i.target.dataset.title;const l=e.substring(1,2),a=e.substring(3,4);var t=i.target(closest,".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[l][a]:this.rightCalendar.calendar[l][a];const h=this.leftCalendar,f=this.rightCalendar,n=this.#e,u=this.initalMonth;this.#t||this.container.querySelectorAll(".drp-calendar tbody td").forEach(s=>{if(s.classList.contains("week"))return;const c=s.dataset.title,d=c.substring(1,2),p=c.substring(3,4),S=s.closest(".drp-calendar").classList.contains("left")?h.calendar[d][p]:f.calendar[d][p];!n&&u?s.classList.remove("in-range"):s.classList.toggle("in-range",S>n&&S<t||S.hasSame(t,"day"))})}hoverRange(i){const e=i.target.dataset.rangeKey,l=[this.#e,this.#t],a=this.ranges[e]??[this.#e,this.#t],r=this.leftCalendar,t=this.rightCalendar;this.container.querySelectorAll(".drp-calendar tbody td").forEach(h=>{if(h.classList.contains("week"))return;const f=h.dataset.ttitle,n=f.substring(1,2),u=f.substring(3,4),c=h.closest(".drp-calendar").classList.contains("left")?r.calendar[n][u]:t.calendar[n][u];h.classList.toggle("start-hover",c.hasSame(a[0],"day")),h.classList.toggle("start-date",c.hasSame(l[0],"day")),h.classList.toggle("end-hover",c.hasSame(a[1],"day")),h.classList.toggle("end-date",l[1]!=null&&c.hasSame(l[1],"day")),h.classList.toggle("range-hover",c.startOf("day")>=a[0].startOf("day")&&c.startOf("day")<=a[1].startOf("day")),h.classList.toggle("in-range",c.startOf("day")>=l[0].startOf("day")&&l[1]!=null&&c.startOf("day")<=l[1].startOf("day"))})}leaveRange(){this.container.querySelectorAll(".drp-calendar tbody td").forEach(i=>{i.classList.contains("week")||(i.classList.remove("start-hover"),i.classList.remove("end-hover"),i.classList.remove("range-hover"))})}clickRange(i){let e=i.target.getAttribute("data-range-key");if(this.chosenLabel=e,e==this.locale.customRangeLabel)this.showCalendars();else{let l=this.ranges[e];const a=!this.#e.hasSame(l[0],"month")||!this.#t.hasSame(l[1],"month");this.#e=l[0],this.#t=l[1],this.timePicker||(this.#e.startOf("day"),this.#t.endOf("day")),this.alwaysShowCalendars||this.hideCalendars(),this.triggerEvent(this.#i.onBeforeHide).defaultPrevented&&this.updateView(a),this.clickApply()}}clickDate(i){if(!i.target.classList.contains("available"))return;let e=i.target.dataset.title,l=e.substring(1,2),a=e.substring(3,4),t=i.target.closest(".drp-calendar").classList.contains("left")?this.leftCalendar.calendar[l][a]:this.rightCalendar.calendar[l][a],h;if(this.#t||!this.#e||t<this.#e.startOf("day")){if(this.timePicker){let f=parseInt(this.container.querySelector(".start-time .hourselect").value,10);isNaN(f)&&(f=parseInt(this.container.querySelector(".start-time .hourselect option:last-child").value,10));let n=0;this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".start-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".start-time .minuteselect option:last-child").value,10)));let u=0;this.timePickerOpts.showSeconds&&(u=parseInt(this.container.querySelector(".start-time .secondselect").value,10),isNaN(u)&&(u=parseInt(this.container.querySelector(".start-time .secondselect option:last-child").value,10))),t=t.set({hour:f,minute:n,second:u})}else t=t.startOf("day");this.#t=null,this.#e=t,h="start"}else if(!this.#t&&t<this.#e)this.#t=this.#e,h="end";else{if(this.timePicker){let f=parseInt(this.container.querySelector(".end-time .hourselect").value,10);isNaN(f)&&(f=parseInt(this.container.querySelector(".end-time .hourselect option:last-child").value,10));let n=0;this.timePickerOpts.showMinutes&&(n=parseInt(this.container.querySelector(".end-time .minuteselect").value,10),isNaN(n)&&(n=parseInt(this.container.querySelector(".end-time .minuteselect option:last-child").value,10)));let u=0;this.timePickerOpts.showSeconds&&(u=parseInt(this.container.querySelector(".end-time .secondselect").value,10),isNaN(u)&&(u=parseInt(this.container.querySelector(".end-time .secondselect option:last-child").value,10))),t=t.set({hour:f,minute:n,second:u})}else t=t.endOf("day");this.#t=t,this.autoApply&&(this.calculateChosenLabel(),this.clickApply()),h="end"}this.singleDatePicker&&(this.#t=this.#e,!this.timePicker&&this.autoApply&&this.clickApply(),h=null),this.updateView(!1),i.stopPropagation(),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onDateChange,{side:h})}calculateChosenLabel(){if(Object.keys(this.ranges).length===0)return;let i=!0,e=this.timePicker?"hour":"day";this.timePicker&&(this.timePickerOpts.showMinutes?e="minute":this.timePickerOpts.showSeconds&&(e="second"));for(const[l,[a,r]]of Object.entries(this.ranges))if(this.#e.startOf(e).equals(a.startOf(e))&&this.#t.startOf(e).equals(r.startOf(e))){i=!1;const t=this.container.querySelector(`.ranges li[data-range-key="${l}"]`);this.chosenLabel=l,t.classList.add("active");break}if(i){if(this.showCustomRangeLabel){const l=this.container.querySelector(".ranges li:last-child");this.chosenLabel=l.dataset.rangeKey,l.classList.add("active")}else this.chosenLabel=null;this.showCalendars()}}timeChanged(i){const e=i.target.closest(".calendar-time"),l=e.classList.contains("start-time")?"start":"end";var a=parseInt(e.querySelector(".hourselect").value,10);if(isNaN(a)&&(a=parseInt(e.querySelector(".hourselect option:last-child").value,10)),!this.timePicker24Hour){const h=e.querySelector(".ampmselect").value;if(h==null&&e.querySelector(".ampmselect option:last-child").value,h!=o.DateTime.fromFormat(`${a}`,"H").toFormat("a",{locale:"en-US"})){e.querySelectorAll(".hourselect > option").forEach(n=>{n.hidden=!n.hidden});const f=o.DateTime.fromFormat(`${a}`,"H").toFormat("h");a=o.DateTime.fromFormat(`${f}${h}`,"ha",{locale:"en-US"}).hour}}var r=0;this.timePickerOpts.showMinutes&&(r=parseInt(e.querySelector(".minuteselect").value,10),isNaN(r)&&(r=parseInt(e.querySelector(".minuteselect option:last-child").value,10)));var t=0;this.timePickerOpts.showSeconds&&(t=parseInt(e.querySelector(".secondselect").value,10),isNaN(t)&&(t=parseInt(e.querySelector(".secondselect option:last-child").value,10))),l==="start"?(this.#e&&(this.#e=this.#e.set({hour:a,minute:r,second:t})),this.singleDatePicker?this.#t=this.#e:this.#t&&this.#t.hasSame(this.#e,"day")&&this.#t<this.#e&&(this.#t=this.#e)):this.#t&&(this.#t=this.#t.set({hour:a,minute:r,second:t})),this.updateCalendars(!1),this.setApplyBtnState(),this.triggerEvent(this.#i.onBeforeRenderTimePicker),this.renderTimePicker("start"),this.renderTimePicker("end"),this.autoUpdateInput&&this.updateElement(),this.triggerEvent(this.#i.onTimeChange,{side:this.singleDatePicker?null:l})}monthOrYearChanged(i){const e=i.target.closest(".drp-calendar").classList.contains("left"),l=e?"left":"right",a=this.container.querySelector(`.drp-calendar.${l}`);let r=parseInt(a.querySelector(".monthselect").value,10),t=a.querySelector(".yearselect").value,h=!1;e||(t<this.#e.year||t==this.#e.year&&r<this.#e.month)&&(r=this.#e.month,t=this.#e.year),this.minDate&&(t<this.minDate.year||t==this.minDate.year&&r<this.minDate.month)&&(r=this.minDate.month,t=this.minDate.year),this.maxDate&&(t>this.maxDate.year||t==this.maxDate.year&&r>this.maxDate.month)&&(r=this.maxDate.month,t=this.maxDate.year),e?(h=!o.DateTime.fromObject({year:t,month:r}).hasSame(this.leftCalendar.month,"month"),this.leftCalendar.month=this.leftCalendar.month.set({year:t,month:r}),this.linkedCalendars&&(this.rightCalendar.month=this.leftCalendar.month.plus({month:1}))):(h=!o.DateTime.fromObject({year:t,month:r}).hasSame(this.leftCalendar.month,"month"),this.rightCalendar.month=this.rightCalendar.month.set({year:t,month:r}),this.linkedCalendars&&(this.leftCalendar.month=this.rightCalendar.month.minus({month:1}))),this.updateCalendars(h)}clickApply(){this.hide(),this.triggerEvent(this.#i.onApply)}clickCancel(){this.#e=this.oldStartDate,this.#t=this.oldEndDate,this.hide(),this.triggerEvent(this.#i.onCancel)}elementChanged(){if(!this.isInputText||!this.element.value.length)return;const i=typeof this.locale.format=="string"?this.locale.format:o.DateTime.parseFormatForOpts(this.locale.format),e=this.element.value.split(this.locale.separator);let l=!1;if(this.singleDatePicker){let a=o.DateTime.fromFormat(this.element.value,i,{locale:o.DateTime.now().locale});const r=this.#e;if(!a.isValid||r.equals(a))return;const t=this.validateInput([a,null],!0);if(t!=null)if(t.newDate!=null)a=t.newDate.startDate;else return;l=!this.#e.hasSame(a,"month"),this.#e=a,this.#t=this.#e,this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else if(!this.singleDatePicker&&e.length===2){const a=[0,1].map(h=>o.DateTime.fromFormat(e[h],i,{locale:o.DateTime.now().locale})),r=[this.#e,this.#t];if(!a[0].isValid||!a[1].isValid||r[0].equals(a[0])&&r[1].equals(a[1])||a[0]>a[1])return;const t=this.validateInput([a[0],a[1]],!0);if(t!=null)if(t.newDate!=null)a[0]=t.newDate.startDate,a[1]=t.newDate.endDate;else return;l=!this.#e.hasSame(a[0],"month")||!this.#t.hasSame(a[1],"month"),this.#e=a[0],this.#t=a[1],this.timePicker||(this.#e=this.#e.startOf("day"),this.#t=this.#t.endOf("day"))}else return;this.updateView(l),this.updateElement(),this.triggerEvent(this.#i.onInputChange)}keydown(i){[9,11].includes(i.keyCode)&&this.hide(),i.keyCode===27&&(i.preventDefault(),i.stopPropagation(),this.hide())}updateElement(){if(!(this.#e==null&&this.initalMonth))if(this.isInputText){let i=this.formatDate(this.#e);this.singleDatePicker||(i+=this.locale.separator,this.#t&&(i+=this.formatDate(this.#t))),this.updateAltInput(),i!==this.element.value&&(this.element.value=i,this.element.dispatchEvent(new Event("change",{bubbles:!0})))}else this.updateAltInput()}updateAltInput(){if(this.altInput!=null)if(this.altFormat==null){let i="day";this.timePicker&&(this.timePickerOpts.showSeconds?i="second":this.timePickerOpts.showMinutes?i="minute":i="hour");const e=this.#e.toISO({format:"basic",precision:i,includeOffset:!1});if((this.singleDatePicker?this.altInput:this.altInput[0]).value=e,!this.singleDatePicker&&this.#t){const l=this.#t.toISO({format:"basic",precision:i,includeOffset:!1});this.altInput[1].value=l}}else{const i=typeof this.altFormat=="function"?this.altFormat(this.#e):this.formatDate(this.#e,this.altFormat);if((this.singleDatePicker?this.altInput:this.altInput[0]).value=i,!this.singleDatePicker&&this.#t){const e=typeof this.altFormat=="function"?this.altFormat(this.#t):this.formatDate(this.#t,this.altFormat);this.altInput[1].value=e}}}remove(){this.element.removeEventListener("click",this.#a),this.element.removeEventListener("focus",this.#a),this.element.removeEventListener("keyup",this.#o),this.element.removeEventListener("keydown",this.#h),this.element.removeEventListener("click",this.#n),this.element.removeEventListener("keydown",this.#n),this.container.remove()}triggerEvent(i,...e){if(e.length===0){const l=new x(this,i);return this.element.dispatchEvent(l),l}else{const l=new x(this,i,...e);return this.element.dispatchEvent(l),l}}addListener(i,e,l,a){this.container.querySelectorAll(i).forEach(r=>{r.addEventListener(e,function(t){const h=t.target.closest(l);h&&r.contains(h)&&a.call(h,t)})})}}function I(m){const i=document.createElement("template");return i.innerHTML=m.trim(),i.content.firstElementChild}class x extends Event{#e;constructor(i,e,l={}){let a={};e.param&&(a=typeof e.param=="function"?e.param():e.param),a={...a,...l},super(e.type,a),this.#e=i;for(const[r,t]of Object.entries(a))Object.getOwnPropertyNames(Event.prototype).includes(r)||(this[r]=t)}get picker(){return this.#e}}function v(m){const i=m.getBoundingClientRect();return{top:i.top+window.scrollY,left:i.left+window.scrollX}}function T(m,i=!1){if(!i)return m.offsetWidth;const e=getComputedStyle(m);return m.offsetWidth+parseFloat(e.marginLeft)+parseFloat(e.marginRight)}function b(m,i=!1){if(!i)return m.offsetHeight;const e=getComputedStyle(m);return m.offsetHeight+parseFloat(e.marginTop)+parseFloat(e.marginBottom)}function O(m,i,e){return typeof m=="string"?O(document.querySelectorAll(m),i,e):(m instanceof HTMLElement&&(m=[m]),(m instanceof NodeList||m instanceof HTMLCollection)&&(m=Array.from(m)),m==null?new L(null,i||{},e):(m.forEach(l=>{l._daterangepicker&&typeof l._daterangepicker.remove=="function"&&l._daterangepicker.remove(),l._daterangepicker=new L(l,i||{},e)}),m.length===1?m[0]:m))}function E(m){return typeof m=="string"&&(m=document.querySelector(m)),m instanceof HTMLElement?m._daterangepicker:void 0}window.jQuery?.fn&&(jQuery.fn.daterangepicker=function(m,i){return this.each(function(){O(this,m,i)})});function $(m){m?.fn&&(m.fn.daterangepicker=function(i,e){return this.each(function(){O(this,i,e)})})}Object.defineProperty(window,"jQuery",{configurable:!0,set(m){this._jQuery=m,$(m)},get(){return this._jQuery}}),exports.DateRangePicker=L,exports.daterangepicker=O,exports.getDateRangePicker=E;
|
|
2
2
|
//# sourceMappingURL=daterangepicker.min.cjs.map
|