@aiquants/period-slider 0.13.0 → 0.14.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 +81 -3
- package/README.md +194 -78
- package/dist/DateSelector.d.ts +13 -20
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +13 -14
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +29 -42
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/VirtualDateDropdown.d.ts +8 -0
- package/dist/VirtualDateDropdown.d.ts.map +1 -1
- package/dist/YearSelector.d.ts +13 -14
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/dateOptionDomain.d.ts +6 -6
- package/dist/dateOptionDomain.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2129 -2038
- package/dist/labels.d.ts +144 -0
- package/dist/labels.d.ts.map +1 -0
- package/dist/optionText.d.ts +5 -5
- package/dist/optionText.d.ts.map +1 -1
- package/dist/usePeriodSlider.d.ts +16 -8
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/dist/useResolvedLabels.d.ts +17 -0
- package/dist/useResolvedLabels.d.ts.map +1 -0
- package/package.json +3 -3
- package/src/DateSelector.tsx +51 -73
- package/src/MonthSelector.tsx +48 -64
- package/src/PeriodSlider.tsx +70 -87
- package/src/VirtualDateDropdown.tsx +14 -2
- package/src/YearSelector.tsx +39 -53
- package/src/dateOptionDomain.ts +8 -8
- package/src/index.ts +13 -6
- package/src/labels.ts +407 -0
- package/src/optionText.ts +21 -21
- package/src/usePeriodSlider.ts +46 -18
- package/src/useResolvedLabels.ts +35 -0
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const D=require("react/jsx-runtime"),lt=require("date-fns"),i=require("react"),us=require("@aiquants/virtualscroll"),ds=require("react-dom"),Ta=120,ao="data-drag-snap",io="--ps-drag-snap-duration",zr={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"]},qa=["low","high"],Za=["tx","ty","rot"],En={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"}},So=(e,t)=>`${e}-${t}`,so=(e,t,r)=>`var(${So(e,t)}, ${r})`,ms=(e,t,r)=>{const n=En[t];for(const o of qa)for(const a of Za)e.style.setProperty(So(n[o],a),r[o][a])},Qa=e=>Math.max(0,Math.min(1,e)),xn=(e,t,r,n)=>{const o=Qa(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},Lo=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},An=(e,t,r,n)=>{const o=Qa(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},lo=(e,t,r,n)=>{if(r){const l=(1-e)*100,c=(1-t)*100;return n?`M 12 ${c} L 12 ${l} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${l} L 20 ${c} 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`},kt=(e,t)=>`var(${e}, ${t}%)`,fs=(e,t,r,n)=>{const[o,a]=zr[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},gs=e=>{for(const[t,r]of Object.values(zr))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(En))for(const r of qa)for(const n of Za)e.style.removeProperty(So(t[r],n))},co=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),ya=new Set(["hidden","clip","scroll","auto","overlay"]),Pa=["paint","strict","content"],hs=["layout","paint","strict","content"],bs=["transform","perspective","filter"],Nr=e=>e!==void 0&&e!==""&&e!=="none",ws=e=>e!==void 0&&e!==""&&e!=="normal",dn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},ps=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,vs=(e,t)=>t==="absolute"&&Nr(e.position)&&e.position!=="static"||Nr(e.transform)||Nr(e.perspective)||Nr(e.filter)||Nr(e.backdropFilter)||ws(e.containerType)||hs.some(r=>e.contain.includes(r))?!0:bs.some(r=>e.willChange.includes(r)),Ds=(e,t,r,n,o,a)=>{const l=t.ownerDocument.defaultView;if(l===null)return!1;const c=e.getBoundingClientRect();if(c.width===0||c.height===0)return!1;const f=n?0:r,h=n?r:0;if(o<c.left-f||o>=c.right+f||a<c.top-h||a>=c.bottom+h)return!1;const p=l.getComputedStyle(t);if(p.visibility!=="visible")return!1;let M=null;for(let b=t;b!==null;b=b.parentElement){const d=b===t?p:l.getComputedStyle(b);if(M!==null&&!vs(d,M))continue;const _=ya.has(d.overflowX)||Pa.some(F=>d.contain.includes(F)),x=ya.has(d.overflowY)||Pa.some(F=>d.contain.includes(F));if(_||x){const F=b.getBoundingClientRect();if(_&&(o<F.left+dn(d.borderLeftWidth)||o>=F.right-dn(d.borderRightWidth))||x&&(a<F.top+dn(d.borderTopWidth)||a>=F.bottom-dn(d.borderBottomWidth)))return!1}M=ps(d)}return!0},uo=new Map,Ms=(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)},xs=(e,t)=>{let r=uo.get(e);if(r===void 0){const a=new Set,l=c=>Ms(a,c);r={participants:a,listener:l},uo.set(e,r),e.addEventListener("wheel",l,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(uo.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Br="gap-[11px]",ht=6,bt=ht*2,Ot=ht*4/3,Rs={left:`0,${bt/2} ${ht},0 ${ht},${bt}`,right:`${Ot},${bt/2} ${Ot-ht},0 ${Ot-ht},${bt}`,up:`${bt/2},0 0,${ht} ${bt},${ht}`,down:`${bt/2},${Ot} 0,${Ot-ht} ${bt},${Ot-ht}`},mo=e=>{e.preventDefault(),e.stopPropagation()},Ss={onMouseDownCapture:mo,onMouseUpCapture:mo,onClickCapture:mo},Ls="period-slider-step",Ts=`${Ls} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,ys="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]",Ps={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"},mn="after:inset-[calc((100%-var(--ps-target-size))/2)]",Ea={horizontal:"px-[19px]",vertical:"py-[19px]"},Es={control:{left:mn,right:mn,up:mn,down:mn},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)]"}},qt=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:l,ref:c})=>{const f=e==="up"||e==="down",h=f?bt:Ot,p=f?Ot:bt,M=r||!n;return D.jsx("button",{ref:c,type:"button","aria-label":a,disabled:r,"aria-disabled":M?!0:void 0,...M?Ss:null,onClick:M?void 0:o,className:`${l===void 0?"":`${l} `}${Ts} ${ys} ${Ps[t]} ${Es[t][e]}`,children:D.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:h,height:p,viewBox:`0 0 ${h} ${p}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:D.jsx("polygon",{points:Rs[e]})})})},Ja={"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"}},Ke=e=>e instanceof Date&&!Number.isNaN(e.getTime()),pe=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),ct=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t)||t<0||t>11)throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${pe(t)})`)},Dr=(e,t)=>t===void 0?0:(ct(e,t),t),Oe=(e,t,r=0)=>{if(!Ke(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${pe(t)})`);ct("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},ne=(e,t,r=0)=>{ct("encode",r);const n=Oe(e,t,r),o=n.getFullYear(),a=n.getMonth()+1,l=n.getDate();if(e==="year")return o;if(e==="month")return o*12+(a-1);const c=new Date(0);return c.setUTCFullYear(o,a-1,l),c.setUTCHours(0,0,0,0),Math.floor(c.getTime()/(1440*60*1e3))},le=(e,t,r=0)=>{ct("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),l=t-a*12;return n.setFullYear(a,l,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},He=(e,t,r)=>{if(!Ke(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${pe(t)})`);return e==="year"?lt.addYears(t,r):e==="month"?lt.addMonths(t,r):lt.addDays(t,r)},ei=(e,t,r,n=0)=>{if(!Ke(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${pe(r)})`);return ct("getMacroWindowStartDate",n),Oe(t,Oe(e,r,n),n)},ti=(e,t,r,n=0)=>{if(!Ke(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${pe(r)})`);if(ct("getMacroWindowEndDate",n),e===t)return Oe(t,r,n);const o=r.getFullYear(),a=r.getMonth();if(e==="year"){const l=Oe("year",r,n),c=lt.addMonths(l,11);if(t==="month")return c;if(t==="day")return Oe("day",lt.addDays(lt.addMonths(l,12),-1))}return e==="month"&&t==="day"?new Date(o,a+1,0):Oe(t,r,n)},Aa=(e,t,r)=>e<t?t:e>r?r:e,wt=(e,t,r,n,o,a=0)=>{if(ct("resolveMacroWindow",a),Ur("macroRange",r,"resolveMacroWindow"),!Ke(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${pe(n)})`);if(!Ke(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${pe(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${pe(n)}, maxDate: ${pe(o)})`);return[Oe(t,Aa(ei(e,t,r[0],a),n,o),a),Oe(t,Aa(ti(e,t,r[1],a),n,o),a)]},ri=(e,t)=>{if(!Ke(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${pe(e)})`);ct("resolveQuarter",t);const r=Oe("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}},As={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Ca=new Map,Cs=(e,t)=>{const r=`${e}\0${t}`,n=Ca.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,As[e]);return Ca.set(r,o),o},Is=4,$s=6,Cn=e=>e>=0?String(e).padStart(Is,"0"):`-${String(-e).padStart($s,"0")}`,ks=(e,t)=>{const r=Cn(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}`},Ye=(e,t,r,n)=>Ke(t)?r?r(t,e,"period"):n===void 0?ks(e,t):Cs(e,n).format(t):"",Wt=(e,t,r,n)=>Ye(e,t,r,n),Os=(e,t)=>{if(!Ke(e))return"";ct("formatQuarterLabel",t);const{quarter:r}=ri(e,t);return`${Ye("year",Oe("year",e,t))}-Q${r}`},he=(e,t,r,n=0)=>{if(ct("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;const o=ne(r,t,n);let a=0,l=e.length-1;if(o<=ne(r,e[a],n))return 0;if(o>=ne(r,e[l],n))return l;for(;a<=l;){const h=a+l>>1,p=ne(r,e[h],n);if(p===o)return h;p<o?a=h+1:l=h-1}const c=Math.abs(ne(r,e[a],n)-o),f=Math.abs(ne(r,e[l],n)-o);return c<f?a:l},St=(e,t,r,n,o=0)=>{if(ct("getSortedAllowedDates",o),!Array.isArray(e)||e.length===0)return[];const a=ne(t,r,o),l=ne(t,n,o),c=new Map;for(const f of e){const h=Oe(t,f,o),p=ne(t,h,o);p<a||p>l||c.has(p)||c.set(p,h)}if(c.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${pe(r)}, maxDate: ${pe(n)}, entries: ${e.length})`);return Array.from(c.keys()).sort((f,h)=>f-h).map(f=>c.get(f))},fn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const l=he(e,n,t,o);if(r==="time"){const c=e[0].getTime(),f=e[a].getTime()-c;return f<=0?0:Math.max(0,Math.min(1,(e[l].getTime()-c)/f))}return l/a},gn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const l=Math.max(0,Math.min(1,n));if(r==="time"){const c=e[0].getTime(),f=e[a].getTime()-c;return f<=0?0:he(e,new Date(c+l*f),t,o)}return Math.max(0,Math.min(a,Math.round(l*a)))},Mo=(e,t,r,n,o,a,l)=>{let c=r,f=n;return l?(c=t,f=t):e==="low"?t>n?(c=n,f=t):c=t:t<r?(f=r,c=t):f=t,[Math.max(o,Math.min(a,c)),Math.max(o,Math.min(a,f))]},ni=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:l,snapMode:c,unit:f,yearStartMonth:h=0})=>{if(a){const x=l.length-1;if(x<=0)return[0,0];const F=Math.max(0,Math.min(x,Math.round(t))),ce=Math.max(F,Math.min(x,Math.round(r)));if(c==="time"){const V=l[0].getTime(),O=l[x].getTime(),ie=l[F].getTime(),j=l[ce].getTime()-ie;let re=ie+e*(O-V),K=re+j;re<V&&(re=V,K=V+j),K>O&&(K=O,re=O-j);const T=he(l,new Date(re),f,h),L=he(l,new Date(K),f,h);return[T,Math.max(T,L)]}const Z=Math.round(e*x);let u=F+Z,X=ce+Z;return u<0&&(X+=-u,u=0),X>x&&(u-=X-x,X=x),[Math.max(0,Math.min(x,u)),Math.max(0,Math.min(x,X))]}const p=x=>Math.max(n,Math.min(o,x)),M=o-n;if(M<=0)return[p(t),p(r)];const b=Math.round(e*M);let d=t+b,_=r+b;return d<n&&(_+=n-d,d=n),_>o&&(d-=_-o,_=o),[p(d),p(_)]},oi=(e,t,r,n,o,a,l,c)=>{let f=0,h=!1,p=!1;switch(e){case"ArrowRight":case"ArrowUp":f=c;break;case"ArrowLeft":case"ArrowDown":f=-c;break;case"PageUp":f=c*5;break;case"PageDown":f=-c*5;break;case"Home":h=!0;break;case"End":p=!0;break;default:return null}if(l){let d=r;return h?d=o:p?d=a:d=Math.max(o,Math.min(a,r+f)),[d,d]}let M=r,b=n;return t==="low"?h?M=o:p?M=n:M=Math.max(o,Math.min(n,r+f)):h?b=r:p?b=a:b=Math.max(r,Math.min(a,n+f)),[M,b]},ai=8,ii=2,si=16,Ns=12,Vs=90,li=(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}},To=(e,t)=>{const r=t?.estimatedHeightPx??si,o=ai+(t?.anchorGapY??ii)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},yo=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,l=o?.estimatedHeightPx??si,c=o?.paddingPx??Ns,f=o?.maxAngleDeg??Vs,h=ai+(o?.anchorGapY??ii),p=To(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return p;const M=Math.max(0,t-e)/100*r,b=a+c;if(M>=b)return p;const d=Math.max(0,Math.min(1,(b-M)/b)),x=d*d*d*(d*(d*6-15)+10)*f,F=n==="top"?-x:x,ce=li(a,l,x),Z=h+ce.acrossPx,u=n==="top"?-Z:+Z,X=2*ce.alongPx,V=Math.max(0,(X+c-M)/2);return{lowAngleDeg:F,highAngleDeg:F,lowOffsetX:-V,highOffsetX:V,lowOffsetY:u,highOffsetY:u,isSlanted:d>.001,proximity:d}},ci=e=>({...e,lowOffsetX:0,highOffsetX:0}),Po=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},ui=(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 di(e,t,r,n,o,a,l="macro-top",c=.05,f=!0,h="range"){if(Po(t,l)==="macro"){const b=Math.abs(e-r),d=Math.abs(e-n);return b<=c&&b<=d?"macro-low":d<=c&&d<b?"macro-high":f&&e>=r&&e<=n?"macro-connect":b<d?"macro-low":"macro-high"}if(h==="point")return"micro-point";const p=Math.abs(e-o),M=Math.abs(e-a);return p<=c&&p<=M?"micro-low":M<=c&&M<p?"micro-high":f&&e>=o&&e<=a?"micro-connect":p<M?"micro-low":"micro-high"}function mi(e,t,r,n,o){if(e==="macro-connect"){const[h,p]=Lo(t-r,n,o);return[h,p,"macro-connect"]}const a=e==="macro-low"?"low":"high",[l,c]=xn(a,t,n,o),f=An(a,t,n,o);return[l,c,f==="low"?"macro-low":"macro-high"]}function fi(e,t,r,n,o){if(e==="micro-point"){const[h]=xn("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,p]=Lo(t-r,n,o);return[h,p,"micro-connect"]}const a=e==="micro-low"?"low":"high",[l,c]=xn(a,t,n,o),f=An(a,t,n,o);return[l,c,f==="low"?"micro-low":"micro-high"]}const jr=i.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 l=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return D.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:D.jsx("path",{d:o,className:l,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});jr.displayName="VernierKnobSvg";const Ys=(e,t)=>{if(!Ke(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${pe(e)})`);if(!Ke(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${pe(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${pe(e)}, maxDate: ${pe(t)})`)},Ur=(e,t,r="PeriodSlider")=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`${r}: ${e} is required and must be a [start, end] Date tuple (received: ${pe(t)})`);const[n,o]=t;if(!Ke(n))throw new RangeError(`${r}: ${e}[0] must be a valid Date (received: ${pe(n)})`);if(!Ke(o))throw new RangeError(`${r}: ${e}[1] must be a valid Date (received: ${pe(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`${r}: ${e} must not be inverted (start: ${pe(n)}, end: ${pe(o)})`)},xo=(e,t)=>{if(!Ke(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${pe(t)})`)},Rt=(e,t,r,n,o,a)=>{const l=ne(r,t,a);if(l<ne(r,n,a)||l>ne(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${pe(t)}, minDate: ${pe(n)}, maxDate: ${pe(o)})`)},Hs=(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&&(Ur(o,a),Rt(`${o}[0]`,a[0],e.unit,t,r,n),Rt(`${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&&(xo(o,a),Rt(o,a,e.unit,t,r,n))}},_s=(e,t,r)=>{const n=e.yearStartMonth??0;Ur("macroRange",e.macroRange);const o=e.microUnit??e.unit,a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,l=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&l)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(l){if(e.microValue!==void 0)return xo("microValue",e.microValue),Rt("microValue",e.microValue,o,t,r,n),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return xo("defaultMicroValue",e.defaultMicroValue),Rt("defaultMicroValue",e.defaultMicroValue,o,t,r,n),{shape:"point",selection:[e.defaultMicroValue,e.defaultMicroValue]};throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)")}if(e.microRange!==void 0)return Ur("microRange",e.microRange),Rt("microRange[0]",e.microRange[0],o,t,r,n),Rt("microRange[1]",e.microRange[1],o,t,r,n),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return Ur("defaultMicroRange",e.defaultMicroRange),Rt("defaultMicroRange[0]",e.defaultMicroRange[0],o,t,r,n),Rt("defaultMicroRange[1]",e.defaultMicroRange[1],o,t,r,n),{shape:"range",selection:e.defaultMicroRange};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")},Vr=(e,t,r,n,o,a,l,c,f)=>{const h=he(e,n,t,f),p=he(e,o,t,f);return l?h:c?p:Math.max(h,Math.min(p,he(e,r,t,f)+a))},fo=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Ia=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback((a,l)=>{const c=r.current;if(c!==null&&c[0].getTime()===a.getTime()&&c[1].getTime()===l.getTime())return;const f=[a,l];r.current=f,t(f)},[]),o=i.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Fs=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},br=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(l=>{for(const c of l){const f=c.borderBoxSize?.[0];f!==void 0&&t(h=>h!==null&&Math.abs(h.widthPx-f.inlineSize)<.5&&Math.abs(h.heightPx-f.blockSize)<.5?h:{widthPx:f.inlineSize,heightPx:f.blockSize})}});a.observe(o),r.current=a},[]);return i.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},go=(e,t)=>{const r=vn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},vn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},js=e=>{const t={};let r=0;for(const o of e){const{side:a,box:l}=o;if(l===null)continue;let c;if(o.reach==="inline-size")c=l.widthPx,r=Math.max(r,l.heightPx/2);else{const f=li(l.widthPx,l.heightPx,o.angleDeg);c=o.centreOffsetPx===null?2*f.acrossPx:Math.abs(o.centreOffsetPx)+f.acrossPx,r=Math.max(r,f.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${Math.ceil(c)}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}},$a=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),ka=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),Rn=(e,t)=>({"--ps-tooltip-tx":so(e,"tx",t.tx),"--ps-tooltip-ty":so(e,"ty",t.ty),"--ps-tooltip-rot":so(e,"rot",t.rot)}),ho=(e,t,r,n)=>{const o=To(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=yo(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),l=n.isMerged?ci(a):a,c=En[e],f={low:$a(l.lowOffsetX,l.lowOffsetY-o.lowOffsetY,l.lowAngleDeg),high:$a(l.highOffsetX,l.highOffsetY-o.highOffsetY,l.highAngleDeg)};return{slant:l,lowStyle:Rn(c.low,f.low),highStyle:Rn(c.high,f.high),placements:f}},Oa={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Na=(e,t,r)=>{const n=To(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Oa,highStyle:Oa,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const f=yo(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?ci(f):f}const l=En.flat,c={low:ka(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:ka(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...Rn(l.low,c.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...Rn(l.high,c.high)},placements:o?c:null}},zs={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Us={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"}},Va={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},Bs={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Br} ${Ea.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Va.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Br} ${Ea.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Va.vertical}`}},Ya={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"}},Ha=(e,t)=>{e.setPointerCapture(t)},Ws=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:l=!1,className:c="",showStepper:f=!0,tooltipStyle:h="always",labelPosition:p="top",autoSlantLabels:M=!0,isVertical:b=!1,hideConnectBar:d=!1,showTicks:_=!1,colorScheme:x="blue-rose",locale:F,decreaseAriaLabel:ce="Decrease",increaseAriaLabel:Z="Increase"}=e,u=Dr("PeriodSlider",e.yearStartMonth);Ys(r,n),Hs(e,r,n),F!==void 0&&Fs("locale",F);const X=e.mode==="vernier"?_s(e,r,n):null,V=X!==null&&X.shape==="point",O=Ja[x],ie=i.useId(),j=i.useRef(e),re=r.getTime(),K=n.getTime(),T=i.useMemo(()=>St(o,t,r,n,u),[o,t,re,K,u]),L=T.length>0,{rangeMin:H,rangeMax:S}=i.useMemo(()=>L?{rangeMin:0,rangeMax:T.length-1}:{rangeMin:ne(t,r,u),rangeMax:ne(t,n,u)},[L,T,t,re,K,u]),I=e.mode==="point",Y=i.useCallback(s=>{if(L){const m=Math.max(0,Math.min(T.length-1,Math.round(s)));return T[m]}return le(t,Math.round(s),u)},[L,T,t,u]),ee=i.useCallback(s=>{if(s===void 0)return H;const m=Oe(t,s,u);return L?he(T,m,t,u):ne(t,m,u)},[L,T,t,H,u]),[_e,ue]=i.useState(()=>X===null?null:X.selection);let B=_e??(X===null?null:X.selection);if(V&&B!==null&&B[0].getTime()!==B[1].getTime()){const s=[B[0],B[0]];B=s,ue(s)}const q=e.mode==="vernier"?e.microValue?.getTime():void 0,te=i.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,q]),se=Ia(),E=Ia(),U=e.mode!=="vernier"?null:V?te??B:e.microRange!==void 0?e.microRange:B,ge=U===null?null:E.shown??U,Ie=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ge?.[0]:void 0,Ne=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ge?.[1]:void 0,Fe=e.mode==="point"?e.value??e.defaultValue:void 0,qe=e.mode==="point"?Fe?.getTime():Ie?.getTime(),Ze=e.mode==="range"?Ne?.getTime():qe,[be,Te]=i.useMemo(()=>{if(e.mode==="point"){const g=ee(Fe);return[g,g]}const s=ee(Ie),m=ee(Ne);return[Math.min(s,m),Math.max(s,m)]},[e.mode,qe,Ze,ee,Fe,Ie,Ne]),Pe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:V?e.microValue!==void 0:e.microRange!==void 0,[G,oe]=i.useState(()=>[be,Te]),[me,v]=i.useState(null),[R,Q]=i.useState(null),fe=i.useRef(null),[De,Me]=i.useState("high"),[xe,ut]=i.useState(null),[nt,Nt]=i.useState(null),ve=me?me[0]:Pe?be:G[0],Ee=me?me[1]:Pe?Te:G[1],y=i.useRef([ve,Ee]),A=e.mode==="vernier",Ue=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",$=Ue==="macro-top"||Ue==="macro-left",Vt=e.mode==="vernier"?e.showVernierProjection??!0:!1,ot=e.mode==="vernier"?e.showVernierTicks??!0:!1,Wr=e.mode==="vernier"?e.showHairline??!0:!1,J=A?e.macroUnit??t:t,C=A?e.microUnit??t:t,kn=A?e.macroIsDiscrete??!1:L,Mr=A?e.microIsDiscrete??!1:L,Eo=A?e.macroAllowedDates??o:o,Ao=A?e.microAllowedDates??o:o,Gr=A?e.formatMacroLabel??e.formatLabel:e.formatLabel,Xr=A?e.formatMicroLabel??e.formatLabel:e.formatLabel,Si=Ie?.getTime(),Li=Ne?.getTime(),[Qe,Kr]=i.useState(null),Lt=i.useRef(null),[xr,Zt]=i.useState(()=>V?"micro-point":"micro-high");let Ve=xr;const On=V?xr==="micro-low"||xr==="micro-high"||xr==="micro-connect"?"micro-point":null:xr==="micro-point"?"micro-high":null;On!==null&&(Ve=On,Zt(On));const je=i.useMemo(()=>ne(J,r,u),[re,J,u]),dt=i.useMemo(()=>{const s=ne(J,n,u);if(A&&s<=je)throw new RangeError(`PeriodSlider: macroUnit "${J}" cannot distinguish minDate from maxDate (minDate: ${pe(r)}, maxDate: ${pe(n)})`);return s},[A,re,K,je,J,u]),ye=i.useMemo(()=>A&&kn?St(Eo,J,r,n,u):[],[A,kn,Eo,J,re,K,u]),Co=s=>[Math.max(je,Math.min(dt,ne(J,s[0],u))),Math.max(je,Math.min(dt,ne(J,s[1],u)))],[Io,$o]=e.mode!=="vernier"?[je,dt]:Co(e.macroRange),[Be,We]=se.shown===null?[Io,$o]:Co(se.shown),pt=i.useMemo(()=>le(J,Be,u),[J,Be,u]),Yt=i.useMemo(()=>le(J,We,u),[J,We,u]),qr=i.useMemo(()=>e.mode!=="vernier"?[r,n]:wt(J,C,[pt,Yt],r,n,u),[e.mode,pt,Yt,J,C,re,K,u]),Re=i.useMemo(()=>ne(C,qr[0],u),[C,qr,u]),Ce=i.useMemo(()=>ne(C,qr[1],u),[C,qr,u]),ko=i.useMemo(()=>A&&Mr?St(Ao,C,r,n,u):[],[A,Mr,Ao,C,re,K,u]),Nn=(s,m)=>ko.filter(g=>{const w=ne(C,g,u);return w>=s&&w<=m}),de=i.useMemo(()=>Nn(Re,Ce),[ko,C,Re,Ce]),Qt=kn&&ye.length>0,at=Mr&&de.length>0,Tt=(s,m,g,w)=>m.length>0?ne(C,m[he(m,s,C,u)],u):Math.max(g,Math.min(w,ne(C,s,u))),Jt=at?de:[],$e=i.useMemo(()=>ge===null?Re:Tt(ge[0],Jt,Re,Ce),[Si,Re,Ce,C,ge,Jt]),Ge=i.useMemo(()=>ge===null?Ce:Tt(ge[1],Jt,Re,Ce),[Li,Re,Ce,C,ge,Jt]),yt=i.useMemo(()=>le(C,$e,u),[C,$e,u]),Pt=i.useMemo(()=>le(C,Ge,u),[C,Ge,u]),Oo=!A||U===null?null:{macroUnit:J,macroLowEnc:Io,macroHighEnc:$o,microUnit:C,microLowEnc:ne(C,U[0],u),microHighEnc:ne(C,U[1],u)},Vn=i.useRef(Oo),Zr=Math.max(1,dt-je),it=Qt?fn(ye,J,a,pt,u):Math.max(0,Math.min(1,(Be-je)/Zr)),mt=Math.max(it,Qt?fn(ye,J,a,Yt,u):Math.min(1,(We-je)/Zr)),Qr=Math.max(1,Ce-Re),er=at?fn(de,C,a,yt,u):Math.max(0,Math.min(1,($e-Re)/Qr)),Rr=Math.max(er,at?fn(de,C,a,Pt,u):Math.min(1,(Ge-Re)/Qr)),Yn=i.useRef({timerId:null,emit:null}),Jr=i.useRef({timerId:null,emit:null}),en=i.useRef({timerId:null,emit:null});i.useEffect(()=>{const s=[Yn,Jr,en];return()=>{for(const m of s)fo(m.current)}},[]);const tr=i.useCallback((s,m,g)=>{fo(s);const{debounceMs:w}=j.current;if(g||!w||w<=0){m();return}s.emit=m,s.timerId=setTimeout(()=>{s.timerId=null,s.emit=null,m()},w)},[]),No=i.useCallback(s=>{const m=s.emit;fo(s),m?.()},[]),rr=i.useCallback(s=>new Date(Math.min(Math.max(s.getTime(),re),K)),[re,K]),Et=i.useCallback((s,m,g=!1)=>{const[w,P]=y.current;if((j.current.mode==="point"?s===w:s===w&&m===P)&&Yn.current.timerId===null)return;const z=Y(s),N=Y(m),ae=()=>{const we=j.current;we.mode==="point"?we.onChangePoint?.(z):we.mode==="range"&&we.onChangeRange?.(z,N)};tr(Yn.current,ae,g)},[Y,tr]),Ht=i.useCallback((s,m,g=!1)=>{const w=Vn.current;if(j.current.mode!=="vernier"||w===null)return;const P=rr(s),k=rr(m);ne(w.macroUnit,P,u)===w.macroLowEnc&&ne(w.macroUnit,k,u)===w.macroHighEnc&&Jr.current.timerId===null||tr(Jr.current,()=>{const z=j.current;z.mode==="vernier"&&z.onChangeMacroRange?.(P,k)},g)},[rr,tr,u]),et=i.useCallback((s,m,g=!1)=>{const w=j.current,P=Vn.current;if(w.mode!=="vernier"||P===null)return;const k=rr(s),z=rr(m);ne(P.microUnit,k,u)===P.microLowEnc&&ne(P.microUnit,z,u)===P.microHighEnc&&en.current.timerId===null||((V?w.microValue===void 0:w.microRange===void 0)&&ue([k,z]),tr(en.current,()=>{const N=j.current;if(N.mode==="vernier"){if(V){N.onChangeMicroPoint?.(k);return}N.onChangeMicroRange?.(k,z)}},g))},[rr,tr,V,u]),Vo=i.useCallback((s,m=!1)=>{et(s,s,m)},[et]),_t=i.useCallback(s=>{if(L&&a==="time"&&T.length>1){const w=Math.max(0,Math.min(T.length-1,Math.round(s))),P=T[0].getTime(),z=T[T.length-1].getTime()-P;if(z<=0)return 0;const N=T[w].getTime();return Math.max(0,Math.min(100,(N-P)/z*100))}const m=S-H;if(m<=0)return 0;const g=(s-H)/m*100;return Math.max(0,Math.min(100,g))},[L,a,T,H,S]),Hn=i.useCallback(s=>{const m=Math.max(0,Math.min(100,s));if(L){if(a==="time"&&T.length>1){const P=T[0].getTime(),z=T[T.length-1].getTime()-P,N=P+m/100*z;return he(T,new Date(N),t,u)}const w=Math.round(m/100*(T.length-1));return Math.max(0,Math.min(T.length-1,w))}const g=H+m/100*(S-H);return Math.round(g)},[L,a,T,H,S,t,u]),Sr=i.useRef(null),Yo=i.useRef(null),Ho=i.useRef(0),Je=i.useRef(null),_n=i.useRef(null),_o=i.useRef(null),Fo=i.useRef(null),[Fn,jo]=i.useState(0),[Ti,nr]=br(),[yi,zo]=br(),[Pi,Uo]=br(),[Ei,Bo]=br(),[Ai,jn]=br(),[Ci,Wo]=br(),Ii=I?nr===null?void 0:{estimatedWidthPx:nr.widthPx,estimatedHeightPx:nr.heightPx}:go(nr,zo),zn=!I&&ve===Ee,Un=Be===We,Bn=!V&&$e===Ge,$i=$?"top":"bottom",ki=$?"bottom":"top",Go=M&&!b,Oi=Go&&!V,Wn={isPointMode:I,isVertical:b,autoSlantLabels:M,isMerged:zn,trackLengthPx:Fn,labelPosition:p,config:Ii},Gn={trackLengthPx:Fn,labelPosition:$i,config:go(Uo,Bo),isMerged:Un,isSlantable:Go},Xn={trackLengthPx:Fn,labelPosition:ki,config:go(jn,Wo),isMerged:Bn,isSlantable:Oi};i.useEffect(()=>{const s=Je.current;if(!s)return;const m=()=>{const w=s.getBoundingClientRect(),P=b?w.height:w.width;P>0&&jo(k=>Math.abs(k-P)<.5?k:P)};if(m(),typeof ResizeObserver<"u"){const w=new ResizeObserver(P=>{for(const k of P){const z=b?k.contentRect.height:k.contentRect.width;z>0&&jo(N=>Math.abs(N-z)<.5?N:z)}});return w.observe(s),()=>w.disconnect()}const g=s.ownerDocument.defaultView;if(g)return g.addEventListener("resize",m),()=>g.removeEventListener("resize",m)},[b]);const or=i.useCallback((s,m,g)=>{const w=b?g.height:g.width;if(!(Number.isFinite(w)&&w>0))return null;const P=b?g.bottom-m:s-g.left;return Number.isFinite(P)?Math.max(0,Math.min(1,P/w)):null},[b]),Xo=i.useCallback((s,m)=>{const g=Je.current;if(!g)return null;const w=or(s,m,g.getBoundingClientRect());return w===null?null:w*100},[or]),Lr=i.useRef(null),vt=i.useRef(null),tn=i.useRef({macroLowRatio:it,macroHighRatio:mt,isVertical:b,isMacroFirstRail:$}),Ko=i.useRef({flat:Wn,macro:Gn,micro:Xn});i.useLayoutEffect(()=>{tn.current={macroLowRatio:it,macroHighRatio:mt,isVertical:b,isMacroFirstRail:$},Ko.current={flat:Wn,macro:Gn,micro:Xn},j.current=e,y.current=[ve,Ee],Vn.current=Oo,fe.current=R,Lt.current=Qe});const qo=(s,m)=>{const g=tn.current;_n.current?.setAttribute("d",lo(s,m,g.isVertical,g.isMacroFirstRail))},Ni=(s,m,g)=>{const w=Ko.current;return s==="flat"?Na(m*100,g*100,w.flat).placements:ho(s,m,g,s==="macro"?w.macro:w.micro).placements},Tr=(s,m,g)=>{const w=Je.current;if(!w)return;Lr.current={rail:s,lowRatio:m,highRatio:g},fs(w,s,m,g);const P=Ni(s,m,g);P!==null&&ms(w,s,P),s==="macro"&&qo(m,g)},Ft=i.useCallback(()=>{vt.current!==null&&(clearTimeout(vt.current),vt.current=null);const s=Je.current;s&&(s.removeAttribute(ao),s.style.removeProperty(io))},[]),Zo=()=>{const s=Je.current;if(Lr.current===null||!s){Lr.current=null;return}Lr.current=null,vt.current!==null&&clearTimeout(vt.current),s.style.setProperty(io,`${Ta}ms`),s.setAttribute(ao,"true"),gs(s),qo(tn.current.macroLowRatio,tn.current.macroHighRatio),vt.current=setTimeout(()=>{vt.current=null,s.removeAttribute(ao),s.style.removeProperty(io)},Ta)};i.useLayoutEffect(()=>{const s=Lr.current;s!==null&&Tr(s.rail,s.lowRatio,s.highRatio)}),i.useEffect(()=>()=>{vt.current!==null&&clearTimeout(vt.current)},[]);const ar=i.useRef(null),ir=i.useRef(null),ft=i.useRef(null),Kn=i.useRef(null),yr=i.useRef(null),At=i.useCallback(()=>ar.current!==null||ir.current!==null,[]),Qo=s=>{if(l)return;if(A){const W=ir.current;if(!W||s.pointerId!==W.pointerId||!Je.current)return;const st=or(s.clientX,s.clientY,Je.current.getBoundingClientRect());if(st===null)return;if(W.handle==="macro-low"||W.handle==="macro-high"||W.handle==="macro-connect"){const[ke,Ae,Dt]=mi(W.handle,st,W.startPointerRatio,W.startMacroLowRatio,W.startMacroHighRatio);Tr("macro",ke,Ae),Dt!==Lt.current&&(Lt.current=Dt,Kr(Dt),Zt(Dt));let ze,tt;if(Qt){const Ct=gn(ye,J,a,ke,u),It=Math.max(Ct,gn(ye,J,a,Ae,u));ze=ye[Ct],tt=ye[It]}else{const Ct=Math.round(je+ke*Zr),It=Math.round(je+Ae*Zr);ze=le(J,Ct,u),tt=le(J,It,u)}se.show(ze,tt);const Ir=`${ze.getTime()}_${tt.getTime()}`;Ir!==Kn.current&&(Kn.current=Ir,Ht(ze,tt));const[Mt,zt]=wt(J,C,[ze,tt],r,n,u),no=ne(C,Mt,u),oo=ne(C,zt,u),xa=Mr?Nn(no,oo):[];let Ut,Bt;if(W.handle==="macro-connect"){const Ct=Mt,It=zt;let fr,gr;if(J==="year"){const $t=ze.getFullYear()-W.startMacroLowDate.getFullYear();fr=He("year",W.initialMicroLowDate,$t),gr=He("year",W.initialMicroHighDate,$t)}else if(J==="month"){const $t=(ze.getFullYear()-W.startMacroLowDate.getFullYear())*12+(ze.getMonth()-W.startMacroLowDate.getMonth());fr=He("month",W.initialMicroLowDate,$t),gr=He("month",W.initialMicroHighDate,$t)}else{const $t=Math.round((ze.getTime()-W.startMacroLowDate.getTime())/864e5);fr=He("day",W.initialMicroLowDate,$t),gr=He("day",W.initialMicroHighDate,$t)}const hr=Ct.getTime(),$r=It.getTime(),La=W.initialMicroHighDate.getTime()-W.initialMicroLowDate.getTime();let kr=fr.getTime(),Or=gr.getTime();kr<hr&&(kr=hr,Or=Math.min($r,kr+La)),Or>$r&&(Or=$r,kr=Math.max(hr,Or-La)),Ut=Oe(C,new Date(kr),u),Bt=Oe(C,new Date(Or),u)}else{const Ct=Mt.getTime(),It=zt.getTime(),fr=W.initialMicroLowDate.getTime(),gr=W.initialMicroHighDate.getTime(),hr=Math.max(Ct,Math.min(It,fr)),$r=Math.max(hr,Math.min(It,gr));Ut=Oe(C,new Date(hr),u),Bt=Oe(C,new Date($r),u)}const Ra=Tt(Ut,xa,no,oo),cs=Math.max(Ra,Tt(Bt,xa,no,oo));Ut=le(C,Ra,u),Bt=le(C,cs,u),E.show(Ut,Bt);const Sa=`${Ut.getTime()}_${Bt.getTime()}`;Sa!==yr.current&&(yr.current=Sa,et(Ut,Bt))}else if(W.handle==="micro-low"||W.handle==="micro-high"||W.handle==="micro-connect"||W.handle==="micro-point"){const[ke,Ae,Dt]=fi(W.handle,st,W.startPointerRatio,W.startMicroLowRatio,W.startMicroHighRatio);Tr("micro",ke,Ae),Dt!==Lt.current&&(Lt.current=Dt,Kr(Dt),Zt(Dt));let ze,tt;if(at){const Mt=gn(de,C,a,ke,u),zt=Math.max(Mt,gn(de,C,a,Ae,u));ze=de[Mt],tt=de[zt]}else{const Mt=Tt(le(C,Math.round(Re+ke*Qr),u),Jt,Re,Ce),zt=Math.max(Mt,Tt(le(C,Math.round(Re+Ae*Qr),u),Jt,Re,Ce));ze=le(C,Mt,u),tt=le(C,zt,u)}E.show(ze,tt);const Ir=`${ze.getTime()}_${tt.getTime()}`;Ir!==yr.current&&(yr.current=Ir,et(ze,tt))}return}const m=ar.current;if(!m||s.pointerId!==m.pointerId||!Je.current)return;const g=Je.current.getBoundingClientRect(),w=b?s.clientY:s.clientX,P=b?g.height:g.width;if(!(Number.isFinite(P)&&P>0))return;if(m.handle==="connect"){const W=b?(m.startPointerPos-w)/P:(w-m.startPointerPos)/P,[st,ke]=Lo(W,m.startLowRatio,m.startHighRatio);Tr("flat",st,ke);const Ae=ni({posDiffPct:W,startLowVal:m.startLowVal,startHighVal:m.startHighVal,rangeMin:H,rangeMax:S,isDiscrete:L,sortedAllowedDates:T,snapMode:a,unit:t,yearStartMonth:u});if(ft.current&&ft.current[0]===Ae[0]&&ft.current[1]===Ae[1])return;ft.current=Ae,v(Ae),Et(Ae[0],Ae[1],!1);return}const k=or(s.clientX,s.clientY,g);if(k===null)return;const[z,N]=xn(I?"point":m.handle,k,m.startLowRatio,m.startHighRatio);Tr("flat",z,N);const ae=Hn(k*100),[we,Se]=Mo(m.handle,ae,m.startLowVal,m.startHighVal,H,S,I);if((!ft.current||ft.current[0]!==we||ft.current[1]!==Se)&&(ft.current=[we,Se],v([we,Se]),Et(we,Se,!1)),!I&&(m.handle==="low"||m.handle==="high")){const W=An(m.handle,k,m.startLowRatio,m.startHighRatio);fe.current!==W&&(fe.current=W,Q(W),Me(W))}},Jo=()=>{Zo(),Kn.current=null,yr.current=null,ir.current=null,Lt.current=null,Kr(null),se.release(),E.release(),No(Jr.current),No(en.current)},ea=()=>{Zo();const s=ft.current??me;s&&(Et(s[0],s[1],!0),oe(s)),ft.current=null,v(null),ar.current=null,fe.current=null,Q(null)},ta=s=>{if(A){const g=ir.current;if(!g||s.pointerId!==g.pointerId)return;Jo();return}const m=ar.current;!m||s.pointerId!==m.pointerId||ea()},ra=()=>{ir.current!==null&&Jo(),ar.current!==null&&ea()},qn=i.useRef(Qo),na=i.useRef(ta),oa=i.useRef(ra);i.useLayoutEffect(()=>{qn.current=Qo,na.current=ta,oa.current=ra});const aa=i.useRef(A);i.useEffect(()=>{aa.current!==A&&(aa.current=A,oa.current())},[A]);const ia=R!==null||Qe!==null;i.useEffect(()=>{if(!ia)return;const s=Sr.current?.ownerDocument.defaultView;if(!s)return;const m=w=>qn.current(w),g=w=>na.current(w);return s.addEventListener("pointermove",m),s.addEventListener("pointerup",g),s.addEventListener("pointercancel",g),s.addEventListener("lostpointercapture",g),()=>{s.removeEventListener("pointermove",m),s.removeEventListener("pointerup",g),s.removeEventListener("pointercancel",g),s.removeEventListener("lostpointercapture",g)}},[ia]);const Zn=i.useCallback((s,m,g,w)=>{Ft(),Ha(s,m),ar.current={pointerId:m,handle:g,startPointerPos:w,startLowVal:ve,startHighVal:Ee,startLowRatio:_t(ve)/100,startHighRatio:_t(Ee)/100},fe.current=g,Q(g),g!=="connect"&&Me(g)},[ve,Ee,_t]),sa=i.useCallback((s,m,g,w)=>{j.current.mode==="vernier"&&(Ft(),Ha(s,m),ir.current={pointerId:m,handle:g,startPointerRatio:w,startMacroLowRatio:it,startMacroHighRatio:mt,startMicroLowRatio:er,startMicroHighRatio:Rr,startMacroLowDate:pt,initialMicroLowDate:yt,initialMicroHighDate:Pt},Lt.current=g,Kr(g),Zt(g))},[it,mt,er,Rr,pt,yt,Pt]),la=s=>m=>{if(l||At())return;m.stopPropagation(),m.preventDefault(),Me(s);const g=b?m.clientY:m.clientX;Zn(m.currentTarget,m.pointerId,s,g)},ca=s=>()=>{l||fe.current!==null||Me(s)},rn=s=>()=>{l||Lt.current!==null||Zt(s)},sr=s=>m=>{if(l||At())return;m.stopPropagation(),m.preventDefault();const g=Je.current;if(!g)return;const w=or(m.clientX,m.clientY,g.getBoundingClientRect());w!==null&&sa(m.currentTarget,m.pointerId,s,w)},Vi=s=>{if(l||d||At())return;s.stopPropagation(),s.preventDefault();const m=b?s.clientY:s.clientX;Zn(s.currentTarget,s.pointerId,"connect",m)},Yi=s=>{if(l||At())return;if(A){const N=Je.current;if(!N)return;const ae=N.getBoundingClientRect(),we=or(s.clientX,s.clientY,ae);if(we===null)return;const Se=b?s.clientX-(ae.left+ae.width/2):s.clientY-(ae.top+ae.height/2),W=di(we,Se,it,mt,er,Rr,Ue,void 0,!d,V?"point":"range");sa(s.currentTarget,s.pointerId,W,we),qn.current(s.nativeEvent);return}const m=Xo(s.clientX,s.clientY);if(m===null)return;const g=Hn(m);let w="low";if(!I){const N=Math.abs(g-ve),ae=Math.abs(g-Ee);N<ae?w="low":ae<N?w="high":w=g>Ee?"high":"low"}Me(w);const[P,k]=Mo(w,g,ve,Ee,H,S,I);v([P,k]),Et(P,k,!0);const z=b?s.clientY:s.clientX;Zn(s.currentTarget,s.pointerId,w,z)},Hi=s=>{if(l||A||R!==null)return;const m=Xo(s.clientX,s.clientY);if(m===null)return;const g=Hn(m);ut(g),Nt(_t(g))},_i=()=>{ut(null),Nt(null)},ua=s=>m=>{if(l||At())return;Me(s);const g=oi(m.key,s,ve,Ee,H,S,I,1);g&&(m.preventDefault(),Ft(),Pe||oe(g),Et(g[0],g[1],!0))},lr=(s,m)=>{if(U===null)return;const[g,w]=wt(J,C,[s,m],r,n,u),P=ne(C,g,u),k=ne(C,w,u),z=Mr?Nn(P,k):[],N=Tt(U[0],z,P,k),ae=Math.max(N,Tt(U[1],z,P,k));et(le(C,N,u),le(C,ae,u),!0)},nn=s=>m=>{if(l||!A||e.mode!=="vernier"||At())return;Zt(s);let g=0,w=!1,P=!1;switch(m.key){case"ArrowRight":case"ArrowUp":g=1;break;case"ArrowLeft":case"ArrowDown":g=-1;break;case"PageUp":g=5;break;case"PageDown":g=-5;break;case"Home":w=!0;break;case"End":P=!0;break;default:return}if(m.preventDefault(),Ft(),s==="macro-low"){const k=le(J,Be,u),z=le(J,We,u);if(Qt){const we=Vr(ye,J,k,ye[0],z,g,w,P,u);if(we===he(ye,k,J,u))return;const Se=ye[we];Ht(Se,z,!0),lr(Se,z);return}let N;if(w?N=je:P?N=We:N=Math.max(je,Math.min(We,Be+g)),N===Be)return;const ae=le(J,N,u);Ht(ae,z,!0),lr(ae,z)}else if(s==="macro-high"){const k=le(J,Be,u),z=le(J,We,u);if(Qt){const we=Vr(ye,J,z,k,ye[ye.length-1],g,w,P,u);if(we===he(ye,z,J,u))return;const Se=ye[we];Ht(k,Se,!0),lr(k,Se);return}let N;if(w?N=Be:P?N=dt:N=Math.max(Be,Math.min(dt,We+g)),N===We)return;const ae=le(J,N,u);Ht(k,ae,!0),lr(k,ae)}else if(s==="micro-low"){const k=le(C,$e,u),z=le(C,Ge,u);if(at){const ae=Vr(de,C,k,de[0],z,g,w,P,u);if(ae===he(de,k,C,u))return;et(de[ae],z,!0);return}let N;if(w?N=Re:P?N=Ge:N=Math.max(Re,Math.min(Ge,$e+g)),N===$e)return;et(le(C,N,u),z,!0)}else if(s==="micro-high"){const k=le(C,$e,u),z=le(C,Ge,u);if(at){const ae=Vr(de,C,z,k,de[de.length-1],g,w,P,u);if(ae===he(de,z,C,u))return;et(k,de[ae],!0);return}let N;if(w?N=$e:P?N=Ce:N=Math.max($e,Math.min(Ce,Ge+g)),N===Ge)return;et(k,le(C,N,u),!0)}else if(s==="micro-point"){const k=le(C,$e,u);if(at){const N=Vr(de,C,k,de[0],de[de.length-1],g,w,P,u);if(N===he(de,k,C,u))return;Vo(de[N],!0);return}let z;if(w?z=Re:P?z=Ce:z=Math.max(Re,Math.min(Ce,$e+g)),z===$e)return;Vo(le(C,z,u),!0)}},Fi=s=>{if(e.mode!=="vernier")return;if(Ft(),Qt){const z=ye.length-1,N=he(ye,pt,J,u),ae=he(ye,Yt,J,u),we=ae-N;let Se=N+s,W=ae+s;if(s<0&&Se<0?(Se=0,W=Math.min(z,we)):s>0&&W>z&&(W=z,Se=Math.max(0,z-we)),Se===N&&W===ae)return;const st=ye[Se],ke=ye[W];Ht(st,ke,!0),lr(st,ke);return}const m=We-Be;let g=Be+s,w=We+s;if(s<0&&g<je?(g=je,w=Math.min(dt,g+m)):s>0&&w>dt&&(w=dt,g=Math.max(je,w-m)),g===Be&&w===We)return;const P=le(J,g,u),k=le(J,w,u);Ht(P,k,!0),lr(P,k)},Qn=i.useCallback(s=>{const m=j.current;if(!(m.disabled||At()))if(Ft(),m.mode==="point"){const g=Math.max(H,Math.min(S,ve+s));Pe||oe([g,g]),Et(g,g,!0)}else if(m.mode==="vernier"){if(at){const we=de.length-1,Se=he(de,yt,C,u),W=he(de,Pt,C,u),st=W-Se;let ke=Se+s,Ae=W+s;s<0&&ke<0?(ke=0,Ae=Math.min(we,st)):s>0&&Ae>we&&(Ae=we,ke=Math.max(0,we-st)),(ke!==Se||Ae!==W)&&et(de[ke],de[Ae],!0);return}const g=$e,w=Ge,P=Re,k=Ce,z=w-g;let N=g+s,ae=w+s;s<0&&N<P?(N=P,ae=Math.min(k,N+z)):s>0&&ae>k&&(ae=k,N=Math.max(P,ae-z)),(N!==g||ae!==w)&&et(le(C,N,u),le(C,ae,u),!0)}else{const g=Ee-ve;let w=ve+s,P=Ee+s;s<0&&w<H?(w=H,P=Math.min(S,w+g)):s>0&&P>S&&(P=S,w=Math.max(H,P-g)),w<=P&&(Pe||oe([w,P]),Et(w,P,!0))}},[ve,Ee,H,S,Pe,Et,et,$e,Ge,Re,Ce,C,at,de,yt,Pt,Ft,u]),da=s=>!l&&co(Sr.current,s),ma=(s,m)=>{const g=Yo.current,w=Je.current,P=Sr.current;if(l||g===null||w===null||P===null||!Ds(g,P,Ho.current,b,s,m))return null;const k=w.getBoundingClientRect();return Math.abs(b?s-(k.left+k.width/2):m-(k.top+k.height/2))},fa=s=>{if(l||At())return;const m=ui(s.deltaX,s.deltaY,b);if(m===0)return;s.preventDefault();const g=s.target,w=co(_o.current,g)||co(Fo.current,g);if(!A||w){Qn(m);return}const P=Je.current;if(!P)return;const k=P.getBoundingClientRect(),z=b?s.clientX-(k.left+k.width/2):s.clientY-(k.top+k.height/2);if(Po(z,Ue)==="macro"){Fi(m);return}Qn(m)},on=i.useRef({ownsWheelHit:da,distanceToRailPx:ma,stepFromRangeAreaWheel:fa});i.useLayoutEffect(()=>{on.current={ownsWheelHit:da,distanceToRailPx:ma,stepFromRangeAreaWheel:fa}});const Pr=i.useRef(null);i.useEffect(()=>{const s=Sr.current?.ownerDocument.defaultView??null,m=Pr.current;if(m!==null&&m.view===s)return;if(m?.unregister(),s===null){Pr.current=null;return}const g=xs(s,{ownsHit:w=>on.current.ownsWheelHit(w),distanceToRailPx:(w,P)=>on.current.distanceToRailPx(w,P),step:w=>on.current.stepFromRangeAreaWheel(w)});Pr.current={view:s,unregister:g}}),i.useEffect(()=>()=>{Pr.current?.unregister(),Pr.current=null},[]);const an=_t(ve),sn=_t(Ee),Jn=Y(ve),eo=Y(Ee),to=Na(an,sn,Wn),Er=to.slant,Ar=R==="low"||R!=="high"&&De==="low",Cr=!I&&(R==="high"||R!=="low"&&De==="high"),ji=Un&&Ve!=="macro-low",zi=Un&&Ve==="macro-low",Ui=Bn&&Ve!=="micro-low",Bi=Bn&&Ve==="micro-low",cr=ho("macro",it,mt,Gn),ur=ho("micro",er,Rr,Xn),Wi=Math.min(an,sn),Gi=Math.max(an,sn),[ga,ha]=zr.flat,[Xi,Ki]=zr.macro,[qi,Zi]=zr.micro,ba=kt(ga,an),wa=kt(ha,sn),ro=kt(ga,Wi),pa=`calc(${kt(ha,Gi)} - ${ro})`,dr=kt(Xi,it*100),ln=kt(Ki,mt*100),mr=kt(qi,er*100),cn=kt(Zi,Rr*100),Qi=b?{bottom:ro,height:pa,top:"auto",left:"0",right:"0"}:{left:ro,width:pa,top:"0",bottom:"0"},Ji=Math.max(.01,mt-it),va=Math.max(.06,Math.min(.25,.28*Math.sqrt(Ji))),es=b?{bottom:ba,left:"50%",transform:"translate(-50%, 50%)",zIndex:Ar?40:30}:{left:ba,top:"50%",transform:"translate(-50%, -50%)",zIndex:Ar?40:30},ts=b?{bottom:wa,left:"50%",transform:"translate(-50%, 50%)",zIndex:Cr?40:30}:{left:wa,top:"50%",transform:"translate(-50%, -50%)",zIndex:Cr?40:30},rs=b?{bottom:`${nt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${nt}%`,top:"50%",transform:"translate(-50%, -50%)"},Da=xe!==null?Y(xe):null,ns=h!=="hover"&&xe!==null&&(xe===ve||!I&&xe===Ee),os=at?ne(C,de[0],u):Re,as=at?ne(C,de[de.length-1],u):Ce,is=A?$e>os:ve>H,ss=A?Ge<as:Ee<S,un=js(A?[{side:$?"before":"after",box:vn(Uo,Bo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:cr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:cr.slant.lowOffsetX}},{side:$?"after":"before",box:V?jn:vn(jn,Wo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:ur.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:ur.slant.lowOffsetX}}]:[{side:b||p==="top"?"before":"after",box:I?nr:vn(nr,zo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Er.lowAngleDeg,centreOffsetPx:Er.lowOffsetY,alongPushPx:Er.lowOffsetX}}]),ls=un===void 0?e.style:{...e.style,...un.style};i.useLayoutEffect(()=>{Ho.current=un===void 0?0:un.mainPx});const gt=V?"micro-point":"micro-low",jt=l?"cursor-not-allowed opacity-50":"cursor-pointer",Ma=s=>{const m=b?"vertical":"horizontal",g=s==="decrease",w=b?!g:g;return D.jsx(qt,{ref:g?_o:Fo,neighbour:"rail",direction:zs[m][s],disabled:l,canStep:g?is:ss,onStep:()=>Qn(g?-1:1),ariaLabel:g?ce:Z,className:`period-slider-stepper-btn ${Us[m][s]} ${Ya[m][w?"leading":"trailing"]}`})};return D.jsxs("div",{ref:Sr,style:ls,className:`period-slider grid select-none place-items-center ${Bs[b?"vertical":"horizontal"][f?"withSteppers":"railOnly"]} ${c}`,"data-disabled":l?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":p,"data-color-scheme":x,children:[D.jsx("div",{ref:Yo,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),f&&Ma(b?"increase":"decrease"),D.jsx("div",{ref:Je,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":A?Ue:void 0,className:`period-slider-track relative touch-none rounded-full ${Ya[b?"vertical":"horizontal"][f?"rail":"railOnly"]} ${jt}`,onPointerDown:Yi,onPointerMove:Hi,onPointerLeave:_i,children:A?D.jsxs(D.Fragment,{children:[Vt&&(b?D.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:[D.jsx("defs",{children:D.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"1",y2:"0",children:[D.jsx("stop",{offset:"0%",stopColor:$?O.macro:O.micro,stopOpacity:"0.28"}),D.jsx("stop",{offset:"100%",stopColor:$?O.micro:O.macro,stopOpacity:va})]})}),D.jsx("path",{ref:_n,"data-testid":"period-slider-vernier-projection",d:lo(it,mt,b,$),fill:`url(#${ie})`})]}):D.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[D.jsx("defs",{children:D.jsxs("linearGradient",{id:ie,x1:"0",y1:"0",x2:"0",y2:"1",children:[D.jsx("stop",{offset:"0%",stopColor:$?O.macro:O.micro,stopOpacity:"0.28"}),D.jsx("stop",{offset:"100%",stopColor:$?O.micro:O.macro,stopOpacity:va})]})}),D.jsx("path",{ref:_n,"data-testid":"period-slider-vernier-projection",d:lo(it,mt,b,$),fill:`url(#${ie})`})]})),!d&&D.jsxs(D.Fragment,{children:[D.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${dr} - 8px)`,height:`calc(${ln} - ${dr} + 16px)`}:{left:`calc(${dr} - 8px)`,width:`calc(${ln} - ${dr} + 16px)`},onPointerDown:sr("macro-connect")}),!V&&D.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${mr} - 8px)`,height:`calc(${cn} - ${mr} + 16px)`}:{left:`calc(${mr} - 8px)`,width:`calc(${cn} - ${mr} + 16px)`},onPointerDown:sr("micro-connect")})]}),ot&&D.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(s=>D.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${s*100}%`}:{left:`${s*100}%`}},`macro-tick-${s}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(s=>D.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${s*100}%`}:{left:`${s*100}%`}},`micro-tick-${s}`))]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":l?"true":void 0,"aria-valuemin":je,"aria-valuemax":We,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(pt,J,"period"):Wt(J,pt,Gr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:dr,left:$?0:"auto",right:$?"auto":0,transform:$?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Qe==="macro-low"||Ve==="macro-low"?30:15}:{left:dr,top:$?0:"auto",bottom:$?"auto":0,transform:$?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Qe==="macro-low"||Ve==="macro-low"?30:15},onPointerDown:sr("macro-low"),onKeyDown:nn("macro-low"),onFocus:rn("macro-low"),"data-active":Qe==="macro-low"?"true":void 0,"data-front":Ve==="macro-low"?"true":void 0,"data-vernier-pos":b?$?"left":"right":$?"top":"bottom","data-handle-type":"macro-low",children:[D.jsx(jr,{type:"macro",isTop:$,isVertical:b,isLeft:$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":ji?"true":void 0,"data-slanted":cr.slant.isSlanted?"true":void 0,ref:Pi,style:cr.lowStyle,children:Ye(J,pt,Gr,F)})]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":l?"true":void 0,"aria-valuemin":Be,"aria-valuemax":dt,"aria-valuenow":We,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Yt,J,"period"):Wt(J,Yt,Gr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:ln,left:$?0:"auto",right:$?"auto":0,transform:$?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Qe==="macro-high"||Ve==="macro-high"?30:15}:{left:ln,top:$?0:"auto",bottom:$?"auto":0,transform:$?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Qe==="macro-high"||Ve==="macro-high"?30:15},onPointerDown:sr("macro-high"),onKeyDown:nn("macro-high"),onFocus:rn("macro-high"),"data-active":Qe==="macro-high"?"true":void 0,"data-front":Ve==="macro-high"?"true":void 0,"data-vernier-pos":b?$?"left":"right":$?"top":"bottom","data-handle-type":"macro-high",children:[D.jsx(jr,{type:"macro",isTop:$,isVertical:b,isLeft:$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":zi?"true":void 0,"data-slanted":cr.slant.isSlanted?"true":void 0,ref:Ei,style:cr.highStyle,children:Ye(J,Yt,Gr,F)})]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":V?e.pointAriaLabel??"Micro selected date":e.lowerAriaLabel??"Micro range start","aria-disabled":l?"true":void 0,"aria-valuemin":Re,"aria-valuemax":V?Ce:Ge,"aria-valuenow":$e,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(yt,C,"period"):Wt(C,yt,Xr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:mr,left:$?"auto":0,right:$?0:"auto",transform:$?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Qe===gt||Ve===gt?30:20}:{left:mr,top:$?"auto":0,bottom:$?0:"auto",transform:$?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Qe===gt||Ve===gt?30:20},onPointerDown:sr(gt),onKeyDown:nn(gt),onFocus:rn(gt),"data-active":Qe===gt?"true":void 0,"data-front":Ve===gt?"true":void 0,"data-vernier-pos":b?$?"right":"left":$?"bottom":"top","data-handle-type":gt,children:[D.jsx(jr,{type:"micro",isTop:!$,isVertical:b,isLeft:!$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":Ui?"true":void 0,"data-slanted":ur.slant.isSlanted?"true":void 0,ref:Ai,style:ur.lowStyle,children:Ye(C,yt,Xr,F)})]}),!V&&D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":l?"true":void 0,"aria-valuemin":$e,"aria-valuemax":Ce,"aria-valuenow":Ge,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Pt,C,"period"):Wt(C,Pt,Xr,F),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${jt}`,style:b?{bottom:cn,left:$?"auto":0,right:$?0:"auto",transform:$?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Qe==="micro-high"||Ve==="micro-high"?30:20}:{left:cn,top:$?"auto":0,bottom:$?0:"auto",transform:$?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Qe==="micro-high"||Ve==="micro-high"?30:20},onPointerDown:sr("micro-high"),onKeyDown:nn("micro-high"),onFocus:rn("micro-high"),"data-active":Qe==="micro-high"?"true":void 0,"data-front":Ve==="micro-high"?"true":void 0,"data-vernier-pos":b?$?"right":"left":$?"bottom":"top","data-handle-type":"micro-high",children:[D.jsx(jr,{type:"micro",isTop:!$,isVertical:b,isLeft:!$}),Wr&&D.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-duplicate":Bi?"true":void 0,"data-slanted":ur.slant.isSlanted?"true":void 0,ref:Ci,style:ur.highStyle,children:Ye(C,Pt,Xr,F)})]})]}):D.jsxs(D.Fragment,{children:[!d&&D.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Qi,onPointerDown:Vi}),_&&L&&T.length>1&&D.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:T.map((s,m)=>{const g=ne(t,s,u),w=_t(m),P=b?{bottom:`${w}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${w}%`,top:"50%",transform:"translate(-50%, -50%)"};return D.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:P},`tick-${g}`)})}),!l&&xe!==null&&nt!==null&&R===null&&Da&&D.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:rs,children:[D.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"}),D.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":ns?"true":void 0,className:`period-slider-hover-tooltip ${p==="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:Ye(t,Da,e.formatLabel,F)})]}),D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":I?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":l?"true":void 0,"aria-valuemin":H,"aria-valuemax":I?S:Ee,"aria-valuenow":ve,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Jn,t,"period"):Wt(t,Jn,e.formatLabel,F),"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 ${jt}`,style:es,onPointerDown:la("low"),onKeyDown:ua("low"),onFocus:ca("low"),"data-active":R==="low"?"true":void 0,"data-front":Ar?"true":void 0,children:[D.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 ${R==="low"?"":"shadow-md"}`}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-label-position":p,"data-slanted":Er.isSlanted?"true":void 0,"data-front":Ar?"true":void 0,"data-duplicate":zn&&!Ar?"true":void 0,ref:Ti,style:to.lowStyle,children:Ye(t,Jn,e.formatLabel,F)})]}),!I&&D.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":l?"true":void 0,"aria-valuemin":ve,"aria-valuemax":S,"aria-valuenow":Ee,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(eo,t,"period"):Wt(t,eo,e.formatLabel,F),"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 ${jt}`,style:ts,onPointerDown:la("high"),onKeyDown:ua("high"),onFocus:ca("high"),"data-active":R==="high"?"true":void 0,"data-front":Cr?"true":void 0,children:[D.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 ${R==="high"?"":"shadow-md"}`}),h!=="hover"&&D.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${h==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":h,"data-label-position":p,"data-slanted":Er.isSlanted?"true":void 0,"data-front":Cr?"true":void 0,"data-duplicate":zn&&!Cr?"true":void 0,ref:yi,style:to.highStyle,children:Ye(t,eo,e.formatLabel,F)})]})]})}),f&&Ma(b?"decrease":"increase")]})},bo=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},gi=(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},Gs=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||e.minDate.getTime()!==t.minDate.getTime()||e.maxDate.getTime()!==t.maxDate.getTime()||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||!gi(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.locale!==t.locale||e.lowerAriaLabel!==t.lowerAriaLabel||e.upperAriaLabel!==t.upperAriaLabel||e.pointAriaLabel!==t.pointAriaLabel||e.macroLowerAriaLabel!==t.macroLowerAriaLabel||e.macroUpperAriaLabel!==t.macroUpperAriaLabel||e.decreaseAriaLabel!==t.decreaseAriaLabel||e.increaseAriaLabel!==t.increaseAriaLabel||e.formatAriaValueText!==t.formatAriaValueText||!bo(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!((e.value?.getTime()??null)!==(t.value?.getTime()??null)||(e.defaultValue?.getTime()??null)!==(t.defaultValue?.getTime()??null)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!((e.range?.[0]?.getTime()??null)!==(t.range?.[0]?.getTime()??null)||(e.range?.[1]?.getTime()??null)!==(t.range?.[1]?.getTime()??null)||(e.defaultRange?.[0]?.getTime()??null)!==(t.defaultRange?.[0]?.getTime()??null)||(e.defaultRange?.[1]?.getTime()??null)!==(t.defaultRange?.[1]?.getTime()??null)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!((e.microRange?.[0]?.getTime()??null)!==(t.microRange?.[0]?.getTime()??null)||(e.microRange?.[1]?.getTime()??null)!==(t.microRange?.[1]?.getTime()??null)||(e.defaultMicroRange?.[0]?.getTime()??null)!==(t.defaultMicroRange?.[0]?.getTime()??null)||(e.defaultMicroRange?.[1]?.getTime()??null)!==(t.defaultMicroRange?.[1]?.getTime()??null)||(e.microValue?.getTime()??null)!==(t.microValue?.getTime()??null)||(e.defaultMicroValue?.getTime()??null)!==(t.defaultMicroValue?.getTime()??null)||e.macroRange[0].getTime()!==t.macroRange[0].getTime()||e.macroRange[1].getTime()!==t.macroRange[1].getTime()||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||!bo(e.macroAllowedDates,t.macroAllowedDates)||!bo(e.microAllowedDates,t.microAllowedDates)):!1,hi=i.memo(Ws,Gs);hi.displayName="PeriodSlider";const bi=864e5,_a=2,Le=-1,Dn=e=>{const t=e.getFullYear(),r=new Date(Date.UTC(t,e.getMonth(),e.getDate()));return r.setUTCFullYear(t),Math.floor(r.getTime()/bi)},wi=e=>{const t=new Date(e*bi),r=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return r.setFullYear(t.getUTCFullYear()),r.setHours(0,0,0,0),r},Yr=e=>`${Cn(e.getFullYear())}-${String(e.getMonth()+1).padStart(_a,"0")}-${String(e.getDate()).padStart(_a,"0")}`,Xs=(e,t,r,n)=>{const o=Dn(e),a=Dn(t),l=a>=o?a-o+1:0,c=f=>wi(a-f);return{count:l,dateAt:c,labelAt:f=>Ye("day",c(f),n,r),indexOf:f=>{const h=Dn(f);return h<o||h>a?Le:a-h}}},Ks=(e,t,r,n,o)=>{const a=r>=t?r-t+1:0,l=c=>e[r-c];return{count:a,dateAt:l,labelAt:c=>Ye("day",l(c),o,n),indexOf:c=>{const f=c.getTime();let h=t,p=r;for(;h<=p;){const M=h+p>>1,b=e[M].getTime();if(b===f)return r-M;b<f?h=M+1:p=M-1}return Le}}},qs={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},indexOf:()=>Le},Zs=(e,t,r)=>{const n=c=>{let f=0,h=e.length;for(;f<h;){const p=f+h>>1;e[p].getTime()<c?f=p+1:h=p}return f},o=c=>{let f=0,h=e.length;for(;f<h;){const p=f+h>>1;e[p].getTime()<=c?f=p+1:h=p}return f},a=t===null?0:n(t.getTime()),l=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:l}},Fa=(e,t,r,n,o)=>{let a=t,l=r,c=null;for(;a<=l;){const f=a+l>>1,h=e[f].getTime();o===-1?h<n?(c=e[f],a=f+1):l=f-1:h>n?(c=e[f],l=f-1):a=f+1}return c},Qs=(e,t)=>{const r=new Map;return e.forEach((n,o)=>{t(o,n);const a=new Date(n);a.setHours(0,0,0,0);const l=a.getTime();r.has(l)||r.set(l,a)}),Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},Js={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},el={month:2,day:2},ja={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},za=new Map,tl=(e,t)=>{const r=`${e}\0${t}`,n=za.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Js[e]);return za.set(r,o),o},rl=(e,t,r)=>r!==void 0?tl(e,r).format(t):e==="year"?Cn(ja.year(t)):String(ja[e](t)).padStart(el[e],"0"),pi=(e,t,r,n)=>{if(t!=="year"&&t!=="month"&&t!=="day")throw new RangeError(`formatOptionText: unit must be "year", "month" or "day" (received: ${String(t)})`);if(r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${String(r)})`);return Ke(e)?r==="part"?rl(t,e,n):Ye(t,e,void 0,n):""},Mn=44,Ua=7,hn=8,nl=2,vi=10,ol=1e3,Ro=8,wo=6,po=4,vo=12,Hr=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),Dn(r)},al=(e,t)=>{if(e.length<po||t.count===0)return Le;const r=Number(e.slice(0,po));if(!Number.isInteger(r))return Le;const n=e.length>=wo,o=n?Number(e.slice(po,wo)):vo;if(o<1||o>vo)return Le;const a=e.length>=Ro,l=a?Number(e.slice(wo,Ro)):0,c=Hr(r,o),f=(o===vo?Hr(r+1,1):Hr(r,o+1))-1,h=a?c+l-1:n?c:Hr(r,1),p=a?h:n?f:Hr(r+1,1)-1;if(a&&(l<1||h>f))return Le;for(let M=p;M>=h;M--){const b=t.indexOf(wi(M));if(b!==Le)return b}return Le},il=e=>e.closest(".dark")===null?"light":"dark",sl=(e,t,r,n)=>{const o=r-e.bottom-hn,a=e.top-hn,l=o>=t||o>=a,f=Math.max(Mn,Math.min(t,l?o:a)),h=l?e.bottom:e.top-f,p=e.width+vi,M=Math.max(hn,Math.min(e.left,n-p-hn));return{top:h,left:M,width:p,height:f}},Di=({domain:e,selectedIndex:t,displayLabel:r,machineValue:n,disabled:o,ariaLabel:a,onCommitIndex:l,controlClassName:c})=>{const f=i.useId(),h=`period-slider-date-listbox-${f}`,p=E=>`period-slider-date-option-${f}-${E}`,[M,b]=i.useState(!1),[d,_]=i.useState(Le),[x,F]=i.useState(!0),[ce,Z]=i.useState(null),[u,X]=i.useState(null),V=i.useRef(null),O=i.useRef(null),ie=i.useRef(null),j=i.useRef({buffer:"",at:0}),re=i.useRef(e);re.current=e;const K=e.count,T=Math.min(K,Ua)*Mn,L=Math.max(1,Math.min(K,Ua)),H=i.useCallback(()=>{const E=V.current;if(E===null)return;const U=E.getBoundingClientRect();Z(sl(U,T,window.innerHeight,window.innerWidth))},[T]),S=i.useCallback(()=>{b(!1),_(Le),j.current={buffer:"",at:0}},[]),I=i.useCallback(E=>{o||K===0||(_(E),b(!0))},[o,K]);i.useLayoutEffect(()=>{if(!M){Z(null),X(null);return}const E=V.current;return E!==null&&X(il(E)),H(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[M,H]),i.useEffect(()=>{if(!M)return;const E=U=>{const ge=U.target;ge!==null&&O.current?.contains(ge)!==!0&&V.current?.contains(ge)!==!0&&S()};return document.addEventListener("pointerdown",E,!0),()=>document.removeEventListener("pointerdown",E,!0)},[M,S]);const Y=i.useRef(d);Y.current=d,i.useEffect(()=>{M&&(o||K===0)&&S()},[M,o,K,S]),i.useEffect(()=>{if(!M)return;const E=Y.current;if(E===Le)return;const U=Math.min(E,K-1);U!==E&&_(U),ie.current?.scrollToIndex(U,{align:"center"})},[K,M]);const ee=E=>{if(K===0)return;const U=Math.max(0,Math.min(E,K-1));_(U),ie.current?.scrollToIndex(U,{align:"center"})},_e=E=>{E<0||E>=K||(l(E),S(),V.current?.focus())},ue=E=>{if(o)return;const U=d!==Le?d:t!==Le?t:0;switch(E.key){case"ArrowDown":if(E.preventDefault(),!M){I(U);return}ee(U+1);return;case"ArrowUp":if(E.preventDefault(),!M){I(U);return}ee(U-1);return;case"Home":if(!M)return;E.preventDefault(),ee(0);return;case"End":if(!M)return;E.preventDefault(),ee(K-1);return;case"PageDown":if(!M)return;E.preventDefault(),ee(U+L);return;case"PageUp":if(!M)return;E.preventDefault(),ee(U-L);return;case"Enter":if(E.preventDefault(),!M){I(U);return}_e(d!==Le?d:U);return;case"Escape":if(!M)return;E.preventDefault(),S();return;case"Tab":M&&S();return}if(E.key.length!==1)return;const ge=E.key>="0"&&E.key<="9",Ie=E.key==="-"||E.key==="/"||E.key===".";if(!(ge||Ie))return;E.preventDefault();const Ne=Date.now(),Fe=Ne-j.current.at>ol?"":j.current.buffer,qe=ge?`${Fe}${E.key}`.slice(0,Ro):Fe;j.current={buffer:qe,at:Ne};const Ze=al(qe,re.current);if(Ze!==Le){if(!M){I(Ze);return}ee(Ze)}},B=i.useCallback(E=>E,[]),q=i.useCallback(()=>Mn,[]),te=i.useCallback(E=>{const U=Y.current;F(U===Le||U>=E.renderingStartIndex&&U<=E.renderingEndIndex)},[]),se=M&&ce!==null&&u!==null&&K>0?D.jsx("div",{ref:O,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":u,style:{top:ce.top,left:ce.left,width:ce.width,height:ce.height},onMouseDown:E=>{E.preventDefault()},children:D.jsx(us.VirtualScroll,{ref:ie,itemCount:K,getItem:B,getItemHeight:q,viewportSize:ce.height-nl,initialScrollIndex:d!==Le?d:void 0,onRangeChange:te,className:"h-full w-full",testId:"period-slider-date-listbox-pane",contentProps:{id:h,role:"listbox","aria-label":a},scrollBarOptions:{width:vi,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:E=>{const U=E===t,ge=E===d;return D.jsx("div",{id:p(E),role:"option","aria-selected":U,"aria-posinset":E+1,"aria-setsize":K,"data-testid":"period-slider-date-option","data-active":ge?"true":void 0,className:"period-slider-date-option",style:{height:Mn},onClick:()=>_e(E),children:re.current.labelAt(E)})}})}):null;return D.jsxs(D.Fragment,{children:[D.jsx("input",{ref:V,type:"text",role:"combobox",readOnly:!0,"aria-label":a,"aria-expanded":M,"aria-controls":M?h:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":M&&d!==Le&&x?p(d):void 0,disabled:o,value:r,className:c,"data-testid":"period-slider-date-combobox","data-value":n,onKeyDown:ue,onMouseDown:E=>{o||(E.preventDefault(),V.current?.focus(),M?S():I(t!==Le?t:0))},onBlur:()=>{M&&S()}}),se===null?null:ds.createPortal(se,document.body)]})};Di.displayName="VirtualDateDropdown";const Gt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},_r=(e,t)=>{if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},ll=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`)}},xt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Do=e=>xt(e,1,1),cl=e=>xt(e,12,31),ul=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:l,minDate:c,maxDate:f,allowedDates:h,variant:p="date",className:M="",style:b,disabled:d=!1,prevDateAriaLabel:_="Previous day",nextDateAriaLabel:x="Next day",selectAriaLabel:F="Date",yearAriaLabel:ce="Year",monthAriaLabel:Z="Month",dayAriaLabel:u="Day",locale:X,formatOption:V}=e;if(ll(X),t!==void 0&&_r("value",t),r!==void 0&&_r("initialDate",r),c!==void 0&&_r("minDate",c),f!==void 0&&_r("maxDate",f),a!==void 0&&!Number.isInteger(a))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(a)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(l)})`);if(p==="split-dropdown"&&h!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const O=t??r;if(O===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const[ie,j]=i.useState(()=>Gt(O)),re=t!==void 0,K=t?.getTime(),T=i.useMemo(()=>t!==void 0?Gt(t):ie,[K,ie]),L=c?.getTime(),H=f?.getTime(),S=i.useMemo(()=>{const y=c?Gt(c):null,A=a!==void 0?Do(a):null;return y===null?A:A===null||y.getTime()>=A.getTime()?y:A},[L,a]),I=i.useMemo(()=>{const y=f?Gt(f):null,A=l!==void 0?cl(l):null;return y===null?A:A===null||y.getTime()<=A.getTime()?y:A},[H,l]),Y=S?.getTime()??null,ee=I?.getTime()??null;if(S!==null&&I!==null&&S.getTime()>I.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Yr(S)} is after max ${Yr(I)})`);if(p!=="date"&&h===void 0&&(S===null||I===null))throw new RangeError(`DateSelector: variant="${p}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${p==="dropdown"?' or supply "allowedDates"':""}`);const _e=i.useMemo(()=>h===void 0?null:h.map(y=>y.getTime()).join(","),[h]),ue=i.useMemo(()=>h===void 0?null:Qs(h,(y,A)=>_r(`allowedDates[${y}]`,A)),[_e]),B=i.useMemo(()=>ue===null?null:{ascending:ue,...Zs(ue,S,I)},[ue,Y,ee]),q=i.useMemo(()=>B!==null?Ks(B.ascending,B.loIndex,B.hiIndex,X,V):S===null||I===null?qs:Xs(S,I,X,V),[B,Y,ee,X,V]),te=y=>{if(B!==null)return q.indexOf(y)!==Le;const A=y.getTime();return!(Y!==null&&A<Y||ee!==null&&A>ee)},se=O.getTime();i.useEffect(()=>{re||j(Gt(O))},[re,se]);const E=y=>{if(d)return;const A=Gt(y);te(A)&&(re||j(A),n?.(A))},U=T.getTime(),ge=te(T),Ie=i.useMemo(()=>{if(B!==null)return Fa(B.ascending,B.loIndex,B.hiIndex,U,-1);const y=lt.addDays(new Date(U),-1);return te(y)?y:null},[B,U,Y,ee]),Ne=i.useMemo(()=>{if(B!==null)return Fa(B.ascending,B.loIndex,B.hiIndex,U,1);const y=lt.addDays(new Date(U),1);return te(y)?y:null},[B,U,Y,ee]),Fe=()=>{Ie!==null&&E(Ie)},qe=()=>{Ne!==null&&E(Ne)},Ze=y=>{if(y.target.value){const A=lt.parseISO(y.target.value);Number.isNaN(A.getTime())||E(A)}},be=T.getFullYear(),Te=T.getMonth()+1,Pe=T.getDate(),G=i.useCallback((y,A)=>V?V(A,y,"part"):pi(A,y,"part",X),[V,X]),oe=i.useMemo(()=>{if(p!=="split-dropdown"||S===null||I===null)return[];const y=[];for(let A=I.getFullYear();A>=S.getFullYear();A--)y.push({value:A,label:G("year",Do(A))});return y},[p,Y,ee,G]),me=i.useMemo(()=>{if(p!=="split-dropdown"||S===null||I===null)return[];const y=S,A=I,Ue=be===y.getFullYear()?y.getMonth()+1:1,$=be===A.getFullYear()?A.getMonth()+1:12,Vt=[];for(let ot=Ue;ot<=$;ot++)Vt.push({value:ot,label:G("month",xt(be,ot,1))});return Vt},[p,Y,ee,be,G]),v=i.useMemo(()=>{if(p!=="split-dropdown"||S===null||I===null)return[];const y=S,A=I,Ue=be===y.getFullYear()&&Te===y.getMonth()+1?y.getDate():1,$=be===A.getFullYear()&&Te===A.getMonth()+1?A.getDate():lt.getDaysInMonth(new Date(U)),Vt=[];for(let ot=Ue;ot<=$;ot++)Vt.push({value:ot,label:G("day",xt(be,Te,ot))});return Vt},[p,Y,ee,U,be,Te,G]),R=(y,A,Ue)=>Ue>lt.getDaysInMonth(xt(y,A,1))?!1:te(xt(y,A,Ue)),Q=(y,A,Ue)=>{R(y,A,Ue)&&E(xt(y,A,Ue))},fe=oe.some(y=>y.value===be),De=me.some(y=>y.value===Te),Me=v.some(y=>y.value===Pe),xe=Yr(T),ut=p==="dropdown"?Ye("day",T,V,X):"",nt=S?Yr(S):void 0,Nt=I?Yr(I):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 D.jsxs("div",{className:`inline-flex items-center ${Br} ${M}`,style:b,"data-variant":p,"data-out-of-range":ge?void 0:"true",children:[D.jsx(qt,{neighbour:"control",direction:"left",disabled:d,canStep:Ie!==null,onStep:Fe,ariaLabel:_}),p==="dropdown"?D.jsx(Di,{domain:q,selectedIndex:ge?q.indexOf(T):Le,displayLabel:ut,machineValue:xe,disabled:d,ariaLabel:F,onCommitIndex:y=>E(q.dateAt(y)),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"}):p==="split-dropdown"?D.jsxs("div",{className:"inline-flex items-center gap-1",children:[D.jsxs("select",{"aria-label":ce,disabled:d,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:fe?be:"",onChange:y=>Q(Number(y.target.value),Te,Pe),children:[fe?null:D.jsx("option",{value:"",disabled:!0,className:ve,children:G("year",Do(be))}),oe.map(y=>D.jsx("option",{value:y.value,disabled:!R(y.value,Te,Pe),className:"dark:bg-slate-700 dark:text-slate-100",children:y.label},y.value))]}),D.jsxs("select",{"aria-label":Z,disabled:d,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:De?Te:"",onChange:y=>Q(be,Number(y.target.value),Pe),children:[De?null:D.jsx("option",{value:"",disabled:!0,className:ve,children:G("month",xt(be,Te,1))}),me.map(y=>D.jsx("option",{value:y.value,disabled:!R(be,y.value,Pe),className:"dark:bg-slate-700 dark:text-slate-100",children:y.label},y.value))]}),D.jsxs("select",{"aria-label":u,disabled:d,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:Me?Pe:"",onChange:y=>Q(be,Te,Number(y.target.value)),children:[Me?null:D.jsx("option",{value:"",disabled:!0,className:ve,children:G("day",xt(be,Te,Pe))}),v.map(y=>D.jsx("option",{value:y.value,disabled:!R(be,Te,y.value),className:"dark:bg-slate-700 dark:text-slate-100",children:y.label},y.value))]})]}):D.jsx("input",{"aria-label":F,disabled:d,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:xe,min:nt,max:Nt,onChange:Ze,type:"date"}),D.jsx(qt,{neighbour:"control",direction:"right",disabled:d,canStep:Ne!==null,onStep:qe,ariaLabel:x}),o]})},wr=e=>e===void 0?null:Gt(e).getTime(),Mi=i.memo(ul,(e,t)=>!(wr(e.value??e.initialDate)!==wr(t.value??t.initialDate)||wr(e.minDate)!==wr(t.minDate)||wr(e.maxDate)!==wr(t.maxDate)||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.allowedDates!==t.allowedDates||e.children!==t.children||e.prevDateAriaLabel!==t.prevDateAriaLabel||e.nextDateAriaLabel!==t.nextDateAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.yearAriaLabel!==t.yearAriaLabel||e.monthAriaLabel!==t.monthAriaLabel||e.dayAriaLabel!==t.dayAriaLabel||e.locale!==t.locale||e.formatOption!==t.formatOption));Mi.displayName="DateSelector";function rt(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(r,n,1);return o.setFullYear(r),o}function Xt(e){return`${Cn(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}function Fr(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Ba(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function dl(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function ml(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 fl(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 gl(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 hl(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let a=r;a<=n;a++)o.push(rt(Math.floor(a/12),(a%12+12)%12));return o}function Wa(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:Ye("month",e[o],r,t),value:Xt(e[o])});return n}const bl=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:a="date",minYear:l,maxYear:c,minDate:f,maxDate:h,allowedMonths:p,isWarning:M=!1,className:b="",style:d,disabled:_=!1,prevMonthAriaLabel:x="Previous month",nextMonthAriaLabel:F="Next month",selectAriaLabel:ce="Month",locale:Z,formatOption:u}=e;dl(Z),Fr(t,"value"),Fr(r,"initialDate"),Fr(f,"minDate"),Fr(h,"maxDate"),Ba(l,"minYear"),Ba(c,"maxYear"),p?.forEach((v,R)=>{Fr(v,`allowedMonths[${R}]`)});const X=t??r;if(X===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[V,O]=i.useState(()=>rt(X.getFullYear(),X.getMonth())),ie=t!==void 0,j=i.useMemo(()=>t!==void 0?rt(t.getFullYear(),t.getMonth()):V,[t?.getTime(),V]),re=f?.getTime(),K=h?.getTime(),T=i.useMemo(()=>ml(l,f),[l,re]),L=i.useMemo(()=>fl(c,h),[c,K]),H=T?.getTime()??null,S=L?.getTime()??null;if(T!==null&&L!==null&&T>L)throw new RangeError(`MonthSelector: the resolved lower bound ${Xt(T)} is after the resolved upper bound ${Xt(L)}.`);if(a==="dropdown"&&p===void 0&&(T===null||L===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 I=p===void 0?null:p.map(v=>v.getTime()).join(","),Y=i.useMemo(()=>p===void 0?null:gl(p,T,L),[I,H,S]),ee=v=>{const R=v.getTime();return Y!==null?Y.some(Q=>Q.getTime()===R):!(H!==null&&R<H||S!==null&&R>S)},_e=X.getTime();i.useEffect(()=>{if(ie)return;const v=rt(X.getFullYear(),X.getMonth());O(R=>R.getTime()===v.getTime()?R:v)},[ie,_e]);const ue=v=>{if(_)return;if(!ee(v))throw new RangeError(`MonthSelector: refusing to emit ${Xt(v)}, which lies outside the selectable months.`);ie||O(v);const R=v.getFullYear()*100+(v.getMonth()+1);n?.(v,R)},B=j.getTime(),q=ee(j),te=i.useMemo(()=>{if(Y!==null){for(let R=Y.length-1;R>=0;R--)if(Y[R].getTime()<B)return Y[R];return null}const v=rt(j.getFullYear(),j.getMonth()-1);return ee(v)?v:null},[Y,B,H,S]),se=i.useMemo(()=>{if(Y!==null){for(const R of Y)if(R.getTime()>B)return R;return null}const v=rt(j.getFullYear(),j.getMonth()+1);return ee(v)?v:null},[Y,B,H,S]),E=()=>{te!==null&&ue(te)},U=()=>{se!==null&&ue(se)},ge=v=>{if(!v)return;const R=v.lastIndexOf("-");if(R<=0)return;const Q=v.slice(0,R),fe=v.slice(R+1),De=Number(Q),Me=Number(fe)-1;if(!(Number.isInteger(De)&&Number.isInteger(Me)))return;const xe=rt(De,Me);ee(xe)&&ue(xe)},Ie=v=>{ge(v.target.value)},Ne=v=>{ge(v.target.value)},Fe=Xt(j),qe=a==="dropdown"&&!q?Ye("month",j,u,Z):"",Ze=T?Xt(T):void 0,be=L?Xt(L):void 0,Te=i.useMemo(()=>a!=="dropdown"?[]:Y!==null?Wa(Y,Z,u):T===null||L===null?[]:Wa(hl(T,L),Z,u),[a,Y,H,S,Z,u]),Pe=q?Fe:"",G=M?"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",oe=`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 ${G}`,me=`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 ${G}`;return D.jsxs("div",{className:`inline-flex items-center ${Br} ${b}`,style:d,"data-out-of-range":q?void 0:"true",children:[D.jsx(qt,{neighbour:"control",direction:"left",disabled:_,canStep:te!==null,onStep:E,ariaLabel:x}),a==="dropdown"?D.jsxs("select",{"aria-label":ce,disabled:_,className:me,value:Pe,onChange:Ne,children:[q?null:D.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:qe}),Te.map(v=>D.jsx("option",{value:v.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:v.label},v.value))]}):D.jsx("input",{"aria-label":ce,disabled:_,className:oe,value:Fe,min:Ze,max:be,onChange:Ie,type:"month"}),D.jsx(qt,{neighbour:"control",direction:"right",disabled:_,canStep:se!==null,onStep:U,ariaLabel:F}),o]})},xi=i.memo(bl,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,a=n?n.getFullYear()*12+n.getMonth():null;if(o!==a||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)return!1;const l=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,c=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(l!==c)return!1;const f=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,h=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(f!==h||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale||e.formatOption!==t.formatOption)});xi.displayName="MonthSelector";function vr(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function In(e,t,r){if(vr(e,"minDate",t),vr(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function Sn(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: ${String(r)})`);if(vr(e,`${t}[0]`,r[0]),vr(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Ln(e,t,r,n,o,a,l,c){const f=ne(r,n,c);if(f<ne(r,o,c)||f>ne(r,a,c))throw new RangeError(`${e}: ${t} must lie within ${l} (value: ${n.toISOString()}, lower: ${o.toISOString()}, upper: ${a.toISOString()})`)}function Tn(e,t,r,n,o,a,l,c){Ln(e,`${t}[0]`,r,n[0],o,a,l,c),Ln(e,`${t}[1]`,r,n[1],o,a,l,c)}function Xe(e,t,r){return e<t?t:e>r?r:e}function yn(e,t,r,n,o,a,l){if(r!==!0)return[];const c=e[0].getTime(),f=e[1].getTime();return St(n,t,o,a,l).filter(h=>h.getTime()>=c&&h.getTime()<=f)}function pr(e,t,r,n,o){if(n.length===0)return Xe(e,r[0],r[1]);const a=n[he(n,e,t,o)];return a.getTime()===e.getTime()?e:a}function bn(e,t,r,n,o){const a=pr(e[0],t,r,n,o),l=pr(e[1],t,r,n,o);return[a,l<a?a:l]}function Pn(e,t,r,n,o){const a=he(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function $n(e){const t=i.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function wl(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:l,formatOption:c,...f}=e,h=Dr("usePeriodSliderRange",l);In("usePeriodSliderRange",r,n),Sn("usePeriodSliderRange","initialRange",o),Tn("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",h);const p=$n(f),M=i.useRef(o),[b,d]=i.useState(o);let _=b;const x=[Xe(b[0],r,n),Xe(b[1],r,n)];(x[0]!==b[0]||x[1]!==b[1])&&(_=x,d(x));const F=i.useRef(_);F.current=_;const ce=i.useRef({minDate:r,maxDate:n,allowedDates:p.allowedDates});ce.current={minDate:r,maxDate:n,allowedDates:p.allowedDates};const Z=i.useRef(a);Z.current=a;const u=i.useCallback(L=>{const{minDate:H,maxDate:S}=ce.current,I=Xe(L[0],H,S),Y=Xe(L[1],H,S),ee=F.current;I.getTime()===ee[0].getTime()&&Y.getTime()===ee[1].getTime()||(F.current=[I,Y],d([I,Y]),Z.current?.(I,Y))},[]),X=i.useCallback(L=>{const H=F.current,S=L.getTime()>H[1].getTime()?L:H[1];u([L,S])},[u]),V=i.useCallback(L=>{const H=F.current,S=L.getTime()<H[0].getTime()?L:H[0];u([S,L])},[u]),O=i.useCallback((L,H)=>{u([L,H])},[u]),ie=i.useCallback(L=>{const{minDate:H,maxDate:S,allowedDates:I}=ce.current,Y=F.current,ee=St(I,t,H,S,h);if(ee.length>0){u([Pn(ee,t,Y[0],L,h),Pn(ee,t,Y[1],L,h)]);return}u([He(t,Y[0],L),He(t,Y[1],L)])},[t,u,h]),j=i.useCallback(()=>{u(M.current)},[u]),re=i.useMemo(()=>({value:_[0],onChange:X,minDate:r,maxDate:_[1],unit:t,yearStartMonth:h,locale:e.locale,formatOption:c}),[_[0],_[1],X,r,t,h]),K=i.useMemo(()=>({value:_[1],onChange:V,minDate:_[0],maxDate:n,unit:t,yearStartMonth:h,locale:e.locale,formatOption:c}),[_[0],_[1],V,n,t,h]),T=i.useMemo(()=>({...p,mode:"range",unit:t,yearStartMonth:h,range:_,minDate:r,maxDate:n,onChangeRange:O}),[p,t,_,r,n,O,h]);return{range:_,lowerDate:_[0],upperDate:_[1],setRange:d,setLowerDate:X,setUpperDate:V,shiftRange:ie,resetRange:j,startSelectorProps:re,endSelectorProps:K,sliderProps:T}}function pl(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:l,formatOption:c,...f}=e,h=Dr("usePeriodSliderPoint",l);In("usePeriodSliderPoint",r,n),vr("usePeriodSliderPoint","initialValue",o),Ln("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",h);const p=$n(f),M=i.useRef(o),[b,d]=i.useState(o);let _=b;const x=Xe(b,r,n);x!==b&&(_=x,d(x));const F=i.useRef(_);F.current=_;const ce=i.useRef({minDate:r,maxDate:n,allowedDates:p.allowedDates});ce.current={minDate:r,maxDate:n,allowedDates:p.allowedDates};const Z=i.useRef(a);Z.current=a;const u=i.useCallback(j=>{const{minDate:re,maxDate:K}=ce.current,T=Xe(j,re,K);T.getTime()!==F.current.getTime()&&(F.current=T,d(T),Z.current?.(T))},[]),X=i.useCallback(j=>{const{minDate:re,maxDate:K,allowedDates:T}=ce.current,L=St(T,t,re,K,h);if(L.length>0){u(Pn(L,t,F.current,j,h));return}u(He(t,F.current,j))},[t,u,h]),V=i.useCallback(()=>{u(M.current)},[u]),O=i.useMemo(()=>({value:_,onChange:u,minDate:r,maxDate:n,unit:t,yearStartMonth:h,locale:e.locale,formatOption:c}),[_,u,r,n,t,h,e.locale,c]),ie=i.useMemo(()=>({...p,mode:"point",unit:t,yearStartMonth:h,value:_,minDate:r,maxDate:n,onChangePoint:u}),[p,t,_,r,n,u,h]);return{value:_,setValue:d,shiftValue:X,resetValue:V,selectorProps:O,sliderProps:ie}}function vl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroRange:h,yearStartMonth:p,formatOption:M,...b}=e,d=Dr("useVernierSliderRange",p);In("useVernierSliderRange",r,n),Sn("useVernierSliderRange","initialMacroRange",o),Sn("useVernierSliderRange","initialMicroRange",a),Tn("useVernierSliderRange","initialMacroRange",l,o,r,n,"[minDate, maxDate]",d);const _=wt(l,c,o,r,n,d);Tn("useVernierSliderRange","initialMicroRange",c,a,_[0],_[1],"the initial macro window",d);const x=$n(b),F=i.useRef(o),ce=i.useRef(a),[Z,u]=i.useState(o),[X,V]=i.useState(a);let O=Z;const ie=[Xe(Z[0],r,n),Xe(Z[1],r,n)];(ie[0]!==Z[0]||ie[1]!==Z[1])&&(O=ie,u(ie));const j=i.useMemo(()=>wt(l,c,O,r,n,d),[l,c,O,r,n,d]),re=i.useMemo(()=>yn(j,c,x.microIsDiscrete,x.microAllowedDates??x.allowedDates,r,n,d),[j,c,x.microIsDiscrete,x.microAllowedDates,x.allowedDates,r,n,d]),K=i.useMemo(()=>x.macroIsDiscrete===!0?St(x.macroAllowedDates??x.allowedDates,l,r,n,d):[],[x.macroIsDiscrete,x.macroAllowedDates,x.allowedDates,l,r,n,d]),T=i.useRef(K);T.current=K;let L=X;const H=bn(X,c,j,re,d);(H[0]!==X[0]||H[1]!==X[1])&&(L=H,V(H));const S=i.useRef(O);S.current=O;const I=i.useRef(L);I.current=L;const Y=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates});Y.current={minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates};const ee=i.useRef(f);ee.current=f;const _e=i.useRef(h);_e.current=h;const ue=i.useCallback(v=>{const{minDate:R,maxDate:Q}=Y.current;return wt(l,c,v,R,Q,d)},[l,c,d]),B=i.useCallback(v=>{const{microIsDiscrete:R,microAllowedDates:Q,allowedDates:fe,minDate:De,maxDate:Me}=Y.current;return yn(v,c,R,Q??fe,De,Me,d)},[c,d]),q=i.useCallback((v,R)=>{const Q=S.current,fe=I.current;(v[0].getTime()!==Q[0].getTime()||v[1].getTime()!==Q[1].getTime())&&(S.current=v,u(v),ee.current?.(v[0],v[1])),(R[0].getTime()!==fe[0].getTime()||R[1].getTime()!==fe[1].getTime())&&(I.current=R,V(R),_e.current?.(R[0],R[1]))},[]),te=i.useCallback((v,R)=>{const{minDate:Q,maxDate:fe}=Y.current,De=[Xe(v,Q,fe),Xe(R,Q,fe)],Me=ue(De);q(De,bn(I.current,c,Me,B(Me),d))},[c,ue,B,q,d]),se=i.useCallback((v,R)=>{const Q=ue(S.current);q(S.current,bn([v,R],c,Q,B(Q),d))},[c,ue,B,q,d]),E=i.useCallback(v=>{const R=S.current[1],Q=v>R?v:R;te(v,Q)},[te]),U=i.useCallback(v=>{const R=S.current[0],Q=v<R?v:R;te(Q,v)},[te]),ge=i.useCallback(v=>{const R=I.current[1],Q=v>R?v:R;se(v,Q)},[se]),Ie=i.useCallback(v=>{const R=I.current[0],Q=v<R?v:R;se(Q,v)},[se]),Ne=i.useCallback(v=>{const{minDate:R,maxDate:Q}=Y.current,fe=S.current,De=T.current;if(De.length>0){const ut=he(De,fe[0],l,d)+v,nt=he(De,fe[1],l,d)+v;if(ut<0||nt>De.length-1)return;te(De[ut],De[nt]);return}const Me=He(l,fe[0],v),xe=He(l,fe[1],v);Me<R||xe>Q||te(Me,xe)},[l,te,d]),Fe=i.useCallback(v=>{const R=S.current,Q=I.current,fe=ue(R),[De,Me]=fe,xe=B(fe);if(xe.length>0){const Nt=he(xe,Q[0],c,d)+v,ve=he(xe,Q[1],c,d)+v;if(Nt<0||ve>xe.length-1)return;se(xe[Nt],xe[ve]);return}const ut=He(c,Q[0],v),nt=He(c,Q[1],v);ut<De||nt>Me||se(ut,nt)},[c,ue,B,se,d]),qe=i.useCallback(()=>{const v=F.current,R=ue(v);q(v,bn(ce.current,c,R,B(R),d))},[c,ue,B,q,d]),[Ze,be]=j,Te=i.useMemo(()=>({value:O[0],onChange:E,minDate:r,maxDate:O[1],unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,E,r,l,d,e.locale,M]),Pe=i.useMemo(()=>({value:O[1],onChange:U,minDate:O[0],maxDate:n,unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,U,n,l,d,e.locale,M]),G=i.useMemo(()=>({value:L[0],onChange:ge,minDate:Ze,maxDate:L[1],unit:c,yearStartMonth:d,locale:e.locale,formatOption:M}),[L,ge,Ze,c,d,e.locale,M]),oe=i.useMemo(()=>({value:L[1],onChange:Ie,minDate:L[0],maxDate:be,unit:c,yearStartMonth:d,locale:e.locale,formatOption:M}),[L,Ie,be,c,d,e.locale,M]),me=i.useMemo(()=>({...x,mode:"vernier",unit:t,yearStartMonth:d,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:O,microRange:L,onChangeMacroRange:te,onChangeMicroRange:se}),[x,t,l,c,r,n,O,L,te,se,d]);return{macroRange:O,setMacroRange:u,microRange:L,setMicroRange:V,setMacroLowerDate:E,setMacroUpperDate:U,setMicroLowerDate:ge,setMicroUpperDate:Ie,shiftMacroRange:Ne,shiftMicroRange:Fe,resetVernier:qe,macroStartSelectorProps:Te,macroEndSelectorProps:Pe,microStartSelectorProps:G,microEndSelectorProps:oe,sliderProps:me}}function Dl(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:f,onChangeMicroPoint:h,yearStartMonth:p,formatOption:M,...b}=e,d=Dr("useVernierSliderPoint",p);In("useVernierSliderPoint",r,n),Sn("useVernierSliderPoint","initialMacroRange",o),vr("useVernierSliderPoint","initialMicroValue",a),Tn("useVernierSliderPoint","initialMacroRange",l,o,r,n,"[minDate, maxDate]",d);const _=wt(l,c,o,r,n,d);Ln("useVernierSliderPoint","initialMicroValue",c,a,_[0],_[1],"the initial macro window",d);const x=$n(b),F=i.useRef(o),ce=i.useRef(a),[Z,u]=i.useState(o),[X,V]=i.useState(a);let O=Z;const ie=[Xe(Z[0],r,n),Xe(Z[1],r,n)];(ie[0]!==Z[0]||ie[1]!==Z[1])&&(O=ie,u(ie));const j=i.useMemo(()=>wt(l,c,O,r,n,d),[l,c,O,r,n,d]),re=i.useMemo(()=>yn(j,c,x.microIsDiscrete,x.microAllowedDates??x.allowedDates,r,n,d),[j,c,x.microIsDiscrete,x.microAllowedDates,x.allowedDates,r,n,d]),K=i.useMemo(()=>x.macroIsDiscrete===!0?St(x.macroAllowedDates??x.allowedDates,l,r,n,d):[],[x.macroIsDiscrete,x.macroAllowedDates,x.allowedDates,l,r,n,d]),T=i.useRef(K);T.current=K;let L=X;const H=pr(X,c,j,re,d);H!==X&&(L=H,V(H));const S=i.useRef(O);S.current=O;const I=i.useRef(L);I.current=L;const Y=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates});Y.current={minDate:r,maxDate:n,macroIsDiscrete:x.macroIsDiscrete,macroAllowedDates:x.macroAllowedDates,microIsDiscrete:x.microIsDiscrete,microAllowedDates:x.microAllowedDates,allowedDates:x.allowedDates};const ee=i.useRef(f);ee.current=f;const _e=i.useRef(h);_e.current=h;const ue=i.useCallback(G=>{const{minDate:oe,maxDate:me}=Y.current;return wt(l,c,G,oe,me,d)},[l,c,d]),B=i.useCallback(G=>{const{microIsDiscrete:oe,microAllowedDates:me,allowedDates:v,minDate:R,maxDate:Q}=Y.current;return yn(G,c,oe,me??v,R,Q,d)},[c,d]),q=i.useCallback((G,oe)=>{const me=S.current,v=I.current;(G[0].getTime()!==me[0].getTime()||G[1].getTime()!==me[1].getTime())&&(S.current=G,u(G),ee.current?.(G[0],G[1])),oe.getTime()!==v.getTime()&&(I.current=oe,V(oe),_e.current?.(oe))},[]),te=i.useCallback((G,oe)=>{const{minDate:me,maxDate:v}=Y.current,R=[Xe(G,me,v),Xe(oe,me,v)],Q=ue(R);q(R,pr(I.current,c,Q,B(Q),d))},[c,ue,B,q,d]),se=i.useCallback(G=>{const oe=ue(S.current);q(S.current,pr(G,c,oe,B(oe),d))},[c,ue,B,q,d]),E=i.useCallback(G=>{const oe=S.current[1],me=G>oe?G:oe;te(G,me)},[te]),U=i.useCallback(G=>{const oe=S.current[0],me=G<oe?G:oe;te(me,G)},[te]),ge=i.useCallback(G=>{const{minDate:oe,maxDate:me}=Y.current,v=S.current,R=T.current;if(R.length>0){const De=he(R,v[0],l,d)+G,Me=he(R,v[1],l,d)+G;if(De<0||Me>R.length-1)return;te(R[De],R[Me]);return}const Q=He(l,v[0],G),fe=He(l,v[1],G);Q<oe||fe>me||te(Q,fe)},[l,te,d]),Ie=i.useCallback(G=>{const oe=S.current,me=ue(oe),v=B(me);if(v.length>0){se(Pn(v,c,I.current,G,d));return}se(He(c,I.current,G))},[c,ue,B,se,d]),Ne=i.useCallback(()=>{const G=F.current,oe=ue(G);q(G,pr(ce.current,c,oe,B(oe),d))},[c,ue,B,q,d]),[Fe,qe]=j,Ze=i.useMemo(()=>({value:O[0],onChange:E,minDate:r,maxDate:O[1],unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,E,r,l,d,e.locale,M]),be=i.useMemo(()=>({value:O[1],onChange:U,minDate:O[0],maxDate:n,unit:l,yearStartMonth:d,locale:e.locale,formatOption:M}),[O,U,n,l,d,e.locale,M]),Te=i.useMemo(()=>({value:L,onChange:se,minDate:Fe,maxDate:qe,unit:c,yearStartMonth:d,locale:e.locale,formatOption:M}),[L,se,Fe,qe,c,d,e.locale,M]),Pe=i.useMemo(()=>({...x,mode:"vernier",unit:t,yearStartMonth:d,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:O,microValue:L,onChangeMacroRange:te,onChangeMicroPoint:se}),[x,t,l,c,r,n,O,L,te,se,d]);return{macroRange:O,setMacroRange:u,microValue:L,setMicroValue:V,setMacroLowerDate:E,setMacroUpperDate:U,setMicroDate:se,shiftMacroRange:ge,shiftMicroValue:Ie,resetVernier:Ne,macroStartSelectorProps:Ze,macroEndSelectorProps:be,microSelectorProps:Te,sliderProps:Pe}}function Ga(e,t){const r=new Date(e,t,1);return r.setFullYear(e),r}function Kt(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function wn(e,t){return e===void 0?null:Kt(e,t)}function pn(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Xa(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function Ml(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function Ka(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Kt(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}const xl=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:l,minDate:c,maxDate:f,className:h="",style:p,disabled:M=!1,prevYearAriaLabel:b="Previous year",nextYearAriaLabel:d="Next year",selectAriaLabel:_="Year",locale:x,formatOption:F,yearStartMonth:ce}=e,Z=Dr("YearSelector",ce);pn(t,"value"),pn(r,"initialDate"),pn(c,"minDate"),pn(f,"maxDate"),Xa(a,"minYear"),Xa(l,"maxYear"),Ml(x);const u=t??r;if(u===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[X,V]=i.useState(()=>Kt(u,Z)),O=c?.getTime(),ie=f?.getTime(),j=i.useMemo(()=>Ka(a,c,Math.max,Z),[a,O,Z]),re=i.useMemo(()=>Ka(l,f,Math.min,Z),[l,ie,Z]);if(j===null||re===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.");if(j>re)throw new RangeError(`YearSelector: the resolved lower bound ${j} is after the resolved upper bound ${re}.`);const K=t!==void 0,T=t!==void 0?Kt(t,Z):X,L=T<j||T>re,H=u.getTime();i.useEffect(()=>{K||V(Kt(u,Z))},[K,H,Z]);const S=q=>q>=j&&q<=re,I=q=>{if(!M){if(!S(q))throw new RangeError(`YearSelector: refusing to emit ${q}, which lies outside the declared bounds ${j}-${re}.`);K||V(q),n?.(Ga(q,Z),q)}},Y=S(T-1)?T-1:null,ee=S(T+1)?T+1:null,_e=()=>{Y!==null&&I(Y)},ue=()=>{ee!==null&&I(ee)},B=i.useMemo(()=>{const q=[];for(let te=re;te>=j;te--)q.push(te);return L&&(q.push(T),q.sort((te,se)=>se-te)),q.map(te=>({value:te,label:Ye("year",Ga(te,Z),F,x)}))},[j,re,L,T,Z,x,F]);return D.jsxs("div",{className:`inline-flex items-center ${Br} ${h}`,style:p,"data-out-of-range":L?"true":void 0,children:[D.jsx(qt,{neighbour:"control",direction:"left",disabled:M,canStep:Y!==null,onStep:_e,ariaLabel:b}),D.jsx("select",{"aria-label":_,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:T,onChange:q=>{if(!q.target.value)return;const te=Number(q.target.value);Number.isInteger(te)&&I(te)},children:B.map(q=>D.jsx("option",{value:q.value,disabled:L&&q.value===T,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))}),D.jsx(qt,{neighbour:"control",direction:"right",disabled:M,canStep:ee!==null,onStep:ue,ariaLabel:d}),o]})},Ri=i.memo(xl,(e,t)=>{const r=e.yearStartMonth??0,n=t.yearStartMonth??0;if(r!==n)return!1;const o=e.value??e.initialDate,a=t.value??t.initialDate,l=o?Kt(o,r):null,c=a?Kt(a,n):null;return!(l!==c||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||wn(e.minDate,r)!==wn(t.minDate,n)||wn(e.maxDate,r)!==wn(t.maxDate,n)||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale||e.formatOption!==t.formatOption)});Ri.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Ja;exports.DateSelector=Mi;exports.MonthSelector=xi;exports.PeriodSlider=hi;exports.YearSelector=Ri;exports.addUnit=He;exports.areStylesEqual=gi;exports.calculateConnectDragValues=ni;exports.calculateHandleDragValues=Mo;exports.calculateKeyboardActionValues=oi;exports.calculateLabelSlant=yo;exports.calculateVernierMacroDrag=mi;exports.calculateVernierMicroDrag=fi;exports.decode=le;exports.encode=ne;exports.findNearestDateIndex=he;exports.formatLabel=Ye;exports.formatOptionText=pi;exports.formatQuarterLabel=Os;exports.formatScreenReaderLabel=Wt;exports.getMacroWindowEndDate=ti;exports.getMacroWindowStartDate=ei;exports.getSortedAllowedDates=St;exports.normalizeDateByUnit=Oe;exports.resolveDraggedEdge=An;exports.resolveMacroWindow=wt;exports.resolveQuarter=ri;exports.resolveVernierRailZone=Po;exports.resolveVernierTargetHandle=di;exports.resolveWheelStep=ui;exports.usePeriodSliderPoint=pl;exports.usePeriodSliderRange=wl;exports.useVernierSliderPoint=Dl;exports.useVernierSliderRange=vl;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("react/jsx-runtime"),lt=require("date-fns"),i=require("react"),Ot=require("@aiquants/virtualscroll"),vl=require("react-dom"),Pa=120,io="data-drag-snap",lo="--ps-drag-snap-duration",jr={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"]},Ja=["low","high"],ei=["tx","ty","rot"],Tn={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"}},yo=(e,t)=>`${e}-${t}`,so=(e,t,r)=>`var(${yo(e,t)}, ${r})`,Dl=(e,t,r)=>{const n=Tn[t];for(const o of Ja)for(const a of ei)e.style.setProperty(yo(n[o],a),r[o][a])},ti=e=>Math.max(0,Math.min(1,e)),pn=(e,t,r,n)=>{const o=ti(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},To=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},Pn=(e,t,r,n)=>{const o=ti(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},co=(e,t,r,n)=>{if(r){const l=(1-e)*100,c=(1-t)*100;return n?`M 12 ${c} L 12 ${l} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${l} L 20 ${c} 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`},$t=(e,t)=>`var(${e}, ${t}%)`,pl=(e,t,r,n)=>{const[o,a]=jr[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},Ml=e=>{for(const[t,r]of Object.values(jr))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Tn))for(const r of Ja)for(const n of ei)e.style.removeProperty(yo(t[r],n))},ri=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],En=[...Ot.VIRTUAL_SCROLL_LABEL_KEYS,...ri],xo=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:"日"})}),ni=Object.freeze({en:Object.freeze({...Ot.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...xo.en}),ja:Object.freeze({...Ot.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...xo.ja})}),Ea=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,xl=e=>En.includes(e),Rl=(e,t)=>{const r={};let n=!1;for(const o of Ot.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},Sl=e=>{try{return Ot.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}},oi=(e,t)=>{const r=Sl(e);if(t===void 0)return ni[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${Ea(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 c of o)if(!xl(c))throw new RangeError(`[period-slider] labels.${c} is not a known label key; expected one of ${En.join(", ")}`);const l={...Ot.resolveVirtualScrollLabels(r,Rl(t,o)),...xo[r]};for(const c of ri){const d=o.has(c)?t[c]:void 0;if(d!==void 0){if(typeof d!="string"||d.trim()==="")throw new RangeError(`[period-slider] labels.${c} must be a non-blank string; got ${Ea(d)}`);l[c]=d}}return Object.freeze(l)},Ll=e=>{const t={};for(const r of Ot.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},yl=(e,t)=>e===t||En.every(r=>e[r]===t[r]),Cn=(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(l=>r.has(l)&&Object.is(o[l],a[l]))},uo=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Ca=new Set(["hidden","clip","scroll","auto","overlay"]),Ia=["paint","strict","content"],Tl=["layout","paint","strict","content"],Pl=["transform","perspective","filter"],kr=e=>e!==void 0&&e!==""&&e!=="none",El=e=>e!==void 0&&e!==""&&e!=="normal",cn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},Cl=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,Il=(e,t)=>t==="absolute"&&kr(e.position)&&e.position!=="static"||kr(e.transform)||kr(e.perspective)||kr(e.filter)||kr(e.backdropFilter)||El(e.containerType)||Tl.some(r=>e.contain.includes(r))?!0:Pl.some(r=>e.willChange.includes(r)),Al=(e,t,r,n,o,a)=>{const l=t.ownerDocument.defaultView;if(l===null)return!1;const c=e.getBoundingClientRect();if(c.width===0||c.height===0)return!1;const d=n?0:r,g=n?r:0;if(o<c.left-d||o>=c.right+d||a<c.top-g||a>=c.bottom+g)return!1;const D=l.getComputedStyle(t);if(D.visibility!=="visible")return!1;let k=null;for(let b=t;b!==null;b=b.parentElement){const h=b===t?D:l.getComputedStyle(b);if(k!==null&&!Il(h,k))continue;const S=Ca.has(h.overflowX)||Ia.some(C=>h.contain.includes(C)),R=Ca.has(h.overflowY)||Ia.some(C=>h.contain.includes(C));if(S||R){const C=b.getBoundingClientRect();if(S&&(o<C.left+cn(h.borderLeftWidth)||o>=C.right-cn(h.borderRightWidth))||R&&(a<C.top+cn(h.borderTopWidth)||a>=C.bottom-cn(h.borderBottomWidth)))return!1}k=Cl(h)}return!0},mo=new Map,$l=(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)},kl=(e,t)=>{let r=mo.get(e);if(r===void 0){const a=new Set,l=c=>$l(a,c);r={participants:a,listener:l},mo.set(e,r),e.addEventListener("wheel",l,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(mo.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},zr="gap-[11px]",ft=6,gt=ft*2,kt=ft*4/3,Ol={left:`0,${gt/2} ${ft},0 ${ft},${gt}`,right:`${kt},${gt/2} ${kt-ft},0 ${kt-ft},${gt}`,up:`${gt/2},0 0,${ft} ${gt},${ft}`,down:`${gt/2},${kt} 0,${kt-ft} ${gt},${kt-ft}`},fo=e=>{e.preventDefault(),e.stopPropagation()},Vl={onMouseDownCapture:fo,onMouseUpCapture:fo,onClickCapture:fo},Nl="period-slider-step",Yl=`${Nl} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,_l="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]",Hl={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"},un="after:inset-[calc((100%-var(--ps-target-size))/2)]",Aa={horizontal:"px-[19px]",vertical:"py-[19px]"},jl={control:{left:un,right:un,up:un,down:un},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)]"}},Kt=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:l,ref:c})=>{const d=e==="up"||e==="down",g=d?gt:kt,D=d?kt:gt,k=r||!n;return x.jsx("button",{ref:c,type:"button","aria-label":a,disabled:r,"aria-disabled":k?!0:void 0,...k?Vl:null,onClick:k?void 0:o,className:`${l===void 0?"":`${l} `}${Yl} ${_l} ${Hl[t]} ${jl[t][e]}`,children:x.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:g,height:D,viewBox:`0 0 ${g} ${D}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:x.jsx("polygon",{points:Ol[e]})})})},In=(e,t)=>{const r=i.useMemo(()=>oi(e,t),[e,t]),n=i.useRef(r);return yl(n.current,r)||(n.current=r),n.current},ai={"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"}},Xe=e=>e instanceof Date&&!Number.isNaN(e.getTime()),ve=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),st=(e,t)=>{if(typeof t!="number"||!Number.isInteger(t)||t<0||t>11)throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${ve(t)})`)},vr=(e,t)=>t===void 0?0:(st(e,t),t),Ne=(e,t,r=0)=>{if(!Xe(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${ve(t)})`);st("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},re=(e,t,r=0)=>{st("encode",r);const n=Ne(e,t,r),o=n.getFullYear(),a=n.getMonth()+1,l=n.getDate();if(e==="year")return o;if(e==="month")return o*12+(a-1);const c=new Date(0);return c.setUTCFullYear(o,a-1,l),c.setUTCHours(0,0,0,0),Math.floor(c.getTime()/(1440*60*1e3))},me=(e,t,r=0)=>{st("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),l=t-a*12;return n.setFullYear(a,l,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},je=(e,t,r)=>{if(!Xe(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${ve(t)})`);return e==="year"?lt.addYears(t,r):e==="month"?lt.addMonths(t,r):lt.addDays(t,r)},ii=(e,t,r,n=0)=>{if(!Xe(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${ve(r)})`);return st("getMacroWindowStartDate",n),Ne(t,Ne(e,r,n),n)},li=(e,t,r,n=0)=>{if(!Xe(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${ve(r)})`);if(st("getMacroWindowEndDate",n),e===t)return Ne(t,r,n);const o=r.getFullYear(),a=r.getMonth();if(e==="year"){const l=Ne("year",r,n),c=lt.addMonths(l,11);if(t==="month")return c;if(t==="day")return Ne("day",lt.addDays(lt.addMonths(l,12),-1))}return e==="month"&&t==="day"?new Date(o,a+1,0):Ne(t,r,n)},$a=(e,t,r)=>e<t?t:e>r?r:e,ht=(e,t,r,n,o,a=0)=>{if(st("resolveMacroWindow",a),Fr("macroRange",r,"resolveMacroWindow"),!Xe(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${ve(n)})`);if(!Xe(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${ve(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${ve(n)}, maxDate: ${ve(o)})`);return[Ne(t,$a(ii(e,t,r[0],a),n,o),a),Ne(t,$a(li(e,t,r[1],a),n,o),a)]},si=(e,t)=>{if(!Xe(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${ve(e)})`);st("resolveQuarter",t);const r=Ne("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}},Fl={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},ka=new Map,zl=(e,t)=>{const r=`${e}\0${t}`,n=ka.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Fl[e]);return ka.set(r,o),o},Bl=4,Ul=6,An=e=>e>=0?String(e).padStart(Bl,"0"):`-${String(-e).padStart(Ul,"0")}`,Wl=(e,t)=>{const r=An(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}`},He=(e,t,r,n)=>Xe(t)?r?r(t,e,"period"):n===void 0?Wl(e,t):zl(e,n).format(t):"",Bt=(e,t,r,n)=>He(e,t,r,n),Gl=(e,t)=>{if(!Xe(e))return"";st("formatQuarterLabel",t);const{quarter:r}=si(e,t);return`${He("year",Ne("year",e,t))}-Q${r}`},be=(e,t,r,n=0)=>{if(st("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;const o=re(r,t,n);let a=0,l=e.length-1;if(o<=re(r,e[a],n))return 0;if(o>=re(r,e[l],n))return l;for(;a<=l;){const g=a+l>>1,D=re(r,e[g],n);if(D===o)return g;D<o?a=g+1:l=g-1}const c=Math.abs(re(r,e[a],n)-o),d=Math.abs(re(r,e[l],n)-o);return c<d?a:l},Rt=(e,t,r,n,o=0)=>{if(st("getSortedAllowedDates",o),!Array.isArray(e)||e.length===0)return[];const a=re(t,r,o),l=re(t,n,o),c=new Map;for(const d of e){const g=Ne(t,d,o),D=re(t,g,o);D<a||D>l||c.has(D)||c.set(D,g)}if(c.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${ve(r)}, maxDate: ${ve(n)}, entries: ${e.length})`);return Array.from(c.keys()).sort((d,g)=>d-g).map(d=>c.get(d))},dn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const l=be(e,n,t,o);if(r==="time"){const c=e[0].getTime(),d=e[a].getTime()-c;return d<=0?0:Math.max(0,Math.min(1,(e[l].getTime()-c)/d))}return l/a},mn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const l=Math.max(0,Math.min(1,n));if(r==="time"){const c=e[0].getTime(),d=e[a].getTime()-c;return d<=0?0:be(e,new Date(c+l*d),t,o)}return Math.max(0,Math.min(a,Math.round(l*a)))},Ro=(e,t,r,n,o,a,l)=>{let c=r,d=n;return l?(c=t,d=t):e==="low"?t>n?(c=n,d=t):c=t:t<r?(d=r,c=t):d=t,[Math.max(o,Math.min(a,c)),Math.max(o,Math.min(a,d))]},ci=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:l,snapMode:c,unit:d,yearStartMonth:g=0})=>{if(a){const R=l.length-1;if(R<=0)return[0,0];const C=Math.max(0,Math.min(R,Math.round(t))),u=Math.max(C,Math.min(R,Math.round(r)));if(c==="time"){const J=l[0].getTime(),j=l[R].getTime(),ae=l[C].getTime(),N=l[u].getTime()-ae;let ne=ae+e*(j-J),z=ne+N;ne<J&&(ne=J,z=J+N),z>j&&(z=j,ne=j-N);const T=be(l,new Date(ne),d,g),p=be(l,new Date(z),d,g);return[T,Math.max(T,p)]}const q=Math.round(e*R);let L=C+q,K=u+q;return L<0&&(K+=-L,L=0),K>R&&(L-=K-R,K=R),[Math.max(0,Math.min(R,L)),Math.max(0,Math.min(R,K))]}const D=R=>Math.max(n,Math.min(o,R)),k=o-n;if(k<=0)return[D(t),D(r)];const b=Math.round(e*k);let h=t+b,S=r+b;return h<n&&(S+=n-h,h=n),S>o&&(h-=S-o,S=o),[D(h),D(S)]},ui=(e,t,r,n,o,a,l,c)=>{let d=0,g=!1,D=!1;switch(e){case"ArrowRight":case"ArrowUp":d=c;break;case"ArrowLeft":case"ArrowDown":d=-c;break;case"PageUp":d=c*5;break;case"PageDown":d=-c*5;break;case"Home":g=!0;break;case"End":D=!0;break;default:return null}if(l){let h=r;return g?h=o:D?h=a:h=Math.max(o,Math.min(a,r+d)),[h,h]}let k=r,b=n;return t==="low"?g?k=o:D?k=n:k=Math.max(o,Math.min(n,r+d)):g?b=r:D?b=a:b=Math.max(r,Math.min(a,n+d)),[k,b]},di=8,mi=2,fi=16,Kl=12,Xl=90,gi=(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}},Po=(e,t)=>{const r=t?.estimatedHeightPx??fi,o=di+(t?.anchorGapY??mi)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},Eo=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,l=o?.estimatedHeightPx??fi,c=o?.paddingPx??Kl,d=o?.maxAngleDeg??Xl,g=di+(o?.anchorGapY??mi),D=Po(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return D;const k=Math.max(0,t-e)/100*r,b=a+c;if(k>=b)return D;const h=Math.max(0,Math.min(1,(b-k)/b)),R=h*h*h*(h*(h*6-15)+10)*d,C=n==="top"?-R:R,u=gi(a,l,R),q=g+u.acrossPx,L=n==="top"?-q:+q,K=2*u.alongPx,J=Math.max(0,(K+c-k)/2);return{lowAngleDeg:C,highAngleDeg:C,lowOffsetX:-J,highOffsetX:J,lowOffsetY:L,highOffsetY:L,isSlanted:h>.001,proximity:h}},hi=e=>({...e,lowOffsetX:0,highOffsetX:0}),Co=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},bi=(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 wi(e,t,r,n,o,a,l="macro-top",c=.05,d=!0,g="range"){if(Co(t,l)==="macro"){const b=Math.abs(e-r),h=Math.abs(e-n);return b<=c&&b<=h?"macro-low":h<=c&&h<b?"macro-high":d&&e>=r&&e<=n?"macro-connect":b<h?"macro-low":"macro-high"}if(g==="point")return"micro-point";const D=Math.abs(e-o),k=Math.abs(e-a);return D<=c&&D<=k?"micro-low":k<=c&&k<D?"micro-high":d&&e>=o&&e<=a?"micro-connect":D<k?"micro-low":"micro-high"}function vi(e,t,r,n,o){if(e==="macro-connect"){const[g,D]=To(t-r,n,o);return[g,D,"macro-connect"]}const a=e==="macro-low"?"low":"high",[l,c]=pn(a,t,n,o),d=Pn(a,t,n,o);return[l,c,d==="low"?"macro-low":"macro-high"]}function Di(e,t,r,n,o){if(e==="micro-point"){const[g]=pn("point",t,n,o);return[g,g,"micro-point"]}if(e==="micro-connect"){const[g,D]=To(t-r,n,o);return[g,D,"micro-connect"]}const a=e==="micro-low"?"low":"high",[l,c]=pn(a,t,n,o),d=Pn(a,t,n,o);return[l,c,d==="low"?"micro-low":"micro-high"]}const Hr=i.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 l=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return x.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:x.jsx("path",{d:o,className:l,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});Hr.displayName="VernierKnobSvg";const ql=(e,t)=>{if(!Xe(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${ve(e)})`);if(!Xe(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${ve(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${ve(e)}, maxDate: ${ve(t)})`)},Fr=(e,t,r="PeriodSlider")=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`${r}: ${e} is required and must be a [start, end] Date tuple (received: ${ve(t)})`);const[n,o]=t;if(!Xe(n))throw new RangeError(`${r}: ${e}[0] must be a valid Date (received: ${ve(n)})`);if(!Xe(o))throw new RangeError(`${r}: ${e}[1] must be a valid Date (received: ${ve(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`${r}: ${e} must not be inverted (start: ${ve(n)}, end: ${ve(o)})`)},So=(e,t)=>{if(!Xe(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${ve(t)})`)},xt=(e,t,r,n,o,a)=>{const l=re(r,t,a);if(l<re(r,n,a)||l>re(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${ve(t)}, minDate: ${ve(n)}, maxDate: ${ve(o)})`)},Zl=(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&&(Fr(o,a),xt(`${o}[0]`,a[0],e.unit,t,r,n),xt(`${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&&(So(o,a),xt(o,a,e.unit,t,r,n))}},Ql=(e,t,r)=>{const n=e.yearStartMonth??0;Fr("macroRange",e.macroRange);const o=e.microUnit??e.unit,a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,l=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&l)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(l){if(e.microValue!==void 0)return So("microValue",e.microValue),xt("microValue",e.microValue,o,t,r,n),{shape:"point",selection:[e.microValue,e.microValue]};if(e.defaultMicroValue!==void 0)return So("defaultMicroValue",e.defaultMicroValue),xt("defaultMicroValue",e.defaultMicroValue,o,t,r,n),{shape:"point",selection:[e.defaultMicroValue,e.defaultMicroValue]};throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)")}if(e.microRange!==void 0)return Fr("microRange",e.microRange),xt("microRange[0]",e.microRange[0],o,t,r,n),xt("microRange[1]",e.microRange[1],o,t,r,n),{shape:"range",selection:e.microRange};if(e.defaultMicroRange!==void 0)return Fr("defaultMicroRange",e.defaultMicroRange),xt("defaultMicroRange[0]",e.defaultMicroRange[0],o,t,r,n),xt("defaultMicroRange[1]",e.defaultMicroRange[1],o,t,r,n),{shape:"range",selection:e.defaultMicroRange};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")},Or=(e,t,r,n,o,a,l,c,d)=>{const g=be(e,n,t,d),D=be(e,o,t,d);return l?g:c?D:Math.max(g,Math.min(D,be(e,r,t,d)+a))},go=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Oa=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback((a,l)=>{const c=r.current;if(c!==null&&c[0].getTime()===a.getTime()&&c[1].getTime()===l.getTime())return;const d=[a,l];r.current=d,t(d)},[]),o=i.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Jl=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},gr=()=>{const[e,t]=i.useState(null),r=i.useRef(null),n=i.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(l=>{for(const c of l){const d=c.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 i.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},ho=(e,t)=>{const r=wn(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},wn=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},es=e=>{const t={};let r=0;for(const o of e){const{side:a,box:l}=o;if(l===null)continue;let c;if(o.reach==="inline-size")c=l.widthPx,r=Math.max(r,l.heightPx/2);else{const d=gi(l.widthPx,l.heightPx,o.angleDeg);c=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(c)}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}},Va=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),Na=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),Mn=(e,t)=>({"--ps-tooltip-tx":so(e,"tx",t.tx),"--ps-tooltip-ty":so(e,"ty",t.ty),"--ps-tooltip-rot":so(e,"rot",t.rot)}),bo=(e,t,r,n)=>{const o=Po(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=Eo(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),l=n.isMerged?hi(a):a,c=Tn[e],d={low:Va(l.lowOffsetX,l.lowOffsetY-o.lowOffsetY,l.lowAngleDeg),high:Va(l.highOffsetX,l.highOffsetY-o.highOffsetY,l.highAngleDeg)};return{slant:l,lowStyle:Mn(c.low,d.low),highStyle:Mn(c.high,d.high),placements:d}},Ya={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},_a=(e,t,r)=>{const n=Po(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Ya,highStyle:Ya,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const d=Eo(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?hi(d):d}const l=Tn.flat,c={low:Na(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:Na(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...Mn(l.low,c.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...Mn(l.high,c.high)},placements:o?c:null}},ts={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},rs={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"}},Ha={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},ns={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${zr} ${Aa.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Ha.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${zr} ${Aa.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Ha.vertical}`}},ja={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"}},Fa=(e,t)=>{e.setPointerCapture(t)},os=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:l=!1,className:c="",showStepper:d=!0,tooltipStyle:g="always",labelPosition:D="top",autoSlantLabels:k=!0,isVertical:b=!1,hideConnectBar:h=!1,showTicks:S=!1,colorScheme:R="blue-rose",formatLocale:C}=e,u=vr("PeriodSlider",e.yearStartMonth);ql(r,n),Zl(e,r,n),C!==void 0&&Jl("formatLocale",C);const q=e.mode==="vernier"?Ql(e,r,n):null,L=q!==null&&q.shape==="point",K=In(e.locale,e.labels),J=ai[R],j=i.useId(),ae=i.useRef(e),N=r.getTime(),ne=n.getTime(),z=i.useMemo(()=>Rt(o,t,r,n,u),[o,t,N,ne,u]),T=z.length>0,{rangeMin:p,rangeMax:E}=i.useMemo(()=>T?{rangeMin:0,rangeMax:z.length-1}:{rangeMin:re(t,r,u),rangeMax:re(t,n,u)},[T,z,t,N,ne,u]),O=e.mode==="point",oe=i.useCallback(s=>{if(T){const m=Math.max(0,Math.min(z.length-1,Math.round(s)));return z[m]}return me(t,Math.round(s),u)},[T,z,t,u]),F=i.useCallback(s=>{if(s===void 0)return p;const m=Ne(t,s,u);return T?be(z,m,t,u):re(t,m,u)},[T,z,t,p,u]),[U,Re]=i.useState(()=>q===null?null:q.selection);let ee=U??(q===null?null:q.selection);if(L&&ee!==null&&ee[0].getTime()!==ee[1].getTime()){const s=[ee[0],ee[0]];ee=s,Re(s)}const ce=e.mode==="vernier"?e.microValue?.getTime():void 0,W=i.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,ce]),G=Oa(),ue=Oa(),pe=e.mode!=="vernier"?null:L?W??ee:e.microRange!==void 0?e.microRange:ee,Me=pe===null?null:ue.shown??pe,$e=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?Me?.[0]:void 0,I=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?Me?.[1]:void 0,ie=e.mode==="point"?e.value??e.defaultValue:void 0,le=e.mode==="point"?ie?.getTime():$e?.getTime(),Se=e.mode==="range"?I?.getTime():le,[Ce,Le]=i.useMemo(()=>{if(e.mode==="point"){const f=F(ie);return[f,f]}const s=F($e),m=F(I);return[Math.min(s,m),Math.max(s,m)]},[e.mode,le,Se,F,ie,$e,I]),ke=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:L?e.microValue!==void 0:e.microRange!==void 0,[Be,Z]=i.useState(()=>[Ce,Le]),[te,ge]=i.useState(null),[v,P]=i.useState(null),X=i.useRef(null),[De,he]=i.useState("high"),[xe,Ye]=i.useState(null),[Qe,bt]=i.useState(null),M=te?te[0]:ke?Ce:Be[0],V=te?te[1]:ke?Le:Be[1],Je=i.useRef([M,V]),de=e.mode==="vernier",nt=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",$=nt==="macro-top"||nt==="macro-left",Ci=e.mode==="vernier"?e.showVernierProjection??!0:!1,Ii=e.mode==="vernier"?e.showVernierTicks??!0:!1,Br=e.mode==="vernier"?e.showHairline??!0:!1,Q=de?e.macroUnit??t:t,A=de?e.microUnit??t:t,On=de?e.macroIsDiscrete??!1:T,Dr=de?e.microIsDiscrete??!1:T,Io=de?e.macroAllowedDates??o:o,Ao=de?e.microAllowedDates??o:o,Ur=de?e.formatMacroLabel??e.formatLabel:e.formatLabel,Wr=de?e.formatMicroLabel??e.formatLabel:e.formatLabel,Ai=$e?.getTime(),$i=I?.getTime(),[qe,Gr]=i.useState(null),St=i.useRef(null),[pr,Xt]=i.useState(()=>L?"micro-point":"micro-high");let _e=pr;const Vn=L?pr==="micro-low"||pr==="micro-high"||pr==="micro-connect"?"micro-point":null:pr==="micro-point"?"micro-high":null;Vn!==null&&(_e=Vn,Xt(Vn));const Fe=i.useMemo(()=>re(Q,r,u),[N,Q,u]),ct=i.useMemo(()=>{const s=re(Q,n,u);if(de&&s<=Fe)throw new RangeError(`PeriodSlider: macroUnit "${Q}" cannot distinguish minDate from maxDate (minDate: ${ve(r)}, maxDate: ${ve(n)})`);return s},[de,N,ne,Fe,Q,u]),Ee=i.useMemo(()=>de&&On?Rt(Io,Q,r,n,u):[],[de,On,Io,Q,N,ne,u]),$o=s=>[Math.max(Fe,Math.min(ct,re(Q,s[0],u))),Math.max(Fe,Math.min(ct,re(Q,s[1],u)))],[ko,Oo]=e.mode!=="vernier"?[Fe,ct]:$o(e.macroRange),[Ue,We]=G.shown===null?[ko,Oo]:$o(G.shown),wt=i.useMemo(()=>me(Q,Ue,u),[Q,Ue,u]),Vt=i.useMemo(()=>me(Q,We,u),[Q,We,u]),Kr=i.useMemo(()=>e.mode!=="vernier"?[r,n]:ht(Q,A,[wt,Vt],r,n,u),[e.mode,wt,Vt,Q,A,N,ne,u]),ye=i.useMemo(()=>re(A,Kr[0],u),[A,Kr,u]),Ae=i.useMemo(()=>re(A,Kr[1],u),[A,Kr,u]),Vo=i.useMemo(()=>de&&Dr?Rt(Ao,A,r,n,u):[],[de,Dr,Ao,A,N,ne,u]),Nn=(s,m)=>Vo.filter(f=>{const w=re(A,f,u);return w>=s&&w<=m}),fe=i.useMemo(()=>Nn(ye,Ae),[Vo,A,ye,Ae]),qt=On&&Ee.length>0,ot=Dr&&fe.length>0,Lt=(s,m,f,w)=>m.length>0?re(A,m[be(m,s,A,u)],u):Math.max(f,Math.min(w,re(A,s,u))),Zt=ot?fe:[],Oe=i.useMemo(()=>Me===null?ye:Lt(Me[0],Zt,ye,Ae),[Ai,ye,Ae,A,Me,Zt]),Ge=i.useMemo(()=>Me===null?Ae:Lt(Me[1],Zt,ye,Ae),[$i,ye,Ae,A,Me,Zt]),yt=i.useMemo(()=>me(A,Oe,u),[A,Oe,u]),Tt=i.useMemo(()=>me(A,Ge,u),[A,Ge,u]),No=!de||pe===null?null:{macroUnit:Q,macroLowEnc:ko,macroHighEnc:Oo,microUnit:A,microLowEnc:re(A,pe[0],u),microHighEnc:re(A,pe[1],u)},Yn=i.useRef(No),Xr=Math.max(1,ct-Fe),at=qt?dn(Ee,Q,a,wt,u):Math.max(0,Math.min(1,(Ue-Fe)/Xr)),ut=Math.max(at,qt?dn(Ee,Q,a,Vt,u):Math.min(1,(We-Fe)/Xr)),qr=Math.max(1,Ae-ye),Qt=ot?dn(fe,A,a,yt,u):Math.max(0,Math.min(1,(Oe-ye)/qr)),Mr=Math.max(Qt,ot?dn(fe,A,a,Tt,u):Math.min(1,(Ge-ye)/qr)),_n=i.useRef({timerId:null,emit:null}),Zr=i.useRef({timerId:null,emit:null}),Qr=i.useRef({timerId:null,emit:null});i.useEffect(()=>{const s=[_n,Zr,Qr];return()=>{for(const m of s)go(m.current)}},[]);const Jt=i.useCallback((s,m,f)=>{go(s);const{debounceMs:w}=ae.current;if(f||!w||w<=0){m();return}s.emit=m,s.timerId=setTimeout(()=>{s.timerId=null,s.emit=null,m()},w)},[]),Yo=i.useCallback(s=>{const m=s.emit;go(s),m?.()},[]),er=i.useCallback(s=>new Date(Math.min(Math.max(s.getTime(),N),ne)),[N,ne]),Pt=i.useCallback((s,m,f=!1)=>{const[w,y]=Je.current;if((ae.current.mode==="point"?s===w:s===w&&m===y)&&_n.current.timerId===null)return;const H=oe(s),_=oe(m),se=()=>{const we=ae.current;we.mode==="point"?we.onChangePoint?.(H):we.mode==="range"&&we.onChangeRange?.(H,_)};Jt(_n.current,se,f)},[oe,Jt]),Nt=i.useCallback((s,m,f=!1)=>{const w=Yn.current;if(ae.current.mode!=="vernier"||w===null)return;const y=er(s),Y=er(m);re(w.macroUnit,y,u)===w.macroLowEnc&&re(w.macroUnit,Y,u)===w.macroHighEnc&&Zr.current.timerId===null||Jt(Zr.current,()=>{const H=ae.current;H.mode==="vernier"&&H.onChangeMacroRange?.(y,Y)},f)},[er,Jt,u]),et=i.useCallback((s,m,f=!1)=>{const w=ae.current,y=Yn.current;if(w.mode!=="vernier"||y===null)return;const Y=er(s),H=er(m);re(y.microUnit,Y,u)===y.microLowEnc&&re(y.microUnit,H,u)===y.microHighEnc&&Qr.current.timerId===null||((L?w.microValue===void 0:w.microRange===void 0)&&Re([Y,H]),Jt(Qr.current,()=>{const _=ae.current;if(_.mode==="vernier"){if(L){_.onChangeMicroPoint?.(Y);return}_.onChangeMicroRange?.(Y,H)}},f))},[er,Jt,L,u]),_o=i.useCallback((s,m=!1)=>{et(s,s,m)},[et]),Yt=i.useCallback(s=>{if(T&&a==="time"&&z.length>1){const w=Math.max(0,Math.min(z.length-1,Math.round(s))),y=z[0].getTime(),H=z[z.length-1].getTime()-y;if(H<=0)return 0;const _=z[w].getTime();return Math.max(0,Math.min(100,(_-y)/H*100))}const m=E-p;if(m<=0)return 0;const f=(s-p)/m*100;return Math.max(0,Math.min(100,f))},[T,a,z,p,E]),Hn=i.useCallback(s=>{const m=Math.max(0,Math.min(100,s));if(T){if(a==="time"&&z.length>1){const y=z[0].getTime(),H=z[z.length-1].getTime()-y,_=y+m/100*H;return be(z,new Date(_),t,u)}const w=Math.round(m/100*(z.length-1));return Math.max(0,Math.min(z.length-1,w))}const f=p+m/100*(E-p);return Math.round(f)},[T,a,z,p,E,t,u]),xr=i.useRef(null),Ho=i.useRef(null),jo=i.useRef(0),Ze=i.useRef(null),jn=i.useRef(null),Fo=i.useRef(null),zo=i.useRef(null),[Fn,Bo]=i.useState(0),[ki,tr]=gr(),[Oi,Uo]=gr(),[Vi,Wo]=gr(),[Ni,Go]=gr(),[Yi,zn]=gr(),[_i,Ko]=gr(),Hi=O?tr===null?void 0:{estimatedWidthPx:tr.widthPx,estimatedHeightPx:tr.heightPx}:ho(tr,Uo),Bn=!O&&M===V,Un=Ue===We,Wn=!L&&Oe===Ge,ji=$?"top":"bottom",Fi=$?"bottom":"top",Xo=k&&!b,zi=Xo&&!L,Gn={isPointMode:O,isVertical:b,autoSlantLabels:k,isMerged:Bn,trackLengthPx:Fn,labelPosition:D,config:Hi},Kn={trackLengthPx:Fn,labelPosition:ji,config:ho(Wo,Go),isMerged:Un,isSlantable:Xo},Xn={trackLengthPx:Fn,labelPosition:Fi,config:ho(zn,Ko),isMerged:Wn,isSlantable:zi};i.useEffect(()=>{const s=Ze.current;if(!s)return;const m=()=>{const w=s.getBoundingClientRect(),y=b?w.height:w.width;y>0&&Bo(Y=>Math.abs(Y-y)<.5?Y:y)};if(m(),typeof ResizeObserver<"u"){const w=new ResizeObserver(y=>{for(const Y of y){const H=b?Y.contentRect.height:Y.contentRect.width;H>0&&Bo(_=>Math.abs(_-H)<.5?_:H)}});return w.observe(s),()=>w.disconnect()}const f=s.ownerDocument.defaultView;if(f)return f.addEventListener("resize",m),()=>f.removeEventListener("resize",m)},[b]);const rr=i.useCallback((s,m,f)=>{const w=b?f.height:f.width;if(!(Number.isFinite(w)&&w>0))return null;const y=b?f.bottom-m:s-f.left;return Number.isFinite(y)?Math.max(0,Math.min(1,y/w)):null},[b]),qo=i.useCallback((s,m)=>{const f=Ze.current;if(!f)return null;const w=rr(s,m,f.getBoundingClientRect());return w===null?null:w*100},[rr]),Rr=i.useRef(null),vt=i.useRef(null),Jr=i.useRef({macroLowRatio:at,macroHighRatio:ut,isVertical:b,isMacroFirstRail:$}),Zo=i.useRef({flat:Gn,macro:Kn,micro:Xn});i.useLayoutEffect(()=>{Jr.current={macroLowRatio:at,macroHighRatio:ut,isVertical:b,isMacroFirstRail:$},Zo.current={flat:Gn,macro:Kn,micro:Xn},ae.current=e,Je.current=[M,V],Yn.current=No,X.current=v,St.current=qe});const Qo=(s,m)=>{const f=Jr.current;jn.current?.setAttribute("d",co(s,m,f.isVertical,f.isMacroFirstRail))},Bi=(s,m,f)=>{const w=Zo.current;return s==="flat"?_a(m*100,f*100,w.flat).placements:bo(s,m,f,s==="macro"?w.macro:w.micro).placements},Sr=(s,m,f)=>{const w=Ze.current;if(!w)return;Rr.current={rail:s,lowRatio:m,highRatio:f},pl(w,s,m,f);const y=Bi(s,m,f);y!==null&&Dl(w,s,y),s==="macro"&&Qo(m,f)},_t=i.useCallback(()=>{vt.current!==null&&(clearTimeout(vt.current),vt.current=null);const s=Ze.current;s&&(s.removeAttribute(io),s.style.removeProperty(lo))},[]),Jo=()=>{const s=Ze.current;if(Rr.current===null||!s){Rr.current=null;return}Rr.current=null,vt.current!==null&&clearTimeout(vt.current),s.style.setProperty(lo,`${Pa}ms`),s.setAttribute(io,"true"),Ml(s),Qo(Jr.current.macroLowRatio,Jr.current.macroHighRatio),vt.current=setTimeout(()=>{vt.current=null,s.removeAttribute(io),s.style.removeProperty(lo)},Pa)};i.useLayoutEffect(()=>{const s=Rr.current;s!==null&&Sr(s.rail,s.lowRatio,s.highRatio)}),i.useEffect(()=>()=>{vt.current!==null&&clearTimeout(vt.current)},[]);const nr=i.useRef(null),or=i.useRef(null),dt=i.useRef(null),qn=i.useRef(null),Lr=i.useRef(null),Et=i.useCallback(()=>nr.current!==null||or.current!==null,[]),ea=s=>{if(l)return;if(de){const B=or.current;if(!B||s.pointerId!==B.pointerId||!Ze.current)return;const it=rr(s.clientX,s.clientY,Ze.current.getBoundingClientRect());if(it===null)return;if(B.handle==="macro-low"||B.handle==="macro-high"||B.handle==="macro-connect"){const[Ve,Ie,Dt]=vi(B.handle,it,B.startPointerRatio,B.startMacroLowRatio,B.startMacroHighRatio);Sr("macro",Ve,Ie),Dt!==St.current&&(St.current=Dt,Gr(Dt),Xt(Dt));let ze,tt;if(qt){const Ct=mn(Ee,Q,a,Ve,u),It=Math.max(Ct,mn(Ee,Q,a,Ie,u));ze=Ee[Ct],tt=Ee[It]}else{const Ct=Math.round(Fe+Ve*Xr),It=Math.round(Fe+Ie*Xr);ze=me(Q,Ct,u),tt=me(Q,It,u)}G.show(ze,tt);const Cr=`${ze.getTime()}_${tt.getTime()}`;Cr!==qn.current&&(qn.current=Cr,Nt(ze,tt));const[pt,jt]=ht(Q,A,[ze,tt],r,n,u),oo=re(A,pt,u),ao=re(A,jt,u),Sa=Dr?Nn(oo,ao):[];let Ft,zt;if(B.handle==="macro-connect"){const Ct=pt,It=jt;let dr,mr;if(Q==="year"){const At=ze.getFullYear()-B.startMacroLowDate.getFullYear();dr=je("year",B.initialMicroLowDate,At),mr=je("year",B.initialMicroHighDate,At)}else if(Q==="month"){const At=(ze.getFullYear()-B.startMacroLowDate.getFullYear())*12+(ze.getMonth()-B.startMacroLowDate.getMonth());dr=je("month",B.initialMicroLowDate,At),mr=je("month",B.initialMicroHighDate,At)}else{const At=Math.round((ze.getTime()-B.startMacroLowDate.getTime())/864e5);dr=je("day",B.initialMicroLowDate,At),mr=je("day",B.initialMicroHighDate,At)}const fr=Ct.getTime(),Ir=It.getTime(),Ta=B.initialMicroHighDate.getTime()-B.initialMicroLowDate.getTime();let Ar=dr.getTime(),$r=mr.getTime();Ar<fr&&(Ar=fr,$r=Math.min(Ir,Ar+Ta)),$r>Ir&&($r=Ir,Ar=Math.max(fr,$r-Ta)),Ft=Ne(A,new Date(Ar),u),zt=Ne(A,new Date($r),u)}else{const Ct=pt.getTime(),It=jt.getTime(),dr=B.initialMicroLowDate.getTime(),mr=B.initialMicroHighDate.getTime(),fr=Math.max(Ct,Math.min(It,dr)),Ir=Math.max(fr,Math.min(It,mr));Ft=Ne(A,new Date(fr),u),zt=Ne(A,new Date(Ir),u)}const La=Lt(Ft,Sa,oo,ao),wl=Math.max(La,Lt(zt,Sa,oo,ao));Ft=me(A,La,u),zt=me(A,wl,u),ue.show(Ft,zt);const ya=`${Ft.getTime()}_${zt.getTime()}`;ya!==Lr.current&&(Lr.current=ya,et(Ft,zt))}else if(B.handle==="micro-low"||B.handle==="micro-high"||B.handle==="micro-connect"||B.handle==="micro-point"){const[Ve,Ie,Dt]=Di(B.handle,it,B.startPointerRatio,B.startMicroLowRatio,B.startMicroHighRatio);Sr("micro",Ve,Ie),Dt!==St.current&&(St.current=Dt,Gr(Dt),Xt(Dt));let ze,tt;if(ot){const pt=mn(fe,A,a,Ve,u),jt=Math.max(pt,mn(fe,A,a,Ie,u));ze=fe[pt],tt=fe[jt]}else{const pt=Lt(me(A,Math.round(ye+Ve*qr),u),Zt,ye,Ae),jt=Math.max(pt,Lt(me(A,Math.round(ye+Ie*qr),u),Zt,ye,Ae));ze=me(A,pt,u),tt=me(A,jt,u)}ue.show(ze,tt);const Cr=`${ze.getTime()}_${tt.getTime()}`;Cr!==Lr.current&&(Lr.current=Cr,et(ze,tt))}return}const m=nr.current;if(!m||s.pointerId!==m.pointerId||!Ze.current)return;const f=Ze.current.getBoundingClientRect(),w=b?s.clientY:s.clientX,y=b?f.height:f.width;if(!(Number.isFinite(y)&&y>0))return;if(m.handle==="connect"){const B=b?(m.startPointerPos-w)/y:(w-m.startPointerPos)/y,[it,Ve]=To(B,m.startLowRatio,m.startHighRatio);Sr("flat",it,Ve);const Ie=ci({posDiffPct:B,startLowVal:m.startLowVal,startHighVal:m.startHighVal,rangeMin:p,rangeMax:E,isDiscrete:T,sortedAllowedDates:z,snapMode:a,unit:t,yearStartMonth:u});if(dt.current&&dt.current[0]===Ie[0]&&dt.current[1]===Ie[1])return;dt.current=Ie,ge(Ie),Pt(Ie[0],Ie[1],!1);return}const Y=rr(s.clientX,s.clientY,f);if(Y===null)return;const[H,_]=pn(O?"point":m.handle,Y,m.startLowRatio,m.startHighRatio);Sr("flat",H,_);const se=Hn(Y*100),[we,Te]=Ro(m.handle,se,m.startLowVal,m.startHighVal,p,E,O);if((!dt.current||dt.current[0]!==we||dt.current[1]!==Te)&&(dt.current=[we,Te],ge([we,Te]),Pt(we,Te,!1)),!O&&(m.handle==="low"||m.handle==="high")){const B=Pn(m.handle,Y,m.startLowRatio,m.startHighRatio);X.current!==B&&(X.current=B,P(B),he(B))}},ta=()=>{Jo(),qn.current=null,Lr.current=null,or.current=null,St.current=null,Gr(null),G.release(),ue.release(),Yo(Zr.current),Yo(Qr.current)},ra=()=>{Jo();const s=dt.current??te;s&&(Pt(s[0],s[1],!0),Z(s)),dt.current=null,ge(null),nr.current=null,X.current=null,P(null)},na=s=>{if(de){const f=or.current;if(!f||s.pointerId!==f.pointerId)return;ta();return}const m=nr.current;!m||s.pointerId!==m.pointerId||ra()},oa=()=>{or.current!==null&&ta(),nr.current!==null&&ra()},Zn=i.useRef(ea),aa=i.useRef(na),ia=i.useRef(oa);i.useLayoutEffect(()=>{Zn.current=ea,aa.current=na,ia.current=oa});const la=i.useRef(de);i.useEffect(()=>{la.current!==de&&(la.current=de,ia.current())},[de]);const sa=v!==null||qe!==null;i.useEffect(()=>{if(!sa)return;const s=xr.current?.ownerDocument.defaultView;if(!s)return;const m=w=>Zn.current(w),f=w=>aa.current(w);return s.addEventListener("pointermove",m),s.addEventListener("pointerup",f),s.addEventListener("pointercancel",f),s.addEventListener("lostpointercapture",f),()=>{s.removeEventListener("pointermove",m),s.removeEventListener("pointerup",f),s.removeEventListener("pointercancel",f),s.removeEventListener("lostpointercapture",f)}},[sa]);const Qn=i.useCallback((s,m,f,w)=>{_t(),Fa(s,m),nr.current={pointerId:m,handle:f,startPointerPos:w,startLowVal:M,startHighVal:V,startLowRatio:Yt(M)/100,startHighRatio:Yt(V)/100},X.current=f,P(f),f!=="connect"&&he(f)},[M,V,Yt]),ca=i.useCallback((s,m,f,w)=>{ae.current.mode==="vernier"&&(_t(),Fa(s,m),or.current={pointerId:m,handle:f,startPointerRatio:w,startMacroLowRatio:at,startMacroHighRatio:ut,startMicroLowRatio:Qt,startMicroHighRatio:Mr,startMacroLowDate:wt,initialMicroLowDate:yt,initialMicroHighDate:Tt},St.current=f,Gr(f),Xt(f))},[at,ut,Qt,Mr,wt,yt,Tt]),ua=s=>m=>{if(l||Et())return;m.stopPropagation(),m.preventDefault(),he(s);const f=b?m.clientY:m.clientX;Qn(m.currentTarget,m.pointerId,s,f)},da=s=>()=>{l||X.current!==null||he(s)},en=s=>()=>{l||St.current!==null||Xt(s)},ar=s=>m=>{if(l||Et())return;m.stopPropagation(),m.preventDefault();const f=Ze.current;if(!f)return;const w=rr(m.clientX,m.clientY,f.getBoundingClientRect());w!==null&&ca(m.currentTarget,m.pointerId,s,w)},Ui=s=>{if(l||h||Et())return;s.stopPropagation(),s.preventDefault();const m=b?s.clientY:s.clientX;Qn(s.currentTarget,s.pointerId,"connect",m)},Wi=s=>{if(l||Et())return;if(de){const _=Ze.current;if(!_)return;const se=_.getBoundingClientRect(),we=rr(s.clientX,s.clientY,se);if(we===null)return;const Te=b?s.clientX-(se.left+se.width/2):s.clientY-(se.top+se.height/2),B=wi(we,Te,at,ut,Qt,Mr,nt,void 0,!h,L?"point":"range");ca(s.currentTarget,s.pointerId,B,we),Zn.current(s.nativeEvent);return}const m=qo(s.clientX,s.clientY);if(m===null)return;const f=Hn(m);let w="low";if(!O){const _=Math.abs(f-M),se=Math.abs(f-V);_<se?w="low":se<_?w="high":w=f>V?"high":"low"}he(w);const[y,Y]=Ro(w,f,M,V,p,E,O);ge([y,Y]),Pt(y,Y,!0);const H=b?s.clientY:s.clientX;Qn(s.currentTarget,s.pointerId,w,H)},Gi=s=>{if(l||de||v!==null)return;const m=qo(s.clientX,s.clientY);if(m===null)return;const f=Hn(m);Ye(f),bt(Yt(f))},Ki=()=>{Ye(null),bt(null)},ma=s=>m=>{if(l||Et())return;he(s);const f=ui(m.key,s,M,V,p,E,O,1);f&&(m.preventDefault(),_t(),ke||Z(f),Pt(f[0],f[1],!0))},ir=(s,m)=>{if(pe===null)return;const[f,w]=ht(Q,A,[s,m],r,n,u),y=re(A,f,u),Y=re(A,w,u),H=Dr?Nn(y,Y):[],_=Lt(pe[0],H,y,Y),se=Math.max(_,Lt(pe[1],H,y,Y));et(me(A,_,u),me(A,se,u),!0)},tn=s=>m=>{if(l||!de||e.mode!=="vernier"||Et())return;Xt(s);let f=0,w=!1,y=!1;switch(m.key){case"ArrowRight":case"ArrowUp":f=1;break;case"ArrowLeft":case"ArrowDown":f=-1;break;case"PageUp":f=5;break;case"PageDown":f=-5;break;case"Home":w=!0;break;case"End":y=!0;break;default:return}if(m.preventDefault(),_t(),s==="macro-low"){const Y=me(Q,Ue,u),H=me(Q,We,u);if(qt){const we=Or(Ee,Q,Y,Ee[0],H,f,w,y,u);if(we===be(Ee,Y,Q,u))return;const Te=Ee[we];Nt(Te,H,!0),ir(Te,H);return}let _;if(w?_=Fe:y?_=We:_=Math.max(Fe,Math.min(We,Ue+f)),_===Ue)return;const se=me(Q,_,u);Nt(se,H,!0),ir(se,H)}else if(s==="macro-high"){const Y=me(Q,Ue,u),H=me(Q,We,u);if(qt){const we=Or(Ee,Q,H,Y,Ee[Ee.length-1],f,w,y,u);if(we===be(Ee,H,Q,u))return;const Te=Ee[we];Nt(Y,Te,!0),ir(Y,Te);return}let _;if(w?_=Ue:y?_=ct:_=Math.max(Ue,Math.min(ct,We+f)),_===We)return;const se=me(Q,_,u);Nt(Y,se,!0),ir(Y,se)}else if(s==="micro-low"){const Y=me(A,Oe,u),H=me(A,Ge,u);if(ot){const se=Or(fe,A,Y,fe[0],H,f,w,y,u);if(se===be(fe,Y,A,u))return;et(fe[se],H,!0);return}let _;if(w?_=ye:y?_=Ge:_=Math.max(ye,Math.min(Ge,Oe+f)),_===Oe)return;et(me(A,_,u),H,!0)}else if(s==="micro-high"){const Y=me(A,Oe,u),H=me(A,Ge,u);if(ot){const se=Or(fe,A,H,Y,fe[fe.length-1],f,w,y,u);if(se===be(fe,H,A,u))return;et(Y,fe[se],!0);return}let _;if(w?_=Oe:y?_=Ae:_=Math.max(Oe,Math.min(Ae,Ge+f)),_===Ge)return;et(Y,me(A,_,u),!0)}else if(s==="micro-point"){const Y=me(A,Oe,u);if(ot){const _=Or(fe,A,Y,fe[0],fe[fe.length-1],f,w,y,u);if(_===be(fe,Y,A,u))return;_o(fe[_],!0);return}let H;if(w?H=ye:y?H=Ae:H=Math.max(ye,Math.min(Ae,Oe+f)),H===Oe)return;_o(me(A,H,u),!0)}},Xi=s=>{if(e.mode!=="vernier")return;if(_t(),qt){const H=Ee.length-1,_=be(Ee,wt,Q,u),se=be(Ee,Vt,Q,u),we=se-_;let Te=_+s,B=se+s;if(s<0&&Te<0?(Te=0,B=Math.min(H,we)):s>0&&B>H&&(B=H,Te=Math.max(0,H-we)),Te===_&&B===se)return;const it=Ee[Te],Ve=Ee[B];Nt(it,Ve,!0),ir(it,Ve);return}const m=We-Ue;let f=Ue+s,w=We+s;if(s<0&&f<Fe?(f=Fe,w=Math.min(ct,f+m)):s>0&&w>ct&&(w=ct,f=Math.max(Fe,w-m)),f===Ue&&w===We)return;const y=me(Q,f,u),Y=me(Q,w,u);Nt(y,Y,!0),ir(y,Y)},Jn=i.useCallback(s=>{const m=ae.current;if(!(m.disabled||Et()))if(_t(),m.mode==="point"){const f=Math.max(p,Math.min(E,M+s));ke||Z([f,f]),Pt(f,f,!0)}else if(m.mode==="vernier"){if(ot){const we=fe.length-1,Te=be(fe,yt,A,u),B=be(fe,Tt,A,u),it=B-Te;let Ve=Te+s,Ie=B+s;s<0&&Ve<0?(Ve=0,Ie=Math.min(we,it)):s>0&&Ie>we&&(Ie=we,Ve=Math.max(0,we-it)),(Ve!==Te||Ie!==B)&&et(fe[Ve],fe[Ie],!0);return}const f=Oe,w=Ge,y=ye,Y=Ae,H=w-f;let _=f+s,se=w+s;s<0&&_<y?(_=y,se=Math.min(Y,_+H)):s>0&&se>Y&&(se=Y,_=Math.max(y,se-H)),(_!==f||se!==w)&&et(me(A,_,u),me(A,se,u),!0)}else{const f=V-M;let w=M+s,y=V+s;s<0&&w<p?(w=p,y=Math.min(E,w+f)):s>0&&y>E&&(y=E,w=Math.max(p,y-f)),w<=y&&(ke||Z([w,y]),Pt(w,y,!0))}},[M,V,p,E,ke,Pt,et,Oe,Ge,ye,Ae,A,ot,fe,yt,Tt,_t,u]),fa=s=>!l&&uo(xr.current,s),ga=(s,m)=>{const f=Ho.current,w=Ze.current,y=xr.current;if(l||f===null||w===null||y===null||!Al(f,y,jo.current,b,s,m))return null;const Y=w.getBoundingClientRect();return Math.abs(b?s-(Y.left+Y.width/2):m-(Y.top+Y.height/2))},ha=s=>{if(l||Et())return;const m=bi(s.deltaX,s.deltaY,b);if(m===0)return;s.preventDefault();const f=s.target,w=uo(Fo.current,f)||uo(zo.current,f);if(!de||w){Jn(m);return}const y=Ze.current;if(!y)return;const Y=y.getBoundingClientRect(),H=b?s.clientX-(Y.left+Y.width/2):s.clientY-(Y.top+Y.height/2);if(Co(H,nt)==="macro"){Xi(m);return}Jn(m)},rn=i.useRef({ownsWheelHit:fa,distanceToRailPx:ga,stepFromRangeAreaWheel:ha});i.useLayoutEffect(()=>{rn.current={ownsWheelHit:fa,distanceToRailPx:ga,stepFromRangeAreaWheel:ha}});const yr=i.useRef(null);i.useEffect(()=>{const s=xr.current?.ownerDocument.defaultView??null,m=yr.current;if(m!==null&&m.view===s)return;if(m?.unregister(),s===null){yr.current=null;return}const f=kl(s,{ownsHit:w=>rn.current.ownsWheelHit(w),distanceToRailPx:(w,y)=>rn.current.distanceToRailPx(w,y),step:w=>rn.current.stepFromRangeAreaWheel(w)});yr.current={view:s,unregister:f}}),i.useEffect(()=>()=>{yr.current?.unregister(),yr.current=null},[]);const nn=Yt(M),on=Yt(V),eo=oe(M),to=oe(V),ro=_a(nn,on,Gn),Tr=ro.slant,Pr=v==="low"||v!=="high"&&De==="low",Er=!O&&(v==="high"||v!=="low"&&De==="high"),qi=Un&&_e!=="macro-low",Zi=Un&&_e==="macro-low",Qi=Wn&&_e!=="micro-low",Ji=Wn&&_e==="micro-low",lr=bo("macro",at,ut,Kn),sr=bo("micro",Qt,Mr,Xn),el=Math.min(nn,on),tl=Math.max(nn,on),[ba,wa]=jr.flat,[rl,nl]=jr.macro,[ol,al]=jr.micro,va=$t(ba,nn),Da=$t(wa,on),no=$t(ba,el),pa=`calc(${$t(wa,tl)} - ${no})`,cr=$t(rl,at*100),an=$t(nl,ut*100),ur=$t(ol,Qt*100),ln=$t(al,Mr*100),il=b?{bottom:no,height:pa,top:"auto",left:"0",right:"0"}:{left:no,width:pa,top:"0",bottom:"0"},ll=Math.max(.01,ut-at),Ma=Math.max(.06,Math.min(.25,.28*Math.sqrt(ll))),sl=b?{bottom:va,left:"50%",transform:"translate(-50%, 50%)",zIndex:Pr?40:30}:{left:va,top:"50%",transform:"translate(-50%, -50%)",zIndex:Pr?40:30},cl=b?{bottom:Da,left:"50%",transform:"translate(-50%, 50%)",zIndex:Er?40:30}:{left:Da,top:"50%",transform:"translate(-50%, -50%)",zIndex:Er?40:30},ul=b?{bottom:`${Qe}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Qe}%`,top:"50%",transform:"translate(-50%, -50%)"},xa=xe!==null?oe(xe):null,dl=g!=="hover"&&xe!==null&&(xe===M||!O&&xe===V),ml=ot?re(A,fe[0],u):ye,fl=ot?re(A,fe[fe.length-1],u):Ae,gl=de?Oe>ml:M>p,hl=de?Ge<fl:V<E,sn=es(de?[{side:$?"before":"after",box:wn(Wo,Go),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:lr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:lr.slant.lowOffsetX}},{side:$?"after":"before",box:L?zn:wn(zn,Ko),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:sr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:sr.slant.lowOffsetX}}]:[{side:b||D==="top"?"before":"after",box:O?tr:wn(tr,Uo),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Tr.lowAngleDeg,centreOffsetPx:Tr.lowOffsetY,alongPushPx:Tr.lowOffsetX}}]),bl=sn===void 0?e.style:{...e.style,...sn.style};i.useLayoutEffect(()=>{jo.current=sn===void 0?0:sn.mainPx});const mt=L?"micro-point":"micro-low",Ht=l?"cursor-not-allowed opacity-50":"cursor-pointer",Ra=s=>{const m=b?"vertical":"horizontal",f=s==="decrease",w=b?!f:f;return x.jsx(Kt,{ref:f?Fo:zo,neighbour:"rail",direction:ts[m][s],disabled:l,canStep:f?gl:hl,onStep:()=>Jn(f?-1:1),ariaLabel:f?K.decrease:K.increase,className:`period-slider-stepper-btn ${rs[m][s]} ${ja[m][w?"leading":"trailing"]}`})};return x.jsxs("div",{ref:xr,style:bl,className:`period-slider grid select-none place-items-center ${ns[b?"vertical":"horizontal"][d?"withSteppers":"railOnly"]} ${c}`,"data-disabled":l?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":D,"data-color-scheme":R,children:[x.jsx("div",{ref:Ho,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),d&&Ra(b?"increase":"decrease"),x.jsx("div",{ref:Ze,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":de?nt:void 0,className:`period-slider-track relative touch-none rounded-full ${ja[b?"vertical":"horizontal"][d?"rail":"railOnly"]} ${Ht}`,onPointerDown:Wi,onPointerMove:Gi,onPointerLeave:Ki,children:de?x.jsxs(x.Fragment,{children:[Ci&&(b?x.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:[x.jsx("defs",{children:x.jsxs("linearGradient",{id:j,x1:"0",y1:"0",x2:"1",y2:"0",children:[x.jsx("stop",{offset:"0%",stopColor:$?J.macro:J.micro,stopOpacity:"0.28"}),x.jsx("stop",{offset:"100%",stopColor:$?J.micro:J.macro,stopOpacity:Ma})]})}),x.jsx("path",{ref:jn,"data-testid":"period-slider-vernier-projection",d:co(at,ut,b,$),fill:`url(#${j})`})]}):x.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[x.jsx("defs",{children:x.jsxs("linearGradient",{id:j,x1:"0",y1:"0",x2:"0",y2:"1",children:[x.jsx("stop",{offset:"0%",stopColor:$?J.macro:J.micro,stopOpacity:"0.28"}),x.jsx("stop",{offset:"100%",stopColor:$?J.micro:J.macro,stopOpacity:Ma})]})}),x.jsx("path",{ref:jn,"data-testid":"period-slider-vernier-projection",d:co(at,ut,b,$),fill:`url(#${j})`})]})),!h&&x.jsxs(x.Fragment,{children:[x.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${cr} - 8px)`,height:`calc(${an} - ${cr} + 16px)`}:{left:`calc(${cr} - 8px)`,width:`calc(${an} - ${cr} + 16px)`},onPointerDown:ar("macro-connect")}),!L&&x.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${ur} - 8px)`,height:`calc(${ln} - ${ur} + 16px)`}:{left:`calc(${ur} - 8px)`,width:`calc(${ln} - ${ur} + 16px)`},onPointerDown:ar("micro-connect")})]}),Ii&&x.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(s=>x.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${s*100}%`}:{left:`${s*100}%`}},`macro-tick-${s}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(s=>x.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${s*100}%`}:{left:`${s*100}%`}},`micro-tick-${s}`))]}),x.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":K.macroRangeStart,"aria-disabled":l?"true":void 0,"aria-valuemin":Fe,"aria-valuemax":We,"aria-valuenow":Ue,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(wt,Q,"period"):Bt(Q,wt,Ur,C),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${Ht}`,style:b?{bottom:cr,left:$?0:"auto",right:$?"auto":0,transform:$?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:qe==="macro-low"||_e==="macro-low"?30:15}:{left:cr,top:$?0:"auto",bottom:$?"auto":0,transform:$?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:qe==="macro-low"||_e==="macro-low"?30:15},onPointerDown:ar("macro-low"),onKeyDown:tn("macro-low"),onFocus:en("macro-low"),"data-active":qe==="macro-low"?"true":void 0,"data-front":_e==="macro-low"?"true":void 0,"data-vernier-pos":b?$?"left":"right":$?"top":"bottom","data-handle-type":"macro-low",children:[x.jsx(Hr,{type:"macro",isTop:$,isVertical:b,isLeft:$}),Br&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&x.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":qi?"true":void 0,"data-slanted":lr.slant.isSlanted?"true":void 0,ref:Vi,style:lr.lowStyle,children:He(Q,wt,Ur,C)})]}),x.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":K.macroRangeEnd,"aria-disabled":l?"true":void 0,"aria-valuemin":Ue,"aria-valuemax":ct,"aria-valuenow":We,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Vt,Q,"period"):Bt(Q,Vt,Ur,C),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${Ht}`,style:b?{bottom:an,left:$?0:"auto",right:$?"auto":0,transform:$?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:qe==="macro-high"||_e==="macro-high"?30:15}:{left:an,top:$?0:"auto",bottom:$?"auto":0,transform:$?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:qe==="macro-high"||_e==="macro-high"?30:15},onPointerDown:ar("macro-high"),onKeyDown:tn("macro-high"),onFocus:en("macro-high"),"data-active":qe==="macro-high"?"true":void 0,"data-front":_e==="macro-high"?"true":void 0,"data-vernier-pos":b?$?"left":"right":$?"top":"bottom","data-handle-type":"macro-high",children:[x.jsx(Hr,{type:"macro",isTop:$,isVertical:b,isLeft:$}),Br&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&x.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":Zi?"true":void 0,"data-slanted":lr.slant.isSlanted?"true":void 0,ref:Ni,style:lr.highStyle,children:He(Q,Vt,Ur,C)})]}),x.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":L?K.microSelectedDate:K.microRangeStart,"aria-disabled":l?"true":void 0,"aria-valuemin":ye,"aria-valuemax":L?Ae:Ge,"aria-valuenow":Oe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(yt,A,"period"):Bt(A,yt,Wr,C),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${Ht}`,style:b?{bottom:ur,left:$?"auto":0,right:$?0:"auto",transform:$?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:qe===mt||_e===mt?30:20}:{left:ur,top:$?"auto":0,bottom:$?0:"auto",transform:$?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:qe===mt||_e===mt?30:20},onPointerDown:ar(mt),onKeyDown:tn(mt),onFocus:en(mt),"data-active":qe===mt?"true":void 0,"data-front":_e===mt?"true":void 0,"data-vernier-pos":b?$?"right":"left":$?"bottom":"top","data-handle-type":mt,children:[x.jsx(Hr,{type:"micro",isTop:!$,isVertical:b,isLeft:!$}),Br&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&x.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":Qi?"true":void 0,"data-slanted":sr.slant.isSlanted?"true":void 0,ref:Yi,style:sr.lowStyle,children:He(A,yt,Wr,C)})]}),!L&&x.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":K.microRangeEnd,"aria-disabled":l?"true":void 0,"aria-valuemin":Oe,"aria-valuemax":Ae,"aria-valuenow":Ge,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Tt,A,"period"):Bt(A,Tt,Wr,C),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?$?"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":$?"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 ${Ht}`,style:b?{bottom:ln,left:$?"auto":0,right:$?0:"auto",transform:$?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:qe==="micro-high"||_e==="micro-high"?30:20}:{left:ln,top:$?"auto":0,bottom:$?0:"auto",transform:$?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:qe==="micro-high"||_e==="micro-high"?30:20},onPointerDown:ar("micro-high"),onKeyDown:tn("micro-high"),onFocus:en("micro-high"),"data-active":qe==="micro-high"?"true":void 0,"data-front":_e==="micro-high"?"true":void 0,"data-vernier-pos":b?$?"right":"left":$?"bottom":"top","data-handle-type":"micro-high",children:[x.jsx(Hr,{type:"micro",isTop:!$,isVertical:b,isLeft:!$}),Br&&x.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&x.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":Ji?"true":void 0,"data-slanted":sr.slant.isSlanted?"true":void 0,ref:_i,style:sr.highStyle,children:He(A,Tt,Wr,C)})]})]}):x.jsxs(x.Fragment,{children:[!h&&x.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:il,onPointerDown:Ui}),S&&T&&z.length>1&&x.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:z.map((s,m)=>{const f=re(t,s,u),w=Yt(m),y=b?{bottom:`${w}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${w}%`,top:"50%",transform:"translate(-50%, -50%)"};return x.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:y},`tick-${f}`)})}),!l&&xe!==null&&Qe!==null&&v===null&&xa&&x.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:ul,children:[x.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"}),x.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":dl?"true":void 0,className:`period-slider-hover-tooltip ${D==="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:He(t,xa,e.formatLabel,C)})]}),x.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":O?K.selectedDate:K.rangeStart,"aria-disabled":l?"true":void 0,"aria-valuemin":p,"aria-valuemax":O?E:V,"aria-valuenow":M,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(eo,t,"period"):Bt(t,eo,e.formatLabel,C),"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 ${Ht}`,style:sl,onPointerDown:ua("low"),onKeyDown:ma("low"),onFocus:da("low"),"data-active":v==="low"?"true":void 0,"data-front":Pr?"true":void 0,children:[x.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 ${v==="low"?"":"shadow-md"}`}),g!=="hover"&&x.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":D,"data-slanted":Tr.isSlanted?"true":void 0,"data-front":Pr?"true":void 0,"data-duplicate":Bn&&!Pr?"true":void 0,ref:ki,style:ro.lowStyle,children:He(t,eo,e.formatLabel,C)})]}),!O&&x.jsxs("div",{tabIndex:l?-1:0,role:"slider","aria-label":K.rangeEnd,"aria-disabled":l?"true":void 0,"aria-valuemin":M,"aria-valuemax":E,"aria-valuenow":V,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(to,t,"period"):Bt(t,to,e.formatLabel,C),"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 ${Ht}`,style:cl,onPointerDown:ua("high"),onKeyDown:ma("high"),onFocus:da("high"),"data-active":v==="high"?"true":void 0,"data-front":Er?"true":void 0,children:[x.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 ${v==="high"?"":"shadow-md"}`}),g!=="hover"&&x.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":D,"data-slanted":Tr.isSlanted?"true":void 0,"data-front":Er?"true":void 0,"data-duplicate":Bn&&!Er?"true":void 0,ref:Oi,style:ro.highStyle,children:He(t,to,e.formatLabel,C)})]})]})}),d&&Ra(b?"decrease":"increase")]})},wo=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},pi=(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},as=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||e.minDate.getTime()!==t.minDate.getTime()||e.maxDate.getTime()!==t.maxDate.getTime()||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||!pi(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Cn(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!wo(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!((e.value?.getTime()??null)!==(t.value?.getTime()??null)||(e.defaultValue?.getTime()??null)!==(t.defaultValue?.getTime()??null)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!((e.range?.[0]?.getTime()??null)!==(t.range?.[0]?.getTime()??null)||(e.range?.[1]?.getTime()??null)!==(t.range?.[1]?.getTime()??null)||(e.defaultRange?.[0]?.getTime()??null)!==(t.defaultRange?.[0]?.getTime()??null)||(e.defaultRange?.[1]?.getTime()??null)!==(t.defaultRange?.[1]?.getTime()??null)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!((e.microRange?.[0]?.getTime()??null)!==(t.microRange?.[0]?.getTime()??null)||(e.microRange?.[1]?.getTime()??null)!==(t.microRange?.[1]?.getTime()??null)||(e.defaultMicroRange?.[0]?.getTime()??null)!==(t.defaultMicroRange?.[0]?.getTime()??null)||(e.defaultMicroRange?.[1]?.getTime()??null)!==(t.defaultMicroRange?.[1]?.getTime()??null)||(e.microValue?.getTime()??null)!==(t.microValue?.getTime()??null)||(e.defaultMicroValue?.getTime()??null)!==(t.defaultMicroValue?.getTime()??null)||e.macroRange[0].getTime()!==t.macroRange[0].getTime()||e.macroRange[1].getTime()!==t.macroRange[1].getTime()||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||!wo(e.macroAllowedDates,t.macroAllowedDates)||!wo(e.microAllowedDates,t.microAllowedDates)):!1,Mi=i.memo(os,as);Mi.displayName="PeriodSlider";const xi=864e5,za=2,Pe=-1,vn=e=>{const t=e.getFullYear(),r=new Date(Date.UTC(t,e.getMonth(),e.getDate()));return r.setUTCFullYear(t),Math.floor(r.getTime()/xi)},Ri=e=>{const t=new Date(e*xi),r=new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate());return r.setFullYear(t.getUTCFullYear()),r.setHours(0,0,0,0),r},Vr=e=>`${An(e.getFullYear())}-${String(e.getMonth()+1).padStart(za,"0")}-${String(e.getDate()).padStart(za,"0")}`,is=(e,t,r,n)=>{const o=vn(e),a=vn(t),l=a>=o?a-o+1:0,c=d=>Ri(a-d);return{count:l,dateAt:c,labelAt:d=>He("day",c(d),n,r),indexOf:d=>{const g=vn(d);return g<o||g>a?Pe:a-g}}},ls=(e,t,r,n,o)=>{const a=r>=t?r-t+1:0,l=c=>e[r-c];return{count:a,dateAt:l,labelAt:c=>He("day",l(c),o,n),indexOf:c=>{const d=c.getTime();let g=t,D=r;for(;g<=D;){const k=g+D>>1,b=e[k].getTime();if(b===d)return r-k;b<d?g=k+1:D=k-1}return Pe}}},ss={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${String(e)})`)},indexOf:()=>Pe},cs=(e,t,r)=>{const n=c=>{let d=0,g=e.length;for(;d<g;){const D=d+g>>1;e[D].getTime()<c?d=D+1:g=D}return d},o=c=>{let d=0,g=e.length;for(;d<g;){const D=d+g>>1;e[D].getTime()<=c?d=D+1:g=D}return d},a=t===null?0:n(t.getTime()),l=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:l}},Ba=(e,t,r,n,o)=>{let a=t,l=r,c=null;for(;a<=l;){const d=a+l>>1,g=e[d].getTime();o===-1?g<n?(c=e[d],a=d+1):l=d-1:g>n?(c=e[d],l=d-1):a=d+1}return c},us=(e,t)=>{const r=new Map;return e.forEach((n,o)=>{t(o,n);const a=new Date(n);a.setHours(0,0,0,0);const l=a.getTime();r.has(l)||r.set(l,a)}),Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},ds={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},ms={month:2,day:2},Ua={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Wa=new Map,fs=(e,t)=>{const r=`${e}\0${t}`,n=Wa.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,ds[e]);return Wa.set(r,o),o},gs=(e,t,r)=>r!==void 0?fs(e,r).format(t):e==="year"?An(Ua.year(t)):String(Ua[e](t)).padStart(ms[e],"0"),Si=(e,t,r,n)=>{if(t!=="year"&&t!=="month"&&t!=="day")throw new RangeError(`formatOptionText: unit must be "year", "month" or "day" (received: ${String(t)})`);if(r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${String(r)})`);return Xe(e)?r==="part"?gs(t,e,n):He(t,e,void 0,n):""},Dn=44,Ga=7,fn=8,hs=2,Li=10,bs=1e3,Lo=8,vo=6,Do=4,po=12,Nr=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),vn(r)},ws=(e,t)=>{if(e.length<Do||t.count===0)return Pe;const r=Number(e.slice(0,Do));if(!Number.isInteger(r))return Pe;const n=e.length>=vo,o=n?Number(e.slice(Do,vo)):po;if(o<1||o>po)return Pe;const a=e.length>=Lo,l=a?Number(e.slice(vo,Lo)):0,c=Nr(r,o),d=(o===po?Nr(r+1,1):Nr(r,o+1))-1,g=a?c+l-1:n?c:Nr(r,1),D=a?g:n?d:Nr(r+1,1)-1;if(a&&(l<1||g>d))return Pe;for(let k=D;k>=g;k--){const b=t.indexOf(Ri(k));if(b!==Pe)return b}return Pe},vs=e=>e.closest(".dark")===null?"light":"dark",Ds=(e,t,r,n)=>{const o=r-e.bottom-fn,a=e.top-fn,l=o>=t||o>=a,d=Math.max(Dn,Math.min(t,l?o:a)),g=l?e.bottom:e.top-d,D=e.width+Li,k=Math.max(fn,Math.min(e.left,n-D-fn));return{top:g,left:k,width:D,height:d}},yi=({domain:e,selectedIndex:t,displayLabel:r,machineValue:n,disabled:o,ariaLabel:a,locale:l,labels:c,onCommitIndex:d,controlClassName:g})=>{const D=i.useId(),k=i.useMemo(()=>Ll(c),[c]),b=`period-slider-date-listbox-${D}`,h=I=>`period-slider-date-option-${D}-${I}`,[S,R]=i.useState(!1),[C,u]=i.useState(Pe),[q,L]=i.useState(!0),[K,J]=i.useState(null),[j,ae]=i.useState(null),N=i.useRef(null),ne=i.useRef(null),z=i.useRef(null),T=i.useRef({buffer:"",at:0}),p=i.useRef(e);p.current=e;const E=e.count,O=Math.min(E,Ga)*Dn,oe=Math.max(1,Math.min(E,Ga)),F=i.useCallback(()=>{const I=N.current;if(I===null)return;const ie=I.getBoundingClientRect();J(Ds(ie,O,window.innerHeight,window.innerWidth))},[O]),U=i.useCallback(()=>{R(!1),u(Pe),T.current={buffer:"",at:0}},[]),Re=i.useCallback(I=>{o||E===0||(u(I),R(!0))},[o,E]);i.useLayoutEffect(()=>{if(!S){J(null),ae(null);return}const I=N.current;return I!==null&&ae(vs(I)),F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[S,F]),i.useEffect(()=>{if(!S)return;const I=ie=>{const le=ie.target;le!==null&&ne.current?.contains(le)!==!0&&N.current?.contains(le)!==!0&&U()};return document.addEventListener("pointerdown",I,!0),()=>document.removeEventListener("pointerdown",I,!0)},[S,U]);const ee=i.useRef(C);ee.current=C,i.useEffect(()=>{S&&(o||E===0)&&U()},[S,o,E,U]),i.useEffect(()=>{if(!S)return;const I=ee.current;if(I===Pe)return;const ie=Math.min(I,E-1);ie!==I&&u(ie),z.current?.scrollToIndex(ie,{align:"center"})},[E,S]);const ce=I=>{if(E===0)return;const ie=Math.max(0,Math.min(I,E-1));u(ie),z.current?.scrollToIndex(ie,{align:"center"})},W=I=>{I<0||I>=E||(d(I),U(),N.current?.focus())},G=I=>{if(o)return;const ie=C!==Pe?C:t!==Pe?t:0;switch(I.key){case"ArrowDown":if(I.preventDefault(),!S){Re(ie);return}ce(ie+1);return;case"ArrowUp":if(I.preventDefault(),!S){Re(ie);return}ce(ie-1);return;case"Home":if(!S)return;I.preventDefault(),ce(0);return;case"End":if(!S)return;I.preventDefault(),ce(E-1);return;case"PageDown":if(!S)return;I.preventDefault(),ce(ie+oe);return;case"PageUp":if(!S)return;I.preventDefault(),ce(ie-oe);return;case"Enter":if(I.preventDefault(),!S){Re(ie);return}W(C!==Pe?C:ie);return;case"Escape":if(!S)return;I.preventDefault(),U();return;case"Tab":S&&U();return}if(I.key.length!==1)return;const le=I.key>="0"&&I.key<="9",Se=I.key==="-"||I.key==="/"||I.key===".";if(!(le||Se))return;I.preventDefault();const Ce=Date.now(),Le=Ce-T.current.at>bs?"":T.current.buffer,ke=le?`${Le}${I.key}`.slice(0,Lo):Le;T.current={buffer:ke,at:Ce};const Be=ws(ke,p.current);if(Be!==Pe){if(!S){Re(Be);return}ce(Be)}},ue=i.useCallback(I=>I,[]),pe=i.useCallback(()=>Dn,[]),Me=i.useCallback(I=>{const ie=ee.current;L(ie===Pe||ie>=I.renderingStartIndex&&ie<=I.renderingEndIndex)},[]),$e=S&&K!==null&&j!==null&&E>0?x.jsx("div",{ref:ne,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":j,style:{top:K.top,left:K.left,width:K.width,height:K.height},onMouseDown:I=>{I.preventDefault()},children:x.jsx(Ot.VirtualScroll,{ref:z,itemCount:E,getItem:ue,getItemHeight:pe,viewportSize:K.height-hs,initialScrollIndex:C!==Pe?C:void 0,onRangeChange:Me,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:l,labels:k,contentProps:{id:b,role:"listbox","aria-label":a},scrollBarOptions:{width:Li,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:I=>{const ie=I===t,le=I===C;return x.jsx("div",{id:h(I),role:"option","aria-selected":ie,"aria-posinset":I+1,"aria-setsize":E,"data-testid":"period-slider-date-option","data-active":le?"true":void 0,className:"period-slider-date-option",style:{height:Dn},onClick:()=>W(I),children:p.current.labelAt(I)})}})}):null;return x.jsxs(x.Fragment,{children:[x.jsx("input",{ref:N,type:"text",role:"combobox",readOnly:!0,"aria-label":a,"aria-expanded":S,"aria-controls":S?b:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":S&&C!==Pe&&q?h(C):void 0,disabled:o,value:r,className:g,"data-testid":"period-slider-date-combobox","data-value":n,onKeyDown:G,onMouseDown:I=>{o||(I.preventDefault(),N.current?.focus(),S?U():Re(t!==Pe?t:0))},onBlur:()=>{S&&U()}}),$e===null?null:vl.createPortal($e,document.body)]})};yi.displayName="VirtualDateDropdown";const Ut=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Yr=(e,t)=>{if(!(t instanceof Date)||Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},ps=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 ${JSON.stringify(e)})`)}},Mt=(e,t,r)=>{const n=new Date(e,t-1,r);return n.setFullYear(e),n.setHours(0,0,0,0),n},Mo=e=>Mt(e,1,1),Ms=e=>Mt(e,12,31),xs=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:l,minDate:c,maxDate:d,allowedDates:g,variant:D="date",className:k="",style:b,disabled:h=!1,locale:S,labels:R,formatLocale:C,formatOption:u}=e;if(ps(C),t!==void 0&&Yr("value",t),r!==void 0&&Yr("initialDate",r),c!==void 0&&Yr("minDate",c),d!==void 0&&Yr("maxDate",d),a!==void 0&&!Number.isInteger(a))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(a)})`);if(l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(l)})`);if(D==="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 q=t??r;if(q===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const L=In(S,R),[K,J]=i.useState(()=>Ut(q)),j=t!==void 0,ae=t?.getTime(),N=i.useMemo(()=>t!==void 0?Ut(t):K,[ae,K]),ne=c?.getTime(),z=d?.getTime(),T=i.useMemo(()=>{const M=c?Ut(c):null,V=a!==void 0?Mo(a):null;return M===null?V:V===null||M.getTime()>=V.getTime()?M:V},[ne,a]),p=i.useMemo(()=>{const M=d?Ut(d):null,V=l!==void 0?Ms(l):null;return M===null?V:V===null||M.getTime()<=V.getTime()?M:V},[z,l]),E=T?.getTime()??null,O=p?.getTime()??null;if(T!==null&&p!==null&&T.getTime()>p.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${Vr(T)} is after max ${Vr(p)})`);if(D!=="date"&&g===void 0&&(T===null||p===null))throw new RangeError(`DateSelector: variant="${D}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${D==="dropdown"?' or supply "allowedDates"':""}`);const oe=i.useMemo(()=>g===void 0?null:g.map(M=>M.getTime()).join(","),[g]),F=i.useMemo(()=>g===void 0?null:us(g,(M,V)=>Yr(`allowedDates[${M}]`,V)),[oe]),U=i.useMemo(()=>F===null?null:{ascending:F,...cs(F,T,p)},[F,E,O]),Re=i.useMemo(()=>U!==null?ls(U.ascending,U.loIndex,U.hiIndex,C,u):T===null||p===null?ss:is(T,p,C,u),[U,E,O,C,u]),ee=M=>{if(U!==null)return Re.indexOf(M)!==Pe;const V=M.getTime();return!(E!==null&&V<E||O!==null&&V>O)},ce=q.getTime();i.useEffect(()=>{j||J(Ut(q))},[j,ce]);const W=M=>{if(h)return;const V=Ut(M);ee(V)&&(j||J(V),n?.(V))},G=N.getTime(),ue=ee(N),pe=i.useMemo(()=>{if(U!==null)return Ba(U.ascending,U.loIndex,U.hiIndex,G,-1);const M=lt.addDays(new Date(G),-1);return ee(M)?M:null},[U,G,E,O]),Me=i.useMemo(()=>{if(U!==null)return Ba(U.ascending,U.loIndex,U.hiIndex,G,1);const M=lt.addDays(new Date(G),1);return ee(M)?M:null},[U,G,E,O]),$e=()=>{pe!==null&&W(pe)},I=()=>{Me!==null&&W(Me)},ie=M=>{if(M.target.value){const V=lt.parseISO(M.target.value);Number.isNaN(V.getTime())||W(V)}},le=N.getFullYear(),Se=N.getMonth()+1,Ce=N.getDate(),Le=i.useCallback((M,V)=>u?u(V,M,"part"):Si(V,M,"part",C),[u,C]),ke=i.useMemo(()=>{if(D!=="split-dropdown"||T===null||p===null)return[];const M=[];for(let V=p.getFullYear();V>=T.getFullYear();V--)M.push({value:V,label:Le("year",Mo(V))});return M},[D,E,O,Le]),Be=i.useMemo(()=>{if(D!=="split-dropdown"||T===null||p===null)return[];const M=T,V=p,Je=le===M.getFullYear()?M.getMonth()+1:1,de=le===V.getFullYear()?V.getMonth()+1:12,nt=[];for(let $=Je;$<=de;$++)nt.push({value:$,label:Le("month",Mt(le,$,1))});return nt},[D,E,O,le,Le]),Z=i.useMemo(()=>{if(D!=="split-dropdown"||T===null||p===null)return[];const M=T,V=p,Je=le===M.getFullYear()&&Se===M.getMonth()+1?M.getDate():1,de=le===V.getFullYear()&&Se===V.getMonth()+1?V.getDate():lt.getDaysInMonth(new Date(G)),nt=[];for(let $=Je;$<=de;$++)nt.push({value:$,label:Le("day",Mt(le,Se,$))});return nt},[D,E,O,G,le,Se,Le]),te=(M,V,Je)=>Je>lt.getDaysInMonth(Mt(M,V,1))?!1:ee(Mt(M,V,Je)),ge=(M,V,Je)=>{te(M,V,Je)&&W(Mt(M,V,Je))},v=ke.some(M=>M.value===le),P=Be.some(M=>M.value===Se),X=Z.some(M=>M.value===Ce),De=Vr(N),he=D==="dropdown"?He("day",N,u,C):"",xe=T?Vr(T):void 0,Ye=p?Vr(p):void 0,Qe="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 x.jsxs("div",{className:`inline-flex items-center ${zr} ${k}`,style:b,"data-variant":D,"data-out-of-range":ue?void 0:"true",children:[x.jsx(Kt,{neighbour:"control",direction:"left",disabled:h,canStep:pe!==null,onStep:$e,ariaLabel:L.previousDay}),D==="dropdown"?x.jsx(yi,{domain:Re,selectedIndex:ue?Re.indexOf(N):Pe,displayLabel:he,machineValue:De,disabled:h,ariaLabel:L.dateSelect,locale:S,labels:L,onCommitIndex:M=>W(Re.dateAt(M)),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"}):D==="split-dropdown"?x.jsxs("div",{className:"inline-flex items-center gap-1",children:[x.jsxs("select",{"aria-label":L.splitYear,disabled:h,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:v?le:"",onChange:M=>ge(Number(M.target.value),Se,Ce),children:[v?null:x.jsx("option",{value:"",disabled:!0,className:Qe,children:Le("year",Mo(le))}),ke.map(M=>x.jsx("option",{value:M.value,disabled:!te(M.value,Se,Ce),className:"dark:bg-slate-700 dark:text-slate-100",children:M.label},M.value))]}),x.jsxs("select",{"aria-label":L.splitMonth,disabled:h,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:P?Se:"",onChange:M=>ge(le,Number(M.target.value),Ce),children:[P?null:x.jsx("option",{value:"",disabled:!0,className:Qe,children:Le("month",Mt(le,Se,1))}),Be.map(M=>x.jsx("option",{value:M.value,disabled:!te(le,M.value,Ce),className:"dark:bg-slate-700 dark:text-slate-100",children:M.label},M.value))]}),x.jsxs("select",{"aria-label":L.splitDay,disabled:h,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:X?Ce:"",onChange:M=>ge(le,Se,Number(M.target.value)),children:[X?null:x.jsx("option",{value:"",disabled:!0,className:Qe,children:Le("day",Mt(le,Se,Ce))}),Z.map(M=>x.jsx("option",{value:M.value,disabled:!te(le,Se,M.value),className:"dark:bg-slate-700 dark:text-slate-100",children:M.label},M.value))]})]}):x.jsx("input",{"aria-label":L.dateSelect,disabled:h,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:De,min:xe,max:Ye,onChange:ie,type:"date"}),x.jsx(Kt,{neighbour:"control",direction:"right",disabled:h,canStep:Me!==null,onStep:I,ariaLabel:L.nextDay}),o]})},hr=e=>e===void 0?null:Ut(e).getTime(),Ti=i.memo(xs,(e,t)=>!(hr(e.value??e.initialDate)!==hr(t.value??t.initialDate)||hr(e.minDate)!==hr(t.minDate)||hr(e.maxDate)!==hr(t.maxDate)||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.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!Cn(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption));Ti.displayName="DateSelector";function rt(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(r,n,1);return o.setFullYear(r),o}function Wt(e){return`${An(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}function _r(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Ka(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function Rs(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 ${JSON.stringify(e)}.`)}}function Ss(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 Ls(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 ys(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 Ts(e,t){const r=e.getFullYear()*12+e.getMonth(),n=t.getFullYear()*12+t.getMonth(),o=[];for(let a=r;a<=n;a++)o.push(rt(Math.floor(a/12),(a%12+12)%12));return o}function Xa(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:He("month",e[o],r,t),value:Wt(e[o])});return n}const Ps=e=>{const{value:t,initialDate:r,onChange:n,children:o,variant:a="date",minYear:l,maxYear:c,minDate:d,maxDate:g,allowedMonths:D,isWarning:k=!1,className:b="",style:h,disabled:S=!1,locale:R,labels:C,formatLocale:u,formatOption:q}=e;Rs(u),_r(t,"value"),_r(r,"initialDate"),_r(d,"minDate"),_r(g,"maxDate"),Ka(l,"minYear"),Ka(c,"maxYear"),D?.forEach((v,P)=>{_r(v,`allowedMonths[${P}]`)});const L=t??r;if(L===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const K=In(R,C),[J,j]=i.useState(()=>rt(L.getFullYear(),L.getMonth())),ae=t!==void 0,N=i.useMemo(()=>t!==void 0?rt(t.getFullYear(),t.getMonth()):J,[t?.getTime(),J]),ne=d?.getTime(),z=g?.getTime(),T=i.useMemo(()=>Ss(l,d),[l,ne]),p=i.useMemo(()=>Ls(c,g),[c,z]),E=T?.getTime()??null,O=p?.getTime()??null;if(T!==null&&p!==null&&T>p)throw new RangeError(`MonthSelector: the resolved lower bound ${Wt(T)} is after the resolved upper bound ${Wt(p)}.`);if(a==="dropdown"&&D===void 0&&(T===null||p===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 oe=D===void 0?null:D.map(v=>v.getTime()).join(","),F=i.useMemo(()=>D===void 0?null:ys(D,T,p),[oe,E,O]),U=v=>{const P=v.getTime();return F!==null?F.some(X=>X.getTime()===P):!(E!==null&&P<E||O!==null&&P>O)},Re=L.getTime();i.useEffect(()=>{if(ae)return;const v=rt(L.getFullYear(),L.getMonth());j(P=>P.getTime()===v.getTime()?P:v)},[ae,Re]);const ee=v=>{if(S)return;if(!U(v))throw new RangeError(`MonthSelector: refusing to emit ${Wt(v)}, which lies outside the selectable months.`);ae||j(v);const P=v.getFullYear()*100+(v.getMonth()+1);n?.(v,P)},ce=N.getTime(),W=U(N),G=i.useMemo(()=>{if(F!==null){for(let P=F.length-1;P>=0;P--)if(F[P].getTime()<ce)return F[P];return null}const v=rt(N.getFullYear(),N.getMonth()-1);return U(v)?v:null},[F,ce,E,O]),ue=i.useMemo(()=>{if(F!==null){for(const P of F)if(P.getTime()>ce)return P;return null}const v=rt(N.getFullYear(),N.getMonth()+1);return U(v)?v:null},[F,ce,E,O]),pe=()=>{G!==null&&ee(G)},Me=()=>{ue!==null&&ee(ue)},$e=v=>{if(!v)return;const P=v.lastIndexOf("-");if(P<=0)return;const X=v.slice(0,P),De=v.slice(P+1),he=Number(X),xe=Number(De)-1;if(!(Number.isInteger(he)&&Number.isInteger(xe)))return;const Ye=rt(he,xe);U(Ye)&&ee(Ye)},I=v=>{$e(v.target.value)},ie=v=>{$e(v.target.value)},le=Wt(N),Se=a==="dropdown"&&!W?He("month",N,q,u):"",Ce=T?Wt(T):void 0,Le=p?Wt(p):void 0,ke=i.useMemo(()=>a!=="dropdown"?[]:F!==null?Xa(F,u,q):T===null||p===null?[]:Xa(Ts(T,p),u,q),[a,F,E,O,u,q]),Be=W?le:"",Z=k?"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 ${Z}`,ge=`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 ${Z}`;return x.jsxs("div",{className:`inline-flex items-center ${zr} ${b}`,style:h,"data-out-of-range":W?void 0:"true",children:[x.jsx(Kt,{neighbour:"control",direction:"left",disabled:S,canStep:G!==null,onStep:pe,ariaLabel:K.previousMonth}),a==="dropdown"?x.jsxs("select",{"aria-label":K.monthSelect,disabled:S,className:ge,value:Be,onChange:ie,children:[W?null:x.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:Se}),ke.map(v=>x.jsx("option",{value:v.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:v.label},v.value))]}):x.jsx("input",{"aria-label":K.monthSelect,disabled:S,className:te,value:le,min:Ce,max:Le,onChange:I,type:"month"}),x.jsx(Kt,{neighbour:"control",direction:"right",disabled:S,canStep:ue!==null,onStep:Me,ariaLabel:K.nextMonth}),o]})},Pi=i.memo(Ps,(e,t)=>{const r=e.value??e.initialDate,n=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,a=n?n.getFullYear()*12+n.getMonth():null;if(o!==a||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)return!1;const l=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,c=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(l!==c)return!1;const d=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,g=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(d!==g||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.children!==t.children||e.locale!==t.locale||!Cn(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)});Pi.displayName="MonthSelector";function wr(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function $n(e,t,r){if(wr(e,"minDate",t),wr(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function xn(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: ${String(r)})`);if(wr(e,`${t}[0]`,r[0]),wr(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Rn(e,t,r,n,o,a,l,c){const d=re(r,n,c);if(d<re(r,o,c)||d>re(r,a,c))throw new RangeError(`${e}: ${t} must lie within ${l} (value: ${n.toISOString()}, lower: ${o.toISOString()}, upper: ${a.toISOString()})`)}function Sn(e,t,r,n,o,a,l,c){Rn(e,`${t}[0]`,r,n[0],o,a,l,c),Rn(e,`${t}[1]`,r,n[1],o,a,l,c)}function Ke(e,t,r){return e<t?t:e>r?r:e}function Ln(e,t,r,n,o,a,l){if(r!==!0)return[];const c=e[0].getTime(),d=e[1].getTime();return Rt(n,t,o,a,l).filter(g=>g.getTime()>=c&&g.getTime()<=d)}function br(e,t,r,n,o){if(n.length===0)return Ke(e,r[0],r[1]);const a=n[be(n,e,t,o)];return a.getTime()===e.getTime()?e:a}function gn(e,t,r,n,o){const a=br(e[0],t,r,n,o),l=br(e[1],t,r,n,o);return[a,l<a?a:l]}function yn(e,t,r,n,o){const a=be(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function kn(e){const t=i.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(c=>Object.is(r[c],n[c]))||(t.current=e),t.current}function Es(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:l,formatOption:c,...d}=e,g=vr("usePeriodSliderRange",l);$n("usePeriodSliderRange",r,n),xn("usePeriodSliderRange","initialRange",o),Sn("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",g);const D=kn(d),k=i.useRef(o),[b,h]=i.useState(o);let S=b;const R=[Ke(b[0],r,n),Ke(b[1],r,n)];(R[0]!==b[0]||R[1]!==b[1])&&(S=R,h(R));const C=i.useRef(S);C.current=S;const u=i.useRef({minDate:r,maxDate:n,allowedDates:D.allowedDates});u.current={minDate:r,maxDate:n,allowedDates:D.allowedDates};const q=i.useRef(a);q.current=a;const L=i.useCallback(p=>{const{minDate:E,maxDate:O}=u.current,oe=Ke(p[0],E,O),F=Ke(p[1],E,O),U=C.current;oe.getTime()===U[0].getTime()&&F.getTime()===U[1].getTime()||(C.current=[oe,F],h([oe,F]),q.current?.(oe,F))},[]),K=i.useCallback(p=>{const E=C.current,O=p.getTime()>E[1].getTime()?p:E[1];L([p,O])},[L]),J=i.useCallback(p=>{const E=C.current,O=p.getTime()<E[0].getTime()?p:E[0];L([O,p])},[L]),j=i.useCallback((p,E)=>{L([p,E])},[L]),ae=i.useCallback(p=>{const{minDate:E,maxDate:O,allowedDates:oe}=u.current,F=C.current,U=Rt(oe,t,E,O,g);if(U.length>0){L([yn(U,t,F[0],p,g),yn(U,t,F[1],p,g)]);return}L([je(t,F[0],p),je(t,F[1],p)])},[t,L,g]),N=i.useCallback(()=>{L(k.current)},[L]),ne=i.useMemo(()=>({value:S[0],onChange:K,minDate:r,maxDate:S[1],unit:t,yearStartMonth:g,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:c}),[S[0],S[1],K,r,t,g,e.formatLocale,e.locale,e.labels,c]),z=i.useMemo(()=>({value:S[1],onChange:J,minDate:S[0],maxDate:n,unit:t,yearStartMonth:g,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:c}),[S[0],S[1],J,n,t,g,e.formatLocale,e.locale,e.labels,c]),T=i.useMemo(()=>({...D,mode:"range",unit:t,yearStartMonth:g,range:S,minDate:r,maxDate:n,onChangeRange:j}),[D,t,S,r,n,j,g]);return{range:S,lowerDate:S[0],upperDate:S[1],setRange:h,setLowerDate:K,setUpperDate:J,shiftRange:ae,resetRange:N,startSelectorProps:ne,endSelectorProps:z,sliderProps:T}}function Cs(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:l,formatOption:c,...d}=e,g=vr("usePeriodSliderPoint",l);$n("usePeriodSliderPoint",r,n),wr("usePeriodSliderPoint","initialValue",o),Rn("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",g);const D=kn(d),k=i.useRef(o),[b,h]=i.useState(o);let S=b;const R=Ke(b,r,n);R!==b&&(S=R,h(R));const C=i.useRef(S);C.current=S;const u=i.useRef({minDate:r,maxDate:n,allowedDates:D.allowedDates});u.current={minDate:r,maxDate:n,allowedDates:D.allowedDates};const q=i.useRef(a);q.current=a;const L=i.useCallback(N=>{const{minDate:ne,maxDate:z}=u.current,T=Ke(N,ne,z);T.getTime()!==C.current.getTime()&&(C.current=T,h(T),q.current?.(T))},[]),K=i.useCallback(N=>{const{minDate:ne,maxDate:z,allowedDates:T}=u.current,p=Rt(T,t,ne,z,g);if(p.length>0){L(yn(p,t,C.current,N,g));return}L(je(t,C.current,N))},[t,L,g]),J=i.useCallback(()=>{L(k.current)},[L]),j=i.useMemo(()=>({value:S,onChange:L,minDate:r,maxDate:n,unit:t,yearStartMonth:g,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:c}),[S,L,r,n,t,g,e.formatLocale,e.locale,e.labels,c]),ae=i.useMemo(()=>({...D,mode:"point",unit:t,yearStartMonth:g,value:S,minDate:r,maxDate:n,onChangePoint:L}),[D,t,S,r,n,L,g]);return{value:S,setValue:h,shiftValue:K,resetValue:J,selectorProps:j,sliderProps:ae}}function Is(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:d,onChangeMicroRange:g,yearStartMonth:D,formatOption:k,...b}=e,h=vr("useVernierSliderRange",D);$n("useVernierSliderRange",r,n),xn("useVernierSliderRange","initialMacroRange",o),xn("useVernierSliderRange","initialMicroRange",a),Sn("useVernierSliderRange","initialMacroRange",l,o,r,n,"[minDate, maxDate]",h);const S=ht(l,c,o,r,n,h);Sn("useVernierSliderRange","initialMicroRange",c,a,S[0],S[1],"the initial macro window",h);const R=kn(b),C=i.useRef(o),u=i.useRef(a),[q,L]=i.useState(o),[K,J]=i.useState(a);let j=q;const ae=[Ke(q[0],r,n),Ke(q[1],r,n)];(ae[0]!==q[0]||ae[1]!==q[1])&&(j=ae,L(ae));const N=i.useMemo(()=>ht(l,c,j,r,n,h),[l,c,j,r,n,h]),ne=i.useMemo(()=>Ln(N,c,R.microIsDiscrete,R.microAllowedDates??R.allowedDates,r,n,h),[N,c,R.microIsDiscrete,R.microAllowedDates,R.allowedDates,r,n,h]),z=i.useMemo(()=>R.macroIsDiscrete===!0?Rt(R.macroAllowedDates??R.allowedDates,l,r,n,h):[],[R.macroIsDiscrete,R.macroAllowedDates,R.allowedDates,l,r,n,h]),T=i.useRef(z);T.current=z;let p=K;const E=gn(K,c,N,ne,h);(E[0]!==K[0]||E[1]!==K[1])&&(p=E,J(E));const O=i.useRef(j);O.current=j;const oe=i.useRef(p);oe.current=p;const F=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates});F.current={minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates};const U=i.useRef(d);U.current=d;const Re=i.useRef(g);Re.current=g;const ee=i.useCallback(v=>{const{minDate:P,maxDate:X}=F.current;return ht(l,c,v,P,X,h)},[l,c,h]),ce=i.useCallback(v=>{const{microIsDiscrete:P,microAllowedDates:X,allowedDates:De,minDate:he,maxDate:xe}=F.current;return Ln(v,c,P,X??De,he,xe,h)},[c,h]),W=i.useCallback((v,P)=>{const X=O.current,De=oe.current;(v[0].getTime()!==X[0].getTime()||v[1].getTime()!==X[1].getTime())&&(O.current=v,L(v),U.current?.(v[0],v[1])),(P[0].getTime()!==De[0].getTime()||P[1].getTime()!==De[1].getTime())&&(oe.current=P,J(P),Re.current?.(P[0],P[1]))},[]),G=i.useCallback((v,P)=>{const{minDate:X,maxDate:De}=F.current,he=[Ke(v,X,De),Ke(P,X,De)],xe=ee(he);W(he,gn(oe.current,c,xe,ce(xe),h))},[c,ee,ce,W,h]),ue=i.useCallback((v,P)=>{const X=ee(O.current);W(O.current,gn([v,P],c,X,ce(X),h))},[c,ee,ce,W,h]),pe=i.useCallback(v=>{const P=O.current[1],X=v>P?v:P;G(v,X)},[G]),Me=i.useCallback(v=>{const P=O.current[0],X=v<P?v:P;G(X,v)},[G]),$e=i.useCallback(v=>{const P=oe.current[1],X=v>P?v:P;ue(v,X)},[ue]),I=i.useCallback(v=>{const P=oe.current[0],X=v<P?v:P;ue(X,v)},[ue]),ie=i.useCallback(v=>{const{minDate:P,maxDate:X}=F.current,De=O.current,he=T.current;if(he.length>0){const Qe=be(he,De[0],l,h)+v,bt=be(he,De[1],l,h)+v;if(Qe<0||bt>he.length-1)return;G(he[Qe],he[bt]);return}const xe=je(l,De[0],v),Ye=je(l,De[1],v);xe<P||Ye>X||G(xe,Ye)},[l,G,h]),le=i.useCallback(v=>{const P=O.current,X=oe.current,De=ee(P),[he,xe]=De,Ye=ce(De);if(Ye.length>0){const M=be(Ye,X[0],c,h)+v,V=be(Ye,X[1],c,h)+v;if(M<0||V>Ye.length-1)return;ue(Ye[M],Ye[V]);return}const Qe=je(c,X[0],v),bt=je(c,X[1],v);Qe<he||bt>xe||ue(Qe,bt)},[c,ee,ce,ue,h]),Se=i.useCallback(()=>{const v=C.current,P=ee(v);W(v,gn(u.current,c,P,ce(P),h))},[c,ee,ce,W,h]),[Ce,Le]=N,ke=i.useMemo(()=>({value:j[0],onChange:pe,minDate:r,maxDate:j[1],unit:l,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[j,pe,r,l,h,e.formatLocale,e.locale,e.labels,k]),Be=i.useMemo(()=>({value:j[1],onChange:Me,minDate:j[0],maxDate:n,unit:l,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[j,Me,n,l,h,e.formatLocale,e.locale,e.labels,k]),Z=i.useMemo(()=>({value:p[0],onChange:$e,minDate:Ce,maxDate:p[1],unit:c,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[p,$e,Ce,c,h,e.formatLocale,e.locale,e.labels,k]),te=i.useMemo(()=>({value:p[1],onChange:I,minDate:p[0],maxDate:Le,unit:c,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[p,I,Le,c,h,e.formatLocale,e.locale,e.labels,k]),ge=i.useMemo(()=>({...R,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:j,microRange:p,onChangeMacroRange:G,onChangeMicroRange:ue}),[R,t,l,c,r,n,j,p,G,ue,h]);return{macroRange:j,setMacroRange:L,microRange:p,setMicroRange:J,setMacroLowerDate:pe,setMacroUpperDate:Me,setMicroLowerDate:$e,setMicroUpperDate:I,shiftMacroRange:ie,shiftMicroRange:le,resetVernier:Se,macroStartSelectorProps:ke,macroEndSelectorProps:Be,microStartSelectorProps:Z,microEndSelectorProps:te,sliderProps:ge}}function As(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:l=t,microUnit:c=t,onChangeMacroRange:d,onChangeMicroPoint:g,yearStartMonth:D,formatOption:k,...b}=e,h=vr("useVernierSliderPoint",D);$n("useVernierSliderPoint",r,n),xn("useVernierSliderPoint","initialMacroRange",o),wr("useVernierSliderPoint","initialMicroValue",a),Sn("useVernierSliderPoint","initialMacroRange",l,o,r,n,"[minDate, maxDate]",h);const S=ht(l,c,o,r,n,h);Rn("useVernierSliderPoint","initialMicroValue",c,a,S[0],S[1],"the initial macro window",h);const R=kn(b),C=i.useRef(o),u=i.useRef(a),[q,L]=i.useState(o),[K,J]=i.useState(a);let j=q;const ae=[Ke(q[0],r,n),Ke(q[1],r,n)];(ae[0]!==q[0]||ae[1]!==q[1])&&(j=ae,L(ae));const N=i.useMemo(()=>ht(l,c,j,r,n,h),[l,c,j,r,n,h]),ne=i.useMemo(()=>Ln(N,c,R.microIsDiscrete,R.microAllowedDates??R.allowedDates,r,n,h),[N,c,R.microIsDiscrete,R.microAllowedDates,R.allowedDates,r,n,h]),z=i.useMemo(()=>R.macroIsDiscrete===!0?Rt(R.macroAllowedDates??R.allowedDates,l,r,n,h):[],[R.macroIsDiscrete,R.macroAllowedDates,R.allowedDates,l,r,n,h]),T=i.useRef(z);T.current=z;let p=K;const E=br(K,c,N,ne,h);E!==K&&(p=E,J(E));const O=i.useRef(j);O.current=j;const oe=i.useRef(p);oe.current=p;const F=i.useRef({minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates});F.current={minDate:r,maxDate:n,macroIsDiscrete:R.macroIsDiscrete,macroAllowedDates:R.macroAllowedDates,microIsDiscrete:R.microIsDiscrete,microAllowedDates:R.microAllowedDates,allowedDates:R.allowedDates};const U=i.useRef(d);U.current=d;const Re=i.useRef(g);Re.current=g;const ee=i.useCallback(Z=>{const{minDate:te,maxDate:ge}=F.current;return ht(l,c,Z,te,ge,h)},[l,c,h]),ce=i.useCallback(Z=>{const{microIsDiscrete:te,microAllowedDates:ge,allowedDates:v,minDate:P,maxDate:X}=F.current;return Ln(Z,c,te,ge??v,P,X,h)},[c,h]),W=i.useCallback((Z,te)=>{const ge=O.current,v=oe.current;(Z[0].getTime()!==ge[0].getTime()||Z[1].getTime()!==ge[1].getTime())&&(O.current=Z,L(Z),U.current?.(Z[0],Z[1])),te.getTime()!==v.getTime()&&(oe.current=te,J(te),Re.current?.(te))},[]),G=i.useCallback((Z,te)=>{const{minDate:ge,maxDate:v}=F.current,P=[Ke(Z,ge,v),Ke(te,ge,v)],X=ee(P);W(P,br(oe.current,c,X,ce(X),h))},[c,ee,ce,W,h]),ue=i.useCallback(Z=>{const te=ee(O.current);W(O.current,br(Z,c,te,ce(te),h))},[c,ee,ce,W,h]),pe=i.useCallback(Z=>{const te=O.current[1],ge=Z>te?Z:te;G(Z,ge)},[G]),Me=i.useCallback(Z=>{const te=O.current[0],ge=Z<te?Z:te;G(ge,Z)},[G]),$e=i.useCallback(Z=>{const{minDate:te,maxDate:ge}=F.current,v=O.current,P=T.current;if(P.length>0){const he=be(P,v[0],l,h)+Z,xe=be(P,v[1],l,h)+Z;if(he<0||xe>P.length-1)return;G(P[he],P[xe]);return}const X=je(l,v[0],Z),De=je(l,v[1],Z);X<te||De>ge||G(X,De)},[l,G,h]),I=i.useCallback(Z=>{const te=O.current,ge=ee(te),v=ce(ge);if(v.length>0){ue(yn(v,c,oe.current,Z,h));return}ue(je(c,oe.current,Z))},[c,ee,ce,ue,h]),ie=i.useCallback(()=>{const Z=C.current,te=ee(Z);W(Z,br(u.current,c,te,ce(te),h))},[c,ee,ce,W,h]),[le,Se]=N,Ce=i.useMemo(()=>({value:j[0],onChange:pe,minDate:r,maxDate:j[1],unit:l,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[j,pe,r,l,h,e.formatLocale,e.locale,e.labels,k]),Le=i.useMemo(()=>({value:j[1],onChange:Me,minDate:j[0],maxDate:n,unit:l,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[j,Me,n,l,h,e.formatLocale,e.locale,e.labels,k]),ke=i.useMemo(()=>({value:p,onChange:ue,minDate:le,maxDate:Se,unit:c,yearStartMonth:h,formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:k}),[p,ue,le,Se,c,h,e.formatLocale,e.locale,e.labels,k]),Be=i.useMemo(()=>({...R,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:l,microUnit:c,minDate:r,maxDate:n,macroRange:j,microValue:p,onChangeMacroRange:G,onChangeMicroPoint:ue}),[R,t,l,c,r,n,j,p,G,ue,h]);return{macroRange:j,setMacroRange:L,microValue:p,setMicroValue:J,setMacroLowerDate:pe,setMacroUpperDate:Me,setMicroDate:ue,shiftMacroRange:$e,shiftMicroValue:I,resetVernier:ie,macroStartSelectorProps:Ce,macroEndSelectorProps:Le,microSelectorProps:ke,sliderProps:Be}}function qa(e,t){const r=new Date(e,t,1);return r.setFullYear(e),r}function Gt(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function hn(e,t){return e===void 0?null:Gt(e,t)}function bn(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function Za(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function $s(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 ${JSON.stringify(e)}.`)}}function Qa(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Gt(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}const ks=e=>{const{value:t,initialDate:r,onChange:n,children:o,minYear:a,maxYear:l,minDate:c,maxDate:d,className:g="",style:D,disabled:k=!1,locale:b,labels:h,formatLocale:S,formatOption:R,yearStartMonth:C}=e,u=vr("YearSelector",C);bn(t,"value"),bn(r,"initialDate"),bn(c,"minDate"),bn(d,"maxDate"),Za(a,"minYear"),Za(l,"maxYear"),$s(S);const q=t??r;if(q===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const L=In(b,h),[K,J]=i.useState(()=>Gt(q,u)),j=c?.getTime(),ae=d?.getTime(),N=i.useMemo(()=>Qa(a,c,Math.max,u),[a,j,u]),ne=i.useMemo(()=>Qa(l,d,Math.min,u),[l,ae,u]);if(N===null||ne===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.");if(N>ne)throw new RangeError(`YearSelector: the resolved lower bound ${N} is after the resolved upper bound ${ne}.`);const z=t!==void 0,T=t!==void 0?Gt(t,u):K,p=T<N||T>ne,E=q.getTime();i.useEffect(()=>{z||J(Gt(q,u))},[z,E,u]);const O=W=>W>=N&&W<=ne,oe=W=>{if(!k){if(!O(W))throw new RangeError(`YearSelector: refusing to emit ${W}, which lies outside the declared bounds ${N}-${ne}.`);z||J(W),n?.(qa(W,u),W)}},F=O(T-1)?T-1:null,U=O(T+1)?T+1:null,Re=()=>{F!==null&&oe(F)},ee=()=>{U!==null&&oe(U)},ce=i.useMemo(()=>{const W=[];for(let G=ne;G>=N;G--)W.push(G);return p&&(W.push(T),W.sort((G,ue)=>ue-G)),W.map(G=>({value:G,label:He("year",qa(G,u),R,S)}))},[N,ne,p,T,u,S,R]);return x.jsxs("div",{className:`inline-flex items-center ${zr} ${g}`,style:D,"data-out-of-range":p?"true":void 0,children:[x.jsx(Kt,{neighbour:"control",direction:"left",disabled:k,canStep:F!==null,onStep:Re,ariaLabel:L.previousYear}),x.jsx("select",{"aria-label":L.yearSelect,disabled:k,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:T,onChange:W=>{if(!W.target.value)return;const G=Number(W.target.value);Number.isInteger(G)&&oe(G)},children:ce.map(W=>x.jsx("option",{value:W.value,disabled:p&&W.value===T,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:W.label},W.value))}),x.jsx(Kt,{neighbour:"control",direction:"right",disabled:k,canStep:U!==null,onStep:ee,ariaLabel:L.nextYear}),o]})},Ei=i.memo(ks,(e,t)=>{const r=e.yearStartMonth??0,n=t.yearStartMonth??0;if(r!==n)return!1;const o=e.value??e.initialDate,a=t.value??t.initialDate,l=o?Gt(o,r):null,c=a?Gt(a,n):null;return!(l!==c||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||hn(e.minDate,r)!==hn(t.minDate,n)||hn(e.maxDate,r)!==hn(t.maxDate,n)||e.onChange!==t.onChange||e.children!==t.children||e.locale!==t.locale||!Cn(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)});Ei.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=ai;exports.DateSelector=Ti;exports.MonthSelector=Pi;exports.PERIOD_SLIDER_LABEL_CATALOGS=ni;exports.PERIOD_SLIDER_LABEL_KEYS=En;exports.PeriodSlider=Mi;exports.YearSelector=Ei;exports.addUnit=je;exports.areStylesEqual=pi;exports.calculateConnectDragValues=ci;exports.calculateHandleDragValues=Ro;exports.calculateKeyboardActionValues=ui;exports.calculateLabelSlant=Eo;exports.calculateVernierMacroDrag=vi;exports.calculateVernierMicroDrag=Di;exports.decode=me;exports.encode=re;exports.findNearestDateIndex=be;exports.formatLabel=He;exports.formatOptionText=Si;exports.formatQuarterLabel=Gl;exports.formatScreenReaderLabel=Bt;exports.getMacroWindowEndDate=li;exports.getMacroWindowStartDate=ii;exports.getSortedAllowedDates=Rt;exports.normalizeDateByUnit=Ne;exports.resolveDraggedEdge=Pn;exports.resolveMacroWindow=ht;exports.resolvePeriodSliderLabels=oi;exports.resolveQuarter=si;exports.resolveVernierRailZone=Co;exports.resolveVernierTargetHandle=wi;exports.resolveWheelStep=bi;exports.usePeriodSliderPoint=Cs;exports.usePeriodSliderRange=Es;exports.useVernierSliderPoint=As;exports.useVernierSliderRange=Is;
|