@pglejzer/datepicker-ui 0.0.1 → 1.1.0
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/LICENSE +21 -0
- package/README.md +245 -0
- package/dist/cjs/index.cjs +1 -0
- package/dist/cjs/index.d.cts +66 -0
- package/dist/cjs/kit.cjs +1 -0
- package/dist/cjs/kit.d.cts +193 -0
- package/dist/cjs/shared.cjs +1 -0
- package/dist/cjs/shared.d.cts +858 -0
- package/dist/css/index.css +1 -0
- package/dist/css/main.css +1 -0
- package/dist/css/themes/theme-ai.css +1 -0
- package/dist/css/themes/theme-blueprint.css +1 -0
- package/dist/css/themes/theme-crane-straight.css +1 -0
- package/dist/css/themes/theme-crane.css +1 -0
- package/dist/css/themes/theme-cyberpunk.css +1 -0
- package/dist/css/themes/theme-glassmorphic.css +1 -0
- package/dist/css/themes/theme-m2.css +1 -0
- package/dist/css/themes/theme-m3-green.css +1 -0
- package/dist/css/themes/theme-pastel.css +1 -0
- package/dist/esm/index.d.ts +70 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/kit.d.ts +194 -0
- package/dist/esm/kit.js +1 -0
- package/dist/esm/shared.d.ts +853 -0
- package/dist/esm/shared.js +1 -0
- package/dist/umd/index.js +1 -0
- package/dist/umd/kit.js +1 -0
- package/package.json +78 -19
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,A as t,At as n,B as r,Bt as i,C as a,Ct as o,D as s,Dt as c,E as l,Et as u,F as d,Ft as f,G as p,H as m,Ht as h,I as g,It as _,J as v,K as y,L as b,Lt as x,M as ee,Mt as S,N as C,Nt as w,O as T,Ot as E,P as te,Pt as D,Q as O,R as k,Rt as A,S as j,Tt as ne,Ut as re,V as ie,Vt as ae,W as oe,X as se,Y as ce,Z as le,_ as ue,_t as de,at as fe,b as pe,bt as M,ct as me,d as he,dt as N,et as ge,f as P,ft as _e,g as F,gt as I,h as ve,ht as ye,i as be,it as xe,j as Se,jt as Ce,k as we,kt as L,lt as R,m as Te,mt as Ee,n as De,nt as Oe,o as ke,ot as Ae,p as je,pt as z,q as Me,r as Ne,rt as Pe,s as Fe,st as Ie,t as Le,tt as Re,ut as B,v as V,vt as ze,w as Be,wt as Ve,x as He,xt as H,y as Ue,yt as We,z as Ge,zt as Ke}from"./shared.js";function U(e){queueMicrotask(()=>{throw e})}var qe=class{store={};on(e,t,n){let r=this.listenersOf(e),i={handler:t},a=()=>{r.delete(i),n?.removeEventListener(`abort`,a)};return n?.aborted||(r.add(i),n?.addEventListener(`abort`,a,{once:!0})),a}once(e,t){let n=this.on(e,e=>{n(),t(e)});return n}off(e,t){let n=this.store[e];if(n){if(!t)n.clear();else for(let e of n)e.handler===t&&n.delete(e)}}emit(e,t){let n=this.store[e];if(!n)return;let r=[];for(let e of[...n])if(n.has(e))try{e.handler(t)}catch(e){r.push(e)}r.length>0&&U(r[0])}listenerCount(e){return this.store[e]?.size??0}clear(){this.store={}}listenersOf(e){let t=this.store[e];if(t)return t;let n=/* @__PURE__ */ new Set;return this.store[e]=n,n}};function Je(e,t){let n={};if((e.calendar||t.calendar)&&(n.calendar={...e.calendar,...t.calendar}),e.ui||t.ui){let r={...e.ui,...t.ui};(e.ui?.inline||t.ui?.inline)&&(r.inline={...e.ui?.inline,...t.ui?.inline}),(e.ui?.yearRange||t.ui?.yearRange)&&(r.yearRange={...e.ui?.yearRange,...t.ui?.yearRange}),n.ui=r}return(e.labels||t.labels)&&(n.labels={...e.labels,...t.labels}),(e.behavior||t.behavior)&&(n.behavior={...e.behavior,...t.behavior}),(e.callbacks||t.callbacks)&&(n.callbacks={...e.callbacks,...t.callbacks}),n}const W={title:`Select date`,monthTitle:`Select month`,yearTitle:`Select year`,noDate:`No date selected`,confirm:`OK`,cancel:`Cancel`,today:`Today`,clear:`Clear`,openCalendar:`Choose date`,previousMonth:`Previous month`,nextMonth:`Next month`,previousYear:`Previous year`,nextYear:`Next year`,chooseMonth:`Choose month`,chooseYear:`Choose year`,weekNumber:`Week`,invalidDate:`Enter a valid date`,unavailableDate:`This date is not available`,rangeTitle:`Select dates`,rangeStart:`Start`,rangeEnd:`End`,inRange:`In range`,multipleSelected:`{count} selected`,save:`Save`,close:`Close`,switchToInput:`Switch to text input`,switchToCalendar:`Switch to calendar`,dateField:`Date`,startDateField:`Start date`,endDateField:`End date`,invalidRange:`End date must be on or after the start date`,beforeMinDate:`Enter a date on or after {date}`,afterMaxDate:`Enter a date on or before {date}`,presets:`Presets`,pageUpKey:`Page Up`,pageDownKey:`Page Down`,shiftKey:`Shift`,hintDay:`dd`,hintMonth:`mm`,hintYear:`yyyy`},G={calendar:{weekStart:`auto`,mode:`single`,precision:`day`,months:1,pageBy:`view`,presets:[]},ui:{displayMode:`auto`,layout:`auto`,inline:{enabled:!1,headline:!0,navigation:`menus`,announceSelection:!0},format:`auto`,theme:`basic`,colorScheme:`auto`,weekNumbers:!1,outsideDays:!1,fixedWeeks:!1,yearRange:{before:100,after:20},todayButton:!1,clearButton:!1,animation:!0,allowPageScroll:!1,fullscreen:!0,cssClass:``,swipe:!0,viewSwitch:!0,initialView:`calendar`,mask:!1,startView:`day`},labels:W,behavior:{closeOnSelect:!1,closeOnCancel:!0,commitOnChange:!1,ignoreOutsideClick:!1,returnFocus:!0}};function Ye(e,t){if(z(e))return null;switch(e.mode){case`single`:return e.date?t(e.date):null;case`range`:return e.start===null||e.end===null?null:{start:t(e.start),end:t(e.end)};default:return de(e).map(t)}}function Xe(e,t){if(e===`today`)return Ge(h(),t);if(typeof e==`string`)return r(e,t);if(e instanceof Date){let n=ae(e);return n===null?null:Ge(n,t)}return null}function Ze(e){if(!(`start`in e&&`end`in e))return null;let t=Xe(e.start,`day`),r=Xe(e.end,`day`);return t===null||r===null||n(t,r)>0?null:{mode:`range`,start:t,end:r}}function Qe(e){let t=[];for(let n of e){let e=Xe(n,`day`);if(e===null)return null;t.push(e)}return{mode:`multiple`,dates:ze(t)}}function K(e,t,n){if(e===null)return B(t);if(t===`multiple`)return Array.isArray(e)?Qe(e):null;if(t===`single`){let r=Xe(e,n);return r===null?null:{mode:t,date:r}}return typeof e==`object`&&!Array.isArray(e)&&!(e instanceof Date)?Ze(e):null}function $e(e,t){return e instanceof Date?e:typeof e!=`string`||e===`today`&&!t?null:e}function et(e,t,n,r){if(e===void 0)return null;let i=$e(e,t),a=i===null?null:ae(i);return a===null&&r.push({option:n,value:e}),a}function tt(e,t,n,r){return e==null?null:K(e,t,n)===null?(r.push({option:`calendar.defaultValue`,value:e}),null):()=>K(e,t,n)}function nt(e,t,n){return e===void 0?null:Array.isArray(e)?e.map(e=>et(e,!1,t,n)).filter(e=>e!==null):(n.push({option:t,value:e}),null)}function q(e,t,n,r,i){if(e===void 0)return n;let a=t(e);return a===void 0?(i.push({option:r,value:e}),n):a}const J=e=>typeof e==`boolean`?e:void 0,rt=e=>typeof e==`string`?e:void 0,it=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,at=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1?e:void 0,ot=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},st=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},ct=e=>{if(typeof e==`string`)return e;if(typeof e!=`object`||!e||Array.isArray(e))return;let t=Object.entries(e),n={};for(let[e,r]of t){if(typeof r!=`string`)return;n[e]=r}return t.length>0?n:void 0},lt=e=>typeof HTMLElement<`u`&&e instanceof HTMLElement||typeof e==`string`&&e.length>0?e:void 0;function Y(e){return t=>e.find(e=>e===t)}function ut(e){return t=>typeof t==`string`&&Ie(t,e)?t:void 0}const dt=Y([`auto`,`docked`,`modal`]),ft=Y([`auto`,`light`,`dark`]),pt=Y([`auto`,`sunday`,`monday`,`saturday`]),mt=Y([`single`,`range`,`multiple`]),ht=Y([`calendar`,`input`]),gt=Y([`day`,`month`,`year`]),_t=Y([`month`,`view`]),vt=Y([`day`,`month`,`year`]),yt=Y([`auto`,`docked`,`modal`,`fullscreen`]),bt=Y([`menus`,`caption`]),xt=Y([`basic`,`m3-green`,`crane`,`crane-straight`,`m2`,`glassmorphic`,`pastel`,`ai`,`cyberpunk`,`blueprint`]);function St(e){return e in W}function Ct(e,t){let n={...W};for(let r of Object.keys(W))St(r)&&r!==`multipleSelected`&&(n[r]=q(e?.[r],rt,W[r],`labels.${r}`,t));return n.multipleSelected=q(e?.multipleSelected,ct,W.multipleSelected,`labels.multipleSelected`,t),n}function wt(e,t){return e===void 0||e===!0?600:e===!1?0:q(e,at,600,`ui.fullscreen`,t)}function Tt(e,t){return e===void 0||e===!1?!1:e===!0?{selectable:!0}:typeof e==`object`&&e?{selectable:q(Reflect.get(e,`selectable`),J,!0,`ui.outsideDays.selectable`,t)}:(t.push({option:`ui.outsideDays`,value:e}),!1)}function Et(e,t){return e===void 0||e===!1?!1:e===!0?{clearInput:!0}:typeof e==`object`&&e?{clearInput:q(Reflect.get(e,`clearInput`),J,!0,`ui.clearButton.clearInput`,t)}:(t.push({option:`ui.clearButton`,value:e}),!1)}const Dt=`calendar.range.presets`;function Ot(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`label`),n=Reflect.get(e,`value`);return typeof t!=`string`||t===``?null:typeof n==`function`?{label:t,value:()=>Reflect.apply(n,void 0,[])}:typeof n==`object`&&n?{label:t,value:()=>n}:null}function kt(e,t){if(e===void 0)return G.calendar.presets;if(!Array.isArray(e))return t.push({option:Dt,value:e}),G.calendar.presets;let n=e,r=[];for(let e of n){let n=Ot(e);n===null?t.push({option:Dt,value:e}):r.push(n)}return r}function At(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6}function jt(e,t){let n=e?.trim();n&&!O(n)&&t.push({option:`calendar.locale`,value:e})}function Mt(e,t){if(e===void 0)return[];if(!Array.isArray(e))return t.push({option:`calendar.disabledWeekdays`,value:e}),[];let n=e,r=[];for(let e of n)At(e)?r.includes(e)||r.push(e):t.push({option:`calendar.disabledWeekdays`,value:e});return r}function Nt(e){if(typeof e!=`object`||!e)return;let t=Reflect.get(e,`className`),n=Reflect.get(e,`badge`),r=Reflect.get(e,`label`);return{...typeof t==`string`?{className:t}:{},...typeof n==`boolean`?{badge:n}:{},...typeof r==`string`?{label:r}:{}}}function Pt(e){return typeof e==`string`||typeof Node<`u`&&e instanceof Node?e:null}function Ft(e){return e===null?null:t=>{try{return Pt(e(t))}catch(e){return U(e),null}}}function It(e){return e===null?null:t=>{try{let n=e(t);return typeof n!=`string`||n.length===0?null:n}catch(e){return U(e),null}}}function Lt(e,t,n){let r=G.calendar,i=q(e,gt,r.precision,`calendar.precision`,n);return i!==`day`&&t!==`single`?(n.push({option:`calendar.precision`,value:e}),r.precision):i}function Rt(e,t){let n=q(e?.range?.minLength,at,null,`calendar.range.minLength`,t),r=q(e?.range?.maxLength,at,null,`calendar.range.maxLength`,t),i=q(e?.multiple?.max,at,null,`calendar.multiple.max`,t);return n!==null&&r!==null&&n>r?(t.push({option:`calendar.range`,value:e?.range}),{minLength:n,maxLength:null,multipleMax:i}):{minLength:n,maxLength:r,multipleMax:i}}function zt(e,t){let n=G.calendar;jt(e?.locale,t);let r=ge(e?.locale),i=q(e?.weekStart,pt,n.weekStart,`calendar.weekStart`,t),a=q(e?.isDateDisabled,ot,null,`calendar.isDateDisabled`,t),o=q(e?.decorateDate,ot,null,`calendar.decorateDate`,t),s=q(e?.renderDate,ot,null,`calendar.renderDate`,t),c=q(e?.validate,st,null,`calendar.validate`,t),l=q(e?.mode,mt,n.mode,`calendar.mode`,t),u=Lt(e?.precision,l,t);return{locale:r,weekStart:Re(r,i),minDate:et(e?.minDate,!0,`calendar.minDate`,t),maxDate:et(e?.maxDate,!0,`calendar.maxDate`,t),disabledDates:nt(e?.disabledDates,`calendar.disabledDates`,t)??[],enabledDates:nt(e?.enabledDates,`calendar.enabledDates`,t),mode:l,precision:u,defaultValue:tt(e?.defaultValue,l,u,t),months:q(e?.months,at,n.months,`calendar.months`,t),pageBy:q(e?.pageBy,_t,n.pageBy,`calendar.pageBy`,t),limits:Rt(e,t),presets:kt(e?.range?.presets,t),isDateDisabled:a===null?null:e=>!!a(e),disabledWeekdays:Mt(e?.disabledWeekdays,t),decorateDate:o===null?null:e=>Nt(o(e)),renderDate:Ft(s),validate:It(c)}}function Bt(e){let t=[],n=G,r=e?.calendar,i=e?.ui,a=e?.behavior,o=(e,n,r,i)=>q(e,n,r,i,t),s=zt(r,t),{locale:c,precision:l}=s,u=o(i?.format,ut(l),n.ui.format,`ui.format`),d=o(i?.footer,J,!1,`ui.footer`),f=a?.id;return{...s,displayMode:o(i?.displayMode,dt,n.ui.displayMode,`ui.displayMode`),layout:o(i?.layout,yt,n.ui.layout,`ui.layout`),inline:{enabled:o(i?.inline?.enabled,J,n.ui.inline.enabled,`ui.inline.enabled`),container:o(i?.inline?.container,lt,null,`ui.inline.container`),headline:o(i?.inline?.headline,J,n.ui.inline.headline,`ui.inline.headline`),navigation:o(i?.inline?.navigation,bt,n.ui.inline.navigation,`ui.inline.navigation`),announceSelection:o(i?.inline?.announceSelection,J,n.ui.inline.announceSelection,`ui.inline.announceSelection`)},pattern:me(u,c,l),theme:o(i?.theme,xt,n.ui.theme,`ui.theme`),colorScheme:o(i?.colorScheme,ft,n.ui.colorScheme,`ui.colorScheme`),toggleButton:o(i?.toggleButton,lt,null,`ui.toggleButton`),endInput:o(i?.endInput,lt,null,`ui.endInput`),weekNumbers:o(i?.weekNumbers,J,n.ui.weekNumbers,`ui.weekNumbers`),outsideDays:Tt(i?.outsideDays,t),fixedWeeks:o(i?.fixedWeeks,J,n.ui.fixedWeeks,`ui.fixedWeeks`),yearRange:{before:o(i?.yearRange?.before,it,n.ui.yearRange.before,`ui.yearRange.before`),after:o(i?.yearRange?.after,it,n.ui.yearRange.after,`ui.yearRange.after`)},todayButton:o(i?.todayButton,J,n.ui.todayButton,`ui.todayButton`),clearButton:Et(i?.clearButton,t),footerExplicit:typeof i?.footer==`boolean`?d:null,animation:o(i?.animation,J,n.ui.animation,`ui.animation`),allowPageScroll:o(i?.allowPageScroll,J,n.ui.allowPageScroll,`ui.allowPageScroll`),fullscreenBelow:wt(i?.fullscreen,t),cssClass:o(i?.cssClass,rt,n.ui.cssClass,`ui.cssClass`),appendTo:o(i?.appendTo,lt,null,`ui.appendTo`),swipe:o(i?.swipe,J,n.ui.swipe,`ui.swipe`),viewSwitch:o(i?.viewSwitch,J,n.ui.viewSwitch,`ui.viewSwitch`),initialView:o(i?.initialView,ht,n.ui.initialView,`ui.initialView`),mask:o(i?.mask,J,n.ui.mask,`ui.mask`),startView:o(i?.startView,vt,n.ui.startView,`ui.startView`),labels:Ct(e?.labels,t),behavior:{closeOnSelect:o(a?.closeOnSelect,J,n.behavior.closeOnSelect,`behavior.closeOnSelect`),closeOnCancel:o(a?.closeOnCancel,J,n.behavior.closeOnCancel,`behavior.closeOnCancel`),commitOnChange:o(a?.commitOnChange,J,n.behavior.commitOnChange,`behavior.commitOnChange`),ignoreOutsideClick:o(a?.ignoreOutsideClick,J,n.behavior.ignoreOutsideClick,`behavior.ignoreOutsideClick`),returnFocus:o(a?.returnFocus,J,n.behavior.returnFocus,`behavior.returnFocus`),id:typeof f==`string`&&f.length>0?f:null},callbacks:{...e?.callbacks},issues:t}}const Vt=/[^\w-]/g;let Ht=0;function Ut(e){return e.replace(Vt,`-`)}function Wt(e){return{year:e.year,month:e.month}}var Gt=class{input;host;createdHost;instanceId;events=new qe;raw;resolved;currentValue;currentDraft;currentView;currentFocus;currentPanel;currentMode=null;currentCalendarLayout=`docked`;currentLayout={months:1,presets:`none`};currentListSpan=null;currentActiveEnd=`start`;currentEndInput=null;activeEndControlled=!1;constructor(e,t,n,r){this.input=e,this.host=t,this.createdHost=n,this.raw=Je({},r??{}),this.resolved=Bt(this.raw),Ht+=1;let i=this.resolved.behavior.id;this.instanceId=i===null?`${re}${String(Ht)}`:Ut(i),this.currentPanel=M(this.resolved.precision),this.currentValue=B(this.resolved.mode),this.currentDraft=this.currentValue;let a=h();this.currentFocus=a,this.currentView=Wt(a)}get options(){return this.resolved}get rawOptions(){return this.raw}setOptions(e){this.raw=Je(this.raw,e),this.resolved=Bt(this.raw),this.events.emit(`change:options`,{})}get value(){return this.currentValue}setValue(e){this.currentValue=e,this.events.emit(`change:value`,{value:e})}get draft(){return this.currentDraft}setDraft(e){this.currentDraft=e,this.events.emit(`change:draft`,{draft:e})}get view(){return this.currentView}setView(e,t,n){let r=Wt(e);this.currentView=r,this.events.emit(`change:view`,{view:r,delta:t,source:n})}get focus(){return this.currentFocus}setFocus(e){this.currentFocus=e,this.events.emit(`change:focus`,{focus:e})}get panel(){return this.currentPanel}setPanel(e){e!==this.currentPanel&&(this.currentPanel=e,this.events.emit(`change:panel`,{panel:e}))}get mode(){return this.currentMode}setMode(e){this.currentMode=e}get calendarLayout(){return this.currentCalendarLayout}setCalendarLayout(e){this.currentCalendarLayout=e}get layout(){return this.currentLayout}setLayout(e){this.currentLayout=e}get listSpan(){return this.currentListSpan}setListSpan(e){this.currentListSpan=e}get activeEnd(){return this.currentActiveEnd}setActiveEnd(e){e!==this.currentActiveEnd&&(this.currentActiveEnd=e,this.events.emit(`change:active-end`,{end:e}))}controlActiveEnd(){this.activeEndControlled=!0}get followsActiveEnd(){return this.currentEndInput!==null||this.activeEndControlled}get endInput(){return this.currentEndInput}setEndInput(e){this.currentEndInput=e}resetSession(){let e=R(this.currentValue)??h(),t=Wt(e);this.currentListSpan=null,this.setPanel(M(this.resolved.precision)),this.setDraft(this.currentValue),this.setView(t,A(this.currentView,t),`api`),this.setFocus(e)}};const Kt=`dp-ui`,qt=[`class`,`name`,`aria-invalid`,`aria-describedby`];function Jt(e){return typeof e==`string`?document.querySelector(e):e}function Yt(e){return e instanceof HTMLInputElement?e:e?.querySelector(`input`)??null}function Xt(e){let t=document.createElement(`div`);return t.className=Kt,e.before(t),t.append(e),t}function Zt(e){if(!Pe())throw Error(`DatepickerUI needs a document`);let t=Jt(e),n=Yt(t);if(n===null)throw Error(`DatepickerUI could not find an input element`);let r=n.parentElement;return r!==null&&(t!==n||r.classList.contains(Kt))?{input:n,host:r,createdHost:!1}:{input:n,host:Xt(n),createdHost:!0}}function Qt(e){let{input:t,host:n,createdHost:r}=e,i=/* @__PURE__ */ new Map;for(let e of qt)i.set(e,t.getAttribute(e));let a=n.classList.contains(Kt);return n.classList.add(Kt),{target:{input:t,host:n,createdHost:r},hostHadClass:a,inputAttributes:i}}function $t(e){let{input:t,host:n,createdHost:r}=e.target;for(let[n,r]of e.inputAttributes)r===null?t.removeAttribute(n):t.setAttribute(n,r);r?t.parentNode===n?n.replaceWith(t):n.remove():e.hostHadClass||n.classList.remove(Kt)}function en(e,t,n,r){let i=A(e,t);return i>=0&&i<n?e:r===`month`?i<0?t:L(t,-(n-1)):L(e,Math.floor(i/n)*n)}function tn(e,t){let{core:r,managers:i}=e,{minDate:a,maxDate:o}=r.options,s=i.validation.yearBounds(),c={year:s.min,month:1,day:1},l={year:s.max,month:12,day:31},u=a!==null&&n(a,c)>0?a:c,d=o!==null&&n(o,l)<0?o:l;return n(t,u)<0?u:n(t,d)>0?d:t}function nn(e,t,n){return tn(e,{year:t.year,month:t.month,day:Math.min(n,D(t))})}function rn(e,t,n){let{core:r,managers:i}=e,a=i.validation.clampView(t),o=A(r.view,a);return o!==0&&(r.setView(a,o,n),r.setFocus(nn(e,a,r.focus.day))),a}function X(e,t,n){let{core:r,managers:i}=e,a={year:t.year,month:t.month},{months:o}=r.layout,s=i.validation.clampView(en(r.view,a,o,r.options.pageBy)),c=A(s,a);if(c<0||c>=o)return;let l=A(r.view,s);l!==0&&r.setView(s,l,n),r.setFocus(t)}function an(e,t,n){let r=w(e,t)+1;return n.minLength!==null&&r<n.minLength?!1:n.maxLength===null||r<=n.maxLength}function on(e,t,r,i){let a=i;if(t.maxLength!==null){let r=E(e,t.maxLength-1);a=n(r,i)<0?r:i}for(let t=E(e,1);n(t,a)<=0;t=E(t,1))if(r(t))return t;return null}function sn(e,t,r,i){if(e.mode===`multiple`){let{multipleMax:n}=t,{dates:r}=e;return t=>n!==null&&r.length>=n&&!_e(e,t)}if(e.mode!==`range`||e.start===null||e.end!==null)return()=>!1;let{start:a}=e,o=null,s=!1;return e=>n(e,a)<0?!1:n(e,i)>0||!an(a,e,t)||(s||=(o=on(a,t,r,i),!0),o!==null&&n(e,o)>=0)}function cn(e,t,r,i){if(!an(e,t,r))return`range-length`;for(let r=e;n(r,t)<=0;r=E(r,1)){let e=i(r);if(e!==null)return e}return null}function ln(e,t){for(let n of e){let e=t(n);if(e!==null)return e}return null}function un(e,t,n){switch(e.mode){case`single`:return e.date===null?null:n(e.date);case`range`:return e.start!==null&&e.end!==null?cn(e.start,e.end,t,n):e.start===null?null:n(e.start);default:return t.multipleMax!==null&&e.dates.length>t.multipleMax?`multiple-max`:ln(e.dates,n)}}function dn(e,t,n){return un(e,t,e=>n(e)?`disabled`:null)===null}function fn(e,t,r){return e.some(e=>n(e,t)===0)?e.filter(e=>n(e,t)!==0):r.multipleMax!==null&&e.length>=r.multipleMax?null:ze([...e,t])}function pn(e){return e.mode===`range`&&e.start!==null&&e.end===null?`end`:`start`}function mn(e,t){return e.mode===`range`?t===`start`?{mode:`range`,start:null,end:null}:{mode:`range`,start:e.start,end:null}:e}function hn(e,t,r,i){switch(e.mode){case`single`:return{mode:`single`,date:t};case`range`:return i===`start`||e.start===null||n(t,e.start)<0?{mode:`range`,start:t,end:null}:{mode:`range`,start:e.start,end:t};default:{let n=fn(e.dates,t,r);return n===null?e:{mode:`multiple`,dates:n}}}}var gn=class{context;session;values;constructor(e,t,n){this.context=e,this.session=t,this.values=n}isOpen(){return this.session.active}select(e){let{core:t,managers:n}=this.context,r=Ge(e,t.options.precision),i=t.followsActiveEnd?t.activeEnd:pn(t.draft);if(!this.session.active||!n.validation.isSelectable(r,mn(t.draft,i)))return;X(this.context,r,`button`);let a=hn(t.draft,r,t.options.limits,i);t.setDraft(a),t.setActiveEnd(pn(a)),this.announce(a,r),this.isOpen()&&this.autoCommit(a)}selectRange(e,t){let{core:n,managers:r}=this.context,{mode:i,limits:a}=n.options;if(!this.session.active||i!==`range`)return;let o={mode:`range`,start:e,end:t};un(o,a,e=>r.validation.unavailableReason(e))===null&&(n.setDraft(o),n.setActiveEnd(`start`),X(this.context,e,`api`),this.emitRangeEnd(e,t),this.isOpen()&&this.autoCommit(o))}typeDraft(e){if(!this.acceptTyped(e))return;let{commitOnChange:t}=this.context.core.options.behavior;t&&N(e)&&this.values.commit(!0)}submitDraft(){let{core:e}=this.context,t=e.draft,n=e.options.behavior.closeOnSelect&&t.mode!==`multiple`;this.session.active&&n&&N(t)&&(I(e.value,t)||this.values.commit(!0),this.session.close())}acceptTyped(e){let{core:t,managers:n}=this.context,{mode:r,limits:i}=t.options,a=e.mode===r&&dn(e,i,e=>n.validation.isDisabled(e));if(!this.session.active||!a||I(t.draft,e))return!1;t.setDraft(e);let o=R(e);return o!==null&&X(this.context,o,`api`),this.announceTyped(e),!0}announceTyped(e){let{emitter:t}=this.context,{describe:n}=this.values;e.mode===`single`?e.date!==null&&t.emit(`select:day`,{value:n(e.date),selected:!0}):e.mode===`range`&&e.start!==null&&(e.end===null?t.emit(`range:start`,{value:n(e.start)}):this.emitRangeEnd(e.start,e.end))}announce(e,t){let{emitter:n}=this.context,{describe:r}=this.values;n.emit(`select:day`,{value:r(t),selected:_e(e,t)}),e.mode===`range`&&(e.start===null||e.end===null?n.emit(`range:start`,{value:r(t)}):this.emitRangeEnd(e.start,e.end))}emitRangeEnd(e,t){let{describe:n}=this.values;this.context.emitter.emit(`range:end`,{start:n(e),end:n(t)})}autoCommit(e){if(e.mode===`range`&&e.end===null)return;let{closeOnSelect:t,commitOnChange:n}=this.context.core.options.behavior,r=t&&e.mode!==`multiple`;(r||n)&&this.values.commit(!0),r&&this.session.close()}},_n=class{context;session;values;selector;constructor(e,t,n){this.context=e,this.session=t,this.values=n,this.selector=new gn(e,t,n)}isOpen(){return this.session.active}select(e){this.selector.select(e)}selectRange(e,t){this.selector.selectRange(e,t)}typeDraft(e){this.selector.typeDraft(e)}submitDraft(){this.selector.submitDraft()}focusDate(e){this.session.active&&X(this.context,e,`keyboard`)}navigate(e,t){this.session.active&&rn(this.context,L(this.context.core.view,e),t)}page(e,t){let{core:n}=this.context,r=n.options.pageBy===`view`?n.layout.months:1;this.navigate(e*r,t)}jumpTo(e,t){if(!this.session.active)return;let{core:n}=this.context,r=n.panel,i=rn(this.context,e,t);t===`menu`&&(n.setPanel(M(n.options.precision)),this.announcePick(r,i))}showPanel(e){this.session.active&&this.context.core.setPanel(e)}confirm(){this.session.active&&N(this.context.core.draft)&&(this.values.commit(!1),this.session.close())}cancel(e){if(!this.session.active)return;let{core:t,emitter:n}=this.context;n.emit(`cancel`,{reason:e}),this.isOpen()&&((t.options.behavior.closeOnCancel||e!==`button`)&&t.mode!==`inline`?this.session.close():t.setDraft(t.value))}today(){if(!this.session.active)return;let{core:e,managers:t}=this.context,n=h();t.validation.isSelectable(n,e.draft)?this.select(n):X(this.context,n,`button`)}clear(){if(!this.session.active)return;let{core:e}=this.context,{clearButton:t}=e.options,n=t!==!1&&t.clearInput,r=this.values.clearedSelection(n);r!==null&&(this.values.emitClear(r),!this.isOpen())||(e.setDraft(B(e.options.mode)),n&&(this.values.commit(!1),this.session.close()))}announcePick(e,t){let{emitter:n}=this.context;e===`month-menu`||e===`month-grid`?n.emit(`select:month`,{year:t.year,month:t.month}):(e===`year-menu`||e===`year-grid`)&&n.emit(`select:year`,{year:t.year})}},vn=class{context;subscriptions=[];constructor(e){this.context=e}bind(){for(let e of this.subscriptions)e();this.subscriptions=[];let{callbacks:e}=this.context.core.options;this.add(`open`,e.onOpen),this.add(`close`,e.onClose),this.add(`cancel`,e.onCancel),this.add(`confirm`,e.onConfirm),this.add(`update`,e.onUpdate),this.add(`error`,e.onError),this.add(`select:day`,e.onSelectDay),this.add(`select:month`,e.onSelectMonth),this.add(`select:year`,e.onSelectYear),this.add(`range:start`,e.onRangeStart),this.add(`range:end`,e.onRangeEnd),this.add(`navigate`,e.onNavigate),this.add(`switch:view`,e.onSwitchView),this.add(`clear`,e.onClear)}add(e,t){t!==void 0&&this.subscriptions.push(this.context.emitter.on(e,t))}};const yn=[`class`,`name`,`aria-invalid`];function bn(e){let{core:t,emitter:n}=e,{endInput:r,mode:i}=t.options;if(i!==`range`||r===null)return null;let a=g(r,t.host);return a instanceof HTMLInputElement&&a!==t.input?a:(n.emit(`error`,{code:`invalid-option`,message:`ui.endInput does not match an input element`,option:`ui.endInput`}),null)}function xn(e){let t=/* @__PURE__ */ new Map;for(let n of yn)t.set(n,e.getAttribute(n));return()=>{for(let[n,r]of t)r===null?e.removeAttribute(n):e.setAttribute(n,r)}}const Sn=[`calendar`,`ui`,`labels`,`behavior`,`callbacks`];function Cn(e){let t=[];for(let n of Sn){let r=e[n];if(r!==void 0)for(let e of Object.keys(r))t.push(`${n}.${e}`)}return t}function wn(e,t){return e.some(e=>t.option===e||t.option.startsWith(`${e}.`))}function Tn(e,t){for(let n of t)e.emitter.emit(`error`,{code:`invalid-option`,message:`Invalid value for option ${n.option}`,option:n.option})}var En=class{context;session;callbacks;triggers;constructor(e,t,n,r){this.context=e,this.session=t,this.callbacks=n,this.triggers=r}apply(e){let{core:t,emitter:n,status:r}=this.context;if(r.destroyed)return;let i=t.options;t.setOptions(e),t.options.mode!==i.mode&&this.resetSelection(),r.created&&this.reapply(i,e),n.emit(`update`,{options:e})}resetSelection(){let{core:e,managers:t,status:n}=this.context,r=B(e.options.mode);e.setValue(r),e.setDraft(r),n.created&&(t.input.write(r),t.form.sync())}reapply(e,t){let{core:n,managers:r}=this.context;this.callbacks.bind(),r.theme.applyHost(),this.triggers.bind(),z(n.value)||r.input.write(n.value),r.triggers.updateLabel(),this.refreshSurface(e);let i=Cn(t);Tn(this.context,n.options.issues.filter(e=>wn(i,e)))}refreshSurface(e){let{core:t}=this.context,n=t.options;if(n.inline.enabled!==e.inline.enabled||n.inline.enabled&&n.inline.container!==e.inline.container){this.session.end(),n.inline.enabled&&this.session.mountInline();return}let r=t.mode;if(!this.session.active||r===null)return;let i=r===`inline`||n.displayMode===e.displayMode?r:this.session.pickMode();i!==r||n.mode!==e.mode||n.layout!==e.layout?this.session.remount(i):this.session.refresh(i,`api`)}},Dn=class{context;session;callbacks;triggers;controller=new AbortController;hostSnapshot;restoreEndInput=null;constructor(e,t,n,r){this.context=e,this.session=t,this.callbacks=n,this.triggers=r,this.hostSnapshot=Qt(e.core)}create(){let{core:e,managers:t,status:n}=this.context;if(n.created||n.destroyed)return;n.created=!0;let r=this.controller.signal;this.callbacks.bind(),t.theme.applyHost();let i=bn(this.context);e.setEndInput(i),i!==null&&(this.restoreEndInput=xn(i));let a=this.initialSelection();e.setValue(a),z(a)||t.input.write(a),t.form.bind(r),t.form.sync(),t.input.bind(r),this.triggers.bind(),t.triggers.updateLabel(),e.events.on(`change:value`,()=>{t.triggers.updateLabel()},r),e.options.inline.enabled&&this.session.mountInline(),Tn(this.context,e.options.issues)}initialSelection(){let{core:e,managers:t}=this.context;if(!z(e.value))return e.value;let n=t.input.readInitial();return z(n)?e.options.defaultValue?.()??n:n}destroy(e){let{core:t,emitter:n,managers:r,status:i}=this.context;i.destroyed||(i.destroyed=!0,this.session.teardown(),this.triggers.release(),this.controller.abort(),r.destroy(),e||(t.input.value=``,t.endInput!==null&&(t.endInput.value=``)),this.restoreEndInput?.(),this.restoreEndInput=null,t.setEndInput(null),$t(this.hostSnapshot),t.events.clear(),n.clear())}},On=class{tail=Promise.resolve();pending=0;stopped=!1;run(e){let t=async()=>{this.stopped||await e()},n=this.pending===0?t():this.tail.then(t);this.pending+=1;let r=n.catch(U).finally(()=>{--this.pending});return this.tail=r,r}stop(){this.stopped=!0}},kn=class{context;views;visible;queue=new On;controller=null;phase=`closed`;sessionId=0;mounts=0;closing=Promise.resolve();openedFrom=`start`;mountSource=`open`;constructor(e,t,n){this.context=e,this.views=t,this.visible=n}get active(){return this.phase===`open`}open(e,t=`start`){let{core:n,emitter:r,managers:i,status:a}=this.context;if(!a.created||a.destroyed||n.options.inline.enabled)return;if(this.phase===`open`){n.setActiveEnd(t);return}if(e!==`api`&&n.input.disabled)return;let o=this.pickMode();this.openedFrom=t,n.setActiveEnd(t),this.begin(o),i.triggers.setExpanded(!0),r.emit(`open`,{mode:n.mode??o})}fallBackToModal(){this.active&&this.context.core.mode===`docked`&&(this.stopListening(),this.adoptMode(`modal`),this.listen(),this.mount(`modal`,this.mountSource))}mountInline(){let{core:e,emitter:t}=this.context;g(e.options.inline.container)===null?t.emit(`error`,{code:`invalid-option`,message:`ui.inline.container does not match an element`,option:`ui.inline.container`}):(this.begin(`inline`),t.emit(`open`,{mode:`inline`}))}close(){return this.context.core.mode===`inline`?Promise.resolve():this.end()}end(){if(this.phase===`closing`)return this.closing;if(this.phase!==`open`)return Promise.resolve();let{core:e,emitter:t,managers:n}=this.context,r=e.mode,i=this.sessionId;this.phase=`closing`,this.stopListening(),this.visible.reset(),n.triggers.setExpanded(!1);let a=this.queue.run(()=>n.display.unmount()).then(()=>{this.finish(i,r)});return this.closing=a,t.emit(`close`,{}),a}syncLayout(e){let{core:t}=this.context,n=t.options,r=window.innerWidth;if(e===`inline`){let e=g(n.inline.container)?.clientWidth??0;r=e>0?e:r}t.setLayout(Ve({months:n.months,precision:n.precision,mode:n.mode,layout:t.calendarLayout,width:r,weekNumbers:n.weekNumbers,presets:n.presets.length}))}remount(e){let{core:t,managers:n}=this.context;this.visible.pause(),this.decideLayout(e),this.syncLayout(e),this.clampView(),t.setMode(e),this.views.dropUnsupported(),this.queue.run(()=>n.display.unmount()),this.mount(e,`api`)}refresh(e,t){let{core:n,managers:r}=this.context;this.visible.hold(t,()=>{this.syncLayout(e),this.clampView(),n.setListSpan(null),r.display.update()})}pickMode(){let{displayMode:e}=this.context.core.options;return o(e,!1,window.innerWidth,window.innerHeight)}clampView(){rn(this.context,this.context.core.view,`api`)}teardown(){this.phase=`closed`,this.stopListening(),this.visible.reset(),this.queue.stop()}begin(e){this.stopListening(),this.sessionId+=1,this.phase=`open`,this.visible.reset(),this.context.core.resetSession(),this.adoptMode(e),this.listen(),this.mount(e,`open`)}adoptMode(e){let{core:t}=this.context;this.decideLayout(e),t.setPanel(this.views.opening(e)),this.syncLayout(e),this.clampView(),t.setMode(e)}listen(){let e=new AbortController;this.controller=e,this.views.bind(e.signal),this.visible.bind(e.signal),window.addEventListener(`resize`,()=>{this.relayout()},{signal:e.signal})}mount(e,t){let{core:n,managers:r}=this.context;this.mounts+=1,this.mountSource=t;let i=this.mounts;this.queue.run(()=>(n.setListSpan(null),r.display.mount(e))).then(()=>{i===this.mounts&&this.active&&this.visible.resume(t)})}decideLayout(e){let{core:t}=this.context;t.setCalendarLayout(We(e,t.options,window.innerWidth))}relayout(){let{core:e}=this.context,t=e.mode;if(t===null)return;let n=e.layout;this.syncLayout(t);let r=e.layout;(r.months!==n.months||r.presets!==n.presets)&&this.refresh(t,`resize`)}stopListening(){this.controller?.abort(),this.controller=null}finish(e,t){this.sessionId===e&&this.phase===`closing`&&(this.phase=`closed`,this.context.core.setMode(null),this.returnFocus(t))}returnFocus(e){let{core:t}=this.context;if(!t.options.behavior.returnFocus)return;let n=document.activeElement;(e===`modal`||n===null||n===document.body)&&((this.openedFrom===`end`?t.endInput:null)??t.input).focus({preventScroll:!0})}},An=class{context;scope=null;constructor(e){this.context=e}bind(){this.release();let{core:e,managers:t}=this.context;if(e.options.inline.enabled)return;let n=new AbortController;this.scope=n,t.triggers.bind(n.signal)}release(){this.scope?.abort(),this.scope=null}};const jn=[`start`,`end`];var Mn=class{context;session;visible;constructor(e,t,n){this.context=e,this.session=t,this.visible=n}describe=e=>{let{pattern:t,precision:n}=this.context.core.options;return{value:m(e,n),date:Ke(e),formatted:k(e,t,n)}};get(){return this.present(this.context.core.value)}set(e){let{core:t,emitter:n,managers:r,status:i}=this.context;if(i.destroyed)return;let a=K(e,t.options.mode,t.options.precision);a===null?n.emit(`error`,{code:`invalid-date`,message:`setValue() received a value that is not a valid date for calendar.mode`,input:typeof e==`string`?e:void 0}):(t.setValue(a),r.input.write(a),i.created&&r.form.sync(),this.follow(),this.validate(a))}isSelectable(e){let{core:t,managers:n}=this.context,{mode:r,precision:i,limits:a}=t.options,o=K(e,r===`single`||typeof e==`string`||e instanceof Date?`single`:r,i);return o===null||z(o)?!1:dn(o,a,e=>n.validation.isDisabled(e))}clear(){let{core:e,managers:t,status:n}=this.context,r=this.clearedSelection(!0);if(n.destroyed||r===null)return;let i=B(e.options.mode);e.setValue(i),this.session.active&&e.setDraft(i),t.input.write(i),n.created&&(t.form.sync(),t.form.dispatchCommit()),this.emitClear(r),this.validate(i)}clearedSelection(e){let{core:t}=this.context;return e&&!z(t.value)?t.value:this.session.active&&!z(t.draft)?t.draft:null}emitClear(e){this.context.emitter.emit(`clear`,{previousValue:this.present(e)})}setActiveEnd(e){let{core:t,status:n}=this.context,r=jn;!n.destroyed&&t.options.mode===`range`&&r.includes(e)&&(t.controlActiveEnd(),t.setActiveEnd(e))}applyTyped(e){let{core:t,emitter:n,managers:r}=this.context,i=!I(t.value,e),a=I(t.draft,e);t.setValue(e),r.form.sync(),(i||!a)&&this.follow(),i&&n.emit(`confirm`,{value:this.present(e),autoCommit:!0}),this.validate(e)}commit(e){let{core:t,emitter:n,managers:r}=this.context,i=t.draft;t.setValue(i),r.input.write(i),r.form.sync(),r.form.dispatchCommit(),n.emit(`confirm`,{value:this.present(i),autoCommit:e}),this.validate(i)}validate(e){let{core:t,managers:n}=this.context,{validate:r}=t.options;if(r===null)return;let i=r(this.present(e));i!==null&&n.input.markInvalid(i)}present(e){return Ye(e,this.describe)}follow(){if(!this.session.active)return;let{core:e}=this.context,t=e.value;e.setDraft(t);let n=R(t);n!==null&&this.visible.hold(`api`,()=>{X(this.context,n,`api`)})}};const Nn=e=>e===`input`?`input`:`calendar`;var Pn=class{context;isShown;visible;constructor(e,t,n){this.context=e,this.isShown=t,this.visible=n}get(){return this.isShown()?Nn(this.context.core.panel):`calendar`}set(e){let{core:t}=this.context;this.isShown()&&this.hasInputView()&&t.setPanel(e===`input`?`input`:M(t.options.precision))}goTo(e){let t=K(e,`single`,`day`),n=t===null?null:R(t);n===null?this.context.emitter.emit(`error`,{code:`invalid-date`,message:`goTo() received a value that is not a valid date`,input:typeof e==`string`?e:void 0}):this.isShown()&&this.visible.hold(`api`,()=>{X(this.context,tn(this.context,n),`api`)})}bind(e){let{core:t,emitter:n}=this.context,r=Nn(t.panel);t.events.on(`change:panel`,({panel:e})=>{let t=Nn(e);t!==r&&(r=t,n.emit(`switch:view`,{view:t}))},e)}opening(e){let{core:t}=this.context,{initialView:n,inline:r,mode:i,precision:a,startView:o}=t.options;if(n===`input`&&this.hasInputView())return`input`;let s=H(e,r).navigation===`caption`;return a!==`day`||i===`range`||s?M(a):u(o,t.calendarLayout)}dropUnsupported(){let{core:e}=this.context;e.panel===`input`&&!this.hasInputView()&&e.setPanel(M(e.options.precision))}hasInputView(){let{core:e}=this.context,{mode:t,precision:n}=e.options;return c(t,e.calendarLayout,n)}};const Fn=(e,t)=>({from:{year:e.year,month:e.month,day:1},to:{year:t.year,month:t.month,day:D(t)}}),In=(e,t,n)=>{let r={year:e.year,month:e.month,day:1},i=(S(r)-t+7)%7,a=n?6:Math.ceil((i+D(e))/7),o=E(r,-i);return{from:o,to:E(o,a*7-1)}},Ln=e=>{let t=e.layout===`docked`&&e.months<=1&&e.outsideDays;return{outsideDays:t,fixedWeeks:e.layout!==`docked`&&!e.inline||t||e.fixedWeeks}},Rn=e=>{let{view:t,listSpan:n,yearBounds:r}=e;return n===null?e.precision===`year`?Fn({year:r.min,month:1},{year:r.max,month:12}):e.precision===`month`?Fn({year:t.year,month:1},{year:t.year,month:12}):e.months>1?Fn(t,L(t,e.months-1)):e.outsideDays?In(t,e.weekStart,e.fixedWeeks):Fn(t,t):Fn(n.first,n.last)};function zn(e){return e<0?-1:+(e>0)}var Bn=class{context;isShown;last=null;live=!1;constructor(e,t){this.context=e,this.isShown=t}current(){if(!this.isShown())return null;let{from:e,to:t}=this.compute();return{from:this.describe(e),to:this.describe(t)}}bind(e){this.context.core.events.on(`change:view`,({source:e})=>{this.report(e)},e)}hold(e,t){let n=this.live;this.live=!1;try{t()}finally{this.live=n}this.report(e)}pause(){this.live=!1}resume(e){this.live=!0,this.report(this.last===null?`open`:e)}reset(){this.last=null,this.live=!1}renderedMonths(e,t){this.context.core.setListSpan({first:e,last:t}),this.report(`scroll`)}report(e){if(!this.live)return;let{core:t,emitter:n}=this.context,{from:r,to:a}=this.compute(),o={view:t.view,from:i(r),to:i(a)},s=this.last;if(s?.from===o.from&&s.to===o.to)return;this.last=o;let c=s===null?0:A(s.view,o.view);n.emit(`navigate`,{year:o.view.year,month:o.view.month,direction:zn(c),source:e,from:this.describe(r),to:this.describe(a)})}compute(){let{core:e,managers:t}=this.context,{options:n,layout:r}=e,i=Ln({layout:e.calendarLayout,inline:e.mode===`inline`,months:r.months,outsideDays:n.mode!==`range`&&n.outsideDays!==!1,fixedWeeks:n.fixedWeeks});return Rn({view:e.view,months:r.months,precision:n.precision,weekStart:n.weekStart,fixedWeeks:i.fixedWeeks,outsideDays:i.outsideDays,yearBounds:t.validation.yearBounds(),listSpan:e.listSpan})}describe(e){return{value:i(e),date:Ke(e),formatted:k(e,this.context.core.options.pattern,`day`)}}},Vn=class{status={created:!1,destroyed:!1};visible;views;session;values;actions;instance;updates;constructor(e,t,n){let r={core:e,emitter:t,managers:n,status:this.status},i=new vn(r),a=new An(r),o=()=>this.session.active;this.visible=new Bn(r,o),this.views=new Pn(r,o,this.visible),this.session=new kn(r,this.views,this.visible),this.values=new Mn(r,this.session,this.visible),this.actions=new _n(r,this.session,this.values),this.instance=new Dn(r,this.session,i,a),this.updates=new En(r,this.session,i,a),n.connect(this)}get created(){return this.status.created}get destroyed(){return this.status.destroyed}create(){this.instance.create()}open(e,t){this.session.open(e,t)}close(){return this.session.close()}destroy(e){this.instance.destroy(e)}setOptions(e){this.updates.apply(e)}getValue(){return this.values.get()}setValue(e){this.values.set(e)}setActiveEnd(e){this.values.setActiveEnd(e)}setView(e){this.views.set(e)}getView(){return this.views.get()}getVisibleRange(){return this.visible.current()}goTo(e){this.views.goTo(e)}isSelectable(e){return this.values.isSelectable(e)}clearValue(){this.values.clear()}applyTyped(e){this.values.applyTyped(e)}fallBackToModal(){this.session.fallBackToModal()}select(e){this.actions.select(e)}selectRange(e,t){this.actions.selectRange(e,t)}typeDraft(e){this.actions.typeDraft(e)}submitDraft(){this.actions.submitDraft()}focusDate(e){this.actions.focusDate(e)}navigate(e,t){this.actions.navigate(e,t)}page(e,t){this.actions.page(e,t)}jumpTo(e,t){this.actions.jumpTo(e,t)}showPanel(e){this.actions.showPanel(e)}confirm(){this.actions.confirm()}cancel(e){this.actions.cancel(e)}today(){this.actions.today()}clear(){this.actions.clear()}renderedMonths(e,t){this.visible.renderedMonths(e,t)}};const Hn=e=>e.toLowerCase().replace(/_/g,`-`);function Un(e,t){Object.entries(T).forEach(([n,r])=>{e.style.setProperty(`--dp-ui-motion-${Hn(n)}`,`${String(t?r:0)}ms`)}),Object.entries(l).forEach(([t,n])=>{e.style.setProperty(`--dp-ui-easing-${Hn(t)}`,n)})}function Wn(e,t,n){if(t===`range`)return e.rangeTitle;switch(n){case`month`:return e.monthTitle;case`year`:return e.yearTitle;case`day`:return e.title}}const Gn=/* @__PURE__ */ new Map,Kn=/* @__PURE__ */ new Map;function qn(e){let t=Gn.get(e);if(t)return t;let n=new Intl.PluralRules(e);return Gn.set(e,n),n}function Jn(e){let t=Kn.get(e);if(t)return t;let n=new Intl.NumberFormat(e);return Kn.set(e,n),n}function Yn(e,t,n){return(typeof e==`string`?e:e[qn(n).select(t)]??e.other??Object.values(e).at(0)??``).replaceAll(`{count}`,Jn(n).format(t))}function Xn(e,t,n,r,i){switch(e.mode){case`single`:return e.date?ce(e.date,i,n,`headline`):r.noDate;case`range`:{if(t===`input`&&e.start&&e.end)return le(e.start,e.end,n);let i=e.start?se(e.start,n):r.rangeStart,a=e.end?se(e.end,n):r.rangeEnd;return`${i}${pe}${a}`}default:return e.dates.length===0?r.noDate:Yn(r.multipleSelected,e.dates.length,n)}}const Zn=`dp-ui--ripple-pressed`,Qn=`dp-ui--ripple-active`,$n=e=>e.getAttribute(`aria-disabled`)===`true`||e instanceof HTMLButtonElement&&e.disabled;function er(e,t,n){let r=e=>e instanceof Element?e.closest(t):null,i=e=>{r(e.target)?.classList.remove(Zn)};e.addEventListener(`pointerdown`,t=>{let a=r(t.target);if(!a||!e.contains(a)||$n(a)||t.pointerType===`mouse`&&t.button!==0)return;a.classList.remove(Qn);let{left:o,top:s,width:c,height:l}=a.getBoundingClientRect();a.style.setProperty(`--dp-ui-ripple-x`,`${String(t.clientX-o)}px`),a.style.setProperty(`--dp-ui-ripple-y`,`${String(t.clientY-s)}px`),a.style.setProperty(`--dp-ui-ripple-size`,`${String(Math.max(c,l)*2)}px`),a.style.setProperty(`--dp-ui-ripple-duration`,`${String(T.RIPPLE)}ms`),a.classList.add(Zn),a.addEventListener(`pointerleave`,i,{once:!0,signal:n}),C()||(requestAnimationFrame(()=>{a.classList.add(Qn)}),window.setTimeout(()=>{a.classList.remove(Qn)},T.RIPPLE))},{signal:n}),e.addEventListener(`pointerup`,i,{signal:n}),e.addEventListener(`pointercancel`,i,{signal:n})}const tr=(e,t)=>{e.querySelectorAll(`.dp-ui__text-button--confirm, .dp-ui__text-button--save`).forEach(e=>{e.disabled=!t})},nr=e=>{let{labels:t}=e,n=d(`div`,`dp-ui__actions`);n.hidden=!e.visible;let r=d(`div`,`dp-ui__actions-start`);e.todayButton&&r.append(ve(`today`,t.today)),e.clearButton&&r.append(ve(`clear`,t.clear));let i=d(`div`,`dp-ui__actions-end`);return i.append(ve(`cancel`,t.cancel),ve(`confirm`,t.confirm)),n.append(r,i),n},rr=[[`dp-ui__icon-button--prev-month`,{kind:`page`,direction:-1}],[`dp-ui__icon-button--next-month`,{kind:`page`,direction:1}],[`dp-ui__icon-button--prev-year`,{kind:`navigate`,delta:-12}],[`dp-ui__icon-button--next-year`,{kind:`navigate`,delta:12}],[`dp-ui__menu-button--month`,{kind:`panel`,panel:`month-menu`}],[`dp-ui__menu-button--year`,{kind:`panel`,panel:`year-menu`}],[`dp-ui__menu-button--year-grid`,{kind:`panel`,panel:`year-grid`}],[`dp-ui__text-button--today`,{kind:`today`}],[`dp-ui__text-button--clear`,{kind:`clear`}],[`dp-ui__text-button--cancel`,{kind:`cancel`}],[`dp-ui__text-button--confirm`,{kind:`confirm`}],[`dp-ui__text-button--save`,{kind:`confirm`}],[`dp-ui__icon-button--close`,{kind:`cancel`}],[`dp-ui__icon-button--switch-view`,{kind:`switch`}]],ir=e=>rr.find(([t])=>e.classList.contains(t)),ar=e=>ir(e)?.[0]??null,or=(e,t)=>{let{actions:n}=t;switch(e.kind){case`navigate`:n.navigate(e.delta,`button`);return;case`page`:n.page(e.direction,`button`);return;case`panel`:n.showPanel(t.panel()===e.panel?t.home:e.panel);return;case`switch`:n.showPanel(t.panel()===`input`?t.home:`input`);return;case`today`:n.today();return;case`clear`:n.clear();return;case`cancel`:n.cancel(`button`);return;case`confirm`:n.confirm()}},sr=(e,t,n)=>{e.addEventListener(`click`,e=>{let{target:t}=e,r=t instanceof Element?t.closest(`button`):null;if(r!==null){let e=ir(r);e&&or(e[1],n);return}let i=n.cellAt(t);i!==null&&n.actions.select(i.date)},{signal:t})},cr=`dp-ui__container--menu-open`,lr=`dp-ui__container--input`,ur=`--dp-ui-visible-months`,dr=e=>e.closest(`.dp-ui__container`),fr=(e,t)=>e!==t&&e!==`days`&&e!==`input`,pr=(e,t)=>{let n=t>1;e.classList.toggle(`dp-ui__container--multi-month`,n),n?e.style.setProperty(ur,String(t)):e.style.removeProperty(ur)},mr=(e,t,n)=>{let r=t===`input`;e.classList.toggle(lr,r),pr(e,r?1:n)},hr=e=>{let{locale:t,labels:n}=e,r=ue(n),i=d(`div`,`dp-ui__navigation dp-ui__navigation--caption`),a=d(`span`,`dp-ui__caption`);a.hidden=e.arrowsOnly,i.append(a,P(`prev-month`,n.previousMonth,V.keyboardArrowLeft,r.previousMonth),P(`next-month`,n.nextMonth,V.keyboardArrowRight,r.nextMonth));let o=e=>{a.textContent=Me(e,t)};return o(e.view),{element:i,setView:o}},gr=(e,t)=>{let n=d(`div`,`dp-ui__navigation-group dp-ui__navigation-group--${e}`);return n.append(...t),n},_r=t=>{let{labels:n}=t,r=ue(n),i=e(t.locale,`short`),a=e(t.locale,`long`),o=je(`month`,``,{name:n.chooseMonth,controls:F(t.instanceId,`month-menu`),shortcut:r.chooseMonth}),s=je(`year`,``,{name:n.chooseYear,controls:F(t.instanceId,`year-menu`),shortcut:r.chooseYear}),c=d(`div`,`dp-ui__header dp-ui__header--docked`),l=gr(`month`,[P(`prev-month`,n.previousMonth,V.keyboardArrowLeft,r.previousMonth),o.button,P(`next-month`,n.nextMonth,V.keyboardArrowRight,r.nextMonth)]);l.hidden=t.groups!==`both`,c.hidden=t.groups===`none`,c.append(l,gr(`year`,[P(`prev-year`,n.previousYear,V.keyboardArrowLeft,r.previousYear),s.button,P(`next-year`,n.nextYear,V.keyboardArrowRight,r.nextYear)]));let u=e=>{o.setText(i[e.month-1]??``,a[e.month-1]??``),s.setText(v(e.year,t.locale))},f=e=>{o.button.setAttribute(`aria-expanded`,String(e===`month-menu`)),s.button.setAttribute(`aria-expanded`,String(e===`year-menu`)),o.button.disabled=e===`year-menu`,s.button.disabled=e===`month-menu`};return u(t.view),f(t.home),{element:c,setView:u,setPanel:f}},vr=`dp-ui__headline--fading-out`,yr=(e,t)=>{let n=d(`div`,`dp-ui__headline`);n.textContent=e;let r=null,i=null,a=()=>{i!==null&&clearTimeout(i),i=null,r=null,n.classList.remove(vr)},o=()=>{let e=r;a(),e!==null&&(n.textContent=e)};return{element:n,setText:e=>{e!==(r??n.textContent)&&(t?(r=e,n.classList.add(vr),i??=setTimeout(o,T.HEADLINE_FADE)):(a(),n.textContent=e))},destroy:a}},br=e=>{let{labels:t,switchView:n}=e,r=d(`div`,`dp-ui__header dp-ui__header--modal`),i=d(`div`,`dp-ui__supporting-text`);i.textContent=e.title;let a=yr(e.text,e.animate);r.append(i,a.element);let o=n===null?null:Te(t,n.panelId);return o!==null&&r.append(o.button),{element:r,setText:e=>{a.setText(e)},setInputView:e=>{o?.setInputView(e)},destroy:()=>{a.destroy()}}},xr=(e,t,n,r,i)=>{if(i)return hr({locale:t,labels:n,view:e,arrowsOnly:!1}).element;let a=ue(n),o=d(`div`,`dp-ui__navigation`);return o.append(je(`year-grid`,Me(e,t),{name:n.chooseYear,controls:F(r,`year-grid`),shortcut:a.chooseYear}).button,P(`prev-month`,n.previousMonth,V.keyboardArrowLeft,a.previousMonth),P(`next-month`,n.nextMonth,V.keyboardArrowRight,a.nextMonth)),o},Sr=(e,t,n,r)=>{let i=d(`div`,`dp-ui__navigation dp-ui__navigation--month-grid`),a=ue(n);return i.append(je(`year-grid`,v(e.year,t),{name:n.chooseYear,controls:F(r,`year-grid`),shortcut:a.chooseYear}).button,P(`prev-year`,n.previousYear,V.keyboardArrowLeft,a.previousYear),P(`next-year`,n.nextYear,V.keyboardArrowRight,a.nextYear)),i},Cr=(e,t,n,r)=>{let i=d(`div`,`dp-ui__navigation dp-ui__navigation--year-grid`),{button:a}=je(`year-grid`,Me(e,t),{name:n.chooseYear,controls:F(r,`year-grid`)});return a.setAttribute(`aria-expanded`,`true`),i.append(a),i},wr=e=>{let{decorateDate:t}=e.options;return t===null?()=>null:e=>{try{return t(Ke(e))??null}catch(e){return U(e),null}}},Tr=e=>{let{renderDate:t}=e.options;return t===null?()=>null:e=>t(Ke(e))},Er=(e,t,n)=>{let{options:r}=e;return{locale:r.locale,weekStart:r.weekStart,weekNumbers:r.weekNumbers,showOutside:n,outsideSelectable:r.outsideDays!==!1&&r.outsideDays.selectable,labels:{weekNumber:r.labels.weekNumber},rangeLabels:{start:r.labels.rangeStart,end:r.labels.rangeEnd,inRange:r.labels.inRange},headingVisible:!1,weekdaysVisible:!0,multiselectable:e.draft.mode!==`single`,rangeRole:()=>null,labelRole:()=>null,decorate:wr(e),content:Tr(e),isSelected:t=>_e(e.draft,t),isDisabled:n=>!t.isSelectable(n,e.followsActiveEnd?mn(e.draft,e.activeEnd):e.draft),today:h(),focus:e.focus}},Dr=(e,t,n)=>{let r=e.layout.months>1,i=n===`docked`&&!r&&e.options.outsideDays!==!1,a=Er(e,t,i);return r?{...a,headingVisible:!0}:a},Or=(e,t)=>y(t,L(t,e.layout.months-1),e.options.locale),Z=e=>Xn(e.draft,e.panel===`input`?`input`:`calendar`,e.options.locale,e.options.labels,e.options.precision),kr={element:null,docked:null,modal:null,caption:null},Ar={days:null,input:null,"month-menu":`.dp-ui__menu-button--month`,"year-menu":`.dp-ui__menu-button--year`,"year-grid":`.dp-ui__menu-button--year-grid`,"month-grid":null},jr=e=>{switch(e){case`day`:return`both`;case`month`:return`year`;case`year`:return`none`}},Mr=e=>Ar[e],Nr=(e,t)=>e.options.precision===`day`&&H(t,e.options.inline).navigation===`caption`,Pr=(e,t,n)=>{let{locale:r,labels:i,animation:a,viewSwitch:o,mode:s,precision:l}=e.options;if(t===`modal`){if(!H(n,e.options.inline).headline)return kr;let t=o&&c(s,e.calendarLayout,l),r=br({labels:i,title:Wn(i,s,l),animate:a,text:Z(e),switchView:t?{panelId:F(e.instanceId,`input`)}:null});return r.setInputView(e.panel===`input`),{element:r.element,docked:null,modal:r,caption:null}}if(Nr(e,n)){let t=hr({locale:r,labels:i,view:e.view,arrowsOnly:e.layout.months>1});return{element:t.element,docked:null,modal:null,caption:t}}let u=_r({instanceId:e.instanceId,locale:r,labels:i,view:e.view,groups:jr(l),home:M(l)});return{element:u.element,docked:u,modal:null,caption:null}},Fr=(e,t)=>{let n=L(e,t);return{year:n.year,month:n.month,day:Math.min(e.day,D(n))}},Ir=(e,t,n,r)=>{let i=t?12:1;switch(e){case`ArrowLeft`:return E(n,r?1:-1);case`ArrowRight`:return E(n,r?-1:1);case`ArrowUp`:return E(n,-7);case`ArrowDown`:return E(n,7);case`Home`:return{year:n.year,month:n.month,day:1};case`End`:return{...n,day:D(n)};case`PageUp`:return Fr(n,-i);case`PageDown`:return Fr(n,i);default:return null}},Lr=e=>e.ctrlKey||e.altKey||e.metaKey,Rr=(e,t)=>{let n=e.toLowerCase();return t===`modal`?n===`y`?`year-grid`:null:n===`m`?`month-menu`:n===`y`?`year-menu`:null},zr=e=>{let{panel:t}=e.core;return e.caption()?!1:e.layout===`docked`?e.home===`days`&&t===`days`:e.layout===`modal`&&t===e.home&&e.home!==`year-grid`},Br=(e,t)=>{let{panel:n}=t.core;n!==t.home&&n!==`input`&&(e.preventDefault(),e.stopPropagation(),t.actions.showPanel(t.home))},Vr=(e,t)=>{if(!e.shiftKey||!zr(t))return!1;let n=Rr(e.key,t.layout);return n!==null&&(e.preventDefault(),t.actions.showPanel(n),!0)},Hr=(e,t,n)=>{e.preventDefault(),e.key===`Enter`&&n.layout===`modal`&&n.core.options.mode===`single`&&ne(n.core.options.footerExplicit,n.core.mode)&&_e(n.core.draft,t.date)?n.actions.confirm():n.actions.select(t.date)},Ur=(e,t,n)=>{if(e.key===`Enter`||e.key===` `){Hr(e,t,n);return}let r=Ir(e.key,e.shiftKey,t.date,n.isRtl());r!==null&&(e.preventDefault(),n.actions.focusDate(r))},Wr=(e,t,n)=>{e.addEventListener(`keydown`,e=>{if(e.defaultPrevented)return;if(e.key===`Escape`){Br(e,n);return}if(Lr(e)||Vr(e,n))return;let t=n.cellAt(e.target);t!==null&&Ur(e,t,n)},{signal:t})},Gr=`dp-ui__ghost`,Kr=e=>Array.from(e.querySelectorAll(`*`)).filter(e=>e.closest(`.${Gr}`)===null),qr=(e,t,n)=>{e.querySelectorAll(`.${Gr}`).forEach(e=>{e.remove()}),e.removeAttribute(`popover`),e.removeAttribute(`style`),e.classList.remove(`dp-ui__container--morphing`),e.classList.add(Gr),e.setAttribute(`aria-hidden`,`true`),e.setAttribute(`inert`,``),e.removeAttribute(`id`),e.removeAttribute(`name`),e.querySelectorAll(`[id], [name]`).forEach(e=>{e.removeAttribute(`id`),e.removeAttribute(`name`)}),e.style.setProperty(`inline-size`,`${String(t)}px`),e.style.setProperty(`block-size`,`${String(n)}px`)},Jr=(e,t)=>{let n=Array.from(t.querySelectorAll(`*`));return Kr(e).flatMap((e,t)=>{let r=n.at(t);return r===void 0||e.scrollTop===0&&e.scrollLeft===0?[]:[{live:e,copy:r,top:e.scrollTop,left:e.scrollLeft}]})},Yr=({live:e,copy:t})=>{let n=e.getBoundingClientRect(),r=Array.from(t.children);Array.from(e.children).forEach((e,t)=>{let i=r.at(t),a=e.getBoundingClientRect();i===void 0||a.bottom>n.top&&a.top<n.bottom||(i.replaceChildren(),i instanceof HTMLElement&&i.style.setProperty(`block-size`,`${String(a.height)}px`))})},Xr=(e,t,n)=>{let r=e.cloneNode(!0);if(!(r instanceof HTMLElement))return null;qr(r,t,n);let i=Jr(e,r);i.forEach(Yr);let a=null,o=()=>{if(a!==null){let e=a;a=null,e.cancel()}r.remove()};return{show:()=>{e.append(r),i.forEach(({copy:e,top:t,left:n})=>{e.scrollTop=t,e.scrollLeft=n}),typeof r.animate==`function`?(a=r.animate([{opacity:1},{opacity:0}],{duration:T.VIEW_SWITCH_FADE_OUT,easing:`linear`,fill:`forwards`}),a.finished.then(o,o)):o()},remove:o}},Zr=`dp-ui__container--morphing`,Qr=/* @__PURE__ */ new WeakMap,$r=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height,radius:getComputedStyle(e).borderRadius}},ei=(e,t)=>{if(t===null)return null;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();return{x:getComputedStyle(t).direction===`rtl`?n.right-r.right:r.left-n.left,y:r.top-n.top,height:r.height}},ti=e=>({width:`${String(e.width)}px`,height:`${String(e.height)}px`,borderRadius:e.radius}),ni=(e,t,n)=>{if(n.height===0)return;let r=getComputedStyle(e).direction===`rtl`,i=(t.x-n.x)*(r?-1:1),a=t.y-n.y,o=t.height/n.height;if(i===0&&a===0&&o===1)return;let s=r?`top right`:`top left`;e.animate([{transform:`translate(${String(i)}px, ${String(a)}px) scale(${String(o)})`,transformOrigin:s},{transform:`none`,transformOrigin:s}],{duration:T.VIEW_SWITCH,easing:l.EMPHASIZED})},ri=(e,t,n)=>{if(n===`none`||typeof e.animate!=`function`)return t(),null;if(n===`reduced`){let n=$r(e),r=Xr(e,n.width,n.height);return t(),r?.show(),null}let r=e.querySelector(`.dp-ui__headline`),i=$r(e),a=ei(e,r),o=Xr(e,i.width,i.height);t();let s=$r(e),c=ei(e,r);e.classList.add(Zr);let u=e.animate([ti(i),ti(s)],{duration:T.VIEW_SWITCH,easing:l.EMPHASIZED});Qr.set(e,u),o?.show(),r!==null&&a!==null&&c!==null&&ni(r,a,c);let d=()=>{o?.remove(),Qr.get(e)===u&&(Qr.delete(e),e.classList.remove(Zr))};return u.finished.then(d,d),u};function ii(e){let t=e.describedById??`${e.id}-supporting`,n=d(`div`,`dp-ui__text-field`),r=d(`input`,`dp-ui__text-field-input`,{id:e.id,type:`text`,inputmode:`numeric`,autocomplete:`off`,placeholder:e.placeholder,tabindex:`0`,"aria-invalid":`false`,"aria-describedby":t});r.value=e.value;let i=d(`label`,`dp-ui__text-field-label`,{for:e.id});i.textContent=e.label;let a=d(`div`,`dp-ui__text-field-supporting`,{id:t,"aria-live":`polite`});return a.textContent=e.hint,n.append(r,i,a),{element:n,input:r,getValue:()=>r.value,setValue:e=>{r.value=e},setError:t=>{let i=t!==null;n.classList.toggle(`dp-ui__text-field--error`,i),r.setAttribute(`aria-invalid`,i?`true`:`false`);let o=t??e.hint;a.textContent!==o&&(a.textContent=o)}}}function ai(e){return e.mode===`single`?e.date:null}function oi(e){return e.mode===`single`?e.date===null:e.mode===`range`?e.start===null:e.dates.length===0}function si(e){let{instanceId:t,draft:r,pattern:i,labels:a,rules:o}=e,s=d(`div`,`dp-ui__input-panel`,{"data-panel":`input`,id:F(t,`input`)}),c=fe(i,Ae(a)),l=(e,n,r)=>ii({id:`${t}-input-${e}`,label:n,placeholder:c,hint:c,value:r?xe(r,i):``}),u=r.mode===`range`,f=l(u?`start`:`date`,u?a.startDateField:a.dateField,r.mode===`range`?r.start:ai(r)),p=u?l(`end`,a.endDateField,r.end):null,m=p?[f,p]:[f],h=t=>{let n=t.getValue().trim();if(n===``)return t.setError(null),{date:null,failed:!1};let r=oe(n,i);if(r===null)return t.setError(a.invalidDate),{date:null,failed:!0};let s=o.unavailableReason(r);return s===null?(t.setError(null),t.setValue(xe(r,i)),{date:r,failed:!1}):(t.setError(e.messageFor(s)),{date:null,failed:!0})},g=()=>{let e=h(f);if(!p)return e.failed?null:{mode:`single`,date:e.date};let t=h(p),r=t.date,i=e.failed||t.failed;return e.date&&r&&n(r,e.date)<0&&(p.setError(a.invalidRange),r=null,i=!0),i?null:{mode:`range`,start:e.date,end:r}},_=t=>{let n=un(t,e.limits,e=>o.unavailableReason(e));return n===null||((p??f).setError(e.messageFor(n)),!1)};return m.forEach(t=>{t.input.addEventListener(`input`,()=>{he(t.input,i)}),t.input.addEventListener(`change`,()=>{let t=g();t&&_(t)&&e.onDraft(t)}),t.input.addEventListener(`keydown`,t=>{if(t.key!==`Enter`)return;t.preventDefault();let n=g();n&&_(n)&&N(n)&&!oi(n)&&(e.onDraft(n),e.onSubmit())})}),s.append(...m.map(e=>e.element)),s}function ci(e,t){let{labels:n,minDate:r,maxDate:i,pattern:a,precision:o}=t;return e===`min`&&r!==null?n.beforeMinDate.replace(`{date}`,k(r,a,o)):e===`max`&&i!==null?n.afterMaxDate.replace(`{date}`,k(i,a,o)):e===`range-length`?n.invalidRange:n.unavailableDate}const li=e=>{let{core:t,actions:n,rules:r}=e,{pattern:i,labels:a,limits:o}=t.options;return[si({instanceId:t.instanceId,draft:t.draft,pattern:i,labels:a,rules:r,limits:o,messageFor:e=>ci(e,t.options),onDraft:e=>{n.typeDraft(e)},onSubmit:()=>{ne(t.options.footerExplicit,t.mode)?n.confirm():n.submitDraft()}})]},ui=`dp-ui__date`,di=`dp-ui__date--outside-month`,fi=`data-decoration-label`,pi=`data-content-label`,mi=`dp-ui__date-content`,hi=`dp-ui__date--has-content`,gi=`:scope > .${mi}`,_i=(e,t,n)=>n.isDisabled(e)||t&&!n.outsideSelectable,vi=(e,t,n,r)=>[[`dp-ui__date--selected`,r.isSelected(e)],[`dp-ui__date--range-start`,n===`start`],[`dp-ui__date--range-end`,n===`end`],[`dp-ui__date--in-range`,n===`in-range`],[`dp-ui__date--today`,_(e,r.today)],[`dp-ui__date--disabled`,_i(e,t,r)],[di,t]],yi=e=>{e.querySelector(gi)?.remove(),e.classList.remove(hi),e.removeAttribute(pi)},bi=(e,t,n)=>{let r=n.content(t);if(r===null){yi(e);return}let i=e.querySelector(gi),a=(typeof r==`string`?r:r.textContent??``).trim();if(typeof r!=`string`||i===null||i.childElementCount!==0||i.textContent!==r){let t=d(`span`,mi);typeof r==`string`?t.textContent=r:t.appendChild(r),i===null?e.querySelector(`.dp-ui__date-indicator`)?.after(t):i.replaceWith(t)}e.classList.add(hi),a===``?e.removeAttribute(pi):e.setAttribute(pi,a)},xi=(e,t)=>e===`start`?t.rangeLabels.start:e===`end`?t.rangeLabels.end:e===`in-range`?t.rangeLabels.inRange:null,Si=(e,t,n,r,i)=>[p(e,i.locale),xi(t,i),n,r].filter(e=>e!==null&&e!==``).join(`, `),Ci=(e,t,n,r)=>{let i=r.rangeRole(t);bi(e,t,r),vi(t,n,i,r).forEach(([t,n])=>e.classList.toggle(t,n)),e.setAttribute(`aria-selected`,String(r.isSelected(t)||i!==null)),e.setAttribute(`aria-label`,Si(t,r.labelRole(t),e.getAttribute(fi),e.getAttribute(pi),r)),_(t,r.today)?e.setAttribute(`aria-current`,`date`):e.removeAttribute(`aria-current`),_i(t,n,r)?e.setAttribute(`aria-disabled`,`true`):e.removeAttribute(`aria-disabled`);let a=!n&&_(t,r.focus);e.setAttribute(`tabindex`,a?`0`:`-1`)},wi=(e,t)=>{if(t===null)return;let n=(t.className??``).split(/\s+/).filter(Boolean);e.classList.add(...n),t.label&&e.setAttribute(fi,t.label),t.badge===!0&&e.appendChild(d(`span`,`dp-ui__date-badge`,{"aria-hidden":`true`}))},Ti=(e,t)=>{if(!e.inMonth&&!t.showOutside)return d(`td`,`${ui} dp-ui__date--empty`);let n=d(`td`,ui,{role:`gridcell`,"data-date":i(e.date)}),r=d(`span`,`dp-ui__date-indicator`);return r.textContent=v(e.date.day,t.locale),n.appendChild(r),wi(n,t.decorate(e.date)),Ci(n,e.date,!e.inMonth,t),n},Ei=`dp-ui__visually-hidden`,Di=e=>{let t=d(`thead`),n=d(`tr`,e.weekdaysVisible?`dp-ui__weekdays`:`dp-ui__weekdays ${Ei}`);if(e.weekNumbers){let t=d(`th`,`dp-ui__week-number-header`,{scope:`col`});t.textContent=e.labels.weekNumber,n.appendChild(t)}let r=Oe(e.locale,`narrow`),i=Oe(e.locale,`long`);for(let t=0;t<7;t++){let a=(e.weekStart+t)%7,o=i[a]??``,s=d(`th`,`dp-ui__weekday`,{role:`columnheader`,scope:`col`,abbr:o,title:o});s.textContent=r[a]??``,n.appendChild(s)}return t.appendChild(n),t},Oi=(e,t)=>{let n=d(`table`,`dp-ui__month-grid`,{role:`grid`});t.multiselectable===!0&&n.setAttribute(`aria-multiselectable`,`true`);let r=d(`caption`,t.headingVisible?`dp-ui__month-subhead`:`dp-ui__month-heading ${Ei}`);r.textContent=Me(e.view,t.locale),n.appendChild(r),n.appendChild(Di(t));let i=d(`tbody`);return e.weeks.forEach((n,r)=>{let a=d(`tr`,`dp-ui__week`);if(t.weekNumbers){let n=d(`th`,`dp-ui__week-number`,{scope:`row`}),i=e.weekNumbers.at(r);n.textContent=i===void 0?``:v(i,t.locale),a.appendChild(n)}n.forEach(e=>a.appendChild(Ti(e,t))),i.appendChild(a)}),n.appendChild(i),n},ki=(e,t)=>{e.querySelectorAll(`td[data-date]`).forEach(e=>{let n=f(e.dataset.date??``);n!==null&&Ci(e,n,e.classList.contains(di),t)})},Ai=(e,t,n)=>{let r={year:e.year,month:e.month,day:1},i=(S(r)-t+7)%7,a=n?6:Math.ceil((i+D(e))/7),o=E(r,-i),s=(4-t+7)%7,c=[],l=[];for(let t=0;t<a;t++){let n=E(o,t*7),r=[];for(let t=0;t<7;t++){let i=E(n,t);r.push({date:i,inMonth:i.year===e.year&&i.month===e.month})}c.push(r),l.push(x(E(n,s)))}return{view:e,weeks:c,weekNumbers:l}},ji=`table.dp-ui__month-grid`,Mi=(e,t)=>{e.style.setProperty(`transition`,`none`),t(),e.getBoundingClientRect(),e.style.removeProperty(`transition`)},Ni=e=>{let{core:t,layout:n,surface:r,gridContext:i}=e,{months:a}=t.layout,{outsideSelectable:o,headingVisible:s}=i(),c=r===`inline`,{fixedWeeks:l}=Ln({layout:n===`modal`?`modal`:`docked`,inline:c,months:a,outsideDays:t.options.outsideDays!==!1,fixedWeeks:t.options.fixedWeeks}),u=n===`docked`||c,p=r!==void 0&&Nr(t,r),m=d(`div`,void 0,{"data-panel":`days`}),h=e=>m.querySelector(`.dp-ui__page:not([inert])`)?.querySelector(e)??null,g=e=>Ai(e,t.options.weekStart,l),_=e=>Array.from({length:a},(t,n)=>L(e,n)),v=e=>{let t=i();if(a===1)return Oi(g(e),t);let n=d(`div`,`dp-ui__months`);return n.append(..._(e).map(e=>Oi(g(e),t))),n},y=e=>{let r=d(`div`);if(n===`modal`){let{locale:n,labels:i}=t.options;r.append(xr(e,n,i,t.instanceId,p))}return r.append(v(e)),r},b=e=>Math.max(..._(e).map(e=>g(e).weeks.length)),x=e=>{let t=b(e),n=h(`.dp-ui__navigation`)?.getBoundingClientRect().height??0,r=m.querySelector(ji),i=r?.tHead?.getBoundingClientRect().height??0,a=(r?.tBodies.item(0)?.rows.item(0))?.getBoundingClientRect().height??0,o=s?r?.caption?.getBoundingClientRect().height??0:0;return i>0&&a>0?n+o+i+a*t:n+(t+(s?2:1))*48},ee=t.options.pageBy===`view`?a:1,S=new ke(m,{rtl:e.rtl,swipe:t.options.swipe,animate:t.options.animation,fitHeight:u,step:(e,t)=>L(e,t*ee),isSame:Fe,renderPage:y,pageHeight:x,onCommit:(t,n)=>{e.onCommit(t,n)}}),C=()=>m.ownerDocument.activeElement,w=e=>{if(!(e instanceof Element))return null;let t=e.closest(`td.dp-ui__date[data-date]`);if(t===null||!m.contains(t)||t.classList.contains(`dp-ui__date--outside-month`)&&!o)return null;let n=f(t.getAttribute(`data-date`)??``);return n===null?null:{element:t,date:n}},T=()=>w(C())!==null,E=e=>{let t=h(`td.dp-ui__date[tabindex="0"]`);return t!==null||!e?t:h(`td.dp-ui__date[data-date]:not(.dp-ui__date--outside-month)`)},te=e=>{E(e)?.focus({preventScroll:!0})},D=()=>{let e=C();return e===null||!m.contains(e)?null:{buttonClass:ar(e)}},O=e=>{let{buttonClass:t}=e;((t===null?null:h(`.${t}`))??E(!0))?.focus({preventScroll:!0})},k=e=>{let t=D();e(),t!==null&&O(t)};return{element:m,present:(e,t)=>{k(()=>{t===0?S.show(e):S.slide(e,t>0?1:-1)})},finish:()=>{S.finish()},refresh:()=>{let e=i();m.querySelectorAll(ji).forEach(t=>{ki(t,e)})},refit:()=>{if(!u||m.hidden)return;let e=`${String(x(t.view))}px`;m.style.getPropertyValue(`--dp-ui-pager-height`)!==e&&k(()=>{Mi(m,()=>{S.show(t.view)})})},cellAt:w,focusCell:te,cellHasFocus:T,find:h,destroy:()=>{S.destroy()}}},Pi=e=>{let t=document.createElement(`div`);t.className=e.className,t.setAttribute(`role`,`listbox`),t.setAttribute(`aria-label`,e.label);let n=[],r=e.focused>=0&&e.focused<e.items.length?e.focused:0,i=(e,r)=>{let i=n.at(Math.max(0,Math.min(n.length-1,r)));i&&(n.at(e)?.setAttribute(`tabindex`,`-1`),i.setAttribute(`tabindex`,`0`),i.focus({preventScroll:!0}),b(t,i,`nearest`))},a=e=>{let n=getComputedStyle(t).direction===`rtl`?-1:1;switch(e){case`ArrowRight`:return n;case`ArrowLeft`:return-n;case`ArrowDown`:return 3;case`ArrowUp`:return-3;default:return null}};return e.items.forEach((o,s)=>{let c=document.createElement(`button`);c.type=`button`,c.className=e.itemClass,c.setAttribute(`role`,`option`),c.setAttribute(`aria-selected`,o.selected?`true`:`false`),c.setAttribute(`aria-label`,o.name),c.setAttribute(`tabindex`,s===r?`0`:`-1`),o.selected&&c.classList.add(`${e.itemClass}--selected`),o.current&&c.classList.add(`${e.itemClass}--current`),o.disabled&&c.setAttribute(`aria-disabled`,`true`),c.textContent=o.label;let l=()=>{o.disabled||o.onPick()};c.addEventListener(`click`,l),c.addEventListener(`keydown`,e=>{let t=a(e.key);t===null?e.key===`Home`?(e.preventDefault(),i(s,0)):e.key===`End`?(e.preventDefault(),i(s,n.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l()):(e.preventDefault(),i(s,s+t))}),n.push(c),t.appendChild(c)}),requestAnimationFrame(()=>{let i=t.querySelector(`.${e.itemClass}--selected`)??n.at(r);i&&b(t,i,`center`)}),t},Fi=t=>{let n=e(t.locale,`short`),r=e(t.locale,`long`),i=v(t.year,t.locale);return Pi({className:`dp-ui__month-selection`,itemClass:`dp-ui__month-selection-item`,label:t.label,focused:t.focused-1,items:n.map((e,n)=>{let a=n+1;return{label:e,name:`${r[n]??e} ${i}`,selected:a===t.selected,current:t.current.year===t.year&&t.current.month===a,disabled:t.isDisabled(a),onPick:()=>{t.onPick(a)}}})})},Ii=e=>{let t=e.querySelector(`.dp-ui__menu-item--selected`);t&&b(e,t,`center`)},Li=(e,t,n)=>{let r=e.at(Math.max(0,Math.min(e.length-1,n))),i=e.at(t);r&&(i?.setAttribute(`tabindex`,`-1`),r.setAttribute(`tabindex`,`0`),r.focus({preventScroll:!0}),r.parentElement&&b(r.parentElement,r,`nearest`))},Ri=(e,t,n)=>{let r=document.createElement(`ul`);r.className=`dp-ui__menu dp-ui__menu--${e}`,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-label`,t);let i=n.some(e=>e.selected),a=n.map((e,t)=>{let n=document.createElement(`li`);n.className=`dp-ui__menu-item`,n.setAttribute(`role`,`option`),n.setAttribute(`aria-selected`,e.selected?`true`:`false`);let r=e.selected||!i&&t===0;if(n.setAttribute(`tabindex`,r?`0`:`-1`),e.selected){n.classList.add(`dp-ui__menu-item--selected`);let e=document.createElement(`span`);e.innerHTML=V.check;let t=e.firstElementChild;t&&(t.setAttribute(`class`,`dp-ui__menu-item-icon`),t.setAttribute(`aria-hidden`,`true`),n.appendChild(t))}e.disabled&&n.setAttribute(`aria-disabled`,`true`);let a=document.createElement(`span`);a.className=`dp-ui__menu-item-label`,a.textContent=e.label,n.appendChild(a);let s=()=>{e.disabled||e.onPick()};return n.addEventListener(`click`,s),n.addEventListener(`keydown`,e=>{e.key===`ArrowDown`?(e.preventDefault(),Li(o,t,t+1)):e.key===`ArrowUp`?(e.preventDefault(),Li(o,t,t-1)):e.key===`Home`?(e.preventDefault(),Li(o,t,0)):e.key===`End`?(e.preventDefault(),Li(o,t,o.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())}),n}),o=a;return a.forEach(e=>r.appendChild(e)),requestAnimationFrame(()=>{Ii(r)}),r},zi=t=>{let n=e(t.locale,`long`);return Ri(`month`,t.label,n.map((e,n)=>{let r=n+1;return{label:e,selected:r===t.view.month,disabled:t.isMonthDisabled({year:t.view.year,month:r}),onPick:()=>{t.onPick(r)}}}))},Bi=e=>Pi({className:`dp-ui__year-selection`,itemClass:`dp-ui__year-selection-item`,label:e.label,focused:e.years.indexOf(e.focused),items:e.years.map(t=>{let n=v(t,e.locale);return{label:n,name:n,selected:t===e.selected,current:t===e.currentYear,disabled:!1,onPick:()=>{e.onPick(t)}}})}),Vi=e=>Ri(`year`,e.label,e.years.map(t=>({label:v(t,e.locale),selected:t===e.view.year,disabled:!1,onPick:()=>{e.onPick(t)}}))),Hi=e=>{let{min:t,max:n}=e.yearBounds(),r=[];for(let e=t;e<=n;e++)r.push(e);return r},Ui=(e,t)=>{let n=R(e.draft);return n?.year===t?n.month:null},Wi=(e,t,n)=>(e.setAttribute(`data-panel`,t),e.id=F(n,t),e),Gi=(e,t)=>{let{core:n,rules:r}=t,{labels:i,locale:a}=n.options,o=n.view,{precision:s}=n.options,c=e=>{t.actions.jumpTo(e,`menu`)},l=e=>{c({year:e,month:n.view.month})};switch(e){case`month-menu`:return[Wi(zi({locale:a,view:o,label:i.chooseMonth,isMonthDisabled:e=>r.isMonthDisabled(e),onPick:e=>{c({year:n.view.year,month:e})}}),e,n.instanceId)];case`year-menu`:return[Wi(Vi({view:o,years:Hi(r),label:i.chooseYear,locale:a,onPick:l}),e,n.instanceId)];case`month-grid`:{let l=s===`month`,u=l?Ui(n,o.year):o.month,d=Wi(Fi({year:o.year,selected:u,focused:u??o.month,current:h(),locale:a,label:i.chooseMonth,isDisabled:e=>r.isMonthDisabled({year:n.view.year,month:e}),onPick:e=>{l?t.actions.select({year:n.view.year,month:e,day:1}):c({year:n.view.year,month:e})}}),e,n.instanceId);return t.layout===`docked`?[d]:[Sr(o,a,i,n.instanceId),d]}case`year-grid`:{let c=s===`year`,u=c?R(n.draft)?.year??null:o.year,d=Wi(Bi({selected:u,focused:u??o.year,years:Hi(r),currentYear:h().year,label:i.chooseYear,locale:a,onPick:c?e=>{t.actions.select({year:e,month:1,day:1})}:l}),e,n.instanceId);return t.layout===`docked`||c?[d]:[Cr(o,a,i,n.instanceId),d]}}},Ki=`[role="option"]`,qi=`data-rebuilt`,Ji=e=>{let{root:t,content:n,days:r}=e,i=`days`,a=[],o=null,s=()=>t.ownerDocument.activeElement,c=e=>{e===`days`?r.hidden=!0:(a.forEach(e=>{e.remove()}),a=[])},l=t=>{t===`days`?(r.hidden=!1,r.removeAttribute(qi)):(a=e.createParts(t),r.after(...a))},u=()=>{let e=o;e!==null&&(o=null,e.complete(),e.animations.forEach(e=>{e.cancel()}))},d=()=>{let e=o;o=null,e?.animations.forEach(e=>{e.cancel()})},f=(t,n,r)=>{let i=e.motion()===`none`?[]:t.filter(e=>!e.hidden&&typeof e.animate==`function`);if(i.length===0){r();return}let a=i.map(e=>e.animate([{opacity:1},{opacity:0}],{duration:n,easing:`linear`,fill:`forwards`})),s={animations:a,complete:r};o=s,Promise.all(a.map(e=>e.finished)).then(()=>{o===s&&u()},()=>void 0)},p=()=>{let e=r.getBoundingClientRect().height;e>0&&n.style.setProperty(`--dp-ui-panel-height`,`${String(e)}px`)},m=n=>{u();let o=i;if(n===o)return;o===`days`&&p();let d=t.contains(s()),m=n===`input`||o===`input`;i=n;let h=()=>{let t=()=>{c(o),l(n),e.onSwitched(n,o,d)};e.swap===void 0?t():e.swap(t,n,o)};m?h():f(o===`days`?[r]:a,T.PANEL_FADE_OUT,h)},h=(e,t)=>{d(),e!==i&&(c(i),i=e,l(e),t?.rebuilt===!0&&a.forEach(e=>{e.setAttribute(qi,``)}))},g=e=>{let t=e.closest(`[role="listbox"]`);return t===null?-1:Array.from(t.querySelectorAll(Ki)).indexOf(e)},_=e=>{for(let t of a){let n=e(t);if(n)return n}return null},v=(e,t)=>t>=0?_(e=>Array.from(e.querySelectorAll(Ki)).at(t)):e===null?null:_(t=>t.querySelector(`.${e}`));return{current:()=>i,settled:()=>o===null,mount:h,switchTo:m,rebuild:()=>{if(i===`days`||i===`input`||o!==null)return;let e=s(),t=e!==null&&a.some(t=>t.contains(e))?e:null,n=t===null?null:ar(t),r=t===null?-1:g(t),u=a.map(e=>e.scrollTop);c(i),l(i),a.forEach(e=>{e.setAttribute(qi,``)}),requestAnimationFrame(()=>{a.forEach((e,t)=>{e.scrollTop=u.at(t)??e.scrollTop})}),t!==null&&v(n,r)?.focus({preventScroll:!0})},entry:()=>{for(let e of a){let t=e.querySelector(`[tabindex="0"]`);if(t!==null)return t}return null},destroy:d}},Yi=e=>{let{root:t,core:n,actions:r,rules:i,mode:a,layout:o}=e,s=n.options,c=Pr(n,o,a),l=Ni({core:n,layout:o,surface:a,rtl:e.rtl,gridContext:()=>Dr(n,i,o),onCommit:(e,t)=>{r.page(e,t)}}),u=d(`div`,`dp-ui__content`);u.append(l.element);let f=Ji({root:t,content:u,days:l.element,motion:e.motion,createParts:e=>e===`input`?li({core:n,actions:r,rules:i}):Gi(e,{core:n,actions:r,rules:i,layout:o}),swap:(r,i,a)=>{let o=dr(t);o===null||i!==`input`&&a!==`input`?r():ri(o,()=>{r(),mr(o,i,n.layout.months)},e.motion())},onSwitched:e.onSwitched}),p=nr({labels:s.labels,visible:ne(s.footerExplicit,a),todayButton:s.todayButton,clearButton:s.clearButton!==!1}),m=d(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`});return t.replaceChildren(...c.element===null?[]:[c.element],u,p,m),{header:c,pages:l,panels:f,liveRegion:m}},Xi=[`drag`,`wheel`,`button`,`keyboard`,`menu`],Zi=e=>Xi.includes(e),Qi=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t===`modal`)},$i=e=>{let{core:t,actions:n,rules:r,mode:i}=e,a=t.calendarLayout===`docked`?`docked`:`modal`,o=new AbortController,s=d(`div`,`dp-ui__calendar`),c,l=0,u=()=>s.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(t.input).direction===`rtl`,f=()=>dr(s),p=()=>M(t.options.precision),m=e=>c.pages.cellAt(e),h=(e,n=!0)=>{c.header.docked?.setPanel(e);let r=f();r!==null&&(r.classList.toggle(cr,fr(e,p())),n&&mr(r,e,t.layout.months))},g=e=>{e===null?c.pages.focusCell(!0):e.focus({preventScroll:!0})},_=e=>{let t=Mr(e);return t===null?null:c.header.element?.querySelector(t)??c.pages.find(t)},v=(e,t,n)=>{e===`days`&&c.pages.refit(),n&&g(e===`days`?t===`input`?null:_(t):c.panels.entry())},y=(e=!1)=>{Qi(s,a),c=Yi({root:s,core:t,actions:n,rules:r,mode:i,layout:a,rtl:u(),motion:()=>ee(t.options.animation),onSwitched:v}),c.pages.present(t.view,0),c.panels.mount(t.panel,{rebuilt:e}),e&&c.pages.element.setAttribute(`data-rebuilt`,``),h(t.panel),c.header.modal?.setInputView(t.panel===`input`),tr(s,N(t.draft)),cancelAnimationFrame(l),l=requestAnimationFrame(()=>{l=0,h(c.panels.current()),c.pages.refit()})},b=()=>{c.panels.destroy(),c.pages.destroy(),c.header.modal?.destroy()},x=()=>{o.signal.aborted||(h(c.panels.current()),c.pages.refit())},S=()=>{o.signal.aborted||(x(),g(c.panels.entry()))},C=(e,n,r)=>{c.header.docked?.setView(e),c.header.caption?.setView(e);let i=Zi(r),a=i&&c.panels.current()===`days`&&c.panels.settled();c.pages.present(e,a?n:0),c.panels.rebuild(),i&&Se(c.liveRegion,Or(t,e))},w=()=>{let e=c.pages.cellHasFocus();c.pages.refresh(),e&&c.pages.focusCell(!1)},T=e=>{c.pages.finish(),h(e,!1),c.header.modal?.setInputView(e===`input`),c.header.modal?.setText(Z(t)),c.panels.switchTo(e)},E=()=>{c.pages.refresh(),c.panels.rebuild(),c.header.modal?.setText(Z(t)),tr(s,N(t.draft));let{announceSelection:e}=H(i,t.options.inline);e&&c.panels.current()===p()&&Se(c.liveRegion,Z(t))};return y(),(e=>{let{events:r}=t;r.on(`change:view`,e=>{C(e.view,e.delta,e.source)},e),r.on(`change:draft`,E,e),r.on(`change:focus`,w,e),r.on(`change:panel`,e=>{T(e.panel)},e),sr(s,e,{actions:n,panel:()=>t.panel,home:p(),cellAt:m}),Wr(s,e,{core:t,actions:n,layout:a,home:p(),caption:()=>Nr(t,i),cellAt:m,isRtl:u}),er(s,`.dp-ui__icon-button, .dp-ui__menu-button, .dp-ui__text-button, .dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator, .dp-ui__menu-item, .dp-ui__year-selection-item, .dp-ui__month-selection-item`,e)})(o.signal),{element:s,focusInitial:S,fit:x,update:()=>{if(o.signal.aborted)return;let e=s.contains(s.ownerDocument.activeElement);b(),y(!0),e&&S()},destroy:()=>{if(o.signal.aborted)return;o.abort(),cancelAnimationFrame(l),b();let e=f();e!==null&&(e.classList.remove(cr,lr),pr(e,1)),s.remove()}}},ea=e=>({year:e.year,month:e.month}),ta=e=>{let t=R(e.draft);return t===null?e.view:ea(t)},na=(e,t)=>{let{minDate:n,maxDate:r}=e.options,i=t.yearBounds(),a={year:i.min,month:1},o={year:i.max,month:12},s=n!==null&&A(a,n)>0,c=r!==null&&A(r,o)>0;return{first:s?ea(n):a,last:c?ea(r):o}},ra=(e,t)=>A(t.first,e)<0?t.first:A(e,t.last)<0?t.last:e,ia=e=>{let t=d(`div`,`dp-ui__top-bar`);return t.append(P(`close`,e.close,V.close),ve(`save`,e.save)),t},aa=e=>{let{labels:t,switchView:n}=e,r=d(`div`,`dp-ui__header-text`),i=d(`div`,`dp-ui__supporting-text`);i.textContent=t.rangeTitle;let a=yr(e.text,e.animate);r.append(i,a.element);let o=n===null?null:Te(t,n.panelId);return{nodes:o===null?[r]:[r,o.button],headline:a,switchButton:o}},oa=e=>{if(e.length===0)return null;let t=d(`div`,`dp-ui__header dp-ui__header--range`);return t.append(...e),t},sa=e=>{let t=e.fullscreen?ia(e.labels):null,n=e.headline?aa(e):null,r=oa([...t===null?[]:[t],...n===null?[]:n.nodes]);return{element:r,setText:e=>{n?.headline.setText(e)},setInputView:e=>{t!==null&&(t.hidden=e),r!==null&&n===null&&(r.hidden=e),n?.switchButton?.setInputView(e)},destroy:()=>{n?.headline.destroy()}}},ca=(e,t)=>{let n=d(`div`,`dp-ui__weekdays-bar`,{"aria-hidden":`true`}),r=Oe(e,`narrow`);for(let e=0;e<7;e++){let i=d(`span`,`dp-ui__weekday`);i.textContent=r.at((t+e)%7)??``,n.append(i)}return n},la=(e,t)=>t===`x`?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight,ua=(e,t)=>t===`x`?e.clientX:e.clientY,da=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},fa=(e,t,n)=>{t===`x`?e.scrollLeft+=n:e.scrollTop+=n},pa=(e,t,n=`x`,r={})=>{let i=null,a=0,o=0,c=0,l=!1;n===`x`&&e.addEventListener(`wheel`,t=>{la(e,n)&&(Math.abs(t.deltaY)<=Math.abs(t.deltaX)||(t.preventDefault(),e.scrollLeft+=t.deltaY))},{signal:t,passive:!1}),e.addEventListener(`pointerdown`,t=>{t.pointerType===`mouse`&&t.button===0&&la(e,n)&&(i=t.pointerId,a=ua(t,n),o=a,c=0,l=!1)},{signal:t}),e.addEventListener(`pointermove`,t=>{if(t.pointerId!==i)return;let r=ua(t,n);c=r-a,!l&&Math.abs(c)<s.DRAG_START_PX||(l||(l=!0,da(e,t.pointerId)),fa(e,n,o-r),o=r)},{signal:t}),e.addEventListener(`selectstart`,e=>{i!==null&&e.preventDefault()},{signal:t});let u=t=>{t.pointerId===i&&(i=null,e.hasPointerCapture(t.pointerId)&&e.releasePointerCapture(t.pointerId),l&&t.type===`pointerup`&&c!==0&&r.onDragEnd?.(c<0?1:-1))};e.addEventListener(`pointerup`,u,{signal:t}),e.addEventListener(`pointercancel`,u,{signal:t}),e.addEventListener(`click`,e=>{l&&(l=!1,e.stopPropagation(),e.preventDefault())},{signal:t,capture:!0})},ma=(e,t,n)=>({...Er(e,t,!1),outsideSelectable:!1,weekNumbers:!1,headingVisible:!0,weekdaysVisible:n,rangeRole:t=>ye(e.draft,t),labelRole:t=>Ee(e.draft,t)}),ha=(e,t,n)=>Oi(Ai(n,e.options.weekStart,!1),ma(e,t,!1)),ga=`td.dp-ui__date[data-date]`,_a=e=>{let{core:t,rules:n}=e,r=new AbortController,a=d(`div`,`dp-ui__month-list`),o=[],c=null,l=0,u=!1,f=0,p=(t,n)=>Array.from({length:n},(n,r)=>e.render(L(t,r))),m=()=>{c!==null&&e.onRendered(c,L(c,o.length-1))},h=t=>{if(c===null)return;let n=L(c,o.length),r=A(n,e.bounds().last)+1,i=Math.min(t,r);if(i<=0)return;let s=p(n,i);o.push(...s),a.append(...s),m()},g=t=>{if(c===null)return;let n=A(e.bounds().first,c),r=Math.min(t,n);if(r<=0)return;let i=L(c,-r),s=p(i,r),l=a.scrollTop,u=a.scrollHeight;c=i,o.unshift(...s),a.prepend(...s),a.scrollTop=l+a.scrollHeight-u,m()},_=t=>{if(c===null)return;let n=ra(t,e.bounds());g(A(n,c)),h(A(L(c,o.length-1),n))},v=e=>{if(c===null)return null;let t=A(c,e);return t<0?null:o.at(t)??null},y=t=>{let n=ra(t,e.bounds());_(n);let r=v(n);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;a.scrollTop+=i},x=()=>{a.scrollTop<a.clientHeight&&g(6),a.scrollHeight-a.scrollTop-a.clientHeight<a.clientHeight&&h(6)},S=e=>{let t=a.getBoundingClientRect().top,n=o.map(e=>({table:e,top:e.getBoundingClientRect().top-t,height:e.getBoundingClientRect().height})),r=Math.max(n.reduce((e,t,n)=>t.top<=1?n:e,0),0),i=n.at(r);if(i===void 0)return null;let c=i.height>0?Math.max(-i.top,0)/i.height:0,l=n.at(r+1)?.table??i.table;return e===1?c>s.COMMIT_FRACTION?l:i.table:c<1-s.COMMIT_FRACTION?i.table:l},C=()=>{u&&(window.clearTimeout(f),u=!1,x())},w=e=>{C(),x();let n=S(e);if(n===null)return;let r=n.getBoundingClientRect().top-a.getBoundingClientRect().top;ee(t.options.animation)===`full`?(u=!0,f=window.setTimeout(C,T.SNAP_SCROLL_FALLBACK),a.scrollTo({top:a.scrollTop+r,behavior:`smooth`})):a.scrollTop+=r},E=e=>{if(!(e instanceof Element))return null;let t=e.closest(ga);return t!==null&&a.contains(t)?t:null},te=e=>{_(ea(e));let t=a.querySelector(`${ga}[data-date="${i(e)}"]`);t!==null&&(t.focus({preventScroll:!0}),b(a,t,`nearest`))},D=()=>{let e=ma(t,n,!1);o.forEach(t=>{ki(t,e)})},O=e.bounds(),k=ra(ta(t),O),j=ra(L(k,-2),O),ne=ra(L(k,9),O),re=A(j,ne)+1;re>0&&(c=j,o.push(...p(j,re)),a.append(...o),m()),a.addEventListener(`scroll`,()=>{l===0&&(l=requestAnimationFrame(()=>{l=0,u||x()}))},{passive:!0,signal:r.signal}),a.addEventListener(`scrollend`,C,{signal:r.signal}),pa(a,r.signal,`y`,{onDragEnd:w});let ie=null;if(typeof ResizeObserver<`u`){let t=0;ie=new ResizeObserver(n=>{let i=n.at(-1);if(i===void 0||r.signal.aborted)return;let a=i.contentRect.height,o=t===0;t=a,o&&a>0&&e.onShown()}),ie.observe(a)}return{element:a,scrollToMonth:y,refresh:D,cellAt:E,focusCell:te,ensureMonth:_,reveal:y,present:(e,t,n)=>{Zi(n)?_(e):y(e)},destroy:()=>{r.abort(),ie?.disconnect(),cancelAnimationFrame(l),l=0,window.clearTimeout(f),u=!1}}},va=e=>{let t=d(`div`,`dp-ui__navigation dp-ui__navigation--months`),n=ue(e);return t.append(P(`prev-month`,e.previousMonth,V.keyboardArrowLeft,n.previousMonth),P(`next-month`,e.nextMonth,V.keyboardArrowRight,n.nextMonth)),t},ya=e=>{let{core:t,actions:n,rules:r}=e,a=Ni({core:t,layout:`docked`,rtl:e.rtl,gridContext:()=>ma(t,r,!0),onCommit:(e,t)=>{n.page(e,t)}});return{element:a.element,cellAt:e=>a.cellAt(e)?.element??null,focusCell:e=>{let t=a.find(`td.dp-ui__date[data-date][data-date="${i(e)}"]`);t===null?a.focusCell(!0):t.focus({preventScroll:!0})},refresh:()=>{a.refresh()},reveal:()=>{a.refit()},present:(e,t,n)=>{a.present(e,n===`api`?0:t)},destroy:()=>{a.destroy()}}};function ba(e){let t;try{t=e.value()}catch(e){return U(e),null}let n=K(t,`range`,`day`);if(n?.mode!==`range`)return null;let{start:r,end:i}=n;return r===null||i===null?null:{start:r,end:i}}const xa=e=>{let{core:t,actions:n,rules:r,signal:i,column:a}=e,{presets:o,labels:s,limits:c}=t.options,l=d(`div`,a?`dp-ui__presets dp-ui__presets--column`:`dp-ui__presets`,{role:`group`,"aria-label":s.presets}),u=o.map(e=>{let t=d(`button`,`dp-ui__preset`,{type:`button`});return t.textContent=e.label,t}),f=u.map(()=>null);l.append(...u);let p=()=>{o.forEach((e,n)=>{let i=u[n],a=ba(e);f[n]=a;let o=!1,s=!1;if(a!==null){let e={mode:`range`,...a};o=dn(e,c,e=>r.isDisabled(e)),s=I(t.draft,e)}i.disabled=!o,i.setAttribute(`aria-pressed`,s?`true`:`false`)})};return l.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button.dp-ui__preset`),r=u.findIndex(e=>e===t);if(r<0)return;let i=f[r];i!==null&&n.selectRange(i.start,i.end)},{signal:i}),pa(l,i),p(),{element:l,refresh:p,setHidden:e=>{l.hidden=e}}},Sa=`dp-ui__container--range`,Ca=`dp-ui__container--fullscreen`,wa=`dp-ui__container--presets`,Ta=[Sa,wa,Ca,lr],Ea=(e,t)=>{let{core:n,actions:r,rules:i,rtl:a}=e,{labels:o,locale:s,weekStart:c}=n.options;if(n.layout.months>1){let e=ya({core:n,actions:r,rules:i,rtl:a});return t.append(va(o),e.element),e}let l=_a({core:n,rules:i,render:e=>ha(n,i,e),bounds:()=>na(n,i),onRendered:(e,t)=>{r.renderedMonths(e,t)},onShown:e.reveal});return t.append(ca(s,c),l.element),l},Da=e=>{let{root:t,core:n,actions:r,rules:i,mode:a,fullscreen:o,signal:s}=e,c=n.options,l=sa({labels:c.labels,animate:c.animation,text:Z(n),fullscreen:o,headline:H(a,c.inline).headline,switchView:c.viewSwitch?{panelId:F(n.instanceId,`input`)}:null}),u=d(`div`,`dp-ui__range`,{"data-panel":`days`}),f=Ea(e,u),p=Ji({root:t,content:t,days:u,motion:e.motion,createParts:e=>e===`input`?li({core:n,actions:r,rules:i}):[],swap:e.swap,onSwitched:e.onSwitched}),m=nr({labels:c.labels,visible:ne(n.options.footerExplicit,a),todayButton:c.todayButton,clearButton:c.clearButton!==!1}),h=d(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`}),g=n.layout.presets===`column`,_=n.layout.presets===`none`?null:xa({core:n,actions:r,rules:i,signal:s,column:g});return t.replaceChildren(...l.element===null?[]:[l.element],..._===null?[]:[_.element],u,m,h),{header:l,days:f,panels:p,liveRegion:h,applyChrome:e=>{let r=e===`input`;l.setInputView(r),l.setText(Z(n)),_?.setHidden(r);let i=dr(t);i!==null&&(i.classList.add(Sa),i.classList.toggle(wa,g),i.classList.toggle(Ca,o&&!r),mr(i,e,n.layout.months))},refreshPresets:()=>{_?.refresh()}}},Oa=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t)},ka=e=>e===`input`?`input`:`days`,Aa=e=>{let{core:t,actions:n,rules:r,mode:i,fullscreen:a}=e,o=t.calendarLayout!==`docked`,s=new AbortController,c=d(`div`,`dp-ui__calendar`),l,u=0,p=null,m=()=>ee(t.options.animation),h=()=>c.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(t.input).direction===`rtl`,g=e=>{let t=l.days.cellAt(e),n=f(t?.dataset.date??``);return t===null||n===null?null:{element:t,date:n}},_=()=>{let{draft:e,value:n}=t,r=z(e)&&z(n);tr(c,N(e)&&!r)},v=()=>{l.days.reveal(ta(t))},y=(e,n,r)=>{e===`days`&&v(),r&&(e===`input`?l.panels.entry()?.focus({preventScroll:!0}):l.days.focusCell(t.focus))},b=(e,t)=>{let n=()=>{l.applyChrome(t),e()};p?.cancel(),p=null;let r=dr(c);r===null?n():p=ri(r,n,m())},x=()=>{Oa(c,o),l=Da({root:c,core:t,actions:n,rules:r,mode:i,fullscreen:a,rtl:h(),signal:s.signal,motion:m,reveal:v,swap:b,onSwitched:y}),l.days.present(t.view,0,`api`),l.panels.mount(ka(t.panel)),l.applyChrome(l.panels.current()),_(),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=0,l.applyChrome(l.panels.current()),l.panels.current()===`days`&&v()})},S=()=>{p?.cancel(),p=null,l.panels.destroy(),l.days.destroy(),l.header.destroy()},C=()=>{if(s.signal.aborted)return;let e=l.panels.current();l.applyChrome(e),e===`days`&&v()},w=()=>{s.signal.aborted||(cancelAnimationFrame(u),u=0,C(),l.panels.current()===`input`?l.panels.entry()?.focus({preventScroll:!0}):l.days.focusCell(t.focus))},T=()=>{l.days.refresh(),l.refreshPresets(),l.header.setText(Z(t)),_();let{announceSelection:e}=H(i,t.options.inline);e&&l.panels.current()===`days`&&Se(l.liveRegion,Z(t))},E=()=>{let e=g(c.ownerDocument.activeElement)!==null;l.days.refresh(),e&&l.days.focusCell(t.focus)},te=(e,n,r)=>{let i=l.panels.current()===`days`&&l.panels.settled();l.days.present(e,i?n:0,r),Zi(r)&&t.layout.months>1&&Se(l.liveRegion,Or(t,e))};return x(),(e=>{let{events:r}=t;r.on(`change:view`,e=>{te(e.view,e.delta,e.source)},e),r.on(`change:draft`,T,e),r.on(`change:active-end`,()=>{l.days.refresh()},e),r.on(`change:value`,_,e),r.on(`change:focus`,E,e),r.on(`change:panel`,e=>{l.panels.switchTo(ka(e.panel))},e),sr(c,e,{actions:n,panel:()=>t.panel,home:`days`,cellAt:g}),Wr(c,e,{core:t,actions:n,layout:`range`,home:`days`,caption:()=>!1,cellAt:g,isRtl:h}),er(c,`.dp-ui__icon-button, .dp-ui__text-button, .dp-ui__preset, .dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`,e)})(s.signal),{element:c,focusInitial:w,fit:C,update:()=>{if(s.signal.aborted)return;let e=c.contains(c.ownerDocument.activeElement);S(),x(),e&&w()},destroy:()=>{if(s.signal.aborted)return;s.abort(),cancelAnimationFrame(u),S();let e=dr(c);e!==null&&(e.classList.remove(...Ta),pr(e,1)),c.remove()}}};var ja=class{core;deps;mounted=null;generation=0;constructor(e,t,n){this.core=e,this.deps=n}get surface(){return this.mounted?.host.root??null}async mount(e){this.release();let n=this.createHost(e);if(n===null)return;let{core:r}=this,{options:i}=r,{actions:a,rules:o,theme:s}=this.deps,c=++this.generation;s.applyTo(n.root),Un(n.root,i.animation);let l={core:r,actions:a,rules:o,mode:e,fullscreen:r.calendarLayout===`fullscreen`},u=i.mode===`range`?Aa(l):$i(l);this.mounted={mode:e,host:n,view:u,stopModality:te(n.root),stopSchemeWatch:e===`inline`?t(()=>{s.applyTo(n.root)}):()=>void 0},n.body.append(u.element);let d=n.open();u.fit(),this.overflows(e,n)?(this.release(),this.deps.overflow()):(await d,c===this.generation&&e!==`inline`&&u.focusInitial())}async unmount(){let e=this.mounted;if(e===null)return;let t=++this.generation;await e.host.close(),t===this.generation&&this.mounted===e&&this.release()}update(){let e=this.mounted;e!==null&&(this.deps.theme.applyTo(e.host.root),e.host.setLabel(this.label()),Un(e.host.root,this.core.options.animation),e.view.update())}label(){let{labels:e,mode:t,precision:n}=this.core.options;return Wn(e,t,n)}destroy(){this.generation+=1,this.release()}overflows(e,t){return e===`docked`&&this.core.options.displayMode===`auto`&&!Ue(t.root,this.core.input)}release(){let e=this.mounted;e!==null&&(this.mounted=null,e.view.destroy(),e.host.destroy(),e.stopModality(),e.stopSchemeWatch())}createHost(e){let{core:t}=this,{options:n}=t,{actions:r}=this.deps,i=this.label();if(e===`inline`){let e=g(n.inline.container);return e===null?null:new Ne({container:e,label:i})}return e===`modal`?new be({parent:g(n.appendTo)??t.host,label:i,allowPageScroll:n.allowPageScroll,onCancel:e=>{r.cancel(e)}}):new De({host:t.host,anchor:t.input,instanceId:t.instanceId,rtl:getComputedStyle(t.input).direction===`rtl`,label:i,ignoreOutsideClick:n.behavior.ignoreOutsideClick,inside:[...t.endInput===null?[]:[t.endInput],...this.deps.inside()],onOutside:()=>{r.cancel(`outside`)},onEscape:()=>{r.cancel(`escape`)}})}},Ma=class{core;fields=[];initial;constructor(e){this.core=e,this.initial=e.value}bind(e){let{input:t}=this.core;this.initial=this.core.value;let n=this.splitEnd();this.bindField(t,n===null?null:`start`),n!==null&&this.bindField(n,`end`),this.fields.length!==0&&t.form?.addEventListener(`reset`,()=>{setTimeout(()=>{this.handleReset()},0)},{signal:e})}sync(){for(let e of this.fields)e.hidden.value=this.valueOf(e.end)}dispatchCommit(){let{input:e}=this.core;e.dispatchEvent(new Event(`input`,{bubbles:!0})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}restore(){for(let e of this.fields)e.hidden.remove(),e.input.setAttribute(`name`,e.name);this.fields=[]}splitEnd(){return this.core.options.mode===`range`?this.core.endInput:null}bindField(e,t){let n=e.getAttribute(`name`);n!==null&&n!==``&&(e.removeAttribute(`name`),this.fields.push({input:e,name:n,hidden:this.createHidden(e,n),end:t}))}valueOf(e){let{value:t,options:n}=this.core;if(e===null||t.mode!==`range`)return Be(t,n.precision);let r=e===`start`?t.start:t.end;return r===null?``:m(r,`day`)}createHidden(e,t){let n=e.ownerDocument.createElement(`input`);return n.type=`hidden`,n.name=t,n.classList.add(`dp-ui__form-value`),e.insertAdjacentElement(`afterend`,n),n}writeFields(e){let{core:t}=this,{pattern:n,precision:r}=t.options,i=this.splitEnd();if(i===null||e.mode!==`range`){t.input.value=He(e,n,r);return}let a=e=>e===null?``:k(e,n,`day`);t.input.value=a(e.start),i.value=a(e.end)}handleReset(){let{core:e}=this,{mode:t}=e.options,n=this.initial.mode===t?this.initial:B(t);e.setValue(n),this.writeFields(n),this.sync()}};const Na=`aria-describedby`,Pa=e=>(e.getAttribute(Na)??``).split(/\s+/).filter(e=>e!==``);function Fa(e,t,n,r){let i=d(`span`,`dp-ui__visually-hidden`,{id:n}),a=d(`span`,void 0,{"aria-live":`polite`}),o=d(`span`);return o.textContent=r,i.append(a,` `,o),t.append(i),e.setAttribute(Na,[...Pa(e),n].join(` `)),{setHint:e=>{o.textContent!==e&&(o.textContent=e)},setError:e=>{let t=e??``;a.textContent!==t&&(a.textContent=t)},destroy:()=>{i.remove();let t=Pa(e).filter(e=>e!==n);t.length===0?e.removeAttribute(Na):e.setAttribute(Na,t.join(` `))}}}const Ia=`dp-ui--error`;function La(e,t,n){e.setAttribute(`aria-invalid`,`true`),t.classList.add(Ia),e.setCustomValidity(n)}function Ra(e,t){e.removeAttribute(`aria-invalid`),t.classList.remove(Ia),e.setCustomValidity(``)}function za(e,t,r){let i=e.trim(),a=t.trim();if(i===``&&a===``)return{kind:`empty`};let o=i===``?null:oe(i,r);if(i!==``&&o===null)return{kind:`invalid`,field:`start`};let s=a===``?null:oe(a,r);return a!==``&&s===null?{kind:`invalid`,field:`end`}:o===null||s===null?{kind:`partial`}:n(o,s)>0?{kind:`reversed`}:{kind:`range`,start:o,end:s}}var Ba=class{core;emitter;deps;dirty=!1;constructor(e,t,n){this.core=e,this.emitter=t,this.deps=n}get end(){return this.core.options.mode===`range`?this.core.endInput:null}bind(e){let{end:t}=this;if(t!==null)for(let n of[this.core.input,t])n.addEventListener(`blur`,()=>{this.commit()},{signal:e}),n.addEventListener(`input`,()=>{this.dirty=!0,this.applyMask(n)},{signal:e}),n.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.commit())},{signal:e})}write(e){let{end:t}=this;if(t===null)return;let n=e.mode===`range`?e:null;this.core.input.value=this.format(n?.start??null),t.value=this.format(n?.end??null),this.dirty=!1,this.clearError()}readInitial(){let{end:e}=this,t=B(`range`);if(e===null)return t;let r=this.readDate(this.core.input.value),i=this.readDate(e.value);return r===null||i===null||n(r,i)>0?t:{mode:`range`,start:r,end:i}}markInvalid(e){let{end:t}=this;if(t===null)return;let{input:n,host:r}=this.core;La(n,r,e),La(t,r,e),this.deps.describe(n,e),this.deps.describe(t,e),this.emitter.emit(`error`,{code:`invalid-value`,message:e})}clearError(){let{end:e}=this;if(e===null)return;let{input:t,host:n}=this.core;Ra(t,n),Ra(e,n),this.deps.describe(t,null),this.deps.describe(e,null)}format(e){return e===null?``:k(e,this.core.options.pattern,`day`)}readDate(e){let{pattern:t}=this.core.options,n=a(e,`single`,`day`)??j(e,`single`,t,`day`);return n?.mode===`single`?n.date:null}applyMask(e){let{options:t}=this.core;t.mask&&he(e,t.pattern)}commit(){let{end:e}=this;if(e===null||!this.dirty)return;let{options:t,input:n}=this.core,r=za(n.value,e.value,t.pattern);r.kind!==`partial`&&(r.kind===`empty`?this.settle(B(`range`)):r.kind===`invalid`?this.fail(r.field,`invalid-date`,t.labels.invalidDate):r.kind===`reversed`?this.fail(`end`,`invalid-date`,t.labels.invalidRange):this.commitRange(r.start,r.end))}commitRange(e,t){let{options:n}=this.core,r={mode:`range`,start:e,end:t},i=e=>this.deps.rules.unavailableReason(e),a=un(r,n.limits,i);if(a===null){this.settle(r);return}let o=i(e)===null?`end`:`start`;this.fail(o,`unavailable-date`,ci(a,n),a)}settle(e){this.write(e),this.deps.onTyped(e)}fail(e,t,n,r){let i=e===`start`?this.core.input:this.end;if(i===null)return;this.clearError(),La(i,this.core.host,n),this.deps.describe(i,n);let a=i.value;r===void 0?this.emitter.emit(`error`,{code:t,message:n,input:a}):this.emitter.emit(`error`,{code:t,message:n,input:a,reason:r})}},Va=class{core;emitter;deps;split;descriptions=/* @__PURE__ */ new Map;constructor(e,t,n){this.core=e,this.emitter=t,this.deps=n,this.split=new Ba(e,t,{rules:n.rules,onTyped:e=>{n.onTyped(e)},describe:(e,t)=>{this.describe(e,t)}})}bind(e){if(this.describeFields(e),this.split.end!==null){this.split.bind(e);return}let{input:t}=this.core;t.addEventListener(`blur`,()=>{this.commit()},{signal:e}),t.addEventListener(`input`,()=>{this.applyMask()},{signal:e}),t.addEventListener(`keydown`,e=>{e.key===`Enter`&&(e.preventDefault(),this.commit())},{signal:e})}write(e){this.split.end===null?(this.core.input.value=He(e,this.core.options.pattern,this.core.options.precision),this.clearError()):this.split.write(e)}readInitial(){if(this.split.end!==null)return this.split.readInitial();let{mode:e,pattern:t,precision:n}=this.core.options,r=this.core.input.value;return a(r,e,n)??j(r,e,t,n)??B(e)}evaluate(e){let{mode:t,pattern:n,limits:r,precision:i}=this.core.options,a=j(e,t,n,i);if(a===null)return{kind:`invalid`};if(z(a))return{kind:`empty`};let o=un(a,r,e=>this.deps.rules.unavailableReason(e));return o===null?{kind:`valid`,selection:a}:{kind:`unavailable`,selection:a,reason:o}}markInvalid(e){this.split.end===null?(this.showError(e),this.emitter.emit(`error`,{code:`invalid-value`,message:e})):this.split.markInvalid(e)}destroy(){this.clearError(),this.split.clearError(),this.descriptions.forEach(e=>{e.destroy()}),this.descriptions.clear()}describeFields(e){let{input:t,host:n,instanceId:r}=this.core,{end:i}=this.split,a=()=>{let{pattern:e,precision:t,labels:n}=this.core.options;return ie(e,t,Ae(n))},o=[[t,`input-description`]];i!==null&&o.push([i,`end-input-description`]);for(let[e,t]of o){let i=F(r,t);this.descriptions.set(e,Fa(e,n,i,a()))}this.core.events.on(`change:options`,()=>{let e=a();this.descriptions.forEach(t=>{t.setHint(e)})},e)}describe(e,t){this.descriptions.get(e)?.setError(t)}applyMask(){let{input:e,options:t}=this.core;t.mask&&t.mode===`single`&&t.precision===`day`&&he(e,t.pattern)}commit(){let e=this.core.input.value,t=this.evaluate(e);if(t.kind===`empty`)this.clearError(),this.deps.onTyped(B(this.core.options.mode));else if(t.kind===`valid`)this.write(t.selection),this.deps.onTyped(t.selection);else if(t.kind===`invalid`){let t=this.core.options.labels.invalidDate;this.showError(t),this.emitter.emit(`error`,{code:`invalid-date`,message:t,input:e})}else{let{reason:n}=t,r=ci(n,this.core.options);this.showError(r),this.emitter.emit(`error`,{code:`unavailable-date`,message:r,input:e,reason:n})}}showError(e){La(this.core.input,this.core.host,e),this.describe(this.core.input,e)}clearError(){Ra(this.core.input,this.core.host),this.describe(this.core.input,null)}},Ha=class{core;constructor(e){this.core=e}applyHost(){this.core.host.setAttribute(`data-theme`,this.core.options.theme)}applyTo(e){let{options:t,input:n,host:r}=this.core;Le(e,{theme:t.theme,colorScheme:t.colorScheme===`auto`?we(r):t.colorScheme,className:t.cssClass,rtl:getComputedStyle(n).direction===`rtl`})}destroy(){this.core.host.removeAttribute(`data-theme`)}};const Ua=(e,t,n,r)=>{let i=de(e);return i.length===0?``:e.mode===`multiple`?Yn(n,i.length,t):i.map(e=>ce(e,r,t,`long`)).join(pe)},Wa=`dp-ui__input--active`;var Ga=class{core;deps;toggle=null;expanded=!1;release=null;constructor(e,t,n){this.core=e,this.deps=n}get toggleElement(){return this.toggle}bind(e){if(this.releaseToggle(),this.core.options.inline.enabled||e.aborted)return;let{input:t}=this.core;this.bindField(t,`start`,e);let n=this.splitEnd();n!==null&&(this.bindField(n,`end`,e),this.core.events.on(`change:active-end`,()=>{this.markActive()},e)),this.bindToggle(e)}setExpanded(e){this.expanded=e,this.toggle?.setAttribute(`aria-expanded`,String(e)),this.markActive()}updateLabel(){if(this.toggle===null)return;let{labels:e,locale:t,precision:n}=this.core.options,r=Ua(this.core.value,t,e.multipleSelected,n),i=r===``?e.openCalendar:`${e.openCalendar}, ${r}`;this.toggle.setAttribute(`aria-label`,i)}destroy(){this.releaseToggle(),this.core.input.classList.remove(Wa),this.core.endInput?.classList.remove(Wa)}splitEnd(){return this.core.options.mode===`range`?this.core.endInput:null}bindField(e,t,n){let r=!1;e.addEventListener(`pointerdown`,()=>{r=!0},{signal:n}),e.addEventListener(`click`,()=>{let n=r;r=!1,(!this.expanded||n)&&this.request(`pointer`,t,e)},{signal:n}),e.addEventListener(`keydown`,n=>{n.altKey&&n.key===`ArrowDown`&&(n.preventDefault(),this.request(`keyboard`,t,e))},{signal:n})}markActive(){let e=this.splitEnd(),{input:t}=this.core;if(e===null){t.classList.remove(Wa);return}let n=this.expanded?this.core.activeEnd:null;t.classList.toggle(Wa,n===`start`),e.classList.toggle(Wa,n===`end`)}request(e,t,n=this.core.input){n.disabled||this.deps.open(e,t)}activateToggle(){this.expanded?this.deps.dismiss():this.request(`toggle`,`start`)}bindToggle(e){let t=g(this.core.options.toggleButton,this.core.host);if(t===null)return;let n=/* @__PURE__ */ new Map,r=(e,r)=>{n.has(e)||n.set(e,t.getAttribute(e)),t.setAttribute(e,r)};r(`aria-haspopup`,`dialog`),t.tagName!==`BUTTON`&&(r(`role`,`button`),r(`tabindex`,`0`),t.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.activateToggle())},{signal:e})),t.addEventListener(`click`,()=>{this.activateToggle()},{signal:e}),this.toggle=t,r(`aria-expanded`,String(this.expanded)),r(`aria-label`,this.core.options.labels.openCalendar),this.updateLabel();let i=()=>{e.removeEventListener(`abort`,i),n.forEach((e,n)=>{e===null?t.removeAttribute(n):t.setAttribute(n,e)}),this.toggle===t&&(this.toggle=null),this.release===i&&(this.release=null)};this.release=i,e.addEventListener(`abort`,i,{once:!0})}releaseToggle(){this.release?.()}};function Q(e){return e.year*12+e.month-1}var Ka=class{core;emitter;lists=null;constructor(e,t){this.core=e,this.emitter=t}isDisabled(e){return this.unavailableReason(e)!==null}unavailableReason(e){switch(this.core.options.precision){case`day`:return this.dayReason(e);case`month`:return this.monthReason(e);case`year`:return this.yearReason(e.year)}}isSelectable(e,t){return!this.isDisabled(e)&&!this.guardFor(t)(e)}isMonthDisabled(e){let t=D(e),r=Ce(e.year,e.month,1),i=Ce(e.year,e.month,t);if(r===null||i===null)return!0;let{minDate:a,maxDate:o}=this.core.options,s=this.yearBounds();if(e.year<s.min||e.year>s.max||a!==null&&n(i,a)<0||o!==null&&n(r,o)>0)return!0;for(let n=1;n<=t;n+=1)if(this.dayReason({year:e.year,month:e.month,day:n})===null)return!1;return!0}yearBounds(){let{minDate:e,maxDate:t,yearRange:n}=this.core.options,r=h(),i=r.year-n.before,a=r.year+n.after;return{min:e===null?i:Math.max(i,e.year),max:t===null?a:Math.min(a,t.year)}}clampView(e){let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds(),i=r.min*12,a=r.max*12+11;t!==null&&(i=Math.max(i,Q(t))),n!==null&&(a=Math.min(a,Q(n)));let o=this.core.layout.months-1;o>0&&(a=Math.max(i,a-o));let s=Math.min(Math.max(Q(e),i),a),c=Math.floor(s/12);return{year:c,month:s-c*12+1}}destroy(){this.lists=null}monthReason(e){if(!this.isMonthDisabled(e))return null;let{minDate:t,maxDate:n}=this.core.options,r=this.yearBounds(),i=Q(e),a=r.min*12,o=r.max*12+11;return t!==null&&(a=Math.max(a,Q(t))),n!==null&&(o=Math.min(o,Q(n))),i<a?`min`:i>o?`max`:`disabled`}yearReason(e){let t=this.yearBounds();return e<t.min?`min`:e>t.max?`max`:null}dayReason(e){let{minDate:t,maxDate:r}=this.core.options,a=this.yearBounds();if(t!==null&&n(e,t)<0||e.year<a.min)return`min`;if(r!==null&&n(e,r)>0||e.year>a.max)return`max`;let o=this.getLists(),s=i(e);return o.disabled.has(s)||o.enabled!==null&&!o.enabled.has(s)?`disabled`:o.source.disabledWeekdays.includes(S(e))?`weekday`:this.isCallbackDisabled(e,o)?`disabled`:null}isCallbackDisabled(e,t){let{isDateDisabled:n}=t.source;if(n===null)return!1;let r=i(e),a=t.callbackResults.get(r);if(a!==void 0)return a;let o=!1;try{o=n(Ke(e))}catch(e){U(e)}return t.callbackResults.set(r,o),o}guardFor(e){let t=this.getLists(),r=t.guardDraft;if(t.guard!==null&&r!==null&&I(r,e))return t.guard;let{maxDate:i,limits:a}=t.source,o={year:this.yearBounds().max,month:12,day:31};i!==null&&n(i,o)<0&&(o=i);let s=sn(e,a,e=>this.isDisabled(e),o);return t.guardDraft=e,t.guard=s,s}getLists(){let e=this.core.options;if(this.lists?.source===e)return this.lists;let t={source:e,disabled:new Set(e.disabledDates.map(i)),enabled:e.enabledDates===null?null:new Set(e.enabledDates.map(i)),callbackResults:/* @__PURE__ */ new Map,guardDraft:null,guard:null};return this.lists=t,t}},qa=class{target=null;select=e=>{this.target?.select(e)};selectRange=(e,t)=>{this.target?.selectRange(e,t)};typeDraft=e=>{this.target?.typeDraft(e)};submitDraft=()=>{this.target?.submitDraft()};focusDate=e=>{this.target?.focusDate(e)};navigate=(e,t)=>{this.target?.navigate(e,t)};page=(e,t)=>{this.target?.page(e,t)};jumpTo=(e,t)=>{this.target?.jumpTo(e,t)};showPanel=e=>{this.target?.showPanel(e)};confirm=()=>{this.target?.confirm()};cancel=e=>{this.target?.cancel(e)};today=()=>{this.target?.today()};clear=()=>{this.target?.clear()};renderedMonths=(e,t)=>{this.target?.renderedMonths(e,t)};open=(e,t)=>{this.target?.open(e,t)};typed=e=>{this.target?.applyTyped(e)};overflow=()=>{this.target?.fallBackToModal()};connect(e){this.target=e}},Ja=class{validation;theme;display;input;triggers;form;relay=new qa;constructor(e,t){this.validation=new Ka(e,t),this.theme=new Ha(e),this.display=new ja(e,t,{actions:this.relay,rules:this.validation,theme:this.theme,inside:()=>{let e=this.triggers.toggleElement;return e===null?[]:[e]},overflow:this.relay.overflow}),this.input=new Va(e,t,{rules:this.validation,onTyped:this.relay.typed}),this.triggers=new Ga(e,t,{open:this.relay.open,dismiss:()=>{this.relay.cancel(`toggle`)}}),this.form=new Ma(e)}connect(e){this.relay.connect(e)}destroy(){this.relay.connect(null),this.display.destroy(),this.triggers.destroy(),this.input.destroy(),this.form.restore(),this.theme.destroy(),this.validation.destroy()}};const $=/* @__PURE__ */ new Map,Ya=()=>void 0;var Xa=class{core;emitter;lifecycle;constructor(e,t){let n=Zt(e);this.emitter=new qe,this.core=new Gt(n.input,n.host,n.createdHost,t),this.lifecycle=new Vn(this.core,this.emitter,new Ja(this.core,this.emitter)),$.set(this.core.instanceId,this)}create(){this.lifecycle.create()}open(){this.lifecycle.open(`api`)}close(){this.lifecycle.close()}destroy(e){this.lifecycle.destroy(e?.keepInputValue??!1),$.get(this.core.instanceId)===this&&$.delete(this.core.instanceId)}getValue(){return this.lifecycle.getValue()}setValue(e){this.lifecycle.setValue(e)}setActiveEnd(e){this.lifecycle.setActiveEnd(e)}setView(e){this.lifecycle.setView(e)}getView(){return this.lifecycle.getView()}getVisibleRange(){return this.lifecycle.getVisibleRange()}goTo(e){this.lifecycle.goTo(e)}isSelectable(e){return this.lifecycle.isSelectable(e)}clear(){this.lifecycle.clearValue()}setOptions(e){this.lifecycle.setOptions(e)}getElement(){return this.core.host}on(e,t){return this.lifecycle.destroyed?Ya:this.emitter.on(e,t)}once(e,t){return this.lifecycle.destroyed?Ya:this.emitter.once(e,t)}off(e,t){this.emitter.off(e,t)}get instanceId(){return this.core.instanceId}get options(){return this.core.rawOptions}get isInitialized(){return this.lifecycle.created}get isDestroyed(){return this.lifecycle.destroyed}static getById(e){return $.get(Ut(e))}static getAllInstances(){return[...$.values()]}static destroyAll(){for(let e of[...$.values()])e.destroy()}},Za=Xa;export{G as DEFAULT_DATEPICKER_OPTIONS,Xa as DatepickerUI,qe as EventEmitter,Za as default};
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { $ as PlainDate, B as formatHint, G as formatFullDate, H as DatePart, I as FormatOption, J as weekdayNames, K as formatMonthYear, L as FormatPattern, R as HintLetters, U as FullDateOptions, V as resolvePattern, W as WeekStartOption, Y as CalendarMode, et as Weekday, q as resolveWeekStart, tt as YearMonth, u as ThemeName, z as formatDate } from "./shared.js";
|
|
2
|
+
type SurfaceMode = "docked" | "modal" | "inline";
|
|
3
|
+
interface SurfaceHost {
|
|
4
|
+
readonly root: HTMLElement;
|
|
5
|
+
readonly body: HTMLElement;
|
|
6
|
+
open(): Promise<void>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
/** Renames the surface by the constructor's rule: a non-empty `labelledBy` sets `aria-labelledby` and removes `aria-label`; otherwise `label` becomes the `aria-label` and `aria-labelledby` is removed. */
|
|
10
|
+
setLabel(label: string, labelledBy?: string): void;
|
|
11
|
+
}
|
|
12
|
+
export declare function waitForExit(element: HTMLElement): Promise<void>;
|
|
13
|
+
export declare class DialogHost implements SurfaceHost {
|
|
14
|
+
readonly root: HTMLElement;
|
|
15
|
+
readonly body: HTMLElement;
|
|
16
|
+
private readonly dialog;
|
|
17
|
+
private readonly controller;
|
|
18
|
+
private readonly allowPageScroll;
|
|
19
|
+
private releaseScroll;
|
|
20
|
+
private openPromise;
|
|
21
|
+
private closePromise;
|
|
22
|
+
private pointerStartedOnBackdrop;
|
|
23
|
+
private destroyed;
|
|
24
|
+
constructor(options: {
|
|
25
|
+
parent: HTMLElement;
|
|
26
|
+
label: string;
|
|
27
|
+
/** Id, or space-separated ids, of a visible title that names the surface. When set, the root gets `aria-labelledby` and no `aria-label`. */
|
|
28
|
+
labelledBy?: string;
|
|
29
|
+
allowPageScroll: boolean;
|
|
30
|
+
onCancel(reason: "escape" | "outside"): void;
|
|
31
|
+
});
|
|
32
|
+
open(): Promise<void>;
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
destroy(): void;
|
|
35
|
+
setLabel(label: string, labelledBy?: string): void;
|
|
36
|
+
private unlock;
|
|
37
|
+
}
|
|
38
|
+
export declare class InlineHost implements SurfaceHost {
|
|
39
|
+
readonly root: HTMLElement;
|
|
40
|
+
readonly body: HTMLElement;
|
|
41
|
+
constructor(options: {
|
|
42
|
+
container: HTMLElement;
|
|
43
|
+
label: string;
|
|
44
|
+
/** Id, or space-separated ids, of a visible title that names the surface. When set, the root gets `aria-labelledby` and no `aria-label`. */
|
|
45
|
+
labelledBy?: string;
|
|
46
|
+
});
|
|
47
|
+
open(): Promise<void>;
|
|
48
|
+
close(): Promise<void>;
|
|
49
|
+
destroy(): void;
|
|
50
|
+
setLabel(label: string, labelledBy?: string): void;
|
|
51
|
+
}
|
|
52
|
+
export declare class PopoverHost implements SurfaceHost {
|
|
53
|
+
readonly root: HTMLElement;
|
|
54
|
+
readonly body: HTMLElement;
|
|
55
|
+
private readonly anchor;
|
|
56
|
+
private readonly anchorName;
|
|
57
|
+
private readonly fallback;
|
|
58
|
+
private readonly controller;
|
|
59
|
+
private stopTracking;
|
|
60
|
+
private restoreAnchor;
|
|
61
|
+
private hasPopover;
|
|
62
|
+
private anchored;
|
|
63
|
+
private openPromise;
|
|
64
|
+
private closePromise;
|
|
65
|
+
private destroyed;
|
|
66
|
+
constructor(options: {
|
|
67
|
+
host: HTMLElement;
|
|
68
|
+
anchor: HTMLElement;
|
|
69
|
+
instanceId: string;
|
|
70
|
+
rtl: boolean;
|
|
71
|
+
label: string;
|
|
72
|
+
/** Id, or space-separated ids, of a visible title that names the surface. When set, the root gets `aria-labelledby` and no `aria-label`. */
|
|
73
|
+
labelledBy?: string;
|
|
74
|
+
inside: readonly HTMLElement[];
|
|
75
|
+
ignoreOutsideClick: boolean;
|
|
76
|
+
onOutside(): void;
|
|
77
|
+
onEscape(): void;
|
|
78
|
+
});
|
|
79
|
+
open(): Promise<void>;
|
|
80
|
+
close(): Promise<void>;
|
|
81
|
+
destroy(): void;
|
|
82
|
+
setLabel(label: string, labelledBy?: string): void;
|
|
83
|
+
private endTracking;
|
|
84
|
+
private show;
|
|
85
|
+
private hide;
|
|
86
|
+
private enableFallback;
|
|
87
|
+
private update;
|
|
88
|
+
}
|
|
89
|
+
export declare const createTextButton: (modifier: string, label: string) => HTMLButtonElement;
|
|
90
|
+
interface PagerOptions<K> {
|
|
91
|
+
/** Right-to-left: dragging left goes back. */
|
|
92
|
+
readonly rtl: boolean;
|
|
93
|
+
/** Drag and wheel paging. */
|
|
94
|
+
readonly swipe: boolean;
|
|
95
|
+
/** Slide animation. Reduced motion turns it into a fade. */
|
|
96
|
+
readonly animate: boolean;
|
|
97
|
+
/** Sets the pager height to the shown page through `pageHeight`. Default `false`. */
|
|
98
|
+
readonly fitHeight?: boolean;
|
|
99
|
+
/** Builds the page for `key`. */
|
|
100
|
+
renderPage(key: K): HTMLElement;
|
|
101
|
+
/** Height of the page for `key`, used with `fitHeight`. */
|
|
102
|
+
pageHeight?(key: K): number;
|
|
103
|
+
/** The key one page before (`-1`) or after (`1`) `key`. */
|
|
104
|
+
step(key: K, direction: -1 | 1): K;
|
|
105
|
+
/** Whether two keys name the same page. */
|
|
106
|
+
isSame(a: K, b: K): boolean;
|
|
107
|
+
/** A drag or wheel gesture finished on a neighbour page. Call `slide()` to show it. */
|
|
108
|
+
onCommit(direction: -1 | 1, source: "drag" | "wheel"): void;
|
|
109
|
+
}
|
|
110
|
+
export declare class Pager<K> {
|
|
111
|
+
private readonly viewport;
|
|
112
|
+
private readonly options;
|
|
113
|
+
private readonly track;
|
|
114
|
+
private readonly controller;
|
|
115
|
+
private readonly previousTouchAction;
|
|
116
|
+
private readonly strip;
|
|
117
|
+
private readonly animator;
|
|
118
|
+
private drag;
|
|
119
|
+
private wheel;
|
|
120
|
+
private resizeObserver;
|
|
121
|
+
private observedWidth;
|
|
122
|
+
private offset;
|
|
123
|
+
private revision;
|
|
124
|
+
constructor(viewport: HTMLElement, options: PagerOptions<K>);
|
|
125
|
+
/** Shows `key` without animation. */
|
|
126
|
+
show(key: K): void;
|
|
127
|
+
/** Slides to `key` in `direction`. */
|
|
128
|
+
slide(key: K, direction: -1 | 1): void;
|
|
129
|
+
/** Ends a running slide at once. */
|
|
130
|
+
finish(): void;
|
|
131
|
+
destroy(): void;
|
|
132
|
+
private get destroyed();
|
|
133
|
+
private enableSwipe;
|
|
134
|
+
private observeWidth;
|
|
135
|
+
private cancelGestures;
|
|
136
|
+
private release;
|
|
137
|
+
private settle;
|
|
138
|
+
private fitHeight;
|
|
139
|
+
private rest;
|
|
140
|
+
private setOffset;
|
|
141
|
+
private transformFor;
|
|
142
|
+
private pageWidth;
|
|
143
|
+
}
|
|
144
|
+
export declare const resolveSurfaceMode: (option: "auto" | "docked" | "modal", inlineEnabled: boolean, viewportWidth: number, viewportHeight: number) => SurfaceMode;
|
|
145
|
+
export declare const isFullscreenRange: (mode: CalendarMode, surface: SurfaceMode, viewportWidth: number, fullscreenBelow: number) => boolean;
|
|
146
|
+
/**
|
|
147
|
+
* Whether a docked surface fits the window entirely below its anchor or
|
|
148
|
+
* entirely above it, keeping an 8 px margin to the window edge. These are
|
|
149
|
+
* the two sides the popover tries, below first. The anchor is measured where
|
|
150
|
+
* it is now, so call it while the surface is shown.
|
|
151
|
+
*/
|
|
152
|
+
export declare function fitsViewport(root: HTMLElement, anchor: HTMLElement): boolean;
|
|
153
|
+
type Scheme = "light" | "dark";
|
|
154
|
+
export declare function detectColorScheme(from: HTMLElement): Scheme;
|
|
155
|
+
export declare function watchColorScheme(onChange: () => void): () => void;
|
|
156
|
+
/** Theme settings for a surface root. */
|
|
157
|
+
interface SurfaceTheme {
|
|
158
|
+
/** Theme name, written to `data-theme`. */
|
|
159
|
+
readonly theme: ThemeName;
|
|
160
|
+
/** Resolved scheme, written to `data-color-scheme`. For `"auto"` use `detectColorScheme()`. */
|
|
161
|
+
readonly colorScheme: Scheme;
|
|
162
|
+
/** Extra classes, like `ui.cssClass`. Classes from the previous call are removed. */
|
|
163
|
+
readonly className?: string;
|
|
164
|
+
/** Right-to-left: toggles `dp-ui__container--rtl` on the surface container. */
|
|
165
|
+
readonly rtl?: boolean;
|
|
166
|
+
}
|
|
167
|
+
/** Applies theme settings to a surface root (`host.root`). Safe to call again. */
|
|
168
|
+
export declare function applyTheme(root: HTMLElement, theme: SurfaceTheme): void;
|
|
169
|
+
export declare function maskDateText(text: string, pattern: FormatPattern): string;
|
|
170
|
+
/**
|
|
171
|
+
* Length of the date at the start of `text`, in characters of `text` as
|
|
172
|
+
* given: the index just after the last digit group `pattern` expects, or the
|
|
173
|
+
* separator before the next group. A separator after the last group is not
|
|
174
|
+
* part of the date. Bidi marks, locale digits and characters the mask skips
|
|
175
|
+
* count as written. Returns 0 when `text` holds no digit.
|
|
176
|
+
*/
|
|
177
|
+
export declare function leadingDateLength(text: string, pattern: FormatPattern): number;
|
|
178
|
+
/**
|
|
179
|
+
* Whether `text` starts with a whole date: every group `pattern` expects is
|
|
180
|
+
* there and the last one has all its digits. A separator closes an earlier
|
|
181
|
+
* group, so `1.5.2026` is complete. Text after the date is ignored.
|
|
182
|
+
*/
|
|
183
|
+
export declare function isDateTextComplete(text: string, pattern: FormatPattern): boolean;
|
|
184
|
+
/** Maps Arabic-Indic and Persian digits to Latin digits, drops bidi marks and trims. */
|
|
185
|
+
export declare function normalizeDigits(text: string): string;
|
|
186
|
+
export declare function parseDate(text: string, pattern: FormatPattern): PlainDate | null;
|
|
187
|
+
export declare const RANGE_SEPARATOR = " – ";
|
|
188
|
+
/**
|
|
189
|
+
* Splits range text into its start and end text the way the picker does:
|
|
190
|
+
* at an en or em dash with optional spaces, or at a hyphen with spaces
|
|
191
|
+
* around it. Returns `null` unless the text splits into exactly two parts.
|
|
192
|
+
*/
|
|
193
|
+
export declare function splitRangeText(text: string): readonly [string, string] | null;
|
|
194
|
+
export { type DatePart, type FormatOption, type FormatPattern, type FullDateOptions, type HintLetters, type PagerOptions, type PlainDate, type Scheme, type SurfaceHost, type SurfaceMode, type SurfaceTheme, type ThemeName, type WeekStartOption, type Weekday, type YearMonth, formatDate, formatFullDate, formatHint, formatMonthYear, resolvePattern, resolveWeekStart, weekdayNames };
|
package/dist/esm/kit.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{i as DialogHost,r as InlineHost,o as Pager,n as PopoverHost,b as RANGE_SEPARATOR,t as applyTheme,h as createTextButton,k as detectColorScheme,y as fitsViewport,it as formatDate,G as formatFullDate,at as formatHint,q as formatMonthYear,c as isDateTextComplete,St as isFullscreenRange,l as leadingDateLength,u as maskDateText,U as normalizeDigits,W as parseDate,ct as resolvePattern,Ct as resolveSurfaceMode,tt as resolveWeekStart,T as splitRangeText,a as waitForExit,A as watchColorScheme,nt as weekdayNames}from"./shared.js";
|