@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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 pglejzer (Piotr Glejzer)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,245 @@
1
+ # datepicker-ui
2
+
3
+ A date picker for web forms. Attach it to an `<input>` and users pick a date, a range or several dates on a Material Design 3 calendar.
4
+
5
+ [![npm version](https://badge.fury.io/js/@pglejzer%2Fdatepicker-ui.svg)](https://www.npmjs.com/package/@pglejzer/datepicker-ui)
6
+ [![downloads](https://img.shields.io/npm/dm/@pglejzer/datepicker-ui)](https://npmcharts.com/compare/@pglejzer/datepicker-ui?minimal=true)
7
+ [![license](https://img.shields.io/badge/license-MIT-green.svg)](https://img.shields.io/npm/l/@pglejzer/datepicker-ui)
8
+ [![Coverage Status](https://coveralls.io/repos/github/pglejzer/datepicker-ui/badge.svg?branch=main)](https://coveralls.io/github/pglejzer/datepicker-ui?branch=main)
9
+ [![CI](https://github.com/pglejzer/datepicker-ui/actions/workflows/ci.yml/badge.svg)](https://github.com/pglejzer/datepicker-ui/actions/workflows/ci.yml)
10
+ [![Socket Badge](https://badge.socket.dev/npm/package/@pglejzer/datepicker-ui/1.1.0)](https://badge.socket.dev/npm/package/@pglejzer/datepicker-ui/1.1.0)
11
+
12
+ [Live demo](https://timepicker-ui.vercel.app/datepicker) · [Documentation](https://timepicker-ui.vercel.app/datepicker/quick-start) · [Changelog](./CHANGELOG.md) · [timepicker-ui](https://timepicker-ui.vercel.app)
13
+
14
+ ## Why datepicker-ui
15
+
16
+ - Zero dependencies.
17
+ - About 40 KB gzipped JavaScript.
18
+ - Material Design 3 look, with light and dark modes and ten themes.
19
+ - Plain JS API, so it works the same in React, Vue, Angular, Svelte or without a framework.
20
+ - Doesn't touch `window` or `document` on import, so it's safe in Next.js, Nuxt and other SSR setups.
21
+ - Keyboard and screen reader support ([accessibility](https://timepicker-ui.vercel.app/datepicker/docs/accessibility)).
22
+ - All texts, the screen-reader ones included, can be translated via `labels`. Month and day names come from `Intl` ([localization](https://timepicker-ui.vercel.app/datepicker/docs/localization)).
23
+
24
+ ## Features
25
+
26
+ - [Single date, range and multiple dates](https://timepicker-ui.vercel.app/datepicker/docs/selection-modes), with [range limits](https://timepicker-ui.vercel.app/datepicker/examples/selection/range-limits)
27
+ - [Docked popover](https://timepicker-ui.vercel.app/datepicker/examples/basic/docked), [modal dialog](https://timepicker-ui.vercel.app/datepicker/examples/basic/modal) and [inline calendar](https://timepicker-ui.vercel.app/datepicker/examples/basic/inline), with a full-screen range picker on small screens ([display modes](https://timepicker-ui.vercel.app/datepicker/docs/display-modes))
28
+ - [Typed input](https://timepicker-ui.vercel.app/datepicker/docs/typed-input) with an opt-in mask for the page input, and a switch between the calendar and an input view that always formats typed digits
29
+ - [Several months side by side](https://timepicker-ui.vercel.app/datepicker/examples/features/several-months)
30
+ - [Range presets](https://timepicker-ui.vercel.app/datepicker/examples/selection/range-presets) and [two fields for a range](https://timepicker-ui.vercel.app/datepicker/examples/selection/two-fields)
31
+ - [Month and year pickers](https://timepicker-ui.vercel.app/datepicker/docs/precision)
32
+ - [Disabled dates](https://timepicker-ui.vercel.app/datepicker/docs/disabled-dates), [min and max](https://timepicker-ui.vercel.app/datepicker/examples/constraints/min-max) and [validation](https://timepicker-ui.vercel.app/datepicker/examples/constraints/validation) with your own rules
33
+ - [Per-day content](https://timepicker-ui.vercel.app/datepicker/examples/features/per-day-content) and [decorated dates](https://timepicker-ui.vercel.app/datepicker/examples/features/decorate-dates)
34
+ - [Ten themes](https://timepicker-ui.vercel.app/datepicker/docs/themes), [dark mode](https://timepicker-ui.vercel.app/datepicker/examples/themes/dark-mode) and [custom styling](https://timepicker-ui.vercel.app/datepicker/docs/styling)
35
+ - [Form integration](https://timepicker-ui.vercel.app/datepicker/examples/advanced/forms) through a hidden ISO value
36
+ - [TypeScript](https://timepicker-ui.vercel.app/datepicker/api/typescript) types included
37
+
38
+ ## Installation
39
+
40
+ ```bash
41
+ npm install @pglejzer/datepicker-ui
42
+ ```
43
+
44
+ From a CDN, the UMD build exposes the class as the global `DatepickerUI`. More in the [installation guide](https://timepicker-ui.vercel.app/datepicker/installation).
45
+
46
+ ## Quick start
47
+
48
+ ```html
49
+ <input id="date" />
50
+ ```
51
+
52
+ ```js
53
+ import { DatepickerUI } from "@pglejzer/datepicker-ui";
54
+ import "@pglejzer/datepicker-ui/index.css";
55
+
56
+ const picker = new DatepickerUI("#date", {
57
+ calendar: { minDate: "today" },
58
+ ui: { theme: "m3-green" },
59
+ callbacks: {
60
+ onConfirm: ({ value }) => console.log(value),
61
+ },
62
+ });
63
+
64
+ picker.create();
65
+ ```
66
+
67
+ `DatepickerUI` is a named export, and also the default export, so `import DatepickerUI from "@pglejzer/datepicker-ui"` works too.
68
+
69
+ The first argument is a selector, an `<input>` or an element that contains an `<input>`. The options argument is optional. Step by step: [quick start](https://timepicker-ui.vercel.app/datepicker/quick-start) and [getting started example](https://timepicker-ui.vercel.app/datepicker/examples/basic/getting-started).
70
+
71
+ ## API
72
+
73
+ ```js
74
+ picker.create(); // set up the picker, mounts it when inline
75
+ picker.open();
76
+ picker.close();
77
+ picker.destroy({ keepInputValue: true });
78
+ picker.getValue(); // DateValue, { start, end }, DateValue[] or null, by calendar.mode
79
+ picker.setValue("2025-03-14"); // a Date, an ISO string or "today"; { start, end } or an array in other modes
80
+ picker.setOptions({ ui: { theme: "crane" } });
81
+ picker.setActiveEnd("end"); // range mode: the end the next pick sets
82
+ picker.clear(); // empty the value, emits "clear" and the input's input + change events
83
+ picker.setValue(null); // empty the value quietly, without those events
84
+ picker.setView("input"); // "calendar" | "input", switch the view
85
+ picker.getView();
86
+ picker.goTo("2025-06-01"); // show that month without selecting
87
+ picker.getVisibleRange(); // { from, to } first and last day shown, or null
88
+ picker.isSelectable("2025-03-14"); // checks a day, a range or an array against every rule
89
+ picker.getElement(); // the .dp-ui host element
90
+
91
+ const off = picker.on("confirm", ({ value }) => {}); // on() and once() return a function that removes the handler
92
+ off();
93
+ picker.on("cancel", ({ reason }) => {}); // "button" | "escape" | "outside" | "toggle"
94
+ picker.on("open", ({ mode }) => {});
95
+ picker.on("close", () => {});
96
+ picker.on("update", ({ options }) => {});
97
+ picker.on("error", ({ code, message }) => {});
98
+ picker.on("select:day", ({ value, selected }) => {});
99
+ picker.on("select:month", ({ year, month }) => {});
100
+ picker.on("select:year", ({ year }) => {});
101
+ picker.on("navigate", ({ year, month, direction, source, from, to }) => {}); // source: drag, wheel, button, keyboard, menu, open, api, resize, scroll
102
+ picker.on("switch:view", ({ view }) => {});
103
+ picker.on("clear", ({ previousValue }) => {});
104
+ picker.on("range:start", ({ value }) => {});
105
+ picker.on("range:end", ({ start, end }) => {});
106
+ picker.once("confirm", handler);
107
+ picker.off("confirm", handler);
108
+
109
+ DatepickerUI.getById("my-id");
110
+ DatepickerUI.getAllInstances();
111
+ DatepickerUI.destroyAll();
112
+ ```
113
+
114
+ The main entry also exports the types `PickerView`, `SwitchViewEventData`, `ClearEventData`, `VisibleRange`, `NavigateSource` and `CancelReason`.
115
+
116
+ Docs: [methods](https://timepicker-ui.vercel.app/datepicker/api/methods), [events](https://timepicker-ui.vercel.app/datepicker/api/events), [events example](https://timepicker-ui.vercel.app/datepicker/examples/advanced/events), [external API example](https://timepicker-ui.vercel.app/datepicker/examples/advanced/external-api)
117
+
118
+ ## Options
119
+
120
+ Grouped by area into `calendar`, `ui`, `labels`, `behavior` and `callbacks`. Pass only what you need, the rest has defaults ([full list](https://timepicker-ui.vercel.app/datepicker/api/options)).
121
+
122
+ ```typescript
123
+ new DatepickerUI(input, {
124
+ calendar: {
125
+ mode: "single" | "range" | "multiple", // default "single"
126
+ defaultValue: "today", // starting value of an empty input, shape of setValue()
127
+ range: { minLength, maxLength, presets: [] },
128
+ multiple: { max },
129
+ months: 1, // months side by side, docked look
130
+ precision: "day" | "month" | "year", // default "day", single mode only
131
+ locale: "en-GB", // default: page locale
132
+ minDate: "today", maxDate: "2026-12-31",
133
+ disabledDates: [], enabledDates: [], disabledWeekdays: [0, 6],
134
+ isDateDisabled: (date) => false,
135
+ decorateDate: (date) => ({ className, badge, label }),
136
+ renderDate: (date) => "$120", // content under the day number
137
+ validate: (value) => null, // or a message to mark the field invalid
138
+ },
139
+ ui: {
140
+ displayMode: "auto" | "docked" | "modal", // default "auto"
141
+ layout: "auto" | "docked" | "modal" | "fullscreen", // look on any surface, default "auto"
142
+ inline: {
143
+ enabled: false, container: "#calendar" | element,
144
+ headline: true, // false hides the inline headline
145
+ navigation: "menus" | "caption", // "caption": text next to the arrows, no menus
146
+ announceSelection: true, // false leaves selection announcements to the host
147
+ },
148
+ format: "auto" | "dd.MM.yyyy",
149
+ theme: "basic" | "m3-green" | "crane" | "blueprint" | ...,
150
+ colorScheme: "auto" | "light" | "dark", // default "auto"
151
+ toggleButton: "#open" | element,
152
+ endInput: "#end" | element, // second input of a range
153
+ startView: "day" | "month" | "year",
154
+ mask: false,
155
+ cssClass: "",
156
+ },
157
+ labels: { title, confirm, cancel, today, clear, previousMonth, nextMonth, invalidDate, inRange, ... },
158
+ behavior: { closeOnSelect: false, commitOnChange: false, returnFocus: true, id: "" },
159
+ callbacks: { onOpen, onClose, onCancel, onConfirm, onUpdate, onError, onSelectDay, onSelectMonth, onSelectYear, onNavigate, onRangeStart, onRangeEnd, onSwitchView, onClear },
160
+ });
161
+ ```
162
+
163
+ With `ui.displayMode: "auto"`, a docked picker that fits neither below nor above the field opens as a dialog, so the result depends on where the field is on the page. An invalid value falls back to the default and emits an `error` event with code `invalid-option`. More on [layouts](https://timepicker-ui.vercel.app/datepicker/docs/layouts) and [changing options at runtime](https://timepicker-ui.vercel.app/datepicker/examples/advanced/set-options).
164
+
165
+ ## Themes
166
+
167
+ [Preview all of them](https://timepicker-ui.vercel.app/datepicker/examples/themes/all-themes): `basic` (the default, light and dark), `blueprint` (follows `ui.colorScheme`), `m3-green`, `crane`, `crane-straight`, `m2`, `glassmorphic`, `pastel`, `ai` and `cyberpunk`.
168
+
169
+ `main.css` is required and already includes `basic`. The other themes are separate files:
170
+
171
+ ```js
172
+ import "@pglejzer/datepicker-ui/main.css";
173
+ import "@pglejzer/datepicker-ui/theme-m2.css";
174
+
175
+ new DatepickerUI("#date", { ui: { theme: "m2" } });
176
+ ```
177
+
178
+ Or import `@pglejzer/datepicker-ui/index.css` to get the core and every theme. Writing your own theme: [themes guide](https://timepicker-ui.vercel.app/datepicker/docs/themes), [custom theme example](https://timepicker-ui.vercel.app/datepicker/examples/themes/custom-theme), [CSS classes](https://timepicker-ui.vercel.app/datepicker/api/css-classes) and [CSS variables](https://timepicker-ui.vercel.app/datepicker/api/css-variables).
179
+
180
+ New classes: `dp-ui__calendar--modal`, `dp-ui__navigation--caption` with `dp-ui__caption`, and `dp-ui__presets--column`, which gives a presets group outside the picker the column look. `--dp-ui-date-container-min-size` (36px) and `--dp-ui-date-container-max-size` (48px) bound the day cell size.
181
+
182
+ An inline picker narrows to fit its container, down to 36px cells, and scrolls sideways below that. The container needs a width that does not come from the picker: a flex or grid item needs `min-width: 0`, and a centered grid item or an `inline-block` also needs `width: 100%`.
183
+
184
+ ## Frameworks
185
+
186
+ React:
187
+
188
+ ```tsx
189
+ import { useEffect, useRef } from "react";
190
+ import { DatepickerUI } from "@pglejzer/datepicker-ui";
191
+ import "@pglejzer/datepicker-ui/index.css";
192
+
193
+ function DateField() {
194
+ const ref = useRef<HTMLInputElement>(null);
195
+ useEffect(() => {
196
+ if (!ref.current) return;
197
+ const picker = new DatepickerUI(ref.current);
198
+ picker.create();
199
+ return () => picker.destroy();
200
+ }, []);
201
+ return <input ref={ref} />;
202
+ }
203
+ ```
204
+
205
+ The same pattern works in Vue, Svelte and Angular. See the [frameworks and SSR guide](https://timepicker-ui.vercel.app/datepicker/docs/frameworks).
206
+
207
+ ## Kit
208
+
209
+ `@pglejzer/datepicker-ui/kit` is a second entry for packages built on top of the picker. It exports the popover, dialog and inline surfaces (`PopoverHost`, `DialogHost`, `InlineHost`), the rule that picks docked or modal (`resolveSurfaceMode`), color scheme detection and the date text helpers (`parseDate`, `formatDate`, `resolvePattern`, `maskDateText`). Like the main entry, it is safe to import during server rendering. See the [kit guide](https://timepicker-ui.vercel.app/datepicker/docs/kit).
210
+
211
+ Also exported:
212
+
213
+ - `applyTheme` and the `SurfaceTheme` type write the theme, color scheme, extra classes and right-to-left state onto a surface root.
214
+ - `createTextButton` builds the picker's text button.
215
+ - `fitsViewport(root, anchor)` tells whether a docked surface fits the window entirely below or entirely above its anchor.
216
+ - `Pager` and `PagerOptions` give the month paging with its drag and wheel gestures.
217
+ - `RANGE_SEPARATOR` and `splitRangeText` write and split range text.
218
+ - `leadingDateLength`, `isDateTextComplete` and `normalizeDigits` help with typed dates.
219
+ - `resolveWeekStart`, `weekdayNames`, `formatMonthYear` and `formatFullDate` are the calendar's week and name helpers. `formatFullDate(date, locale, { year: false })` leaves the year out.
220
+ - The hosts accept a `labelledBy` option, the id of a visible title that names the surface. `setLabel(label, labelledBy?)` renames a shown surface by the same rule.
221
+
222
+ ```js
223
+ import { parseDate, resolvePattern } from "@pglejzer/datepicker-ui/kit";
224
+ ```
225
+ ## Need a time picker?
226
+
227
+ [timepicker-ui](https://timepicker-ui.vercel.app) is the companion time picker from the same author. It has no dependencies and uses the same theme names, so the two pickers match.
228
+
229
+ ```bash
230
+ npm install timepicker-ui
231
+ ```
232
+
233
+ The [date and time guide](https://timepicker-ui.vercel.app/datepicker/docs/with-timepicker) shows how to use both pickers in one form, and the [date and time example](https://timepicker-ui.vercel.app/datepicker/examples/advanced/date-and-time) shows it running.
234
+
235
+ ## Development
236
+
237
+ See [`app/README.md`](./app/README.md).
238
+
239
+ ## Contributing
240
+
241
+ Issues and PRs welcome on [GitHub](https://github.com/pglejzer/datepicker-ui/issues).
242
+
243
+ ## License
244
+
245
+ MIT © [Piotr Glejzer](https://github.com/pglejzer)
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./shared.cjs");function t(e){queueMicrotask(()=>{throw e})}var n=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,n){let r=this.store[e];if(!r)return;let i=[];for(let e of[...r])if(r.has(e))try{e.handler(n)}catch(e){i.push(e)}i.length>0&&t(i[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 r(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 i={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`},a={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:i,behavior:{closeOnSelect:!1,closeOnCancel:!0,commitOnChange:!1,ignoreOutsideClick:!1,returnFocus:!0}};function o(t,n){if(e.pt(t))return null;switch(t.mode){case`single`:return t.date?n(t.date):null;case`range`:return t.start===null||t.end===null?null:{start:n(t.start),end:n(t.end)};default:return e._t(t).map(n)}}function s(t,n){if(t===`today`)return e.z(e.Ht(),n);if(typeof t==`string`)return e.B(t,n);if(t instanceof Date){let r=e.Vt(t);return r===null?null:e.z(r,n)}return null}function c(t){if(!(`start`in t&&`end`in t))return null;let n=s(t.start,`day`),r=s(t.end,`day`);return n===null||r===null||e.At(n,r)>0?null:{mode:`range`,start:n,end:r}}function l(t){let n=[];for(let e of t){let t=s(e,`day`);if(t===null)return null;n.push(t)}return{mode:`multiple`,dates:e.vt(n)}}function u(t,n,r){if(t===null)return e.ut(n);if(n===`multiple`)return Array.isArray(t)?l(t):null;if(n===`single`){let e=s(t,r);return e===null?null:{mode:n,date:e}}return typeof t==`object`&&!Array.isArray(t)&&!(t instanceof Date)?c(t):null}function d(e,t){return e instanceof Date?e:typeof e!=`string`||e===`today`&&!t?null:e}function f(t,n,r,i){if(t===void 0)return null;let a=d(t,n),o=a===null?null:e.Vt(a);return o===null&&i.push({option:r,value:t}),o}function p(e,t,n,r){return e==null?null:u(e,t,n)===null?(r.push({option:`calendar.defaultValue`,value:e}),null):()=>u(e,t,n)}function m(e,t,n){return e===void 0?null:Array.isArray(e)?e.map(e=>f(e,!1,t,n)).filter(e=>e!==null):(n.push({option:t,value:e}),null)}function h(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 g=e=>typeof e==`boolean`?e:void 0,_=e=>typeof e==`string`?e:void 0,v=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?Math.floor(e):void 0,y=e=>typeof e==`number`&&Number.isInteger(e)&&e>=1?e:void 0,b=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},x=e=>{if(typeof e==`function`)return t=>Reflect.apply(e,void 0,[t])},S=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},C=e=>typeof HTMLElement<`u`&&e instanceof HTMLElement||typeof e==`string`&&e.length>0?e:void 0;function w(e){return t=>e.find(e=>e===t)}function T(t){return n=>typeof n==`string`&&e.st(n,t)?n:void 0}const E=w([`auto`,`docked`,`modal`]),D=w([`auto`,`light`,`dark`]),O=w([`auto`,`sunday`,`monday`,`saturday`]),k=w([`single`,`range`,`multiple`]),A=w([`calendar`,`input`]),ee=w([`day`,`month`,`year`]),te=w([`month`,`view`]),ne=w([`day`,`month`,`year`]),re=w([`auto`,`docked`,`modal`,`fullscreen`]),ie=w([`menus`,`caption`]),ae=w([`basic`,`m3-green`,`crane`,`crane-straight`,`m2`,`glassmorphic`,`pastel`,`ai`,`cyberpunk`,`blueprint`]);function oe(e){return e in i}function se(e,t){let n={...i};for(let r of Object.keys(i))oe(r)&&r!==`multipleSelected`&&(n[r]=h(e?.[r],_,i[r],`labels.${r}`,t));return n.multipleSelected=h(e?.multipleSelected,S,i.multipleSelected,`labels.multipleSelected`,t),n}function ce(e,t){return e===void 0||e===!0?600:e===!1?0:h(e,y,600,`ui.fullscreen`,t)}function le(e,t){return e===void 0||e===!1?!1:e===!0?{selectable:!0}:typeof e==`object`&&e?{selectable:h(Reflect.get(e,`selectable`),g,!0,`ui.outsideDays.selectable`,t)}:(t.push({option:`ui.outsideDays`,value:e}),!1)}function ue(e,t){return e===void 0||e===!1?!1:e===!0?{clearInput:!0}:typeof e==`object`&&e?{clearInput:h(Reflect.get(e,`clearInput`),g,!0,`ui.clearButton.clearInput`,t)}:(t.push({option:`ui.clearButton`,value:e}),!1)}const de=`calendar.range.presets`;function fe(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 pe(e,t){if(e===void 0)return a.calendar.presets;if(!Array.isArray(e))return t.push({option:de,value:e}),a.calendar.presets;let n=e,r=[];for(let e of n){let n=fe(e);n===null?t.push({option:de,value:e}):r.push(n)}return r}function me(e){return typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6}function he(t,n){let r=t?.trim();r&&!e.Q(r)&&n.push({option:`calendar.locale`,value:t})}function ge(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)me(e)?r.includes(e)||r.push(e):t.push({option:`calendar.disabledWeekdays`,value:e});return r}function _e(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 ve(e){return typeof e==`string`||typeof Node<`u`&&e instanceof Node?e:null}function ye(e){return e===null?null:n=>{try{return ve(e(n))}catch(e){return t(e),null}}}function be(e){return e===null?null:n=>{try{let t=e(n);return typeof t!=`string`||t.length===0?null:t}catch(e){return t(e),null}}}function xe(e,t,n){let r=a.calendar,i=h(e,ee,r.precision,`calendar.precision`,n);return i!==`day`&&t!==`single`?(n.push({option:`calendar.precision`,value:e}),r.precision):i}function Se(e,t){let n=h(e?.range?.minLength,y,null,`calendar.range.minLength`,t),r=h(e?.range?.maxLength,y,null,`calendar.range.maxLength`,t),i=h(e?.multiple?.max,y,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 Ce(t,n){let r=a.calendar;he(t?.locale,n);let i=e.et(t?.locale),o=h(t?.weekStart,O,r.weekStart,`calendar.weekStart`,n),s=h(t?.isDateDisabled,b,null,`calendar.isDateDisabled`,n),c=h(t?.decorateDate,b,null,`calendar.decorateDate`,n),l=h(t?.renderDate,b,null,`calendar.renderDate`,n),u=h(t?.validate,x,null,`calendar.validate`,n),d=h(t?.mode,k,r.mode,`calendar.mode`,n),g=xe(t?.precision,d,n);return{locale:i,weekStart:e.tt(i,o),minDate:f(t?.minDate,!0,`calendar.minDate`,n),maxDate:f(t?.maxDate,!0,`calendar.maxDate`,n),disabledDates:m(t?.disabledDates,`calendar.disabledDates`,n)??[],enabledDates:m(t?.enabledDates,`calendar.enabledDates`,n),mode:d,precision:g,defaultValue:p(t?.defaultValue,d,g,n),months:h(t?.months,y,r.months,`calendar.months`,n),pageBy:h(t?.pageBy,te,r.pageBy,`calendar.pageBy`,n),limits:Se(t,n),presets:pe(t?.range?.presets,n),isDateDisabled:s===null?null:e=>!!s(e),disabledWeekdays:ge(t?.disabledWeekdays,n),decorateDate:c===null?null:e=>_e(c(e)),renderDate:ye(l),validate:be(u)}}function we(t){let n=[],r=a,i=t?.calendar,o=t?.ui,s=t?.behavior,c=(e,t,r,i)=>h(e,t,r,i,n),l=Ce(i,n),{locale:u,precision:d}=l,f=c(o?.format,T(d),r.ui.format,`ui.format`),p=c(o?.footer,g,!1,`ui.footer`),m=s?.id;return{...l,displayMode:c(o?.displayMode,E,r.ui.displayMode,`ui.displayMode`),layout:c(o?.layout,re,r.ui.layout,`ui.layout`),inline:{enabled:c(o?.inline?.enabled,g,r.ui.inline.enabled,`ui.inline.enabled`),container:c(o?.inline?.container,C,null,`ui.inline.container`),headline:c(o?.inline?.headline,g,r.ui.inline.headline,`ui.inline.headline`),navigation:c(o?.inline?.navigation,ie,r.ui.inline.navigation,`ui.inline.navigation`),announceSelection:c(o?.inline?.announceSelection,g,r.ui.inline.announceSelection,`ui.inline.announceSelection`)},pattern:e.ct(f,u,d),theme:c(o?.theme,ae,r.ui.theme,`ui.theme`),colorScheme:c(o?.colorScheme,D,r.ui.colorScheme,`ui.colorScheme`),toggleButton:c(o?.toggleButton,C,null,`ui.toggleButton`),endInput:c(o?.endInput,C,null,`ui.endInput`),weekNumbers:c(o?.weekNumbers,g,r.ui.weekNumbers,`ui.weekNumbers`),outsideDays:le(o?.outsideDays,n),fixedWeeks:c(o?.fixedWeeks,g,r.ui.fixedWeeks,`ui.fixedWeeks`),yearRange:{before:c(o?.yearRange?.before,v,r.ui.yearRange.before,`ui.yearRange.before`),after:c(o?.yearRange?.after,v,r.ui.yearRange.after,`ui.yearRange.after`)},todayButton:c(o?.todayButton,g,r.ui.todayButton,`ui.todayButton`),clearButton:ue(o?.clearButton,n),footerExplicit:typeof o?.footer==`boolean`?p:null,animation:c(o?.animation,g,r.ui.animation,`ui.animation`),allowPageScroll:c(o?.allowPageScroll,g,r.ui.allowPageScroll,`ui.allowPageScroll`),fullscreenBelow:ce(o?.fullscreen,n),cssClass:c(o?.cssClass,_,r.ui.cssClass,`ui.cssClass`),appendTo:c(o?.appendTo,C,null,`ui.appendTo`),swipe:c(o?.swipe,g,r.ui.swipe,`ui.swipe`),viewSwitch:c(o?.viewSwitch,g,r.ui.viewSwitch,`ui.viewSwitch`),initialView:c(o?.initialView,A,r.ui.initialView,`ui.initialView`),mask:c(o?.mask,g,r.ui.mask,`ui.mask`),startView:c(o?.startView,ne,r.ui.startView,`ui.startView`),labels:se(t?.labels,n),behavior:{closeOnSelect:c(s?.closeOnSelect,g,r.behavior.closeOnSelect,`behavior.closeOnSelect`),closeOnCancel:c(s?.closeOnCancel,g,r.behavior.closeOnCancel,`behavior.closeOnCancel`),commitOnChange:c(s?.commitOnChange,g,r.behavior.commitOnChange,`behavior.commitOnChange`),ignoreOutsideClick:c(s?.ignoreOutsideClick,g,r.behavior.ignoreOutsideClick,`behavior.ignoreOutsideClick`),returnFocus:c(s?.returnFocus,g,r.behavior.returnFocus,`behavior.returnFocus`),id:typeof m==`string`&&m.length>0?m:null},callbacks:{...t?.callbacks},issues:n}}const Te=/[^\w-]/g;let Ee=0;function De(e){return e.replace(Te,`-`)}function Oe(e){return{year:e.year,month:e.month}}var ke=class{input;host;createdHost;instanceId;events=new n;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(t,n,i,a){this.input=t,this.host=n,this.createdHost=i,this.raw=r({},a??{}),this.resolved=we(this.raw),Ee+=1;let o=this.resolved.behavior.id;this.instanceId=o===null?`${e.Ut}${String(Ee)}`:De(o),this.currentPanel=e.bt(this.resolved.precision),this.currentValue=e.ut(this.resolved.mode),this.currentDraft=this.currentValue;let s=e.Ht();this.currentFocus=s,this.currentView=Oe(s)}get options(){return this.resolved}get rawOptions(){return this.raw}setOptions(e){this.raw=r(this.raw,e),this.resolved=we(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=Oe(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 t=e.lt(this.currentValue)??e.Ht(),n=Oe(t);this.currentListSpan=null,this.setPanel(e.bt(this.resolved.precision)),this.setDraft(this.currentValue),this.setView(n,e.Rt(this.currentView,n),`api`),this.setFocus(t)}};const j=`dp-ui`,Ae=[`class`,`name`,`aria-invalid`,`aria-describedby`];function je(e){return typeof e==`string`?document.querySelector(e):e}function Me(e){return e instanceof HTMLInputElement?e:e?.querySelector(`input`)??null}function Ne(e){let t=document.createElement(`div`);return t.className=j,e.before(t),t.append(e),t}function Pe(t){if(!e.rt())throw Error(`DatepickerUI needs a document`);let n=je(t),r=Me(n);if(r===null)throw Error(`DatepickerUI could not find an input element`);let i=r.parentElement;return i!==null&&(n!==r||i.classList.contains(j))?{input:r,host:i,createdHost:!1}:{input:r,host:Ne(r),createdHost:!0}}function Fe(e){let{input:t,host:n,createdHost:r}=e,i=/* @__PURE__ */ new Map;for(let e of Ae)i.set(e,t.getAttribute(e));let a=n.classList.contains(j);return n.classList.add(j),{target:{input:t,host:n,createdHost:r},hostHadClass:a,inputAttributes:i}}function Ie(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(j)}function Le(t,n,r,i){let a=e.Rt(t,n);return a>=0&&a<r?t:i===`month`?a<0?n:e.kt(n,-(r-1)):e.kt(t,Math.floor(a/r)*r)}function Re(t,n){let{core:r,managers:i}=t,{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&&e.At(a,c)>0?a:c,d=o!==null&&e.At(o,l)<0?o:l;return e.At(n,u)<0?u:e.At(n,d)>0?d:n}function ze(t,n,r){return Re(t,{year:n.year,month:n.month,day:Math.min(r,e.Pt(n))})}function M(t,n,r){let{core:i,managers:a}=t,o=a.validation.clampView(n),s=e.Rt(i.view,o);return s!==0&&(i.setView(o,s,r),i.setFocus(ze(t,o,i.focus.day))),o}function N(t,n,r){let{core:i,managers:a}=t,o={year:n.year,month:n.month},{months:s}=i.layout,c=a.validation.clampView(Le(i.view,o,s,i.options.pageBy)),l=e.Rt(c,o);if(l<0||l>=s)return;let u=e.Rt(i.view,c);u!==0&&i.setView(c,u,r),i.setFocus(n)}function Be(t,n,r){let i=e.Nt(t,n)+1;return r.minLength!==null&&i<r.minLength?!1:r.maxLength===null||i<=r.maxLength}function Ve(t,n,r,i){let a=i;if(n.maxLength!==null){let r=e.Ot(t,n.maxLength-1);a=e.At(r,i)<0?r:i}for(let n=e.Ot(t,1);e.At(n,a)<=0;n=e.Ot(n,1))if(r(n))return n;return null}function He(t,n,r,i){if(t.mode===`multiple`){let{multipleMax:r}=n,{dates:i}=t;return n=>r!==null&&i.length>=r&&!e.ft(t,n)}if(t.mode!==`range`||t.start===null||t.end!==null)return()=>!1;let{start:a}=t,o=null,s=!1;return t=>e.At(t,a)<0?!1:e.At(t,i)>0||!Be(a,t,n)||(s||=(o=Ve(a,n,r,i),!0),o!==null&&e.At(t,o)>=0)}function Ue(t,n,r,i){if(!Be(t,n,r))return`range-length`;for(let r=t;e.At(r,n)<=0;r=e.Ot(r,1)){let e=i(r);if(e!==null)return e}return null}function We(e,t){for(let n of e){let e=t(n);if(e!==null)return e}return null}function P(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?Ue(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`:We(e.dates,n)}}function Ge(e,t,n){return P(e,t,e=>n(e)?`disabled`:null)===null}function Ke(t,n,r){return t.some(t=>e.At(t,n)===0)?t.filter(t=>e.At(t,n)!==0):r.multipleMax!==null&&t.length>=r.multipleMax?null:e.vt([...t,n])}function qe(e){return e.mode===`range`&&e.start!==null&&e.end===null?`end`:`start`}function Je(e,t){return e.mode===`range`?t===`start`?{mode:`range`,start:null,end:null}:{mode:`range`,start:e.start,end:null}:e}function Ye(t,n,r,i){switch(t.mode){case`single`:return{mode:`single`,date:n};case`range`:return i===`start`||t.start===null||e.At(n,t.start)<0?{mode:`range`,start:n,end:null}:{mode:`range`,start:t.start,end:n};default:{let e=Ke(t.dates,n,r);return e===null?t:{mode:`multiple`,dates:e}}}}var Xe=class{context;session;values;constructor(e,t,n){this.context=e,this.session=t,this.values=n}isOpen(){return this.session.active}select(t){let{core:n,managers:r}=this.context,i=e.z(t,n.options.precision),a=n.followsActiveEnd?n.activeEnd:qe(n.draft);if(!this.session.active||!r.validation.isSelectable(i,Je(n.draft,a)))return;N(this.context,i,`button`);let o=Ye(n.draft,i,n.options.limits,a);n.setDraft(o),n.setActiveEnd(qe(o)),this.announce(o,i),this.isOpen()&&this.autoCommit(o)}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};P(o,a,e=>r.validation.unavailableReason(e))===null&&(n.setDraft(o),n.setActiveEnd(`start`),N(this.context,e,`api`),this.emitRangeEnd(e,t),this.isOpen()&&this.autoCommit(o))}typeDraft(t){if(!this.acceptTyped(t))return;let{commitOnChange:n}=this.context.core.options.behavior;n&&e.dt(t)&&this.values.commit(!0)}submitDraft(){let{core:t}=this.context,n=t.draft,r=t.options.behavior.closeOnSelect&&n.mode!==`multiple`;this.session.active&&r&&e.dt(n)&&(e.gt(t.value,n)||this.values.commit(!0),this.session.close())}acceptTyped(t){let{core:n,managers:r}=this.context,{mode:i,limits:a}=n.options,o=t.mode===i&&Ge(t,a,e=>r.validation.isDisabled(e));if(!this.session.active||!o||e.gt(n.draft,t))return!1;n.setDraft(t);let s=e.lt(t);return s!==null&&N(this.context,s,`api`),this.announceTyped(t),!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(t,n){let{emitter:r}=this.context,{describe:i}=this.values;r.emit(`select:day`,{value:i(n),selected:e.ft(t,n)}),t.mode===`range`&&(t.start===null||t.end===null?r.emit(`range:start`,{value:i(n)}):this.emitRangeEnd(t.start,t.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()}},Ze=class{context;session;values;selector;constructor(e,t,n){this.context=e,this.session=t,this.values=n,this.selector=new Xe(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&&N(this.context,e,`keyboard`)}navigate(t,n){this.session.active&&M(this.context,e.kt(this.context.core.view,t),n)}page(e,t){let{core:n}=this.context,r=n.options.pageBy===`view`?n.layout.months:1;this.navigate(e*r,t)}jumpTo(t,n){if(!this.session.active)return;let{core:r}=this.context,i=r.panel,a=M(this.context,t,n);n===`menu`&&(r.setPanel(e.bt(r.options.precision)),this.announcePick(i,a))}showPanel(e){this.session.active&&this.context.core.setPanel(e)}confirm(){this.session.active&&e.dt(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:t,managers:n}=this.context,r=e.Ht();n.validation.isSelectable(r,t.draft)?this.select(r):N(this.context,r,`button`)}clear(){if(!this.session.active)return;let{core:t}=this.context,{clearButton:n}=t.options,r=n!==!1&&n.clearInput,i=this.values.clearedSelection(r);i!==null&&(this.values.emitClear(i),!this.isOpen())||(t.setDraft(e.ut(t.options.mode)),r&&(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})}},Qe=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 $e=[`class`,`name`,`aria-invalid`];function et(t){let{core:n,emitter:r}=t,{endInput:i,mode:a}=n.options;if(a!==`range`||i===null)return null;let o=e.I(i,n.host);return o instanceof HTMLInputElement&&o!==n.input?o:(r.emit(`error`,{code:`invalid-option`,message:`ui.endInput does not match an input element`,option:`ui.endInput`}),null)}function tt(e){let t=/* @__PURE__ */ new Map;for(let n of $e)t.set(n,e.getAttribute(n));return()=>{for(let[n,r]of t)r===null?e.removeAttribute(n):e.setAttribute(n,r)}}const nt=[`calendar`,`ui`,`labels`,`behavior`,`callbacks`];function rt(e){let t=[];for(let n of nt){let r=e[n];if(r!==void 0)for(let e of Object.keys(r))t.push(`${n}.${e}`)}return t}function it(e,t){return e.some(e=>t.option===e||t.option.startsWith(`${e}.`))}function at(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 ot=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:t,managers:n,status:r}=this.context,i=e.ut(t.options.mode);t.setValue(i),t.setDraft(i),r.created&&(n.input.write(i),n.form.sync())}reapply(t,n){let{core:r,managers:i}=this.context;this.callbacks.bind(),i.theme.applyHost(),this.triggers.bind(),e.pt(r.value)||i.input.write(r.value),i.triggers.updateLabel(),this.refreshSurface(t);let a=rt(n);at(this.context,r.options.issues.filter(e=>it(a,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`)}},st=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=Fe(e.core)}create(){let{core:t,managers:n,status:r}=this.context;if(r.created||r.destroyed)return;r.created=!0;let i=this.controller.signal;this.callbacks.bind(),n.theme.applyHost();let a=et(this.context);t.setEndInput(a),a!==null&&(this.restoreEndInput=tt(a));let o=this.initialSelection();t.setValue(o),e.pt(o)||n.input.write(o),n.form.bind(i),n.form.sync(),n.input.bind(i),this.triggers.bind(),n.triggers.updateLabel(),t.events.on(`change:value`,()=>{n.triggers.updateLabel()},i),t.options.inline.enabled&&this.session.mountInline(),at(this.context,t.options.issues)}initialSelection(){let{core:t,managers:n}=this.context;if(!e.pt(t.value))return t.value;let r=n.input.readInitial();return e.pt(r)?t.options.defaultValue?.()??r:r}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),Ie(this.hostSnapshot),t.events.clear(),n.clear())}},ct=class{tail=Promise.resolve();pending=0;stopped=!1;run(e){let n=async()=>{this.stopped||await e()},r=this.pending===0?n():this.tail.then(n);this.pending+=1;let i=r.catch(t).finally(()=>{--this.pending});return this.tail=i,i}stop(){this.stopped=!0}},lt=class{context;views;visible;queue=new ct;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:t,emitter:n}=this.context;e.I(t.options.inline.container)===null?n.emit(`error`,{code:`invalid-option`,message:`ui.inline.container does not match an element`,option:`ui.inline.container`}):(this.begin(`inline`),n.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(t){let{core:n}=this.context,r=n.options,i=window.innerWidth;if(t===`inline`){let t=e.I(r.inline.container)?.clientWidth??0;i=t>0?t:i}n.setLayout(e.wt({months:r.months,precision:r.precision,mode:r.mode,layout:n.calendarLayout,width:i,weekNumbers:r.weekNumbers,presets:r.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:t}=this.context.core.options;return e.Ct(t,!1,window.innerWidth,window.innerHeight)}clampView(){M(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(t){let{core:n}=this.context;n.setCalendarLayout(e.yt(t,n.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})}},ut=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 dt=[`start`,`end`];var ft=class{context;session;visible;constructor(e,t,n){this.context=e,this.session=t,this.visible=n}describe=t=>{let{pattern:n,precision:r}=this.context.core.options;return{value:e.H(t,r),date:e.zt(t),formatted:e.R(t,n,r)}};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=u(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(t){let{core:n,managers:r}=this.context,{mode:i,precision:a,limits:o}=n.options,s=u(t,i===`single`||typeof t==`string`||t instanceof Date?`single`:i,a);return s===null||e.pt(s)?!1:Ge(s,o,e=>r.validation.isDisabled(e))}clear(){let{core:t,managers:n,status:r}=this.context,i=this.clearedSelection(!0);if(r.destroyed||i===null)return;let a=e.ut(t.options.mode);t.setValue(a),this.session.active&&t.setDraft(a),n.input.write(a),r.created&&(n.form.sync(),n.form.dispatchCommit()),this.emitClear(i),this.validate(a)}clearedSelection(t){let{core:n}=this.context;return t&&!e.pt(n.value)?n.value:this.session.active&&!e.pt(n.draft)?n.draft:null}emitClear(e){this.context.emitter.emit(`clear`,{previousValue:this.present(e)})}setActiveEnd(e){let{core:t,status:n}=this.context,r=dt;!n.destroyed&&t.options.mode===`range`&&r.includes(e)&&(t.controlActiveEnd(),t.setActiveEnd(e))}applyTyped(t){let{core:n,emitter:r,managers:i}=this.context,a=!e.gt(n.value,t),o=e.gt(n.draft,t);n.setValue(t),i.form.sync(),(a||!o)&&this.follow(),a&&r.emit(`confirm`,{value:this.present(t),autoCommit:!0}),this.validate(t)}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 o(e,this.describe)}follow(){if(!this.session.active)return;let{core:t}=this.context,n=t.value;t.setDraft(n);let r=e.lt(n);r!==null&&this.visible.hold(`api`,()=>{N(this.context,r,`api`)})}};const pt=e=>e===`input`?`input`:`calendar`;var mt=class{context;isShown;visible;constructor(e,t,n){this.context=e,this.isShown=t,this.visible=n}get(){return this.isShown()?pt(this.context.core.panel):`calendar`}set(t){let{core:n}=this.context;this.isShown()&&this.hasInputView()&&n.setPanel(t===`input`?`input`:e.bt(n.options.precision))}goTo(t){let n=u(t,`single`,`day`),r=n===null?null:e.lt(n);r===null?this.context.emitter.emit(`error`,{code:`invalid-date`,message:`goTo() received a value that is not a valid date`,input:typeof t==`string`?t:void 0}):this.isShown()&&this.visible.hold(`api`,()=>{N(this.context,Re(this.context,r),`api`)})}bind(e){let{core:t,emitter:n}=this.context,r=pt(t.panel);t.events.on(`change:panel`,({panel:e})=>{let t=pt(e);t!==r&&(r=t,n.emit(`switch:view`,{view:t}))},e)}opening(t){let{core:n}=this.context,{initialView:r,inline:i,mode:a,precision:o,startView:s}=n.options;if(r===`input`&&this.hasInputView())return`input`;let c=e.xt(t,i).navigation===`caption`;return o!==`day`||a===`range`||c?e.bt(o):e.Et(s,n.calendarLayout)}dropUnsupported(){let{core:t}=this.context;t.panel===`input`&&!this.hasInputView()&&t.setPanel(e.bt(t.options.precision))}hasInputView(){let{core:t}=this.context,{mode:n,precision:r}=t.options;return e.Dt(n,t.calendarLayout,r)}};const F=(t,n)=>({from:{year:t.year,month:t.month,day:1},to:{year:n.year,month:n.month,day:e.Pt(n)}}),ht=(t,n,r)=>{let i={year:t.year,month:t.month,day:1},a=(e.Mt(i)-n+7)%7,o=r?6:Math.ceil((a+e.Pt(t))/7),s=e.Ot(i,-a);return{from:s,to:e.Ot(s,o*7-1)}},gt=e=>{let t=e.layout===`docked`&&e.months<=1&&e.outsideDays;return{outsideDays:t,fixedWeeks:e.layout!==`docked`&&!e.inline||t||e.fixedWeeks}},_t=t=>{let{view:n,listSpan:r,yearBounds:i}=t;return r===null?t.precision===`year`?F({year:i.min,month:1},{year:i.max,month:12}):t.precision===`month`?F({year:n.year,month:1},{year:n.year,month:12}):t.months>1?F(n,e.kt(n,t.months-1)):t.outsideDays?ht(n,t.weekStart,t.fixedWeeks):F(n,n):F(r.first,r.last)};function vt(e){return e<0?-1:+(e>0)}var yt=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(t){if(!this.live)return;let{core:n,emitter:r}=this.context,{from:i,to:a}=this.compute(),o={view:n.view,from:e.Bt(i),to:e.Bt(a)},s=this.last;if(s?.from===o.from&&s.to===o.to)return;this.last=o;let c=s===null?0:e.Rt(s.view,o.view);r.emit(`navigate`,{year:o.view.year,month:o.view.month,direction:vt(c),source:t,from:this.describe(i),to:this.describe(a)})}compute(){let{core:e,managers:t}=this.context,{options:n,layout:r}=e,i=gt({layout:e.calendarLayout,inline:e.mode===`inline`,months:r.months,outsideDays:n.mode!==`range`&&n.outsideDays!==!1,fixedWeeks:n.fixedWeeks});return _t({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(t){return{value:e.Bt(t),date:e.zt(t),formatted:e.R(t,this.context.core.options.pattern,`day`)}}},bt=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 Qe(r),a=new ut(r),o=()=>this.session.active;this.visible=new yt(r,o),this.views=new mt(r,o,this.visible),this.session=new lt(r,this.views,this.visible),this.values=new ft(r,this.session,this.visible),this.actions=new Ze(r,this.session,this.values),this.instance=new st(r,this.session,i,a),this.updates=new ot(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 xt=e=>e.toLowerCase().replace(/_/g,`-`);function St(t,n){Object.entries(e.O).forEach(([e,r])=>{t.style.setProperty(`--dp-ui-motion-${xt(e)}`,`${String(n?r:0)}ms`)}),Object.entries(e.E).forEach(([e,n])=>{t.style.setProperty(`--dp-ui-easing-${xt(e)}`,n)})}function Ct(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 wt=/* @__PURE__ */ new Map,Tt=/* @__PURE__ */ new Map;function Et(e){let t=wt.get(e);if(t)return t;let n=new Intl.PluralRules(e);return wt.set(e,n),n}function Dt(e){let t=Tt.get(e);if(t)return t;let n=new Intl.NumberFormat(e);return Tt.set(e,n),n}function Ot(e,t,n){return(typeof e==`string`?e:e[Et(n).select(t)]??e.other??Object.values(e).at(0)??``).replaceAll(`{count}`,Dt(n).format(t))}function kt(t,n,r,i,a){switch(t.mode){case`single`:return t.date?e.Y(t.date,a,r,`headline`):i.noDate;case`range`:{if(n===`input`&&t.start&&t.end)return e.Z(t.start,t.end,r);let a=t.start?e.X(t.start,r):i.rangeStart,o=t.end?e.X(t.end,r):i.rangeEnd;return`${a}${e.b}${o}`}default:return t.dates.length===0?i.noDate:Ot(i.multipleSelected,t.dates.length,r)}}const At=`dp-ui--ripple-pressed`,jt=`dp-ui--ripple-active`,Mt=e=>e.getAttribute(`aria-disabled`)===`true`||e instanceof HTMLButtonElement&&e.disabled;function Nt(t,n,r){let i=e=>e instanceof Element?e.closest(n):null,a=e=>{i(e.target)?.classList.remove(At)};t.addEventListener(`pointerdown`,n=>{let o=i(n.target);if(!o||!t.contains(o)||Mt(o)||n.pointerType===`mouse`&&n.button!==0)return;o.classList.remove(jt);let{left:s,top:c,width:l,height:u}=o.getBoundingClientRect();o.style.setProperty(`--dp-ui-ripple-x`,`${String(n.clientX-s)}px`),o.style.setProperty(`--dp-ui-ripple-y`,`${String(n.clientY-c)}px`),o.style.setProperty(`--dp-ui-ripple-size`,`${String(Math.max(l,u)*2)}px`),o.style.setProperty(`--dp-ui-ripple-duration`,`${String(e.O.RIPPLE)}ms`),o.classList.add(At),o.addEventListener(`pointerleave`,a,{once:!0,signal:r}),e.N()||(requestAnimationFrame(()=>{o.classList.add(jt)}),window.setTimeout(()=>{o.classList.remove(jt)},e.O.RIPPLE))},{signal:r}),t.addEventListener(`pointerup`,a,{signal:r}),t.addEventListener(`pointercancel`,a,{signal:r})}const Pt=(e,t)=>{e.querySelectorAll(`.dp-ui__text-button--confirm, .dp-ui__text-button--save`).forEach(e=>{e.disabled=!t})},Ft=t=>{let{labels:n}=t,r=e.F(`div`,`dp-ui__actions`);r.hidden=!t.visible;let i=e.F(`div`,`dp-ui__actions-start`);t.todayButton&&i.append(e.h(`today`,n.today)),t.clearButton&&i.append(e.h(`clear`,n.clear));let a=e.F(`div`,`dp-ui__actions-end`);return a.append(e.h(`cancel`,n.cancel),e.h(`confirm`,n.confirm)),r.append(i,a),r},It=[[`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`}]],Lt=e=>It.find(([t])=>e.classList.contains(t)),Rt=e=>Lt(e)?.[0]??null,zt=(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()}},Bt=(e,t,n)=>{e.addEventListener(`click`,e=>{let{target:t}=e,r=t instanceof Element?t.closest(`button`):null;if(r!==null){let e=Lt(r);e&&zt(e[1],n);return}let i=n.cellAt(t);i!==null&&n.actions.select(i.date)},{signal:t})},Vt=`dp-ui__container--menu-open`,I=`dp-ui__container--input`,Ht=`--dp-ui-visible-months`,L=e=>e.closest(`.dp-ui__container`),Ut=(e,t)=>e!==t&&e!==`days`&&e!==`input`,R=(e,t)=>{let n=t>1;e.classList.toggle(`dp-ui__container--multi-month`,n),n?e.style.setProperty(Ht,String(t)):e.style.removeProperty(Ht)},z=(e,t,n)=>{let r=t===`input`;e.classList.toggle(I,r),R(e,r?1:n)},Wt=t=>{let{locale:n,labels:r}=t,i=e._(r),a=e.F(`div`,`dp-ui__navigation dp-ui__navigation--caption`),o=e.F(`span`,`dp-ui__caption`);o.hidden=t.arrowsOnly,a.append(o,e.f(`prev-month`,r.previousMonth,e.v.keyboardArrowLeft,i.previousMonth),e.f(`next-month`,r.nextMonth,e.v.keyboardArrowRight,i.nextMonth));let s=t=>{o.textContent=e.q(t,n)};return s(t.view),{element:a,setView:s}},Gt=(t,n)=>{let r=e.F(`div`,`dp-ui__navigation-group dp-ui__navigation-group--${t}`);return r.append(...n),r},Kt=t=>{let{labels:n}=t,r=e._(n),i=e.$(t.locale,`short`),a=e.$(t.locale,`long`),o=e.p(`month`,``,{name:n.chooseMonth,controls:e.g(t.instanceId,`month-menu`),shortcut:r.chooseMonth}),s=e.p(`year`,``,{name:n.chooseYear,controls:e.g(t.instanceId,`year-menu`),shortcut:r.chooseYear}),c=e.F(`div`,`dp-ui__header dp-ui__header--docked`),l=Gt(`month`,[e.f(`prev-month`,n.previousMonth,e.v.keyboardArrowLeft,r.previousMonth),o.button,e.f(`next-month`,n.nextMonth,e.v.keyboardArrowRight,r.nextMonth)]);l.hidden=t.groups!==`both`,c.hidden=t.groups===`none`,c.append(l,Gt(`year`,[e.f(`prev-year`,n.previousYear,e.v.keyboardArrowLeft,r.previousYear),s.button,e.f(`next-year`,n.nextYear,e.v.keyboardArrowRight,r.nextYear)]));let u=n=>{o.setText(i[n.month-1]??``,a[n.month-1]??``),s.setText(e.J(n.year,t.locale))},d=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),d(t.home),{element:c,setView:u,setPanel:d}},qt=`dp-ui__headline--fading-out`,Jt=(t,n)=>{let r=e.F(`div`,`dp-ui__headline`);r.textContent=t;let i=null,a=null,o=()=>{a!==null&&clearTimeout(a),a=null,i=null,r.classList.remove(qt)},s=()=>{let e=i;o(),e!==null&&(r.textContent=e)};return{element:r,setText:t=>{t!==(i??r.textContent)&&(n?(i=t,r.classList.add(qt),a??=setTimeout(s,e.O.HEADLINE_FADE)):(o(),r.textContent=t))},destroy:o}},Yt=t=>{let{labels:n,switchView:r}=t,i=e.F(`div`,`dp-ui__header dp-ui__header--modal`),a=e.F(`div`,`dp-ui__supporting-text`);a.textContent=t.title;let o=Jt(t.text,t.animate);i.append(a,o.element);let s=r===null?null:e.m(n,r.panelId);return s!==null&&i.append(s.button),{element:i,setText:e=>{o.setText(e)},setInputView:e=>{s?.setInputView(e)},destroy:()=>{o.destroy()}}},Xt=(t,n,r,i,a)=>{if(a)return Wt({locale:n,labels:r,view:t,arrowsOnly:!1}).element;let o=e._(r),s=e.F(`div`,`dp-ui__navigation`);return s.append(e.p(`year-grid`,e.q(t,n),{name:r.chooseYear,controls:e.g(i,`year-grid`),shortcut:o.chooseYear}).button,e.f(`prev-month`,r.previousMonth,e.v.keyboardArrowLeft,o.previousMonth),e.f(`next-month`,r.nextMonth,e.v.keyboardArrowRight,o.nextMonth)),s},Zt=(t,n,r,i)=>{let a=e.F(`div`,`dp-ui__navigation dp-ui__navigation--month-grid`),o=e._(r);return a.append(e.p(`year-grid`,e.J(t.year,n),{name:r.chooseYear,controls:e.g(i,`year-grid`),shortcut:o.chooseYear}).button,e.f(`prev-year`,r.previousYear,e.v.keyboardArrowLeft,o.previousYear),e.f(`next-year`,r.nextYear,e.v.keyboardArrowRight,o.nextYear)),a},Qt=(t,n,r,i)=>{let a=e.F(`div`,`dp-ui__navigation dp-ui__navigation--year-grid`),{button:o}=e.p(`year-grid`,e.q(t,n),{name:r.chooseYear,controls:e.g(i,`year-grid`)});return o.setAttribute(`aria-expanded`,`true`),a.append(o),a},$t=n=>{let{decorateDate:r}=n.options;return r===null?()=>null:n=>{try{return r(e.zt(n))??null}catch(e){return t(e),null}}},en=t=>{let{renderDate:n}=t.options;return n===null?()=>null:t=>n(e.zt(t))},tn=(t,n,r)=>{let{options:i}=t;return{locale:i.locale,weekStart:i.weekStart,weekNumbers:i.weekNumbers,showOutside:r,outsideSelectable:i.outsideDays!==!1&&i.outsideDays.selectable,labels:{weekNumber:i.labels.weekNumber},rangeLabels:{start:i.labels.rangeStart,end:i.labels.rangeEnd,inRange:i.labels.inRange},headingVisible:!1,weekdaysVisible:!0,multiselectable:t.draft.mode!==`single`,rangeRole:()=>null,labelRole:()=>null,decorate:$t(t),content:en(t),isSelected:n=>e.ft(t.draft,n),isDisabled:e=>!n.isSelectable(e,t.followsActiveEnd?Je(t.draft,t.activeEnd):t.draft),today:e.Ht(),focus:t.focus}},nn=(e,t,n)=>{let r=e.layout.months>1,i=n===`docked`&&!r&&e.options.outsideDays!==!1,a=tn(e,t,i);return r?{...a,headingVisible:!0}:a},rn=(t,n)=>e.K(n,e.kt(n,t.layout.months-1),t.options.locale),B=e=>kt(e.draft,e.panel===`input`?`input`:`calendar`,e.options.locale,e.options.labels,e.options.precision),an={element:null,docked:null,modal:null,caption:null},on={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},sn=e=>{switch(e){case`day`:return`both`;case`month`:return`year`;case`year`:return`none`}},cn=e=>on[e],V=(t,n)=>t.options.precision===`day`&&e.xt(n,t.options.inline).navigation===`caption`,ln=(t,n,r)=>{let{locale:i,labels:a,animation:o,viewSwitch:s,mode:c,precision:l}=t.options;if(n===`modal`){if(!e.xt(r,t.options.inline).headline)return an;let n=s&&e.Dt(c,t.calendarLayout,l),i=Yt({labels:a,title:Ct(a,c,l),animate:o,text:B(t),switchView:n?{panelId:e.g(t.instanceId,`input`)}:null});return i.setInputView(t.panel===`input`),{element:i.element,docked:null,modal:i,caption:null}}if(V(t,r)){let e=Wt({locale:i,labels:a,view:t.view,arrowsOnly:t.layout.months>1});return{element:e.element,docked:null,modal:null,caption:e}}let u=Kt({instanceId:t.instanceId,locale:i,labels:a,view:t.view,groups:sn(l),home:e.bt(l)});return{element:u.element,docked:u,modal:null,caption:null}},un=(t,n)=>{let r=e.kt(t,n);return{year:r.year,month:r.month,day:Math.min(t.day,e.Pt(r))}},dn=(t,n,r,i)=>{let a=n?12:1;switch(t){case`ArrowLeft`:return e.Ot(r,i?1:-1);case`ArrowRight`:return e.Ot(r,i?-1:1);case`ArrowUp`:return e.Ot(r,-7);case`ArrowDown`:return e.Ot(r,7);case`Home`:return{year:r.year,month:r.month,day:1};case`End`:return{...r,day:e.Pt(r)};case`PageUp`:return un(r,-a);case`PageDown`:return un(r,a);default:return null}},fn=e=>e.ctrlKey||e.altKey||e.metaKey,pn=(e,t)=>{let n=e.toLowerCase();return t===`modal`?n===`y`?`year-grid`:null:n===`m`?`month-menu`:n===`y`?`year-menu`:null},mn=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`},hn=(e,t)=>{let{panel:n}=t.core;n!==t.home&&n!==`input`&&(e.preventDefault(),e.stopPropagation(),t.actions.showPanel(t.home))},gn=(e,t)=>{if(!e.shiftKey||!mn(t))return!1;let n=pn(e.key,t.layout);return n!==null&&(e.preventDefault(),t.actions.showPanel(n),!0)},_n=(t,n,r)=>{t.preventDefault(),t.key===`Enter`&&r.layout===`modal`&&r.core.options.mode===`single`&&e.Tt(r.core.options.footerExplicit,r.core.mode)&&e.ft(r.core.draft,n.date)?r.actions.confirm():r.actions.select(n.date)},vn=(e,t,n)=>{if(e.key===`Enter`||e.key===` `){_n(e,t,n);return}let r=dn(e.key,e.shiftKey,t.date,n.isRtl());r!==null&&(e.preventDefault(),n.actions.focusDate(r))},yn=(e,t,n)=>{e.addEventListener(`keydown`,e=>{if(e.defaultPrevented)return;if(e.key===`Escape`){hn(e,n);return}if(fn(e)||gn(e,n))return;let t=n.cellAt(e.target);t!==null&&vn(e,t,n)},{signal:t})},H=`dp-ui__ghost`,bn=e=>Array.from(e.querySelectorAll(`*`)).filter(e=>e.closest(`.${H}`)===null),xn=(e,t,n)=>{e.querySelectorAll(`.${H}`).forEach(e=>{e.remove()}),e.removeAttribute(`popover`),e.removeAttribute(`style`),e.classList.remove(`dp-ui__container--morphing`),e.classList.add(H),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`)},Sn=(e,t)=>{let n=Array.from(t.querySelectorAll(`*`));return bn(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}]})},Cn=({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`))})},wn=(t,n,r)=>{let i=t.cloneNode(!0);if(!(i instanceof HTMLElement))return null;xn(i,n,r);let a=Sn(t,i);a.forEach(Cn);let o=null,s=()=>{if(o!==null){let e=o;o=null,e.cancel()}i.remove()};return{show:()=>{t.append(i),a.forEach(({copy:e,top:t,left:n})=>{e.scrollTop=t,e.scrollLeft=n}),typeof i.animate==`function`?(o=i.animate([{opacity:1},{opacity:0}],{duration:e.O.VIEW_SWITCH_FADE_OUT,easing:`linear`,fill:`forwards`}),o.finished.then(s,s)):s()},remove:s}},Tn=`dp-ui__container--morphing`,U=/* @__PURE__ */ new WeakMap,En=e=>{let t=e.getBoundingClientRect();return{width:t.width,height:t.height,radius:getComputedStyle(e).borderRadius}},Dn=(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}},On=e=>({width:`${String(e.width)}px`,height:`${String(e.height)}px`,borderRadius:e.radius}),kn=(t,n,r)=>{if(r.height===0)return;let i=getComputedStyle(t).direction===`rtl`,a=(n.x-r.x)*(i?-1:1),o=n.y-r.y,s=n.height/r.height;if(a===0&&o===0&&s===1)return;let c=i?`top right`:`top left`;t.animate([{transform:`translate(${String(a)}px, ${String(o)}px) scale(${String(s)})`,transformOrigin:c},{transform:`none`,transformOrigin:c}],{duration:e.O.VIEW_SWITCH,easing:e.E.EMPHASIZED})},An=(t,n,r)=>{if(r===`none`||typeof t.animate!=`function`)return n(),null;if(r===`reduced`){let e=En(t),r=wn(t,e.width,e.height);return n(),r?.show(),null}let i=t.querySelector(`.dp-ui__headline`),a=En(t),o=Dn(t,i),s=wn(t,a.width,a.height);n();let c=En(t),l=Dn(t,i);t.classList.add(Tn);let u=t.animate([On(a),On(c)],{duration:e.O.VIEW_SWITCH,easing:e.E.EMPHASIZED});U.set(t,u),s?.show(),i!==null&&o!==null&&l!==null&&kn(i,o,l);let d=()=>{s?.remove(),U.get(t)===u&&(U.delete(t),t.classList.remove(Tn))};return u.finished.then(d,d),u};function jn(t){let n=t.describedById??`${t.id}-supporting`,r=e.F(`div`,`dp-ui__text-field`),i=e.F(`input`,`dp-ui__text-field-input`,{id:t.id,type:`text`,inputmode:`numeric`,autocomplete:`off`,placeholder:t.placeholder,tabindex:`0`,"aria-invalid":`false`,"aria-describedby":n});i.value=t.value;let a=e.F(`label`,`dp-ui__text-field-label`,{for:t.id});a.textContent=t.label;let o=e.F(`div`,`dp-ui__text-field-supporting`,{id:n,"aria-live":`polite`});return o.textContent=t.hint,r.append(i,a,o),{element:r,input:i,getValue:()=>i.value,setValue:e=>{i.value=e},setError:e=>{let n=e!==null;r.classList.toggle(`dp-ui__text-field--error`,n),i.setAttribute(`aria-invalid`,n?`true`:`false`);let a=e??t.hint;o.textContent!==a&&(o.textContent=a)}}}function Mn(e){return e.mode===`single`?e.date:null}function Nn(e){return e.mode===`single`?e.date===null:e.mode===`range`?e.start===null:e.dates.length===0}function Pn(t){let{instanceId:n,draft:r,pattern:i,labels:a,rules:o}=t,s=e.F(`div`,`dp-ui__input-panel`,{"data-panel":`input`,id:e.g(n,`input`)}),c=e.at(i,e.ot(a)),l=(t,r,a)=>jn({id:`${n}-input-${t}`,label:r,placeholder:c,hint:c,value:a?e.it(a,i):``}),u=r.mode===`range`,d=l(u?`start`:`date`,u?a.startDateField:a.dateField,r.mode===`range`?r.start:Mn(r)),f=u?l(`end`,a.endDateField,r.end):null,p=f?[d,f]:[d],m=n=>{let r=n.getValue().trim();if(r===``)return n.setError(null),{date:null,failed:!1};let s=e.W(r,i);if(s===null)return n.setError(a.invalidDate),{date:null,failed:!0};let c=o.unavailableReason(s);return c===null?(n.setError(null),n.setValue(e.it(s,i)),{date:s,failed:!1}):(n.setError(t.messageFor(c)),{date:null,failed:!0})},h=()=>{let t=m(d);if(!f)return t.failed?null:{mode:`single`,date:t.date};let n=m(f),r=n.date,i=t.failed||n.failed;return t.date&&r&&e.At(r,t.date)<0&&(f.setError(a.invalidRange),r=null,i=!0),i?null:{mode:`range`,start:t.date,end:r}},g=e=>{let n=P(e,t.limits,e=>o.unavailableReason(e));return n===null||((f??d).setError(t.messageFor(n)),!1)};return p.forEach(n=>{n.input.addEventListener(`input`,()=>{e.d(n.input,i)}),n.input.addEventListener(`change`,()=>{let e=h();e&&g(e)&&t.onDraft(e)}),n.input.addEventListener(`keydown`,n=>{if(n.key!==`Enter`)return;n.preventDefault();let r=h();r&&g(r)&&e.dt(r)&&!Nn(r)&&(t.onDraft(r),t.onSubmit())})}),s.append(...p.map(e=>e.element)),s}function Fn(t,n){let{labels:r,minDate:i,maxDate:a,pattern:o,precision:s}=n;return t===`min`&&i!==null?r.beforeMinDate.replace(`{date}`,e.R(i,o,s)):t===`max`&&a!==null?r.afterMaxDate.replace(`{date}`,e.R(a,o,s)):t===`range-length`?r.invalidRange:r.unavailableDate}const In=t=>{let{core:n,actions:r,rules:i}=t,{pattern:a,labels:o,limits:s}=n.options;return[Pn({instanceId:n.instanceId,draft:n.draft,pattern:a,labels:o,rules:i,limits:s,messageFor:e=>Fn(e,n.options),onDraft:e=>{r.typeDraft(e)},onSubmit:()=>{e.Tt(n.options.footerExplicit,n.mode)?r.confirm():r.submitDraft()}})]},Ln=`dp-ui__date`,Rn=`dp-ui__date--outside-month`,zn=`data-decoration-label`,W=`data-content-label`,Bn=`dp-ui__date-content`,Vn=`dp-ui__date--has-content`,Hn=`:scope > .${Bn}`,Un=(e,t,n)=>n.isDisabled(e)||t&&!n.outsideSelectable,Wn=(t,n,r,i)=>[[`dp-ui__date--selected`,i.isSelected(t)],[`dp-ui__date--range-start`,r===`start`],[`dp-ui__date--range-end`,r===`end`],[`dp-ui__date--in-range`,r===`in-range`],[`dp-ui__date--today`,e.It(t,i.today)],[`dp-ui__date--disabled`,Un(t,n,i)],[Rn,n]],Gn=e=>{e.querySelector(Hn)?.remove(),e.classList.remove(Vn),e.removeAttribute(W)},Kn=(t,n,r)=>{let i=r.content(n);if(i===null){Gn(t);return}let a=t.querySelector(Hn),o=(typeof i==`string`?i:i.textContent??``).trim();if(typeof i!=`string`||a===null||a.childElementCount!==0||a.textContent!==i){let n=e.F(`span`,Bn);typeof i==`string`?n.textContent=i:n.appendChild(i),a===null?t.querySelector(`.dp-ui__date-indicator`)?.after(n):a.replaceWith(n)}t.classList.add(Vn),o===``?t.removeAttribute(W):t.setAttribute(W,o)},qn=(e,t)=>e===`start`?t.rangeLabels.start:e===`end`?t.rangeLabels.end:e===`in-range`?t.rangeLabels.inRange:null,Jn=(t,n,r,i,a)=>[e.G(t,a.locale),qn(n,a),r,i].filter(e=>e!==null&&e!==``).join(`, `),Yn=(t,n,r,i)=>{let a=i.rangeRole(n);Kn(t,n,i),Wn(n,r,a,i).forEach(([e,n])=>t.classList.toggle(e,n)),t.setAttribute(`aria-selected`,String(i.isSelected(n)||a!==null)),t.setAttribute(`aria-label`,Jn(n,i.labelRole(n),t.getAttribute(zn),t.getAttribute(W),i)),e.It(n,i.today)?t.setAttribute(`aria-current`,`date`):t.removeAttribute(`aria-current`),Un(n,r,i)?t.setAttribute(`aria-disabled`,`true`):t.removeAttribute(`aria-disabled`);let o=!r&&e.It(n,i.focus);t.setAttribute(`tabindex`,o?`0`:`-1`)},Xn=(t,n)=>{if(n===null)return;let r=(n.className??``).split(/\s+/).filter(Boolean);t.classList.add(...r),n.label&&t.setAttribute(zn,n.label),n.badge===!0&&t.appendChild(e.F(`span`,`dp-ui__date-badge`,{"aria-hidden":`true`}))},Zn=(t,n)=>{if(!t.inMonth&&!n.showOutside)return e.F(`td`,`${Ln} dp-ui__date--empty`);let r=e.F(`td`,Ln,{role:`gridcell`,"data-date":e.Bt(t.date)}),i=e.F(`span`,`dp-ui__date-indicator`);return i.textContent=e.J(t.date.day,n.locale),r.appendChild(i),Xn(r,n.decorate(t.date)),Yn(r,t.date,!t.inMonth,n),r},Qn=`dp-ui__visually-hidden`,$n=t=>{let n=e.F(`thead`),r=e.F(`tr`,t.weekdaysVisible?`dp-ui__weekdays`:`dp-ui__weekdays ${Qn}`);if(t.weekNumbers){let n=e.F(`th`,`dp-ui__week-number-header`,{scope:`col`});n.textContent=t.labels.weekNumber,r.appendChild(n)}let i=e.nt(t.locale,`narrow`),a=e.nt(t.locale,`long`);for(let n=0;n<7;n++){let o=(t.weekStart+n)%7,s=a[o]??``,c=e.F(`th`,`dp-ui__weekday`,{role:`columnheader`,scope:`col`,abbr:s,title:s});c.textContent=i[o]??``,r.appendChild(c)}return n.appendChild(r),n},er=(t,n)=>{let r=e.F(`table`,`dp-ui__month-grid`,{role:`grid`});n.multiselectable===!0&&r.setAttribute(`aria-multiselectable`,`true`);let i=e.F(`caption`,n.headingVisible?`dp-ui__month-subhead`:`dp-ui__month-heading ${Qn}`);i.textContent=e.q(t.view,n.locale),r.appendChild(i),r.appendChild($n(n));let a=e.F(`tbody`);return t.weeks.forEach((r,i)=>{let o=e.F(`tr`,`dp-ui__week`);if(n.weekNumbers){let r=e.F(`th`,`dp-ui__week-number`,{scope:`row`}),a=t.weekNumbers.at(i);r.textContent=a===void 0?``:e.J(a,n.locale),o.appendChild(r)}r.forEach(e=>o.appendChild(Zn(e,n))),a.appendChild(o)}),r.appendChild(a),r},tr=(t,n)=>{t.querySelectorAll(`td[data-date]`).forEach(t=>{let r=e.Ft(t.dataset.date??``);r!==null&&Yn(t,r,t.classList.contains(Rn),n)})},nr=(t,n,r)=>{let i={year:t.year,month:t.month,day:1},a=(e.Mt(i)-n+7)%7,o=r?6:Math.ceil((a+e.Pt(t))/7),s=e.Ot(i,-a),c=(4-n+7)%7,l=[],u=[];for(let n=0;n<o;n++){let r=e.Ot(s,n*7),i=[];for(let n=0;n<7;n++){let a=e.Ot(r,n);i.push({date:a,inMonth:a.year===t.year&&a.month===t.month})}l.push(i),u.push(e.Lt(e.Ot(r,c)))}return{view:t,weeks:l,weekNumbers:u}},rr=`table.dp-ui__month-grid`,ir=(e,t)=>{e.style.setProperty(`transition`,`none`),t(),e.getBoundingClientRect(),e.style.removeProperty(`transition`)},ar=t=>{let{core:n,layout:r,surface:i,gridContext:a}=t,{months:o}=n.layout,{outsideSelectable:s,headingVisible:c}=a(),l=i===`inline`,{fixedWeeks:u}=gt({layout:r===`modal`?`modal`:`docked`,inline:l,months:o,outsideDays:n.options.outsideDays!==!1,fixedWeeks:n.options.fixedWeeks}),d=r===`docked`||l,f=i!==void 0&&V(n,i),p=e.F(`div`,void 0,{"data-panel":`days`}),m=e=>p.querySelector(`.dp-ui__page:not([inert])`)?.querySelector(e)??null,h=e=>nr(e,n.options.weekStart,u),g=t=>Array.from({length:o},(n,r)=>e.kt(t,r)),_=t=>{let n=a();if(o===1)return er(h(t),n);let r=e.F(`div`,`dp-ui__months`);return r.append(...g(t).map(e=>er(h(e),n))),r},v=t=>{let i=e.F(`div`);if(r===`modal`){let{locale:e,labels:r}=n.options;i.append(Xt(t,e,r,n.instanceId,f))}return i.append(_(t)),i},y=e=>Math.max(...g(e).map(e=>h(e).weeks.length)),b=e=>{let t=y(e),n=m(`.dp-ui__navigation`)?.getBoundingClientRect().height??0,r=p.querySelector(rr),i=r?.tHead?.getBoundingClientRect().height??0,a=(r?.tBodies.item(0)?.rows.item(0))?.getBoundingClientRect().height??0,o=c?r?.caption?.getBoundingClientRect().height??0:0;return i>0&&a>0?n+o+i+a*t:n+(t+(c?2:1))*48},x=n.options.pageBy===`view`?o:1,S=new e.o(p,{rtl:t.rtl,swipe:n.options.swipe,animate:n.options.animation,fitHeight:d,step:(t,n)=>e.kt(t,n*x),isSame:e.s,renderPage:v,pageHeight:b,onCommit:(e,n)=>{t.onCommit(e,n)}}),C=()=>p.ownerDocument.activeElement,w=t=>{if(!(t instanceof Element))return null;let n=t.closest(`td.dp-ui__date[data-date]`);if(n===null||!p.contains(n)||n.classList.contains(`dp-ui__date--outside-month`)&&!s)return null;let r=e.Ft(n.getAttribute(`data-date`)??``);return r===null?null:{element:n,date:r}},T=()=>w(C())!==null,E=e=>{let t=m(`td.dp-ui__date[tabindex="0"]`);return t!==null||!e?t:m(`td.dp-ui__date[data-date]:not(.dp-ui__date--outside-month)`)},D=e=>{E(e)?.focus({preventScroll:!0})},O=()=>{let e=C();return e===null||!p.contains(e)?null:{buttonClass:Rt(e)}},k=e=>{let{buttonClass:t}=e;((t===null?null:m(`.${t}`))??E(!0))?.focus({preventScroll:!0})},A=e=>{let t=O();e(),t!==null&&k(t)};return{element:p,present:(e,t)=>{A(()=>{t===0?S.show(e):S.slide(e,t>0?1:-1)})},finish:()=>{S.finish()},refresh:()=>{let e=a();p.querySelectorAll(rr).forEach(t=>{tr(t,e)})},refit:()=>{if(!d||p.hidden)return;let e=`${String(b(n.view))}px`;p.style.getPropertyValue(`--dp-ui-pager-height`)!==e&&A(()=>{ir(p,()=>{S.show(n.view)})})},cellAt:w,focusCell:D,cellHasFocus:T,find:m,destroy:()=>{S.destroy()}}},or=t=>{let n=document.createElement(`div`);n.className=t.className,n.setAttribute(`role`,`listbox`),n.setAttribute(`aria-label`,t.label);let r=[],i=t.focused>=0&&t.focused<t.items.length?t.focused:0,a=(t,i)=>{let a=r.at(Math.max(0,Math.min(r.length-1,i)));a&&(r.at(t)?.setAttribute(`tabindex`,`-1`),a.setAttribute(`tabindex`,`0`),a.focus({preventScroll:!0}),e.L(n,a,`nearest`))},o=e=>{let t=getComputedStyle(n).direction===`rtl`?-1:1;switch(e){case`ArrowRight`:return t;case`ArrowLeft`:return-t;case`ArrowDown`:return 3;case`ArrowUp`:return-3;default:return null}};return t.items.forEach((e,s)=>{let c=document.createElement(`button`);c.type=`button`,c.className=t.itemClass,c.setAttribute(`role`,`option`),c.setAttribute(`aria-selected`,e.selected?`true`:`false`),c.setAttribute(`aria-label`,e.name),c.setAttribute(`tabindex`,s===i?`0`:`-1`),e.selected&&c.classList.add(`${t.itemClass}--selected`),e.current&&c.classList.add(`${t.itemClass}--current`),e.disabled&&c.setAttribute(`aria-disabled`,`true`),c.textContent=e.label;let l=()=>{e.disabled||e.onPick()};c.addEventListener(`click`,l),c.addEventListener(`keydown`,e=>{let t=o(e.key);t===null?e.key===`Home`?(e.preventDefault(),a(s,0)):e.key===`End`?(e.preventDefault(),a(s,r.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),l()):(e.preventDefault(),a(s,s+t))}),r.push(c),n.appendChild(c)}),requestAnimationFrame(()=>{let a=n.querySelector(`.${t.itemClass}--selected`)??r.at(i);a&&e.L(n,a,`center`)}),n},sr=t=>{let n=e.$(t.locale,`short`),r=e.$(t.locale,`long`),i=e.J(t.year,t.locale);return or({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)}}})})},cr=t=>{let n=t.querySelector(`.dp-ui__menu-item--selected`);n&&e.L(t,n,`center`)},G=(t,n,r)=>{let i=t.at(Math.max(0,Math.min(t.length-1,r))),a=t.at(n);i&&(a?.setAttribute(`tabindex`,`-1`),i.setAttribute(`tabindex`,`0`),i.focus({preventScroll:!0}),i.parentElement&&e.L(i.parentElement,i,`nearest`))},lr=(t,n,r)=>{let i=document.createElement(`ul`);i.className=`dp-ui__menu dp-ui__menu--${t}`,i.setAttribute(`role`,`listbox`),i.setAttribute(`aria-label`,n);let a=r.some(e=>e.selected),o=r.map((t,n)=>{let r=document.createElement(`li`);r.className=`dp-ui__menu-item`,r.setAttribute(`role`,`option`),r.setAttribute(`aria-selected`,t.selected?`true`:`false`);let i=t.selected||!a&&n===0;if(r.setAttribute(`tabindex`,i?`0`:`-1`),t.selected){r.classList.add(`dp-ui__menu-item--selected`);let t=document.createElement(`span`);t.innerHTML=e.v.check;let n=t.firstElementChild;n&&(n.setAttribute(`class`,`dp-ui__menu-item-icon`),n.setAttribute(`aria-hidden`,`true`),r.appendChild(n))}t.disabled&&r.setAttribute(`aria-disabled`,`true`);let o=document.createElement(`span`);o.className=`dp-ui__menu-item-label`,o.textContent=t.label,r.appendChild(o);let c=()=>{t.disabled||t.onPick()};return r.addEventListener(`click`,c),r.addEventListener(`keydown`,e=>{e.key===`ArrowDown`?(e.preventDefault(),G(s,n,n+1)):e.key===`ArrowUp`?(e.preventDefault(),G(s,n,n-1)):e.key===`Home`?(e.preventDefault(),G(s,n,0)):e.key===`End`?(e.preventDefault(),G(s,n,s.length-1)):(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())}),r}),s=o;return o.forEach(e=>i.appendChild(e)),requestAnimationFrame(()=>{cr(i)}),i},ur=t=>{let n=e.$(t.locale,`long`);return lr(`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)}}}))},dr=t=>or({className:`dp-ui__year-selection`,itemClass:`dp-ui__year-selection-item`,label:t.label,focused:t.years.indexOf(t.focused),items:t.years.map(n=>{let r=e.J(n,t.locale);return{label:r,name:r,selected:n===t.selected,current:n===t.currentYear,disabled:!1,onPick:()=>{t.onPick(n)}}})}),fr=t=>lr(`year`,t.label,t.years.map(n=>({label:e.J(n,t.locale),selected:n===t.view.year,disabled:!1,onPick:()=>{t.onPick(n)}}))),pr=e=>{let{min:t,max:n}=e.yearBounds(),r=[];for(let e=t;e<=n;e++)r.push(e);return r},mr=(t,n)=>{let r=e.lt(t.draft);return r?.year===n?r.month:null},K=(t,n,r)=>(t.setAttribute(`data-panel`,n),t.id=e.g(r,n),t),hr=(t,n)=>{let{core:r,rules:i}=n,{labels:a,locale:o}=r.options,s=r.view,{precision:c}=r.options,l=e=>{n.actions.jumpTo(e,`menu`)},u=e=>{l({year:e,month:r.view.month})};switch(t){case`month-menu`:return[K(ur({locale:o,view:s,label:a.chooseMonth,isMonthDisabled:e=>i.isMonthDisabled(e),onPick:e=>{l({year:r.view.year,month:e})}}),t,r.instanceId)];case`year-menu`:return[K(fr({view:s,years:pr(i),label:a.chooseYear,locale:o,onPick:u}),t,r.instanceId)];case`month-grid`:{let u=c===`month`,d=u?mr(r,s.year):s.month,f=K(sr({year:s.year,selected:d,focused:d??s.month,current:e.Ht(),locale:o,label:a.chooseMonth,isDisabled:e=>i.isMonthDisabled({year:r.view.year,month:e}),onPick:e=>{u?n.actions.select({year:r.view.year,month:e,day:1}):l({year:r.view.year,month:e})}}),t,r.instanceId);return n.layout===`docked`?[f]:[Zt(s,o,a,r.instanceId),f]}case`year-grid`:{let l=c===`year`,d=l?e.lt(r.draft)?.year??null:s.year,f=K(dr({selected:d,focused:d??s.year,years:pr(i),currentYear:e.Ht().year,label:a.chooseYear,locale:o,onPick:l?e=>{n.actions.select({year:e,month:1,day:1})}:u}),t,r.instanceId);return n.layout===`docked`||l?[f]:[Qt(s,o,a,r.instanceId),f]}}},gr=`[role="option"]`,_r=`data-rebuilt`,vr=t=>{let{root:n,content:r,days:i}=t,a=`days`,o=[],s=null,c=()=>n.ownerDocument.activeElement,l=e=>{e===`days`?i.hidden=!0:(o.forEach(e=>{e.remove()}),o=[])},u=e=>{e===`days`?(i.hidden=!1,i.removeAttribute(_r)):(o=t.createParts(e),i.after(...o))},d=()=>{let e=s;e!==null&&(s=null,e.complete(),e.animations.forEach(e=>{e.cancel()}))},f=()=>{let e=s;s=null,e?.animations.forEach(e=>{e.cancel()})},p=(e,n,r)=>{let i=t.motion()===`none`?[]:e.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`})),o={animations:a,complete:r};s=o,Promise.all(a.map(e=>e.finished)).then(()=>{s===o&&d()},()=>void 0)},m=()=>{let e=i.getBoundingClientRect().height;e>0&&r.style.setProperty(`--dp-ui-panel-height`,`${String(e)}px`)},h=r=>{d();let s=a;if(r===s)return;s===`days`&&m();let f=n.contains(c()),h=r===`input`||s===`input`;a=r;let g=()=>{let e=()=>{l(s),u(r),t.onSwitched(r,s,f)};t.swap===void 0?e():t.swap(e,r,s)};h?g():p(s===`days`?[i]:o,e.O.PANEL_FADE_OUT,g)},g=(e,t)=>{f(),e!==a&&(l(a),a=e,u(e),t?.rebuilt===!0&&o.forEach(e=>{e.setAttribute(_r,``)}))},_=e=>{let t=e.closest(`[role="listbox"]`);return t===null?-1:Array.from(t.querySelectorAll(gr)).indexOf(e)},v=e=>{for(let t of o){let n=e(t);if(n)return n}return null},y=(e,t)=>t>=0?v(e=>Array.from(e.querySelectorAll(gr)).at(t)):e===null?null:v(t=>t.querySelector(`.${e}`));return{current:()=>a,settled:()=>s===null,mount:g,switchTo:h,rebuild:()=>{if(a===`days`||a===`input`||s!==null)return;let e=c(),t=e!==null&&o.some(t=>t.contains(e))?e:null,n=t===null?null:Rt(t),r=t===null?-1:_(t),i=o.map(e=>e.scrollTop);l(a),u(a),o.forEach(e=>{e.setAttribute(_r,``)}),requestAnimationFrame(()=>{o.forEach((e,t)=>{e.scrollTop=i.at(t)??e.scrollTop})}),t!==null&&y(n,r)?.focus({preventScroll:!0})},entry:()=>{for(let e of o){let t=e.querySelector(`[tabindex="0"]`);if(t!==null)return t}return null},destroy:f}},yr=t=>{let{root:n,core:r,actions:i,rules:a,mode:o,layout:s}=t,c=r.options,l=ln(r,s,o),u=ar({core:r,layout:s,surface:o,rtl:t.rtl,gridContext:()=>nn(r,a,s),onCommit:(e,t)=>{i.page(e,t)}}),d=e.F(`div`,`dp-ui__content`);d.append(u.element);let f=vr({root:n,content:d,days:u.element,motion:t.motion,createParts:e=>e===`input`?In({core:r,actions:i,rules:a}):hr(e,{core:r,actions:i,rules:a,layout:s}),swap:(e,i,a)=>{let o=L(n);o===null||i!==`input`&&a!==`input`?e():An(o,()=>{e(),z(o,i,r.layout.months)},t.motion())},onSwitched:t.onSwitched}),p=Ft({labels:c.labels,visible:e.Tt(c.footerExplicit,o),todayButton:c.todayButton,clearButton:c.clearButton!==!1}),m=e.F(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`});return n.replaceChildren(...l.element===null?[]:[l.element],d,p,m),{header:l,pages:u,panels:f,liveRegion:m}},br=[`drag`,`wheel`,`button`,`keyboard`,`menu`],xr=e=>br.includes(e),Sr=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t===`modal`)},Cr=t=>{let{core:n,actions:r,rules:i,mode:a}=t,o=n.calendarLayout===`docked`?`docked`:`modal`,s=new AbortController,c=e.F(`div`,`dp-ui__calendar`),l,u=0,d=()=>c.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(n.input).direction===`rtl`,f=()=>L(c),p=()=>e.bt(n.options.precision),m=e=>l.pages.cellAt(e),h=(e,t=!0)=>{l.header.docked?.setPanel(e);let r=f();r!==null&&(r.classList.toggle(Vt,Ut(e,p())),t&&z(r,e,n.layout.months))},g=e=>{e===null?l.pages.focusCell(!0):e.focus({preventScroll:!0})},_=e=>{let t=cn(e);return t===null?null:l.header.element?.querySelector(t)??l.pages.find(t)},v=(e,t,n)=>{e===`days`&&l.pages.refit(),n&&g(e===`days`?t===`input`?null:_(t):l.panels.entry())},y=(t=!1)=>{Sr(c,o),l=yr({root:c,core:n,actions:r,rules:i,mode:a,layout:o,rtl:d(),motion:()=>e.M(n.options.animation),onSwitched:v}),l.pages.present(n.view,0),l.panels.mount(n.panel,{rebuilt:t}),t&&l.pages.element.setAttribute(`data-rebuilt`,``),h(n.panel),l.header.modal?.setInputView(n.panel===`input`),Pt(c,e.dt(n.draft)),cancelAnimationFrame(u),u=requestAnimationFrame(()=>{u=0,h(l.panels.current()),l.pages.refit()})},b=()=>{l.panels.destroy(),l.pages.destroy(),l.header.modal?.destroy()},x=()=>{s.signal.aborted||(h(l.panels.current()),l.pages.refit())},S=()=>{s.signal.aborted||(x(),g(l.panels.entry()))},C=(t,r,i)=>{l.header.docked?.setView(t),l.header.caption?.setView(t);let a=xr(i),o=a&&l.panels.current()===`days`&&l.panels.settled();l.pages.present(t,o?r:0),l.panels.rebuild(),a&&e.j(l.liveRegion,rn(n,t))},w=()=>{let e=l.pages.cellHasFocus();l.pages.refresh(),e&&l.pages.focusCell(!1)},T=e=>{l.pages.finish(),h(e,!1),l.header.modal?.setInputView(e===`input`),l.header.modal?.setText(B(n)),l.panels.switchTo(e)},E=()=>{l.pages.refresh(),l.panels.rebuild(),l.header.modal?.setText(B(n)),Pt(c,e.dt(n.draft));let{announceSelection:t}=e.xt(a,n.options.inline);t&&l.panels.current()===p()&&e.j(l.liveRegion,B(n))};return y(),(e=>{let{events:t}=n;t.on(`change:view`,e=>{C(e.view,e.delta,e.source)},e),t.on(`change:draft`,E,e),t.on(`change:focus`,w,e),t.on(`change:panel`,e=>{T(e.panel)},e),Bt(c,e,{actions:r,panel:()=>n.panel,home:p(),cellAt:m}),yn(c,e,{core:n,actions:r,layout:o,home:p(),caption:()=>V(n,a),cellAt:m,isRtl:d}),Nt(c,`.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)})(s.signal),{element:c,focusInitial:S,fit:x,update:()=>{if(s.signal.aborted)return;let e=c.contains(c.ownerDocument.activeElement);b(),y(!0),e&&S()},destroy:()=>{if(s.signal.aborted)return;s.abort(),cancelAnimationFrame(u),b();let e=f();e!==null&&(e.classList.remove(Vt,I),R(e,1)),c.remove()}}},q=e=>({year:e.year,month:e.month}),wr=t=>{let n=e.lt(t.draft);return n===null?t.view:q(n)},Tr=(t,n)=>{let{minDate:r,maxDate:i}=t.options,a=n.yearBounds(),o={year:a.min,month:1},s={year:a.max,month:12},c=r!==null&&e.Rt(o,r)>0,l=i!==null&&e.Rt(i,s)>0;return{first:c?q(r):o,last:l?q(i):s}},J=(t,n)=>e.Rt(n.first,t)<0?n.first:e.Rt(t,n.last)<0?n.last:t,Er=t=>{let n=e.F(`div`,`dp-ui__top-bar`);return n.append(e.f(`close`,t.close,e.v.close),e.h(`save`,t.save)),n},Dr=t=>{let{labels:n,switchView:r}=t,i=e.F(`div`,`dp-ui__header-text`),a=e.F(`div`,`dp-ui__supporting-text`);a.textContent=n.rangeTitle;let o=Jt(t.text,t.animate);i.append(a,o.element);let s=r===null?null:e.m(n,r.panelId);return{nodes:s===null?[i]:[i,s.button],headline:o,switchButton:s}},Or=t=>{if(t.length===0)return null;let n=e.F(`div`,`dp-ui__header dp-ui__header--range`);return n.append(...t),n},kr=e=>{let t=e.fullscreen?Er(e.labels):null,n=e.headline?Dr(e):null,r=Or([...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()}}},Ar=(t,n)=>{let r=e.F(`div`,`dp-ui__weekdays-bar`,{"aria-hidden":`true`}),i=e.nt(t,`narrow`);for(let t=0;t<7;t++){let a=e.F(`span`,`dp-ui__weekday`);a.textContent=i.at((n+t)%7)??``,r.append(a)}return r},jr=(e,t)=>t===`x`?e.scrollWidth>e.clientWidth:e.scrollHeight>e.clientHeight,Mr=(e,t)=>t===`x`?e.clientX:e.clientY,Nr=(e,t)=>{try{e.setPointerCapture(t)}catch{return}},Pr=(e,t,n)=>{t===`x`?e.scrollLeft+=n:e.scrollTop+=n},Fr=(t,n,r=`x`,i={})=>{let a=null,o=0,s=0,c=0,l=!1;r===`x`&&t.addEventListener(`wheel`,e=>{jr(t,r)&&(Math.abs(e.deltaY)<=Math.abs(e.deltaX)||(e.preventDefault(),t.scrollLeft+=e.deltaY))},{signal:n,passive:!1}),t.addEventListener(`pointerdown`,e=>{e.pointerType===`mouse`&&e.button===0&&jr(t,r)&&(a=e.pointerId,o=Mr(e,r),s=o,c=0,l=!1)},{signal:n}),t.addEventListener(`pointermove`,n=>{if(n.pointerId!==a)return;let i=Mr(n,r);c=i-o,!l&&Math.abs(c)<e.D.DRAG_START_PX||(l||(l=!0,Nr(t,n.pointerId)),Pr(t,r,s-i),s=i)},{signal:n}),t.addEventListener(`selectstart`,e=>{a!==null&&e.preventDefault()},{signal:n});let u=e=>{e.pointerId===a&&(a=null,t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),l&&e.type===`pointerup`&&c!==0&&i.onDragEnd?.(c<0?1:-1))};t.addEventListener(`pointerup`,u,{signal:n}),t.addEventListener(`pointercancel`,u,{signal:n}),t.addEventListener(`click`,e=>{l&&(l=!1,e.stopPropagation(),e.preventDefault())},{signal:n,capture:!0})},Ir=(t,n,r)=>({...tn(t,n,!1),outsideSelectable:!1,weekNumbers:!1,headingVisible:!0,weekdaysVisible:r,rangeRole:n=>e.ht(t.draft,n),labelRole:n=>e.mt(t.draft,n)}),Lr=(e,t,n)=>er(nr(n,e.options.weekStart,!1),Ir(e,t,!1)),Rr=`td.dp-ui__date[data-date]`,zr=t=>{let{core:n,rules:r}=t,i=new AbortController,a=e.F(`div`,`dp-ui__month-list`),o=[],s=null,c=0,l=!1,u=0,d=(n,r)=>Array.from({length:r},(r,i)=>t.render(e.kt(n,i))),f=()=>{s!==null&&t.onRendered(s,e.kt(s,o.length-1))},p=n=>{if(s===null)return;let r=e.kt(s,o.length),i=e.Rt(r,t.bounds().last)+1,c=Math.min(n,i);if(c<=0)return;let l=d(r,c);o.push(...l),a.append(...l),f()},m=n=>{if(s===null)return;let r=e.Rt(t.bounds().first,s),i=Math.min(n,r);if(i<=0)return;let c=e.kt(s,-i),l=d(c,i),u=a.scrollTop,p=a.scrollHeight;s=c,o.unshift(...l),a.prepend(...l),a.scrollTop=u+a.scrollHeight-p,f()},h=n=>{if(s===null)return;let r=J(n,t.bounds());m(e.Rt(r,s)),p(e.Rt(e.kt(s,o.length-1),r))},g=t=>{if(s===null)return null;let n=e.Rt(s,t);return n<0?null:o.at(n)??null},_=e=>{let n=J(e,t.bounds());h(n);let r=g(n);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;a.scrollTop+=i},v=()=>{a.scrollTop<a.clientHeight&&m(6),a.scrollHeight-a.scrollTop-a.clientHeight<a.clientHeight&&p(6)},y=t=>{let n=a.getBoundingClientRect().top,r=o.map(e=>({table:e,top:e.getBoundingClientRect().top-n,height:e.getBoundingClientRect().height})),i=Math.max(r.reduce((e,t,n)=>t.top<=1?n:e,0),0),s=r.at(i);if(s===void 0)return null;let c=s.height>0?Math.max(-s.top,0)/s.height:0,l=r.at(i+1)?.table??s.table;return t===1?c>e.D.COMMIT_FRACTION?l:s.table:c<1-e.D.COMMIT_FRACTION?s.table:l},b=()=>{l&&(window.clearTimeout(u),l=!1,v())},x=t=>{b(),v();let r=y(t);if(r===null)return;let i=r.getBoundingClientRect().top-a.getBoundingClientRect().top;e.M(n.options.animation)===`full`?(l=!0,u=window.setTimeout(b,e.O.SNAP_SCROLL_FALLBACK),a.scrollTo({top:a.scrollTop+i,behavior:`smooth`})):a.scrollTop+=i},S=e=>{if(!(e instanceof Element))return null;let t=e.closest(Rr);return t!==null&&a.contains(t)?t:null},C=t=>{h(q(t));let n=a.querySelector(`${Rr}[data-date="${e.Bt(t)}"]`);n!==null&&(n.focus({preventScroll:!0}),e.L(a,n,`nearest`))},w=()=>{let e=Ir(n,r,!1);o.forEach(t=>{tr(t,e)})},T=t.bounds(),E=J(wr(n),T),D=J(e.kt(E,-2),T),O=J(e.kt(E,9),T),k=e.Rt(D,O)+1;k>0&&(s=D,o.push(...d(D,k)),a.append(...o),f()),a.addEventListener(`scroll`,()=>{c===0&&(c=requestAnimationFrame(()=>{c=0,l||v()}))},{passive:!0,signal:i.signal}),a.addEventListener(`scrollend`,b,{signal:i.signal}),Fr(a,i.signal,`y`,{onDragEnd:x});let A=null;if(typeof ResizeObserver<`u`){let e=0;A=new ResizeObserver(n=>{let r=n.at(-1);if(r===void 0||i.signal.aborted)return;let a=r.contentRect.height,o=e===0;e=a,o&&a>0&&t.onShown()}),A.observe(a)}return{element:a,scrollToMonth:_,refresh:w,cellAt:S,focusCell:C,ensureMonth:h,reveal:_,present:(e,t,n)=>{xr(n)?h(e):_(e)},destroy:()=>{i.abort(),A?.disconnect(),cancelAnimationFrame(c),c=0,window.clearTimeout(u),l=!1}}},Br=t=>{let n=e.F(`div`,`dp-ui__navigation dp-ui__navigation--months`),r=e._(t);return n.append(e.f(`prev-month`,t.previousMonth,e.v.keyboardArrowLeft,r.previousMonth),e.f(`next-month`,t.nextMonth,e.v.keyboardArrowRight,r.nextMonth)),n},Vr=t=>{let{core:n,actions:r,rules:i}=t,a=ar({core:n,layout:`docked`,rtl:t.rtl,gridContext:()=>Ir(n,i,!0),onCommit:(e,t)=>{r.page(e,t)}});return{element:a.element,cellAt:e=>a.cellAt(e)?.element??null,focusCell:t=>{let n=a.find(`td.dp-ui__date[data-date][data-date="${e.Bt(t)}"]`);n===null?a.focusCell(!0):n.focus({preventScroll:!0})},refresh:()=>{a.refresh()},reveal:()=>{a.refit()},present:(e,t,n)=>{a.present(e,n===`api`?0:t)},destroy:()=>{a.destroy()}}};function Hr(e){let n;try{n=e.value()}catch(e){return t(e),null}let r=u(n,`range`,`day`);if(r?.mode!==`range`)return null;let{start:i,end:a}=r;return i===null||a===null?null:{start:i,end:a}}const Ur=t=>{let{core:n,actions:r,rules:i,signal:a,column:o}=t,{presets:s,labels:c,limits:l}=n.options,u=e.F(`div`,o?`dp-ui__presets dp-ui__presets--column`:`dp-ui__presets`,{role:`group`,"aria-label":c.presets}),d=s.map(t=>{let n=e.F(`button`,`dp-ui__preset`,{type:`button`});return n.textContent=t.label,n}),f=d.map(()=>null);u.append(...d);let p=()=>{s.forEach((t,r)=>{let a=d[r],o=Hr(t);f[r]=o;let s=!1,c=!1;if(o!==null){let t={mode:`range`,...o};s=Ge(t,l,e=>i.isDisabled(e)),c=e.gt(n.draft,t)}a.disabled=!s,a.setAttribute(`aria-pressed`,c?`true`:`false`)})};return u.addEventListener(`click`,e=>{if(!(e.target instanceof Element))return;let t=e.target.closest(`button.dp-ui__preset`),n=d.findIndex(e=>e===t);if(n<0)return;let i=f[n];i!==null&&r.selectRange(i.start,i.end)},{signal:a}),Fr(u,a),p(),{element:u,refresh:p,setHidden:e=>{u.hidden=e}}},Wr=`dp-ui__container--range`,Gr=`dp-ui__container--fullscreen`,Kr=`dp-ui__container--presets`,qr=[Wr,Kr,Gr,I],Jr=(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=Vr({core:n,actions:r,rules:i,rtl:a});return t.append(Br(o),e.element),e}let l=zr({core:n,rules:i,render:e=>Lr(n,i,e),bounds:()=>Tr(n,i),onRendered:(e,t)=>{r.renderedMonths(e,t)},onShown:e.reveal});return t.append(Ar(s,c),l.element),l},Yr=t=>{let{root:n,core:r,actions:i,rules:a,mode:o,fullscreen:s,signal:c}=t,l=r.options,u=kr({labels:l.labels,animate:l.animation,text:B(r),fullscreen:s,headline:e.xt(o,l.inline).headline,switchView:l.viewSwitch?{panelId:e.g(r.instanceId,`input`)}:null}),d=e.F(`div`,`dp-ui__range`,{"data-panel":`days`}),f=Jr(t,d),p=vr({root:n,content:n,days:d,motion:t.motion,createParts:e=>e===`input`?In({core:r,actions:i,rules:a}):[],swap:t.swap,onSwitched:t.onSwitched}),m=Ft({labels:l.labels,visible:e.Tt(r.options.footerExplicit,o),todayButton:l.todayButton,clearButton:l.clearButton!==!1}),h=e.F(`div`,`dp-ui__live-region dp-ui__visually-hidden`,{"aria-live":`polite`,"aria-atomic":`true`}),g=r.layout.presets===`column`,_=r.layout.presets===`none`?null:Ur({core:r,actions:i,rules:a,signal:c,column:g});return n.replaceChildren(...u.element===null?[]:[u.element],..._===null?[]:[_.element],d,m,h),{header:u,days:f,panels:p,liveRegion:h,applyChrome:e=>{let t=e===`input`;u.setInputView(t),u.setText(B(r)),_?.setHidden(t);let i=L(n);i!==null&&(i.classList.add(Wr),i.classList.toggle(Kr,g),i.classList.toggle(Gr,s&&!t),z(i,e,r.layout.months))},refreshPresets:()=>{_?.refresh()}}},Xr=(e,t)=>{e.classList.toggle(`dp-ui__calendar--modal`,t)},Zr=e=>e===`input`?`input`:`days`,Qr=t=>{let{core:n,actions:r,rules:i,mode:a,fullscreen:o}=t,s=n.calendarLayout!==`docked`,c=new AbortController,l=e.F(`div`,`dp-ui__calendar`),u,d=0,f=null,p=()=>e.M(n.options.animation),m=()=>l.closest(`.dp-ui__container--rtl`)!==null||getComputedStyle(n.input).direction===`rtl`,h=t=>{let n=u.days.cellAt(t),r=e.Ft(n?.dataset.date??``);return n===null||r===null?null:{element:n,date:r}},g=()=>{let{draft:t,value:r}=n,i=e.pt(t)&&e.pt(r);Pt(l,e.dt(t)&&!i)},_=()=>{u.days.reveal(wr(n))},v=(e,t,r)=>{e===`days`&&_(),r&&(e===`input`?u.panels.entry()?.focus({preventScroll:!0}):u.days.focusCell(n.focus))},y=(e,t)=>{let n=()=>{u.applyChrome(t),e()};f?.cancel(),f=null;let r=L(l);r===null?n():f=An(r,n,p())},b=()=>{Xr(l,s),u=Yr({root:l,core:n,actions:r,rules:i,mode:a,fullscreen:o,rtl:m(),signal:c.signal,motion:p,reveal:_,swap:y,onSwitched:v}),u.days.present(n.view,0,`api`),u.panels.mount(Zr(n.panel)),u.applyChrome(u.panels.current()),g(),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{d=0,u.applyChrome(u.panels.current()),u.panels.current()===`days`&&_()})},x=()=>{f?.cancel(),f=null,u.panels.destroy(),u.days.destroy(),u.header.destroy()},S=()=>{if(c.signal.aborted)return;let e=u.panels.current();u.applyChrome(e),e===`days`&&_()},C=()=>{c.signal.aborted||(cancelAnimationFrame(d),d=0,S(),u.panels.current()===`input`?u.panels.entry()?.focus({preventScroll:!0}):u.days.focusCell(n.focus))},w=()=>{u.days.refresh(),u.refreshPresets(),u.header.setText(B(n)),g();let{announceSelection:t}=e.xt(a,n.options.inline);t&&u.panels.current()===`days`&&e.j(u.liveRegion,B(n))},T=()=>{let e=h(l.ownerDocument.activeElement)!==null;u.days.refresh(),e&&u.days.focusCell(n.focus)},E=(t,r,i)=>{let a=u.panels.current()===`days`&&u.panels.settled();u.days.present(t,a?r:0,i),xr(i)&&n.layout.months>1&&e.j(u.liveRegion,rn(n,t))};return b(),(e=>{let{events:t}=n;t.on(`change:view`,e=>{E(e.view,e.delta,e.source)},e),t.on(`change:draft`,w,e),t.on(`change:active-end`,()=>{u.days.refresh()},e),t.on(`change:value`,g,e),t.on(`change:focus`,T,e),t.on(`change:panel`,e=>{u.panels.switchTo(Zr(e.panel))},e),Bt(l,e,{actions:r,panel:()=>n.panel,home:`days`,cellAt:h}),yn(l,e,{core:n,actions:r,layout:`range`,home:`days`,caption:()=>!1,cellAt:h,isRtl:m}),Nt(l,`.dp-ui__icon-button, .dp-ui__text-button, .dp-ui__preset, .dp-ui__date:not(.dp-ui__date--disabled) .dp-ui__date-indicator`,e)})(c.signal),{element:l,focusInitial:C,fit:S,update:()=>{if(c.signal.aborted)return;let e=l.contains(l.ownerDocument.activeElement);x(),b(),e&&C()},destroy:()=>{if(c.signal.aborted)return;c.abort(),cancelAnimationFrame(d),x();let e=L(l);e!==null&&(e.classList.remove(...qr),R(e,1)),l.remove()}}};var $r=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(t){this.release();let n=this.createHost(t);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),St(n.root,i.animation);let l={core:r,actions:a,rules:o,mode:t,fullscreen:r.calendarLayout===`fullscreen`},u=i.mode===`range`?Qr(l):Cr(l);this.mounted={mode:t,host:n,view:u,stopModality:e.P(n.root),stopSchemeWatch:t===`inline`?e.A(()=>{s.applyTo(n.root)}):()=>void 0},n.body.append(u.element);let d=n.open();u.fit(),this.overflows(t,n)?(this.release(),this.deps.overflow()):(await d,c===this.generation&&t!==`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()),St(e.host.root,this.core.options.animation),e.view.update())}label(){let{labels:e,mode:t,precision:n}=this.core.options;return Ct(e,t,n)}destroy(){this.generation+=1,this.release()}overflows(t,n){return t===`docked`&&this.core.options.displayMode===`auto`&&!e.y(n.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(t){let{core:n}=this,{options:r}=n,{actions:i}=this.deps,a=this.label();if(t===`inline`){let t=e.I(r.inline.container);return t===null?null:new e.r({container:t,label:a})}return t===`modal`?new e.i({parent:e.I(r.appendTo)??n.host,label:a,allowPageScroll:r.allowPageScroll,onCancel:e=>{i.cancel(e)}}):new e.n({host:n.host,anchor:n.input,instanceId:n.instanceId,rtl:getComputedStyle(n.input).direction===`rtl`,label:a,ignoreOutsideClick:r.behavior.ignoreOutsideClick,inside:[...n.endInput===null?[]:[n.endInput],...this.deps.inside()],onOutside:()=>{i.cancel(`outside`)},onEscape:()=>{i.cancel(`escape`)}})}},ei=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(t){let{value:n,options:r}=this.core;if(t===null||n.mode!==`range`)return e.w(n,r.precision);let i=t===`start`?n.start:n.end;return i===null?``:e.H(i,`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(t){let{core:n}=this,{pattern:r,precision:i}=n.options,a=this.splitEnd();if(a===null||t.mode!==`range`){n.input.value=e.x(t,r,i);return}let o=t=>t===null?``:e.R(t,r,`day`);n.input.value=o(t.start),a.value=o(t.end)}handleReset(){let{core:t}=this,{mode:n}=t.options,r=this.initial.mode===n?this.initial:e.ut(n);t.setValue(r),this.writeFields(r),this.sync()}};const Y=`aria-describedby`,ti=e=>(e.getAttribute(Y)??``).split(/\s+/).filter(e=>e!==``);function ni(t,n,r,i){let a=e.F(`span`,`dp-ui__visually-hidden`,{id:r}),o=e.F(`span`,void 0,{"aria-live":`polite`}),s=e.F(`span`);return s.textContent=i,a.append(o,` `,s),n.append(a),t.setAttribute(Y,[...ti(t),r].join(` `)),{setHint:e=>{s.textContent!==e&&(s.textContent=e)},setError:e=>{let t=e??``;o.textContent!==t&&(o.textContent=t)},destroy:()=>{a.remove();let e=ti(t).filter(e=>e!==r);e.length===0?t.removeAttribute(Y):t.setAttribute(Y,e.join(` `))}}}const ri=`dp-ui--error`;function X(e,t,n){e.setAttribute(`aria-invalid`,`true`),t.classList.add(ri),e.setCustomValidity(n)}function ii(e,t){e.removeAttribute(`aria-invalid`),t.classList.remove(ri),e.setCustomValidity(``)}function ai(t,n,r){let i=t.trim(),a=n.trim();if(i===``&&a===``)return{kind:`empty`};let o=i===``?null:e.W(i,r);if(i!==``&&o===null)return{kind:`invalid`,field:`start`};let s=a===``?null:e.W(a,r);return a!==``&&s===null?{kind:`invalid`,field:`end`}:o===null||s===null?{kind:`partial`}:e.At(o,s)>0?{kind:`reversed`}:{kind:`range`,start:o,end:s}}var oi=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:t}=this,n=e.ut(`range`);if(t===null)return n;let r=this.readDate(this.core.input.value),i=this.readDate(t.value);return r===null||i===null||e.At(r,i)>0?n:{mode:`range`,start:r,end:i}}markInvalid(e){let{end:t}=this;if(t===null)return;let{input:n,host:r}=this.core;X(n,r,e),X(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;ii(t,n),ii(e,n),this.deps.describe(t,null),this.deps.describe(e,null)}format(t){return t===null?``:e.R(t,this.core.options.pattern,`day`)}readDate(t){let{pattern:n}=this.core.options,r=e.C(t,`single`,`day`)??e.S(t,`single`,n,`day`);return r?.mode===`single`?r.date:null}applyMask(t){let{options:n}=this.core;n.mask&&e.d(t,n.pattern)}commit(){let{end:t}=this;if(t===null||!this.dirty)return;let{options:n,input:r}=this.core,i=ai(r.value,t.value,n.pattern);i.kind!==`partial`&&(i.kind===`empty`?this.settle(e.ut(`range`)):i.kind===`invalid`?this.fail(i.field,`invalid-date`,n.labels.invalidDate):i.kind===`reversed`?this.fail(`end`,`invalid-date`,n.labels.invalidRange):this.commitRange(i.start,i.end))}commitRange(e,t){let{options:n}=this.core,r={mode:`range`,start:e,end:t},i=e=>this.deps.rules.unavailableReason(e),a=P(r,n.limits,i);if(a===null){this.settle(r);return}let o=i(e)===null?`end`:`start`;this.fail(o,`unavailable-date`,Fn(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(),X(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})}},si=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 oi(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(t){this.split.end===null?(this.core.input.value=e.x(t,this.core.options.pattern,this.core.options.precision),this.clearError()):this.split.write(t)}readInitial(){if(this.split.end!==null)return this.split.readInitial();let{mode:t,pattern:n,precision:r}=this.core.options,i=this.core.input.value;return e.C(i,t,r)??e.S(i,t,n,r)??e.ut(t)}evaluate(t){let{mode:n,pattern:r,limits:i,precision:a}=this.core.options,o=e.S(t,n,r,a);if(o===null)return{kind:`invalid`};if(e.pt(o))return{kind:`empty`};let s=P(o,i,e=>this.deps.rules.unavailableReason(e));return s===null?{kind:`valid`,selection:o}:{kind:`unavailable`,selection:o,reason:s}}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(t){let{input:n,host:r,instanceId:i}=this.core,{end:a}=this.split,o=()=>{let{pattern:t,precision:n,labels:r}=this.core.options;return e.V(t,n,e.ot(r))},s=[[n,`input-description`]];a!==null&&s.push([a,`end-input-description`]);for(let[t,n]of s){let a=e.g(i,n);this.descriptions.set(t,ni(t,r,a,o()))}this.core.events.on(`change:options`,()=>{let e=o();this.descriptions.forEach(t=>{t.setHint(e)})},t)}describe(e,t){this.descriptions.get(e)?.setError(t)}applyMask(){let{input:t,options:n}=this.core;n.mask&&n.mode===`single`&&n.precision===`day`&&e.d(t,n.pattern)}commit(){let t=this.core.input.value,n=this.evaluate(t);if(n.kind===`empty`)this.clearError(),this.deps.onTyped(e.ut(this.core.options.mode));else if(n.kind===`valid`)this.write(n.selection),this.deps.onTyped(n.selection);else if(n.kind===`invalid`){let e=this.core.options.labels.invalidDate;this.showError(e),this.emitter.emit(`error`,{code:`invalid-date`,message:e,input:t})}else{let{reason:e}=n,r=Fn(e,this.core.options);this.showError(r),this.emitter.emit(`error`,{code:`unavailable-date`,message:r,input:t,reason:e})}}showError(e){X(this.core.input,this.core.host,e),this.describe(this.core.input,e)}clearError(){ii(this.core.input,this.core.host),this.describe(this.core.input,null)}},ci=class{core;constructor(e){this.core=e}applyHost(){this.core.host.setAttribute(`data-theme`,this.core.options.theme)}applyTo(t){let{options:n,input:r,host:i}=this.core;e.t(t,{theme:n.theme,colorScheme:n.colorScheme===`auto`?e.k(i):n.colorScheme,className:n.cssClass,rtl:getComputedStyle(r).direction===`rtl`})}destroy(){this.core.host.removeAttribute(`data-theme`)}};const li=(t,n,r,i)=>{let a=e._t(t);return a.length===0?``:t.mode===`multiple`?Ot(r,a.length,n):a.map(t=>e.Y(t,i,n,`long`)).join(e.b)},Z=`dp-ui__input--active`;var ui=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=li(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(Z),this.core.endInput?.classList.remove(Z)}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(Z);return}let n=this.expanded?this.core.activeEnd:null;t.classList.toggle(Z,n===`start`),e.classList.toggle(Z,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(t){let n=e.I(this.core.options.toggleButton,this.core.host);if(n===null)return;let r=/* @__PURE__ */ new Map,i=(e,t)=>{r.has(e)||r.set(e,n.getAttribute(e)),n.setAttribute(e,t)};i(`aria-haspopup`,`dialog`),n.tagName!==`BUTTON`&&(i(`role`,`button`),i(`tabindex`,`0`),n.addEventListener(`keydown`,e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),this.activateToggle())},{signal:t})),n.addEventListener(`click`,()=>{this.activateToggle()},{signal:t}),this.toggle=n,i(`aria-expanded`,String(this.expanded)),i(`aria-label`,this.core.options.labels.openCalendar),this.updateLabel();let a=()=>{t.removeEventListener(`abort`,a),r.forEach((e,t)=>{e===null?n.removeAttribute(t):n.setAttribute(t,e)}),this.toggle===n&&(this.toggle=null),this.release===a&&(this.release=null)};this.release=a,t.addEventListener(`abort`,a,{once:!0})}releaseToggle(){this.release?.()}};function Q(e){return e.year*12+e.month-1}var di=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(t){let n=e.Pt(t),r=e.jt(t.year,t.month,1),i=e.jt(t.year,t.month,n);if(r===null||i===null)return!0;let{minDate:a,maxDate:o}=this.core.options,s=this.yearBounds();if(t.year<s.min||t.year>s.max||a!==null&&e.At(i,a)<0||o!==null&&e.At(r,o)>0)return!0;for(let e=1;e<=n;e+=1)if(this.dayReason({year:t.year,month:t.month,day:e})===null)return!1;return!0}yearBounds(){let{minDate:t,maxDate:n,yearRange:r}=this.core.options,i=e.Ht(),a=i.year-r.before,o=i.year+r.after;return{min:t===null?a:Math.max(a,t.year),max:n===null?o:Math.min(o,n.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(t){let{minDate:n,maxDate:r}=this.core.options,i=this.yearBounds();if(n!==null&&e.At(t,n)<0||t.year<i.min)return`min`;if(r!==null&&e.At(t,r)>0||t.year>i.max)return`max`;let a=this.getLists(),o=e.Bt(t);return a.disabled.has(o)||a.enabled!==null&&!a.enabled.has(o)?`disabled`:a.source.disabledWeekdays.includes(e.Mt(t))?`weekday`:this.isCallbackDisabled(t,a)?`disabled`:null}isCallbackDisabled(n,r){let{isDateDisabled:i}=r.source;if(i===null)return!1;let a=e.Bt(n),o=r.callbackResults.get(a);if(o!==void 0)return o;let s=!1;try{s=i(e.zt(n))}catch(e){t(e)}return r.callbackResults.set(a,s),s}guardFor(t){let n=this.getLists(),r=n.guardDraft;if(n.guard!==null&&r!==null&&e.gt(r,t))return n.guard;let{maxDate:i,limits:a}=n.source,o={year:this.yearBounds().max,month:12,day:31};i!==null&&e.At(i,o)<0&&(o=i);let s=He(t,a,e=>this.isDisabled(e),o);return n.guardDraft=t,n.guard=s,s}getLists(){let t=this.core.options;if(this.lists?.source===t)return this.lists;let n={source:t,disabled:new Set(t.disabledDates.map(e.Bt)),enabled:t.enabledDates===null?null:new Set(t.enabledDates.map(e.Bt)),callbackResults:/* @__PURE__ */ new Map,guardDraft:null,guard:null};return this.lists=n,n}},fi=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}},pi=class{validation;theme;display;input;triggers;form;relay=new fi;constructor(e,t){this.validation=new di(e,t),this.theme=new ci(e),this.display=new $r(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 si(e,t,{rules:this.validation,onTyped:this.relay.typed}),this.triggers=new ui(e,t,{open:this.relay.open,dismiss:()=>{this.relay.cancel(`toggle`)}}),this.form=new ei(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,mi=()=>void 0;var hi=class{core;emitter;lifecycle;constructor(e,t){let r=Pe(e);this.emitter=new n,this.core=new ke(r.input,r.host,r.createdHost,t),this.lifecycle=new bt(this.core,this.emitter,new pi(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?mi:this.emitter.on(e,t)}once(e,t){return this.lifecycle.destroyed?mi: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(De(e))}static getAllInstances(){return[...$.values()]}static destroyAll(){for(let e of[...$.values()])e.destroy()}},gi=hi;exports.DEFAULT_DATEPICKER_OPTIONS=a,exports.DatepickerUI=hi,exports.EventEmitter=n,exports.default=gi;
@@ -0,0 +1,66 @@
1
+ import { $ as Precision, A as RangeValue, C as NavigateSource, D as PickerView, E as PickerValueInput, F as UnavailableReason, I as UpdateEventData, K as WeekStartOption, L as VisibleRange, M as SelectMonthEventData, N as SelectYearEventData, O as RangeEndEventData, P as SwitchViewEventData, Q as PageBy, S as NavigateEventData, T as PickerValue, Z as CalendarMode, _ as CloseEventData, a as CallbacksOptions, b as DatepickerEventMap, c as LabelsOptions, d as RangePresetValue, et as RangeEnd, f as ThemeName, g as ClearEventData, h as CancelReason, i as CalendarOptions, j as SelectDayEventData, k as RangeStartEventData, l as PluralLabel, m as CancelEventData, o as DateDecoration, p as UIOptions, r as BehaviorOptions, s as DatepickerOptions, t as ResolvedPreset, tt as PlainDate, u as RangePreset, v as ConfirmEventData, w as OpenEventData, x as ErrorEventData, y as DateValue } from "./shared.cjs";
2
+ type Handler<Data> = (data: Data) => void;
3
+ export declare class EventEmitter<Events extends object> {
4
+ private store;
5
+ on<K extends keyof Events>(event: K, handler: Handler<Events[K]>, signal?: AbortSignal): () => void;
6
+ once<K extends keyof Events>(event: K, handler: Handler<Events[K]>): () => void;
7
+ off<K extends keyof Events>(event: K, handler?: Handler<Events[K]>): void;
8
+ emit<K extends keyof Events>(event: K, data: Events[K]): void;
9
+ listenerCount(event: keyof Events): number;
10
+ clear(): void;
11
+ private listenersOf;
12
+ }
13
+ export default class DatepickerUI {
14
+ private readonly core;
15
+ private readonly emitter;
16
+ private readonly lifecycle;
17
+ constructor(selectorOrElement: string | HTMLElement, options?: DatepickerOptions);
18
+ create(): void;
19
+ open(): void;
20
+ close(): void;
21
+ destroy(options?: {
22
+ keepInputValue?: boolean;
23
+ }): void;
24
+ getValue(): PickerValue | null;
25
+ setValue(value: PickerValueInput | null): void;
26
+ setActiveEnd(end: RangeEnd): void;
27
+ setView(view: PickerView): void;
28
+ getView(): PickerView;
29
+ getVisibleRange(): VisibleRange | null;
30
+ goTo(date: Date | string): void;
31
+ isSelectable(value: PickerValueInput): boolean;
32
+ clear(): void;
33
+ setOptions(options: DatepickerOptions): void;
34
+ getElement(): HTMLElement;
35
+ on<K extends keyof DatepickerEventMap>(event: K, handler: Handler<DatepickerEventMap[K]>): () => void;
36
+ once<K extends keyof DatepickerEventMap>(event: K, handler: Handler<DatepickerEventMap[K]>): () => void;
37
+ off<K extends keyof DatepickerEventMap>(event: K, handler?: Handler<DatepickerEventMap[K]>): void;
38
+ get instanceId(): string;
39
+ get options(): DatepickerOptions;
40
+ get isInitialized(): boolean;
41
+ get isDestroyed(): boolean;
42
+ static getById(id: string): DatepickerUI | undefined;
43
+ static getAllInstances(): DatepickerUI[];
44
+ static destroyAll(): void;
45
+ }
46
+ interface DefaultOptions {
47
+ readonly calendar: {
48
+ readonly weekStart: WeekStartOption;
49
+ readonly mode: CalendarMode;
50
+ readonly precision: Precision;
51
+ readonly months: number;
52
+ readonly pageBy: PageBy;
53
+ readonly presets: readonly ResolvedPreset[];
54
+ };
55
+ readonly ui: Required<Pick<UIOptions, "displayMode" | "layout" | "format" | "theme" | "colorScheme" | "weekNumbers" | "outsideDays" | "fixedWeeks" | "todayButton" | "clearButton" | "animation" | "allowPageScroll" | "fullscreen" | "cssClass" | "swipe" | "viewSwitch" | "initialView" | "mask" | "startView">> & {
56
+ readonly inline: Required<Omit<NonNullable<UIOptions["inline"]>, "container">>;
57
+ readonly yearRange: {
58
+ readonly before: number;
59
+ readonly after: number;
60
+ };
61
+ };
62
+ readonly labels: Required<LabelsOptions>;
63
+ readonly behavior: Required<Omit<BehaviorOptions, "id">>;
64
+ }
65
+ export declare const DEFAULT_DATEPICKER_OPTIONS: DefaultOptions;
66
+ export { type BehaviorOptions, type CalendarMode, type CalendarOptions, type CallbacksOptions, type CancelEventData, type CancelReason, type ClearEventData, type CloseEventData, type ConfirmEventData, type DateDecoration, type DateValue, type DatepickerEventMap, type DatepickerOptions, DatepickerUI, type ErrorEventData, type LabelsOptions, type NavigateEventData, type NavigateSource, type OpenEventData, type PageBy, type PickerValue, type PickerValueInput, type PickerView, type PlainDate, type PluralLabel, type Precision, type RangeEnd, type RangeEndEventData, type RangePreset, type RangePresetValue, type RangeStartEventData, type RangeValue, type SelectDayEventData, type SelectMonthEventData, type SelectYearEventData, type SwitchViewEventData, type ThemeName, type UIOptions, type UnavailableReason, type UpdateEventData, type VisibleRange };
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./shared.cjs");exports.DialogHost=e.i,exports.InlineHost=e.r,exports.Pager=e.o,exports.PopoverHost=e.n,exports.RANGE_SEPARATOR=e.b,exports.applyTheme=e.t,exports.createTextButton=e.h,exports.detectColorScheme=e.k,exports.fitsViewport=e.y,exports.formatDate=e.it,exports.formatFullDate=e.G,exports.formatHint=e.at,exports.formatMonthYear=e.q,exports.isDateTextComplete=e.c,exports.isFullscreenRange=e.St,exports.leadingDateLength=e.l,exports.maskDateText=e.u,exports.normalizeDigits=e.U,exports.parseDate=e.W,exports.resolvePattern=e.ct,exports.resolveSurfaceMode=e.Ct,exports.resolveWeekStart=e.tt,exports.splitRangeText=e.T,exports.waitForExit=e.a,exports.watchColorScheme=e.A,exports.weekdayNames=e.nt;