@aiquants/period-slider 0.17.0 → 0.19.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 +216 -0
- package/README.md +58 -50
- package/dist/DateSelector.d.ts +9 -9
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts +5 -4
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +136 -35
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/VirtualDateDropdown.d.ts +24 -1
- package/dist/VirtualDateDropdown.d.ts.map +1 -1
- package/dist/YearSelector.d.ts +7 -4
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2631 -2610
- package/dist/inputValue.d.ts +20 -12
- package/dist/inputValue.d.ts.map +1 -1
- package/dist/optionText.d.ts +2 -2
- package/dist/optionText.d.ts.map +1 -1
- package/dist/selectorMemo.d.ts +30 -22
- package/dist/selectorMemo.d.ts.map +1 -1
- package/dist/selectorStep.d.ts +14 -22
- package/dist/selectorStep.d.ts.map +1 -1
- package/dist/useCommittedRef.d.ts +54 -27
- package/dist/useCommittedRef.d.ts.map +1 -1
- package/dist/usePeriodSlider.d.ts +32 -22
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/dist/useUncontrolledSelection.d.ts +32 -19
- package/dist/useUncontrolledSelection.d.ts.map +1 -1
- package/dist/vernierStep.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/DateSelector.tsx +67 -73
- package/src/MonthSelector.tsx +57 -64
- package/src/PeriodSlider.tsx +255 -96
- package/src/VirtualDateDropdown.tsx +171 -111
- package/src/YearSelector.tsx +43 -73
- package/src/inputValue.ts +20 -12
- package/src/optionText.ts +9 -9
- package/src/selectorMemo.ts +41 -25
- package/src/selectorStep.ts +25 -32
- package/src/useCommittedRef.ts +70 -32
- package/src/usePeriodSlider.ts +252 -109
- package/src/useUncontrolledSelection.ts +58 -30
- package/src/vernierStep.ts +7 -7
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("react/jsx-runtime"),ql=require("date-fns"),l=require("react"),lr=require("@aiquants/virtualscroll"),Xl=require("react-dom"),Ma="an object that cannot be converted to a string",Zl=3,$e=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},Pt=e=>{try{return Array.isArray(e)}catch{return!1}},wo=e=>e===void 0||Pt(e);function Ea(e,t,r){if(!wo(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${S(r)})`)}const S=e=>{if(typeof e=="string")return JSON.stringify(e);if($e(e))return Date.prototype.toISOString.call(e);if(Pt(e))return Ql(e);try{return String(e)}catch{return Ma}},Ql=e=>{let t;try{t=e.length}catch{return Ma}const r=Math.min(t,Zl),n=[];for(let a=0;a<r;a++)n.push(Jl(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},Jl=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return Pt(r)?`Array(${r.length})`:S(r)}catch{return Ma}},xt=(e,t)=>$e(e)?t(e):Number.NaN,dt=(e,t)=>e===void 0?null:xt(e,t),Vi=120,Zo="data-drag-snap",Qo="--ps-drag-snap-duration",gn={flat:["--ps-drag-low","--ps-drag-high"],macro:["--ps-drag-macro-low","--ps-drag-macro-high"],micro:["--ps-drag-micro-low","--ps-drag-micro-high"]},Ds=["low","high"],Rs=["tx","ty","rot"],bo={flat:{low:"--ps-drag-label-low",high:"--ps-drag-label-high"},macro:{low:"--ps-drag-macro-label-low",high:"--ps-drag-macro-label-high"},micro:{low:"--ps-drag-micro-label-low",high:"--ps-drag-micro-label-high"}},ya=(e,t)=>`${e}-${t}`,Jo=(e,t,r)=>`var(${ya(e,t)}, ${r})`,ec=(e,t,r)=>{const n=bo[t];for(const o of Ds)for(const a of Rs)e.style.setProperty(ya(n[o],a),r[o][a])},Ms=e=>Math.max(0,Math.min(1,e)),oo=(e,t,r,n)=>{const o=Ms(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},Pa=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},po=(e,t,r,n)=>{const o=Ms(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ea=(e,t,r,n)=>{if(r){const i=(1-e)*100,s=(1-t)*100;return n?`M 12 ${s} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${s} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},rr=(e,t)=>`var(${e}, ${t}%)`,tc=(e,t,r,n)=>{const[o,a]=gn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},rc=e=>{for(const[t,r]of Object.values(gn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(bo))for(const r of Ds)for(const n of Rs)e.style.removeProperty(ya(t[r],n))},Es=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],vo=[...lr.VIRTUAL_SCROLL_LABEL_KEYS,...Es],da=Object.freeze({en:Object.freeze({rangeStart:"Range start",rangeEnd:"Range end",selectedDate:"Selected date",macroRangeStart:"Macro range start",macroRangeEnd:"Macro range end",microRangeStart:"Micro range start",microRangeEnd:"Micro range end",microSelectedDate:"Micro selected date",decrease:"Decrease",increase:"Increase",previousYear:"Previous year",nextYear:"Next year",yearSelect:"Year",previousMonth:"Previous month",nextMonth:"Next month",monthSelect:"Month",previousDay:"Previous day",nextDay:"Next day",dateSelect:"Date",splitYear:"Year",splitMonth:"Month",splitDay:"Day"}),ja:Object.freeze({rangeStart:"期間の開始",rangeEnd:"期間の終了",selectedDate:"選択日",macroRangeStart:"広域期間の開始",macroRangeEnd:"広域期間の終了",microRangeStart:"詳細期間の開始",microRangeEnd:"詳細期間の終了",microSelectedDate:"詳細の選択日",decrease:"前へ",increase:"次へ",previousYear:"前年",nextYear:"翌年",yearSelect:"年",previousMonth:"前月",nextMonth:"翌月",monthSelect:"年月",previousDay:"前日",nextDay:"翌日",dateSelect:"日付",splitYear:"年",splitMonth:"月",splitDay:"日"})}),ys=Object.freeze({en:Object.freeze({...lr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...da.en}),ja:Object.freeze({...lr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...da.ja})}),_i=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,nc=e=>vo.includes(e),oc=(e,t)=>{const r={};let n=!1;for(const o of lr.VIRTUAL_SCROLL_LABEL_KEYS){const a=t.has(o)?e[o]:void 0;a!==void 0&&(r[o]=a,n=!0)}return n?r:void 0},ac=e=>{try{return lr.resolveVirtualScrollLocale(e)}catch(t){throw t instanceof RangeError?new RangeError(`[period-slider] locale is the UI language, not a BCP 47 tag (date formatting reads formatLocale): ${t.message}`,{cause:t}):t}},Ps=(e,t)=>{const r=ac(e);if(t===void 0)return ys[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${_i(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const s of o)if(!nc(s))throw new RangeError(`[period-slider] labels.${s} is not a known label key; expected one of ${vo.join(", ")}`);const i={...lr.resolveVirtualScrollLabels(r,oc(t,o)),...da[r]};for(const s of Es){const d=o.has(s)?t[s]:void 0;if(d!==void 0){if(typeof d!="string"||d.trim()==="")throw new RangeError(`[period-slider] labels.${s} must be a non-blank string; got ${_i(d)}`);i[s]=d}}return Object.freeze(i)},ic=e=>{const t={};for(const r of lr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},sc=(e,t)=>e===t||vo.every(r=>e[r]===t[r]),xo=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0||e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const r=new Set(Object.keys(e)),n=Object.keys(t);if(r.size!==n.length)return!1;const o=e,a=t;return n.every(i=>r.has(i)&&Object.is(o[i],a[i]))},ta=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Yi=new Set(["hidden","clip","scroll","auto","overlay"]),Hi=["paint","strict","content"],lc=["layout","paint","strict","content"],cc=["transform","perspective","filter"],sn=e=>e!==void 0&&e!==""&&e!=="none",uc=e=>e!==void 0&&e!==""&&e!=="normal",Un=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},dc=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,mc=(e,t)=>t==="absolute"&&sn(e.position)&&e.position!=="static"||sn(e.transform)||sn(e.perspective)||sn(e.filter)||sn(e.backdropFilter)||uc(e.containerType)||lc.some(r=>e.contain.includes(r))?!0:cc.some(r=>e.willChange.includes(r)),fc=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const s=e.getBoundingClientRect();if(s.width===0||s.height===0)return!1;const d=n?0:r,g=n?r:0;if(o<s.left-d||o>=s.right+d||a<s.top-g||a>=s.bottom+g)return!1;const m=i.getComputedStyle(t);if(m.visibility!=="visible")return!1;let v=null;for(let b=t;b!==null;b=b.parentElement){const M=b===t?m:i.getComputedStyle(b);if(v!==null&&!mc(M,v))continue;const U=Yi.has(M.overflowX)||Hi.some(D=>M.contain.includes(D)),u=Yi.has(M.overflowY)||Hi.some(D=>M.contain.includes(D));if(U||u){const D=b.getBoundingClientRect();if(U&&(o<D.left+Un(M.borderLeftWidth)||o>=D.right-Un(M.borderRightWidth))||u&&(a<D.top+Un(M.borderTopWidth)||a>=D.bottom-Un(M.borderBottomWidth)))return!1}v=dc(M)}return!0},ra=new Map,gc=(e,t)=>{if(!(t.shiftKey&&t.cancelable))return;for(const o of e)if(o.ownsHit(t.target)){o.step(t);return}let r=null,n=Number.POSITIVE_INFINITY;for(const o of e){const a=o.distanceToRailPx(t.clientX,t.clientY);a===null||a>=n||(r=o,n=a)}r?.step(t)},hc=(e,t)=>{let r=ra.get(e);if(r===void 0){const a=new Set,i=s=>gc(a,s);r={participants:a,listener:i},ra.set(e,r),e.addEventListener("wheel",i,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(ra.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},hn="gap-[11px]",Nt=6,Ot=Nt*2,nr=Nt*4/3,wc={left:`0,${Ot/2} ${Nt},0 ${Nt},${Ot}`,right:`${nr},${Ot/2} ${nr-Nt},0 ${nr-Nt},${Ot}`,up:`${Ot/2},0 0,${Nt} ${Ot},${Nt}`,down:`${Ot/2},${nr} 0,${nr-Nt} ${Ot},${nr-Nt}`},na=e=>{e.preventDefault(),e.stopPropagation()},bc={onMouseDownCapture:na,onMouseUpCapture:na,onClickCapture:na},pc="period-slider-step",vc=`${pc} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,xc="transition-colors motion-reduce:transition-none not-aria-disabled:cursor-pointer aria-disabled:cursor-not-allowed focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 dark:focus-visible:ring-blue-400 forced-colors:not-aria-disabled:hover:text-[Highlight] forced-colors:aria-disabled:text-[GrayText]",Sc={control:"text-slate-500 not-aria-disabled:hover:bg-slate-500/15 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-500/25 aria-disabled:text-slate-500/40 dark:text-slate-400 dark:not-aria-disabled:hover:text-slate-50 dark:aria-disabled:text-slate-400/40",rail:"border border-slate-300 bg-white text-slate-700 shadow-2xs not-aria-disabled:hover:border-slate-400 not-aria-disabled:hover:bg-slate-100 not-aria-disabled:hover:text-slate-900 not-aria-disabled:active:bg-slate-200 aria-disabled:border-slate-300/40 aria-disabled:bg-white/40 aria-disabled:text-slate-700/40 aria-disabled:shadow-none dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:not-aria-disabled:hover:border-slate-500 dark:not-aria-disabled:hover:bg-slate-700 dark:not-aria-disabled:hover:text-white dark:not-aria-disabled:active:bg-slate-600 dark:aria-disabled:border-slate-700/40 dark:aria-disabled:bg-slate-800/40 dark:aria-disabled:text-slate-200/40"},zn="after:inset-[calc((100%-var(--ps-target-size))/2)]",ji={horizontal:"px-[19px]",vertical:"py-[19px]"},Dc={control:{left:zn,right:zn,up:zn,down:zn},rail:{left:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:left-[calc(100%-var(--ps-target-size)+4px)] after:-right-[4px]",right:"after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-left-[4px] after:right-[calc(100%-var(--ps-target-size)+4px)]",up:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-[calc(100%-var(--ps-target-size)+4px)] after:-bottom-[4px]",down:"after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-[4px] after:bottom-[calc(100%-var(--ps-target-size)+4px)]"}},Rr=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:i,ref:s})=>{const d=e==="up"||e==="down",g=d?Ot:nr,m=d?nr:Ot,v=r||!n;return L.jsx("button",{ref:s,type:"button","aria-label":a,disabled:r,"aria-disabled":v?!0:void 0,...v?bc:null,onClick:v?void 0:o,className:`${i===void 0?"":`${i} `}${vc} ${xc} ${Sc[t]} ${Dc[t][e]}`,children:L.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:g,height:m,viewBox:`0 0 ${g} ${m}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:L.jsx("polygon",{points:wc[e]})})})},So=(e,t)=>{const r=l.useMemo(()=>Ps(e,t),[e,t]),n=l.useRef(r);return sc(n.current,r)||(n.current=r),n.current},ct=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${S(r)})`)},ur=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&ct(e,"values.min",t.min),t.max!==null&&ct(e,"values.max",t.max),t.min!==null&&t.max!==null&&t.max<t.min)throw new RangeError(`${e}: values.max must not precede values.min (min: ${t.min}, max: ${t.max})`);return}ct(e,"values.loIndex",t.loIndex),ct(e,"values.hiIndex",t.hiIndex)},En=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Do=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},wn=(e,t)=>(ur("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:En(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),bn=(e,t)=>{if(ur("drawnValuesHas",e),ct("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(En(e))return!1;const r=Do(e,t);return r<=e.hiIndex&&e.ascending[r]===t},pn=(e,t)=>{if(ur("drawnValuesNearest",e),ct("drawnValuesNearest","value",t),e.kind==="range")return e.min!==null&&t<e.min?e.min:e.max!==null&&t>e.max?e.max:t;if(En(e))return null;const r=Do(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Xt=(e,t,r)=>{if(ur("drawnValuesNeighbour",e),ct("drawnValuesNeighbour","value",t),e.kind==="range"){if(r===-1){const i=e.max===null?t-1:Math.min(t-1,e.max);return e.min!==null&&i<e.min?null:i}const a=e.min===null?t+1:Math.max(t+1,e.min);return e.max!==null&&a>e.max?null:a}if(En(e))return null;const n=Do(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},Zn=(e,t,r)=>{if(ur("clampPairIntoDrawnValues",e),ct("clampPairIntoDrawnValues","low",t),ct("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=pn(e,t),o=pn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Rc=(e,t,r)=>{if(ur("carryPairIntoDrawnValues",e),ct("carryPairIntoDrawnValues","low",t),ct("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(En(e))return null;const n=wn(e,-1),o=wn(e,1),a=r-t;return o!==null&&r>o?Zn(e,o-a,o):n!==null&&t<n?Zn(e,n,n+a):Zn(e,t,r)},Qn=(e,t,r)=>(ur("drawnValuesAtOrBeyond",e),ct("drawnValuesAtOrBeyond","target",t),Xt(e,t-r,r)),Gr=(e,t,r)=>{if(t!==null&&ct("drawnValuesWithin","min",t),r!==null&&ct("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:Do(n,t),hiIndex:o-1}},Jn=e=>(ur("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Xt(e,t,r),edge:t=>wn(e,t)}),ma=(e,t,r,n,o)=>{if(ct("stepPair","low",t),ct("stepPair","high",r),r<t)throw new RangeError(`stepPair: high must not precede low (low: ${t}, high: ${r})`);if(n!==-1&&n!==1)throw new RangeError(`stepPair: direction must be -1 or 1 (received: ${S(n)})`);switch(o.motion){case"shift":{if(o.edge!=="disable"&&o.edge!=="clamp")throw new RangeError(`stepPair: rule.edge must be "disable" or "clamp" (received: ${S(o.edge)})`);const a=n===1?r:t,i=n===1?t:r,s=e.stepEnd(i,n);if(s===null)return null;let d=e.stepEnd(a,n);if(d===null){const g=e.edge(n);if(o.edge==="disable"||g===null||(n===1?a>g:a<g))return null;d=g}return n===1?[s,d]:[d,s]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${S(o.shows)})`);const a=e.stepEnd(o.shows==="start"?t:r,n);return a===null?null:[a,a]}default:throw new RangeError(`stepPair: rule.motion must be one of "shift", "start", "end", "single" (received: ${S(o.motion)})`)}},$s={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},Ls=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,$t=(e,t)=>{if(!Ls(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${S(t)})`)},dr=(e,t)=>t===void 0?0:($t(e,t),t),Mc=[31,28,31,30,31,30,31,31,30,31,30,31],Ts=719468,eo=146097,fa=(e,t)=>t!==1?Mc[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,$a=(e,t,r,n)=>{const o=e*12+t+n,a=Math.floor(o/12),i=o-a*12;return[a,i,Math.min(r,fa(a,i))]},vn=(e,t,r)=>{const n=t<2?e-1:e,o=Math.floor(n/400),a=n-o*400,i=t<2?t+10:t-2,s=Math.floor((153*i+2)/5)+r-1,d=a*365+Math.floor(a/4)-Math.floor(a/100)+s;return o*eo+d-Ts},Ui=e=>{const t=e+Ts,r=Math.floor(t/eo),n=t-r*eo,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(eo-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),s=i<10?i+2:i-10;return[r*400+o+(s<2?1:0),s,a-Math.floor((153*i+2)/5)+1]},La=(e,t,r)=>e-(t<r?1:0),wt=(e,t,r=0)=>{if(!$e(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${S(t)})`);$t("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(La(t.getFullYear(),t.getMonth(),r),r,1),n.setHours(0,0,0,0)):(e==="month"&&n.setDate(1),n.setHours(0,0,0,0)),n},_=(e,t,r=0)=>{$t("encode",r);const n=wt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:vn(o,a,n.getDate())},ee=(e,t,r=0)=>{$t("decode",r);const n=new Date(0);if(n.setHours(0,0,0,0),e==="year")return n.setFullYear(t,r,1),n;if(e==="month"){const a=Math.floor(t/12),i=t-a*12;return n.setFullYear(a,i,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},Cs='; minDate is required, so pass the earliest date to offer instead of a sentinel for "no bound"',ut=(e,t,r,n,o,a)=>{const i=Is(r,n,o);if(i===null)throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${S(r)})${a}`);return i},Is=(e,t,r)=>{const n=_(t,e,r);return Number.isInteger(n)?n:null},ks=(e,t,r)=>{if(!$e(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${S(t)})`);if(!Number.isInteger(r))throw new RangeError(`addUnit: amount must be an integer number of units (received: ${S(r)})`);const n=new Date(t.getTime());return r===0?n:e==="year"||e==="month"?(n.setFullYear(...$a(t.getFullYear(),t.getMonth(),t.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},zi=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,s,d]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:Ui(t),[g,m,v]=r==="year"||r==="month"?$a(i,s,d,r==="year"?n*12:n):Ui(vn(i,s,d)+n);return e==="year"?La(g,m,o):e==="month"?g*12+m:vn(g,m,v)},As=(e,t,r,n=0)=>{if(!$e(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${S(r)})`);return $t("getMacroWindowStartDate",n),ut("getMacroWindowStartDate","d",r,e,n,""),ut("getMacroWindowStartDate","d",r,t,n,""),wt(t,wt(e,r,n),n)},Ns=(e,t,r,n=0)=>{if(!$e(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${S(r)})`);$t("getMacroWindowEndDate",n);let o;if(e==="year"&&t!=="year"){const[i,s]=$a(La(r.getFullYear(),r.getMonth(),n),n,1,11);o=t==="month"?i*12+s:vn(i,s,fa(i,s))}else if(e==="month"&&t==="day")o=vn(r.getFullYear(),r.getMonth(),fa(r.getFullYear(),r.getMonth()));else return ut("getMacroWindowEndDate","d",r,t,n,""),wt(t,r,n);const a=ee(t,o,n);if(!$e(a))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${S(r)})`);return a},Fi=(e,t,r)=>e<t?t:e>r?r:e,Dt=(e,t,r,n,o,a=0)=>{if($t("resolveMacroWindow",a),ao("macroRange",r,!0,"resolveMacroWindow"),!$e(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${S(n)})`);if(!$e(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${S(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${S(n)}, maxDate: ${S(o)})`);ut("resolveMacroWindow","maxDate",o,t,a,""),ut("resolveMacroWindow","macroRange[0]",r[0],e,a,""),ut("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=_(e,r[1],a)<_(e,o,a)?Fi(Ns(e,t,r[1],a),n,o):o;return[wt(t,Fi(As(e,t,r[0],a),n,o),a),wt(t,i,a)]},Os=(e,t)=>{if(!$e(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${S(e)})`);$t("resolveQuarter",t);const r=wt("year",e,t).getFullYear(),n=((e.getMonth()-t)%12+12)%12,o=Math.floor(n/3)+1,a=new Date(e.getTime());return a.setFullYear(r,t+3*(o-1),1),a.setHours(0,0,0,0),{year:r,quarter:o,startDate:a}},Ec={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Bi=new Map,yc=(e,t)=>{const r=`${e}\0${t}`,n=Bi.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Ec[e]);return Bi.set(r,o),o},Pc=4,$c=6,Ro=e=>e>=0?String(e).padStart(Pc,"0"):`-${String(-e).padStart($c,"0")}`,Lc=(e,t)=>{const r=Ro(t.getFullYear());if(e==="year")return r;const n=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${n}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${n}-${o}`},st=(e,t,r,n)=>$e(t)?r?r(t,e,"period"):n===void 0?Lc(e,t):yc(e,n).format(t):"",xr=(e,t,r,n)=>st(e,t,r,n),Tc=(e,t)=>{if(!$e(e))return"";$t("formatQuarterLabel",t);const{quarter:r}=Os(e,t);return`${st("year",wt("year",e,t))}-Q${r}`},Pe=(e,t,r,n=0)=>{if($t("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!$e(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${S(t)})`);const o=ut("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=_(r,e[a],n))return 0;if(o>=_(r,e[i],n))return i;for(;a<=i;){const g=a+i>>1,m=_(r,e[g],n);if(m===o)return g;m<o?a=g+1:i=g-1}const s=Math.abs(_(r,e[a],n)-o),d=Math.abs(_(r,e[i],n)-o);return s<d?a:i},Cc=(e,t,r,n,o=0)=>cr("getSortedAllowedDates",Mo(e),t,r,n,o).dates,Mo=e=>({list:e,path:"allowedDates",inheritedBy:null}),cr=(e,t,r,n,o,a)=>{$t(e,a);const{list:i,path:s}=t,d=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(Ea(e,`${s}${d}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[M,U]of[["minDate",n],["maxDate",o]])if(!$e(U))throw new RangeError(`${e}: ${M} must be a valid Date (received: ${S(U)})`);const g=ut(e,"minDate",n,r,a,""),m=ut(e,"maxDate",o,r,a,""),v=new Map;for(let M=0;M<i.length;M++){const U=i[M];if(!$e(U))throw new RangeError(`${e}: ${s}[${M}]${d} must be a valid Date (received: ${S(U)})`);const u=ut(e,`${s}[${M}]${d}`,U,r,a,"");u<g||u>m||v.has(u)||v.set(u,wt(r,U,a))}if(v.size===0)throw new RangeError(`${e}: every ${s} entry${d} falls outside [minDate, maxDate] (minDate: ${S(n)}, maxDate: ${S(o)}, entries: ${i.length})`);const b=Array.from(v.keys()).sort((M,U)=>M-U);return{keys:b,dates:b.map(M=>v.get(M))}},Ta=(e,t,r,n,o,a)=>{const{keys:i,dates:s}=cr(e,t,r,n,o,a);return s.length===0?null:{...Gr(i,null,null),dates:s}},xn=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),Fn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Pe(e,n,t,o);if(r==="time"){const s=e[0].getTime(),d=e[a].getTime()-s;return d<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-s)/d))}return i/a},Bn=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const s=e[0].getTime(),d=e[a].getTime()-s;return d<=0?0:Pe(e,new Date(s+i*d),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},ga=(e,t,r,n,o,a,i)=>{let s=r,d=n;return i?(s=t,d=t):e==="low"?t>n?(s=n,d=t):s=t:t<r?(d=r,s=t):d=t,[Math.max(o,Math.min(a,s)),Math.max(o,Math.min(a,d))]},Vs=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:s,unit:d,yearStartMonth:g=0})=>{if(a){const u=i.length-1;if(u<=0)return[0,0];const D=Math.max(0,Math.min(u,Math.round(t))),f=Math.max(D,Math.min(u,Math.round(r)));if(s==="time"){const H=i[0].getTime(),de=i[u].getTime(),Y=i[D].getTime(),re=i[f].getTime()-Y;let oe=Y+e*(de-H),V=oe+re;oe<H&&(oe=H,V=H+re),V>de&&(V=de,oe=de-re);const ne=Pe(i,new Date(oe),d,g),R=Pe(i,new Date(V),d,g);return[ne,Math.max(ne,R)]}const z=Math.round(e*u);let P=D+z,K=f+z;return P<0&&(K+=-P,P=0),K>u&&(P-=K-u,K=u),[Math.max(0,Math.min(u,P)),Math.max(0,Math.min(u,K))]}const m=u=>Math.max(n,Math.min(o,u)),v=o-n;if(v<=0)return[m(t),m(r)];const b=Math.round(e*v);let M=t+b,U=r+b;return M<n&&(U+=n-M,M=n),U>o&&(M-=U-o,U=o),[m(M),m(U)]},_s=(e,t,r,n,o,a,i,s)=>{let d=0,g=!1,m=!1;switch(e){case"ArrowRight":case"ArrowUp":d=s;break;case"ArrowLeft":case"ArrowDown":d=-s;break;case"PageUp":d=s*5;break;case"PageDown":d=-s*5;break;case"Home":g=!0;break;case"End":m=!0;break;default:return null}if(i){let M=r;return g?M=o:m?M=a:M=Math.max(o,Math.min(a,r+d)),[M,M]}let v=r,b=n;return t==="low"?g?v=o:m?v=n:v=Math.max(o,Math.min(n,r+d)):g?b=r:m?b=a:b=Math.max(r,Math.min(a,n+d)),[v,b]},Ys=8,Hs=2,js=16,Ic=12,kc=90,Us=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},Ca=(e,t)=>{const r=t?.estimatedHeightPx??js,o=Ys+(t?.anchorGapY??Hs)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},Ia=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??js,s=o?.paddingPx??Ic,d=o?.maxAngleDeg??kc,g=Ys+(o?.anchorGapY??Hs),m=Ca(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return m;const v=Math.max(0,t-e)/100*r,b=a+s;if(v>=b)return m;const M=Math.max(0,Math.min(1,(b-v)/b)),u=M*M*M*(M*(M*6-15)+10)*d,D=n==="top"?-u:u,f=Us(a,i,u),z=g+f.acrossPx,P=n==="top"?-z:+z,K=2*f.alongPx,H=Math.max(0,(K+s-v)/2);return{lowAngleDeg:D,highAngleDeg:D,lowOffsetX:-H,highOffsetX:H,lowOffsetY:P,highOffsetY:P,isSlanted:M>.001,proximity:M}},zs=e=>({...e,lowOffsetX:0,highOffsetX:0}),St=(e,t)=>{const r=e==="macro"?t.macroAllowedDates:t.microAllowedDates;return r!==void 0?{list:r,path:e==="macro"?"macroAllowedDates":"microAllowedDates",inheritedBy:null}:{list:t.allowedDates,path:"allowedDates",inheritedBy:e}},to=(e,t,r,n)=>e==="pan"?Rc(t,r,Math.max(r,n)):Zn(t,r,Math.max(r,n)),ka=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},Fs=(e,t,r)=>{const n=Math.abs(e)>Math.abs(t)?e:t;return!Number.isFinite(n)||n===0?0:(r?n<0:n>0)?1:-1};function Bs(e,t,r,n,o,a,i="macro-top",s=.05,d=!0,g="range"){if(ka(t,i)==="macro"){const b=Math.abs(e-r),M=Math.abs(e-n);return b<=s&&b<=M?"macro-low":M<=s&&M<b?"macro-high":d&&e>=r&&e<=n?"macro-connect":b<M?"macro-low":"macro-high"}if(g==="point")return"micro-point";const m=Math.abs(e-o),v=Math.abs(e-a);return m<=s&&m<=v?"micro-low":v<=s&&v<m?"micro-high":d&&e>=o&&e<=a?"micro-connect":m<v?"micro-low":"micro-high"}function Ws(e,t,r,n,o){if(e==="macro-connect"){const[g,m]=Pa(t-r,n,o);return[g,m,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,s]=oo(a,t,n,o),d=po(a,t,n,o);return[i,s,d==="low"?"macro-low":"macro-high"]}function Ks(e,t,r,n,o){if(e==="micro-point"){const[g]=oo("point",t,n,o);return[g,g,"micro-point"]}if(e==="micro-connect"){const[g,m]=Pa(t-r,n,o);return[g,m,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,s]=oo(a,t,n,o),d=po(a,t,n,o);return[i,s,d==="low"?"micro-low":"micro-high"]}const mn=l.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",a=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return L.jsx("svg",{className:a,width:r?"8":"16",height:r?"16":"8",viewBox:r?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:L.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});mn.displayName="VernierKnobSvg";const Ac=(e,t,r,n)=>{if(!$e(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${S(e)})`);if(!$e(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${S(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${S(e)}, maxDate: ${S(t)})`);for(const o of r)ut("PeriodSlider","minDate",e,o,n,Cs)},ao=(e,t,r,n="PeriodSlider")=>{if(!Pt(t)||t.length!==2){const i=r?"is required and must":"must";throw new RangeError(`${n}: ${e} ${i} be a [start, end] Date tuple (received: ${S(t)})`)}const[o,a]=t;if(!$e(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${S(o)})`);if(!$e(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${S(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${S(o)}, end: ${S(a)})`)},Gs=(e,t)=>{if(!$e(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${S(t)})`)},zr=(e,t,r,n,o,a)=>{const i=ut("PeriodSlider",e,t,r,a,"");if(i<_(r,n,a)||i>_(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${S(t)}, minDate: ${S(n)}, maxDate: ${S(o)})`)},Nc=(e,t,r)=>{const n=e.yearStartMonth??0;if(e.mode==="range"){for(const o of["range","defaultRange"]){const a=e[o];a!==void 0&&(ao(o,a,!1),zr(`${o}[0]`,a[0],e.unit,t,r,n),zr(`${o}[1]`,a[1],e.unit,t,r,n))}return}if(e.mode==="point")for(const o of["value","defaultValue"]){const a=e[o];a!==void 0&&(Gs(o,a),zr(o,a,e.unit,t,r,n))}},Oc=(e,t,r)=>{const n=e.yearStartMonth??0;ao("macroRange",e.macroRange,!0),ut("PeriodSlider","macroRange[0]",e.macroRange[0],e.macroUnit??e.unit,n,"");const o=e.microUnit??e.unit,a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,i=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&i)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(i){for(const g of["microValue","defaultMicroValue"]){const m=e[g];m!==void 0&&(Gs(g,m),zr(g,m,o,t,r,n))}const d=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(d===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[d,d]}}for(const d of["microRange","defaultMicroRange"]){const g=e[d];g!==void 0&&(ao(d,g,!1),zr(`${d}[0]`,g[0],o,t,r,n),zr(`${d}[1]`,g[1],o,t,r,n))}const s=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(s!==void 0)return{shape:"range",selection:s};throw a?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},ln=(e,t,r,n,o,a,i,s,d)=>{const g=Pe(e,n,t,d),m=Pe(e,o,t,d);return i?g:s?m:Math.max(g,Math.min(m,Pe(e,r,t,d)+a))},oa=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Wi=()=>{const[e,t]=l.useState(null),r=l.useRef(null),n=l.useCallback((a,i)=>{const s=r.current;if(s!==null&&s[0].getTime()===a.getTime()&&s[1].getTime()===i.getTime())return;const d=[a,i];r.current=d,t(d)},[]),o=l.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Vc=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${S(t)})`)}},jr=()=>{const[e,t]=l.useState(null),r=l.useRef(null),n=l.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const s of i){const d=s.borderBoxSize?.[0];d!==void 0&&t(g=>g!==null&&Math.abs(g.widthPx-d.inlineSize)<.5&&Math.abs(g.heightPx-d.blockSize)<.5?g:{widthPx:d.inlineSize,heightPx:d.blockSize})}});a.observe(o),r.current=a},[]);return l.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},aa=(e,t)=>{const r=ro(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},ro=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},_c=e=>{const t={};let r=0;for(const o of e){const{side:a,box:i}=o;if(i===null)continue;let s;if(o.reach==="inline-size")s=i.widthPx,r=Math.max(r,i.heightPx/2);else{const d=Us(i.widthPx,i.heightPx,o.angleDeg);s=o.centreOffsetPx===null?2*d.acrossPx:Math.abs(o.centreOffsetPx)+d.acrossPx,r=Math.max(r,d.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${Math.ceil(s)}px`}if(Object.keys(t).length===0)return;const n=Math.ceil(r);return t["--ps-label-reach-main"]=`${n}px`,{style:t,mainPx:n}},Ki=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),Gi=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),io=(e,t)=>({"--ps-tooltip-tx":Jo(e,"tx",t.tx),"--ps-tooltip-ty":Jo(e,"ty",t.ty),"--ps-tooltip-rot":Jo(e,"rot",t.rot)}),ia=(e,t,r,n)=>{const o=Ca(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=Ia(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?zs(a):a,s=bo[e],d={low:Ki(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:Ki(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:io(s.low,d.low),highStyle:io(s.high,d.high),placements:d}},qi={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Xi=(e,t,r)=>{const n=Ca(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:qi,highStyle:qi,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const d=Ia(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?zs(d):d}const i=bo.flat,s={low:Gi(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:Gi(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...io(i.low,s.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...io(i.high,s.high)},placements:o?s:null}},Yc={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Hc={horizontal:{decrease:"period-slider-stepper-prev",increase:"period-slider-stepper-next"},vertical:{decrease:"period-slider-stepper-prev period-slider-stepper-down",increase:"period-slider-stepper-next period-slider-stepper-up"}},Zi={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},jc={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${hn} ${ji.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Zi.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${hn} ${ji.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Zi.vertical}`}},Qi={horizontal:{leading:"col-start-1 row-start-1",rail:"col-start-2 row-start-1",railOnly:"col-start-1 row-start-1",trailing:"col-start-3 row-start-1"},vertical:{leading:"col-start-1 row-start-1",rail:"col-start-1 row-start-2",railOnly:"col-start-1 row-start-1",trailing:"col-start-1 row-start-3"}},Ji=(e,t)=>{e.setPointerCapture(t)},Uc=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:s="",showStepper:d=!0,tooltipStyle:g="always",labelPosition:m="top",autoSlantLabels:v=!0,isVertical:b=!1,hideConnectBar:M=!1,showTicks:U=!1,colorScheme:u="blue-rose",formatLocale:D}=e,f=dr("PeriodSlider",e.yearStartMonth);Ac(r,n,e.mode==="vernier"?[e.macroUnit??t,e.microUnit??t,t]:[t],f),Nc(e,r,n),D!==void 0&&Vc("formatLocale",D);const z=e.mode==="vernier"?Oc(e,r,n):null,P=z!==null&&z.shape==="point",K=So(e.locale,e.labels),H=$s[u],de=l.useId(),Y=l.useRef(e),re=r.getTime(),oe=n.getTime(),V=l.useMemo(()=>cr("PeriodSlider",Mo(o),t,r,n,f).dates,[o,t,re,oe,f]),ne=V.length>0,{rangeMin:R,rangeMax:E}=l.useMemo(()=>ne?{rangeMin:0,rangeMax:V.length-1}:{rangeMin:_(t,r,f),rangeMax:_(t,n,f)},[ne,V,t,re,oe,f]),$=e.mode==="point",W=l.useCallback(c=>{if(ne){const w=Math.max(0,Math.min(V.length-1,Math.round(c)));return V[w]}return ee(t,Math.round(c),f)},[ne,V,t,f]),J=l.useCallback(c=>{if(c===void 0)return R;const w=wt(t,c,f);return ne?Pe(V,w,t,f):_(t,w,f)},[ne,V,t,R,f]),[F,G]=l.useState(()=>z===null?null:z.selection);let k=F??(z===null?null:z.selection);if(P&&k!==null&&k[0].getTime()!==k[1].getTime()){const c=[k[0],k[0]];k=c,G(c)}const ie=e.mode==="vernier"?e.microValue?.getTime():void 0,we=l.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,ie]),Se=Wi(),q=Wi(),A=e.mode!=="vernier"?null:P?we??k:e.microRange!==void 0?e.microRange:k,ge=A===null?null:q.shown??A,ue=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ge?.[0]:void 0,ae=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ge?.[1]:void 0,I=e.mode==="point"?e.value??e.defaultValue:void 0,he=e.mode==="point"?I?.getTime():ue?.getTime(),fe=e.mode==="range"?ae?.getTime():he,[De,be]=l.useMemo(()=>{if(e.mode==="point"){const p=J(I);return[p,p]}const c=J(ue),w=J(ae);return[Math.min(c,w),Math.max(c,w)]},[e.mode,he,fe,J,I,ue,ae]),pe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:P?e.microValue!==void 0:e.microRange!==void 0,[Oe,Te]=l.useState(()=>[De,be]),[Ze,ot]=l.useState(null),[Le,Q]=l.useState(null),Ye=l.useRef(null),[Rt,ze]=l.useState("high"),[Fe,qe]=l.useState(null),[Qe,ft]=l.useState(null),ve=Ze?Ze[0]:pe?De:Oe[0],ye=Ze?Ze[1]:pe?be:Oe[1],T=l.useRef([ve,ye]),C=e.mode==="vernier",Ve=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",O=Ve==="macro-top"||Ve==="macro-left",Je=e.mode==="vernier"?e.showVernierProjection??!0:!1,Lt=e.mode==="vernier"?e.showVernierTicks??!0:!1,jt=e.mode==="vernier"?e.showHairline??!0:!1,te=C?e.macroUnit??t:t,h=C?e.microUnit??t:t,se=C?e.macroIsDiscrete??!1:ne,Re=C?e.microIsDiscrete??!1:ne,Be=C?St("macro",e).list:o,y=C?St("micro",e).list:o,j=C?e.formatMacroLabel??e.formatLabel:e.formatLabel,le=C?e.formatMicroLabel??e.formatLabel:e.formatLabel,He=ue?.getTime(),_e=ae?.getTime(),[Me,je]=l.useState(null),et=l.useRef(null),[bt,Ut]=l.useState(()=>P?"micro-point":"micro-high");let We=bt;const Po=P?bt==="micro-low"||bt==="micro-high"||bt==="micro-connect"?"micro-point":null:bt==="micro-point"?"micro-high":null;Po!==null&&(We=Po,Ut(Po));const gt=l.useMemo(()=>_(te,r,f),[re,te,f]),Tt=l.useMemo(()=>_(te,n,f),[oe,te,f]),ke=l.useMemo(()=>C&&se?cr("PeriodSlider",St("macro",e),te,r,n,f).dates:[],[C,se,Be,te,re,oe,f]),Ya=c=>[Math.max(gt,Math.min(Tt,_(te,c[0],f))),Math.max(gt,Math.min(Tt,_(te,c[1],f)))],[Ha,ja]=e.mode!=="vernier"?[gt,Tt]:Ya(e.macroRange),[tt,lt]=Se.shown===null?[Ha,ja]:Ya(Se.shown),mr=l.useMemo(()=>ee(te,tt,f),[te,tt,f]),fr=l.useMemo(()=>ee(te,lt,f),[te,lt,f]),yn=l.useMemo(()=>e.mode!=="vernier"?[r,n]:Dt(te,h,[mr,fr],r,n,f),[e.mode,mr,fr,te,h,re,oe,f]),Ue=l.useMemo(()=>_(h,yn[0],f),[h,yn,f]),at=l.useMemo(()=>_(h,yn[1],f),[h,yn,f]),Pn=l.useMemo(()=>C&&Re?Ta("PeriodSlider",St("micro",e),h,r,n,f):null,[C,Re,y,h,re,oe,f]),$o=(c,w)=>Pn===null?[]:xn(Pn,Gr(Pn.ascending,c,w)),xe=l.useMemo(()=>$o(Ue,at),[Pn,Ue,at]),Zt=se&&ke.length>0,Mt=Re&&xe.length>0,Ua=Zt?_(te,ke[0],f):gt,za=Zt?_(te,ke[ke.length-1],f):Tt,Fa=Mt?_(h,xe[0],f):Ue,Lo=Mt?_(h,xe[xe.length-1],f):at,ul=Math.min(Ua,tt),dl=Math.max(za,lt),Qt=(c,w,p,x)=>w.length>0?_(h,w[Pe(w,c,h,f)],f):Math.max(p,Math.min(x,_(h,c,f))),Er=Mt?xe:[],Ke=l.useMemo(()=>ge===null?Ue:Qt(ge[0],Er,Ue,at),[He,Ue,at,h,ge,Er]),it=l.useMemo(()=>ge===null?at:Qt(ge[1],Er,Ue,at),[_e,Ue,at,h,ge,Er]),yr=l.useMemo(()=>ee(h,Ke,f),[h,Ke,f]),Pr=l.useMemo(()=>ee(h,it,f),[h,it,f]),Ba=!C||A===null?null:{macroUnit:te,macroLowEnc:Ha,macroHighEnc:ja,microUnit:h,microLowEnc:_(h,A[0],f),microHighEnc:_(h,A[1],f)},To=l.useRef(Ba),Co=Math.max(1,Tt-gt),Et=Zt?Fn(ke,te,a,mr,f):Math.max(0,Math.min(1,(tt-gt)/Co)),Ct=Math.max(Et,Zt?Fn(ke,te,a,fr,f):Math.min(1,(lt-gt)/Co)),Wa=c=>Math.max(Ua,Math.min(za,Math.round(gt+c*Co))),$n=Math.max(1,at-Ue),$r=Mt?Fn(xe,h,a,yr,f):Math.max(0,Math.min(1,(Ke-Ue)/$n)),qr=Math.max($r,Mt?Fn(xe,h,a,Pr,f):Math.min(1,(it-Ue)/$n)),Io=l.useRef({timerId:null,emit:null}),Ln=l.useRef({timerId:null,emit:null}),Tn=l.useRef({timerId:null,emit:null});l.useEffect(()=>{const c=[Io,Ln,Tn];return()=>{for(const w of c)oa(w.current)}},[]);const Lr=l.useCallback((c,w,p)=>{oa(c);const{debounceMs:x}=Y.current;if(p||!x||x<=0){w();return}c.emit=w,c.timerId=setTimeout(()=>{c.timerId=null,c.emit=null,w()},x)},[]),Ka=l.useCallback(c=>{const w=c.emit;oa(c),w?.()},[]),Tr=l.useCallback(c=>new Date(Math.min(Math.max(c.getTime(),re),oe)),[re,oe]),Jt=l.useCallback((c,w,p=!1)=>{const[x,N]=T.current;if((Y.current.mode==="point"?c===x:c===x&&w===N)&&Io.current.timerId===null)return;const Z=W(c),X=W(w),me=()=>{const Ee=Y.current;Ee.mode==="point"?Ee.onChangePoint?.(Z):Ee.mode==="range"&&Ee.onChangeRange?.(Z,X)};Lr(Io.current,me,p)},[W,Lr]),gr=l.useCallback((c,w,p=!1)=>{const x=To.current;if(Y.current.mode!=="vernier"||x===null)return;const N=Tr(c),B=Tr(w);_(x.macroUnit,N,f)===x.macroLowEnc&&_(x.macroUnit,B,f)===x.macroHighEnc&&Ln.current.timerId===null||Lr(Ln.current,()=>{const Z=Y.current;Z.mode==="vernier"&&Z.onChangeMacroRange?.(N,B)},p)},[Tr,Lr,f]),pt=l.useCallback((c,w,p=!1)=>{const x=Y.current,N=To.current;if(x.mode!=="vernier"||N===null)return;const B=Tr(c),Z=Tr(w);_(N.microUnit,B,f)===N.microLowEnc&&_(N.microUnit,Z,f)===N.microHighEnc&&Tn.current.timerId===null||((P?x.microValue===void 0:x.microRange===void 0)&&G([B,Z]),Lr(Tn.current,()=>{const X=Y.current;if(X.mode==="vernier"){if(P){X.onChangeMicroPoint?.(B);return}X.onChangeMicroRange?.(B,Z)}},p))},[Tr,Lr,P,f]),Ga=l.useCallback((c,w=!1)=>{pt(c,c,w)},[pt]),hr=l.useCallback(c=>{if(ne&&a==="time"&&V.length>1){const x=Math.max(0,Math.min(V.length-1,Math.round(c))),N=V[0].getTime(),Z=V[V.length-1].getTime()-N;if(Z<=0)return 0;const X=V[x].getTime();return Math.max(0,Math.min(100,(X-N)/Z*100))}const w=E-R;if(w<=0)return 0;const p=(c-R)/w*100;return Math.max(0,Math.min(100,p))},[ne,a,V,R,E]),ko=l.useCallback(c=>{const w=Math.max(0,Math.min(100,c));if(ne){if(a==="time"&&V.length>1){const N=V[0].getTime(),Z=V[V.length-1].getTime()-N,X=N+w/100*Z;return Pe(V,new Date(X),t,f)}const x=Math.round(w/100*(V.length-1));return Math.max(0,Math.min(V.length-1,x))}const p=R+w/100*(E-R);return Math.round(p)},[ne,a,V,R,E,t,f]),Xr=l.useRef(null),qa=l.useRef(null),Xa=l.useRef(0),mt=l.useRef(null),Ao=l.useRef(null),Za=l.useRef(null),Qa=l.useRef(null),[No,Ja]=l.useState(0),[ml,Cr]=jr(),[fl,ei]=jr(),[gl,ti]=jr(),[hl,ri]=jr(),[wl,Oo]=jr(),[bl,ni]=jr(),pl=$?Cr===null?void 0:{estimatedWidthPx:Cr.widthPx,estimatedHeightPx:Cr.heightPx}:aa(Cr,ei),Vo=!$&&ve===ye,_o=tt===lt,Yo=!P&&Ke===it,vl=O?"top":"bottom",xl=O?"bottom":"top",oi=v&&!b,Sl=oi&&!P,Ho={isPointMode:$,isVertical:b,autoSlantLabels:v,isMerged:Vo,trackLengthPx:No,labelPosition:m,config:pl},jo={trackLengthPx:No,labelPosition:vl,config:aa(ti,ri),isMerged:_o,isSlantable:oi},Uo={trackLengthPx:No,labelPosition:xl,config:aa(Oo,ni),isMerged:Yo,isSlantable:Sl};l.useEffect(()=>{const c=mt.current;if(!c)return;const w=()=>{const x=c.getBoundingClientRect(),N=b?x.height:x.width;N>0&&Ja(B=>Math.abs(B-N)<.5?B:N)};if(w(),typeof ResizeObserver<"u"){const x=new ResizeObserver(N=>{for(const B of N){const Z=b?B.contentRect.height:B.contentRect.width;Z>0&&Ja(X=>Math.abs(X-Z)<.5?X:Z)}});return x.observe(c),()=>x.disconnect()}const p=c.ownerDocument.defaultView;if(p)return p.addEventListener("resize",w),()=>p.removeEventListener("resize",w)},[b]);const Ir=l.useCallback((c,w,p)=>{const x=b?p.height:p.width;if(!(Number.isFinite(x)&&x>0))return null;const N=b?p.bottom-w:c-p.left;return Number.isFinite(N)?Math.max(0,Math.min(1,N/x)):null},[b]),ai=l.useCallback((c,w)=>{const p=mt.current;if(!p)return null;const x=Ir(c,w,p.getBoundingClientRect());return x===null?null:x*100},[Ir]),Zr=l.useRef(null),zt=l.useRef(null),Cn=l.useRef({macroLowRatio:Et,macroHighRatio:Ct,isVertical:b,isMacroFirstRail:O}),ii=l.useRef({flat:Ho,macro:jo,micro:Uo});l.useLayoutEffect(()=>{Cn.current={macroLowRatio:Et,macroHighRatio:Ct,isVertical:b,isMacroFirstRail:O},ii.current={flat:Ho,macro:jo,micro:Uo},Y.current=e,T.current=[ve,ye],To.current=Ba,Ye.current=Le,et.current=Me});const si=(c,w)=>{const p=Cn.current;Ao.current?.setAttribute("d",ea(c,w,p.isVertical,p.isMacroFirstRail))},Dl=(c,w,p)=>{const x=ii.current;return c==="flat"?Xi(w*100,p*100,x.flat).placements:ia(c,w,p,c==="macro"?x.macro:x.micro).placements},Qr=(c,w,p)=>{const x=mt.current;if(!x)return;Zr.current={rail:c,lowRatio:w,highRatio:p},tc(x,c,w,p);const N=Dl(c,w,p);N!==null&&ec(x,c,N),c==="macro"&&si(w,p)},wr=l.useCallback(()=>{zt.current!==null&&(clearTimeout(zt.current),zt.current=null);const c=mt.current;c&&(c.removeAttribute(Zo),c.style.removeProperty(Qo))},[]),li=()=>{const c=mt.current;if(Zr.current===null||!c){Zr.current=null;return}Zr.current=null,zt.current!==null&&clearTimeout(zt.current),c.style.setProperty(Qo,`${Vi}ms`),c.setAttribute(Zo,"true"),rc(c),si(Cn.current.macroLowRatio,Cn.current.macroHighRatio),zt.current=setTimeout(()=>{zt.current=null,c.removeAttribute(Zo),c.style.removeProperty(Qo)},Vi)};l.useLayoutEffect(()=>{const c=Zr.current;c!==null&&Qr(c.rail,c.lowRatio,c.highRatio)}),l.useEffect(()=>()=>{zt.current!==null&&clearTimeout(zt.current)},[]);const kr=l.useRef(null),Ar=l.useRef(null),It=l.useRef(null),zo=l.useRef(null),Jr=l.useRef(null),er=l.useCallback(()=>kr.current!==null||Ar.current!==null,[]),ci=c=>{if(i)return;if(C){const ce=Ar.current;if(!ce||c.pointerId!==ce.pointerId||!mt.current)return;const yt=Ir(c.clientX,c.clientY,mt.current.getBoundingClientRect());if(yt===null)return;if(ce.handle==="macro-low"||ce.handle==="macro-high"||ce.handle==="macro-connect"){const[rt,Ge,Ft]=Ws(ce.handle,yt,ce.startPointerRatio,ce.startMacroLowRatio,ce.startMacroHighRatio);Qr("macro",rt,Ge),Ft!==et.current&&(et.current=Ft,je(Ft),Ut(Ft));let At,ht,Bt;if(Zt){const Wt=Bn(ke,te,a,rt,f),an=Math.max(Wt,Bn(ke,te,a,Ge,f));ht=ke[Wt],Bt=ke[an],At=_(te,ht,f)}else At=Wa(rt),ht=ee(te,At,f),Bt=ee(te,Wa(Ge),f);Se.show(ht,Bt);const tr=`${ht.getTime()}_${Bt.getTime()}`;tr!==zo.current&&(zo.current=tr,gr(ht,Bt));const[on,Kl]=Dt(te,h,[ht,Bt],r,n,f),Hn=_(h,on,f),jn=_(h,Kl,f),ki=Re?$o(Hn,jn):[],Ai={kind:"range",min:Hn,max:jn};let pr,vr;if(ce.handle==="macro-connect"){const Wt=At-ce.startMacroLowEnc,an=to("pan",Ai,zi(h,ce.initialMicroLowEnc,te,Wt,f),zi(h,ce.initialMicroHighEnc,te,Wt,f));if(an===null)return;pr=ee(h,an[0],f),vr=ee(h,an[1],f)}else{const Wt=to("resize",Ai,ce.initialMicroLowEnc,ce.initialMicroHighEnc);if(Wt===null)return;pr=ee(h,Wt[0],f),vr=ee(h,Wt[1],f)}const Ni=Qt(pr,ki,Hn,jn),Gl=Math.max(Ni,Qt(vr,ki,Hn,jn));pr=ee(h,Ni,f),vr=ee(h,Gl,f),q.show(pr,vr);const Oi=`${pr.getTime()}_${vr.getTime()}`;Oi!==Jr.current&&(Jr.current=Oi,pt(pr,vr))}else if(ce.handle==="micro-low"||ce.handle==="micro-high"||ce.handle==="micro-connect"||ce.handle==="micro-point"){const[rt,Ge,Ft]=Ks(ce.handle,yt,ce.startPointerRatio,ce.startMicroLowRatio,ce.startMicroHighRatio);Qr("micro",rt,Ge),Ft!==et.current&&(et.current=Ft,je(Ft),Ut(Ft));let At,ht;if(Mt){const tr=Bn(xe,h,a,rt,f),on=Math.max(tr,Bn(xe,h,a,Ge,f));At=xe[tr],ht=xe[on]}else{const tr=Qt(ee(h,Math.round(Ue+rt*$n),f),Er,Ue,at),on=Math.max(tr,Qt(ee(h,Math.round(Ue+Ge*$n),f),Er,Ue,at));At=ee(h,tr,f),ht=ee(h,on,f)}q.show(At,ht);const Bt=`${At.getTime()}_${ht.getTime()}`;Bt!==Jr.current&&(Jr.current=Bt,pt(At,ht))}return}const w=kr.current;if(!w||c.pointerId!==w.pointerId||!mt.current)return;const p=mt.current.getBoundingClientRect(),x=b?c.clientY:c.clientX,N=b?p.height:p.width;if(!(Number.isFinite(N)&&N>0))return;if(w.handle==="connect"){const ce=b?(w.startPointerPos-x)/N:(x-w.startPointerPos)/N,[yt,rt]=Pa(ce,w.startLowRatio,w.startHighRatio);Qr("flat",yt,rt);const Ge=Vs({posDiffPct:ce,startLowVal:w.startLowVal,startHighVal:w.startHighVal,rangeMin:R,rangeMax:E,isDiscrete:ne,sortedAllowedDates:V,snapMode:a,unit:t,yearStartMonth:f});if(It.current&&It.current[0]===Ge[0]&&It.current[1]===Ge[1])return;It.current=Ge,ot(Ge),Jt(Ge[0],Ge[1],!1);return}const B=Ir(c.clientX,c.clientY,p);if(B===null)return;const[Z,X]=oo($?"point":w.handle,B,w.startLowRatio,w.startHighRatio);Qr("flat",Z,X);const me=ko(B*100),[Ee,Ae]=ga(w.handle,me,w.startLowVal,w.startHighVal,R,E,$);if((!It.current||It.current[0]!==Ee||It.current[1]!==Ae)&&(It.current=[Ee,Ae],ot([Ee,Ae]),Jt(Ee,Ae,!1)),!$&&(w.handle==="low"||w.handle==="high")){const ce=po(w.handle,B,w.startLowRatio,w.startHighRatio);Ye.current!==ce&&(Ye.current=ce,Q(ce),ze(ce))}},ui=()=>{li(),zo.current=null,Jr.current=null,Ar.current=null,et.current=null,je(null),Se.release(),q.release(),Ka(Ln.current),Ka(Tn.current)},di=()=>{li();const c=It.current??Ze;c&&(Jt(c[0],c[1],!0),Te(c)),It.current=null,ot(null),kr.current=null,Ye.current=null,Q(null)},mi=c=>{if(C){const p=Ar.current;if(!p||c.pointerId!==p.pointerId)return;ui();return}const w=kr.current;!w||c.pointerId!==w.pointerId||di()},fi=()=>{Ar.current!==null&&ui(),kr.current!==null&&di()},Fo=l.useRef(ci),gi=l.useRef(mi),hi=l.useRef(fi);l.useLayoutEffect(()=>{Fo.current=ci,gi.current=mi,hi.current=fi});const wi=l.useRef(C);l.useEffect(()=>{wi.current!==C&&(wi.current=C,hi.current())},[C]);const bi=Le!==null||Me!==null;l.useEffect(()=>{if(!bi)return;const c=Xr.current?.ownerDocument.defaultView;if(!c)return;const w=x=>Fo.current(x),p=x=>gi.current(x);return c.addEventListener("pointermove",w),c.addEventListener("pointerup",p),c.addEventListener("pointercancel",p),c.addEventListener("lostpointercapture",p),()=>{c.removeEventListener("pointermove",w),c.removeEventListener("pointerup",p),c.removeEventListener("pointercancel",p),c.removeEventListener("lostpointercapture",p)}},[bi]);const Bo=l.useCallback((c,w,p,x)=>{wr(),Ji(c,w),kr.current={pointerId:w,handle:p,startPointerPos:x,startLowVal:ve,startHighVal:ye,startLowRatio:hr(ve)/100,startHighRatio:hr(ye)/100},Ye.current=p,Q(p),p!=="connect"&&ze(p)},[ve,ye,hr]),pi=l.useCallback((c,w,p,x)=>{Y.current.mode==="vernier"&&(wr(),Ji(c,w),Ar.current={pointerId:w,handle:p,startPointerRatio:x,startMacroLowRatio:Et,startMacroHighRatio:Ct,startMicroLowRatio:$r,startMicroHighRatio:qr,startMacroLowEnc:tt,initialMicroLowEnc:Ke,initialMicroHighEnc:it},et.current=p,je(p),Ut(p))},[Et,Ct,$r,qr,tt,Ke,it]),vi=c=>w=>{if(i||er())return;w.stopPropagation(),w.preventDefault(),ze(c);const p=b?w.clientY:w.clientX;Bo(w.currentTarget,w.pointerId,c,p)},xi=c=>()=>{i||Ye.current!==null||ze(c)},In=c=>()=>{i||et.current!==null||Ut(c)},Nr=c=>w=>{if(i||er())return;w.stopPropagation(),w.preventDefault();const p=mt.current;if(!p)return;const x=Ir(w.clientX,w.clientY,p.getBoundingClientRect());x!==null&&pi(w.currentTarget,w.pointerId,c,x)},Rl=c=>{if(i||M||er())return;c.stopPropagation(),c.preventDefault();const w=b?c.clientY:c.clientX;Bo(c.currentTarget,c.pointerId,"connect",w)},Ml=c=>{if(i||er())return;if(C){const X=mt.current;if(!X)return;const me=X.getBoundingClientRect(),Ee=Ir(c.clientX,c.clientY,me);if(Ee===null)return;const Ae=b?c.clientX-(me.left+me.width/2):c.clientY-(me.top+me.height/2),ce=Bs(Ee,Ae,Et,Ct,$r,qr,Ve,void 0,!M,P?"point":"range");pi(c.currentTarget,c.pointerId,ce,Ee),Fo.current(c.nativeEvent);return}const w=ai(c.clientX,c.clientY);if(w===null)return;const p=ko(w);let x="low";if(!$){const X=Math.abs(p-ve),me=Math.abs(p-ye);X<me?x="low":me<X?x="high":x=p>ye?"high":"low"}ze(x);const[N,B]=ga(x,p,ve,ye,R,E,$);ot([N,B]),Jt(N,B,!0);const Z=b?c.clientY:c.clientX;Bo(c.currentTarget,c.pointerId,x,Z)},El=c=>{if(i||C||Le!==null)return;const w=ai(c.clientX,c.clientY);if(w===null)return;const p=ko(w);qe(p),ft(hr(p))},yl=()=>{qe(null),ft(null)},Si=c=>w=>{if(i||er())return;ze(c);const p=_s(w.key,c,ve,ye,R,E,$,1);p&&(w.preventDefault(),wr(),pe||Te(p),Jt(p[0],p[1],!0))},Or=(c,w,p)=>{if(A===null)return;const[x,N]=Dt(te,h,[c,w],r,n,f),B=_(h,x,f),Z=_(h,N,f),X=Re?$o(B,Z):[],me=to(p,{kind:"range",min:B,max:Z},_(h,A[0],f),_(h,A[1],f));if(me===null)return;const Ee=Qt(ee(h,me[0],f),X,B,Z),Ae=Math.max(Ee,Qt(ee(h,me[1],f),X,B,Z));pt(ee(h,Ee,f),ee(h,Ae,f),!0)},kn=c=>w=>{if(i||!C||e.mode!=="vernier"||er())return;Ut(c);let p=0,x=!1,N=!1;switch(w.key){case"ArrowRight":case"ArrowUp":p=1;break;case"ArrowLeft":case"ArrowDown":p=-1;break;case"PageUp":p=5;break;case"PageDown":p=-5;break;case"Home":x=!0;break;case"End":N=!0;break;default:return}if(w.preventDefault(),wr(),c==="macro-low"){const B=ee(te,tt,f),Z=ee(te,lt,f);if(Zt){const Ee=ln(ke,te,B,ke[0],Z,p,x,N,f);if(Ee===Pe(ke,B,te,f))return;const Ae=ke[Ee];gr(Ae,Z,!0),Or(Ae,Z,"resize");return}let X;if(x?X=gt:N?X=lt:X=Math.max(gt,Math.min(lt,tt+p)),X===tt)return;const me=ee(te,X,f);gr(me,Z,!0),Or(me,Z,"resize")}else if(c==="macro-high"){const B=ee(te,tt,f),Z=ee(te,lt,f);if(Zt){const Ee=ln(ke,te,Z,B,ke[ke.length-1],p,x,N,f);if(Ee===Pe(ke,Z,te,f))return;const Ae=ke[Ee];gr(B,Ae,!0),Or(B,Ae,"resize");return}let X;if(x?X=tt:N?X=Tt:X=Math.max(tt,Math.min(Tt,lt+p)),X===lt)return;const me=ee(te,X,f);gr(B,me,!0),Or(B,me,"resize")}else if(c==="micro-low"){const B=ee(h,Ke,f),Z=ee(h,it,f);if(Mt){const me=ln(xe,h,B,xe[0],Z,p,x,N,f);if(me===Pe(xe,B,h,f))return;pt(xe[me],Z,!0);return}let X;if(x?X=Ue:N?X=it:X=Math.max(Ue,Math.min(it,Ke+p)),X===Ke)return;pt(ee(h,X,f),Z,!0)}else if(c==="micro-high"){const B=ee(h,Ke,f),Z=ee(h,it,f);if(Mt){const me=ln(xe,h,Z,B,xe[xe.length-1],p,x,N,f);if(me===Pe(xe,Z,h,f))return;pt(B,xe[me],!0);return}let X;if(x?X=Ke:N?X=at:X=Math.max(Ke,Math.min(at,it+p)),X===it)return;pt(B,ee(h,X,f),!0)}else if(c==="micro-point"){const B=ee(h,Ke,f);if(Mt){const X=ln(xe,h,B,xe[0],xe[xe.length-1],p,x,N,f);if(X===Pe(xe,B,h,f))return;Ga(xe[X],!0);return}let Z;if(x?Z=Ue:N?Z=at:Z=Math.max(Ue,Math.min(at,Ke+p)),Z===Ke)return;Ga(ee(h,Z,f),!0)}},Pl=c=>{if(e.mode!=="vernier")return;if(wr(),Zt){const Z=ke.length-1,X=Pe(ke,mr,te,f),me=Pe(ke,fr,te,f),Ee=me-X;let Ae=X+c,ce=me+c;if(c<0&&Ae<0?(Ae=0,ce=Math.min(Z,Ee)):c>0&&ce>Z&&(ce=Z,Ae=Math.max(0,Z-Ee)),Ae===X&&ce===me)return;const yt=ke[Ae],rt=ke[ce];gr(yt,rt,!0),Or(yt,rt,"pan");return}const w=lt-tt;let p=tt+c,x=lt+c;if(c<0&&p<gt?(p=gt,x=Math.min(Tt,p+w)):c>0&&x>Tt&&(x=Tt,p=Math.max(gt,x-w)),p===tt&&x===lt)return;const N=ee(te,p,f),B=ee(te,x,f);gr(N,B,!0),Or(N,B,"pan")},Wo=l.useCallback(c=>{const w=Y.current;if(!(w.disabled||er()))if(wr(),w.mode==="point"){const p=Math.max(R,Math.min(E,ve+c));pe||Te([p,p]),Jt(p,p,!0)}else if(w.mode==="vernier"){if(Mt){const Ee=xe.length-1,Ae=Pe(xe,yr,h,f),ce=Pe(xe,Pr,h,f),yt=ce-Ae;let rt=Ae+c,Ge=ce+c;c<0&&rt<0?(rt=0,Ge=Math.min(Ee,yt)):c>0&&Ge>Ee&&(Ge=Ee,rt=Math.max(0,Ee-yt)),(rt!==Ae||Ge!==ce)&&pt(xe[rt],xe[Ge],!0);return}const p=Ke,x=it,N=Ue,B=at,Z=x-p;let X=p+c,me=x+c;c<0&&X<N?(X=N,me=Math.min(B,X+Z)):c>0&&me>B&&(me=B,X=Math.max(N,me-Z)),(X!==p||me!==x)&&pt(ee(h,X,f),ee(h,me,f),!0)}else{const p=ye-ve;let x=ve+c,N=ye+c;c<0&&x<R?(x=R,N=Math.min(E,x+p)):c>0&&N>E&&(N=E,x=Math.max(R,N-p)),x<=N&&(pe||Te([x,N]),Jt(x,N,!0))}},[ve,ye,R,E,pe,Jt,pt,Ke,it,Ue,at,h,Mt,xe,yr,Pr,wr,f]),Di=c=>!i&&ta(Xr.current,c),Ri=(c,w)=>{const p=qa.current,x=mt.current,N=Xr.current;if(i||p===null||x===null||N===null||!fc(p,N,Xa.current,b,c,w))return null;const B=x.getBoundingClientRect();return Math.abs(b?c-(B.left+B.width/2):w-(B.top+B.height/2))},Mi=c=>{if(i||er())return;const w=Fs(c.deltaX,c.deltaY,b);if(w===0)return;c.preventDefault();const p=c.target,x=ta(Za.current,p)||ta(Qa.current,p);if(!C||x){Wo(w);return}const N=mt.current;if(!N)return;const B=N.getBoundingClientRect(),Z=b?c.clientX-(B.left+B.width/2):c.clientY-(B.top+B.height/2);if(ka(Z,Ve)==="macro"){Pl(w);return}Wo(w)},An=l.useRef({ownsWheelHit:Di,distanceToRailPx:Ri,stepFromRangeAreaWheel:Mi});l.useLayoutEffect(()=>{An.current={ownsWheelHit:Di,distanceToRailPx:Ri,stepFromRangeAreaWheel:Mi}});const en=l.useRef(null);l.useEffect(()=>{const c=Xr.current?.ownerDocument.defaultView??null,w=en.current;if(w!==null&&w.view===c)return;if(w?.unregister(),c===null){en.current=null;return}const p=hc(c,{ownsHit:x=>An.current.ownsWheelHit(x),distanceToRailPx:(x,N)=>An.current.distanceToRailPx(x,N),step:x=>An.current.stepFromRangeAreaWheel(x)});en.current={view:c,unregister:p}}),l.useEffect(()=>()=>{en.current?.unregister(),en.current=null},[]);const Nn=hr(ve),On=hr(ye),Ko=W(ve),Go=W(ye),qo=Xi(Nn,On,Ho),tn=qo.slant,rn=Le==="low"||Le!=="high"&&Rt==="low",nn=!$&&(Le==="high"||Le!=="low"&&Rt==="high"),$l=_o&&We!=="macro-low",Ll=_o&&We==="macro-low",Tl=Yo&&We!=="micro-low",Cl=Yo&&We==="micro-low",Vr=ia("macro",Et,Ct,jo),_r=ia("micro",$r,qr,Uo),Il=Math.min(Nn,On),kl=Math.max(Nn,On),[Ei,yi]=gn.flat,[Al,Nl]=gn.macro,[Ol,Vl]=gn.micro,Pi=rr(Ei,Nn),$i=rr(yi,On),Xo=rr(Ei,Il),Li=`calc(${rr(yi,kl)} - ${Xo})`,Yr=rr(Al,Et*100),Vn=rr(Nl,Ct*100),Hr=rr(Ol,$r*100),_n=rr(Vl,qr*100),_l=b?{bottom:Xo,height:Li,top:"auto",left:"0",right:"0"}:{left:Xo,width:Li,top:"0",bottom:"0"},Yl=Math.max(.01,Ct-Et),Ti=Math.max(.06,Math.min(.25,.28*Math.sqrt(Yl))),Hl=b?{bottom:Pi,left:"50%",transform:"translate(-50%, 50%)",zIndex:rn?40:30}:{left:Pi,top:"50%",transform:"translate(-50%, -50%)",zIndex:rn?40:30},jl=b?{bottom:$i,left:"50%",transform:"translate(-50%, 50%)",zIndex:nn?40:30}:{left:$i,top:"50%",transform:"translate(-50%, -50%)",zIndex:nn?40:30},Ul=b?{bottom:`${Qe}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Qe}%`,top:"50%",transform:"translate(-50%, -50%)"},Ci=Fe!==null?W(Fe):null,zl=g!=="hover"&&Fe!==null&&(Fe===ve||!$&&Fe===ye),Fl=C?Ke>Fa:ve>R,Bl=C?it<Lo:ye<E,Yn=_c(C?[{side:O?"before":"after",box:ro(ti,ri),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:Vr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Vr.slant.lowOffsetX}},{side:O?"after":"before",box:P?Oo:ro(Oo,ni),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:_r.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:_r.slant.lowOffsetX}}]:[{side:b||m==="top"?"before":"after",box:$?Cr:ro(Cr,ei),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:tn.lowAngleDeg,centreOffsetPx:tn.lowOffsetY,alongPushPx:tn.lowOffsetX}}]),Wl=Yn===void 0?e.style:{...e.style,...Yn.style};l.useLayoutEffect(()=>{Xa.current=Yn===void 0?0:Yn.mainPx});const kt=P?"micro-point":"micro-low",br=i?"cursor-not-allowed opacity-50":"cursor-pointer",Ii=c=>{const w=b?"vertical":"horizontal",p=c==="decrease",x=b?!p:p;return L.jsx(Rr,{ref:p?Za:Qa,neighbour:"rail",direction:Yc[w][c],disabled:i,canStep:p?Fl:Bl,onStep:()=>Wo(p?-1:1),ariaLabel:p?K.decrease:K.increase,className:`period-slider-stepper-btn ${Hc[w][c]} ${Qi[w][x?"leading":"trailing"]}`})};return L.jsxs("div",{ref:Xr,style:Wl,className:`period-slider grid select-none place-items-center ${jc[b?"vertical":"horizontal"][d?"withSteppers":"railOnly"]} ${s}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":m,"data-color-scheme":u,children:[L.jsx("div",{ref:qa,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),d&&Ii(b?"increase":"decrease"),L.jsx("div",{ref:mt,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":C?Ve:void 0,className:`period-slider-track relative touch-none rounded-full ${Qi[b?"vertical":"horizontal"][d?"rail":"railOnly"]} ${br}`,onPointerDown:Ml,onPointerMove:El,onPointerLeave:yl,children:C?L.jsxs(L.Fragment,{children:[Je&&(b?L.jsxs("svg",{className:"period-slider-vernier-projection is-vertical",role:"presentation","aria-hidden":"true",width:"32",height:"100%",viewBox:"0 0 32 100",preserveAspectRatio:"none",children:[L.jsx("defs",{children:L.jsxs("linearGradient",{id:de,x1:"0",y1:"0",x2:"1",y2:"0",children:[L.jsx("stop",{offset:"0%",stopColor:O?H.macro:H.micro,stopOpacity:"0.28"}),L.jsx("stop",{offset:"100%",stopColor:O?H.micro:H.macro,stopOpacity:Ti})]})}),L.jsx("path",{ref:Ao,"data-testid":"period-slider-vernier-projection",d:ea(Et,Ct,b,O),fill:`url(#${de})`})]}):L.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[L.jsx("defs",{children:L.jsxs("linearGradient",{id:de,x1:"0",y1:"0",x2:"0",y2:"1",children:[L.jsx("stop",{offset:"0%",stopColor:O?H.macro:H.micro,stopOpacity:"0.28"}),L.jsx("stop",{offset:"100%",stopColor:O?H.micro:H.macro,stopOpacity:Ti})]})}),L.jsx("path",{ref:Ao,"data-testid":"period-slider-vernier-projection",d:ea(Et,Ct,b,O),fill:`url(#${de})`})]})),!M&&L.jsxs(L.Fragment,{children:[L.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${Yr} - 8px)`,height:`calc(${Vn} - ${Yr} + 16px)`}:{left:`calc(${Yr} - 8px)`,width:`calc(${Vn} - ${Yr} + 16px)`},onPointerDown:Nr("macro-connect")}),!P&&L.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${Hr} - 8px)`,height:`calc(${_n} - ${Hr} + 16px)`}:{left:`calc(${Hr} - 8px)`,width:`calc(${_n} - ${Hr} + 16px)`},onPointerDown:Nr("micro-connect")})]}),Lt&&L.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(c=>L.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`macro-tick-${c}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(c=>L.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`micro-tick-${c}`))]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":ul,"aria-valuemax":lt,"aria-valuenow":tt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(mr,te,"period"):xr(te,mr,j,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:Yr,left:O?0:"auto",right:O?"auto":0,transform:O?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Me==="macro-low"||We==="macro-low"?30:15}:{left:Yr,top:O?0:"auto",bottom:O?"auto":0,transform:O?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Me==="macro-low"||We==="macro-low"?30:15},onPointerDown:Nr("macro-low"),onKeyDown:kn("macro-low"),onFocus:In("macro-low"),"data-active":Me==="macro-low"?"true":void 0,"data-front":We==="macro-low"?"true":void 0,"data-vernier-pos":b?O?"left":"right":O?"top":"bottom","data-handle-type":"macro-low",children:[L.jsx(mn,{type:"macro",isTop:O,isVertical:b,isLeft:O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":$l?"true":void 0,"data-slanted":Vr.slant.isSlanted?"true":void 0,ref:gl,style:Vr.lowStyle,children:st(te,mr,j,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":tt,"aria-valuemax":dl,"aria-valuenow":lt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(fr,te,"period"):xr(te,fr,j,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:Vn,left:O?0:"auto",right:O?"auto":0,transform:O?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:Me==="macro-high"||We==="macro-high"?30:15}:{left:Vn,top:O?0:"auto",bottom:O?"auto":0,transform:O?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:Me==="macro-high"||We==="macro-high"?30:15},onPointerDown:Nr("macro-high"),onKeyDown:kn("macro-high"),onFocus:In("macro-high"),"data-active":Me==="macro-high"?"true":void 0,"data-front":We==="macro-high"?"true":void 0,"data-vernier-pos":b?O?"left":"right":O?"top":"bottom","data-handle-type":"macro-high",children:[L.jsx(mn,{type:"macro",isTop:O,isVertical:b,isLeft:O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Ll?"true":void 0,"data-slanted":Vr.slant.isSlanted?"true":void 0,ref:hl,style:Vr.highStyle,children:st(te,fr,j,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":P?K.microSelectedDate:K.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Fa,"aria-valuemax":P?Lo:it,"aria-valuenow":Ke,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(yr,h,"period"):xr(h,yr,le,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:Hr,left:O?"auto":0,right:O?0:"auto",transform:O?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Me===kt||We===kt?30:20}:{left:Hr,top:O?"auto":0,bottom:O?0:"auto",transform:O?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Me===kt||We===kt?30:20},onPointerDown:Nr(kt),onKeyDown:kn(kt),onFocus:In(kt),"data-active":Me===kt?"true":void 0,"data-front":We===kt?"true":void 0,"data-vernier-pos":b?O?"right":"left":O?"bottom":"top","data-handle-type":kt,children:[L.jsx(mn,{type:"micro",isTop:!O,isVertical:b,isLeft:!O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Tl?"true":void 0,"data-slanted":_r.slant.isSlanted?"true":void 0,ref:wl,style:_r.lowStyle,children:st(h,yr,le,D)})]}),!P&&L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Ke,"aria-valuemax":Lo,"aria-valuenow":it,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Pr,h,"period"):xr(h,Pr,le,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?O?"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:-right-4 after:left-0":"after:absolute after:inset-y-[calc((100%-var(--ps-target-size))/2)] after:right-0 after:-left-4":O?"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:top-0 after:-bottom-4":"after:absolute after:inset-x-[calc((100%-var(--ps-target-size))/2)] after:-top-4 after:bottom-0"} after:content-[''] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 dark:focus-visible:ring-blue-400 ${br}`,style:b?{bottom:_n,left:O?"auto":0,right:O?0:"auto",transform:O?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:Me==="micro-high"||We==="micro-high"?30:20}:{left:_n,top:O?"auto":0,bottom:O?0:"auto",transform:O?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:Me==="micro-high"||We==="micro-high"?30:20},onPointerDown:Nr("micro-high"),onKeyDown:kn("micro-high"),onFocus:In("micro-high"),"data-active":Me==="micro-high"?"true":void 0,"data-front":We==="micro-high"?"true":void 0,"data-vernier-pos":b?O?"right":"left":O?"bottom":"top","data-handle-type":"micro-high",children:[L.jsx(mn,{type:"micro",isTop:!O,isVertical:b,isLeft:!O}),jt&&L.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-duplicate":Cl?"true":void 0,"data-slanted":_r.slant.isSlanted?"true":void 0,ref:bl,style:_r.highStyle,children:st(h,Pr,le,D)})]})]}):L.jsxs(L.Fragment,{children:[!M&&L.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:_l,onPointerDown:Rl}),U&&ne&&V.length>1&&L.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:V.map((c,w)=>{const p=_(t,c,f),x=hr(w),N=b?{bottom:`${x}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${x}%`,top:"50%",transform:"translate(-50%, -50%)"};return L.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:N},`tick-${p}`)})}),!i&&Fe!==null&&Qe!==null&&Le===null&&Ci&&L.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Ul,children:[L.jsx("div",{"data-testid":"period-slider-hover-dot",className:"period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-[var(--aqps-accent-light)] shadow-[0_0_6px_var(--aqps-accent-glow)] dark:border-slate-800"}),L.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":zl?"true":void 0,className:`period-slider-hover-tooltip ${m==="bottom"&&!b?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:st(t,Ci,e.formatLabel,D)})]}),L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":$?K.selectedDate:K.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":R,"aria-valuemax":$?E:ye,"aria-valuenow":ve,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Ko,t,"period"):xr(t,Ko,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${br}`,style:Hl,onPointerDown:vi("low"),onKeyDown:Si("low"),onFocus:xi("low"),"data-active":Le==="low"?"true":void 0,"data-front":rn?"true":void 0,children:[L.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${Le==="low"?"":"shadow-md"}`}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":m,"data-slanted":tn.isSlanted?"true":void 0,"data-front":rn?"true":void 0,"data-duplicate":Vo&&!rn?"true":void 0,ref:ml,style:qo.lowStyle,children:st(t,Ko,e.formatLabel,D)})]}),!$&&L.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":K.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":ve,"aria-valuemax":E,"aria-valuenow":ye,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Go,t,"period"):xr(t,Go,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${br}`,style:jl,onPointerDown:vi("high"),onKeyDown:Si("high"),onFocus:xi("high"),"data-active":Le==="high"?"true":void 0,"data-front":nn?"true":void 0,children:[L.jsx("div",{"data-testid":"period-slider-knob",className:`period-slider-knob h-full w-full rounded-full border-2 border-white bg-[var(--aqps-accent-color)] group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-[var(--aqps-accent-light)] dark:group-focus-visible:ring-blue-400 ${Le==="high"?"":"shadow-md"}`}),g!=="hover"&&L.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":m,"data-slanted":tn.isSlanted?"true":void 0,"data-front":nn?"true":void 0,"data-duplicate":Vo&&!nn?"true":void 0,ref:fl,style:qo.highStyle,children:st(t,Go,e.formatLabel,D)})]})]})}),d&&Ii(b?"decrease":"increase")]})},nt=e=>e.getTime(),qs=(e,t)=>!(Pt(e)&&Pt(t))||e.length!==2||t.length!==2?!1:xt(e[0],nt)===xt(t[0],nt)&&xt(e[1],nt)===xt(t[1],nt),Wn=(e,t)=>e===void 0||t===void 0?e===t:qs(e,t),sa=(e,t)=>{if(e===t)return!0;if(!(Pt(e)&&Pt(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(xt(e[r],nt)!==xt(t[r],nt))return!1;return!0},Xs=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),n=Object.keys(t);if(r.length!==n.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},zc=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||xt(e.minDate,nt)!==xt(t.minDate,nt)||xt(e.maxDate,nt)!==xt(t.maxDate,nt)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.isVertical!==t.isVertical||e.hideConnectBar!==t.hideConnectBar||e.showTicks!==t.showTicks||e.disabled!==t.disabled||e.showStepper!==t.showStepper||e.debounceMs!==t.debounceMs||e.tooltipStyle!==t.tooltipStyle||e.colorScheme!==t.colorScheme||e.className!==t.className||!Xs(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!sa(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(dt(e.value,nt)!==dt(t.value,nt)||dt(e.defaultValue,nt)!==dt(t.defaultValue,nt)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!Wn(e.range,t.range)||!Wn(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!Wn(e.microRange,t.microRange)||!Wn(e.defaultMicroRange,t.defaultMicroRange)||dt(e.microValue,nt)!==dt(t.microValue,nt)||dt(e.defaultMicroValue,nt)!==dt(t.defaultMicroValue,nt)||!qs(e.macroRange,t.macroRange)||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroPoint!==t.onChangeMicroPoint||e.onChangeMacroRange!==t.onChangeMacroRange||!sa(e.macroAllowedDates,t.macroAllowedDates)||!sa(e.microAllowedDates,t.microAllowedDates)):!1,Zs=l.memo(Uc,zc);Zs.displayName="PeriodSlider";const es=2,Ie=-1,vt=e=>_("day",e),Sn=e=>ee("day",e),cn=e=>`${Ro(e.getFullYear())}-${String(e.getMonth()+1).padStart(es,"0")}-${String(e.getDate()).padStart(es,"0")}`,Fc=(e,t,r,n)=>{const o=vt(e),a=vt(t),i=a>=o?a-o+1:0,s=g=>Sn(a-g),d={kind:"range",min:o,max:a};return{count:i,dateAt:s,labelAt:g=>st("day",s(g),n,r),indexOf:g=>{const m=vt(g);return m<o||m>a?Ie:a-m},nearestIndexOf:g=>{if(i===0)return Ie;const m=pn(d,vt(g));return m===null?Ie:a-m}}},Bc=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,s=v=>e[n-v],d={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},g=v=>{const b=v.getTime();let M=r,U=n;for(;M<=U;){const u=M+U>>1,D=e[u].getTime();if(D===b)return n-u;D<b?M=u+1:U=u-1}return Ie},m=v=>v===null?Ie:g(Sn(v));return{count:i,dateAt:s,labelAt:v=>st("day",s(v),a,o),indexOf:g,nearestIndexOf:v=>m(pn(d,vt(v)))}},Wc={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${S(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${S(e)})`)},indexOf:()=>Ie,nearestIndexOf:()=>Ie},Kc=(e,t,r)=>{const n=s=>{let d=0,g=e.length;for(;d<g;){const m=d+g>>1;e[m].getTime()<s?d=m+1:g=m}return d},o=s=>{let d=0,g=e.length;for(;d<g;){const m=d+g>>1;e[m].getTime()<=s?d=m+1:g=m}return d},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},Gc=(e,t)=>{const r=new Map;for(let n=0;n<e.length;n++){const o=e[n];t(n,o);const a=new Date(o);a.setHours(0,0,0,0);const i=a.getTime();r.has(i)||r.set(i,a)}return Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},qc={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},Xc={month:2,day:2},ts={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},rs=new Map,Zc=(e,t)=>{const r=`${e}\0${t}`,n=rs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,qc[e]);return rs.set(r,o),o},Qc=(e,t,r)=>r!==void 0?Zc(e,r).format(t):e==="year"?Ro(ts.year(t)):String(ts[e](t)).padStart(Xc[e],"0"),Qs=(e,t,r,n)=>{if(t!=="year"&&t!=="month"&&t!=="day")throw new RangeError(`formatOptionText: unit must be "year", "month" or "day" (received: ${S(t)})`);if(r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${S(r)})`);return $e(e)?r==="part"?Qc(t,e,n):st(t,e,void 0,n):""},Js=(e,t)=>t(e).getTime(),Aa=(e,t,r)=>{const n=a=>Js(a,r),o=a=>a.value!==void 0?a.value:a.initialDate;return dt(o(e),n)!==dt(o(t),n)||t.value!==void 0&&Number.isNaN(dt(t.initialDate,n))||dt(e.minDate,n)!==dt(t.minDate,n)?!1:dt(e.maxDate,n)===dt(t.maxDate,n)},ns=Symbol("nothing handed");class Jc{held;writeCount=0;handed=ns;constructor(t){this.held=t}get current(){return this.held}set current(t){this.held=t,this.writeCount+=1}get writes(){return this.writeCount}hand(t){this.handed=t}get holdsHanded(){return this.handed===this.held}forgetHandedUnless(t){this.handed!==t&&(this.handed=ns)}commit(t,r){this.writeCount===r&&(this.held=t)}}function Xe(e){const[t]=l.useState(()=>new Jc(e)),r=t.writes;return l.useInsertionEffect(()=>{t.commit(e,r)}),t}const eu={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},tu=["shift","start","end","single"],ru=["disable","clamp"],nu=["follow","keep"],os={day:{day:1},month:{month:1,year:12},year:{year:1}},as=new WeakMap,ha=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${S(r)})`)},is=(e,t,r,n)=>{for(const[o,a]of Object.entries(r))if(!(a===void 0||n.includes(o)))throw new RangeError(`${e}: ${t}.${o} is not read here; the accepted keys are ${n.map(i=>`"${i}"`).join(", ")} (received: ${S(a)})`)},Mr=(e,t,r,n)=>{ha(e,t,r),is(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];ha(e,a,i),is(e,a,i,eu[n]);const{motion:s,edge:d,window:g}=i;if(n!=="vernierPoint"&&(typeof s!="string"||!tu.includes(s)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${S(s)})`);if(d!==void 0){if(s!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${S(d)} with motion ${S(s)})`);if(typeof d!="string"||!ru.includes(d))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${S(d)})`)}if(g!==void 0&&(typeof g!="string"||!nu.includes(g)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${S(g)})`)}},Na=e=>{if(typeof e!="object"||e===null)return{field:"stepper",expected:"an object",received:S(e)};const{onStep:t,canStepPrevious:r,canStepNext:n}=e;return typeof t!="function"?{field:"stepper.onStep",expected:"a function",received:S(t)}:typeof r!="boolean"?{field:"stepper.canStepPrevious",expected:"a boolean",received:S(r)}:typeof n!="boolean"?{field:"stepper.canStepNext",expected:"a boolean",received:S(n)}:null},Gt=(e,t,r,n,o)=>{if(!$e(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${S(r)})`);return ut(e,t,r,n,o,"")},so=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${S(r)})`)},el=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=as.get(r),s=i?.get(a);if(s!==void 0)return s;const d=[];for(let m=0;m<r.length;m++)d.push(Gt(e,`${t}[${m}]`,r[m],n,o));const g=Array.from(new Set(d)).sort((m,v)=>m-v);return i===void 0?as.set(r,new Map([[a,g]])):i.set(a,g),g},ou=(e,t)=>t===1?Jn(e):{stepEnd:(r,n)=>Qn(e,r+t*n,n),edge:r=>wn(e,r)},wa=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},ba=(e,t,r,n,o,a)=>{if(a){const d=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:ee(n,e[0],o);return Number.isNaN(d.getTime())?null:[d,d]}const i=e[0]===t[0]?r[0]:ee(n,e[0],o),s=e[1]===t[1]?r[1]:ee(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(s.getTime())?null:[i,s.getTime()<i.getTime()?i:s]},pa=e=>{const t="resolveSelectorSteps";ha(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:s,rules:d}=e;so(t,"unit",o);const g=e.stepUnit===void 0?o:e.stepUnit;so(t,"stepUnit",g);const m=os[o][g];if(m===void 0){const P=Object.keys(os[o]).map(K=>`"${K}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${P} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${S(g)})`)}const v=dr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${S(n)})`);if(!Pt(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${S(r)})`);Mr(t,"rules",d,"motion");const b=Gt(t,"selection[0]",r[0],o,v),M=Gt(t,"selection[1]",r[1],o,v);if(M<b)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${S(r[0])}, end: ${S(r[1])})`);const U=a===void 0?null:Gt(t,"minDate",a,o,v),u=i===void 0?null:Gt(t,"maxDate",i,o,v);if(U!==null&&u!==null&&u<U)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${S(a)}, maxDate: ${S(i)})`);Ea(t,"allowedDates",s);const D=s===void 0?{kind:"range",min:U,max:u}:Gr(el(t,"allowedDates",s,o,v),U,u),f=ou(D,m),z=(P,K)=>{const H=ma(f,b,M,P,wa(K,n));return H===null?null:ba(H,[b,M],r,o,v,K.motion==="single")};return{previous:z(-1,d.previous),next:z(1,d.next)}},Vt=(e,t)=>{const r=Xe({targets:e,onStepTo:t}),n=l.useCallback(i=>{const{targets:s,onStepTo:d}=r.current,g=s[i];g!==null&&d(g,i)},[]),o=e.previous!==null,a=e.next!==null;return l.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function Oa(e,t,r,n){const o=t?null:Js(e,r),[a,i]=l.useState(()=>({source:o,held:n(e)})),s=l.useCallback(g=>i(m=>({source:m.source,held:g})),[]);if(a.source===o)return[a.held,s];const d=o===null?{source:o,held:a.held}:{source:o,held:n(e)};return i(d),[d.held,s]}const no=44,ss=7,Kn=8,au=2,tl=10,iu=1e3,va=8,la=6,ca=4,ua=12,un=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),vt(r)},su=(e,t)=>{if(e.length<ca||t.count===0)return Ie;const r=Number(e.slice(0,ca));if(!Number.isInteger(r))return Ie;const n=e.length>=la,o=n?Number(e.slice(ca,la)):ua;if(o<1||o>ua)return Ie;const a=e.length>=va,i=a?Number(e.slice(la,va)):0,s=un(r,o),d=(o===ua?un(r+1,1):un(r,o+1))-1,g=a?s+i-1:n?s:un(r,1),m=a?g:n?d:un(r+1,1)-1;if(a&&(i<1||g>d))return Ie;for(let v=m;v>=g;v--){const b=t.indexOf(Sn(v));if(b!==Ie)return b}return Ie},lu=e=>e.closest(".dark")===null?"light":"dark",cu=(e,t,r,n)=>{const o=r-e.bottom-Kn,a=e.top-Kn,i=o>=t||o>=a,d=Math.max(no,Math.min(t,i?o:a)),g=i?e.bottom:e.top-d,m=e.width+tl,v=Math.max(Kn,Math.min(e.left,n-m-Kn));return{top:g,left:v,width:m,height:d}},rl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:s,labels:d,onCommitIndex:g,controlClassName:m})=>{const v=l.useId(),b=l.useMemo(()=>ic(d),[d]),M=`period-slider-date-listbox-${v}`,U=I=>`period-slider-date-option-${v}-${I}`,[u,D]=l.useState(!1),[f,z]=l.useState(Ie),[P,K]=l.useState(!0),[H,de]=l.useState(null),[Y,re]=l.useState(null),oe=l.useRef(null),V=l.useRef(null),ne=l.useRef(null),R=l.useRef({buffer:"",at:0}),E=l.useRef(e);E.current=e;const $=e.count,W=Math.min($,ss)*no,J=Math.max(1,Math.min($,ss)),F=l.useCallback(()=>{const I=oe.current;if(I===null)return;const he=I.getBoundingClientRect();de(cu(he,W,window.innerHeight,window.innerWidth))},[W]),G=l.useCallback(()=>{D(!1),z(Ie),R.current={buffer:"",at:0}},[]),k=l.useCallback(I=>{a||$===0||(z(I),D(!0))},[a,$]);l.useLayoutEffect(()=>{if(!u){de(null),re(null);return}const I=oe.current;return I!==null&&re(lu(I)),F(),window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),()=>{window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)}},[u,F]),l.useEffect(()=>{if(!u)return;const I=he=>{const fe=he.target;fe!==null&&V.current?.contains(fe)!==!0&&oe.current?.contains(fe)!==!0&&G()};return document.addEventListener("pointerdown",I,!0),()=>document.removeEventListener("pointerdown",I,!0)},[u,G]);const ie=l.useRef(f);ie.current=f,l.useEffect(()=>{u&&(a||$===0)&&G()},[u,a,$,G]),l.useEffect(()=>{if(!u)return;const I=ie.current;if(I===Ie)return;const he=Math.min(I,$-1);he!==I&&z(he),ne.current?.scrollToIndex(he,{align:"center"})},[$,u]);const we=I=>{if($===0)return;const he=Math.max(0,Math.min(I,$-1));z(he),ne.current?.scrollToIndex(he,{align:"center"})},Se=I=>{I<0||I>=$||(g(I),G(),oe.current?.focus())},q=I=>{if(a)return;const he=f!==Ie?f:t!==Ie?t:r;switch(I.key){case"ArrowDown":if(I.preventDefault(),!u){k(he);return}we(he+1);return;case"ArrowUp":if(I.preventDefault(),!u){k(he);return}we(he-1);return;case"Home":if(!u)return;I.preventDefault(),we(0);return;case"End":if(!u)return;I.preventDefault(),we($-1);return;case"PageDown":if(!u)return;I.preventDefault(),we(he+J);return;case"PageUp":if(!u)return;I.preventDefault(),we(he-J);return;case"Enter":if(I.preventDefault(),!u){k(he);return}Se(f!==Ie?f:he);return;case"Escape":if(!u)return;I.preventDefault(),G();return;case"Tab":u&&G();return}if(I.key.length!==1)return;const fe=I.key>="0"&&I.key<="9",De=I.key==="-"||I.key==="/"||I.key===".";if(!(fe||De))return;I.preventDefault();const be=Date.now(),pe=be-R.current.at>iu?"":R.current.buffer,Oe=fe?`${pe}${I.key}`.slice(0,va):pe;R.current={buffer:Oe,at:be};const Te=su(Oe,E.current);if(Te!==Ie){if(!u){k(Te);return}we(Te)}},A=l.useCallback(I=>I,[]),ge=l.useCallback(()=>no,[]),ue=l.useCallback(I=>{const he=ie.current;K(he===Ie||he>=I.renderingStartIndex&&he<=I.renderingEndIndex)},[]),ae=u&&H!==null&&Y!==null&&$>0?L.jsx("div",{ref:V,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":Y,style:{top:H.top,left:H.left,width:H.width,height:H.height},onMouseDown:I=>{I.preventDefault()},children:L.jsx(lr.VirtualScroll,{ref:ne,itemCount:$,getItem:A,getItemHeight:ge,viewportSize:H.height-au,initialScrollIndex:f!==Ie?f:void 0,onRangeChange:ue,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:s,labels:b,contentProps:{id:M,role:"listbox","aria-label":i},scrollBarOptions:{width:tl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:I=>{const he=I===t,fe=I===f;return L.jsx("div",{id:U(I),role:"option","aria-selected":he,"aria-posinset":I+1,"aria-setsize":$,"data-testid":"period-slider-date-option","data-active":fe?"true":void 0,className:"period-slider-date-option",style:{height:no},onClick:()=>Se(I),children:E.current.labelAt(I)})}})}):null;return L.jsxs(L.Fragment,{children:[L.jsx("input",{ref:oe,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":u,"aria-controls":u?M:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":u&&f!==Ie&&P?U(f):void 0,disabled:a,value:n,className:m,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:q,onMouseDown:I=>{a||(I.preventDefault(),oe.current?.focus(),u?G():k(t!==Ie?t:r))},onBlur:()=>{u&&G()}}),ae===null?null:Xl.createPortal(ae,document.body)]})};rl.displayName="VirtualDateDropdown";const Kt=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},uu='; leave the bound out where the variant allows it, or declare the days to offer with `minYear` / `maxYear` or `allowedDates`, instead of a sentinel for "no bound"',du='; variant="split-dropdown" requires both bounds, so declare the years to offer with `minYear` / `maxYear` instead of a sentinel for "no bound"',mu=31,dn=(e,t,r)=>{if(!$e(t))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${S(t)})`);if(Number.isNaN(Kt(t).getTime()))throw new RangeError(`DateSelector: "${e}" must fall on a day that starts inside the Date range (received ${S(t)})${r}`)},fu=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "formatLocale" must be a valid BCP 47 language tag (received ${S(e)})`)}},or=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},fn=e=>or(e,1,1),ls=e=>or(e,12,31),nl=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,cs=(e,t,r,n)=>nl(e,t,r)&&e.getDate()===n,Va=e=>!Number.isNaN(fn(e.getFullYear()).getTime()),gu=e=>Va(e)?Kt(e):new Date(Number.NaN),Gn=(e,t,r)=>{if(!Va(t))throw new RangeError(`DateSelector: "${e}" must fall in a year that starts inside the Date range, because variant="split-dropdown" draws its year (received ${S(t)})${r}`)},us=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const s=r(i);if(Number.isNaN(s.getTime()))break;n(s,i)&&a.push({value:i,label:o(s)})}return a},hu=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:s,minDate:d,maxDate:g,allowedDates:m,variant:v="date",className:b="",style:M,disabled:U=!1,locale:u,labels:D,formatLocale:f,formatOption:z}=e;fu(f);const P=v==="split-dropdown"?du:uu;if(t!==void 0&&dn("value",t,""),r!==void 0&&dn("initialDate",r,""),d!==void 0&&dn("minDate",d,P),g!==void 0&&dn("maxDate",g,P),v==="split-dropdown"&&(t!==void 0&&Gn("value",t,""),r!==void 0&&Gn("initialDate",r,""),d!==void 0&&Gn("minDate",d,P),g!==void 0&&Gn("maxDate",g,P)),i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${S(i)})`);if(s!==void 0&&!Number.isInteger(s))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${S(s)})`);if(i!==void 0&&Number.isNaN(fn(i).getTime()))throw new RangeError(`DateSelector: "minYear" must name a year whose first day is inside the Date range (received ${S(i)})`);if(s!==void 0&&Number.isNaN(ls(s).getTime()))throw new RangeError(`DateSelector: "maxYear" must name a year whose last day is inside the Date range (received ${S(s)})`);if(v==="split-dropdown"&&m!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');if(!wo(m))throw new RangeError(`DateSelector: "allowedDates" must be an array of Dates (received ${S(m)})`);const K=t??r;if(K===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");if(o!==void 0){const T=Na(o);if(T!==null)throw new RangeError(`DateSelector: "${T.field}" must be ${T.expected} (received ${T.received})`);if(t===void 0)throw new RangeError('DateSelector: "stepper" requires the controlled "value"; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled "initialDate" would never change')}const H=So(u,D),de=t!==void 0,[Y,re]=Oa(K,de,Kt,Kt),oe=t?.getTime(),V=l.useMemo(()=>t!==void 0?Kt(t):Y,[oe,Y]);if(v==="split-dropdown"&&!de&&!Va(V))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${S(V)}), because that selection's year starts outside the Date range; control the date with "value" to decide what the split dropdown holds`);const ne=d?.getTime(),R=g?.getTime(),E=l.useMemo(()=>{const T=d?Kt(d):null,C=i!==void 0?fn(i):null;return T===null?C:C===null||T.getTime()>=C.getTime()?T:C},[ne,i]),$=l.useMemo(()=>{const T=g?Kt(g):null,C=s!==void 0?ls(s):null;return T===null?C:C===null||T.getTime()<=C.getTime()?T:C},[R,s]),W=E?.getTime()??null,J=$?.getTime()??null;if(E!==null&&$!==null&&E.getTime()>$.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${cn(E)} is after max ${cn($)})`);if(v!=="date"&&m===void 0&&(E===null||$===null))throw new RangeError(`DateSelector: variant=${S(v)} needs a bounded range; supply minDate/minYear and maxDate/maxYear${v==="dropdown"?' or supply "allowedDates"':""}`);const F=l.useMemo(()=>m===void 0?null:m.map(T=>xt(T,C=>C.getTime())).join(","),[m]),G=l.useMemo(()=>{if(m===void 0)return null;const T=Gc(m,(C,Ve)=>dn(`allowedDates[${C}]`,Ve,""));return{ascending:T,ascendingSerials:T.map(vt)}},[F]),k=l.useMemo(()=>G===null?null:{...G,...Kc(G.ascending,E,$)},[G,W,J]),ie=l.useMemo(()=>k!==null?Bc(k.ascending,k.ascendingSerials,k.loIndex,k.hiIndex,f,z):E===null||$===null?Wc:Fc(E,$,f,z),[k,W,J,f,z]),we=l.useMemo(()=>k!==null?{kind:"candidates",ascending:k.ascendingSerials,loIndex:k.loIndex,hiIndex:k.hiIndex}:{kind:"range",min:E===null?null:vt(E),max:$===null?null:vt($)},[k,W,J]),Se=T=>!Number.isNaN(T.getTime())&&bn(we,vt(T)),q=T=>{if(U)return;const C=Kt(T);Se(C)&&(de||re(C),n?.(C))},A=V.getTime(),ge=Se(V),ue=l.useMemo(()=>{const T=Xt(we,vt(V),-1);if(T===null)return null;const C=Sn(T);return Number.isNaN(C.getTime())?null:C},[we,A]),ae=l.useMemo(()=>{const T=Xt(we,vt(V),1);if(T===null)return null;const C=Sn(T);return Number.isNaN(C.getTime())?null:C},[we,A]),I=()=>{if(o!==void 0){o.onStep("previous");return}ue!==null&&q(ue)},he=()=>{if(o!==void 0){o.onStep("next");return}ae!==null&&q(ae)},fe=T=>{if(T.target.value){const C=ql.parseISO(T.target.value);Number.isNaN(C.getTime())||q(C)}},De=V.getFullYear(),be=V.getMonth()+1,pe=V.getDate(),Oe=l.useCallback((T,C)=>z?z(C,T,"part"):Qs(C,T,"part",f),[z,f]),Te=l.useMemo(()=>{if(v!=="split-dropdown"||E===null||$===null)return[];const T=[];for(let C=$.getFullYear();C>=E.getFullYear();C--)T.push({value:C,label:Oe("year",fn(C))});return T},[v,W,J,Oe]),Ze=l.useMemo(()=>{if(v!=="split-dropdown"||E===null||$===null)return[];const T=E,C=$,Ve=De===T.getFullYear()?T.getMonth()+1:1,O=De===C.getFullYear()?C.getMonth()+1:12;return us(Ve,O,Je=>or(De,Je,1),(Je,Lt)=>nl(Je,De,Lt),Je=>Oe("month",Je))},[v,W,J,De,Oe]),ot=l.useMemo(()=>{if(v!=="split-dropdown"||E===null||$===null)return[];const T=E,C=$,Ve=De===T.getFullYear()&&be===T.getMonth()+1?T.getDate():1,O=De===C.getFullYear()&&be===C.getMonth()+1?C.getDate():mu;return us(Ve,O,Je=>or(De,be,Je),(Je,Lt)=>cs(Je,De,be,Lt),Je=>Oe("day",Je))},[v,W,J,De,be,Oe]),Le=(T,C,Ve)=>{const O=or(T,C,Ve);return cs(O,T,C,Ve)&&Se(O)},Q=(T,C,Ve)=>{Le(T,C,Ve)&&q(or(T,C,Ve))},Ye=Te.some(T=>T.value===De),Rt=Ze.some(T=>T.value===be),ze=ot.some(T=>T.value===pe),Fe=cn(V),qe=v==="dropdown"?st("day",V,z,f):"",Qe=E?cn(E):void 0,ft=$?cn($):void 0,ve="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400";return L.jsxs("div",{className:`inline-flex items-center ${hn} ${b}`,style:M,"data-variant":v,"data-out-of-range":ge?void 0:"true",children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:U,canStep:o===void 0?ue!==null:o.canStepPrevious,onStep:I,ariaLabel:H.previousDay}),v==="dropdown"?L.jsx(rl,{domain:ie,selectedIndex:ge?ie.indexOf(V):Ie,openAnchorIndex:ie.nearestIndexOf(V),displayLabel:qe,machineValue:Fe,disabled:U,ariaLabel:H.dateSelect,locale:u,labels:H,onCommitIndex:T=>q(ie.dateAt(T)),controlClassName:"period-slider-date-combobox-field w-28 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500"}):v==="split-dropdown"?L.jsxs("div",{className:"inline-flex items-center gap-1",children:[L.jsxs("select",{"aria-label":H.splitYear,disabled:U,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Ye?De:"",onChange:T=>Q(Number(T.target.value),be,pe),children:[Ye?null:L.jsx("option",{value:"",disabled:!0,className:ve,children:Oe("year",fn(De))}),Te.map(T=>L.jsx("option",{value:T.value,disabled:!Le(T.value,be,pe),className:"dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]}),L.jsxs("select",{"aria-label":H.splitMonth,disabled:U,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Rt?be:"",onChange:T=>Q(De,Number(T.target.value),pe),children:[Rt?null:L.jsx("option",{value:"",disabled:!0,className:ve,children:Oe("month",or(De,be,1))}),Ze.map(T=>L.jsx("option",{value:T.value,disabled:!Le(De,T.value,pe),className:"dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]}),L.jsxs("select",{"aria-label":H.splitDay,disabled:U,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:ze?pe:"",onChange:T=>Q(De,be,Number(T.target.value)),children:[ze?null:L.jsx("option",{value:"",disabled:!0,className:ve,children:Oe("day",or(De,be,pe))}),ot.map(T=>L.jsx("option",{value:T.value,disabled:!Le(De,be,T.value),className:"dark:bg-slate-700 dark:text-slate-100",children:T.label},T.value))]})]}):L.jsx("input",{"aria-label":H.dateSelect,disabled:U,className:"period-slider-native-date-field w-28 rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500 dark:placeholder:text-gray-400",value:Fe,min:Qe,max:ft,onChange:fe,type:"date"}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:U,canStep:o===void 0?ae!==null:o.canStepNext,onStep:he,ariaLabel:H.nextDay}),a]})},wu=(e,t)=>!(!Aa(e,t,t.variant==="split-dropdown"?gu:Kt)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),ol=l.memo(hu,wu);ol.displayName="DateSelector";function Ht(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function lo(e){return Ht(e.getFullYear(),e.getMonth())}function Sr(e){return`${Ro(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const ds='; leave the bound out where the variant allows it, or declare the months to offer with `minYear` / `maxYear` or `allowedMonths`, instead of a sentinel for "no bound"';function qn(e,t,r){e!==void 0&&al(e,t,r)}function al(e,t,r){if(!$e(e))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${S(e)}.`);if(Number.isNaN(lo(e).getTime()))throw new RangeError(`MonthSelector: \`${t}\` must fall in a month that starts inside the Date range, received ${S(e)}${r}.`)}function ms(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${S(e)}.`);if(Number.isNaN(Ht(e,r).getTime()))throw new RangeError(`MonthSelector: \`${t}\` must name a year whose ${r===0?"January":"December"} starts inside the Date range, received ${S(e)}.`)}}function bu(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`formatLocale\` must be a valid BCP 47 language tag, received ${S(e)}.`)}}function pu(e,t){const r=e===void 0?null:Ht(e,0),n=t===void 0?null:Ht(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function vu(e,t){const r=e===void 0?null:Ht(e,11),n=t===void 0?null:Ht(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function ar(e){return e.getFullYear()*12+e.getMonth()}function xa(e){return Ht(Math.floor(e/12),(e%12+12)%12)}function fs(e){return Number.isNaN(e.getTime())?null:e}function xu(e,t,r){const n=new Map;for(const o of e){const a=Ht(o.getFullYear(),o.getMonth());t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function Su(e,t){const r=[];for(let n=ar(e);n<=ar(t);n++)r.push(xa(n));return r}function gs(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:st("month",e[o],r,t),value:Sr(e[o])});return n}const Du=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:s,maxYear:d,minDate:g,maxDate:m,allowedMonths:v,isWarning:b=!1,className:M="",style:U,disabled:u=!1,locale:D,labels:f,formatLocale:z,formatOption:P}=e;if(bu(z),qn(t,"value",""),qn(r,"initialDate",""),qn(g,"minDate",ds),qn(m,"maxDate",ds),ms(s,"minYear",0),ms(d,"maxYear",11),!wo(v))throw new RangeError(`MonthSelector: \`allowedMonths\` must be an array of Dates, received ${S(v)}.`);if(v!==void 0)for(let Q=0;Q<v.length;Q++)al(v[Q],`allowedMonths[${Q}]`,"");const K=t??r;if(K===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");if(o!==void 0){const Q=Na(o);if(Q!==null)throw new RangeError(`MonthSelector: \`${Q.field}\` must be ${Q.expected}, received ${Q.received}.`);if(t===void 0)throw new RangeError("MonthSelector: `stepper` requires the controlled `value`; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled `initialDate` would never change.")}const H=So(D,f),de=t!==void 0,[Y,re]=Oa(K,de,lo,lo),oe=l.useMemo(()=>t!==void 0?Ht(t.getFullYear(),t.getMonth()):Y,[t?.getTime(),Y]),V=g?.getTime(),ne=m?.getTime(),R=l.useMemo(()=>pu(s,g),[s,V]),E=l.useMemo(()=>vu(d,m),[d,ne]),$=R?.getTime()??null,W=E?.getTime()??null;if(R!==null&&E!==null&&R>E)throw new RangeError(`MonthSelector: the resolved lower bound ${Sr(R)} is after the resolved upper bound ${Sr(E)}.`);if(i==="dropdown"&&v===void 0&&(R===null||E===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedMonths`; the option window is never invented.');const J=v===void 0?null:v.map(Q=>Q.getTime()).join(","),F=l.useMemo(()=>v===void 0?null:xu(v,R,E),[J,$,W]),G=l.useMemo(()=>{if(F!==null){const Q=F.map(ar);return{kind:"candidates",ascending:Q,loIndex:0,hiIndex:Q.length-1}}return{kind:"range",min:R===null?null:ar(R),max:E===null?null:ar(E)}},[F,$,W]),k=Q=>!Number.isNaN(Q.getTime())&&bn(G,ar(Q)),ie=Q=>{if(u)return;if(!k(Q))throw new RangeError(`MonthSelector: refusing to emit ${Sr(Q)}, which lies outside the selectable months.`);de||re(Q);const Ye=Q.getFullYear()*100+(Q.getMonth()+1);n?.(Q,Ye)},we=oe.getTime(),Se=k(oe),q=l.useMemo(()=>{const Q=Xt(G,ar(oe),-1);return Q===null?null:fs(xa(Q))},[G,we]),A=l.useMemo(()=>{const Q=Xt(G,ar(oe),1);return Q===null?null:fs(xa(Q))},[G,we]),ge=()=>{if(o!==void 0){o.onStep("previous");return}q!==null&&ie(q)},ue=()=>{if(o!==void 0){o.onStep("next");return}A!==null&&ie(A)},ae=Q=>{if(!Q)return;const Ye=Q.lastIndexOf("-");if(Ye<=0)return;const Rt=Q.slice(0,Ye),ze=Q.slice(Ye+1),Fe=Number(Rt),qe=Number(ze)-1;if(!(Number.isInteger(Fe)&&Number.isInteger(qe)))return;const Qe=Ht(Fe,qe);k(Qe)&&ie(Qe)},I=Q=>{ae(Q.target.value)},he=Q=>{ae(Q.target.value)},fe=Sr(oe),De=i==="dropdown"&&!Se?st("month",oe,P,z):"",be=R?Sr(R):void 0,pe=E?Sr(E):void 0,Oe=l.useMemo(()=>i!=="dropdown"?[]:F!==null?gs(F,z,P):R===null||E===null?[]:gs(Su(R,E),z,P),[i,F,$,W,z,P]),Te=Se?fe:"",Ze=b?"border-amber-300 bg-amber-50 text-amber-900 focus:border-amber-500 focus:ring-amber-500 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200":"border-gray-300 bg-gray-100 text-gray-900 focus:border-blue-500 focus:ring-blue-500 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",ot=`period-slider-native-date-field w-28 rounded-md border py-0.5 px-1 text-center font-mono text-xs tabular-nums dark:placeholder:text-gray-400 disabled:opacity-50 ${Ze}`,Le=`w-28 appearance-none rounded-md border px-1 py-0.5 text-center font-mono text-xs tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${Ze}`;return L.jsxs("div",{className:`inline-flex items-center ${hn} ${M}`,style:U,"data-out-of-range":Se?void 0:"true",children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:u,canStep:o===void 0?q!==null:o.canStepPrevious,onStep:ge,ariaLabel:H.previousMonth}),i==="dropdown"?L.jsxs("select",{"aria-label":H.monthSelect,disabled:u,className:Le,value:Te,onChange:he,children:[Se?null:L.jsx("option",{value:"",disabled:!0,className:"text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",children:De}),Oe.map(Q=>L.jsx("option",{value:Q.value,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:Q.label},Q.value))]}):L.jsx("input",{"aria-label":H.monthSelect,disabled:u,className:ot,value:fe,min:be,max:pe,onChange:I,type:"month"}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:u,canStep:o===void 0?A!==null:o.canStepNext,onStep:ue,ariaLabel:H.nextMonth}),a]})},Ru=(e,t)=>!(!Aa(e,t,lo)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),il=l.memo(Du,Ru);il.displayName="MonthSelector";function Ne(e,t,r){return e<t?t:e>r?r:e}const Mu=Gr([],null,null);function Dn(e,t,r,n){return r===null?Mu:Sa(r,_(t,e[0],n),_(t,e[1],n))}function Dr(e,t,r,n,o){const a=_(t,e,o),i=Da(n)?null:pn(n,a);return i===null?a<_(t,r[0],o)?r[0]:a>_(t,r[1],o)?r[1]:e:i===a?e:ee(t,i,o)}function Ur(e,t,r,n,o,a){const i=_(t,e[0],o),s=_(t,e[1],o),d=to(a,{kind:"range",min:_(t,r[0],o),max:_(t,r[1],o)},i,s);if(d===null)return e;const g=Dr(d[0]===i?e[0]:ee(t,d[0],o),t,r,n,o),m=Dr(d[1]===s?e[1]:ee(t,d[1],o),t,r,n,o);return[g,m<g?g:m]}const hs=(e,t,r,n,o,a,i)=>{if(Ea(e,t,r),r===void 0||r.length===0)return null;const s=Gr(el(e,t,r,n,i),_(n,o,i),_(n,a,i));if(s.hiIndex<s.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${S(o)}, maxDate: ${S(a)}, entries: ${r.length})`);return s},Sa=(e,t,r)=>{const n=Gr(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},Da=e=>e.hiIndex<e.loIndex,Eu=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Xt(o,t,r);a!==null&&(n===null||(r===1?a<n:a>n))&&(n=a)}return n},edge:t=>{let r=null;for(const n of e){const o=wn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Fr=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),ws=(e,t,r,n,o)=>{if(!Pt(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${S(r)})`);const a=Gt(e,`${t}[0]`,r[0],n,o),i=Gt(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${S(r[0])}, end: ${S(r[1])})`);return[a,i]},ir=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${S(e)})`);const{row:r,shows:n,macroUnit:o,microUnit:a,minDate:i,maxDate:s,macroRange:d,microSelection:g}=e;if(r!=="macro"&&r!=="micro")throw new RangeError(`${t}: row must be "macro" or "micro" (received: ${S(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${S(n)})`);so(t,"macroUnit",o),so(t,"microUnit",a);const m=dr(t,e.yearStartMonth);for(const[R,E]of[["minDate",i],["maxDate",s]])if(!$e(E))throw new RangeError(`${t}: ${R} must be a valid Date (received: ${S(E)})`);if(s.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${S(i)}, maxDate: ${S(s)})`);Gt(t,"minDate",i,o,m),Gt(t,"minDate",i,a,m),Mr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const v=ws(t,"macroRange",d,o,m);if(d[1].getTime()<d[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${S(d[0])}, end: ${S(d[1])})`);const b=ws(t,"microSelection",g,a,m),M=hs(t,"macroAllowedDates",e.macroAllowedDates,o,i,s,m),U=hs(t,"microAllowedDates",e.microAllowedDates,a,i,s,m),u=[d[0],d[1]],D=[g[0],g[1]],f=R=>{const E=Dt(o,a,[R[0],R[1]],i,s,m);return[_(a,E[0],m),_(a,E[1],m)]},z=(R,E)=>{if(U!==null){const $=Sa(U,R,E);if(!Da($))return $}return{kind:"range",min:R,max:E}},P=(R,E)=>{const $=Fr(R,u)?u:R;return $===u&&Fr(E,D)?null:{macroRange:$,microSelection:E}};if(e.row==="macro"){const R=M??{kind:"range",min:_(o,i,m),max:_(o,s,m)},E=Jn(R),$=(J,F)=>{const G=Dt(o,a,J,i,s,m);return Ur(D,a,G,Dn(G,a,U,m),m,F)},W=(J,F)=>{const G=ma(E,v[0],v[1],J,wa(F,n));if(G===null)return null;const k=ba(G,v,u,o,m,F.motion==="single");if(k===null)return null;const ie=[Ne(k[0],i,s),Ne(k[1],i,s)],we=Math.sign(G[0]-v[0])===J&&Math.sign(G[1]-v[1])===J;return P(ie,$(ie,we?"pan":"resize"))};return{previous:W(-1,e.rules.previous),next:W(1,e.rules.next)}}const K=f(u);let H=[_(a,i,m),_(a,s,m)];if(M!==null){const R=f([ee(o,M.ascending[M.loIndex],m),ee(o,M.ascending[M.hiIndex],m)]);H=[Math.min(R[0],K[0]),Math.max(R[1],K[1])]}const de=U===null?null:Sa(U,H[0],H[1]);let Y=Jn({kind:"range",min:H[0],max:H[1]});if(de!==null&&!Da(de)){const R=z(K[0],K[1]);Y=R.kind==="candidates"?Jn(de):Eu([de,R])}const re=R=>{if(M===null)return[Ne(wt(o,R[0],m),i,s),Ne(wt(o,R[1],m),i,s)];const E=Qn(M,_(o,R[0],m),-1),$=Qn(M,_(o,R[1],m),1);return E===null||$===null?null:[Ne(ee(o,E,m),i,s),Ne(ee(o,$,m),i,s)]},oe=(R,E,$)=>{const[W,J]=f(R),F=z(W,J),G=we=>{const Se=_(a,we,m);if(bn(F,Se))return we;const q=Qn(F,Se,$);return q===null?null:ee(a,q,m)},k=G(E[0]),ie=G(E[1]);return k===null||ie===null?null:[k,ie.getTime()<k.getTime()?k:ie]},V=(R,E)=>R>=K[0]&&E<=K[1],ne=(R,E)=>{const $=ma(Y,b[0],b[1],R,wa(E,n));if($===null)return null;const W=ba($,b,D,a,m,E.motion==="single");if(W===null)return null;const J=E.window!=="follow",F=J&&V($[0],$[1])?u:re(W);if(F===null)return null;const G=oe(F,W,R);if(G===null)return null;const k=J&&V(_(a,G[0],m),_(a,G[1],m))?u:re(G);return k===null?null:P(k,G)};return{previous:ne(-1,e.rules.previous),next:ne(1,e.rules.next)}};function Ra(e,t,r){if(!$e(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${S(r)})`)}function Ce(e,t,r,n,o){Ra(e,t,r),ut(e,t,r,n,o,"")}function Eo(e,t,r,n,o){if(Ra(e,"minDate",t),Ra(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${S(t)}, maxDate: ${S(r)})`);for(const a of n)ut(e,"minDate",t,a,o,Cs)}function sr(e,t,r,n,o){if(!Pt(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${S(r)})`);if(Ce(e,`${t}[0]`,r[0],n,o),Ce(e,`${t}[1]`,r[1],n,o),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${S(r[0])}, upper: ${S(r[1])})`)}function co(e,t,r,n,o,a,i,s){const d=_(r,n,s);if(d<_(r,o,s)||d>_(r,a,s))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${S(n)}, lower: ${S(o)}, upper: ${S(a)})`)}function uo(e,t,r,n,o,a,i,s){co(e,`${t}[0]`,r,n[0],o,a,i,s),co(e,`${t}[1]`,r,n[1],o,a,i,s)}function mo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${S(r)}, upper: ${S(n)})`)}function Br(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${S(r)})`)}function _t(e,t,r,n,o,a){const i=ks(e,t,r);return $e(i)&&Is(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function fo(e,t,r,n,o){const a=Pe(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function go(e,t,r,n,o,a){const i=Ne(e,r,n);if(o.length===0)return i;const s=o[Pe(o,i,t,a)];return _(t,s,a)===_(t,i,a)?i:Ne(s,r,n)}function bs(e,t,r,n,o,a){const i=go(e[0],t,r,n,o,a),s=go(e[1],t,r,n,o,a);return[i,s<i?i:s]}const yu={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function Yt(e,t){return t.length===0?{}:{[yu[e]]:t}}function yo(e){const t=l.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(s=>Object.is(r[s],n[s]))||(t.current=e),t.current}const qt={previous:null,next:null},Pu=["motion","edge","window"];function Rn(e){const t=l.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Pu.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const sl=(e,t)=>e.getTime()===t.getTime();function Wr(e,t,r,n){if(!r(e.current,t))e.current=t;else if(e.holdsHanded)return;e.hand(e.current),n(e.current)}function Kr(e,t,r){e.current=t,e.hand(t),r(t)}function $u(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:s,selectorStep:d,...g}=e,m=dr("usePeriodSliderRange",i);Eo("usePeriodSliderRange",r,n,[t],m),sr("usePeriodSliderRange","initialRange",o,t,m),d!==void 0&&Mr("usePeriodSliderRange","selectorStep",d,"motion");const v=yo(g),b=r.getTime(),M=n.getTime(),U=l.useMemo(()=>cr("usePeriodSliderRange",Mo(v.allowedDates),t,r,n,m).dates,[v.allowedDates,t,b,M,m]),u=l.useRef(o),[D,f]=l.useState(()=>(uo("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",m),o));sr("usePeriodSliderRange","range",D,t,m);let z=D;const P=bs(D,t,r,n,U,m);(P[0]!==D[0]||P[1]!==D[1])&&(z=P,f(P));const K=Xe(z);K.forgetHandedUnless(D);const H=l.useRef(o),de=Xe({minDate:r,maxDate:n,candidates:U}),Y=Xe(a),re=l.useCallback(q=>{const{minDate:A,maxDate:ge,candidates:ue}=de.current,ae=bs(q,t,A,ge,ue,m);Wr(K,ae,Fr,f);const I=H.current;ae[0].getTime()===I[0].getTime()&&ae[1].getTime()===I[1].getTime()||(H.current=ae,Y.current?.(ae[0],ae[1]))},[t,m]),oe=l.useCallback(q=>{const A=typeof q=="function"?q(K.current):q;H.current=A,Kr(K,A,f)},[]),V=l.useCallback(q=>{Ce("usePeriodSliderRange","setLowerDate(date)",q,t,m);const A=K.current,ge=q.getTime()>A[1].getTime()?q:A[1];re([q,ge])},[re,t,m]),ne=l.useCallback(q=>{Ce("usePeriodSliderRange","setUpperDate(date)",q,t,m);const A=K.current,ge=q.getTime()<A[0].getTime()?q:A[0];re([ge,q])},[re,t,m]),R=l.useCallback((q,A)=>{Ce("usePeriodSliderRange","sliderProps.onChangeRange(lower)",q,t,m),Ce("usePeriodSliderRange","sliderProps.onChangeRange(upper)",A,t,m),mo("usePeriodSliderRange","sliderProps.onChangeRange",q,A),re([q,A])},[re,t,m]),E=l.useCallback(q=>{Br("usePeriodSliderRange","shiftRange",q);const{minDate:A,maxDate:ge,candidates:ue}=de.current,ae=K.current;if(ue.length>0){re([fo(ue,t,ae[0],q,m),fo(ue,t,ae[1],q,m)]);return}re([_t(t,ae[0],q,A,ge,m).date,_t(t,ae[1],q,A,ge,m).date])},[t,re,m]),$=l.useCallback(()=>{re(u.current)},[re]),W=Rn(d),J=W!==void 0,F=l.useMemo(()=>{if(W===void 0)return{start:qt,end:qt};const q=U.length>0?v.allowedDates:void 0,A={selection:z,unit:t,yearStartMonth:m,minDate:r,maxDate:n,allowedDates:q,rules:W};return{start:pa({...A,shows:"start"}),end:pa({...A,shows:"end"})}},[W,z,t,m,b,M,U,v.allowedDates]),G=Vt(F.start,re),k=Vt(F.end,re),ie=l.useMemo(()=>({value:z[0],onChange:V,minDate:r,maxDate:z[1],unit:t,yearStartMonth:m,...Yt(t,U),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:s,...J?{stepper:G}:{}}),[z[0],z[1],V,r,t,m,U,e.formatLocale,e.locale,e.labels,s,J,G]),we=l.useMemo(()=>({value:z[1],onChange:ne,minDate:z[0],maxDate:n,unit:t,yearStartMonth:m,...Yt(t,U),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:s,...J?{stepper:k}:{}}),[z[0],z[1],ne,n,t,m,U,e.formatLocale,e.locale,e.labels,s,J,k]),Se=l.useMemo(()=>({...v,mode:"range",unit:t,yearStartMonth:m,range:z,minDate:r,maxDate:n,onChangeRange:R}),[v,t,z,r,n,R,m]);return{range:z,lowerDate:z[0],upperDate:z[1],setRange:oe,setLowerDate:V,setUpperDate:ne,shiftRange:E,resetRange:$,startSelectorProps:ie,endSelectorProps:we,sliderProps:Se}}function Lu(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:s,...d}=e,g=dr("usePeriodSliderPoint",i);Eo("usePeriodSliderPoint",r,n,[t],g),Ce("usePeriodSliderPoint","initialValue",o,t,g);const m=yo(d),v=r.getTime(),b=n.getTime(),M=l.useMemo(()=>cr("usePeriodSliderPoint",Mo(m.allowedDates),t,r,n,g).dates,[m.allowedDates,t,v,b,g]),U=l.useRef(o),[u,D]=l.useState(()=>(co("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",g),o));Ce("usePeriodSliderPoint","value",u,t,g);let f=u;const z=go(u,t,r,n,M,g);z!==u&&(f=z,D(z));const P=Xe(f);P.forgetHandedUnless(u);const K=l.useRef(o),H=Xe({minDate:r,maxDate:n,candidates:M}),de=Xe(a),Y=l.useCallback(W=>{const{minDate:J,maxDate:F,candidates:G}=H.current,k=go(W,t,J,F,G,g);Wr(P,k,sl,D),k.getTime()!==K.current.getTime()&&(K.current=k,de.current?.(k))},[t,g]),re=l.useCallback(W=>{const J=typeof W=="function"?W(P.current):W;K.current=J,Kr(P,J,D)},[]),oe=l.useCallback(W=>{Ce("usePeriodSliderPoint","selectorProps.onChange(date)",W,t,g),Y(W)},[Y,t,g]),V=l.useCallback(W=>{Ce("usePeriodSliderPoint","sliderProps.onChangePoint(value)",W,t,g),Y(W)},[Y,t,g]),ne=l.useCallback(W=>{Br("usePeriodSliderPoint","shiftValue",W);const{minDate:J,maxDate:F,candidates:G}=H.current;if(G.length>0){Y(fo(G,t,P.current,W,g));return}Y(_t(t,P.current,W,J,F,g).date)},[t,Y,g]),R=l.useCallback(()=>{Y(U.current)},[Y]),E=l.useMemo(()=>({value:f,onChange:oe,minDate:r,maxDate:n,unit:t,yearStartMonth:g,...Yt(t,M),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:s}),[f,oe,r,n,t,g,M,e.formatLocale,e.locale,e.labels,s]),$=l.useMemo(()=>({...m,mode:"point",unit:t,yearStartMonth:g,value:f,minDate:r,maxDate:n,onChangePoint:V}),[m,t,f,r,n,V,g]);return{value:f,setValue:re,shiftValue:ne,resetValue:R,selectorProps:E,sliderProps:$}}function Tu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i=t,microUnit:s=t,onChangeMacroRange:d,onChangeMicroRange:g,yearStartMonth:m,formatOption:v,macroSelectorStep:b,microSelectorStep:M,...U}=e,u=dr("useVernierSliderRange",m);Eo("useVernierSliderRange",r,n,[i,s,t],u),sr("useVernierSliderRange","initialMacroRange",o,i,u),sr("useVernierSliderRange","initialMicroRange",a,s,u),b!==void 0&&Mr("useVernierSliderRange","macroSelectorStep",b,"motion"),M!==void 0&&Mr("useVernierSliderRange","microSelectorStep",M,"vernierRange");const D=yo(U),f=l.useRef(o),z=l.useRef(a),[P,K]=l.useState(()=>(uo("useVernierSliderRange","initialMacroRange",i,o,r,n,"[minDate, maxDate]",u),o)),[H,de]=l.useState(()=>{const y=Dt(i,s,o,r,n,u);return uo("useVernierSliderRange","initialMicroRange",s,a,y[0],y[1],"the initial macro window",u),a});let Y=P;sr("useVernierSliderRange","macroRange",P,i,u);const re=[Ne(P[0],r,n),Ne(P[1],r,n)];(re[0]!==P[0]||re[1]!==P[1])&&(Y=re,K(re));const oe=r.getTime(),V=n.getTime(),ne=l.useMemo(()=>Dt(i,s,Y,r,n,u),[i,s,Y,oe,V,u]),R=l.useMemo(()=>D.microIsDiscrete===!0?Ta("useVernierSliderRange",St("micro",D),s,r,n,u):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,s,oe,V,u]),E=l.useMemo(()=>D.macroIsDiscrete===!0?cr("useVernierSliderRange",St("macro",D),i,r,n,u).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,i,oe,V,u]),$=Xe(E),W=l.useMemo(()=>Dn(ne,s,R,u),[ne,s,R,u]),J=l.useMemo(()=>xn(R,W),[R,W]);let F=H;sr("useVernierSliderRange","microRange",H,s,u);const G=Ur(H,s,ne,W,u,"resize");(G[0]!==H[0]||G[1]!==H[1])&&(F=G,de(G));const k=Xe(Y),ie=Xe(F);k.forgetHandedUnless(P),ie.forgetHandedUnless(H);const we=l.useRef(a),Se=l.useRef(o),q=Xe({minDate:r,maxDate:n}),A=Xe(d),ge=Xe(g),ue=l.useCallback(y=>{const{minDate:j,maxDate:le}=q.current;return Dt(i,s,y,j,le,u)},[i,s,u]),ae=l.useCallback(y=>Dn(y,s,R,u),[s,R,u]),I=l.useCallback(y=>{Wr(k,y,Fr,K);const j=Se.current;y[0].getTime()===j[0].getTime()&&y[1].getTime()===j[1].getTime()||(Se.current=y,A.current?.(y[0],y[1]))},[]),he=l.useCallback(y=>{const j=typeof y=="function"?y(k.current):y;Se.current=j,Kr(k,j,K)},[]),fe=l.useCallback((y,j)=>{I(y),Wr(ie,j,Fr,de);const le=we.current;(j[0].getTime()!==le[0].getTime()||j[1].getTime()!==le[1].getTime())&&(we.current=j,ge.current?.(j[0],j[1]))},[I]),De=l.useCallback(y=>{const j=typeof y=="function"?y(ie.current):y;we.current=j,Kr(ie,j,de)},[]),be=l.useCallback((y,j,le)=>{const{minDate:He,maxDate:_e}=q.current,Me=[Ne(y,He,_e),Ne(j,He,_e)],je=ue(Me);fe(Me,Ur(ie.current,s,je,ae(je),u,le))},[s,ue,ae,fe,u]),pe=l.useCallback((y,j)=>be(y,j,"resize"),[be]),Oe=l.useCallback((y,j)=>{Ce("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",y,i,u),Ce("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",j,i,u),mo("useVernierSliderRange","sliderProps.onChangeMacroRange",y,j);const{minDate:le,maxDate:He}=q.current,_e=[Ne(y,le,He),Ne(j,le,He)],Me=ie.current,je=ue(_e),et=Ur(Me,s,je,ae(je),u,"resize");if(et[0].getTime()!==Me[0].getTime()||et[1].getTime()!==Me[1].getTime()){I(_e);return}fe(_e,Me)},[i,s,ue,ae,I,fe,u]),Te=l.useCallback((y,j)=>{const le=ue(k.current);fe(k.current,Ur([y,j],s,le,ae(le),u,"resize"))},[s,ue,ae,fe,u]),Ze=l.useCallback((y,j)=>{Ce("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",y,s,u),Ce("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",j,s,u),mo("useVernierSliderRange","sliderProps.onChangeMicroRange",y,j),Te(y,j)},[Te,s,u]),ot=l.useCallback(y=>{Ce("useVernierSliderRange","setMacroLowerDate(date)",y,i,u);const j=k.current[1],le=y>j?y:j;pe(y,le)},[pe,i,u]),Le=l.useCallback(y=>{Ce("useVernierSliderRange","setMacroUpperDate(date)",y,i,u);const j=k.current[0],le=y<j?y:j;pe(le,y)},[pe,i,u]),Q=l.useCallback(y=>{Ce("useVernierSliderRange","setMicroLowerDate(date)",y,s,u);const j=ie.current[1],le=y>j?y:j;Te(y,le)},[Te,s,u]),Ye=l.useCallback(y=>{Ce("useVernierSliderRange","setMicroUpperDate(date)",y,s,u);const j=ie.current[0],le=y<j?y:j;Te(le,y)},[Te,s,u]),Rt=l.useCallback(y=>{Br("useVernierSliderRange","shiftMacroRange",y);const{minDate:j,maxDate:le}=q.current,He=k.current,_e=$.current;if(_e.length>0){const et=Pe(_e,He[0],i,u)+y,bt=Pe(_e,He[1],i,u)+y;if(et<0||bt>_e.length-1)return;be(_e[et],_e[bt],"pan");return}const Me=_t(i,He[0],y,j,le,u),je=_t(i,He[1],y,j,le,u);Me.pastDateRange||je.pastDateRange||Me.date<j||je.date>le||be(Me.date,je.date,"pan")},[i,be,u]),ze=l.useCallback(y=>{Br("useVernierSliderRange","shiftMicroRange",y);const j=k.current,le=ie.current,He=ue(j),[_e,Me]=He,je=xn(R,ae(He));if(je.length>0){const Ut=Pe(je,le[0],s,u)+y,We=Pe(je,le[1],s,u)+y;if(Ut<0||We>je.length-1)return;Te(je[Ut],je[We]);return}const et=_t(s,le[0],y,_e,Me,u),bt=_t(s,le[1],y,_e,Me,u);et.pastDateRange||bt.pastDateRange||_(s,et.date,u)<_(s,_e,u)||_(s,bt.date,u)>_(s,Me,u)||Te(et.date,bt.date)},[s,R,ue,ae,Te,u]),Fe=l.useCallback(()=>{const{minDate:y,maxDate:j}=q.current,le=[Ne(f.current[0],y,j),Ne(f.current[1],y,j)],He=ue(le);fe(le,Ur(z.current,s,He,ae(He),u,"resize"))},[s,ue,ae,fe,u]),qe=Rn(b),Qe=Rn(M),ft=qe!==void 0,ve=Qe!==void 0,ye=l.useMemo(()=>{const y={macroUnit:i,microUnit:s,yearStartMonth:u,minDate:r,maxDate:n,macroRange:Y,microSelection:F,macroAllowedDates:D.macroIsDiscrete===!0?St("macro",D).list:void 0,microAllowedDates:D.microIsDiscrete===!0?St("micro",D).list:void 0};return{macroStart:qe===void 0?qt:ir({...y,row:"macro",shows:"start",rules:qe}),macroEnd:qe===void 0?qt:ir({...y,row:"macro",shows:"end",rules:qe}),microStart:Qe===void 0?qt:ir({...y,row:"micro",shows:"start",rules:Qe}),microEnd:Qe===void 0?qt:ir({...y,row:"micro",shows:"end",rules:Qe})}},[qe,Qe,i,s,u,oe,V,Y,F,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),T=l.useCallback(y=>fe(y.macroRange,y.microSelection),[fe]),C=Vt(ye.macroStart,T),Ve=Vt(ye.macroEnd,T),O=Vt(ye.microStart,T),Je=Vt(ye.microEnd,T),[Lt,jt]=ne,te=l.useMemo(()=>({value:Y[0],onChange:ot,minDate:r,maxDate:Y[1],unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ft?{stepper:C}:{}}),[Y,ot,r,i,u,E,e.formatLocale,e.locale,e.labels,v,ft,C]),h=l.useMemo(()=>({value:Y[1],onChange:Le,minDate:Y[0],maxDate:n,unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ft?{stepper:Ve}:{}}),[Y,Le,n,i,u,E,e.formatLocale,e.locale,e.labels,v,ft,Ve]),se=l.useMemo(()=>({value:F[0],onChange:Q,minDate:Lt,maxDate:F[1],unit:s,yearStartMonth:u,...Yt(s,J),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ve?{stepper:O}:{}}),[F,Q,Lt,s,u,J,e.formatLocale,e.locale,e.labels,v,ve,O]),Re=l.useMemo(()=>({value:F[1],onChange:Ye,minDate:F[0],maxDate:jt,unit:s,yearStartMonth:u,...Yt(s,J),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...ve?{stepper:Je}:{}}),[F,Ye,jt,s,u,J,e.formatLocale,e.locale,e.labels,v,ve,Je]),Be=l.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:u,macroUnit:i,microUnit:s,minDate:r,maxDate:n,macroRange:Y,microRange:F,onChangeMacroRange:Oe,onChangeMicroRange:Ze}),[D,t,i,s,r,n,Y,F,Oe,Ze,u]);return{macroRange:Y,setMacroRange:he,microRange:F,setMicroRange:De,setMacroLowerDate:ot,setMacroUpperDate:Le,setMicroLowerDate:Q,setMicroUpperDate:Ye,shiftMacroRange:Rt,shiftMicroRange:ze,resetVernier:Fe,macroStartSelectorProps:te,macroEndSelectorProps:h,microStartSelectorProps:se,microEndSelectorProps:Re,sliderProps:Be}}function Cu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i=t,microUnit:s=t,onChangeMacroRange:d,onChangeMicroPoint:g,yearStartMonth:m,formatOption:v,macroSelectorStep:b,microSelectorStep:M,...U}=e,u=dr("useVernierSliderPoint",m);Eo("useVernierSliderPoint",r,n,[i,s,t],u),sr("useVernierSliderPoint","initialMacroRange",o,i,u),Ce("useVernierSliderPoint","initialMicroValue",a,s,u),b!==void 0&&Mr("useVernierSliderPoint","macroSelectorStep",b,"motion"),M!==void 0&&Mr("useVernierSliderPoint","microSelectorStep",M,"vernierPoint");const D=yo(U),f=l.useRef(o),z=l.useRef(a),[P,K]=l.useState(()=>(uo("useVernierSliderPoint","initialMacroRange",i,o,r,n,"[minDate, maxDate]",u),o)),[H,de]=l.useState(()=>{const h=Dt(i,s,o,r,n,u);return co("useVernierSliderPoint","initialMicroValue",s,a,h[0],h[1],"the initial macro window",u),a});let Y=P;sr("useVernierSliderPoint","macroRange",P,i,u);const re=[Ne(P[0],r,n),Ne(P[1],r,n)];(re[0]!==P[0]||re[1]!==P[1])&&(Y=re,K(re));const oe=r.getTime(),V=n.getTime(),ne=l.useMemo(()=>Dt(i,s,Y,r,n,u),[i,s,Y,oe,V,u]),R=l.useMemo(()=>D.microIsDiscrete===!0?Ta("useVernierSliderPoint",St("micro",D),s,r,n,u):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,s,oe,V,u]),E=l.useMemo(()=>D.macroIsDiscrete===!0?cr("useVernierSliderPoint",St("macro",D),i,r,n,u).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,i,oe,V,u]),$=Xe(E),W=l.useMemo(()=>Dn(ne,s,R,u),[ne,s,R,u]),J=l.useMemo(()=>xn(R,W),[R,W]);let F=H;Ce("useVernierSliderPoint","microValue",H,s,u);const G=Dr(H,s,ne,W,u);G!==H&&(F=G,de(G));const k=Xe(Y),ie=Xe(F);k.forgetHandedUnless(P),ie.forgetHandedUnless(H);const we=l.useRef(a),Se=l.useRef(o),q=Xe({minDate:r,maxDate:n}),A=Xe(d),ge=Xe(g),ue=l.useCallback(h=>{const{minDate:se,maxDate:Re}=q.current;return Dt(i,s,h,se,Re,u)},[i,s,u]),ae=l.useCallback(h=>Dn(h,s,R,u),[s,R,u]),I=l.useCallback(h=>{Wr(k,h,Fr,K);const se=Se.current;h[0].getTime()===se[0].getTime()&&h[1].getTime()===se[1].getTime()||(Se.current=h,A.current?.(h[0],h[1]))},[]),he=l.useCallback(h=>{const se=typeof h=="function"?h(k.current):h;Se.current=se,Kr(k,se,K)},[]),fe=l.useCallback((h,se)=>{I(h),Wr(ie,se,sl,de),se.getTime()!==we.current.getTime()&&(we.current=se,ge.current?.(se))},[I]),De=l.useCallback(h=>{const se=typeof h=="function"?h(ie.current):h;we.current=se,Kr(ie,se,de)},[]),be=l.useCallback((h,se)=>{const{minDate:Re,maxDate:Be}=q.current,y=[Ne(h,Re,Be),Ne(se,Re,Be)],j=ue(y);fe(y,Dr(ie.current,s,j,ae(j),u))},[s,ue,ae,fe,u]),pe=l.useCallback(h=>{const se=ue(k.current);fe(k.current,Dr(h,s,se,ae(se),u))},[s,ue,ae,fe,u]),Oe=l.useCallback((h,se)=>{Ce("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",h,i,u),Ce("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",se,i,u),mo("useVernierSliderPoint","sliderProps.onChangeMacroRange",h,se);const{minDate:Re,maxDate:Be}=q.current,y=[Ne(h,Re,Be),Ne(se,Re,Be)],j=ie.current,le=ue(y);if(Dr(j,s,le,ae(le),u).getTime()!==j.getTime()){I(y);return}fe(y,j)},[i,s,ue,ae,I,fe,u]),Te=l.useCallback(h=>{Ce("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",h,s,u),pe(h)},[pe,s,u]),Ze=l.useCallback(h=>{Ce("useVernierSliderPoint","setMacroLowerDate(date)",h,i,u);const se=k.current[1],Re=h>se?h:se;be(h,Re)},[be,i,u]),ot=l.useCallback(h=>{Ce("useVernierSliderPoint","setMacroUpperDate(date)",h,i,u);const se=k.current[0],Re=h<se?h:se;be(Re,h)},[be,i,u]),Le=l.useCallback(h=>{Ce("useVernierSliderPoint","setMicroDate(date)",h,s,u),pe(h)},[pe,s,u]),Q=l.useCallback(h=>{Br("useVernierSliderPoint","shiftMacroRange",h);const{minDate:se,maxDate:Re}=q.current,Be=k.current,y=$.current;if(y.length>0){const He=Pe(y,Be[0],i,u)+h,_e=Pe(y,Be[1],i,u)+h;if(He<0||_e>y.length-1)return;be(y[He],y[_e]);return}const j=_t(i,Be[0],h,se,Re,u),le=_t(i,Be[1],h,se,Re,u);j.pastDateRange||le.pastDateRange||j.date<se||le.date>Re||be(j.date,le.date)},[i,be,u]),Ye=l.useCallback(h=>{Br("useVernierSliderPoint","shiftMicroValue",h);const se=k.current,Re=ue(se),Be=xn(R,ae(Re));if(Be.length>0){pe(fo(Be,s,ie.current,h,u));return}pe(_t(s,ie.current,h,Re[0],Re[1],u).date)},[s,R,ue,ae,pe,u]),Rt=l.useCallback(()=>{const{minDate:h,maxDate:se}=q.current,Re=[Ne(f.current[0],h,se),Ne(f.current[1],h,se)],Be=ue(Re);fe(Re,Dr(z.current,s,Be,ae(Be),u))},[s,ue,ae,fe,u]),ze=Rn(b),Fe=Rn(M),qe=ze!==void 0,Qe=Fe!==void 0,ft=l.useMemo(()=>{const h={macroUnit:i,microUnit:s,yearStartMonth:u,minDate:r,maxDate:n,macroRange:Y,microSelection:[F,F],macroAllowedDates:D.macroIsDiscrete===!0?St("macro",D).list:void 0,microAllowedDates:D.microIsDiscrete===!0?St("micro",D).list:void 0};return{macroStart:ze===void 0?qt:ir({...h,row:"macro",shows:"start",rules:ze}),macroEnd:ze===void 0?qt:ir({...h,row:"macro",shows:"end",rules:ze}),micro:Fe===void 0?qt:ir({...h,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:Fe.previous.window},next:{motion:"shift",window:Fe.next.window}}})}},[ze,Fe,i,s,u,oe,V,Y,F,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),ve=l.useCallback(h=>fe(h.macroRange,h.microSelection[0]),[fe]),ye=Vt(ft.macroStart,ve),T=Vt(ft.macroEnd,ve),C=Vt(ft.micro,ve),[Ve,O]=ne,Je=l.useMemo(()=>({value:Y[0],onChange:Ze,minDate:r,maxDate:Y[1],unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...qe?{stepper:ye}:{}}),[Y,Ze,r,i,u,E,e.formatLocale,e.locale,e.labels,v,qe,ye]),Lt=l.useMemo(()=>({value:Y[1],onChange:ot,minDate:Y[0],maxDate:n,unit:i,yearStartMonth:u,...Yt(i,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...qe?{stepper:T}:{}}),[Y,ot,n,i,u,E,e.formatLocale,e.locale,e.labels,v,qe,T]),jt=l.useMemo(()=>({value:F,onChange:Le,minDate:Ve,maxDate:O,unit:s,yearStartMonth:u,...Yt(s,J),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:v,...Qe?{stepper:C}:{}}),[F,Le,Ve,O,s,u,J,e.formatLocale,e.locale,e.labels,v,Qe,C]),te=l.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:u,macroUnit:i,microUnit:s,minDate:r,maxDate:n,macroRange:Y,microValue:F,onChangeMacroRange:Oe,onChangeMicroPoint:Te}),[D,t,i,s,r,n,Y,F,Oe,Te,u]);return{macroRange:Y,setMacroRange:he,microValue:F,setMicroValue:De,setMacroLowerDate:Ze,setMacroUpperDate:ot,setMicroDate:Le,shiftMacroRange:Q,shiftMicroValue:Ye,resetVernier:Rt,macroStartSelectorProps:Je,macroEndSelectorProps:Lt,microSelectorProps:jt,sliderProps:te}}function ho(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Mn(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function _a(e,t){return ho(Mn(e,t),t)}function ps(e){return e===void 0?0:Ls(e)?e:Number.NaN}const vs='; declare the years to offer with `minYear` / `maxYear` or `allowedYears` instead of a sentinel for "no bound"';function Xn(e,t,r,n){e!==void 0&&ll(e,t,r,n)}function ll(e,t,r,n){if(!$e(e))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${S(e)}.`);if(Number.isNaN(_a(e,r).getTime()))throw new RangeError(`YearSelector: \`${t}\` must fall in a year that starts inside the Date range, received ${S(e)}${n}.`)}function xs(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${S(e)}.`);if(Number.isNaN(ho(e,r).getTime()))throw new RangeError(`YearSelector: \`${t}\` must name a year that starts inside the Date range, received ${S(e)}; under yearStartMonth ${r} that year starts on month ${r+1}, day 1.`)}}function Iu(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`formatLocale\` must be a valid BCP 47 language tag, received ${S(e)}.`)}}function Ss(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Mn(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function ku(e,t,r,n){const o=new Set;for(const a of e){const i=Mn(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function Au(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:ku(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function Nu(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const Ou=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:s,minDate:d,maxDate:g,allowedYears:m,className:v="",style:b,disabled:M=!1,locale:U,labels:u,formatLocale:D,formatOption:f,yearStartMonth:z}=e,P=dr("YearSelector",z);if(Xn(t,"value",P,""),Xn(r,"initialDate",P,""),Xn(d,"minDate",P,vs),Xn(g,"maxDate",P,vs),xs(i,"minYear",P),xs(s,"maxYear",P),!wo(m))throw new RangeError(`YearSelector: \`allowedYears\` must be an array of Dates, received ${S(m)}.`);if(m!==void 0)for(let A=0;A<m.length;A++)ll(m[A],`allowedYears[${A}]`,P,"");Iu(D);const K=t??r;if(K===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");if(o!==void 0){const A=Na(o);if(A!==null)throw new RangeError(`YearSelector: \`${A.field}\` must be ${A.expected}, received ${A.received}.`);if(t===void 0)throw new RangeError("YearSelector: `stepper` requires the controlled `value`; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled `initialDate` would never change.")}const H=So(U,u),de=t!==void 0,[Y,re]=Oa(K,de,A=>_a(A,P),A=>Mn(A,P)),oe=d?.getTime(),V=g?.getTime(),ne=l.useMemo(()=>Ss(i,d,Math.max,P),[i,oe,P]),R=l.useMemo(()=>Ss(s,g,Math.min,P),[s,V,P]);if(ne!==null&&R!==null&&ne>R)throw new RangeError(`YearSelector: the resolved lower bound ${ne} is after the resolved upper bound ${R}.`);const E=m===void 0?null:m.map(A=>A.getTime()).join(","),$=l.useMemo(()=>Au(m,ne,R,P),[E,ne,R,P]);if($===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`), or `allowedYears`, are required; the year option list is never invented.");const W=l.useMemo(()=>$.kind==="discrete"?{kind:"candidates",ascending:$.ascending,loIndex:0,hiIndex:$.ascending.length-1}:{kind:"range",min:$.minYear,max:$.maxYear},[$]),J=t!==void 0?Mn(t,P):Y,F=!bn(W,J),G=A=>{if(!M){if(!bn(W,A))throw new RangeError(`YearSelector: refusing to emit ${A}, which lies outside the selectable years.`);de||re(A),n?.(ho(A,P),A)}},k=Xt(W,J,-1),ie=Xt(W,J,1),we=()=>{if(o!==void 0){o.onStep("previous");return}k!==null&&G(k)},Se=()=>{if(o!==void 0){o.onStep("next");return}ie!==null&&G(ie)},q=l.useMemo(()=>{const A=$.kind==="discrete"?[...$.ascending].reverse():Nu($.minYear,$.maxYear);return F&&(A.push(J),A.sort((ge,ue)=>ue-ge)),A.map(ge=>({value:ge,label:st("year",ho(ge,P),f,D)}))},[$,F,J,P,D,f]);return L.jsxs("div",{className:`inline-flex items-center ${hn} ${v}`,style:b,"data-out-of-range":F?"true":void 0,children:[L.jsx(Rr,{neighbour:"control",direction:"left",disabled:M,canStep:o===void 0?k!==null:o.canStepPrevious,onStep:we,ariaLabel:H.previousYear}),L.jsx("select",{"aria-label":H.yearSelect,disabled:M,className:"w-18 appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums [text-align-last:center] [text-align:center] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100 dark:focus:border-blue-500 dark:focus:ring-blue-500",value:J,onChange:A=>{if(!A.target.value)return;const ge=Number(A.target.value);Number.isInteger(ge)&&G(ge)},children:q.map(A=>L.jsx("option",{value:A.value,disabled:F&&A.value===J,className:"text-center font-mono text-gray-900 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-100",children:A.label},A.value))}),L.jsx(Rr,{neighbour:"control",direction:"right",disabled:M,canStep:o===void 0?ie!==null:o.canStepNext,onStep:Se,ariaLabel:H.nextYear}),a]})},Vu=(e,t)=>{const r=ps(t.yearStartMonth);return!(ps(e.yearStartMonth)!==r||!Aa(e,t,n=>_a(n,r))||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedYears!==t.allowedYears||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!xo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},cl=l.memo(Ou,Vu);cl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=$s;exports.DateSelector=ol;exports.MonthSelector=il;exports.PERIOD_SLIDER_LABEL_CATALOGS=ys;exports.PERIOD_SLIDER_LABEL_KEYS=vo;exports.PeriodSlider=Zs;exports.YearSelector=cl;exports.addUnit=ks;exports.areStylesEqual=Xs;exports.calculateConnectDragValues=Vs;exports.calculateHandleDragValues=ga;exports.calculateKeyboardActionValues=_s;exports.calculateLabelSlant=Ia;exports.calculateVernierMacroDrag=Ws;exports.calculateVernierMicroDrag=Ks;exports.decode=ee;exports.encode=_;exports.findNearestDateIndex=Pe;exports.formatLabel=st;exports.formatOptionText=Qs;exports.formatQuarterLabel=Tc;exports.formatScreenReaderLabel=xr;exports.getMacroWindowEndDate=Ns;exports.getMacroWindowStartDate=As;exports.getSortedAllowedDates=Cc;exports.normalizeDateByUnit=wt;exports.resolveDraggedEdge=po;exports.resolveMacroWindow=Dt;exports.resolvePeriodSliderLabels=Ps;exports.resolveQuarter=Os;exports.resolveSelectorSteps=pa;exports.resolveVernierRailZone=ka;exports.resolveVernierSelectorSteps=ir;exports.resolveVernierTargetHandle=Bs;exports.resolveWheelStep=Fs;exports.usePeriodSliderPoint=Lu;exports.usePeriodSliderRange=$u;exports.useSelectorStepper=Vt;exports.useVernierSliderPoint=Cu;exports.useVernierSliderRange=Tu;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),nc=require("date-fns"),s=require("react"),cr=require("@aiquants/virtualscroll"),oc=require("react-dom"),Va="an object that cannot be converted to a string",ac=3,Re=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},Tt=e=>{try{return Array.isArray(e)}catch{return!1}},ic=e=>e===void 0||Tt(e);function Jr(e,t,r){if(!ic(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${y(r)})`)}const y=e=>{if(typeof e=="string")return JSON.stringify(e);if(Re(e))return Date.prototype.toISOString.call(e);if(Tt(e))return sc(e);try{return String(e)}catch{return Va}},sc=e=>{let t;try{t=e.length}catch{return Va}const r=Math.min(t,ac),n=[];for(let a=0;a<r;a++)n.push(lc(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},lc=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return Tt(r)?`Array(${r.length})`:y(r)}catch{return Va}},St=(e,t)=>Re(e)?t(e):Number.NaN,mt=(e,t)=>e===void 0?null:St(e,t),Gi=120,sa="data-drag-snap",la="--ps-drag-snap-duration",xn={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"]},Cs=["low","high"],Is=["tx","ty","rot"],Eo={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"}},_a=(e,t)=>`${e}-${t}`,ca=(e,t,r)=>`var(${_a(e,t)}, ${r})`,cc=(e,t,r)=>{const n=Eo[t];for(const o of Cs)for(const a of Is)e.style.setProperty(_a(n[o],a),r[o][a])},ks=e=>Math.max(0,Math.min(1,e)),bo=(e,t,r,n)=>{const o=ks(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},Ya=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},yo=(e,t,r,n)=>{const o=ks(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ua=(e,t,r,n)=>{if(r){const i=(1-e)*100,u=(1-t)*100;return n?`M 12 ${u} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${u} 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`},nr=(e,t)=>`var(${e}, ${t}%)`,uc=(e,t,r,n)=>{const[o,a]=xn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},dc=e=>{for(const[t,r]of Object.values(xn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Eo))for(const r of Cs)for(const n of Is)e.style.removeProperty(_a(t[r],n))},As=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],Po=[...cr.VIRTUAL_SCROLL_LABEL_KEYS,...As],Ra=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:"日"})}),Ns=Object.freeze({en:Object.freeze({...cr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Ra.en}),ja:Object.freeze({...cr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Ra.ja})}),qi=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,mc=e=>Po.includes(e),fc=(e,t)=>{const r={};let n=!1;for(const o of cr.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},gc=e=>{try{return cr.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}},Os=(e,t)=>{const r=gc(e);if(t===void 0)return Ns[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${qi(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 u of o)if(!mc(u))throw new RangeError(`[period-slider] labels.${u} is not a known label key; expected one of ${Po.join(", ")}`);const i={...cr.resolveVirtualScrollLabels(r,fc(t,o)),...Ra[r]};for(const u of As){const m=o.has(u)?t[u]:void 0;if(m!==void 0){if(typeof m!="string"||m.trim()==="")throw new RangeError(`[period-slider] labels.${u} must be a non-blank string; got ${qi(m)}`);i[u]=m}}return Object.freeze(i)},hc=e=>{const t={};for(const r of cr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},wc=(e,t)=>e===t||Po.every(r=>e[r]===t[r]),Lo=(e,t)=>{if(e===t)return!0;if(e===void 0||t===void 0||e===null||t===null||typeof e!="object"||typeof t!="object")return!1;const r=new Set(Object.keys(e)),n=Object.keys(t);if(r.size!==n.length)return!1;const o=e,a=t;return n.every(i=>r.has(i)&&Object.is(o[i],a[i]))},da=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Xi=new Set(["hidden","clip","scroll","auto","overlay"]),Zi=["paint","strict","content"],bc=["layout","paint","strict","content"],pc=["transform","perspective","filter"],fn=e=>e!==void 0&&e!==""&&e!=="none",vc=e=>e!==void 0&&e!==""&&e!=="normal",Jn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},xc=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,Sc=(e,t)=>t==="absolute"&&fn(e.position)&&e.position!=="static"||fn(e.transform)||fn(e.perspective)||fn(e.filter)||fn(e.backdropFilter)||vc(e.containerType)||bc.some(r=>e.contain.includes(r))?!0:pc.some(r=>e.willChange.includes(r)),Dc=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const u=e.getBoundingClientRect();if(u.width===0||u.height===0)return!1;const m=n?0:r,h=n?r:0;if(o<u.left-m||o>=u.right+m||a<u.top-h||a>=u.bottom+h)return!1;const f=i.getComputedStyle(t);if(f.visibility!=="visible")return!1;let S=null;for(let v=t;v!==null;v=v.parentElement){const L=v===t?f:i.getComputedStyle(v);if(S!==null&&!Sc(L,S))continue;const Y=Xi.has(L.overflowX)||Zi.some(b=>L.contain.includes(b)),w=Xi.has(L.overflowY)||Zi.some(b=>L.contain.includes(b));if(Y||w){const b=v.getBoundingClientRect();if(Y&&(o<b.left+Jn(L.borderLeftWidth)||o>=b.right-Jn(L.borderRightWidth))||w&&(a<b.top+Jn(L.borderTopWidth)||a>=b.bottom-Jn(L.borderBottomWidth)))return!1}S=xc(L)}return!0},ma=new Map,Rc=(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)},Mc=(e,t)=>{let r=ma.get(e);if(r===void 0){const a=new Set,i=u=>Rc(a,u);r={participants:a,listener:i},ma.set(e,r),e.addEventListener("wheel",i,{passive:!1,capture:!0})}const{participants:n,listener:o}=r;return n.add(t),()=>{n.delete(t),!(n.size>0)&&(ma.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Dn="gap-[11px]",_t=6,Yt=_t*2,or=_t*4/3,Ec={left:`0,${Yt/2} ${_t},0 ${_t},${Yt}`,right:`${or},${Yt/2} ${or-_t},0 ${or-_t},${Yt}`,up:`${Yt/2},0 0,${_t} ${Yt},${_t}`,down:`${Yt/2},${or} 0,${or-_t} ${Yt},${or-_t}`},fa=e=>{e.preventDefault(),e.stopPropagation()},yc={onMouseDownCapture:fa,onMouseUpCapture:fa,onClickCapture:fa},Pc="period-slider-step",Lc=`${Pc} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,$c="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]",Tc={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"},eo="after:inset-[calc((100%-var(--ps-target-size))/2)]",Qi={horizontal:"px-[19px]",vertical:"py-[19px]"},Cc={control:{left:eo,right:eo,up:eo,down:eo},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)]"}},Mr=({direction:e,neighbour:t,disabled:r,canStep:n,onStep:o,ariaLabel:a,className:i,ref:u})=>{const m=e==="up"||e==="down",h=m?Yt:or,f=m?or:Yt,S=r||!n;return $.jsx("button",{ref:u,type:"button","aria-label":a,disabled:r,"aria-disabled":S?!0:void 0,...S?yc:null,onClick:S?void 0:o,className:`${i===void 0?"":`${i} `}${Lc} ${$c} ${Tc[t]} ${Cc[t][e]}`,children:$.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,width:h,height:f,viewBox:`0 0 ${h} ${f}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:$.jsx("polygon",{points:Ec[e]})})})},$o=(e,t)=>{const r=s.useMemo(()=>Os(e,t),[e,t]),n=s.useRef(r);return wc(n.current,r)||(n.current=r),n.current},ut=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${y(r)})`)},dr=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&ut(e,"values.min",t.min),t.max!==null&&ut(e,"values.max",t.max),t.min!==null&&t.max!==null&&t.max<t.min)throw new RangeError(`${e}: values.max must not precede values.min (min: ${t.min}, max: ${t.max})`);return}ut(e,"values.loIndex",t.loIndex),ut(e,"values.hiIndex",t.hiIndex)},kn=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,To=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},Rn=(e,t)=>(dr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:kn(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),Mn=(e,t)=>{if(dr("drawnValuesHas",e),ut("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(kn(e))return!1;const r=To(e,t);return r<=e.hiIndex&&e.ascending[r]===t},En=(e,t)=>{if(dr("drawnValuesNearest",e),ut("drawnValuesNearest","value",t),e.kind==="range")return e.min!==null&&t<e.min?e.min:e.max!==null&&t>e.max?e.max:t;if(kn(e))return null;const r=To(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Xt=(e,t,r)=>{if(dr("drawnValuesNeighbour",e),ut("drawnValuesNeighbour","value",t),e.kind==="range"){if(r===-1){const i=e.max===null?t-1:Math.min(t-1,e.max);return e.min!==null&&i<e.min?null:i}const a=e.min===null?t+1:Math.max(t+1,e.min);return e.max!==null&&a>e.max?null:a}if(kn(e))return null;const n=To(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},co=(e,t,r)=>{if(dr("clampPairIntoDrawnValues",e),ut("clampPairIntoDrawnValues","low",t),ut("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=En(e,t),o=En(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Ic=(e,t,r)=>{if(dr("carryPairIntoDrawnValues",e),ut("carryPairIntoDrawnValues","low",t),ut("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(kn(e))return null;const n=Rn(e,-1),o=Rn(e,1),a=r-t;return o!==null&&r>o?co(e,o-a,o):n!==null&&t<n?co(e,n,n+a):co(e,t,r)},uo=(e,t,r)=>(dr("drawnValuesAtOrBeyond",e),ut("drawnValuesAtOrBeyond","target",t),Xt(e,t-r,r)),en=(e,t,r)=>{if(t!==null&&ut("drawnValuesWithin","min",t),r!==null&&ut("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:To(n,t),hiIndex:o-1}},mo=e=>(dr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Xt(e,t,r),edge:t=>Rn(e,t)}),Ma=(e,t,r,n,o)=>{if(ut("stepPair","low",t),ut("stepPair","high",r),r<t)throw new RangeError(`stepPair: high must not precede low (low: ${t}, high: ${r})`);if(n!==-1&&n!==1)throw new RangeError(`stepPair: direction must be -1 or 1 (received: ${y(n)})`);switch(o.motion){case"shift":{if(o.edge!=="disable"&&o.edge!=="clamp")throw new RangeError(`stepPair: rule.edge must be "disable" or "clamp" (received: ${y(o.edge)})`);const a=n===1?r:t,i=n===1?t:r,u=e.stepEnd(i,n);if(u===null)return null;let m=e.stepEnd(a,n);if(m===null){const h=e.edge(n);if(o.edge==="disable"||h===null||(n===1?a>h:a<h))return null;m=h}return n===1?[u,m]:[m,u]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${y(o.shows)})`);const a=e.stepEnd(o.shows==="start"?t:r,n);return a===null?null:[a,a]}default:throw new RangeError(`stepPair: rule.motion must be one of "shift", "start", "end", "single" (received: ${y(o.motion)})`)}},Vs={"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"}},_s=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Ct=(e,t)=>{if(!_s(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${y(t)})`)},mr=(e,t)=>t===void 0?0:(Ct(e,t),t),Te=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${y(r)})`)},Zt=(e,t,r,n)=>r===void 0?n:(Te(e,t,r),r),kc=[31,28,31,30,31,30,31,31,30,31,30,31],Ys=719468,fo=146097,Ea=(e,t)=>t!==1?kc[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,Ha=(e,t,r,n)=>{const o=e*12+t+n,a=Math.floor(o/12),i=o-a*12;return[a,i,Math.min(r,Ea(a,i))]},yn=(e,t,r)=>{const n=t<2?e-1:e,o=Math.floor(n/400),a=n-o*400,i=t<2?t+10:t-2,u=Math.floor((153*i+2)/5)+r-1,m=a*365+Math.floor(a/4)-Math.floor(a/100)+u;return o*fo+m-Ys},Ji=e=>{const t=e+Ys,r=Math.floor(t/fo),n=t-r*fo,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(fo-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),u=i<10?i+2:i-10;return[r*400+o+(u<2?1:0),u,a-Math.floor((153*i+2)/5)+1]},Co=(e,t,r)=>e-(t<r?1:0),pt=(e,t,r=0)=>{if(Te("normalizeDateByUnit","unit",e),!Re(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${y(t)})`);Ct("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(Co(n.getFullYear(),n.getMonth(),r),r,1),n.setHours(0,0,0,0)):(e==="month"&&n.setDate(1),n.setHours(0,0,0,0)),n},O=(e,t,r=0)=>{Te("encode","unit",e),Ct("encode",r);const n=pt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:yn(o,a,n.getDate())},ee=(e,t,r=0)=>{Te("decode","unit",e),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),i=t-a*12;return n.setFullYear(a,i,1),n}const o=new Date(t*24*60*60*1e3);return n.setFullYear(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()),n},An=e=>`; ${e} instead of a sentinel for "no bound"`,Hs=An("minDate is required, so pass the earliest date to offer"),Xe=(e,t,r,n,o,a)=>{const i=Nn(r,n,o);if(i===null)throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${y(r)})${a}`);return i},Nn=(e,t,r)=>{const n=O(t,e,r);return Number.isInteger(n)?n:null},js=(e,t,r)=>{if(Te("addUnit","unit",e),!Re(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${y(t)})`);if(!Number.isInteger(r))throw new RangeError(`addUnit: amount must be an integer number of units (received: ${y(r)})`);const n=new Date(t.getTime());return r===0?n:e==="year"||e==="month"?(n.setFullYear(...Ha(n.getFullYear(),n.getMonth(),n.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},es=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,u,m]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:Ji(t),[h,f,S]=r==="year"||r==="month"?Ha(i,u,m,r==="year"?n*12:n):Ji(yn(i,u,m)+n);return e==="year"?Co(h,f,o):e==="month"?h*12+f:yn(h,f,S)},Us=(e,t,r,n=0)=>{if(Te("getMacroWindowStartDate","macroUnit",e),Te("getMacroWindowStartDate","microUnit",t),!Re(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${y(r)})`);return Ct("getMacroWindowStartDate",n),Xe("getMacroWindowStartDate","d",r,e,n,""),Xe("getMacroWindowStartDate","d",r,t,n,""),pt(t,pt(e,r,n),n)},zs=(e,t,r,n=0)=>{if(Te("getMacroWindowEndDate","macroUnit",e),Te("getMacroWindowEndDate","microUnit",t),!Re(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${y(r)})`);Ct("getMacroWindowEndDate",n);let o;const a=new Date(r.getTime());if(e==="year"&&t!=="year"){const[u,m]=Ha(Co(a.getFullYear(),a.getMonth(),n),n,1,11);o=t==="month"?u*12+m:yn(u,m,Ea(u,m))}else if(e==="month"&&t==="day")o=yn(a.getFullYear(),a.getMonth(),Ea(a.getFullYear(),a.getMonth()));else return Xe("getMacroWindowEndDate","d",r,t,n,""),pt(t,r,n);const i=ee(t,o,n);if(!Re(i))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${y(r)})`);return i},ts=(e,t,r)=>e<t?t:e>r?r:e,Rt=(e,t,r,n,o,a=0)=>{if(Te("resolveMacroWindow","macroUnit",e),Te("resolveMacroWindow","microUnit",t),Ct("resolveMacroWindow",a),po("macroRange",r,!0,"resolveMacroWindow"),!Re(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${y(n)})`);if(!Re(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${y(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${y(n)}, maxDate: ${y(o)})`);Xe("resolveMacroWindow","maxDate",o,t,a,""),Xe("resolveMacroWindow","macroRange[0]",r[0],e,a,""),Xe("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=O(e,r[1],a)<O(e,o,a)?ts(zs(e,t,r[1],a),n,o):o;return[pt(t,ts(Us(e,t,r[0],a),n,o),a),pt(t,i,a)]},Ws=(e,t)=>{if(!Re(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${y(e)})`);Ct("resolveQuarter",t);const r=pt("year",e,t).getFullYear(),n=new Date(e.getTime()),o=((n.getMonth()-t)%12+12)%12,a=Math.floor(o/3)+1;return n.setFullYear(r,t+3*(a-1),1),n.setHours(0,0,0,0),{year:r,quarter:a,startDate:n}},Ac={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},rs=new Map,Nc=(e,t)=>{const r=`${e}\0${t}`,n=rs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Ac[e]);return rs.set(r,o),o},Oc=4,Vc=6,Io=e=>e>=0?String(e).padStart(Oc,"0"):`-${String(-e).padStart(Vc,"0")}`,_c=(e,t)=>{const r=new Date(t.getTime()),n=Io(r.getFullYear());if(e==="year")return n;const o=String(r.getMonth()+1).padStart(2,"0");if(e==="month")return`${n}-${o}`;const a=String(r.getDate()).padStart(2,"0");return`${n}-${o}-${a}`},st=(e,t,r,n)=>(Te("formatLabel","unit",e),Re(t)?r?r(t,e,"period"):n===void 0?_c(e,t):Nc(e,n).format(t):""),Sr=(e,t,r,n)=>(Te("formatScreenReaderLabel","unit",e),st(e,t,r,n)),Yc=(e,t)=>{if(!Re(e))return"";Ct("formatQuarterLabel",t);const{quarter:r}=Ws(e,t);return`${st("year",pt("year",e,t))}-Q${r}`},De=(e,t,r,n=0)=>{if(Te("findNearestDateIndex","unit",r),Ct("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!Re(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${y(t)})`);const o=Xe("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=O(r,e[a],n))return 0;if(o>=O(r,e[i],n))return i;for(;a<=i;){const h=a+i>>1,f=O(r,e[h],n);if(f===o)return h;f<o?a=h+1:i=h-1}const u=Math.abs(O(r,e[a],n)-o),m=Math.abs(O(r,e[i],n)-o);return u<m?a:i},Hc=(e,t,r,n,o=0)=>(Te("getSortedAllowedDates","unit",t),ur("getSortedAllowedDates",ko(e),t,r,n,o).dates),ko=e=>({list:e,path:"allowedDates",inheritedBy:null}),ur=(e,t,r,n,o,a)=>{Ct(e,a);const{list:i,path:u}=t,m=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(Jr(e,`${u}${m}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[L,Y]of[["minDate",n],["maxDate",o]])if(!Re(Y))throw new RangeError(`${e}: ${L} must be a valid Date (received: ${y(Y)})`);const h=Xe(e,"minDate",n,r,a,""),f=Xe(e,"maxDate",o,r,a,""),S=new Map;for(let L=0;L<i.length;L++){const Y=i[L];if(!Re(Y))throw new RangeError(`${e}: ${u}[${L}]${m} must be a valid Date (received: ${y(Y)})`);const w=Xe(e,`${u}[${L}]${m}`,Y,r,a,"");w<h||w>f||S.has(w)||S.set(w,pt(r,Y,a))}if(S.size===0)throw new RangeError(`${e}: every ${u} entry${m} falls outside [minDate, maxDate] (minDate: ${y(n)}, maxDate: ${y(o)}, entries: ${i.length})`);const v=Array.from(S.keys()).sort((L,Y)=>L-Y);return{keys:v,dates:v.map(L=>S.get(L))}},ja=(e,t,r,n,o,a)=>{const{keys:i,dates:u}=ur(e,t,r,n,o,a);return u.length===0?null:{...en(i,null,null),dates:u}},Pn=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),to=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=De(e,n,t,o);if(r==="time"){const u=e[0].getTime(),m=e[a].getTime()-u;return m<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-u)/m))}return i/a},ro=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const u=e[0].getTime(),m=e[a].getTime()-u;return m<=0?0:De(e,new Date(u+i*m),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},ya=(e,t,r,n,o,a,i)=>{let u=r,m=n;return i?(u=t,m=t):e==="low"?t>n?(u=n,m=t):u=t:t<r?(m=r,u=t):m=t,[Math.max(o,Math.min(a,u)),Math.max(o,Math.min(a,m))]},Bs=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:u,unit:m,yearStartMonth:h=0})=>{if(Te("calculateConnectDragValues","unit",m),a){const w=i.length-1;if(w<=0)return[0,0];const b=Math.max(0,Math.min(w,Math.round(t))),c=Math.max(b,Math.min(w,Math.round(r)));if(u==="time"){const A=i[0].getTime(),te=i[w].getTime(),G=i[b].getTime(),he=i[c].getTime()-G;let N=G+e*(te-A),X=N+he;N<A&&(N=A,X=A+he),X>te&&(X=te,N=te-he);const Q=De(i,new Date(N),m,h),R=De(i,new Date(X),m,h);return[Q,Math.max(Q,R)]}const g=Math.round(e*w);let d=b+g,oe=c+g;return d<0&&(oe+=-d,d=0),oe>w&&(d-=oe-w,oe=w),[Math.max(0,Math.min(w,d)),Math.max(0,Math.min(w,oe))]}const f=w=>Math.max(n,Math.min(o,w)),S=o-n;if(S<=0)return[f(t),f(r)];const v=Math.round(e*S);let L=t+v,Y=r+v;return L<n&&(Y+=n-L,L=n),Y>o&&(L-=Y-o,Y=o),[f(L),f(Y)]},Fs=(e,t,r,n,o,a,i,u)=>{let m=0,h=!1,f=!1;switch(e){case"ArrowRight":case"ArrowUp":m=u;break;case"ArrowLeft":case"ArrowDown":m=-u;break;case"PageUp":m=u*5;break;case"PageDown":m=-u*5;break;case"Home":h=!0;break;case"End":f=!0;break;default:return null}if(i){let L=r;return h?L=o:f?L=a:L=Math.max(o,Math.min(a,r+m)),[L,L]}let S=r,v=n;return t==="low"?h?S=o:f?S=n:S=Math.max(o,Math.min(n,r+m)):h?v=r:f?v=a:v=Math.max(r,Math.min(a,n+m)),[S,v]},Ks=8,Gs=2,qs=16,jc=12,Uc=90,Xs=(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}},Ua=(e,t)=>{const r=t?.estimatedHeightPx??qs,o=Ks+(t?.anchorGapY??Gs)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},za=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??qs,u=o?.paddingPx??jc,m=o?.maxAngleDeg??Uc,h=Ks+(o?.anchorGapY??Gs),f=Ua(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return f;const S=Math.max(0,t-e)/100*r,v=a+u;if(S>=v)return f;const L=Math.max(0,Math.min(1,(v-S)/v)),w=L*L*L*(L*(L*6-15)+10)*m,b=n==="top"?-w:w,c=Xs(a,i,w),g=h+c.acrossPx,d=n==="top"?-g:+g,oe=2*c.alongPx,A=Math.max(0,(oe+u-S)/2);return{lowAngleDeg:b,highAngleDeg:b,lowOffsetX:-A,highOffsetX:A,lowOffsetY:d,highOffsetY:d,isSlanted:L>.001,proximity:L}},Zs=e=>({...e,lowOffsetX:0,highOffsetX:0}),Ht=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Dt=(e,t)=>{const r=e==="macro"?t.macroAllowedDates:t.microAllowedDates;return r!==void 0?{list:r,path:e==="macro"?"macroAllowedDates":"microAllowedDates",inheritedBy:null}:{list:t.allowedDates,path:"allowedDates",inheritedBy:e}},go=(e,t,r,n)=>e==="pan"?Ic(t,r,Math.max(r,n)):co(t,r,Math.max(r,n)),Wa=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},Qs=(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 Js(e,t,r,n,o,a,i="macro-top",u=.05,m=!0,h="range"){if(Wa(t,i)==="macro"){const v=Math.abs(e-r),L=Math.abs(e-n);return v<=u&&v<=L?"macro-low":L<=u&&L<v?"macro-high":m&&e>=r&&e<=n?"macro-connect":v<L?"macro-low":"macro-high"}if(h==="point")return"micro-point";const f=Math.abs(e-o),S=Math.abs(e-a);return f<=u&&f<=S?"micro-low":S<=u&&S<f?"micro-high":m&&e>=o&&e<=a?"micro-connect":f<S?"micro-low":"micro-high"}function el(e,t,r,n,o){if(e==="macro-connect"){const[h,f]=Ya(t-r,n,o);return[h,f,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,u]=bo(a,t,n,o),m=yo(a,t,n,o);return[i,u,m==="low"?"macro-low":"macro-high"]}function tl(e,t,r,n,o){if(e==="micro-point"){const[h]=bo("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,f]=Ya(t-r,n,o);return[h,f,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,u]=bo(a,t,n,o),m=yo(a,t,n,o);return[i,u,m==="low"?"micro-low":"micro-high"]}const vn=s.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:n=!0})=>{let o,a;r?(o=n?"M 7.375 0.625 A 7.375 7.375 0 0 0 7.375 15.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 1 0.625 15.375 Z",a=`period-slider-knob period-slider-knob-svg is-vertical ${n?"is-semicircle-left":"is-semicircle-right"}`):(o=t?"M 0.625 7.375 A 7.375 7.375 0 0 1 15.375 7.375 Z":"M 0.625 0.625 A 7.375 7.375 0 0 0 15.375 0.625 Z",a=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const i=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return $.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:$.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});vn.displayName="VernierKnobSvg";const zc=(e,t,r,n)=>{if(!Re(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${y(e)})`);if(!Re(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${y(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${y(e)}, maxDate: ${y(t)})`);for(const o of r)Xe("PeriodSlider","minDate",e,o,n,Hs)},po=(e,t,r,n="PeriodSlider")=>{if(!Tt(t)||t.length!==2){const i=r?"is required and must":"must";throw new RangeError(`${n}: ${e} ${i} be a [start, end] Date tuple (received: ${y(t)})`)}const[o,a]=t;if(!Re(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${y(o)})`);if(!Re(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${y(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${y(o)}, end: ${y(a)})`)},rl=(e,t)=>{if(!Re(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${y(t)})`)},Fr=(e,t,r,n,o,a)=>{const i=Xe("PeriodSlider",e,t,r,a,"");if(i<O(r,n,a)||i>O(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${y(t)}, minDate: ${y(n)}, maxDate: ${y(o)})`)},Wc=(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&&(po(o,a,!1),Fr(`${o}[0]`,a[0],e.unit,t,r,n),Fr(`${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&&(rl(o,a),Fr(o,a,e.unit,t,r,n))}},Bc=(e,t,r)=>{const n=e.yearStartMonth??0;po("macroRange",e.macroRange,!0),Xe("PeriodSlider","macroRange[0]",e.macroRange[0],Zt("PeriodSlider","macroUnit",e.macroUnit,e.unit),n,"");const o=Zt("PeriodSlider","microUnit",e.microUnit,e.unit),a=e.microRange!==void 0||e.defaultMicroRange!==void 0||e.onChangeMicroRange!==void 0,i=e.microValue!==void 0||e.defaultMicroValue!==void 0||e.onChangeMicroPoint!==void 0;if(a&&i)throw new RangeError("PeriodSlider: vernier mode takes either a micro range (microRange / defaultMicroRange / onChangeMicroRange) or a micro point (microValue / defaultMicroValue / onChangeMicroPoint), never both");if(i){for(const h of["microValue","defaultMicroValue"]){const f=e[h];f!==void 0&&(rl(h,f),Fr(h,f,o,t,r,n))}const m=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(m===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[m,m]}}for(const m of["microRange","defaultMicroRange"]){const h=e[m];h!==void 0&&(po(m,h,!1),Fr(`${m}[0]`,h[0],o,t,r,n),Fr(`${m}[1]`,h[1],o,t,r,n))}const u=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(u!==void 0)return{shape:"range",selection:u};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")},gn=(e,t,r,n,o,a,i,u,m)=>{const h=De(e,n,t,m),f=De(e,o,t,m);return i?h:u?f:Math.max(h,Math.min(f,De(e,r,t,m)+a))},ga=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function Fc(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Kc(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const ns=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback((a,i)=>{const u=r.current;if(u!==null&&u[0].getTime()===a.getTime()&&u[1].getTime()===i.getTime())return;const m=[a,i];r.current=m,t(m)},[]),o=s.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Ao=(e,t,r)=>{try{Intl.DateTimeFormat.supportedLocalesOf([r])}catch{throw new RangeError(`${e}: ${t} must be a valid BCP 47 language tag (received: ${y(r)})`)}},Wr=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const u of i){const m=u.borderBoxSize?.[0];m!==void 0&&t(h=>h!==null&&Math.abs(h.widthPx-m.inlineSize)<.5&&Math.abs(h.heightPx-m.blockSize)<.5?h:{widthPx:m.inlineSize,heightPx:m.blockSize})}});a.observe(o),r.current=a},[]);return s.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},ha=(e,t)=>{const r=ho(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},ho=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Gc=e=>{const t={};let r=0;for(const o of e){const{side:a,box:i}=o;if(i===null)continue;let u;if(o.reach==="inline-size")u=i.widthPx,r=Math.max(r,i.heightPx/2);else{const m=Xs(i.widthPx,i.heightPx,o.angleDeg);u=o.centreOffsetPx===null?2*m.acrossPx:Math.abs(o.centreOffsetPx)+m.acrossPx,r=Math.max(r,m.alongPx+Math.abs(o.alongPushPx))}t[`--ps-label-reach-${a}`]=`${Math.ceil(u)}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}},os=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),as=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),vo=(e,t)=>({"--ps-tooltip-tx":ca(e,"tx",t.tx),"--ps-tooltip-ty":ca(e,"ty",t.ty),"--ps-tooltip-rot":ca(e,"rot",t.rot)}),wa=(e,t,r,n)=>{const o=Ua(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=za(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?Zs(a):a,u=Eo[e],m={low:os(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:os(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:vo(u.low,m.low),highStyle:vo(u.high,m.high),placements:m}},is={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},ss=(e,t,r)=>{const n=Ua(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:is,highStyle:is,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const m=za(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?Zs(m):m}const i=Eo.flat,u={low:as(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:as(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...vo(i.low,u.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...vo(i.high,u.high)},placements:o?u:null}},qc={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Xc={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"}},ls={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},Zc={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Dn} ${Qi.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${ls.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Dn} ${Qi.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${ls.vertical}`}},cs={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"}},us=(e,t)=>{e.setPointerCapture(t)},Qc=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:u="",showStepper:m=!0,tooltipStyle:h="always",labelPosition:f="top",autoSlantLabels:S=!0,isVertical:v=!1,hideConnectBar:L=!1,showTicks:Y=!1,colorScheme:w="blue-rose",formatLocale:b}=e;Te("PeriodSlider","unit",t);const c=e.mode==="vernier"?Zt("PeriodSlider","macroUnit",e.macroUnit,t):t,g=e.mode==="vernier"?Zt("PeriodSlider","microUnit",e.microUnit,t):t,d=mr("PeriodSlider",e.yearStartMonth);zc(r,n,e.mode==="vernier"?[c,g,t]:[t],d),Wc(e,r,n),b!==void 0&&Ao("PeriodSlider","formatLocale",b);const oe=e.mode==="vernier"?Bc(e,r,n):null,A=oe!==null&&oe.shape==="point",te=$o(e.locale,e.labels),G=Vs[w],he=s.useId(),N=s.useRef(e),X=r.getTime(),Q=n.getTime(),R=e.mode==="vernier",M=s.useMemo(()=>R?[]:ur("PeriodSlider",ko(o),t,r,n,d).dates,[R,o,t,X,Q,d]),E=M.length>0,{rangeMin:B,rangeMax:H}=s.useMemo(()=>E?{rangeMin:0,rangeMax:M.length-1}:{rangeMin:O(t,r,d),rangeMax:O(t,n,d)},[E,M,t,X,Q,d]),j=e.mode==="point",I=s.useCallback(l=>{if(E){const p=Math.max(0,Math.min(M.length-1,Math.round(l)));return M[p]}return ee(t,Math.round(l),d)},[E,M,t,d]),_=s.useCallback(l=>{if(l===void 0)return B;const p=pt(t,l,d);return E?De(M,p,t,d):O(t,p,d)},[E,M,t,B,d]),[ie,pe]=s.useState(()=>oe===null?null:oe.selection),Z=ie??(oe===null?null:oe.selection),J=Z===null?null:Fc(Z,A);s.useLayoutEffect(()=>{J!==Z&&pe(l=>l===ie?J:l)});const ne=e.mode==="vernier"?e.microValue?.getTime():void 0,xe=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,ne]),ae=ns(),fe=ns(),Pe=e.mode!=="vernier"?null:A?xe??J:e.microRange!==void 0?e.microRange:J,Ke=Pe===null?null:fe.shown??Pe,T=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?Ke?.[0]:void 0,se=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?Ke?.[1]:void 0,le=e.mode==="point"?e.value??e.defaultValue:void 0,Me=e.mode==="point"?le?.getTime():T?.getTime(),_e=e.mode==="range"?se?.getTime():Me,[Ce,Ge]=s.useMemo(()=>{if(e.mode==="point"){const x=_(le);return[x,x]}const l=_(T),p=_(se);return[Math.min(l,p),Math.max(l,p)]},[e.mode,Me,_e,_,le,T,se]),Ve=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:A?e.microValue!==void 0:e.microRange!==void 0,[lt,re]=s.useState(()=>R?null:[Ce,Ge]),nt=lt??[Ce,Ge],[ft,Ze]=s.useState(null),[Ee,ze]=s.useState(null),He=s.useRef(null),[ht,qe]=s.useState("high"),[dt,C]=s.useState(null),[q,We]=s.useState(null),we=ft?ft[0]:Ve?Ce:nt[0],ge=ft?ft[1]:Ve?Ge:nt[1],Mt=s.useRef([we,ge]),It=e.mode==="vernier"?e.vernierOrientation??(v?"macro-left":"macro-top"):"macro-top",W=It==="macro-top"||It==="macro-left",V=e.mode==="vernier"?e.showVernierProjection??!0:!1,ce=e.mode==="vernier"?e.showVernierTicks??!0:!1,Se=e.mode==="vernier"?e.showHairline??!0:!1,Ye=R?Ht("macro",e):E,P=R?Ht("micro",e):E,U=R?Dt("macro",e).list:o,de=R?Dt("micro",e).list:o,Ie=R?e.formatMacroLabel??e.formatLabel:e.formatLabel,Le=R?e.formatMicroLabel??e.formatLabel:e.formatLabel,ot=T?.getTime(),Qe=se?.getTime(),[ke,Et]=s.useState(null),yt=s.useRef(null),[yr,Pr]=s.useState(()=>A?"micro-point":"micro-high"),Je=Kc(yr,A);s.useLayoutEffect(()=>{Je!==yr&&Pr(l=>l===yr?Je:l)});const wt=s.useMemo(()=>O(c,r,d),[X,c,d]),kt=s.useMemo(()=>O(c,n,d),[Q,c,d]),Vn=s.useMemo(()=>R&&P?ja("PeriodSlider",Dt("micro",e),g,r,n,d):null,[R,P,de,g,X,Q,d]),Ae=s.useMemo(()=>R&&Ye?ur("PeriodSlider",Dt("macro",e),c,r,n,d).dates:[],[R,Ye,U,c,X,Q,d]),Xa=l=>[Math.max(wt,Math.min(kt,O(c,l[0],d))),Math.max(wt,Math.min(kt,O(c,l[1],d)))],[Za,Qa]=e.mode!=="vernier"?[wt,kt]:Xa(e.macroRange),[et,ct]=ae.shown===null?[Za,Qa]:Xa(ae.shown),fr=s.useMemo(()=>ee(c,et,d),[c,et,d]),gr=s.useMemo(()=>ee(c,ct,d),[c,ct,d]),_n=s.useMemo(()=>e.mode!=="vernier"?[r,n]:Rt(c,g,[fr,gr],r,n,d),[e.mode,fr,gr,c,g,X,Q,d]),je=s.useMemo(()=>O(g,_n[0],d),[g,_n,d]),at=s.useMemo(()=>O(g,_n[1],d),[g,_n,d]),_o=(l,p)=>Vn===null?[]:Pn(Vn,en(Vn.ascending,l,p)),be=s.useMemo(()=>_o(je,at),[Vn,je,at]),Qt=Ye&&Ae.length>0,Pt=P&&be.length>0,Ja=Qt?O(c,Ae[0],d):wt,ei=Qt?O(c,Ae[Ae.length-1],d):kt,ti=Pt?O(g,be[0],d):je,Yo=Pt?O(g,be[be.length-1],d):at,pl=Math.min(Ja,et),vl=Math.max(ei,ct),Jt=(l,p,x,D)=>p.length>0?O(g,p[De(p,l,g,d)],d):Math.max(x,Math.min(D,O(g,l,d))),Lr=Pt?be:[],Be=s.useMemo(()=>Ke===null?je:Jt(Ke[0],Lr,je,at),[ot,je,at,g,Ke,Lr]),it=s.useMemo(()=>Ke===null?at:Jt(Ke[1],Lr,je,at),[Qe,je,at,g,Ke,Lr]),$r=s.useMemo(()=>ee(g,Be,d),[g,Be,d]),Tr=s.useMemo(()=>ee(g,it,d),[g,it,d]),ri=!R||Pe===null?null:{macroUnit:c,macroLowEnc:Za,macroHighEnc:Qa,microUnit:g,microLowEnc:O(g,Pe[0],d),microHighEnc:O(g,Pe[1],d)},Ho=s.useRef(ri),jo=Math.max(1,kt-wt),Lt=Qt?to(Ae,c,a,fr,d):Math.max(0,Math.min(1,(et-wt)/jo)),At=Math.max(Lt,Qt?to(Ae,c,a,gr,d):Math.min(1,(ct-wt)/jo)),ni=l=>Math.max(Ja,Math.min(ei,Math.round(wt+l*jo))),Yn=Math.max(1,at-je),Cr=Pt?to(be,g,a,$r,d):Math.max(0,Math.min(1,(Be-je)/Yn)),tn=Math.max(Cr,Pt?to(be,g,a,Tr,d):Math.min(1,(it-je)/Yn)),Uo=s.useRef({timerId:null,emit:null}),Hn=s.useRef({timerId:null,emit:null}),jn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const l=[Uo,Hn,jn];return()=>{for(const p of l)ga(p.current)}},[]);const Ir=s.useCallback((l,p,x)=>{ga(l);const{debounceMs:D}=N.current;if(x||!D||D<=0){p();return}l.emit=p,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,p()},D)},[]),oi=s.useCallback(l=>{const p=l.emit;ga(l),p?.()},[]),kr=s.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),X),Q)),[X,Q]),er=s.useCallback((l,p,x=!1)=>{const[D,k]=Mt.current;if((N.current.mode==="point"?l===D:l===D&&p===k)&&Uo.current.timerId===null)return;const K=I(l),F=I(p),me=()=>{const ve=N.current;ve.mode==="point"?ve.onChangePoint?.(K):ve.mode==="range"&&ve.onChangeRange?.(K,F)};Ir(Uo.current,me,x)},[I,Ir]),hr=s.useCallback((l,p,x=!1)=>{const D=Ho.current;if(N.current.mode!=="vernier"||D===null)return;const k=kr(l),z=kr(p);O(D.macroUnit,k,d)===D.macroLowEnc&&O(D.macroUnit,z,d)===D.macroHighEnc&&Hn.current.timerId===null||Ir(Hn.current,()=>{const K=N.current;K.mode==="vernier"&&K.onChangeMacroRange?.(k,z)},x)},[kr,Ir,d]),vt=s.useCallback((l,p,x=!1)=>{const D=N.current,k=Ho.current;if(D.mode!=="vernier"||k===null)return;const z=kr(l),K=kr(p);O(k.microUnit,z,d)===k.microLowEnc&&O(k.microUnit,K,d)===k.microHighEnc&&jn.current.timerId===null||((A?D.microValue===void 0:D.microRange===void 0)&&pe([z,K]),Ir(jn.current,()=>{const F=N.current;if(F.mode==="vernier"){if(A){F.onChangeMicroPoint?.(z);return}F.onChangeMicroRange?.(z,K)}},x))},[kr,Ir,A,d]),ai=s.useCallback((l,p=!1)=>{vt(l,l,p)},[vt]),wr=s.useCallback(l=>{if(E&&a==="time"&&M.length>1){const D=Math.max(0,Math.min(M.length-1,Math.round(l))),k=M[0].getTime(),K=M[M.length-1].getTime()-k;if(K<=0)return 0;const F=M[D].getTime();return Math.max(0,Math.min(100,(F-k)/K*100))}const p=H-B;if(p<=0)return 0;const x=(l-B)/p*100;return Math.max(0,Math.min(100,x))},[E,a,M,B,H]),zo=s.useCallback(l=>{const p=Math.max(0,Math.min(100,l));if(E){if(a==="time"&&M.length>1){const k=M[0].getTime(),K=M[M.length-1].getTime()-k,F=k+p/100*K;return De(M,new Date(F),t,d)}const D=Math.round(p/100*(M.length-1));return Math.max(0,Math.min(M.length-1,D))}const x=B+p/100*(H-B);return Math.round(x)},[E,a,M,B,H,t,d]),rn=s.useRef(null),ii=s.useRef(null),si=s.useRef(0),gt=s.useRef(null),Wo=s.useRef(null),li=s.useRef(null),ci=s.useRef(null),[Bo,ui]=s.useState(0),[xl,Ar]=Wr(),[Sl,di]=Wr(),[Dl,mi]=Wr(),[Rl,fi]=Wr(),[Ml,Fo]=Wr(),[El,gi]=Wr(),yl=j?Ar===null?void 0:{estimatedWidthPx:Ar.widthPx,estimatedHeightPx:Ar.heightPx}:ha(Ar,di),Ko=!j&&we===ge,Go=et===ct,qo=!A&&Be===it,Pl=W?"top":"bottom",Ll=W?"bottom":"top",hi=S&&!v,$l=hi&&!A,Xo={isPointMode:j,isVertical:v,autoSlantLabels:S,isMerged:Ko,trackLengthPx:Bo,labelPosition:f,config:yl},Zo={trackLengthPx:Bo,labelPosition:Pl,config:ha(mi,fi),isMerged:Go,isSlantable:hi},Qo={trackLengthPx:Bo,labelPosition:Ll,config:ha(Fo,gi),isMerged:qo,isSlantable:$l};s.useEffect(()=>{const l=gt.current;if(!l)return;const p=()=>{const D=l.getBoundingClientRect(),k=v?D.height:D.width;k>0&&ui(z=>Math.abs(z-k)<.5?z:k)};if(p(),typeof ResizeObserver<"u"){const D=new ResizeObserver(k=>{for(const z of k){const K=v?z.contentRect.height:z.contentRect.width;K>0&&ui(F=>Math.abs(F-K)<.5?F:K)}});return D.observe(l),()=>D.disconnect()}const x=l.ownerDocument.defaultView;if(x)return x.addEventListener("resize",p),()=>x.removeEventListener("resize",p)},[v]);const Nr=s.useCallback((l,p,x)=>{const D=v?x.height:x.width;if(!(Number.isFinite(D)&&D>0))return null;const k=v?x.bottom-p:l-x.left;return Number.isFinite(k)?Math.max(0,Math.min(1,k/D)):null},[v]),wi=s.useCallback((l,p)=>{const x=gt.current;if(!x)return null;const D=Nr(l,p,x.getBoundingClientRect());return D===null?null:D*100},[Nr]),nn=s.useRef(null),Wt=s.useRef(null),Un=s.useRef({macroLowRatio:Lt,macroHighRatio:At,isVertical:v,isMacroFirstRail:W}),bi=s.useRef({flat:Xo,macro:Zo,micro:Qo});s.useLayoutEffect(()=>{Un.current={macroLowRatio:Lt,macroHighRatio:At,isVertical:v,isMacroFirstRail:W},bi.current={flat:Xo,macro:Zo,micro:Qo},N.current=e,Mt.current=[we,ge],Ho.current=ri,He.current=Ee,yt.current=ke});const pi=(l,p)=>{const x=Un.current;Wo.current?.setAttribute("d",ua(l,p,x.isVertical,x.isMacroFirstRail))},Tl=(l,p,x)=>{const D=bi.current;return l==="flat"?ss(p*100,x*100,D.flat).placements:wa(l,p,x,l==="macro"?D.macro:D.micro).placements},on=(l,p,x)=>{const D=gt.current;if(!D)return;nn.current={rail:l,lowRatio:p,highRatio:x},uc(D,l,p,x);const k=Tl(l,p,x);k!==null&&cc(D,l,k),l==="macro"&&pi(p,x)},br=s.useCallback(()=>{Wt.current!==null&&(clearTimeout(Wt.current),Wt.current=null);const l=gt.current;l&&(l.removeAttribute(sa),l.style.removeProperty(la))},[]),vi=()=>{const l=gt.current;if(nn.current===null||!l){nn.current=null;return}nn.current=null,Wt.current!==null&&clearTimeout(Wt.current),l.style.setProperty(la,`${Gi}ms`),l.setAttribute(sa,"true"),dc(l),pi(Un.current.macroLowRatio,Un.current.macroHighRatio),Wt.current=setTimeout(()=>{Wt.current=null,l.removeAttribute(sa),l.style.removeProperty(la)},Gi)};s.useLayoutEffect(()=>{const l=nn.current;l!==null&&on(l.rail,l.lowRatio,l.highRatio)}),s.useEffect(()=>()=>{Wt.current!==null&&clearTimeout(Wt.current)},[]);const Or=s.useRef(null),Vr=s.useRef(null),Nt=s.useRef(null),Jo=s.useRef(null),an=s.useRef(null),tr=s.useCallback(()=>Or.current!==null||Vr.current!==null,[]),xi=l=>{if(i)return;if(R){const ue=Vr.current;if(!ue||l.pointerId!==ue.pointerId||!gt.current)return;const $t=Nr(l.clientX,l.clientY,gt.current.getBoundingClientRect());if($t===null)return;if(ue.handle==="macro-low"||ue.handle==="macro-high"||ue.handle==="macro-connect"){const[tt,Fe,Bt]=el(ue.handle,$t,ue.startPointerRatio,ue.startMacroLowRatio,ue.startMacroHighRatio);on("macro",tt,Fe),Bt!==yt.current&&(yt.current=Bt,Et(Bt),Pr(Bt));let Vt,bt,Ft;if(Qt){const Kt=ro(Ae,c,a,tt,d),mn=Math.max(Kt,ro(Ae,c,a,Fe,d));bt=Ae[Kt],Ft=Ae[mn],Vt=O(c,bt,d)}else Vt=ni(tt),bt=ee(c,Vt,d),Ft=ee(c,ni(Fe),d);ae.show(bt,Ft);const rr=`${bt.getTime()}_${Ft.getTime()}`;rr!==Jo.current&&(Jo.current=rr,hr(bt,Ft));const[dn,tc]=Rt(c,g,[bt,Ft],r,n,d),Zn=O(g,dn,d),Qn=O(g,tc,d),Wi=P?_o(Zn,Qn):[],Bi={kind:"range",min:Zn,max:Qn};let vr,xr;if(ue.handle==="macro-connect"){const Kt=Vt-ue.startMacroLowEnc,mn=go("pan",Bi,es(g,ue.initialMicroLowEnc,c,Kt,d),es(g,ue.initialMicroHighEnc,c,Kt,d));if(mn===null)return;vr=ee(g,mn[0],d),xr=ee(g,mn[1],d)}else{const Kt=go("resize",Bi,ue.initialMicroLowEnc,ue.initialMicroHighEnc);if(Kt===null)return;vr=ee(g,Kt[0],d),xr=ee(g,Kt[1],d)}const Fi=Jt(vr,Wi,Zn,Qn),rc=Math.max(Fi,Jt(xr,Wi,Zn,Qn));vr=ee(g,Fi,d),xr=ee(g,rc,d),fe.show(vr,xr);const Ki=`${vr.getTime()}_${xr.getTime()}`;Ki!==an.current&&(an.current=Ki,vt(vr,xr))}else if(ue.handle==="micro-low"||ue.handle==="micro-high"||ue.handle==="micro-connect"||ue.handle==="micro-point"){const[tt,Fe,Bt]=tl(ue.handle,$t,ue.startPointerRatio,ue.startMicroLowRatio,ue.startMicroHighRatio);on("micro",tt,Fe),Bt!==yt.current&&(yt.current=Bt,Et(Bt),Pr(Bt));let Vt,bt;if(Pt){const rr=ro(be,g,a,tt,d),dn=Math.max(rr,ro(be,g,a,Fe,d));Vt=be[rr],bt=be[dn]}else{const rr=Jt(ee(g,Math.round(je+tt*Yn),d),Lr,je,at),dn=Math.max(rr,Jt(ee(g,Math.round(je+Fe*Yn),d),Lr,je,at));Vt=ee(g,rr,d),bt=ee(g,dn,d)}fe.show(Vt,bt);const Ft=`${Vt.getTime()}_${bt.getTime()}`;Ft!==an.current&&(an.current=Ft,vt(Vt,bt))}return}const p=Or.current;if(!p||l.pointerId!==p.pointerId||!gt.current)return;const x=gt.current.getBoundingClientRect(),D=v?l.clientY:l.clientX,k=v?x.height:x.width;if(!(Number.isFinite(k)&&k>0))return;if(p.handle==="connect"){const ue=v?(p.startPointerPos-D)/k:(D-p.startPointerPos)/k,[$t,tt]=Ya(ue,p.startLowRatio,p.startHighRatio);on("flat",$t,tt);const Fe=Bs({posDiffPct:ue,startLowVal:p.startLowVal,startHighVal:p.startHighVal,rangeMin:B,rangeMax:H,isDiscrete:E,sortedAllowedDates:M,snapMode:a,unit:t,yearStartMonth:d});if(Nt.current&&Nt.current[0]===Fe[0]&&Nt.current[1]===Fe[1])return;Nt.current=Fe,Ze(Fe),er(Fe[0],Fe[1],!1);return}const z=Nr(l.clientX,l.clientY,x);if(z===null)return;const[K,F]=bo(j?"point":p.handle,z,p.startLowRatio,p.startHighRatio);on("flat",K,F);const me=zo(z*100),[ve,Ne]=ya(p.handle,me,p.startLowVal,p.startHighVal,B,H,j);if((!Nt.current||Nt.current[0]!==ve||Nt.current[1]!==Ne)&&(Nt.current=[ve,Ne],Ze([ve,Ne]),er(ve,Ne,!1)),!j&&(p.handle==="low"||p.handle==="high")){const ue=yo(p.handle,z,p.startLowRatio,p.startHighRatio);He.current!==ue&&(He.current=ue,ze(ue),qe(ue))}},Si=()=>{vi(),Jo.current=null,an.current=null,Vr.current=null,yt.current=null,Et(null),ae.release(),fe.release(),oi(Hn.current),oi(jn.current)},Di=()=>{vi();const l=Nt.current??ft;l&&(er(l[0],l[1],!0),re(l)),Nt.current=null,Ze(null),Or.current=null,He.current=null,ze(null)},Ri=l=>{if(R){const x=Vr.current;if(!x||l.pointerId!==x.pointerId)return;Si();return}const p=Or.current;!p||l.pointerId!==p.pointerId||Di()},Mi=()=>{Vr.current!==null&&Si(),Or.current!==null&&Di()},ea=s.useRef(xi),Ei=s.useRef(Ri),yi=s.useRef(Mi);s.useLayoutEffect(()=>{ea.current=xi,Ei.current=Ri,yi.current=Mi});const Pi=s.useRef(R);s.useEffect(()=>{Pi.current!==R&&(Pi.current=R,yi.current())},[R]);const Li=Ee!==null||ke!==null;s.useEffect(()=>{if(!Li)return;const l=rn.current?.ownerDocument.defaultView;if(!l)return;const p=D=>ea.current(D),x=D=>Ei.current(D);return l.addEventListener("pointermove",p),l.addEventListener("pointerup",x),l.addEventListener("pointercancel",x),l.addEventListener("lostpointercapture",x),()=>{l.removeEventListener("pointermove",p),l.removeEventListener("pointerup",x),l.removeEventListener("pointercancel",x),l.removeEventListener("lostpointercapture",x)}},[Li]);const ta=s.useCallback((l,p,x,D)=>{br(),us(l,p),Or.current={pointerId:p,handle:x,startPointerPos:D,startLowVal:we,startHighVal:ge,startLowRatio:wr(we)/100,startHighRatio:wr(ge)/100},He.current=x,ze(x),x!=="connect"&&qe(x)},[we,ge,wr]),$i=s.useCallback((l,p,x,D)=>{N.current.mode==="vernier"&&(br(),us(l,p),Vr.current={pointerId:p,handle:x,startPointerRatio:D,startMacroLowRatio:Lt,startMacroHighRatio:At,startMicroLowRatio:Cr,startMicroHighRatio:tn,startMacroLowEnc:et,initialMicroLowEnc:Be,initialMicroHighEnc:it},yt.current=x,Et(x),Pr(x))},[Lt,At,Cr,tn,et,Be,it]),Ti=l=>p=>{if(i||tr())return;p.stopPropagation(),p.preventDefault(),qe(l);const x=v?p.clientY:p.clientX;ta(p.currentTarget,p.pointerId,l,x)},Ci=l=>()=>{i||He.current!==null||qe(l)},zn=l=>()=>{i||yt.current!==null||Pr(l)},_r=l=>p=>{if(i||tr())return;p.stopPropagation(),p.preventDefault();const x=gt.current;if(!x)return;const D=Nr(p.clientX,p.clientY,x.getBoundingClientRect());D!==null&&$i(p.currentTarget,p.pointerId,l,D)},Cl=l=>{if(i||L||tr())return;l.stopPropagation(),l.preventDefault();const p=v?l.clientY:l.clientX;ta(l.currentTarget,l.pointerId,"connect",p)},Il=l=>{if(i||tr())return;if(R){const F=gt.current;if(!F)return;const me=F.getBoundingClientRect(),ve=Nr(l.clientX,l.clientY,me);if(ve===null)return;const Ne=v?l.clientX-(me.left+me.width/2):l.clientY-(me.top+me.height/2),ue=Js(ve,Ne,Lt,At,Cr,tn,It,void 0,!L,A?"point":"range");$i(l.currentTarget,l.pointerId,ue,ve),ea.current(l.nativeEvent);return}const p=wi(l.clientX,l.clientY);if(p===null)return;const x=zo(p);let D="low";if(!j){const F=Math.abs(x-we),me=Math.abs(x-ge);F<me?D="low":me<F?D="high":D=x>ge?"high":"low"}qe(D);const[k,z]=ya(D,x,we,ge,B,H,j);Ze([k,z]),er(k,z,!0);const K=v?l.clientY:l.clientX;ta(l.currentTarget,l.pointerId,D,K)},kl=l=>{if(i||R||Ee!==null)return;const p=wi(l.clientX,l.clientY);if(p===null)return;const x=zo(p);C(x),We(wr(x))},Al=()=>{C(null),We(null)},Ii=l=>p=>{if(i||tr())return;qe(l);const x=Fs(p.key,l,we,ge,B,H,j,1);x&&(p.preventDefault(),br(),Ve||re(x),er(x[0],x[1],!0))},Yr=(l,p,x)=>{if(Pe===null)return;const[D,k]=Rt(c,g,[l,p],r,n,d),z=O(g,D,d),K=O(g,k,d),F=P?_o(z,K):[],me=go(x,{kind:"range",min:z,max:K},O(g,Pe[0],d),O(g,Pe[1],d));if(me===null)return;const ve=Jt(ee(g,me[0],d),F,z,K),Ne=Math.max(ve,Jt(ee(g,me[1],d),F,z,K));vt(ee(g,ve,d),ee(g,Ne,d),!0)},Wn=l=>p=>{if(i||!R||e.mode!=="vernier"||tr())return;Pr(l);let x=0,D=!1,k=!1;switch(p.key){case"ArrowRight":case"ArrowUp":x=1;break;case"ArrowLeft":case"ArrowDown":x=-1;break;case"PageUp":x=5;break;case"PageDown":x=-5;break;case"Home":D=!0;break;case"End":k=!0;break;default:return}if(p.preventDefault(),br(),l==="macro-low"){const z=ee(c,et,d),K=ee(c,ct,d);if(Qt){const ve=gn(Ae,c,z,Ae[0],K,x,D,k,d);if(ve===De(Ae,z,c,d))return;const Ne=Ae[ve];hr(Ne,K,!0),Yr(Ne,K,"resize");return}let F;if(D?F=wt:k?F=ct:F=Math.max(wt,Math.min(ct,et+x)),F===et)return;const me=ee(c,F,d);hr(me,K,!0),Yr(me,K,"resize")}else if(l==="macro-high"){const z=ee(c,et,d),K=ee(c,ct,d);if(Qt){const ve=gn(Ae,c,K,z,Ae[Ae.length-1],x,D,k,d);if(ve===De(Ae,K,c,d))return;const Ne=Ae[ve];hr(z,Ne,!0),Yr(z,Ne,"resize");return}let F;if(D?F=et:k?F=kt:F=Math.max(et,Math.min(kt,ct+x)),F===ct)return;const me=ee(c,F,d);hr(z,me,!0),Yr(z,me,"resize")}else if(l==="micro-low"){const z=ee(g,Be,d),K=ee(g,it,d);if(Pt){const me=gn(be,g,z,be[0],K,x,D,k,d);if(me===De(be,z,g,d))return;vt(be[me],K,!0);return}let F;if(D?F=je:k?F=it:F=Math.max(je,Math.min(it,Be+x)),F===Be)return;vt(ee(g,F,d),K,!0)}else if(l==="micro-high"){const z=ee(g,Be,d),K=ee(g,it,d);if(Pt){const me=gn(be,g,K,z,be[be.length-1],x,D,k,d);if(me===De(be,K,g,d))return;vt(z,be[me],!0);return}let F;if(D?F=Be:k?F=at:F=Math.max(Be,Math.min(at,it+x)),F===it)return;vt(z,ee(g,F,d),!0)}else if(l==="micro-point"){const z=ee(g,Be,d);if(Pt){const F=gn(be,g,z,be[0],be[be.length-1],x,D,k,d);if(F===De(be,z,g,d))return;ai(be[F],!0);return}let K;if(D?K=je:k?K=at:K=Math.max(je,Math.min(at,Be+x)),K===Be)return;ai(ee(g,K,d),!0)}},Nl=l=>{if(e.mode!=="vernier")return;if(br(),Qt){const K=Ae.length-1,F=De(Ae,fr,c,d),me=De(Ae,gr,c,d),ve=me-F;let Ne=F+l,ue=me+l;if(l<0&&Ne<0?(Ne=0,ue=Math.min(K,ve)):l>0&&ue>K&&(ue=K,Ne=Math.max(0,K-ve)),Ne===F&&ue===me)return;const $t=Ae[Ne],tt=Ae[ue];hr($t,tt,!0),Yr($t,tt,"pan");return}const p=ct-et;let x=et+l,D=ct+l;if(l<0&&x<wt?(x=wt,D=Math.min(kt,x+p)):l>0&&D>kt&&(D=kt,x=Math.max(wt,D-p)),x===et&&D===ct)return;const k=ee(c,x,d),z=ee(c,D,d);hr(k,z,!0),Yr(k,z,"pan")},ra=s.useCallback(l=>{const p=N.current;if(!(p.disabled||tr()))if(br(),p.mode==="point"){const x=Math.max(B,Math.min(H,we+l));Ve||re([x,x]),er(x,x,!0)}else if(p.mode==="vernier"){if(Pt){const ve=be.length-1,Ne=De(be,$r,g,d),ue=De(be,Tr,g,d),$t=ue-Ne;let tt=Ne+l,Fe=ue+l;l<0&&tt<0?(tt=0,Fe=Math.min(ve,$t)):l>0&&Fe>ve&&(Fe=ve,tt=Math.max(0,ve-$t)),(tt!==Ne||Fe!==ue)&&vt(be[tt],be[Fe],!0);return}const x=Be,D=it,k=je,z=at,K=D-x;let F=x+l,me=D+l;l<0&&F<k?(F=k,me=Math.min(z,F+K)):l>0&&me>z&&(me=z,F=Math.max(k,me-K)),(F!==x||me!==D)&&vt(ee(g,F,d),ee(g,me,d),!0)}else{const x=ge-we;let D=we+l,k=ge+l;l<0&&D<B?(D=B,k=Math.min(H,D+x)):l>0&&k>H&&(k=H,D=Math.max(B,k-x)),D<=k&&(Ve||re([D,k]),er(D,k,!0))}},[we,ge,B,H,Ve,er,vt,Be,it,je,at,g,Pt,be,$r,Tr,br,d]),ki=l=>!i&&da(rn.current,l),Ai=(l,p)=>{const x=ii.current,D=gt.current,k=rn.current;if(i||x===null||D===null||k===null||!Dc(x,k,si.current,v,l,p))return null;const z=D.getBoundingClientRect();return Math.abs(v?l-(z.left+z.width/2):p-(z.top+z.height/2))},Ni=l=>{if(i||tr())return;const p=Qs(l.deltaX,l.deltaY,v);if(p===0)return;l.preventDefault();const x=l.target,D=da(li.current,x)||da(ci.current,x);if(!R||D){ra(p);return}const k=gt.current;if(!k)return;const z=k.getBoundingClientRect(),K=v?l.clientX-(z.left+z.width/2):l.clientY-(z.top+z.height/2);if(Wa(K,It)==="macro"){Nl(p);return}ra(p)},Bn=s.useRef({ownsWheelHit:ki,distanceToRailPx:Ai,stepFromRangeAreaWheel:Ni});s.useLayoutEffect(()=>{Bn.current={ownsWheelHit:ki,distanceToRailPx:Ai,stepFromRangeAreaWheel:Ni}});const sn=s.useRef(null);s.useEffect(()=>{const l=rn.current?.ownerDocument.defaultView??null,p=sn.current;if(p!==null&&p.view===l)return;if(p?.unregister(),l===null){sn.current=null;return}const x=Mc(l,{ownsHit:D=>Bn.current.ownsWheelHit(D),distanceToRailPx:(D,k)=>Bn.current.distanceToRailPx(D,k),step:D=>Bn.current.stepFromRangeAreaWheel(D)});sn.current={view:l,unregister:x}}),s.useEffect(()=>()=>{sn.current?.unregister(),sn.current=null},[]);const Fn=wr(we),Kn=wr(ge),na=I(we),oa=I(ge),aa=ss(Fn,Kn,Xo),ln=aa.slant,cn=Ee==="low"||Ee!=="high"&&ht==="low",un=!j&&(Ee==="high"||Ee!=="low"&&ht==="high"),Ol=Go&&Je!=="macro-low",Vl=Go&&Je==="macro-low",_l=qo&&Je!=="micro-low",Yl=qo&&Je==="micro-low",Hr=wa("macro",Lt,At,Zo),jr=wa("micro",Cr,tn,Qo),Hl=Math.min(Fn,Kn),jl=Math.max(Fn,Kn),[Oi,Vi]=xn.flat,[Ul,zl]=xn.macro,[Wl,Bl]=xn.micro,_i=nr(Oi,Fn),Yi=nr(Vi,Kn),ia=nr(Oi,Hl),Hi=`calc(${nr(Vi,jl)} - ${ia})`,Ur=nr(Ul,Lt*100),Gn=nr(zl,At*100),zr=nr(Wl,Cr*100),qn=nr(Bl,tn*100),Fl=v?{bottom:ia,height:Hi,top:"auto",left:"0",right:"0"}:{left:ia,width:Hi,top:"0",bottom:"0"},Kl=Math.max(.01,At-Lt),ji=Math.max(.06,Math.min(.25,.28*Math.sqrt(Kl))),Gl=v?{bottom:_i,left:"50%",transform:"translate(-50%, 50%)",zIndex:cn?40:30}:{left:_i,top:"50%",transform:"translate(-50%, -50%)",zIndex:cn?40:30},ql=v?{bottom:Yi,left:"50%",transform:"translate(-50%, 50%)",zIndex:un?40:30}:{left:Yi,top:"50%",transform:"translate(-50%, -50%)",zIndex:un?40:30},Xl=v?{bottom:`${q}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${q}%`,top:"50%",transform:"translate(-50%, -50%)"},Ui=dt!==null?I(dt):null,Zl=h!=="hover"&&dt!==null&&(dt===we||!j&&dt===ge),Ql=R?Be>ti:we>B,Jl=R?it<Yo:ge<H,Xn=Gc(R?[{side:W?"before":"after",box:ho(mi,fi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:Hr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Hr.slant.lowOffsetX}},{side:W?"after":"before",box:A?Fo:ho(Fo,gi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:jr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:jr.slant.lowOffsetX}}]:[{side:v||f==="top"?"before":"after",box:j?Ar:ho(Ar,di),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:ln.lowAngleDeg,centreOffsetPx:ln.lowOffsetY,alongPushPx:ln.lowOffsetX}}]),ec=Xn===void 0?e.style:{...e.style,...Xn.style};s.useLayoutEffect(()=>{si.current=Xn===void 0?0:Xn.mainPx});const Ot=A?"micro-point":"micro-low",pr=i?"cursor-not-allowed opacity-50":"cursor-pointer",zi=l=>{const p=v?"vertical":"horizontal",x=l==="decrease",D=v?!x:x;return $.jsx(Mr,{ref:x?li:ci,neighbour:"rail",direction:qc[p][l],disabled:i,canStep:x?Ql:Jl,onStep:()=>ra(x?-1:1),ariaLabel:x?te.decrease:te.increase,className:`period-slider-stepper-btn ${Xc[p][l]} ${cs[p][D?"leading":"trailing"]}`})};return $.jsxs("div",{ref:rn,style:ec,className:`period-slider grid select-none place-items-center ${Zc[v?"vertical":"horizontal"][m?"withSteppers":"railOnly"]} ${u}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":v?"vertical":"horizontal","data-label-position":f,"data-color-scheme":w,children:[$.jsx("div",{ref:ii,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),m&&zi(v?"increase":"decrease"),$.jsx("div",{ref:gt,"data-testid":"period-slider-track","data-orientation":v?"vertical":"horizontal","data-vernier-orientation":R?It:void 0,className:`period-slider-track relative touch-none rounded-full ${cs[v?"vertical":"horizontal"][m?"rail":"railOnly"]} ${pr}`,onPointerDown:Il,onPointerMove:kl,onPointerLeave:Al,children:R?$.jsxs($.Fragment,{children:[V&&(v?$.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:[$.jsx("defs",{children:$.jsxs("linearGradient",{id:he,x1:"0",y1:"0",x2:"1",y2:"0",children:[$.jsx("stop",{offset:"0%",stopColor:W?G.macro:G.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:W?G.micro:G.macro,stopOpacity:ji})]})}),$.jsx("path",{ref:Wo,"data-testid":"period-slider-vernier-projection",d:ua(Lt,At,v,W),fill:`url(#${he})`})]}):$.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[$.jsx("defs",{children:$.jsxs("linearGradient",{id:he,x1:"0",y1:"0",x2:"0",y2:"1",children:[$.jsx("stop",{offset:"0%",stopColor:W?G.macro:G.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:W?G.micro:G.macro,stopOpacity:ji})]})}),$.jsx("path",{ref:Wo,"data-testid":"period-slider-vernier-projection",d:ua(Lt,At,v,W),fill:`url(#${he})`})]})),!L&&$.jsxs($.Fragment,{children:[$.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:v?{bottom:`calc(${Ur} - 8px)`,height:`calc(${Gn} - ${Ur} + 16px)`}:{left:`calc(${Ur} - 8px)`,width:`calc(${Gn} - ${Ur} + 16px)`},onPointerDown:_r("macro-connect")}),!A&&$.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:v?{bottom:`calc(${zr} - 8px)`,height:`calc(${qn} - ${zr} + 16px)`}:{left:`calc(${zr} - 8px)`,width:`calc(${qn} - ${zr} + 16px)`},onPointerDown:_r("micro-connect")})]}),ce&&$.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>$.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:v?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>$.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:v?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":te.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":pl,"aria-valuemax":ct,"aria-valuenow":et,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(fr,c,"period"):Sr(c,fr,Ie,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?W?"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":W?"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 ${pr}`,style:v?{bottom:Ur,left:W?0:"auto",right:W?"auto":0,transform:W?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:ke==="macro-low"||Je==="macro-low"?30:15}:{left:Ur,top:W?0:"auto",bottom:W?"auto":0,transform:W?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:ke==="macro-low"||Je==="macro-low"?30:15},onPointerDown:_r("macro-low"),onKeyDown:Wn("macro-low"),onFocus:zn("macro-low"),"data-active":ke==="macro-low"?"true":void 0,"data-front":Je==="macro-low"?"true":void 0,"data-vernier-pos":v?W?"left":"right":W?"top":"bottom","data-handle-type":"macro-low",children:[$.jsx(vn,{type:"macro",isTop:W,isVertical:v,isLeft:W}),Se&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":Ol?"true":void 0,"data-slanted":Hr.slant.isSlanted?"true":void 0,ref:Dl,style:Hr.lowStyle,children:st(c,fr,Ie,b)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":te.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":et,"aria-valuemax":vl,"aria-valuenow":ct,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(gr,c,"period"):Sr(c,gr,Ie,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?W?"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":W?"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 ${pr}`,style:v?{bottom:Gn,left:W?0:"auto",right:W?"auto":0,transform:W?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:ke==="macro-high"||Je==="macro-high"?30:15}:{left:Gn,top:W?0:"auto",bottom:W?"auto":0,transform:W?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:ke==="macro-high"||Je==="macro-high"?30:15},onPointerDown:_r("macro-high"),onKeyDown:Wn("macro-high"),onFocus:zn("macro-high"),"data-active":ke==="macro-high"?"true":void 0,"data-front":Je==="macro-high"?"true":void 0,"data-vernier-pos":v?W?"left":"right":W?"top":"bottom","data-handle-type":"macro-high",children:[$.jsx(vn,{type:"macro",isTop:W,isVertical:v,isLeft:W}),Se&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":Vl?"true":void 0,"data-slanted":Hr.slant.isSlanted?"true":void 0,ref:Rl,style:Hr.highStyle,children:st(c,gr,Ie,b)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":A?te.microSelectedDate:te.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":ti,"aria-valuemax":A?Yo:it,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText($r,g,"period"):Sr(g,$r,Le,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?W?"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":W?"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 ${pr}`,style:v?{bottom:zr,left:W?"auto":0,right:W?0:"auto",transform:W?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:ke===Ot||Je===Ot?30:20}:{left:zr,top:W?"auto":0,bottom:W?0:"auto",transform:W?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:ke===Ot||Je===Ot?30:20},onPointerDown:_r(Ot),onKeyDown:Wn(Ot),onFocus:zn(Ot),"data-active":ke===Ot?"true":void 0,"data-front":Je===Ot?"true":void 0,"data-vernier-pos":v?W?"right":"left":W?"bottom":"top","data-handle-type":Ot,children:[$.jsx(vn,{type:"micro",isTop:!W,isVertical:v,isLeft:!W}),Se&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":_l?"true":void 0,"data-slanted":jr.slant.isSlanted?"true":void 0,ref:Ml,style:jr.lowStyle,children:st(g,$r,Le,b)})]}),!A&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":te.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Be,"aria-valuemax":Yo,"aria-valuenow":it,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Tr,g,"period"):Sr(g,Tr,Le,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?W?"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":W?"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 ${pr}`,style:v?{bottom:qn,left:W?"auto":0,right:W?0:"auto",transform:W?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:ke==="micro-high"||Je==="micro-high"?30:20}:{left:qn,top:W?"auto":0,bottom:W?0:"auto",transform:W?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:ke==="micro-high"||Je==="micro-high"?30:20},onPointerDown:_r("micro-high"),onKeyDown:Wn("micro-high"),onFocus:zn("micro-high"),"data-active":ke==="micro-high"?"true":void 0,"data-front":Je==="micro-high"?"true":void 0,"data-vernier-pos":v?W?"right":"left":W?"bottom":"top","data-handle-type":"micro-high",children:[$.jsx(vn,{type:"micro",isTop:!W,isVertical:v,isLeft:!W}),Se&&$.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),h!=="hover"&&$.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":Yl?"true":void 0,"data-slanted":jr.slant.isSlanted?"true":void 0,ref:El,style:jr.highStyle,children:st(g,Tr,Le,b)})]})]}):$.jsxs($.Fragment,{children:[!L&&$.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Fl,onPointerDown:Cl}),Y&&E&&M.length>1&&$.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:M.map((l,p)=>{const x=O(t,l,d),D=wr(p),k=v?{bottom:`${D}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${D}%`,top:"50%",transform:"translate(-50%, -50%)"};return $.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:k},`tick-${x}`)})}),!i&&dt!==null&&q!==null&&Ee===null&&Ui&&$.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Xl,children:[$.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"}),$.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":Zl?"true":void 0,className:`period-slider-hover-tooltip ${f==="bottom"&&!v?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:st(t,Ui,e.formatLabel,b)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":j?te.selectedDate:te.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":B,"aria-valuemax":j?H:ge,"aria-valuenow":we,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(na,t,"period"):Sr(t,na,e.formatLabel,b),"aria-orientation":v?"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 ${pr}`,style:Gl,onPointerDown:Ti("low"),onKeyDown:Ii("low"),onFocus:Ci("low"),"data-active":Ee==="low"?"true":void 0,"data-front":cn?"true":void 0,children:[$.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 ${Ee==="low"?"":"shadow-md"}`}),h!=="hover"&&$.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":f,"data-slanted":ln.isSlanted?"true":void 0,"data-front":cn?"true":void 0,"data-duplicate":Ko&&!cn?"true":void 0,ref:xl,style:aa.lowStyle,children:st(t,na,e.formatLabel,b)})]}),!j&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":te.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":we,"aria-valuemax":H,"aria-valuenow":ge,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(oa,t,"period"):Sr(t,oa,e.formatLabel,b),"aria-orientation":v?"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 ${pr}`,style:ql,onPointerDown:Ti("high"),onKeyDown:Ii("high"),onFocus:Ci("high"),"data-active":Ee==="high"?"true":void 0,"data-front":un?"true":void 0,children:[$.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 ${Ee==="high"?"":"shadow-md"}`}),h!=="hover"&&$.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":f,"data-slanted":ln.isSlanted?"true":void 0,"data-front":un?"true":void 0,"data-duplicate":Ko&&!un?"true":void 0,ref:Sl,style:aa.highStyle,children:st(t,oa,e.formatLabel,b)})]})]})}),m&&zi(v?"decrease":"increase")]})},rt=e=>e.getTime(),nl=(e,t)=>!(Tt(e)&&Tt(t))||e.length!==2||t.length!==2?!1:St(e[0],rt)===St(t[0],rt)&&St(e[1],rt)===St(t[1],rt),no=(e,t)=>e===void 0||t===void 0?e===t:nl(e,t),ba=(e,t)=>{if(e===t)return!0;if(!(Tt(e)&&Tt(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(St(e[r],rt)!==St(t[r],rt))return!1;return!0},ol=(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},Jc=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||St(e.minDate,rt)!==St(t.minDate,rt)||St(e.maxDate,rt)!==St(t.maxDate,rt)||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||!ol(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Lo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!ba(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(mt(e.value,rt)!==mt(t.value,rt)||mt(e.defaultValue,rt)!==mt(t.defaultValue,rt)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!no(e.range,t.range)||!no(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!no(e.microRange,t.microRange)||!no(e.defaultMicroRange,t.defaultMicroRange)||mt(e.microValue,rt)!==mt(t.microValue,rt)||mt(e.defaultMicroValue,rt)!==mt(t.defaultMicroValue,rt)||!nl(e.macroRange,t.macroRange)||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroPoint!==t.onChangeMicroPoint||e.onChangeMacroRange!==t.onChangeMacroRange||!ba(e.macroAllowedDates,t.macroAllowedDates)||!ba(e.microAllowedDates,t.microAllowedDates)):!1,al=s.memo(Qc,Jc);al.displayName="PeriodSlider";const ds=2,$e=-1,xt=e=>O("day",e),Ln=e=>ee("day",e),hn=e=>`${Io(e.getFullYear())}-${String(e.getMonth()+1).padStart(ds,"0")}-${String(e.getDate()).padStart(ds,"0")}`,eu=(e,t,r,n)=>{const o=xt(e),a=xt(t),i=a>=o?a-o+1:0,u=h=>Ln(a-h),m={kind:"range",min:o,max:a};return{count:i,dateAt:u,labelAt:h=>st("day",u(h),n,r),indexOf:h=>{const f=xt(h);return f<o||f>a?$e:a-f},nearestIndexOf:h=>{if(i===0)return $e;const f=En(m,xt(h));return f===null?$e:a-f}}},tu=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,u=S=>e[n-S],m={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},h=S=>{const v=S.getTime();let L=r,Y=n;for(;L<=Y;){const w=L+Y>>1,b=e[w].getTime();if(b===v)return n-w;b<v?L=w+1:Y=w-1}return $e},f=S=>S===null?$e:h(Ln(S));return{count:i,dateAt:u,labelAt:S=>st("day",u(S),a,o),indexOf:h,nearestIndexOf:S=>f(En(m,xt(S)))}},ru={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${y(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${y(e)})`)},indexOf:()=>$e,nearestIndexOf:()=>$e},nu=(e,t,r)=>{const n=u=>{let m=0,h=e.length;for(;m<h;){const f=m+h>>1;e[f].getTime()<u?m=f+1:h=f}return m},o=u=>{let m=0,h=e.length;for(;m<h;){const f=m+h>>1;e[f].getTime()<=u?m=f+1:h=f}return m},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},ou=(e,t)=>{const r=new Map;for(let n=0;n<e.length;n++){const o=e[n];t(n,o);const a=new Date(o);a.setHours(0,0,0,0);const i=a.getTime();r.has(i)||r.set(i,a)}return Array.from(r.keys()).sort((n,o)=>n-o).map(n=>r.get(n))},au={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},iu={month:2,day:2},ms={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},fs=new Map,su=(e,t)=>{const r=`${e}\0${t}`,n=fs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,au[e]);return fs.set(r,o),o},lu=(e,t,r)=>{if(r!==void 0)return su(e,r).format(t);const n=new Date(t.getTime());return e==="year"?Io(ms.year(n)):String(ms[e](n)).padStart(iu[e],"0")},il=(e,t,r,n)=>{if(Te("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${y(r)})`);return Re(e)?r==="part"?lu(t,e,n):st(t,e,void 0,n):""},cu=12,No=(e,t,r)=>{const n=Nn(e,t,r);return n===null?Number.NaN:n*cu+r},Ba=(e,t,r)=>{const n=o=>o.value!==void 0?o.value:o.initialDate;return mt(n(e),r)!==mt(n(t),r)||t.value!==void 0&&Number.isNaN(mt(t.initialDate,r))||mt(e.minDate,r)!==mt(t.minDate,r)?!1:mt(e.maxDate,r)===mt(t.maxDate,r)},pa=Symbol("nothing handed");class uu{held;writeCount=0;handed=pa;constructor(t){this.held=t}get current(){return this.held}set current(t){this.held=t,this.writeCount+=1}get writes(){return this.writeCount}hand(t){this.handed=t}get holdsHanded(){return this.handed===this.held}forgetHanded(){this.handed=pa}forgetHandedUnless(t){this.handed!==t&&(this.handed=pa)}commit(t,r){this.writeCount===r&&(this.held=t)}}function Ue(e){const[t]=s.useState(()=>new uu(e)),r=t.writes;return s.useInsertionEffect(()=>{t.commit(e,r)}),t}const du={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},mu=["shift","start","end","single"],fu=["disable","clamp"],gu=["follow","keep"],gs={day:{day:1},month:{month:1,year:12},year:{year:1}},hs=new WeakMap,Pa=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${y(r)})`)},ws=(e,t,r,n)=>{for(const[o,a]of Object.entries(r))if(!(a===void 0||n.includes(o)))throw new RangeError(`${e}: ${t}.${o} is not read here; the accepted keys are ${n.map(i=>`"${i}"`).join(", ")} (received: ${y(a)})`)},Er=(e,t,r,n)=>{Pa(e,t,r),ws(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Pa(e,a,i),ws(e,a,i,du[n]);const{motion:u,edge:m,window:h}=i;if(n!=="vernierPoint"&&(typeof u!="string"||!mu.includes(u)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${y(u)})`);if(m!==void 0){if(u!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${y(m)} with motion ${y(u)})`);if(typeof m!="string"||!fu.includes(m))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${y(m)})`)}if(h!==void 0&&(typeof h!="string"||!gu.includes(h)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${y(h)})`)}},Fa=(e,t,r)=>{if(typeof t!="object"||t===null)throw new RangeError(`${e}: stepper must be an object (received: ${y(t)})`);const{onStep:n,canStepPrevious:o,canStepNext:a}=t;if(typeof n!="function")throw new RangeError(`${e}: stepper.onStep must be a function (received: ${y(n)})`);if(typeof o!="boolean")throw new RangeError(`${e}: stepper.canStepPrevious must be a boolean (received: ${y(o)})`);if(typeof a!="boolean")throw new RangeError(`${e}: stepper.canStepNext must be a boolean (received: ${y(a)})`);if(!r)throw new RangeError(`${e}: stepper requires the controlled value; the owner that takes the ◀▶ over moves the value itself, so an uncontrolled initialDate would never change`)},Gt=(e,t,r,n,o)=>{if(!Re(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${y(r)})`);return Xe(e,t,r,n,o,"")},sl=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=hs.get(r),u=i?.get(a);if(u!==void 0)return u;const m=[];for(let f=0;f<r.length;f++)m.push(Gt(e,`${t}[${f}]`,r[f],n,o));const h=Array.from(new Set(m)).sort((f,S)=>f-S);return i===void 0?hs.set(r,new Map([[a,h]])):i.set(a,h),h},hu=(e,t)=>t===1?mo(e):{stepEnd:(r,n)=>uo(e,r+t*n,n),edge:r=>Rn(e,r)},La=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},$a=(e,t,r,n,o,a)=>{if(a){const m=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:ee(n,e[0],o);return Number.isNaN(m.getTime())?null:[m,m]}const i=e[0]===t[0]?r[0]:ee(n,e[0],o),u=e[1]===t[1]?r[1]:ee(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(u.getTime())?null:[i,u.getTime()<i.getTime()?i:u]},Ta=e=>{const t="resolveSelectorSteps";Pa(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:u,rules:m}=e;Te(t,"unit",o);const h=Zt(t,"stepUnit",e.stepUnit,o),f=gs[o][h];if(f===void 0){const d=Object.keys(gs[o]).map(oe=>`"${oe}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${d} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${y(h)})`)}const S=mr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${y(n)})`);if(!Tt(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${y(r)})`);Er(t,"rules",m,"motion");const v=Gt(t,"selection[0]",r[0],o,S),L=Gt(t,"selection[1]",r[1],o,S);if(L<v)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${y(r[0])}, end: ${y(r[1])})`);const Y=a===void 0?null:Gt(t,"minDate",a,o,S),w=i===void 0?null:Gt(t,"maxDate",i,o,S);if(Y!==null&&w!==null&&w<Y)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${y(a)}, maxDate: ${y(i)})`);Jr(t,"allowedDates",u);const b=u===void 0?{kind:"range",min:Y,max:w}:en(sl(t,"allowedDates",u,o,S),Y,w),c=hu(b,f),g=(d,oe)=>{const A=Ma(c,v,L,d,La(oe,n));return A===null?null:$a(A,[v,L],r,o,S,oe.motion==="single")};return{previous:g(-1,m.previous),next:g(1,m.next)}},jt=(e,t)=>{const r=Ue({targets:e,onStepTo:t}),n=s.useCallback(i=>{const{targets:u,onStepTo:m}=r.current,h=u[i];h!==null&&m(h,i)},[]),o=e.previous!==null,a=e.next!==null;return s.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function wu(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function Ka(e,t,r,n){const o=t?null:r(e),[a,i]=s.useState(()=>({source:o,held:n(e)})),u=s.useCallback(h=>i(f=>({source:f.source,held:h})),[]),m=wu(a,o,e,n);return s.useLayoutEffect(()=>{m!==a&&i(h=>h===a?m:h)}),[m.held,u]}const wo=44,bs=7,oo=8,bu=2,ll=10,pu=1e3,Ca=8,va=6,xa=4,Sa=12,wn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),xt(r)},vu=(e,t)=>{if(e.length<xa||t.count===0)return $e;const r=Number(e.slice(0,xa));if(!Number.isInteger(r))return $e;const n=e.length>=va,o=n?Number(e.slice(xa,va)):Sa;if(o<1||o>Sa)return $e;const a=e.length>=Ca,i=a?Number(e.slice(va,Ca)):0,u=wn(r,o),m=(o===Sa?wn(r+1,1):wn(r,o+1))-1,h=a?u+i-1:n?u:wn(r,1),f=a?h:n?m:wn(r+1,1)-1;if(a&&(i<1||h>m))return $e;for(let S=f;S>=h;S--){const v=t.indexOf(Ln(S));if(v!==$e)return v}return $e},xu=e=>e.closest(".dark")===null?"light":"dark",Su=(e,t,r,n)=>{const o=r-e.bottom-oo,a=e.top-oo,i=o>=t||o>=a,m=Math.max(wo,Math.min(t,i?o:a)),h=i?e.bottom:e.top-m,f=e.width+ll,S=Math.max(oo,Math.min(e.left,n-f-oo));return{top:h,left:S,width:f,height:m}},Du=(e,t)=>e<t?e:t>0?t-1:$e,cl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:u,labels:m,onCommitIndex:h,controlClassName:f})=>{const S=s.useId(),v=s.useMemo(()=>hc(m),[m]),L=`period-slider-date-listbox-${S}`,Y=s.useCallback(T=>`period-slider-date-option-${S}-${T}`,[S]),[w,b]=s.useState(!1),[c,g]=s.useState($e),[d,oe]=s.useState(null),[A,te]=s.useState(null),G=s.useRef(null),he=s.useRef(null),N=s.useRef(null),X=s.useRef({buffer:"",at:0}),Q=e.count,R=Du(c,Q),M=Ue(R);s.useLayoutEffect(()=>{R!==c&&g(T=>T===c?R:T)});const E=Math.min(Q,bs)*wo,B=Math.max(1,Math.min(Q,bs)),H=s.useCallback(()=>{const T=G.current;if(T===null)return;const se=T.getBoundingClientRect();oe(Su(se,E,window.innerHeight,window.innerWidth))},[E]),j=s.useCallback(()=>{b(!1),g($e),X.current={buffer:"",at:0}},[]),I=s.useCallback(T=>{a||Q===0||(g(T),b(!0))},[a,Q]);s.useLayoutEffect(()=>{if(!w){oe(null),te(null);return}const T=G.current;return T!==null&&te(xu(T)),H(),window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),()=>{window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)}},[w,H]),s.useEffect(()=>{if(!w)return;const T=se=>{const le=se.target;le!==null&&he.current?.contains(le)!==!0&&G.current?.contains(le)!==!0&&j()};return document.addEventListener("pointerdown",T,!0),()=>document.removeEventListener("pointerdown",T,!0)},[w,j]),s.useEffect(()=>{w&&(a||Q===0)&&j()},[w,a,Q,j]),s.useEffect(()=>{if(!w)return;const T=M.current;T!==$e&&N.current?.scrollToIndex(T,{align:"center"})},[Q,w,M]);const _=T=>{if(Q===0)return;const se=Math.max(0,Math.min(T,Q-1));g(se),N.current?.scrollToIndex(se,{align:"center"})},ie=T=>{T<0||T>=Q||(h(T),j(),G.current?.focus())},pe=Ue(ie),Z=T=>{if(a)return;const se=R!==$e?R:t!==$e?t:r;switch(T.key){case"ArrowDown":if(T.preventDefault(),!w){I(se);return}_(se+1);return;case"ArrowUp":if(T.preventDefault(),!w){I(se);return}_(se-1);return;case"Home":if(!w)return;T.preventDefault(),_(0);return;case"End":if(!w)return;T.preventDefault(),_(Q-1);return;case"PageDown":if(!w)return;T.preventDefault(),_(se+B);return;case"PageUp":if(!w)return;T.preventDefault(),_(se-B);return;case"Enter":if(T.preventDefault(),!w){I(se);return}ie(R!==$e?R:se);return;case"Escape":if(!w)return;T.preventDefault(),j();return;case"Tab":w&&j();return}if(T.key.length!==1)return;const le=T.key>="0"&&T.key<="9",Me=T.key==="-"||T.key==="/"||T.key===".";if(!(le||Me))return;T.preventDefault();const _e=Date.now(),Ce=_e-X.current.at>pu?"":X.current.buffer,Ge=le?`${Ce}${T.key}`.slice(0,Ca):Ce;X.current={buffer:Ge,at:_e};const Ve=vu(Ge,e);if(Ve!==$e){if(!w){I(Ve);return}_(Ve)}},J=s.useCallback(T=>T,[]),ne=s.useCallback(()=>wo,[]),xe=R===$e?null:Y(R),ae=s.useCallback(()=>{const T=G.current;if(T===null||xe===null)throw new Error("VirtualDateDropdown: the active row attached without its combobox control or an active option id, so aria-activedescendant has nothing to name it on");return T.setAttribute("aria-activedescendant",xe),()=>{T.getAttribute("aria-activedescendant")===xe&&T.removeAttribute("aria-activedescendant")}},[xe]),fe=s.useCallback(T=>{const se=T===t,le=T===R;return $.jsx("div",{id:Y(T),role:"option","aria-selected":se,"aria-posinset":T+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":le?"true":void 0,ref:le?ae:void 0,className:"period-slider-date-option",style:{height:wo},onClick:()=>pe.current(T),children:e.labelAt(T)})},[e,t,R,Y,pe,ae]),Pe=w&&d!==null&&A!==null&&Q>0,Ke=Pe?$.jsx("div",{ref:he,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":A,style:{top:d.top,left:d.left,width:d.width,height:d.height},onMouseDown:T=>{T.preventDefault()},children:$.jsx(cr.VirtualScroll,{ref:N,itemCount:Q,getItem:J,getItemHeight:ne,viewportSize:d.height-bu,initialScrollIndex:R!==$e?R:void 0,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:u,labels:v,contentProps:{id:L,role:"listbox","aria-label":i},scrollBarOptions:{width:ll,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:fe})}):null;return $.jsxs($.Fragment,{children:[$.jsx("input",{ref:G,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":w,"aria-controls":Pe?L:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none",disabled:a,value:n,className:f,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:Z,onMouseDown:T=>{a||(T.preventDefault(),G.current?.focus(),w?j():I(t!==$e?t:r))},onBlur:()=>{w&&j()}}),Ke===null?null:oc.createPortal(Ke,document.body)]})};cl.displayName="VirtualDateDropdown";const bn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Ru=An("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),Mu=An('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Eu=31,pn=(e,t,r)=>{if(!Re(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${y(t)})`);Xe("DateSelector",e,t,"day",0,r)},ar=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},ao=e=>ar(e,1,1),ps=e=>ar(e,12,31),ul=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,vs=(e,t,r,n)=>ul(e,t,r)&&e.getDate()===n,Ga=e=>Nn(e,"year",0)!==null,qa=e=>No(e,"day",0),yu=e=>Ga(e)?qa(e):Number.NaN,io=(e,t,r)=>{if(!Ga(t))throw new RangeError(`DateSelector: ${e} must fall in a year that starts inside the Date range, because variant="split-dropdown" draws its year (received: ${y(t)})${r}`)},xs=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const u=r(i);if(Number.isNaN(u.getTime()))break;n(u,i)&&a.push({value:i,label:o(u)})}return a},Pu=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedDates:f,variant:S="date",className:v="",style:L,disabled:Y=!1,locale:w,labels:b,formatLocale:c,formatOption:g}=e;c!==void 0&&Ao("DateSelector","formatLocale",c);const d=S==="split-dropdown"?Mu:Ru;if(t!==void 0&&pn("value",t,""),r!==void 0&&pn("initialDate",r,""),m!==void 0&&pn("minDate",m,d),h!==void 0&&pn("maxDate",h,d),S==="split-dropdown"&&(t!==void 0&&io("value",t,""),r!==void 0&&io("initialDate",r,""),m!==void 0&&io("minDate",m,d),h!==void 0&&io("maxDate",h,d)),i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: minYear must be an integer year (received: ${y(i)})`);if(u!==void 0&&!Number.isInteger(u))throw new RangeError(`DateSelector: maxYear must be an integer year (received: ${y(u)})`);if(i!==void 0&&Number.isNaN(ao(i).getTime()))throw new RangeError(`DateSelector: minYear must name a year whose first day starts inside the Date range (received: ${y(i)})`);if(u!==void 0&&Number.isNaN(ps(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${y(u)})`);if(S==="split-dropdown"&&f!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour allowedDates; use variant="dropdown" or variant="date" for a discrete date set');Jr("DateSelector","allowedDates",f);const oe=t??r;if(oe===void 0)throw new RangeError("DateSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected date is never inferred from the wall clock");o!==void 0&&Fa("DateSelector",o,t!==void 0);const A=$o(w,b),te=t!==void 0,[G,he]=Ka(oe,te,qa,bn),N=t?.getTime(),X=s.useMemo(()=>t!==void 0?bn(t):G,[N,G]);if(S==="split-dropdown"&&!te&&!Ga(X))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${y(X)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const Q=m?.getTime(),R=h?.getTime(),M=s.useMemo(()=>{const C=m?bn(m):null,q=i!==void 0?ao(i):null;return C===null?q:q===null||C.getTime()>=q.getTime()?C:q},[Q,i]),E=s.useMemo(()=>{const C=h?bn(h):null,q=u!==void 0?ps(u):null;return C===null?q:q===null||C.getTime()<=q.getTime()?C:q},[R,u]),B=M?.getTime()??null,H=E?.getTime()??null;if(M!==null&&E!==null&&M.getTime()>E.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${hn(M)}, upper: ${hn(E)})`);if(S!=="date"&&f===void 0&&(M===null||E===null))throw new RangeError(`DateSelector: variant=${y(S)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${S==="dropdown"?", or allowedDates":""}; the option list is never invented`);const j=s.useMemo(()=>f===void 0?null:f.map(C=>St(C,q=>q.getTime())).join(","),[f]),I=s.useMemo(()=>{if(f===void 0)return null;const C=ou(f,(q,We)=>pn(`allowedDates[${q}]`,We,""));return{ascending:C,ascendingSerials:C.map(xt)}},[j]),_=s.useMemo(()=>I===null?null:{...I,...nu(I.ascending,M,E)},[I,B,H]),ie=s.useMemo(()=>_!==null?tu(_.ascending,_.ascendingSerials,_.loIndex,_.hiIndex,c,g):M===null||E===null?ru:eu(M,E,c,g),[_,B,H,c,g]),pe=s.useMemo(()=>_!==null?{kind:"candidates",ascending:_.ascendingSerials,loIndex:_.loIndex,hiIndex:_.hiIndex}:{kind:"range",min:M===null?null:xt(M),max:E===null?null:xt(E)},[_,B,H]),Z=C=>!Number.isNaN(C.getTime())&&Mn(pe,xt(C)),J=C=>{if(Y)return;const q=bn(C);Z(q)&&(te||he(q),n?.(q))},ne=X.getTime(),xe=Z(X),ae=s.useMemo(()=>{const C=Xt(pe,xt(X),-1);if(C===null)return null;const q=Ln(C);return Number.isNaN(q.getTime())?null:q},[pe,ne]),fe=s.useMemo(()=>{const C=Xt(pe,xt(X),1);if(C===null)return null;const q=Ln(C);return Number.isNaN(q.getTime())?null:q},[pe,ne]),Pe=()=>{if(o!==void 0){o.onStep("previous");return}ae!==null&&J(ae)},Ke=()=>{if(o!==void 0){o.onStep("next");return}fe!==null&&J(fe)},T=C=>{if(C.target.value){const q=nc.parseISO(C.target.value);Number.isNaN(q.getTime())||J(q)}},se=X.getFullYear(),le=X.getMonth()+1,Me=X.getDate(),_e=s.useCallback((C,q)=>g?g(q,C,"part"):il(q,C,"part",c),[g,c]),Ce=s.useMemo(()=>{if(S!=="split-dropdown"||M===null||E===null)return[];const C=[];for(let q=E.getFullYear();q>=M.getFullYear();q--)C.push({value:q,label:_e("year",ao(q))});return C},[S,B,H,_e]),Ge=s.useMemo(()=>{if(S!=="split-dropdown"||M===null||E===null)return[];const C=M,q=E,We=se===C.getFullYear()?C.getMonth()+1:1,we=se===q.getFullYear()?q.getMonth()+1:12;return xs(We,we,ge=>ar(se,ge,1),(ge,Mt)=>ul(ge,se,Mt),ge=>_e("month",ge))},[S,B,H,se,_e]),Ve=s.useMemo(()=>{if(S!=="split-dropdown"||M===null||E===null)return[];const C=M,q=E,We=se===C.getFullYear()&&le===C.getMonth()+1?C.getDate():1,we=se===q.getFullYear()&&le===q.getMonth()+1?q.getDate():Eu;return xs(We,we,ge=>ar(se,le,ge),(ge,Mt)=>vs(ge,se,le,Mt),ge=>_e("day",ge))},[S,B,H,se,le,_e]),lt=(C,q,We)=>{const we=ar(C,q,We);return vs(we,C,q,We)&&Z(we)},re=(C,q,We)=>{lt(C,q,We)&&J(ar(C,q,We))},nt=Ce.some(C=>C.value===se),ft=Ge.some(C=>C.value===le),Ze=Ve.some(C=>C.value===Me),Ee=hn(X),ze=S==="dropdown"?st("day",X,g,c):"",He=M?hn(M):void 0,ht=E?hn(E):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 $.jsxs("div",{className:`inline-flex items-center ${Dn} ${v}`,style:L,"data-variant":S,"data-out-of-range":xe?void 0:"true",children:[$.jsx(Mr,{neighbour:"control",direction:"left",disabled:Y,canStep:o===void 0?ae!==null:o.canStepPrevious,onStep:Pe,ariaLabel:A.previousDay}),S==="dropdown"?$.jsx(cl,{domain:ie,selectedIndex:xe?ie.indexOf(X):$e,openAnchorIndex:ie.nearestIndexOf(X),displayLabel:ze,machineValue:Ee,disabled:Y,ariaLabel:A.dateSelect,locale:w,labels:A,onCommitIndex:C=>J(ie.dateAt(C)),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"}):S==="split-dropdown"?$.jsxs("div",{className:"inline-flex items-center gap-1",children:[$.jsxs("select",{"aria-label":A.splitYear,disabled:Y,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:nt?se:"",onChange:C=>re(Number(C.target.value),le,Me),children:[nt?null:$.jsx("option",{value:"",disabled:!0,className:qe,children:_e("year",ao(se))}),Ce.map(C=>$.jsx("option",{value:C.value,disabled:!lt(C.value,le,Me),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":A.splitMonth,disabled:Y,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:ft?le:"",onChange:C=>re(se,Number(C.target.value),Me),children:[ft?null:$.jsx("option",{value:"",disabled:!0,className:qe,children:_e("month",ar(se,le,1))}),Ge.map(C=>$.jsx("option",{value:C.value,disabled:!lt(se,C.value,Me),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":A.splitDay,disabled:Y,className:"rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 text-xs tabular-nums focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 dark:border-slate-600 dark:bg-slate-700 dark:text-slate-100",value:Ze?Me:"",onChange:C=>re(se,le,Number(C.target.value)),children:[Ze?null:$.jsx("option",{value:"",disabled:!0,className:qe,children:_e("day",ar(se,le,Me))}),Ve.map(C=>$.jsx("option",{value:C.value,disabled:!lt(se,le,C.value),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]})]}):$.jsx("input",{"aria-label":A.dateSelect,disabled:Y,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:Ee,min:He,max:ht,onChange:T,type:"date"}),$.jsx(Mr,{neighbour:"control",direction:"right",disabled:Y,canStep:o===void 0?fe!==null:o.canStepNext,onStep:Ke,ariaLabel:A.nextDay}),a]})},Lu=(e,t)=>!(!Ba(e,t,t.variant==="split-dropdown"?yu:qa)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!Lo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),dl=s.memo(Pu,Lu);dl.displayName="DateSelector";function On(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function $n(e){const t=Nn(e,"month",0);return ee("month",t===null?Number.NaN:t,0)}const ml=e=>No(e,"month",0);function Dr(e){return`${Io(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Ss=An("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function so(e,t,r){e!==void 0&&fl(e,t,r)}function fl(e,t,r){if(!Re(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${y(e)})`);Xe("MonthSelector",t,e,"month",0,r)}function Ds(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: ${t} must be an integer year (received: ${y(e)})`);if(Number.isNaN(On(e,r).getTime()))throw new RangeError(`MonthSelector: ${t} must name a year whose ${r===0?"January":"December"} starts inside the Date range (received: ${y(e)})`)}}function $u(e,t){const r=e===void 0?null:On(e,0),n=t===void 0?null:$n(t);return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Tu(e,t){const r=e===void 0?null:On(e,11),n=t===void 0?null:$n(t);return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function ir(e){return e.getFullYear()*12+e.getMonth()}function Ia(e){return On(Math.floor(e/12),(e%12+12)%12)}function Rs(e){return Number.isNaN(e.getTime())?null:e}function Cu(e,t,r){const n=new Map;for(const o of e){const a=$n(o);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 Iu(e,t){const r=[];for(let n=ir(e);n<=ir(t);n++)r.push(Ia(n));return r}function Ms(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:st("month",e[o],r,t),value:Dr(e[o])});return n}const ku=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:u,maxYear:m,minDate:h,maxDate:f,allowedMonths:S,isWarning:v=!1,className:L="",style:Y,disabled:w=!1,locale:b,labels:c,formatLocale:g,formatOption:d}=e;if(g!==void 0&&Ao("MonthSelector","formatLocale",g),so(t,"value",""),so(r,"initialDate",""),so(h,"minDate",Ss),so(f,"maxDate",Ss),Ds(u,"minYear",0),Ds(m,"maxYear",11),Jr("MonthSelector","allowedMonths",S),S!==void 0)for(let re=0;re<S.length;re++)fl(S[re],`allowedMonths[${re}]`,"");const oe=t??r;if(oe===void 0)throw new RangeError("MonthSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected month is never inferred from the wall clock");o!==void 0&&Fa("MonthSelector",o,t!==void 0);const A=$o(b,c),te=t!==void 0,[G,he]=Ka(oe,te,ml,$n),N=s.useMemo(()=>t!==void 0?$n(t):G,[t?.getTime(),G]),X=h?.getTime(),Q=f?.getTime(),R=s.useMemo(()=>$u(u,h),[u,X]),M=s.useMemo(()=>Tu(m,f),[m,Q]),E=R?.getTime()??null,B=M?.getTime()??null;if(R!==null&&M!==null&&R>M)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Dr(R)}, upper: ${Dr(M)})`);if(i==="dropdown"&&S===void 0&&(R===null||M===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 list is never invented');const H=S===void 0?null:S.map(re=>re.getTime()).join(","),j=s.useMemo(()=>S===void 0?null:Cu(S,R,M),[H,E,B]),I=s.useMemo(()=>{if(j!==null){const re=j.map(ir);return{kind:"candidates",ascending:re,loIndex:0,hiIndex:re.length-1}}return{kind:"range",min:R===null?null:ir(R),max:M===null?null:ir(M)}},[j,E,B]),_=re=>!Number.isNaN(re.getTime())&&Mn(I,ir(re)),ie=re=>{if(w)return;if(!_(re))throw new RangeError(`MonthSelector: refusing to emit ${Dr(re)}, which lies outside the selectable months`);te||he(re);const nt=re.getFullYear()*100+(re.getMonth()+1);n?.(re,nt)},pe=N.getTime(),Z=_(N),J=s.useMemo(()=>{const re=Xt(I,ir(N),-1);return re===null?null:Rs(Ia(re))},[I,pe]),ne=s.useMemo(()=>{const re=Xt(I,ir(N),1);return re===null?null:Rs(Ia(re))},[I,pe]),xe=()=>{if(o!==void 0){o.onStep("previous");return}J!==null&&ie(J)},ae=()=>{if(o!==void 0){o.onStep("next");return}ne!==null&&ie(ne)},fe=re=>{if(!re)return;const nt=re.lastIndexOf("-");if(nt<=0)return;const ft=re.slice(0,nt),Ze=re.slice(nt+1),Ee=Number(ft),ze=Number(Ze)-1;if(!(Number.isInteger(Ee)&&Number.isInteger(ze)))return;const He=On(Ee,ze);_(He)&&ie(He)},Pe=re=>{fe(re.target.value)},Ke=re=>{fe(re.target.value)},T=Dr(N),se=i==="dropdown"&&!Z?st("month",N,d,g):"",le=R?Dr(R):void 0,Me=M?Dr(M):void 0,_e=s.useMemo(()=>i!=="dropdown"?[]:j!==null?Ms(j,g,d):R===null||M===null?[]:Ms(Iu(R,M),g,d),[i,j,E,B,g,d]),Ce=Z?T:"",Ge=v?"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",Ve=`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 ${Ge}`,lt=`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 ${Ge}`;return $.jsxs("div",{className:`inline-flex items-center ${Dn} ${L}`,style:Y,"data-out-of-range":Z?void 0:"true",children:[$.jsx(Mr,{neighbour:"control",direction:"left",disabled:w,canStep:o===void 0?J!==null:o.canStepPrevious,onStep:xe,ariaLabel:A.previousMonth}),i==="dropdown"?$.jsxs("select",{"aria-label":A.monthSelect,disabled:w,className:lt,value:Ce,onChange:Ke,children:[Z?null:$.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}),_e.map(re=>$.jsx("option",{value:re.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:re.label},re.value))]}):$.jsx("input",{"aria-label":A.monthSelect,disabled:w,className:Ve,value:T,min:le,max:Me,onChange:Pe,type:"month"}),$.jsx(Mr,{neighbour:"control",direction:"right",disabled:w,canStep:o===void 0?ne!==null:o.canStepNext,onStep:ae,ariaLabel:A.nextMonth}),a]})},Au=(e,t)=>!(!Ba(e,t,ml)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedMonths!==t.allowedMonths||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!Lo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),gl=s.memo(ku,Au);gl.displayName="MonthSelector";function Oe(e,t,r){return e<t?t:e>r?r:e}const Nu=en([],null,null);function Tn(e,t,r,n){return r===null?Nu:ka(r,O(t,e[0],n),O(t,e[1],n))}function Rr(e,t,r,n,o){const a=O(t,e,o),i=Aa(n)?null:En(n,a);return i===null?a<O(t,r[0],o)?r[0]:a>O(t,r[1],o)?r[1]:e:i===a?e:ee(t,i,o)}function Br(e,t,r,n,o,a){const i=O(t,e[0],o),u=O(t,e[1],o),m=go(a,{kind:"range",min:O(t,r[0],o),max:O(t,r[1],o)},i,u);if(m===null)return e;const h=Rr(m[0]===i?e[0]:ee(t,m[0],o),t,r,n,o),f=Rr(m[1]===u?e[1]:ee(t,m[1],o),t,r,n,o);return[h,f<h?h:f]}const Es=(e,t,r,n,o,a,i)=>{if(Jr(e,t,r),r===void 0||r.length===0)return null;const u=en(sl(e,t,r,n,i),O(n,o,i),O(n,a,i));if(u.hiIndex<u.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${y(o)}, maxDate: ${y(a)}, entries: ${r.length})`);return u},ka=(e,t,r)=>{const n=en(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},Aa=e=>e.hiIndex<e.loIndex,Ou=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Xt(o,t,r);a!==null&&(n===null||(r===1?a<n:a>n))&&(n=a)}return n},edge:t=>{let r=null;for(const n of e){const o=Rn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Kr=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),ys=(e,t,r,n,o)=>{if(!Tt(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${y(r)})`);const a=Gt(e,`${t}[0]`,r[0],n,o),i=Gt(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${y(r[0])}, end: ${y(r[1])})`);return[a,i]},sr=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${y(e)})`);const{row:r,shows:n,macroUnit:o,microUnit:a,minDate:i,maxDate:u,macroRange:m,microSelection:h}=e;if(r!=="macro"&&r!=="micro")throw new RangeError(`${t}: row must be "macro" or "micro" (received: ${y(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${y(n)})`);Te(t,"macroUnit",o),Te(t,"microUnit",a);const f=mr(t,e.yearStartMonth);for(const[R,M]of[["minDate",i],["maxDate",u]])if(!Re(M))throw new RangeError(`${t}: ${R} must be a valid Date (received: ${y(M)})`);if(u.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${y(i)}, maxDate: ${y(u)})`);Gt(t,"minDate",i,o,f),Gt(t,"minDate",i,a,f),Er(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const S=ys(t,"macroRange",m,o,f);if(m[1].getTime()<m[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${y(m[0])}, end: ${y(m[1])})`);const v=ys(t,"microSelection",h,a,f),L=Es(t,"macroAllowedDates",e.macroAllowedDates,o,i,u,f),Y=Es(t,"microAllowedDates",e.microAllowedDates,a,i,u,f),w=[m[0],m[1]],b=[h[0],h[1]],c=R=>{const M=Rt(o,a,[R[0],R[1]],i,u,f);return[O(a,M[0],f),O(a,M[1],f)]},g=(R,M)=>{if(Y!==null){const E=ka(Y,R,M);if(!Aa(E))return E}return{kind:"range",min:R,max:M}},d=(R,M)=>{const E=Kr(R,w)?w:R;return E===w&&Kr(M,b)?null:{macroRange:E,microSelection:M}};if(e.row==="macro"){const R=L??{kind:"range",min:O(o,i,f),max:O(o,u,f)},M=mo(R),E=(H,j)=>{const I=Rt(o,a,H,i,u,f);return Br(b,a,I,Tn(I,a,Y,f),f,j)},B=(H,j)=>{const I=Ma(M,S[0],S[1],H,La(j,n));if(I===null)return null;const _=$a(I,S,w,o,f,j.motion==="single");if(_===null)return null;const ie=[Oe(_[0],i,u),Oe(_[1],i,u)],pe=Math.sign(I[0]-S[0])===H&&Math.sign(I[1]-S[1])===H;return d(ie,E(ie,pe?"pan":"resize"))};return{previous:B(-1,e.rules.previous),next:B(1,e.rules.next)}}const oe=c(w);let A=[O(a,i,f),O(a,u,f)];if(L!==null){const R=c([ee(o,L.ascending[L.loIndex],f),ee(o,L.ascending[L.hiIndex],f)]);A=[Math.min(R[0],oe[0]),Math.max(R[1],oe[1])]}const te=Y===null?null:ka(Y,A[0],A[1]);let G=mo({kind:"range",min:A[0],max:A[1]});if(te!==null&&!Aa(te)){const R=g(oe[0],oe[1]);G=R.kind==="candidates"?mo(te):Ou([te,R])}const he=R=>{if(L===null)return[Oe(pt(o,R[0],f),i,u),Oe(pt(o,R[1],f),i,u)];const M=uo(L,O(o,R[0],f),-1),E=uo(L,O(o,R[1],f),1);return M===null||E===null?null:[Oe(ee(o,M,f),i,u),Oe(ee(o,E,f),i,u)]},N=(R,M,E)=>{const[B,H]=c(R),j=g(B,H),I=pe=>{const Z=O(a,pe,f);if(Mn(j,Z))return pe;const J=uo(j,Z,E);return J===null?null:ee(a,J,f)},_=I(M[0]),ie=I(M[1]);return _===null||ie===null?null:[_,ie.getTime()<_.getTime()?_:ie]},X=(R,M)=>R>=oe[0]&&M<=oe[1],Q=(R,M)=>{const E=Ma(G,v[0],v[1],R,La(M,n));if(E===null)return null;const B=$a(E,v,b,a,f,M.motion==="single");if(B===null)return null;const H=M.window!=="follow",j=H&&X(E[0],E[1])?w:he(B);if(j===null)return null;const I=N(j,B,R);if(I===null)return null;const _=H&&X(O(a,I[0],f),O(a,I[1],f))?w:he(I);return _===null?null:d(_,I)};return{previous:Q(-1,e.rules.previous),next:Q(1,e.rules.next)}};function Na(e,t,r){if(!Re(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${y(r)})`)}function ye(e,t,r,n,o){Na(e,t,r),Xe(e,t,r,n,o,"")}function Oo(e,t,r,n,o){if(Na(e,"minDate",t),Na(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${y(t)}, maxDate: ${y(r)})`);for(const a of n)Xe(e,"minDate",t,a,o,Hs)}function lr(e,t,r,n,o){if(!Tt(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${y(r)})`);if(ye(e,`${t}[0]`,r[0],n,o),ye(e,`${t}[1]`,r[1],n,o),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${y(r[0])}, upper: ${y(r[1])})`)}function xo(e,t,r,n,o,a,i,u){const m=O(r,n,u);if(m<O(r,o,u)||m>O(r,a,u))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${y(n)}, lower: ${y(o)}, upper: ${y(a)})`)}function So(e,t,r,n,o,a,i,u){xo(e,`${t}[0]`,r,n[0],o,a,i,u),xo(e,`${t}[1]`,r,n[1],o,a,i,u)}function Do(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${y(r)}, upper: ${y(n)})`)}function Gr(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${y(r)})`)}function Ut(e,t,r,n,o,a){const i=js(e,t,r);return Re(i)&&Nn(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function Ro(e,t,r,n,o){const a=De(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function Sn(e,t,r,n,o,a){const i=Oe(e,r,n);if(o.length===0)return i;const u=o[De(o,i,t,a)];return O(t,u,a)===O(t,i,a)?i:Oe(u,r,n)}function Da(e,t,r,n,o,a){const i=Sn(e[0],t,r,n,o,a),u=Sn(e[1],t,r,n,o,a);return[i,u<i?i:u]}function Cn(e,t){return t[0]===e[0]&&t[1]===e[1]?e:t}const Vu={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function zt(e,t){return t.length===0?{}:{[Vu[e]]:t}}function Vo(e){const t=s.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(u=>Object.is(r[u],n[u]))||(t.current=e),t.current}const qt={previous:null,next:null},_u=["motion","edge","window"];function In(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>_u.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const hl=(e,t)=>e.getTime()===t.getTime();function qr(e,t,r,n){if(!r(e.current,t))e.current=t;else if(e.holdsHanded)return;e.hand(e.current),n(e.current)}function Xr(e,t,r){e.current=t,e.hand(t),r(t)}function Yu(e,t){return typeof t=="function"?t(e):t}function Zr(e){return s.useReducer(Yu,void 0,e)}function Qr(e,t,r,n){r===t||e.current!==r||(e.forgetHanded(),n(o=>o===t?r:o))}function Hu(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:u,selectorStep:m,...h}=e;Te("usePeriodSliderRange","unit",t);const f=mr("usePeriodSliderRange",i);Oo("usePeriodSliderRange",r,n,[t],f),lr("usePeriodSliderRange","initialRange",o,t,f),m!==void 0&&Er("usePeriodSliderRange","selectorStep",m,"motion");const S=Vo(h),v=r.getTime(),L=n.getTime(),Y=s.useMemo(()=>ur("usePeriodSliderRange",ko(S.allowedDates),t,r,n,f).dates,[S.allowedDates,t,v,L,f]),w=s.useRef(o),[b,c]=Zr(()=>(So("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",f),Cn(o,Da(o,t,r,n,Y,f))));lr("usePeriodSliderRange","range",b,t,f);const g=Cn(b,Da(b,t,r,n,Y,f)),d=Ue(g);d.forgetHandedUnless(b),s.useLayoutEffect(()=>{Qr(d,b,g,c)});const oe=s.useRef(o),A=Ue({minDate:r,maxDate:n,candidates:Y}),te=Ue(a),G=s.useCallback(Z=>{const{minDate:J,maxDate:ne,candidates:xe}=A.current,ae=Da(Z,t,J,ne,xe,f);qr(d,ae,Kr,c);const fe=oe.current;ae[0].getTime()===fe[0].getTime()&&ae[1].getTime()===fe[1].getTime()||(oe.current=ae,te.current?.(ae[0],ae[1]))},[t,f]),he=s.useCallback(Z=>{const J=typeof Z=="function"?Z(d.current):Z;oe.current=J,Xr(d,J,c)},[]),N=s.useCallback(Z=>{ye("usePeriodSliderRange","setLowerDate(date)",Z,t,f);const J=d.current,ne=Z.getTime()>J[1].getTime()?Z:J[1];G([Z,ne])},[G,t,f]),X=s.useCallback(Z=>{ye("usePeriodSliderRange","setUpperDate(date)",Z,t,f);const J=d.current,ne=Z.getTime()<J[0].getTime()?Z:J[0];G([ne,Z])},[G,t,f]),Q=s.useCallback((Z,J)=>{ye("usePeriodSliderRange","sliderProps.onChangeRange(lower)",Z,t,f),ye("usePeriodSliderRange","sliderProps.onChangeRange(upper)",J,t,f),Do("usePeriodSliderRange","sliderProps.onChangeRange",Z,J),G([Z,J])},[G,t,f]),R=s.useCallback(Z=>{Gr("usePeriodSliderRange","shiftRange",Z);const{minDate:J,maxDate:ne,candidates:xe}=A.current,ae=d.current;if(xe.length>0){G([Ro(xe,t,ae[0],Z,f),Ro(xe,t,ae[1],Z,f)]);return}G([Ut(t,ae[0],Z,J,ne,f).date,Ut(t,ae[1],Z,J,ne,f).date])},[t,G,f]),M=s.useCallback(()=>{G(w.current)},[G]),E=In(m),B=E!==void 0,H=s.useMemo(()=>{if(E===void 0)return{start:qt,end:qt};const Z=Y.length>0?S.allowedDates:void 0,J={selection:g,unit:t,yearStartMonth:f,minDate:r,maxDate:n,allowedDates:Z,rules:E};return{start:Ta({...J,shows:"start"}),end:Ta({...J,shows:"end"})}},[E,g,t,f,v,L,Y,S.allowedDates]),j=jt(H.start,G),I=jt(H.end,G),_=s.useMemo(()=>({value:g[0],onChange:N,minDate:r,maxDate:g[1],unit:t,yearStartMonth:f,...zt(t,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...B?{stepper:j}:{}}),[g[0],g[1],N,r,t,f,Y,e.formatLocale,e.locale,e.labels,u,B,j]),ie=s.useMemo(()=>({value:g[1],onChange:X,minDate:g[0],maxDate:n,unit:t,yearStartMonth:f,...zt(t,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...B?{stepper:I}:{}}),[g[0],g[1],X,n,t,f,Y,e.formatLocale,e.locale,e.labels,u,B,I]),pe=s.useMemo(()=>({...S,mode:"range",unit:t,yearStartMonth:f,range:g,minDate:r,maxDate:n,onChangeRange:Q}),[S,t,g,r,n,Q,f]);return{range:g,lowerDate:g[0],upperDate:g[1],setRange:he,setLowerDate:N,setUpperDate:X,shiftRange:R,resetRange:M,startSelectorProps:_,endSelectorProps:ie,sliderProps:pe}}function ju(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:u,...m}=e;Te("usePeriodSliderPoint","unit",t);const h=mr("usePeriodSliderPoint",i);Oo("usePeriodSliderPoint",r,n,[t],h),ye("usePeriodSliderPoint","initialValue",o,t,h);const f=Vo(m),S=r.getTime(),v=n.getTime(),L=s.useMemo(()=>ur("usePeriodSliderPoint",ko(f.allowedDates),t,r,n,h).dates,[f.allowedDates,t,S,v,h]),Y=s.useRef(o),[w,b]=Zr(()=>(xo("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",h),Sn(o,t,r,n,L,h)));ye("usePeriodSliderPoint","value",w,t,h);const c=Sn(w,t,r,n,L,h),g=Ue(c);g.forgetHandedUnless(w),s.useLayoutEffect(()=>{Qr(g,w,c,b)});const d=s.useRef(o),oe=Ue({minDate:r,maxDate:n,candidates:L}),A=Ue(a),te=s.useCallback(E=>{const{minDate:B,maxDate:H,candidates:j}=oe.current,I=Sn(E,t,B,H,j,h);qr(g,I,hl,b),I.getTime()!==d.current.getTime()&&(d.current=I,A.current?.(I))},[t,h]),G=s.useCallback(E=>{const B=typeof E=="function"?E(g.current):E;d.current=B,Xr(g,B,b)},[]),he=s.useCallback(E=>{ye("usePeriodSliderPoint","selectorProps.onChange(date)",E,t,h),te(E)},[te,t,h]),N=s.useCallback(E=>{ye("usePeriodSliderPoint","sliderProps.onChangePoint(value)",E,t,h),te(E)},[te,t,h]),X=s.useCallback(E=>{Gr("usePeriodSliderPoint","shiftValue",E);const{minDate:B,maxDate:H,candidates:j}=oe.current;if(j.length>0){te(Ro(j,t,g.current,E,h));return}te(Ut(t,g.current,E,B,H,h).date)},[t,te,h]),Q=s.useCallback(()=>{te(Y.current)},[te]),R=s.useMemo(()=>({value:c,onChange:he,minDate:r,maxDate:n,unit:t,yearStartMonth:h,...zt(t,L),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u}),[c,he,r,n,t,h,L,e.formatLocale,e.locale,e.labels,u]),M=s.useMemo(()=>({...f,mode:"point",unit:t,yearStartMonth:h,value:c,minDate:r,maxDate:n,onChangePoint:N}),[f,t,c,r,n,N,h]);return{value:c,setValue:G,shiftValue:X,resetValue:Q,selectorProps:R,sliderProps:M}}function Uu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroRange:h,yearStartMonth:f,formatOption:S,macroSelectorStep:v,microSelectorStep:L,...Y}=e;Te("useVernierSliderRange","unit",t);const w=Zt("useVernierSliderRange","macroUnit",i,t),b=Zt("useVernierSliderRange","microUnit",u,t),c=mr("useVernierSliderRange",f);Oo("useVernierSliderRange",r,n,[w,b,t],c),lr("useVernierSliderRange","initialMacroRange",o,w,c),lr("useVernierSliderRange","initialMicroRange",a,b,c),v!==void 0&&Er("useVernierSliderRange","macroSelectorStep",v,"motion"),L!==void 0&&Er("useVernierSliderRange","microSelectorStep",L,"vernierRange");const g=Vo(Y),d=s.useRef(o),oe=s.useRef(a),[A,te]=Zr(()=>(So("useVernierSliderRange","initialMacroRange",w,o,r,n,"[minDate, maxDate]",c),o)),[G,he]=Zr(()=>{const P=Rt(w,b,o,r,n,c);return So("useVernierSliderRange","initialMicroRange",b,a,P[0],P[1],"the initial macro window",c),a});lr("useVernierSliderRange","macroRange",A,w,c);const N=Cn(A,[Oe(A[0],r,n),Oe(A[1],r,n)]),X=r.getTime(),Q=n.getTime(),R=s.useMemo(()=>Rt(w,b,N,r,n,c),[w,b,N,X,Q,c]),M=s.useMemo(()=>Ht("micro",g)?ja("useVernierSliderRange",Dt("micro",g),b,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,b,X,Q,c]),E=s.useMemo(()=>Ht("macro",g)?ur("useVernierSliderRange",Dt("macro",g),w,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,w,X,Q,c]),B=Ue(E),H=s.useMemo(()=>Tn(R,b,M,c),[R,b,M,c]),j=s.useMemo(()=>Pn(M,H),[M,H]);lr("useVernierSliderRange","microRange",G,b,c);const I=Cn(G,Br(G,b,R,H,c,"resize")),_=Ue(N),ie=Ue(I);_.forgetHandedUnless(A),ie.forgetHandedUnless(G),s.useLayoutEffect(()=>{Qr(_,A,N,te),Qr(ie,G,I,he)});const pe=s.useRef(a),Z=s.useRef(o),J=Ue({minDate:r,maxDate:n}),ne=Ue(m),xe=Ue(h),ae=s.useCallback(P=>{const{minDate:U,maxDate:de}=J.current;return Rt(w,b,P,U,de,c)},[w,b,c]),fe=s.useCallback(P=>Tn(P,b,M,c),[b,M,c]),Pe=s.useCallback(P=>{qr(_,P,Kr,te);const U=Z.current;P[0].getTime()===U[0].getTime()&&P[1].getTime()===U[1].getTime()||(Z.current=P,ne.current?.(P[0],P[1]))},[]),Ke=s.useCallback(P=>{const U=typeof P=="function"?P(_.current):P;Z.current=U,Xr(_,U,te)},[]),T=s.useCallback((P,U)=>{Pe(P),qr(ie,U,Kr,he);const de=pe.current;(U[0].getTime()!==de[0].getTime()||U[1].getTime()!==de[1].getTime())&&(pe.current=U,xe.current?.(U[0],U[1]))},[Pe]),se=s.useCallback(P=>{const U=typeof P=="function"?P(ie.current):P;pe.current=U,Xr(ie,U,he)},[]),le=s.useCallback((P,U,de)=>{const{minDate:Ie,maxDate:Le}=J.current,ot=[Oe(P,Ie,Le),Oe(U,Ie,Le)],Qe=ae(ot);T(ot,Br(ie.current,b,Qe,fe(Qe),c,de))},[b,ae,fe,T,c]),Me=s.useCallback((P,U)=>le(P,U,"resize"),[le]),_e=s.useCallback((P,U)=>{ye("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",P,w,c),ye("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",U,w,c),Do("useVernierSliderRange","sliderProps.onChangeMacroRange",P,U);const{minDate:de,maxDate:Ie}=J.current,Le=[Oe(P,de,Ie),Oe(U,de,Ie)],ot=ie.current,Qe=ae(Le),ke=Br(ot,b,Qe,fe(Qe),c,"resize");if(ke[0].getTime()!==ot[0].getTime()||ke[1].getTime()!==ot[1].getTime()){Pe(Le);return}T(Le,ot)},[w,b,ae,fe,Pe,T,c]),Ce=s.useCallback((P,U)=>{const de=ae(_.current);T(_.current,Br([P,U],b,de,fe(de),c,"resize"))},[b,ae,fe,T,c]),Ge=s.useCallback((P,U)=>{ye("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",P,b,c),ye("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",U,b,c),Do("useVernierSliderRange","sliderProps.onChangeMicroRange",P,U),Ce(P,U)},[Ce,b,c]),Ve=s.useCallback(P=>{ye("useVernierSliderRange","setMacroLowerDate(date)",P,w,c);const U=_.current[1],de=P>U?P:U;Me(P,de)},[Me,w,c]),lt=s.useCallback(P=>{ye("useVernierSliderRange","setMacroUpperDate(date)",P,w,c);const U=_.current[0],de=P<U?P:U;Me(de,P)},[Me,w,c]),re=s.useCallback(P=>{ye("useVernierSliderRange","setMicroLowerDate(date)",P,b,c);const U=ie.current[1],de=P>U?P:U;Ce(P,de)},[Ce,b,c]),nt=s.useCallback(P=>{ye("useVernierSliderRange","setMicroUpperDate(date)",P,b,c);const U=ie.current[0],de=P<U?P:U;Ce(de,P)},[Ce,b,c]),ft=s.useCallback(P=>{Gr("useVernierSliderRange","shiftMacroRange",P);const{minDate:U,maxDate:de}=J.current,Ie=_.current,Le=B.current;if(Le.length>0){const ke=De(Le,Ie[0],w,c)+P,Et=De(Le,Ie[1],w,c)+P;if(ke<0||Et>Le.length-1)return;le(Le[ke],Le[Et],"pan");return}const ot=Ut(w,Ie[0],P,U,de,c),Qe=Ut(w,Ie[1],P,U,de,c);ot.pastDateRange||Qe.pastDateRange||ot.date<U||Qe.date>de||le(ot.date,Qe.date,"pan")},[w,le,c]),Ze=s.useCallback(P=>{Gr("useVernierSliderRange","shiftMicroRange",P);const U=_.current,de=ie.current,Ie=ae(U),[Le,ot]=Ie,Qe=Pn(M,fe(Ie));if(Qe.length>0){const yt=De(Qe,de[0],b,c)+P,yr=De(Qe,de[1],b,c)+P;if(yt<0||yr>Qe.length-1)return;Ce(Qe[yt],Qe[yr]);return}const ke=Ut(b,de[0],P,Le,ot,c),Et=Ut(b,de[1],P,Le,ot,c);ke.pastDateRange||Et.pastDateRange||O(b,ke.date,c)<O(b,Le,c)||O(b,Et.date,c)>O(b,ot,c)||Ce(ke.date,Et.date)},[b,M,ae,fe,Ce,c]),Ee=s.useCallback(()=>{const{minDate:P,maxDate:U}=J.current,de=[Oe(d.current[0],P,U),Oe(d.current[1],P,U)],Ie=ae(de);T(de,Br(oe.current,b,Ie,fe(Ie),c,"resize"))},[b,ae,fe,T,c]),ze=In(v),He=In(L),ht=ze!==void 0,qe=He!==void 0,dt=s.useMemo(()=>{const P={macroUnit:w,microUnit:b,yearStartMonth:c,minDate:r,maxDate:n,macroRange:N,microSelection:I,macroAllowedDates:Ht("macro",g)?Dt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Dt("micro",g).list:void 0};return{macroStart:ze===void 0?qt:sr({...P,row:"macro",shows:"start",rules:ze}),macroEnd:ze===void 0?qt:sr({...P,row:"macro",shows:"end",rules:ze}),microStart:He===void 0?qt:sr({...P,row:"micro",shows:"start",rules:He}),microEnd:He===void 0?qt:sr({...P,row:"micro",shows:"end",rules:He})}},[ze,He,w,b,c,X,Q,N,I,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),C=s.useCallback(P=>T(P.macroRange,P.microSelection),[T]),q=jt(dt.macroStart,C),We=jt(dt.macroEnd,C),we=jt(dt.microStart,C),ge=jt(dt.microEnd,C),[Mt,It]=R,W=s.useMemo(()=>({value:N[0],onChange:Ve,minDate:r,maxDate:N[1],unit:w,yearStartMonth:c,...zt(w,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...ht?{stepper:q}:{}}),[N,Ve,r,w,c,E,e.formatLocale,e.locale,e.labels,S,ht,q]),V=s.useMemo(()=>({value:N[1],onChange:lt,minDate:N[0],maxDate:n,unit:w,yearStartMonth:c,...zt(w,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...ht?{stepper:We}:{}}),[N,lt,n,w,c,E,e.formatLocale,e.locale,e.labels,S,ht,We]),ce=s.useMemo(()=>({value:I[0],onChange:re,minDate:Mt,maxDate:I[1],unit:b,yearStartMonth:c,...zt(b,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...qe?{stepper:we}:{}}),[I,re,Mt,b,c,j,e.formatLocale,e.locale,e.labels,S,qe,we]),Se=s.useMemo(()=>({value:I[1],onChange:nt,minDate:I[0],maxDate:It,unit:b,yearStartMonth:c,...zt(b,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...qe?{stepper:ge}:{}}),[I,nt,It,b,c,j,e.formatLocale,e.locale,e.labels,S,qe,ge]),Ye=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:w,microUnit:b,minDate:r,maxDate:n,macroRange:N,microRange:I,onChangeMacroRange:_e,onChangeMicroRange:Ge}),[g,t,w,b,r,n,N,I,_e,Ge,c]);return{macroRange:N,setMacroRange:Ke,microRange:I,setMicroRange:se,setMacroLowerDate:Ve,setMacroUpperDate:lt,setMicroLowerDate:re,setMicroUpperDate:nt,shiftMacroRange:ft,shiftMicroRange:Ze,resetVernier:Ee,macroStartSelectorProps:W,macroEndSelectorProps:V,microStartSelectorProps:ce,microEndSelectorProps:Se,sliderProps:Ye}}function zu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroPoint:h,yearStartMonth:f,formatOption:S,macroSelectorStep:v,microSelectorStep:L,...Y}=e;Te("useVernierSliderPoint","unit",t);const w=Zt("useVernierSliderPoint","macroUnit",i,t),b=Zt("useVernierSliderPoint","microUnit",u,t),c=mr("useVernierSliderPoint",f);Oo("useVernierSliderPoint",r,n,[w,b,t],c),lr("useVernierSliderPoint","initialMacroRange",o,w,c),ye("useVernierSliderPoint","initialMicroValue",a,b,c),v!==void 0&&Er("useVernierSliderPoint","macroSelectorStep",v,"motion"),L!==void 0&&Er("useVernierSliderPoint","microSelectorStep",L,"vernierPoint");const g=Vo(Y),d=s.useRef(o),oe=s.useRef(a),[A,te]=Zr(()=>(So("useVernierSliderPoint","initialMacroRange",w,o,r,n,"[minDate, maxDate]",c),o)),[G,he]=Zr(()=>{const V=Rt(w,b,o,r,n,c);return xo("useVernierSliderPoint","initialMicroValue",b,a,V[0],V[1],"the initial macro window",c),a});lr("useVernierSliderPoint","macroRange",A,w,c);const N=Cn(A,[Oe(A[0],r,n),Oe(A[1],r,n)]),X=r.getTime(),Q=n.getTime(),R=s.useMemo(()=>Rt(w,b,N,r,n,c),[w,b,N,X,Q,c]),M=s.useMemo(()=>Ht("micro",g)?ja("useVernierSliderPoint",Dt("micro",g),b,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,b,X,Q,c]),E=s.useMemo(()=>Ht("macro",g)?ur("useVernierSliderPoint",Dt("macro",g),w,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,w,X,Q,c]),B=Ue(E),H=s.useMemo(()=>Tn(R,b,M,c),[R,b,M,c]),j=s.useMemo(()=>Pn(M,H),[M,H]);ye("useVernierSliderPoint","microValue",G,b,c);const I=Rr(G,b,R,H,c),_=Ue(N),ie=Ue(I);_.forgetHandedUnless(A),ie.forgetHandedUnless(G),s.useLayoutEffect(()=>{Qr(_,A,N,te),Qr(ie,G,I,he)});const pe=s.useRef(a),Z=s.useRef(o),J=Ue({minDate:r,maxDate:n}),ne=Ue(m),xe=Ue(h),ae=s.useCallback(V=>{const{minDate:ce,maxDate:Se}=J.current;return Rt(w,b,V,ce,Se,c)},[w,b,c]),fe=s.useCallback(V=>Tn(V,b,M,c),[b,M,c]),Pe=s.useCallback(V=>{qr(_,V,Kr,te);const ce=Z.current;V[0].getTime()===ce[0].getTime()&&V[1].getTime()===ce[1].getTime()||(Z.current=V,ne.current?.(V[0],V[1]))},[]),Ke=s.useCallback(V=>{const ce=typeof V=="function"?V(_.current):V;Z.current=ce,Xr(_,ce,te)},[]),T=s.useCallback((V,ce)=>{Pe(V),qr(ie,ce,hl,he),ce.getTime()!==pe.current.getTime()&&(pe.current=ce,xe.current?.(ce))},[Pe]),se=s.useCallback(V=>{const ce=typeof V=="function"?V(ie.current):V;pe.current=ce,Xr(ie,ce,he)},[]),le=s.useCallback((V,ce)=>{const{minDate:Se,maxDate:Ye}=J.current,P=[Oe(V,Se,Ye),Oe(ce,Se,Ye)],U=ae(P);T(P,Rr(ie.current,b,U,fe(U),c))},[b,ae,fe,T,c]),Me=s.useCallback(V=>{const ce=ae(_.current);T(_.current,Rr(V,b,ce,fe(ce),c))},[b,ae,fe,T,c]),_e=s.useCallback((V,ce)=>{ye("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",V,w,c),ye("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",ce,w,c),Do("useVernierSliderPoint","sliderProps.onChangeMacroRange",V,ce);const{minDate:Se,maxDate:Ye}=J.current,P=[Oe(V,Se,Ye),Oe(ce,Se,Ye)],U=ie.current,de=ae(P);if(Rr(U,b,de,fe(de),c).getTime()!==U.getTime()){Pe(P);return}T(P,U)},[w,b,ae,fe,Pe,T,c]),Ce=s.useCallback(V=>{ye("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",V,b,c),Me(V)},[Me,b,c]),Ge=s.useCallback(V=>{ye("useVernierSliderPoint","setMacroLowerDate(date)",V,w,c);const ce=_.current[1],Se=V>ce?V:ce;le(V,Se)},[le,w,c]),Ve=s.useCallback(V=>{ye("useVernierSliderPoint","setMacroUpperDate(date)",V,w,c);const ce=_.current[0],Se=V<ce?V:ce;le(Se,V)},[le,w,c]),lt=s.useCallback(V=>{ye("useVernierSliderPoint","setMicroDate(date)",V,b,c),Me(V)},[Me,b,c]),re=s.useCallback(V=>{Gr("useVernierSliderPoint","shiftMacroRange",V);const{minDate:ce,maxDate:Se}=J.current,Ye=_.current,P=B.current;if(P.length>0){const Ie=De(P,Ye[0],w,c)+V,Le=De(P,Ye[1],w,c)+V;if(Ie<0||Le>P.length-1)return;le(P[Ie],P[Le]);return}const U=Ut(w,Ye[0],V,ce,Se,c),de=Ut(w,Ye[1],V,ce,Se,c);U.pastDateRange||de.pastDateRange||U.date<ce||de.date>Se||le(U.date,de.date)},[w,le,c]),nt=s.useCallback(V=>{Gr("useVernierSliderPoint","shiftMicroValue",V);const ce=_.current,Se=ae(ce),Ye=Pn(M,fe(Se));if(Ye.length>0){Me(Ro(Ye,b,ie.current,V,c));return}Me(Ut(b,ie.current,V,Se[0],Se[1],c).date)},[b,M,ae,fe,Me,c]),ft=s.useCallback(()=>{const{minDate:V,maxDate:ce}=J.current,Se=[Oe(d.current[0],V,ce),Oe(d.current[1],V,ce)],Ye=ae(Se);T(Se,Rr(oe.current,b,Ye,fe(Ye),c))},[b,ae,fe,T,c]),Ze=In(v),Ee=In(L),ze=Ze!==void 0,He=Ee!==void 0,ht=s.useMemo(()=>{const V={macroUnit:w,microUnit:b,yearStartMonth:c,minDate:r,maxDate:n,macroRange:N,microSelection:[I,I],macroAllowedDates:Ht("macro",g)?Dt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Dt("micro",g).list:void 0};return{macroStart:Ze===void 0?qt:sr({...V,row:"macro",shows:"start",rules:Ze}),macroEnd:Ze===void 0?qt:sr({...V,row:"macro",shows:"end",rules:Ze}),micro:Ee===void 0?qt:sr({...V,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:Ee.previous.window},next:{motion:"shift",window:Ee.next.window}}})}},[Ze,Ee,w,b,c,X,Q,N,I,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),qe=s.useCallback(V=>T(V.macroRange,V.microSelection[0]),[T]),dt=jt(ht.macroStart,qe),C=jt(ht.macroEnd,qe),q=jt(ht.micro,qe),[We,we]=R,ge=s.useMemo(()=>({value:N[0],onChange:Ge,minDate:r,maxDate:N[1],unit:w,yearStartMonth:c,...zt(w,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...ze?{stepper:dt}:{}}),[N,Ge,r,w,c,E,e.formatLocale,e.locale,e.labels,S,ze,dt]),Mt=s.useMemo(()=>({value:N[1],onChange:Ve,minDate:N[0],maxDate:n,unit:w,yearStartMonth:c,...zt(w,E),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...ze?{stepper:C}:{}}),[N,Ve,n,w,c,E,e.formatLocale,e.locale,e.labels,S,ze,C]),It=s.useMemo(()=>({value:I,onChange:lt,minDate:We,maxDate:we,unit:b,yearStartMonth:c,...zt(b,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:S,...He?{stepper:q}:{}}),[I,lt,We,we,b,c,j,e.formatLocale,e.locale,e.labels,S,He,q]),W=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:w,microUnit:b,minDate:r,maxDate:n,macroRange:N,microValue:I,onChangeMacroRange:_e,onChangeMicroPoint:Ce}),[g,t,w,b,r,n,N,I,_e,Ce,c]);return{macroRange:N,setMacroRange:Ke,microValue:I,setMicroValue:se,setMacroLowerDate:Ge,setMacroUpperDate:Ve,setMicroDate:lt,shiftMacroRange:re,shiftMicroValue:nt,resetVernier:ft,macroStartSelectorProps:ge,macroEndSelectorProps:Mt,microSelectorProps:It,sliderProps:W}}function Oa(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Mo(e,t){const r=new Date(e.getTime());return Co(r.getFullYear(),r.getMonth(),t)}function Ps(e){return e===void 0?0:_s(e)?e:Number.NaN}const Ls=An("declare the years to offer with minYear / maxYear or allowedYears");function lo(e,t,r,n){e!==void 0&&wl(e,t,r,n)}function wl(e,t,r,n){if(!Re(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${y(e)})`);Xe("YearSelector",t,e,"year",r,n)}function $s(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: ${t} must be an integer year (received: ${y(e)})`);if(Number.isNaN(Oa(e,r).getTime()))throw new RangeError(`YearSelector: ${t} must name a year that starts inside the Date range (received: ${y(e)}); under yearStartMonth ${r} that year starts on month ${r+1}, day 1`)}}function Ts(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Mo(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function Wu(e,t,r,n){const o=new Set;for(const a of e){const i=Mo(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function Bu(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:Wu(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function Fu(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const Ku=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedYears:f,className:S="",style:v,disabled:L=!1,locale:Y,labels:w,formatLocale:b,formatOption:c,yearStartMonth:g}=e,d=mr("YearSelector",g);if(lo(t,"value",d,""),lo(r,"initialDate",d,""),lo(m,"minDate",d,Ls),lo(h,"maxDate",d,Ls),$s(i,"minYear",d),$s(u,"maxYear",d),Jr("YearSelector","allowedYears",f),f!==void 0)for(let ne=0;ne<f.length;ne++)wl(f[ne],`allowedYears[${ne}]`,d,"");b!==void 0&&Ao("YearSelector","formatLocale",b);const oe=t??r;if(oe===void 0)throw new RangeError("YearSelector: either value (controlled) or initialDate (uncontrolled) is required; the selected year is never inferred from the wall clock");o!==void 0&&Fa("YearSelector",o,t!==void 0);const A=$o(Y,w),te=t!==void 0,[G,he]=Ka(oe,te,ne=>No(ne,"year",d),ne=>Mo(ne,d)),N=m?.getTime(),X=h?.getTime(),Q=s.useMemo(()=>Ts(i,m,Math.max,d),[i,N,d]),R=s.useMemo(()=>Ts(u,h,Math.min,d),[u,X,d]);if(Q!==null&&R!==null&&Q>R)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Q}, upper: ${R})`);const M=f===void 0?null:f.map(ne=>ne.getTime()).join(","),E=s.useMemo(()=>Bu(f,Q,R,d),[M,Q,R,d]);if(E===null)throw new RangeError("YearSelector: a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate), or allowedYears, are required; the option list is never invented");const B=s.useMemo(()=>E.kind==="discrete"?{kind:"candidates",ascending:E.ascending,loIndex:0,hiIndex:E.ascending.length-1}:{kind:"range",min:E.minYear,max:E.maxYear},[E]),H=t!==void 0?Mo(t,d):G,j=!Mn(B,H),I=ne=>{if(!L){if(!Mn(B,ne))throw new RangeError(`YearSelector: refusing to emit ${ne}, which lies outside the selectable years`);te||he(ne),n?.(Oa(ne,d),ne)}},_=Xt(B,H,-1),ie=Xt(B,H,1),pe=()=>{if(o!==void 0){o.onStep("previous");return}_!==null&&I(_)},Z=()=>{if(o!==void 0){o.onStep("next");return}ie!==null&&I(ie)},J=s.useMemo(()=>{const ne=E.kind==="discrete"?[...E.ascending].reverse():Fu(E.minYear,E.maxYear);return j&&(ne.push(H),ne.sort((xe,ae)=>ae-xe)),ne.map(xe=>({value:xe,label:st("year",Oa(xe,d),c,b)}))},[E,j,H,d,b,c]);return $.jsxs("div",{className:`inline-flex items-center ${Dn} ${S}`,style:v,"data-out-of-range":j?"true":void 0,children:[$.jsx(Mr,{neighbour:"control",direction:"left",disabled:L,canStep:o===void 0?_!==null:o.canStepPrevious,onStep:pe,ariaLabel:A.previousYear}),$.jsx("select",{"aria-label":A.yearSelect,disabled:L,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:H,onChange:ne=>{if(!ne.target.value)return;const xe=Number(ne.target.value);Number.isInteger(xe)&&I(xe)},children:J.map(ne=>$.jsx("option",{value:ne.value,disabled:j&&ne.value===H,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:ne.label},ne.value))}),$.jsx(Mr,{neighbour:"control",direction:"right",disabled:L,canStep:o===void 0?ie!==null:o.canStepNext,onStep:Z,ariaLabel:A.nextYear}),a]})},Gu=(e,t)=>{const r=Ps(t.yearStartMonth);return!(Ps(e.yearStartMonth)!==r||!Ba(e,t,n=>No(n,"year",r))||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.allowedYears!==t.allowedYears||e.onChange!==t.onChange||e.stepper===void 0!=(t.stepper===void 0)||e.value===void 0!=(t.value===void 0)||e.stepper?.onStep!==t.stepper?.onStep||e.stepper?.canStepPrevious!==t.stepper?.canStepPrevious||e.stepper?.canStepNext!==t.stepper?.canStepNext||e.children!==t.children||e.locale!==t.locale||!Lo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},bl=s.memo(Ku,Gu);bl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Vs;exports.DateSelector=dl;exports.MonthSelector=gl;exports.PERIOD_SLIDER_LABEL_CATALOGS=Ns;exports.PERIOD_SLIDER_LABEL_KEYS=Po;exports.PeriodSlider=al;exports.YearSelector=bl;exports.addUnit=js;exports.areStylesEqual=ol;exports.calculateConnectDragValues=Bs;exports.calculateHandleDragValues=ya;exports.calculateKeyboardActionValues=Fs;exports.calculateLabelSlant=za;exports.calculateVernierMacroDrag=el;exports.calculateVernierMicroDrag=tl;exports.decode=ee;exports.encode=O;exports.findNearestDateIndex=De;exports.formatLabel=st;exports.formatOptionText=il;exports.formatQuarterLabel=Yc;exports.formatScreenReaderLabel=Sr;exports.getMacroWindowEndDate=zs;exports.getMacroWindowStartDate=Us;exports.getSortedAllowedDates=Hc;exports.normalizeDateByUnit=pt;exports.resolveDraggedEdge=yo;exports.resolveMacroWindow=Rt;exports.resolvePeriodSliderLabels=Os;exports.resolveQuarter=Ws;exports.resolveSelectorSteps=Ta;exports.resolveVernierRailZone=Wa;exports.resolveVernierSelectorSteps=sr;exports.resolveVernierTargetHandle=Js;exports.resolveWheelStep=Qs;exports.usePeriodSliderPoint=ju;exports.usePeriodSliderRange=Hu;exports.useSelectorStepper=jt;exports.useVernierSliderPoint=zu;exports.useVernierSliderRange=Uu;
|