@aiquants/period-slider 0.16.0 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +215 -0
- package/README.md +55 -30
- package/dist/DateSelector.d.ts +2 -2
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +2 -2
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +235 -40
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/YearSelector.d.ts +4 -2
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2459 -2340
- package/dist/inputValue.d.ts +90 -21
- package/dist/inputValue.d.ts.map +1 -1
- package/dist/selectorMemo.d.ts +14 -0
- package/dist/selectorMemo.d.ts.map +1 -1
- package/dist/selectorStep.d.ts +13 -10
- package/dist/selectorStep.d.ts.map +1 -1
- package/dist/useCommittedRef.d.ts +80 -0
- package/dist/useCommittedRef.d.ts.map +1 -0
- package/dist/usePeriodSlider.d.ts +42 -18
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/dist/useUncontrolledSelection.d.ts +27 -0
- package/dist/useUncontrolledSelection.d.ts.map +1 -0
- package/dist/vernierStep.d.ts +10 -1
- package/dist/vernierStep.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/DateSelector.tsx +15 -17
- package/src/MonthSelector.tsx +11 -15
- package/src/PeriodSlider.tsx +430 -148
- package/src/YearSelector.tsx +20 -13
- package/src/inputValue.ts +151 -21
- package/src/selectorMemo.ts +18 -3
- package/src/selectorStep.ts +24 -29
- package/src/useCommittedRef.ts +206 -0
- package/src/usePeriodSlider.ts +342 -208
- package/src/useUncontrolledSelection.ts +54 -0
- package/src/valueSet.ts +1 -1
- package/src/vernierStep.ts +12 -10
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),Sr=require("date-fns"),s=require("react"),ir=require("@aiquants/virtualscroll"),Pl=require("react-dom"),Ll="an object that cannot be converted to a string",Ne=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},M=e=>{if(typeof e=="string")return JSON.stringify(e);if(Ne(e))return Date.prototype.toISOString.call(e);try{return String(e)}catch{return Ll}},St=(e,t)=>Ne(e)?t(e):Number.NaN,mt=(e,t)=>e===void 0?null:St(e,t),Si=120,Fo="data-drag-snap",Uo="--ps-drag-snap-duration",dn={flat:["--ps-drag-low","--ps-drag-high"],macro:["--ps-drag-macro-low","--ps-drag-macro-high"],micro:["--ps-drag-micro-low","--ps-drag-micro-high"]},os=["low","high"],as=["tx","ty","rot"],lo={flat:{low:"--ps-drag-label-low",high:"--ps-drag-label-high"},macro:{low:"--ps-drag-macro-label-low",high:"--ps-drag-macro-label-high"},micro:{low:"--ps-drag-micro-label-low",high:"--ps-drag-micro-label-high"}},ga=(e,t)=>`${e}-${t}`,Bo=(e,t,r)=>`var(${ga(e,t)}, ${r})`,Tl=(e,t,r)=>{const n=lo[t];for(const o of os)for(const a of as)e.style.setProperty(ga(n[o],a),r[o][a])},is=e=>Math.max(0,Math.min(1,e)),Qn=(e,t,r,n)=>{const o=is(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},ha=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},co=(e,t,r,n)=>{const o=is(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},Wo=(e,t,r,n)=>{if(r){const i=(1-e)*100,l=(1-t)*100;return n?`M 12 ${l} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${l} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},er=(e,t)=>`var(${e}, ${t}%)`,$l=(e,t,r,n)=>{const[o,a]=dn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},Cl=e=>{for(const[t,r]of Object.values(dn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(lo))for(const r of os)for(const n of as)e.style.removeProperty(ga(t[r],n))},ss=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],uo=[...ir.VIRTUAL_SCROLL_LABEL_KEYS,...ss],na=Object.freeze({en:Object.freeze({rangeStart:"Range start",rangeEnd:"Range end",selectedDate:"Selected date",macroRangeStart:"Macro range start",macroRangeEnd:"Macro range end",microRangeStart:"Micro range start",microRangeEnd:"Micro range end",microSelectedDate:"Micro selected date",decrease:"Decrease",increase:"Increase",previousYear:"Previous year",nextYear:"Next year",yearSelect:"Year",previousMonth:"Previous month",nextMonth:"Next month",monthSelect:"Month",previousDay:"Previous day",nextDay:"Next day",dateSelect:"Date",splitYear:"Year",splitMonth:"Month",splitDay:"Day"}),ja:Object.freeze({rangeStart:"期間の開始",rangeEnd:"期間の終了",selectedDate:"選択日",macroRangeStart:"広域期間の開始",macroRangeEnd:"広域期間の終了",microRangeStart:"詳細期間の開始",microRangeEnd:"詳細期間の終了",microSelectedDate:"詳細の選択日",decrease:"前へ",increase:"次へ",previousYear:"前年",nextYear:"翌年",yearSelect:"年",previousMonth:"前月",nextMonth:"翌月",monthSelect:"年月",previousDay:"前日",nextDay:"翌日",dateSelect:"日付",splitYear:"年",splitMonth:"月",splitDay:"日"})}),ls=Object.freeze({en:Object.freeze({...ir.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...na.en}),ja:Object.freeze({...ir.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...na.ja})}),Ri=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,Il=e=>uo.includes(e),kl=(e,t)=>{const r={};let n=!1;for(const o of ir.VIRTUAL_SCROLL_LABEL_KEYS){const a=t.has(o)?e[o]:void 0;a!==void 0&&(r[o]=a,n=!0)}return n?r:void 0},Al=e=>{try{return ir.resolveVirtualScrollLocale(e)}catch(t){throw t instanceof RangeError?new RangeError(`[period-slider] locale is the UI language, not a BCP 47 tag (date formatting reads formatLocale): ${t.message}`,{cause:t}):t}},cs=(e,t)=>{const r=Al(e);if(t===void 0)return ls[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${Ri(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const l of o)if(!Il(l))throw new RangeError(`[period-slider] labels.${l} is not a known label key; expected one of ${uo.join(", ")}`);const i={...ir.resolveVirtualScrollLabels(r,kl(t,o)),...na[r]};for(const l of ss){const u=o.has(l)?t[l]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[period-slider] labels.${l} must be a non-blank string; got ${Ri(u)}`);i[l]=u}}return Object.freeze(i)},Nl=e=>{const t={};for(const r of ir.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Vl=(e,t)=>e===t||uo.every(r=>e[r]===t[r]),mo=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0||e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const r=new Set(Object.keys(e)),n=Object.keys(t);if(r.size!==n.length)return!1;const o=e,a=t;return n.every(i=>r.has(i)&&Object.is(o[i],a[i]))},Go=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Di=new Set(["hidden","clip","scroll","auto","overlay"]),Mi=["paint","strict","content"],Ol=["layout","paint","strict","content"],_l=["transform","perspective","filter"],nn=e=>e!==void 0&&e!==""&&e!=="none",Yl=e=>e!==void 0&&e!==""&&e!=="normal",On=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},Hl=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,jl=(e,t)=>t==="absolute"&&nn(e.position)&&e.position!=="static"||nn(e.transform)||nn(e.perspective)||nn(e.filter)||nn(e.backdropFilter)||Yl(e.containerType)||Ol.some(r=>e.contain.includes(r))?!0:_l.some(r=>e.willChange.includes(r)),zl=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const l=e.getBoundingClientRect();if(l.width===0||l.height===0)return!1;const u=n?0:r,f=n?r:0;if(o<l.left-u||o>=l.right+u||a<l.top-f||a>=l.bottom+f)return!1;const g=i.getComputedStyle(t);if(g.visibility!=="visible")return!1;let v=null;for(let b=t;b!==null;b=b.parentElement){const T=b===t?g:i.getComputedStyle(b);if(v!==null&&!jl(T,v))continue;const Q=Di.has(T.overflowX)||Mi.some(D=>T.contain.includes(D)),m=Di.has(T.overflowY)||Mi.some(D=>T.contain.includes(D));if(Q||m){const D=b.getBoundingClientRect();if(Q&&(o<D.left+On(T.borderLeftWidth)||o>=D.right-On(T.borderRightWidth))||m&&(a<D.top+On(T.borderTopWidth)||a>=D.bottom-On(T.borderBottomWidth)))return!1}v=Hl(T)}return!0},Ko=new Map,Fl=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},Ul=(e,t)=>{let r=Ko.get(e);if(r===void 0){const a=new Set,i=l=>Fl(a,l);r={participants:a,listener:i},Ko.set(e,r),e.addEventListener("wheel",i,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(Ko.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},mn="gap-[11px]",Nt=6,Vt=Nt*2,tr=Nt*4/3,Bl={left:`0,${Vt/2} ${Nt},0 ${Nt},${Vt}`,right:`${tr},${Vt/2} ${tr-Nt},0 ${tr-Nt},${Vt}`,up:`${Vt/2},0 0,${Nt} ${Vt},${Nt}`,down:`${Vt/2},${tr} 0,${tr-Nt} ${Vt},${tr-Nt}`},qo=e=>{e.preventDefault(),e.stopPropagation()},Wl={onMouseDownCapture:qo,onMouseUpCapture:qo,onClickCapture:qo},Gl="period-slider-step",Kl=`${Gl} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,ql="transition-colors motion-reduce:transition-none not-aria-disabled:cursor-pointer aria-disabled:cursor-not-allowed focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 dark:focus-visible:ring-blue-400 forced-colors:not-aria-disabled:hover:text-[Highlight] forced-colors:aria-disabled:text-[GrayText]",Xl={control:"text-slate-500 not-aria-disabled:hover:bg-slate-500/15 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-500/25 aria-disabled:text-slate-500/40 dark:text-slate-400 dark:not-aria-disabled:hover:text-slate-50 dark:aria-disabled:text-slate-400/40",rail:"border border-slate-300 bg-white text-slate-700 shadow-2xs not-aria-disabled:hover:border-slate-400 not-aria-disabled:hover:bg-slate-100 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-200 aria-disabled:border-slate-300/40 aria-disabled:bg-white/40 aria-disabled:text-slate-700/40 aria-disabled:shadow-none dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:not-aria-disabled:hover:border-slate-500 dark:not-aria-disabled:hover:bg-slate-700 dark:not-aria-disabled:hover:text-white dark:not-aria-disabled:active:bg-slate-600 dark:aria-disabled:border-slate-700/40 dark:aria-disabled:bg-slate-800/40 dark:aria-disabled:text-slate-200/40"},_n="after:inset-[calc((100%-var(--ps-target-size))/2)]",yi={horizontal:"px-[19px]",vertical:"py-[19px]"},Zl={control:{left:_n,right:_n,up:_n,down:_n},rail:{left:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:left-[calc(100%-var(--ps-target-size)+4px)] after:-right-[4px]",right:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-left-[4px] after:right-[calc(100%-var(--ps-target-size)+4px)]",up:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-[calc(100%-var(--ps-target-size)+4px)] after:-bottom-[4px]",down:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-[4px] after:bottom-[calc(100%-var(--ps-target-size)+4px)]"}},Rr=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:i,ref:l})=>{const u=e==="up"||e==="down",f=u?Vt:tr,g=u?tr:Vt,v=r||!n;return L.jsx("button",{ref:l,type:"button","aria-label":a,disabled:r,"aria-disabled":v?!0:void 0,...v?Wl:null,onClick:v?void 0:o,className:`${i===void 0?"":`${i} `}${Kl} ${ql} ${Xl[t]} ${Zl[t][e]}`,children:L.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:f,height:g,viewBox:`0 0 ${f} ${g}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:L.jsx("polygon",{points:Bl[e]})})})},fo=(e,t)=>{const r=s.useMemo(()=>cs(e,t),[e,t]),n=s.useRef(r);return Vl(n.current,r)||(n.current=r),n.current},ct=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${M(r)})`)},sr=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&ct(e,"values.min",t.min),t.max!==null&&ct(e,"values.max",t.max),t.min!==null&&t.max!==null&&t.max<t.min)throw new RangeError(`${e}: values.max must not precede values.min (min: ${t.min}, max: ${t.max})`);return}ct(e,"values.loIndex",t.loIndex),ct(e,"values.hiIndex",t.hiIndex)},xn=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,go=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},fn=(e,t)=>(sr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:xn(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),gn=(e,t)=>{if(sr("drawnValuesHas",e),ct("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(xn(e))return!1;const r=go(e,t);return r<=e.hiIndex&&e.ascending[r]===t},hn=(e,t)=>{if(sr("drawnValuesNearest",e),ct("drawnValuesNearest","value",t),e.kind==="range")return e.min!==null&&t<e.min?e.min:e.max!==null&&t>e.max?e.max:t;if(xn(e))return null;const r=go(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Wt=(e,t,r)=>{if(sr("drawnValuesNeighbour",e),ct("drawnValuesNeighbour","value",t),e.kind==="range"){if(r===-1){const i=e.max===null?t-1:Math.min(t-1,e.max);return e.min!==null&&i<e.min?null:i}const a=e.min===null?t+1:Math.max(t+1,e.min);return e.max!==null&&a>e.max?null:a}if(xn(e))return null;const n=go(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},Wn=(e,t,r)=>{if(sr("clampPairIntoDrawnValues",e),ct("clampPairIntoDrawnValues","low",t),ct("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=hn(e,t),o=hn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Ql=(e,t,r)=>{if(sr("carryPairIntoDrawnValues",e),ct("carryPairIntoDrawnValues","low",t),ct("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(xn(e))return null;const n=fn(e,-1),o=fn(e,1),a=r-t;return o!==null&&r>o?Wn(e,o-a,o):n!==null&&t<n?Wn(e,n,n+a):Wn(e,t,r)},Gn=(e,t,r)=>(sr("drawnValuesAtOrBeyond",e),ct("drawnValuesAtOrBeyond","target",t),Wt(e,t-r,r)),Br=(e,t,r)=>{if(t!==null&&ct("drawnValuesWithin","min",t),r!==null&&ct("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:go(n,t),hiIndex:o-1}},Kn=e=>(sr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Wt(e,t,r),edge:t=>fn(e,t)}),oa=(e,t,r,n,o)=>{if(ct("stepPair","low",t),ct("stepPair","high",r),r<t)throw new RangeError(`stepPair: high must not precede low (low: ${t}, high: ${r})`);if(n!==-1&&n!==1)throw new RangeError(`stepPair: direction must be -1 or 1 (received: ${M(n)})`);switch(o.motion){case"shift":{if(o.edge!=="disable"&&o.edge!=="clamp")throw new RangeError(`stepPair: rule.edge must be "disable" or "clamp" (received: ${M(o.edge)})`);const a=n===1?r:t,i=n===1?t:r,l=e.stepEnd(i,n);if(l===null)return null;let u=e.stepEnd(a,n);if(u===null){const f=e.edge(n);if(o.edge==="disable"||f===null||(n===1?a>f:a<f))return null;u=f}return n===1?[l,u]:[u,l]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${M(o.shows)})`);const a=e.stepEnd(o.shows==="start"?t:r,n);return a===null?null:[a,a]}default:throw new RangeError(`stepPair: rule.motion must be one of "shift", "start", "end", "single" (received: ${M(o.motion)})`)}},us={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},ds=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,$t=(e,t)=>{if(!ds(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${M(t)})`)},lr=(e,t)=>t===void 0?0:($t(e,t),t),ut=(e,t,r=0)=>{if(!Ne(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${M(t)})`);$t("normalizeDateByUnit",r);const n=new Date(t.getTime());if(e==="year"){const o=t.getFullYear()-(t.getMonth()<r?1:0);n.setFullYear(o,r,1),n.setHours(0,0,0,0)}else e==="month"&&n.setDate(1),n.setHours(0,0,0,0);return n},A=(e,t,r=0)=>{$t("encode",r);const n=ut(e,t,r),o=n.getFullYear(),a=n.getMonth()+1,i=n.getDate();if(e==="year")return o;if(e==="month")return o*12+(a-1);const l=new Date(0);return l.setUTCFullYear(o,a-1,i),l.setUTCHours(0,0,0,0),Math.floor(l.getTime()/(1440*60*1e3))},te=(e,t,r=0)=>{$t("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),i=t-a*12;return n.setFullYear(a,i,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},nt=(e,t,r)=>{if(!Ne(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${M(t)})`);return e==="year"?Sr.addYears(t,r):e==="month"?Sr.addMonths(t,r):Sr.addDays(t,r)},ms=(e,t,r,n=0)=>{if(!Ne(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${M(r)})`);return $t("getMacroWindowStartDate",n),ut(t,ut(e,r,n),n)},fs=(e,t,r,n=0)=>{if(!Ne(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${M(r)})`);if($t("getMacroWindowEndDate",n),e===t)return ut(t,r,n);const o=r.getFullYear(),a=r.getMonth();if(e==="year"){const i=ut("year",r,n),l=Sr.addMonths(i,11);if(t==="month")return l;if(t==="day")return ut("day",Sr.addDays(Sr.addMonths(i,12),-1))}return e==="month"&&t==="day"?new Date(o,a+1,0):ut(t,r,n)},Ei=(e,t,r)=>e<t?t:e>r?r:e,Dt=(e,t,r,n,o,a=0)=>{if($t("resolveMacroWindow",a),Jn("macroRange",r,!0,"resolveMacroWindow"),!Ne(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${M(n)})`);if(!Ne(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${M(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${M(n)}, maxDate: ${M(o)})`);return[ut(t,Ei(ms(e,t,r[0],a),n,o),a),ut(t,Ei(fs(e,t,r[1],a),n,o),a)]},gs=(e,t)=>{if(!Ne(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${M(e)})`);$t("resolveQuarter",t);const r=ut("year",e,t).getFullYear(),n=((e.getMonth()-t)%12+12)%12,o=Math.floor(n/3)+1,a=new Date(e.getTime());return a.setFullYear(r,t+3*(o-1),1),a.setHours(0,0,0,0),{year:r,quarter:o,startDate:a}},Jl={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Pi=new Map,ec=(e,t)=>{const r=`${e}\0${t}`,n=Pi.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Jl[e]);return Pi.set(r,o),o},tc=4,rc=6,ho=e=>e>=0?String(e).padStart(tc,"0"):`-${String(-e).padStart(rc,"0")}`,nc=(e,t)=>{const r=ho(t.getFullYear());if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${o}`},rt=(e,t,r,n)=>Ne(t)?r?r(t,e,"period"):n===void 0?nc(e,t):ec(e,n).format(t):"",br=(e,t,r,n)=>rt(e,t,r,n),oc=(e,t)=>{if(!Ne(e))return"";$t("formatQuarterLabel",t);const{quarter:r}=gs(e,t);return`${rt("year",ut("year",e,t))}-Q${r}`},Ee=(e,t,r,n=0)=>{if($t("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;const o=A(r,t,n);let a=0,i=e.length-1;if(o<=A(r,e[a],n))return 0;if(o>=A(r,e[i],n))return i;for(;a<=i;){const f=a+i>>1,g=A(r,e[f],n);if(g===o)return f;g<o?a=f+1:i=f-1}const l=Math.abs(A(r,e[a],n)-o),u=Math.abs(A(r,e[i],n)-o);return l<u?a:i},Dr=(e,t,r,n,o=0)=>hs(e,t,r,n,o).dates,hs=(e,t,r,n,o)=>{if($t("getSortedAllowedDates",o),!Array.isArray(e)||e.length===0)return{keys:[],dates:[]};const a=A(t,r,o),i=A(t,n,o),l=new Map;for(let f=0;f<e.length;f++){const g=e[f];if(!Ne(g))throw new RangeError(`getSortedAllowedDates: allowedDates[${f}] must be a valid Date (received: ${M(g)})`);const v=ut(t,g,o),b=A(t,v,o);b<a||b>i||l.has(b)||l.set(b,v)}if(l.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${M(r)}, maxDate: ${M(n)}, entries: ${e.length})`);const u=Array.from(l.keys()).sort((f,g)=>f-g);return{keys:u,dates:u.map(f=>l.get(f))}},wa=(e,t,r,n,o)=>{const{keys:a,dates:i}=hs(e,t,r,n,o);return i.length===0?null:{...Br(a,null,null),dates:i}},wn=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),Yn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Ee(e,n,t,o);if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-l)/u))}return i/a},Hn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Ee(e,new Date(l+i*u),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},aa=(e,t,r,n,o,a,i)=>{let l=r,u=n;return i?(l=t,u=t):e==="low"?t>n?(l=n,u=t):l=t:t<r?(u=r,l=t):u=t,[Math.max(o,Math.min(a,l)),Math.max(o,Math.min(a,u))]},ws=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:l,unit:u,yearStartMonth:f=0})=>{if(a){const m=i.length-1;if(m<=0)return[0,0];const D=Math.max(0,Math.min(m,Math.round(t))),d=Math.max(D,Math.min(m,Math.round(r)));if(l==="time"){const H=i[0].getTime(),fe=i[m].getTime(),O=i[D].getTime(),ee=i[d].getTime()-O;let ie=O+e*(fe-H),N=ie+ee;ie<H&&(ie=H,N=H+ee),N>fe&&(N=fe,ie=fe-ee);const oe=Ee(i,new Date(ie),u,f),E=Ee(i,new Date(N),u,f);return[oe,Math.max(oe,E)]}const j=Math.round(e*m);let P=D+j,_=d+j;return P<0&&(_+=-P,P=0),_>m&&(P-=_-m,_=m),[Math.max(0,Math.min(m,P)),Math.max(0,Math.min(m,_))]}const g=m=>Math.max(n,Math.min(o,m)),v=o-n;if(v<=0)return[g(t),g(r)];const b=Math.round(e*v);let T=t+b,Q=r+b;return T<n&&(Q+=n-T,T=n),Q>o&&(T-=Q-o,Q=o),[g(T),g(Q)]},bs=(e,t,r,n,o,a,i,l)=>{let u=0,f=!1,g=!1;switch(e){case"ArrowRight":case"ArrowUp":u=l;break;case"ArrowLeft":case"ArrowDown":u=-l;break;case"PageUp":u=l*5;break;case"PageDown":u=-l*5;break;case"Home":f=!0;break;case"End":g=!0;break;default:return null}if(i){let T=r;return f?T=o:g?T=a:T=Math.max(o,Math.min(a,r+u)),[T,T]}let v=r,b=n;return t==="low"?f?v=o:g?v=n:v=Math.max(o,Math.min(n,r+u)):f?b=r:g?b=a:b=Math.max(r,Math.min(a,n+u)),[v,b]},ps=8,vs=2,xs=16,ac=12,ic=90,Ss=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},ba=(e,t)=>{const r=t?.estimatedHeightPx??xs,o=ps+(t?.anchorGapY??vs)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},pa=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??xs,l=o?.paddingPx??ac,u=o?.maxAngleDeg??ic,f=ps+(o?.anchorGapY??vs),g=ba(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return g;const v=Math.max(0,t-e)/100*r,b=a+l;if(v>=b)return g;const T=Math.max(0,Math.min(1,(b-v)/b)),m=T*T*T*(T*(T*6-15)+10)*u,D=n==="top"?-m:m,d=Ss(a,i,m),j=f+d.acrossPx,P=n==="top"?-j:+j,_=2*d.alongPx,H=Math.max(0,(_+l-v)/2);return{lowAngleDeg:D,highAngleDeg:D,lowOffsetX:-H,highOffsetX:H,lowOffsetY:P,highOffsetY:P,isSlanted:T>.001,proximity:T}},Rs=e=>({...e,lowOffsetX:0,highOffsetX:0}),Ot=(e,t)=>(e==="macro"?t.macroAllowedDates:t.microAllowedDates)??t.allowedDates,qn=(e,t,r,n)=>e==="pan"?Ql(t,r,Math.max(r,n)):Wn(t,r,Math.max(r,n)),va=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},Ds=(e,t,r)=>{const n=Math.abs(e)>Math.abs(t)?e:t;return!Number.isFinite(n)||n===0?0:(r?n<0:n>0)?1:-1};function Ms(e,t,r,n,o,a,i="macro-top",l=.05,u=!0,f="range"){if(va(t,i)==="macro"){const b=Math.abs(e-r),T=Math.abs(e-n);return b<=l&&b<=T?"macro-low":T<=l&&T<b?"macro-high":u&&e>=r&&e<=n?"macro-connect":b<T?"macro-low":"macro-high"}if(f==="point")return"micro-point";const g=Math.abs(e-o),v=Math.abs(e-a);return g<=l&&g<=v?"micro-low":v<=l&&v<g?"micro-high":u&&e>=o&&e<=a?"micro-connect":g<v?"micro-low":"micro-high"}function ys(e,t,r,n,o){if(e==="macro-connect"){const[f,g]=ha(t-r,n,o);return[f,g,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,l]=Qn(a,t,n,o),u=co(a,t,n,o);return[i,l,u==="low"?"macro-low":"macro-high"]}function Es(e,t,r,n,o){if(e==="micro-point"){const[f]=Qn("point",t,n,o);return[f,f,"micro-point"]}if(e==="micro-connect"){const[f,g]=ha(t-r,n,o);return[f,g,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,l]=Qn(a,t,n,o),u=co(a,t,n,o);return[i,l,u==="low"?"micro-low":"micro-high"]}const cn=s.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",a=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return L.jsx("svg",{className:a,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:L.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});cn.displayName="VernierKnobSvg";const sc=(e,t)=>{if(!Ne(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${M(e)})`);if(!Ne(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${M(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${M(e)}, maxDate: ${M(t)})`)},Jn=(e,t,r,n="PeriodSlider")=>{if(!Array.isArray(t)||t.length!==2){const i=r?"is required and must":"must";throw new RangeError(`${n}: ${e} ${i} be a [start, end] Date tuple (received: ${M(t)})`)}const[o,a]=t;if(!Ne(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${M(o)})`);if(!Ne(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${M(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${M(o)}, end: ${M(a)})`)},Ps=(e,t)=>{if(!Ne(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${M(t)})`)},zr=(e,t,r,n,o,a)=>{const i=A(r,t,a);if(i<A(r,n,a)||i>A(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${M(t)}, minDate: ${M(n)}, maxDate: ${M(o)})`)},lc=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(Jn(o,a,!1),zr(`${o}[0]`,a[0],e.unit,t,r,n),zr(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(Ps(o,a),zr(o,a,e.unit,t,r,n))}},cc=(e,t,r)=>{const n=e.yearStartMonth??0;Jn("macroRange",e.macroRange,!0);const o=e.microUnit??e.unit,a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,i=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&i)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(i){for(const f of["microValue","defaultMicroValue"]){const g=e[f];g!==void 0&&(Ps(f,g),zr(f,g,o,t,r,n))}const u=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(u===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[u,u]}}for(const u of["microRange","defaultMicroRange"]){const f=e[u];f!==void 0&&(Jn(u,f,!1),zr(`${u}[0]`,f[0],o,t,r,n),zr(`${u}[1]`,f[1],o,t,r,n))}const l=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(l!==void 0)return{shape:"range",selection:l};throw a?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},on=(e,t,r,n,o,a,i,l,u)=>{const f=Ee(e,n,t,u),g=Ee(e,o,t,u);return i?f:l?g:Math.max(f,Math.min(g,Ee(e,r,t,u)+a))},Xo=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Li=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback((a,i)=>{const l=r.current;if(l!==null&&l[0].getTime()===a.getTime()&&l[1].getTime()===i.getTime())return;const u=[a,i];r.current=u,t(u)},[]),o=s.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},uc=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${M(t)})`)}},Hr=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const l of i){const u=l.borderBoxSize?.[0];u!==void 0&&t(f=>f!==null&&Math.abs(f.widthPx-u.inlineSize)<.5&&Math.abs(f.heightPx-u.blockSize)<.5?f:{widthPx:u.inlineSize,heightPx:u.blockSize})}});a.observe(o),r.current=a},[]);return s.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},Zo=(e,t)=>{const r=Xn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},Xn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},dc=e=>{const t={};let r=0;for(const o of e){const{side:a,box:i}=o;if(i===null)continue;let l;if(o.reach==="inline-size")l=i.widthPx,r=Math.max(r,i.heightPx/2);else{const u=Ss(i.widthPx,i.heightPx,o.angleDeg);l=o.centreOffsetPx===null?2*u.acrossPx:Math.abs(o.centreOffsetPx)+u.acrossPx,r=Math.max(r,u.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${Math.ceil(l)}px`}if(Object.keys(t).length===0)return;const n=Math.ceil(r);return t["--ps-label-reach-main"]=`${n}px`,{style:t,mainPx:n}},Ti=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),$i=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),eo=(e,t)=>({"--ps-tooltip-tx":Bo(e,"tx",t.tx),"--ps-tooltip-ty":Bo(e,"ty",t.ty),"--ps-tooltip-rot":Bo(e,"rot",t.rot)}),Qo=(e,t,r,n)=>{const o=ba(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=pa(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?Rs(a):a,l=lo[e],u={low:Ti(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:Ti(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:eo(l.low,u.low),highStyle:eo(l.high,u.high),placements:u}},Ci={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Ii=(e,t,r)=>{const n=ba(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Ci,highStyle:Ci,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const u=pa(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?Rs(u):u}const i=lo.flat,l={low:$i(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:$i(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...eo(i.low,l.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...eo(i.high,l.high)},placements:o?l:null}},mc={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},fc={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},ki={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},gc={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${mn} ${yi.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${ki.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${mn} ${yi.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${ki.vertical}`}},Ai={horizontal:{leading:"col-start-1 row-start-1",rail:"col-start-2 row-start-1",railOnly:"col-start-1 row-start-1",trailing:"col-start-3 row-start-1"},vertical:{leading:"col-start-1 row-start-1",rail:"col-start-1 row-start-2",railOnly:"col-start-1 row-start-1",trailing:"col-start-1 row-start-3"}},Ni=(e,t)=>{e.setPointerCapture(t)},hc=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:l="",showStepper:u=!0,tooltipStyle:f="always",labelPosition:g="top",autoSlantLabels:v=!0,isVertical:b=!1,hideConnectBar:T=!1,showTicks:Q=!1,colorScheme:m="blue-rose",formatLocale:D}=e,d=lr("PeriodSlider",e.yearStartMonth);sc(r,n),lc(e,r,n),D!==void 0&&uc("formatLocale",D);const j=e.mode==="vernier"?cc(e,r,n):null,P=j!==null&&j.shape==="point",_=fo(e.locale,e.labels),H=us[m],fe=s.useId(),O=s.useRef(e),ee=r.getTime(),ie=n.getTime(),N=s.useMemo(()=>Dr(o,t,r,n,d),[o,t,ee,ie,d]),oe=N.length>0,{rangeMin:E,rangeMax:R}=s.useMemo(()=>oe?{rangeMin:0,rangeMax:N.length-1}:{rangeMin:A(t,r,d),rangeMax:A(t,n,d)},[oe,N,t,ee,ie,d]),$=e.mode==="point",W=s.useCallback(c=>{if(oe){const w=Math.max(0,Math.min(N.length-1,Math.round(c)));return N[w]}return te(t,Math.round(c),d)},[oe,N,t,d]),Z=s.useCallback(c=>{if(c===void 0)return E;const w=ut(t,c,d);return oe?Ee(N,w,t,d):A(t,w,d)},[oe,N,t,E,d]),[z,J]=s.useState(()=>j===null?null:j.selection);let C=z??(j===null?null:j.selection);if(P&&C!==null&&C[0].getTime()!==C[1].getTime()){const c=[C[0],C[0]];C=c,J(c)}const ce=e.mode==="vernier"?e.microValue?.getTime():void 0,we=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,ce]),Me=Li(),K=Li(),re=e.mode!=="vernier"?null:P?we??C:e.microRange!==void 0?e.microRange:C,U=re===null?null:K.shown??re,de=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?U?.[0]:void 0,se=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?U?.[1]:void 0,I=e.mode==="point"?e.value??e.defaultValue:void 0,ge=e.mode==="point"?I?.getTime():de?.getTime(),pe=e.mode==="range"?se?.getTime():ge,[gt,me]=s.useMemo(()=>{if(e.mode==="point"){const p=Z(I);return[p,p]}const c=Z(de),w=Z(se);return[Math.min(c,w),Math.max(c,w)]},[e.mode,ge,pe,Z,I,de,se]),be=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:P?e.microValue!==void 0:e.microRange!==void 0,[Ve,ve]=s.useState(()=>[gt,me]),[Je,We]=s.useState(null),[Te,ot]=s.useState(null),B=s.useRef(null),[Ge,Ye]=s.useState("high"),[Be,He]=s.useState(null),[Ke,at]=s.useState(null),Re=Je?Je[0]:be?gt:Ve[0],Se=Je?Je[1]:be?me:Ve[1],Mt=s.useRef([Re,Se]),x=e.mode==="vernier",q=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",k=q==="macro-top"||q==="macro-left",ht=e.mode==="vernier"?e.showVernierProjection??!0:!1,qe=e.mode==="vernier"?e.showVernierTicks??!0:!1,wt=e.mode==="vernier"?e.showHairline??!0:!1,ne=x?e.macroUnit??t:t,h=x?e.microUnit??t:t,le=x?e.macroIsDiscrete??!1:oe,ye=x?e.microIsDiscrete??!1:oe,Oe=x?Ot("macro",e):o,y=x?Ot("micro",e):o,Y=x?e.formatMacroLabel??e.formatLabel:e.formatLabel,ue=x?e.formatMicroLabel??e.formatLabel:e.formatLabel,Ce=de?.getTime(),je=se?.getTime(),[Le,ze]=s.useState(null),et=s.useRef(null),[yt,Ht]=s.useState(()=>P?"micro-point":"micro-high");let Fe=yt;const po=P?yt==="micro-low"||yt==="micro-high"||yt==="micro-connect"?"micro-point":null:yt==="micro-point"?"micro-high":null;po!==null&&(Fe=po,Ht(po));const bt=s.useMemo(()=>A(ne,r,d),[ee,ne,d]),Ct=s.useMemo(()=>A(ne,n,d),[ie,ne,d]),Ie=s.useMemo(()=>x&&le?Dr(Oe,ne,r,n,d):[],[x,le,Oe,ne,ee,ie,d]),Da=c=>[Math.max(bt,Math.min(Ct,A(ne,c[0],d))),Math.max(bt,Math.min(Ct,A(ne,c[1],d)))],[Ma,ya]=e.mode!=="vernier"?[bt,Ct]:Da(e.macroRange),[it,st]=Me.shown===null?[Ma,ya]:Da(Me.shown),jt=s.useMemo(()=>te(ne,it,d),[ne,it,d]),cr=s.useMemo(()=>te(ne,st,d),[ne,st,d]),Sn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:Dt(ne,h,[jt,cr],r,n,d),[e.mode,jt,cr,ne,h,ee,ie,d]),_e=s.useMemo(()=>A(h,Sn[0],d),[h,Sn,d]),tt=s.useMemo(()=>A(h,Sn[1],d),[h,Sn,d]),Rn=s.useMemo(()=>x&&ye?wa(y,h,r,n,d):null,[x,ye,y,h,ee,ie,d]),vo=(c,w)=>Rn===null?[]:wn(Rn,Br(Rn.ascending,c,w)),xe=s.useMemo(()=>vo(_e,tt),[Rn,_e,tt]),Gt=le&&Ie.length>0,Et=ye&&xe.length>0,Ea=Gt?A(ne,Ie[0],d):bt,Pa=Gt?A(ne,Ie[Ie.length-1],d):Ct,La=Et?A(h,xe[0],d):_e,xo=Et?A(h,xe[xe.length-1],d):tt,Fs=Math.min(Ea,it),Us=Math.max(Pa,st),Kt=(c,w,p,S)=>w.length>0?A(h,w[Ee(w,c,h,d)],d):Math.max(p,Math.min(S,A(h,c,d))),yr=Et?xe:[],Xe=s.useMemo(()=>U===null?_e:Kt(U[0],yr,_e,tt),[Ce,_e,tt,h,U,yr]),dt=s.useMemo(()=>U===null?tt:Kt(U[1],yr,_e,tt),[je,_e,tt,h,U,yr]),qt=s.useMemo(()=>te(h,Xe,d),[h,Xe,d]),Xt=s.useMemo(()=>te(h,dt,d),[h,dt,d]),Ta=!x||re===null?null:{macroUnit:ne,macroLowEnc:Ma,macroHighEnc:ya,microUnit:h,microLowEnc:A(h,re[0],d),microHighEnc:A(h,re[1],d)},So=s.useRef(Ta),Ro=Math.max(1,Ct-bt),Pt=Gt?Yn(Ie,ne,a,jt,d):Math.max(0,Math.min(1,(it-bt)/Ro)),It=Math.max(Pt,Gt?Yn(Ie,ne,a,cr,d):Math.min(1,(st-bt)/Ro)),$a=c=>Math.max(Ea,Math.min(Pa,Math.round(bt+c*Ro))),Dn=Math.max(1,tt-_e),Er=Et?Yn(xe,h,a,qt,d):Math.max(0,Math.min(1,(Xe-_e)/Dn)),Wr=Math.max(Er,Et?Yn(xe,h,a,Xt,d):Math.min(1,(dt-_e)/Dn)),Do=s.useRef({timerId:null,emit:null}),Mn=s.useRef({timerId:null,emit:null}),yn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const c=[Do,Mn,yn];return()=>{for(const w of c)Xo(w.current)}},[]);const Pr=s.useCallback((c,w,p)=>{Xo(c);const{debounceMs:S}=O.current;if(p||!S||S<=0){w();return}c.emit=w,c.timerId=setTimeout(()=>{c.timerId=null,c.emit=null,w()},S)},[]),Ca=s.useCallback(c=>{const w=c.emit;Xo(c),w?.()},[]),Lr=s.useCallback(c=>new Date(Math.min(Math.max(c.getTime(),ee),ie)),[ee,ie]),Zt=s.useCallback((c,w,p=!1)=>{const[S,V]=Mt.current;if((O.current.mode==="point"?c===S:c===S&&w===V)&&Do.current.timerId===null)return;const X=W(c),G=W(w),he=()=>{const De=O.current;De.mode==="point"?De.onChangePoint?.(X):De.mode==="range"&&De.onChangeRange?.(X,G)};Pr(Do.current,he,p)},[W,Pr]),ur=s.useCallback((c,w,p=!1)=>{const S=So.current;if(O.current.mode!=="vernier"||S===null)return;const V=Lr(c),F=Lr(w);A(S.macroUnit,V,d)===S.macroLowEnc&&A(S.macroUnit,F,d)===S.macroHighEnc&&Mn.current.timerId===null||Pr(Mn.current,()=>{const X=O.current;X.mode==="vernier"&&X.onChangeMacroRange?.(V,F)},p)},[Lr,Pr,d]),pt=s.useCallback((c,w,p=!1)=>{const S=O.current,V=So.current;if(S.mode!=="vernier"||V===null)return;const F=Lr(c),X=Lr(w);A(V.microUnit,F,d)===V.microLowEnc&&A(V.microUnit,X,d)===V.microHighEnc&&yn.current.timerId===null||((P?S.microValue===void 0:S.microRange===void 0)&&J([F,X]),Pr(yn.current,()=>{const G=O.current;if(G.mode==="vernier"){if(P){G.onChangeMicroPoint?.(F);return}G.onChangeMicroRange?.(F,X)}},p))},[Lr,Pr,P,d]),Ia=s.useCallback((c,w=!1)=>{pt(c,c,w)},[pt]),dr=s.useCallback(c=>{if(oe&&a==="time"&&N.length>1){const S=Math.max(0,Math.min(N.length-1,Math.round(c))),V=N[0].getTime(),X=N[N.length-1].getTime()-V;if(X<=0)return 0;const G=N[S].getTime();return Math.max(0,Math.min(100,(G-V)/X*100))}const w=R-E;if(w<=0)return 0;const p=(c-E)/w*100;return Math.max(0,Math.min(100,p))},[oe,a,N,E,R]),Mo=s.useCallback(c=>{const w=Math.max(0,Math.min(100,c));if(oe){if(a==="time"&&N.length>1){const V=N[0].getTime(),X=N[N.length-1].getTime()-V,G=V+w/100*X;return Ee(N,new Date(G),t,d)}const S=Math.round(w/100*(N.length-1));return Math.max(0,Math.min(N.length-1,S))}const p=E+w/100*(R-E);return Math.round(p)},[oe,a,N,E,R,t,d]),Gr=s.useRef(null),ka=s.useRef(null),Aa=s.useRef(0),ft=s.useRef(null),yo=s.useRef(null),Na=s.useRef(null),Va=s.useRef(null),[Eo,Oa]=s.useState(0),[Bs,Tr]=Hr(),[Ws,_a]=Hr(),[Gs,Ya]=Hr(),[Ks,Ha]=Hr(),[qs,Po]=Hr(),[Xs,ja]=Hr(),Zs=$?Tr===null?void 0:{estimatedWidthPx:Tr.widthPx,estimatedHeightPx:Tr.heightPx}:Zo(Tr,_a),Lo=!$&&Re===Se,To=it===st,$o=!P&&Xe===dt,Qs=k?"top":"bottom",Js=k?"bottom":"top",za=v&&!b,el=za&&!P,Co={isPointMode:$,isVertical:b,autoSlantLabels:v,isMerged:Lo,trackLengthPx:Eo,labelPosition:g,config:Zs},Io={trackLengthPx:Eo,labelPosition:Qs,config:Zo(Ya,Ha),isMerged:To,isSlantable:za},ko={trackLengthPx:Eo,labelPosition:Js,config:Zo(Po,ja),isMerged:$o,isSlantable:el};s.useEffect(()=>{const c=ft.current;if(!c)return;const w=()=>{const S=c.getBoundingClientRect(),V=b?S.height:S.width;V>0&&Oa(F=>Math.abs(F-V)<.5?F:V)};if(w(),typeof ResizeObserver<"u"){const S=new ResizeObserver(V=>{for(const F of V){const X=b?F.contentRect.height:F.contentRect.width;X>0&&Oa(G=>Math.abs(G-X)<.5?G:X)}});return S.observe(c),()=>S.disconnect()}const p=c.ownerDocument.defaultView;if(p)return p.addEventListener("resize",w),()=>p.removeEventListener("resize",w)},[b]);const $r=s.useCallback((c,w,p)=>{const S=b?p.height:p.width;if(!(Number.isFinite(S)&&S>0))return null;const V=b?p.bottom-w:c-p.left;return Number.isFinite(V)?Math.max(0,Math.min(1,V/S)):null},[b]),Fa=s.useCallback((c,w)=>{const p=ft.current;if(!p)return null;const S=$r(c,w,p.getBoundingClientRect());return S===null?null:S*100},[$r]),Kr=s.useRef(null),zt=s.useRef(null),En=s.useRef({macroLowRatio:Pt,macroHighRatio:It,isVertical:b,isMacroFirstRail:k}),Ua=s.useRef({flat:Co,macro:Io,micro:ko});s.useLayoutEffect(()=>{En.current={macroLowRatio:Pt,macroHighRatio:It,isVertical:b,isMacroFirstRail:k},Ua.current={flat:Co,macro:Io,micro:ko},O.current=e,Mt.current=[Re,Se],So.current=Ta,B.current=Te,et.current=Le});const Ba=(c,w)=>{const p=En.current;yo.current?.setAttribute("d",Wo(c,w,p.isVertical,p.isMacroFirstRail))},tl=(c,w,p)=>{const S=Ua.current;return c==="flat"?Ii(w*100,p*100,S.flat).placements:Qo(c,w,p,c==="macro"?S.macro:S.micro).placements},qr=(c,w,p)=>{const S=ft.current;if(!S)return;Kr.current={rail:c,lowRatio:w,highRatio:p},$l(S,c,w,p);const V=tl(c,w,p);V!==null&&Tl(S,c,V),c==="macro"&&Ba(w,p)},mr=s.useCallback(()=>{zt.current!==null&&(clearTimeout(zt.current),zt.current=null);const c=ft.current;c&&(c.removeAttribute(Fo),c.style.removeProperty(Uo))},[]),Wa=()=>{const c=ft.current;if(Kr.current===null||!c){Kr.current=null;return}Kr.current=null,zt.current!==null&&clearTimeout(zt.current),c.style.setProperty(Uo,`${Si}ms`),c.setAttribute(Fo,"true"),Cl(c),Ba(En.current.macroLowRatio,En.current.macroHighRatio),zt.current=setTimeout(()=>{zt.current=null,c.removeAttribute(Fo),c.style.removeProperty(Uo)},Si)};s.useLayoutEffect(()=>{const c=Kr.current;c!==null&&qr(c.rail,c.lowRatio,c.highRatio)}),s.useEffect(()=>()=>{zt.current!==null&&clearTimeout(zt.current)},[]);const Cr=s.useRef(null),Ir=s.useRef(null),kt=s.useRef(null),Ao=s.useRef(null),Xr=s.useRef(null),Qt=s.useCallback(()=>Cr.current!==null||Ir.current!==null,[]),Ga=c=>{if(i)return;if(x){const ae=Ir.current;if(!ae||c.pointerId!==ae.pointerId||!ft.current)return;const Lt=$r(c.clientX,c.clientY,ft.current.getBoundingClientRect());if(Lt===null)return;if(ae.handle==="macro-low"||ae.handle==="macro-high"||ae.handle==="macro-connect"){const[Ze,Ue,Ft]=ys(ae.handle,Lt,ae.startPointerRatio,ae.startMacroLowRatio,ae.startMacroHighRatio);qr("macro",Ze,Ue),Ft!==et.current&&(et.current=Ft,ze(Ft),Ht(Ft));let lt,vt;if(Gt){const Tt=Hn(Ie,ne,a,Ze,d),Yr=Math.max(Tt,Hn(Ie,ne,a,Ue,d));lt=Ie[Tt],vt=Ie[Yr]}else lt=te(ne,$a(Ze),d),vt=te(ne,$a(Ue),d);Me.show(lt,vt);const tn=`${lt.getTime()}_${vt.getTime()}`;tn!==Ao.current&&(Ao.current=tn,ur(lt,vt));const[gr,rn]=Dt(ne,h,[lt,vt],r,n,d),Nn=A(h,gr,d),Vn=A(h,rn,d),bi=ye?vo(Nn,Vn):[],pi={kind:"range",min:Nn,max:Vn};let hr,wr;if(ae.handle==="macro-connect"){let Tt,Yr;if(ne==="year"){const Jt=lt.getFullYear()-ae.startMacroLowDate.getFullYear();Tt=nt("year",ae.initialMicroLowDate,Jt),Yr=nt("year",ae.initialMicroHighDate,Jt)}else if(ne==="month"){const Jt=(lt.getFullYear()-ae.startMacroLowDate.getFullYear())*12+(lt.getMonth()-ae.startMacroLowDate.getMonth());Tt=nt("month",ae.initialMicroLowDate,Jt),Yr=nt("month",ae.initialMicroHighDate,Jt)}else{const Jt=Math.round((lt.getTime()-ae.startMacroLowDate.getTime())/864e5);Tt=nt("day",ae.initialMicroLowDate,Jt),Yr=nt("day",ae.initialMicroHighDate,Jt)}const zo=qn("pan",pi,A(h,Tt,d),A(h,Yr,d));if(zo===null)return;hr=te(h,zo[0],d),wr=te(h,zo[1],d)}else{const Tt=qn("resize",pi,A(h,ae.initialMicroLowDate,d),A(h,ae.initialMicroHighDate,d));if(Tt===null)return;hr=te(h,Tt[0],d),wr=te(h,Tt[1],d)}const vi=Kt(hr,bi,Nn,Vn),El=Math.max(vi,Kt(wr,bi,Nn,Vn));hr=te(h,vi,d),wr=te(h,El,d),K.show(hr,wr);const xi=`${hr.getTime()}_${wr.getTime()}`;xi!==Xr.current&&(Xr.current=xi,pt(hr,wr))}else if(ae.handle==="micro-low"||ae.handle==="micro-high"||ae.handle==="micro-connect"||ae.handle==="micro-point"){const[Ze,Ue,Ft]=Es(ae.handle,Lt,ae.startPointerRatio,ae.startMicroLowRatio,ae.startMicroHighRatio);qr("micro",Ze,Ue),Ft!==et.current&&(et.current=Ft,ze(Ft),Ht(Ft));let lt,vt;if(Et){const gr=Hn(xe,h,a,Ze,d),rn=Math.max(gr,Hn(xe,h,a,Ue,d));lt=xe[gr],vt=xe[rn]}else{const gr=Kt(te(h,Math.round(_e+Ze*Dn),d),yr,_e,tt),rn=Math.max(gr,Kt(te(h,Math.round(_e+Ue*Dn),d),yr,_e,tt));lt=te(h,gr,d),vt=te(h,rn,d)}K.show(lt,vt);const tn=`${lt.getTime()}_${vt.getTime()}`;tn!==Xr.current&&(Xr.current=tn,pt(lt,vt))}return}const w=Cr.current;if(!w||c.pointerId!==w.pointerId||!ft.current)return;const p=ft.current.getBoundingClientRect(),S=b?c.clientY:c.clientX,V=b?p.height:p.width;if(!(Number.isFinite(V)&&V>0))return;if(w.handle==="connect"){const ae=b?(w.startPointerPos-S)/V:(S-w.startPointerPos)/V,[Lt,Ze]=ha(ae,w.startLowRatio,w.startHighRatio);qr("flat",Lt,Ze);const Ue=ws({posDiffPct:ae,startLowVal:w.startLowVal,startHighVal:w.startHighVal,rangeMin:E,rangeMax:R,isDiscrete:oe,sortedAllowedDates:N,snapMode:a,unit:t,yearStartMonth:d});if(kt.current&&kt.current[0]===Ue[0]&&kt.current[1]===Ue[1])return;kt.current=Ue,We(Ue),Zt(Ue[0],Ue[1],!1);return}const F=$r(c.clientX,c.clientY,p);if(F===null)return;const[X,G]=Qn($?"point":w.handle,F,w.startLowRatio,w.startHighRatio);qr("flat",X,G);const he=Mo(F*100),[De,ke]=aa(w.handle,he,w.startLowVal,w.startHighVal,E,R,$);if((!kt.current||kt.current[0]!==De||kt.current[1]!==ke)&&(kt.current=[De,ke],We([De,ke]),Zt(De,ke,!1)),!$&&(w.handle==="low"||w.handle==="high")){const ae=co(w.handle,F,w.startLowRatio,w.startHighRatio);B.current!==ae&&(B.current=ae,ot(ae),Ye(ae))}},Ka=()=>{Wa(),Ao.current=null,Xr.current=null,Ir.current=null,et.current=null,ze(null),Me.release(),K.release(),Ca(Mn.current),Ca(yn.current)},qa=()=>{Wa();const c=kt.current??Je;c&&(Zt(c[0],c[1],!0),ve(c)),kt.current=null,We(null),Cr.current=null,B.current=null,ot(null)},Xa=c=>{if(x){const p=Ir.current;if(!p||c.pointerId!==p.pointerId)return;Ka();return}const w=Cr.current;!w||c.pointerId!==w.pointerId||qa()},Za=()=>{Ir.current!==null&&Ka(),Cr.current!==null&&qa()},No=s.useRef(Ga),Qa=s.useRef(Xa),Ja=s.useRef(Za);s.useLayoutEffect(()=>{No.current=Ga,Qa.current=Xa,Ja.current=Za});const ei=s.useRef(x);s.useEffect(()=>{ei.current!==x&&(ei.current=x,Ja.current())},[x]);const ti=Te!==null||Le!==null;s.useEffect(()=>{if(!ti)return;const c=Gr.current?.ownerDocument.defaultView;if(!c)return;const w=S=>No.current(S),p=S=>Qa.current(S);return c.addEventListener("pointermove",w),c.addEventListener("pointerup",p),c.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p),()=>{c.removeEventListener("pointermove",w),c.removeEventListener("pointerup",p),c.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p)}},[ti]);const Vo=s.useCallback((c,w,p,S)=>{mr(),Ni(c,w),Cr.current={pointerId:w,handle:p,startPointerPos:S,startLowVal:Re,startHighVal:Se,startLowRatio:dr(Re)/100,startHighRatio:dr(Se)/100},B.current=p,ot(p),p!=="connect"&&Ye(p)},[Re,Se,dr]),ri=s.useCallback((c,w,p,S)=>{O.current.mode==="vernier"&&(mr(),Ni(c,w),Ir.current={pointerId:w,handle:p,startPointerRatio:S,startMacroLowRatio:Pt,startMacroHighRatio:It,startMicroLowRatio:Er,startMicroHighRatio:Wr,startMacroLowDate:jt,initialMicroLowDate:qt,initialMicroHighDate:Xt},et.current=p,ze(p),Ht(p))},[Pt,It,Er,Wr,jt,qt,Xt]),ni=c=>w=>{if(i||Qt())return;w.stopPropagation(),w.preventDefault(),Ye(c);const p=b?w.clientY:w.clientX;Vo(w.currentTarget,w.pointerId,c,p)},oi=c=>()=>{i||B.current!==null||Ye(c)},Pn=c=>()=>{i||et.current!==null||Ht(c)},kr=c=>w=>{if(i||Qt())return;w.stopPropagation(),w.preventDefault();const p=ft.current;if(!p)return;const S=$r(w.clientX,w.clientY,p.getBoundingClientRect());S!==null&&ri(w.currentTarget,w.pointerId,c,S)},rl=c=>{if(i||T||Qt())return;c.stopPropagation(),c.preventDefault();const w=b?c.clientY:c.clientX;Vo(c.currentTarget,c.pointerId,"connect",w)},nl=c=>{if(i||Qt())return;if(x){const G=ft.current;if(!G)return;const he=G.getBoundingClientRect(),De=$r(c.clientX,c.clientY,he);if(De===null)return;const ke=b?c.clientX-(he.left+he.width/2):c.clientY-(he.top+he.height/2),ae=Ms(De,ke,Pt,It,Er,Wr,q,void 0,!T,P?"point":"range");ri(c.currentTarget,c.pointerId,ae,De),No.current(c.nativeEvent);return}const w=Fa(c.clientX,c.clientY);if(w===null)return;const p=Mo(w);let S="low";if(!$){const G=Math.abs(p-Re),he=Math.abs(p-Se);G<he?S="low":he<G?S="high":S=p>Se?"high":"low"}Ye(S);const[V,F]=aa(S,p,Re,Se,E,R,$);We([V,F]),Zt(V,F,!0);const X=b?c.clientY:c.clientX;Vo(c.currentTarget,c.pointerId,S,X)},ol=c=>{if(i||x||Te!==null)return;const w=Fa(c.clientX,c.clientY);if(w===null)return;const p=Mo(w);He(p),at(dr(p))},al=()=>{He(null),at(null)},ai=c=>w=>{if(i||Qt())return;Ye(c);const p=bs(w.key,c,Re,Se,E,R,$,1);p&&(w.preventDefault(),mr(),be||ve(p),Zt(p[0],p[1],!0))},Ar=(c,w,p)=>{if(re===null)return;const[S,V]=Dt(ne,h,[c,w],r,n,d),F=A(h,S,d),X=A(h,V,d),G=ye?vo(F,X):[],he=qn(p,{kind:"range",min:F,max:X},A(h,re[0],d),A(h,re[1],d));if(he===null)return;const De=Kt(te(h,he[0],d),G,F,X),ke=Math.max(De,Kt(te(h,he[1],d),G,F,X));pt(te(h,De,d),te(h,ke,d),!0)},Ln=c=>w=>{if(i||!x||e.mode!=="vernier"||Qt())return;Ht(c);let p=0,S=!1,V=!1;switch(w.key){case"ArrowRight":case"ArrowUp":p=1;break;case"ArrowLeft":case"ArrowDown":p=-1;break;case"PageUp":p=5;break;case"PageDown":p=-5;break;case"Home":S=!0;break;case"End":V=!0;break;default:return}if(w.preventDefault(),mr(),c==="macro-low"){const F=te(ne,it,d),X=te(ne,st,d);if(Gt){const De=on(Ie,ne,F,Ie[0],X,p,S,V,d);if(De===Ee(Ie,F,ne,d))return;const ke=Ie[De];ur(ke,X,!0),Ar(ke,X,"resize");return}let G;if(S?G=bt:V?G=st:G=Math.max(bt,Math.min(st,it+p)),G===it)return;const he=te(ne,G,d);ur(he,X,!0),Ar(he,X,"resize")}else if(c==="macro-high"){const F=te(ne,it,d),X=te(ne,st,d);if(Gt){const De=on(Ie,ne,X,F,Ie[Ie.length-1],p,S,V,d);if(De===Ee(Ie,X,ne,d))return;const ke=Ie[De];ur(F,ke,!0),Ar(F,ke,"resize");return}let G;if(S?G=it:V?G=Ct:G=Math.max(it,Math.min(Ct,st+p)),G===st)return;const he=te(ne,G,d);ur(F,he,!0),Ar(F,he,"resize")}else if(c==="micro-low"){const F=te(h,Xe,d),X=te(h,dt,d);if(Et){const he=on(xe,h,F,xe[0],X,p,S,V,d);if(he===Ee(xe,F,h,d))return;pt(xe[he],X,!0);return}let G;if(S?G=_e:V?G=dt:G=Math.max(_e,Math.min(dt,Xe+p)),G===Xe)return;pt(te(h,G,d),X,!0)}else if(c==="micro-high"){const F=te(h,Xe,d),X=te(h,dt,d);if(Et){const he=on(xe,h,X,F,xe[xe.length-1],p,S,V,d);if(he===Ee(xe,X,h,d))return;pt(F,xe[he],!0);return}let G;if(S?G=Xe:V?G=tt:G=Math.max(Xe,Math.min(tt,dt+p)),G===dt)return;pt(F,te(h,G,d),!0)}else if(c==="micro-point"){const F=te(h,Xe,d);if(Et){const G=on(xe,h,F,xe[0],xe[xe.length-1],p,S,V,d);if(G===Ee(xe,F,h,d))return;Ia(xe[G],!0);return}let X;if(S?X=_e:V?X=tt:X=Math.max(_e,Math.min(tt,Xe+p)),X===Xe)return;Ia(te(h,X,d),!0)}},il=c=>{if(e.mode!=="vernier")return;if(mr(),Gt){const X=Ie.length-1,G=Ee(Ie,jt,ne,d),he=Ee(Ie,cr,ne,d),De=he-G;let ke=G+c,ae=he+c;if(c<0&&ke<0?(ke=0,ae=Math.min(X,De)):c>0&&ae>X&&(ae=X,ke=Math.max(0,X-De)),ke===G&&ae===he)return;const Lt=Ie[ke],Ze=Ie[ae];ur(Lt,Ze,!0),Ar(Lt,Ze,"pan");return}const w=st-it;let p=it+c,S=st+c;if(c<0&&p<bt?(p=bt,S=Math.min(Ct,p+w)):c>0&&S>Ct&&(S=Ct,p=Math.max(bt,S-w)),p===it&&S===st)return;const V=te(ne,p,d),F=te(ne,S,d);ur(V,F,!0),Ar(V,F,"pan")},Oo=s.useCallback(c=>{const w=O.current;if(!(w.disabled||Qt()))if(mr(),w.mode==="point"){const p=Math.max(E,Math.min(R,Re+c));be||ve([p,p]),Zt(p,p,!0)}else if(w.mode==="vernier"){if(Et){const De=xe.length-1,ke=Ee(xe,qt,h,d),ae=Ee(xe,Xt,h,d),Lt=ae-ke;let Ze=ke+c,Ue=ae+c;c<0&&Ze<0?(Ze=0,Ue=Math.min(De,Lt)):c>0&&Ue>De&&(Ue=De,Ze=Math.max(0,De-Lt)),(Ze!==ke||Ue!==ae)&&pt(xe[Ze],xe[Ue],!0);return}const p=Xe,S=dt,V=_e,F=tt,X=S-p;let G=p+c,he=S+c;c<0&&G<V?(G=V,he=Math.min(F,G+X)):c>0&&he>F&&(he=F,G=Math.max(V,he-X)),(G!==p||he!==S)&&pt(te(h,G,d),te(h,he,d),!0)}else{const p=Se-Re;let S=Re+c,V=Se+c;c<0&&S<E?(S=E,V=Math.min(R,S+p)):c>0&&V>R&&(V=R,S=Math.max(E,V-p)),S<=V&&(be||ve([S,V]),Zt(S,V,!0))}},[Re,Se,E,R,be,Zt,pt,Xe,dt,_e,tt,h,Et,xe,qt,Xt,mr,d]),ii=c=>!i&&Go(Gr.current,c),si=(c,w)=>{const p=ka.current,S=ft.current,V=Gr.current;if(i||p===null||S===null||V===null||!zl(p,V,Aa.current,b,c,w))return null;const F=S.getBoundingClientRect();return Math.abs(b?c-(F.left+F.width/2):w-(F.top+F.height/2))},li=c=>{if(i||Qt())return;const w=Ds(c.deltaX,c.deltaY,b);if(w===0)return;c.preventDefault();const p=c.target,S=Go(Na.current,p)||Go(Va.current,p);if(!x||S){Oo(w);return}const V=ft.current;if(!V)return;const F=V.getBoundingClientRect(),X=b?c.clientX-(F.left+F.width/2):c.clientY-(F.top+F.height/2);if(va(X,q)==="macro"){il(w);return}Oo(w)},Tn=s.useRef({ownsWheelHit:ii,distanceToRailPx:si,stepFromRangeAreaWheel:li});s.useLayoutEffect(()=>{Tn.current={ownsWheelHit:ii,distanceToRailPx:si,stepFromRangeAreaWheel:li}});const Zr=s.useRef(null);s.useEffect(()=>{const c=Gr.current?.ownerDocument.defaultView??null,w=Zr.current;if(w!==null&&w.view===c)return;if(w?.unregister(),c===null){Zr.current=null;return}const p=Ul(c,{ownsHit:S=>Tn.current.ownsWheelHit(S),distanceToRailPx:(S,V)=>Tn.current.distanceToRailPx(S,V),step:S=>Tn.current.stepFromRangeAreaWheel(S)});Zr.current={view:c,unregister:p}}),s.useEffect(()=>()=>{Zr.current?.unregister(),Zr.current=null},[]);const $n=dr(Re),Cn=dr(Se),_o=W(Re),Yo=W(Se),Ho=Ii($n,Cn,Co),Qr=Ho.slant,Jr=Te==="low"||Te!=="high"&&Ge==="low",en=!$&&(Te==="high"||Te!=="low"&&Ge==="high"),sl=To&&Fe!=="macro-low",ll=To&&Fe==="macro-low",cl=$o&&Fe!=="micro-low",ul=$o&&Fe==="micro-low",Nr=Qo("macro",Pt,It,Io),Vr=Qo("micro",Er,Wr,ko),dl=Math.min($n,Cn),ml=Math.max($n,Cn),[ci,ui]=dn.flat,[fl,gl]=dn.macro,[hl,wl]=dn.micro,di=er(ci,$n),mi=er(ui,Cn),jo=er(ci,dl),fi=`calc(${er(ui,ml)} - ${jo})`,Or=er(fl,Pt*100),In=er(gl,It*100),_r=er(hl,Er*100),kn=er(wl,Wr*100),bl=b?{bottom:jo,height:fi,top:"auto",left:"0",right:"0"}:{left:jo,width:fi,top:"0",bottom:"0"},pl=Math.max(.01,It-Pt),gi=Math.max(.06,Math.min(.25,.28*Math.sqrt(pl))),vl=b?{bottom:di,left:"50%",transform:"translate(-50%, 50%)",zIndex:Jr?40:30}:{left:di,top:"50%",transform:"translate(-50%, -50%)",zIndex:Jr?40:30},xl=b?{bottom:mi,left:"50%",transform:"translate(-50%, 50%)",zIndex:en?40:30}:{left:mi,top:"50%",transform:"translate(-50%, -50%)",zIndex:en?40:30},Sl=b?{bottom:`${Ke}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Ke}%`,top:"50%",transform:"translate(-50%, -50%)"},hi=Be!==null?W(Be):null,Rl=f!=="hover"&&Be!==null&&(Be===Re||!$&&Be===Se),Dl=x?Xe>La:Re>E,Ml=x?dt<xo:Se<R,An=dc(x?[{side:k?"before":"after",box:Xn(Ya,Ha),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Nr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Nr.slant.lowOffsetX}},{side:k?"after":"before",box:P?Po:Xn(Po,ja),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Vr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Vr.slant.lowOffsetX}}]:[{side:b||g==="top"?"before":"after",box:$?Tr:Xn(Tr,_a),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Qr.lowAngleDeg,centreOffsetPx:Qr.lowOffsetY,alongPushPx:Qr.lowOffsetX}}]),yl=An===void 0?e.style:{...e.style,...An.style};s.useLayoutEffect(()=>{Aa.current=An===void 0?0:An.mainPx});const At=P?"micro-point":"micro-low",fr=i?"cursor-not-allowed opacity-50":"cursor-pointer",wi=c=>{const w=b?"vertical":"horizontal",p=c==="decrease",S=b?!p:p;return L.jsx(Rr,{ref:p?Na:Va,neighbour:"rail",direction:mc[w][c],disabled:i,canStep:p?Dl:Ml,onStep:()=>Oo(p?-1:1),ariaLabel:p?_.decrease:_.increase,className:`period-slider-stepper-btn ${fc[w][c]} ${Ai[w][S?"leading":"trailing"]}`})};return L.jsxs("div",{ref:Gr,style:yl,className:`period-slider grid select-none place-items-center ${gc[b?"vertical":"horizontal"][u?"withSteppers":"railOnly"]} ${l}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":g,"data-color-scheme":m,children:[L.jsx("div",{ref:ka,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),u&&wi(b?"increase":"decrease"),L.jsx("div",{ref:ft,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":x?q:void 0,className:`period-slider-track relative touch-none rounded-full ${Ai[b?"vertical":"horizontal"][u?"rail":"railOnly"]} ${fr}`,onPointerDown:nl,onPointerMove:ol,onPointerLeave:al,children:x?L.jsxs(L.Fragment,{children:[ht&&(b?L.jsxs("svg",{className:"period-slider-vernier-projection is-vertical",role:"presentation","aria-hidden":"true",width:"32",height:"100%",viewBox:"0 0 32 100",preserveAspectRatio:"none",children:[L.jsx("defs",{children:L.jsxs("linearGradient",{id:fe,x1:"0",y1:"0",x2:"1",y2:"0",children:[L.jsx("stop",{offset:"0%",stopColor:k?H.macro:H.micro,stopOpacity:"0.28"}),L.jsx("stop",{offset:"100%",stopColor:k?H.micro:H.macro,stopOpacity:gi})]})}),L.jsx("path",{ref:yo,"data-testid":"period-slider-vernier-projection",d:Wo(Pt,It,b,k),fill:`url(#${fe})`})]}):L.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[L.jsx("defs",{children:L.jsxs("linearGradient",{id:fe,x1:"0",y1:"0",x2:"0",y2:"1",children:[L.jsx("stop",{offset:"0%",stopColor:k?H.macro:H.micro,stopOpacity:"0.28"}),L.jsx("stop",{offset:"100%",stopColor:k?H.micro:H.macro,stopOpacity:gi})]})}),L.jsx("path",{ref:yo,"data-testid":"period-slider-vernier-projection",d:Wo(Pt,It,b,k),fill:`url(#${fe})`})]})),!T&&L.jsxs(L.Fragment,{children:[L.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${Or} - 8px)`,height:`calc(${In} - ${Or} + 16px)`}:{left:`calc(${Or} - 8px)`,width:`calc(${In} - ${Or} + 16px)`},onPointerDown:kr("macro-connect")}),!P&&L.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${_r} - 8px)`,height:`calc(${kn} - ${_r} + 16px)`}:{left:`calc(${_r} - 8px)`,width:`calc(${kn} - ${_r} + 16px)`},onPointerDown:kr("micro-connect")})]}),qe&&L.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(c=>L.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`macro-tick-${c}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(c=>L.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`micro-tick-${c}`))]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":_.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Fs,"aria-valuemax":st,"aria-valuenow":it,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(jt,ne,"period"):br(ne,jt,Y,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?k?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":k?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${fr}`,style:b?{bottom:Or,left:k?0:"auto",right:k?"auto":0,transform:k?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Le==="macro-low"||Fe==="macro-low"?30:15}:{left:Or,top:k?0:"auto",bottom:k?"auto":0,transform:k?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Le==="macro-low"||Fe==="macro-low"?30:15},onPointerDown:kr("macro-low"),onKeyDown:Ln("macro-low"),onFocus:Pn("macro-low"),"data-active":Le==="macro-low"?"true":void 0,"data-front":Fe==="macro-low"?"true":void 0,"data-vernier-pos":b?k?"left":"right":k?"top":"bottom","data-handle-type":"macro-low",children:[L.jsx(cn,{type:"macro",isTop:k,isVertical:b,isLeft:k}),wt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),f!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":sl?"true":void 0,"data-slanted":Nr.slant.isSlanted?"true":void 0,ref:Gs,style:Nr.lowStyle,children:rt(ne,jt,Y,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":_.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":it,"aria-valuemax":Us,"aria-valuenow":st,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(cr,ne,"period"):br(ne,cr,Y,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?k?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":k?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${fr}`,style:b?{bottom:In,left:k?0:"auto",right:k?"auto":0,transform:k?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Le==="macro-high"||Fe==="macro-high"?30:15}:{left:In,top:k?0:"auto",bottom:k?"auto":0,transform:k?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Le==="macro-high"||Fe==="macro-high"?30:15},onPointerDown:kr("macro-high"),onKeyDown:Ln("macro-high"),onFocus:Pn("macro-high"),"data-active":Le==="macro-high"?"true":void 0,"data-front":Fe==="macro-high"?"true":void 0,"data-vernier-pos":b?k?"left":"right":k?"top":"bottom","data-handle-type":"macro-high",children:[L.jsx(cn,{type:"macro",isTop:k,isVertical:b,isLeft:k}),wt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),f!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ll?"true":void 0,"data-slanted":Nr.slant.isSlanted?"true":void 0,ref:Ks,style:Nr.highStyle,children:rt(ne,cr,Y,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":P?_.microSelectedDate:_.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":La,"aria-valuemax":P?xo:dt,"aria-valuenow":Xe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(qt,h,"period"):br(h,qt,ue,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?k?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":k?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${fr}`,style:b?{bottom:_r,left:k?"auto":0,right:k?0:"auto",transform:k?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Le===At||Fe===At?30:20}:{left:_r,top:k?"auto":0,bottom:k?0:"auto",transform:k?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Le===At||Fe===At?30:20},onPointerDown:kr(At),onKeyDown:Ln(At),onFocus:Pn(At),"data-active":Le===At?"true":void 0,"data-front":Fe===At?"true":void 0,"data-vernier-pos":b?k?"right":"left":k?"bottom":"top","data-handle-type":At,children:[L.jsx(cn,{type:"micro",isTop:!k,isVertical:b,isLeft:!k}),wt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),f!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":cl?"true":void 0,"data-slanted":Vr.slant.isSlanted?"true":void 0,ref:qs,style:Vr.lowStyle,children:rt(h,qt,ue,D)})]}),!P&&L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":_.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Xe,"aria-valuemax":xo,"aria-valuenow":dt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Xt,h,"period"):br(h,Xt,ue,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?k?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":k?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${fr}`,style:b?{bottom:kn,left:k?"auto":0,right:k?0:"auto",transform:k?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Le==="micro-high"||Fe==="micro-high"?30:20}:{left:kn,top:k?"auto":0,bottom:k?0:"auto",transform:k?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Le==="micro-high"||Fe==="micro-high"?30:20},onPointerDown:kr("micro-high"),onKeyDown:Ln("micro-high"),onFocus:Pn("micro-high"),"data-active":Le==="micro-high"?"true":void 0,"data-front":Fe==="micro-high"?"true":void 0,"data-vernier-pos":b?k?"right":"left":k?"bottom":"top","data-handle-type":"micro-high",children:[L.jsx(cn,{type:"micro",isTop:!k,isVertical:b,isLeft:!k}),wt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),f!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-duplicate":ul?"true":void 0,"data-slanted":Vr.slant.isSlanted?"true":void 0,ref:Xs,style:Vr.highStyle,children:rt(h,Xt,ue,D)})]})]}):L.jsxs(L.Fragment,{children:[!T&&L.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:bl,onPointerDown:rl}),Q&&oe&&N.length>1&&L.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:N.map((c,w)=>{const p=A(t,c,d),S=dr(w),V=b?{bottom:`${S}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${S}%`,top:"50%",transform:"translate(-50%, -50%)"};return L.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:V},`tick-${p}`)})}),!i&&Be!==null&&Ke!==null&&Te===null&&hi&&L.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Sl,children:[L.jsx("div",{"data-testid":"period-slider-hover-dot",className:"period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-[var(--aqps-accent-light)] shadow-[0_0_6px_var(--aqps-accent-glow)] dark:border-slate-800"}),L.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Rl?"true":void 0,className:`period-slider-hover-tooltip ${g==="bottom"&&!b?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:rt(t,hi,e.formatLabel,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":$?_.selectedDate:_.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":E,"aria-valuemax":$?R:Se,"aria-valuenow":Re,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(_o,t,"period"):br(t,_o,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${fr}`,style:vl,onPointerDown:ni("low"),onKeyDown:ai("low"),onFocus:oi("low"),"data-active":Te==="low"?"true":void 0,"data-front":Jr?"true":void 0,children:[L.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${Te==="low"?"":"shadow-md"}`}),f!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":g,"data-slanted":Qr.isSlanted?"true":void 0,"data-front":Jr?"true":void 0,"data-duplicate":Lo&&!Jr?"true":void 0,ref:Bs,style:Ho.lowStyle,children:rt(t,_o,e.formatLabel,D)})]}),!$&&L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":_.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Re,"aria-valuemax":R,"aria-valuenow":Se,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Yo,t,"period"):br(t,Yo,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${fr}`,style:xl,onPointerDown:ni("high"),onKeyDown:ai("high"),onFocus:oi("high"),"data-active":Te==="high"?"true":void 0,"data-front":en?"true":void 0,children:[L.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${Te==="high"?"":"shadow-md"}`}),f!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${f==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":f,"data-label-position":g,"data-slanted":Qr.isSlanted?"true":void 0,"data-front":en?"true":void 0,"data-duplicate":Lo&&!en?"true":void 0,ref:Ws,style:Ho.highStyle,children:rt(t,Yo,e.formatLabel,D)})]})]})}),u&&wi(b?"decrease":"increase")]})},Qe=e=>e.getTime(),Ls=(e,t)=>!(Array.isArray(e)&&Array.isArray(t))||e.length!==2||t.length!==2?!1:St(e[0],Qe)===St(t[0],Qe)&&St(e[1],Qe)===St(t[1],Qe),jn=(e,t)=>e===void 0||t===void 0?e===t:Ls(e,t),Jo=(e,t)=>{if(e===t)return!0;if(!(Array.isArray(e)&&Array.isArray(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(St(e[r],Qe)!==St(t[r],Qe))return!1;return!0},Ts=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},wc=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||St(e.minDate,Qe)!==St(t.minDate,Qe)||St(e.maxDate,Qe)!==St(t.maxDate,Qe)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.isVertical!==t.isVertical||e.hideConnectBar!==t.hideConnectBar||e.showTicks!==t.showTicks||e.disabled!==t.disabled||e.showStepper!==t.showStepper||e.debounceMs!==t.debounceMs||e.tooltipStyle!==t.tooltipStyle||e.colorScheme!==t.colorScheme||e.className!==t.className||!Ts(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!mo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!Jo(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(mt(e.value,Qe)!==mt(t.value,Qe)||mt(e.defaultValue,Qe)!==mt(t.defaultValue,Qe)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!jn(e.range,t.range)||!jn(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!jn(e.microRange,t.microRange)||!jn(e.defaultMicroRange,t.defaultMicroRange)||mt(e.microValue,Qe)!==mt(t.microValue,Qe)||mt(e.defaultMicroValue,Qe)!==mt(t.defaultMicroValue,Qe)||!Ls(e.macroRange,t.macroRange)||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroPoint!==t.onChangeMicroPoint||e.onChangeMacroRange!==t.onChangeMacroRange||!Jo(e.macroAllowedDates,t.macroAllowedDates)||!Jo(e.microAllowedDates,t.microAllowedDates)):!1,$s=s.memo(hc,wc);$s.displayName="PeriodSlider";const Vi=2,$e=-1,xt=e=>A("day",e),bn=e=>te("day",e),an=e=>`${ho(e.getFullYear())}-${String(e.getMonth()+1).padStart(Vi,"0")}-${String(e.getDate()).padStart(Vi,"0")}`,bc=(e,t,r,n)=>{const o=xt(e),a=xt(t),i=a>=o?a-o+1:0,l=f=>bn(a-f),u={kind:"range",min:o,max:a};return{count:i,dateAt:l,labelAt:f=>rt("day",l(f),n,r),indexOf:f=>{const g=xt(f);return g<o||g>a?$e:a-g},nearestIndexOf:f=>{if(i===0)return $e;const g=hn(u,xt(f));return g===null?$e:a-g}}},pc=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,l=v=>e[n-v],u={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},f=v=>{const b=v.getTime();let T=r,Q=n;for(;T<=Q;){const m=T+Q>>1,D=e[m].getTime();if(D===b)return n-m;D<b?T=m+1:Q=m-1}return $e},g=v=>v===null?$e:f(bn(v));return{count:i,dateAt:l,labelAt:v=>rt("day",l(v),a,o),indexOf:f,nearestIndexOf:v=>g(hn(u,xt(v)))}},vc={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${M(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${M(e)})`)},indexOf:()=>$e,nearestIndexOf:()=>$e},xc=(e,t,r)=>{const n=l=>{let u=0,f=e.length;for(;u<f;){const g=u+f>>1;e[g].getTime()<l?u=g+1:f=g}return u},o=l=>{let u=0,f=e.length;for(;u<f;){const g=u+f>>1;e[g].getTime()<=l?u=g+1:f=g}return u},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},Sc=(e,t)=>{const r=new Map;for(let n=0;n<e.length;n++){const o=e[n];t(n,o);const a=new Date(o);a.setHours(0,0,0,0);const i=a.getTime();r.has(i)||r.set(i,a)}return Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},Rc={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Dc={month:2,day:2},Oi={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},_i=new Map,Mc=(e,t)=>{const r=`${e}\0${t}`,n=_i.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Rc[e]);return _i.set(r,o),o},yc=(e,t,r)=>r!==void 0?Mc(e,r).format(t):e==="year"?ho(Oi.year(t)):String(Oi[e](t)).padStart(Dc[e],"0"),Cs=(e,t,r,n)=>{if(t!=="year"&&t!=="month"&&t!=="day")throw new RangeError(`formatOptionText: unit must be "year", "month" or "day" (received: ${M(t)})`);if(r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${M(r)})`);return Ne(e)?r==="part"?yc(t,e,n):rt(t,e,void 0,n):""},xa=(e,t,r)=>{const n=a=>r(a).getTime(),o=a=>a.value!==void 0?a.value:a.initialDate;return mt(o(e),n)!==mt(o(t),n)||t.value!==void 0&&Number.isNaN(mt(t.initialDate,n))||mt(e.minDate,n)!==mt(t.minDate,n)?!1:mt(e.maxDate,n)===mt(t.maxDate,n)},Ec={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},Pc=["shift","start","end","single"],Lc=["disable","clamp"],Tc=["follow","keep"],Yi={day:{day:1},month:{month:1,year:12},year:{year:1}},Hi=new WeakMap,ia=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${M(r)})`)},ji=(e,t,r,n)=>{for(const[o,a]of Object.entries(r))if(!(a===void 0||n.includes(o)))throw new RangeError(`${e}: ${t}.${o} is not read here; the accepted keys are ${n.map(i=>`"${i}"`).join(", ")} (received: ${M(a)})`)},Mr=(e,t,r,n)=>{ia(e,t,r),ji(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];ia(e,a,i),ji(e,a,i,Ec[n]);const{motion:l,edge:u,window:f}=i;if(n!=="vernierPoint"&&(typeof l!="string"||!Pc.includes(l)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${M(l)})`);if(u!==void 0){if(l!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${M(u)} with motion ${M(l)})`);if(typeof u!="string"||!Lc.includes(u))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${M(u)})`)}if(f!==void 0&&(typeof f!="string"||!Tc.includes(f)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${M(f)})`)}},Sa=e=>{if(typeof e!="object"||e===null)return{field:"stepper",expected:"an object",received:M(e)};const{onStep:t,canStepPrevious:r,canStepNext:n}=e;return typeof t!="function"?{field:"stepper.onStep",expected:"a function",received:M(t)}:typeof r!="boolean"?{field:"stepper.canStepPrevious",expected:"a boolean",received:M(r)}:typeof n!="boolean"?{field:"stepper.canStepNext",expected:"a boolean",received:M(n)}:null},xr=(e,t,r,n,o)=>{if(!Ne(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${M(r)})`);const a=A(n,r,o);if(!Number.isInteger(a))throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${M(r)})`);return a},to=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${M(r)})`)},Is=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=Hi.get(r),l=i?.get(a);if(l!==void 0)return l;const u=[];for(let g=0;g<r.length;g++)u.push(xr(e,`${t}[${g}]`,r[g],n,o));const f=Array.from(new Set(u)).sort((g,v)=>g-v);return i===void 0?Hi.set(r,new Map([[a,f]])):i.set(a,f),f},$c=(e,t)=>t===1?Kn(e):{stepEnd:(r,n)=>Gn(e,r+t*n,n),edge:r=>fn(e,r)},sa=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},la=(e,t,r,n,o,a)=>{if(a){const u=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:te(n,e[0],o);return Number.isNaN(u.getTime())?null:[u,u]}const i=e[0]===t[0]?r[0]:te(n,e[0],o),l=e[1]===t[1]?r[1]:te(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(l.getTime())?null:[i,l.getTime()<i.getTime()?i:l]},ca=e=>{const t="resolveSelectorSteps";ia(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:l,rules:u}=e;to(t,"unit",o);const f=e.stepUnit===void 0?o:e.stepUnit;to(t,"stepUnit",f);const g=Yi[o][f];if(g===void 0){const P=Object.keys(Yi[o]).map(_=>`"${_}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${P} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${M(f)})`)}const v=lr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${M(n)})`);if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${M(r)})`);Mr(t,"rules",u,"motion");const b=xr(t,"selection[0]",r[0],o,v),T=xr(t,"selection[1]",r[1],o,v);if(T<b)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${M(r[0])}, end: ${M(r[1])})`);const Q=a===void 0?null:xr(t,"minDate",a,o,v),m=i===void 0?null:xr(t,"maxDate",i,o,v);if(Q!==null&&m!==null&&m<Q)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${M(a)}, maxDate: ${M(i)})`);if(l!==void 0&&!Array.isArray(l))throw new RangeError(`${t}: allowedDates must be an array of Dates (received: ${M(l)})`);const D=l===void 0?{kind:"range",min:Q,max:m}:Br(Is(t,"allowedDates",l,o,v),Q,m),d=$c(D,g),j=(P,_)=>{const H=oa(d,b,T,P,sa(_,n));return H===null?null:la(H,[b,T],r,o,v,_.motion==="single")};return{previous:j(-1,u.previous),next:j(1,u.next)}},_t=(e,t)=>{const r=s.useRef(e);r.current=e;const n=s.useRef(t);n.current=t;const o=s.useCallback(l=>{const u=r.current[l];u!==null&&n.current(u,l)},[]),a=e.previous!==null,i=e.next!==null;return s.useMemo(()=>({onStep:o,canStepPrevious:a,canStepNext:i}),[o,a,i])},Zn=44,zi=7,zn=8,Cc=2,ks=10,Ic=1e3,ua=8,ea=6,ta=4,ra=12,sn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),xt(r)},kc=(e,t)=>{if(e.length<ta||t.count===0)return $e;const r=Number(e.slice(0,ta));if(!Number.isInteger(r))return $e;const n=e.length>=ea,o=n?Number(e.slice(ta,ea)):ra;if(o<1||o>ra)return $e;const a=e.length>=ua,i=a?Number(e.slice(ea,ua)):0,l=sn(r,o),u=(o===ra?sn(r+1,1):sn(r,o+1))-1,f=a?l+i-1:n?l:sn(r,1),g=a?f:n?u:sn(r+1,1)-1;if(a&&(i<1||f>u))return $e;for(let v=g;v>=f;v--){const b=t.indexOf(bn(v));if(b!==$e)return b}return $e},Ac=e=>e.closest(".dark")===null?"light":"dark",Nc=(e,t,r,n)=>{const o=r-e.bottom-zn,a=e.top-zn,i=o>=t||o>=a,u=Math.max(Zn,Math.min(t,i?o:a)),f=i?e.bottom:e.top-u,g=e.width+ks,v=Math.max(zn,Math.min(e.left,n-g-zn));return{top:f,left:v,width:g,height:u}},As=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:l,labels:u,onCommitIndex:f,controlClassName:g})=>{const v=s.useId(),b=s.useMemo(()=>Nl(u),[u]),T=`period-slider-date-listbox-${v}`,Q=I=>`period-slider-date-option-${v}-${I}`,[m,D]=s.useState(!1),[d,j]=s.useState($e),[P,_]=s.useState(!0),[H,fe]=s.useState(null),[O,ee]=s.useState(null),ie=s.useRef(null),N=s.useRef(null),oe=s.useRef(null),E=s.useRef({buffer:"",at:0}),R=s.useRef(e);R.current=e;const $=e.count,W=Math.min($,zi)*Zn,Z=Math.max(1,Math.min($,zi)),z=s.useCallback(()=>{const I=ie.current;if(I===null)return;const ge=I.getBoundingClientRect();fe(Nc(ge,W,window.innerHeight,window.innerWidth))},[W]),J=s.useCallback(()=>{D(!1),j($e),E.current={buffer:"",at:0}},[]),C=s.useCallback(I=>{a||$===0||(j(I),D(!0))},[a,$]);s.useLayoutEffect(()=>{if(!m){fe(null),ee(null);return}const I=ie.current;return I!==null&&ee(Ac(I)),z(),window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[m,z]),s.useEffect(()=>{if(!m)return;const I=ge=>{const pe=ge.target;pe!==null&&N.current?.contains(pe)!==!0&&ie.current?.contains(pe)!==!0&&J()};return document.addEventListener("pointerdown",I,!0),()=>document.removeEventListener("pointerdown",I,!0)},[m,J]);const ce=s.useRef(d);ce.current=d,s.useEffect(()=>{m&&(a||$===0)&&J()},[m,a,$,J]),s.useEffect(()=>{if(!m)return;const I=ce.current;if(I===$e)return;const ge=Math.min(I,$-1);ge!==I&&j(ge),oe.current?.scrollToIndex(ge,{align:"center"})},[$,m]);const we=I=>{if($===0)return;const ge=Math.max(0,Math.min(I,$-1));j(ge),oe.current?.scrollToIndex(ge,{align:"center"})},Me=I=>{I<0||I>=$||(f(I),J(),ie.current?.focus())},K=I=>{if(a)return;const ge=d!==$e?d:t!==$e?t:r;switch(I.key){case"ArrowDown":if(I.preventDefault(),!m){C(ge);return}we(ge+1);return;case"ArrowUp":if(I.preventDefault(),!m){C(ge);return}we(ge-1);return;case"Home":if(!m)return;I.preventDefault(),we(0);return;case"End":if(!m)return;I.preventDefault(),we($-1);return;case"PageDown":if(!m)return;I.preventDefault(),we(ge+Z);return;case"PageUp":if(!m)return;I.preventDefault(),we(ge-Z);return;case"Enter":if(I.preventDefault(),!m){C(ge);return}Me(d!==$e?d:ge);return;case"Escape":if(!m)return;I.preventDefault(),J();return;case"Tab":m&&J();return}if(I.key.length!==1)return;const pe=I.key>="0"&&I.key<="9",gt=I.key==="-"||I.key==="/"||I.key===".";if(!(pe||gt))return;I.preventDefault();const me=Date.now(),be=me-E.current.at>Ic?"":E.current.buffer,Ve=pe?`${be}${I.key}`.slice(0,ua):be;E.current={buffer:Ve,at:me};const ve=kc(Ve,R.current);if(ve!==$e){if(!m){C(ve);return}we(ve)}},re=s.useCallback(I=>I,[]),U=s.useCallback(()=>Zn,[]),de=s.useCallback(I=>{const ge=ce.current;_(ge===$e||ge>=I.renderingStartIndex&&ge<=I.renderingEndIndex)},[]),se=m&&H!==null&&O!==null&&$>0?L.jsx("div",{ref:N,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":O,style:{top:H.top,left:H.left,width:H.width,height:H.height},onMouseDown:I=>{I.preventDefault()},children:L.jsx(ir.VirtualScroll,{ref:oe,itemCount:$,getItem:re,getItemHeight:U,viewportSize:H.height-Cc,initialScrollIndex:d!==$e?d:void 0,onRangeChange:de,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:l,labels:b,contentProps:{id:T,role:"listbox","aria-label":i},scrollBarOptions:{width:ks,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:I=>{const ge=I===t,pe=I===d;return L.jsx("div",{id:Q(I),role:"option","aria-selected":ge,"aria-posinset":I+1,"aria-setsize":$,"data-testid":"period-slider-date-option","data-active":pe?"true":void 0,className:"period-slider-date-option",style:{height:Zn},onClick:()=>Me(I),children:R.current.labelAt(I)})}})}):null;return L.jsxs(L.Fragment,{children:[L.jsx("input",{ref:ie,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":m,"aria-controls":m?T:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":m&&d!==$e&&P?Q(d):void 0,disabled:a,value:n,className:g,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:K,onMouseDown:I=>{a||(I.preventDefault(),ie.current?.focus(),m?J():C(t!==$e?t:r))},onBlur:()=>{m&&J()}}),se===null?null:Pl.createPortal(se,document.body)]})};As.displayName="VirtualDateDropdown";const Ut=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Vc='; leave the bound out where the variant allows it, or declare the days to offer with `minYear` / `maxYear` or `allowedDates`, instead of a sentinel for "no bound"',Oc='; variant="split-dropdown" requires both bounds, so declare the years to offer with `minYear` / `maxYear` instead of a sentinel for "no bound"',_c=31,ln=(e,t,r)=>{if(!Ne(t))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${M(t)})`);if(Number.isNaN(Ut(t).getTime()))throw new RangeError(`DateSelector: "${e}" must fall on a day that starts inside the Date range (received ${M(t)})${r}`)},Yc=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "formatLocale" must be a valid BCP 47 language tag (received ${M(e)})`)}},rr=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},un=e=>rr(e,1,1),Fi=e=>rr(e,12,31),Ns=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,Ui=(e,t,r,n)=>Ns(e,t,r)&&e.getDate()===n,Ra=e=>!Number.isNaN(un(e.getFullYear()).getTime()),Hc=e=>Ra(e)?Ut(e):new Date(Number.NaN),Fn=(e,t,r)=>{if(!Ra(t))throw new RangeError(`DateSelector: "${e}" must fall in a year that starts inside the Date range, because variant="split-dropdown" draws its year (received ${M(t)})${r}`)},Bi=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const l=r(i);if(Number.isNaN(l.getTime()))break;n(l,i)&&a.push({value:i,label:o(l)})}return a},jc=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:l,minDate:u,maxDate:f,allowedDates:g,variant:v="date",className:b="",style:T,disabled:Q=!1,locale:m,labels:D,formatLocale:d,formatOption:j}=e;Yc(d);const P=v==="split-dropdown"?Oc:Vc;if(t!==void 0&&ln("value",t,""),r!==void 0&&ln("initialDate",r,""),u!==void 0&&ln("minDate",u,P),f!==void 0&&ln("maxDate",f,P),v==="split-dropdown"&&(t!==void 0&&Fn("value",t,""),r!==void 0&&Fn("initialDate",r,""),u!==void 0&&Fn("minDate",u,P),f!==void 0&&Fn("maxDate",f,P)),i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${M(i)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${M(l)})`);if(i!==void 0&&Number.isNaN(un(i).getTime()))throw new RangeError(`DateSelector: "minYear" must name a year whose first day is inside the Date range (received ${M(i)})`);if(l!==void 0&&Number.isNaN(Fi(l).getTime()))throw new RangeError(`DateSelector: "maxYear" must name a year whose last day is inside the Date range (received ${M(l)})`);if(v==="split-dropdown"&&g!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const _=t??r;if(_===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");if(o!==void 0){const x=Sa(o);if(x!==null)throw new RangeError(`DateSelector: "${x.field}" must be ${x.expected} (received ${x.received})`);if(t===void 0)throw new RangeError('DateSelector: "stepper" requires the controlled "value"; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled "initialDate" would never change')}const H=fo(m,D),[fe,O]=s.useState(()=>Ut(_)),ee=t!==void 0,ie=t?.getTime(),N=s.useMemo(()=>t!==void 0?Ut(t):fe,[ie,fe]);if(v==="split-dropdown"&&!ee&&!Ra(N))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${M(N)}), because that selection's year starts outside the Date range; control the date with "value" to decide what the split dropdown holds`);const oe=u?.getTime(),E=f?.getTime(),R=s.useMemo(()=>{const x=u?Ut(u):null,q=i!==void 0?un(i):null;return x===null?q:q===null||x.getTime()>=q.getTime()?x:q},[oe,i]),$=s.useMemo(()=>{const x=f?Ut(f):null,q=l!==void 0?Fi(l):null;return x===null?q:q===null||x.getTime()<=q.getTime()?x:q},[E,l]),W=R?.getTime()??null,Z=$?.getTime()??null;if(R!==null&&$!==null&&R.getTime()>$.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${an(R)} is after max ${an($)})`);if(v!=="date"&&g===void 0&&(R===null||$===null))throw new RangeError(`DateSelector: variant=${M(v)} needs a bounded range; supply minDate/minYear and maxDate/maxYear${v==="dropdown"?' or supply "allowedDates"':""}`);const z=s.useMemo(()=>g===void 0?null:g.map(x=>St(x,q=>q.getTime())).join(","),[g]),J=s.useMemo(()=>{if(g===void 0)return null;const x=Sc(g,(q,k)=>ln(`allowedDates[${q}]`,k,""));return{ascending:x,ascendingSerials:x.map(xt)}},[z]),C=s.useMemo(()=>J===null?null:{...J,...xc(J.ascending,R,$)},[J,W,Z]),ce=s.useMemo(()=>C!==null?pc(C.ascending,C.ascendingSerials,C.loIndex,C.hiIndex,d,j):R===null||$===null?vc:bc(R,$,d,j),[C,W,Z,d,j]),we=s.useMemo(()=>C!==null?{kind:"candidates",ascending:C.ascendingSerials,loIndex:C.loIndex,hiIndex:C.hiIndex}:{kind:"range",min:R===null?null:xt(R),max:$===null?null:xt($)},[C,W,Z]),Me=x=>!Number.isNaN(x.getTime())&&gn(we,xt(x)),K=_.getTime();s.useEffect(()=>{ee||O(Ut(_))},[ee,K]);const re=x=>{if(Q)return;const q=Ut(x);Me(q)&&(ee||O(q),n?.(q))},U=N.getTime(),de=Me(N),se=s.useMemo(()=>{const x=Wt(we,xt(N),-1);if(x===null)return null;const q=bn(x);return Number.isNaN(q.getTime())?null:q},[we,U]),I=s.useMemo(()=>{const x=Wt(we,xt(N),1);if(x===null)return null;const q=bn(x);return Number.isNaN(q.getTime())?null:q},[we,U]),ge=()=>{if(o!==void 0){o.onStep("previous");return}se!==null&&re(se)},pe=()=>{if(o!==void 0){o.onStep("next");return}I!==null&&re(I)},gt=x=>{if(x.target.value){const q=Sr.parseISO(x.target.value);Number.isNaN(q.getTime())||re(q)}},me=N.getFullYear(),be=N.getMonth()+1,Ve=N.getDate(),ve=s.useCallback((x,q)=>j?j(q,x,"part"):Cs(q,x,"part",d),[j,d]),Je=s.useMemo(()=>{if(v!=="split-dropdown"||R===null||$===null)return[];const x=[];for(let q=$.getFullYear();q>=R.getFullYear();q--)x.push({value:q,label:ve("year",un(q))});return x},[v,W,Z,ve]),We=s.useMemo(()=>{if(v!=="split-dropdown"||R===null||$===null)return[];const x=R,q=$,k=me===x.getFullYear()?x.getMonth()+1:1,ht=me===q.getFullYear()?q.getMonth()+1:12;return Bi(k,ht,qe=>rr(me,qe,1),(qe,wt)=>Ns(qe,me,wt),qe=>ve("month",qe))},[v,W,Z,me,ve]),Te=s.useMemo(()=>{if(v!=="split-dropdown"||R===null||$===null)return[];const x=R,q=$,k=me===x.getFullYear()&&be===x.getMonth()+1?x.getDate():1,ht=me===q.getFullYear()&&be===q.getMonth()+1?q.getDate():_c;return Bi(k,ht,qe=>rr(me,be,qe),(qe,wt)=>Ui(qe,me,be,wt),qe=>ve("day",qe))},[v,W,Z,me,be,ve]),ot=(x,q,k)=>{const ht=rr(x,q,k);return Ui(ht,x,q,k)&&Me(ht)},B=(x,q,k)=>{ot(x,q,k)&&re(rr(x,q,k))},Ge=Je.some(x=>x.value===me),Ye=We.some(x=>x.value===be),Be=Te.some(x=>x.value===Ve),He=an(N),Ke=v==="dropdown"?rt("day",N,j,d):"",at=R?an(R):void 0,Re=$?an($):void 0,Se="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400";return L.jsxs("div",{className:`inline-flex items-center ${mn} ${b}`,style:T,"data-variant":v,"data-out-of-range":de?void 0:"true",children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:Q,canStep:o===void 0?se!==null:o.canStepPrevious,onStep:ge,ariaLabel:H.previousDay}),v==="dropdown"?L.jsx(As,{domain:ce,selectedIndex:de?ce.indexOf(N):$e,openAnchorIndex:ce.nearestIndexOf(N),displayLabel:Ke,machineValue:He,disabled:Q,ariaLabel:H.dateSelect,locale:m,labels:H,onCommitIndex:x=>re(ce.dateAt(x)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):v==="split-dropdown"?L.jsxs("div",{className:"inline-flex items-center gap-1",children:[L.jsxs("select",{"aria-label":H.splitYear,disabled:Q,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Ge?me:"",onChange:x=>B(Number(x.target.value),be,Ve),children:[Ge?null:L.jsx("option",{value:"",disabled:!0,className:Se,children:ve("year",un(me))}),Je.map(x=>L.jsx("option",{value:x.value,disabled:!ot(x.value,be,Ve),className:"dark:bg-slate-700 dark:text-slate-100",children:x.label},x.value))]}),L.jsxs("select",{"aria-label":H.splitMonth,disabled:Q,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Ye?be:"",onChange:x=>B(me,Number(x.target.value),Ve),children:[Ye?null:L.jsx("option",{value:"",disabled:!0,className:Se,children:ve("month",rr(me,be,1))}),We.map(x=>L.jsx("option",{value:x.value,disabled:!ot(me,x.value,Ve),className:"dark:bg-slate-700 dark:text-slate-100",children:x.label},x.value))]}),L.jsxs("select",{"aria-label":H.splitDay,disabled:Q,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Be?Ve:"",onChange:x=>B(me,be,Number(x.target.value)),children:[Be?null:L.jsx("option",{value:"",disabled:!0,className:Se,children:ve("day",rr(me,be,Ve))}),Te.map(x=>L.jsx("option",{value:x.value,disabled:!ot(me,be,x.value),className:"dark:bg-slate-700 dark:text-slate-100",children:x.label},x.value))]})]}):L.jsx("input",{"aria-label":H.dateSelect,disabled:Q,className:"period-slider-native-date-field w-28 rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",value:He,min:at,max:Re,onChange:gt,type:"date"}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:Q,canStep:o===void 0?I!==null:o.canStepNext,onStep:pe,ariaLabel:H.nextDay}),a]})},zc=(e,t)=>!(!xa(e,t,t.variant==="split-dropdown"?Hc:Ut)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!mo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Vs=s.memo(jc,zc);Vs.displayName="DateSelector";function Rt(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function Os(e){return Rt(e.getFullYear(),e.getMonth())}function pr(e){return`${ho(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Wi='; leave the bound out where the variant allows it, or declare the months to offer with `minYear` / `maxYear` or `allowedMonths`, instead of a sentinel for "no bound"';function Un(e,t,r){e!==void 0&&_s(e,t,r)}function _s(e,t,r){if(!Ne(e))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${M(e)}.`);if(Number.isNaN(Os(e).getTime()))throw new RangeError(`MonthSelector: \`${t}\` must fall in a month that starts inside the Date range, received ${M(e)}${r}.`)}function Gi(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${M(e)}.`);if(Number.isNaN(Rt(e,r).getTime()))throw new RangeError(`MonthSelector: \`${t}\` must name a year whose ${r===0?"January":"December"} starts inside the Date range, received ${M(e)}.`)}}function Fc(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`formatLocale\` must be a valid BCP 47 language tag, received ${M(e)}.`)}}function Uc(e,t){const r=e===void 0?null:Rt(e,0),n=t===void 0?null:Rt(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Bc(e,t){const r=e===void 0?null:Rt(e,11),n=t===void 0?null:Rt(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function nr(e){return e.getFullYear()*12+e.getMonth()}function da(e){return Rt(Math.floor(e/12),(e%12+12)%12)}function Ki(e){return Number.isNaN(e.getTime())?null:e}function Wc(e,t,r){const n=new Map;for(const o of e){const a=Rt(o.getFullYear(),o.getMonth());t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function Gc(e,t){const r=[];for(let n=nr(e);n<=nr(t);n++)r.push(da(n));return r}function qi(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:rt("month",e[o],r,t),value:pr(e[o])});return n}const Kc=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:l,maxYear:u,minDate:f,maxDate:g,allowedMonths:v,isWarning:b=!1,className:T="",style:Q,disabled:m=!1,locale:D,labels:d,formatLocale:j,formatOption:P}=e;if(Fc(j),Un(t,"value",""),Un(r,"initialDate",""),Un(f,"minDate",Wi),Un(g,"maxDate",Wi),Gi(l,"minYear",0),Gi(u,"maxYear",11),v!==void 0)for(let B=0;B<v.length;B++)_s(v[B],`allowedMonths[${B}]`,"");const _=t??r;if(_===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");if(o!==void 0){const B=Sa(o);if(B!==null)throw new RangeError(`MonthSelector: \`${B.field}\` must be ${B.expected}, received ${B.received}.`);if(t===void 0)throw new RangeError("MonthSelector: `stepper` requires the controlled `value`; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled `initialDate` would never change.")}const H=fo(D,d),[fe,O]=s.useState(()=>Rt(_.getFullYear(),_.getMonth())),ee=t!==void 0,ie=s.useMemo(()=>t!==void 0?Rt(t.getFullYear(),t.getMonth()):fe,[t?.getTime(),fe]),N=f?.getTime(),oe=g?.getTime(),E=s.useMemo(()=>Uc(l,f),[l,N]),R=s.useMemo(()=>Bc(u,g),[u,oe]),$=E?.getTime()??null,W=R?.getTime()??null;if(E!==null&&R!==null&&E>R)throw new RangeError(`MonthSelector: the resolved lower bound ${pr(E)} is after the resolved upper bound ${pr(R)}.`);if(i==="dropdown"&&v===void 0&&(E===null||R===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedMonths`; the option window is never invented.');const Z=v===void 0?null:v.map(B=>B.getTime()).join(","),z=s.useMemo(()=>v===void 0?null:Wc(v,E,R),[Z,$,W]),J=s.useMemo(()=>{if(z!==null){const B=z.map(nr);return{kind:"candidates",ascending:B,loIndex:0,hiIndex:B.length-1}}return{kind:"range",min:E===null?null:nr(E),max:R===null?null:nr(R)}},[z,$,W]),C=B=>!Number.isNaN(B.getTime())&&gn(J,nr(B)),ce=_.getTime();s.useEffect(()=>{if(ee)return;const B=Rt(_.getFullYear(),_.getMonth());O(Ge=>Ge.getTime()===B.getTime()?Ge:B)},[ee,ce]);const we=B=>{if(m)return;if(!C(B))throw new RangeError(`MonthSelector: refusing to emit ${pr(B)}, which lies outside the selectable months.`);ee||O(B);const Ge=B.getFullYear()*100+(B.getMonth()+1);n?.(B,Ge)},Me=ie.getTime(),K=C(ie),re=s.useMemo(()=>{const B=Wt(J,nr(ie),-1);return B===null?null:Ki(da(B))},[J,Me]),U=s.useMemo(()=>{const B=Wt(J,nr(ie),1);return B===null?null:Ki(da(B))},[J,Me]),de=()=>{if(o!==void 0){o.onStep("previous");return}re!==null&&we(re)},se=()=>{if(o!==void 0){o.onStep("next");return}U!==null&&we(U)},I=B=>{if(!B)return;const Ge=B.lastIndexOf("-");if(Ge<=0)return;const Ye=B.slice(0,Ge),Be=B.slice(Ge+1),He=Number(Ye),Ke=Number(Be)-1;if(!(Number.isInteger(He)&&Number.isInteger(Ke)))return;const at=Rt(He,Ke);C(at)&&we(at)},ge=B=>{I(B.target.value)},pe=B=>{I(B.target.value)},gt=pr(ie),me=i==="dropdown"&&!K?rt("month",ie,P,j):"",be=E?pr(E):void 0,Ve=R?pr(R):void 0,ve=s.useMemo(()=>i!=="dropdown"?[]:z!==null?qi(z,j,P):E===null||R===null?[]:qi(Gc(E,R),j,P),[i,z,$,W,j,P]),Je=K?gt:"",We=b?"border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200":"border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",Te=`period-slider-native-date-field w-28 rounded-md border py-0.5 px-1 text-center font-mono text-xs tabular-nums dark:placeholder:text-gray-400 disabled:opacity-50 ${We}`,ot=`w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${We}`;return L.jsxs("div",{className:`inline-flex items-center ${mn} ${T}`,style:Q,"data-out-of-range":K?void 0:"true",children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:m,canStep:o===void 0?re!==null:o.canStepPrevious,onStep:de,ariaLabel:H.previousMonth}),i==="dropdown"?L.jsxs("select",{"aria-label":H.monthSelect,disabled:m,className:ot,value:Je,onChange:pe,children:[K?null:L.jsx("option",{value:"",disabled:!0,className:"text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",children:me}),ve.map(B=>L.jsx("option",{value:B.value,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:B.label},B.value))]}):L.jsx("input",{"aria-label":H.monthSelect,disabled:m,className:Te,value:gt,min:be,max:Ve,onChange:ge,type:"month"}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:m,canStep:o===void 0?U!==null:o.canStepNext,onStep:se,ariaLabel:H.nextMonth}),a]})},qc=(e,t)=>!(!xa(e,t,Os)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!mo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Ys=s.memo(Kc,qc);Ys.displayName="MonthSelector";function Ae(e,t,r){return e<t?t:e>r?r:e}const Xc=Br([],null,null);function pn(e,t,r,n){return r===null?Xc:ma(r,A(t,e[0],n),A(t,e[1],n))}function vr(e,t,r,n,o){const a=A(t,e,o),i=fa(n)?null:hn(n,a);return i===null?a<A(t,r[0],o)?r[0]:a>A(t,r[1],o)?r[1]:e:i===a?e:te(t,i,o)}function jr(e,t,r,n,o,a){const i=A(t,e[0],o),l=A(t,e[1],o),u=qn(a,{kind:"range",min:A(t,r[0],o),max:A(t,r[1],o)},i,l);if(u===null)return e;const f=vr(u[0]===i?e[0]:te(t,u[0],o),t,r,n,o),g=vr(u[1]===l?e[1]:te(t,u[1],o),t,r,n,o);return[f,g<f?f:g]}const Xi=(e,t,r,n,o,a,i)=>{if(r===void 0)return null;if(!Array.isArray(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${M(r)})`);if(r.length===0)return null;const l=Br(Is(e,t,r,n,i),A(n,o,i),A(n,a,i));if(l.hiIndex<l.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${M(o)}, maxDate: ${M(a)}, entries: ${r.length})`);return l},ma=(e,t,r)=>{const n=Br(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},fa=e=>e.hiIndex<e.loIndex,Zc=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Wt(o,t,r);a!==null&&(n===null||(r===1?a<n:a>n))&&(n=a)}return n},edge:t=>{let r=null;for(const n of e){const o=fn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Zi=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),Qi=(e,t,r,n,o)=>{if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${M(r)})`);const a=xr(e,`${t}[0]`,r[0],n,o),i=xr(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${M(r[0])}, end: ${M(r[1])})`);return[a,i]},or=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${M(e)})`);const{row:r,shows:n,macroUnit:o,microUnit:a,minDate:i,maxDate:l,macroRange:u,microSelection:f}=e;if(r!=="macro"&&r!=="micro")throw new RangeError(`${t}: row must be "macro" or "micro" (received: ${M(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${M(n)})`);to(t,"macroUnit",o),to(t,"microUnit",a);const g=lr(t,e.yearStartMonth);for(const[E,R]of[["minDate",i],["maxDate",l]])if(!Ne(R))throw new RangeError(`${t}: ${E} must be a valid Date (received: ${M(R)})`);if(l.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${M(i)}, maxDate: ${M(l)})`);Mr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const v=Qi(t,"macroRange",u,o,g);if(u[1].getTime()<u[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${M(u[0])}, end: ${M(u[1])})`);const b=Qi(t,"microSelection",f,a,g),T=Xi(t,"macroAllowedDates",e.macroAllowedDates,o,i,l,g),Q=Xi(t,"microAllowedDates",e.microAllowedDates,a,i,l,g),m=[u[0],u[1]],D=[f[0],f[1]],d=E=>{const R=Dt(o,a,[E[0],E[1]],i,l,g);return[A(a,R[0],g),A(a,R[1],g)]},j=(E,R)=>{if(Q!==null){const $=ma(Q,E,R);if(!fa($))return $}return{kind:"range",min:E,max:R}},P=(E,R)=>{const $=Zi(E,m)?m:E;return $===m&&Zi(R,D)?null:{macroRange:$,microSelection:R}};if(e.row==="macro"){const E=T??{kind:"range",min:A(o,i,g),max:A(o,l,g)},R=Kn(E),$=(Z,z)=>{const J=Dt(o,a,Z,i,l,g);return jr(D,a,J,pn(J,a,Q,g),g,z)},W=(Z,z)=>{const J=oa(R,v[0],v[1],Z,sa(z,n));if(J===null)return null;const C=la(J,v,m,o,g,z.motion==="single");if(C===null)return null;const ce=[Ae(C[0],i,l),Ae(C[1],i,l)],we=Math.sign(J[0]-v[0])===Z&&Math.sign(J[1]-v[1])===Z;return P(ce,$(ce,we?"pan":"resize"))};return{previous:W(-1,e.rules.previous),next:W(1,e.rules.next)}}const _=d(m);let H=[A(a,i,g),A(a,l,g)];if(T!==null){const E=d([te(o,T.ascending[T.loIndex],g),te(o,T.ascending[T.hiIndex],g)]);H=[Math.min(E[0],_[0]),Math.max(E[1],_[1])]}const fe=Q===null?null:ma(Q,H[0],H[1]);let O=Kn({kind:"range",min:H[0],max:H[1]});if(fe!==null&&!fa(fe)){const E=j(_[0],_[1]);O=E.kind==="candidates"?Kn(fe):Zc([fe,E])}const ee=E=>{if(T===null)return[Ae(ut(o,E[0],g),i,l),Ae(ut(o,E[1],g),i,l)];const R=Gn(T,A(o,E[0],g),-1),$=Gn(T,A(o,E[1],g),1);return R===null||$===null?null:[Ae(te(o,R,g),i,l),Ae(te(o,$,g),i,l)]},ie=(E,R,$)=>{const[W,Z]=d(E),z=j(W,Z),J=we=>{const Me=A(a,we,g);if(gn(z,Me))return we;const K=Gn(z,Me,$);return K===null?null:te(a,K,g)},C=J(R[0]),ce=J(R[1]);return C===null||ce===null?null:[C,ce.getTime()<C.getTime()?C:ce]},N=(E,R)=>E>=_[0]&&R<=_[1],oe=(E,R)=>{const $=oa(O,b[0],b[1],E,sa(R,n));if($===null)return null;const W=la($,b,D,a,g,R.motion==="single");if(W===null)return null;const Z=R.window!=="follow",z=Z&&N($[0],$[1])?m:ee(W);if(z===null)return null;const J=ie(z,W,E);if(J===null)return null;const C=Z&&N(A(a,J[0],g),A(a,J[1],g))?m:ee(J);return C===null?null:P(C,J)};return{previous:oe(-1,e.rules.previous),next:oe(1,e.rules.next)}};function Pe(e,t,r){if(!Ne(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${M(r)})`)}function wo(e,t,r){if(Pe(e,"minDate",t),Pe(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${M(t)}, maxDate: ${M(r)})`)}function ar(e,t,r){if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${M(r)})`);if(Pe(e,`${t}[0]`,r[0]),Pe(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${M(r[0])}, upper: ${M(r[1])})`)}function ro(e,t,r,n,o,a,i,l){const u=A(r,n,l);if(u<A(r,o,l)||u>A(r,a,l))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${M(n)}, lower: ${M(o)}, upper: ${M(a)})`)}function no(e,t,r,n,o,a,i,l){ro(e,`${t}[0]`,r,n[0],o,a,i,l),ro(e,`${t}[1]`,r,n[1],o,a,i,l)}function oo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${M(r)}, upper: ${M(n)})`)}function Ur(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${M(r)})`)}function ao(e,t,r,n,o){const a=Ee(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function io(e,t,r,n,o,a){const i=Ae(e,r,n);if(o.length===0)return i;const l=o[Ee(o,i,t,a)];return A(t,l,a)===A(t,i,a)?i:Ae(l,r,n)}function Ji(e,t,r,n,o,a){const i=io(e[0],t,r,n,o,a),l=io(e[1],t,r,n,o,a);return[i,l<i?i:l]}const Qc={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function Yt(e,t){return t.length===0?{}:{[Qc[e]]:t}}function bo(e){const t=s.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(l=>Object.is(r[l],n[l]))||(t.current=e),t.current}const Bt={previous:null,next:null},Jc=["motion","edge","window"];function vn(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Jc.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}function eu(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:l,selectorStep:u,...f}=e,g=lr("usePeriodSliderRange",i);wo("usePeriodSliderRange",r,n),ar("usePeriodSliderRange","initialRange",o),u!==void 0&&Mr("usePeriodSliderRange","selectorStep",u,"motion");const v=bo(f),b=r.getTime(),T=n.getTime(),Q=s.useMemo(()=>Dr(v.allowedDates,t,r,n,g),[v.allowedDates,t,b,T,g]),m=s.useRef(o),[D,d]=s.useState(()=>(no("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",g),o));ar("usePeriodSliderRange","range",D);let j=D;const P=Ji(D,t,r,n,Q,g);(P[0]!==D[0]||P[1]!==D[1])&&(j=P,d(P));const _=s.useRef(j);_.current=j;const H=s.useRef(o),fe=s.useRef({minDate:r,maxDate:n,candidates:Q});fe.current={minDate:r,maxDate:n,candidates:Q};const O=s.useRef(a);O.current=a;const ee=s.useCallback(K=>{const{minDate:re,maxDate:U,candidates:de}=fe.current,se=Ji(K,t,re,U,de,g),I=_.current;(se[0].getTime()!==I[0].getTime()||se[1].getTime()!==I[1].getTime())&&(_.current=se,d(se));const ge=H.current;se[0].getTime()===ge[0].getTime()&&se[1].getTime()===ge[1].getTime()||(H.current=se,O.current?.(se[0],se[1]))},[t,g]),ie=s.useCallback(K=>{const re=typeof K=="function"?K(_.current):K;H.current=re,_.current=re,d(re)},[]),N=s.useCallback(K=>{Pe("usePeriodSliderRange","setLowerDate(date)",K);const re=_.current,U=K.getTime()>re[1].getTime()?K:re[1];ee([K,U])},[ee]),oe=s.useCallback(K=>{Pe("usePeriodSliderRange","setUpperDate(date)",K);const re=_.current,U=K.getTime()<re[0].getTime()?K:re[0];ee([U,K])},[ee]),E=s.useCallback((K,re)=>{Pe("usePeriodSliderRange","sliderProps.onChangeRange(lower)",K),Pe("usePeriodSliderRange","sliderProps.onChangeRange(upper)",re),oo("usePeriodSliderRange","sliderProps.onChangeRange",K,re),ee([K,re])},[ee]),R=s.useCallback(K=>{Ur("usePeriodSliderRange","shiftRange",K);const{candidates:re}=fe.current,U=_.current;if(re.length>0){ee([ao(re,t,U[0],K,g),ao(re,t,U[1],K,g)]);return}ee([nt(t,U[0],K),nt(t,U[1],K)])},[t,ee,g]),$=s.useCallback(()=>{ee(m.current)},[ee]),W=vn(u),Z=W!==void 0,z=s.useMemo(()=>{if(W===void 0)return{start:Bt,end:Bt};const K=Array.isArray(v.allowedDates)&&v.allowedDates.length>0?v.allowedDates:void 0,re={selection:j,unit:t,yearStartMonth:g,minDate:r,maxDate:n,allowedDates:K,rules:W};return{start:ca({...re,shows:"start"}),end:ca({...re,shows:"end"})}},[W,j,t,g,b,T,v.allowedDates]),J=_t(z.start,ee),C=_t(z.end,ee),ce=s.useMemo(()=>({value:j[0],onChange:N,minDate:r,maxDate:j[1],unit:t,yearStartMonth:g,...Yt(t,Q),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...Z?{stepper:J}:{}}),[j[0],j[1],N,r,t,g,Q,e.formatLocale,e.locale,e.labels,l,Z,J]),we=s.useMemo(()=>({value:j[1],onChange:oe,minDate:j[0],maxDate:n,unit:t,yearStartMonth:g,...Yt(t,Q),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...Z?{stepper:C}:{}}),[j[0],j[1],oe,n,t,g,Q,e.formatLocale,e.locale,e.labels,l,Z,C]),Me=s.useMemo(()=>({...v,mode:"range",unit:t,yearStartMonth:g,range:j,minDate:r,maxDate:n,onChangeRange:E}),[v,t,j,r,n,E,g]);return{range:j,lowerDate:j[0],upperDate:j[1],setRange:ie,setLowerDate:N,setUpperDate:oe,shiftRange:R,resetRange:$,startSelectorProps:ce,endSelectorProps:we,sliderProps:Me}}function tu(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:l,...u}=e,f=lr("usePeriodSliderPoint",i);wo("usePeriodSliderPoint",r,n),Pe("usePeriodSliderPoint","initialValue",o);const g=bo(u),v=r.getTime(),b=n.getTime(),T=s.useMemo(()=>Dr(g.allowedDates,t,r,n,f),[g.allowedDates,t,v,b,f]),Q=s.useRef(o),[m,D]=s.useState(()=>(ro("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",f),o));Pe("usePeriodSliderPoint","value",m);let d=m;const j=io(m,t,r,n,T,f);j!==m&&(d=j,D(j));const P=s.useRef(d);P.current=d;const _=s.useRef(o),H=s.useRef({minDate:r,maxDate:n,candidates:T});H.current={minDate:r,maxDate:n,candidates:T};const fe=s.useRef(a);fe.current=a;const O=s.useCallback(W=>{const{minDate:Z,maxDate:z,candidates:J}=H.current,C=io(W,t,Z,z,J,f);C.getTime()!==P.current.getTime()&&(P.current=C,D(C)),C.getTime()!==_.current.getTime()&&(_.current=C,fe.current?.(C))},[t,f]),ee=s.useCallback(W=>{const Z=typeof W=="function"?W(P.current):W;_.current=Z,P.current=Z,D(Z)},[]),ie=s.useCallback(W=>{Pe("usePeriodSliderPoint","selectorProps.onChange(date)",W),O(W)},[O]),N=s.useCallback(W=>{Pe("usePeriodSliderPoint","sliderProps.onChangePoint(value)",W),O(W)},[O]),oe=s.useCallback(W=>{Ur("usePeriodSliderPoint","shiftValue",W);const{candidates:Z}=H.current;if(Z.length>0){O(ao(Z,t,P.current,W,f));return}O(nt(t,P.current,W))},[t,O,f]),E=s.useCallback(()=>{O(Q.current)},[O]),R=s.useMemo(()=>({value:d,onChange:ie,minDate:r,maxDate:n,unit:t,yearStartMonth:f,...Yt(t,T),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l}),[d,ie,r,n,t,f,T,e.formatLocale,e.locale,e.labels,l]),$=s.useMemo(()=>({...g,mode:"point",unit:t,yearStartMonth:f,value:d,minDate:r,maxDate:n,onChangePoint:N}),[g,t,d,r,n,N,f]);return{value:d,setValue:ee,shiftValue:oe,resetValue:E,selectorProps:R,sliderProps:$}}function ru(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i=t,microUnit:l=t,onChangeMacroRange:u,onChangeMicroRange:f,yearStartMonth:g,formatOption:v,macroSelectorStep:b,microSelectorStep:T,...Q}=e,m=lr("useVernierSliderRange",g);wo("useVernierSliderRange",r,n),ar("useVernierSliderRange","initialMacroRange",o),ar("useVernierSliderRange","initialMicroRange",a),b!==void 0&&Mr("useVernierSliderRange","macroSelectorStep",b,"motion"),T!==void 0&&Mr("useVernierSliderRange","microSelectorStep",T,"vernierRange");const D=bo(Q),d=s.useRef(o),j=s.useRef(a),[P,_]=s.useState(()=>(no("useVernierSliderRange","initialMacroRange",i,o,r,n,"[minDate, maxDate]",m),o)),[H,fe]=s.useState(()=>{const y=Dt(i,l,o,r,n,m);return no("useVernierSliderRange","initialMicroRange",l,a,y[0],y[1],"the initial macro window",m),a});let O=P;ar("useVernierSliderRange","macroRange",P);const ee=[Ae(P[0],r,n),Ae(P[1],r,n)];(ee[0]!==P[0]||ee[1]!==P[1])&&(O=ee,_(ee));const ie=r.getTime(),N=n.getTime(),oe=s.useMemo(()=>Dt(i,l,O,r,n,m),[i,l,O,ie,N,m]),E=s.useMemo(()=>D.microIsDiscrete===!0?wa(Ot("micro",D),l,r,n,m):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,l,ie,N,m]),R=s.useMemo(()=>D.macroIsDiscrete===!0?Dr(Ot("macro",D),i,r,n,m):[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,i,ie,N,m]),$=s.useRef(R);$.current=R;const W=s.useMemo(()=>pn(oe,l,E,m),[oe,l,E,m]),Z=s.useMemo(()=>wn(E,W),[E,W]);let z=H;ar("useVernierSliderRange","microRange",H);const J=jr(H,l,oe,W,m,"resize");(J[0]!==H[0]||J[1]!==H[1])&&(z=J,fe(J));const C=s.useRef(O);C.current=O;const ce=s.useRef(z);ce.current=z;const we=s.useRef(a),Me=s.useRef(o),K=s.useRef({minDate:r,maxDate:n});K.current={minDate:r,maxDate:n};const re=s.useRef(u);re.current=u;const U=s.useRef(f);U.current=f;const de=s.useCallback(y=>{const{minDate:Y,maxDate:ue}=K.current;return Dt(i,l,y,Y,ue,m)},[i,l,m]),se=s.useCallback(y=>pn(y,l,E,m),[l,E,m]),I=s.useCallback(y=>{const Y=C.current;(y[0].getTime()!==Y[0].getTime()||y[1].getTime()!==Y[1].getTime())&&(C.current=y,_(y));const ue=Me.current;y[0].getTime()===ue[0].getTime()&&y[1].getTime()===ue[1].getTime()||(Me.current=y,re.current?.(y[0],y[1]))},[]),ge=s.useCallback(y=>{const Y=typeof y=="function"?y(C.current):y;Me.current=Y,C.current=Y,_(Y)},[]),pe=s.useCallback((y,Y)=>{I(y);const ue=ce.current;(Y[0].getTime()!==ue[0].getTime()||Y[1].getTime()!==ue[1].getTime())&&(ce.current=Y,fe(Y));const Ce=we.current;(Y[0].getTime()!==Ce[0].getTime()||Y[1].getTime()!==Ce[1].getTime())&&(we.current=Y,U.current?.(Y[0],Y[1]))},[I]),gt=s.useCallback(y=>{const Y=typeof y=="function"?y(ce.current):y;we.current=Y,ce.current=Y,fe(Y)},[]),me=s.useCallback((y,Y,ue)=>{const{minDate:Ce,maxDate:je}=K.current,Le=[Ae(y,Ce,je),Ae(Y,Ce,je)],ze=de(Le);pe(Le,jr(ce.current,l,ze,se(ze),m,ue))},[l,de,se,pe,m]),be=s.useCallback((y,Y)=>me(y,Y,"resize"),[me]),Ve=s.useCallback((y,Y)=>{Pe("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",y),Pe("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",Y),oo("useVernierSliderRange","sliderProps.onChangeMacroRange",y,Y);const{minDate:ue,maxDate:Ce}=K.current,je=[Ae(y,ue,Ce),Ae(Y,ue,Ce)],Le=ce.current,ze=de(je),et=jr(Le,l,ze,se(ze),m,"resize");if(et[0].getTime()!==Le[0].getTime()||et[1].getTime()!==Le[1].getTime()){I(je);return}pe(je,Le)},[l,de,se,I,pe,m]),ve=s.useCallback((y,Y)=>{const ue=de(C.current);pe(C.current,jr([y,Y],l,ue,se(ue),m,"resize"))},[l,de,se,pe,m]),Je=s.useCallback((y,Y)=>{Pe("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",y),Pe("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",Y),oo("useVernierSliderRange","sliderProps.onChangeMicroRange",y,Y),ve(y,Y)},[ve]),We=s.useCallback(y=>{Pe("useVernierSliderRange","setMacroLowerDate(date)",y);const Y=C.current[1],ue=y>Y?y:Y;be(y,ue)},[be]),Te=s.useCallback(y=>{Pe("useVernierSliderRange","setMacroUpperDate(date)",y);const Y=C.current[0],ue=y<Y?y:Y;be(ue,y)},[be]),ot=s.useCallback(y=>{Pe("useVernierSliderRange","setMicroLowerDate(date)",y);const Y=ce.current[1],ue=y>Y?y:Y;ve(y,ue)},[ve]),B=s.useCallback(y=>{Pe("useVernierSliderRange","setMicroUpperDate(date)",y);const Y=ce.current[0],ue=y<Y?y:Y;ve(ue,y)},[ve]),Ge=s.useCallback(y=>{Ur("useVernierSliderRange","shiftMacroRange",y);const{minDate:Y,maxDate:ue}=K.current,Ce=C.current,je=$.current;if(je.length>0){const et=Ee(je,Ce[0],i,m)+y,yt=Ee(je,Ce[1],i,m)+y;if(et<0||yt>je.length-1)return;me(je[et],je[yt],"pan");return}const Le=nt(i,Ce[0],y),ze=nt(i,Ce[1],y);Le<Y||ze>ue||me(Le,ze,"pan")},[i,me,m]),Ye=s.useCallback(y=>{Ur("useVernierSliderRange","shiftMicroRange",y);const Y=C.current,ue=ce.current,Ce=de(Y),[je,Le]=Ce,ze=wn(E,se(Ce));if(ze.length>0){const Ht=Ee(ze,ue[0],l,m)+y,Fe=Ee(ze,ue[1],l,m)+y;if(Ht<0||Fe>ze.length-1)return;ve(ze[Ht],ze[Fe]);return}const et=nt(l,ue[0],y),yt=nt(l,ue[1],y);A(l,et,m)<A(l,je,m)||A(l,yt,m)>A(l,Le,m)||ve(et,yt)},[l,E,de,se,ve,m]),Be=s.useCallback(()=>{const{minDate:y,maxDate:Y}=K.current,ue=[Ae(d.current[0],y,Y),Ae(d.current[1],y,Y)],Ce=de(ue);pe(ue,jr(j.current,l,Ce,se(Ce),m,"resize"))},[l,de,se,pe,m]),He=vn(b),Ke=vn(T),at=He!==void 0,Re=Ke!==void 0,Se=s.useMemo(()=>{const y={macroUnit:i,microUnit:l,yearStartMonth:m,minDate:r,maxDate:n,macroRange:O,microSelection:z,macroAllowedDates:D.macroIsDiscrete===!0?Ot("macro",D):void 0,microAllowedDates:D.microIsDiscrete===!0?Ot("micro",D):void 0};return{macroStart:He===void 0?Bt:or({...y,row:"macro",shows:"start",rules:He}),macroEnd:He===void 0?Bt:or({...y,row:"macro",shows:"end",rules:He}),microStart:Ke===void 0?Bt:or({...y,row:"micro",shows:"start",rules:Ke}),microEnd:Ke===void 0?Bt:or({...y,row:"micro",shows:"end",rules:Ke})}},[He,Ke,i,l,m,ie,N,O,z,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),Mt=s.useCallback(y=>pe(y.macroRange,y.microSelection),[pe]),x=_t(Se.macroStart,Mt),q=_t(Se.macroEnd,Mt),k=_t(Se.microStart,Mt),ht=_t(Se.microEnd,Mt),[qe,wt]=oe,ne=s.useMemo(()=>({value:O[0],onChange:We,minDate:r,maxDate:O[1],unit:i,yearStartMonth:m,...Yt(i,R),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...at?{stepper:x}:{}}),[O,We,r,i,m,R,e.formatLocale,e.locale,e.labels,v,at,x]),h=s.useMemo(()=>({value:O[1],onChange:Te,minDate:O[0],maxDate:n,unit:i,yearStartMonth:m,...Yt(i,R),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...at?{stepper:q}:{}}),[O,Te,n,i,m,R,e.formatLocale,e.locale,e.labels,v,at,q]),le=s.useMemo(()=>({value:z[0],onChange:ot,minDate:qe,maxDate:z[1],unit:l,yearStartMonth:m,...Yt(l,Z),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...Re?{stepper:k}:{}}),[z,ot,qe,l,m,Z,e.formatLocale,e.locale,e.labels,v,Re,k]),ye=s.useMemo(()=>({value:z[1],onChange:B,minDate:z[0],maxDate:wt,unit:l,yearStartMonth:m,...Yt(l,Z),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...Re?{stepper:ht}:{}}),[z,B,wt,l,m,Z,e.formatLocale,e.locale,e.labels,v,Re,ht]),Oe=s.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:m,macroUnit:i,microUnit:l,minDate:r,maxDate:n,macroRange:O,microRange:z,onChangeMacroRange:Ve,onChangeMicroRange:Je}),[D,t,i,l,r,n,O,z,Ve,Je,m]);return{macroRange:O,setMacroRange:ge,microRange:z,setMicroRange:gt,setMacroLowerDate:We,setMacroUpperDate:Te,setMicroLowerDate:ot,setMicroUpperDate:B,shiftMacroRange:Ge,shiftMicroRange:Ye,resetVernier:Be,macroStartSelectorProps:ne,macroEndSelectorProps:h,microStartSelectorProps:le,microEndSelectorProps:ye,sliderProps:Oe}}function nu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i=t,microUnit:l=t,onChangeMacroRange:u,onChangeMicroPoint:f,yearStartMonth:g,formatOption:v,macroSelectorStep:b,microSelectorStep:T,...Q}=e,m=lr("useVernierSliderPoint",g);wo("useVernierSliderPoint",r,n),ar("useVernierSliderPoint","initialMacroRange",o),Pe("useVernierSliderPoint","initialMicroValue",a),b!==void 0&&Mr("useVernierSliderPoint","macroSelectorStep",b,"motion"),T!==void 0&&Mr("useVernierSliderPoint","microSelectorStep",T,"vernierPoint");const D=bo(Q),d=s.useRef(o),j=s.useRef(a),[P,_]=s.useState(()=>(no("useVernierSliderPoint","initialMacroRange",i,o,r,n,"[minDate, maxDate]",m),o)),[H,fe]=s.useState(()=>{const h=Dt(i,l,o,r,n,m);return ro("useVernierSliderPoint","initialMicroValue",l,a,h[0],h[1],"the initial macro window",m),a});let O=P;ar("useVernierSliderPoint","macroRange",P);const ee=[Ae(P[0],r,n),Ae(P[1],r,n)];(ee[0]!==P[0]||ee[1]!==P[1])&&(O=ee,_(ee));const ie=r.getTime(),N=n.getTime(),oe=s.useMemo(()=>Dt(i,l,O,r,n,m),[i,l,O,ie,N,m]),E=s.useMemo(()=>D.microIsDiscrete===!0?wa(Ot("micro",D),l,r,n,m):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,l,ie,N,m]),R=s.useMemo(()=>D.macroIsDiscrete===!0?Dr(Ot("macro",D),i,r,n,m):[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,i,ie,N,m]),$=s.useRef(R);$.current=R;const W=s.useMemo(()=>pn(oe,l,E,m),[oe,l,E,m]),Z=s.useMemo(()=>wn(E,W),[E,W]);let z=H;Pe("useVernierSliderPoint","microValue",H);const J=vr(H,l,oe,W,m);J!==H&&(z=J,fe(J));const C=s.useRef(O);C.current=O;const ce=s.useRef(z);ce.current=z;const we=s.useRef(a),Me=s.useRef(o),K=s.useRef({minDate:r,maxDate:n});K.current={minDate:r,maxDate:n};const re=s.useRef(u);re.current=u;const U=s.useRef(f);U.current=f;const de=s.useCallback(h=>{const{minDate:le,maxDate:ye}=K.current;return Dt(i,l,h,le,ye,m)},[i,l,m]),se=s.useCallback(h=>pn(h,l,E,m),[l,E,m]),I=s.useCallback(h=>{const le=C.current;(h[0].getTime()!==le[0].getTime()||h[1].getTime()!==le[1].getTime())&&(C.current=h,_(h));const ye=Me.current;h[0].getTime()===ye[0].getTime()&&h[1].getTime()===ye[1].getTime()||(Me.current=h,re.current?.(h[0],h[1]))},[]),ge=s.useCallback(h=>{const le=typeof h=="function"?h(C.current):h;Me.current=le,C.current=le,_(le)},[]),pe=s.useCallback((h,le)=>{I(h),le.getTime()!==ce.current.getTime()&&(ce.current=le,fe(le)),le.getTime()!==we.current.getTime()&&(we.current=le,U.current?.(le))},[I]),gt=s.useCallback(h=>{const le=typeof h=="function"?h(ce.current):h;we.current=le,ce.current=le,fe(le)},[]),me=s.useCallback((h,le)=>{const{minDate:ye,maxDate:Oe}=K.current,y=[Ae(h,ye,Oe),Ae(le,ye,Oe)],Y=de(y);pe(y,vr(ce.current,l,Y,se(Y),m))},[l,de,se,pe,m]),be=s.useCallback(h=>{const le=de(C.current);pe(C.current,vr(h,l,le,se(le),m))},[l,de,se,pe,m]),Ve=s.useCallback((h,le)=>{Pe("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",h),Pe("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",le),oo("useVernierSliderPoint","sliderProps.onChangeMacroRange",h,le);const{minDate:ye,maxDate:Oe}=K.current,y=[Ae(h,ye,Oe),Ae(le,ye,Oe)],Y=ce.current,ue=de(y);if(vr(Y,l,ue,se(ue),m).getTime()!==Y.getTime()){I(y);return}pe(y,Y)},[l,de,se,I,pe,m]),ve=s.useCallback(h=>{Pe("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",h),be(h)},[be]),Je=s.useCallback(h=>{Pe("useVernierSliderPoint","setMacroLowerDate(date)",h);const le=C.current[1],ye=h>le?h:le;me(h,ye)},[me]),We=s.useCallback(h=>{Pe("useVernierSliderPoint","setMacroUpperDate(date)",h);const le=C.current[0],ye=h<le?h:le;me(ye,h)},[me]),Te=s.useCallback(h=>{Pe("useVernierSliderPoint","setMicroDate(date)",h),be(h)},[be]),ot=s.useCallback(h=>{Ur("useVernierSliderPoint","shiftMacroRange",h);const{minDate:le,maxDate:ye}=K.current,Oe=C.current,y=$.current;if(y.length>0){const Ce=Ee(y,Oe[0],i,m)+h,je=Ee(y,Oe[1],i,m)+h;if(Ce<0||je>y.length-1)return;me(y[Ce],y[je]);return}const Y=nt(i,Oe[0],h),ue=nt(i,Oe[1],h);Y<le||ue>ye||me(Y,ue)},[i,me,m]),B=s.useCallback(h=>{Ur("useVernierSliderPoint","shiftMicroValue",h);const le=C.current,ye=de(le),Oe=wn(E,se(ye));if(Oe.length>0){be(ao(Oe,l,ce.current,h,m));return}be(nt(l,ce.current,h))},[l,E,de,se,be,m]),Ge=s.useCallback(()=>{const{minDate:h,maxDate:le}=K.current,ye=[Ae(d.current[0],h,le),Ae(d.current[1],h,le)],Oe=de(ye);pe(ye,vr(j.current,l,Oe,se(Oe),m))},[l,de,se,pe,m]),Ye=vn(b),Be=vn(T),He=Ye!==void 0,Ke=Be!==void 0,at=s.useMemo(()=>{const h={macroUnit:i,microUnit:l,yearStartMonth:m,minDate:r,maxDate:n,macroRange:O,microSelection:[z,z],macroAllowedDates:D.macroIsDiscrete===!0?Ot("macro",D):void 0,microAllowedDates:D.microIsDiscrete===!0?Ot("micro",D):void 0};return{macroStart:Ye===void 0?Bt:or({...h,row:"macro",shows:"start",rules:Ye}),macroEnd:Ye===void 0?Bt:or({...h,row:"macro",shows:"end",rules:Ye}),micro:Be===void 0?Bt:or({...h,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:Be.previous.window},next:{motion:"shift",window:Be.next.window}}})}},[Ye,Be,i,l,m,ie,N,O,z,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),Re=s.useCallback(h=>pe(h.macroRange,h.microSelection[0]),[pe]),Se=_t(at.macroStart,Re),Mt=_t(at.macroEnd,Re),x=_t(at.micro,Re),[q,k]=oe,ht=s.useMemo(()=>({value:O[0],onChange:Je,minDate:r,maxDate:O[1],unit:i,yearStartMonth:m,...Yt(i,R),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...He?{stepper:Se}:{}}),[O,Je,r,i,m,R,e.formatLocale,e.locale,e.labels,v,He,Se]),qe=s.useMemo(()=>({value:O[1],onChange:We,minDate:O[0],maxDate:n,unit:i,yearStartMonth:m,...Yt(i,R),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...He?{stepper:Mt}:{}}),[O,We,n,i,m,R,e.formatLocale,e.locale,e.labels,v,He,Mt]),wt=s.useMemo(()=>({value:z,onChange:Te,minDate:q,maxDate:k,unit:l,yearStartMonth:m,...Yt(l,Z),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...Ke?{stepper:x}:{}}),[z,Te,q,k,l,m,Z,e.formatLocale,e.locale,e.labels,v,Ke,x]),ne=s.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:m,macroUnit:i,microUnit:l,minDate:r,maxDate:n,macroRange:O,microValue:z,onChangeMacroRange:Ve,onChangeMicroPoint:ve}),[D,t,i,l,r,n,O,z,Ve,ve,m]);return{macroRange:O,setMacroRange:ge,microValue:z,setMicroValue:gt,setMacroLowerDate:Je,setMacroUpperDate:We,setMicroDate:Te,shiftMacroRange:ot,shiftMicroValue:B,resetVernier:Ge,macroStartSelectorProps:ht,macroEndSelectorProps:qe,microSelectorProps:wt,sliderProps:ne}}function so(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Fr(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function Hs(e,t){return so(Fr(e,t),t)}function es(e){return e===void 0?0:ds(e)?e:Number.NaN}const ts='; declare the years to offer with `minYear` / `maxYear` or `allowedYears` instead of a sentinel for "no bound"';function Bn(e,t,r,n){e!==void 0&&js(e,t,r,n)}function js(e,t,r,n){if(!Ne(e))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${M(e)}.`);if(Number.isNaN(Hs(e,r).getTime()))throw new RangeError(`YearSelector: \`${t}\` must fall in a year that starts inside the Date range, received ${M(e)}${n}.`)}function rs(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${M(e)}.`);if(Number.isNaN(so(e,r).getTime()))throw new RangeError(`YearSelector: \`${t}\` must name a year that starts inside the Date range, received ${M(e)}; under yearStartMonth ${r} that year starts on month ${r+1}, day 1.`)}}function ou(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`formatLocale\` must be a valid BCP 47 language tag, received ${M(e)}.`)}}function ns(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Fr(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function au(e,t,r,n){const o=new Set;for(const a of e){const i=Fr(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function iu(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:au(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function su(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const lu=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:l,minDate:u,maxDate:f,allowedYears:g,className:v="",style:b,disabled:T=!1,locale:Q,labels:m,formatLocale:D,formatOption:d,yearStartMonth:j}=e,P=lr("YearSelector",j);if(Bn(t,"value",P,""),Bn(r,"initialDate",P,""),Bn(u,"minDate",P,ts),Bn(f,"maxDate",P,ts),rs(i,"minYear",P),rs(l,"maxYear",P),g!==void 0)for(let U=0;U<g.length;U++)js(g[U],`allowedYears[${U}]`,P,"");ou(D);const _=t??r;if(_===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");if(o!==void 0){const U=Sa(o);if(U!==null)throw new RangeError(`YearSelector: \`${U.field}\` must be ${U.expected}, received ${U.received}.`);if(t===void 0)throw new RangeError("YearSelector: `stepper` requires the controlled `value`; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled `initialDate` would never change.")}const H=fo(Q,m),[fe,O]=s.useState(()=>Fr(_,P)),ee=u?.getTime(),ie=f?.getTime(),N=s.useMemo(()=>ns(i,u,Math.max,P),[i,ee,P]),oe=s.useMemo(()=>ns(l,f,Math.min,P),[l,ie,P]);if(N!==null&&oe!==null&&N>oe)throw new RangeError(`YearSelector: the resolved lower bound ${N} is after the resolved upper bound ${oe}.`);const E=g===void 0?null:g.map(U=>U.getTime()).join(","),R=s.useMemo(()=>iu(g,N,oe,P),[E,N,oe,P]);if(R===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedYears`, are required; the year option list is never invented.");const $=s.useMemo(()=>R.kind==="discrete"?{kind:"candidates",ascending:R.ascending,loIndex:0,hiIndex:R.ascending.length-1}:{kind:"range",min:R.minYear,max:R.maxYear},[R]),W=t!==void 0,Z=t!==void 0?Fr(t,P):fe,z=!gn($,Z),J=_.getTime();s.useEffect(()=>{W||O(Fr(_,P))},[W,J,P]);const C=U=>{if(!T){if(!gn($,U))throw new RangeError(`YearSelector: refusing to emit ${U}, which lies outside the selectable years.`);W||O(U),n?.(so(U,P),U)}},ce=Wt($,Z,-1),we=Wt($,Z,1),Me=()=>{if(o!==void 0){o.onStep("previous");return}ce!==null&&C(ce)},K=()=>{if(o!==void 0){o.onStep("next");return}we!==null&&C(we)},re=s.useMemo(()=>{const U=R.kind==="discrete"?[...R.ascending].reverse():su(R.minYear,R.maxYear);return z&&(U.push(Z),U.sort((de,se)=>se-de)),U.map(de=>({value:de,label:rt("year",so(de,P),d,D)}))},[R,z,Z,P,D,d]);return L.jsxs("div",{className:`inline-flex items-center ${mn} ${v}`,style:b,"data-out-of-range":z?"true":void 0,children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:T,canStep:o===void 0?ce!==null:o.canStepPrevious,onStep:Me,ariaLabel:H.previousYear}),L.jsx("select",{"aria-label":H.yearSelect,disabled:T,className:"w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",value:Z,onChange:U=>{if(!U.target.value)return;const de=Number(U.target.value);Number.isInteger(de)&&C(de)},children:re.map(U=>L.jsx("option",{value:U.value,disabled:z&&U.value===Z,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:U.label},U.value))}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:T,canStep:o===void 0?we!==null:o.canStepNext,onStep:K,ariaLabel:H.nextYear}),a]})},cu=(e,t)=>{const r=es(t.yearStartMonth);return!(es(e.yearStartMonth)!==r||!xa(e,t,n=>Hs(n,r))||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedYears!==t.allowedYears||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!mo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},zs=s.memo(lu,cu);zs.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=us;exports.DateSelector=Vs;exports.MonthSelector=Ys;exports.PERIOD_SLIDER_LABEL_CATALOGS=ls;exports.PERIOD_SLIDER_LABEL_KEYS=uo;exports.PeriodSlider=$s;exports.YearSelector=zs;exports.addUnit=nt;exports.areStylesEqual=Ts;exports.calculateConnectDragValues=ws;exports.calculateHandleDragValues=aa;exports.calculateKeyboardActionValues=bs;exports.calculateLabelSlant=pa;exports.calculateVernierMacroDrag=ys;exports.calculateVernierMicroDrag=Es;exports.decode=te;exports.encode=A;exports.findNearestDateIndex=Ee;exports.formatLabel=rt;exports.formatOptionText=Cs;exports.formatQuarterLabel=oc;exports.formatScreenReaderLabel=br;exports.getMacroWindowEndDate=fs;exports.getMacroWindowStartDate=ms;exports.getSortedAllowedDates=Dr;exports.normalizeDateByUnit=ut;exports.resolveDraggedEdge=co;exports.resolveMacroWindow=Dt;exports.resolvePeriodSliderLabels=cs;exports.resolveQuarter=gs;exports.resolveSelectorSteps=ca;exports.resolveVernierRailZone=va;exports.resolveVernierSelectorSteps=or;exports.resolveVernierTargetHandle=Ms;exports.resolveWheelStep=Ds;exports.usePeriodSliderPoint=tu;exports.usePeriodSliderRange=eu;exports.useSelectorStepper=_t;exports.useVernierSliderPoint=nu;exports.useVernierSliderRange=ru;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),ql=require("date-fns"),l=require("react"),lr=require("@aiquants/virtualscroll"),Xl=require("react-dom"),Ma="an object that cannot be converted to a string",Zl=3,$e=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},Pt=e=>{try{return Array.isArray(e)}catch{return!1}},wo=e=>e===void 0||Pt(e);function Ea(e,t,r){if(!wo(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${S(r)})`)}const S=e=>{if(typeof e=="string")return JSON.stringify(e);if($e(e))return Date.prototype.toISOString.call(e);if(Pt(e))return Ql(e);try{return String(e)}catch{return Ma}},Ql=e=>{let t;try{t=e.length}catch{return Ma}const r=Math.min(t,Zl),n=[];for(let a=0;a<r;a++)n.push(Jl(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},Jl=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return Pt(r)?`Array(${r.length})`:S(r)}catch{return Ma}},xt=(e,t)=>$e(e)?t(e):Number.NaN,dt=(e,t)=>e===void 0?null:xt(e,t),Vi=120,Zo="data-drag-snap",Qo="--ps-drag-snap-duration",gn={flat:["--ps-drag-low","--ps-drag-high"],macro:["--ps-drag-macro-low","--ps-drag-macro-high"],micro:["--ps-drag-micro-low","--ps-drag-micro-high"]},Ds=["low","high"],Rs=["tx","ty","rot"],bo={flat:{low:"--ps-drag-label-low",high:"--ps-drag-label-high"},macro:{low:"--ps-drag-macro-label-low",high:"--ps-drag-macro-label-high"},micro:{low:"--ps-drag-micro-label-low",high:"--ps-drag-micro-label-high"}},ya=(e,t)=>`${e}-${t}`,Jo=(e,t,r)=>`var(${ya(e,t)}, ${r})`,ec=(e,t,r)=>{const n=bo[t];for(const o of Ds)for(const a of Rs)e.style.setProperty(ya(n[o],a),r[o][a])},Ms=e=>Math.max(0,Math.min(1,e)),oo=(e,t,r,n)=>{const o=Ms(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},Pa=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},po=(e,t,r,n)=>{const o=Ms(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ea=(e,t,r,n)=>{if(r){const i=(1-e)*100,s=(1-t)*100;return n?`M 12 ${s} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${s} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},rr=(e,t)=>`var(${e}, ${t}%)`,tc=(e,t,r,n)=>{const[o,a]=gn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},rc=e=>{for(const[t,r]of Object.values(gn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(bo))for(const r of Ds)for(const n of Rs)e.style.removeProperty(ya(t[r],n))},Es=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],vo=[...lr.VIRTUAL_SCROLL_LABEL_KEYS,...Es],da=Object.freeze({en:Object.freeze({rangeStart:"Range start",rangeEnd:"Range end",selectedDate:"Selected date",macroRangeStart:"Macro range start",macroRangeEnd:"Macro range end",microRangeStart:"Micro range start",microRangeEnd:"Micro range end",microSelectedDate:"Micro selected date",decrease:"Decrease",increase:"Increase",previousYear:"Previous year",nextYear:"Next year",yearSelect:"Year",previousMonth:"Previous month",nextMonth:"Next month",monthSelect:"Month",previousDay:"Previous day",nextDay:"Next day",dateSelect:"Date",splitYear:"Year",splitMonth:"Month",splitDay:"Day"}),ja:Object.freeze({rangeStart:"期間の開始",rangeEnd:"期間の終了",selectedDate:"選択日",macroRangeStart:"広域期間の開始",macroRangeEnd:"広域期間の終了",microRangeStart:"詳細期間の開始",microRangeEnd:"詳細期間の終了",microSelectedDate:"詳細の選択日",decrease:"前へ",increase:"次へ",previousYear:"前年",nextYear:"翌年",yearSelect:"年",previousMonth:"前月",nextMonth:"翌月",monthSelect:"年月",previousDay:"前日",nextDay:"翌日",dateSelect:"日付",splitYear:"年",splitMonth:"月",splitDay:"日"})}),ys=Object.freeze({en:Object.freeze({...lr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...da.en}),ja:Object.freeze({...lr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...da.ja})}),_i=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,nc=e=>vo.includes(e),oc=(e,t)=>{const r={};let n=!1;for(const o of lr.VIRTUAL_SCROLL_LABEL_KEYS){const a=t.has(o)?e[o]:void 0;a!==void 0&&(r[o]=a,n=!0)}return n?r:void 0},ac=e=>{try{return lr.resolveVirtualScrollLocale(e)}catch(t){throw t instanceof RangeError?new RangeError(`[period-slider] locale is the UI language, not a BCP 47 tag (date formatting reads formatLocale): ${t.message}`,{cause:t}):t}},Ps=(e,t)=>{const r=ac(e);if(t===void 0)return ys[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${_i(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const s of o)if(!nc(s))throw new RangeError(`[period-slider] labels.${s} is not a known label key; expected one of ${vo.join(", ")}`);const i={...lr.resolveVirtualScrollLabels(r,oc(t,o)),...da[r]};for(const s of Es){const d=o.has(s)?t[s]:void 0;if(d!==void 0){if(typeof d!="string"||d.trim()==="")throw new RangeError(`[period-slider] labels.${s} must be a non-blank string; got ${_i(d)}`);i[s]=d}}return Object.freeze(i)},ic=e=>{const t={};for(const r of lr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},sc=(e,t)=>e===t||vo.every(r=>e[r]===t[r]),xo=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0||e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const r=new Set(Object.keys(e)),n=Object.keys(t);if(r.size!==n.length)return!1;const o=e,a=t;return n.every(i=>r.has(i)&&Object.is(o[i],a[i]))},ta=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Yi=new Set(["hidden","clip","scroll","auto","overlay"]),Hi=["paint","strict","content"],lc=["layout","paint","strict","content"],cc=["transform","perspective","filter"],sn=e=>e!==void 0&&e!==""&&e!=="none",uc=e=>e!==void 0&&e!==""&&e!=="normal",Un=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},dc=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,mc=(e,t)=>t==="absolute"&&sn(e.position)&&e.position!=="static"||sn(e.transform)||sn(e.perspective)||sn(e.filter)||sn(e.backdropFilter)||uc(e.containerType)||lc.some(r=>e.contain.includes(r))?!0:cc.some(r=>e.willChange.includes(r)),fc=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const s=e.getBoundingClientRect();if(s.width===0||s.height===0)return!1;const d=n?0:r,g=n?r:0;if(o<s.left-d||o>=s.right+d||a<s.top-g||a>=s.bottom+g)return!1;const m=i.getComputedStyle(t);if(m.visibility!=="visible")return!1;let v=null;for(let b=t;b!==null;b=b.parentElement){const M=b===t?m:i.getComputedStyle(b);if(v!==null&&!mc(M,v))continue;const U=Yi.has(M.overflowX)||Hi.some(D=>M.contain.includes(D)),u=Yi.has(M.overflowY)||Hi.some(D=>M.contain.includes(D));if(U||u){const D=b.getBoundingClientRect();if(U&&(o<D.left+Un(M.borderLeftWidth)||o>=D.right-Un(M.borderRightWidth))||u&&(a<D.top+Un(M.borderTopWidth)||a>=D.bottom-Un(M.borderBottomWidth)))return!1}v=dc(M)}return!0},ra=new Map,gc=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},hc=(e,t)=>{let r=ra.get(e);if(r===void 0){const a=new Set,i=s=>gc(a,s);r={participants:a,listener:i},ra.set(e,r),e.addEventListener("wheel",i,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(ra.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},hn="gap-[11px]",Nt=6,Ot=Nt*2,nr=Nt*4/3,wc={left:`0,${Ot/2} ${Nt},0 ${Nt},${Ot}`,right:`${nr},${Ot/2} ${nr-Nt},0 ${nr-Nt},${Ot}`,up:`${Ot/2},0 0,${Nt} ${Ot},${Nt}`,down:`${Ot/2},${nr} 0,${nr-Nt} ${Ot},${nr-Nt}`},na=e=>{e.preventDefault(),e.stopPropagation()},bc={onMouseDownCapture:na,onMouseUpCapture:na,onClickCapture:na},pc="period-slider-step",vc=`${pc} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,xc="transition-colors motion-reduce:transition-none not-aria-disabled:cursor-pointer aria-disabled:cursor-not-allowed focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 dark:focus-visible:ring-blue-400 forced-colors:not-aria-disabled:hover:text-[Highlight] forced-colors:aria-disabled:text-[GrayText]",Sc={control:"text-slate-500 not-aria-disabled:hover:bg-slate-500/15 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-500/25 aria-disabled:text-slate-500/40 dark:text-slate-400 dark:not-aria-disabled:hover:text-slate-50 dark:aria-disabled:text-slate-400/40",rail:"border border-slate-300 bg-white text-slate-700 shadow-2xs not-aria-disabled:hover:border-slate-400 not-aria-disabled:hover:bg-slate-100 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-200 aria-disabled:border-slate-300/40 aria-disabled:bg-white/40 aria-disabled:text-slate-700/40 aria-disabled:shadow-none dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:not-aria-disabled:hover:border-slate-500 dark:not-aria-disabled:hover:bg-slate-700 dark:not-aria-disabled:hover:text-white dark:not-aria-disabled:active:bg-slate-600 dark:aria-disabled:border-slate-700/40 dark:aria-disabled:bg-slate-800/40 dark:aria-disabled:text-slate-200/40"},zn="after:inset-[calc((100%-var(--ps-target-size))/2)]",ji={horizontal:"px-[19px]",vertical:"py-[19px]"},Dc={control:{left:zn,right:zn,up:zn,down:zn},rail:{left:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:left-[calc(100%-var(--ps-target-size)+4px)] after:-right-[4px]",right:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-left-[4px] after:right-[calc(100%-var(--ps-target-size)+4px)]",up:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-[calc(100%-var(--ps-target-size)+4px)] after:-bottom-[4px]",down:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-[4px] after:bottom-[calc(100%-var(--ps-target-size)+4px)]"}},Rr=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:i,ref:s})=>{const d=e==="up"||e==="down",g=d?Ot:nr,m=d?nr:Ot,v=r||!n;return L.jsx("button",{ref:s,type:"button","aria-label":a,disabled:r,"aria-disabled":v?!0:void 0,...v?bc:null,onClick:v?void 0:o,className:`${i===void 0?"":`${i} `}${vc} ${xc} ${Sc[t]} ${Dc[t][e]}`,children:L.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:g,height:m,viewBox:`0 0 ${g} ${m}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:L.jsx("polygon",{points:wc[e]})})})},So=(e,t)=>{const r=l.useMemo(()=>Ps(e,t),[e,t]),n=l.useRef(r);return sc(n.current,r)||(n.current=r),n.current},ct=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${S(r)})`)},ur=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&ct(e,"values.min",t.min),t.max!==null&&ct(e,"values.max",t.max),t.min!==null&&t.max!==null&&t.max<t.min)throw new RangeError(`${e}: values.max must not precede values.min (min: ${t.min}, max: ${t.max})`);return}ct(e,"values.loIndex",t.loIndex),ct(e,"values.hiIndex",t.hiIndex)},En=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Do=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},wn=(e,t)=>(ur("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:En(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),bn=(e,t)=>{if(ur("drawnValuesHas",e),ct("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(En(e))return!1;const r=Do(e,t);return r<=e.hiIndex&&e.ascending[r]===t},pn=(e,t)=>{if(ur("drawnValuesNearest",e),ct("drawnValuesNearest","value",t),e.kind==="range")return e.min!==null&&t<e.min?e.min:e.max!==null&&t>e.max?e.max:t;if(En(e))return null;const r=Do(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Xt=(e,t,r)=>{if(ur("drawnValuesNeighbour",e),ct("drawnValuesNeighbour","value",t),e.kind==="range"){if(r===-1){const i=e.max===null?t-1:Math.min(t-1,e.max);return e.min!==null&&i<e.min?null:i}const a=e.min===null?t+1:Math.max(t+1,e.min);return e.max!==null&&a>e.max?null:a}if(En(e))return null;const n=Do(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},Zn=(e,t,r)=>{if(ur("clampPairIntoDrawnValues",e),ct("clampPairIntoDrawnValues","low",t),ct("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=pn(e,t),o=pn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Rc=(e,t,r)=>{if(ur("carryPairIntoDrawnValues",e),ct("carryPairIntoDrawnValues","low",t),ct("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(En(e))return null;const n=wn(e,-1),o=wn(e,1),a=r-t;return o!==null&&r>o?Zn(e,o-a,o):n!==null&&t<n?Zn(e,n,n+a):Zn(e,t,r)},Qn=(e,t,r)=>(ur("drawnValuesAtOrBeyond",e),ct("drawnValuesAtOrBeyond","target",t),Xt(e,t-r,r)),Gr=(e,t,r)=>{if(t!==null&&ct("drawnValuesWithin","min",t),r!==null&&ct("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:Do(n,t),hiIndex:o-1}},Jn=e=>(ur("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Xt(e,t,r),edge:t=>wn(e,t)}),ma=(e,t,r,n,o)=>{if(ct("stepPair","low",t),ct("stepPair","high",r),r<t)throw new RangeError(`stepPair: high must not precede low (low: ${t}, high: ${r})`);if(n!==-1&&n!==1)throw new RangeError(`stepPair: direction must be -1 or 1 (received: ${S(n)})`);switch(o.motion){case"shift":{if(o.edge!=="disable"&&o.edge!=="clamp")throw new RangeError(`stepPair: rule.edge must be "disable" or "clamp" (received: ${S(o.edge)})`);const a=n===1?r:t,i=n===1?t:r,s=e.stepEnd(i,n);if(s===null)return null;let d=e.stepEnd(a,n);if(d===null){const g=e.edge(n);if(o.edge==="disable"||g===null||(n===1?a>g:a<g))return null;d=g}return n===1?[s,d]:[d,s]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${S(o.shows)})`);const a=e.stepEnd(o.shows==="start"?t:r,n);return a===null?null:[a,a]}default:throw new RangeError(`stepPair: rule.motion must be one of "shift", "start", "end", "single" (received: ${S(o.motion)})`)}},$s={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},Ls=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,$t=(e,t)=>{if(!Ls(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${S(t)})`)},dr=(e,t)=>t===void 0?0:($t(e,t),t),Mc=[31,28,31,30,31,30,31,31,30,31,30,31],Ts=719468,eo=146097,fa=(e,t)=>t!==1?Mc[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,$a=(e,t,r,n)=>{const o=e*12+t+n,a=Math.floor(o/12),i=o-a*12;return[a,i,Math.min(r,fa(a,i))]},vn=(e,t,r)=>{const n=t<2?e-1:e,o=Math.floor(n/400),a=n-o*400,i=t<2?t+10:t-2,s=Math.floor((153*i+2)/5)+r-1,d=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return o*eo+d-Ts},Ui=e=>{const t=e+Ts,r=Math.floor(t/eo),n=t-r*eo,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(eo-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),s=i<10?i+2:i-10;return[r*400+o+(s<2?1:0),s,a-Math.floor((153*i+2)/5)+1]},La=(e,t,r)=>e-(t<r?1:0),wt=(e,t,r=0)=>{if(!$e(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${S(t)})`);$t("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(La(t.getFullYear(),t.getMonth(),r),r,1),n.setHours(0,0,0,0)):(e==="month"&&n.setDate(1),n.setHours(0,0,0,0)),n},_=(e,t,r=0)=>{$t("encode",r);const n=wt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:vn(o,a,n.getDate())},ee=(e,t,r=0)=>{$t("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),i=t-a*12;return n.setFullYear(a,i,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},Cs='; minDate is required, so pass the earliest date to offer instead of a sentinel for "no bound"',ut=(e,t,r,n,o,a)=>{const i=Is(r,n,o);if(i===null)throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${S(r)})${a}`);return i},Is=(e,t,r)=>{const n=_(t,e,r);return Number.isInteger(n)?n:null},ks=(e,t,r)=>{if(!$e(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${S(t)})`);if(!Number.isInteger(r))throw new RangeError(`addUnit: amount must be an integer number of units (received: ${S(r)})`);const n=new Date(t.getTime());return r===0?n:e==="year"||e==="month"?(n.setFullYear(...$a(t.getFullYear(),t.getMonth(),t.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},zi=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,s,d]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:Ui(t),[g,m,v]=r==="year"||r==="month"?$a(i,s,d,r==="year"?n*12:n):Ui(vn(i,s,d)+n);return e==="year"?La(g,m,o):e==="month"?g*12+m:vn(g,m,v)},As=(e,t,r,n=0)=>{if(!$e(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${S(r)})`);return $t("getMacroWindowStartDate",n),ut("getMacroWindowStartDate","d",r,e,n,""),ut("getMacroWindowStartDate","d",r,t,n,""),wt(t,wt(e,r,n),n)},Ns=(e,t,r,n=0)=>{if(!$e(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${S(r)})`);$t("getMacroWindowEndDate",n);let o;if(e==="year"&&t!=="year"){const[i,s]=$a(La(r.getFullYear(),r.getMonth(),n),n,1,11);o=t==="month"?i*12+s:vn(i,s,fa(i,s))}else if(e==="month"&&t==="day")o=vn(r.getFullYear(),r.getMonth(),fa(r.getFullYear(),r.getMonth()));else return ut("getMacroWindowEndDate","d",r,t,n,""),wt(t,r,n);const a=ee(t,o,n);if(!$e(a))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${S(r)})`);return a},Fi=(e,t,r)=>e<t?t:e>r?r:e,Dt=(e,t,r,n,o,a=0)=>{if($t("resolveMacroWindow",a),ao("macroRange",r,!0,"resolveMacroWindow"),!$e(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${S(n)})`);if(!$e(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${S(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${S(n)}, maxDate: ${S(o)})`);ut("resolveMacroWindow","maxDate",o,t,a,""),ut("resolveMacroWindow","macroRange[0]",r[0],e,a,""),ut("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=_(e,r[1],a)<_(e,o,a)?Fi(Ns(e,t,r[1],a),n,o):o;return[wt(t,Fi(As(e,t,r[0],a),n,o),a),wt(t,i,a)]},Os=(e,t)=>{if(!$e(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${S(e)})`);$t("resolveQuarter",t);const r=wt("year",e,t).getFullYear(),n=((e.getMonth()-t)%12+12)%12,o=Math.floor(n/3)+1,a=new Date(e.getTime());return a.setFullYear(r,t+3*(o-1),1),a.setHours(0,0,0,0),{year:r,quarter:o,startDate:a}},Ec={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Bi=new Map,yc=(e,t)=>{const r=`${e}\0${t}`,n=Bi.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Ec[e]);return Bi.set(r,o),o},Pc=4,$c=6,Ro=e=>e>=0?String(e).padStart(Pc,"0"):`-${String(-e).padStart($c,"0")}`,Lc=(e,t)=>{const r=Ro(t.getFullYear());if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${o}`},st=(e,t,r,n)=>$e(t)?r?r(t,e,"period"):n===void 0?Lc(e,t):yc(e,n).format(t):"",xr=(e,t,r,n)=>st(e,t,r,n),Tc=(e,t)=>{if(!$e(e))return"";$t("formatQuarterLabel",t);const{quarter:r}=Os(e,t);return`${st("year",wt("year",e,t))}-Q${r}`},Pe=(e,t,r,n=0)=>{if($t("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!$e(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${S(t)})`);const o=ut("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=_(r,e[a],n))return 0;if(o>=_(r,e[i],n))return i;for(;a<=i;){const g=a+i>>1,m=_(r,e[g],n);if(m===o)return g;m<o?a=g+1:i=g-1}const s=Math.abs(_(r,e[a],n)-o),d=Math.abs(_(r,e[i],n)-o);return s<d?a:i},Cc=(e,t,r,n,o=0)=>cr("getSortedAllowedDates",Mo(e),t,r,n,o).dates,Mo=e=>({list:e,path:"allowedDates",inheritedBy:null}),cr=(e,t,r,n,o,a)=>{$t(e,a);const{list:i,path:s}=t,d=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(Ea(e,`${s}${d}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[M,U]of[["minDate",n],["maxDate",o]])if(!$e(U))throw new RangeError(`${e}: ${M} must be a valid Date (received: ${S(U)})`);const g=ut(e,"minDate",n,r,a,""),m=ut(e,"maxDate",o,r,a,""),v=new Map;for(let M=0;M<i.length;M++){const U=i[M];if(!$e(U))throw new RangeError(`${e}: ${s}[${M}]${d} must be a valid Date (received: ${S(U)})`);const u=ut(e,`${s}[${M}]${d}`,U,r,a,"");u<g||u>m||v.has(u)||v.set(u,wt(r,U,a))}if(v.size===0)throw new RangeError(`${e}: every ${s} entry${d} falls outside [minDate, maxDate] (minDate: ${S(n)}, maxDate: ${S(o)}, entries: ${i.length})`);const b=Array.from(v.keys()).sort((M,U)=>M-U);return{keys:b,dates:b.map(M=>v.get(M))}},Ta=(e,t,r,n,o,a)=>{const{keys:i,dates:s}=cr(e,t,r,n,o,a);return s.length===0?null:{...Gr(i,null,null),dates:s}},xn=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),Fn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Pe(e,n,t,o);if(r==="time"){const s=e[0].getTime(),d=e[a].getTime()-s;return d<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-s)/d))}return i/a},Bn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const s=e[0].getTime(),d=e[a].getTime()-s;return d<=0?0:Pe(e,new Date(s+i*d),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},ga=(e,t,r,n,o,a,i)=>{let s=r,d=n;return i?(s=t,d=t):e==="low"?t>n?(s=n,d=t):s=t:t<r?(d=r,s=t):d=t,[Math.max(o,Math.min(a,s)),Math.max(o,Math.min(a,d))]},Vs=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:s,unit:d,yearStartMonth:g=0})=>{if(a){const u=i.length-1;if(u<=0)return[0,0];const D=Math.max(0,Math.min(u,Math.round(t))),f=Math.max(D,Math.min(u,Math.round(r)));if(s==="time"){const H=i[0].getTime(),de=i[u].getTime(),Y=i[D].getTime(),re=i[f].getTime()-Y;let oe=Y+e*(de-H),V=oe+re;oe<H&&(oe=H,V=H+re),V>de&&(V=de,oe=de-re);const ne=Pe(i,new Date(oe),d,g),R=Pe(i,new Date(V),d,g);return[ne,Math.max(ne,R)]}const z=Math.round(e*u);let P=D+z,K=f+z;return P<0&&(K+=-P,P=0),K>u&&(P-=K-u,K=u),[Math.max(0,Math.min(u,P)),Math.max(0,Math.min(u,K))]}const m=u=>Math.max(n,Math.min(o,u)),v=o-n;if(v<=0)return[m(t),m(r)];const b=Math.round(e*v);let M=t+b,U=r+b;return M<n&&(U+=n-M,M=n),U>o&&(M-=U-o,U=o),[m(M),m(U)]},_s=(e,t,r,n,o,a,i,s)=>{let d=0,g=!1,m=!1;switch(e){case"ArrowRight":case"ArrowUp":d=s;break;case"ArrowLeft":case"ArrowDown":d=-s;break;case"PageUp":d=s*5;break;case"PageDown":d=-s*5;break;case"Home":g=!0;break;case"End":m=!0;break;default:return null}if(i){let M=r;return g?M=o:m?M=a:M=Math.max(o,Math.min(a,r+d)),[M,M]}let v=r,b=n;return t==="low"?g?v=o:m?v=n:v=Math.max(o,Math.min(n,r+d)):g?b=r:m?b=a:b=Math.max(r,Math.min(a,n+d)),[v,b]},Ys=8,Hs=2,js=16,Ic=12,kc=90,Us=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},Ca=(e,t)=>{const r=t?.estimatedHeightPx??js,o=Ys+(t?.anchorGapY??Hs)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},Ia=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??js,s=o?.paddingPx??Ic,d=o?.maxAngleDeg??kc,g=Ys+(o?.anchorGapY??Hs),m=Ca(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return m;const v=Math.max(0,t-e)/100*r,b=a+s;if(v>=b)return m;const M=Math.max(0,Math.min(1,(b-v)/b)),u=M*M*M*(M*(M*6-15)+10)*d,D=n==="top"?-u:u,f=Us(a,i,u),z=g+f.acrossPx,P=n==="top"?-z:+z,K=2*f.alongPx,H=Math.max(0,(K+s-v)/2);return{lowAngleDeg:D,highAngleDeg:D,lowOffsetX:-H,highOffsetX:H,lowOffsetY:P,highOffsetY:P,isSlanted:M>.001,proximity:M}},zs=e=>({...e,lowOffsetX:0,highOffsetX:0}),St=(e,t)=>{const r=e==="macro"?t.macroAllowedDates:t.microAllowedDates;return r!==void 0?{list:r,path:e==="macro"?"macroAllowedDates":"microAllowedDates",inheritedBy:null}:{list:t.allowedDates,path:"allowedDates",inheritedBy:e}},to=(e,t,r,n)=>e==="pan"?Rc(t,r,Math.max(r,n)):Zn(t,r,Math.max(r,n)),ka=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},Fs=(e,t,r)=>{const n=Math.abs(e)>Math.abs(t)?e:t;return!Number.isFinite(n)||n===0?0:(r?n<0:n>0)?1:-1};function Bs(e,t,r,n,o,a,i="macro-top",s=.05,d=!0,g="range"){if(ka(t,i)==="macro"){const b=Math.abs(e-r),M=Math.abs(e-n);return b<=s&&b<=M?"macro-low":M<=s&&M<b?"macro-high":d&&e>=r&&e<=n?"macro-connect":b<M?"macro-low":"macro-high"}if(g==="point")return"micro-point";const m=Math.abs(e-o),v=Math.abs(e-a);return m<=s&&m<=v?"micro-low":v<=s&&v<m?"micro-high":d&&e>=o&&e<=a?"micro-connect":m<v?"micro-low":"micro-high"}function Ws(e,t,r,n,o){if(e==="macro-connect"){const[g,m]=Pa(t-r,n,o);return[g,m,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,s]=oo(a,t,n,o),d=po(a,t,n,o);return[i,s,d==="low"?"macro-low":"macro-high"]}function Ks(e,t,r,n,o){if(e==="micro-point"){const[g]=oo("point",t,n,o);return[g,g,"micro-point"]}if(e==="micro-connect"){const[g,m]=Pa(t-r,n,o);return[g,m,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,s]=oo(a,t,n,o),d=po(a,t,n,o);return[i,s,d==="low"?"micro-low":"micro-high"]}const mn=l.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",a=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return L.jsx("svg",{className:a,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:L.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});mn.displayName="VernierKnobSvg";const Ac=(e,t,r,n)=>{if(!$e(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${S(e)})`);if(!$e(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${S(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${S(e)}, maxDate: ${S(t)})`);for(const o of r)ut("PeriodSlider","minDate",e,o,n,Cs)},ao=(e,t,r,n="PeriodSlider")=>{if(!Pt(t)||t.length!==2){const i=r?"is required and must":"must";throw new RangeError(`${n}: ${e} ${i} be a [start, end] Date tuple (received: ${S(t)})`)}const[o,a]=t;if(!$e(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${S(o)})`);if(!$e(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${S(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${S(o)}, end: ${S(a)})`)},Gs=(e,t)=>{if(!$e(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${S(t)})`)},zr=(e,t,r,n,o,a)=>{const i=ut("PeriodSlider",e,t,r,a,"");if(i<_(r,n,a)||i>_(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${S(t)}, minDate: ${S(n)}, maxDate: ${S(o)})`)},Nc=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(ao(o,a,!1),zr(`${o}[0]`,a[0],e.unit,t,r,n),zr(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(Gs(o,a),zr(o,a,e.unit,t,r,n))}},Oc=(e,t,r)=>{const n=e.yearStartMonth??0;ao("macroRange",e.macroRange,!0),ut("PeriodSlider","macroRange[0]",e.macroRange[0],e.macroUnit??e.unit,n,"");const o=e.microUnit??e.unit,a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,i=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&i)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(i){for(const g of["microValue","defaultMicroValue"]){const m=e[g];m!==void 0&&(Gs(g,m),zr(g,m,o,t,r,n))}const d=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(d===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[d,d]}}for(const d of["microRange","defaultMicroRange"]){const g=e[d];g!==void 0&&(ao(d,g,!1),zr(`${d}[0]`,g[0],o,t,r,n),zr(`${d}[1]`,g[1],o,t,r,n))}const s=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(s!==void 0)return{shape:"range",selection:s};throw a?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},ln=(e,t,r,n,o,a,i,s,d)=>{const g=Pe(e,n,t,d),m=Pe(e,o,t,d);return i?g:s?m:Math.max(g,Math.min(m,Pe(e,r,t,d)+a))},oa=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Wi=()=>{const[e,t]=l.useState(null),r=l.useRef(null),n=l.useCallback((a,i)=>{const s=r.current;if(s!==null&&s[0].getTime()===a.getTime()&&s[1].getTime()===i.getTime())return;const d=[a,i];r.current=d,t(d)},[]),o=l.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Vc=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${S(t)})`)}},jr=()=>{const[e,t]=l.useState(null),r=l.useRef(null),n=l.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const s of i){const d=s.borderBoxSize?.[0];d!==void 0&&t(g=>g!==null&&Math.abs(g.widthPx-d.inlineSize)<.5&&Math.abs(g.heightPx-d.blockSize)<.5?g:{widthPx:d.inlineSize,heightPx:d.blockSize})}});a.observe(o),r.current=a},[]);return l.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},aa=(e,t)=>{const r=ro(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},ro=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},_c=e=>{const t={};let r=0;for(const o of e){const{side:a,box:i}=o;if(i===null)continue;let s;if(o.reach==="inline-size")s=i.widthPx,r=Math.max(r,i.heightPx/2);else{const d=Us(i.widthPx,i.heightPx,o.angleDeg);s=o.centreOffsetPx===null?2*d.acrossPx:Math.abs(o.centreOffsetPx)+d.acrossPx,r=Math.max(r,d.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${Math.ceil(s)}px`}if(Object.keys(t).length===0)return;const n=Math.ceil(r);return t["--ps-label-reach-main"]=`${n}px`,{style:t,mainPx:n}},Ki=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),Gi=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),io=(e,t)=>({"--ps-tooltip-tx":Jo(e,"tx",t.tx),"--ps-tooltip-ty":Jo(e,"ty",t.ty),"--ps-tooltip-rot":Jo(e,"rot",t.rot)}),ia=(e,t,r,n)=>{const o=Ca(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=Ia(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?zs(a):a,s=bo[e],d={low:Ki(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:Ki(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:io(s.low,d.low),highStyle:io(s.high,d.high),placements:d}},qi={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Xi=(e,t,r)=>{const n=Ca(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:qi,highStyle:qi,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const d=Ia(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?zs(d):d}const i=bo.flat,s={low:Gi(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:Gi(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...io(i.low,s.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...io(i.high,s.high)},placements:o?s:null}},Yc={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Hc={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},Zi={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},jc={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${hn} ${ji.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Zi.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${hn} ${ji.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Zi.vertical}`}},Qi={horizontal:{leading:"col-start-1 row-start-1",rail:"col-start-2 row-start-1",railOnly:"col-start-1 row-start-1",trailing:"col-start-3 row-start-1"},vertical:{leading:"col-start-1 row-start-1",rail:"col-start-1 row-start-2",railOnly:"col-start-1 row-start-1",trailing:"col-start-1 row-start-3"}},Ji=(e,t)=>{e.setPointerCapture(t)},Uc=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:s="",showStepper:d=!0,tooltipStyle:g="always",labelPosition:m="top",autoSlantLabels:v=!0,isVertical:b=!1,hideConnectBar:M=!1,showTicks:U=!1,colorScheme:u="blue-rose",formatLocale:D}=e,f=dr("PeriodSlider",e.yearStartMonth);Ac(r,n,e.mode==="vernier"?[e.macroUnit??t,e.microUnit??t,t]:[t],f),Nc(e,r,n),D!==void 0&&Vc("formatLocale",D);const z=e.mode==="vernier"?Oc(e,r,n):null,P=z!==null&&z.shape==="point",K=So(e.locale,e.labels),H=$s[u],de=l.useId(),Y=l.useRef(e),re=r.getTime(),oe=n.getTime(),V=l.useMemo(()=>cr("PeriodSlider",Mo(o),t,r,n,f).dates,[o,t,re,oe,f]),ne=V.length>0,{rangeMin:R,rangeMax:E}=l.useMemo(()=>ne?{rangeMin:0,rangeMax:V.length-1}:{rangeMin:_(t,r,f),rangeMax:_(t,n,f)},[ne,V,t,re,oe,f]),$=e.mode==="point",W=l.useCallback(c=>{if(ne){const w=Math.max(0,Math.min(V.length-1,Math.round(c)));return V[w]}return ee(t,Math.round(c),f)},[ne,V,t,f]),J=l.useCallback(c=>{if(c===void 0)return R;const w=wt(t,c,f);return ne?Pe(V,w,t,f):_(t,w,f)},[ne,V,t,R,f]),[F,G]=l.useState(()=>z===null?null:z.selection);let k=F??(z===null?null:z.selection);if(P&&k!==null&&k[0].getTime()!==k[1].getTime()){const c=[k[0],k[0]];k=c,G(c)}const ie=e.mode==="vernier"?e.microValue?.getTime():void 0,we=l.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,ie]),Se=Wi(),q=Wi(),A=e.mode!=="vernier"?null:P?we??k:e.microRange!==void 0?e.microRange:k,ge=A===null?null:q.shown??A,ue=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ge?.[0]:void 0,ae=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ge?.[1]:void 0,I=e.mode==="point"?e.value??e.defaultValue:void 0,he=e.mode==="point"?I?.getTime():ue?.getTime(),fe=e.mode==="range"?ae?.getTime():he,[De,be]=l.useMemo(()=>{if(e.mode==="point"){const p=J(I);return[p,p]}const c=J(ue),w=J(ae);return[Math.min(c,w),Math.max(c,w)]},[e.mode,he,fe,J,I,ue,ae]),pe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:P?e.microValue!==void 0:e.microRange!==void 0,[Oe,Te]=l.useState(()=>[De,be]),[Ze,ot]=l.useState(null),[Le,Q]=l.useState(null),Ye=l.useRef(null),[Rt,ze]=l.useState("high"),[Fe,qe]=l.useState(null),[Qe,ft]=l.useState(null),ve=Ze?Ze[0]:pe?De:Oe[0],ye=Ze?Ze[1]:pe?be:Oe[1],T=l.useRef([ve,ye]),C=e.mode==="vernier",Ve=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",O=Ve==="macro-top"||Ve==="macro-left",Je=e.mode==="vernier"?e.showVernierProjection??!0:!1,Lt=e.mode==="vernier"?e.showVernierTicks??!0:!1,jt=e.mode==="vernier"?e.showHairline??!0:!1,te=C?e.macroUnit??t:t,h=C?e.microUnit??t:t,se=C?e.macroIsDiscrete??!1:ne,Re=C?e.microIsDiscrete??!1:ne,Be=C?St("macro",e).list:o,y=C?St("micro",e).list:o,j=C?e.formatMacroLabel??e.formatLabel:e.formatLabel,le=C?e.formatMicroLabel??e.formatLabel:e.formatLabel,He=ue?.getTime(),_e=ae?.getTime(),[Me,je]=l.useState(null),et=l.useRef(null),[bt,Ut]=l.useState(()=>P?"micro-point":"micro-high");let We=bt;const Po=P?bt==="micro-low"||bt==="micro-high"||bt==="micro-connect"?"micro-point":null:bt==="micro-point"?"micro-high":null;Po!==null&&(We=Po,Ut(Po));const gt=l.useMemo(()=>_(te,r,f),[re,te,f]),Tt=l.useMemo(()=>_(te,n,f),[oe,te,f]),ke=l.useMemo(()=>C&&se?cr("PeriodSlider",St("macro",e),te,r,n,f).dates:[],[C,se,Be,te,re,oe,f]),Ya=c=>[Math.max(gt,Math.min(Tt,_(te,c[0],f))),Math.max(gt,Math.min(Tt,_(te,c[1],f)))],[Ha,ja]=e.mode!=="vernier"?[gt,Tt]:Ya(e.macroRange),[tt,lt]=Se.shown===null?[Ha,ja]:Ya(Se.shown),mr=l.useMemo(()=>ee(te,tt,f),[te,tt,f]),fr=l.useMemo(()=>ee(te,lt,f),[te,lt,f]),yn=l.useMemo(()=>e.mode!=="vernier"?[r,n]:Dt(te,h,[mr,fr],r,n,f),[e.mode,mr,fr,te,h,re,oe,f]),Ue=l.useMemo(()=>_(h,yn[0],f),[h,yn,f]),at=l.useMemo(()=>_(h,yn[1],f),[h,yn,f]),Pn=l.useMemo(()=>C&&Re?Ta("PeriodSlider",St("micro",e),h,r,n,f):null,[C,Re,y,h,re,oe,f]),$o=(c,w)=>Pn===null?[]:xn(Pn,Gr(Pn.ascending,c,w)),xe=l.useMemo(()=>$o(Ue,at),[Pn,Ue,at]),Zt=se&&ke.length>0,Mt=Re&&xe.length>0,Ua=Zt?_(te,ke[0],f):gt,za=Zt?_(te,ke[ke.length-1],f):Tt,Fa=Mt?_(h,xe[0],f):Ue,Lo=Mt?_(h,xe[xe.length-1],f):at,ul=Math.min(Ua,tt),dl=Math.max(za,lt),Qt=(c,w,p,x)=>w.length>0?_(h,w[Pe(w,c,h,f)],f):Math.max(p,Math.min(x,_(h,c,f))),Er=Mt?xe:[],Ke=l.useMemo(()=>ge===null?Ue:Qt(ge[0],Er,Ue,at),[He,Ue,at,h,ge,Er]),it=l.useMemo(()=>ge===null?at:Qt(ge[1],Er,Ue,at),[_e,Ue,at,h,ge,Er]),yr=l.useMemo(()=>ee(h,Ke,f),[h,Ke,f]),Pr=l.useMemo(()=>ee(h,it,f),[h,it,f]),Ba=!C||A===null?null:{macroUnit:te,macroLowEnc:Ha,macroHighEnc:ja,microUnit:h,microLowEnc:_(h,A[0],f),microHighEnc:_(h,A[1],f)},To=l.useRef(Ba),Co=Math.max(1,Tt-gt),Et=Zt?Fn(ke,te,a,mr,f):Math.max(0,Math.min(1,(tt-gt)/Co)),Ct=Math.max(Et,Zt?Fn(ke,te,a,fr,f):Math.min(1,(lt-gt)/Co)),Wa=c=>Math.max(Ua,Math.min(za,Math.round(gt+c*Co))),$n=Math.max(1,at-Ue),$r=Mt?Fn(xe,h,a,yr,f):Math.max(0,Math.min(1,(Ke-Ue)/$n)),qr=Math.max($r,Mt?Fn(xe,h,a,Pr,f):Math.min(1,(it-Ue)/$n)),Io=l.useRef({timerId:null,emit:null}),Ln=l.useRef({timerId:null,emit:null}),Tn=l.useRef({timerId:null,emit:null});l.useEffect(()=>{const c=[Io,Ln,Tn];return()=>{for(const w of c)oa(w.current)}},[]);const Lr=l.useCallback((c,w,p)=>{oa(c);const{debounceMs:x}=Y.current;if(p||!x||x<=0){w();return}c.emit=w,c.timerId=setTimeout(()=>{c.timerId=null,c.emit=null,w()},x)},[]),Ka=l.useCallback(c=>{const w=c.emit;oa(c),w?.()},[]),Tr=l.useCallback(c=>new Date(Math.min(Math.max(c.getTime(),re),oe)),[re,oe]),Jt=l.useCallback((c,w,p=!1)=>{const[x,N]=T.current;if((Y.current.mode==="point"?c===x:c===x&&w===N)&&Io.current.timerId===null)return;const Z=W(c),X=W(w),me=()=>{const Ee=Y.current;Ee.mode==="point"?Ee.onChangePoint?.(Z):Ee.mode==="range"&&Ee.onChangeRange?.(Z,X)};Lr(Io.current,me,p)},[W,Lr]),gr=l.useCallback((c,w,p=!1)=>{const x=To.current;if(Y.current.mode!=="vernier"||x===null)return;const N=Tr(c),B=Tr(w);_(x.macroUnit,N,f)===x.macroLowEnc&&_(x.macroUnit,B,f)===x.macroHighEnc&&Ln.current.timerId===null||Lr(Ln.current,()=>{const Z=Y.current;Z.mode==="vernier"&&Z.onChangeMacroRange?.(N,B)},p)},[Tr,Lr,f]),pt=l.useCallback((c,w,p=!1)=>{const x=Y.current,N=To.current;if(x.mode!=="vernier"||N===null)return;const B=Tr(c),Z=Tr(w);_(N.microUnit,B,f)===N.microLowEnc&&_(N.microUnit,Z,f)===N.microHighEnc&&Tn.current.timerId===null||((P?x.microValue===void 0:x.microRange===void 0)&&G([B,Z]),Lr(Tn.current,()=>{const X=Y.current;if(X.mode==="vernier"){if(P){X.onChangeMicroPoint?.(B);return}X.onChangeMicroRange?.(B,Z)}},p))},[Tr,Lr,P,f]),Ga=l.useCallback((c,w=!1)=>{pt(c,c,w)},[pt]),hr=l.useCallback(c=>{if(ne&&a==="time"&&V.length>1){const x=Math.max(0,Math.min(V.length-1,Math.round(c))),N=V[0].getTime(),Z=V[V.length-1].getTime()-N;if(Z<=0)return 0;const X=V[x].getTime();return Math.max(0,Math.min(100,(X-N)/Z*100))}const w=E-R;if(w<=0)return 0;const p=(c-R)/w*100;return Math.max(0,Math.min(100,p))},[ne,a,V,R,E]),ko=l.useCallback(c=>{const w=Math.max(0,Math.min(100,c));if(ne){if(a==="time"&&V.length>1){const N=V[0].getTime(),Z=V[V.length-1].getTime()-N,X=N+w/100*Z;return Pe(V,new Date(X),t,f)}const x=Math.round(w/100*(V.length-1));return Math.max(0,Math.min(V.length-1,x))}const p=R+w/100*(E-R);return Math.round(p)},[ne,a,V,R,E,t,f]),Xr=l.useRef(null),qa=l.useRef(null),Xa=l.useRef(0),mt=l.useRef(null),Ao=l.useRef(null),Za=l.useRef(null),Qa=l.useRef(null),[No,Ja]=l.useState(0),[ml,Cr]=jr(),[fl,ei]=jr(),[gl,ti]=jr(),[hl,ri]=jr(),[wl,Oo]=jr(),[bl,ni]=jr(),pl=$?Cr===null?void 0:{estimatedWidthPx:Cr.widthPx,estimatedHeightPx:Cr.heightPx}:aa(Cr,ei),Vo=!$&&ve===ye,_o=tt===lt,Yo=!P&&Ke===it,vl=O?"top":"bottom",xl=O?"bottom":"top",oi=v&&!b,Sl=oi&&!P,Ho={isPointMode:$,isVertical:b,autoSlantLabels:v,isMerged:Vo,trackLengthPx:No,labelPosition:m,config:pl},jo={trackLengthPx:No,labelPosition:vl,config:aa(ti,ri),isMerged:_o,isSlantable:oi},Uo={trackLengthPx:No,labelPosition:xl,config:aa(Oo,ni),isMerged:Yo,isSlantable:Sl};l.useEffect(()=>{const c=mt.current;if(!c)return;const w=()=>{const x=c.getBoundingClientRect(),N=b?x.height:x.width;N>0&&Ja(B=>Math.abs(B-N)<.5?B:N)};if(w(),typeof ResizeObserver<"u"){const x=new ResizeObserver(N=>{for(const B of N){const Z=b?B.contentRect.height:B.contentRect.width;Z>0&&Ja(X=>Math.abs(X-Z)<.5?X:Z)}});return x.observe(c),()=>x.disconnect()}const p=c.ownerDocument.defaultView;if(p)return p.addEventListener("resize",w),()=>p.removeEventListener("resize",w)},[b]);const Ir=l.useCallback((c,w,p)=>{const x=b?p.height:p.width;if(!(Number.isFinite(x)&&x>0))return null;const N=b?p.bottom-w:c-p.left;return Number.isFinite(N)?Math.max(0,Math.min(1,N/x)):null},[b]),ai=l.useCallback((c,w)=>{const p=mt.current;if(!p)return null;const x=Ir(c,w,p.getBoundingClientRect());return x===null?null:x*100},[Ir]),Zr=l.useRef(null),zt=l.useRef(null),Cn=l.useRef({macroLowRatio:Et,macroHighRatio:Ct,isVertical:b,isMacroFirstRail:O}),ii=l.useRef({flat:Ho,macro:jo,micro:Uo});l.useLayoutEffect(()=>{Cn.current={macroLowRatio:Et,macroHighRatio:Ct,isVertical:b,isMacroFirstRail:O},ii.current={flat:Ho,macro:jo,micro:Uo},Y.current=e,T.current=[ve,ye],To.current=Ba,Ye.current=Le,et.current=Me});const si=(c,w)=>{const p=Cn.current;Ao.current?.setAttribute("d",ea(c,w,p.isVertical,p.isMacroFirstRail))},Dl=(c,w,p)=>{const x=ii.current;return c==="flat"?Xi(w*100,p*100,x.flat).placements:ia(c,w,p,c==="macro"?x.macro:x.micro).placements},Qr=(c,w,p)=>{const x=mt.current;if(!x)return;Zr.current={rail:c,lowRatio:w,highRatio:p},tc(x,c,w,p);const N=Dl(c,w,p);N!==null&&ec(x,c,N),c==="macro"&&si(w,p)},wr=l.useCallback(()=>{zt.current!==null&&(clearTimeout(zt.current),zt.current=null);const c=mt.current;c&&(c.removeAttribute(Zo),c.style.removeProperty(Qo))},[]),li=()=>{const c=mt.current;if(Zr.current===null||!c){Zr.current=null;return}Zr.current=null,zt.current!==null&&clearTimeout(zt.current),c.style.setProperty(Qo,`${Vi}ms`),c.setAttribute(Zo,"true"),rc(c),si(Cn.current.macroLowRatio,Cn.current.macroHighRatio),zt.current=setTimeout(()=>{zt.current=null,c.removeAttribute(Zo),c.style.removeProperty(Qo)},Vi)};l.useLayoutEffect(()=>{const c=Zr.current;c!==null&&Qr(c.rail,c.lowRatio,c.highRatio)}),l.useEffect(()=>()=>{zt.current!==null&&clearTimeout(zt.current)},[]);const kr=l.useRef(null),Ar=l.useRef(null),It=l.useRef(null),zo=l.useRef(null),Jr=l.useRef(null),er=l.useCallback(()=>kr.current!==null||Ar.current!==null,[]),ci=c=>{if(i)return;if(C){const ce=Ar.current;if(!ce||c.pointerId!==ce.pointerId||!mt.current)return;const yt=Ir(c.clientX,c.clientY,mt.current.getBoundingClientRect());if(yt===null)return;if(ce.handle==="macro-low"||ce.handle==="macro-high"||ce.handle==="macro-connect"){const[rt,Ge,Ft]=Ws(ce.handle,yt,ce.startPointerRatio,ce.startMacroLowRatio,ce.startMacroHighRatio);Qr("macro",rt,Ge),Ft!==et.current&&(et.current=Ft,je(Ft),Ut(Ft));let At,ht,Bt;if(Zt){const Wt=Bn(ke,te,a,rt,f),an=Math.max(Wt,Bn(ke,te,a,Ge,f));ht=ke[Wt],Bt=ke[an],At=_(te,ht,f)}else At=Wa(rt),ht=ee(te,At,f),Bt=ee(te,Wa(Ge),f);Se.show(ht,Bt);const tr=`${ht.getTime()}_${Bt.getTime()}`;tr!==zo.current&&(zo.current=tr,gr(ht,Bt));const[on,Kl]=Dt(te,h,[ht,Bt],r,n,f),Hn=_(h,on,f),jn=_(h,Kl,f),ki=Re?$o(Hn,jn):[],Ai={kind:"range",min:Hn,max:jn};let pr,vr;if(ce.handle==="macro-connect"){const Wt=At-ce.startMacroLowEnc,an=to("pan",Ai,zi(h,ce.initialMicroLowEnc,te,Wt,f),zi(h,ce.initialMicroHighEnc,te,Wt,f));if(an===null)return;pr=ee(h,an[0],f),vr=ee(h,an[1],f)}else{const Wt=to("resize",Ai,ce.initialMicroLowEnc,ce.initialMicroHighEnc);if(Wt===null)return;pr=ee(h,Wt[0],f),vr=ee(h,Wt[1],f)}const Ni=Qt(pr,ki,Hn,jn),Gl=Math.max(Ni,Qt(vr,ki,Hn,jn));pr=ee(h,Ni,f),vr=ee(h,Gl,f),q.show(pr,vr);const Oi=`${pr.getTime()}_${vr.getTime()}`;Oi!==Jr.current&&(Jr.current=Oi,pt(pr,vr))}else if(ce.handle==="micro-low"||ce.handle==="micro-high"||ce.handle==="micro-connect"||ce.handle==="micro-point"){const[rt,Ge,Ft]=Ks(ce.handle,yt,ce.startPointerRatio,ce.startMicroLowRatio,ce.startMicroHighRatio);Qr("micro",rt,Ge),Ft!==et.current&&(et.current=Ft,je(Ft),Ut(Ft));let At,ht;if(Mt){const tr=Bn(xe,h,a,rt,f),on=Math.max(tr,Bn(xe,h,a,Ge,f));At=xe[tr],ht=xe[on]}else{const tr=Qt(ee(h,Math.round(Ue+rt*$n),f),Er,Ue,at),on=Math.max(tr,Qt(ee(h,Math.round(Ue+Ge*$n),f),Er,Ue,at));At=ee(h,tr,f),ht=ee(h,on,f)}q.show(At,ht);const Bt=`${At.getTime()}_${ht.getTime()}`;Bt!==Jr.current&&(Jr.current=Bt,pt(At,ht))}return}const w=kr.current;if(!w||c.pointerId!==w.pointerId||!mt.current)return;const p=mt.current.getBoundingClientRect(),x=b?c.clientY:c.clientX,N=b?p.height:p.width;if(!(Number.isFinite(N)&&N>0))return;if(w.handle==="connect"){const ce=b?(w.startPointerPos-x)/N:(x-w.startPointerPos)/N,[yt,rt]=Pa(ce,w.startLowRatio,w.startHighRatio);Qr("flat",yt,rt);const Ge=Vs({posDiffPct:ce,startLowVal:w.startLowVal,startHighVal:w.startHighVal,rangeMin:R,rangeMax:E,isDiscrete:ne,sortedAllowedDates:V,snapMode:a,unit:t,yearStartMonth:f});if(It.current&&It.current[0]===Ge[0]&&It.current[1]===Ge[1])return;It.current=Ge,ot(Ge),Jt(Ge[0],Ge[1],!1);return}const B=Ir(c.clientX,c.clientY,p);if(B===null)return;const[Z,X]=oo($?"point":w.handle,B,w.startLowRatio,w.startHighRatio);Qr("flat",Z,X);const me=ko(B*100),[Ee,Ae]=ga(w.handle,me,w.startLowVal,w.startHighVal,R,E,$);if((!It.current||It.current[0]!==Ee||It.current[1]!==Ae)&&(It.current=[Ee,Ae],ot([Ee,Ae]),Jt(Ee,Ae,!1)),!$&&(w.handle==="low"||w.handle==="high")){const ce=po(w.handle,B,w.startLowRatio,w.startHighRatio);Ye.current!==ce&&(Ye.current=ce,Q(ce),ze(ce))}},ui=()=>{li(),zo.current=null,Jr.current=null,Ar.current=null,et.current=null,je(null),Se.release(),q.release(),Ka(Ln.current),Ka(Tn.current)},di=()=>{li();const c=It.current??Ze;c&&(Jt(c[0],c[1],!0),Te(c)),It.current=null,ot(null),kr.current=null,Ye.current=null,Q(null)},mi=c=>{if(C){const p=Ar.current;if(!p||c.pointerId!==p.pointerId)return;ui();return}const w=kr.current;!w||c.pointerId!==w.pointerId||di()},fi=()=>{Ar.current!==null&&ui(),kr.current!==null&&di()},Fo=l.useRef(ci),gi=l.useRef(mi),hi=l.useRef(fi);l.useLayoutEffect(()=>{Fo.current=ci,gi.current=mi,hi.current=fi});const wi=l.useRef(C);l.useEffect(()=>{wi.current!==C&&(wi.current=C,hi.current())},[C]);const bi=Le!==null||Me!==null;l.useEffect(()=>{if(!bi)return;const c=Xr.current?.ownerDocument.defaultView;if(!c)return;const w=x=>Fo.current(x),p=x=>gi.current(x);return c.addEventListener("pointermove",w),c.addEventListener("pointerup",p),c.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p),()=>{c.removeEventListener("pointermove",w),c.removeEventListener("pointerup",p),c.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p)}},[bi]);const Bo=l.useCallback((c,w,p,x)=>{wr(),Ji(c,w),kr.current={pointerId:w,handle:p,startPointerPos:x,startLowVal:ve,startHighVal:ye,startLowRatio:hr(ve)/100,startHighRatio:hr(ye)/100},Ye.current=p,Q(p),p!=="connect"&&ze(p)},[ve,ye,hr]),pi=l.useCallback((c,w,p,x)=>{Y.current.mode==="vernier"&&(wr(),Ji(c,w),Ar.current={pointerId:w,handle:p,startPointerRatio:x,startMacroLowRatio:Et,startMacroHighRatio:Ct,startMicroLowRatio:$r,startMicroHighRatio:qr,startMacroLowEnc:tt,initialMicroLowEnc:Ke,initialMicroHighEnc:it},et.current=p,je(p),Ut(p))},[Et,Ct,$r,qr,tt,Ke,it]),vi=c=>w=>{if(i||er())return;w.stopPropagation(),w.preventDefault(),ze(c);const p=b?w.clientY:w.clientX;Bo(w.currentTarget,w.pointerId,c,p)},xi=c=>()=>{i||Ye.current!==null||ze(c)},In=c=>()=>{i||et.current!==null||Ut(c)},Nr=c=>w=>{if(i||er())return;w.stopPropagation(),w.preventDefault();const p=mt.current;if(!p)return;const x=Ir(w.clientX,w.clientY,p.getBoundingClientRect());x!==null&&pi(w.currentTarget,w.pointerId,c,x)},Rl=c=>{if(i||M||er())return;c.stopPropagation(),c.preventDefault();const w=b?c.clientY:c.clientX;Bo(c.currentTarget,c.pointerId,"connect",w)},Ml=c=>{if(i||er())return;if(C){const X=mt.current;if(!X)return;const me=X.getBoundingClientRect(),Ee=Ir(c.clientX,c.clientY,me);if(Ee===null)return;const Ae=b?c.clientX-(me.left+me.width/2):c.clientY-(me.top+me.height/2),ce=Bs(Ee,Ae,Et,Ct,$r,qr,Ve,void 0,!M,P?"point":"range");pi(c.currentTarget,c.pointerId,ce,Ee),Fo.current(c.nativeEvent);return}const w=ai(c.clientX,c.clientY);if(w===null)return;const p=ko(w);let x="low";if(!$){const X=Math.abs(p-ve),me=Math.abs(p-ye);X<me?x="low":me<X?x="high":x=p>ye?"high":"low"}ze(x);const[N,B]=ga(x,p,ve,ye,R,E,$);ot([N,B]),Jt(N,B,!0);const Z=b?c.clientY:c.clientX;Bo(c.currentTarget,c.pointerId,x,Z)},El=c=>{if(i||C||Le!==null)return;const w=ai(c.clientX,c.clientY);if(w===null)return;const p=ko(w);qe(p),ft(hr(p))},yl=()=>{qe(null),ft(null)},Si=c=>w=>{if(i||er())return;ze(c);const p=_s(w.key,c,ve,ye,R,E,$,1);p&&(w.preventDefault(),wr(),pe||Te(p),Jt(p[0],p[1],!0))},Or=(c,w,p)=>{if(A===null)return;const[x,N]=Dt(te,h,[c,w],r,n,f),B=_(h,x,f),Z=_(h,N,f),X=Re?$o(B,Z):[],me=to(p,{kind:"range",min:B,max:Z},_(h,A[0],f),_(h,A[1],f));if(me===null)return;const Ee=Qt(ee(h,me[0],f),X,B,Z),Ae=Math.max(Ee,Qt(ee(h,me[1],f),X,B,Z));pt(ee(h,Ee,f),ee(h,Ae,f),!0)},kn=c=>w=>{if(i||!C||e.mode!=="vernier"||er())return;Ut(c);let p=0,x=!1,N=!1;switch(w.key){case"ArrowRight":case"ArrowUp":p=1;break;case"ArrowLeft":case"ArrowDown":p=-1;break;case"PageUp":p=5;break;case"PageDown":p=-5;break;case"Home":x=!0;break;case"End":N=!0;break;default:return}if(w.preventDefault(),wr(),c==="macro-low"){const B=ee(te,tt,f),Z=ee(te,lt,f);if(Zt){const Ee=ln(ke,te,B,ke[0],Z,p,x,N,f);if(Ee===Pe(ke,B,te,f))return;const Ae=ke[Ee];gr(Ae,Z,!0),Or(Ae,Z,"resize");return}let X;if(x?X=gt:N?X=lt:X=Math.max(gt,Math.min(lt,tt+p)),X===tt)return;const me=ee(te,X,f);gr(me,Z,!0),Or(me,Z,"resize")}else if(c==="macro-high"){const B=ee(te,tt,f),Z=ee(te,lt,f);if(Zt){const Ee=ln(ke,te,Z,B,ke[ke.length-1],p,x,N,f);if(Ee===Pe(ke,Z,te,f))return;const Ae=ke[Ee];gr(B,Ae,!0),Or(B,Ae,"resize");return}let X;if(x?X=tt:N?X=Tt:X=Math.max(tt,Math.min(Tt,lt+p)),X===lt)return;const me=ee(te,X,f);gr(B,me,!0),Or(B,me,"resize")}else if(c==="micro-low"){const B=ee(h,Ke,f),Z=ee(h,it,f);if(Mt){const me=ln(xe,h,B,xe[0],Z,p,x,N,f);if(me===Pe(xe,B,h,f))return;pt(xe[me],Z,!0);return}let X;if(x?X=Ue:N?X=it:X=Math.max(Ue,Math.min(it,Ke+p)),X===Ke)return;pt(ee(h,X,f),Z,!0)}else if(c==="micro-high"){const B=ee(h,Ke,f),Z=ee(h,it,f);if(Mt){const me=ln(xe,h,Z,B,xe[xe.length-1],p,x,N,f);if(me===Pe(xe,Z,h,f))return;pt(B,xe[me],!0);return}let X;if(x?X=Ke:N?X=at:X=Math.max(Ke,Math.min(at,it+p)),X===it)return;pt(B,ee(h,X,f),!0)}else if(c==="micro-point"){const B=ee(h,Ke,f);if(Mt){const X=ln(xe,h,B,xe[0],xe[xe.length-1],p,x,N,f);if(X===Pe(xe,B,h,f))return;Ga(xe[X],!0);return}let Z;if(x?Z=Ue:N?Z=at:Z=Math.max(Ue,Math.min(at,Ke+p)),Z===Ke)return;Ga(ee(h,Z,f),!0)}},Pl=c=>{if(e.mode!=="vernier")return;if(wr(),Zt){const Z=ke.length-1,X=Pe(ke,mr,te,f),me=Pe(ke,fr,te,f),Ee=me-X;let Ae=X+c,ce=me+c;if(c<0&&Ae<0?(Ae=0,ce=Math.min(Z,Ee)):c>0&&ce>Z&&(ce=Z,Ae=Math.max(0,Z-Ee)),Ae===X&&ce===me)return;const yt=ke[Ae],rt=ke[ce];gr(yt,rt,!0),Or(yt,rt,"pan");return}const w=lt-tt;let p=tt+c,x=lt+c;if(c<0&&p<gt?(p=gt,x=Math.min(Tt,p+w)):c>0&&x>Tt&&(x=Tt,p=Math.max(gt,x-w)),p===tt&&x===lt)return;const N=ee(te,p,f),B=ee(te,x,f);gr(N,B,!0),Or(N,B,"pan")},Wo=l.useCallback(c=>{const w=Y.current;if(!(w.disabled||er()))if(wr(),w.mode==="point"){const p=Math.max(R,Math.min(E,ve+c));pe||Te([p,p]),Jt(p,p,!0)}else if(w.mode==="vernier"){if(Mt){const Ee=xe.length-1,Ae=Pe(xe,yr,h,f),ce=Pe(xe,Pr,h,f),yt=ce-Ae;let rt=Ae+c,Ge=ce+c;c<0&&rt<0?(rt=0,Ge=Math.min(Ee,yt)):c>0&&Ge>Ee&&(Ge=Ee,rt=Math.max(0,Ee-yt)),(rt!==Ae||Ge!==ce)&&pt(xe[rt],xe[Ge],!0);return}const p=Ke,x=it,N=Ue,B=at,Z=x-p;let X=p+c,me=x+c;c<0&&X<N?(X=N,me=Math.min(B,X+Z)):c>0&&me>B&&(me=B,X=Math.max(N,me-Z)),(X!==p||me!==x)&&pt(ee(h,X,f),ee(h,me,f),!0)}else{const p=ye-ve;let x=ve+c,N=ye+c;c<0&&x<R?(x=R,N=Math.min(E,x+p)):c>0&&N>E&&(N=E,x=Math.max(R,N-p)),x<=N&&(pe||Te([x,N]),Jt(x,N,!0))}},[ve,ye,R,E,pe,Jt,pt,Ke,it,Ue,at,h,Mt,xe,yr,Pr,wr,f]),Di=c=>!i&&ta(Xr.current,c),Ri=(c,w)=>{const p=qa.current,x=mt.current,N=Xr.current;if(i||p===null||x===null||N===null||!fc(p,N,Xa.current,b,c,w))return null;const B=x.getBoundingClientRect();return Math.abs(b?c-(B.left+B.width/2):w-(B.top+B.height/2))},Mi=c=>{if(i||er())return;const w=Fs(c.deltaX,c.deltaY,b);if(w===0)return;c.preventDefault();const p=c.target,x=ta(Za.current,p)||ta(Qa.current,p);if(!C||x){Wo(w);return}const N=mt.current;if(!N)return;const B=N.getBoundingClientRect(),Z=b?c.clientX-(B.left+B.width/2):c.clientY-(B.top+B.height/2);if(ka(Z,Ve)==="macro"){Pl(w);return}Wo(w)},An=l.useRef({ownsWheelHit:Di,distanceToRailPx:Ri,stepFromRangeAreaWheel:Mi});l.useLayoutEffect(()=>{An.current={ownsWheelHit:Di,distanceToRailPx:Ri,stepFromRangeAreaWheel:Mi}});const en=l.useRef(null);l.useEffect(()=>{const c=Xr.current?.ownerDocument.defaultView??null,w=en.current;if(w!==null&&w.view===c)return;if(w?.unregister(),c===null){en.current=null;return}const p=hc(c,{ownsHit:x=>An.current.ownsWheelHit(x),distanceToRailPx:(x,N)=>An.current.distanceToRailPx(x,N),step:x=>An.current.stepFromRangeAreaWheel(x)});en.current={view:c,unregister:p}}),l.useEffect(()=>()=>{en.current?.unregister(),en.current=null},[]);const Nn=hr(ve),On=hr(ye),Ko=W(ve),Go=W(ye),qo=Xi(Nn,On,Ho),tn=qo.slant,rn=Le==="low"||Le!=="high"&&Rt==="low",nn=!$&&(Le==="high"||Le!=="low"&&Rt==="high"),$l=_o&&We!=="macro-low",Ll=_o&&We==="macro-low",Tl=Yo&&We!=="micro-low",Cl=Yo&&We==="micro-low",Vr=ia("macro",Et,Ct,jo),_r=ia("micro",$r,qr,Uo),Il=Math.min(Nn,On),kl=Math.max(Nn,On),[Ei,yi]=gn.flat,[Al,Nl]=gn.macro,[Ol,Vl]=gn.micro,Pi=rr(Ei,Nn),$i=rr(yi,On),Xo=rr(Ei,Il),Li=`calc(${rr(yi,kl)} - ${Xo})`,Yr=rr(Al,Et*100),Vn=rr(Nl,Ct*100),Hr=rr(Ol,$r*100),_n=rr(Vl,qr*100),_l=b?{bottom:Xo,height:Li,top:"auto",left:"0",right:"0"}:{left:Xo,width:Li,top:"0",bottom:"0"},Yl=Math.max(.01,Ct-Et),Ti=Math.max(.06,Math.min(.25,.28*Math.sqrt(Yl))),Hl=b?{bottom:Pi,left:"50%",transform:"translate(-50%, 50%)",zIndex:rn?40:30}:{left:Pi,top:"50%",transform:"translate(-50%, -50%)",zIndex:rn?40:30},jl=b?{bottom:$i,left:"50%",transform:"translate(-50%, 50%)",zIndex:nn?40:30}:{left:$i,top:"50%",transform:"translate(-50%, -50%)",zIndex:nn?40:30},Ul=b?{bottom:`${Qe}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Qe}%`,top:"50%",transform:"translate(-50%, -50%)"},Ci=Fe!==null?W(Fe):null,zl=g!=="hover"&&Fe!==null&&(Fe===ve||!$&&Fe===ye),Fl=C?Ke>Fa:ve>R,Bl=C?it<Lo:ye<E,Yn=_c(C?[{side:O?"before":"after",box:ro(ti,ri),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Vr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Vr.slant.lowOffsetX}},{side:O?"after":"before",box:P?Oo:ro(Oo,ni),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:_r.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:_r.slant.lowOffsetX}}]:[{side:b||m==="top"?"before":"after",box:$?Cr:ro(Cr,ei),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:tn.lowAngleDeg,centreOffsetPx:tn.lowOffsetY,alongPushPx:tn.lowOffsetX}}]),Wl=Yn===void 0?e.style:{...e.style,...Yn.style};l.useLayoutEffect(()=>{Xa.current=Yn===void 0?0:Yn.mainPx});const kt=P?"micro-point":"micro-low",br=i?"cursor-not-allowed opacity-50":"cursor-pointer",Ii=c=>{const w=b?"vertical":"horizontal",p=c==="decrease",x=b?!p:p;return L.jsx(Rr,{ref:p?Za:Qa,neighbour:"rail",direction:Yc[w][c],disabled:i,canStep:p?Fl:Bl,onStep:()=>Wo(p?-1:1),ariaLabel:p?K.decrease:K.increase,className:`period-slider-stepper-btn ${Hc[w][c]} ${Qi[w][x?"leading":"trailing"]}`})};return L.jsxs("div",{ref:Xr,style:Wl,className:`period-slider grid select-none place-items-center ${jc[b?"vertical":"horizontal"][d?"withSteppers":"railOnly"]} ${s}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":m,"data-color-scheme":u,children:[L.jsx("div",{ref:qa,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),d&&Ii(b?"increase":"decrease"),L.jsx("div",{ref:mt,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":C?Ve:void 0,className:`period-slider-track relative touch-none rounded-full ${Qi[b?"vertical":"horizontal"][d?"rail":"railOnly"]} ${br}`,onPointerDown:Ml,onPointerMove:El,onPointerLeave:yl,children:C?L.jsxs(L.Fragment,{children:[Je&&(b?L.jsxs("svg",{className:"period-slider-vernier-projection is-vertical",role:"presentation","aria-hidden":"true",width:"32",height:"100%",viewBox:"0 0 32 100",preserveAspectRatio:"none",children:[L.jsx("defs",{children:L.jsxs("linearGradient",{id:de,x1:"0",y1:"0",x2:"1",y2:"0",children:[L.jsx("stop",{offset:"0%",stopColor:O?H.macro:H.micro,stopOpacity:"0.28"}),L.jsx("stop",{offset:"100%",stopColor:O?H.micro:H.macro,stopOpacity:Ti})]})}),L.jsx("path",{ref:Ao,"data-testid":"period-slider-vernier-projection",d:ea(Et,Ct,b,O),fill:`url(#${de})`})]}):L.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[L.jsx("defs",{children:L.jsxs("linearGradient",{id:de,x1:"0",y1:"0",x2:"0",y2:"1",children:[L.jsx("stop",{offset:"0%",stopColor:O?H.macro:H.micro,stopOpacity:"0.28"}),L.jsx("stop",{offset:"100%",stopColor:O?H.micro:H.macro,stopOpacity:Ti})]})}),L.jsx("path",{ref:Ao,"data-testid":"period-slider-vernier-projection",d:ea(Et,Ct,b,O),fill:`url(#${de})`})]})),!M&&L.jsxs(L.Fragment,{children:[L.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${Yr} - 8px)`,height:`calc(${Vn} - ${Yr} + 16px)`}:{left:`calc(${Yr} - 8px)`,width:`calc(${Vn} - ${Yr} + 16px)`},onPointerDown:Nr("macro-connect")}),!P&&L.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${Hr} - 8px)`,height:`calc(${_n} - ${Hr} + 16px)`}:{left:`calc(${Hr} - 8px)`,width:`calc(${_n} - ${Hr} + 16px)`},onPointerDown:Nr("micro-connect")})]}),Lt&&L.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(c=>L.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`macro-tick-${c}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(c=>L.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`micro-tick-${c}`))]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":ul,"aria-valuemax":lt,"aria-valuenow":tt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(mr,te,"period"):xr(te,mr,j,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:Yr,left:O?0:"auto",right:O?"auto":0,transform:O?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Me==="macro-low"||We==="macro-low"?30:15}:{left:Yr,top:O?0:"auto",bottom:O?"auto":0,transform:O?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Me==="macro-low"||We==="macro-low"?30:15},onPointerDown:Nr("macro-low"),onKeyDown:kn("macro-low"),onFocus:In("macro-low"),"data-active":Me==="macro-low"?"true":void 0,"data-front":We==="macro-low"?"true":void 0,"data-vernier-pos":b?O?"left":"right":O?"top":"bottom","data-handle-type":"macro-low",children:[L.jsx(mn,{type:"macro",isTop:O,isVertical:b,isLeft:O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":$l?"true":void 0,"data-slanted":Vr.slant.isSlanted?"true":void 0,ref:gl,style:Vr.lowStyle,children:st(te,mr,j,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":tt,"aria-valuemax":dl,"aria-valuenow":lt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(fr,te,"period"):xr(te,fr,j,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:Vn,left:O?0:"auto",right:O?"auto":0,transform:O?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Me==="macro-high"||We==="macro-high"?30:15}:{left:Vn,top:O?0:"auto",bottom:O?"auto":0,transform:O?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Me==="macro-high"||We==="macro-high"?30:15},onPointerDown:Nr("macro-high"),onKeyDown:kn("macro-high"),onFocus:In("macro-high"),"data-active":Me==="macro-high"?"true":void 0,"data-front":We==="macro-high"?"true":void 0,"data-vernier-pos":b?O?"left":"right":O?"top":"bottom","data-handle-type":"macro-high",children:[L.jsx(mn,{type:"macro",isTop:O,isVertical:b,isLeft:O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Ll?"true":void 0,"data-slanted":Vr.slant.isSlanted?"true":void 0,ref:hl,style:Vr.highStyle,children:st(te,fr,j,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":P?K.microSelectedDate:K.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Fa,"aria-valuemax":P?Lo:it,"aria-valuenow":Ke,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(yr,h,"period"):xr(h,yr,le,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:Hr,left:O?"auto":0,right:O?0:"auto",transform:O?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Me===kt||We===kt?30:20}:{left:Hr,top:O?"auto":0,bottom:O?0:"auto",transform:O?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Me===kt||We===kt?30:20},onPointerDown:Nr(kt),onKeyDown:kn(kt),onFocus:In(kt),"data-active":Me===kt?"true":void 0,"data-front":We===kt?"true":void 0,"data-vernier-pos":b?O?"right":"left":O?"bottom":"top","data-handle-type":kt,children:[L.jsx(mn,{type:"micro",isTop:!O,isVertical:b,isLeft:!O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Tl?"true":void 0,"data-slanted":_r.slant.isSlanted?"true":void 0,ref:wl,style:_r.lowStyle,children:st(h,yr,le,D)})]}),!P&&L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Ke,"aria-valuemax":Lo,"aria-valuenow":it,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Pr,h,"period"):xr(h,Pr,le,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:_n,left:O?"auto":0,right:O?0:"auto",transform:O?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Me==="micro-high"||We==="micro-high"?30:20}:{left:_n,top:O?"auto":0,bottom:O?0:"auto",transform:O?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Me==="micro-high"||We==="micro-high"?30:20},onPointerDown:Nr("micro-high"),onKeyDown:kn("micro-high"),onFocus:In("micro-high"),"data-active":Me==="micro-high"?"true":void 0,"data-front":We==="micro-high"?"true":void 0,"data-vernier-pos":b?O?"right":"left":O?"bottom":"top","data-handle-type":"micro-high",children:[L.jsx(mn,{type:"micro",isTop:!O,isVertical:b,isLeft:!O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Cl?"true":void 0,"data-slanted":_r.slant.isSlanted?"true":void 0,ref:bl,style:_r.highStyle,children:st(h,Pr,le,D)})]})]}):L.jsxs(L.Fragment,{children:[!M&&L.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:_l,onPointerDown:Rl}),U&&ne&&V.length>1&&L.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:V.map((c,w)=>{const p=_(t,c,f),x=hr(w),N=b?{bottom:`${x}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${x}%`,top:"50%",transform:"translate(-50%, -50%)"};return L.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:N},`tick-${p}`)})}),!i&&Fe!==null&&Qe!==null&&Le===null&&Ci&&L.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Ul,children:[L.jsx("div",{"data-testid":"period-slider-hover-dot",className:"period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-[var(--aqps-accent-light)] shadow-[0_0_6px_var(--aqps-accent-glow)] dark:border-slate-800"}),L.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":zl?"true":void 0,className:`period-slider-hover-tooltip ${m==="bottom"&&!b?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:st(t,Ci,e.formatLabel,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":$?K.selectedDate:K.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":R,"aria-valuemax":$?E:ye,"aria-valuenow":ve,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Ko,t,"period"):xr(t,Ko,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${br}`,style:Hl,onPointerDown:vi("low"),onKeyDown:Si("low"),onFocus:xi("low"),"data-active":Le==="low"?"true":void 0,"data-front":rn?"true":void 0,children:[L.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${Le==="low"?"":"shadow-md"}`}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":m,"data-slanted":tn.isSlanted?"true":void 0,"data-front":rn?"true":void 0,"data-duplicate":Vo&&!rn?"true":void 0,ref:ml,style:qo.lowStyle,children:st(t,Ko,e.formatLabel,D)})]}),!$&&L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":ve,"aria-valuemax":E,"aria-valuenow":ye,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Go,t,"period"):xr(t,Go,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${br}`,style:jl,onPointerDown:vi("high"),onKeyDown:Si("high"),onFocus:xi("high"),"data-active":Le==="high"?"true":void 0,"data-front":nn?"true":void 0,children:[L.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${Le==="high"?"":"shadow-md"}`}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":m,"data-slanted":tn.isSlanted?"true":void 0,"data-front":nn?"true":void 0,"data-duplicate":Vo&&!nn?"true":void 0,ref:fl,style:qo.highStyle,children:st(t,Go,e.formatLabel,D)})]})]})}),d&&Ii(b?"decrease":"increase")]})},nt=e=>e.getTime(),qs=(e,t)=>!(Pt(e)&&Pt(t))||e.length!==2||t.length!==2?!1:xt(e[0],nt)===xt(t[0],nt)&&xt(e[1],nt)===xt(t[1],nt),Wn=(e,t)=>e===void 0||t===void 0?e===t:qs(e,t),sa=(e,t)=>{if(e===t)return!0;if(!(Pt(e)&&Pt(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(xt(e[r],nt)!==xt(t[r],nt))return!1;return!0},Xs=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},zc=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||xt(e.minDate,nt)!==xt(t.minDate,nt)||xt(e.maxDate,nt)!==xt(t.maxDate,nt)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.isVertical!==t.isVertical||e.hideConnectBar!==t.hideConnectBar||e.showTicks!==t.showTicks||e.disabled!==t.disabled||e.showStepper!==t.showStepper||e.debounceMs!==t.debounceMs||e.tooltipStyle!==t.tooltipStyle||e.colorScheme!==t.colorScheme||e.className!==t.className||!Xs(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!sa(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(dt(e.value,nt)!==dt(t.value,nt)||dt(e.defaultValue,nt)!==dt(t.defaultValue,nt)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!Wn(e.range,t.range)||!Wn(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!Wn(e.microRange,t.microRange)||!Wn(e.defaultMicroRange,t.defaultMicroRange)||dt(e.microValue,nt)!==dt(t.microValue,nt)||dt(e.defaultMicroValue,nt)!==dt(t.defaultMicroValue,nt)||!qs(e.macroRange,t.macroRange)||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroPoint!==t.onChangeMicroPoint||e.onChangeMacroRange!==t.onChangeMacroRange||!sa(e.macroAllowedDates,t.macroAllowedDates)||!sa(e.microAllowedDates,t.microAllowedDates)):!1,Zs=l.memo(Uc,zc);Zs.displayName="PeriodSlider";const es=2,Ie=-1,vt=e=>_("day",e),Sn=e=>ee("day",e),cn=e=>`${Ro(e.getFullYear())}-${String(e.getMonth()+1).padStart(es,"0")}-${String(e.getDate()).padStart(es,"0")}`,Fc=(e,t,r,n)=>{const o=vt(e),a=vt(t),i=a>=o?a-o+1:0,s=g=>Sn(a-g),d={kind:"range",min:o,max:a};return{count:i,dateAt:s,labelAt:g=>st("day",s(g),n,r),indexOf:g=>{const m=vt(g);return m<o||m>a?Ie:a-m},nearestIndexOf:g=>{if(i===0)return Ie;const m=pn(d,vt(g));return m===null?Ie:a-m}}},Bc=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,s=v=>e[n-v],d={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},g=v=>{const b=v.getTime();let M=r,U=n;for(;M<=U;){const u=M+U>>1,D=e[u].getTime();if(D===b)return n-u;D<b?M=u+1:U=u-1}return Ie},m=v=>v===null?Ie:g(Sn(v));return{count:i,dateAt:s,labelAt:v=>st("day",s(v),a,o),indexOf:g,nearestIndexOf:v=>m(pn(d,vt(v)))}},Wc={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${S(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${S(e)})`)},indexOf:()=>Ie,nearestIndexOf:()=>Ie},Kc=(e,t,r)=>{const n=s=>{let d=0,g=e.length;for(;d<g;){const m=d+g>>1;e[m].getTime()<s?d=m+1:g=m}return d},o=s=>{let d=0,g=e.length;for(;d<g;){const m=d+g>>1;e[m].getTime()<=s?d=m+1:g=m}return d},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},Gc=(e,t)=>{const r=new Map;for(let n=0;n<e.length;n++){const o=e[n];t(n,o);const a=new Date(o);a.setHours(0,0,0,0);const i=a.getTime();r.has(i)||r.set(i,a)}return Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},qc={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Xc={month:2,day:2},ts={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},rs=new Map,Zc=(e,t)=>{const r=`${e}\0${t}`,n=rs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,qc[e]);return rs.set(r,o),o},Qc=(e,t,r)=>r!==void 0?Zc(e,r).format(t):e==="year"?Ro(ts.year(t)):String(ts[e](t)).padStart(Xc[e],"0"),Qs=(e,t,r,n)=>{if(t!=="year"&&t!=="month"&&t!=="day")throw new RangeError(`formatOptionText: unit must be "year", "month" or "day" (received: ${S(t)})`);if(r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${S(r)})`);return $e(e)?r==="part"?Qc(t,e,n):st(t,e,void 0,n):""},Js=(e,t)=>t(e).getTime(),Aa=(e,t,r)=>{const n=a=>Js(a,r),o=a=>a.value!==void 0?a.value:a.initialDate;return dt(o(e),n)!==dt(o(t),n)||t.value!==void 0&&Number.isNaN(dt(t.initialDate,n))||dt(e.minDate,n)!==dt(t.minDate,n)?!1:dt(e.maxDate,n)===dt(t.maxDate,n)},ns=Symbol("nothing handed");class Jc{held;writeCount=0;handed=ns;constructor(t){this.held=t}get current(){return this.held}set current(t){this.held=t,this.writeCount+=1}get writes(){return this.writeCount}hand(t){this.handed=t}get holdsHanded(){return this.handed===this.held}forgetHandedUnless(t){this.handed!==t&&(this.handed=ns)}commit(t,r){this.writeCount===r&&(this.held=t)}}function Xe(e){const[t]=l.useState(()=>new Jc(e)),r=t.writes;return l.useInsertionEffect(()=>{t.commit(e,r)}),t}const eu={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},tu=["shift","start","end","single"],ru=["disable","clamp"],nu=["follow","keep"],os={day:{day:1},month:{month:1,year:12},year:{year:1}},as=new WeakMap,ha=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${S(r)})`)},is=(e,t,r,n)=>{for(const[o,a]of Object.entries(r))if(!(a===void 0||n.includes(o)))throw new RangeError(`${e}: ${t}.${o} is not read here; the accepted keys are ${n.map(i=>`"${i}"`).join(", ")} (received: ${S(a)})`)},Mr=(e,t,r,n)=>{ha(e,t,r),is(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];ha(e,a,i),is(e,a,i,eu[n]);const{motion:s,edge:d,window:g}=i;if(n!=="vernierPoint"&&(typeof s!="string"||!tu.includes(s)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${S(s)})`);if(d!==void 0){if(s!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${S(d)} with motion ${S(s)})`);if(typeof d!="string"||!ru.includes(d))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${S(d)})`)}if(g!==void 0&&(typeof g!="string"||!nu.includes(g)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${S(g)})`)}},Na=e=>{if(typeof e!="object"||e===null)return{field:"stepper",expected:"an object",received:S(e)};const{onStep:t,canStepPrevious:r,canStepNext:n}=e;return typeof t!="function"?{field:"stepper.onStep",expected:"a function",received:S(t)}:typeof r!="boolean"?{field:"stepper.canStepPrevious",expected:"a boolean",received:S(r)}:typeof n!="boolean"?{field:"stepper.canStepNext",expected:"a boolean",received:S(n)}:null},Gt=(e,t,r,n,o)=>{if(!$e(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${S(r)})`);return ut(e,t,r,n,o,"")},so=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${S(r)})`)},el=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=as.get(r),s=i?.get(a);if(s!==void 0)return s;const d=[];for(let m=0;m<r.length;m++)d.push(Gt(e,`${t}[${m}]`,r[m],n,o));const g=Array.from(new Set(d)).sort((m,v)=>m-v);return i===void 0?as.set(r,new Map([[a,g]])):i.set(a,g),g},ou=(e,t)=>t===1?Jn(e):{stepEnd:(r,n)=>Qn(e,r+t*n,n),edge:r=>wn(e,r)},wa=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},ba=(e,t,r,n,o,a)=>{if(a){const d=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:ee(n,e[0],o);return Number.isNaN(d.getTime())?null:[d,d]}const i=e[0]===t[0]?r[0]:ee(n,e[0],o),s=e[1]===t[1]?r[1]:ee(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(s.getTime())?null:[i,s.getTime()<i.getTime()?i:s]},pa=e=>{const t="resolveSelectorSteps";ha(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:s,rules:d}=e;so(t,"unit",o);const g=e.stepUnit===void 0?o:e.stepUnit;so(t,"stepUnit",g);const m=os[o][g];if(m===void 0){const P=Object.keys(os[o]).map(K=>`"${K}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${P} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${S(g)})`)}const v=dr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${S(n)})`);if(!Pt(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${S(r)})`);Mr(t,"rules",d,"motion");const b=Gt(t,"selection[0]",r[0],o,v),M=Gt(t,"selection[1]",r[1],o,v);if(M<b)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${S(r[0])}, end: ${S(r[1])})`);const U=a===void 0?null:Gt(t,"minDate",a,o,v),u=i===void 0?null:Gt(t,"maxDate",i,o,v);if(U!==null&&u!==null&&u<U)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${S(a)}, maxDate: ${S(i)})`);Ea(t,"allowedDates",s);const D=s===void 0?{kind:"range",min:U,max:u}:Gr(el(t,"allowedDates",s,o,v),U,u),f=ou(D,m),z=(P,K)=>{const H=ma(f,b,M,P,wa(K,n));return H===null?null:ba(H,[b,M],r,o,v,K.motion==="single")};return{previous:z(-1,d.previous),next:z(1,d.next)}},Vt=(e,t)=>{const r=Xe({targets:e,onStepTo:t}),n=l.useCallback(i=>{const{targets:s,onStepTo:d}=r.current,g=s[i];g!==null&&d(g,i)},[]),o=e.previous!==null,a=e.next!==null;return l.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function Oa(e,t,r,n){const o=t?null:Js(e,r),[a,i]=l.useState(()=>({source:o,held:n(e)})),s=l.useCallback(g=>i(m=>({source:m.source,held:g})),[]);if(a.source===o)return[a.held,s];const d=o===null?{source:o,held:a.held}:{source:o,held:n(e)};return i(d),[d.held,s]}const no=44,ss=7,Kn=8,au=2,tl=10,iu=1e3,va=8,la=6,ca=4,ua=12,un=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),vt(r)},su=(e,t)=>{if(e.length<ca||t.count===0)return Ie;const r=Number(e.slice(0,ca));if(!Number.isInteger(r))return Ie;const n=e.length>=la,o=n?Number(e.slice(ca,la)):ua;if(o<1||o>ua)return Ie;const a=e.length>=va,i=a?Number(e.slice(la,va)):0,s=un(r,o),d=(o===ua?un(r+1,1):un(r,o+1))-1,g=a?s+i-1:n?s:un(r,1),m=a?g:n?d:un(r+1,1)-1;if(a&&(i<1||g>d))return Ie;for(let v=m;v>=g;v--){const b=t.indexOf(Sn(v));if(b!==Ie)return b}return Ie},lu=e=>e.closest(".dark")===null?"light":"dark",cu=(e,t,r,n)=>{const o=r-e.bottom-Kn,a=e.top-Kn,i=o>=t||o>=a,d=Math.max(no,Math.min(t,i?o:a)),g=i?e.bottom:e.top-d,m=e.width+tl,v=Math.max(Kn,Math.min(e.left,n-m-Kn));return{top:g,left:v,width:m,height:d}},rl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:s,labels:d,onCommitIndex:g,controlClassName:m})=>{const v=l.useId(),b=l.useMemo(()=>ic(d),[d]),M=`period-slider-date-listbox-${v}`,U=I=>`period-slider-date-option-${v}-${I}`,[u,D]=l.useState(!1),[f,z]=l.useState(Ie),[P,K]=l.useState(!0),[H,de]=l.useState(null),[Y,re]=l.useState(null),oe=l.useRef(null),V=l.useRef(null),ne=l.useRef(null),R=l.useRef({buffer:"",at:0}),E=l.useRef(e);E.current=e;const $=e.count,W=Math.min($,ss)*no,J=Math.max(1,Math.min($,ss)),F=l.useCallback(()=>{const I=oe.current;if(I===null)return;const he=I.getBoundingClientRect();de(cu(he,W,window.innerHeight,window.innerWidth))},[W]),G=l.useCallback(()=>{D(!1),z(Ie),R.current={buffer:"",at:0}},[]),k=l.useCallback(I=>{a||$===0||(z(I),D(!0))},[a,$]);l.useLayoutEffect(()=>{if(!u){de(null),re(null);return}const I=oe.current;return I!==null&&re(lu(I)),F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[u,F]),l.useEffect(()=>{if(!u)return;const I=he=>{const fe=he.target;fe!==null&&V.current?.contains(fe)!==!0&&oe.current?.contains(fe)!==!0&&G()};return document.addEventListener("pointerdown",I,!0),()=>document.removeEventListener("pointerdown",I,!0)},[u,G]);const ie=l.useRef(f);ie.current=f,l.useEffect(()=>{u&&(a||$===0)&&G()},[u,a,$,G]),l.useEffect(()=>{if(!u)return;const I=ie.current;if(I===Ie)return;const he=Math.min(I,$-1);he!==I&&z(he),ne.current?.scrollToIndex(he,{align:"center"})},[$,u]);const we=I=>{if($===0)return;const he=Math.max(0,Math.min(I,$-1));z(he),ne.current?.scrollToIndex(he,{align:"center"})},Se=I=>{I<0||I>=$||(g(I),G(),oe.current?.focus())},q=I=>{if(a)return;const he=f!==Ie?f:t!==Ie?t:r;switch(I.key){case"ArrowDown":if(I.preventDefault(),!u){k(he);return}we(he+1);return;case"ArrowUp":if(I.preventDefault(),!u){k(he);return}we(he-1);return;case"Home":if(!u)return;I.preventDefault(),we(0);return;case"End":if(!u)return;I.preventDefault(),we($-1);return;case"PageDown":if(!u)return;I.preventDefault(),we(he+J);return;case"PageUp":if(!u)return;I.preventDefault(),we(he-J);return;case"Enter":if(I.preventDefault(),!u){k(he);return}Se(f!==Ie?f:he);return;case"Escape":if(!u)return;I.preventDefault(),G();return;case"Tab":u&&G();return}if(I.key.length!==1)return;const fe=I.key>="0"&&I.key<="9",De=I.key==="-"||I.key==="/"||I.key===".";if(!(fe||De))return;I.preventDefault();const be=Date.now(),pe=be-R.current.at>iu?"":R.current.buffer,Oe=fe?`${pe}${I.key}`.slice(0,va):pe;R.current={buffer:Oe,at:be};const Te=su(Oe,E.current);if(Te!==Ie){if(!u){k(Te);return}we(Te)}},A=l.useCallback(I=>I,[]),ge=l.useCallback(()=>no,[]),ue=l.useCallback(I=>{const he=ie.current;K(he===Ie||he>=I.renderingStartIndex&&he<=I.renderingEndIndex)},[]),ae=u&&H!==null&&Y!==null&&$>0?L.jsx("div",{ref:V,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":Y,style:{top:H.top,left:H.left,width:H.width,height:H.height},onMouseDown:I=>{I.preventDefault()},children:L.jsx(lr.VirtualScroll,{ref:ne,itemCount:$,getItem:A,getItemHeight:ge,viewportSize:H.height-au,initialScrollIndex:f!==Ie?f:void 0,onRangeChange:ue,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:s,labels:b,contentProps:{id:M,role:"listbox","aria-label":i},scrollBarOptions:{width:tl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:I=>{const he=I===t,fe=I===f;return L.jsx("div",{id:U(I),role:"option","aria-selected":he,"aria-posinset":I+1,"aria-setsize":$,"data-testid":"period-slider-date-option","data-active":fe?"true":void 0,className:"period-slider-date-option",style:{height:no},onClick:()=>Se(I),children:E.current.labelAt(I)})}})}):null;return L.jsxs(L.Fragment,{children:[L.jsx("input",{ref:oe,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":u,"aria-controls":u?M:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":u&&f!==Ie&&P?U(f):void 0,disabled:a,value:n,className:m,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:q,onMouseDown:I=>{a||(I.preventDefault(),oe.current?.focus(),u?G():k(t!==Ie?t:r))},onBlur:()=>{u&&G()}}),ae===null?null:Xl.createPortal(ae,document.body)]})};rl.displayName="VirtualDateDropdown";const Kt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},uu='; leave the bound out where the variant allows it, or declare the days to offer with `minYear` / `maxYear` or `allowedDates`, instead of a sentinel for "no bound"',du='; variant="split-dropdown" requires both bounds, so declare the years to offer with `minYear` / `maxYear` instead of a sentinel for "no bound"',mu=31,dn=(e,t,r)=>{if(!$e(t))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${S(t)})`);if(Number.isNaN(Kt(t).getTime()))throw new RangeError(`DateSelector: "${e}" must fall on a day that starts inside the Date range (received ${S(t)})${r}`)},fu=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "formatLocale" must be a valid BCP 47 language tag (received ${S(e)})`)}},or=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},fn=e=>or(e,1,1),ls=e=>or(e,12,31),nl=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,cs=(e,t,r,n)=>nl(e,t,r)&&e.getDate()===n,Va=e=>!Number.isNaN(fn(e.getFullYear()).getTime()),gu=e=>Va(e)?Kt(e):new Date(Number.NaN),Gn=(e,t,r)=>{if(!Va(t))throw new RangeError(`DateSelector: "${e}" must fall in a year that starts inside the Date range, because variant="split-dropdown" draws its year (received ${S(t)})${r}`)},us=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const s=r(i);if(Number.isNaN(s.getTime()))break;n(s,i)&&a.push({value:i,label:o(s)})}return a},hu=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:s,minDate:d,maxDate:g,allowedDates:m,variant:v="date",className:b="",style:M,disabled:U=!1,locale:u,labels:D,formatLocale:f,formatOption:z}=e;fu(f);const P=v==="split-dropdown"?du:uu;if(t!==void 0&&dn("value",t,""),r!==void 0&&dn("initialDate",r,""),d!==void 0&&dn("minDate",d,P),g!==void 0&&dn("maxDate",g,P),v==="split-dropdown"&&(t!==void 0&&Gn("value",t,""),r!==void 0&&Gn("initialDate",r,""),d!==void 0&&Gn("minDate",d,P),g!==void 0&&Gn("maxDate",g,P)),i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${S(i)})`);if(s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${S(s)})`);if(i!==void 0&&Number.isNaN(fn(i).getTime()))throw new RangeError(`DateSelector: "minYear" must name a year whose first day is inside the Date range (received ${S(i)})`);if(s!==void 0&&Number.isNaN(ls(s).getTime()))throw new RangeError(`DateSelector: "maxYear" must name a year whose last day is inside the Date range (received ${S(s)})`);if(v==="split-dropdown"&&m!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');if(!wo(m))throw new RangeError(`DateSelector: "allowedDates" must be an array of Dates (received ${S(m)})`);const K=t??r;if(K===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");if(o!==void 0){const T=Na(o);if(T!==null)throw new RangeError(`DateSelector: "${T.field}" must be ${T.expected} (received ${T.received})`);if(t===void 0)throw new RangeError('DateSelector: "stepper" requires the controlled "value"; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled "initialDate" would never change')}const H=So(u,D),de=t!==void 0,[Y,re]=Oa(K,de,Kt,Kt),oe=t?.getTime(),V=l.useMemo(()=>t!==void 0?Kt(t):Y,[oe,Y]);if(v==="split-dropdown"&&!de&&!Va(V))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${S(V)}), because that selection's year starts outside the Date range; control the date with "value" to decide what the split dropdown holds`);const ne=d?.getTime(),R=g?.getTime(),E=l.useMemo(()=>{const T=d?Kt(d):null,C=i!==void 0?fn(i):null;return T===null?C:C===null||T.getTime()>=C.getTime()?T:C},[ne,i]),$=l.useMemo(()=>{const T=g?Kt(g):null,C=s!==void 0?ls(s):null;return T===null?C:C===null||T.getTime()<=C.getTime()?T:C},[R,s]),W=E?.getTime()??null,J=$?.getTime()??null;if(E!==null&&$!==null&&E.getTime()>$.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${cn(E)} is after max ${cn($)})`);if(v!=="date"&&m===void 0&&(E===null||$===null))throw new RangeError(`DateSelector: variant=${S(v)} needs a bounded range; supply minDate/minYear and maxDate/maxYear${v==="dropdown"?' or supply "allowedDates"':""}`);const F=l.useMemo(()=>m===void 0?null:m.map(T=>xt(T,C=>C.getTime())).join(","),[m]),G=l.useMemo(()=>{if(m===void 0)return null;const T=Gc(m,(C,Ve)=>dn(`allowedDates[${C}]`,Ve,""));return{ascending:T,ascendingSerials:T.map(vt)}},[F]),k=l.useMemo(()=>G===null?null:{...G,...Kc(G.ascending,E,$)},[G,W,J]),ie=l.useMemo(()=>k!==null?Bc(k.ascending,k.ascendingSerials,k.loIndex,k.hiIndex,f,z):E===null||$===null?Wc:Fc(E,$,f,z),[k,W,J,f,z]),we=l.useMemo(()=>k!==null?{kind:"candidates",ascending:k.ascendingSerials,loIndex:k.loIndex,hiIndex:k.hiIndex}:{kind:"range",min:E===null?null:vt(E),max:$===null?null:vt($)},[k,W,J]),Se=T=>!Number.isNaN(T.getTime())&&bn(we,vt(T)),q=T=>{if(U)return;const C=Kt(T);Se(C)&&(de||re(C),n?.(C))},A=V.getTime(),ge=Se(V),ue=l.useMemo(()=>{const T=Xt(we,vt(V),-1);if(T===null)return null;const C=Sn(T);return Number.isNaN(C.getTime())?null:C},[we,A]),ae=l.useMemo(()=>{const T=Xt(we,vt(V),1);if(T===null)return null;const C=Sn(T);return Number.isNaN(C.getTime())?null:C},[we,A]),I=()=>{if(o!==void 0){o.onStep("previous");return}ue!==null&&q(ue)},he=()=>{if(o!==void 0){o.onStep("next");return}ae!==null&&q(ae)},fe=T=>{if(T.target.value){const C=ql.parseISO(T.target.value);Number.isNaN(C.getTime())||q(C)}},De=V.getFullYear(),be=V.getMonth()+1,pe=V.getDate(),Oe=l.useCallback((T,C)=>z?z(C,T,"part"):Qs(C,T,"part",f),[z,f]),Te=l.useMemo(()=>{if(v!=="split-dropdown"||E===null||$===null)return[];const T=[];for(let C=$.getFullYear();C>=E.getFullYear();C--)T.push({value:C,label:Oe("year",fn(C))});return T},[v,W,J,Oe]),Ze=l.useMemo(()=>{if(v!=="split-dropdown"||E===null||$===null)return[];const T=E,C=$,Ve=De===T.getFullYear()?T.getMonth()+1:1,O=De===C.getFullYear()?C.getMonth()+1:12;return us(Ve,O,Je=>or(De,Je,1),(Je,Lt)=>nl(Je,De,Lt),Je=>Oe("month",Je))},[v,W,J,De,Oe]),ot=l.useMemo(()=>{if(v!=="split-dropdown"||E===null||$===null)return[];const T=E,C=$,Ve=De===T.getFullYear()&&be===T.getMonth()+1?T.getDate():1,O=De===C.getFullYear()&&be===C.getMonth()+1?C.getDate():mu;return us(Ve,O,Je=>or(De,be,Je),(Je,Lt)=>cs(Je,De,be,Lt),Je=>Oe("day",Je))},[v,W,J,De,be,Oe]),Le=(T,C,Ve)=>{const O=or(T,C,Ve);return cs(O,T,C,Ve)&&Se(O)},Q=(T,C,Ve)=>{Le(T,C,Ve)&&q(or(T,C,Ve))},Ye=Te.some(T=>T.value===De),Rt=Ze.some(T=>T.value===be),ze=ot.some(T=>T.value===pe),Fe=cn(V),qe=v==="dropdown"?st("day",V,z,f):"",Qe=E?cn(E):void 0,ft=$?cn($):void 0,ve="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400";return L.jsxs("div",{className:`inline-flex items-center ${hn} ${b}`,style:M,"data-variant":v,"data-out-of-range":ge?void 0:"true",children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:U,canStep:o===void 0?ue!==null:o.canStepPrevious,onStep:I,ariaLabel:H.previousDay}),v==="dropdown"?L.jsx(rl,{domain:ie,selectedIndex:ge?ie.indexOf(V):Ie,openAnchorIndex:ie.nearestIndexOf(V),displayLabel:qe,machineValue:Fe,disabled:U,ariaLabel:H.dateSelect,locale:u,labels:H,onCommitIndex:T=>q(ie.dateAt(T)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):v==="split-dropdown"?L.jsxs("div",{className:"inline-flex items-center gap-1",children:[L.jsxs("select",{"aria-label":H.splitYear,disabled:U,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Ye?De:"",onChange:T=>Q(Number(T.target.value),be,pe),children:[Ye?null:L.jsx("option",{value:"",disabled:!0,className:ve,children:Oe("year",fn(De))}),Te.map(T=>L.jsx("option",{value:T.value,disabled:!Le(T.value,be,pe),className:"dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]}),L.jsxs("select",{"aria-label":H.splitMonth,disabled:U,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Rt?be:"",onChange:T=>Q(De,Number(T.target.value),pe),children:[Rt?null:L.jsx("option",{value:"",disabled:!0,className:ve,children:Oe("month",or(De,be,1))}),Ze.map(T=>L.jsx("option",{value:T.value,disabled:!Le(De,T.value,pe),className:"dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]}),L.jsxs("select",{"aria-label":H.splitDay,disabled:U,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:ze?pe:"",onChange:T=>Q(De,be,Number(T.target.value)),children:[ze?null:L.jsx("option",{value:"",disabled:!0,className:ve,children:Oe("day",or(De,be,pe))}),ot.map(T=>L.jsx("option",{value:T.value,disabled:!Le(De,be,T.value),className:"dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]})]}):L.jsx("input",{"aria-label":H.dateSelect,disabled:U,className:"period-slider-native-date-field w-28 rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",value:Fe,min:Qe,max:ft,onChange:fe,type:"date"}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:U,canStep:o===void 0?ae!==null:o.canStepNext,onStep:he,ariaLabel:H.nextDay}),a]})},wu=(e,t)=>!(!Aa(e,t,t.variant==="split-dropdown"?gu:Kt)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),ol=l.memo(hu,wu);ol.displayName="DateSelector";function Ht(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function lo(e){return Ht(e.getFullYear(),e.getMonth())}function Sr(e){return`${Ro(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const ds='; leave the bound out where the variant allows it, or declare the months to offer with `minYear` / `maxYear` or `allowedMonths`, instead of a sentinel for "no bound"';function qn(e,t,r){e!==void 0&&al(e,t,r)}function al(e,t,r){if(!$e(e))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${S(e)}.`);if(Number.isNaN(lo(e).getTime()))throw new RangeError(`MonthSelector: \`${t}\` must fall in a month that starts inside the Date range, received ${S(e)}${r}.`)}function ms(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${S(e)}.`);if(Number.isNaN(Ht(e,r).getTime()))throw new RangeError(`MonthSelector: \`${t}\` must name a year whose ${r===0?"January":"December"} starts inside the Date range, received ${S(e)}.`)}}function bu(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`formatLocale\` must be a valid BCP 47 language tag, received ${S(e)}.`)}}function pu(e,t){const r=e===void 0?null:Ht(e,0),n=t===void 0?null:Ht(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function vu(e,t){const r=e===void 0?null:Ht(e,11),n=t===void 0?null:Ht(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function ar(e){return e.getFullYear()*12+e.getMonth()}function xa(e){return Ht(Math.floor(e/12),(e%12+12)%12)}function fs(e){return Number.isNaN(e.getTime())?null:e}function xu(e,t,r){const n=new Map;for(const o of e){const a=Ht(o.getFullYear(),o.getMonth());t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function Su(e,t){const r=[];for(let n=ar(e);n<=ar(t);n++)r.push(xa(n));return r}function gs(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:st("month",e[o],r,t),value:Sr(e[o])});return n}const Du=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:s,maxYear:d,minDate:g,maxDate:m,allowedMonths:v,isWarning:b=!1,className:M="",style:U,disabled:u=!1,locale:D,labels:f,formatLocale:z,formatOption:P}=e;if(bu(z),qn(t,"value",""),qn(r,"initialDate",""),qn(g,"minDate",ds),qn(m,"maxDate",ds),ms(s,"minYear",0),ms(d,"maxYear",11),!wo(v))throw new RangeError(`MonthSelector: \`allowedMonths\` must be an array of Dates, received ${S(v)}.`);if(v!==void 0)for(let Q=0;Q<v.length;Q++)al(v[Q],`allowedMonths[${Q}]`,"");const K=t??r;if(K===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");if(o!==void 0){const Q=Na(o);if(Q!==null)throw new RangeError(`MonthSelector: \`${Q.field}\` must be ${Q.expected}, received ${Q.received}.`);if(t===void 0)throw new RangeError("MonthSelector: `stepper` requires the controlled `value`; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled `initialDate` would never change.")}const H=So(D,f),de=t!==void 0,[Y,re]=Oa(K,de,lo,lo),oe=l.useMemo(()=>t!==void 0?Ht(t.getFullYear(),t.getMonth()):Y,[t?.getTime(),Y]),V=g?.getTime(),ne=m?.getTime(),R=l.useMemo(()=>pu(s,g),[s,V]),E=l.useMemo(()=>vu(d,m),[d,ne]),$=R?.getTime()??null,W=E?.getTime()??null;if(R!==null&&E!==null&&R>E)throw new RangeError(`MonthSelector: the resolved lower bound ${Sr(R)} is after the resolved upper bound ${Sr(E)}.`);if(i==="dropdown"&&v===void 0&&(R===null||E===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedMonths`; the option window is never invented.');const J=v===void 0?null:v.map(Q=>Q.getTime()).join(","),F=l.useMemo(()=>v===void 0?null:xu(v,R,E),[J,$,W]),G=l.useMemo(()=>{if(F!==null){const Q=F.map(ar);return{kind:"candidates",ascending:Q,loIndex:0,hiIndex:Q.length-1}}return{kind:"range",min:R===null?null:ar(R),max:E===null?null:ar(E)}},[F,$,W]),k=Q=>!Number.isNaN(Q.getTime())&&bn(G,ar(Q)),ie=Q=>{if(u)return;if(!k(Q))throw new RangeError(`MonthSelector: refusing to emit ${Sr(Q)}, which lies outside the selectable months.`);de||re(Q);const Ye=Q.getFullYear()*100+(Q.getMonth()+1);n?.(Q,Ye)},we=oe.getTime(),Se=k(oe),q=l.useMemo(()=>{const Q=Xt(G,ar(oe),-1);return Q===null?null:fs(xa(Q))},[G,we]),A=l.useMemo(()=>{const Q=Xt(G,ar(oe),1);return Q===null?null:fs(xa(Q))},[G,we]),ge=()=>{if(o!==void 0){o.onStep("previous");return}q!==null&&ie(q)},ue=()=>{if(o!==void 0){o.onStep("next");return}A!==null&&ie(A)},ae=Q=>{if(!Q)return;const Ye=Q.lastIndexOf("-");if(Ye<=0)return;const Rt=Q.slice(0,Ye),ze=Q.slice(Ye+1),Fe=Number(Rt),qe=Number(ze)-1;if(!(Number.isInteger(Fe)&&Number.isInteger(qe)))return;const Qe=Ht(Fe,qe);k(Qe)&&ie(Qe)},I=Q=>{ae(Q.target.value)},he=Q=>{ae(Q.target.value)},fe=Sr(oe),De=i==="dropdown"&&!Se?st("month",oe,P,z):"",be=R?Sr(R):void 0,pe=E?Sr(E):void 0,Oe=l.useMemo(()=>i!=="dropdown"?[]:F!==null?gs(F,z,P):R===null||E===null?[]:gs(Su(R,E),z,P),[i,F,$,W,z,P]),Te=Se?fe:"",Ze=b?"border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200":"border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",ot=`period-slider-native-date-field w-28 rounded-md border py-0.5 px-1 text-center font-mono text-xs tabular-nums dark:placeholder:text-gray-400 disabled:opacity-50 ${Ze}`,Le=`w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${Ze}`;return L.jsxs("div",{className:`inline-flex items-center ${hn} ${M}`,style:U,"data-out-of-range":Se?void 0:"true",children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:u,canStep:o===void 0?q!==null:o.canStepPrevious,onStep:ge,ariaLabel:H.previousMonth}),i==="dropdown"?L.jsxs("select",{"aria-label":H.monthSelect,disabled:u,className:Le,value:Te,onChange:he,children:[Se?null:L.jsx("option",{value:"",disabled:!0,className:"text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",children:De}),Oe.map(Q=>L.jsx("option",{value:Q.value,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:Q.label},Q.value))]}):L.jsx("input",{"aria-label":H.monthSelect,disabled:u,className:ot,value:fe,min:be,max:pe,onChange:I,type:"month"}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:u,canStep:o===void 0?A!==null:o.canStepNext,onStep:ue,ariaLabel:H.nextMonth}),a]})},Ru=(e,t)=>!(!Aa(e,t,lo)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),il=l.memo(Du,Ru);il.displayName="MonthSelector";function Ne(e,t,r){return e<t?t:e>r?r:e}const Mu=Gr([],null,null);function Dn(e,t,r,n){return r===null?Mu:Sa(r,_(t,e[0],n),_(t,e[1],n))}function Dr(e,t,r,n,o){const a=_(t,e,o),i=Da(n)?null:pn(n,a);return i===null?a<_(t,r[0],o)?r[0]:a>_(t,r[1],o)?r[1]:e:i===a?e:ee(t,i,o)}function Ur(e,t,r,n,o,a){const i=_(t,e[0],o),s=_(t,e[1],o),d=to(a,{kind:"range",min:_(t,r[0],o),max:_(t,r[1],o)},i,s);if(d===null)return e;const g=Dr(d[0]===i?e[0]:ee(t,d[0],o),t,r,n,o),m=Dr(d[1]===s?e[1]:ee(t,d[1],o),t,r,n,o);return[g,m<g?g:m]}const hs=(e,t,r,n,o,a,i)=>{if(Ea(e,t,r),r===void 0||r.length===0)return null;const s=Gr(el(e,t,r,n,i),_(n,o,i),_(n,a,i));if(s.hiIndex<s.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${S(o)}, maxDate: ${S(a)}, entries: ${r.length})`);return s},Sa=(e,t,r)=>{const n=Gr(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},Da=e=>e.hiIndex<e.loIndex,Eu=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Xt(o,t,r);a!==null&&(n===null||(r===1?a<n:a>n))&&(n=a)}return n},edge:t=>{let r=null;for(const n of e){const o=wn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Fr=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),ws=(e,t,r,n,o)=>{if(!Pt(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${S(r)})`);const a=Gt(e,`${t}[0]`,r[0],n,o),i=Gt(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${S(r[0])}, end: ${S(r[1])})`);return[a,i]},ir=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${S(e)})`);const{row:r,shows:n,macroUnit:o,microUnit:a,minDate:i,maxDate:s,macroRange:d,microSelection:g}=e;if(r!=="macro"&&r!=="micro")throw new RangeError(`${t}: row must be "macro" or "micro" (received: ${S(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${S(n)})`);so(t,"macroUnit",o),so(t,"microUnit",a);const m=dr(t,e.yearStartMonth);for(const[R,E]of[["minDate",i],["maxDate",s]])if(!$e(E))throw new RangeError(`${t}: ${R} must be a valid Date (received: ${S(E)})`);if(s.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${S(i)}, maxDate: ${S(s)})`);Gt(t,"minDate",i,o,m),Gt(t,"minDate",i,a,m),Mr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const v=ws(t,"macroRange",d,o,m);if(d[1].getTime()<d[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${S(d[0])}, end: ${S(d[1])})`);const b=ws(t,"microSelection",g,a,m),M=hs(t,"macroAllowedDates",e.macroAllowedDates,o,i,s,m),U=hs(t,"microAllowedDates",e.microAllowedDates,a,i,s,m),u=[d[0],d[1]],D=[g[0],g[1]],f=R=>{const E=Dt(o,a,[R[0],R[1]],i,s,m);return[_(a,E[0],m),_(a,E[1],m)]},z=(R,E)=>{if(U!==null){const $=Sa(U,R,E);if(!Da($))return $}return{kind:"range",min:R,max:E}},P=(R,E)=>{const $=Fr(R,u)?u:R;return $===u&&Fr(E,D)?null:{macroRange:$,microSelection:E}};if(e.row==="macro"){const R=M??{kind:"range",min:_(o,i,m),max:_(o,s,m)},E=Jn(R),$=(J,F)=>{const G=Dt(o,a,J,i,s,m);return Ur(D,a,G,Dn(G,a,U,m),m,F)},W=(J,F)=>{const G=ma(E,v[0],v[1],J,wa(F,n));if(G===null)return null;const k=ba(G,v,u,o,m,F.motion==="single");if(k===null)return null;const ie=[Ne(k[0],i,s),Ne(k[1],i,s)],we=Math.sign(G[0]-v[0])===J&&Math.sign(G[1]-v[1])===J;return P(ie,$(ie,we?"pan":"resize"))};return{previous:W(-1,e.rules.previous),next:W(1,e.rules.next)}}const K=f(u);let H=[_(a,i,m),_(a,s,m)];if(M!==null){const R=f([ee(o,M.ascending[M.loIndex],m),ee(o,M.ascending[M.hiIndex],m)]);H=[Math.min(R[0],K[0]),Math.max(R[1],K[1])]}const de=U===null?null:Sa(U,H[0],H[1]);let Y=Jn({kind:"range",min:H[0],max:H[1]});if(de!==null&&!Da(de)){const R=z(K[0],K[1]);Y=R.kind==="candidates"?Jn(de):Eu([de,R])}const re=R=>{if(M===null)return[Ne(wt(o,R[0],m),i,s),Ne(wt(o,R[1],m),i,s)];const E=Qn(M,_(o,R[0],m),-1),$=Qn(M,_(o,R[1],m),1);return E===null||$===null?null:[Ne(ee(o,E,m),i,s),Ne(ee(o,$,m),i,s)]},oe=(R,E,$)=>{const[W,J]=f(R),F=z(W,J),G=we=>{const Se=_(a,we,m);if(bn(F,Se))return we;const q=Qn(F,Se,$);return q===null?null:ee(a,q,m)},k=G(E[0]),ie=G(E[1]);return k===null||ie===null?null:[k,ie.getTime()<k.getTime()?k:ie]},V=(R,E)=>R>=K[0]&&E<=K[1],ne=(R,E)=>{const $=ma(Y,b[0],b[1],R,wa(E,n));if($===null)return null;const W=ba($,b,D,a,m,E.motion==="single");if(W===null)return null;const J=E.window!=="follow",F=J&&V($[0],$[1])?u:re(W);if(F===null)return null;const G=oe(F,W,R);if(G===null)return null;const k=J&&V(_(a,G[0],m),_(a,G[1],m))?u:re(G);return k===null?null:P(k,G)};return{previous:ne(-1,e.rules.previous),next:ne(1,e.rules.next)}};function Ra(e,t,r){if(!$e(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${S(r)})`)}function Ce(e,t,r,n,o){Ra(e,t,r),ut(e,t,r,n,o,"")}function Eo(e,t,r,n,o){if(Ra(e,"minDate",t),Ra(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${S(t)}, maxDate: ${S(r)})`);for(const a of n)ut(e,"minDate",t,a,o,Cs)}function sr(e,t,r,n,o){if(!Pt(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${S(r)})`);if(Ce(e,`${t}[0]`,r[0],n,o),Ce(e,`${t}[1]`,r[1],n,o),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${S(r[0])}, upper: ${S(r[1])})`)}function co(e,t,r,n,o,a,i,s){const d=_(r,n,s);if(d<_(r,o,s)||d>_(r,a,s))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${S(n)}, lower: ${S(o)}, upper: ${S(a)})`)}function uo(e,t,r,n,o,a,i,s){co(e,`${t}[0]`,r,n[0],o,a,i,s),co(e,`${t}[1]`,r,n[1],o,a,i,s)}function mo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${S(r)}, upper: ${S(n)})`)}function Br(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${S(r)})`)}function _t(e,t,r,n,o,a){const i=ks(e,t,r);return $e(i)&&Is(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function fo(e,t,r,n,o){const a=Pe(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function go(e,t,r,n,o,a){const i=Ne(e,r,n);if(o.length===0)return i;const s=o[Pe(o,i,t,a)];return _(t,s,a)===_(t,i,a)?i:Ne(s,r,n)}function bs(e,t,r,n,o,a){const i=go(e[0],t,r,n,o,a),s=go(e[1],t,r,n,o,a);return[i,s<i?i:s]}const yu={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function Yt(e,t){return t.length===0?{}:{[yu[e]]:t}}function yo(e){const t=l.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(s=>Object.is(r[s],n[s]))||(t.current=e),t.current}const qt={previous:null,next:null},Pu=["motion","edge","window"];function Rn(e){const t=l.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Pu.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const sl=(e,t)=>e.getTime()===t.getTime();function Wr(e,t,r,n){if(!r(e.current,t))e.current=t;else if(e.holdsHanded)return;e.hand(e.current),n(e.current)}function Kr(e,t,r){e.current=t,e.hand(t),r(t)}function $u(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:s,selectorStep:d,...g}=e,m=dr("usePeriodSliderRange",i);Eo("usePeriodSliderRange",r,n,[t],m),sr("usePeriodSliderRange","initialRange",o,t,m),d!==void 0&&Mr("usePeriodSliderRange","selectorStep",d,"motion");const v=yo(g),b=r.getTime(),M=n.getTime(),U=l.useMemo(()=>cr("usePeriodSliderRange",Mo(v.allowedDates),t,r,n,m).dates,[v.allowedDates,t,b,M,m]),u=l.useRef(o),[D,f]=l.useState(()=>(uo("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",m),o));sr("usePeriodSliderRange","range",D,t,m);let z=D;const P=bs(D,t,r,n,U,m);(P[0]!==D[0]||P[1]!==D[1])&&(z=P,f(P));const K=Xe(z);K.forgetHandedUnless(D);const H=l.useRef(o),de=Xe({minDate:r,maxDate:n,candidates:U}),Y=Xe(a),re=l.useCallback(q=>{const{minDate:A,maxDate:ge,candidates:ue}=de.current,ae=bs(q,t,A,ge,ue,m);Wr(K,ae,Fr,f);const I=H.current;ae[0].getTime()===I[0].getTime()&&ae[1].getTime()===I[1].getTime()||(H.current=ae,Y.current?.(ae[0],ae[1]))},[t,m]),oe=l.useCallback(q=>{const A=typeof q=="function"?q(K.current):q;H.current=A,Kr(K,A,f)},[]),V=l.useCallback(q=>{Ce("usePeriodSliderRange","setLowerDate(date)",q,t,m);const A=K.current,ge=q.getTime()>A[1].getTime()?q:A[1];re([q,ge])},[re,t,m]),ne=l.useCallback(q=>{Ce("usePeriodSliderRange","setUpperDate(date)",q,t,m);const A=K.current,ge=q.getTime()<A[0].getTime()?q:A[0];re([ge,q])},[re,t,m]),R=l.useCallback((q,A)=>{Ce("usePeriodSliderRange","sliderProps.onChangeRange(lower)",q,t,m),Ce("usePeriodSliderRange","sliderProps.onChangeRange(upper)",A,t,m),mo("usePeriodSliderRange","sliderProps.onChangeRange",q,A),re([q,A])},[re,t,m]),E=l.useCallback(q=>{Br("usePeriodSliderRange","shiftRange",q);const{minDate:A,maxDate:ge,candidates:ue}=de.current,ae=K.current;if(ue.length>0){re([fo(ue,t,ae[0],q,m),fo(ue,t,ae[1],q,m)]);return}re([_t(t,ae[0],q,A,ge,m).date,_t(t,ae[1],q,A,ge,m).date])},[t,re,m]),$=l.useCallback(()=>{re(u.current)},[re]),W=Rn(d),J=W!==void 0,F=l.useMemo(()=>{if(W===void 0)return{start:qt,end:qt};const q=U.length>0?v.allowedDates:void 0,A={selection:z,unit:t,yearStartMonth:m,minDate:r,maxDate:n,allowedDates:q,rules:W};return{start:pa({...A,shows:"start"}),end:pa({...A,shows:"end"})}},[W,z,t,m,b,M,U,v.allowedDates]),G=Vt(F.start,re),k=Vt(F.end,re),ie=l.useMemo(()=>({value:z[0],onChange:V,minDate:r,maxDate:z[1],unit:t,yearStartMonth:m,...Yt(t,U),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:s,...J?{stepper:G}:{}}),[z[0],z[1],V,r,t,m,U,e.formatLocale,e.locale,e.labels,s,J,G]),we=l.useMemo(()=>({value:z[1],onChange:ne,minDate:z[0],maxDate:n,unit:t,yearStartMonth:m,...Yt(t,U),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:s,...J?{stepper:k}:{}}),[z[0],z[1],ne,n,t,m,U,e.formatLocale,e.locale,e.labels,s,J,k]),Se=l.useMemo(()=>({...v,mode:"range",unit:t,yearStartMonth:m,range:z,minDate:r,maxDate:n,onChangeRange:R}),[v,t,z,r,n,R,m]);return{range:z,lowerDate:z[0],upperDate:z[1],setRange:oe,setLowerDate:V,setUpperDate:ne,shiftRange:E,resetRange:$,startSelectorProps:ie,endSelectorProps:we,sliderProps:Se}}function Lu(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:s,...d}=e,g=dr("usePeriodSliderPoint",i);Eo("usePeriodSliderPoint",r,n,[t],g),Ce("usePeriodSliderPoint","initialValue",o,t,g);const m=yo(d),v=r.getTime(),b=n.getTime(),M=l.useMemo(()=>cr("usePeriodSliderPoint",Mo(m.allowedDates),t,r,n,g).dates,[m.allowedDates,t,v,b,g]),U=l.useRef(o),[u,D]=l.useState(()=>(co("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",g),o));Ce("usePeriodSliderPoint","value",u,t,g);let f=u;const z=go(u,t,r,n,M,g);z!==u&&(f=z,D(z));const P=Xe(f);P.forgetHandedUnless(u);const K=l.useRef(o),H=Xe({minDate:r,maxDate:n,candidates:M}),de=Xe(a),Y=l.useCallback(W=>{const{minDate:J,maxDate:F,candidates:G}=H.current,k=go(W,t,J,F,G,g);Wr(P,k,sl,D),k.getTime()!==K.current.getTime()&&(K.current=k,de.current?.(k))},[t,g]),re=l.useCallback(W=>{const J=typeof W=="function"?W(P.current):W;K.current=J,Kr(P,J,D)},[]),oe=l.useCallback(W=>{Ce("usePeriodSliderPoint","selectorProps.onChange(date)",W,t,g),Y(W)},[Y,t,g]),V=l.useCallback(W=>{Ce("usePeriodSliderPoint","sliderProps.onChangePoint(value)",W,t,g),Y(W)},[Y,t,g]),ne=l.useCallback(W=>{Br("usePeriodSliderPoint","shiftValue",W);const{minDate:J,maxDate:F,candidates:G}=H.current;if(G.length>0){Y(fo(G,t,P.current,W,g));return}Y(_t(t,P.current,W,J,F,g).date)},[t,Y,g]),R=l.useCallback(()=>{Y(U.current)},[Y]),E=l.useMemo(()=>({value:f,onChange:oe,minDate:r,maxDate:n,unit:t,yearStartMonth:g,...Yt(t,M),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:s}),[f,oe,r,n,t,g,M,e.formatLocale,e.locale,e.labels,s]),$=l.useMemo(()=>({...m,mode:"point",unit:t,yearStartMonth:g,value:f,minDate:r,maxDate:n,onChangePoint:V}),[m,t,f,r,n,V,g]);return{value:f,setValue:re,shiftValue:ne,resetValue:R,selectorProps:E,sliderProps:$}}function Tu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i=t,microUnit:s=t,onChangeMacroRange:d,onChangeMicroRange:g,yearStartMonth:m,formatOption:v,macroSelectorStep:b,microSelectorStep:M,...U}=e,u=dr("useVernierSliderRange",m);Eo("useVernierSliderRange",r,n,[i,s,t],u),sr("useVernierSliderRange","initialMacroRange",o,i,u),sr("useVernierSliderRange","initialMicroRange",a,s,u),b!==void 0&&Mr("useVernierSliderRange","macroSelectorStep",b,"motion"),M!==void 0&&Mr("useVernierSliderRange","microSelectorStep",M,"vernierRange");const D=yo(U),f=l.useRef(o),z=l.useRef(a),[P,K]=l.useState(()=>(uo("useVernierSliderRange","initialMacroRange",i,o,r,n,"[minDate, maxDate]",u),o)),[H,de]=l.useState(()=>{const y=Dt(i,s,o,r,n,u);return uo("useVernierSliderRange","initialMicroRange",s,a,y[0],y[1],"the initial macro window",u),a});let Y=P;sr("useVernierSliderRange","macroRange",P,i,u);const re=[Ne(P[0],r,n),Ne(P[1],r,n)];(re[0]!==P[0]||re[1]!==P[1])&&(Y=re,K(re));const oe=r.getTime(),V=n.getTime(),ne=l.useMemo(()=>Dt(i,s,Y,r,n,u),[i,s,Y,oe,V,u]),R=l.useMemo(()=>D.microIsDiscrete===!0?Ta("useVernierSliderRange",St("micro",D),s,r,n,u):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,s,oe,V,u]),E=l.useMemo(()=>D.macroIsDiscrete===!0?cr("useVernierSliderRange",St("macro",D),i,r,n,u).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,i,oe,V,u]),$=Xe(E),W=l.useMemo(()=>Dn(ne,s,R,u),[ne,s,R,u]),J=l.useMemo(()=>xn(R,W),[R,W]);let F=H;sr("useVernierSliderRange","microRange",H,s,u);const G=Ur(H,s,ne,W,u,"resize");(G[0]!==H[0]||G[1]!==H[1])&&(F=G,de(G));const k=Xe(Y),ie=Xe(F);k.forgetHandedUnless(P),ie.forgetHandedUnless(H);const we=l.useRef(a),Se=l.useRef(o),q=Xe({minDate:r,maxDate:n}),A=Xe(d),ge=Xe(g),ue=l.useCallback(y=>{const{minDate:j,maxDate:le}=q.current;return Dt(i,s,y,j,le,u)},[i,s,u]),ae=l.useCallback(y=>Dn(y,s,R,u),[s,R,u]),I=l.useCallback(y=>{Wr(k,y,Fr,K);const j=Se.current;y[0].getTime()===j[0].getTime()&&y[1].getTime()===j[1].getTime()||(Se.current=y,A.current?.(y[0],y[1]))},[]),he=l.useCallback(y=>{const j=typeof y=="function"?y(k.current):y;Se.current=j,Kr(k,j,K)},[]),fe=l.useCallback((y,j)=>{I(y),Wr(ie,j,Fr,de);const le=we.current;(j[0].getTime()!==le[0].getTime()||j[1].getTime()!==le[1].getTime())&&(we.current=j,ge.current?.(j[0],j[1]))},[I]),De=l.useCallback(y=>{const j=typeof y=="function"?y(ie.current):y;we.current=j,Kr(ie,j,de)},[]),be=l.useCallback((y,j,le)=>{const{minDate:He,maxDate:_e}=q.current,Me=[Ne(y,He,_e),Ne(j,He,_e)],je=ue(Me);fe(Me,Ur(ie.current,s,je,ae(je),u,le))},[s,ue,ae,fe,u]),pe=l.useCallback((y,j)=>be(y,j,"resize"),[be]),Oe=l.useCallback((y,j)=>{Ce("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",y,i,u),Ce("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",j,i,u),mo("useVernierSliderRange","sliderProps.onChangeMacroRange",y,j);const{minDate:le,maxDate:He}=q.current,_e=[Ne(y,le,He),Ne(j,le,He)],Me=ie.current,je=ue(_e),et=Ur(Me,s,je,ae(je),u,"resize");if(et[0].getTime()!==Me[0].getTime()||et[1].getTime()!==Me[1].getTime()){I(_e);return}fe(_e,Me)},[i,s,ue,ae,I,fe,u]),Te=l.useCallback((y,j)=>{const le=ue(k.current);fe(k.current,Ur([y,j],s,le,ae(le),u,"resize"))},[s,ue,ae,fe,u]),Ze=l.useCallback((y,j)=>{Ce("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",y,s,u),Ce("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",j,s,u),mo("useVernierSliderRange","sliderProps.onChangeMicroRange",y,j),Te(y,j)},[Te,s,u]),ot=l.useCallback(y=>{Ce("useVernierSliderRange","setMacroLowerDate(date)",y,i,u);const j=k.current[1],le=y>j?y:j;pe(y,le)},[pe,i,u]),Le=l.useCallback(y=>{Ce("useVernierSliderRange","setMacroUpperDate(date)",y,i,u);const j=k.current[0],le=y<j?y:j;pe(le,y)},[pe,i,u]),Q=l.useCallback(y=>{Ce("useVernierSliderRange","setMicroLowerDate(date)",y,s,u);const j=ie.current[1],le=y>j?y:j;Te(y,le)},[Te,s,u]),Ye=l.useCallback(y=>{Ce("useVernierSliderRange","setMicroUpperDate(date)",y,s,u);const j=ie.current[0],le=y<j?y:j;Te(le,y)},[Te,s,u]),Rt=l.useCallback(y=>{Br("useVernierSliderRange","shiftMacroRange",y);const{minDate:j,maxDate:le}=q.current,He=k.current,_e=$.current;if(_e.length>0){const et=Pe(_e,He[0],i,u)+y,bt=Pe(_e,He[1],i,u)+y;if(et<0||bt>_e.length-1)return;be(_e[et],_e[bt],"pan");return}const Me=_t(i,He[0],y,j,le,u),je=_t(i,He[1],y,j,le,u);Me.pastDateRange||je.pastDateRange||Me.date<j||je.date>le||be(Me.date,je.date,"pan")},[i,be,u]),ze=l.useCallback(y=>{Br("useVernierSliderRange","shiftMicroRange",y);const j=k.current,le=ie.current,He=ue(j),[_e,Me]=He,je=xn(R,ae(He));if(je.length>0){const Ut=Pe(je,le[0],s,u)+y,We=Pe(je,le[1],s,u)+y;if(Ut<0||We>je.length-1)return;Te(je[Ut],je[We]);return}const et=_t(s,le[0],y,_e,Me,u),bt=_t(s,le[1],y,_e,Me,u);et.pastDateRange||bt.pastDateRange||_(s,et.date,u)<_(s,_e,u)||_(s,bt.date,u)>_(s,Me,u)||Te(et.date,bt.date)},[s,R,ue,ae,Te,u]),Fe=l.useCallback(()=>{const{minDate:y,maxDate:j}=q.current,le=[Ne(f.current[0],y,j),Ne(f.current[1],y,j)],He=ue(le);fe(le,Ur(z.current,s,He,ae(He),u,"resize"))},[s,ue,ae,fe,u]),qe=Rn(b),Qe=Rn(M),ft=qe!==void 0,ve=Qe!==void 0,ye=l.useMemo(()=>{const y={macroUnit:i,microUnit:s,yearStartMonth:u,minDate:r,maxDate:n,macroRange:Y,microSelection:F,macroAllowedDates:D.macroIsDiscrete===!0?St("macro",D).list:void 0,microAllowedDates:D.microIsDiscrete===!0?St("micro",D).list:void 0};return{macroStart:qe===void 0?qt:ir({...y,row:"macro",shows:"start",rules:qe}),macroEnd:qe===void 0?qt:ir({...y,row:"macro",shows:"end",rules:qe}),microStart:Qe===void 0?qt:ir({...y,row:"micro",shows:"start",rules:Qe}),microEnd:Qe===void 0?qt:ir({...y,row:"micro",shows:"end",rules:Qe})}},[qe,Qe,i,s,u,oe,V,Y,F,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),T=l.useCallback(y=>fe(y.macroRange,y.microSelection),[fe]),C=Vt(ye.macroStart,T),Ve=Vt(ye.macroEnd,T),O=Vt(ye.microStart,T),Je=Vt(ye.microEnd,T),[Lt,jt]=ne,te=l.useMemo(()=>({value:Y[0],onChange:ot,minDate:r,maxDate:Y[1],unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ft?{stepper:C}:{}}),[Y,ot,r,i,u,E,e.formatLocale,e.locale,e.labels,v,ft,C]),h=l.useMemo(()=>({value:Y[1],onChange:Le,minDate:Y[0],maxDate:n,unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ft?{stepper:Ve}:{}}),[Y,Le,n,i,u,E,e.formatLocale,e.locale,e.labels,v,ft,Ve]),se=l.useMemo(()=>({value:F[0],onChange:Q,minDate:Lt,maxDate:F[1],unit:s,yearStartMonth:u,...Yt(s,J),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ve?{stepper:O}:{}}),[F,Q,Lt,s,u,J,e.formatLocale,e.locale,e.labels,v,ve,O]),Re=l.useMemo(()=>({value:F[1],onChange:Ye,minDate:F[0],maxDate:jt,unit:s,yearStartMonth:u,...Yt(s,J),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ve?{stepper:Je}:{}}),[F,Ye,jt,s,u,J,e.formatLocale,e.locale,e.labels,v,ve,Je]),Be=l.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:u,macroUnit:i,microUnit:s,minDate:r,maxDate:n,macroRange:Y,microRange:F,onChangeMacroRange:Oe,onChangeMicroRange:Ze}),[D,t,i,s,r,n,Y,F,Oe,Ze,u]);return{macroRange:Y,setMacroRange:he,microRange:F,setMicroRange:De,setMacroLowerDate:ot,setMacroUpperDate:Le,setMicroLowerDate:Q,setMicroUpperDate:Ye,shiftMacroRange:Rt,shiftMicroRange:ze,resetVernier:Fe,macroStartSelectorProps:te,macroEndSelectorProps:h,microStartSelectorProps:se,microEndSelectorProps:Re,sliderProps:Be}}function Cu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i=t,microUnit:s=t,onChangeMacroRange:d,onChangeMicroPoint:g,yearStartMonth:m,formatOption:v,macroSelectorStep:b,microSelectorStep:M,...U}=e,u=dr("useVernierSliderPoint",m);Eo("useVernierSliderPoint",r,n,[i,s,t],u),sr("useVernierSliderPoint","initialMacroRange",o,i,u),Ce("useVernierSliderPoint","initialMicroValue",a,s,u),b!==void 0&&Mr("useVernierSliderPoint","macroSelectorStep",b,"motion"),M!==void 0&&Mr("useVernierSliderPoint","microSelectorStep",M,"vernierPoint");const D=yo(U),f=l.useRef(o),z=l.useRef(a),[P,K]=l.useState(()=>(uo("useVernierSliderPoint","initialMacroRange",i,o,r,n,"[minDate, maxDate]",u),o)),[H,de]=l.useState(()=>{const h=Dt(i,s,o,r,n,u);return co("useVernierSliderPoint","initialMicroValue",s,a,h[0],h[1],"the initial macro window",u),a});let Y=P;sr("useVernierSliderPoint","macroRange",P,i,u);const re=[Ne(P[0],r,n),Ne(P[1],r,n)];(re[0]!==P[0]||re[1]!==P[1])&&(Y=re,K(re));const oe=r.getTime(),V=n.getTime(),ne=l.useMemo(()=>Dt(i,s,Y,r,n,u),[i,s,Y,oe,V,u]),R=l.useMemo(()=>D.microIsDiscrete===!0?Ta("useVernierSliderPoint",St("micro",D),s,r,n,u):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,s,oe,V,u]),E=l.useMemo(()=>D.macroIsDiscrete===!0?cr("useVernierSliderPoint",St("macro",D),i,r,n,u).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,i,oe,V,u]),$=Xe(E),W=l.useMemo(()=>Dn(ne,s,R,u),[ne,s,R,u]),J=l.useMemo(()=>xn(R,W),[R,W]);let F=H;Ce("useVernierSliderPoint","microValue",H,s,u);const G=Dr(H,s,ne,W,u);G!==H&&(F=G,de(G));const k=Xe(Y),ie=Xe(F);k.forgetHandedUnless(P),ie.forgetHandedUnless(H);const we=l.useRef(a),Se=l.useRef(o),q=Xe({minDate:r,maxDate:n}),A=Xe(d),ge=Xe(g),ue=l.useCallback(h=>{const{minDate:se,maxDate:Re}=q.current;return Dt(i,s,h,se,Re,u)},[i,s,u]),ae=l.useCallback(h=>Dn(h,s,R,u),[s,R,u]),I=l.useCallback(h=>{Wr(k,h,Fr,K);const se=Se.current;h[0].getTime()===se[0].getTime()&&h[1].getTime()===se[1].getTime()||(Se.current=h,A.current?.(h[0],h[1]))},[]),he=l.useCallback(h=>{const se=typeof h=="function"?h(k.current):h;Se.current=se,Kr(k,se,K)},[]),fe=l.useCallback((h,se)=>{I(h),Wr(ie,se,sl,de),se.getTime()!==we.current.getTime()&&(we.current=se,ge.current?.(se))},[I]),De=l.useCallback(h=>{const se=typeof h=="function"?h(ie.current):h;we.current=se,Kr(ie,se,de)},[]),be=l.useCallback((h,se)=>{const{minDate:Re,maxDate:Be}=q.current,y=[Ne(h,Re,Be),Ne(se,Re,Be)],j=ue(y);fe(y,Dr(ie.current,s,j,ae(j),u))},[s,ue,ae,fe,u]),pe=l.useCallback(h=>{const se=ue(k.current);fe(k.current,Dr(h,s,se,ae(se),u))},[s,ue,ae,fe,u]),Oe=l.useCallback((h,se)=>{Ce("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",h,i,u),Ce("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",se,i,u),mo("useVernierSliderPoint","sliderProps.onChangeMacroRange",h,se);const{minDate:Re,maxDate:Be}=q.current,y=[Ne(h,Re,Be),Ne(se,Re,Be)],j=ie.current,le=ue(y);if(Dr(j,s,le,ae(le),u).getTime()!==j.getTime()){I(y);return}fe(y,j)},[i,s,ue,ae,I,fe,u]),Te=l.useCallback(h=>{Ce("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",h,s,u),pe(h)},[pe,s,u]),Ze=l.useCallback(h=>{Ce("useVernierSliderPoint","setMacroLowerDate(date)",h,i,u);const se=k.current[1],Re=h>se?h:se;be(h,Re)},[be,i,u]),ot=l.useCallback(h=>{Ce("useVernierSliderPoint","setMacroUpperDate(date)",h,i,u);const se=k.current[0],Re=h<se?h:se;be(Re,h)},[be,i,u]),Le=l.useCallback(h=>{Ce("useVernierSliderPoint","setMicroDate(date)",h,s,u),pe(h)},[pe,s,u]),Q=l.useCallback(h=>{Br("useVernierSliderPoint","shiftMacroRange",h);const{minDate:se,maxDate:Re}=q.current,Be=k.current,y=$.current;if(y.length>0){const He=Pe(y,Be[0],i,u)+h,_e=Pe(y,Be[1],i,u)+h;if(He<0||_e>y.length-1)return;be(y[He],y[_e]);return}const j=_t(i,Be[0],h,se,Re,u),le=_t(i,Be[1],h,se,Re,u);j.pastDateRange||le.pastDateRange||j.date<se||le.date>Re||be(j.date,le.date)},[i,be,u]),Ye=l.useCallback(h=>{Br("useVernierSliderPoint","shiftMicroValue",h);const se=k.current,Re=ue(se),Be=xn(R,ae(Re));if(Be.length>0){pe(fo(Be,s,ie.current,h,u));return}pe(_t(s,ie.current,h,Re[0],Re[1],u).date)},[s,R,ue,ae,pe,u]),Rt=l.useCallback(()=>{const{minDate:h,maxDate:se}=q.current,Re=[Ne(f.current[0],h,se),Ne(f.current[1],h,se)],Be=ue(Re);fe(Re,Dr(z.current,s,Be,ae(Be),u))},[s,ue,ae,fe,u]),ze=Rn(b),Fe=Rn(M),qe=ze!==void 0,Qe=Fe!==void 0,ft=l.useMemo(()=>{const h={macroUnit:i,microUnit:s,yearStartMonth:u,minDate:r,maxDate:n,macroRange:Y,microSelection:[F,F],macroAllowedDates:D.macroIsDiscrete===!0?St("macro",D).list:void 0,microAllowedDates:D.microIsDiscrete===!0?St("micro",D).list:void 0};return{macroStart:ze===void 0?qt:ir({...h,row:"macro",shows:"start",rules:ze}),macroEnd:ze===void 0?qt:ir({...h,row:"macro",shows:"end",rules:ze}),micro:Fe===void 0?qt:ir({...h,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:Fe.previous.window},next:{motion:"shift",window:Fe.next.window}}})}},[ze,Fe,i,s,u,oe,V,Y,F,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),ve=l.useCallback(h=>fe(h.macroRange,h.microSelection[0]),[fe]),ye=Vt(ft.macroStart,ve),T=Vt(ft.macroEnd,ve),C=Vt(ft.micro,ve),[Ve,O]=ne,Je=l.useMemo(()=>({value:Y[0],onChange:Ze,minDate:r,maxDate:Y[1],unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...qe?{stepper:ye}:{}}),[Y,Ze,r,i,u,E,e.formatLocale,e.locale,e.labels,v,qe,ye]),Lt=l.useMemo(()=>({value:Y[1],onChange:ot,minDate:Y[0],maxDate:n,unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...qe?{stepper:T}:{}}),[Y,ot,n,i,u,E,e.formatLocale,e.locale,e.labels,v,qe,T]),jt=l.useMemo(()=>({value:F,onChange:Le,minDate:Ve,maxDate:O,unit:s,yearStartMonth:u,...Yt(s,J),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...Qe?{stepper:C}:{}}),[F,Le,Ve,O,s,u,J,e.formatLocale,e.locale,e.labels,v,Qe,C]),te=l.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:u,macroUnit:i,microUnit:s,minDate:r,maxDate:n,macroRange:Y,microValue:F,onChangeMacroRange:Oe,onChangeMicroPoint:Te}),[D,t,i,s,r,n,Y,F,Oe,Te,u]);return{macroRange:Y,setMacroRange:he,microValue:F,setMicroValue:De,setMacroLowerDate:Ze,setMacroUpperDate:ot,setMicroDate:Le,shiftMacroRange:Q,shiftMicroValue:Ye,resetVernier:Rt,macroStartSelectorProps:Je,macroEndSelectorProps:Lt,microSelectorProps:jt,sliderProps:te}}function ho(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Mn(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function _a(e,t){return ho(Mn(e,t),t)}function ps(e){return e===void 0?0:Ls(e)?e:Number.NaN}const vs='; declare the years to offer with `minYear` / `maxYear` or `allowedYears` instead of a sentinel for "no bound"';function Xn(e,t,r,n){e!==void 0&&ll(e,t,r,n)}function ll(e,t,r,n){if(!$e(e))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${S(e)}.`);if(Number.isNaN(_a(e,r).getTime()))throw new RangeError(`YearSelector: \`${t}\` must fall in a year that starts inside the Date range, received ${S(e)}${n}.`)}function xs(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${S(e)}.`);if(Number.isNaN(ho(e,r).getTime()))throw new RangeError(`YearSelector: \`${t}\` must name a year that starts inside the Date range, received ${S(e)}; under yearStartMonth ${r} that year starts on month ${r+1}, day 1.`)}}function Iu(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`formatLocale\` must be a valid BCP 47 language tag, received ${S(e)}.`)}}function Ss(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Mn(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function ku(e,t,r,n){const o=new Set;for(const a of e){const i=Mn(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function Au(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:ku(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function Nu(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const Ou=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:s,minDate:d,maxDate:g,allowedYears:m,className:v="",style:b,disabled:M=!1,locale:U,labels:u,formatLocale:D,formatOption:f,yearStartMonth:z}=e,P=dr("YearSelector",z);if(Xn(t,"value",P,""),Xn(r,"initialDate",P,""),Xn(d,"minDate",P,vs),Xn(g,"maxDate",P,vs),xs(i,"minYear",P),xs(s,"maxYear",P),!wo(m))throw new RangeError(`YearSelector: \`allowedYears\` must be an array of Dates, received ${S(m)}.`);if(m!==void 0)for(let A=0;A<m.length;A++)ll(m[A],`allowedYears[${A}]`,P,"");Iu(D);const K=t??r;if(K===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");if(o!==void 0){const A=Na(o);if(A!==null)throw new RangeError(`YearSelector: \`${A.field}\` must be ${A.expected}, received ${A.received}.`);if(t===void 0)throw new RangeError("YearSelector: `stepper` requires the controlled `value`; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled `initialDate` would never change.")}const H=So(U,u),de=t!==void 0,[Y,re]=Oa(K,de,A=>_a(A,P),A=>Mn(A,P)),oe=d?.getTime(),V=g?.getTime(),ne=l.useMemo(()=>Ss(i,d,Math.max,P),[i,oe,P]),R=l.useMemo(()=>Ss(s,g,Math.min,P),[s,V,P]);if(ne!==null&&R!==null&&ne>R)throw new RangeError(`YearSelector: the resolved lower bound ${ne} is after the resolved upper bound ${R}.`);const E=m===void 0?null:m.map(A=>A.getTime()).join(","),$=l.useMemo(()=>Au(m,ne,R,P),[E,ne,R,P]);if($===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedYears`, are required; the year option list is never invented.");const W=l.useMemo(()=>$.kind==="discrete"?{kind:"candidates",ascending:$.ascending,loIndex:0,hiIndex:$.ascending.length-1}:{kind:"range",min:$.minYear,max:$.maxYear},[$]),J=t!==void 0?Mn(t,P):Y,F=!bn(W,J),G=A=>{if(!M){if(!bn(W,A))throw new RangeError(`YearSelector: refusing to emit ${A}, which lies outside the selectable years.`);de||re(A),n?.(ho(A,P),A)}},k=Xt(W,J,-1),ie=Xt(W,J,1),we=()=>{if(o!==void 0){o.onStep("previous");return}k!==null&&G(k)},Se=()=>{if(o!==void 0){o.onStep("next");return}ie!==null&&G(ie)},q=l.useMemo(()=>{const A=$.kind==="discrete"?[...$.ascending].reverse():Nu($.minYear,$.maxYear);return F&&(A.push(J),A.sort((ge,ue)=>ue-ge)),A.map(ge=>({value:ge,label:st("year",ho(ge,P),f,D)}))},[$,F,J,P,D,f]);return L.jsxs("div",{className:`inline-flex items-center ${hn} ${v}`,style:b,"data-out-of-range":F?"true":void 0,children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:M,canStep:o===void 0?k!==null:o.canStepPrevious,onStep:we,ariaLabel:H.previousYear}),L.jsx("select",{"aria-label":H.yearSelect,disabled:M,className:"w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",value:J,onChange:A=>{if(!A.target.value)return;const ge=Number(A.target.value);Number.isInteger(ge)&&G(ge)},children:q.map(A=>L.jsx("option",{value:A.value,disabled:F&&A.value===J,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:A.label},A.value))}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:M,canStep:o===void 0?ie!==null:o.canStepNext,onStep:Se,ariaLabel:H.nextYear}),a]})},Vu=(e,t)=>{const r=ps(t.yearStartMonth);return!(ps(e.yearStartMonth)!==r||!Aa(e,t,n=>_a(n,r))||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedYears!==t.allowedYears||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},cl=l.memo(Ou,Vu);cl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=$s;exports.DateSelector=ol;exports.MonthSelector=il;exports.PERIOD_SLIDER_LABEL_CATALOGS=ys;exports.PERIOD_SLIDER_LABEL_KEYS=vo;exports.PeriodSlider=Zs;exports.YearSelector=cl;exports.addUnit=ks;exports.areStylesEqual=Xs;exports.calculateConnectDragValues=Vs;exports.calculateHandleDragValues=ga;exports.calculateKeyboardActionValues=_s;exports.calculateLabelSlant=Ia;exports.calculateVernierMacroDrag=Ws;exports.calculateVernierMicroDrag=Ks;exports.decode=ee;exports.encode=_;exports.findNearestDateIndex=Pe;exports.formatLabel=st;exports.formatOptionText=Qs;exports.formatQuarterLabel=Tc;exports.formatScreenReaderLabel=xr;exports.getMacroWindowEndDate=Ns;exports.getMacroWindowStartDate=As;exports.getSortedAllowedDates=Cc;exports.normalizeDateByUnit=wt;exports.resolveDraggedEdge=po;exports.resolveMacroWindow=Dt;exports.resolvePeriodSliderLabels=Ps;exports.resolveQuarter=Os;exports.resolveSelectorSteps=pa;exports.resolveVernierRailZone=ka;exports.resolveVernierSelectorSteps=ir;exports.resolveVernierTargetHandle=Bs;exports.resolveWheelStep=Fs;exports.usePeriodSliderPoint=Lu;exports.usePeriodSliderRange=$u;exports.useSelectorStepper=Vt;exports.useVernierSliderPoint=Cu;exports.useVernierSliderRange=Tu;
|