@reachweb/alpine-calendar 0.1.1

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.
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).AlpineCalendar={})}(this,function(e){"use strict";class t{constructor(e,t,s){this.year=e,this.month=t,this.day=s}static today(e){const s=new Date;return e?t.fromNativeDate(s,e):new t(s.getFullYear(),s.getMonth()+1,s.getDate())}static fromNativeDate(e,s){if(s){const a=new Intl.DateTimeFormat("en-US",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(e);let i=0,n=0,r=0;for(const e of a)"year"===e.type?i=Number(e.value):"month"===e.type?n=Number(e.value):"day"===e.type&&(r=Number(e.value));return new t(i,n,r)}return new t(e.getFullYear(),e.getMonth()+1,e.getDate())}static fromISO(e){const a=/^(\d{4})-(\d{2})-(\d{2})$/.exec(e);if(!a)return null;const i=Number(a[1]),n=Number(a[2]),r=Number(a[3]);return n<1||n>12||r<1||r>s(i,n)?null:new t(i,n,r)}toNativeDate(){return new Date(this.year,this.month-1,this.day)}toISO(){return`${String(this.year).padStart(4,"0")}-${String(this.month).padStart(2,"0")}-${String(this.day).padStart(2,"0")}`}toKey(){return this.toISO()}isSame(e){return this.year===e.year&&this.month===e.month&&this.day===e.day}isBefore(e){return this.year!==e.year?this.year<e.year:this.month!==e.month?this.month<e.month:this.day<e.day}isAfter(e){return this.year!==e.year?this.year>e.year:this.month!==e.month?this.month>e.month:this.day>e.day}isBetween(e,t){return!this.isBefore(e)&&!this.isAfter(t)}diffDays(e){const t=Date.UTC(this.year,this.month-1,this.day),s=Date.UTC(e.year,e.month-1,e.day);return Math.round((s-t)/864e5)}addDays(e){const s=this.toNativeDate();return s.setDate(s.getDate()+e),t.fromNativeDate(s)}addMonths(e){let a=this.month-1+e;const i=this.year+Math.floor(a/12);a=(a%12+12)%12;const n=s(i,a+1),r=Math.min(this.day,n);return new t(i,a+1,r)}addYears(e){const a=s(this.year+e,this.month),i=Math.min(this.day,a);return new t(this.year+e,this.month,i)}startOfMonth(){return new t(this.year,this.month,1)}endOfMonth(){return new t(this.year,this.month,s(this.year,this.month))}format(e,t){const s=this.toNativeDate();return new Intl.DateTimeFormat(t,e).format(s)}}function s(e,t){return new Date(e,t,0).getDate()}function a(e){const t=new Date(Date.UTC(e.year,e.month-1,e.day)),s=t.getUTCDay()||7;t.setUTCDate(t.getUTCDate()+4-s);const a=new Date(Date.UTC(t.getUTCFullYear(),0,1));return Math.ceil(((t.getTime()-a.getTime())/864e5+1)/7)}function i(e){return{disabledKeys:e.disabledDates?new Set(e.disabledDates.map(e=>e.toKey())):void 0,disabledDays:e.disabledDaysOfWeek?new Set(e.disabledDaysOfWeek):void 0,enabledKeys:e.enabledDates?new Set(e.enabledDates.map(e=>e.toKey())):void 0,enabledDays:e.enabledDaysOfWeek?new Set(e.enabledDaysOfWeek):void 0,disabledMonths:e.disabledMonths?new Set(e.disabledMonths):void 0,enabledMonths:e.enabledMonths?new Set(e.enabledMonths):void 0,disabledYears:e.disabledYears?new Set(e.disabledYears):void 0,enabledYears:e.enabledYears?new Set(e.enabledYears):void 0}}function n(e,t,s,a){if(t&&e.isBefore(t))return!0;if(s&&e.isAfter(s))return!0;if(a.enabledKeys&&a.enabledKeys.has(e.toKey()))return!1;if(a.enabledYears&&!a.enabledYears.has(e.year))return!0;if(a.disabledYears&&a.disabledYears.has(e.year))return!0;if(a.enabledMonths&&!a.enabledMonths.has(e.month))return!0;if(a.disabledMonths&&a.disabledMonths.has(e.month))return!0;const i=void 0!==a.enabledDays||void 0!==a.disabledDays?e.toNativeDate().getDay():-1;return!(!a.enabledDays||a.enabledDays.has(i))||(!(!a.disabledKeys||!a.disabledKeys.has(e.toKey()))||!(!a.disabledDays||!a.disabledDays.has(i)))}function r(e,t){return e.from&&e.to?t.isBetween(e.from,e.to):!!e.recurringMonths&&e.recurringMonths.has(t.month)}function l(e,t){let s;for(const a of e)r(a,t)&&(!s||a.priority>s.priority)&&(s=a);return s}function o(e){const{minDate:t,maxDate:s,rules:a}=e,r=i(e),o=null==a?void 0:a.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:i(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return o&&0!==o.length?e=>{const a=l(o,e);if(!a)return n(e,t,s,r);return n(e,a.hasMinDate?a.minDate:t,a.hasMaxDate?a.maxDate:s,{disabledKeys:void 0!==a.sets.disabledKeys?a.sets.disabledKeys:r.disabledKeys,disabledDays:void 0!==a.sets.disabledDays?a.sets.disabledDays:r.disabledDays,enabledKeys:void 0!==a.sets.enabledKeys?a.sets.enabledKeys:r.enabledKeys,enabledDays:void 0!==a.sets.enabledDays?a.sets.enabledDays:r.enabledDays,disabledMonths:void 0!==a.sets.disabledMonths?a.sets.disabledMonths:r.disabledMonths,enabledMonths:void 0!==a.sets.enabledMonths?a.sets.enabledMonths:r.enabledMonths,disabledYears:void 0!==a.sets.disabledYears?a.sets.disabledYears:r.disabledYears,enabledYears:void 0!==a.sets.enabledYears?a.sets.enabledYears:r.enabledYears})}:e=>n(e,t,s,r)}function d(e){const{minRange:t,maxRange:s,rules:a}=e;if(void 0===t&&void 0===s&&(!a||a.every(e=>void 0===e.minRange&&void 0===e.maxRange)))return()=>!0;const n=null==a?void 0:a.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:i(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return(e,a)=>{let i=t,r=s;if(n){const t=l(n,e);t&&(void 0!==t.minRange&&(i=t.minRange),void 0!==t.maxRange&&(r=t.maxRange))}const o=e.diffDays(a)+1;return!(void 0!==i&&o<i)&&!(void 0!==r&&o>r)}}function h(e){const{minDate:s,maxDate:a}=e,i=e.disabledMonths?new Set(e.disabledMonths):void 0,n=e.enabledMonths?new Set(e.enabledMonths):void 0,r=e.disabledYears?new Set(e.disabledYears):void 0,l=e.enabledYears?new Set(e.enabledYears):void 0;return(e,o)=>{if(s){if(new t(e,o,1).endOfMonth().isBefore(s))return!0}if(a){if(new t(e,o,1).isAfter(a))return!0}return!(!l||l.has(e))||(!(!r||!r.has(e))||(!(!n||n.has(o))||!(!i||!i.has(o))))}}function c(e){const{minDate:s,maxDate:a}=e,i=e.disabledYears?new Set(e.disabledYears):void 0,n=e.enabledYears?new Set(e.enabledYears):void 0;return e=>{if(s){if(new t(e,12,31).isBefore(s))return!0}if(a){if(new t(e,1,1).isAfter(a))return!0}return!(!n||n.has(e))||!(!i||!i.has(e))}}const u={beforeMinDate:"Before the earliest available date",afterMaxDate:"After the latest available date",disabledDate:"This date is not available",disabledDayOfWeek:"This day of the week is not available",disabledMonth:"This month is not available",disabledYear:"This year is not available",notEnabledDate:"This date is not available",notEnabledDayOfWeek:"This day of the week is not available",notEnabledMonth:"This month is not available",notEnabledYear:"This year is not available"};function m(e,t,s,a,i){const n=[];if(t&&e.isBefore(t))return n.push(i.beforeMinDate),n;if(s&&e.isAfter(s))return n.push(i.afterMaxDate),n;if(a.enabledKeys&&a.enabledKeys.has(e.toKey()))return n;if(a.enabledYears&&!a.enabledYears.has(e.year))return n.push(i.notEnabledYear),n;if(a.disabledYears&&a.disabledYears.has(e.year))return n.push(i.disabledYear),n;if(a.enabledMonths&&!a.enabledMonths.has(e.month))return n.push(i.notEnabledMonth),n;if(a.disabledMonths&&a.disabledMonths.has(e.month))return n.push(i.disabledMonth),n;const r=void 0!==a.enabledDays||void 0!==a.disabledDays?e.toNativeDate().getDay():-1;return a.enabledDays&&!a.enabledDays.has(r)&&n.push(i.notEnabledDayOfWeek),a.disabledKeys&&a.disabledKeys.has(e.toKey())&&n.push(i.disabledDate),a.disabledDays&&a.disabledDays.has(r)&&n.push(i.disabledDayOfWeek),n}function y(e,t){const{minDate:s,maxDate:a,rules:n}=e,r={...u,...t},o=i(e),d=null==n?void 0:n.map((e,t)=>({from:e.from,to:e.to,recurringMonths:e.months?new Set(e.months):void 0,minDate:e.minDate,maxDate:e.maxDate,minRange:e.minRange,maxRange:e.maxRange,sets:i(e),hasMinDate:void 0!==e.minDate,hasMaxDate:void 0!==e.maxDate,priority:e.priority??0,originalIndex:t}));return d&&0!==d.length?e=>{const t=l(d,e);if(!t)return m(e,s,a,o,r);return m(e,t.hasMinDate?t.minDate:s,t.hasMaxDate?t.maxDate:a,{disabledKeys:void 0!==t.sets.disabledKeys?t.sets.disabledKeys:o.disabledKeys,disabledDays:void 0!==t.sets.disabledDays?t.sets.disabledDays:o.disabledDays,enabledKeys:void 0!==t.sets.enabledKeys?t.sets.enabledKeys:o.enabledKeys,enabledDays:void 0!==t.sets.enabledDays?t.sets.enabledDays:o.enabledDays,disabledMonths:void 0!==t.sets.disabledMonths?t.sets.disabledMonths:o.disabledMonths,enabledMonths:void 0!==t.sets.enabledMonths?t.sets.enabledMonths:o.enabledMonths,disabledYears:void 0!==t.sets.disabledYears?t.sets.disabledYears:o.disabledYears,enabledYears:void 0!==t.sets.enabledYears?t.sets.enabledYears:o.enabledYears},r)}:e=>m(e,s,a,o,r)}function f(e,s,i=0,n,r){const l=n??t.today(),o=r??(()=>!1),d=new t(e,s,1),h=(d.toNativeDate().getDay()-i+7)%7,c=d.addDays(-h),u=[],m=[];for(let t=0;t<6;t++){const i=[];for(let a=0;a<7;a++){const n=7*t+a,r=c.addDays(n);i.push({date:r,isCurrentMonth:r.month===s&&r.year===e,isToday:r.isSame(l),isDisabled:o(r)})}const n=i[0];n&&m.push(a(n.date)),u.push(i)}return{year:e,month:s,rows:u,weekNumbers:m}}function b(e,s,a,i){const n=s??t.today(),r=i??(()=>!1),l=[];for(let o=0;o<3;o++){const s=[];for(let i=0;i<4;i++){const l=4*o+i+1,d=new t(e,l,1);s.push({month:l,year:e,label:d.format({month:"short"},a),isCurrentMonth:n.month===l&&n.year===e,isDisabled:r(e,l)})}l.push(s)}return l}function p(e,s,a){const i=s??t.today(),n=a??(()=>!1),r=12*Math.floor(e/12),l=[];for(let t=0;t<3;t++){const e=[];for(let s=0;s<4;s++){const a=r+4*t+s;e.push({year:a,label:String(a),isCurrentYear:i.year===a,isDisabled:n(a)})}l.push(e)}return l}function g(e,t,s,a=0,i,n){const r=[];for(let l=0;l<s;l++){let s=t+l,o=e;for(;s>12;)s-=12,o++;r.push(f(o,s,a,i,n))}return r}class v{constructor(e){this.selected=null,this.selected=e??null}isSelected(e){return null!==this.selected&&this.selected.isSame(e)}toggle(e){null!==this.selected&&this.selected.isSame(e)?this.selected=null:this.selected=e}clear(){this.selected=null}toArray(){return null!==this.selected?[this.selected]:[]}toValue(){return null!==this.selected?this.selected.toISO():""}getSelected(){return this.selected}}class D{constructor(e){if(this.keys=new Set,e)for(const t of e)this.keys.add(t.toKey())}isSelected(e){return this.keys.has(e.toKey())}toggle(e){const t=e.toKey();this.keys.has(t)?this.keys.delete(t):this.keys.add(t)}clear(){this.keys.clear()}toArray(){return[...this.keys].sort().map(e=>t.fromISO(e))}toValue(){return[...this.keys].sort().join(", ")}get count(){return this.keys.size}}class w{constructor(e,t){this.start=null,this.end=null,this.start=e??null,this.end=t??null}isSelected(e){return!(null===this.start||!this.start.isSame(e))||!(null===this.end||!this.end.isSame(e))}toggle(e){null===this.start?this.start=e:null===this.end?e.isBefore(this.start)?(this.end=this.start,this.start=e):e.isSame(this.start)?this.start=null:this.end=e:(this.start=e,this.end=null)}setRange(e,t){this.start=e,this.end=t}clear(){this.start=null,this.end=null}toArray(){return null===this.start?[]:null===this.end?[this.start]:[this.start,this.end]}toValue(){return null===this.start?"":null===this.end?this.start.toISO():`${this.start.toISO()} – ${this.end.toISO()}`}isInRange(e,t){if(null!==this.start&&null!==this.end)return e.isBetween(this.start,this.end);if(null!==this.start&&void 0!==t){const s=this.start.isBefore(t)?this.start:t,a=this.start.isBefore(t)?t:this.start;return e.isBetween(s,a)}return!1}getStart(){return this.start}getEnd(){return this.end}isPartial(){return null!==this.start&&null===this.end}isComplete(){return null!==this.start&&null!==this.end}}const _={YYYY:e=>String(e.year).padStart(4,"0"),YY:e=>String(e.year%100).padStart(2,"0"),MM:e=>String(e.month).padStart(2,"0"),M:e=>String(e.month),DD:e=>String(e.day).padStart(2,"0"),D:e=>String(e.day)},x=Object.keys(_).sort((e,t)=>t.length-e.length);function S(e,t){let s=t,a="";for(;s.length>0;){let t=!1;for(const i of x)if(s.startsWith(i)){const n=_[i];if(n){a+=n(e),s=s.slice(i.length),t=!0;break}}t||(a+=s[0],s=s.slice(1))}return a}function M(e,t,s){return`${S(e,s)} – ${S(t,s)}`}function k(e,t,s){return 0===e.length?"":void 0!==s&&e.length>s?`${e.length} dates selected`:e.map(e=>S(e,t)).join(", ")}const Y={YYYY:{pattern:"(\\d{4})",extract:e=>Number(e)},YY:{pattern:"(\\d{2})",extract:e=>2e3+Number(e)},MM:{pattern:"(\\d{1,2})",extract:e=>Number(e)},M:{pattern:"(\\d{1,2})",extract:e=>Number(e)},DD:{pattern:"(\\d{1,2})",extract:e=>Number(e)},D:{pattern:"(\\d{1,2})",extract:e=>Number(e)}},R=Object.keys(Y).sort((e,t)=>t.length-e.length);function O(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function z(e,a){const i=e.trim();if(""===i)return null;const{regex:n,extractors:r}=function(e){let t=e,s="^";const a=[];let i=1;for(;t.length>0;){let e=!1;for(const n of R)if(t.startsWith(n)){const r=Y[n];if(r){s+=r.pattern,a.push({token:n,index:i}),i++,t=t.slice(n.length),e=!0;break}}e||(s+=O(t[0]),t=t.slice(1))}return s+="$",{regex:new RegExp(s),extractors:a}}(a),l=n.exec(i);if(!l)return null;let o=0,d=0,h=0;for(const{token:t,index:s}of r){const e=l[s];if(void 0===e)return null;const a=Y[t];if(!a)return null;const i=a.extract(e);"YYYY"===t||"YY"===t?o=i:"MM"===t||"M"===t?d=i:"DD"!==t&&"D"!==t||(h=i)}return function(e,t,a){return!(t<1||t>12||a<1||a>s(e,t)||e<1)}(o,d,h)?new t(o,d,h):null}function I(e,s){const a=e.trim();if(""===a)return null;const i=[" – "," — "," - "];for(const n of i){const e=a.indexOf(n);if(-1!==e){const i=a.slice(0,e),r=a.slice(e+n.length),l=z(i,s)??t.fromISO(i.trim()),o=z(r,s)??t.fromISO(r.trim());if(l&&o)return[l,o]}}return null}function $(e,s){const a=e.trim();if(""===a)return[];const i=a.split(","),n=[];for(const r of i){const e=z(r,s)??t.fromISO(r.trim());e&&n.push(e)}return n}const C={YYYY:4,YY:2,MM:2,M:2,DD:2,D:2},T=Object.keys(C).sort((e,t)=>t.length-e.length);function A(e){return e.replace(/\D/g,"")}function L(e){let t=0;for(const s of e)s>="0"&&s<="9"&&t++;return t}function N(e,t){let s="",a=0;for(const i of t)if("digit"===i.type){if(a>=e.length)break;s+=e[a],a++}else{if(!(a>0))break;s+=i.char}return s}function E(e,t,s){if(s<=0)return 0;let a=0;for(let i=0;i<e.length&&i<t.length;i++){const n=t[i];if(n&&"digit"===n.type&&(a++,a===s)){let s=i+1;for(;s<t.length&&s<e.length;){const e=t[s];if(!e||"literal"!==e.type)break;s++}return s}}return e.length}function K(e){const t=[];let s=e;for(;s.length>0;){let e=!1;for(const a of T)if(s.startsWith(a)){const i=C[a];if(void 0===i)continue;for(let e=0;e<i;e++)t.push({type:"digit",char:"9"});s=s.slice(a.length),e=!0;break}e||(t.push({type:"literal",char:s[0]}),s=s.slice(1))}return t}function V(e){const t=K(e),s=t.filter(e=>"digit"===e.type).length,a=t.map(e=>"digit"===e.type?"9":e.char).join("");return{apply:e=>N(A(e).slice(0,s),t),get pattern(){return a},get format(){return e},get length(){return t.length},get slots(){return t},get maxDigits(){return s}}}function W(e){const{slots:t,maxDigits:s}=e;return{onInput:function(e){const a=e.target,i=a.value,n=a.selectionStart??i.length,r=L(i.slice(0,n)),l=N(A(i).slice(0,s),t);a.value=l;const o=E(l,t,r);a.setSelectionRange(o,o)},onKeyDown:function(e){const s=e.target,a=s.selectionStart??0;if(a===(s.selectionEnd??a)){if("Backspace"===e.key&&a>0){const i=a<=t.length?t[a-1]:void 0;if(i&&"literal"===i.type){e.preventDefault();let i=a-1;for(;i>0;){const e=t[i-1];if(!e||"literal"!==e.type)break;i--}if(i>0){const e=A(s.value),a=L(s.value.slice(0,i));if(a>0){const i=N(e.slice(0,a-1)+e.slice(a),t);s.value=i;const n=E(i,t,a-1);s.setSelectionRange(n,n)}}}}if("Delete"===e.key&&a<s.value.length){const i=a<t.length?t[a]:void 0;if(i&&"literal"===i.type){e.preventDefault();let i=a+1;for(;i<t.length;){const e=t[i];if(!e||"literal"!==e.type)break;i++}if(i<s.value.length){const e=A(s.value),a=L(s.value.slice(0,i)),n=N(e.slice(0,a)+e.slice(a+1),t);s.value=n;const r=E(n,t,a);s.setSelectionRange(r,r)}}}}},onPaste:function(e){var a;e.preventDefault();const i=e.target,n=A((null==(a=e.clipboardData)?void 0:a.getData("text"))??"");if(0===n.length)return;const r=i.selectionStart??0,l=i.selectionEnd??r,o=A(i.value),d=L(i.value.slice(0,r)),h=L(i.value.slice(r,l)),c=N((o.slice(0,d)+n+o.slice(d+h)).slice(0,s),t);i.value=c;const u=Math.min(d+n.length,s),m=E(c,t,u);i.setSelectionRange(m,m)}}}function F(e,t){const s=V(t),a=W(s);return e.addEventListener("input",a.onInput),e.addEventListener("keydown",a.onKeyDown),e.addEventListener("paste",a.onPaste),e.value&&(e.value=s.apply(e.value)),()=>{e.removeEventListener("input",a.onInput),e.removeEventListener("keydown",a.onKeyDown),e.removeEventListener("paste",a.onPaste)}}function B(e){return Array.from({length:6},(t,s)=>function(e,t){return`<div class="${t?"rc-row rc-row--week-numbers":"rc-row"}" x-show="mg.rows.length > ${e}">\n ${t?`<div class="rc-week-number" x-text="mg.weekNumbers[${e}]"></div>`:""}<template x-for="cell in (mg.rows[${e}] || [])" :key="cell.date.toISO()">\n <div :class="dayClasses(cell)" :id="'day-' + cell.date.toISO()" :aria-selected="isSelected(cell.date)" :aria-disabled="cell.isDisabled" :title="dayTitle(cell)" role="option" tabindex="-1" @click="!cell.isDisabled && selectDate(cell.date)" @mouseenter="hoverDate = cell.date" @mouseleave="hoverDate = null" x-text="cell.date.day"></div>\n </template>\n </div>`}(s,e)).join("\n ")}function G(e){const{display:t,isDualMonth:s,isWizard:a,hasName:i,showWeekNumbers:n,hasPresets:r,isScrollable:l,scrollHeight:o}=e,d="popup"===t,h=a?"rc-calendar rc-calendar--wizard":"rc-calendar",c=a?"Birth date wizard":"Calendar",u=[];d&&u.push(function(e){return`<div class="rc-popup-header">\n ${e?'<span class="rc-popup-header__title" x-text="wizardStepLabel"></span>':'<span class="rc-popup-header__title">Select Date</span>'}\n <button class="rc-popup-header__close" @click="close()" aria-label="Close calendar"><svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><line x1="4" y1="4" x2="12" y2="12"/><line x1="12" y1="4" x2="4" y2="12"/></svg></button>\n</div>`}(a)),a&&u.push('<div class="rc-wizard-steps">\n <template x-for="step in wizardTotalSteps" :key="step">\n <div class="rc-wizard-step" :class="{ \'rc-wizard-step--active\': wizardStep === step, \'rc-wizard-step--done\': wizardStep > step }"></div>\n </template>\n</div>\n<div class="rc-wizard-label" x-text="wizardStepLabel"></div>\n<template x-if="wizardStep > 1">\n <button class="rc-wizard-back" @click="wizardBack()" aria-label="Go back">&#8249; Back</button>\n</template>'),u.push('<template x-if="view === \'years\'">\n <div class="rc-view-enter">\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous decade">&#8249;</button>\n <span class="rc-header__label" x-text="decadeLabel"></span>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next decade">&#8250;</button>\n </div>\n <div class="rc-year-grid" role="group" :aria-label="decadeLabel">\n <template x-for="cell in yearGrid.flat()" :key="cell.year">\n <div :class="yearClasses(cell)" :aria-disabled="cell.isDisabled" tabindex="-1" @click="!cell.isDisabled && selectYear(cell.year)" x-text="cell.label"></div>\n </template>\n </div>\n </div>\n</template>'),u.push('<template x-if="view === \'months\'">\n <div class="rc-view-enter">\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous year">&#8249;</button>\n <button class="rc-header__label" @click="setView(\'years\')" aria-label="Change view" x-text="yearLabel"></button>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next year">&#8250;</button>\n </div>\n <div class="rc-month-grid" role="group" :aria-label="yearLabel">\n <template x-for="cell in monthGrid.flat()" :key="cell.month">\n <div :class="monthClasses(cell)" :aria-disabled="cell.isDisabled" tabindex="-1" @click="!cell.isDisabled && selectMonth(cell.month)" x-text="cell.label"></div>\n </template>\n </div>\n </div>\n</template>'),l?u.push(function(e,t){return`<template x-if="view === 'days'">\n <div>\n <div class="rc-header rc-header--scroll-sticky">\n <span class="rc-header__label rc-header__label--scroll" x-text="scrollHeaderLabel"></span>\n </div>\n ${e?'<div class="rc-weekdays rc-weekdays--week-numbers">\n <span class="rc-weekday rc-week-label"></span>\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>':'<div class="rc-weekdays">\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>'}\n <div class="rc-months rc-months--scroll" style="max-height: ${t}px">\n <template x-for="(mg, gi) in grid" :key="mg.year + '-' + mg.month">\n <div :data-month-id="'month-' + mg.year + '-' + mg.month">\n <div class="rc-header rc-header--scroll" x-show="gi > 0">\n <span class="rc-header__label rc-header__label--scroll" x-text="monthYearLabel(gi)"></span>\n </div>\n <div class=${e?'"rc-grid rc-grid--week-numbers"':'"rc-grid"'} role="listbox" :aria-label="monthYearLabel(gi)">\n ${B(e)}\n </div>\n </div>\n </template>\n </div>\n </div>\n</template>`}(n,o)):u.push(function(e,t){return`<template x-if="view === 'days'">\n <div class="rc-months${e?"":" rc-view-enter"}"${e?" :class=\"{ 'rc-months--dual': monthCount === 2 }\"":""}>\n <template x-for="(mg, gi) in grid" :key="mg.year + '-' + mg.month">\n <div>\n <div class="rc-header">\n <button class="rc-header__nav" @click="prev()" :disabled="!canGoPrev" aria-label="Previous month"${e?" :style=\"gi > 0 ? 'visibility:hidden' : ''\"":""}>&#8249;</button>\n <button class="rc-header__label" @click="setView('months')" aria-label="Change view" x-text="monthYearLabel(gi)"></button>\n <button class="rc-header__nav" @click="next()" :disabled="!canGoNext" aria-label="Next month"${e?" :style=\"gi < grid.length - 1 ? 'visibility:hidden' : ''\"":""}>&#8250;</button>\n </div>\n ${t?'<div class="rc-weekdays rc-weekdays--week-numbers">\n <span class="rc-weekday rc-week-label"></span>\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>':'<div class="rc-weekdays">\n <template x-for="wd in weekdayHeaders" :key="wd">\n <span class="rc-weekday" x-text="wd"></span>\n </template>\n </div>'}\n <div class="rc-grid-wrapper">\n <div class=${t?'"rc-grid rc-grid--week-numbers"':'"rc-grid"'} :class="{ 'rc-grid--slide-next': _navDirection === 'next', 'rc-grid--slide-prev': _navDirection === 'prev' }" @animationend="_navDirection = ''" role="listbox" :aria-label="monthYearLabel(gi)">\n ${B(t)}\n </div>\n </div>\n </div>\n </template>\n </div>\n</template>`}(s,n)),r&&u.push('<div class="rc-presets" role="group" aria-label="Quick select">\n <template x-for="(preset, pi) in presets" :key="pi">\n <button class="rc-preset" @click="applyPreset(pi)" x-text="preset.label"></button>\n </template>\n</div>'),a&&u.push('<div class="rc-wizard-summary" x-show="wizardSummary" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 transform translate-y-1" x-transition:enter-end="opacity-100 transform translate-y-0" x-text="wizardSummary"></div>'),i&&u.push('<template x-if="inputName">\n <template x-for="val in hiddenInputValues" :key="val">\n <input type="hidden" :name="inputName" :value="val">\n </template>\n</template>');const m=`<div class="${h}" @keydown="handleKeydown($event)" tabindex="0" :aria-activedescendant="focusedDateISO ? 'day-' + focusedDateISO : null" role="application" aria-label="${c}">\n<div class="rc-sr-only" role="status" aria-live="polite" aria-atomic="true" x-text="_statusMessage"></div>\n${u.join("\n")}\n</div>`;return d?`<div x-ref="popup" x-show="isOpen" :style="popupStyle" class="rc-popup-overlay" @click.self="close()" role="dialog" aria-modal="true" :aria-label="popupAriaLabel" x-transition:enter="transition ease-out duration-150" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition ease-in duration-100" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0">\n${m}\n</div>`:m}function P(e){return t.fromISO(e)}function H(e){return e.map(e=>t.fromISO(e)).filter(e=>null!==e)}function U(e,s){const a={};if(e.minDate){const s=t.fromISO(e.minDate);s&&(a.minDate=s)}if(e.maxDate){const s=t.fromISO(e.maxDate);s&&(a.maxDate=s)}if(e.disabledDates&&(a.disabledDates=H(e.disabledDates)),e.disabledDaysOfWeek&&(a.disabledDaysOfWeek=e.disabledDaysOfWeek),e.enabledDates&&(a.enabledDates=H(e.enabledDates)),e.enabledDaysOfWeek&&(a.enabledDaysOfWeek=e.enabledDaysOfWeek),e.disabledMonths&&(a.disabledMonths=e.disabledMonths),e.enabledMonths&&(a.enabledMonths=e.enabledMonths),e.disabledYears&&(a.disabledYears=e.disabledYears),e.enabledYears&&(a.enabledYears=e.enabledYears),void 0!==e.minRange&&(a.minRange=e.minRange),void 0!==e.maxRange&&(a.maxRange=e.maxRange),e.rules){const t=e.rules.map(e=>function(e){const t=e.from?P(e.from):null,s=e.to?P(e.to):null,a=null!==t&&null!==s,i=Array.isArray(e.months)&&e.months.length>0;if(!a&&!i)return null;const n={};if(a&&(n.from=t,n.to=s),i&&(n.months=e.months),void 0!==e.priority&&(n.priority=e.priority),e.minDate){const t=P(e.minDate);t&&(n.minDate=t)}if(e.maxDate){const t=P(e.maxDate);t&&(n.maxDate=t)}return e.disabledDates&&(n.disabledDates=H(e.disabledDates)),e.disabledDaysOfWeek&&(n.disabledDaysOfWeek=e.disabledDaysOfWeek),e.enabledDates&&(n.enabledDates=H(e.enabledDates)),e.enabledDaysOfWeek&&(n.enabledDaysOfWeek=e.enabledDaysOfWeek),e.disabledMonths&&(n.disabledMonths=e.disabledMonths),e.enabledMonths&&(n.enabledMonths=e.enabledMonths),e.disabledYears&&(n.disabledYears=e.disabledYears),e.enabledYears&&(n.enabledYears=e.enabledYears),void 0!==e.minRange&&(n.minRange=e.minRange),void 0!==e.maxRange&&(n.maxRange=e.maxRange),n}(e)).filter(e=>null!==e);t.length>0&&(a.rules=t)}return{isDisabledDate:o(a),isRangeValid:d(a),isMonthDisabled:h(a),isYearDisabled:c(a),getDisabledReasons:y(a,s)}}const j=["minDate","maxDate","disabledDates","disabledDaysOfWeek","enabledDates","enabledDaysOfWeek","disabledMonths","enabledMonths","disabledYears","enabledYears","minRange","maxRange","rules"];function q(e){const t={};for(const s of j)void 0!==e[s]&&(t[s]=e[s]);return t}function Z(e={},s){!function(e){const s=e=>console.warn(`[reach-calendar] ${e}`);if(void 0!==e.months&&(e.months<1||!Number.isInteger(e.months))&&s(`months must be a positive integer, got: ${e.months}`),e.wizard&&e.months&&e.months>=3&&s("months >= 3 (scrollable) is not compatible with wizard mode; using months: 1"),void 0!==e.firstDay&&(e.firstDay<0||e.firstDay>6)&&s(`firstDay must be 0-6, got: ${e.firstDay}`),e.minDate&&!t.fromISO(e.minDate)&&s(`invalid minDate: "${e.minDate}"`),e.maxDate&&!t.fromISO(e.maxDate)&&s(`invalid maxDate: "${e.maxDate}"`),e.minDate&&e.maxDate){const a=t.fromISO(e.minDate),i=t.fromISO(e.maxDate);a&&i&&a.isAfter(i)&&s(`minDate "${e.minDate}" is after maxDate "${e.maxDate}"`)}if(void 0!==e.minRange&&void 0!==e.maxRange&&e.minRange>e.maxRange&&s(`minRange (${e.minRange}) exceeds maxRange (${e.maxRange})`),e.wizard&&e.mode&&"single"!==e.mode&&s(`wizard mode is designed for single selection; mode "${e.mode}" may not work as expected`),e.timezone)try{Intl.DateTimeFormat(void 0,{timeZone:e.timezone})}catch{s(`invalid timezone: "${e.timezone}"`)}}(e);const a=e.mode??"single",i=e.display??"inline",n=e.format??"DD/MM/YYYY",r=e.firstDay??0;let l=e.timezone;if(l)try{Intl.DateTimeFormat(void 0,{timeZone:l})}catch{l=void 0}const o=e.wizard??!1,d=e.months??1,h=o&&d>=3?1:d,c=h>=3,u=e.scrollHeight??400,m=!!o,y=!0===o?"full":!1===o?"none":o,f="none"===y?0:"full"===y?3:2,_="full"===y||"year-month"===y?"years":"month-day"===y?"months":"days",x=e.mask??!0,Y=e.showWeekNumbers??!1,R=e.presets??[],O=e.name??"",C=e.inputId??null,T=e.inputRef??"rc-input",A=e.locale,L=e.closeOnSelect??!0,N=e.beforeSelect??null,E=e.constraintMessages,K=U(e,E);const V="multiple"===a?new D:"range"===a?new w:new v;if(e.value)if("single"===a){const s=z(e.value,n)??t.fromISO(e.value);s&&!K.isDisabledDate(s)&&V.toggle(s)}else if("range"===a){const t=I(e.value,n);if(t){let[e,s]=t;if(s.isBefore(e)){const t=e;e=s,s=t}K.isDisabledDate(e)||K.isDisabledDate(s)||!K.isRangeValid(e,s)||(V.toggle(e),V.toggle(s))}}else if("multiple"===a){const t=$(e.value,n);for(const e of t)K.isDisabledDate(e)||V.toggle(e)}const W=t.today(l),B=V.toArray(),P=B.length>0?B[0]:W,H="full"===y||"year-month"===y?new t(W.year-30,W.month,W.day):P;function Z(e){const t=e.toArray();if(0===t.length)return"";const s=t[0];return"range"===a&&2===t.length?M(s,t[1],n):"multiple"===a?k(t,n):S(s,n)}return{mode:a,display:i,format:n,monthCount:h,firstDay:r,wizard:m,wizardMode:y,wizardTotalSteps:f,showWeekNumbers:Y,presets:R,inputName:O,month:H.month,year:H.year,view:m?_:"days",isOpen:"inline"===i,grid:[],monthGrid:[],yearGrid:[],inputValue:Z(V),popupStyle:"popup"===i?"position:fixed;inset:0;z-index:50;":"",focusedDate:null,hoverDate:null,wizardStep:m?1:0,_wizardYear:null,_wizardMonth:null,_wizardDay:null,_navDirection:"",_selection:V,_today:W,_constraintConfig:q(e),_isDisabledDate:K.isDisabledDate,_isRangeValid:K.isRangeValid,_isMonthDisabled:K.isMonthDisabled,_isYearDisabled:K.isYearDisabled,_getDisabledReasons:K.getDisabledReasons,_inputEl:null,_detachInput:null,_syncing:!1,_suppressFocusOpen:!1,_Alpine:s??null,_autoRendered:!1,isScrollable:c,_scrollHeight:u,_scrollContainerEl:null,_scrollObserver:null,_scrollVisibleIndex:0,_selectionRev:0,_statusMessage:"",get selectedDates(){return this._selection.toArray()},get formattedValue(){return Z(this._selection)},get hiddenInputValues(){return this._selection.toArray().map(e=>e.toISO())},get focusedDateISO(){return this.focusedDate?this.focusedDate.toISO():""},get inputId(){return C},get inputAriaLabel(){return"range"===a?"Select date range":"multiple"===a?"Select dates":m?"Select birth date":"Select date"},get popupAriaLabel(){return m?"Birth date wizard":"range"===a?"Date range picker":"Date picker"},get wizardStepLabel(){return this.wizard?"full"===y?1===this.wizardStep?"Select Year":2===this.wizardStep?"Select Month":"Select Day":"year-month"===y?1===this.wizardStep?"Select Year":"Select Month":"month-day"===y?1===this.wizardStep?"Select Month":"Select Day":"":""},get wizardSummary(){if(!m)return"";const e=[];if(null!==this._wizardYear&&e.push(String(this._wizardYear)),null!==this._wizardMonth){const s=new t(this._wizardYear??this.year,this._wizardMonth,1);e.push(s.format({month:"long"},A))}return null!==this._wizardDay&&e.push(String(this._wizardDay)),e.join(" · ")},get weekdayHeaders(){const e=[],t=new Date(2026,0,4);for(let s=0;s<7;s++){const a=(this.firstDay+s)%7,i=new Date(t);i.setDate(t.getDate()+a),e.push(new Intl.DateTimeFormat(A,{weekday:"short"}).format(i))}return e},init(){var t;const s=this.$el;if(!(null!==s.querySelector(".rc-calendar"))&&!1!==e.template&&(null==(t=this._Alpine)?void 0:t.initTree)){const e=document.createRange().createContextualFragment(G({display:this.display,isDualMonth:2===this.monthCount,isWizard:"none"!==this.wizardMode,hasName:!!this.inputName,showWeekNumbers:this.showWeekNumbers,hasPresets:this.presets.length>0,isScrollable:this.isScrollable,scrollHeight:this._scrollHeight})),t=Array.from(e.children).filter(e=>e instanceof HTMLElement);s.appendChild(e);for(const s of t)this._Alpine.initTree(s);this._autoRendered=!0}this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this.$watch("month",()=>{this._rebuildGrid(),this._emitNavigate(),this._announceNavigation(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})}),this.$watch("year",()=>{this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this._emitNavigate(),this._announceNavigation(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})}),this.$watch("view",()=>{this._emitViewChange(),this._announceViewChange()}),this.$nextTick(()=>{const e=this.$refs;e&&e[T]&&e[T]instanceof HTMLInputElement?this.bindInput(e[T]):"popup"===this.display&&console.warn(`[reach-calendar] Popup mode requires an <input x-ref="${T}"> inside the component container.`),this.isScrollable&&this._initScrollListener()})},destroy(){var e,t;if(this._scrollObserver&&(this._scrollObserver.disconnect(),this._scrollObserver=null),this._scrollContainerEl=null,this._detachInput&&(this._detachInput(),this._detachInput=null),this._inputEl=null,this._autoRendered){const s=this.$el;null==(e=s.querySelector(".rc-popup-overlay"))||e.remove(),null==(t=s.querySelector(".rc-calendar"))||t.remove(),this._autoRendered=!1}},_rebuildGrid(){this.grid=g(this.year,this.month,this.monthCount,this.firstDay,this._today,this._isDisabledDate)},_rebuildMonthGrid(){this.monthGrid=b(this.year,this._today,A,this._isMonthDisabled)},_rebuildYearGrid(){this.yearGrid=p(this.year,this._today,this._isYearDisabled)},dayGridItems(e){const t=[];for(let s=0;s<e.rows.length;s++){const a=e.rows[s];if(!a||0===a.length)continue;const i=a[0];t.push({isWeekNumber:!0,weekNumber:e.weekNumbers[s]??0,cell:i,key:`wn-${s}`});for(const e of a)t.push({isWeekNumber:!1,weekNumber:0,cell:e,key:e.date.toISO()})}return t},get yearLabel(){return String(this.year)},get decadeLabel(){const e=12*Math.floor(this.year/12);return`${e} – ${e+11}`},get canGoPrev(){if("days"===this.view){if(this.isScrollable)return!1;const e=new t(this.year,this.month,1).addMonths(-1);return!this._isMonthDisabled(e.year,e.month)}if("months"===this.view)return!this._isYearDisabled(this.year-1);if("years"===this.view){const e=12*Math.floor(this.year/12);for(let t=e-12;t<e;t++)if(!this._isYearDisabled(t))return!0;return!1}return!0},get canGoNext(){if("days"===this.view){if(this.isScrollable)return!1;const e=new t(this.year,this.month,1).addMonths(1);return!this._isMonthDisabled(e.year,e.month)}if("months"===this.view)return!this._isYearDisabled(this.year+1);if("years"===this.view){const e=12*Math.floor(this.year/12);for(let t=e+12;t<e+24;t++)if(!this._isYearDisabled(t))return!0;return!1}return!0},yearClasses(e){const t=this.year===e.year&&"months"===this.view;return{"rc-year":!0,"rc-year--current":e.isCurrentYear,"rc-year--selected":t,"rc-year--disabled":e.isDisabled}},monthClasses(e){const t=this.month===e.month&&"days"===this.view;return{"rc-month":!0,"rc-month--current":e.isCurrentMonth,"rc-month--selected":t,"rc-month--disabled":e.isDisabled}},monthYearLabel(e){const s=this.grid[e];if(!s)return"";return new t(s.year,s.month,1).format({month:"long",year:"numeric"},A)},dayClasses(e){this._selectionRev;const t=e.date,s=this.isSelected(t),i=this.isRangeStart(t),n=this.isRangeEnd(t),r=this.isInRange(t,this.hoverDate??void 0),l=!e.isCurrentMonth;let o=!1;return"range"!==a||null===this.hoverDate||e.isDisabled||s||!this._selection.isPartial()||(o=!this.isDateSelectableForRange(t)),{"rc-day":!0,"rc-day--today":e.isToday,"rc-day--selected":s,"rc-day--range-start":i,"rc-day--range-end":n,"rc-day--in-range":r&&!i&&!n,"rc-day--disabled":e.isDisabled,"rc-day--other-month":l,"rc-day--hidden":l&&this.monthCount>1,"rc-day--focused":null!==this.focusedDate&&this.focusedDate.isSame(t),"rc-day--range-invalid":o}},dayTitle(e){return e.isDisabled?this._getDisabledReasons(e.date).join("; "):""},bindInput(e){this._detachInput&&(this._detachInput(),this._detachInput=null),this._inputEl=e,e.value=this.inputValue,x&&(this._detachInput=F(e,n),this.inputValue=e.value);const t=()=>{this._syncing||(this.inputValue=e.value)};e.addEventListener("input",t);const s=()=>this.handleFocus(),a=()=>this.handleBlur();e.addEventListener("focus",s),e.addEventListener("blur",a),"popup"===i&&(e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded",String(this.isOpen)),e.setAttribute("autocomplete","off"),C&&!e.id&&(e.id=C),e.getAttribute("aria-label")||e.setAttribute("aria-label",this.inputAriaLabel));const r=this._detachInput;this._detachInput=()=>{null==r||r(),e.removeEventListener("input",t),e.removeEventListener("focus",s),e.removeEventListener("blur",a),"popup"===i&&(e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("autocomplete"))},e.placeholder||(e.placeholder=n.toLowerCase())},handleInput(e){const t=e.target;this.inputValue=t.value},handleFocus(){this._suppressFocusOpen?this._suppressFocusOpen=!1:this.open()},handleBlur(){const e=this._inputEl?this._inputEl.value:this.inputValue;if(!e.trim())return this._selection.toArray().length>0&&(this._selection.clear(),this._selectionRev++,this._emitChange()),void this._syncInputFromSelection();let s=!1;if("single"===a){const a=z(e,n)??t.fromISO(e);a&&!this._isDisabledDate(a)&&(this._selection.clear(),this._selection.toggle(a),this.month=a.month,this.year=a.year,s=!0)}else if("range"===a){const t=I(e,n);if(t){let[e,a]=t;if(a.isBefore(e)){const t=e;e=a,a=t}this._isDisabledDate(e)||this._isDisabledDate(a)||!this._isRangeValid(e,a)||(this._selection.clear(),this._selection.toggle(e),this._selection.toggle(a),this.month=e.month,this.year=e.year,s=!0)}}else if("multiple"===a){const t=$(e,n).filter(e=>!this._isDisabledDate(e));if(t.length>0){this._selection.clear();for(const s of t)this._selection.toggle(s);const e=t[0];this.month=e.month,this.year=e.year,s=!0}}s&&(this._selectionRev++,this._emitChange()),this._syncInputFromSelection()},_syncInputFromSelection(){this._syncing=!0,this.inputValue=this.formattedValue,this._inputEl&&(this._inputEl.value=this.inputValue),this._syncing=!1},_announce(e){this._statusMessage="",this.$nextTick(()=>{this._statusMessage=e})},_announceNavigation(){if("days"===this.view)if(this.monthCount>1&&!this.isScrollable){const e=[];for(let t=0;t<this.grid.length;t++)e.push(this.monthYearLabel(t));this._announce(e.join(" – "))}else this._announce(this.monthYearLabel(0));else"months"===this.view?this._announce("Year: "+this.year):"years"===this.view&&this._announce("Decade: "+this.decadeLabel)},_announceViewChange(){"days"===this.view?this._announce(this.monthYearLabel(0)):"months"===this.view?this._announce("Select month, "+this.year):"years"===this.view&&this._announce("Select year, "+this.decadeLabel)},_emitChange(){this.$dispatch("calendar:change",{value:this._selection.toValue(),dates:this._selection.toArray().map(e=>e.toISO()),formatted:this.formattedValue})},_emitNavigate(){this.$dispatch("calendar:navigate",{year:this.year,month:this.month,view:this.view})},_emitViewChange(){this.$dispatch("calendar:view-change",{view:this.view,year:this.year,month:this.month})},prev(){if(this._navDirection="prev","days"===this.view){if(this.isScrollable)return;const e=new t(this.year,this.month,1).addMonths(-1);this.month=e.month,this.year=e.year}else"months"===this.view?this.year--:"years"===this.view&&(this.year-=12)},next(){if(this._navDirection="next","days"===this.view){if(this.isScrollable)return;const e=new t(this.year,this.month,1).addMonths(1);this.month=e.month,this.year=e.year}else"months"===this.view?this.year++:"years"===this.view&&(this.year+=12)},goToToday(){this.month=this._today.month,this.year=this._today.year,this.view="days"},selectDate(e){const s="string"==typeof e?t.fromISO(e):e;if(!s)return;if(this._isDisabledDate(s))return;if("range"===a){const e=this._selection,t=e.getStart();if(e.isPartial()&&t&&!s.isSame(t)){let e=t,a=s;if(a.isBefore(e)){const t=e;e=a,a=t}if(!this._isRangeValid(e,a))return}}if(N){const e=this._selection.isSelected(s)?"deselect":"select";if(!1===N(s,{mode:a,selectedDates:this._selection.toArray(),action:e}))return}const n=this._selection.isSelected(s),r="range"===a&&this._selection.isPartial();this._selection.toggle(s),m&&(this._wizardDay=s.day),this._selectionRev++,this._emitChange(),this._syncInputFromSelection();const l=s.format({weekday:"long",month:"long",day:"numeric",year:"numeric"},A);if("single"===a)this._announce(l+" selected");else if("multiple"===a){const e=this._selection.toArray().length;n?this._announce(l+" deselected. "+e+" dates selected"):this._announce(l+" selected. "+e+" dates selected")}else if("range"===a){const e=this._selection;if(e.isPartial())this._announce("Range start: "+l+". Select end date");else if(r){const t=e.toArray();if(2===t.length){const e=t[0].format({weekday:"long",month:"long",day:"numeric",year:"numeric"},A),s=t[1].format({weekday:"long",month:"long",day:"numeric",year:"numeric"},A);this._announce("Range: "+e+" to "+s)}}}if(L&&"popup"===i&&this.isOpen){("single"===a||"range"===a&&!this._selection.isPartial()||"multiple"===a)&&this.close()}},isSelected(e){return this._selection.isSelected(e)},isInRange(e,t){return"range"===a&&this._selection.isInRange(e,t)},isRangeStart(e){if("range"!==a)return!1;const t=this._selection.getStart();return null!==t&&e.isSame(t)},isRangeEnd(e){if("range"!==a)return!1;const t=this._selection.getEnd();return null!==t&&e.isSame(t)},isDateSelectableForRange(e){if("range"!==a)return!1;if(this._isDisabledDate(e))return!1;const t=this._selection;if(!t.isPartial())return!0;const s=t.getStart();if(!s)return!0;if(e.isSame(s))return!0;let i=s,n=e;if(n.isBefore(i)){const e=i;i=n,n=e}return this._isRangeValid(i,n)},getDisabledReason(e){const s="string"==typeof e?t.fromISO(e):e;return s?this._getDisabledReasons(s):[]},clearSelection(){this._selection.clear(),this._selectionRev++,this._emitChange(),this._syncInputFromSelection(),this._announce("Selection cleared")},setValue(e){this._selection.clear();const s=[];if("string"==typeof e){const a=t.fromISO(e)??z(e,n);a&&!this._isDisabledDate(a)&&s.push(a)}else if(Array.isArray(e))for(const a of e){const e="string"==typeof a?t.fromISO(a)??z(a,n):a;e&&!this._isDisabledDate(e)&&s.push(e)}else e instanceof t&&(this._isDisabledDate(e)||s.push(e));if("range"===a&&2===s.length){let[e,t]=s;if(t.isBefore(e)){const s=e;e=t,t=s}if(!this._isRangeValid(e,t))return this._selectionRev++,this._emitChange(),void this._syncInputFromSelection();this._selection.setRange(e,t)}else for(const t of s)this._selection.toggle(t);const i=this._selection.toArray();if(i.length>0){const e=i[0];this.month=e.month,this.year=e.year}this._selectionRev++,this._emitChange(),this._syncInputFromSelection()},clear(){this.clearSelection()},goTo(e,t){this.year=e,void 0!==t&&(this.month=t),this.view="days",this.isScrollable&&(this._rebuildGrid(),this.$nextTick(()=>{this._rebindScrollObserver(),this._scrollToMonth(e,t??this.month)}))},getSelection(){return[...this._selection.toArray()]},applyPreset(e){const t=this.presets[e];if(!t)return;const[s,i]=t.value();"single"===a?this.setValue(s):this.setValue([s,i]),"popup"===this.display&&L&&this.close()},updateConstraints(e){const t={...this._constraintConfig};for(const a of j)a in e&&(t[a]=e[a]);this._constraintConfig=t;const s=U(t,E);this._isDisabledDate=s.isDisabledDate,this._isRangeValid=s.isRangeValid,this._isMonthDisabled=s.isMonthDisabled,this._isYearDisabled=s.isYearDisabled,this._getDisabledReasons=s.getDisabledReasons,this._rebuildGrid(),this._rebuildMonthGrid(),this._rebuildYearGrid(),this.isScrollable&&this.$nextTick(()=>{this._rebindScrollObserver()})},setView(e){this.view=e},selectMonth(e){if(!this._isMonthDisabled(this.year,e)){if(this.month=e,this._wizardMonth=e,"year-month"===y)return this.wizardStep=f,void this.selectDate(new t(this.year,e,1));this.view="days",m&&(this.wizardStep="month-day"===y?2:3)}},selectYear(e){this._isYearDisabled(e)||(this.year=e,this._wizardYear=e,this.view="months",this.wizard&&(this.wizardStep=2))},wizardBack(){this.wizard&&("full"===y?3===this.wizardStep?(this.wizardStep=2,this.view="months",this._wizardMonth=null,this._wizardDay=null):2===this.wizardStep&&(this.wizardStep=1,this.view="years",this._wizardYear=null,this._wizardMonth=null):"year-month"===y?2===this.wizardStep&&(this.wizardStep=1,this.view="years",this._wizardYear=null,this._wizardMonth=null):"month-day"===y&&2===this.wizardStep&&(this.wizardStep=1,this.view="months",this._wizardMonth=null))},open(){var e;"popup"===this.display&&(m&&(this.wizardStep=1,this.view=_,this._wizardYear=null,this._wizardMonth=null,this._wizardDay=null,"month-day"!==y&&(this.year=this._today.year-30,this._rebuildYearGrid())),this.isOpen=!0,null==(e=this._inputEl)||e.setAttribute("aria-expanded","true"),this.$dispatch("calendar:open"),this.$nextTick(()=>{}))},close(){var e;"popup"===this.display&&(this.isOpen=!1,null==(e=this._inputEl)||e.setAttribute("aria-expanded","false"),this.$dispatch("calendar:close"))},toggle(){this.isOpen?this.close():this.open()},handleKeydown(e){if("Escape"===e.key)return e.preventDefault(),e.stopPropagation(),this.wizard&&this.wizardStep>1?void this.wizardBack():"months"===this.view||"years"===this.view?void(this.view="days"):void("popup"===i&&this.isOpen&&(this.close(),this._inputEl&&(this._suppressFocusOpen=!0,this._inputEl.focus())));if("days"===this.view)switch(e.key){case"ArrowRight":case"ArrowLeft":case"ArrowDown":case"ArrowUp":case"PageDown":case"PageUp":case"Home":case"End":if(e.preventDefault(),!this.focusedDate){const e=this._selection.toArray();e.length>0?this.focusedDate=e[0]:this.focusedDate=new t(this.year,this.month,1)}return void("ArrowRight"===e.key?this._moveFocus(1):"ArrowLeft"===e.key?this._moveFocus(-1):"ArrowDown"===e.key?this._moveFocus(7):"ArrowUp"===e.key?this._moveFocus(-7):"PageDown"===e.key?this._moveFocusByMonths(e.shiftKey?12:1):"PageUp"===e.key?this._moveFocusByMonths(e.shiftKey?-12:-1):"Home"===e.key?this._setFocusedDate(new t(this.year,this.month,1)):"End"===e.key&&this._setFocusedDate(new t(this.year,this.month,1).endOfMonth()));case"Enter":case" ":return void(this.focusedDate&&(e.preventDefault(),this.selectDate(this.focusedDate)))}},_moveFocus(e){if(!this.focusedDate)return;let t=this.focusedDate.addDays(e),s=0;for(;this._isDisabledDate(t)&&s<31;)t=t.addDays(e>0?1:-1),s++;this._isDisabledDate(t)||this._setFocusedDate(t)},_moveFocusByMonths(e){if(!this.focusedDate)return;const t=this.focusedDate.addMonths(e);this._setFocusedDate(t)},_setFocusedDate(e){this.focusedDate=e,this.isScrollable?this.$nextTick(()=>{this._scrollToMonth(e.year,e.month)}):e.month===this.month&&e.year===this.year||(this.month=e.month,this.year=e.year)},get scrollHeaderLabel(){if(!this.isScrollable)return"";const e=this.grid[this._scrollVisibleIndex];if(!e)return"";return new t(e.year,e.month,1).format({month:"long",year:"numeric"},A)},_initScrollListener(){if("undefined"==typeof IntersectionObserver)return;const e=this.$el.querySelector(".rc-months--scroll");if(!e)return;this._scrollContainerEl=e;const t=e.querySelectorAll("[data-month-id]");if(0===t.length)return;const s=new Map;t.forEach((e,t)=>s.set(e,t));const a=new Set,i=new IntersectionObserver(e=>{for(const t of e){const e=s.get(t.target);void 0!==e&&(t.isIntersecting?a.add(e):a.delete(e))}if(a.size>0){const e=Math.min(...a);this._scrollVisibleIndex!==e&&(this._scrollVisibleIndex=e)}},{root:e,rootMargin:"0px 0px -90% 0px",threshold:0});t.forEach(e=>i.observe(e)),this._scrollObserver=i},_rebindScrollObserver(){this._scrollObserver&&(this._scrollObserver.disconnect(),this._scrollObserver=null),this._initScrollListener()},_scrollToMonth(e,t){if(!this._scrollContainerEl)return;const s=this._scrollContainerEl.querySelector(`[data-month-id="month-${e}-${t}"]`);s&&s.scrollIntoView({behavior:"smooth",block:"start"})}}}let Q={};function X(e){e.data("calendar",(t={})=>Z({...Q,...t},e))}X.defaults=e=>{Q={...Q,...e}},X.getDefaults=()=>({...Q}),X.resetDefaults=()=>{Q={}},e.CalendarDate=t,e.MultipleSelection=D,e.RangeSelection=w,e.SingleSelection=v,e.attachMask=F,e.autoUpdate=function(e,t,s=16){let a=!1,i=0,n=0;const r=()=>{a||(a=!0,s<=16?i=requestAnimationFrame(()=>{t(),a=!1}):n=window.setTimeout(()=>{t(),a=!1},s))};window.addEventListener("resize",r,{passive:!0});const l=function(e){const t=[];let s=e.parentElement;for(;s;){const e=getComputedStyle(s),a=e.overflow+e.overflowX+e.overflowY;/auto|scroll|overlay/.test(a)&&t.push(s),s=s.parentElement}return t.push(document),t}(e);for(const o of l)o.addEventListener("scroll",r,{passive:!0});return()=>{cancelAnimationFrame(i),clearTimeout(n),window.removeEventListener("resize",r);for(const e of l)e.removeEventListener("scroll",r)}},e.calendarPlugin=X,e.computePosition=function(e,t,s={}){const a=s.placement??"bottom-start",i=s.offset??4,n=s.flip??!0,r=e.getBoundingClientRect(),l=t.getBoundingClientRect(),o=window.innerHeight,d=window.innerWidth;let h;var c,u,m;h="start"===(a.includes("start")?"start":"end")?r.left:r.right-l.width,c=h,u=0,m=Math.max(0,d-l.width),h=Math.max(u,Math.min(m,c));const y=a.startsWith("bottom");let f=a;if(y){const e=r.bottom+i;if(!(e+l.height<=o)&&n){const e=r.top-i-l.height;if(e>=0)return f=a.replace("bottom","top"),{x:h,y:e,placement:f}}return{x:h,y:e,placement:f}}const b=r.top-i-l.height;if(b<0&&n){const e=r.bottom+i;if(e+l.height<=o)return f=a.replace("top","bottom"),{x:h,y:e,placement:f}}return{x:h,y:Math.max(0,b),placement:f}},e.createCalendarData=Z,e.createDateConstraint=o,e.createDisabledReasons=y,e.createMask=V,e.createMaskHandlers=W,e.createRangeValidator=d,e.daysInMonth=s,e.default=X,e.formatDate=S,e.formatMultiple=k,e.formatRange=M,e.generateMonth=f,e.generateMonthGrid=b,e.generateMonths=g,e.generateYearGrid=p,e.getISOWeekNumber=a,e.isDateDisabled=function(e,t){return o(t)(e)},e.parseDate=z,e.parseDateMultiple=$,e.parseDateRange=I,e.parseFormatToSlots=K,e.presetLastMonth=function(e="Last Month",a){return{label:e,value:()=>{const e=t.today(a).addMonths(-1);return[e.startOfMonth(),new t(e.year,e.month,s(e.year,e.month))]}}},e.presetLastNDays=function(e,s,a){return{label:s??`Last ${e} Days`,value:()=>{const s=t.today(a);return[s.addDays(-(e-1)),s]}}},e.presetLastWeek=function(e="Last Week",s=1,a){return{label:e,value:()=>{const e=t.today(a),i=(e.toNativeDate().getDay()-s+7)%7,n=e.addDays(-i);return[n.addDays(-7),n.addDays(-1)]}}},e.presetLastYear=function(e="Last Year",s){return{label:e,value:()=>{const e=t.today(s).year-1;return[new t(e,1,1),new t(e,12,31)]}}},e.presetThisMonth=function(e="This Month",s){return{label:e,value:()=>{const e=t.today(s);return[e.startOfMonth(),e]}}},e.presetThisWeek=function(e="This Week",s=1,a){return{label:e,value:()=>{const e=t.today(a),i=(e.toNativeDate().getDay()-s+7)%7;return[e.addDays(-i),e]}}},e.presetThisYear=function(e="This Year",s){return{label:e,value:()=>{const e=t.today(s);return[new t(e.year,1,1),e]}}},e.presetToday=function(e="Today",s){return{label:e,value:()=>{const e=t.today(s);return[e,e]}}},e.presetYesterday=function(e="Yesterday",s){return{label:e,value:()=>{const e=t.today(s).addDays(-1);return[e,e]}}},Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
2
+ //# sourceMappingURL=alpine-calendar.umd.js.map