@lekoala/date-picker 0.5.3 → 0.6.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.
@@ -1 +1 @@
1
- :where(date-calendar,date-picker){--dp-bg: #ffffff;--dp-fg: #1f2328;--dp-muted: color-mix(in srgb,var(--dp-fg) 58%,var(--dp-bg));--dp-border: color-mix(in srgb,var(--dp-fg) 16%,var(--dp-bg));--dp-hover: color-mix(in srgb,var(--dp-fg) 5%,var(--dp-bg));--dp-accent: #2563eb;--dp-accent-fg: #fff;--dp-focus: var(--dp-accent);--dp-focus-width: 2px;--dp-radius: 0.5rem;--dp-day-size: 2.75rem;--dp-gap: 0.375rem;--dp-header-control-size: 2.25rem;--dp-header-block-gap: 0.75rem;--dp-row-gap: 0.375rem;--dp-picker-button-size: 2.5rem;--dp-year-inline-size: 5.5rem;--dp-day-radius: calc(var(--dp-radius) * 0.75);color: var(--dp-fg);font: inherit}.dp-visually-hidden{position: absolute !important;inline-size: 1px !important;block-size: 1px !important;padding: 0 !important;margin: -1px !important;overflow: hidden !important;clip: rect(0 0 0 0) !important;white-space: nowrap !important;border: 0 !important}date-calendar{display: block;inline-size: max-content;max-inline-size: 100%}.dp-calendar-shell{inline-size: max-content;max-inline-size: 100%}.dp-calendar-header{display: grid;grid-template-columns: minmax(0,1fr) var(--dp-year-inline-size) auto auto;align-items: stretch;gap: var(--dp-gap);margin-block-end: var(--dp-header-block-gap)}date-calendar[data-year-first] .dp-calendar-header{grid-template-columns: var(--dp-year-inline-size) minmax(0,1fr) auto auto}.dp-calendar-header :where(button,select,input){box-sizing: border-box;min-inline-size: 0}.dp-calendar-header .dp-skin{min-block-size: var(--dp-header-control-size);padding-block: 0.15rem;border: 1px solid var(--dp-border);border-radius: calc(var(--dp-radius) * 0.75);background: var(--dp-bg);color: var(--dp-fg);font: inherit;line-height: 1.2}.dp-calendar-header input.dp-skin{padding-inline: 0.45rem}.dp-month-select{inline-size: 100%;overflow: hidden;text-overflow: ellipsis}.dp-month-select.dp-skin{appearance: none;padding-inline: 0.45rem 2rem;background-image: linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);background-position: calc(100% - 0.9rem) 50%,calc(100% - 0.65rem) 50%;background-size: 0.3rem 0.3rem;background-repeat: no-repeat}[dir="rtl"] .dp-month-select.dp-skin,html[dir="rtl"] .dp-month-select.dp-skin{background-position: 0.9rem 50%,0.65rem 50%}.dp-year-input{inline-size: 100%}.dp-nav.dp-skin{display: grid;place-items: center;inline-size: var(--dp-header-control-size);padding: 0;font-size: 1.35rem;line-height: 1;cursor: pointer}.dp-nav svg{display: block;inline-size: 1rem;block-size: 1rem;pointer-events: none}.dp-calendar-header .dp-skin:disabled,.dp-picker-button:disabled{cursor: not-allowed;opacity: 0.45}.dp-nav.dp-skin:hover:not(:disabled){background: var(--dp-hover)}.dp-calendar-header .dp-skin:focus-visible,date-picker>input:not([type="hidden"]):focus-visible,.dp-day:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: calc(var(--dp-focus-width) * -1)}.dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not( [data-range-end="true"] ){background: var(--dp-hover)}.dp-grid{border-collapse: separate;border-spacing: 0 var(--dp-row-gap);table-layout: fixed}.dp-grid :where(th,td){box-sizing: border-box;inline-size: var(--dp-day-size);block-size: var(--dp-day-size);padding: 0;text-align: center}.dp-grid thead th{block-size: 1.5rem;color: var(--dp-muted);font-size: 0.72rem;font-weight: 500}.dp-day{position: relative;border: 1px solid transparent;border-radius: var(--dp-day-radius);cursor: pointer;outline: none;vertical-align: middle;font-size: 0.875rem}.dp-day:is([data-selected="true"],[data-range-start="true"],[data-range-end="true"]):focus-visible{outline-color: var(--dp-accent-fg)}.dp-day[data-outside-month="true"]{color: var(--dp-muted)}.dp-day[data-selected="true"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-today="true"]:not([data-selected="true"],[data-range-start="true"],[data-range-end="true"]){border-color: var(--dp-accent)}.dp-day[data-disabled="true"]{cursor: not-allowed;opacity: 0.42}.dp-day[data-range-start="true"],.dp-day[data-range-end="true"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-in-range="true"]{border-radius: 0;background: color-mix(in srgb,var(--dp-accent) 18%,var(--dp-bg))}.dp-day[data-range-start="true"]:has(+ [data-in-range="true"],+ [data-range-end="true"]){border-start-end-radius: 0;border-end-end-radius: 0}.dp-day:is([data-in-range="true"],[data-range-start="true"]) + .dp-day[data-range-end="true"]{border-start-start-radius: 0;border-end-start-radius: 0}.dp-day[data-in-range="true"]:first-of-type{border-start-start-radius: var(--dp-day-radius);border-end-start-radius: var(--dp-day-radius)}.dp-day[data-in-range="true"]:last-of-type{border-start-end-radius: var(--dp-day-radius);border-end-end-radius: var(--dp-day-radius)}[data-range-preview] .dp-day:is([data-range-start="true"],[data-range-end="true"]){background: color-mix(in srgb,var(--dp-accent) 58%,var(--dp-bg))}[data-range-preview] .dp-day[data-in-range="true"]{background: color-mix(in srgb,var(--dp-accent) 11%,var(--dp-bg))}[data-range-drag] .dp-day:is([data-range-start="true"],[data-range-end="true"]){cursor: grab}[data-range-drag="active"],[data-range-drag="active"] .dp-day{cursor: grabbing}.dp-day-number{display: block;font-variant-numeric: tabular-nums}.dp-day[data-disabled="true"]:focus-visible{opacity: 1}.dp-day[data-disabled="true"]:focus-visible .dp-day-number{color: var(--dp-muted)}.dp-day-extra{position: absolute;inset-inline: 2px;inset-block-end: 1px;display: flex;justify-content: center;gap: 2px;min-block-size: 0.35rem;font-size: 0.55rem;line-height: 1;pointer-events: none}.dp-week-number,.dp-week-heading{inline-size: 1.6rem !important;color: var(--dp-muted);font-size: 0.65rem;font-weight: 500}date-picker{position: relative;display: inline-grid;grid-template-columns: minmax(0,1fr);align-items: stretch;max-inline-size: 100%}date-picker>input:not([type="hidden"]){min-inline-size: 0}date-picker>input:not([type="hidden"]):not([type="time"]){grid-column: 1;grid-row: 1;box-sizing: border-box;inline-size: 100%;padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem)}.dp-picker-button{display: grid;place-items: center;grid-column: 1;grid-row: 1;justify-self: end;align-self: stretch;inline-size: var(--dp-picker-button-size);min-inline-size: 0;border: 0;background: transparent;color: var(--dp-fg);font: inherit;cursor: pointer}.dp-picker-button:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: -5px;border-radius: var(--dp-radius)}date-picker:has(>[data-time-start],>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr);column-gap: var(--dp-gap)}date-picker:has(>[data-time-start]):has(>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}date-picker>input[data-time-start]{grid-column: 2;grid-row: 1;min-inline-size: 0}date-picker>input[data-time-end]{grid-column: 3;grid-row: 1;min-inline-size: 0}date-picker[range]{row-gap: var(--dp-gap)}date-picker[range]>input[data-range-start]{grid-row: 1}date-picker[range]>input[data-range-end]{grid-row: 2}date-picker[range]>.dp-picker-button[data-endpoint="start"]{grid-row: 1}date-picker[range]>.dp-picker-button[data-endpoint="end"]{grid-row: 2}.dp-picker-panel[popover]{position: fixed;inset: auto;margin: 0;padding: 0.875rem 1rem;border: 1px solid var(--dp-border);border-radius: var(--dp-radius);background: var(--dp-bg);color: var(--dp-fg);box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);max-block-size: var(--available-height,90svh);max-inline-size: calc(100vi - 1rem);overflow: auto}.dp-picker-panel:not(:popover-open){display: none}@media (forced-colors: active){.dp-month-select.dp-skin,[dir="rtl"] .dp-month-select.dp-skin{appearance: auto;background-image: none;padding-inline: 0.45rem}.dp-day:is([data-selected="true"],[data-range-start="true"],[data-range-end="true"]){border: 2px solid Highlight;background-color: Canvas;color: CanvasText}.dp-day[data-in-range="true"]{color: CanvasText}.dp-day[data-in-range="true"]::after{content: "";position: absolute;inset-inline: 3px;inset-block-end: 4px;block-size: 1px;background-color: Highlight}.dp-day[data-today="true"]{border-color: Highlight}.dp-day-extra{color: CanvasText;forced-color-adjust: none}}
1
+ :where(date-calendar,date-picker){--dp-bg: #ffffff;--dp-fg: #1f2328;--dp-muted: color-mix(in srgb,var(--dp-fg) 58%,var(--dp-bg));--dp-border: color-mix(in srgb,var(--dp-fg) 16%,var(--dp-bg));--dp-hover: color-mix(in srgb,var(--dp-fg) 5%,var(--dp-bg));--dp-accent: #2563eb;--dp-accent-fg: #fff;--dp-focus: var(--dp-accent);--dp-focus-width: 2px;--dp-radius: 0.5rem;--dp-day-size: 2.75rem;--dp-gap: 0.375rem;--dp-header-control-size: 2.25rem;--dp-header-block-gap: 0.75rem;--dp-row-gap: 0.375rem;--dp-picker-button-size: 2.5rem;--dp-year-inline-size: 5.5rem;--dp-day-radius: calc(var(--dp-radius) * 0.75);color: var(--dp-fg);font: inherit}.dp-visually-hidden{position: absolute !important;inline-size: 1px !important;block-size: 1px !important;padding: 0 !important;margin: -1px !important;overflow: hidden !important;clip: rect(0 0 0 0) !important;white-space: nowrap !important;border: 0 !important}date-calendar{display: block;inline-size: max-content;max-inline-size: 100%}.dp-calendar-shell{inline-size: max-content;max-inline-size: 100%}.dp-calendar-header{display: grid;grid-template-columns: minmax(0,1fr) var(--dp-year-inline-size) auto auto;align-items: stretch;gap: var(--dp-gap);margin-block-end: var(--dp-header-block-gap)}date-calendar[data-year-first] .dp-calendar-header{grid-template-columns: var(--dp-year-inline-size) minmax(0,1fr) auto auto}.dp-calendar-header :where(button,select,input){box-sizing: border-box;min-inline-size: 0}.dp-calendar-header .dp-skin{min-block-size: var(--dp-header-control-size);padding-block: 0.15rem;border: 1px solid var(--dp-border);border-radius: calc(var(--dp-radius) * 0.75);background: var(--dp-bg);color: var(--dp-fg);font: inherit;line-height: 1.2}.dp-calendar-header input.dp-skin{padding-inline: 0.45rem}.dp-month-select{inline-size: 100%;overflow: hidden;text-overflow: ellipsis}.dp-month-select.dp-skin{appearance: none;padding-inline: 0.45rem 2rem;background-image: linear-gradient(45deg,transparent 50%,currentColor 50%),linear-gradient(135deg,currentColor 50%,transparent 50%);background-position: calc(100% - 0.9rem) 50%,calc(100% - 0.65rem) 50%;background-size: 0.3rem 0.3rem;background-repeat: no-repeat}[dir="rtl"] .dp-month-select.dp-skin,html[dir="rtl"] .dp-month-select.dp-skin{background-position: 0.9rem 50%,0.65rem 50%}.dp-year-input{inline-size: 100%}.dp-nav.dp-skin{display: grid;place-items: center;inline-size: var(--dp-header-control-size);padding: 0;font-size: 1.35rem;line-height: 1;cursor: pointer}.dp-nav svg{display: block;inline-size: 1rem;block-size: 1rem;pointer-events: none}.dp-calendar-header .dp-skin:disabled,.dp-picker-button:disabled{cursor: not-allowed;opacity: 0.45}.dp-nav.dp-skin:hover:not(:disabled){background: var(--dp-hover)}.dp-calendar-header .dp-skin:focus-visible,date-picker>input:not([type="hidden"]):focus-visible,.dp-day:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: calc(var(--dp-focus-width) * -1)}.dp-day:hover:not([data-disabled="true"]):not([data-selected="true"]):not([data-range-start="true"]):not( [data-range-end="true"] ){background: var(--dp-hover)}.dp-grid{border-collapse: separate;border-spacing: 0 var(--dp-row-gap);table-layout: fixed}.dp-grid :where(th,td){box-sizing: border-box;inline-size: var(--dp-day-size);block-size: var(--dp-day-size);padding: 0;text-align: center}.dp-grid thead th{block-size: 1.5rem;color: var(--dp-muted);font-size: 0.72rem;font-weight: 500}.dp-day{position: relative;border: 1px solid transparent;border-radius: var(--dp-day-radius);cursor: pointer;outline: none;vertical-align: middle;font-size: 0.875rem}.dp-day:is([data-selected="true"],[data-range-start="true"],[data-range-end="true"]):focus-visible{outline-color: var(--dp-accent-fg)}.dp-day[data-outside-month="true"]{color: var(--dp-muted)}.dp-day[data-selected="true"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-today="true"]:not([data-selected="true"],[data-range-start="true"],[data-range-end="true"]){border-color: var(--dp-accent)}.dp-day[data-disabled="true"]{cursor: not-allowed;opacity: 0.42}.dp-day[data-range-start="true"],.dp-day[data-range-end="true"]{background: var(--dp-accent);color: var(--dp-accent-fg)}.dp-day[data-in-range="true"]{border-radius: 0;background: color-mix(in srgb,var(--dp-accent) 18%,var(--dp-bg))}.dp-day[data-range-start="true"]:has(+ [data-in-range="true"],+ [data-range-end="true"]){border-start-end-radius: 0;border-end-end-radius: 0}.dp-day:is([data-in-range="true"],[data-range-start="true"]) + .dp-day[data-range-end="true"]{border-start-start-radius: 0;border-end-start-radius: 0}.dp-day[data-in-range="true"]:first-of-type{border-start-start-radius: var(--dp-day-radius);border-end-start-radius: var(--dp-day-radius)}.dp-day[data-in-range="true"]:last-of-type{border-start-end-radius: var(--dp-day-radius);border-end-end-radius: var(--dp-day-radius)}[data-range-preview] .dp-day:is([data-range-start="true"],[data-range-end="true"]){background: color-mix(in srgb,var(--dp-accent) 58%,var(--dp-bg))}[data-range-preview] .dp-day[data-in-range="true"]{background: color-mix(in srgb,var(--dp-accent) 11%,var(--dp-bg))}.dp-day-number{display: block;font-variant-numeric: tabular-nums}.dp-day[data-disabled="true"]:focus-visible{opacity: 1}.dp-day[data-disabled="true"]:focus-visible .dp-day-number{color: var(--dp-muted)}.dp-day-extra{position: absolute;inset-inline: 2px;inset-block-end: 1px;display: flex;justify-content: center;gap: 2px;min-block-size: 0.35rem;font-size: 0.55rem;line-height: 1;pointer-events: none}.dp-week-number,.dp-week-heading{inline-size: 1.6rem !important;color: var(--dp-muted);font-size: 0.65rem;font-weight: 500}date-picker{position: relative;display: inline-grid;grid-template-columns: minmax(0,1fr);align-items: stretch;max-inline-size: 100%}date-picker>input:not([type="hidden"]){min-inline-size: 0}date-picker>input:not([type="hidden"]):not([type="time"]){grid-column: 1;grid-row: 1;box-sizing: border-box;inline-size: 100%;padding-inline-end: calc(var(--dp-picker-button-size) + 0.5rem)}.dp-picker-button{display: grid;place-items: center;grid-column: 1;grid-row: 1;justify-self: end;align-self: stretch;inline-size: var(--dp-picker-button-size);min-inline-size: 0;border: 0;background: transparent;color: var(--dp-fg);font: inherit;cursor: pointer}.dp-picker-button:focus-visible{outline: var(--dp-focus-width) solid var(--dp-focus);outline-offset: -5px;border-radius: var(--dp-radius)}date-picker:has(>[data-time-start],>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr);column-gap: var(--dp-gap)}date-picker:has(>[data-time-start]):has(>[data-time-end]){grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr)}date-picker>input[data-time-start]{grid-column: 2;grid-row: 1;min-inline-size: 0}date-picker>input[data-time-end]{grid-column: 3;grid-row: 1;min-inline-size: 0}date-picker[range]{row-gap: var(--dp-gap)}date-picker[range]>input[data-range-start]{grid-row: 1}date-picker[range]>input[data-range-end]{grid-row: 2}date-picker[range]>.dp-picker-button[data-endpoint="start"]{grid-row: 1}date-picker[range]>.dp-picker-button[data-endpoint="end"]{grid-row: 2}.dp-picker-panel[popover]{position: fixed;inset: auto;margin: 0;padding: 0.875rem 1rem;border: 1px solid var(--dp-border);border-radius: var(--dp-radius);background: var(--dp-bg);color: var(--dp-fg);box-shadow: 0 0.5rem 1.5rem rgb(15 23 42 / 0.12);max-block-size: var(--available-height,90svh);max-inline-size: calc(100vi - 1rem);overflow: auto}.dp-picker-panel:not(:popover-open){display: none}@media (forced-colors: active){.dp-month-select.dp-skin,[dir="rtl"] .dp-month-select.dp-skin{appearance: auto;background-image: none;padding-inline: 0.45rem}.dp-day:is([data-selected="true"],[data-range-start="true"],[data-range-end="true"]){border: 2px solid Highlight;background-color: Canvas;color: CanvasText}.dp-day[data-in-range="true"]{color: CanvasText}.dp-day[data-in-range="true"]::after{content: "";position: absolute;inset-inline: 3px;inset-block-end: 4px;block-size: 1px;background-color: Highlight}.dp-day[data-today="true"]{border-color: Highlight}.dp-day-extra{color: CanvasText;forced-color-adjust: none}}
@@ -1,16 +1,16 @@
1
- /*** @lekoala/date-picker v0.5.3 - https://github.com/lekoala/date-picker ***/
2
- (()=>{var{defineProperty:wt,getOwnPropertyNames:ge,getOwnPropertyDescriptor:ye}=Object,ve=Object.prototype.hasOwnProperty;function be(t){return this[t]}var De=(t)=>{var e=(Pt??=new WeakMap).get(t),s;if(e)return e;if(e=wt({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function"){for(var i of ge(t))if(!ve.call(e,i))wt(e,i,{get:be.bind(t,i),enumerable:!(s=ye(t,i))||s.enumerable})}return Pt.set(t,e),e},Pt;var we=(t)=>t;function Ee(t,e){this[t]=we.bind(null,e)}var Ce=(t,e)=>{for(var s in e)wt(t,s,{get:e[s],enumerable:!0,configurable:!0,set:Ee.bind(e,s)})};var as={};Ce(as,{defineDatePicker:()=>ue});var tt=new WeakMap;var xe=/^(\d{4})-(\d{2})-(\d{2})$/,Ae=/^(\d{4})-(\d{2})$/;function Se(t){return t%4===0&&(t%100!==0||t%400===0)}function st(t,e){if(e===2)return Se(t)?29:28;return[4,6,9,11].includes(e)?30:31}function F(t){let e=xe.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=Number(e[3]);if(s<1||s>9999||i<1||i>12)return null;if(n<1||n>st(s,i))return null;return{year:s,month:i,day:n}}function c(t){return F(t)!==null}function p(t){let e=String(t||""),s=Ae.exec(e);if(s){let n=Number(s[1]),r=Number(s[2]);if(n>=1&&n<=9999&&r>=1&&r<=12)return`${s[1]}-${String(r).padStart(2,"0")}`}let i=F(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function G(t,e,s){let i=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(s).padStart(2,"0")}`;if(!c(i))throw TypeError(`Invalid civil date: ${i}`);return i}function N(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function ke(t){return G(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function V(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return N(e)}function _(t,e){if(!c(t)||!c(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function I(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=N(s);return i.setUTCDate(i.getUTCDate()+e),ke(i)}function ht(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let i=s.year*12+(s.month-1)+e,n=Math.floor(i/12),a=(i%12+12)%12+1,o=Math.min(s.day,st(n,a));return G(n,a,o)}function Bt(t,e){let s=F(t);if(!s||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let i=s.year+e,n=Math.min(s.day,st(i,s.month));return G(i,s.month,n)}function et(t,e){let s=`${p(t)}-01`;return p(ht(s,e))}function Me(t){return`${p(t)}-01`}function Et(t){let e=F(`${p(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return G(e.year,e.month,st(e.year,e.month))}function Te(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return N(e).getUTCDay()}function W(t){if(t===7)return 0;if(!Number.isInteger(t)||t<0||t>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return t}function ft(t,e=1){let s=(Te(t)-W(e)+7)%7;return I(t,-s)}function Ct(t,e=1){return I(ft(t,e),6)}function Nt(t,e={}){let s=e.firstDay??1,i=ft(Me(t),s),n=Ct(Et(t),s),r=[],a=i;for(;;){let o=[];for(let l=0;l<7;l++)o.push(I(a,l));if(r.push(o),_(o[6],n)>=0){if(!e.fixedWeeks||r.length>=6||_(o[6],I("9999-12-31",-7))>0)break}a=I(a,7)}return r}function Ht(t,e,s){let i=N({year:1,month:1,day:1});return Math.round((N({year:t,month:e,day:s}).getTime()-i.getTime())/86400000)}function it(t,e=1){let s=W(e),i=Ht(9999,12,31),n=p(t);for(;;){let r=F(`${n}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${t}`);let a=Ht(r.year,r.month,1),o=(N(r).getUTCDay()-s+7)%7;if(a-o<0){n=et(n,1);continue}let l=st(r.year,r.month),d={year:r.year,month:r.month,day:l},h=a+l-1,v=(N(d).getUTCDay()-s+7)%7;if(h-v+6>i){n=et(n,-1);continue}return n}}function Vt(t,e="",s=""){if(!c(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&_(t,e)<0)return e;if(s&&_(t,s)>0)return s;return t}function O(){let t=new Date;return G(t.getFullYear(),t.getMonth()+1,t.getDate())}function Ut(t){let e=F(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=N(e),i=s.getUTCDay()||7;s.setUTCDate(s.getUTCDate()+4-i);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(s.getUTCFullYear(),0,1),Math.ceil(((s.getTime()-n.getTime())/86400000+1)/7)}class xt{constructor(t={}){let e=O();this.firstDay=W(t.firstDay??1),this.value=t.value&&c(t.value)?t.value:"",this.focused=t.focused&&c(t.focused)?t.focused:this.value||e,this.display=t.display?p(t.display):p(this.focused)}setValue(t){if(t&&!c(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=p(t),s=Number(this.focused.slice(8,10))||1,i=ht(`${e}-01`,0),n=I(i,Math.max(0,s-1));return this.focused=p(n)===e?n:I(`${et(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!c(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=p(t);return this.focused}moveFocusDays(t){return this.setFocused(I(this.focused,t))}moveFocusMonths(t){return this.setFocused(ht(this.focused,t))}moveFocusYears(t){return this.setFocused(Bt(this.focused,t))}focusWeekStart(){return this.setFocused(ft(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(Ct(this.focused,this.firstDay))}navigateMonth(t){let e=et(this.display,t);return this.setDisplay(e),this.display}}function Ie(t){if(typeof t!=="string")return"";return[...new Set(t.split(/\s+/).filter((e)=>e&&!e.startsWith("dp-")&&![...e].some((s)=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)))].join(" ")}function kt(t,e){return t.month===e.month&&t.year===e.year&&t.nav===e.nav}var At={month:"",year:"",nav:""};function nt(){return{...At}}function rt(t){if(t==null)return null;let e={};for(let s of["month","year","nav"])if(Object.hasOwn(t,s))e[s]=Ie(t[s]);return e}function Gt(t){return t==null||["month","year","nav"].some((e)=>!Object.hasOwn(t,e))}function at(t){return{...nt(),...rt(t)}}function pt(t){let e=at(t);if(kt(At,e))return;At=e;for(let s of St)s()}var St=new Set;function Yt(t){return St.add(t),()=>{St.delete(t)}}function mt(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:s=""}=t;if(e&&!c(e))throw TypeError(`Invalid range start: ${e}`);if(s&&!c(s))throw TypeError(`Invalid range end: ${s}`);if(!e&&s)throw TypeError("highlightedRange cannot define an end without a start");if(e&&s&&_(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function _t(t,e){if(!e||!c(t))return"";let{start:s,end:i}=e;if(!s||!c(s))return"";if(s===t)return i?i===t?"single":"start":"start";if(i&&i===t)return"end";if(i&&_(t,s)>=0&&_(t,i)<=0)return"in";return""}class Mt{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&_(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}_refuse(t){return{status:"refused",endpoint:t,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(t,e=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);let{start:s,end:i}=this;if(this.complete&&(_(t,s)<0||_(t,i)>0)){let r=_(t,s)<0?"start":"end";if(!e(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:t,end:i}:{start:s,end:t},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(s&&!i&&_(t,s)<0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:t,end:s},activeEndpoint:"end"}}if(s&&_(t,s)<0)return this._refuse("end");if(!e("end"))return this._refuse("end");return{status:s?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:s,end:t},activeEndpoint:"end"}}if(i&&!s&&_(t,i)>0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:i,end:t},activeEndpoint:"start"}}if(!e("start"))return this._refuse("start");let n=e("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:t,end:i},activeEndpoint:n?"end":this.activeEndpoint,...n?{}:{close:!0}}}projectEndpoint(t,e,s=()=>!0){if(!c(t))throw TypeError(`Invalid range activation: ${t}`);if(!this.complete||!s(e))return this._refuse(e);let{start:i,end:n}=this,r=e==="start"?i:n,a=e==="start"?Fe(t,n):$e(t,i);return{status:"complete",endpoint:e,changedEndpoints:a===r?[]:[e],range:e==="start"?{start:a,end:n}:{start:i,end:a},activeEndpoint:e}}previewRange(t,e="",s=()=>!0){if(!c(t))return null;if(!e&&Boolean(this.start)===Boolean(this.end))return null;let i=e?this.projectEndpoint(t,e,s):this.project(t,s);if(i.status==="refused")return null;let{start:n,end:r}=i.range;if(!n||r&&_(r,n)<0)return null;return{start:n,end:r}}_apply(t){if(t.status==="refused")return t;return this.start=t.range.start,this.end=t.range.end,this.activeEndpoint=t.activeEndpoint,t}activate(t,e=()=>!0){return this._apply(this.project(t,e))}moveEndpoint(t,e,s=()=>!0){return this._apply(this.projectEndpoint(t,e,s))}}function $e(t,e){if(!t)return e;if(!e)return t;return _(t,e)>=0?t:e}function Fe(t,e){if(!t)return e;if(!e)return t;return _(t,e)<=0?t:e}var Wt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,Le=new Map,Re=new Map;function zt(t,e,s){let i=t.get(e);if(i!==void 0)return i;let n=s(),r=t.keys().next().value;if(t.size>=64&&r!==void 0)t.delete(r);return t.set(e,n),n}function z(t,e){let s=JSON.stringify([t,e]);return zt(Le,s,()=>new Intl.DateTimeFormat(t,e))}function P(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Oe(t){return zt(Re,t,()=>{let e=new Intl.NumberFormat(t,{useGrouping:!1}),s=new Map;for(let i=0;i<=9;i++)s.set(e.format(i),String(i));return s})}function jt(t,e,s={}){let i=String(t||"").replace(Wt,"");if(s.trim!==!1)i=i.trim();for(let[n,r]of Oe(e))i=i.split(n).join(r);return i}function ot(t,e=""){let s=P(e);return z(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(V(t))}function qt(t,e=""){let s=P(e);return z(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(V(`${t.slice(0,7)}-15`))}function Kt(t=""){let e=P(t);try{let s=z(e,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(V("2026-09-15")),i=-1,n=-1;if(s.forEach((r,a)=>{let o=r.type;if(o==="month"){if(i<0)i=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),i>=0&&n>=0)return n<i?["year","month"]:["month","year"]}catch{}return["month","year"]}function Xt(t="",e="long"){let s=P(t),i=z(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(V(`2026-${String(r+1).padStart(2,"0")}-15`)))}function Tt(t="",e=1,s="short"){let i=P(t),n=z(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=W(e),a=V("2026-01-04");return Array.from({length:7},(o,l)=>{let d=new Date(a);return d.setUTCDate(a.getUTCDate()+(r+l)%7),n.format(d)})}function Pe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function lt(t=""){let e=P(t),s=z(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=V("2006-11-22"),n=s.formatToParts(i).filter((d)=>d.type!=="literal"||d.value),r=n.filter((d)=>["day","month","year"].includes(d.type)).map((d)=>d.type),a=n.map((d)=>{if(d.type==="day")return"DD";if(d.type==="month")return"MM";if(d.type==="year")return"YYYY";return d.value.replace(Wt,"")}).join(""),o=n.map((d)=>{if(d.type==="day"||d.type==="month")return"(\\d{1,2})";if(d.type==="year")return"(\\d{4})";let h=jt(d.value,e,{trim:!1});return Pe(h).replace(/\s+/g,"\\s*")}).join(""),l=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(d){if(!c(d))return"";return s.format(V(d))},parse(d){let h=jt(d,e);if(c(h))return h;let v=l.exec(h);if(!v)return"";let w={};if(r.forEach((E,k)=>{w[E]=Number(v[k+1])}),!w.year||!w.month||!w.day)return"";try{return G(w.year,w.month,w.day)}catch{return""}}}}var He={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},It={...He};function U(){return{...It}}function gt(t){It={...It,...t};for(let e of $t)e()}var $t=new Set;function yt(t){return $t.add(t),()=>{$t.delete(t)}}function Zt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,s=new Map;if(Array.isArray(e)){for(let i of e){if(!i||typeof i!=="object"||!("date"in i))continue;let{date:n,...r}=i;s.set(String(n),r)}return s}if(e&&typeof e==="object")for(let[i,n]of Object.entries(e))s.set(i,n&&typeof n==="object"?n:{});return s}function q(t,e){for(let s of e){if(!Object.hasOwn(t,s))continue;let i=Reflect.get(t,s);Reflect.deleteProperty(t,s),Reflect.set(t,s,i)}}var Be=0;function S(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function Ne(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Ve(t){return Number(t.slice(0,4))}function vt(t,e){let[s,i]=t.split("-").map(Number),n=s*12+(i-1)+e,r=Math.floor(n/12),a=(n%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function Jt(t){return{"data-range-start":t==="start"||t==="single","data-range-end":t==="end"||t==="single","data-in-range":t==="in"}}function Ue(t){return Object.entries(Jt(t)).filter(([,e])=>e).map(([e])=>` ${e}="true"`).join("")}function Ge(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class dt extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];static setDefaultControlClasses(t){pt(t)}static getDefaultControlClasses(){return nt()}static setDefaultMessages(t){gt(t)}static getDefaultMessages(){return U()}constructor(){super();this._id=`date-calendar-${++Be}`,this._model=new xt,this._connected=!1,this._lifecycleId=0,this._rendering=!1,this._heading=null,this._renderRoot=null,this._source=null,this._hostIntent=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._paintedRange={start:"",end:""},this._paintedPreview=!1,this._renderedStates=new Map,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._stopDefaultControlClasses=null,this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;this._lifecycleId++,q(this,["locale","min","max","firstDay","selection","monthFormat","fixedWeeks","showWeekNumbers","controlClasses","messages","source","dateState","renderDay","isDateDisabled","highlightedRange","value","display"]),this._syncModel(),q(this,["focusedDate"]),this._stopDefaultControlClasses=Yt(()=>{if(Gt(this._controlClasses))this.render()}),this._stopDefaultMessages=yt(()=>{if(this._messages===null)this.render()}),this._connected=!0,this.addEventListener("click",this._onClick),this.addEventListener("change",this._onChange),this.addEventListener("keydown",this._onKeyDown),this.addEventListener("focusin",this._onFocusIn),this.render()}disconnectedCallback(){this._stopDefaultControlClasses?.(),this._stopDefaultControlClasses=null,this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._lifecycleId++,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeEventListener("click",this._onClick),this.removeEventListener("change",this._onChange),this.removeEventListener("keydown",this._onKeyDown),this.removeEventListener("focusin",this._onFocusIn)}attributeChangedCallback(t,e,s){if(this._rendering)return;if(t==="value"&&s&&!c(s)){this._reflect("value",this._model.value);return}if((t==="min"||t==="max")&&s&&!c(s)){if(this._reflect(t,""),this._connected)this._syncModel(),this.render();return}if(t==="display"&&s)try{if(p(s)!==s)throw TypeError("Non-canonical month")}catch{this._reflect("display",this._model.display);return}if(!this._connected)return;this._syncModel(),this.render()}_queueFocus(t){let e=this._lifecycleId;queueMicrotask(()=>{if(!this._connected||e!==this._lifecycleId)return;t()})}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!c(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return Ne(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=mt(t),s=this.hasAttribute("data-range-preview");if(e.start===this._paintedRange.start&&e.end===this._paintedRange.end&&s===this._paintedPreview)return;if(this._highlightedRange=e,this._connected)this._updateRangeDom()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get controlClasses(){return at(this._controlClasses)}set controlClasses(t){let e=this.controlClasses;if(this._controlClasses=rt(t),kt(e,this.controlClasses))return;if(this._connected)this.render()}get messages(){return this._messages??U()}set messages(t){if(this._messages=t==null?null:{...U(),...t},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||c(e))this._model.value=e;let s=this.getAttribute("display")||"";if(s)try{this._model.setDisplay(it(s,t))}catch{}else if(this._model.value)this._model.display=p(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=p(this._model.focused)}_reflect(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){let e=Vt(t,this.min,this.max),s=p(e),i=it(s,this.firstDay);if(i===s)return e;let n=Number(e.slice(8,10))||1,r=I(`${i}-01`,n-1),a=Et(i);return _(r,a)>0?a:r}_weeks(t=this.display){return Nt(it(t,this.firstDay),{firstDay:this.firstDay,fixedWeeks:this.fixedWeeks})}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(c(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),s=e[0],i=e[e.length-1];if(!s||!i)throw Error("Calendar month produced no weeks");return{start:s[0],end:i[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},s=this._dateState?.(t,{...e})||{},i={...e,...s},n=this.min&&_(t,this.min)<0||this.max&&_(t,this.max)>0,a=i.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(i.disabled)||a;return{...i,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(t){if(!c(t)||!this._source)return!0;return await this._loadDisplay(p(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let s=this._range(t),i=`${s.start}/${s.end}`;if(this._loadedRanges.has(i))return"loaded";if(i===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=i;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:s,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let l=await o(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[d,h]of Zt(l))this._sourceStates.set(d,h);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,bubbles:!0})),e&&this._connected&&p(this.display)===p(t))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...s,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this.removeAttribute("data-loading");if(this._loadingKey===i)this._loadingKey="",this._loadingPromise=null}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let s=this._model.display;if(this._model.setDisplay(it(t,this.firstDay)),this._model.focused=this._clamp(this._model.focused),this._model.display=p(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(e.emit!==!1&&s!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(vt(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(vt(this.display,1)??this.display)}focusDate(t,e={}){if(!c(t))throw TypeError(`Invalid date: ${t}`);let s=this._clamp(t),i=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(s),this._reflect("display",this._model.display),i!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)this._queueFocus(()=>this.focusGrid())}_moveFocusDom(t,e,s=!0){let i=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,s)n.focus()}else if(s)this.focusGrid()}_syncRovingDom(t){for(let s of this.querySelectorAll('.dp-day[tabindex="0"]'))if(s instanceof HTMLElement&&s.dataset.date!==t)s.tabIndex=-1;let e=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(e instanceof HTMLElement)e.tabIndex=0}_moveSelectionDom(t,e){if(t){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.removeAttribute("data-selected"),s.removeAttribute("aria-selected")}if(e){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)return s.setAttribute("data-selected","true"),s.setAttribute("aria-selected","true"),!0}return!1}_dayLabel(t,e,s){let i=this.hasAttribute("data-range-preview")?"":Ge(s),n=typeof e.description==="string"?e.description:"";return[ot(t,this.locale),n,i?this.messages[i]:"",e.disabled?this.messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){let t=this._paintedRange,e=this._paintedPreview;this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let s of this.querySelectorAll(".dp-day[data-date]")){if(!(s instanceof HTMLTableCellElement))continue;let i=s.dataset.date||"",n=_t(i,this._highlightedRange);if(n===_t(i,t)&&e===this._paintedPreview)continue;for(let[r,a]of Object.entries(Jt(n)))if(a)s.setAttribute(r,"true");else s.removeAttribute(r);if(!e||!this._paintedPreview){let r=this._renderedStates.get(i)||{},a=this._dayLabel(i,r,n);if(s.getAttribute("aria-label")!==a)s.setAttribute("aria-label",a)}}}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async activateDate(t){if(!this._connected)return!1;let e=this._lifecycleId,s=this._hostIntent?.date===t?this._hostIntent.intent:void 0;this._hostIntent=null;let i=(o)=>{if(s!==void 0)tt.set(o,s);return o},n=await this.ensureDate(t);if(!this._connected||e!==this._lifecycleId)return!1;let r=this.getDateState(t);if(!n||r.disabled)return this.dispatchEvent(i(new CustomEvent("dateinvalid",{detail:{date:t,state:r},bubbles:!0}))),!1;if(!this.dispatchEvent(i(new CustomEvent("dateactivate",{detail:{date:t,state:r},bubbles:!0,cancelable:!0}))))return!1;if(this.selection==="single"){let o=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(p(t)===this.display)this._moveSelectionDom(o,t);else this.render()}else if(this._connected){if(p(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let s=e.closest("[data-calendar-action]");if(s instanceof HTMLButtonElement){let a=s.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let i=e.closest(".dp-day[data-date]");if(!(i instanceof HTMLTableCellElement))return;let n=i.dataset.date||"";if(!c(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();else this._syncRovingDom(this._model.focused);this.activateDate(n)}_onChange(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let s=Number(e.value);if(!Number.isInteger(s)||s<1||s>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(s).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||"";if(!c(s))return;this._model.focused=s,this._syncRovingDom(s),this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:s,state:this.getDateState(s)},bubbles:!0}))}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.activateDate(s);return}let i=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(s,{follow:!1}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=i,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,s=this.display,i=Ve(s),n=Number(s.slice(5,7)),r=Xt(e,this.monthFormat),a=Tt(e,this.firstDay,"short"),o=Tt(e,this.firstDay,"long"),l=this._weeks(),d=O(),h=`${this._id}-heading`,v=`${this._id}-grid`,w=this.min?p(this.min):"",E=this.max?p(this.max):"",k=vt(s,-1),M=vt(s,1),T=Boolean(w&&k!==null&&k<w),y=Boolean(E&&M!==null&&M>E),b=` min="${this.min?Number(this.min.slice(0,4)):1}"`,C=` max="${this.max?Number(this.max.slice(0,4)):9999}"`,A=this.showWeekNumbers&&this.firstDay===1,x=A?`<th scope="col" class="dp-week-heading" abbr="${S(this.messages.week)}">#</th>`:"",B=r.map((u,f)=>{let D=f+1,m=`${String(i).padStart(4,"0")}-${String(D).padStart(2,"0")}`,Q=w&&m<w||E&&m>E;return`<option value="${String(D).padStart(2,"0")}"${D===n?" selected":""}${Q?" disabled":""}>${S(u)}</option>`}).join(""),L=a.map((u,f)=>`<th scope="col" abbr="${S(o[f])}">${S(u.replace(".",""))}</th>`).join("");this._renderedStates.clear();let Y=l.map((u)=>{let f=A?`<th scope="row" class="dp-week-number">${Ut(u[0])}</th>`:"",D=u.map((m)=>{let Q=this.getDateState(m);this._renderedStates.set(m,Q);let he=p(m)!==s,fe=this.value===m,pe=this.focusedDate===m,me=m===d,Ot=_t(m,this._highlightedRange),_e=this._dayLabel(m,Q,Ot);return`<td class="dp-day" data-date="${m}"${he?' data-outside-month="true"':""}${me?' data-today="true" aria-current="date"':""}${fe?' data-selected="true" aria-selected="true"':""}${Ue(Ot)}${Q.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${pe?"0":"-1"}" aria-label="${S(_e)}"><span class="dp-day-number" aria-hidden="true">${Number(m.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${f}${D}</tr>`}).join(""),K=document.activeElement,X=K instanceof HTMLElement&&this.contains(K)?this._focusTargetKey(K):"",R=Kt(e)[0]==="year";this.toggleAttribute("data-year-first",R);let Z=this.controlClasses,j=S(Z.month||"dp-skin"),Dt=S(Z.year||"dp-skin"),ut=S(Z.nav||"dp-skin"),J=`<label class="dp-visually-hidden" for="${this._id}-month">${S(this.messages.month)}</label>
3
- <select id="${this._id}-month" class="dp-month-select ${j}" aria-label="${S(this.messages.month)}">${B}</select>`,g=`<label class="dp-visually-hidden" for="${this._id}-year">${S(this.messages.year)}</label>
4
- <input id="${this._id}-year" class="dp-year-input ${Dt}" type="number" inputmode="numeric" value="${i}"${b}${C} aria-label="${S(this.messages.year)}">`;if(!this._heading?.isConnected||!this._renderRoot?.isConnected){this.replaceChildren();let u=document.createElement("h2");u.id=h,u.className="dp-calendar-heading dp-visually-hidden",u.setAttribute("aria-live","polite");let f=document.createElement("div");f.className="dp-calendar-render",this.append(u,f),this._heading=u,this._renderRoot=f}if(this._rendering=!0,this._renderRoot.innerHTML=`
1
+ /*** @lekoala/date-picker v0.6.0 - https://github.com/lekoala/date-picker ***/
2
+ (()=>{var{defineProperty:xt,getOwnPropertyNames:ye,getOwnPropertyDescriptor:be}=Object,ve=Object.prototype.hasOwnProperty;function De(t){return this[t]}var we=(t)=>{var e=(Bt??=new WeakMap).get(t),s;if(e)return e;if(e=xt({},"__esModule",{value:!0}),t&&typeof t==="object"||typeof t==="function"){for(var i of ye(t))if(!ve.call(e,i))xt(e,i,{get:De.bind(t,i),enumerable:!(s=be(t,i))||s.enumerable})}return Bt.set(t,e),e},Bt;var Ee=(t)=>t;function xe(t,e){this[t]=Ee.bind(null,e)}var Ce=(t,e)=>{for(var s in e)xt(t,s,{get:e[s],enumerable:!0,configurable:!0,set:xe.bind(e,s)})};var rs={};Ce(rs,{defineDatePicker:()=>he});var st=new WeakMap;var Ae=/^(\d{4})-(\d{2})-(\d{2})$/,Se=/^(\d{4})-(\d{2})$/;function ke(t){return t%4===0&&(t%100!==0||t%400===0)}function nt(t,e){if(e===2)return ke(t)?29:28;return[4,6,9,11].includes(e)?30:31}function R(t){let e=Ae.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=Number(e[3]);if(s<1||s>9999||i<1||i>12)return null;if(n<1||n>nt(s,i))return null;return{year:s,month:i,day:n}}function l(t){return R(t)!==null}function p(t){let e=String(t||""),s=Se.exec(e);if(s){let n=Number(s[1]),r=Number(s[2]);if(n>=1&&n<=9999&&r>=1&&r<=12)return`${s[1]}-${String(r).padStart(2,"0")}`}let i=R(e);if(!i)throw TypeError(`Invalid civil date/month: ${t}`);return`${String(i.year).padStart(4,"0")}-${String(i.month).padStart(2,"0")}`}function z(t,e,s){let i=`${String(t).padStart(4,"0")}-${String(e).padStart(2,"0")}-${String(s).padStart(2,"0")}`;if(!l(i))throw TypeError(`Invalid civil date: ${i}`);return i}function N(t){let e=new Date(0);return e.setUTCHours(12,0,0,0),e.setUTCFullYear(t.year,t.month-1,t.day),e}function Me(t){return z(t.getUTCFullYear(),t.getUTCMonth()+1,t.getUTCDate())}function V(t){let e=R(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return N(e)}function g(t,e){if(!l(t)||!l(e))throw TypeError("compareDates() expects YYYY-MM-DD values");return t===e?0:t<e?-1:1}function F(t,e){let s=R(t);if(!s||!Number.isInteger(e))throw TypeError("addDays() expects a date and integer amount");let i=N(s);return i.setUTCDate(i.getUTCDate()+e),Me(i)}function pt(t,e){let s=R(t);if(!s||!Number.isInteger(e))throw TypeError("addMonths() expects a date and integer amount");let i=s.year*12+(s.month-1)+e,n=Math.floor(i/12),a=(i%12+12)%12+1,o=Math.min(s.day,nt(n,a));return z(n,a,o)}function Vt(t,e){let s=R(t);if(!s||!Number.isInteger(e))throw TypeError("addYears() expects a date and integer amount");let i=s.year+e,n=Math.min(s.day,nt(i,s.month));return z(i,s.month,n)}function it(t,e){let s=`${p(t)}-01`;return p(pt(s,e))}function Te(t){return`${p(t)}-01`}function Ct(t){let e=R(`${p(t)}-01`);if(!e)throw TypeError(`Invalid month: ${t}`);return z(e.year,e.month,nt(e.year,e.month))}function $e(t){let e=R(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);return N(e).getUTCDay()}function j(t){if(t===7)return 0;if(!Number.isInteger(t)||t<0||t>6)throw RangeError("firstDay must be 0..6 (Sunday=0, 7 accepted as Sunday alias)");return t}function mt(t,e=1){let s=($e(t)-j(e)+7)%7;return F(t,-s)}function At(t,e=1){return F(mt(t,e),6)}function Ut(t,e={}){let s=e.firstDay??1,i=mt(Te(t),s),n=At(Ct(t),s),r=[],a=i;for(;;){let o=[];for(let d=0;d<7;d++)o.push(F(a,d));if(r.push(o),g(o[6],n)>=0){if(!e.fixedWeeks||r.length>=6||g(o[6],F("9999-12-31",-7))>0)break}a=F(a,7)}return r}function Nt(t,e,s){let i=N({year:1,month:1,day:1});return Math.round((N({year:t,month:e,day:s}).getTime()-i.getTime())/86400000)}function rt(t,e=1){let s=j(e),i=Nt(9999,12,31),n=p(t);for(;;){let r=R(`${n}-01`);if(!r)throw TypeError(`Invalid civil date/month: ${t}`);let a=Nt(r.year,r.month,1),o=(N(r).getUTCDay()-s+7)%7;if(a-o<0){n=it(n,1);continue}let d=nt(r.year,r.month),c={year:r.year,month:r.month,day:d},h=a+d-1,b=(N(c).getUTCDay()-s+7)%7;if(h-b+6>i){n=it(n,-1);continue}return n}}function zt(t,e="",s=""){if(!l(t))throw TypeError(`Invalid civil date: ${t}`);if(e&&g(t,e)<0)return e;if(s&&g(t,s)>0)return s;return t}function O(){let t=new Date;return z(t.getFullYear(),t.getMonth()+1,t.getDate())}function Wt(t){let e=R(t);if(!e)throw TypeError(`Invalid civil date: ${t}`);let s=N(e),i=s.getUTCDay()||7;s.setUTCDate(s.getUTCDate()+4-i);let n=new Date(0);return n.setUTCHours(12,0,0,0),n.setUTCFullYear(s.getUTCFullYear(),0,1),Math.ceil(((s.getTime()-n.getTime())/86400000+1)/7)}class St{constructor(t={}){let e=O();this.firstDay=j(t.firstDay??1),this.value=t.value&&l(t.value)?t.value:"",this.focused=t.focused&&l(t.focused)?t.focused:this.value||e,this.display=t.display?p(t.display):p(this.focused)}setValue(t){if(t&&!l(t))throw TypeError(`Invalid value: ${t}`);return this.value=t||"",this.value}setDisplay(t){let e=p(t),s=Number(this.focused.slice(8,10))||1,i=pt(`${e}-01`,0),n=F(i,Math.max(0,s-1));return this.focused=p(n)===e?n:F(`${it(e,1)}-01`,-1),this.display=e,this.display}setFocused(t,e={}){if(!l(t))throw TypeError(`Invalid focused date: ${t}`);if(this.focused=t,e.follow!==!1)this.display=p(t);return this.focused}moveFocusDays(t){return this.setFocused(F(this.focused,t))}moveFocusMonths(t){return this.setFocused(pt(this.focused,t))}moveFocusYears(t){return this.setFocused(Vt(this.focused,t))}focusWeekStart(){return this.setFocused(mt(this.focused,this.firstDay))}focusWeekEnd(){return this.setFocused(At(this.focused,this.firstDay))}navigateMonth(t){let e=it(this.display,t);return this.setDisplay(e),this.display}}function Fe(t){if(typeof t!=="string")return"";return[...new Set(t.split(/\s+/).filter((e)=>e&&!e.startsWith("dp-")&&![...e].some((s)=>s.charCodeAt(0)<32||s.charCodeAt(0)===127)))].join(" ")}function Tt(t,e){return t.month===e.month&&t.year===e.year&&t.nav===e.nav}var kt={month:"",year:"",nav:""};function at(){return{...kt}}function ot(t){if(t==null)return null;let e={};for(let s of["month","year","nav"])if(Object.hasOwn(t,s))e[s]=Fe(t[s]);return e}function Yt(t){return t==null||["month","year","nav"].some((e)=>!Object.hasOwn(t,e))}function lt(t){return{...at(),...ot(t)}}function _t(t){let e=lt(t);if(Tt(kt,e))return;kt=e;for(let s of Mt)s()}var Mt=new Set;function jt(t){return Mt.add(t),()=>{Mt.delete(t)}}function gt(t){if(t==null)return{start:"",end:""};if(typeof t!=="object")throw TypeError("highlightedRange expects { start, end }");let{start:e="",end:s=""}=t;if(e&&!l(e))throw TypeError(`Invalid range start: ${e}`);if(s&&!l(s))throw TypeError(`Invalid range end: ${s}`);if(!e&&s)throw TypeError("highlightedRange cannot define an end without a start");if(e&&s&&g(s,e)<0)throw TypeError("highlightedRange must be ordered; start must be on or before end");return{start:e,end:s}}function yt(t,e){if(!e||!l(t))return"";let{start:s,end:i}=e;if(!s||!l(s))return"";if(s===t)return i?i===t?"single":"start":"start";if(i&&i===t)return"end";if(i&&g(t,s)>=0&&g(t,i)<=0)return"in";return""}class $t{constructor(){this.activeEndpoint="",this.start="",this.end=""}get range(){return{start:this.start,end:this.end}}get complete(){return Boolean(this.start&&this.end&&g(this.end,this.start)>=0)}focus(t){this.activeEndpoint=t}_refuse(t){return{status:"refused",endpoint:t,changedEndpoints:[],range:this.range,activeEndpoint:this.activeEndpoint}}project(t,e=()=>!0){if(!l(t))throw TypeError(`Invalid range activation: ${t}`);let{start:s,end:i}=this;if(this.complete&&(g(t,s)<0||g(t,i)>0)){let r=g(t,s)<0?"start":"end";if(!e(r))return this._refuse(r);return{status:"complete",endpoint:r,changedEndpoints:[r],range:r==="start"?{start:t,end:i}:{start:s,end:t},activeEndpoint:r}}if(this.activeEndpoint==="end"){if(s&&!i&&g(t,s)<0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"end",changedEndpoints:["start","end"],range:{start:t,end:s},activeEndpoint:"end"}}if(s&&g(t,s)<0)return this._refuse("end");if(!e("end"))return this._refuse("end");return{status:s?"complete":"pending",endpoint:"end",changedEndpoints:["end"],range:{start:s,end:t},activeEndpoint:"end"}}if(i&&!s&&g(t,i)>0){if(!e("start"))return this._refuse("start");if(!e("end"))return this._refuse("end");return{status:"complete",endpoint:"start",changedEndpoints:["start","end"],range:{start:i,end:t},activeEndpoint:"start"}}if(!e("start"))return this._refuse("start");let n=e("end");return{status:"pending",endpoint:"start",changedEndpoints:["start"],range:{start:t,end:i},activeEndpoint:n?"end":this.activeEndpoint,...n?{}:{close:!0}}}previewRange(t,e=()=>!0){if(!l(t))return null;if(Boolean(this.start)===Boolean(this.end))return null;let s=this.project(t,e);if(s.status==="refused")return null;let{start:i,end:n}=s.range;if(!i||n&&g(n,i)<0)return null;return{start:i,end:n}}_apply(t){if(t.status==="refused")return t;return this.start=t.range.start,this.end=t.range.end,this.activeEndpoint=t.activeEndpoint,t}activate(t,e=()=>!0){return this._apply(this.project(t,e))}}var Kt=/[\u200e\u200f\u061c\u202a-\u202e\u2066-\u2069]/g,Re=new Map,Le=new Map;function Gt(t,e,s){let i=t.get(e);if(i!==void 0)return i;let n=s(),r=t.keys().next().value;if(t.size>=64&&r!==void 0)t.delete(r);return t.set(e,n),n}function q(t,e){let s=JSON.stringify([t,e]);return Gt(Re,s,()=>new Intl.DateTimeFormat(t,e))}function P(t=""){if(t)return t;if(typeof document<"u"&&document.documentElement.lang)return document.documentElement.lang;if(typeof navigator<"u"&&navigator.language)return navigator.language;return"en-US"}function Ie(t){return Gt(Le,t,()=>{let e=new Intl.NumberFormat(t,{useGrouping:!1}),s=new Map;for(let i=0;i<=9;i++)s.set(e.format(i),String(i));return s})}function qt(t,e,s={}){let i=String(t||"").replace(Kt,"");if(s.trim!==!1)i=i.trim();for(let[n,r]of Ie(e))i=i.split(n).join(r);return i}function dt(t,e=""){let s=P(e);return q(s,{calendar:"gregory",weekday:"long",year:"numeric",month:"long",day:"numeric",timeZone:"UTC"}).format(V(t))}function Zt(t,e=""){let s=P(e);return q(s,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).format(V(`${t.slice(0,7)}-15`))}function Xt(t=""){let e=P(t);try{let s=q(e,{calendar:"gregory",year:"numeric",month:"long",timeZone:"UTC"}).formatToParts(V("2026-09-15")),i=-1,n=-1;if(s.forEach((r,a)=>{let o=r.type;if(o==="month"){if(i<0)i=a}else if(o==="year"||o==="relatedYear"||o==="yearName"){if(n<0)n=a}}),i>=0&&n>=0)return n<i?["year","month"]:["month","year"]}catch{}return["month","year"]}function Jt(t="",e="long"){let s=P(t),i=q(s,{calendar:"gregory",month:e,timeZone:"UTC"});return Array.from({length:12},(n,r)=>i.format(V(`2026-${String(r+1).padStart(2,"0")}-15`)))}function Ft(t="",e=1,s="short"){let i=P(t),n=q(i,{calendar:"gregory",weekday:s,timeZone:"UTC"}),r=j(e),a=V("2026-01-04");return Array.from({length:7},(o,d)=>{let c=new Date(a);return c.setUTCDate(a.getUTCDate()+(r+d)%7),n.format(c)})}function Oe(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ct(t=""){let e=P(t),s=q(e,{calendar:"gregory",year:"numeric",month:"2-digit",day:"2-digit",timeZone:"UTC"}),i=V("2006-11-22"),n=s.formatToParts(i).filter((c)=>c.type!=="literal"||c.value),r=n.filter((c)=>["day","month","year"].includes(c.type)).map((c)=>c.type),a=n.map((c)=>{if(c.type==="day")return"DD";if(c.type==="month")return"MM";if(c.type==="year")return"YYYY";return c.value.replace(Kt,"")}).join(""),o=n.map((c)=>{if(c.type==="day"||c.type==="month")return"(\\d{1,2})";if(c.type==="year")return"(\\d{4})";let h=qt(c.value,e,{trim:!1});return Oe(h).replace(/\s+/g,"\\s*")}).join(""),d=new RegExp(`^\\s*${o}\\s*$`);return{locale:e,placeholder:a,format(c){if(!l(c))return"";return s.format(V(c))},parse(c){let h=qt(c,e);if(l(h))return h;let b=d.exec(h);if(!b)return"";let w={};if(r.forEach((E,k)=>{w[E]=Number(b[k+1])}),!w.year||!w.month||!w.day)return"";try{return z(w.year,w.month,w.day)}catch{return""}}}}var Pe={chooseDate:"Choose date",changeDate:"Change date",previousMonth:"Previous month",nextMonth:"Next month",month:"Month",year:"Year",calendar:"Choose a date",unavailable:"Unavailable",invalidDate:"Enter a valid date",unavailableDate:"This date is unavailable",formatHint:"Format",week:"Week",rangeStart:"Range start",rangeInRange:"Inside range",rangeEnd:"Range end",rangeSingle:"Range of one day",rangeOrderStart:"Start must be on or before end",rangeOrderEnd:"End must be on or after start"},Rt={...Pe};function U(){return{...Rt}}function bt(t){Rt={...Rt,...t};for(let e of Lt)e()}var Lt=new Set;function vt(t){return Lt.add(t),()=>{Lt.delete(t)}}function K(){return new AbortController}function G(t,e){return()=>{if(!t.aborted)e()}}function Qt(t){let e=t&&typeof t==="object"&&!Array.isArray(t)&&"dates"in t?t.dates:t,s=new Map;if(Array.isArray(e)){for(let i of e){if(!i||typeof i!=="object"||!("date"in i))continue;let{date:n,...r}=i;s.set(String(n),r)}return s}if(e&&typeof e==="object")for(let[i,n]of Object.entries(e))s.set(i,n&&typeof n==="object"?n:{});return s}function Z(t,e){for(let s of e){if(!Object.hasOwn(t,s))continue;let i=Reflect.get(t,s);Reflect.deleteProperty(t,s),Reflect.set(t,s,i)}}var He=0;function S(t){return String(t).replaceAll("&","&amp;").replaceAll("<","&lt;").replaceAll(">","&gt;").replaceAll('"',"&quot;").replaceAll("'","&#039;")}function Be(t){let e=Number(t);if(e===7)return 0;return Number.isInteger(e)&&e>=0&&e<=6?e:1}function Ne(t){return Number(t.slice(0,4))}function Dt(t,e){let[s,i]=t.split("-").map(Number),n=s*12+(i-1)+e,r=Math.floor(n/12),a=(n%12+12)%12+1;if(r<1||r>9999)return null;return`${String(r).padStart(4,"0")}-${String(a).padStart(2,"0")}`}function te(t){return{"data-range-start":t==="start"||t==="single","data-range-end":t==="end"||t==="single","data-in-range":t==="in"}}function Ve(t){return Object.entries(te(t)).filter(([,e])=>e).map(([e])=>` ${e}="true"`).join("")}function Ue(t){if(t==="single")return"rangeSingle";if(t==="start")return"rangeStart";if(t==="end")return"rangeEnd";if(t==="in")return"rangeInRange";return""}class ut extends HTMLElement{static observedAttributes=["value","display","min","max","first-day","locale","fixed-weeks","show-week-numbers","selection","month-format"];static setDefaultControlClasses(t){_t(t)}static getDefaultControlClasses(){return at()}static setDefaultMessages(t){bt(t)}static getDefaultMessages(){return U()}constructor(){super();this._id=`date-calendar-${++He}`,this._model=new St,this._connected=!1,this._session=null,this._rendering=!1,this._heading=null,this._renderRoot=null,this._source=null,this._hostIntent=null,this._sourceStates=new Map,this._loadedRanges=new Set,this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._highlightedRange={start:"",end:""},this._paintedRange={start:"",end:""},this._paintedPreview=!1,this._renderedStates=new Map,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._stopDefaultControlClasses=null,this._onClick=this._onClick.bind(this),this._onChange=this._onChange.bind(this),this._onKeyDown=this._onKeyDown.bind(this),this._onFocusIn=this._onFocusIn.bind(this)}connectedCallback(){if(this._connected)return;if(this._session=K(),Z(this,["locale","min","max","firstDay","selection","monthFormat","fixedWeeks","showWeekNumbers","controlClasses","messages","source","dateState","renderDay","isDateDisabled","highlightedRange","value","display"]),this._normalizeAttributes(),this._syncModel(),this.hasAttribute("display"))this._reflect("display",this._model.display);Z(this,["focusedDate"]),this._stopDefaultControlClasses=jt(()=>{if(Yt(this._controlClasses))this.render()}),this._stopDefaultMessages=vt(()=>{if(this._messages===null)this.render()}),this._connected=!0;let{signal:t}=this._session;this.addEventListener("click",this._onClick,{signal:t}),this.addEventListener("change",this._onChange,{signal:t}),this.addEventListener("keydown",this._onKeyDown,{signal:t}),this.addEventListener("focusin",this._onFocusIn,{signal:t}),this.render()}disconnectedCallback(){this._stopDefaultControlClasses?.(),this._stopDefaultControlClasses=null,this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeAttribute("data-loading"),this._session?.abort(),this._session=null}_normalizeAttributes(){let t=this.getAttribute("value");if(t&&!l(t))this.removeAttribute("value");for(let e of["min","max"]){let s=this.getAttribute(e);if(s&&!l(s))this.removeAttribute(e)}}attributeChangedCallback(t,e,s){if(this._rendering)return;if(!this._connected)return;if(t==="value"&&s&&!l(s)){this._reflect("value",this._model.value);return}if((t==="min"||t==="max")&&s&&!l(s)){if(this._reflect(t,""),this._connected)this._syncModel(),this.render();return}if(t==="display"&&s)try{if(p(s)!==s)throw TypeError("Non-canonical month")}catch{this._reflect("display",this._model.display);return}this._syncModel(),this.render()}_queueFocus(t){let e=this._session;if(!e)return;queueMicrotask(G(e.signal,t))}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get value(){return this._model.value}set value(t){let e=t||"";if(e&&!l(e))throw TypeError(`Invalid calendar value: ${e}`);if(e===this._model.value)return;if(this._model.setValue(e),this._reflect("value",e),this._connected)this.render()}get display(){return this._model.display}set display(t){this._setDisplay(t,{emit:!1})}get focusedDate(){return this._model.focused}set focusedDate(t){let e=t||"";if(e===this._model.focused)return;this.focusDate(e,{moveFocus:!1})}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get firstDay(){return Be(this.getAttribute("first-day")||"1")}set firstDay(t){this.setAttribute("first-day",String(t))}get selection(){return this.getAttribute("selection")==="none"?"none":"single"}set selection(t){this.setAttribute("selection",t==="none"?"none":"single")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get highlightedRange(){return{...this._highlightedRange}}set highlightedRange(t){let e=gt(t),s=this.hasAttribute("data-range-preview");if(e.start===this._paintedRange.start&&e.end===this._paintedRange.end&&s===this._paintedPreview)return;if(this._highlightedRange=e,this._connected)this._updateRangeDom()}get fixedWeeks(){return this.hasAttribute("fixed-weeks")}set fixedWeeks(t){this.toggleAttribute("fixed-weeks",Boolean(t))}get showWeekNumbers(){return this.hasAttribute("show-week-numbers")}set showWeekNumbers(t){this.toggleAttribute("show-week-numbers",Boolean(t))}get controlClasses(){return lt(this._controlClasses)}set controlClasses(t){let e=this.controlClasses;if(this._controlClasses=ot(t),Tt(e,this.controlClasses))return;if(this._connected)this.render()}get messages(){return this._messages??U()}set messages(t){if(this._messages=t==null?null:{...U(),...t},this._connected)this.render()}get source(){return this._source}set source(t){this._source=t||null,this.refreshSource()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._connected)this.render()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._connected)this.render()}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._connected)this.render()}_syncModel(){let t=this.firstDay;this._model.firstDay=t;let e=this.getAttribute("value")||"";if(!e||l(e))this._model.value=e;let s=this.getAttribute("display")||"";if(s)try{this._model.setDisplay(rt(s,t))}catch{}else if(this._model.value)this._model.display=p(this._model.value),this._model.focused=this._model.value;if(this._model.focused=this._clamp(this._model.focused),!this.getAttribute("display"))this._model.display=p(this._model.focused)}_reflect(t,e){if(this._rendering=!0,e){if(this.getAttribute(t)!==e)this.setAttribute(t,e)}else if(this.hasAttribute(t))this.removeAttribute(t);this._rendering=!1}_clamp(t){let e=zt(t,this.min,this.max),s=p(e),i=rt(s,this.firstDay);if(i===s)return e;let n=Number(e.slice(8,10))||1,r=F(`${i}-01`,n-1),a=Ct(i);return g(r,a)>0?a:r}_weeks(t=this.display){return Ut(rt(t,this.firstDay),{firstDay:this.firstDay,fixedWeeks:this.fixedWeeks})}_focusTargetKey(t){if(t.matches(".dp-month-select, .dp-year-input")&&t.id)return`#${CSS.escape(t.id)}`;if(t.matches(".dp-nav[data-calendar-action]"))return`.dp-nav[data-calendar-action="${CSS.escape(t.dataset.calendarAction||"")}"]`;if(t.matches(".dp-day[data-date]")){let e=t.getAttribute("data-date")||"";if(l(e))return`.dp-day[data-date="${e}"]`}return""}_range(t=this.display){let e=this._weeks(t),s=e[0],i=e[e.length-1];if(!s||!i)throw Error("Calendar month produced no weeks");return{start:s[0],end:i[6]}}getDateState(t){let e=this._sourceStates.get(t)||{},s=this._dateState?.(t,{...e})||{},i={...e,...s},n=this.min&&g(t,this.min)<0||this.max&&g(t,this.max)>0,a=i.enabled===!0?!1:Boolean(this._isDateDisabled?.(t)),o=Boolean(n)||Boolean(i.disabled)||a;return{...i,disabled:o}}async refreshSource(){if(this._loadController?.abort(),this._loadController=null,this._loadingKey="",this._loadingPromise=null,this._loadedRanges.clear(),this._sourceStates.clear(),this._connected)this.render(),await this._loadDisplay(this.display)}async ensureDate(t){if(!l(t)||!this._source)return!0;return await this._loadDisplay(p(t),!1)==="loaded"}async _loadDisplay(t,e=!0){if(!this._source)return"loaded";let s=this._range(t),i=`${s.start}/${s.end}`;if(this._loadedRanges.has(i))return"loaded";if(i===this._loadingKey&&this._loadingPromise)return this._loadingPromise;this._loadController?.abort();let n=new AbortController;this._loadController=n,this._loadingKey=i;let r=this._source,a=(async()=>{this.toggleAttribute("data-loading",!0),this.dispatchEvent(new CustomEvent("dateloadstart",{detail:s,bubbles:!0}));try{let o=typeof r==="function"?r:r?.load?.bind(r);if(!o)throw TypeError("Date source must be a function or expose load(range, { signal })");let d=await o(s,{signal:n.signal});if(n.signal.aborted)return"cancelled";for(let[c,h]of Qt(d))this._sourceStates.set(c,h);if(this._loadedRanges.add(i),this.dispatchEvent(new CustomEvent("dateloadend",{detail:s,bubbles:!0})),e&&this._connected&&p(this.display)===p(t))this.render(!1);return"loaded"}catch(o){if(n.signal.aborted)return"cancelled";return this.dispatchEvent(new CustomEvent("dateloaderror",{detail:{...s,error:o},bubbles:!0})),"failed"}finally{if(this._loadController===n)this._loadController=null,this._loadingKey="",this._loadingPromise=null,this.removeAttribute("data-loading")}})();return this._loadingPromise=a,a}_setDisplay(t,e={}){let s=this._model.display;if(this._model.setDisplay(rt(t,this.firstDay)),this._model.focused=this._clamp(this._model.focused),this._model.display=p(this._model.focused),this._reflect("display",this._model.display),this._connected)this.render();if(e.emit!==!1&&s!==this._model.display)this._emitDisplayChange();return this._model.display}_emitDisplayChange(){let t=this._range();this.dispatchEvent(new CustomEvent("displaychange",{detail:{display:this.display,...t},bubbles:!0}))}previousMonth(){return this._setDisplay(Dt(this.display,-1)??this.display)}nextMonth(){return this._setDisplay(Dt(this.display,1)??this.display)}focusDate(t,e={}){if(!l(t))throw TypeError(`Invalid date: ${t}`);let s=this._clamp(t),i=this.display,n=this._model.focused,r=e.moveFocus!==!1;if(this._model.setFocused(s),this._reflect("display",this._model.display),i!==this.display){if(this._connected)this.render();this._emitDisplayChange()}else if(this._connected&&n!==this._model.focused)this._moveFocusDom(n,this._model.focused,r);if(r)this._queueFocus(()=>this.focusGrid())}_moveFocusDom(t,e,s=!0){let i=t?this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`):null,n=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(i instanceof HTMLElement)i.tabIndex=-1;if(n instanceof HTMLElement){if(n.tabIndex=0,s)n.focus()}else if(s)this.focusGrid()}_syncRovingDom(t){for(let s of this.querySelectorAll('.dp-day[tabindex="0"]'))if(s instanceof HTMLElement&&s.dataset.date!==t)s.tabIndex=-1;let e=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(e instanceof HTMLElement)e.tabIndex=0}_moveSelectionDom(t,e){if(t){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(t)}"]`);if(s instanceof HTMLElement)s.removeAttribute("data-selected"),s.removeAttribute("aria-selected")}if(e){let s=this.querySelector(`.dp-day[data-date="${CSS.escape(e)}"]`);if(s instanceof HTMLElement)return s.setAttribute("data-selected","true"),s.setAttribute("aria-selected","true"),!0}return!1}_dayLabel(t,e,s){let i=this.hasAttribute("data-range-preview")?"":Ue(s),n=typeof e.description==="string"?e.description:"";return[dt(t,this.locale),n,i?this.messages[i]:"",e.disabled?this.messages.unavailable:""].filter(Boolean).join(". ")}_updateRangeDom(){let t=this._paintedRange,e=this._paintedPreview;this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview");for(let s of this.querySelectorAll(".dp-day[data-date]")){if(!(s instanceof HTMLTableCellElement))continue;let i=s.dataset.date||"",n=yt(i,this._highlightedRange);if(n===yt(i,t)&&e===this._paintedPreview)continue;for(let[r,a]of Object.entries(te(n)))if(a)s.setAttribute(r,"true");else s.removeAttribute(r);if(!e||!this._paintedPreview){let r=this._renderedStates.get(i)||{},a=this._dayLabel(i,r,n);if(s.getAttribute("aria-label")!==a)s.setAttribute("aria-label",a)}}}focusGrid(){let t=this.querySelector(`.dp-day[data-date="${CSS.escape(this.focusedDate)}"]`);if(t instanceof HTMLElement)t.focus()}async activateDate(t){if(!this._connected)return!1;let e=this._session,s=this._hostIntent?.date===t?this._hostIntent.intent:void 0;this._hostIntent=null;let i=(o)=>{if(s!==void 0)st.set(o,s);return o},n=await this.ensureDate(t);if(!e||e.signal.aborted)return!1;let r=this.getDateState(t);if(!n||r.disabled)return this.dispatchEvent(i(new CustomEvent("dateinvalid",{detail:{date:t,state:r},bubbles:!0}))),!1;if(!this.dispatchEvent(i(new CustomEvent("dateactivate",{detail:{date:t,state:r},bubbles:!0,cancelable:!0})))||e.signal.aborted)return!1;if(this.selection==="single"){let o=this._model.value;if(this._model.setValue(t),this._reflect("value",t),this.dispatchEvent(new CustomEvent("datechange",{detail:{value:t},bubbles:!0})),this.dispatchEvent(new Event("change",{bubbles:!0})),this._connected)if(p(t)===this.display)this._moveSelectionDom(o,t);else this.render()}else if(this._connected){if(p(t)!==this.display)this.render()}return!0}_onClick(t){let e=t.target;if(!(e instanceof Element))return;let s=e.closest("[data-calendar-action]");if(s instanceof HTMLButtonElement){let a=s.dataset.calendarAction;if(a==="previous")this.previousMonth();if(a==="next")this.nextMonth();return}let i=e.closest(".dp-day[data-date]");if(!(i instanceof HTMLTableCellElement))return;let n=i.dataset.date||"";if(!l(n))return;let r=this.display;if(this._model.setFocused(this._clamp(n)),this._reflect("display",this._model.display),r!==this.display)this._emitDisplayChange();else this._syncRovingDom(this._model.focused);this.activateDate(n)}_onChange(t){let e=t.target;if(e instanceof HTMLSelectElement&&e.matches(".dp-month-select")){this._setDisplay(`${this.display.slice(0,4)}-${e.value}`);return}if(e instanceof HTMLInputElement&&e.matches(".dp-year-input")){let s=Number(e.value);if(!Number.isInteger(s)||s<1||s>9999){if(this._connected)this.render(!1);return}this._setDisplay(`${String(s).padStart(4,"0")}-${this.display.slice(5,7)}`)}}_onFocusIn(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||"";if(!l(s))return;this._model.focused=s,this._syncRovingDom(s),this.dispatchEvent(new CustomEvent("datefocus",{detail:{date:s,state:this.getDateState(s)},bubbles:!0}))}_onKeyDown(t){let e=t.target;if(!(e instanceof HTMLTableCellElement)||!e.matches(".dp-day[data-date]"))return;let s=e.dataset.date||this.focusedDate;if(t.key==="Enter"||t.key===" "){t.preventDefault(),this.activateDate(s);return}let i=this._model.focused,n=this._model.display;if(this._model.firstDay=this.firstDay,this._model.setFocused(s,{follow:!1}),t.key==="ArrowLeft")this._model.moveFocusDays(-1);else if(t.key==="ArrowRight")this._model.moveFocusDays(1);else if(t.key==="ArrowUp")this._model.moveFocusDays(-7);else if(t.key==="ArrowDown")this._model.moveFocusDays(7);else if(t.key==="Home")this._model.focusWeekStart();else if(t.key==="End")this._model.focusWeekEnd();else if(t.key==="PageUp")t.shiftKey?this._model.moveFocusYears(-1):this._model.moveFocusMonths(-1);else if(t.key==="PageDown")t.shiftKey?this._model.moveFocusYears(1):this._model.moveFocusMonths(1);else return;let r=this._model.focused;if(this._model.focused=i,this._model.display=n,!r)return;t.preventDefault(),this.focusDate(this._clamp(r))}render(t=!0){if(!this._connected)return;let e=this.locale,s=this.display,i=Ne(s),n=Number(s.slice(5,7)),r=Jt(e,this.monthFormat),a=Ft(e,this.firstDay,"short"),o=Ft(e,this.firstDay,"long"),d=this._weeks(),c=O(),h=`${this._id}-heading`,b=`${this._id}-grid`,w=this.min?p(this.min):"",E=this.max?p(this.max):"",k=Dt(s,-1),M=Dt(s,1),T=Boolean(w&&k!==null&&k<w),y=Boolean(E&&M!==null&&M>E),v=` min="${this.min?Number(this.min.slice(0,4)):1}"`,x=` max="${this.max?Number(this.max.slice(0,4)):9999}"`,A=this.showWeekNumbers&&this.firstDay===1,C=A?`<th scope="col" class="dp-week-heading" abbr="${S(this.messages.week)}">#</th>`:"",B=r.map((u,f)=>{let D=f+1,m=`${String(i).padStart(4,"0")}-${String(D).padStart(2,"0")}`,et=w&&m<w||E&&m>E;return`<option value="${String(D).padStart(2,"0")}"${D===n?" selected":""}${et?" disabled":""}>${S(u)}</option>`}).join(""),L=a.map((u,f)=>`<th scope="col" abbr="${S(o[f])}">${S(u.replace(".",""))}</th>`).join("");this._renderedStates.clear();let W=d.map((u)=>{let f=A?`<th scope="row" class="dp-week-number">${Wt(u[0])}</th>`:"",D=u.map((m)=>{let et=this.getDateState(m);this._renderedStates.set(m,et);let fe=p(m)!==s,pe=this.value===m,me=this.focusedDate===m,_e=m===c,Ht=yt(m,this._highlightedRange),ge=this._dayLabel(m,et,Ht);return`<td class="dp-day" data-date="${m}"${fe?' data-outside-month="true"':""}${_e?' data-today="true" aria-current="date"':""}${pe?' data-selected="true" aria-selected="true"':""}${Ve(Ht)}${et.disabled?' data-disabled="true" aria-disabled="true"':""} tabindex="${me?"0":"-1"}" aria-label="${S(ge)}"><span class="dp-day-number" aria-hidden="true">${Number(m.slice(8,10))}</span><span class="dp-day-extra" aria-hidden="true"></span></td>`}).join("");return`<tr>${f}${D}</tr>`}).join(""),X=document.activeElement,J=X instanceof HTMLElement&&this.contains(X)?this._focusTargetKey(X):"",I=Xt(e)[0]==="year";this.toggleAttribute("data-year-first",I);let Q=this.controlClasses,Y=S(Q.month||"dp-skin"),Et=S(Q.year||"dp-skin"),ft=S(Q.nav||"dp-skin"),tt=`<label class="dp-visually-hidden" for="${this._id}-month">${S(this.messages.month)}</label>
3
+ <select id="${this._id}-month" class="dp-month-select ${Y}" aria-label="${S(this.messages.month)}">${B}</select>`,_=`<label class="dp-visually-hidden" for="${this._id}-year">${S(this.messages.year)}</label>
4
+ <input id="${this._id}-year" class="dp-year-input ${Et}" type="number" inputmode="numeric" value="${i}"${v}${x} aria-label="${S(this.messages.year)}">`;if(!this._heading?.isConnected||!this._renderRoot?.isConnected){this.replaceChildren();let u=document.createElement("h2");u.id=h,u.className="dp-calendar-heading dp-visually-hidden",u.setAttribute("aria-live","polite");let f=document.createElement("div");f.className="dp-calendar-render",this.append(u,f),this._heading=u,this._renderRoot=f}if(this._rendering=!0,this._renderRoot.innerHTML=`
5
5
  <div class="dp-calendar-shell">
6
6
  <div class="dp-calendar-header">
7
- ${R?g:J}
8
- ${R?J:g}
9
- <button type="button" class="dp-nav dp-prev ${ut}" data-calendar-action="previous" aria-label="${S(this.messages.previousMonth)}"${T?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m4 10 4-4 4 4"/></svg></button>
10
- <button type="button" class="dp-nav dp-next ${ut}" data-calendar-action="next" aria-label="${S(this.messages.nextMonth)}"${y?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m4 6 4 4 4-4"/></svg></button>
7
+ ${I?_:tt}
8
+ ${I?tt:_}
9
+ <button type="button" class="dp-nav dp-prev ${ft}" data-calendar-action="previous" aria-label="${S(this.messages.previousMonth)}"${T?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m4 10 4-4 4 4"/></svg></button>
10
+ <button type="button" class="dp-nav dp-next ${ft}" data-calendar-action="next" aria-label="${S(this.messages.nextMonth)}"${y?" disabled":""}><svg aria-hidden="true" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m4 6 4 4 4-4"/></svg></button>
11
11
  </div>
12
- <table id="${v}" class="dp-grid" role="grid" aria-labelledby="${h}">
13
- <thead><tr>${x}${L}</tr></thead>
14
- <tbody>${Y}</tbody>
12
+ <table id="${b}" class="dp-grid" role="grid" aria-labelledby="${h}">
13
+ <thead><tr>${C}${L}</tr></thead>
14
+ <tbody>${W}</tbody>
15
15
  </table>
16
- </div>`,this._heading.textContent=qt(`${s}-15`,e),this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),X)this._queueFocus(()=>{let u=X;if(u.startsWith(".dp-day[data-date="))u=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let f=this.querySelector(u);if(f instanceof HTMLElement)f.focus()});if(this._renderDay)for(let u of this.querySelectorAll(".dp-day[data-date]")){if(!(u instanceof HTMLTableCellElement))continue;let f=u.dataset.date||"",D=u.querySelector(".dp-day-extra");if(!(D instanceof HTMLElement))continue;let m=this._renderDay(f,this._renderedStates.get(f)||{});if(m instanceof Node)D.append(m);else if(m!==void 0&&m!==null)D.textContent=String(m)}if(t)this._loadDisplay(s)}}function bt(t){return t==="top"||t==="bottom"?"x":"y"}var ne={top:"bottom",bottom:"top",left:"right",right:"left"},Ye=new Set(Object.keys(ne).flatMap((t)=>[t,`${t}-start`,`${t}-end`])),je=new Set(["viewport","document"]);function We(t){if(!Ye.has(t))throw TypeError(`Unknown placement: ${t}`);let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:bt(e)}}function ze(t,e,s,i,n,r){let a=bt(s),o=t.x+t.width/2-e.width/2,l=t.y+t.height/2-e.height/2,d=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(s){case"top":h={x:o,y:t.y-e.height-r};break;case"bottom":h={x:o,y:t.y+t.height+r};break;case"right":h={x:t.x+t.width+r,y:l};break;case"left":h={x:t.x-e.width-r,y:l};break;default:h={x:t.x,y:t.y}}if(i==="start"||i==="end"){let v=(n&&a==="x"?-1:1)*(i==="end"?1:-1);h[a]+=d*v}return h}function qe(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function Ke(t){let e=t.ownerDocument?.defaultView;if(e&&t instanceof e.Element)return e.getComputedStyle(t).direction==="rtl";return"dir"in t&&t.dir==="rtl"}var Xe=25;function Ze(t){let e=t.defaultView;if(!e)return null;let s=t.documentElement,i=e.visualViewport,n=i?.offsetLeft||0,r=i?.offsetTop||0,a=i?.width||s.clientWidth||e.innerWidth,o=i?.height||s.clientHeight||e.innerHeight,l=t.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(l>0&&l<=Xe){let d=e.getComputedStyle?.(s).scrollbarGutter;if(d&&d!=="auto")a-=l}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function Je(t,e){return e.scope?e.scope.getBoundingClientRect():Ze(t.ownerDocument)}function Qt(t,e,s,i,n){let r=s+n,a=i-e-n,o=a>=r,l=o?r:s,d=o?a:i-e;return Math.max(l,Math.min(t,d))}function te(t,e,s){if(!s)return 50;let i=(t-e)/s*100;return Math.round(Math.min(100,Math.max(0,i))*1000)/1000}function Qe(t,e){for(let s=0;s<t.length;s++){let i=t[s];if(i.right>=e.x&&i.left<=e.right&&i.bottom>=e.y&&i.top<=e.bottom)return!1}return!0}function ts(t,e,s,i,n){if(e==="top")return Math.max(0,t.top-s.y-i-n);if(e==="bottom")return Math.max(0,s.bottom-t.bottom-i-n);return Math.max(0,s.height-n*2)}function es(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function re(t){let{offsetWidth:e,offsetHeight:s}=t;if(e&&s)return{width:e,height:s};let i=t.getBoundingClientRect();return{width:e||i.width,height:s||i.height}}var ee=new WeakMap,se={scroll:0,resize:1,"element-resize":2};function ss(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let s=new Set,i=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function l(y,b){let C=i.get(y);if(C===void 0||se[b]>se[C])i.set(y,b)}function d(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let y=[...i];i.clear(),r=!1;for(let[b,C]of y){if(!s.has(b)||!b.floating.isConnected)continue;try{b.callback({type:C})}catch(A){h(A)}}})}function h(y){if(typeof e.reportError==="function")e.reportError(y);else e.setTimeout(()=>{throw y})}function v(y){for(let b of s)l(b,y);d()}function w(y){if(!n)return null;let b=new Set,C=new n((B)=>{let L=!1;for(let Y of B)if(b.has(Y.target))L=!0;else b.add(Y.target);if(!L)return;l(y,"element-resize"),d()}),{reference:A,floating:x}=y;if(A)C.observe(A);if(x!==A)C.observe(x);return C}let E=()=>v("scroll"),k=()=>v("resize");function M(){if(a)return;t.addEventListener("scroll",E,{passive:!0,capture:!0}),e.addEventListener("resize",k,{passive:!0}),o?.addEventListener("scroll",E,{passive:!0}),o?.addEventListener("resize",k,{passive:!0}),a=!0}function T(){if(!a)return;t.removeEventListener("scroll",E,{capture:!0}),e.removeEventListener("resize",k),o?.removeEventListener("scroll",E),o?.removeEventListener("resize",k),a=!1}return{add(y,b,C){let A={reference:y,floating:b,callback:C};s.add(A),M();let x=w(A),B=!1;return()=>{if(B)return;if(B=!0,s.delete(A),i.delete(A),x?.disconnect(),s.size===0)T()}}}}function is(t){let e=t.ownerDocument,s=ee.get(e);if(!s)s=ss(e),ee.set(e,s);return s}function ae(t,e,s){if(!e?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(t&&t.ownerDocument!==e.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof s!=="function")throw TypeError("callback must be a function");return is(e).add(t,e,s)}function ie(t,e,s){let i=s.placement===void 0?"bottom-start":s.placement,{side:n,align:r,crossAxis:a}=We(i),o=s.coordinateSpace===void 0?"viewport":s.coordinateSpace;if(!je.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!es(e))return null;let l=s.distance||0,d=s.flip!==!1,h=s.shift!==!1,v=s.shiftPadding??4,w=r?Ke(t):!1,E=t.getClientRects();if(!E.length)return null;let k=(g)=>g==="bottom"?E[E.length-1]:E[0],M=Je(t,s);if(!M||Qe(E,M))return null;let T=re(e),y={x:{size:T.width,start:M.x,end:M.right},y:{size:T.height,start:M.y,end:M.bottom}},b=(g,u)=>ze(k(g),T,g,u,w,l),C=(g,u)=>{let{size:f,start:D,end:m}=y[u];return qe(g,f,D+v,m-v)},A=(g,u)=>{let{size:f,start:D,end:m}=y[u];return C(h?Qt(g,f,D,m,v):g,u)},x=b(n,r),B=(g,u)=>{let f=bt(g),D=f==="x"?"y":"x",m=C(u[D],D);return{main:m,total:m+A(u[f],f)}};if(d){let g=B(n,x),u=(f)=>{let D=b(f,r),m=B(f,D);if(m.total<g.total)n=f,x=D,g=m};if(g.main>0)u(ne[n]);if(a==="y"&&g.main>0)u("top"),u("bottom");a=bt(n)}if(a==="x"&&h&&r){let g=C(x.x,"x");if(g>0){let u=r==="end"?"start":"end",f=b(n,u);if(C(f.x,"x")<g)r=u,x=f}}if(h){let{size:g,start:u,end:f}=y[a];x[a]=Qt(x[a],g,u,f,v)}let L=k(n),Y=te(L.x+L.width/2,x.x,T.width),K=te(L.y+L.height/2,x.y,T.height),X=`${ts(L,n,M,l,v)}px`,{style:R}=e,Z=R.getPropertyValue("--available-height")!==X,j=o==="document"?t.ownerDocument.defaultView:null,Dt=j?j.scrollX:0,ut=j?j.scrollY:0;R.left=`${x.x+Dt}px`,R.top=`${x.y+ut}px`,R.setProperty("--arrow-x",`${Y}%`),R.setProperty("--arrow-y",`${K}%`),R.setProperty("--available-height",X);let J=r?`${n}-${r}`:n;return e.dataset.placement=J,{width:T.width,height:T.height,roomChanged:Z,placement:J}}function oe(t,e,s={}){let i=ie(t,e,s);if(!i)return!1;if(i.roomChanged){let n=re(e);if(n.width!==i.width||n.height!==i.height)ie(t,e,{...s,placement:i.placement,flip:!1})}return!0}function H(t){return!t.matches(":disabled")&&!t.readOnly}class ct{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=lt(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._disposed=!1,this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null,this._generatedDefault=null}setLocale(t){let e=this._generatedDefault,s=e?this.adapter.format(e):null;if(this.adapter=lt(t||""),e&&this.input.defaultValue===s)this.input.defaultValue=this.adapter.format(e)}adoptDefault(){let t=this.input;if(t.getAttribute("value")!=null||t.defaultValue!=="")return;t.defaultValue=t.value,this._generatedDefault=this.canonical&&t.value?this.canonical:null}setMessages(t){this.messages=t||{}}format(t){return this.adapter.format(t)}parse(t){return this.adapter.parse(t)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.matches(":disabled")}get isReadOnly(){return this.input.readOnly}setupFormValue(){let t=this.input;this._originalName=t.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(t,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let t=this.input,e=t.getAttribute("name")||"";if(e){if(!this.hidden){let s=document.createElement("input");s.type="hidden",s.value=this.canonical,t.insertAdjacentElement("afterend",s),this.hidden=s}if(this.hidden)this.hidden.name=e;t.removeAttribute("name")}if(this.hidden){if(t.hasAttribute("form"))this.hidden.setAttribute("form",t.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=t.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let t=this.input,e=t.value.trim(),s=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),e===s){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;t.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!e){t.setCustomValidity("");return}t.setCustomValidity(this.messages.invalidDate)}async commit(t={}){let e=this.input,s=++this._commitId;if(this._disposed)return{status:"stale",commitId:s};let i=e.value.trim();if(!i){if(s!==this._commitId)return{status:"stale",commitId:s};return e.setCustomValidity(""),{status:"clear",value:"",commitId:s}}let n=this.adapter.parse(i);if(!n){if(s!==this._commitId)return{status:"stale",commitId:s};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid",commitId:s}}if(this.confirm){let r=await this.confirm(n,t);if(this._disposed||s!==this._commitId)return{status:"stale",commitId:s};if(!r?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(r?.message||this.messages.unavailableDate),{status:"invalid",commitId:s}}}return{status:"ok",value:n,commitId:s}}isCommitCurrent(t){return t===this._commitId}setCanonical(t,e={}){let s=t||"";if(s&&!c(s))throw TypeError(`Invalid date-picker value: ${s}`);if(this.dirty(),this.canonical=s,this._dirty=!1,this.hidden)this.hidden.value=s;if(e.format!==!1)this.input.value=s?this.adapter.format(s):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=c(t)?t:this.adapter.parse(t);return e&&c(e)?e:""}teardown(){this.dirty(),this._disposed=!0,this._attributeObserver?.disconnect(),this._attributeObserver=null;let t=this.hidden?.getAttribute("name")||this._originalName;if(t)this.input.setAttribute("name",t);this.hidden?.remove(),this.hidden=null}}var ns=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function Ft(t){let e=ns.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=e[3]===void 0?0:Number(e[3]),r=e[4]===void 0?0:Number(e[4].padEnd(3,"0"));if(s>23||i>59||n>59||r>999)return null;return{hour:s,minute:i,second:n,millisecond:r}}function Lt(t){return Ft(t)!==null}function le(t){return((t.hour*60+t.minute)*60+t.second)*1000+t.millisecond}function de(t,e){let s=Ft(t),i=Ft(e);if(!s||!i)throw TypeError("compareTimes() expects HH:MM values");let n=le(s)-le(i);return n===0?0:n<0?-1:1}var rs=0,ce=4;class Rt extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];static setDefaultControlClasses(t){pt(t)}static getDefaultControlClasses(){return nt()}static setDefaultMessages(t){gt(t)}static getDefaultMessages(){return U()}constructor(){super();this._id=`date-picker-${++rs}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._activationId=0,this._previewDate="",this._drag=null,this._suppressGridClick=!1,this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholders=new WeakSet,this._controller=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}_ownsField(t){return this._connected&&(t===this._field||Boolean(this._fields?.includes(t)))}connectedCallback(){if(this._connected)return;if(q(this,["locale","min","max","monthFormat","openOnFocus","coordinateSpace","controlClasses","messages","source","dateState","renderDay","isDateDisabled"]),this.hasAttribute("range"))this._connectRange();else this._connectSingle();if(this._connected)q(this,["value","range"]),this._stopDefaultMessages=yt(()=>{if(this._messages===null)this._refreshMessages()}),this.validate()}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._discoverTimeFields(),this._field=new ct(t,{messages:this.messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i,n)=>this._confirmDate(i,n),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),s=this.getAttribute("value")||(c(t.value)?t.value:e.parse(t.value));if(s&&c(s))this._setValue(s,{emit:!1,format:!0});else if(!t.value)this._setValue("",{emit:!1,format:!1});else t.setCustomValidity(this.messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;this._field.adoptDefault()}_discoverTimeFields(){this._timeFields=[null,null];let t=["data-time-start","data-time-end"];for(let[e,s]of t.entries()){let i=this.querySelectorAll(`:scope > input[${s}]`);if(i.length>1)console.warn(`<date-picker> expects at most one direct child input[${s}]; ignoring extras`);let n=i[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${s}] must be an <input type="time">; ignoring it`);continue}this._timeFields[e]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let t=this.querySelector(":scope > input[data-range-start]"),e=this.querySelector(":scope > input[data-range-end]");if(!(t instanceof HTMLInputElement)||!(e instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new ct(t,{messages:this.messages,locale:this.locale}),new ct(e,{messages:this.messages,locale:this.locale})],this._range=new Mt,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let o of this._fields)o.onAttributesChanged=()=>this._syncRangeFields(),o.confirm=(l,d)=>this._confirmDate(l,d),o.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let s=this._adapter(),i=c(t.value)?t.value:s.parse(t.value),n=c(e.value)?e.value:s.parse(e.value),r=t.value,a=e.value;this._setRange(i||"",n||"",{emit:!1});for(let[o,l,d]of[[t,r,i],[e,a,n]]){if(!l.trim()||c(d))continue;o.value=l,o.setCustomValidity(this.messages.invalidDate)}if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;for(let o of this._fields)o.adoptDefault()}disconnectedCallback(){if(this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._suppressFocusOpen=!1,this.hide(!1),this._controller?.abort(),this._controller=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let t of this._fields||[])this._teardownField(t);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:t}of this._buttons)t.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(t){if(!t)return;let e=t.input,s=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),s)e.setAttribute("aria-describedby",s);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,s){if(this._reflecting||e===s)return;if(t==="value"&&s&&!c(s)){this._reflectValue(this._value);return}if((t==="min"||t==="max")&&s&&!c(s)){if(this.removeAttribute(t),this._connected)this._syncCalendarOptions(),this.validate();return}if(!this._connected)return;if(t==="value"){if(this._rangeMode())return;if(!s||c(s))this._supersedeActivations(),this._setValue(s||"",{emit:!1,format:!0,reflect:!1});return}if(t==="locale")this._refreshLocale();if(t==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(t){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);this._supersedeActivations(),this._setValue(t||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(t){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:e,end:s}=mt(t);this._supersedeActivations(),this._setRange(e,s)}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let t=this.getAttribute("min")||"";return c(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return c(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(t){if(t===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get controlClasses(){return at(this._controlClasses)}set controlClasses(t){if(this._controlClasses=rt(t),this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages??U()}set messages(t){if(this._messages=t==null?null:{...U(),...t},this._calendar)this._calendar.messages=this._messages;this._refreshMessages()}_refreshMessages(){let t=this.messages;for(let s of this._fields||[])s.setMessages(t);this._field?.setMessages(t),this._panel?.setAttribute("aria-label",t.calendar);let e=this._field??this._fields?.[0];if(this._formatHint&&e)this._formatHint.textContent=`${t.formatHint}: ${e.placeholder}`;if(this._refreshButtonLabel(),this._connected)this.validate()}get source(){return this._source}set source(t){if(this._source=t||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(t){this._coordinateSpace=t==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??lt(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;this._field?.syncInputState();let e=this._buttons[0]?.button;if(e)e.disabled=t.disabled||t.readOnly;if(this._open&&!H(t))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let s of this._fields)s.syncInputState();for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?1:0,r=this._fields[n];s.disabled=Boolean(r?.input.disabled||r?.input.readOnly)}this._syncDragAffordance();let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields[t]?.input;if(this._open&&e&&!H(e))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let t of this._fields){let e=t.input,s=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",s),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",this._panel.id)}}_createTrigger(t){let e=document.createElement("button");if(e.type="button",e.className="dp-picker-button",e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",`${this._id}-panel`),t)e.dataset.endpoint=t;return e.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>',e}_build(){let t=this._rangeMode(),e=[];if(t)for(let[o,l]of(this._fields||[]).entries())e.push([l.input,o===1?"end":"start"]);else if(this._input)e.push([this._input,""]);if(!e.length)return;let s=`${this._id}-panel`,i=`${this._id}-format`;this._buttons=e.map(([o,l])=>{let d=this._createTrigger(l);return o.insertAdjacentElement("afterend",d),{button:d,endpoint:l}});let n=document.createElement("div");n.id=s,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this.messages.calendar);let r=new dt;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=i,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!t&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,i].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",s)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(t,e,s){this.ownerDocument.addEventListener("pointerdown",(i)=>{if(!this._open||i.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:t}),this.ownerDocument.addEventListener("reset",(i)=>{if(!(i.target instanceof HTMLFormElement)||!e||i.target!==e.form)return;this.hide(!1),queueMicrotask(()=>{if(!t.aborted&&!i.defaultPrevented)s()})},{capture:!0,signal:t}),this.addEventListener("keydown",(i)=>this._onEscape(i),{signal:t})}_bind(){let t=this._input,e=this._buttons[0]?.button,s=this._calendar;if(!t||!e||!s)return;let i=new AbortController;this._controller=i;let{signal:n}=i;t.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),t.addEventListener("change",()=>void this._commitText(!1),{signal:n}),t.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),t.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),t.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){this._defer(()=>this._calendar?.focusGrid());return}this.hide(!1);return}this.show({returnFocus:e})},{signal:n}),e.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),s.addEventListener("click",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("keydown",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!c(o))return;let l=tt.get(a);queueMicrotask(()=>{if(n.aborted||a.defaultPrevented||!this._connected)return;if(l&&l.id!==this._activationId)return;if(!this._input||!H(this._input))return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),s.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this._bindPopup(n,this._input,()=>this._restoreDefault())}_bindRange(){let t=this._calendar;if(!this._fields||!this._buttons.length||!t)return;let e=new AbortController;this._controller=e;let{signal:s}=e;for(let[i,n]of this._fields.entries()){let r=i===1?"end":"start";n.input.addEventListener("input",()=>{if(n.handleInput(),this._orderTags.delete(i),!n.isDirty)this._revalidateRange(r)},{signal:s}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:s}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:s})}for(let i of this._buttons){let n=i.endpoint;if(n==="")continue;i.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:s}),i.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:s})}t.addEventListener("click",(i)=>{if(this._suppressGridClick){this._suppressGridClick=!1,i.preventDefault(),i.stopImmediatePropagation();return}this._captureGridIntent(i)},{capture:!0,signal:s}),t.addEventListener("keydown",(i)=>this._captureGridIntent(i),{capture:!0,signal:s}),t.addEventListener("dateactivate",(i)=>{let n=i,r=n.detail?.date;if(!c(r))return;queueMicrotask(()=>{if(s.aborted||n.defaultPrevented||!this._connected||!this._range)return;let a=tt.get(n);if(a===void 0||a.id!==this._activationId)return;let o=(d)=>this._boundEditable(d),l=a.endpoint?this._range.moveEndpoint(r,a.endpoint,o):this._range.activate(r,o);if(l.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(l),a.endpoint)return;if(l.close||l.status==="complete")this.hide(!1),this._focusField(l.endpoint)})},{signal:s}),t.addEventListener("datefocus",(i)=>this._onGridDateFocus(i),{signal:s}),t.addEventListener("pointerover",(i)=>this._onGridPointerOver(i),{signal:s}),t.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:s}),t.addEventListener("pointerdown",(i)=>this._onGridPointerDown(i),{signal:s}),t.addEventListener("pointermove",(i)=>this._onGridPointerMove(i),{signal:s}),t.addEventListener("pointerup",(i)=>this._onGridPointerUp(i),{signal:s}),t.addEventListener("pointercancel",(i)=>this._onGridPointerCancel(i),{signal:s}),t.addEventListener("lostpointercapture",(i)=>this._onGridPointerCancel(i),{signal:s}),t.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,this._fields?.[0]?.input,()=>this._restoreRangeDefault())}_activateRangeEndpoint(t){let e=this._calendar;if(!this._range||!e)return;this._range.focus(t),this._activationId++,this._lastFocusEndpoint=t;let s=this._boundCanonical(t)||O();e.display=p(s),e.focusedDate=s,this._clearPreview()}_onRangeTriggerClick(t,e){if(!this._open){this.show({endpoint:t});return}if(e.detail===0){this._activateRangeEndpoint(t),this._defer(()=>this._calendar?.focusGrid());return}if(t!==this._range?.activeEndpoint){this._activateRangeEndpoint(t);return}this.hide(!1)}_onTriggerKeyDown(t,e){if(e.key!=="ArrowDown")return;if(e.preventDefault(),this._open){if(this._rangeMode()&&t)this._activateRangeEndpoint(t);this._defer(()=>this._calendar?.focusGrid());return}if(this._rangeMode())this.show({endpoint:t||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)this._defer(()=>this._calendar?.focusGrid());else this.show()}else if(e.key==="Escape"&&this._open)e.preventDefault(),this.hide(!1)}_onFieldFocus(t,e){if(!this._rangeMode()||!t)return;let s=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),s)this._activationId++;if(!this.openOnFocus||this._suppressFocusOpen)return;let i=e.relatedTarget;if(i instanceof Node&&this.contains(i))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(this._rangeMode()?!this._range:!this._field)return;if(t.type==="keydown"){let i=t.key;if(i!=="Enter"&&i!==" ")return}if(t.type==="click"&&this._suppressGridClick)return;if(!(t.target instanceof Element))return;let s=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!c(s))return;this._attachIntent(s,"")}_attachIntent(t,e){if(!this._calendar)return;this._calendar._hostIntent={date:t,intent:{id:++this._activationId,endpoint:e}}}_supersedeActivations(){this._activationId++}_boundEditable(t){let e=this._fields?.[t==="end"?1:0];return e!=null&&H(e.input)}_applyRangeTransition(t){let e=this._fields;if(!e||!this._range||t.status==="refused")return;let s=[];for(let i of t.changedEndpoints){let n=e[i==="end"?1:0],r=i==="end"?t.range.end:t.range.start;if(!n||n.canonical===r)continue;n.setCanonical(r,{format:!0}),s.push(n)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(t.endpoint),!s.length)return;this._emitRangeChange();for(let i of s)i.input.dispatchEvent(new Event("input",{bubbles:!0})),i.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(t,e=""){let s=this._calendar;if(!s||!this._range||!this._open)return;let i=c(t)&&!s.getDateState(t).disabled?t:"",n=i?this._range.previewRange(i,e,(r)=>this._boundEditable(r)):null;if(!n){this._clearPreview();return}this._previewDate=i,s.toggleAttribute("data-range-preview",!0),s.highlightedRange=n}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(t){if(this._drag)return;let e=t.detail?.date;if(c(e))this._setPreview(e)}_onGridPointerOver(t){let e=t;if(this._drag||e.pointerType==="touch")return;this._setPreview(this._cellDate(e.target))}_onGridPointerLeave(){if(this._drag?.active===!1)this._drag=null;if(this._drag)return;this._clearPreview()}_cellDate(t){let s=(t instanceof Element?t.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return c(s)?s:""}_dateAtPoint(t,e){let s=this.ownerDocument.elementFromPoint(t,e);if(!(s instanceof Element)||!this._calendar?.contains(s))return"";return this._cellDate(s)}_onGridPointerDown(t){let e=t;if(this._suppressGridClick=!1,this._drag?.active===!1)this._drag=null;if(!this._open||!this._range||this._drag)return;if(!e.isPrimary||e.button!==0)return;if(e.pointerType!=="mouse"&&e.pointerType!=="pen")return;if(!this._range.complete)return;let s=e.target instanceof Element?e.target.closest(".dp-day[data-date]"):null;if(!(s instanceof HTMLElement))return;let i=s.hasAttribute("data-range-start"),n=s.hasAttribute("data-range-end");if(i===n)return;let r=i?"start":"end",a=this._cellDate(s);if(!a||!this._boundEditable(r))return;this._drag={pointerId:e.pointerId,endpoint:r,x:e.clientX,y:e.clientY,date:a,active:!1}}_onGridPointerMove(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;if(!s.active){if(!(Math.abs(e.clientX-s.x)>ce||Math.abs(e.clientY-s.y)>ce))return;s.active=!0;try{this._calendar?.setPointerCapture(s.pointerId)}catch{}this._syncDragAffordance()}let i=this._dateAtPoint(e.clientX,e.clientY);if(!i||this._calendar?.getDateState(i).disabled)return;s.date=i,this._setPreview(i,s.endpoint)}_onGridPointerUp(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;if(this._drag=null,this._releaseDragCapture(s.pointerId),!s.active){this._syncDragAffordance();return}this._suppressGridClick=!0;let i=this._range?.projectEndpoint(s.date,s.endpoint,(r)=>this._boundEditable(r));if(!i||i.status==="refused"||!i.changedEndpoints.length){this._syncHighlight();return}let n=s.endpoint==="start"?i.range.start:i.range.end;this._attachIntent(n,s.endpoint),this._calendar?.activateDate(n)}_onGridPointerCancel(t){let e=t,s=this._drag;if(!s||e.pointerId!==s.pointerId)return;this._drag=null,this._releaseDragCapture(s.pointerId),this._syncHighlight()}_releaseDragCapture(t){let e=this._calendar;if(e?.hasPointerCapture(t))e.releasePointerCapture(t)}_syncDragAffordance(){let t=this._calendar;if(!t||!this._range)return;if(this._drag?.active){t.setAttribute("data-range-drag","active");return}let{start:e,end:s}=this._range;if(this._range.complete&&e!==s&&(this._boundEditable("start")||this._boundEditable("end")))t.setAttribute("data-range-drag","ready");else t.removeAttribute("data-range-drag")}_onEscape(t){if(t.key==="Escape"&&this._open)t.preventDefault(),t.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let t=this._calendar,e=this._panel;if(!t)return;if(t.locale=this.locale,t.min=this.min,t.max=this.max,t.monthFormat=this.monthFormat,t.controlClasses=this._controlClasses,t.messages=this._messages,t.source=this._source,t.dateState=this._dateState,t.renderDay=this._renderDay,t.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)t.value=this._value;if(e)e.setAttribute("aria-label",this.messages.calendar)}_refreshLocale(){let t=this._formatHint;if(!t)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),t.textContent=`${this.messages.formatHint}: ${this._fields[0].placeholder}`;for(let[s,i]of this._fields.entries()){if(!i.input.hasAttribute("placeholder")||this._generatedPlaceholders.has(i.input))i.input.placeholder=i.placeholder,this._generatedPlaceholders.add(i.input);let n=s===1?this._range?.end||"":this._range?.start||"";if(n)i.input.value=i.format(n)}this._refreshButtonLabel();return}let e=this._field;if(!e)return;if(e.setLocale(this.locale),t.textContent=`${this.messages.formatHint}: ${e.placeholder}`,!e.input.hasAttribute("placeholder")||this._generatedPlaceholders.has(e.input))e.input.placeholder=e.placeholder,this._generatedPlaceholders.add(e.input);if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let t=this._buttons[0]?.button;if(!t)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this.messages.changeDate:this.messages.chooseDate,s=this._value?`, ${ot(this._value,this.locale)}`:"";t.setAttribute("aria-label",`${e}${s}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:t,end:e}=this._range;for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?e:t,r=n?this.messages.changeDate:this.messages.chooseDate,a=n?`, ${ot(n,this.locale)}`:"",o=i==="end"?this.messages.rangeEnd:this.messages.rangeStart;s.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!c(t))throw TypeError(`Invalid date-picker value: ${t}`);let s=this._value;if(this._value=t||"",e.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:e.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value&&e.moveDisplay!==!1)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),s!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let i=this._field.input;i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t,e={}){let s=this._calendar;if(!s)return{ok:!0};if(e.moveDisplay!==!1){let r=p(t);if(s.display!==r)s.display=r}let i=await s.ensureDate(t),n=s.getDateState(t);if(!i||n.disabled)return{ok:!1,message:this.messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let s=this._field;if(!s)return!1;if(!e.force&&!s.isDirty)return!1;let i=await s.commit(e);if(!this._ownsField(s)||!s.isCommitCurrent(i.commitId))return!1;if(i.status==="stale"||i.status==="invalid")return!1;return this._setValue(i.value||"",{emit:t,format:i.status==="ok",moveDisplay:e.moveDisplay}),!0}async _commitFieldText(t){let e=this._fields;if(!e)return!1;let s=t==="end"?1:0,i=e[s];if(!i?.isDirty)return!1;let n=await i.commit();if(!this._ownsField(i)||!i.isCommitCurrent(n.commitId))return!1;if(n.status==="stale")return!1;if(n.status==="invalid")return this._orderTags.delete(s),!1;return this._setBound(t,n.value||"",{emit:!1,user:!0,format:n.status==="ok"}),!0}_setBound(t,e,s={}){if(!this._range)return!1;let i=this._fields;if(!i)return!1;let r=i[t==="end"?1:0];if(!r)return!1;if(s.user===!0&&!H(r.input))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:s.format!==!1}),t==="end")this._range.end=a;else this._range.start=a;let l=o!==a;if(l){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),s.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(t),l}_setRange(t,e,s={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:s.format!==!1}),this._fields[1].setCanonical(e||"",{format:s.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),s.emit!==!1)this._emitRangeChange()}_boundCanonical(t){return this._range?t==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_displayRange(){let{start:t,end:e}=this._range?.range??{start:"",end:""};if(!t)return{start:"",end:""};if(e&&_(e,t)<0)return{start:t,end:""};return{start:t,end:e}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange(),this._syncDragAffordance()}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:s}=this._range,i=Boolean(e&&s&&_(s,e)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,l=r==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(i&&r===t)o.setCustomValidity(l),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(t){let[e,s]=this._timeFields,i=["start","end"],n=[e,s],r=e&&!e.matches(":disabled")?e.value.trim():"",a=s&&!s.matches(":disabled")?s.value.trim():"",o=Boolean(e&&s&&r&&a)&&Lt(r)&&Lt(a)&&de(a,r)<0;for(let[l,d]of i.entries()){let h=n[l];if(!h)continue;let v=d==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(o&&d===t)h.setCustomValidity(v),this._timeOrderOwned.add(h);else if(this._timeOrderOwned.has(h))h.setCustomValidity(""),this._timeOrderOwned.delete(h)}}_clearTimeOrderValidity(){for(let t of this._timeOrderOwned)t.setCustomValidity("");this._timeOrderOwned.clear()}_defer(t){let e=this._controller;setTimeout(()=>{if(!this._connected||!e||e.signal.aborted||this._controller!==e)return;t()},0)}_restoreDefault(){let t=this._field;if(!t)return;let e=t.restoreDefault();if(this._setValue(e,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=p(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=p(O()),this._calendar.focusedDate=O();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let t=this._fields[0].restoreDefault(),e=this._fields[1].restoreDefault();if(this._setRange(t,e),this._calendar){let s=this._range?.start||O();this._calendar.display=p(s),this._calendar.focusedDate=s}this.validate()}_focusField(t){let e=t==="end"?1:0,s=this._fields?.[e]?.input;if(!s)return;this._suppressFocusOpen=!0,this._defer(()=>{s.focus(),this._suppressFocusOpen=!1})}_restoreFocus(){let t=this._returnFocus;if(this._returnFocus=null,!(t instanceof HTMLElement)||!t.isConnected||t.matches(":disabled"))return;this._suppressFocusOpen=!0,this._defer(()=>{t.focus(),this._suppressFocusOpen=!1})}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(H(this._fields[e].input))return t;let s=t==="end"?"start":"end",i=s==="end"?1:0;if(H(this._fields[i].input))return s;return""}async validate(){if(this._rangeMode()){let s=this._fields;if(!s)return!0;for(let[i,n]of s.entries()){let r=await n.commit({moveDisplay:!1});if(!this._ownsField(n)||!n.isCommitCurrent(r.commitId))continue;if(r.status==="invalid")this._orderTags.delete(i);if(r.status==="ok"||r.status==="clear"){let a=i===1?"end":"start";this._setBound(a,r.value||"",{format:r.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),s.every((i)=>i.input.checkValidity())}let t=this._field?.input;if(!t){let s=this.hasAttribute("range")?this.querySelectorAll(":scope > input[data-range-start], :scope > input[data-range-end]"):this._input?[this._input]:[],i=this.querySelectorAll(":scope > input[type=time][data-time-start], :scope > input[type=time][data-time-end]");return[...s,...i].every((n)=>n instanceof HTMLInputElement&&n.checkValidity())}await this._commitText(!1,{force:!0,moveDisplay:!1}),this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let e=this._timeFields.every((s)=>s?.checkValidity()??!0);return t.checkValidity()&&e}show(t={}){let e=this._panel,s=this._calendar;if(!e||!s||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=t.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||!H(r))return;let a=this._value||this._adapter().parse(r.value)||O();s.display=p(a),s.focusedDate=a,this._returnFocus=t.returnFocus instanceof HTMLElement?t.returnFocus:r}e.showPopover(),this._open=!0,this._setExpanded(!0);let i=this.coordinateSpace;e.style.position=i==="document"?"absolute":"fixed";let n=()=>oe(this,e,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:i});if(n(),this._stopTracking=ae(this,e,n),t.moveFocus!==!1){let r=this._controller;queueMicrotask(()=>{if(!this._connected||!r||r.signal.aborted||this._controller!==r)return;s.focusGrid()})}this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e);for(let{button:s}of this._buttons)s.setAttribute("aria-expanded",e);for(let s of this._fields||[])s.input.setAttribute("aria-expanded",e)}hide(t=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._supersedeActivations(),this._suppressGridClick=!1,this._drag)this._releaseDragCapture(this._drag.pointerId),this._drag=null;if(this._syncHighlight(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._restoreFocus();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let t=this._range?.activeEndpoint||"";if(t){let e=t==="end"?1:0,s=this._fields?.[e];if(s&&H(s.input))return t}return this._resolveRangeEndpoint()}}function ue(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",dt);if(!customElements.get("date-picker"))customElements.define("date-picker",Rt)}ue();})();
16
+ </div>`,this._heading.textContent=Zt(`${s}-15`,e),this._rendering=!1,this._paintedRange={...this._highlightedRange},this._paintedPreview=this.hasAttribute("data-range-preview"),J)this._queueFocus(()=>{let u=J;if(u.startsWith(".dp-day[data-date="))u=`.dp-day[data-date="${CSS.escape(this._model.focused)}"]`;let f=this.querySelector(u);if(f instanceof HTMLElement)f.focus()});if(this._renderDay)for(let u of this.querySelectorAll(".dp-day[data-date]")){if(!(u instanceof HTMLTableCellElement))continue;let f=u.dataset.date||"",D=u.querySelector(".dp-day-extra");if(!(D instanceof HTMLElement))continue;let m=this._renderDay(f,this._renderedStates.get(f)||{});if(m instanceof Node)D.append(m);else if(m!==void 0&&m!==null)D.textContent=String(m)}if(t)this._loadDisplay(s)}}function wt(t){return t==="top"||t==="bottom"?"x":"y"}var ae={top:"bottom",bottom:"top",left:"right",right:"left"},ze=new Set(Object.keys(ae).flatMap((t)=>[t,`${t}-start`,`${t}-end`])),We=new Set(["viewport","document"]);function Ye(t){if(!ze.has(t))throw TypeError(`Unknown placement: ${t}`);let[e,s=null]=t.split("-");return{side:e,align:s,crossAxis:wt(e)}}function je(t,e,s,i,n,r){let a=wt(s),o=t.x+t.width/2-e.width/2,d=t.y+t.height/2-e.height/2,c=t[a==="x"?"width":"height"]/2-e[a==="x"?"width":"height"]/2,h;switch(s){case"top":h={x:o,y:t.y-e.height-r};break;case"bottom":h={x:o,y:t.y+t.height+r};break;case"right":h={x:t.x+t.width+r,y:d};break;case"left":h={x:t.x-e.width-r,y:d};break;default:h={x:t.x,y:t.y}}if(i==="start"||i==="end"){let b=(n&&a==="x"?-1:1)*(i==="end"?1:-1);h[a]+=c*b}return h}function qe(t,e,s,i){return Math.max(s-t,0)+Math.max(t+e-i,0)}function Ke(t){let e=t.ownerDocument?.defaultView;if(e&&t instanceof e.Element)return e.getComputedStyle(t).direction==="rtl";return"dir"in t&&t.dir==="rtl"}var Ge=25;function Ze(t){let e=t.defaultView;if(!e)return null;let s=t.documentElement,i=e.visualViewport,n=i?.offsetLeft||0,r=i?.offsetTop||0,a=i?.width||s.clientWidth||e.innerWidth,o=i?.height||s.clientHeight||e.innerHeight,d=t.compatMode==="BackCompat"?a-s.clientWidth:s.clientWidth-s.getBoundingClientRect().width;if(d>0&&d<=Ge){let c=e.getComputedStyle?.(s).scrollbarGutter;if(c&&c!=="auto")a-=d}return{x:n,y:r,width:a,height:o,right:n+a,bottom:r+o}}function Xe(t,e){return e.scope?e.scope.getBoundingClientRect():Ze(t.ownerDocument)}function ee(t,e,s,i,n){let r=s+n,a=i-e-n,o=a>=r,d=o?r:s,c=o?a:i-e;return Math.max(d,Math.min(t,c))}function se(t,e,s){if(!s)return 50;let i=(t-e)/s*100;return Math.round(Math.min(100,Math.max(0,i))*1000)/1000}function Je(t,e){for(let s=0;s<t.length;s++){let i=t[s];if(i.right>=e.x&&i.left<=e.right&&i.bottom>=e.y&&i.top<=e.bottom)return!1}return!0}function Qe(t,e,s,i,n){if(e==="top")return Math.max(0,t.top-s.y-i-n);if(e==="bottom")return Math.max(0,s.bottom-t.bottom-i-n);return Math.max(0,s.height-n*2)}function ts(t){if(t.hidden)return!1;if(typeof t.checkVisibility==="function")return t.checkVisibility();return t.getClientRects().length>0}function oe(t){let{offsetWidth:e,offsetHeight:s}=t;if(e&&s)return{width:e,height:s};let i=t.getBoundingClientRect();return{width:e||i.width,height:s||i.height}}var ie=new WeakMap,ne={scroll:0,resize:1,"element-resize":2};function es(t){let e=t.defaultView;if(!e)throw TypeError("floating must belong to a document with a browsing context");let s=new Set,i=new Map,n=e.ResizeObserver,r=!1,a=!1,o=e.visualViewport;function d(y,v){let x=i.get(y);if(x===void 0||ne[v]>ne[x])i.set(y,v)}function c(){if(r)return;r=!0,e.requestAnimationFrame(()=>{let y=[...i];i.clear(),r=!1;for(let[v,x]of y){if(!s.has(v)||!v.floating.isConnected)continue;try{v.callback({type:x})}catch(A){h(A)}}})}function h(y){if(typeof e.reportError==="function")e.reportError(y);else e.setTimeout(()=>{throw y})}function b(y){for(let v of s)d(v,y);c()}function w(y){if(!n)return null;let v=new Set,x=new n((B)=>{let L=!1;for(let W of B)if(v.has(W.target))L=!0;else v.add(W.target);if(!L)return;d(y,"element-resize"),c()}),{reference:A,floating:C}=y;if(A)x.observe(A);if(C!==A)x.observe(C);return x}let E=()=>b("scroll"),k=()=>b("resize");function M(){if(a)return;t.addEventListener("scroll",E,{passive:!0,capture:!0}),e.addEventListener("resize",k,{passive:!0}),o?.addEventListener("scroll",E,{passive:!0}),o?.addEventListener("resize",k,{passive:!0}),a=!0}function T(){if(!a)return;t.removeEventListener("scroll",E,{capture:!0}),e.removeEventListener("resize",k),o?.removeEventListener("scroll",E),o?.removeEventListener("resize",k),a=!1}return{add(y,v,x){let A={reference:y,floating:v,callback:x};s.add(A),M();let C=w(A),B=!1;return()=>{if(B)return;if(B=!0,s.delete(A),i.delete(A),C?.disconnect(),s.size===0)T()}}}}function ss(t){let e=t.ownerDocument,s=ie.get(e);if(!s)s=es(e),ie.set(e,s);return s}function le(t,e,s){if(!e?.ownerDocument)throw TypeError("autoUpdate() expects a floating HTMLElement");if(t&&t.ownerDocument!==e.ownerDocument)throw TypeError("reference and floating must belong to the same document");if(typeof s!=="function")throw TypeError("callback must be a function");return ss(e).add(t,e,s)}function re(t,e,s){let i=s.placement===void 0?"bottom-start":s.placement,{side:n,align:r,crossAxis:a}=Ye(i),o=s.coordinateSpace===void 0?"viewport":s.coordinateSpace;if(!We.has(o))throw TypeError(`Unknown coordinateSpace: ${o}`);if(!ts(e))return null;let d=s.distance||0,c=s.flip!==!1,h=s.shift!==!1,b=s.shiftPadding??4,w=r?Ke(t):!1,E=t.getClientRects();if(!E.length)return null;let k=(_)=>_==="bottom"?E[E.length-1]:E[0],M=Xe(t,s);if(!M||Je(E,M))return null;let T=oe(e),y={x:{size:T.width,start:M.x,end:M.right},y:{size:T.height,start:M.y,end:M.bottom}},v=(_,u)=>je(k(_),T,_,u,w,d),x=(_,u)=>{let{size:f,start:D,end:m}=y[u];return qe(_,f,D+b,m-b)},A=(_,u)=>{let{size:f,start:D,end:m}=y[u];return x(h?ee(_,f,D,m,b):_,u)},C=v(n,r),B=(_,u)=>{let f=wt(_),D=f==="x"?"y":"x",m=x(u[D],D);return{main:m,total:m+A(u[f],f)}};if(c){let _=B(n,C),u=(f)=>{let D=v(f,r),m=B(f,D);if(m.total<_.total)n=f,C=D,_=m};if(_.main>0)u(ae[n]);if(a==="y"&&_.main>0)u("top"),u("bottom");a=wt(n)}if(a==="x"&&h&&r){let _=x(C.x,"x");if(_>0){let u=r==="end"?"start":"end",f=v(n,u);if(x(f.x,"x")<_)r=u,C=f}}if(h){let{size:_,start:u,end:f}=y[a];C[a]=ee(C[a],_,u,f,b)}let L=k(n),W=se(L.x+L.width/2,C.x,T.width),X=se(L.y+L.height/2,C.y,T.height),J=`${Qe(L,n,M,d,b)}px`,{style:I}=e,Q=I.getPropertyValue("--available-height")!==J,Y=o==="document"?t.ownerDocument.defaultView:null,Et=Y?Y.scrollX:0,ft=Y?Y.scrollY:0;I.left=`${C.x+Et}px`,I.top=`${C.y+ft}px`,I.setProperty("--arrow-x",`${W}%`),I.setProperty("--arrow-y",`${X}%`),I.setProperty("--available-height",J);let tt=r?`${n}-${r}`:n;return e.dataset.placement=tt,{width:T.width,height:T.height,roomChanged:Q,placement:tt}}function de(t,e,s={}){let i=re(t,e,s);if(!i)return!1;if(i.roomChanged){let n=oe(e);if(n.width!==i.width||n.height!==i.height)re(t,e,{...s,placement:i.placement,flip:!1})}return!0}function H(t){return!t.matches(":disabled")&&!t.readOnly}class ht{constructor(t,e={}){this.input=t,this.messages=e.messages||{},this.adapter=ct(e.locale||""),this.hidden=null,this.canonical="",this._dirty=!1,this._commitId=0,this._session=K(),this._originalName=t.getAttribute("name")||"",this._attributeObserver=null,this.onAttributesChanged=null,this.confirm=null,this._generatedDefault=null}setLocale(t){let e=this._generatedDefault,s=e?this.adapter.format(e):null;if(this.adapter=ct(t||""),e&&this.input.defaultValue===s)this.input.defaultValue=this.adapter.format(e)}adoptDefault(){let t=this.input;if(t.getAttribute("value")!=null||t.defaultValue!=="")return;t.defaultValue=t.value,this._generatedDefault=this.canonical&&t.value?this.canonical:null}setMessages(t){this.messages=t||{}}format(t){return this.adapter.format(t)}parse(t){return this.adapter.parse(t)}get placeholder(){return this.adapter.placeholder}get isDisabled(){return this.input.matches(":disabled")}get isReadOnly(){return this.input.readOnly}setupFormValue(){let t=this.input;this._originalName=t.getAttribute("name")||"",this._attributeObserver=new MutationObserver(()=>this.onAttributesChanged?.()),this._attributeObserver.observe(t,{attributes:!0,attributeFilter:["disabled","readonly","name","form"]}),this.syncInputState()}syncInputState(){let t=this.input,e=t.getAttribute("name")||"";if(e){if(!this.hidden){let s=document.createElement("input");s.type="hidden",s.value=this.canonical,t.insertAdjacentElement("afterend",s),this.hidden=s}if(this.hidden)this.hidden.name=e;t.removeAttribute("name")}if(this.hidden){if(t.hasAttribute("form"))this.hidden.setAttribute("form",t.getAttribute("form")||"");else this.hidden.removeAttribute("form");this.hidden.disabled=t.disabled}}dirty(){this._commitId++}get isDirty(){return this._dirty}handleInput(){let t=this.input,e=t.value.trim(),s=this.canonical?this.adapter.format(this.canonical):"";if(this.dirty(),e===s){if(this._dirty=!1,this.hidden)this.hidden.value=this.canonical;t.setCustomValidity("");return}if(this._dirty=!0,this.hidden)this.hidden.value="";if(!e){t.setCustomValidity("");return}t.setCustomValidity(this.messages.invalidDate)}async commit(t={}){let e=this.input,s=++this._commitId,i=this._session;if(i.signal.aborted)return{status:"stale",commitId:s};let n=e.value.trim();if(!n){if(s!==this._commitId)return{status:"stale",commitId:s};return e.setCustomValidity(""),{status:"clear",value:"",commitId:s}}let r=this.adapter.parse(n);if(!r){if(s!==this._commitId)return{status:"stale",commitId:s};if(this.hidden)this.hidden.value="";return e.setCustomValidity(this.messages.invalidDate),{status:"invalid",commitId:s}}if(this.confirm){let a=await this.confirm(r,t);if(i.signal.aborted||s!==this._commitId)return{status:"stale",commitId:s};if(!a?.ok){if(this.hidden)this.hidden.value="";return e.setCustomValidity(a?.message||this.messages.unavailableDate),{status:"invalid",commitId:s}}}return{status:"ok",value:r,commitId:s}}isCommitCurrent(t){return t===this._commitId}setCanonical(t,e={}){let s=t||"";if(s&&!l(s))throw TypeError(`Invalid date-picker value: ${s}`);if(this.dirty(),this.canonical=s,this._dirty=!1,this.hidden)this.hidden.value=s;if(e.format!==!1)this.input.value=s?this.adapter.format(s):"";this.input.setCustomValidity("")}restoreDefault(){let t=String(this.input.defaultValue??"").trim(),e=l(t)?t:this.adapter.parse(t);return e&&l(e)?e:""}teardown(){this.dirty(),this._session.abort(),this._attributeObserver?.disconnect(),this._attributeObserver=null;let t=this.hidden?.getAttribute("name")||this._originalName;if(t)this.input.setAttribute("name",t);this.hidden?.remove(),this.hidden=null}}var is=/^(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,3}))?)?$/;function It(t){let e=is.exec(String(t||""));if(!e)return null;let s=Number(e[1]),i=Number(e[2]),n=e[3]===void 0?0:Number(e[3]),r=e[4]===void 0?0:Number(e[4].padEnd(3,"0"));if(s>23||i>59||n>59||r>999)return null;return{hour:s,minute:i,second:n,millisecond:r}}function Ot(t){return It(t)!==null}function ce(t){return((t.hour*60+t.minute)*60+t.second)*1000+t.millisecond}function ue(t,e){let s=It(t),i=It(e);if(!s||!i)throw TypeError("compareTimes() expects HH:MM values");let n=ce(s)-ce(i);return n===0?0:n<0?-1:1}var ns=0;class Pt extends HTMLElement{static observedAttributes=["value","locale","min","max","open-on-focus","month-format"];static setDefaultControlClasses(t){_t(t)}static getDefaultControlClasses(){return at()}static setDefaultMessages(t){bt(t)}static getDefaultMessages(){return U()}constructor(){super();this._id=`date-picker-${++ns}`,this._connected=!1,this._reflecting=!1,this._value="",this._input=null,this._field=null,this._fields=null,this._range=null,this._orderTags=new Set,this._timeFields=[null,null],this._timeOrderOwned=new Set,this._lastFocusEndpoint="",this._activationId=0,this._previewDate="",this._buttons=[],this._returnFocus=null,this._panel=null,this._calendar=null,this._originalDescribedBy="",this._rangeOriginalDescribedBy=["",""],this._formatHint=null,this._generatedPlaceholders=new WeakSet,this._session=null,this._stopTracking=null,this._open=!1,this._suppressFocusOpen=!1,this._messages=null,this._controlClasses=null,this._stopDefaultMessages=null,this._source=null,this._dateState=null,this._renderDay=null,this._isDateDisabled=null,this._coordinateSpace="viewport"}_rangeMode(){return this.hasAttribute("range")&&Boolean(this._range)}connectedCallback(){if(this._connected)return;if(this._session=K(),Z(this,["locale","min","max","monthFormat","openOnFocus","coordinateSpace","controlClasses","messages","source","dateState","renderDay","isDateDisabled"]),this._normalizeAttributes(),this.hasAttribute("range"))this._connectRange();else this._connectSingle();if(!this._connected){this._session.abort(),this._session=null;return}Z(this,["value","range"]),this._stopDefaultMessages=vt(()=>{if(this._messages===null)this._refreshMessages()}),this.validate()}_normalizeAttributes(){let t=this.getAttribute("value");if(t&&!l(t))this.removeAttribute("value");for(let e of["min","max"]){let s=this.getAttribute(e);if(s&&!l(s))this.removeAttribute(e)}}_connectSingle(){let t=this.querySelector(":scope > input:not([type=hidden]):not([type=time]):not([data-time-start]):not([data-time-end])");if(!(t instanceof HTMLInputElement)){console.warn("<date-picker> expects a direct child text input");return}this._connected=!0,this._input=t,this._discoverTimeFields(),this._field=new ht(t,{messages:this.messages,locale:this.locale}),this._field.onAttributesChanged=()=>this._syncInputState(),this._field.confirm=(i,n)=>this._confirmDate(i,n),this._setupFormValue(),this._build(),this._syncInputState(),this._bind(),this._syncCalendarOptions();let e=this._adapter(),s=this.getAttribute("value")||(l(t.value)?t.value:e.parse(t.value));if(s&&l(s))this._setValue(s,{emit:!1,format:!0});else if(!t.value)this._setValue("",{emit:!1,format:!1});else t.setCustomValidity(this.messages.invalidDate);if(this._field.hidden)this._field.hidden.defaultValue=this._value;this._field.adoptDefault()}_discoverTimeFields(){this._timeFields=[null,null];let t=["data-time-start","data-time-end"];for(let[e,s]of t.entries()){let i=this.querySelectorAll(`:scope > input[${s}]`);if(i.length>1)console.warn(`<date-picker> expects at most one direct child input[${s}]; ignoring extras`);let n=i[0];if(n==null)continue;if(!(n instanceof HTMLInputElement)||n.type!=="time"){console.warn(`<date-picker> input[${s}] must be an <input type="time">; ignoring it`);continue}this._timeFields[e]=n}if(this.querySelector(":scope > input[type=time]:not([data-time-start]):not([data-time-end])"))console.warn("<date-picker> time inputs need [data-time-start] or [data-time-end]; ignoring it")}_connectRange(){if(this.querySelector(":scope > input[data-time-start], :scope > input[data-time-end]"))console.warn("<date-picker range> time companions are not supported yet; leaving them native");let t=this.querySelector(":scope > input[data-range-start]"),e=this.querySelector(":scope > input[data-range-end]");if(!(t instanceof HTMLInputElement)||!(e instanceof HTMLInputElement)){console.warn("<date-picker range> expects direct child inputs marked [data-range-start] and [data-range-end]");return}this._connected=!0,this._input=null,this._fields=[new ht(t,{messages:this.messages,locale:this.locale}),new ht(e,{messages:this.messages,locale:this.locale})],this._range=new $t,this._rangeOriginalDescribedBy=[t.getAttribute("aria-describedby")||"",e.getAttribute("aria-describedby")||""];for(let o of this._fields)o.onAttributesChanged=()=>this._syncRangeFields(),o.confirm=(d,c)=>this._confirmDate(d,c),o.setupFormValue();this._build(),this._setRangeAria(),this._syncRangeFields(),this._bindRange(),this._syncCalendarOptions();let s=this._adapter(),i=l(t.value)?t.value:s.parse(t.value),n=l(e.value)?e.value:s.parse(e.value),r=t.value,a=e.value;this._setRange(i||"",n||"",{emit:!1});for(let[o,d,c]of[[t,r,i],[e,a,n]]){if(!d.trim()||l(c))continue;o.value=d,o.setCustomValidity(this.messages.invalidDate)}if(this._fields[0].hidden)this._fields[0].hidden.defaultValue=this._range.start;if(this._fields[1].hidden)this._fields[1].hidden.defaultValue=this._range.end;for(let o of this._fields)o.adoptDefault()}disconnectedCallback(){if(this._stopDefaultMessages?.(),this._stopDefaultMessages=null,this._connected=!1,this._suppressFocusOpen=!1,this.hide(!1),this._session?.abort(),this._session=null,this._clearTimeOrderValidity(),this._timeFields=[null,null],this._rangeMode()){for(let t of this._fields||[])this._teardownField(t);this._fields=null,this._range=null}else this._teardownField(this._field);this._field=null;for(let{button:t}of this._buttons)t.remove();this._buttons=[],this._returnFocus=null,this._panel?.remove(),this._formatHint?.remove(),this._panel=null,this._calendar=null,this._formatHint=null}_teardownField(t){if(!t)return;let e=t.input,s=this._fields?.includes(t)?this._rangeOriginalDescribedBy[this._fields?.indexOf(t)??0]||"":this._originalDescribedBy;if(t.teardown(),s)e.setAttribute("aria-describedby",s);else e.removeAttribute("aria-describedby");e.removeAttribute("role"),e.removeAttribute("aria-haspopup"),e.removeAttribute("aria-expanded"),e.removeAttribute("aria-controls")}attributeChangedCallback(t,e,s){if(this._reflecting||e===s)return;if(!this._connected)return;if(t==="value"&&s&&!l(s)){this._reflectValue(this._value);return}if((t==="min"||t==="max")&&s&&!l(s)){if(this.removeAttribute(t),this._connected)this._syncCalendarOptions(),this.validate();return}if(t==="value"){if(this._rangeMode())return;if(!s||l(s))this._supersedeActivations(),this._setValue(s||"",{emit:!1,format:!0,reflect:!1});return}if(t==="locale")this._refreshLocale();if(t==="open-on-focus")return;this._syncCalendarOptions(),this.validate()}get input(){return this._rangeMode()?void 0:this._input}get calendar(){return this._calendar}get value(){return this._rangeMode()?void 0:this._value}set value(t){if(this._rangeMode())throw TypeError("value is not available in range mode; use range");if(t&&!l(t))throw TypeError(`Invalid date-picker value: ${t}`);this._supersedeActivations(),this._setValue(t||"",{emit:!1,format:!0})}get range(){return this._rangeMode()&&this._range?{...this._range.range}:void 0}set range(t){if(!this._rangeMode())throw TypeError("range is only available on <date-picker range>");let{start:e,end:s}=gt(t);this._supersedeActivations(),this._setRange(e,s)}get locale(){return P(this.getAttribute("locale")||"")}set locale(t){if(t)this.setAttribute("locale",t);else this.removeAttribute("locale")}get monthFormat(){return this.getAttribute("month-format")==="short"?"short":"long"}set monthFormat(t){if(t==="short")this.setAttribute("month-format","short");else this.removeAttribute("month-format")}get min(){let t=this.getAttribute("min")||"";return l(t)?t:""}set min(t){if(t)this.setAttribute("min",t);else this.removeAttribute("min")}get max(){let t=this.getAttribute("max")||"";return l(t)?t:""}set max(t){if(t)this.setAttribute("max",t);else this.removeAttribute("max")}get openOnFocus(){return this.getAttribute("open-on-focus")!=="false"}set openOnFocus(t){if(t===!1)this.setAttribute("open-on-focus","false");else this.removeAttribute("open-on-focus")}get open(){return this._open}get controlClasses(){return lt(this._controlClasses)}set controlClasses(t){if(this._controlClasses=ot(t),this._calendar)this._calendar.controlClasses=this._controlClasses}get messages(){return this._messages??U()}set messages(t){if(this._messages=t==null?null:{...U(),...t},this._calendar)this._calendar.messages=this._messages;this._refreshMessages()}_refreshMessages(){let t=this.messages;for(let s of this._fields||[])s.setMessages(t);this._field?.setMessages(t),this._panel?.setAttribute("aria-label",t.calendar);let e=this._field??this._fields?.[0];if(this._formatHint&&e)this._formatHint.textContent=`${t.formatHint}: ${e.placeholder}`;if(this._refreshButtonLabel(),this._connected)this.validate()}get source(){return this._source}set source(t){if(this._source=t||null,this._calendar)this._calendar.source=this._source;if(this._connected)this.validate()}get dateState(){return this._dateState}set dateState(t){if(this._dateState=typeof t==="function"?t:null,this._calendar)this._calendar.dateState=this._dateState;if(this._connected)this.validate()}get renderDay(){return this._renderDay}set renderDay(t){if(this._renderDay=typeof t==="function"?t:null,this._calendar)this._calendar.renderDay=this._renderDay}get isDateDisabled(){return this._isDateDisabled}set isDateDisabled(t){if(this._isDateDisabled=typeof t==="function"?t:null,this._calendar)this._calendar.isDateDisabled=this._isDateDisabled;if(this._connected)this.validate()}get coordinateSpace(){return this._coordinateSpace}set coordinateSpace(t){this._coordinateSpace=t==="document"?"document":"viewport"}_adapter(){return this._field?.adapter??this._fields?.[0]?.adapter??ct(this.locale)}_setupFormValue(){this._field?.setupFormValue()}_syncInputState(){let t=this._input;if(!t)return;this._field?.syncInputState();let e=this._buttons[0]?.button;if(e)e.disabled=t.disabled||t.readOnly;if(this._open&&!H(t))this.hide(!1)}_syncRangeFields(){if(!this._fields)return;for(let s of this._fields)s.syncInputState();for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?1:0,r=this._fields[n];s.disabled=Boolean(r?.input.disabled||r?.input.readOnly)}let t=this._range?.activeEndpoint==="end"?1:0,e=this._fields[t]?.input;if(this._open&&e&&!H(e))this.hide(!1)}_setRangeAria(){if(!this._fields||!this._panel||!this._formatHint)return;for(let t of this._fields){let e=t.input,s=[this._rangeOriginalDescribedBy[this._fields.indexOf(t)],this._formatHint.id].filter(Boolean).join(" ");e.setAttribute("aria-describedby",s),e.setAttribute("role","combobox"),e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",this._panel.id)}}_createTrigger(t){let e=document.createElement("button");if(e.type="button",e.className="dp-picker-button",e.setAttribute("aria-haspopup","dialog"),e.setAttribute("aria-expanded","false"),e.setAttribute("aria-controls",`${this._id}-panel`),t)e.dataset.endpoint=t;return e.innerHTML='<span aria-hidden="true"><svg viewBox="0 0 16 16" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round"><rect x="1.75" y="3" width="12.5" height="11" rx="1.75"/><path d="M1.75 6.75h12.5"/><path d="M5.25 1.75v2.5M10.75 1.75v2.5"/></svg></span>',e}_build(){let t=this._rangeMode(),e=[];if(t)for(let[o,d]of(this._fields||[]).entries())e.push([d.input,o===1?"end":"start"]);else if(this._input)e.push([this._input,""]);if(!e.length)return;let s=`${this._id}-panel`,i=`${this._id}-format`;this._buttons=e.map(([o,d])=>{let c=this._createTrigger(d);return o.insertAdjacentElement("afterend",c),{button:c,endpoint:d}});let n=document.createElement("div");n.id=s,n.className="dp-picker-panel",n.setAttribute("popover","manual"),n.setAttribute("role","dialog"),n.setAttribute("aria-label",this.messages.calendar);let r=new ut;r.selection="none",r.fixedWeeks=!0,n.append(r);let a=document.createElement("span");if(a.id=i,a.className="dp-visually-hidden",this.append(n,a),this._panel=n,this._calendar=r,this._formatHint=a,!t&&this._input){this._originalDescribedBy=this._input.getAttribute("aria-describedby")||"";let o=[this._originalDescribedBy,i].filter(Boolean).join(" ");this._input.setAttribute("aria-describedby",o),this._input.setAttribute("role","combobox"),this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded","false"),this._input.setAttribute("aria-controls",s)}this._refreshLocale(),this._refreshButtonLabel()}_bindPopup(t,e,s){this.ownerDocument.addEventListener("pointerdown",(i)=>{if(!this._open||i.composedPath().includes(this))return;this.hide(!1)},{capture:!0,signal:t}),this.ownerDocument.addEventListener("reset",(i)=>{if(!(i.target instanceof HTMLFormElement)||!e||i.target!==e.form)return;this.hide(!1),queueMicrotask(G(t,()=>{if(!i.defaultPrevented)s()}))},{capture:!0,signal:t}),this.addEventListener("keydown",(i)=>this._onEscape(i),{signal:t})}_bind(){let t=this._input,e=this._buttons[0]?.button,s=this._calendar;if(!t||!e||!s)return;let i=this._session;if(!i)return;let{signal:n}=i;t.addEventListener("input",()=>{this._field?.handleInput()},{signal:n}),t.addEventListener("change",()=>void this._commitText(!1),{signal:n}),t.addEventListener("blur",()=>void this._commitText(!1),{signal:n}),t.addEventListener("focus",(r)=>{if(!this.openOnFocus||this._suppressFocusOpen)return;let a=r.relatedTarget;if(a instanceof Node&&this.contains(a))return;if(!this._open)this.show({moveFocus:!1})},{signal:n}),t.addEventListener("keydown",(r)=>{this._onFieldKeyDown("",r)},{signal:n});for(let[r,a]of this._timeFields.entries()){if(!a)continue;let o=r===1?"end":"start";a.addEventListener("input",()=>this._revalidateTimeOrder(o),{signal:n}),a.addEventListener("change",()=>this._revalidateTimeOrder(o),{signal:n})}e.addEventListener("click",(r)=>{if(this._open){if(r.detail===0){this._defer(()=>this._calendar?.focusGrid());return}this.hide(!1);return}this.show({returnFocus:e})},{signal:n}),e.addEventListener("keydown",(r)=>this._onTriggerKeyDown("",r),{signal:n}),s.addEventListener("click",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("keydown",(r)=>this._captureGridIntent(r),{capture:!0,signal:n}),s.addEventListener("dateactivate",(r)=>{let a=r,o=a.detail?.date;if(!l(o))return;let d=st.get(a);queueMicrotask(()=>{if(n.aborted||a.defaultPrevented)return;if(d&&d.id!==this._activationId)return;if(!this._input||!H(this._input))return;this._field?.dirty(),this._setValue(o,{emit:!0,format:!0}),this.hide(!1),this._restoreFocus()})},{signal:n}),s.addEventListener("dateloadend",()=>void this.validate(),{signal:n}),this._bindPopup(n,this._input,()=>this._restoreDefault())}_bindRange(){let t=this._calendar;if(!this._fields||!this._buttons.length||!t)return;let e=this._session;if(!e)return;let{signal:s}=e;for(let[i,n]of this._fields.entries()){let r=i===1?"end":"start";n.input.addEventListener("input",()=>{if(n.handleInput(),this._orderTags.delete(i),!n.isDirty)this._revalidateRange(r)},{signal:s}),n.input.addEventListener("change",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("blur",()=>void this._commitFieldText(r),{signal:s}),n.input.addEventListener("focus",(a)=>this._onFieldFocus(r,a),{signal:s}),n.input.addEventListener("keydown",(a)=>this._onFieldKeyDown(r,a),{signal:s})}for(let i of this._buttons){let n=i.endpoint;if(n==="")continue;i.button.addEventListener("click",(r)=>this._onRangeTriggerClick(n,r),{signal:s}),i.button.addEventListener("keydown",(r)=>this._onTriggerKeyDown(n,r),{signal:s})}t.addEventListener("click",(i)=>{this._captureGridIntent(i)},{capture:!0,signal:s}),t.addEventListener("keydown",(i)=>this._captureGridIntent(i),{capture:!0,signal:s}),t.addEventListener("dateactivate",(i)=>{let n=i,r=n.detail?.date;if(!l(r))return;queueMicrotask(()=>{if(s.aborted||n.defaultPrevented||!this._range)return;let a=st.get(n);if(a===void 0||a.id!==this._activationId)return;let o=(c)=>this._boundEditable(c),d=this._range.activate(r,o);if(d.status==="refused"){this._calendar?.dispatchEvent(new CustomEvent("dateinvalid",{detail:{date:r,state:this._calendar.getDateState(r)},bubbles:!0}));return}if(this._applyRangeTransition(d),d.close||d.status==="complete")this.hide(!1),this._focusField(d.endpoint)})},{signal:s}),t.addEventListener("datefocus",(i)=>this._onGridDateFocus(i),{signal:s}),t.addEventListener("pointerover",(i)=>this._onGridPointerOver(i),{signal:s}),t.addEventListener("pointerleave",()=>this._onGridPointerLeave(),{signal:s}),t.addEventListener("dateloadend",()=>void this.validate(),{signal:s}),this._bindPopup(s,this._fields?.[0]?.input,()=>this._restoreRangeDefault())}_activateRangeEndpoint(t){let e=this._calendar;if(!this._range||!e)return;this._range.focus(t),this._activationId++,this._lastFocusEndpoint=t;let s=this._boundCanonical(t)||O();e.display=p(s),e.focusedDate=s,this._clearPreview()}_onRangeTriggerClick(t,e){if(!this._open){this.show({endpoint:t});return}if(e.detail===0){this._activateRangeEndpoint(t),this._defer(()=>this._calendar?.focusGrid());return}if(t!==this._range?.activeEndpoint){this._activateRangeEndpoint(t);return}this.hide(!1)}_onTriggerKeyDown(t,e){if(e.key!=="ArrowDown")return;if(e.preventDefault(),this._open){if(this._rangeMode()&&t)this._activateRangeEndpoint(t);this._defer(()=>this._calendar?.focusGrid());return}if(this._rangeMode())this.show({endpoint:t||void 0});else this.show({returnFocus:this._buttons[0]?.button})}_onFieldKeyDown(t,e){if(e.key==="ArrowDown"){if(e.preventDefault(),this._rangeMode()&&t)this._lastFocusEndpoint=t,this._range?.focus(t);if(this._open)this._defer(()=>this._calendar?.focusGrid());else this.show()}else if(e.key==="Escape"&&this._open)e.preventDefault(),this.hide(!1)}_onFieldFocus(t,e){if(!this._rangeMode()||!t)return;let s=t!==this._range?.activeEndpoint;if(this._lastFocusEndpoint=t,this._range?.focus(t),s)this._activationId++;if(!this.openOnFocus||this._suppressFocusOpen)return;let i=e.relatedTarget;if(i instanceof Node&&this.contains(i))return;if(!this._open)this.show({moveFocus:!1})}_captureGridIntent(t){if(this._rangeMode()?!this._range:!this._field)return;if(t.type==="keydown"){let i=t.key;if(i!=="Enter"&&i!==" ")return}if(!(t.target instanceof Element))return;let s=t.target.closest(".dp-day[data-date]")?.getAttribute("data-date")||"";if(!l(s))return;this._attachIntent(s)}_attachIntent(t){if(!this._calendar)return;this._calendar._hostIntent={date:t,intent:{id:++this._activationId}}}_supersedeActivations(){this._activationId++}_boundEditable(t){let e=this._fields?.[t==="end"?1:0];return e!=null&&H(e.input)}_applyRangeTransition(t){let e=this._fields;if(!e||!this._range||t.status==="refused")return;let s=[];for(let i of t.changedEndpoints){let n=e[i==="end"?1:0],r=i==="end"?t.range.end:t.range.start;if(!n||n.canonical===r)continue;n.setCanonical(r,{format:!0}),s.push(n)}if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange(t.endpoint),!s.length)return;this._emitRangeChange();for(let i of s)i.input.dispatchEvent(new Event("input",{bubbles:!0})),i.input.dispatchEvent(new Event("change",{bubbles:!0}))}_setPreview(t){let e=this._calendar;if(!e||!this._range||!this._open)return;let s=l(t)&&!e.getDateState(t).disabled?t:"",i=s?this._range.previewRange(s,(n)=>this._boundEditable(n)):null;if(!i){this._clearPreview();return}this._previewDate=s,e.toggleAttribute("data-range-preview",!0),e.highlightedRange=i}_clearPreview(){if(!this._previewDate)return;this._syncHighlight()}_onGridDateFocus(t){let e=t.detail?.date;if(l(e))this._setPreview(e)}_onGridPointerOver(t){let e=t;if(e.pointerType==="touch")return;this._setPreview(this._cellDate(e.target))}_onGridPointerLeave(){this._clearPreview()}_cellDate(t){let s=(t instanceof Element?t.closest(".dp-day[data-date]"):null)?.getAttribute("data-date")||"";return l(s)?s:""}_onEscape(t){if(t.key==="Escape"&&this._open)t.preventDefault(),t.stopPropagation(),this.hide(!0)}_syncCalendarOptions(){let t=this._calendar,e=this._panel;if(!t)return;if(t.locale=this.locale,t.min=this.min,t.max=this.max,t.monthFormat=this.monthFormat,t.controlClasses=this._controlClasses,t.messages=this._messages,t.source=this._source,t.dateState=this._dateState,t.renderDay=this._renderDay,t.isDateDisabled=this._isDateDisabled,!this._rangeMode()&&this._value)t.value=this._value;if(e)e.setAttribute("aria-label",this.messages.calendar)}_refreshLocale(){let t=this._formatHint;if(!t)return;if(this._rangeMode()&&this._fields){this._fields[0].setLocale(this.locale),this._fields[1].setLocale(this.locale),t.textContent=`${this.messages.formatHint}: ${this._fields[0].placeholder}`;for(let[s,i]of this._fields.entries()){if(!i.input.hasAttribute("placeholder")||this._generatedPlaceholders.has(i.input))i.input.placeholder=i.placeholder,this._generatedPlaceholders.add(i.input);let n=s===1?this._range?.end||"":this._range?.start||"";if(n)i.input.value=i.format(n)}this._refreshButtonLabel();return}let e=this._field;if(!e)return;if(e.setLocale(this.locale),t.textContent=`${this.messages.formatHint}: ${e.placeholder}`,!e.input.hasAttribute("placeholder")||this._generatedPlaceholders.has(e.input))e.input.placeholder=e.placeholder,this._generatedPlaceholders.add(e.input);if(this._value)e.input.value=e.format(this._value);this._refreshButtonLabel()}_refreshButtonLabel(){let t=this._buttons[0]?.button;if(!t)return;if(this._rangeMode()){this._refreshRangeButtonLabel();return}let e=this._value?this.messages.changeDate:this.messages.chooseDate,s=this._value?`, ${dt(this._value,this.locale)}`:"";t.setAttribute("aria-label",`${e}${s}`)}_refreshRangeButtonLabel(){if(!this._range)return;let{start:t,end:e}=this._range;for(let{button:s,endpoint:i}of this._buttons){let n=i==="end"?e:t,r=n?this.messages.changeDate:this.messages.chooseDate,a=n?`, ${dt(n,this.locale)}`:"",o=i==="end"?this.messages.rangeEnd:this.messages.rangeStart;s.setAttribute("aria-label",`${r}${a}, ${o}`)}}_reflectValue(t){if(this._reflecting=!0,t)this.setAttribute("value",t);else this.removeAttribute("value");this._reflecting=!1}_setValue(t,e={}){if(t&&!l(t))throw TypeError(`Invalid date-picker value: ${t}`);let s=this._value;if(this._value=t||"",e.reflect!==!1)this._reflectValue(this._value);if(this._field?.setCanonical(this._value,{format:e.format!==!1}),this._calendar){if(this._calendar.value=this._value,this._value&&e.moveDisplay!==!1)this._calendar.focusedDate=this._value}if(this._refreshButtonLabel(),s!==this._value){if(this.dispatchEvent(new CustomEvent("valuechange",{detail:{value:this._value},bubbles:!0})),e.emit&&this._field){let i=this._field.input;i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0}))}}}async _confirmDate(t,e={}){let s=this._calendar;if(!s)return{ok:!0};if(e.moveDisplay!==!1){let r=p(t);if(s.display!==r)s.display=r}let i=await s.ensureDate(t),n=s.getDateState(t);if(!i||n.disabled)return{ok:!1,message:this.messages.unavailableDate};return{ok:!0}}async _commitText(t,e={}){let s=this._field,i=this._session;if(!s||!i)return!1;if(!e.force&&!s.isDirty)return!1;let n=await s.commit(e);if(i.signal.aborted||!s.isCommitCurrent(n.commitId))return!1;if(n.status==="stale"||n.status==="invalid")return!1;return this._setValue(n.value||"",{emit:t,format:n.status==="ok",moveDisplay:e.moveDisplay}),!0}async _commitFieldText(t){let e=this._fields,s=this._session;if(!e||!s)return!1;let i=t==="end"?1:0,n=e[i];if(!n?.isDirty)return!1;let r=await n.commit();if(s.signal.aborted||!n.isCommitCurrent(r.commitId))return!1;if(r.status==="stale")return!1;if(r.status==="invalid")return this._orderTags.delete(i),!1;return this._setBound(t,r.value||"",{emit:!1,user:!0,format:r.status==="ok"}),!0}_setBound(t,e,s={}){if(!this._range)return!1;let i=this._fields;if(!i)return!1;let r=i[t==="end"?1:0];if(!r)return!1;if(s.user===!0&&!H(r.input))return!1;let a=e||"",o=r.canonical;if(r.setCanonical(a,{format:s.format!==!1}),t==="end")this._range.end=a;else this._range.start=a;let d=o!==a;if(d){if(this._syncHighlight(),this._refreshRangeButtonLabel(),this._emitRangeChange(),s.emit)r.input.dispatchEvent(new Event("input",{bubbles:!0})),r.input.dispatchEvent(new Event("change",{bubbles:!0}))}return this._revalidateRange(t),d}_setRange(t,e,s={}){if(!this._range||!this._fields)return;if(this._range.start=t||"",this._range.end=e||"",this._fields[0].setCanonical(t||"",{format:s.format!==!1}),this._fields[1].setCanonical(e||"",{format:s.format!==!1}),this._syncHighlight(),this._refreshRangeButtonLabel(),this._revalidateRange("start"),this._revalidateRange("end"),s.emit!==!1)this._emitRangeChange()}_boundCanonical(t){return this._range?t==="end"?this._range.end:this._range.start:""}_emitRangeChange(){if(!this._range)return;this.dispatchEvent(new CustomEvent("rangechange",{detail:{...this._range.range},bubbles:!0}))}_displayRange(){let{start:t,end:e}=this._range?.range??{start:"",end:""};if(!t)return{start:"",end:""};if(e&&g(e,t)<0)return{start:t,end:""};return{start:t,end:e}}_syncHighlight(){if(!this._calendar||!this._range)return;this._previewDate="",this._calendar.removeAttribute("data-range-preview"),this._calendar.highlightedRange=this._displayRange()}_revalidateRange(t){if(!this._fields||!this._range)return;let{start:e,end:s}=this._range,i=Boolean(e&&s&&g(s,e)<0),n=["start","end"];for(let r of n){let a=r==="end"?1:0,o=this._fields[a].input,d=r==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(i&&r===t)o.setCustomValidity(d),this._orderTags.add(a);else if(this._orderTags.has(a))o.setCustomValidity(""),this._orderTags.delete(a)}}_revalidateTimeOrder(t){let[e,s]=this._timeFields,i=["start","end"],n=[e,s],r=e&&!e.matches(":disabled")?e.value.trim():"",a=s&&!s.matches(":disabled")?s.value.trim():"",o=Boolean(e&&s&&r&&a)&&Ot(r)&&Ot(a)&&ue(a,r)<0;for(let[d,c]of i.entries()){let h=n[d];if(!h)continue;let b=c==="end"?this.messages.rangeOrderEnd:this.messages.rangeOrderStart;if(o&&c===t)h.setCustomValidity(b),this._timeOrderOwned.add(h);else if(this._timeOrderOwned.has(h))h.setCustomValidity(""),this._timeOrderOwned.delete(h)}}_clearTimeOrderValidity(){for(let t of this._timeOrderOwned)t.setCustomValidity("");this._timeOrderOwned.clear()}_defer(t){let e=this._session;if(!e)return;setTimeout(G(e.signal,t),0)}_restoreDefault(){let t=this._field;if(!t)return;let e=t.restoreDefault();if(this._setValue(e,{emit:!1,format:!0}),this._calendar)if(this._value)this._calendar.display=p(this._value),this._calendar.focusedDate=this._value;else this._calendar.display=p(O()),this._calendar.focusedDate=O();this.validate()}_restoreRangeDefault(){if(!this._fields)return;let t=this._fields[0].restoreDefault(),e=this._fields[1].restoreDefault();if(this._setRange(t,e),this._calendar){let s=this._range?.start||O();this._calendar.display=p(s),this._calendar.focusedDate=s}this.validate()}_focusField(t){let e=t==="end"?1:0,s=this._fields?.[e]?.input;if(!s)return;this._suppressFocusOpen=!0,this._defer(()=>{s.focus(),this._suppressFocusOpen=!1})}_restoreFocus(){let t=this._returnFocus;if(this._returnFocus=null,!(t instanceof HTMLElement)||!t.isConnected||t.matches(":disabled"))return;this._suppressFocusOpen=!0,this._defer(()=>{t.focus(),this._suppressFocusOpen=!1})}_resolveRangeEndpoint(){if(!this._fields)return"";let t=this._lastFocusEndpoint||"start",e=t==="end"?1:0;if(H(this._fields[e].input))return t;let s=t==="end"?"start":"end",i=s==="end"?1:0;if(H(this._fields[i].input))return s;return""}async validate(){let t=this._session;if(this._rangeMode()){let i=this._fields;if(!i)return!0;for(let[n,r]of i.entries()){let a=await r.commit({moveDisplay:!1});if(!t||t.signal.aborted)return i.every((o)=>o.input.checkValidity());if(!r.isCommitCurrent(a.commitId))continue;if(a.status==="invalid")this._orderTags.delete(n);if(a.status==="ok"||a.status==="clear"){let o=n===1?"end":"start";this._setBound(o,a.value||"",{format:a.status==="ok"})}}return this._revalidateRange("start"),this._revalidateRange("end"),i.every((n)=>n.input.checkValidity())}let e=this._field?.input;if(!e){let i=this.hasAttribute("range")?this.querySelectorAll(":scope > input[data-range-start], :scope > input[data-range-end]"):this._input?[this._input]:[],n=this.querySelectorAll(":scope > input[type=time][data-time-start], :scope > input[type=time][data-time-end]");return[...i,...n].every((r)=>r instanceof HTMLInputElement&&r.checkValidity())}if(await this._commitText(!1,{force:!0,moveDisplay:!1}),!t||t.signal.aborted)return e.checkValidity()&&this._timeFields.every((i)=>i?.checkValidity()??!0);this._revalidateTimeOrder("start"),this._revalidateTimeOrder("end");let s=this._timeFields.every((i)=>i?.checkValidity()??!0);return e.checkValidity()&&s}show(t={}){let e=this._panel,s=this._calendar;if(!e||!s||!this._buttons.length||this._open)return;if(this._rangeMode()){let r=t.endpoint||this._resolveRangeEndpoint();if(!r)return;this._activateRangeEndpoint(r)}else{let r=this._input;if(!r||!H(r))return;let a=this._value||this._adapter().parse(r.value)||O();s.display=p(a),s.focusedDate=a,this._returnFocus=t.returnFocus instanceof HTMLElement?t.returnFocus:r}e.showPopover(),this._open=!0,this._setExpanded(!0);let i=this.coordinateSpace;e.style.position=i==="document"?"absolute":"fixed";let n=()=>de(this,e,{placement:"bottom-start",distance:4,shiftPadding:8,coordinateSpace:i});if(n(),this._stopTracking=le(this,e,n),t.moveFocus!==!1){let r=this._session;if(r)queueMicrotask(G(r.signal,()=>s.focusGrid()))}this.dispatchEvent(new Event("open",{bubbles:!0}))}_setExpanded(t){let e=t?"true":"false";this._input?.setAttribute("aria-expanded",e);for(let{button:s}of this._buttons)s.setAttribute("aria-expanded",e);for(let s of this._fields||[])s.input.setAttribute("aria-expanded",e)}hide(t=!1){if(!this._panel||!this._open)return;this._stopTracking?.(),this._stopTracking=null;try{this._panel.hidePopover()}catch{}if(this._open=!1,this._setExpanded(!1),this._supersedeActivations(),this._syncHighlight(),t)if(this._rangeMode()){let e=this._restoreFocusEndpoint();if(e)this._focusField(e)}else this._restoreFocus();this.dispatchEvent(new Event("close",{bubbles:!0}))}_restoreFocusEndpoint(){let t=this._range?.activeEndpoint||"";if(t){let e=t==="end"?1:0,s=this._fields?.[e];if(s&&H(s.input))return t}return this._resolveRangeEndpoint()}}function he(){if(!customElements.get("date-calendar"))customElements.define("date-calendar",ut);if(!customElements.get("date-picker"))customElements.define("date-picker",Pt)}he();})();