@aiquants/period-slider 0.18.0 → 0.20.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 +209 -0
- package/README.md +26 -7
- 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 +23 -4
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/VirtualDateDropdown.d.ts +25 -10
- 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 +2859 -2394
- package/dist/optionText.d.ts +1 -1
- package/dist/optionText.d.ts.map +1 -1
- package/dist/renderScope.d.ts +486 -0
- package/dist/renderScope.d.ts.map +1 -0
- package/dist/selectorMemo.d.ts +42 -22
- package/dist/selectorMemo.d.ts.map +1 -1
- package/dist/useCommittedRef.d.ts +64 -71
- package/dist/useCommittedRef.d.ts.map +1 -1
- package/dist/usePeriodSlider.d.ts +56 -12
- package/dist/usePeriodSlider.d.ts.map +1 -1
- package/dist/useUncontrolledSelection.d.ts +7 -7
- package/dist/useUncontrolledSelection.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/DateSelector.tsx +45 -20
- package/src/MonthSelector.tsx +41 -19
- package/src/PeriodSlider.tsx +39 -14
- package/src/VirtualDateDropdown.tsx +163 -92
- package/src/YearSelector.tsx +26 -27
- package/src/optionText.ts +6 -4
- package/src/renderScope.ts +766 -0
- package/src/selectorMemo.ts +53 -25
- package/src/useCommittedRef.ts +51 -155
- package/src/usePeriodSlider.ts +316 -138
- package/src/useUncontrolledSelection.ts +8 -9
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),tc=require("date-fns"),s=require("react"),dr=require("@aiquants/virtualscroll"),rc=require("react-dom"),ka="an object that cannot be converted to a string",nc=3,Me=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}},oc=e=>e===void 0||Tt(e);function en(e,t,r){if(!oc(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(Me(e))return Date.prototype.toISOString.call(e);if(Tt(e))return ac(e);try{return String(e)}catch{return ka}},ac=e=>{let t;try{t=e.length}catch{return ka}const r=Math.min(t,nc),n=[];for(let a=0;a<r;a++)n.push(ic(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},ic=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return Tt(r)?`Array(${r.length})`:y(r)}catch{return ka}},xt=(e,t)=>Me(e)?t(e):Number.NaN,mt=(e,t)=>e===void 0?null:xt(e,t),Wi=120,na="data-drag-snap",oa="--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"]},Ps=["low","high"],Ls=["tx","ty","rot"],Do={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"}},Aa=(e,t)=>`${e}-${t}`,aa=(e,t,r)=>`var(${Aa(e,t)}, ${r})`,sc=(e,t,r)=>{const n=Do[t];for(const o of Ps)for(const a of Ls)e.style.setProperty(Aa(n[o],a),r[o][a])},$s=e=>Math.max(0,Math.min(1,e)),ho=(e,t,r,n)=>{const o=$s(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},Oa=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},Ro=(e,t,r,n)=>{const o=$s(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ia=(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`},or=(e,t)=>`var(${e}, ${t}%)`,lc=(e,t,r,n)=>{const[o,a]=xn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},cc=e=>{for(const[t,r]of Object.values(xn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Do))for(const r of Ps)for(const n of Ls)e.style.removeProperty(Aa(t[r],n))},Ts=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],Eo=[...dr.VIRTUAL_SCROLL_LABEL_KEYS,...Ts],va=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:"日"})}),Cs=Object.freeze({en:Object.freeze({...dr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...va.en}),ja:Object.freeze({...dr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...va.ja})}),Bi=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,uc=e=>Eo.includes(e),dc=(e,t)=>{const r={};let n=!1;for(const o of dr.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},mc=e=>{try{return dr.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}},Is=(e,t)=>{const r=mc(e);if(t===void 0)return Cs[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${Bi(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(!uc(u))throw new RangeError(`[period-slider] labels.${u} is not a known label key; expected one of ${Eo.join(", ")}`);const i={...dr.resolveVirtualScrollLabels(r,dc(t,o)),...va[r]};for(const u of Ts){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 ${Bi(m)}`);i[u]=m}}return Object.freeze(i)},fc=e=>{const t={};for(const r of dr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},gc=(e,t)=>e===t||Eo.every(r=>e[r]===t[r]),yo=(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]))},sa=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Fi=new Set(["hidden","clip","scroll","auto","overlay"]),Ki=["paint","strict","content"],hc=["layout","paint","strict","content"],wc=["transform","perspective","filter"],gn=e=>e!==void 0&&e!==""&&e!=="none",bc=e=>e!==void 0&&e!==""&&e!=="normal",Qn=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},pc=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,vc=(e,t)=>t==="absolute"&&gn(e.position)&&e.position!=="static"||gn(e.transform)||gn(e.perspective)||gn(e.filter)||gn(e.backdropFilter)||bc(e.containerType)||hc.some(r=>e.contain.includes(r))?!0:wc.some(r=>e.willChange.includes(r)),Sc=(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 x=null;for(let v=t;v!==null;v=v.parentElement){const L=v===t?f:i.getComputedStyle(v);if(x!==null&&!vc(L,x))continue;const Y=Fi.has(L.overflowX)||Ki.some(b=>L.contain.includes(b)),w=Fi.has(L.overflowY)||Ki.some(b=>L.contain.includes(b));if(Y||w){const b=v.getBoundingClientRect();if(Y&&(o<b.left+Qn(L.borderLeftWidth)||o>=b.right-Qn(L.borderRightWidth))||w&&(a<b.top+Qn(L.borderTopWidth)||a>=b.bottom-Qn(L.borderBottomWidth)))return!1}x=pc(L)}return!0},la=new Map,xc=(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=la.get(e);if(r===void 0){const a=new Set,i=u=>xc(a,u);r={participants:a,listener:i},la.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)&&(la.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Dn="gap-[11px]",_t=6,Yt=_t*2,ar=_t*4/3,Dc={left:`0,${Yt/2} ${_t},0 ${_t},${Yt}`,right:`${ar},${Yt/2} ${ar-_t},0 ${ar-_t},${Yt}`,up:`${Yt/2},0 0,${_t} ${Yt},${_t}`,down:`${Yt/2},${ar} 0,${ar-_t} ${Yt},${ar-_t}`},ca=e=>{e.preventDefault(),e.stopPropagation()},Rc={onMouseDownCapture:ca,onMouseUpCapture:ca,onClickCapture:ca},Ec="period-slider-step",yc=`${Ec} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Pc="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]",Lc={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"},Jn="after:inset-[calc((100%-var(--ps-target-size))/2)]",Gi={horizontal:"px-[19px]",vertical:"py-[19px]"},$c={control:{left:Jn,right:Jn,up:Jn,down:Jn},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)]"}},yr=({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:ar,f=m?ar:Yt,x=r||!n;return $.jsx("button",{ref:u,type:"button","aria-label":a,disabled:r,"aria-disabled":x?!0:void 0,...x?Rc:null,onClick:x?void 0:o,className:`${i===void 0?"":`${i} `}${yc} ${Pc} ${Lc[t]} ${$c[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:Dc[e]})})})},Po=(e,t)=>{const r=s.useMemo(()=>Is(e,t),[e,t]),n=s.useRef(r);return gc(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)})`)},fr=(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)},An=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Lo=(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)=>(fr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:An(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),En=(e,t)=>{if(fr("drawnValuesHas",e),ut("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(An(e))return!1;const r=Lo(e,t);return r<=e.hiIndex&&e.ascending[r]===t},yn=(e,t)=>{if(fr("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(An(e))return null;const r=Lo(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},Zt=(e,t,r)=>{if(fr("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(An(e))return null;const n=Lo(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]},so=(e,t,r)=>{if(fr("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=yn(e,t),o=yn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Tc=(e,t,r)=>{if(fr("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(An(e))return null;const n=Rn(e,-1),o=Rn(e,1),a=r-t;return o!==null&&r>o?so(e,o-a,o):n!==null&&t<n?so(e,n,n+a):so(e,t,r)},lo=(e,t,r)=>(fr("drawnValuesAtOrBeyond",e),ut("drawnValuesAtOrBeyond","target",t),Zt(e,t-r,r)),tn=(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:Lo(n,t),hiIndex:o-1}},co=e=>(fr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Zt(e,t,r),edge:t=>Rn(e,t)}),Sa=(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)})`)}},ks={"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"}},As=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Ct=(e,t)=>{if(!As(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${y(t)})`)},gr=(e,t)=>t===void 0?0:(Ct(e,t),t),$e=(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)})`)},Qt=(e,t,r,n)=>r===void 0?n:($e(e,t,r),r),Cc=[31,28,31,30,31,30,31,31,30,31,30,31],Os=719468,uo=146097,xa=(e,t)=>t!==1?Cc[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,Va=(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,xa(a,i))]},Pn=(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*uo+m-Os},qi=e=>{const t=e+Os,r=Math.floor(t/uo),n=t-r*uo,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(uo-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]},Na=(e,t,r)=>e-(t<r?1:0),pt=(e,t,r=0)=>{if($e("normalizeDateByUnit","unit",e),!Me(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(Na(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},N=(e,t,r=0)=>{$e("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:Pn(o,a,n.getDate())},ee=(e,t,r=0)=>{$e("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},On=e=>`; ${e} instead of a sentinel for "no bound"`,Vs=On("minDate is required, so pass the earliest date to offer"),Xe=(e,t,r,n,o,a)=>{const i=Ns(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},Ns=(e,t,r)=>{const n=N(t,e,r);return Number.isInteger(n)?n:null},_s=(e,t,r)=>{if($e("addUnit","unit",e),!Me(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(...Va(t.getFullYear(),t.getMonth(),t.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},Xi=(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]:qi(t),[h,f,x]=r==="year"||r==="month"?Va(i,u,m,r==="year"?n*12:n):qi(Pn(i,u,m)+n);return e==="year"?Na(h,f,o):e==="month"?h*12+f:Pn(h,f,x)},Ys=(e,t,r,n=0)=>{if($e("getMacroWindowStartDate","macroUnit",e),$e("getMacroWindowStartDate","microUnit",t),!Me(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)},Hs=(e,t,r,n=0)=>{if($e("getMacroWindowEndDate","macroUnit",e),$e("getMacroWindowEndDate","microUnit",t),!Me(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${y(r)})`);Ct("getMacroWindowEndDate",n);let o;if(e==="year"&&t!=="year"){const[i,u]=Va(Na(r.getFullYear(),r.getMonth(),n),n,1,11);o=t==="month"?i*12+u:Pn(i,u,xa(i,u))}else if(e==="month"&&t==="day")o=Pn(r.getFullYear(),r.getMonth(),xa(r.getFullYear(),r.getMonth()));else return Xe("getMacroWindowEndDate","d",r,t,n,""),pt(t,r,n);const a=ee(t,o,n);if(!Me(a))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${y(r)})`);return a},Zi=(e,t,r)=>e<t?t:e>r?r:e,Dt=(e,t,r,n,o,a=0)=>{if($e("resolveMacroWindow","macroUnit",e),$e("resolveMacroWindow","microUnit",t),Ct("resolveMacroWindow",a),wo("macroRange",r,!0,"resolveMacroWindow"),!Me(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${y(n)})`);if(!Me(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=N(e,r[1],a)<N(e,o,a)?Zi(Hs(e,t,r[1],a),n,o):o;return[pt(t,Zi(Ys(e,t,r[0],a),n,o),a),pt(t,i,a)]},js=(e,t)=>{if(!Me(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=((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}},Ic={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Qi=new Map,kc=(e,t)=>{const r=`${e}\0${t}`,n=Qi.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Ic[e]);return Qi.set(r,o),o},Ac=4,Oc=6,$o=e=>e>=0?String(e).padStart(Ac,"0"):`-${String(-e).padStart(Oc,"0")}`,Vc=(e,t)=>{const r=$o(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("formatLabel","unit",e),Me(t)?r?r(t,e,"period"):n===void 0?Vc(e,t):kc(e,n).format(t):""),Dr=(e,t,r,n)=>($e("formatScreenReaderLabel","unit",e),st(e,t,r,n)),Nc=(e,t)=>{if(!Me(e))return"";Ct("formatQuarterLabel",t);const{quarter:r}=js(e,t);return`${st("year",pt("year",e,t))}-Q${r}`},xe=(e,t,r,n=0)=>{if($e("findNearestDateIndex","unit",r),Ct("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!Me(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<=N(r,e[a],n))return 0;if(o>=N(r,e[i],n))return i;for(;a<=i;){const h=a+i>>1,f=N(r,e[h],n);if(f===o)return h;f<o?a=h+1:i=h-1}const u=Math.abs(N(r,e[a],n)-o),m=Math.abs(N(r,e[i],n)-o);return u<m?a:i},_c=(e,t,r,n,o=0)=>($e("getSortedAllowedDates","unit",t),mr("getSortedAllowedDates",To(e),t,r,n,o).dates),To=e=>({list:e,path:"allowedDates",inheritedBy:null}),mr=(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(en(e,`${u}${m}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[L,Y]of[["minDate",n],["maxDate",o]])if(!Me(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,""),x=new Map;for(let L=0;L<i.length;L++){const Y=i[L];if(!Me(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||x.has(w)||x.set(w,pt(r,Y,a))}if(x.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(x.keys()).sort((L,Y)=>L-Y);return{keys:v,dates:v.map(L=>x.get(L))}},_a=(e,t,r,n,o,a)=>{const{keys:i,dates:u}=mr(e,t,r,n,o,a);return u.length===0?null:{...tn(i,null,null),dates:u}},Ln=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),eo=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=xe(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},to=(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:xe(e,new Date(u+i*m),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},Ma=(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))]},Us=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:u,unit:m,yearStartMonth:h=0})=>{if($e("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 I=i[0].getTime(),Z=i[w].getTime(),te=i[b].getTime(),we=i[c].getTime()-te;let O=te+e*(Z-I),Q=O+we;O<I&&(O=I,Q=I+we),Q>Z&&(Q=Z,O=Z-we);const se=xe(i,new Date(O),m,h),E=xe(i,new Date(Q),m,h);return[se,Math.max(se,E)]}const g=Math.round(e*w);let d=b+g,ae=c+g;return d<0&&(ae+=-d,d=0),ae>w&&(d-=ae-w,ae=w),[Math.max(0,Math.min(w,d)),Math.max(0,Math.min(w,ae))]}const f=w=>Math.max(n,Math.min(o,w)),x=o-n;if(x<=0)return[f(t),f(r)];const v=Math.round(e*x);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)]},zs=(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 x=r,v=n;return t==="low"?h?x=o:f?x=n:x=Math.max(o,Math.min(n,r+m)):h?v=r:f?v=a:v=Math.max(r,Math.min(a,n+m)),[x,v]},Ws=8,Bs=2,Fs=16,Yc=12,Hc=90,Ks=(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}},Ya=(e,t)=>{const r=t?.estimatedHeightPx??Fs,o=Ws+(t?.anchorGapY??Bs)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},Ha=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??Fs,u=o?.paddingPx??Yc,m=o?.maxAngleDeg??Hc,h=Ws+(o?.anchorGapY??Bs),f=Ya(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return f;const x=Math.max(0,t-e)/100*r,v=a+u;if(x>=v)return f;const L=Math.max(0,Math.min(1,(v-x)/v)),w=L*L*L*(L*(L*6-15)+10)*m,b=n==="top"?-w:w,c=Ks(a,i,w),g=h+c.acrossPx,d=n==="top"?-g:+g,ae=2*c.alongPx,I=Math.max(0,(ae+u-x)/2);return{lowAngleDeg:b,highAngleDeg:b,lowOffsetX:-I,highOffsetX:I,lowOffsetY:d,highOffsetY:d,isSlanted:L>.001,proximity:L}},Gs=e=>({...e,lowOffsetX:0,highOffsetX:0}),Ht=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Mt=(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}},mo=(e,t,r,n)=>e==="pan"?Tc(t,r,Math.max(r,n)):so(t,r,Math.max(r,n)),ja=(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 Xs(e,t,r,n,o,a,i="macro-top",u=.05,m=!0,h="range"){if(ja(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),x=Math.abs(e-a);return f<=u&&f<=x?"micro-low":x<=u&&x<f?"micro-high":m&&e>=o&&e<=a?"micro-connect":f<x?"micro-low":"micro-high"}function Zs(e,t,r,n,o){if(e==="macro-connect"){const[h,f]=Oa(t-r,n,o);return[h,f,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,u]=ho(a,t,n,o),m=Ro(a,t,n,o);return[i,u,m==="low"?"macro-low":"macro-high"]}function Qs(e,t,r,n,o){if(e==="micro-point"){const[h]=ho("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,f]=Oa(t-r,n,o);return[h,f,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,u]=ho(a,t,n,o),m=Ro(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 jc=(e,t,r,n)=>{if(!Me(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${y(e)})`);if(!Me(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,Vs)},wo=(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(!Me(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${y(o)})`);if(!Me(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)})`)},Js=(e,t)=>{if(!Me(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${y(t)})`)},Gr=(e,t,r,n,o,a)=>{const i=Xe("PeriodSlider",e,t,r,a,"");if(i<N(r,n,a)||i>N(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${y(t)}, minDate: ${y(n)}, maxDate: ${y(o)})`)},Uc=(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&&(wo(o,a,!1),Gr(`${o}[0]`,a[0],e.unit,t,r,n),Gr(`${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&&(Js(o,a),Gr(o,a,e.unit,t,r,n))}},zc=(e,t,r)=>{const n=e.yearStartMonth??0;wo("macroRange",e.macroRange,!0),Xe("PeriodSlider","macroRange[0]",e.macroRange[0],Qt("PeriodSlider","macroUnit",e.macroUnit,e.unit),n,"");const o=Qt("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&&(Js(h,f),Gr(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&&(wo(m,h,!1),Gr(`${m}[0]`,h[0],o,t,r,n),Gr(`${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")},hn=(e,t,r,n,o,a,i,u,m)=>{const h=xe(e,n,t,m),f=xe(e,o,t,m);return i?h:u?f:Math.max(h,Math.min(f,xe(e,r,t,m)+a))},ua=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function Wc(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Bc(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const Ji=()=>{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}},Co=(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)})`)}},Fr=()=>{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]},da=(e,t)=>{const r=fo(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},fo=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Fc=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=Ks(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}},es=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),ts=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),bo=(e,t)=>({"--ps-tooltip-tx":aa(e,"tx",t.tx),"--ps-tooltip-ty":aa(e,"ty",t.ty),"--ps-tooltip-rot":aa(e,"rot",t.rot)}),ma=(e,t,r,n)=>{const o=Ya(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=Ha(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?Gs(a):a,u=Do[e],m={low:es(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:es(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:bo(u.low,m.low),highStyle:bo(u.high,m.high),placements:m}},rs={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},ns=(e,t,r)=>{const n=Ya(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:rs,highStyle:rs,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const m=Ha(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?Gs(m):m}const i=Do.flat,u={low:ts(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:ts(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...bo(i.low,u.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...bo(i.high,u.high)},placements:o?u:null}},Kc={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},Gc={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"}},os={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},qc={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Dn} ${Gi.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${os.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Dn} ${Gi.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${os.vertical}`}},as={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"}},is=(e,t)=>{e.setPointerCapture(t)},Xc=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:x=!0,isVertical:v=!1,hideConnectBar:L=!1,showTicks:Y=!1,colorScheme:w="blue-rose",formatLocale:b}=e;$e("PeriodSlider","unit",t);const c=e.mode==="vernier"?Qt("PeriodSlider","macroUnit",e.macroUnit,t):t,g=e.mode==="vernier"?Qt("PeriodSlider","microUnit",e.microUnit,t):t,d=gr("PeriodSlider",e.yearStartMonth);jc(r,n,e.mode==="vernier"?[c,g,t]:[t],d),Uc(e,r,n),b!==void 0&&Co("PeriodSlider","formatLocale",b);const ae=e.mode==="vernier"?zc(e,r,n):null,I=ae!==null&&ae.shape==="point",Z=Po(e.locale,e.labels),te=ks[w],we=s.useId(),O=s.useRef(e),Q=r.getTime(),se=n.getTime(),E=e.mode==="vernier",M=s.useMemo(()=>E?[]:mr("PeriodSlider",To(o),t,r,n,d).dates,[E,o,t,Q,se,d]),D=M.length>0,{rangeMin:H,rangeMax:W}=s.useMemo(()=>D?{rangeMin:0,rangeMax:M.length-1}:{rangeMin:N(t,r,d),rangeMax:N(t,n,d)},[D,M,t,Q,se,d]),F=e.mode==="point",k=s.useCallback(l=>{if(D){const p=Math.max(0,Math.min(M.length-1,Math.round(l)));return M[p]}return ee(t,Math.round(l),d)},[D,M,t,d]),V=s.useCallback(l=>{if(l===void 0)return H;const p=pt(t,l,d);return D?xe(M,p,t,d):N(t,p,d)},[D,M,t,H,d]),[oe,ge]=s.useState(()=>ae===null?null:ae.selection),q=oe??(ae===null?null:ae.selection),X=q===null?null:Wc(q,I);s.useLayoutEffect(()=>{X!==q&&ge(l=>l===oe?X:l)});const re=e.mode==="vernier"?e.microValue?.getTime():void 0,Re=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,re]),ie=Ji(),fe=Ji(),Te=e.mode!=="vernier"?null:I?Re??X:e.microRange!==void 0?e.microRange:X,Ke=Te===null?null:fe.shown??Te,T=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?Ke?.[0]:void 0,ne=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?Ke?.[1]:void 0,ue=e.mode==="point"?e.value??e.defaultValue:void 0,De=e.mode==="point"?ue?.getTime():T?.getTime(),_e=e.mode==="range"?ne?.getTime():De,[Ce,Ge]=s.useMemo(()=>{if(e.mode==="point"){const S=V(ue);return[S,S]}const l=V(T),p=V(ne);return[Math.min(l,p),Math.max(l,p)]},[e.mode,De,_e,V,ue,T,ne]),Ne=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:I?e.microValue!==void 0:e.microRange!==void 0,[lt,J]=s.useState(()=>E?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),[G,We]=s.useState(null),be=ft?ft[0]:Ne?Ce:nt[0],he=ft?ft[1]:Ne?Ge:nt[1],Rt=s.useRef([be,he]),It=e.mode==="vernier"?e.vernierOrientation??(v?"macro-left":"macro-top"):"macro-top",z=It==="macro-top"||It==="macro-left",_=e.mode==="vernier"?e.showVernierProjection??!0:!1,le=e.mode==="vernier"?e.showVernierTicks??!0:!1,Se=e.mode==="vernier"?e.showHairline??!0:!1,Ye=E?Ht("macro",e):D,P=E?Ht("micro",e):D,j=E?Mt("macro",e).list:o,de=E?Mt("micro",e).list:o,Ie=E?e.formatMacroLabel??e.formatLabel:e.formatLabel,Le=E?e.formatMicroLabel??e.formatLabel:e.formatLabel,ot=T?.getTime(),Qe=ne?.getTime(),[ke,Et]=s.useState(null),yt=s.useRef(null),[Lr,$r]=s.useState(()=>I?"micro-point":"micro-high"),Je=Bc(Lr,I);s.useLayoutEffect(()=>{Je!==Lr&&$r(l=>l===Lr?Je:l)});const wt=s.useMemo(()=>N(c,r,d),[Q,c,d]),kt=s.useMemo(()=>N(c,n,d),[se,c,d]),Vn=s.useMemo(()=>E&&P?_a("PeriodSlider",Mt("micro",e),g,r,n,d):null,[E,P,de,g,Q,se,d]),Ae=s.useMemo(()=>E&&Ye?mr("PeriodSlider",Mt("macro",e),c,r,n,d).dates:[],[E,Ye,j,c,Q,se,d]),Fa=l=>[Math.max(wt,Math.min(kt,N(c,l[0],d))),Math.max(wt,Math.min(kt,N(c,l[1],d)))],[Ka,Ga]=e.mode!=="vernier"?[wt,kt]:Fa(e.macroRange),[et,ct]=ie.shown===null?[Ka,Ga]:Fa(ie.shown),hr=s.useMemo(()=>ee(c,et,d),[c,et,d]),wr=s.useMemo(()=>ee(c,ct,d),[c,ct,d]),Nn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:Dt(c,g,[hr,wr],r,n,d),[e.mode,hr,wr,c,g,Q,se,d]),je=s.useMemo(()=>N(g,Nn[0],d),[g,Nn,d]),at=s.useMemo(()=>N(g,Nn[1],d),[g,Nn,d]),Ao=(l,p)=>Vn===null?[]:Ln(Vn,tn(Vn.ascending,l,p)),pe=s.useMemo(()=>Ao(je,at),[Vn,je,at]),Jt=Ye&&Ae.length>0,Pt=P&&pe.length>0,qa=Jt?N(c,Ae[0],d):wt,Xa=Jt?N(c,Ae[Ae.length-1],d):kt,Za=Pt?N(g,pe[0],d):je,Oo=Pt?N(g,pe[pe.length-1],d):at,wl=Math.min(qa,et),bl=Math.max(Xa,ct),er=(l,p,S,R)=>p.length>0?N(g,p[xe(p,l,g,d)],d):Math.max(S,Math.min(R,N(g,l,d))),Tr=Pt?pe:[],Be=s.useMemo(()=>Ke===null?je:er(Ke[0],Tr,je,at),[ot,je,at,g,Ke,Tr]),it=s.useMemo(()=>Ke===null?at:er(Ke[1],Tr,je,at),[Qe,je,at,g,Ke,Tr]),Cr=s.useMemo(()=>ee(g,Be,d),[g,Be,d]),Ir=s.useMemo(()=>ee(g,it,d),[g,it,d]),Qa=!E||Te===null?null:{macroUnit:c,macroLowEnc:Ka,macroHighEnc:Ga,microUnit:g,microLowEnc:N(g,Te[0],d),microHighEnc:N(g,Te[1],d)},Vo=s.useRef(Qa),No=Math.max(1,kt-wt),Lt=Jt?eo(Ae,c,a,hr,d):Math.max(0,Math.min(1,(et-wt)/No)),At=Math.max(Lt,Jt?eo(Ae,c,a,wr,d):Math.min(1,(ct-wt)/No)),Ja=l=>Math.max(qa,Math.min(Xa,Math.round(wt+l*No))),_n=Math.max(1,at-je),kr=Pt?eo(pe,g,a,Cr,d):Math.max(0,Math.min(1,(Be-je)/_n)),rn=Math.max(kr,Pt?eo(pe,g,a,Ir,d):Math.min(1,(it-je)/_n)),_o=s.useRef({timerId:null,emit:null}),Yn=s.useRef({timerId:null,emit:null}),Hn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const l=[_o,Yn,Hn];return()=>{for(const p of l)ua(p.current)}},[]);const Ar=s.useCallback((l,p,S)=>{ua(l);const{debounceMs:R}=O.current;if(S||!R||R<=0){p();return}l.emit=p,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,p()},R)},[]),ei=s.useCallback(l=>{const p=l.emit;ua(l),p?.()},[]),Or=s.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),Q),se)),[Q,se]),tr=s.useCallback((l,p,S=!1)=>{const[R,A]=Rt.current;if((O.current.mode==="point"?l===R:l===R&&p===A)&&_o.current.timerId===null)return;const K=k(l),B=k(p),me=()=>{const ve=O.current;ve.mode==="point"?ve.onChangePoint?.(K):ve.mode==="range"&&ve.onChangeRange?.(K,B)};Ar(_o.current,me,S)},[k,Ar]),br=s.useCallback((l,p,S=!1)=>{const R=Vo.current;if(O.current.mode!=="vernier"||R===null)return;const A=Or(l),U=Or(p);N(R.macroUnit,A,d)===R.macroLowEnc&&N(R.macroUnit,U,d)===R.macroHighEnc&&Yn.current.timerId===null||Ar(Yn.current,()=>{const K=O.current;K.mode==="vernier"&&K.onChangeMacroRange?.(A,U)},S)},[Or,Ar,d]),vt=s.useCallback((l,p,S=!1)=>{const R=O.current,A=Vo.current;if(R.mode!=="vernier"||A===null)return;const U=Or(l),K=Or(p);N(A.microUnit,U,d)===A.microLowEnc&&N(A.microUnit,K,d)===A.microHighEnc&&Hn.current.timerId===null||((I?R.microValue===void 0:R.microRange===void 0)&&ge([U,K]),Ar(Hn.current,()=>{const B=O.current;if(B.mode==="vernier"){if(I){B.onChangeMicroPoint?.(U);return}B.onChangeMicroRange?.(U,K)}},S))},[Or,Ar,I,d]),ti=s.useCallback((l,p=!1)=>{vt(l,l,p)},[vt]),pr=s.useCallback(l=>{if(D&&a==="time"&&M.length>1){const R=Math.max(0,Math.min(M.length-1,Math.round(l))),A=M[0].getTime(),K=M[M.length-1].getTime()-A;if(K<=0)return 0;const B=M[R].getTime();return Math.max(0,Math.min(100,(B-A)/K*100))}const p=W-H;if(p<=0)return 0;const S=(l-H)/p*100;return Math.max(0,Math.min(100,S))},[D,a,M,H,W]),Yo=s.useCallback(l=>{const p=Math.max(0,Math.min(100,l));if(D){if(a==="time"&&M.length>1){const A=M[0].getTime(),K=M[M.length-1].getTime()-A,B=A+p/100*K;return xe(M,new Date(B),t,d)}const R=Math.round(p/100*(M.length-1));return Math.max(0,Math.min(M.length-1,R))}const S=H+p/100*(W-H);return Math.round(S)},[D,a,M,H,W,t,d]),nn=s.useRef(null),ri=s.useRef(null),ni=s.useRef(0),gt=s.useRef(null),Ho=s.useRef(null),oi=s.useRef(null),ai=s.useRef(null),[jo,ii]=s.useState(0),[pl,Vr]=Fr(),[vl,si]=Fr(),[Sl,li]=Fr(),[xl,ci]=Fr(),[Ml,Uo]=Fr(),[Dl,ui]=Fr(),Rl=F?Vr===null?void 0:{estimatedWidthPx:Vr.widthPx,estimatedHeightPx:Vr.heightPx}:da(Vr,si),zo=!F&&be===he,Wo=et===ct,Bo=!I&&Be===it,El=z?"top":"bottom",yl=z?"bottom":"top",di=x&&!v,Pl=di&&!I,Fo={isPointMode:F,isVertical:v,autoSlantLabels:x,isMerged:zo,trackLengthPx:jo,labelPosition:f,config:Rl},Ko={trackLengthPx:jo,labelPosition:El,config:da(li,ci),isMerged:Wo,isSlantable:di},Go={trackLengthPx:jo,labelPosition:yl,config:da(Uo,ui),isMerged:Bo,isSlantable:Pl};s.useEffect(()=>{const l=gt.current;if(!l)return;const p=()=>{const R=l.getBoundingClientRect(),A=v?R.height:R.width;A>0&&ii(U=>Math.abs(U-A)<.5?U:A)};if(p(),typeof ResizeObserver<"u"){const R=new ResizeObserver(A=>{for(const U of A){const K=v?U.contentRect.height:U.contentRect.width;K>0&&ii(B=>Math.abs(B-K)<.5?B:K)}});return R.observe(l),()=>R.disconnect()}const S=l.ownerDocument.defaultView;if(S)return S.addEventListener("resize",p),()=>S.removeEventListener("resize",p)},[v]);const Nr=s.useCallback((l,p,S)=>{const R=v?S.height:S.width;if(!(Number.isFinite(R)&&R>0))return null;const A=v?S.bottom-p:l-S.left;return Number.isFinite(A)?Math.max(0,Math.min(1,A/R)):null},[v]),mi=s.useCallback((l,p)=>{const S=gt.current;if(!S)return null;const R=Nr(l,p,S.getBoundingClientRect());return R===null?null:R*100},[Nr]),on=s.useRef(null),Bt=s.useRef(null),jn=s.useRef({macroLowRatio:Lt,macroHighRatio:At,isVertical:v,isMacroFirstRail:z}),fi=s.useRef({flat:Fo,macro:Ko,micro:Go});s.useLayoutEffect(()=>{jn.current={macroLowRatio:Lt,macroHighRatio:At,isVertical:v,isMacroFirstRail:z},fi.current={flat:Fo,macro:Ko,micro:Go},O.current=e,Rt.current=[be,he],Vo.current=Qa,He.current=Ee,yt.current=ke});const gi=(l,p)=>{const S=jn.current;Ho.current?.setAttribute("d",ia(l,p,S.isVertical,S.isMacroFirstRail))},Ll=(l,p,S)=>{const R=fi.current;return l==="flat"?ns(p*100,S*100,R.flat).placements:ma(l,p,S,l==="macro"?R.macro:R.micro).placements},an=(l,p,S)=>{const R=gt.current;if(!R)return;on.current={rail:l,lowRatio:p,highRatio:S},lc(R,l,p,S);const A=Ll(l,p,S);A!==null&&sc(R,l,A),l==="macro"&&gi(p,S)},vr=s.useCallback(()=>{Bt.current!==null&&(clearTimeout(Bt.current),Bt.current=null);const l=gt.current;l&&(l.removeAttribute(na),l.style.removeProperty(oa))},[]),hi=()=>{const l=gt.current;if(on.current===null||!l){on.current=null;return}on.current=null,Bt.current!==null&&clearTimeout(Bt.current),l.style.setProperty(oa,`${Wi}ms`),l.setAttribute(na,"true"),cc(l),gi(jn.current.macroLowRatio,jn.current.macroHighRatio),Bt.current=setTimeout(()=>{Bt.current=null,l.removeAttribute(na),l.style.removeProperty(oa)},Wi)};s.useLayoutEffect(()=>{const l=on.current;l!==null&&an(l.rail,l.lowRatio,l.highRatio)}),s.useEffect(()=>()=>{Bt.current!==null&&clearTimeout(Bt.current)},[]);const _r=s.useRef(null),Yr=s.useRef(null),Ot=s.useRef(null),qo=s.useRef(null),sn=s.useRef(null),rr=s.useCallback(()=>_r.current!==null||Yr.current!==null,[]),wi=l=>{if(i)return;if(E){const ce=Yr.current;if(!ce||l.pointerId!==ce.pointerId||!gt.current)return;const $t=Nr(l.clientX,l.clientY,gt.current.getBoundingClientRect());if($t===null)return;if(ce.handle==="macro-low"||ce.handle==="macro-high"||ce.handle==="macro-connect"){const[tt,Fe,Ft]=Zs(ce.handle,$t,ce.startPointerRatio,ce.startMacroLowRatio,ce.startMacroHighRatio);an("macro",tt,Fe),Ft!==yt.current&&(yt.current=Ft,Et(Ft),$r(Ft));let Nt,bt,Kt;if(Jt){const Gt=to(Ae,c,a,tt,d),fn=Math.max(Gt,to(Ae,c,a,Fe,d));bt=Ae[Gt],Kt=Ae[fn],Nt=N(c,bt,d)}else Nt=Ja(tt),bt=ee(c,Nt,d),Kt=ee(c,Ja(Fe),d);ie.show(bt,Kt);const nr=`${bt.getTime()}_${Kt.getTime()}`;nr!==qo.current&&(qo.current=nr,br(bt,Kt));const[mn,Jl]=Dt(c,g,[bt,Kt],r,n,d),Xn=N(g,mn,d),Zn=N(g,Jl,d),Hi=P?Ao(Xn,Zn):[],ji={kind:"range",min:Xn,max:Zn};let xr,Mr;if(ce.handle==="macro-connect"){const Gt=Nt-ce.startMacroLowEnc,fn=mo("pan",ji,Xi(g,ce.initialMicroLowEnc,c,Gt,d),Xi(g,ce.initialMicroHighEnc,c,Gt,d));if(fn===null)return;xr=ee(g,fn[0],d),Mr=ee(g,fn[1],d)}else{const Gt=mo("resize",ji,ce.initialMicroLowEnc,ce.initialMicroHighEnc);if(Gt===null)return;xr=ee(g,Gt[0],d),Mr=ee(g,Gt[1],d)}const Ui=er(xr,Hi,Xn,Zn),ec=Math.max(Ui,er(Mr,Hi,Xn,Zn));xr=ee(g,Ui,d),Mr=ee(g,ec,d),fe.show(xr,Mr);const zi=`${xr.getTime()}_${Mr.getTime()}`;zi!==sn.current&&(sn.current=zi,vt(xr,Mr))}else if(ce.handle==="micro-low"||ce.handle==="micro-high"||ce.handle==="micro-connect"||ce.handle==="micro-point"){const[tt,Fe,Ft]=Qs(ce.handle,$t,ce.startPointerRatio,ce.startMicroLowRatio,ce.startMicroHighRatio);an("micro",tt,Fe),Ft!==yt.current&&(yt.current=Ft,Et(Ft),$r(Ft));let Nt,bt;if(Pt){const nr=to(pe,g,a,tt,d),mn=Math.max(nr,to(pe,g,a,Fe,d));Nt=pe[nr],bt=pe[mn]}else{const nr=er(ee(g,Math.round(je+tt*_n),d),Tr,je,at),mn=Math.max(nr,er(ee(g,Math.round(je+Fe*_n),d),Tr,je,at));Nt=ee(g,nr,d),bt=ee(g,mn,d)}fe.show(Nt,bt);const Kt=`${Nt.getTime()}_${bt.getTime()}`;Kt!==sn.current&&(sn.current=Kt,vt(Nt,bt))}return}const p=_r.current;if(!p||l.pointerId!==p.pointerId||!gt.current)return;const S=gt.current.getBoundingClientRect(),R=v?l.clientY:l.clientX,A=v?S.height:S.width;if(!(Number.isFinite(A)&&A>0))return;if(p.handle==="connect"){const ce=v?(p.startPointerPos-R)/A:(R-p.startPointerPos)/A,[$t,tt]=Oa(ce,p.startLowRatio,p.startHighRatio);an("flat",$t,tt);const Fe=Us({posDiffPct:ce,startLowVal:p.startLowVal,startHighVal:p.startHighVal,rangeMin:H,rangeMax:W,isDiscrete:D,sortedAllowedDates:M,snapMode:a,unit:t,yearStartMonth:d});if(Ot.current&&Ot.current[0]===Fe[0]&&Ot.current[1]===Fe[1])return;Ot.current=Fe,Ze(Fe),tr(Fe[0],Fe[1],!1);return}const U=Nr(l.clientX,l.clientY,S);if(U===null)return;const[K,B]=ho(F?"point":p.handle,U,p.startLowRatio,p.startHighRatio);an("flat",K,B);const me=Yo(U*100),[ve,Oe]=Ma(p.handle,me,p.startLowVal,p.startHighVal,H,W,F);if((!Ot.current||Ot.current[0]!==ve||Ot.current[1]!==Oe)&&(Ot.current=[ve,Oe],Ze([ve,Oe]),tr(ve,Oe,!1)),!F&&(p.handle==="low"||p.handle==="high")){const ce=Ro(p.handle,U,p.startLowRatio,p.startHighRatio);He.current!==ce&&(He.current=ce,ze(ce),qe(ce))}},bi=()=>{hi(),qo.current=null,sn.current=null,Yr.current=null,yt.current=null,Et(null),ie.release(),fe.release(),ei(Yn.current),ei(Hn.current)},pi=()=>{hi();const l=Ot.current??ft;l&&(tr(l[0],l[1],!0),J(l)),Ot.current=null,Ze(null),_r.current=null,He.current=null,ze(null)},vi=l=>{if(E){const S=Yr.current;if(!S||l.pointerId!==S.pointerId)return;bi();return}const p=_r.current;!p||l.pointerId!==p.pointerId||pi()},Si=()=>{Yr.current!==null&&bi(),_r.current!==null&&pi()},Xo=s.useRef(wi),xi=s.useRef(vi),Mi=s.useRef(Si);s.useLayoutEffect(()=>{Xo.current=wi,xi.current=vi,Mi.current=Si});const Di=s.useRef(E);s.useEffect(()=>{Di.current!==E&&(Di.current=E,Mi.current())},[E]);const Ri=Ee!==null||ke!==null;s.useEffect(()=>{if(!Ri)return;const l=nn.current?.ownerDocument.defaultView;if(!l)return;const p=R=>Xo.current(R),S=R=>xi.current(R);return l.addEventListener("pointermove",p),l.addEventListener("pointerup",S),l.addEventListener("pointercancel",S),l.addEventListener("lostpointercapture",S),()=>{l.removeEventListener("pointermove",p),l.removeEventListener("pointerup",S),l.removeEventListener("pointercancel",S),l.removeEventListener("lostpointercapture",S)}},[Ri]);const Zo=s.useCallback((l,p,S,R)=>{vr(),is(l,p),_r.current={pointerId:p,handle:S,startPointerPos:R,startLowVal:be,startHighVal:he,startLowRatio:pr(be)/100,startHighRatio:pr(he)/100},He.current=S,ze(S),S!=="connect"&&qe(S)},[be,he,pr]),Ei=s.useCallback((l,p,S,R)=>{O.current.mode==="vernier"&&(vr(),is(l,p),Yr.current={pointerId:p,handle:S,startPointerRatio:R,startMacroLowRatio:Lt,startMacroHighRatio:At,startMicroLowRatio:kr,startMicroHighRatio:rn,startMacroLowEnc:et,initialMicroLowEnc:Be,initialMicroHighEnc:it},yt.current=S,Et(S),$r(S))},[Lt,At,kr,rn,et,Be,it]),yi=l=>p=>{if(i||rr())return;p.stopPropagation(),p.preventDefault(),qe(l);const S=v?p.clientY:p.clientX;Zo(p.currentTarget,p.pointerId,l,S)},Pi=l=>()=>{i||He.current!==null||qe(l)},Un=l=>()=>{i||yt.current!==null||$r(l)},Hr=l=>p=>{if(i||rr())return;p.stopPropagation(),p.preventDefault();const S=gt.current;if(!S)return;const R=Nr(p.clientX,p.clientY,S.getBoundingClientRect());R!==null&&Ei(p.currentTarget,p.pointerId,l,R)},$l=l=>{if(i||L||rr())return;l.stopPropagation(),l.preventDefault();const p=v?l.clientY:l.clientX;Zo(l.currentTarget,l.pointerId,"connect",p)},Tl=l=>{if(i||rr())return;if(E){const B=gt.current;if(!B)return;const me=B.getBoundingClientRect(),ve=Nr(l.clientX,l.clientY,me);if(ve===null)return;const Oe=v?l.clientX-(me.left+me.width/2):l.clientY-(me.top+me.height/2),ce=Xs(ve,Oe,Lt,At,kr,rn,It,void 0,!L,I?"point":"range");Ei(l.currentTarget,l.pointerId,ce,ve),Xo.current(l.nativeEvent);return}const p=mi(l.clientX,l.clientY);if(p===null)return;const S=Yo(p);let R="low";if(!F){const B=Math.abs(S-be),me=Math.abs(S-he);B<me?R="low":me<B?R="high":R=S>he?"high":"low"}qe(R);const[A,U]=Ma(R,S,be,he,H,W,F);Ze([A,U]),tr(A,U,!0);const K=v?l.clientY:l.clientX;Zo(l.currentTarget,l.pointerId,R,K)},Cl=l=>{if(i||E||Ee!==null)return;const p=mi(l.clientX,l.clientY);if(p===null)return;const S=Yo(p);C(S),We(pr(S))},Il=()=>{C(null),We(null)},Li=l=>p=>{if(i||rr())return;qe(l);const S=zs(p.key,l,be,he,H,W,F,1);S&&(p.preventDefault(),vr(),Ne||J(S),tr(S[0],S[1],!0))},jr=(l,p,S)=>{if(Te===null)return;const[R,A]=Dt(c,g,[l,p],r,n,d),U=N(g,R,d),K=N(g,A,d),B=P?Ao(U,K):[],me=mo(S,{kind:"range",min:U,max:K},N(g,Te[0],d),N(g,Te[1],d));if(me===null)return;const ve=er(ee(g,me[0],d),B,U,K),Oe=Math.max(ve,er(ee(g,me[1],d),B,U,K));vt(ee(g,ve,d),ee(g,Oe,d),!0)},zn=l=>p=>{if(i||!E||e.mode!=="vernier"||rr())return;$r(l);let S=0,R=!1,A=!1;switch(p.key){case"ArrowRight":case"ArrowUp":S=1;break;case"ArrowLeft":case"ArrowDown":S=-1;break;case"PageUp":S=5;break;case"PageDown":S=-5;break;case"Home":R=!0;break;case"End":A=!0;break;default:return}if(p.preventDefault(),vr(),l==="macro-low"){const U=ee(c,et,d),K=ee(c,ct,d);if(Jt){const ve=hn(Ae,c,U,Ae[0],K,S,R,A,d);if(ve===xe(Ae,U,c,d))return;const Oe=Ae[ve];br(Oe,K,!0),jr(Oe,K,"resize");return}let B;if(R?B=wt:A?B=ct:B=Math.max(wt,Math.min(ct,et+S)),B===et)return;const me=ee(c,B,d);br(me,K,!0),jr(me,K,"resize")}else if(l==="macro-high"){const U=ee(c,et,d),K=ee(c,ct,d);if(Jt){const ve=hn(Ae,c,K,U,Ae[Ae.length-1],S,R,A,d);if(ve===xe(Ae,K,c,d))return;const Oe=Ae[ve];br(U,Oe,!0),jr(U,Oe,"resize");return}let B;if(R?B=et:A?B=kt:B=Math.max(et,Math.min(kt,ct+S)),B===ct)return;const me=ee(c,B,d);br(U,me,!0),jr(U,me,"resize")}else if(l==="micro-low"){const U=ee(g,Be,d),K=ee(g,it,d);if(Pt){const me=hn(pe,g,U,pe[0],K,S,R,A,d);if(me===xe(pe,U,g,d))return;vt(pe[me],K,!0);return}let B;if(R?B=je:A?B=it:B=Math.max(je,Math.min(it,Be+S)),B===Be)return;vt(ee(g,B,d),K,!0)}else if(l==="micro-high"){const U=ee(g,Be,d),K=ee(g,it,d);if(Pt){const me=hn(pe,g,K,U,pe[pe.length-1],S,R,A,d);if(me===xe(pe,K,g,d))return;vt(U,pe[me],!0);return}let B;if(R?B=Be:A?B=at:B=Math.max(Be,Math.min(at,it+S)),B===it)return;vt(U,ee(g,B,d),!0)}else if(l==="micro-point"){const U=ee(g,Be,d);if(Pt){const B=hn(pe,g,U,pe[0],pe[pe.length-1],S,R,A,d);if(B===xe(pe,U,g,d))return;ti(pe[B],!0);return}let K;if(R?K=je:A?K=at:K=Math.max(je,Math.min(at,Be+S)),K===Be)return;ti(ee(g,K,d),!0)}},kl=l=>{if(e.mode!=="vernier")return;if(vr(),Jt){const K=Ae.length-1,B=xe(Ae,hr,c,d),me=xe(Ae,wr,c,d),ve=me-B;let Oe=B+l,ce=me+l;if(l<0&&Oe<0?(Oe=0,ce=Math.min(K,ve)):l>0&&ce>K&&(ce=K,Oe=Math.max(0,K-ve)),Oe===B&&ce===me)return;const $t=Ae[Oe],tt=Ae[ce];br($t,tt,!0),jr($t,tt,"pan");return}const p=ct-et;let S=et+l,R=ct+l;if(l<0&&S<wt?(S=wt,R=Math.min(kt,S+p)):l>0&&R>kt&&(R=kt,S=Math.max(wt,R-p)),S===et&&R===ct)return;const A=ee(c,S,d),U=ee(c,R,d);br(A,U,!0),jr(A,U,"pan")},Qo=s.useCallback(l=>{const p=O.current;if(!(p.disabled||rr()))if(vr(),p.mode==="point"){const S=Math.max(H,Math.min(W,be+l));Ne||J([S,S]),tr(S,S,!0)}else if(p.mode==="vernier"){if(Pt){const ve=pe.length-1,Oe=xe(pe,Cr,g,d),ce=xe(pe,Ir,g,d),$t=ce-Oe;let tt=Oe+l,Fe=ce+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!==Oe||Fe!==ce)&&vt(pe[tt],pe[Fe],!0);return}const S=Be,R=it,A=je,U=at,K=R-S;let B=S+l,me=R+l;l<0&&B<A?(B=A,me=Math.min(U,B+K)):l>0&&me>U&&(me=U,B=Math.max(A,me-K)),(B!==S||me!==R)&&vt(ee(g,B,d),ee(g,me,d),!0)}else{const S=he-be;let R=be+l,A=he+l;l<0&&R<H?(R=H,A=Math.min(W,R+S)):l>0&&A>W&&(A=W,R=Math.max(H,A-S)),R<=A&&(Ne||J([R,A]),tr(R,A,!0))}},[be,he,H,W,Ne,tr,vt,Be,it,je,at,g,Pt,pe,Cr,Ir,vr,d]),$i=l=>!i&&sa(nn.current,l),Ti=(l,p)=>{const S=ri.current,R=gt.current,A=nn.current;if(i||S===null||R===null||A===null||!Sc(S,A,ni.current,v,l,p))return null;const U=R.getBoundingClientRect();return Math.abs(v?l-(U.left+U.width/2):p-(U.top+U.height/2))},Ci=l=>{if(i||rr())return;const p=qs(l.deltaX,l.deltaY,v);if(p===0)return;l.preventDefault();const S=l.target,R=sa(oi.current,S)||sa(ai.current,S);if(!E||R){Qo(p);return}const A=gt.current;if(!A)return;const U=A.getBoundingClientRect(),K=v?l.clientX-(U.left+U.width/2):l.clientY-(U.top+U.height/2);if(ja(K,It)==="macro"){kl(p);return}Qo(p)},Wn=s.useRef({ownsWheelHit:$i,distanceToRailPx:Ti,stepFromRangeAreaWheel:Ci});s.useLayoutEffect(()=>{Wn.current={ownsWheelHit:$i,distanceToRailPx:Ti,stepFromRangeAreaWheel:Ci}});const ln=s.useRef(null);s.useEffect(()=>{const l=nn.current?.ownerDocument.defaultView??null,p=ln.current;if(p!==null&&p.view===l)return;if(p?.unregister(),l===null){ln.current=null;return}const S=Mc(l,{ownsHit:R=>Wn.current.ownsWheelHit(R),distanceToRailPx:(R,A)=>Wn.current.distanceToRailPx(R,A),step:R=>Wn.current.stepFromRangeAreaWheel(R)});ln.current={view:l,unregister:S}}),s.useEffect(()=>()=>{ln.current?.unregister(),ln.current=null},[]);const Bn=pr(be),Fn=pr(he),Jo=k(be),ea=k(he),ta=ns(Bn,Fn,Fo),cn=ta.slant,un=Ee==="low"||Ee!=="high"&&ht==="low",dn=!F&&(Ee==="high"||Ee!=="low"&&ht==="high"),Al=Wo&&Je!=="macro-low",Ol=Wo&&Je==="macro-low",Vl=Bo&&Je!=="micro-low",Nl=Bo&&Je==="micro-low",Ur=ma("macro",Lt,At,Ko),zr=ma("micro",kr,rn,Go),_l=Math.min(Bn,Fn),Yl=Math.max(Bn,Fn),[Ii,ki]=xn.flat,[Hl,jl]=xn.macro,[Ul,zl]=xn.micro,Ai=or(Ii,Bn),Oi=or(ki,Fn),ra=or(Ii,_l),Vi=`calc(${or(ki,Yl)} - ${ra})`,Wr=or(Hl,Lt*100),Kn=or(jl,At*100),Br=or(Ul,kr*100),Gn=or(zl,rn*100),Wl=v?{bottom:ra,height:Vi,top:"auto",left:"0",right:"0"}:{left:ra,width:Vi,top:"0",bottom:"0"},Bl=Math.max(.01,At-Lt),Ni=Math.max(.06,Math.min(.25,.28*Math.sqrt(Bl))),Fl=v?{bottom:Ai,left:"50%",transform:"translate(-50%, 50%)",zIndex:un?40:30}:{left:Ai,top:"50%",transform:"translate(-50%, -50%)",zIndex:un?40:30},Kl=v?{bottom:Oi,left:"50%",transform:"translate(-50%, 50%)",zIndex:dn?40:30}:{left:Oi,top:"50%",transform:"translate(-50%, -50%)",zIndex:dn?40:30},Gl=v?{bottom:`${G}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${G}%`,top:"50%",transform:"translate(-50%, -50%)"},_i=dt!==null?k(dt):null,ql=h!=="hover"&&dt!==null&&(dt===be||!F&&dt===he),Xl=E?Be>Za:be>H,Zl=E?it<Oo:he<W,qn=Fc(E?[{side:z?"before":"after",box:fo(li,ci),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:Ur.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Ur.slant.lowOffsetX}},{side:z?"after":"before",box:I?Uo:fo(Uo,ui),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:zr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:zr.slant.lowOffsetX}}]:[{side:v||f==="top"?"before":"after",box:F?Vr:fo(Vr,si),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:cn.lowAngleDeg,centreOffsetPx:cn.lowOffsetY,alongPushPx:cn.lowOffsetX}}]),Ql=qn===void 0?e.style:{...e.style,...qn.style};s.useLayoutEffect(()=>{ni.current=qn===void 0?0:qn.mainPx});const Vt=I?"micro-point":"micro-low",Sr=i?"cursor-not-allowed opacity-50":"cursor-pointer",Yi=l=>{const p=v?"vertical":"horizontal",S=l==="decrease",R=v?!S:S;return $.jsx(yr,{ref:S?oi:ai,neighbour:"rail",direction:Kc[p][l],disabled:i,canStep:S?Xl:Zl,onStep:()=>Qo(S?-1:1),ariaLabel:S?Z.decrease:Z.increase,className:`period-slider-stepper-btn ${Gc[p][l]} ${as[p][R?"leading":"trailing"]}`})};return $.jsxs("div",{ref:nn,style:Ql,className:`period-slider grid select-none place-items-center ${qc[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:ri,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),m&&Yi(v?"increase":"decrease"),$.jsx("div",{ref:gt,"data-testid":"period-slider-track","data-orientation":v?"vertical":"horizontal","data-vernier-orientation":E?It:void 0,className:`period-slider-track relative touch-none rounded-full ${as[v?"vertical":"horizontal"][m?"rail":"railOnly"]} ${Sr}`,onPointerDown:Tl,onPointerMove:Cl,onPointerLeave:Il,children:E?$.jsxs($.Fragment,{children:[_&&(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:we,x1:"0",y1:"0",x2:"1",y2:"0",children:[$.jsx("stop",{offset:"0%",stopColor:z?te.macro:te.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:z?te.micro:te.macro,stopOpacity:Ni})]})}),$.jsx("path",{ref:Ho,"data-testid":"period-slider-vernier-projection",d:ia(Lt,At,v,z),fill:`url(#${we})`})]}):$.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:we,x1:"0",y1:"0",x2:"0",y2:"1",children:[$.jsx("stop",{offset:"0%",stopColor:z?te.macro:te.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:z?te.micro:te.macro,stopOpacity:Ni})]})}),$.jsx("path",{ref:Ho,"data-testid":"period-slider-vernier-projection",d:ia(Lt,At,v,z),fill:`url(#${we})`})]})),!L&&$.jsxs($.Fragment,{children:[$.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:v?{bottom:`calc(${Wr} - 8px)`,height:`calc(${Kn} - ${Wr} + 16px)`}:{left:`calc(${Wr} - 8px)`,width:`calc(${Kn} - ${Wr} + 16px)`},onPointerDown:Hr("macro-connect")}),!I&&$.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:v?{bottom:`calc(${Br} - 8px)`,height:`calc(${Gn} - ${Br} + 16px)`}:{left:`calc(${Br} - 8px)`,width:`calc(${Gn} - ${Br} + 16px)`},onPointerDown:Hr("micro-connect")})]}),le&&$.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":Z.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":wl,"aria-valuemax":ct,"aria-valuenow":et,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(hr,c,"period"):Dr(c,hr,Ie,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${Sr}`,style:v?{bottom:Wr,left:z?0:"auto",right:z?"auto":0,transform:z?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:ke==="macro-low"||Je==="macro-low"?30:15}:{left:Wr,top:z?0:"auto",bottom:z?"auto":0,transform:z?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:ke==="macro-low"||Je==="macro-low"?30:15},onPointerDown:Hr("macro-low"),onKeyDown:zn("macro-low"),onFocus:Un("macro-low"),"data-active":ke==="macro-low"?"true":void 0,"data-front":Je==="macro-low"?"true":void 0,"data-vernier-pos":v?z?"left":"right":z?"top":"bottom","data-handle-type":"macro-low",children:[$.jsx(vn,{type:"macro",isTop:z,isVertical:v,isLeft:z}),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":Al?"true":void 0,"data-slanted":Ur.slant.isSlanted?"true":void 0,ref:Sl,style:Ur.lowStyle,children:st(c,hr,Ie,b)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":Z.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":et,"aria-valuemax":bl,"aria-valuenow":ct,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(wr,c,"period"):Dr(c,wr,Ie,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${Sr}`,style:v?{bottom:Kn,left:z?0:"auto",right:z?"auto":0,transform:z?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:ke==="macro-high"||Je==="macro-high"?30:15}:{left:Kn,top:z?0:"auto",bottom:z?"auto":0,transform:z?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:ke==="macro-high"||Je==="macro-high"?30:15},onPointerDown:Hr("macro-high"),onKeyDown:zn("macro-high"),onFocus:Un("macro-high"),"data-active":ke==="macro-high"?"true":void 0,"data-front":Je==="macro-high"?"true":void 0,"data-vernier-pos":v?z?"left":"right":z?"top":"bottom","data-handle-type":"macro-high",children:[$.jsx(vn,{type:"macro",isTop:z,isVertical:v,isLeft:z}),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":Ur.slant.isSlanted?"true":void 0,ref:xl,style:Ur.highStyle,children:st(c,wr,Ie,b)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":I?Z.microSelectedDate:Z.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Za,"aria-valuemax":I?Oo:it,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Cr,g,"period"):Dr(g,Cr,Le,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${Sr}`,style:v?{bottom:Br,left:z?"auto":0,right:z?0:"auto",transform:z?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:ke===Vt||Je===Vt?30:20}:{left:Br,top:z?"auto":0,bottom:z?0:"auto",transform:z?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:ke===Vt||Je===Vt?30:20},onPointerDown:Hr(Vt),onKeyDown:zn(Vt),onFocus:Un(Vt),"data-active":ke===Vt?"true":void 0,"data-front":Je===Vt?"true":void 0,"data-vernier-pos":v?z?"right":"left":z?"bottom":"top","data-handle-type":Vt,children:[$.jsx(vn,{type:"micro",isTop:!z,isVertical:v,isLeft:!z}),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":zr.slant.isSlanted?"true":void 0,ref:Ml,style:zr.lowStyle,children:st(g,Cr,Le,b)})]}),!I&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":Z.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Be,"aria-valuemax":Oo,"aria-valuenow":it,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Ir,g,"period"):Dr(g,Ir,Le,b),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${Sr}`,style:v?{bottom:Gn,left:z?"auto":0,right:z?0:"auto",transform:z?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:ke==="micro-high"||Je==="micro-high"?30:20}:{left:Gn,top:z?"auto":0,bottom:z?0:"auto",transform:z?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:ke==="micro-high"||Je==="micro-high"?30:20},onPointerDown:Hr("micro-high"),onKeyDown:zn("micro-high"),onFocus:Un("micro-high"),"data-active":ke==="micro-high"?"true":void 0,"data-front":Je==="micro-high"?"true":void 0,"data-vernier-pos":v?z?"right":"left":z?"bottom":"top","data-handle-type":"micro-high",children:[$.jsx(vn,{type:"micro",isTop:!z,isVertical:v,isLeft:!z}),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":Nl?"true":void 0,"data-slanted":zr.slant.isSlanted?"true":void 0,ref:Dl,style:zr.highStyle,children:st(g,Ir,Le,b)})]})]}):$.jsxs($.Fragment,{children:[!L&&$.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Wl,onPointerDown:$l}),Y&&D&&M.length>1&&$.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:M.map((l,p)=>{const S=N(t,l,d),R=pr(p),A=v?{bottom:`${R}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${R}%`,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:A},`tick-${S}`)})}),!i&&dt!==null&&G!==null&&Ee===null&&_i&&$.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Gl,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":ql?"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,_i,e.formatLabel,b)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":F?Z.selectedDate:Z.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":H,"aria-valuemax":F?W:he,"aria-valuenow":be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Jo,t,"period"):Dr(t,Jo,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 ${Sr}`,style:Fl,onPointerDown:yi("low"),onKeyDown:Li("low"),onFocus:Pi("low"),"data-active":Ee==="low"?"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==="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":cn.isSlanted?"true":void 0,"data-front":un?"true":void 0,"data-duplicate":zo&&!un?"true":void 0,ref:pl,style:ta.lowStyle,children:st(t,Jo,e.formatLabel,b)})]}),!F&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":Z.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":be,"aria-valuemax":W,"aria-valuenow":he,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(ea,t,"period"):Dr(t,ea,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 ${Sr}`,style:Kl,onPointerDown:yi("high"),onKeyDown:Li("high"),onFocus:Pi("high"),"data-active":Ee==="high"?"true":void 0,"data-front":dn?"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":cn.isSlanted?"true":void 0,"data-front":dn?"true":void 0,"data-duplicate":zo&&!dn?"true":void 0,ref:vl,style:ta.highStyle,children:st(t,ea,e.formatLabel,b)})]})]})}),m&&Yi(v?"decrease":"increase")]})},rt=e=>e.getTime(),el=(e,t)=>!(Tt(e)&&Tt(t))||e.length!==2||t.length!==2?!1:xt(e[0],rt)===xt(t[0],rt)&&xt(e[1],rt)===xt(t[1],rt),ro=(e,t)=>e===void 0||t===void 0?e===t:el(e,t),fa=(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(xt(e[r],rt)!==xt(t[r],rt))return!1;return!0},tl=(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,rt)!==xt(t.minDate,rt)||xt(e.maxDate,rt)!==xt(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||!tl(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!yo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!fa(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"?!(!ro(e.range,t.range)||!ro(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!ro(e.microRange,t.microRange)||!ro(e.defaultMicroRange,t.defaultMicroRange)||mt(e.microValue,rt)!==mt(t.microValue,rt)||mt(e.defaultMicroValue,rt)!==mt(t.defaultMicroValue,rt)||!el(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||!fa(e.macroAllowedDates,t.macroAllowedDates)||!fa(e.microAllowedDates,t.microAllowedDates)):!1,rl=s.memo(Xc,Zc);rl.displayName="PeriodSlider";const ss=2,ye=-1,St=e=>N("day",e),$n=e=>ee("day",e),wn=e=>`${$o(e.getFullYear())}-${String(e.getMonth()+1).padStart(ss,"0")}-${String(e.getDate()).padStart(ss,"0")}`,Qc=(e,t,r,n)=>{const o=St(e),a=St(t),i=a>=o?a-o+1:0,u=h=>$n(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=St(h);return f<o||f>a?ye:a-f},nearestIndexOf:h=>{if(i===0)return ye;const f=yn(m,St(h));return f===null?ye:a-f}}},Jc=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,u=x=>e[n-x],m={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},h=x=>{const v=x.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 ye},f=x=>x===null?ye:h($n(x));return{count:i,dateAt:u,labelAt:x=>st("day",u(x),a,o),indexOf:h,nearestIndexOf:x=>f(yn(m,St(x)))}},eu={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:()=>ye,nearestIndexOf:()=>ye},tu=(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}},ru=(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))},nu={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},ou={month:2,day:2},ls={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},cs=new Map,au=(e,t)=>{const r=`${e}\0${t}`,n=cs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,nu[e]);return cs.set(r,o),o},iu=(e,t,r)=>r!==void 0?au(e,r).format(t):e==="year"?$o(ls.year(t)):String(ls[e](t)).padStart(ou[e],"0"),nl=(e,t,r,n)=>{if($e("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${y(r)})`);return Me(e)?r==="part"?iu(t,e,n):st(t,e,void 0,n):""},ol=(e,t)=>t(e).getTime(),Ua=(e,t,r)=>{const n=a=>ol(a,r),o=a=>a.value!==void 0?a.value:a.initialDate;return mt(o(e),n)!==mt(o(t),n)||t.value!==void 0&&Number.isNaN(mt(t.initialDate,n))||mt(e.minDate,n)!==mt(t.minDate,n)?!1:mt(e.maxDate,n)===mt(t.maxDate,n)},ga=Symbol("nothing handed");class su{held;writeCount=0;handed=ga;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=ga}forgetHandedUnless(t){this.handed!==t&&(this.handed=ga)}commit(t,r){this.writeCount===r&&(this.held=t)}}function Ue(e){const[t]=s.useState(()=>new su(e)),r=t.writes;return s.useInsertionEffect(()=>{t.commit(e,r)}),t}const lu={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},cu=["shift","start","end","single"],uu=["disable","clamp"],du=["follow","keep"],us={day:{day:1},month:{month:1,year:12},year:{year:1}},ds=new WeakMap,Da=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${y(r)})`)},ms=(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)})`)},Pr=(e,t,r,n)=>{Da(e,t,r),ms(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Da(e,a,i),ms(e,a,i,lu[n]);const{motion:u,edge:m,window:h}=i;if(n!=="vernierPoint"&&(typeof u!="string"||!cu.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"||!uu.includes(m))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${y(m)})`)}if(h!==void 0&&(typeof h!="string"||!du.includes(h)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${y(h)})`)}},za=(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`)},qt=(e,t,r,n,o)=>{if(!Me(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${y(r)})`);return Xe(e,t,r,n,o,"")},al=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=ds.get(r),u=i?.get(a);if(u!==void 0)return u;const m=[];for(let f=0;f<r.length;f++)m.push(qt(e,`${t}[${f}]`,r[f],n,o));const h=Array.from(new Set(m)).sort((f,x)=>f-x);return i===void 0?ds.set(r,new Map([[a,h]])):i.set(a,h),h},mu=(e,t)=>t===1?co(e):{stepEnd:(r,n)=>lo(e,r+t*n,n),edge:r=>Rn(e,r)},Ra=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},Ea=(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]},ya=e=>{const t="resolveSelectorSteps";Da(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:u,rules:m}=e;$e(t,"unit",o);const h=Qt(t,"stepUnit",e.stepUnit,o),f=us[o][h];if(f===void 0){const d=Object.keys(us[o]).map(ae=>`"${ae}"`).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 x=gr(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)})`);Pr(t,"rules",m,"motion");const v=qt(t,"selection[0]",r[0],o,x),L=qt(t,"selection[1]",r[1],o,x);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:qt(t,"minDate",a,o,x),w=i===void 0?null:qt(t,"maxDate",i,o,x);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)})`);en(t,"allowedDates",u);const b=u===void 0?{kind:"range",min:Y,max:w}:tn(al(t,"allowedDates",u,o,x),Y,w),c=mu(b,f),g=(d,ae)=>{const I=Sa(c,v,L,d,Ra(ae,n));return I===null?null:Ea(I,[v,L],r,o,x,ae.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 fu(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function Wa(e,t,r,n){const o=t?null:ol(e,r),[a,i]=s.useState(()=>({source:o,held:n(e)})),u=s.useCallback(h=>i(f=>({source:f.source,held:h})),[]),m=fu(a,o,e,n);return s.useLayoutEffect(()=>{m!==a&&i(h=>h===a?m:h)}),[m.held,u]}const go=44,fs=7,no=8,gu=2,il=10,hu=1e3,Pa=8,ha=6,wa=4,ba=12,bn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),St(r)},wu=(e,t)=>{if(e.length<wa||t.count===0)return ye;const r=Number(e.slice(0,wa));if(!Number.isInteger(r))return ye;const n=e.length>=ha,o=n?Number(e.slice(wa,ha)):ba;if(o<1||o>ba)return ye;const a=e.length>=Pa,i=a?Number(e.slice(ha,Pa)):0,u=bn(r,o),m=(o===ba?bn(r+1,1):bn(r,o+1))-1,h=a?u+i-1:n?u:bn(r,1),f=a?h:n?m:bn(r+1,1)-1;if(a&&(i<1||h>m))return ye;for(let x=f;x>=h;x--){const v=t.indexOf($n(x));if(v!==ye)return v}return ye},bu=e=>e.closest(".dark")===null?"light":"dark",pu=(e,t,r,n)=>{const o=r-e.bottom-no,a=e.top-no,i=o>=t||o>=a,m=Math.max(go,Math.min(t,i?o:a)),h=i?e.bottom:e.top-m,f=e.width+il,x=Math.max(no,Math.min(e.left,n-f-no));return{top:h,left:x,width:f,height:m}},vu=(e,t)=>e<t?e:t>0?t-1:ye,sl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:u,labels:m,onCommitIndex:h,controlClassName:f})=>{const x=s.useId(),v=s.useMemo(()=>fc(m),[m]),L=`period-slider-date-listbox-${x}`,Y=s.useCallback(T=>`period-slider-date-option-${x}-${T}`,[x]),[w,b]=s.useState(!1),[c,g]=s.useState(ye),[d,ae]=s.useState(!0),[I,Z]=s.useState(null),[te,we]=s.useState(null),O=s.useRef(null),Q=s.useRef(null),se=s.useRef(null),E=s.useRef({buffer:"",at:0}),M=e.count,D=vu(c,M),H=Ue(D);s.useLayoutEffect(()=>{D!==c&&g(T=>T===c?D:T)});const W=Math.min(M,fs)*go,F=Math.max(1,Math.min(M,fs)),k=s.useCallback(()=>{const T=O.current;if(T===null)return;const ne=T.getBoundingClientRect();Z(pu(ne,W,window.innerHeight,window.innerWidth))},[W]),V=s.useCallback(()=>{b(!1),g(ye),E.current={buffer:"",at:0}},[]),oe=s.useCallback(T=>{a||M===0||(g(T),b(!0))},[a,M]);s.useLayoutEffect(()=>{if(!w){Z(null),we(null);return}const T=O.current;return T!==null&&we(bu(T)),k(),window.addEventListener("scroll",k,!0),window.addEventListener("resize",k),()=>{window.removeEventListener("scroll",k,!0),window.removeEventListener("resize",k)}},[w,k]),s.useEffect(()=>{if(!w)return;const T=ne=>{const ue=ne.target;ue!==null&&Q.current?.contains(ue)!==!0&&O.current?.contains(ue)!==!0&&V()};return document.addEventListener("pointerdown",T,!0),()=>document.removeEventListener("pointerdown",T,!0)},[w,V]),s.useEffect(()=>{w&&(a||M===0)&&V()},[w,a,M,V]),s.useEffect(()=>{if(!w)return;const T=H.current;T!==ye&&se.current?.scrollToIndex(T,{align:"center"})},[M,w,H]);const ge=T=>{if(M===0)return;const ne=Math.max(0,Math.min(T,M-1));g(ne),se.current?.scrollToIndex(ne,{align:"center"})},q=T=>{T<0||T>=M||(h(T),V(),O.current?.focus())},X=Ue(q),re=T=>{if(a)return;const ne=D!==ye?D:t!==ye?t:r;switch(T.key){case"ArrowDown":if(T.preventDefault(),!w){oe(ne);return}ge(ne+1);return;case"ArrowUp":if(T.preventDefault(),!w){oe(ne);return}ge(ne-1);return;case"Home":if(!w)return;T.preventDefault(),ge(0);return;case"End":if(!w)return;T.preventDefault(),ge(M-1);return;case"PageDown":if(!w)return;T.preventDefault(),ge(ne+F);return;case"PageUp":if(!w)return;T.preventDefault(),ge(ne-F);return;case"Enter":if(T.preventDefault(),!w){oe(ne);return}q(D!==ye?D:ne);return;case"Escape":if(!w)return;T.preventDefault(),V();return;case"Tab":w&&V();return}if(T.key.length!==1)return;const ue=T.key>="0"&&T.key<="9",De=T.key==="-"||T.key==="/"||T.key===".";if(!(ue||De))return;T.preventDefault();const _e=Date.now(),Ce=_e-E.current.at>hu?"":E.current.buffer,Ge=ue?`${Ce}${T.key}`.slice(0,Pa):Ce;E.current={buffer:Ge,at:_e};const Ne=wu(Ge,e);if(Ne!==ye){if(!w){oe(Ne);return}ge(Ne)}},Re=s.useCallback(T=>T,[]),ie=s.useCallback(()=>go,[]),fe=s.useCallback(T=>{const ne=H.current;ae(ne===ye||ne>=T.renderingStartIndex&&ne<=T.renderingEndIndex)},[H]),Te=s.useCallback(T=>{const ne=T===t,ue=T===D;return $.jsx("div",{id:Y(T),role:"option","aria-selected":ne,"aria-posinset":T+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":ue?"true":void 0,className:"period-slider-date-option",style:{height:go},onClick:()=>X.current(T),children:e.labelAt(T)})},[e,t,D,Y,X]),Ke=w&&I!==null&&te!==null&&M>0?$.jsx("div",{ref:Q,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":te,style:{top:I.top,left:I.left,width:I.width,height:I.height},onMouseDown:T=>{T.preventDefault()},children:$.jsx(dr.VirtualScroll,{ref:se,itemCount:M,getItem:Re,getItemHeight:ie,viewportSize:I.height-gu,initialScrollIndex:D!==ye?D:void 0,onRangeChange:fe,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:il,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:Te})}):null;return $.jsxs($.Fragment,{children:[$.jsx("input",{ref:O,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":w,"aria-controls":w?L:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none","aria-activedescendant":w&&D!==ye&&d?Y(D):void 0,disabled:a,value:n,className:f,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:re,onMouseDown:T=>{a||(T.preventDefault(),O.current?.focus(),w?V():oe(t!==ye?t:r))},onBlur:()=>{w&&V()}}),Ke===null?null:rc.createPortal(Ke,document.body)]})};sl.displayName="VirtualDateDropdown";const ir=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Su=On("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),xu=On('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Mu=31,pn=(e,t,r)=>{if(!Me(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${y(t)})`);Xe("DateSelector",e,t,"day",0,r)},sr=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},Sn=e=>sr(e,1,1),gs=e=>sr(e,12,31),ll=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,hs=(e,t,r,n)=>ll(e,t,r)&&e.getDate()===n,Ba=e=>!Number.isNaN(Sn(e.getFullYear()).getTime()),Du=e=>Ba(e)?ir(e):new Date(Number.NaN),oo=(e,t,r)=>{if(!Ba(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}`)},ws=(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},Ru=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedDates:f,variant:x="date",className:v="",style:L,disabled:Y=!1,locale:w,labels:b,formatLocale:c,formatOption:g}=e;c!==void 0&&Co("DateSelector","formatLocale",c);const d=x==="split-dropdown"?xu:Su;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),x==="split-dropdown"&&(t!==void 0&&oo("value",t,""),r!==void 0&&oo("initialDate",r,""),m!==void 0&&oo("minDate",m,d),h!==void 0&&oo("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(Sn(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(gs(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${y(u)})`);if(x==="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');en("DateSelector","allowedDates",f);const ae=t??r;if(ae===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&&za("DateSelector",o,t!==void 0);const I=Po(w,b),Z=t!==void 0,[te,we]=Wa(ae,Z,ir,ir),O=t?.getTime(),Q=s.useMemo(()=>t!==void 0?ir(t):te,[O,te]);if(x==="split-dropdown"&&!Z&&!Ba(Q))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${y(Q)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const se=m?.getTime(),E=h?.getTime(),M=s.useMemo(()=>{const C=m?ir(m):null,G=i!==void 0?Sn(i):null;return C===null?G:G===null||C.getTime()>=G.getTime()?C:G},[se,i]),D=s.useMemo(()=>{const C=h?ir(h):null,G=u!==void 0?gs(u):null;return C===null?G:G===null||C.getTime()<=G.getTime()?C:G},[E,u]),H=M?.getTime()??null,W=D?.getTime()??null;if(M!==null&&D!==null&&M.getTime()>D.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${wn(M)}, upper: ${wn(D)})`);if(x!=="date"&&f===void 0&&(M===null||D===null))throw new RangeError(`DateSelector: variant=${y(x)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${x==="dropdown"?", or allowedDates":""}; the option list is never invented`);const F=s.useMemo(()=>f===void 0?null:f.map(C=>xt(C,G=>G.getTime())).join(","),[f]),k=s.useMemo(()=>{if(f===void 0)return null;const C=ru(f,(G,We)=>pn(`allowedDates[${G}]`,We,""));return{ascending:C,ascendingSerials:C.map(St)}},[F]),V=s.useMemo(()=>k===null?null:{...k,...tu(k.ascending,M,D)},[k,H,W]),oe=s.useMemo(()=>V!==null?Jc(V.ascending,V.ascendingSerials,V.loIndex,V.hiIndex,c,g):M===null||D===null?eu:Qc(M,D,c,g),[V,H,W,c,g]),ge=s.useMemo(()=>V!==null?{kind:"candidates",ascending:V.ascendingSerials,loIndex:V.loIndex,hiIndex:V.hiIndex}:{kind:"range",min:M===null?null:St(M),max:D===null?null:St(D)},[V,H,W]),q=C=>!Number.isNaN(C.getTime())&&En(ge,St(C)),X=C=>{if(Y)return;const G=ir(C);q(G)&&(Z||we(G),n?.(G))},re=Q.getTime(),Re=q(Q),ie=s.useMemo(()=>{const C=Zt(ge,St(Q),-1);if(C===null)return null;const G=$n(C);return Number.isNaN(G.getTime())?null:G},[ge,re]),fe=s.useMemo(()=>{const C=Zt(ge,St(Q),1);if(C===null)return null;const G=$n(C);return Number.isNaN(G.getTime())?null:G},[ge,re]),Te=()=>{if(o!==void 0){o.onStep("previous");return}ie!==null&&X(ie)},Ke=()=>{if(o!==void 0){o.onStep("next");return}fe!==null&&X(fe)},T=C=>{if(C.target.value){const G=tc.parseISO(C.target.value);Number.isNaN(G.getTime())||X(G)}},ne=Q.getFullYear(),ue=Q.getMonth()+1,De=Q.getDate(),_e=s.useCallback((C,G)=>g?g(G,C,"part"):nl(G,C,"part",c),[g,c]),Ce=s.useMemo(()=>{if(x!=="split-dropdown"||M===null||D===null)return[];const C=[];for(let G=D.getFullYear();G>=M.getFullYear();G--)C.push({value:G,label:_e("year",Sn(G))});return C},[x,H,W,_e]),Ge=s.useMemo(()=>{if(x!=="split-dropdown"||M===null||D===null)return[];const C=M,G=D,We=ne===C.getFullYear()?C.getMonth()+1:1,be=ne===G.getFullYear()?G.getMonth()+1:12;return ws(We,be,he=>sr(ne,he,1),(he,Rt)=>ll(he,ne,Rt),he=>_e("month",he))},[x,H,W,ne,_e]),Ne=s.useMemo(()=>{if(x!=="split-dropdown"||M===null||D===null)return[];const C=M,G=D,We=ne===C.getFullYear()&&ue===C.getMonth()+1?C.getDate():1,be=ne===G.getFullYear()&&ue===G.getMonth()+1?G.getDate():Mu;return ws(We,be,he=>sr(ne,ue,he),(he,Rt)=>hs(he,ne,ue,Rt),he=>_e("day",he))},[x,H,W,ne,ue,_e]),lt=(C,G,We)=>{const be=sr(C,G,We);return hs(be,C,G,We)&&q(be)},J=(C,G,We)=>{lt(C,G,We)&&X(sr(C,G,We))},nt=Ce.some(C=>C.value===ne),ft=Ge.some(C=>C.value===ue),Ze=Ne.some(C=>C.value===De),Ee=wn(Q),ze=x==="dropdown"?st("day",Q,g,c):"",He=M?wn(M):void 0,ht=D?wn(D):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":x,"data-out-of-range":Re?void 0:"true",children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:Y,canStep:o===void 0?ie!==null:o.canStepPrevious,onStep:Te,ariaLabel:I.previousDay}),x==="dropdown"?$.jsx(sl,{domain:oe,selectedIndex:Re?oe.indexOf(Q):ye,openAnchorIndex:oe.nearestIndexOf(Q),displayLabel:ze,machineValue:Ee,disabled:Y,ariaLabel:I.dateSelect,locale:w,labels:I,onCommitIndex:C=>X(oe.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"}):x==="split-dropdown"?$.jsxs("div",{className:"inline-flex items-center gap-1",children:[$.jsxs("select",{"aria-label":I.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?ne:"",onChange:C=>J(Number(C.target.value),ue,De),children:[nt?null:$.jsx("option",{value:"",disabled:!0,className:qe,children:_e("year",Sn(ne))}),Ce.map(C=>$.jsx("option",{value:C.value,disabled:!lt(C.value,ue,De),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":I.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?ue:"",onChange:C=>J(ne,Number(C.target.value),De),children:[ft?null:$.jsx("option",{value:"",disabled:!0,className:qe,children:_e("month",sr(ne,ue,1))}),Ge.map(C=>$.jsx("option",{value:C.value,disabled:!lt(ne,C.value,De),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":I.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?De:"",onChange:C=>J(ne,ue,Number(C.target.value)),children:[Ze?null:$.jsx("option",{value:"",disabled:!0,className:qe,children:_e("day",sr(ne,ue,De))}),Ne.map(C=>$.jsx("option",{value:C.value,disabled:!lt(ne,ue,C.value),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]})]}):$.jsx("input",{"aria-label":I.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(yr,{neighbour:"control",direction:"right",disabled:Y,canStep:o===void 0?fe!==null:o.canStepNext,onStep:Ke,ariaLabel:I.nextDay}),a]})},Eu=(e,t)=>!(!Ua(e,t,t.variant==="split-dropdown"?Du:ir)||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||!yo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),cl=s.memo(Ru,Eu);cl.displayName="DateSelector";function Wt(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 La(e){return Wt(e.getFullYear(),e.getMonth())}function Rr(e){return`${$o(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const bs=On("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function ao(e,t,r){e!==void 0&&ul(e,t,r)}function ul(e,t,r){if(!Me(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${y(e)})`);Xe("MonthSelector",t,e,"month",0,r)}function ps(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(Wt(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 yu(e,t){const r=e===void 0?null:Wt(e,0),n=t===void 0?null:Wt(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Pu(e,t){const r=e===void 0?null:Wt(e,11),n=t===void 0?null:Wt(t.getFullYear(),t.getMonth());return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function lr(e){return e.getFullYear()*12+e.getMonth()}function $a(e){return Wt(Math.floor(e/12),(e%12+12)%12)}function vs(e){return Number.isNaN(e.getTime())?null:e}function Lu(e,t,r){const n=new Map;for(const o of e){const a=Wt(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 $u(e,t){const r=[];for(let n=lr(e);n<=lr(t);n++)r.push($a(n));return r}function Ss(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:st("month",e[o],r,t),value:Rr(e[o])});return n}const Tu=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:u,maxYear:m,minDate:h,maxDate:f,allowedMonths:x,isWarning:v=!1,className:L="",style:Y,disabled:w=!1,locale:b,labels:c,formatLocale:g,formatOption:d}=e;if(g!==void 0&&Co("MonthSelector","formatLocale",g),ao(t,"value",""),ao(r,"initialDate",""),ao(h,"minDate",bs),ao(f,"maxDate",bs),ps(u,"minYear",0),ps(m,"maxYear",11),en("MonthSelector","allowedMonths",x),x!==void 0)for(let J=0;J<x.length;J++)ul(x[J],`allowedMonths[${J}]`,"");const ae=t??r;if(ae===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&&za("MonthSelector",o,t!==void 0);const I=Po(b,c),Z=t!==void 0,[te,we]=Wa(ae,Z,La,La),O=s.useMemo(()=>t!==void 0?Wt(t.getFullYear(),t.getMonth()):te,[t?.getTime(),te]),Q=h?.getTime(),se=f?.getTime(),E=s.useMemo(()=>yu(u,h),[u,Q]),M=s.useMemo(()=>Pu(m,f),[m,se]),D=E?.getTime()??null,H=M?.getTime()??null;if(E!==null&&M!==null&&E>M)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Rr(E)}, upper: ${Rr(M)})`);if(i==="dropdown"&&x===void 0&&(E===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 W=x===void 0?null:x.map(J=>J.getTime()).join(","),F=s.useMemo(()=>x===void 0?null:Lu(x,E,M),[W,D,H]),k=s.useMemo(()=>{if(F!==null){const J=F.map(lr);return{kind:"candidates",ascending:J,loIndex:0,hiIndex:J.length-1}}return{kind:"range",min:E===null?null:lr(E),max:M===null?null:lr(M)}},[F,D,H]),V=J=>!Number.isNaN(J.getTime())&&En(k,lr(J)),oe=J=>{if(w)return;if(!V(J))throw new RangeError(`MonthSelector: refusing to emit ${Rr(J)}, which lies outside the selectable months`);Z||we(J);const nt=J.getFullYear()*100+(J.getMonth()+1);n?.(J,nt)},ge=O.getTime(),q=V(O),X=s.useMemo(()=>{const J=Zt(k,lr(O),-1);return J===null?null:vs($a(J))},[k,ge]),re=s.useMemo(()=>{const J=Zt(k,lr(O),1);return J===null?null:vs($a(J))},[k,ge]),Re=()=>{if(o!==void 0){o.onStep("previous");return}X!==null&&oe(X)},ie=()=>{if(o!==void 0){o.onStep("next");return}re!==null&&oe(re)},fe=J=>{if(!J)return;const nt=J.lastIndexOf("-");if(nt<=0)return;const ft=J.slice(0,nt),Ze=J.slice(nt+1),Ee=Number(ft),ze=Number(Ze)-1;if(!(Number.isInteger(Ee)&&Number.isInteger(ze)))return;const He=Wt(Ee,ze);V(He)&&oe(He)},Te=J=>{fe(J.target.value)},Ke=J=>{fe(J.target.value)},T=Rr(O),ne=i==="dropdown"&&!q?st("month",O,d,g):"",ue=E?Rr(E):void 0,De=M?Rr(M):void 0,_e=s.useMemo(()=>i!=="dropdown"?[]:F!==null?Ss(F,g,d):E===null||M===null?[]:Ss($u(E,M),g,d),[i,F,D,H,g,d]),Ce=q?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",Ne=`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":q?void 0:"true",children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:w,canStep:o===void 0?X!==null:o.canStepPrevious,onStep:Re,ariaLabel:I.previousMonth}),i==="dropdown"?$.jsxs("select",{"aria-label":I.monthSelect,disabled:w,className:lt,value:Ce,onChange:Ke,children:[q?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:ne}),_e.map(J=>$.jsx("option",{value:J.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:J.label},J.value))]}):$.jsx("input",{"aria-label":I.monthSelect,disabled:w,className:Ne,value:T,min:ue,max:De,onChange:Te,type:"month"}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:w,canStep:o===void 0?re!==null:o.canStepNext,onStep:ie,ariaLabel:I.nextMonth}),a]})},Cu=(e,t)=>!(!Ua(e,t,La)||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||!yo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),dl=s.memo(Tu,Cu);dl.displayName="MonthSelector";function Ve(e,t,r){return e<t?t:e>r?r:e}const Iu=tn([],null,null);function Tn(e,t,r,n){return r===null?Iu:Ta(r,N(t,e[0],n),N(t,e[1],n))}function Er(e,t,r,n,o){const a=N(t,e,o),i=Ca(n)?null:yn(n,a);return i===null?a<N(t,r[0],o)?r[0]:a>N(t,r[1],o)?r[1]:e:i===a?e:ee(t,i,o)}function Kr(e,t,r,n,o,a){const i=N(t,e[0],o),u=N(t,e[1],o),m=mo(a,{kind:"range",min:N(t,r[0],o),max:N(t,r[1],o)},i,u);if(m===null)return e;const h=Er(m[0]===i?e[0]:ee(t,m[0],o),t,r,n,o),f=Er(m[1]===u?e[1]:ee(t,m[1],o),t,r,n,o);return[h,f<h?h:f]}const xs=(e,t,r,n,o,a,i)=>{if(en(e,t,r),r===void 0||r.length===0)return null;const u=tn(al(e,t,r,n,i),N(n,o,i),N(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},Ta=(e,t,r)=>{const n=tn(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},Ca=e=>e.hiIndex<e.loIndex,ku=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Zt(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}}),qr=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),Ms=(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=qt(e,`${t}[0]`,r[0],n,o),i=qt(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]},cr=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)})`);$e(t,"macroUnit",o),$e(t,"microUnit",a);const f=gr(t,e.yearStartMonth);for(const[E,M]of[["minDate",i],["maxDate",u]])if(!Me(M))throw new RangeError(`${t}: ${E} 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)})`);qt(t,"minDate",i,o,f),qt(t,"minDate",i,a,f),Pr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const x=Ms(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=Ms(t,"microSelection",h,a,f),L=xs(t,"macroAllowedDates",e.macroAllowedDates,o,i,u,f),Y=xs(t,"microAllowedDates",e.microAllowedDates,a,i,u,f),w=[m[0],m[1]],b=[h[0],h[1]],c=E=>{const M=Dt(o,a,[E[0],E[1]],i,u,f);return[N(a,M[0],f),N(a,M[1],f)]},g=(E,M)=>{if(Y!==null){const D=Ta(Y,E,M);if(!Ca(D))return D}return{kind:"range",min:E,max:M}},d=(E,M)=>{const D=qr(E,w)?w:E;return D===w&&qr(M,b)?null:{macroRange:D,microSelection:M}};if(e.row==="macro"){const E=L??{kind:"range",min:N(o,i,f),max:N(o,u,f)},M=co(E),D=(W,F)=>{const k=Dt(o,a,W,i,u,f);return Kr(b,a,k,Tn(k,a,Y,f),f,F)},H=(W,F)=>{const k=Sa(M,x[0],x[1],W,Ra(F,n));if(k===null)return null;const V=Ea(k,x,w,o,f,F.motion==="single");if(V===null)return null;const oe=[Ve(V[0],i,u),Ve(V[1],i,u)],ge=Math.sign(k[0]-x[0])===W&&Math.sign(k[1]-x[1])===W;return d(oe,D(oe,ge?"pan":"resize"))};return{previous:H(-1,e.rules.previous),next:H(1,e.rules.next)}}const ae=c(w);let I=[N(a,i,f),N(a,u,f)];if(L!==null){const E=c([ee(o,L.ascending[L.loIndex],f),ee(o,L.ascending[L.hiIndex],f)]);I=[Math.min(E[0],ae[0]),Math.max(E[1],ae[1])]}const Z=Y===null?null:Ta(Y,I[0],I[1]);let te=co({kind:"range",min:I[0],max:I[1]});if(Z!==null&&!Ca(Z)){const E=g(ae[0],ae[1]);te=E.kind==="candidates"?co(Z):ku([Z,E])}const we=E=>{if(L===null)return[Ve(pt(o,E[0],f),i,u),Ve(pt(o,E[1],f),i,u)];const M=lo(L,N(o,E[0],f),-1),D=lo(L,N(o,E[1],f),1);return M===null||D===null?null:[Ve(ee(o,M,f),i,u),Ve(ee(o,D,f),i,u)]},O=(E,M,D)=>{const[H,W]=c(E),F=g(H,W),k=ge=>{const q=N(a,ge,f);if(En(F,q))return ge;const X=lo(F,q,D);return X===null?null:ee(a,X,f)},V=k(M[0]),oe=k(M[1]);return V===null||oe===null?null:[V,oe.getTime()<V.getTime()?V:oe]},Q=(E,M)=>E>=ae[0]&&M<=ae[1],se=(E,M)=>{const D=Sa(te,v[0],v[1],E,Ra(M,n));if(D===null)return null;const H=Ea(D,v,b,a,f,M.motion==="single");if(H===null)return null;const W=M.window!=="follow",F=W&&Q(D[0],D[1])?w:we(H);if(F===null)return null;const k=O(F,H,E);if(k===null)return null;const V=W&&Q(N(a,k[0],f),N(a,k[1],f))?w:we(k);return V===null?null:d(V,k)};return{previous:se(-1,e.rules.previous),next:se(1,e.rules.next)}};function Ia(e,t,r){if(!Me(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${y(r)})`)}function Pe(e,t,r,n,o){Ia(e,t,r),Xe(e,t,r,n,o,"")}function Io(e,t,r,n,o){if(Ia(e,"minDate",t),Ia(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,Vs)}function ur(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(Pe(e,`${t}[0]`,r[0],n,o),Pe(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 po(e,t,r,n,o,a,i,u){const m=N(r,n,u);if(m<N(r,o,u)||m>N(r,a,u))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${y(n)}, lower: ${y(o)}, upper: ${y(a)})`)}function vo(e,t,r,n,o,a,i,u){po(e,`${t}[0]`,r,n[0],o,a,i,u),po(e,`${t}[1]`,r,n[1],o,a,i,u)}function So(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 Xr(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=_s(e,t,r);return Me(i)&&Ns(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function xo(e,t,r,n,o){const a=xe(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function Mn(e,t,r,n,o,a){const i=Ve(e,r,n);if(o.length===0)return i;const u=o[xe(o,i,t,a)];return N(t,u,a)===N(t,i,a)?i:Ve(u,r,n)}function pa(e,t,r,n,o,a){const i=Mn(e[0],t,r,n,o,a),u=Mn(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 Au={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function zt(e,t){return t.length===0?{}:{[Au[e]]:t}}function ko(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 Xt={previous:null,next:null},Ou=["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=>Ou.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const ml=(e,t)=>e.getTime()===t.getTime();function Zr(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 Qr(e,t,r){e.current=t,e.hand(t),r(t)}function Jr(e,t,r,n){if(r===t||e.current!==r)return;e.forgetHanded();let o=!0;n(a=>o||a===t?r:a),o=!1}function Vu(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:u,selectorStep:m,...h}=e;$e("usePeriodSliderRange","unit",t);const f=gr("usePeriodSliderRange",i);Io("usePeriodSliderRange",r,n,[t],f),ur("usePeriodSliderRange","initialRange",o,t,f),m!==void 0&&Pr("usePeriodSliderRange","selectorStep",m,"motion");const x=ko(h),v=r.getTime(),L=n.getTime(),Y=s.useMemo(()=>mr("usePeriodSliderRange",To(x.allowedDates),t,r,n,f).dates,[x.allowedDates,t,v,L,f]),w=s.useRef(o),[b,c]=s.useState(()=>(vo("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",f),Cn(o,pa(o,t,r,n,Y,f))));ur("usePeriodSliderRange","range",b,t,f);const g=Cn(b,pa(b,t,r,n,Y,f)),d=Ue(g);d.forgetHandedUnless(b),s.useLayoutEffect(()=>{Jr(d,b,g,c)});const ae=s.useRef(o),I=Ue({minDate:r,maxDate:n,candidates:Y}),Z=Ue(a),te=s.useCallback(q=>{const{minDate:X,maxDate:re,candidates:Re}=I.current,ie=pa(q,t,X,re,Re,f);Zr(d,ie,qr,c);const fe=ae.current;ie[0].getTime()===fe[0].getTime()&&ie[1].getTime()===fe[1].getTime()||(ae.current=ie,Z.current?.(ie[0],ie[1]))},[t,f]),we=s.useCallback(q=>{const X=typeof q=="function"?q(d.current):q;ae.current=X,Qr(d,X,c)},[]),O=s.useCallback(q=>{Pe("usePeriodSliderRange","setLowerDate(date)",q,t,f);const X=d.current,re=q.getTime()>X[1].getTime()?q:X[1];te([q,re])},[te,t,f]),Q=s.useCallback(q=>{Pe("usePeriodSliderRange","setUpperDate(date)",q,t,f);const X=d.current,re=q.getTime()<X[0].getTime()?q:X[0];te([re,q])},[te,t,f]),se=s.useCallback((q,X)=>{Pe("usePeriodSliderRange","sliderProps.onChangeRange(lower)",q,t,f),Pe("usePeriodSliderRange","sliderProps.onChangeRange(upper)",X,t,f),So("usePeriodSliderRange","sliderProps.onChangeRange",q,X),te([q,X])},[te,t,f]),E=s.useCallback(q=>{Xr("usePeriodSliderRange","shiftRange",q);const{minDate:X,maxDate:re,candidates:Re}=I.current,ie=d.current;if(Re.length>0){te([xo(Re,t,ie[0],q,f),xo(Re,t,ie[1],q,f)]);return}te([Ut(t,ie[0],q,X,re,f).date,Ut(t,ie[1],q,X,re,f).date])},[t,te,f]),M=s.useCallback(()=>{te(w.current)},[te]),D=In(m),H=D!==void 0,W=s.useMemo(()=>{if(D===void 0)return{start:Xt,end:Xt};const q=Y.length>0?x.allowedDates:void 0,X={selection:g,unit:t,yearStartMonth:f,minDate:r,maxDate:n,allowedDates:q,rules:D};return{start:ya({...X,shows:"start"}),end:ya({...X,shows:"end"})}},[D,g,t,f,v,L,Y,x.allowedDates]),F=jt(W.start,te),k=jt(W.end,te),V=s.useMemo(()=>({value:g[0],onChange:O,minDate:r,maxDate:g[1],unit:t,yearStartMonth:f,...zt(t,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...H?{stepper:F}:{}}),[g[0],g[1],O,r,t,f,Y,e.formatLocale,e.locale,e.labels,u,H,F]),oe=s.useMemo(()=>({value:g[1],onChange:Q,minDate:g[0],maxDate:n,unit:t,yearStartMonth:f,...zt(t,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...H?{stepper:k}:{}}),[g[0],g[1],Q,n,t,f,Y,e.formatLocale,e.locale,e.labels,u,H,k]),ge=s.useMemo(()=>({...x,mode:"range",unit:t,yearStartMonth:f,range:g,minDate:r,maxDate:n,onChangeRange:se}),[x,t,g,r,n,se,f]);return{range:g,lowerDate:g[0],upperDate:g[1],setRange:we,setLowerDate:O,setUpperDate:Q,shiftRange:E,resetRange:M,startSelectorProps:V,endSelectorProps:oe,sliderProps:ge}}function Nu(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:u,...m}=e;$e("usePeriodSliderPoint","unit",t);const h=gr("usePeriodSliderPoint",i);Io("usePeriodSliderPoint",r,n,[t],h),Pe("usePeriodSliderPoint","initialValue",o,t,h);const f=ko(m),x=r.getTime(),v=n.getTime(),L=s.useMemo(()=>mr("usePeriodSliderPoint",To(f.allowedDates),t,r,n,h).dates,[f.allowedDates,t,x,v,h]),Y=s.useRef(o),[w,b]=s.useState(()=>(po("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",h),Mn(o,t,r,n,L,h)));Pe("usePeriodSliderPoint","value",w,t,h);const c=Mn(w,t,r,n,L,h),g=Ue(c);g.forgetHandedUnless(w),s.useLayoutEffect(()=>{Jr(g,w,c,b)});const d=s.useRef(o),ae=Ue({minDate:r,maxDate:n,candidates:L}),I=Ue(a),Z=s.useCallback(D=>{const{minDate:H,maxDate:W,candidates:F}=ae.current,k=Mn(D,t,H,W,F,h);Zr(g,k,ml,b),k.getTime()!==d.current.getTime()&&(d.current=k,I.current?.(k))},[t,h]),te=s.useCallback(D=>{const H=typeof D=="function"?D(g.current):D;d.current=H,Qr(g,H,b)},[]),we=s.useCallback(D=>{Pe("usePeriodSliderPoint","selectorProps.onChange(date)",D,t,h),Z(D)},[Z,t,h]),O=s.useCallback(D=>{Pe("usePeriodSliderPoint","sliderProps.onChangePoint(value)",D,t,h),Z(D)},[Z,t,h]),Q=s.useCallback(D=>{Xr("usePeriodSliderPoint","shiftValue",D);const{minDate:H,maxDate:W,candidates:F}=ae.current;if(F.length>0){Z(xo(F,t,g.current,D,h));return}Z(Ut(t,g.current,D,H,W,h).date)},[t,Z,h]),se=s.useCallback(()=>{Z(Y.current)},[Z]),E=s.useMemo(()=>({value:c,onChange:we,minDate:r,maxDate:n,unit:t,yearStartMonth:h,...zt(t,L),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u}),[c,we,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:O}),[f,t,c,r,n,O,h]);return{value:c,setValue:te,shiftValue:Q,resetValue:se,selectorProps:E,sliderProps:M}}function _u(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroRange:h,yearStartMonth:f,formatOption:x,macroSelectorStep:v,microSelectorStep:L,...Y}=e;$e("useVernierSliderRange","unit",t);const w=Qt("useVernierSliderRange","macroUnit",i,t),b=Qt("useVernierSliderRange","microUnit",u,t),c=gr("useVernierSliderRange",f);Io("useVernierSliderRange",r,n,[w,b,t],c),ur("useVernierSliderRange","initialMacroRange",o,w,c),ur("useVernierSliderRange","initialMicroRange",a,b,c),v!==void 0&&Pr("useVernierSliderRange","macroSelectorStep",v,"motion"),L!==void 0&&Pr("useVernierSliderRange","microSelectorStep",L,"vernierRange");const g=ko(Y),d=s.useRef(o),ae=s.useRef(a),[I,Z]=s.useState(()=>(vo("useVernierSliderRange","initialMacroRange",w,o,r,n,"[minDate, maxDate]",c),o)),[te,we]=s.useState(()=>{const P=Dt(w,b,o,r,n,c);return vo("useVernierSliderRange","initialMicroRange",b,a,P[0],P[1],"the initial macro window",c),a});ur("useVernierSliderRange","macroRange",I,w,c);const O=Cn(I,[Ve(I[0],r,n),Ve(I[1],r,n)]),Q=r.getTime(),se=n.getTime(),E=s.useMemo(()=>Dt(w,b,O,r,n,c),[w,b,O,Q,se,c]),M=s.useMemo(()=>Ht("micro",g)?_a("useVernierSliderRange",Mt("micro",g),b,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,b,Q,se,c]),D=s.useMemo(()=>Ht("macro",g)?mr("useVernierSliderRange",Mt("macro",g),w,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,w,Q,se,c]),H=Ue(D),W=s.useMemo(()=>Tn(E,b,M,c),[E,b,M,c]),F=s.useMemo(()=>Ln(M,W),[M,W]);ur("useVernierSliderRange","microRange",te,b,c);const k=Cn(te,Kr(te,b,E,W,c,"resize")),V=Ue(O),oe=Ue(k);V.forgetHandedUnless(I),oe.forgetHandedUnless(te),s.useLayoutEffect(()=>{Jr(V,I,O,Z),Jr(oe,te,k,we)});const ge=s.useRef(a),q=s.useRef(o),X=Ue({minDate:r,maxDate:n}),re=Ue(m),Re=Ue(h),ie=s.useCallback(P=>{const{minDate:j,maxDate:de}=X.current;return Dt(w,b,P,j,de,c)},[w,b,c]),fe=s.useCallback(P=>Tn(P,b,M,c),[b,M,c]),Te=s.useCallback(P=>{Zr(V,P,qr,Z);const j=q.current;P[0].getTime()===j[0].getTime()&&P[1].getTime()===j[1].getTime()||(q.current=P,re.current?.(P[0],P[1]))},[]),Ke=s.useCallback(P=>{const j=typeof P=="function"?P(V.current):P;q.current=j,Qr(V,j,Z)},[]),T=s.useCallback((P,j)=>{Te(P),Zr(oe,j,qr,we);const de=ge.current;(j[0].getTime()!==de[0].getTime()||j[1].getTime()!==de[1].getTime())&&(ge.current=j,Re.current?.(j[0],j[1]))},[Te]),ne=s.useCallback(P=>{const j=typeof P=="function"?P(oe.current):P;ge.current=j,Qr(oe,j,we)},[]),ue=s.useCallback((P,j,de)=>{const{minDate:Ie,maxDate:Le}=X.current,ot=[Ve(P,Ie,Le),Ve(j,Ie,Le)],Qe=ie(ot);T(ot,Kr(oe.current,b,Qe,fe(Qe),c,de))},[b,ie,fe,T,c]),De=s.useCallback((P,j)=>ue(P,j,"resize"),[ue]),_e=s.useCallback((P,j)=>{Pe("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",P,w,c),Pe("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",j,w,c),So("useVernierSliderRange","sliderProps.onChangeMacroRange",P,j);const{minDate:de,maxDate:Ie}=X.current,Le=[Ve(P,de,Ie),Ve(j,de,Ie)],ot=oe.current,Qe=ie(Le),ke=Kr(ot,b,Qe,fe(Qe),c,"resize");if(ke[0].getTime()!==ot[0].getTime()||ke[1].getTime()!==ot[1].getTime()){Te(Le);return}T(Le,ot)},[w,b,ie,fe,Te,T,c]),Ce=s.useCallback((P,j)=>{const de=ie(V.current);T(V.current,Kr([P,j],b,de,fe(de),c,"resize"))},[b,ie,fe,T,c]),Ge=s.useCallback((P,j)=>{Pe("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",P,b,c),Pe("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",j,b,c),So("useVernierSliderRange","sliderProps.onChangeMicroRange",P,j),Ce(P,j)},[Ce,b,c]),Ne=s.useCallback(P=>{Pe("useVernierSliderRange","setMacroLowerDate(date)",P,w,c);const j=V.current[1],de=P>j?P:j;De(P,de)},[De,w,c]),lt=s.useCallback(P=>{Pe("useVernierSliderRange","setMacroUpperDate(date)",P,w,c);const j=V.current[0],de=P<j?P:j;De(de,P)},[De,w,c]),J=s.useCallback(P=>{Pe("useVernierSliderRange","setMicroLowerDate(date)",P,b,c);const j=oe.current[1],de=P>j?P:j;Ce(P,de)},[Ce,b,c]),nt=s.useCallback(P=>{Pe("useVernierSliderRange","setMicroUpperDate(date)",P,b,c);const j=oe.current[0],de=P<j?P:j;Ce(de,P)},[Ce,b,c]),ft=s.useCallback(P=>{Xr("useVernierSliderRange","shiftMacroRange",P);const{minDate:j,maxDate:de}=X.current,Ie=V.current,Le=H.current;if(Le.length>0){const ke=xe(Le,Ie[0],w,c)+P,Et=xe(Le,Ie[1],w,c)+P;if(ke<0||Et>Le.length-1)return;ue(Le[ke],Le[Et],"pan");return}const ot=Ut(w,Ie[0],P,j,de,c),Qe=Ut(w,Ie[1],P,j,de,c);ot.pastDateRange||Qe.pastDateRange||ot.date<j||Qe.date>de||ue(ot.date,Qe.date,"pan")},[w,ue,c]),Ze=s.useCallback(P=>{Xr("useVernierSliderRange","shiftMicroRange",P);const j=V.current,de=oe.current,Ie=ie(j),[Le,ot]=Ie,Qe=Ln(M,fe(Ie));if(Qe.length>0){const yt=xe(Qe,de[0],b,c)+P,Lr=xe(Qe,de[1],b,c)+P;if(yt<0||Lr>Qe.length-1)return;Ce(Qe[yt],Qe[Lr]);return}const ke=Ut(b,de[0],P,Le,ot,c),Et=Ut(b,de[1],P,Le,ot,c);ke.pastDateRange||Et.pastDateRange||N(b,ke.date,c)<N(b,Le,c)||N(b,Et.date,c)>N(b,ot,c)||Ce(ke.date,Et.date)},[b,M,ie,fe,Ce,c]),Ee=s.useCallback(()=>{const{minDate:P,maxDate:j}=X.current,de=[Ve(d.current[0],P,j),Ve(d.current[1],P,j)],Ie=ie(de);T(de,Kr(ae.current,b,Ie,fe(Ie),c,"resize"))},[b,ie,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:O,microSelection:k,macroAllowedDates:Ht("macro",g)?Mt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Mt("micro",g).list:void 0};return{macroStart:ze===void 0?Xt:cr({...P,row:"macro",shows:"start",rules:ze}),macroEnd:ze===void 0?Xt:cr({...P,row:"macro",shows:"end",rules:ze}),microStart:He===void 0?Xt:cr({...P,row:"micro",shows:"start",rules:He}),microEnd:He===void 0?Xt:cr({...P,row:"micro",shows:"end",rules:He})}},[ze,He,w,b,c,Q,se,O,k,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),C=s.useCallback(P=>T(P.macroRange,P.microSelection),[T]),G=jt(dt.macroStart,C),We=jt(dt.macroEnd,C),be=jt(dt.microStart,C),he=jt(dt.microEnd,C),[Rt,It]=E,z=s.useMemo(()=>({value:O[0],onChange:Ne,minDate:r,maxDate:O[1],unit:w,yearStartMonth:c,...zt(w,D),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ht?{stepper:G}:{}}),[O,Ne,r,w,c,D,e.formatLocale,e.locale,e.labels,x,ht,G]),_=s.useMemo(()=>({value:O[1],onChange:lt,minDate:O[0],maxDate:n,unit:w,yearStartMonth:c,...zt(w,D),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ht?{stepper:We}:{}}),[O,lt,n,w,c,D,e.formatLocale,e.locale,e.labels,x,ht,We]),le=s.useMemo(()=>({value:k[0],onChange:J,minDate:Rt,maxDate:k[1],unit:b,yearStartMonth:c,...zt(b,F),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...qe?{stepper:be}:{}}),[k,J,Rt,b,c,F,e.formatLocale,e.locale,e.labels,x,qe,be]),Se=s.useMemo(()=>({value:k[1],onChange:nt,minDate:k[0],maxDate:It,unit:b,yearStartMonth:c,...zt(b,F),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...qe?{stepper:he}:{}}),[k,nt,It,b,c,F,e.formatLocale,e.locale,e.labels,x,qe,he]),Ye=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:w,microUnit:b,minDate:r,maxDate:n,macroRange:O,microRange:k,onChangeMacroRange:_e,onChangeMicroRange:Ge}),[g,t,w,b,r,n,O,k,_e,Ge,c]);return{macroRange:O,setMacroRange:Ke,microRange:k,setMicroRange:ne,setMacroLowerDate:Ne,setMacroUpperDate:lt,setMicroLowerDate:J,setMicroUpperDate:nt,shiftMacroRange:ft,shiftMicroRange:Ze,resetVernier:Ee,macroStartSelectorProps:z,macroEndSelectorProps:_,microStartSelectorProps:le,microEndSelectorProps:Se,sliderProps:Ye}}function Yu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroPoint:h,yearStartMonth:f,formatOption:x,macroSelectorStep:v,microSelectorStep:L,...Y}=e;$e("useVernierSliderPoint","unit",t);const w=Qt("useVernierSliderPoint","macroUnit",i,t),b=Qt("useVernierSliderPoint","microUnit",u,t),c=gr("useVernierSliderPoint",f);Io("useVernierSliderPoint",r,n,[w,b,t],c),ur("useVernierSliderPoint","initialMacroRange",o,w,c),Pe("useVernierSliderPoint","initialMicroValue",a,b,c),v!==void 0&&Pr("useVernierSliderPoint","macroSelectorStep",v,"motion"),L!==void 0&&Pr("useVernierSliderPoint","microSelectorStep",L,"vernierPoint");const g=ko(Y),d=s.useRef(o),ae=s.useRef(a),[I,Z]=s.useState(()=>(vo("useVernierSliderPoint","initialMacroRange",w,o,r,n,"[minDate, maxDate]",c),o)),[te,we]=s.useState(()=>{const _=Dt(w,b,o,r,n,c);return po("useVernierSliderPoint","initialMicroValue",b,a,_[0],_[1],"the initial macro window",c),a});ur("useVernierSliderPoint","macroRange",I,w,c);const O=Cn(I,[Ve(I[0],r,n),Ve(I[1],r,n)]),Q=r.getTime(),se=n.getTime(),E=s.useMemo(()=>Dt(w,b,O,r,n,c),[w,b,O,Q,se,c]),M=s.useMemo(()=>Ht("micro",g)?_a("useVernierSliderPoint",Mt("micro",g),b,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,b,Q,se,c]),D=s.useMemo(()=>Ht("macro",g)?mr("useVernierSliderPoint",Mt("macro",g),w,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,w,Q,se,c]),H=Ue(D),W=s.useMemo(()=>Tn(E,b,M,c),[E,b,M,c]),F=s.useMemo(()=>Ln(M,W),[M,W]);Pe("useVernierSliderPoint","microValue",te,b,c);const k=Er(te,b,E,W,c),V=Ue(O),oe=Ue(k);V.forgetHandedUnless(I),oe.forgetHandedUnless(te),s.useLayoutEffect(()=>{Jr(V,I,O,Z),Jr(oe,te,k,we)});const ge=s.useRef(a),q=s.useRef(o),X=Ue({minDate:r,maxDate:n}),re=Ue(m),Re=Ue(h),ie=s.useCallback(_=>{const{minDate:le,maxDate:Se}=X.current;return Dt(w,b,_,le,Se,c)},[w,b,c]),fe=s.useCallback(_=>Tn(_,b,M,c),[b,M,c]),Te=s.useCallback(_=>{Zr(V,_,qr,Z);const le=q.current;_[0].getTime()===le[0].getTime()&&_[1].getTime()===le[1].getTime()||(q.current=_,re.current?.(_[0],_[1]))},[]),Ke=s.useCallback(_=>{const le=typeof _=="function"?_(V.current):_;q.current=le,Qr(V,le,Z)},[]),T=s.useCallback((_,le)=>{Te(_),Zr(oe,le,ml,we),le.getTime()!==ge.current.getTime()&&(ge.current=le,Re.current?.(le))},[Te]),ne=s.useCallback(_=>{const le=typeof _=="function"?_(oe.current):_;ge.current=le,Qr(oe,le,we)},[]),ue=s.useCallback((_,le)=>{const{minDate:Se,maxDate:Ye}=X.current,P=[Ve(_,Se,Ye),Ve(le,Se,Ye)],j=ie(P);T(P,Er(oe.current,b,j,fe(j),c))},[b,ie,fe,T,c]),De=s.useCallback(_=>{const le=ie(V.current);T(V.current,Er(_,b,le,fe(le),c))},[b,ie,fe,T,c]),_e=s.useCallback((_,le)=>{Pe("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",_,w,c),Pe("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",le,w,c),So("useVernierSliderPoint","sliderProps.onChangeMacroRange",_,le);const{minDate:Se,maxDate:Ye}=X.current,P=[Ve(_,Se,Ye),Ve(le,Se,Ye)],j=oe.current,de=ie(P);if(Er(j,b,de,fe(de),c).getTime()!==j.getTime()){Te(P);return}T(P,j)},[w,b,ie,fe,Te,T,c]),Ce=s.useCallback(_=>{Pe("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",_,b,c),De(_)},[De,b,c]),Ge=s.useCallback(_=>{Pe("useVernierSliderPoint","setMacroLowerDate(date)",_,w,c);const le=V.current[1],Se=_>le?_:le;ue(_,Se)},[ue,w,c]),Ne=s.useCallback(_=>{Pe("useVernierSliderPoint","setMacroUpperDate(date)",_,w,c);const le=V.current[0],Se=_<le?_:le;ue(Se,_)},[ue,w,c]),lt=s.useCallback(_=>{Pe("useVernierSliderPoint","setMicroDate(date)",_,b,c),De(_)},[De,b,c]),J=s.useCallback(_=>{Xr("useVernierSliderPoint","shiftMacroRange",_);const{minDate:le,maxDate:Se}=X.current,Ye=V.current,P=H.current;if(P.length>0){const Ie=xe(P,Ye[0],w,c)+_,Le=xe(P,Ye[1],w,c)+_;if(Ie<0||Le>P.length-1)return;ue(P[Ie],P[Le]);return}const j=Ut(w,Ye[0],_,le,Se,c),de=Ut(w,Ye[1],_,le,Se,c);j.pastDateRange||de.pastDateRange||j.date<le||de.date>Se||ue(j.date,de.date)},[w,ue,c]),nt=s.useCallback(_=>{Xr("useVernierSliderPoint","shiftMicroValue",_);const le=V.current,Se=ie(le),Ye=Ln(M,fe(Se));if(Ye.length>0){De(xo(Ye,b,oe.current,_,c));return}De(Ut(b,oe.current,_,Se[0],Se[1],c).date)},[b,M,ie,fe,De,c]),ft=s.useCallback(()=>{const{minDate:_,maxDate:le}=X.current,Se=[Ve(d.current[0],_,le),Ve(d.current[1],_,le)],Ye=ie(Se);T(Se,Er(ae.current,b,Ye,fe(Ye),c))},[b,ie,fe,T,c]),Ze=In(v),Ee=In(L),ze=Ze!==void 0,He=Ee!==void 0,ht=s.useMemo(()=>{const _={macroUnit:w,microUnit:b,yearStartMonth:c,minDate:r,maxDate:n,macroRange:O,microSelection:[k,k],macroAllowedDates:Ht("macro",g)?Mt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Mt("micro",g).list:void 0};return{macroStart:Ze===void 0?Xt:cr({..._,row:"macro",shows:"start",rules:Ze}),macroEnd:Ze===void 0?Xt:cr({..._,row:"macro",shows:"end",rules:Ze}),micro:Ee===void 0?Xt:cr({..._,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:Ee.previous.window},next:{motion:"shift",window:Ee.next.window}}})}},[Ze,Ee,w,b,c,Q,se,O,k,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),qe=s.useCallback(_=>T(_.macroRange,_.microSelection[0]),[T]),dt=jt(ht.macroStart,qe),C=jt(ht.macroEnd,qe),G=jt(ht.micro,qe),[We,be]=E,he=s.useMemo(()=>({value:O[0],onChange:Ge,minDate:r,maxDate:O[1],unit:w,yearStartMonth:c,...zt(w,D),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ze?{stepper:dt}:{}}),[O,Ge,r,w,c,D,e.formatLocale,e.locale,e.labels,x,ze,dt]),Rt=s.useMemo(()=>({value:O[1],onChange:Ne,minDate:O[0],maxDate:n,unit:w,yearStartMonth:c,...zt(w,D),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ze?{stepper:C}:{}}),[O,Ne,n,w,c,D,e.formatLocale,e.locale,e.labels,x,ze,C]),It=s.useMemo(()=>({value:k,onChange:lt,minDate:We,maxDate:be,unit:b,yearStartMonth:c,...zt(b,F),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...He?{stepper:G}:{}}),[k,lt,We,be,b,c,F,e.formatLocale,e.locale,e.labels,x,He,G]),z=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:w,microUnit:b,minDate:r,maxDate:n,macroRange:O,microValue:k,onChangeMacroRange:_e,onChangeMicroPoint:Ce}),[g,t,w,b,r,n,O,k,_e,Ce,c]);return{macroRange:O,setMacroRange:Ke,microValue:k,setMicroValue:ne,setMacroLowerDate:Ge,setMacroUpperDate:Ne,setMicroDate:lt,shiftMacroRange:J,shiftMicroValue:nt,resetVernier:ft,macroStartSelectorProps:he,macroEndSelectorProps:Rt,microSelectorProps:It,sliderProps:z}}function Mo(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function kn(e,t){return e.getFullYear()-(e.getMonth()<t?1:0)}function fl(e,t){return Mo(kn(e,t),t)}function Ds(e){return e===void 0?0:As(e)?e:Number.NaN}const Rs=On("declare the years to offer with minYear / maxYear or allowedYears");function io(e,t,r,n){e!==void 0&&gl(e,t,r,n)}function gl(e,t,r,n){if(!Me(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${y(e)})`);Xe("YearSelector",t,e,"year",r,n)}function Es(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(Mo(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 ys(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:kn(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function Hu(e,t,r,n){const o=new Set;for(const a of e){const i=kn(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function ju(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:Hu(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function Uu(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const zu=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedYears:f,className:x="",style:v,disabled:L=!1,locale:Y,labels:w,formatLocale:b,formatOption:c,yearStartMonth:g}=e,d=gr("YearSelector",g);if(io(t,"value",d,""),io(r,"initialDate",d,""),io(m,"minDate",d,Rs),io(h,"maxDate",d,Rs),Es(i,"minYear",d),Es(u,"maxYear",d),en("YearSelector","allowedYears",f),f!==void 0)for(let re=0;re<f.length;re++)gl(f[re],`allowedYears[${re}]`,d,"");b!==void 0&&Co("YearSelector","formatLocale",b);const ae=t??r;if(ae===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&&za("YearSelector",o,t!==void 0);const I=Po(Y,w),Z=t!==void 0,[te,we]=Wa(ae,Z,re=>fl(re,d),re=>kn(re,d)),O=m?.getTime(),Q=h?.getTime(),se=s.useMemo(()=>ys(i,m,Math.max,d),[i,O,d]),E=s.useMemo(()=>ys(u,h,Math.min,d),[u,Q,d]);if(se!==null&&E!==null&&se>E)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${se}, upper: ${E})`);const M=f===void 0?null:f.map(re=>re.getTime()).join(","),D=s.useMemo(()=>ju(f,se,E,d),[M,se,E,d]);if(D===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 H=s.useMemo(()=>D.kind==="discrete"?{kind:"candidates",ascending:D.ascending,loIndex:0,hiIndex:D.ascending.length-1}:{kind:"range",min:D.minYear,max:D.maxYear},[D]),W=t!==void 0?kn(t,d):te,F=!En(H,W),k=re=>{if(!L){if(!En(H,re))throw new RangeError(`YearSelector: refusing to emit ${re}, which lies outside the selectable years`);Z||we(re),n?.(Mo(re,d),re)}},V=Zt(H,W,-1),oe=Zt(H,W,1),ge=()=>{if(o!==void 0){o.onStep("previous");return}V!==null&&k(V)},q=()=>{if(o!==void 0){o.onStep("next");return}oe!==null&&k(oe)},X=s.useMemo(()=>{const re=D.kind==="discrete"?[...D.ascending].reverse():Uu(D.minYear,D.maxYear);return F&&(re.push(W),re.sort((Re,ie)=>ie-Re)),re.map(Re=>({value:Re,label:st("year",Mo(Re,d),c,b)}))},[D,F,W,d,b,c]);return $.jsxs("div",{className:`inline-flex items-center ${Dn} ${x}`,style:v,"data-out-of-range":F?"true":void 0,children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:L,canStep:o===void 0?V!==null:o.canStepPrevious,onStep:ge,ariaLabel:I.previousYear}),$.jsx("select",{"aria-label":I.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:W,onChange:re=>{if(!re.target.value)return;const Re=Number(re.target.value);Number.isInteger(Re)&&k(Re)},children:X.map(re=>$.jsx("option",{value:re.value,disabled:F&&re.value===W,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(yr,{neighbour:"control",direction:"right",disabled:L,canStep:o===void 0?oe!==null:o.canStepNext,onStep:q,ariaLabel:I.nextYear}),a]})},Wu=(e,t)=>{const r=Ds(t.yearStartMonth);return!(Ds(e.yearStartMonth)!==r||!Ua(e,t,n=>fl(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||!yo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},hl=s.memo(zu,Wu);hl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=ks;exports.DateSelector=cl;exports.MonthSelector=dl;exports.PERIOD_SLIDER_LABEL_CATALOGS=Cs;exports.PERIOD_SLIDER_LABEL_KEYS=Eo;exports.PeriodSlider=rl;exports.YearSelector=hl;exports.addUnit=_s;exports.areStylesEqual=tl;exports.calculateConnectDragValues=Us;exports.calculateHandleDragValues=Ma;exports.calculateKeyboardActionValues=zs;exports.calculateLabelSlant=Ha;exports.calculateVernierMacroDrag=Zs;exports.calculateVernierMicroDrag=Qs;exports.decode=ee;exports.encode=N;exports.findNearestDateIndex=xe;exports.formatLabel=st;exports.formatOptionText=nl;exports.formatQuarterLabel=Nc;exports.formatScreenReaderLabel=Dr;exports.getMacroWindowEndDate=Hs;exports.getMacroWindowStartDate=Ys;exports.getSortedAllowedDates=_c;exports.normalizeDateByUnit=pt;exports.resolveDraggedEdge=Ro;exports.resolveMacroWindow=Dt;exports.resolvePeriodSliderLabels=Is;exports.resolveQuarter=js;exports.resolveSelectorSteps=ya;exports.resolveVernierRailZone=ja;exports.resolveVernierSelectorSteps=cr;exports.resolveVernierTargetHandle=Xs;exports.resolveWheelStep=qs;exports.usePeriodSliderPoint=Nu;exports.usePeriodSliderRange=Vu;exports.useSelectorStepper=jt;exports.useVernierSliderPoint=Yu;exports.useVernierSliderRange=_u;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("react/jsx-runtime"),cc=require("date-fns"),s=require("react"),ur=require("@aiquants/virtualscroll"),uc=require("react-dom"),Ua="an object that cannot be converted to a string",dc=3,ye=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},$t=e=>{try{return Array.isArray(e)}catch{return!1}},mc=e=>e===void 0||$t(e);function en(e,t,r){if(!mc(r))throw new RangeError(`${e}: ${t} must be an array of Dates (received: ${E(r)})`)}const E=e=>{if(typeof e=="string")return JSON.stringify(e);if(ye(e))return Date.prototype.toISOString.call(e);if($t(e))return fc(e);try{return String(e)}catch{return Ua}},fc=e=>{let t;try{t=e.length}catch{return Ua}const r=Math.min(t,dc),n=[];for(let a=0;a<r;a++)n.push(hc(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},hc=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return $t(r)?`Array(${r.length})`:E(r)}catch{return Ua}},Dt=(e,t)=>ye(e)?t(e):Number.NaN,mt=(e,t)=>e===void 0?null:Dt(e,t),Ji=120,da="data-drag-snap",ma="--ps-drag-snap-duration",Rn={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"]},Ns=["low","high"],Vs=["tx","ty","rot"],Lo={flat:{low:"--ps-drag-label-low",high:"--ps-drag-label-high"},macro:{low:"--ps-drag-macro-label-low",high:"--ps-drag-macro-label-high"},micro:{low:"--ps-drag-micro-label-low",high:"--ps-drag-micro-label-high"}},Wa=(e,t)=>`${e}-${t}`,fa=(e,t,r)=>`var(${Wa(e,t)}, ${r})`,gc=(e,t,r)=>{const n=Lo[t];for(const o of Ns)for(const a of Vs)e.style.setProperty(Wa(n[o],a),r[o][a])},_s=e=>Math.max(0,Math.min(1,e)),So=(e,t,r,n)=>{const o=_s(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},za=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},$o=(e,t,r,n)=>{const o=_s(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},ha=(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`},or=(e,t)=>`var(${e}, ${t}%)`,pc=(e,t,r,n)=>{const[o,a]=Rn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},wc=e=>{for(const[t,r]of Object.values(Rn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Lo))for(const r of Ns)for(const n of Vs)e.style.removeProperty(Wa(t[r],n))},Ys=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],To=[...ur.VIRTUAL_SCROLL_LABEL_KEYS,...Ys],Pa=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:"日"})}),Hs=Object.freeze({en:Object.freeze({...ur.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Pa.en}),ja:Object.freeze({...ur.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Pa.ja})}),es=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,bc=e=>To.includes(e),vc=(e,t)=>{const r={};let n=!1;for(const o of ur.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},Sc=e=>{try{return ur.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}},js=(e,t)=>{const r=Sc(e);if(t===void 0)return Hs[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${es(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(!bc(u))throw new RangeError(`[period-slider] labels.${u} is not a known label key; expected one of ${To.join(", ")}`);const i={...ur.resolveVirtualScrollLabels(r,vc(t,o)),...Pa[r]};for(const u of Ys){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 ${es(m)}`);i[u]=m}}return Object.freeze(i)},xc=e=>{const t={};for(const r of ur.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},Rc=(e,t)=>e===t||To.every(r=>e[r]===t[r]),Co=(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]))},ga=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),ts=new Set(["hidden","clip","scroll","auto","overlay"]),rs=["paint","strict","content"],Dc=["layout","paint","strict","content"],Mc=["transform","perspective","filter"],gn=e=>e!==void 0&&e!==""&&e!=="none",yc=e=>e!==void 0&&e!==""&&e!=="normal",to=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},Ec=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,Pc=(e,t)=>t==="absolute"&&gn(e.position)&&e.position!=="static"||gn(e.transform)||gn(e.perspective)||gn(e.filter)||gn(e.backdropFilter)||yc(e.containerType)||Dc.some(r=>e.contain.includes(r))?!0:Mc.some(r=>e.willChange.includes(r)),Lc=(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 x=null;for(let v=t;v!==null;v=v.parentElement){const P=v===t?f:i.getComputedStyle(v);if(x!==null&&!Pc(P,x))continue;const j=ts.has(P.overflowX)||rs.some(w=>P.contain.includes(w)),p=ts.has(P.overflowY)||rs.some(w=>P.contain.includes(w));if(j||p){const w=v.getBoundingClientRect();if(j&&(o<w.left+to(P.borderLeftWidth)||o>=w.right-to(P.borderRightWidth))||p&&(a<w.top+to(P.borderTopWidth)||a>=w.bottom-to(P.borderBottomWidth)))return!1}x=Ec(P)}return!0},pa=new Map,$c=(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)},Tc=(e,t)=>{let r=pa.get(e);if(r===void 0){const a=new Set,i=u=>$c(a,u);r={participants:a,listener:i},pa.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)&&(pa.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Mn="gap-[11px]",_t=6,Yt=_t*2,ar=_t*4/3,Cc={left:`0,${Yt/2} ${_t},0 ${_t},${Yt}`,right:`${ar},${Yt/2} ${ar-_t},0 ${ar-_t},${Yt}`,up:`${Yt/2},0 0,${_t} ${Yt},${_t}`,down:`${Yt/2},${ar} 0,${ar-_t} ${Yt},${ar-_t}`},wa=e=>{e.preventDefault(),e.stopPropagation()},kc={onMouseDownCapture:wa,onMouseUpCapture:wa,onClickCapture:wa},Ic="period-slider-step",Ac=`${Ic} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Oc="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]",Nc={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"},ro="after:inset-[calc((100%-var(--ps-target-size))/2)]",ns={horizontal:"px-[19px]",vertical:"py-[19px]"},Vc={control:{left:ro,right:ro,up:ro,down:ro},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)]"}},yr=({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:ar,f=m?ar:Yt,x=r||!n;return $.jsx("button",{ref:u,type:"button","aria-label":a,disabled:r,"aria-disabled":x?!0:void 0,...x?kc:null,onClick:x?void 0:o,className:`${i===void 0?"":`${i} `}${Ac} ${Oc} ${Nc[t]} ${Vc[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:Cc[e]})})})},ko=(e,t)=>{const r=s.useMemo(()=>js(e,t),[e,t]),n=s.useRef(r);return Rc(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: ${E(r)})`)},mr=(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)},On=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Io=(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},yn=(e,t)=>(mr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:On(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),En=(e,t)=>{if(mr("drawnValuesHas",e),ct("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(On(e))return!1;const r=Io(e,t);return r<=e.hiIndex&&e.ascending[r]===t},Pn=(e,t)=>{if(mr("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(On(e))return null;const r=Io(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},Zt=(e,t,r)=>{if(mr("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(On(e))return null;const n=Io(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]},mo=(e,t,r)=>{if(mr("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)]},_c=(e,t,r)=>{if(mr("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(On(e))return null;const n=yn(e,-1),o=yn(e,1),a=r-t;return o!==null&&r>o?mo(e,o-a,o):n!==null&&t<n?mo(e,n,n+a):mo(e,t,r)},fo=(e,t,r)=>(mr("drawnValuesAtOrBeyond",e),ct("drawnValuesAtOrBeyond","target",t),Zt(e,t-r,r)),tn=(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:Io(n,t),hiIndex:o-1}},ho=e=>(mr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Zt(e,t,r),edge:t=>yn(e,t)}),La=(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: ${E(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: ${E(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: ${E(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: ${E(o.motion)})`)}},Us={"blue-rose":{macro:"#0284c7",macroLight:"#38bdf8",micro:"#e11d48",microLight:"#fb7185",accent:"#0284c7"},"indigo-amber":{macro:"#4f46e5",macroLight:"#818cf8",micro:"#d97706",microLight:"#fbbf24",accent:"#4f46e5"},"teal-emerald":{macro:"#0d9488",macroLight:"#2dd4bf",micro:"#059669",microLight:"#34d399",accent:"#0d9488"},"violet-fuchsia":{macro:"#7c3aed",macroLight:"#a78bfa",micro:"#c026d3",microLight:"#e879f9",accent:"#7c3aed"},"slate-sky":{macro:"#475569",macroLight:"#94a3b8",micro:"#0284c7",microLight:"#38bdf8",accent:"#475569"},monochrome:{macro:"#52525b",macroLight:"#a1a1aa",micro:"#18181b",microLight:"#71717a",accent:"#27272a"}},Ws=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Tt=(e,t)=>{if(!Ws(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${E(t)})`)},fr=(e,t)=>t===void 0?0:(Tt(e,t),t),Ce=(e,t,r)=>{if(r!=="year"&&r!=="month"&&r!=="day")throw new RangeError(`${e}: ${t} must be one of "year", "month", "day" (received: ${E(r)})`)},Qt=(e,t,r,n)=>r===void 0?n:(Ce(e,t,r),r),Yc=[31,28,31,30,31,30,31,31,30,31,30,31],zs=719468,go=146097,$a=(e,t)=>t!==1?Yc[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,Ba=(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,$a(a,i))]},Ln=(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*go+m-zs},os=e=>{const t=e+zs,r=Math.floor(t/go),n=t-r*go,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(go-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]},Ao=(e,t,r)=>e-(t<r?1:0),bt=(e,t,r=0)=>{if(Ce("normalizeDateByUnit","unit",e),!ye(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${E(t)})`);Tt("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(Ao(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},Y=(e,t,r=0)=>{Ce("encode","unit",e),Tt("encode",r);const n=bt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:Ln(o,a,n.getDate())},oe=(e,t,r=0)=>{Ce("decode","unit",e),Tt("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},Nn=e=>`; ${e} instead of a sentinel for "no bound"`,Bs=Nn("minDate is required, so pass the earliest date to offer"),qe=(e,t,r,n,o,a)=>{const i=Vn(r,n,o);if(i===null)throw new RangeError(`${e}: ${t} must fall in a ${n} that starts inside the Date range (received: ${E(r)})${a}`);return i},Vn=(e,t,r)=>{const n=Y(t,e,r);return Number.isInteger(n)?n:null},Fs=(e,t,r)=>{if(Ce("addUnit","unit",e),!ye(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${E(t)})`);if(!Number.isInteger(r))throw new RangeError(`addUnit: amount must be an integer number of units (received: ${E(r)})`);const n=new Date(t.getTime());return r===0?n:e==="year"||e==="month"?(n.setFullYear(...Ba(n.getFullYear(),n.getMonth(),n.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},as=(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]:os(t),[h,f,x]=r==="year"||r==="month"?Ba(i,u,m,r==="year"?n*12:n):os(Ln(i,u,m)+n);return e==="year"?Ao(h,f,o):e==="month"?h*12+f:Ln(h,f,x)},Ks=(e,t,r,n=0)=>{if(Ce("getMacroWindowStartDate","macroUnit",e),Ce("getMacroWindowStartDate","microUnit",t),!ye(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${E(r)})`);return Tt("getMacroWindowStartDate",n),qe("getMacroWindowStartDate","d",r,e,n,""),qe("getMacroWindowStartDate","d",r,t,n,""),bt(t,bt(e,r,n),n)},Gs=(e,t,r,n=0)=>{if(Ce("getMacroWindowEndDate","macroUnit",e),Ce("getMacroWindowEndDate","microUnit",t),!ye(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${E(r)})`);Tt("getMacroWindowEndDate",n);let o;const a=new Date(r.getTime());if(e==="year"&&t!=="year"){const[u,m]=Ba(Ao(a.getFullYear(),a.getMonth(),n),n,1,11);o=t==="month"?u*12+m:Ln(u,m,$a(u,m))}else if(e==="month"&&t==="day")o=Ln(a.getFullYear(),a.getMonth(),$a(a.getFullYear(),a.getMonth()));else return qe("getMacroWindowEndDate","d",r,t,n,""),bt(t,r,n);const i=oe(t,o,n);if(!ye(i))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${E(r)})`);return i},is=(e,t,r)=>e<t?t:e>r?r:e,yt=(e,t,r,n,o,a=0)=>{if(Ce("resolveMacroWindow","macroUnit",e),Ce("resolveMacroWindow","microUnit",t),Tt("resolveMacroWindow",a),xo("macroRange",r,!0,"resolveMacroWindow"),!ye(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${E(n)})`);if(!ye(o))throw new RangeError(`resolveMacroWindow: maxDate must be a valid Date (received: ${E(o)})`);if(o.getTime()<n.getTime())throw new RangeError(`resolveMacroWindow: maxDate must not precede minDate (minDate: ${E(n)}, maxDate: ${E(o)})`);qe("resolveMacroWindow","maxDate",o,t,a,""),qe("resolveMacroWindow","macroRange[0]",r[0],e,a,""),qe("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=Y(e,r[1],a)<Y(e,o,a)?is(Gs(e,t,r[1],a),n,o):o;return[bt(t,is(Ks(e,t,r[0],a),n,o),a),bt(t,i,a)]},qs=(e,t)=>{if(!ye(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${E(e)})`);Tt("resolveQuarter",t);const r=bt("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}},Hc={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},ss=new Map,jc=(e,t)=>{const r=`${e}\0${t}`,n=ss.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Hc[e]);return ss.set(r,o),o},Uc=4,Wc=6,Oo=e=>e>=0?String(e).padStart(Uc,"0"):`-${String(-e).padStart(Wc,"0")}`,zc=(e,t)=>{const r=new Date(t.getTime()),n=Oo(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}`},nt=(e,t,r,n)=>(Ce("formatLabel","unit",e),ye(t)?r?r(t,e,"period"):n===void 0?zc(e,t):jc(e,n).format(t):""),Rr=(e,t,r,n)=>(Ce("formatScreenReaderLabel","unit",e),nt(e,t,r,n)),Bc=(e,t)=>{if(!ye(e))return"";Tt("formatQuarterLabel",t);const{quarter:r}=qs(e,t);return`${nt("year",bt("year",e,t))}-Q${r}`},Me=(e,t,r,n=0)=>{if(Ce("findNearestDateIndex","unit",r),Tt("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!ye(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${E(t)})`);const o=qe("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=Y(r,e[a],n))return 0;if(o>=Y(r,e[i],n))return i;for(;a<=i;){const h=a+i>>1,f=Y(r,e[h],n);if(f===o)return h;f<o?a=h+1:i=h-1}const u=Math.abs(Y(r,e[a],n)-o),m=Math.abs(Y(r,e[i],n)-o);return u<m?a:i},Fc=(e,t,r,n,o=0)=>(Ce("getSortedAllowedDates","unit",t),dr("getSortedAllowedDates",No(e),t,r,n,o).dates),No=e=>({list:e,path:"allowedDates",inheritedBy:null}),dr=(e,t,r,n,o,a)=>{Tt(e,a);const{list:i,path:u}=t,m=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(en(e,`${u}${m}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[P,j]of[["minDate",n],["maxDate",o]])if(!ye(j))throw new RangeError(`${e}: ${P} must be a valid Date (received: ${E(j)})`);const h=qe(e,"minDate",n,r,a,""),f=qe(e,"maxDate",o,r,a,""),x=new Map;for(let P=0;P<i.length;P++){const j=i[P];if(!ye(j))throw new RangeError(`${e}: ${u}[${P}]${m} must be a valid Date (received: ${E(j)})`);const p=qe(e,`${u}[${P}]${m}`,j,r,a,"");p<h||p>f||x.has(p)||x.set(p,bt(r,j,a))}if(x.size===0)throw new RangeError(`${e}: every ${u} entry${m} falls outside [minDate, maxDate] (minDate: ${E(n)}, maxDate: ${E(o)}, entries: ${i.length})`);const v=Array.from(x.keys()).sort((P,j)=>P-j);return{keys:v,dates:v.map(P=>x.get(P))}},Fa=(e,t,r,n,o,a)=>{const{keys:i,dates:u}=dr(e,t,r,n,o,a);return u.length===0?null:{...tn(i,null,null),dates:u}},$n=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),no=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Me(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},oo=(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:Me(e,new Date(u+i*m),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},Ta=(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))]},Xs=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:u,unit:m,yearStartMonth:h=0})=>{if(Ce("calculateConnectDragValues","unit",m),a){const p=i.length-1;if(p<=0)return[0,0];const w=Math.max(0,Math.min(p,Math.round(t))),c=Math.max(w,Math.min(p,Math.round(r)));if(u==="time"){const O=i[0].getTime(),ae=i[p].getTime(),J=i[w].getTime(),se=i[c].getTime()-J;let ne=J+e*(ae-O),A=ne+se;ne<O&&(ne=O,A=O+se),A>ae&&(A=ae,ne=ae-se);const ee=Me(i,new Date(ne),m,h),D=Me(i,new Date(A),m,h);return[ee,Math.max(ee,D)]}const g=Math.round(e*p);let d=w+g,re=c+g;return d<0&&(re+=-d,d=0),re>p&&(d-=re-p,re=p),[Math.max(0,Math.min(p,d)),Math.max(0,Math.min(p,re))]}const f=p=>Math.max(n,Math.min(o,p)),x=o-n;if(x<=0)return[f(t),f(r)];const v=Math.round(e*x);let P=t+v,j=r+v;return P<n&&(j+=n-P,P=n),j>o&&(P-=j-o,j=o),[f(P),f(j)]},Zs=(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 P=r;return h?P=o:f?P=a:P=Math.max(o,Math.min(a,r+m)),[P,P]}let x=r,v=n;return t==="low"?h?x=o:f?x=n:x=Math.max(o,Math.min(n,r+m)):h?v=r:f?v=a:v=Math.max(r,Math.min(a,n+m)),[x,v]},Qs=8,Js=2,el=16,Kc=12,Gc=90,tl=(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}},Ka=(e,t)=>{const r=t?.estimatedHeightPx??el,o=Qs+(t?.anchorGapY??Js)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,proximity:0}},Ga=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??el,u=o?.paddingPx??Kc,m=o?.maxAngleDeg??Gc,h=Qs+(o?.anchorGapY??Js),f=Ka(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return f;const x=Math.max(0,t-e)/100*r,v=a+u;if(x>=v)return f;const P=Math.max(0,Math.min(1,(v-x)/v)),p=P*P*P*(P*(P*6-15)+10)*m,w=n==="top"?-p:p,c=tl(a,i,p),g=h+c.acrossPx,d=n==="top"?-g:+g,re=2*c.alongPx,O=Math.max(0,(re+u-x)/2);return{lowAngleDeg:w,highAngleDeg:w,lowOffsetX:-O,highOffsetX:O,lowOffsetY:d,highOffsetY:d,isSlanted:P>.001,proximity:P}},rl=e=>({...e,lowOffsetX:0,highOffsetX:0}),Ht=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Mt=(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}},po=(e,t,r,n)=>e==="pan"?_c(t,r,Math.max(r,n)):mo(t,r,Math.max(r,n)),qa=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},nl=(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 ol(e,t,r,n,o,a,i="macro-top",u=.05,m=!0,h="range"){if(qa(t,i)==="macro"){const v=Math.abs(e-r),P=Math.abs(e-n);return v<=u&&v<=P?"macro-low":P<=u&&P<v?"macro-high":m&&e>=r&&e<=n?"macro-connect":v<P?"macro-low":"macro-high"}if(h==="point")return"micro-point";const f=Math.abs(e-o),x=Math.abs(e-a);return f<=u&&f<=x?"micro-low":x<=u&&x<f?"micro-high":m&&e>=o&&e<=a?"micro-connect":f<x?"micro-low":"micro-high"}function al(e,t,r,n,o){if(e==="macro-connect"){const[h,f]=za(t-r,n,o);return[h,f,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,u]=So(a,t,n,o),m=$o(a,t,n,o);return[i,u,m==="low"?"macro-low":"macro-high"]}function il(e,t,r,n,o){if(e==="micro-point"){const[h]=So("point",t,n,o);return[h,h,"micro-point"]}if(e==="micro-connect"){const[h,f]=za(t-r,n,o);return[h,f,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,u]=So(a,t,n,o),m=$o(a,t,n,o);return[i,u,m==="low"?"micro-low":"micro-high"]}const xn=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"})})});xn.displayName="VernierKnobSvg";const qc=(e,t,r,n)=>{if(!ye(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${E(e)})`);if(!ye(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${E(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${E(e)}, maxDate: ${E(t)})`);for(const o of r)qe("PeriodSlider","minDate",e,o,n,Bs)},xo=(e,t,r,n="PeriodSlider")=>{if(!$t(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: ${E(t)})`)}const[o,a]=t;if(!ye(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${E(o)})`);if(!ye(a))throw new RangeError(`${n}: ${e}[1] must be a valid Date (received: ${E(a)})`);if(a.getTime()<o.getTime())throw new RangeError(`${n}: ${e} must not be inverted (start: ${E(o)}, end: ${E(a)})`)},sl=(e,t)=>{if(!ye(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${E(t)})`)},Fr=(e,t,r,n,o,a)=>{const i=qe("PeriodSlider",e,t,r,a,"");if(i<Y(r,n,a)||i>Y(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${E(t)}, minDate: ${E(n)}, maxDate: ${E(o)})`)},Xc=(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&&(xo(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&&(sl(o,a),Fr(o,a,e.unit,t,r,n))}},Zc=(e,t,r)=>{const n=e.yearStartMonth??0;xo("macroRange",e.macroRange,!0),qe("PeriodSlider","macroRange[0]",e.macroRange[0],Qt("PeriodSlider","macroUnit",e.macroUnit,e.unit),n,"");const o=Qt("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&&(sl(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&&(xo(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")},pn=(e,t,r,n,o,a,i,u,m)=>{const h=Me(e,n,t,m),f=Me(e,o,t,m);return i?h:u?f:Math.max(h,Math.min(f,Me(e,r,t,m)+a))},ba=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function Qc(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Jc(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const ls=()=>{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}},Vo=(e,t,r)=>{try{Intl.DateTimeFormat.supportedLocalesOf([r])}catch{throw new RangeError(`${e}: ${t} must be a valid BCP 47 language tag (received: ${E(r)})`)}},zr=()=>{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]},va=(e,t)=>{const r=wo(e,t);return r===null?void 0:{estimatedWidthPx:r.widthPx,estimatedHeightPx:r.heightPx}},wo=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},eu=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=tl(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}},cs=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`}),us=(e,t,r)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`}),Ro=(e,t)=>({"--ps-tooltip-tx":fa(e,"tx",t.tx),"--ps-tooltip-ty":fa(e,"ty",t.ty),"--ps-tooltip-rot":fa(e,"rot",t.rot)}),Sa=(e,t,r,n)=>{const o=Ka(n.labelPosition,n.config);if(!n.isSlantable)return{slant:o,lowStyle:void 0,highStyle:void 0,placements:null};const a=Ga(t*100,r*100,n.trackLengthPx,n.labelPosition,n.config),i=n.isMerged?rl(a):a,u=Lo[e],m={low:cs(i.lowOffsetX,i.lowOffsetY-o.lowOffsetY,i.lowAngleDeg),high:cs(i.highOffsetX,i.highOffsetY-o.highOffsetY,i.highAngleDeg)};return{slant:i,lowStyle:Ro(u.low,m.low),highStyle:Ro(u.high,m.high),placements:m}},ds={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},ms=(e,t,r)=>{const n=Ka(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:ds,highStyle:ds,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const m=Ga(e,t,r.trackLengthPx,r.labelPosition,r.config);a=r.isMerged?rl(m):m}const i=Lo.flat,u={low:us(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg),high:us(a.highOffsetX,a.highOffsetY,a.highAngleDeg)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...Ro(i.low,u.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...Ro(i.high,u.high)},placements:o?u:null}},tu={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},ru={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"}},fs={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},nu={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Mn} ${ns.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${fs.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Mn} ${ns.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${fs.vertical}`}},hs={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"}},gs=(e,t)=>{e.setPointerCapture(t)},ou=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:x=!0,isVertical:v=!1,hideConnectBar:P=!1,showTicks:j=!1,colorScheme:p="blue-rose",formatLocale:w}=e;Ce("PeriodSlider","unit",t);const c=e.mode==="vernier"?Qt("PeriodSlider","macroUnit",e.macroUnit,t):t,g=e.mode==="vernier"?Qt("PeriodSlider","microUnit",e.microUnit,t):t,d=fr("PeriodSlider",e.yearStartMonth);qc(r,n,e.mode==="vernier"?[c,g,t]:[t],d),Xc(e,r,n),w!==void 0&&Vo("PeriodSlider","formatLocale",w);const re=e.mode==="vernier"?Zc(e,r,n):null,O=re!==null&&re.shape==="point",ae=ko(e.locale,e.labels),J=Us[p],se=s.useId(),ne=s.useRef(e),A=r.getTime(),ee=n.getTime(),D=e.mode==="vernier",M=s.useMemo(()=>D?[]:dr("PeriodSlider",No(o),t,r,n,d).dates,[D,o,t,A,ee,d]),L=M.length>0,{rangeMin:k,rangeMax:U}=s.useMemo(()=>L?{rangeMin:0,rangeMax:M.length-1}:{rangeMin:Y(t,r,d),rangeMax:Y(t,n,d)},[L,M,t,A,ee,d]),F=e.mode==="point",W=s.useCallback(l=>{if(L){const b=Math.max(0,Math.min(M.length-1,Math.round(l)));return M[b]}return oe(t,Math.round(l),d)},[L,M,t,d]),V=s.useCallback(l=>{if(l===void 0)return k;const b=bt(t,l,d);return L?Me(M,b,t,d):Y(t,b,d)},[L,M,t,k,d]),[Q,ce]=s.useState(()=>re===null?null:re.selection),ve=Q??(re===null?null:re.selection),G=ve===null?null:Qc(ve,O);s.useLayoutEffect(()=>{G!==ve&&ce(l=>l===Q?G:l)});const _=e.mode==="vernier"?e.microValue?.getTime():void 0,De=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,_]),Ee=ls(),ie=ls(),fe=e.mode!=="vernier"?null:O?De??G:e.microRange!==void 0?e.microRange:G,ke=fe===null?null:ie.shown??fe,ot=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?ke?.[0]:void 0,te=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?ke?.[1]:void 0,T=e.mode==="point"?e.value??e.defaultValue:void 0,ue=e.mode==="point"?T?.getTime():ot?.getTime(),pe=e.mode==="range"?te?.getTime():ue,[at,$e]=s.useMemo(()=>{if(e.mode==="point"){const S=V(T);return[S,S]}const l=V(ot),b=V(te);return[Math.min(l,b),Math.max(l,b)]},[e.mode,ue,pe,V,T,ot,te]),He=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:O?e.microValue!==void 0:e.microRange!==void 0,[Ke,q]=s.useState(()=>D?null:[at,$e]),et=Ke??[at,$e],[it,gt]=s.useState(null),[Pe,st]=s.useState(null),Ve=s.useRef(null),[ft,Ge]=s.useState("high"),[dt,C]=s.useState(null),[Z,ze]=s.useState(null),Se=it?it[0]:He?at:et[0],ge=it?it[1]:He?$e:et[1],vt=s.useRef([Se,ge]),Ct=e.mode==="vernier"?e.vernierOrientation??(v?"macro-left":"macro-top"):"macro-top",z=Ct==="macro-top"||Ct==="macro-left",Pr=e.mode==="vernier"?e.showVernierProjection??!0:!1,rn=e.mode==="vernier"?e.showVernierTicks??!0:!1,I=e.mode==="vernier"?e.showHairline??!0:!1,le=D?Ht("macro",e):L,we=D?Ht("micro",e):L,Ye=D?Mt("macro",e).list:o,y=D?Mt("micro",e).list:o,H=D?e.formatMacroLabel??e.formatLabel:e.formatLabel,de=D?e.formatMicroLabel??e.formatLabel:e.formatLabel,_e=ot?.getTime(),Ie=te?.getTime(),[be,je]=s.useState(null),Xe=s.useRef(null),[kt,zt]=s.useState(()=>O?"micro-point":"micro-high"),Ue=Jc(kt,O);s.useLayoutEffect(()=>{Ue!==kt&&zt(l=>l===kt?Ue:l)});const pt=s.useMemo(()=>Y(c,r,d),[A,c,d]),It=s.useMemo(()=>Y(c,n,d),[ee,c,d]),Yn=s.useMemo(()=>D&&we?Fa("PeriodSlider",Mt("micro",e),g,r,n,d):null,[D,we,y,g,A,ee,d]),Ae=s.useMemo(()=>D&&le?dr("PeriodSlider",Mt("macro",e),c,r,n,d).dates:[],[D,le,Ye,c,A,ee,d]),ti=l=>[Math.max(pt,Math.min(It,Y(c,l[0],d))),Math.max(pt,Math.min(It,Y(c,l[1],d)))],[ri,ni]=e.mode!=="vernier"?[pt,It]:ti(e.macroRange),[Ze,lt]=Ee.shown===null?[ri,ni]:ti(Ee.shown),hr=s.useMemo(()=>oe(c,Ze,d),[c,Ze,d]),gr=s.useMemo(()=>oe(c,lt,d),[c,lt,d]),Hn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:yt(c,g,[hr,gr],r,n,d),[e.mode,hr,gr,c,g,A,ee,d]),We=s.useMemo(()=>Y(g,Hn[0],d),[g,Hn,d]),tt=s.useMemo(()=>Y(g,Hn[1],d),[g,Hn,d]),Uo=(l,b)=>Yn===null?[]:$n(Yn,tn(Yn.ascending,l,b)),xe=s.useMemo(()=>Uo(We,tt),[Yn,We,tt]),Jt=le&&Ae.length>0,Et=we&&xe.length>0,oi=Jt?Y(c,Ae[0],d):pt,ai=Jt?Y(c,Ae[Ae.length-1],d):It,ii=Et?Y(g,xe[0],d):We,Wo=Et?Y(g,xe[xe.length-1],d):tt,Ml=Math.min(oi,Ze),yl=Math.max(ai,lt),er=(l,b,S,R)=>b.length>0?Y(g,b[Me(b,l,g,d)],d):Math.max(S,Math.min(R,Y(g,l,d))),Lr=Et?xe:[],Be=s.useMemo(()=>ke===null?We:er(ke[0],Lr,We,tt),[_e,We,tt,g,ke,Lr]),rt=s.useMemo(()=>ke===null?tt:er(ke[1],Lr,We,tt),[Ie,We,tt,g,ke,Lr]),$r=s.useMemo(()=>oe(g,Be,d),[g,Be,d]),Tr=s.useMemo(()=>oe(g,rt,d),[g,rt,d]),si=!D||fe===null?null:{macroUnit:c,macroLowEnc:ri,macroHighEnc:ni,microUnit:g,microLowEnc:Y(g,fe[0],d),microHighEnc:Y(g,fe[1],d)},zo=s.useRef(si),Bo=Math.max(1,It-pt),Pt=Jt?no(Ae,c,a,hr,d):Math.max(0,Math.min(1,(Ze-pt)/Bo)),At=Math.max(Pt,Jt?no(Ae,c,a,gr,d):Math.min(1,(lt-pt)/Bo)),li=l=>Math.max(oi,Math.min(ai,Math.round(pt+l*Bo))),jn=Math.max(1,tt-We),Cr=Et?no(xe,g,a,$r,d):Math.max(0,Math.min(1,(Be-We)/jn)),nn=Math.max(Cr,Et?no(xe,g,a,Tr,d):Math.min(1,(rt-We)/jn)),Fo=s.useRef({timerId:null,emit:null}),Un=s.useRef({timerId:null,emit:null}),Wn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const l=[Fo,Un,Wn];return()=>{for(const b of l)ba(b.current)}},[]);const kr=s.useCallback((l,b,S)=>{ba(l);const{debounceMs:R}=ne.current;if(S||!R||R<=0){b();return}l.emit=b,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,b()},R)},[]),ci=s.useCallback(l=>{const b=l.emit;ba(l),b?.()},[]),Ir=s.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),A),ee)),[A,ee]),tr=s.useCallback((l,b,S=!1)=>{const[R,N]=vt.current;if((ne.current.mode==="point"?l===R:l===R&&b===N)&&Fo.current.timerId===null)return;const X=W(l),K=W(b),he=()=>{const Re=ne.current;Re.mode==="point"?Re.onChangePoint?.(X):Re.mode==="range"&&Re.onChangeRange?.(X,K)};kr(Fo.current,he,S)},[W,kr]),pr=s.useCallback((l,b,S=!1)=>{const R=zo.current;if(ne.current.mode!=="vernier"||R===null)return;const N=Ir(l),B=Ir(b);Y(R.macroUnit,N,d)===R.macroLowEnc&&Y(R.macroUnit,B,d)===R.macroHighEnc&&Un.current.timerId===null||kr(Un.current,()=>{const X=ne.current;X.mode==="vernier"&&X.onChangeMacroRange?.(N,B)},S)},[Ir,kr,d]),St=s.useCallback((l,b,S=!1)=>{const R=ne.current,N=zo.current;if(R.mode!=="vernier"||N===null)return;const B=Ir(l),X=Ir(b);Y(N.microUnit,B,d)===N.microLowEnc&&Y(N.microUnit,X,d)===N.microHighEnc&&Wn.current.timerId===null||((O?R.microValue===void 0:R.microRange===void 0)&&ce([B,X]),kr(Wn.current,()=>{const K=ne.current;if(K.mode==="vernier"){if(O){K.onChangeMicroPoint?.(B);return}K.onChangeMicroRange?.(B,X)}},S))},[Ir,kr,O,d]),ui=s.useCallback((l,b=!1)=>{St(l,l,b)},[St]),wr=s.useCallback(l=>{if(L&&a==="time"&&M.length>1){const R=Math.max(0,Math.min(M.length-1,Math.round(l))),N=M[0].getTime(),X=M[M.length-1].getTime()-N;if(X<=0)return 0;const K=M[R].getTime();return Math.max(0,Math.min(100,(K-N)/X*100))}const b=U-k;if(b<=0)return 0;const S=(l-k)/b*100;return Math.max(0,Math.min(100,S))},[L,a,M,k,U]),Ko=s.useCallback(l=>{const b=Math.max(0,Math.min(100,l));if(L){if(a==="time"&&M.length>1){const N=M[0].getTime(),X=M[M.length-1].getTime()-N,K=N+b/100*X;return Me(M,new Date(K),t,d)}const R=Math.round(b/100*(M.length-1));return Math.max(0,Math.min(M.length-1,R))}const S=k+b/100*(U-k);return Math.round(S)},[L,a,M,k,U,t,d]),on=s.useRef(null),di=s.useRef(null),mi=s.useRef(0),ht=s.useRef(null),Go=s.useRef(null),fi=s.useRef(null),hi=s.useRef(null),[qo,gi]=s.useState(0),[El,Ar]=zr(),[Pl,pi]=zr(),[Ll,wi]=zr(),[$l,bi]=zr(),[Tl,Xo]=zr(),[Cl,vi]=zr(),kl=F?Ar===null?void 0:{estimatedWidthPx:Ar.widthPx,estimatedHeightPx:Ar.heightPx}:va(Ar,pi),Zo=!F&&Se===ge,Qo=Ze===lt,Jo=!O&&Be===rt,Il=z?"top":"bottom",Al=z?"bottom":"top",Si=x&&!v,Ol=Si&&!O,ea={isPointMode:F,isVertical:v,autoSlantLabels:x,isMerged:Zo,trackLengthPx:qo,labelPosition:f,config:kl},ta={trackLengthPx:qo,labelPosition:Il,config:va(wi,bi),isMerged:Qo,isSlantable:Si},ra={trackLengthPx:qo,labelPosition:Al,config:va(Xo,vi),isMerged:Jo,isSlantable:Ol};s.useEffect(()=>{const l=ht.current;if(!l)return;const b=()=>{const R=l.getBoundingClientRect(),N=v?R.height:R.width;N>0&&gi(B=>Math.abs(B-N)<.5?B:N)};if(b(),typeof ResizeObserver<"u"){const R=new ResizeObserver(N=>{for(const B of N){const X=v?B.contentRect.height:B.contentRect.width;X>0&&gi(K=>Math.abs(K-X)<.5?K:X)}});return R.observe(l),()=>R.disconnect()}const S=l.ownerDocument.defaultView;if(S)return S.addEventListener("resize",b),()=>S.removeEventListener("resize",b)},[v]);const Or=s.useCallback((l,b,S)=>{const R=v?S.height:S.width;if(!(Number.isFinite(R)&&R>0))return null;const N=v?S.bottom-b:l-S.left;return Number.isFinite(N)?Math.max(0,Math.min(1,N/R)):null},[v]),xi=s.useCallback((l,b)=>{const S=ht.current;if(!S)return null;const R=Or(l,b,S.getBoundingClientRect());return R===null?null:R*100},[Or]),an=s.useRef(null),Bt=s.useRef(null),zn=s.useRef({macroLowRatio:Pt,macroHighRatio:At,isVertical:v,isMacroFirstRail:z}),Ri=s.useRef({flat:ea,macro:ta,micro:ra});s.useLayoutEffect(()=>{zn.current={macroLowRatio:Pt,macroHighRatio:At,isVertical:v,isMacroFirstRail:z},Ri.current={flat:ea,macro:ta,micro:ra},ne.current=e,vt.current=[Se,ge],zo.current=si,Ve.current=Pe,Xe.current=be});const Di=(l,b)=>{const S=zn.current;Go.current?.setAttribute("d",ha(l,b,S.isVertical,S.isMacroFirstRail))},Nl=(l,b,S)=>{const R=Ri.current;return l==="flat"?ms(b*100,S*100,R.flat).placements:Sa(l,b,S,l==="macro"?R.macro:R.micro).placements},sn=(l,b,S)=>{const R=ht.current;if(!R)return;an.current={rail:l,lowRatio:b,highRatio:S},pc(R,l,b,S);const N=Nl(l,b,S);N!==null&&gc(R,l,N),l==="macro"&&Di(b,S)},br=s.useCallback(()=>{Bt.current!==null&&(clearTimeout(Bt.current),Bt.current=null);const l=ht.current;l&&(l.removeAttribute(da),l.style.removeProperty(ma))},[]),Mi=()=>{const l=ht.current;if(an.current===null||!l){an.current=null;return}an.current=null,Bt.current!==null&&clearTimeout(Bt.current),l.style.setProperty(ma,`${Ji}ms`),l.setAttribute(da,"true"),wc(l),Di(zn.current.macroLowRatio,zn.current.macroHighRatio),Bt.current=setTimeout(()=>{Bt.current=null,l.removeAttribute(da),l.style.removeProperty(ma)},Ji)};s.useLayoutEffect(()=>{const l=an.current;l!==null&&sn(l.rail,l.lowRatio,l.highRatio)}),s.useEffect(()=>()=>{Bt.current!==null&&clearTimeout(Bt.current)},[]);const Nr=s.useRef(null),Vr=s.useRef(null),Ot=s.useRef(null),na=s.useRef(null),ln=s.useRef(null),rr=s.useCallback(()=>Nr.current!==null||Vr.current!==null,[]),yi=l=>{if(i)return;if(D){const me=Vr.current;if(!me||l.pointerId!==me.pointerId||!ht.current)return;const Lt=Or(l.clientX,l.clientY,ht.current.getBoundingClientRect());if(Lt===null)return;if(me.handle==="macro-low"||me.handle==="macro-high"||me.handle==="macro-connect"){const[Qe,Fe,Ft]=al(me.handle,Lt,me.startPointerRatio,me.startMacroLowRatio,me.startMacroHighRatio);sn("macro",Qe,Fe),Ft!==Xe.current&&(Xe.current=Ft,je(Ft),zt(Ft));let Vt,wt,Kt;if(Jt){const Gt=oo(Ae,c,a,Qe,d),hn=Math.max(Gt,oo(Ae,c,a,Fe,d));wt=Ae[Gt],Kt=Ae[hn],Vt=Y(c,wt,d)}else Vt=li(Qe),wt=oe(c,Vt,d),Kt=oe(c,li(Fe),d);Ee.show(wt,Kt);const nr=`${wt.getTime()}_${Kt.getTime()}`;nr!==na.current&&(na.current=nr,pr(wt,Kt));const[fn,sc]=yt(c,g,[wt,Kt],r,n,d),Jn=Y(g,fn,d),eo=Y(g,sc,d),qi=we?Uo(Jn,eo):[],Xi={kind:"range",min:Jn,max:eo};let Sr,xr;if(me.handle==="macro-connect"){const Gt=Vt-me.startMacroLowEnc,hn=po("pan",Xi,as(g,me.initialMicroLowEnc,c,Gt,d),as(g,me.initialMicroHighEnc,c,Gt,d));if(hn===null)return;Sr=oe(g,hn[0],d),xr=oe(g,hn[1],d)}else{const Gt=po("resize",Xi,me.initialMicroLowEnc,me.initialMicroHighEnc);if(Gt===null)return;Sr=oe(g,Gt[0],d),xr=oe(g,Gt[1],d)}const Zi=er(Sr,qi,Jn,eo),lc=Math.max(Zi,er(xr,qi,Jn,eo));Sr=oe(g,Zi,d),xr=oe(g,lc,d),ie.show(Sr,xr);const Qi=`${Sr.getTime()}_${xr.getTime()}`;Qi!==ln.current&&(ln.current=Qi,St(Sr,xr))}else if(me.handle==="micro-low"||me.handle==="micro-high"||me.handle==="micro-connect"||me.handle==="micro-point"){const[Qe,Fe,Ft]=il(me.handle,Lt,me.startPointerRatio,me.startMicroLowRatio,me.startMicroHighRatio);sn("micro",Qe,Fe),Ft!==Xe.current&&(Xe.current=Ft,je(Ft),zt(Ft));let Vt,wt;if(Et){const nr=oo(xe,g,a,Qe,d),fn=Math.max(nr,oo(xe,g,a,Fe,d));Vt=xe[nr],wt=xe[fn]}else{const nr=er(oe(g,Math.round(We+Qe*jn),d),Lr,We,tt),fn=Math.max(nr,er(oe(g,Math.round(We+Fe*jn),d),Lr,We,tt));Vt=oe(g,nr,d),wt=oe(g,fn,d)}ie.show(Vt,wt);const Kt=`${Vt.getTime()}_${wt.getTime()}`;Kt!==ln.current&&(ln.current=Kt,St(Vt,wt))}return}const b=Nr.current;if(!b||l.pointerId!==b.pointerId||!ht.current)return;const S=ht.current.getBoundingClientRect(),R=v?l.clientY:l.clientX,N=v?S.height:S.width;if(!(Number.isFinite(N)&&N>0))return;if(b.handle==="connect"){const me=v?(b.startPointerPos-R)/N:(R-b.startPointerPos)/N,[Lt,Qe]=za(me,b.startLowRatio,b.startHighRatio);sn("flat",Lt,Qe);const Fe=Xs({posDiffPct:me,startLowVal:b.startLowVal,startHighVal:b.startHighVal,rangeMin:k,rangeMax:U,isDiscrete:L,sortedAllowedDates:M,snapMode:a,unit:t,yearStartMonth:d});if(Ot.current&&Ot.current[0]===Fe[0]&&Ot.current[1]===Fe[1])return;Ot.current=Fe,gt(Fe),tr(Fe[0],Fe[1],!1);return}const B=Or(l.clientX,l.clientY,S);if(B===null)return;const[X,K]=So(F?"point":b.handle,B,b.startLowRatio,b.startHighRatio);sn("flat",X,K);const he=Ko(B*100),[Re,Oe]=Ta(b.handle,he,b.startLowVal,b.startHighVal,k,U,F);if((!Ot.current||Ot.current[0]!==Re||Ot.current[1]!==Oe)&&(Ot.current=[Re,Oe],gt([Re,Oe]),tr(Re,Oe,!1)),!F&&(b.handle==="low"||b.handle==="high")){const me=$o(b.handle,B,b.startLowRatio,b.startHighRatio);Ve.current!==me&&(Ve.current=me,st(me),Ge(me))}},Ei=()=>{Mi(),na.current=null,ln.current=null,Vr.current=null,Xe.current=null,je(null),Ee.release(),ie.release(),ci(Un.current),ci(Wn.current)},Pi=()=>{Mi();const l=Ot.current??it;l&&(tr(l[0],l[1],!0),q(l)),Ot.current=null,gt(null),Nr.current=null,Ve.current=null,st(null)},Li=l=>{if(D){const S=Vr.current;if(!S||l.pointerId!==S.pointerId)return;Ei();return}const b=Nr.current;!b||l.pointerId!==b.pointerId||Pi()},$i=()=>{Vr.current!==null&&Ei(),Nr.current!==null&&Pi()},oa=s.useRef(yi),Ti=s.useRef(Li),Ci=s.useRef($i);s.useLayoutEffect(()=>{oa.current=yi,Ti.current=Li,Ci.current=$i});const ki=s.useRef(D);s.useEffect(()=>{ki.current!==D&&(ki.current=D,Ci.current())},[D]);const Ii=Pe!==null||be!==null;s.useEffect(()=>{if(!Ii)return;const l=on.current?.ownerDocument.defaultView;if(!l)return;const b=R=>oa.current(R),S=R=>Ti.current(R);return l.addEventListener("pointermove",b),l.addEventListener("pointerup",S),l.addEventListener("pointercancel",S),l.addEventListener("lostpointercapture",S),()=>{l.removeEventListener("pointermove",b),l.removeEventListener("pointerup",S),l.removeEventListener("pointercancel",S),l.removeEventListener("lostpointercapture",S)}},[Ii]);const aa=s.useCallback((l,b,S,R)=>{br(),gs(l,b),Nr.current={pointerId:b,handle:S,startPointerPos:R,startLowVal:Se,startHighVal:ge,startLowRatio:wr(Se)/100,startHighRatio:wr(ge)/100},Ve.current=S,st(S),S!=="connect"&&Ge(S)},[Se,ge,wr]),Ai=s.useCallback((l,b,S,R)=>{ne.current.mode==="vernier"&&(br(),gs(l,b),Vr.current={pointerId:b,handle:S,startPointerRatio:R,startMacroLowRatio:Pt,startMacroHighRatio:At,startMicroLowRatio:Cr,startMicroHighRatio:nn,startMacroLowEnc:Ze,initialMicroLowEnc:Be,initialMicroHighEnc:rt},Xe.current=S,je(S),zt(S))},[Pt,At,Cr,nn,Ze,Be,rt]),Oi=l=>b=>{if(i||rr())return;b.stopPropagation(),b.preventDefault(),Ge(l);const S=v?b.clientY:b.clientX;aa(b.currentTarget,b.pointerId,l,S)},Ni=l=>()=>{i||Ve.current!==null||Ge(l)},Bn=l=>()=>{i||Xe.current!==null||zt(l)},_r=l=>b=>{if(i||rr())return;b.stopPropagation(),b.preventDefault();const S=ht.current;if(!S)return;const R=Or(b.clientX,b.clientY,S.getBoundingClientRect());R!==null&&Ai(b.currentTarget,b.pointerId,l,R)},Vl=l=>{if(i||P||rr())return;l.stopPropagation(),l.preventDefault();const b=v?l.clientY:l.clientX;aa(l.currentTarget,l.pointerId,"connect",b)},_l=l=>{if(i||rr())return;if(D){const K=ht.current;if(!K)return;const he=K.getBoundingClientRect(),Re=Or(l.clientX,l.clientY,he);if(Re===null)return;const Oe=v?l.clientX-(he.left+he.width/2):l.clientY-(he.top+he.height/2),me=ol(Re,Oe,Pt,At,Cr,nn,Ct,void 0,!P,O?"point":"range");Ai(l.currentTarget,l.pointerId,me,Re),oa.current(l.nativeEvent);return}const b=xi(l.clientX,l.clientY);if(b===null)return;const S=Ko(b);let R="low";if(!F){const K=Math.abs(S-Se),he=Math.abs(S-ge);K<he?R="low":he<K?R="high":R=S>ge?"high":"low"}Ge(R);const[N,B]=Ta(R,S,Se,ge,k,U,F);gt([N,B]),tr(N,B,!0);const X=v?l.clientY:l.clientX;aa(l.currentTarget,l.pointerId,R,X)},Yl=l=>{if(i||D||Pe!==null)return;const b=xi(l.clientX,l.clientY);if(b===null)return;const S=Ko(b);C(S),ze(wr(S))},Hl=()=>{C(null),ze(null)},Vi=l=>b=>{if(i||rr())return;Ge(l);const S=Zs(b.key,l,Se,ge,k,U,F,1);S&&(b.preventDefault(),br(),He||q(S),tr(S[0],S[1],!0))},Yr=(l,b,S)=>{if(fe===null)return;const[R,N]=yt(c,g,[l,b],r,n,d),B=Y(g,R,d),X=Y(g,N,d),K=we?Uo(B,X):[],he=po(S,{kind:"range",min:B,max:X},Y(g,fe[0],d),Y(g,fe[1],d));if(he===null)return;const Re=er(oe(g,he[0],d),K,B,X),Oe=Math.max(Re,er(oe(g,he[1],d),K,B,X));St(oe(g,Re,d),oe(g,Oe,d),!0)},Fn=l=>b=>{if(i||!D||e.mode!=="vernier"||rr())return;zt(l);let S=0,R=!1,N=!1;switch(b.key){case"ArrowRight":case"ArrowUp":S=1;break;case"ArrowLeft":case"ArrowDown":S=-1;break;case"PageUp":S=5;break;case"PageDown":S=-5;break;case"Home":R=!0;break;case"End":N=!0;break;default:return}if(b.preventDefault(),br(),l==="macro-low"){const B=oe(c,Ze,d),X=oe(c,lt,d);if(Jt){const Re=pn(Ae,c,B,Ae[0],X,S,R,N,d);if(Re===Me(Ae,B,c,d))return;const Oe=Ae[Re];pr(Oe,X,!0),Yr(Oe,X,"resize");return}let K;if(R?K=pt:N?K=lt:K=Math.max(pt,Math.min(lt,Ze+S)),K===Ze)return;const he=oe(c,K,d);pr(he,X,!0),Yr(he,X,"resize")}else if(l==="macro-high"){const B=oe(c,Ze,d),X=oe(c,lt,d);if(Jt){const Re=pn(Ae,c,X,B,Ae[Ae.length-1],S,R,N,d);if(Re===Me(Ae,X,c,d))return;const Oe=Ae[Re];pr(B,Oe,!0),Yr(B,Oe,"resize");return}let K;if(R?K=Ze:N?K=It:K=Math.max(Ze,Math.min(It,lt+S)),K===lt)return;const he=oe(c,K,d);pr(B,he,!0),Yr(B,he,"resize")}else if(l==="micro-low"){const B=oe(g,Be,d),X=oe(g,rt,d);if(Et){const he=pn(xe,g,B,xe[0],X,S,R,N,d);if(he===Me(xe,B,g,d))return;St(xe[he],X,!0);return}let K;if(R?K=We:N?K=rt:K=Math.max(We,Math.min(rt,Be+S)),K===Be)return;St(oe(g,K,d),X,!0)}else if(l==="micro-high"){const B=oe(g,Be,d),X=oe(g,rt,d);if(Et){const he=pn(xe,g,X,B,xe[xe.length-1],S,R,N,d);if(he===Me(xe,X,g,d))return;St(B,xe[he],!0);return}let K;if(R?K=Be:N?K=tt:K=Math.max(Be,Math.min(tt,rt+S)),K===rt)return;St(B,oe(g,K,d),!0)}else if(l==="micro-point"){const B=oe(g,Be,d);if(Et){const K=pn(xe,g,B,xe[0],xe[xe.length-1],S,R,N,d);if(K===Me(xe,B,g,d))return;ui(xe[K],!0);return}let X;if(R?X=We:N?X=tt:X=Math.max(We,Math.min(tt,Be+S)),X===Be)return;ui(oe(g,X,d),!0)}},jl=l=>{if(e.mode!=="vernier")return;if(br(),Jt){const X=Ae.length-1,K=Me(Ae,hr,c,d),he=Me(Ae,gr,c,d),Re=he-K;let Oe=K+l,me=he+l;if(l<0&&Oe<0?(Oe=0,me=Math.min(X,Re)):l>0&&me>X&&(me=X,Oe=Math.max(0,X-Re)),Oe===K&&me===he)return;const Lt=Ae[Oe],Qe=Ae[me];pr(Lt,Qe,!0),Yr(Lt,Qe,"pan");return}const b=lt-Ze;let S=Ze+l,R=lt+l;if(l<0&&S<pt?(S=pt,R=Math.min(It,S+b)):l>0&&R>It&&(R=It,S=Math.max(pt,R-b)),S===Ze&&R===lt)return;const N=oe(c,S,d),B=oe(c,R,d);pr(N,B,!0),Yr(N,B,"pan")},ia=s.useCallback(l=>{const b=ne.current;if(!(b.disabled||rr()))if(br(),b.mode==="point"){const S=Math.max(k,Math.min(U,Se+l));He||q([S,S]),tr(S,S,!0)}else if(b.mode==="vernier"){if(Et){const Re=xe.length-1,Oe=Me(xe,$r,g,d),me=Me(xe,Tr,g,d),Lt=me-Oe;let Qe=Oe+l,Fe=me+l;l<0&&Qe<0?(Qe=0,Fe=Math.min(Re,Lt)):l>0&&Fe>Re&&(Fe=Re,Qe=Math.max(0,Re-Lt)),(Qe!==Oe||Fe!==me)&&St(xe[Qe],xe[Fe],!0);return}const S=Be,R=rt,N=We,B=tt,X=R-S;let K=S+l,he=R+l;l<0&&K<N?(K=N,he=Math.min(B,K+X)):l>0&&he>B&&(he=B,K=Math.max(N,he-X)),(K!==S||he!==R)&&St(oe(g,K,d),oe(g,he,d),!0)}else{const S=ge-Se;let R=Se+l,N=ge+l;l<0&&R<k?(R=k,N=Math.min(U,R+S)):l>0&&N>U&&(N=U,R=Math.max(k,N-S)),R<=N&&(He||q([R,N]),tr(R,N,!0))}},[Se,ge,k,U,He,tr,St,Be,rt,We,tt,g,Et,xe,$r,Tr,br,d]),_i=l=>!i&&ga(on.current,l),Yi=(l,b)=>{const S=di.current,R=ht.current,N=on.current;if(i||S===null||R===null||N===null||!Lc(S,N,mi.current,v,l,b))return null;const B=R.getBoundingClientRect();return Math.abs(v?l-(B.left+B.width/2):b-(B.top+B.height/2))},Hi=l=>{if(i||rr())return;const b=nl(l.deltaX,l.deltaY,v);if(b===0)return;l.preventDefault();const S=l.target,R=ga(fi.current,S)||ga(hi.current,S);if(!D||R){ia(b);return}const N=ht.current;if(!N)return;const B=N.getBoundingClientRect(),X=v?l.clientX-(B.left+B.width/2):l.clientY-(B.top+B.height/2);if(qa(X,Ct)==="macro"){jl(b);return}ia(b)},Kn=s.useRef({ownsWheelHit:_i,distanceToRailPx:Yi,stepFromRangeAreaWheel:Hi});s.useLayoutEffect(()=>{Kn.current={ownsWheelHit:_i,distanceToRailPx:Yi,stepFromRangeAreaWheel:Hi}});const cn=s.useRef(null);s.useEffect(()=>{const l=on.current?.ownerDocument.defaultView??null,b=cn.current;if(b!==null&&b.view===l)return;if(b?.unregister(),l===null){cn.current=null;return}const S=Tc(l,{ownsHit:R=>Kn.current.ownsWheelHit(R),distanceToRailPx:(R,N)=>Kn.current.distanceToRailPx(R,N),step:R=>Kn.current.stepFromRangeAreaWheel(R)});cn.current={view:l,unregister:S}}),s.useEffect(()=>()=>{cn.current?.unregister(),cn.current=null},[]);const Gn=wr(Se),qn=wr(ge),sa=W(Se),la=W(ge),ca=ms(Gn,qn,ea),un=ca.slant,dn=Pe==="low"||Pe!=="high"&&ft==="low",mn=!F&&(Pe==="high"||Pe!=="low"&&ft==="high"),Ul=Qo&&Ue!=="macro-low",Wl=Qo&&Ue==="macro-low",zl=Jo&&Ue!=="micro-low",Bl=Jo&&Ue==="micro-low",Hr=Sa("macro",Pt,At,ta),jr=Sa("micro",Cr,nn,ra),Fl=Math.min(Gn,qn),Kl=Math.max(Gn,qn),[ji,Ui]=Rn.flat,[Gl,ql]=Rn.macro,[Xl,Zl]=Rn.micro,Wi=or(ji,Gn),zi=or(Ui,qn),ua=or(ji,Fl),Bi=`calc(${or(Ui,Kl)} - ${ua})`,Ur=or(Gl,Pt*100),Xn=or(ql,At*100),Wr=or(Xl,Cr*100),Zn=or(Zl,nn*100),Ql=v?{bottom:ua,height:Bi,top:"auto",left:"0",right:"0"}:{left:ua,width:Bi,top:"0",bottom:"0"},Jl=Math.max(.01,At-Pt),Fi=Math.max(.06,Math.min(.25,.28*Math.sqrt(Jl))),ec=v?{bottom:Wi,left:"50%",transform:"translate(-50%, 50%)",zIndex:dn?40:30}:{left:Wi,top:"50%",transform:"translate(-50%, -50%)",zIndex:dn?40:30},tc=v?{bottom:zi,left:"50%",transform:"translate(-50%, 50%)",zIndex:mn?40:30}:{left:zi,top:"50%",transform:"translate(-50%, -50%)",zIndex:mn?40:30},rc=v?{bottom:`${Z}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Z}%`,top:"50%",transform:"translate(-50%, -50%)"},Ki=dt!==null?W(dt):null,nc=h!=="hover"&&dt!==null&&(dt===Se||!F&&dt===ge),oc=D?Be>ii:Se>k,ac=D?rt<Wo:ge<U,Qn=eu(D?[{side:z?"before":"after",box:wo(wi,bi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:Hr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:Hr.slant.lowOffsetX}},{side:z?"after":"before",box:O?Xo:wo(Xo,vi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:jr.slant.lowAngleDeg,centreOffsetPx:null,alongPushPx:jr.slant.lowOffsetX}}]:[{side:v||f==="top"?"before":"after",box:F?Ar:wo(Ar,pi),...v?{reach:"inline-size"}:{reach:"rotated",angleDeg:un.lowAngleDeg,centreOffsetPx:un.lowOffsetY,alongPushPx:un.lowOffsetX}}]),ic=Qn===void 0?e.style:{...e.style,...Qn.style};s.useLayoutEffect(()=>{mi.current=Qn===void 0?0:Qn.mainPx});const Nt=O?"micro-point":"micro-low",vr=i?"cursor-not-allowed opacity-50":"cursor-pointer",Gi=l=>{const b=v?"vertical":"horizontal",S=l==="decrease",R=v?!S:S;return $.jsx(yr,{ref:S?fi:hi,neighbour:"rail",direction:tu[b][l],disabled:i,canStep:S?oc:ac,onStep:()=>ia(S?-1:1),ariaLabel:S?ae.decrease:ae.increase,className:`period-slider-stepper-btn ${ru[b][l]} ${hs[b][R?"leading":"trailing"]}`})};return $.jsxs("div",{ref:on,style:ic,className:`period-slider grid select-none place-items-center ${nu[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":p,children:[$.jsx("div",{ref:di,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),m&&Gi(v?"increase":"decrease"),$.jsx("div",{ref:ht,"data-testid":"period-slider-track","data-orientation":v?"vertical":"horizontal","data-vernier-orientation":D?Ct:void 0,className:`period-slider-track relative touch-none rounded-full ${hs[v?"vertical":"horizontal"][m?"rail":"railOnly"]} ${vr}`,onPointerDown:_l,onPointerMove:Yl,onPointerLeave:Hl,children:D?$.jsxs($.Fragment,{children:[Pr&&(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:se,x1:"0",y1:"0",x2:"1",y2:"0",children:[$.jsx("stop",{offset:"0%",stopColor:z?J.macro:J.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:z?J.micro:J.macro,stopOpacity:Fi})]})}),$.jsx("path",{ref:Go,"data-testid":"period-slider-vernier-projection",d:ha(Pt,At,v,z),fill:`url(#${se})`})]}):$.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:se,x1:"0",y1:"0",x2:"0",y2:"1",children:[$.jsx("stop",{offset:"0%",stopColor:z?J.macro:J.micro,stopOpacity:"0.28"}),$.jsx("stop",{offset:"100%",stopColor:z?J.micro:J.macro,stopOpacity:Fi})]})}),$.jsx("path",{ref:Go,"data-testid":"period-slider-vernier-projection",d:ha(Pt,At,v,z),fill:`url(#${se})`})]})),!P&&$.jsxs($.Fragment,{children:[$.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:v?{bottom:`calc(${Ur} - 8px)`,height:`calc(${Xn} - ${Ur} + 16px)`}:{left:`calc(${Ur} - 8px)`,width:`calc(${Xn} - ${Ur} + 16px)`},onPointerDown:_r("macro-connect")}),!O&&$.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:v?{bottom:`calc(${Wr} - 8px)`,height:`calc(${Zn} - ${Wr} + 16px)`}:{left:`calc(${Wr} - 8px)`,width:`calc(${Zn} - ${Wr} + 16px)`},onPointerDown:_r("micro-connect")})]}),rn&&$.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":ae.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Ml,"aria-valuemax":lt,"aria-valuenow":Ze,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(hr,c,"period"):Rr(c,hr,H,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Ur,left:z?0:"auto",right:z?"auto":0,transform:z?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:be==="macro-low"||Ue==="macro-low"?30:15}:{left:Ur,top:z?0:"auto",bottom:z?"auto":0,transform:z?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:be==="macro-low"||Ue==="macro-low"?30:15},onPointerDown:_r("macro-low"),onKeyDown:Fn("macro-low"),onFocus:Bn("macro-low"),"data-active":be==="macro-low"?"true":void 0,"data-front":Ue==="macro-low"?"true":void 0,"data-vernier-pos":v?z?"left":"right":z?"top":"bottom","data-handle-type":"macro-low",children:[$.jsx(xn,{type:"macro",isTop:z,isVertical:v,isLeft:z}),I&&$.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":Ul?"true":void 0,"data-slanted":Hr.slant.isSlanted?"true":void 0,ref:Ll,style:Hr.lowStyle,children:nt(c,hr,H,w)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Ze,"aria-valuemax":yl,"aria-valuenow":lt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(gr,c,"period"):Rr(c,gr,H,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Xn,left:z?0:"auto",right:z?"auto":0,transform:z?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:be==="macro-high"||Ue==="macro-high"?30:15}:{left:Xn,top:z?0:"auto",bottom:z?"auto":0,transform:z?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:be==="macro-high"||Ue==="macro-high"?30:15},onPointerDown:_r("macro-high"),onKeyDown:Fn("macro-high"),onFocus:Bn("macro-high"),"data-active":be==="macro-high"?"true":void 0,"data-front":Ue==="macro-high"?"true":void 0,"data-vernier-pos":v?z?"left":"right":z?"top":"bottom","data-handle-type":"macro-high",children:[$.jsx(xn,{type:"macro",isTop:z,isVertical:v,isLeft:z}),I&&$.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":Wl?"true":void 0,"data-slanted":Hr.slant.isSlanted?"true":void 0,ref:$l,style:Hr.highStyle,children:nt(c,gr,H,w)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":O?ae.microSelectedDate:ae.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":ii,"aria-valuemax":O?Wo:rt,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText($r,g,"period"):Rr(g,$r,de,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Wr,left:z?"auto":0,right:z?0:"auto",transform:z?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:be===Nt||Ue===Nt?30:20}:{left:Wr,top:z?"auto":0,bottom:z?0:"auto",transform:z?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:be===Nt||Ue===Nt?30:20},onPointerDown:_r(Nt),onKeyDown:Fn(Nt),onFocus:Bn(Nt),"data-active":be===Nt?"true":void 0,"data-front":Ue===Nt?"true":void 0,"data-vernier-pos":v?z?"right":"left":z?"bottom":"top","data-handle-type":Nt,children:[$.jsx(xn,{type:"micro",isTop:!z,isVertical:v,isLeft:!z}),I&&$.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":zl?"true":void 0,"data-slanted":jr.slant.isSlanted?"true":void 0,ref:Tl,style:jr.lowStyle,children:nt(g,$r,de,w)})]}),!O&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Be,"aria-valuemax":Wo,"aria-valuenow":rt,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Tr,g,"period"):Rr(g,Tr,de,w),"aria-orientation":v?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${v?"is-vertical":""} group absolute touch-none ${v?z?"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":z?"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 ${vr}`,style:v?{bottom:Zn,left:z?"auto":0,right:z?0:"auto",transform:z?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:be==="micro-high"||Ue==="micro-high"?30:20}:{left:Zn,top:z?"auto":0,bottom:z?0:"auto",transform:z?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:be==="micro-high"||Ue==="micro-high"?30:20},onPointerDown:_r("micro-high"),onKeyDown:Fn("micro-high"),onFocus:Bn("micro-high"),"data-active":be==="micro-high"?"true":void 0,"data-front":Ue==="micro-high"?"true":void 0,"data-vernier-pos":v?z?"right":"left":z?"bottom":"top","data-handle-type":"micro-high",children:[$.jsx(xn,{type:"micro",isTop:!z,isVertical:v,isLeft:!z}),I&&$.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":Bl?"true":void 0,"data-slanted":jr.slant.isSlanted?"true":void 0,ref:Cl,style:jr.highStyle,children:nt(g,Tr,de,w)})]})]}):$.jsxs($.Fragment,{children:[!P&&$.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Ql,onPointerDown:Vl}),j&&L&&M.length>1&&$.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:M.map((l,b)=>{const S=Y(t,l,d),R=wr(b),N=v?{bottom:`${R}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${R}%`,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:N},`tick-${S}`)})}),!i&&dt!==null&&Z!==null&&Pe===null&&Ki&&$.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:rc,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":nc?"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:nt(t,Ki,e.formatLabel,w)})]}),$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":F?ae.selectedDate:ae.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":k,"aria-valuemax":F?U:ge,"aria-valuenow":Se,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(sa,t,"period"):Rr(t,sa,e.formatLabel,w),"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 ${vr}`,style:ec,onPointerDown:Oi("low"),onKeyDown:Vi("low"),onFocus:Ni("low"),"data-active":Pe==="low"?"true":void 0,"data-front":dn?"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 ${Pe==="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":un.isSlanted?"true":void 0,"data-front":dn?"true":void 0,"data-duplicate":Zo&&!dn?"true":void 0,ref:El,style:ca.lowStyle,children:nt(t,sa,e.formatLabel,w)})]}),!F&&$.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ae.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Se,"aria-valuemax":U,"aria-valuenow":ge,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(la,t,"period"):Rr(t,la,e.formatLabel,w),"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 ${vr}`,style:tc,onPointerDown:Oi("high"),onKeyDown:Vi("high"),onFocus:Ni("high"),"data-active":Pe==="high"?"true":void 0,"data-front":mn?"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 ${Pe==="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":un.isSlanted?"true":void 0,"data-front":mn?"true":void 0,"data-duplicate":Zo&&!mn?"true":void 0,ref:Pl,style:ca.highStyle,children:nt(t,la,e.formatLabel,w)})]})]})}),m&&Gi(v?"decrease":"increase")]})},Je=e=>e.getTime(),ll=(e,t)=>!($t(e)&&$t(t))||e.length!==2||t.length!==2?!1:Dt(e[0],Je)===Dt(t[0],Je)&&Dt(e[1],Je)===Dt(t[1],Je),ao=(e,t)=>e===void 0||t===void 0?e===t:ll(e,t),xa=(e,t)=>{if(e===t)return!0;if(!($t(e)&&$t(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(Dt(e[r],Je)!==Dt(t[r],Je))return!1;return!0},cl=(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},au=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||Dt(e.minDate,Je)!==Dt(t.minDate,Je)||Dt(e.maxDate,Je)!==Dt(t.maxDate,Je)||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||!cl(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Co(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!xa(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(mt(e.value,Je)!==mt(t.value,Je)||mt(e.defaultValue,Je)!==mt(t.defaultValue,Je)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!ao(e.range,t.range)||!ao(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!ao(e.microRange,t.microRange)||!ao(e.defaultMicroRange,t.defaultMicroRange)||mt(e.microValue,Je)!==mt(t.microValue,Je)||mt(e.defaultMicroValue,Je)!==mt(t.defaultMicroValue,Je)||!ll(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||!xa(e.macroAllowedDates,t.macroAllowedDates)||!xa(e.microAllowedDates,t.microAllowedDates)):!1,ul=s.memo(ou,au);ul.displayName="PeriodSlider";const ps=2,Te=-1,xt=e=>Y("day",e),Tn=e=>oe("day",e),wn=e=>`${Oo(e.getFullYear())}-${String(e.getMonth()+1).padStart(ps,"0")}-${String(e.getDate()).padStart(ps,"0")}`,iu=(e,t,r,n)=>{const o=xt(e),a=xt(t),i=a>=o?a-o+1:0,u=h=>Tn(a-h),m={kind:"range",min:o,max:a};return{count:i,dateAt:u,labelAt:h=>nt("day",u(h),n,r),indexOf:h=>{const f=xt(h);return f<o||f>a?Te:a-f},nearestIndexOf:h=>{if(i===0)return Te;const f=Pn(m,xt(h));return f===null?Te:a-f}}},su=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,u=x=>e[n-x],m={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},h=x=>{const v=x.getTime();let P=r,j=n;for(;P<=j;){const p=P+j>>1,w=e[p].getTime();if(w===v)return n-p;w<v?P=p+1:j=p-1}return Te},f=x=>x===null?Te:h(Tn(x));return{count:i,dateAt:u,labelAt:x=>nt("day",u(x),a,o),indexOf:h,nearestIndexOf:x=>f(Pn(m,xt(x)))}},lu={count:0,dateAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${E(e)})`)},labelAt:e=>{throw new RangeError(`DateSelector: the option domain is empty (requested index ${E(e)})`)},indexOf:()=>Te,nearestIndexOf:()=>Te},cu=(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}},uu=(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))},du={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},mu={month:2,day:2},ws={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},bs=new Map,fu=(e,t)=>{const r=`${e}\0${t}`,n=bs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,du[e]);return bs.set(r,o),o},hu=(e,t,r)=>{if(r!==void 0)return fu(e,r).format(t);const n=new Date(t.getTime());return e==="year"?Oo(ws.year(n)):String(ws[e](n)).padStart(mu[e],"0")},dl=(e,t,r,n)=>{if(Ce("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${E(r)})`);return ye(e)?r==="part"?hu(t,e,n):nt(t,e,void 0,n):""},gu=12,_o=(e,t,r)=>{const n=Vn(e,t,r);return n===null?Number.NaN:n*gu+r},Xa=(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)};class ml{held;writeCount=0;constructor(t){this.held=t}get current(){return this.held}set current(t){this.held=t,this.writeCount+=1}get writes(){return this.writeCount}commit(t,r){this.writeCount===r&&(this.held=t)}}function fl(e,t){const[r]=s.useState(()=>t(e)),n=r.writes;return s.useInsertionEffect(()=>{r.commit(e,n)}),r}function ut(e){return fl(e,t=>new ml(t))}const pu={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},wu=["shift","start","end","single"],bu=["disable","clamp"],vu=["follow","keep"],vs={day:{day:1},month:{month:1,year:12},year:{year:1}},Ss=new WeakMap,Ca=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${E(r)})`)},xs=(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: ${E(a)})`)},Er=(e,t,r,n)=>{Ca(e,t,r),xs(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Ca(e,a,i),xs(e,a,i,pu[n]);const{motion:u,edge:m,window:h}=i;if(n!=="vernierPoint"&&(typeof u!="string"||!wu.includes(u)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${E(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 ${E(m)} with motion ${E(u)})`);if(typeof m!="string"||!bu.includes(m))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${E(m)})`)}if(h!==void 0&&(typeof h!="string"||!vu.includes(h)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${E(h)})`)}},Za=(e,t,r)=>{if(typeof t!="object"||t===null)throw new RangeError(`${e}: stepper must be an object (received: ${E(t)})`);const{onStep:n,canStepPrevious:o,canStepNext:a}=t;if(typeof n!="function")throw new RangeError(`${e}: stepper.onStep must be a function (received: ${E(n)})`);if(typeof o!="boolean")throw new RangeError(`${e}: stepper.canStepPrevious must be a boolean (received: ${E(o)})`);if(typeof a!="boolean")throw new RangeError(`${e}: stepper.canStepNext must be a boolean (received: ${E(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`)},qt=(e,t,r,n,o)=>{if(!ye(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${E(r)})`);return qe(e,t,r,n,o,"")},hl=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=Ss.get(r),u=i?.get(a);if(u!==void 0)return u;const m=[];for(let f=0;f<r.length;f++)m.push(qt(e,`${t}[${f}]`,r[f],n,o));const h=Array.from(new Set(m)).sort((f,x)=>f-x);return i===void 0?Ss.set(r,new Map([[a,h]])):i.set(a,h),h},Su=(e,t)=>t===1?ho(e):{stepEnd:(r,n)=>fo(e,r+t*n,n),edge:r=>yn(e,r)},ka=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},Ia=(e,t,r,n,o,a)=>{if(a){const m=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:oe(n,e[0],o);return Number.isNaN(m.getTime())?null:[m,m]}const i=e[0]===t[0]?r[0]:oe(n,e[0],o),u=e[1]===t[1]?r[1]:oe(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(u.getTime())?null:[i,u.getTime()<i.getTime()?i:u]},Aa=e=>{const t="resolveSelectorSteps";Ca(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:u,rules:m}=e;Ce(t,"unit",o);const h=Qt(t,"stepUnit",e.stepUnit,o),f=vs[o][h];if(f===void 0){const d=Object.keys(vs[o]).map(re=>`"${re}"`).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: ${E(h)})`)}const x=fr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${E(n)})`);if(!$t(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${E(r)})`);Er(t,"rules",m,"motion");const v=qt(t,"selection[0]",r[0],o,x),P=qt(t,"selection[1]",r[1],o,x);if(P<v)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${E(r[0])}, end: ${E(r[1])})`);const j=a===void 0?null:qt(t,"minDate",a,o,x),p=i===void 0?null:qt(t,"maxDate",i,o,x);if(j!==null&&p!==null&&p<j)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${E(a)}, maxDate: ${E(i)})`);en(t,"allowedDates",u);const w=u===void 0?{kind:"range",min:j,max:p}:tn(hl(t,"allowedDates",u,o,x),j,p),c=Su(w,f),g=(d,re)=>{const O=La(c,v,P,d,ka(re,n));return O===null?null:Ia(O,[v,P],r,o,x,re.motion==="single")};return{previous:g(-1,m.previous),next:g(1,m.next)}},jt=(e,t)=>{const r=ut({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 xu(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function Qa(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=xu(a,o,e,n);return s.useLayoutEffect(()=>{m!==a&&i(h=>h===a?m:h)}),[m.held,u]}const bo=44,Rs=7,io=8,Ru=2,gl=10,Du=1e3,Oa=8,Ra=6,Da=4,Ma=12,bn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),xt(r)},Mu=(e,t)=>{if(e.length<Da||t.count===0)return Te;const r=Number(e.slice(0,Da));if(!Number.isInteger(r))return Te;const n=e.length>=Ra,o=n?Number(e.slice(Da,Ra)):Ma;if(o<1||o>Ma)return Te;const a=e.length>=Oa,i=a?Number(e.slice(Ra,Oa)):0,u=bn(r,o),m=(o===Ma?bn(r+1,1):bn(r,o+1))-1,h=a?u+i-1:n?u:bn(r,1),f=a?h:n?m:bn(r+1,1)-1;if(a&&(i<1||h>m))return Te;for(let x=f;x>=h;x--){const v=t.indexOf(Tn(x));if(v!==Te)return v}return Te},yu=e=>e.closest(".dark")===null?"light":"dark",Eu=(e,t,r,n)=>{const o=r-e.bottom-io,a=e.top-io,i=o>=t||o>=a,m=Math.max(bo,Math.min(t,i?o:a)),h=i?e.bottom:e.top-m,f=e.width+gl,x=Math.max(io,Math.min(e.left,n-f-io));return{top:h,left:x,width:f,height:m}},Pu=(e,t)=>e<t?e:t>0?t-1:Te,pl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:u,labels:m,onCommitIndex:h,controlClassName:f})=>{const x=s.useId(),v=s.useMemo(()=>xc(m),[m]),P=`period-slider-date-listbox-${x}`,j=s.useCallback(T=>`period-slider-date-option-${x}-${T}`,[x]),[p,w]=s.useState(!1),[c,g]=s.useState(Te),[d,re]=s.useState(null),[O,ae]=s.useState(null),J=s.useRef(null),se=s.useRef(null),ne=s.useRef(null),A=s.useRef({buffer:"",at:0}),ee=e.count,D=Pu(c,ee),M=ut(D);s.useLayoutEffect(()=>{D!==c&&g(T=>T===c?D:T)});const L=Math.min(ee,Rs)*bo,k=Math.max(1,Math.min(ee,Rs)),U=s.useCallback(()=>{const T=J.current;if(T===null)return;const ue=T.getBoundingClientRect();re(Eu(ue,L,window.innerHeight,window.innerWidth))},[L]),F=ut(p),W=s.useCallback(()=>{w(!1),g(Te),A.current={buffer:"",at:0},F.current=!1},[F]);s.useLayoutEffect(()=>()=>{F.current&&W()},[F,W]);const V=s.useCallback(T=>{a||ee===0||(g(T),w(!0),F.current=!0)},[a,ee,F]);s.useLayoutEffect(()=>{if(!p){re(null),ae(null);return}const T=J.current;return T!==null&&ae(yu(T)),U(),window.addEventListener("scroll",U,!0),window.addEventListener("resize",U),()=>{window.removeEventListener("scroll",U,!0),window.removeEventListener("resize",U)}},[p,U]),s.useEffect(()=>{if(!p)return;const T=ue=>{const pe=ue.target;pe!==null&&se.current?.contains(pe)!==!0&&J.current?.contains(pe)!==!0&&W()};return document.addEventListener("pointerdown",T,!0),()=>document.removeEventListener("pointerdown",T,!0)},[p,W]),s.useEffect(()=>{p&&(a||ee===0)&&W()},[p,a,ee,W]),s.useEffect(()=>{if(!p)return;const T=M.current;T!==Te&&ne.current?.scrollToIndex(T,{align:"center"})},[ee,p,M]);const Q=T=>{if(ee===0)return;const ue=Math.max(0,Math.min(T,ee-1));g(ue),ne.current?.scrollToIndex(ue,{align:"center"})},ce=T=>{T<0||T>=ee||(h(T),W(),J.current?.focus())},ve=ut(ce),G=T=>{if(a||J.current===null)return;const ue=D!==Te?D:t!==Te?t:r;switch(T.key){case"ArrowDown":if(T.preventDefault(),!p){V(ue);return}Q(ue+1);return;case"ArrowUp":if(T.preventDefault(),!p){V(ue);return}Q(ue-1);return;case"Home":if(!p)return;T.preventDefault(),Q(0);return;case"End":if(!p)return;T.preventDefault(),Q(ee-1);return;case"PageDown":if(!p)return;T.preventDefault(),Q(ue+k);return;case"PageUp":if(!p)return;T.preventDefault(),Q(ue-k);return;case"Enter":if(T.preventDefault(),!p){V(ue);return}ce(D!==Te?D:ue);return;case"Escape":if(!p)return;T.preventDefault(),W();return;case"Tab":p&&W();return}if(T.key.length!==1)return;const pe=T.key>="0"&&T.key<="9",at=T.key==="-"||T.key==="/"||T.key===".";if(!(pe||at))return;T.preventDefault();const $e=Date.now(),He=$e-A.current.at>Du?"":A.current.buffer,Ke=pe?`${He}${T.key}`.slice(0,Oa):He;A.current={buffer:Ke,at:$e};const q=Mu(Ke,e);if(q!==Te){if(!p){V(q);return}Q(q)}},_=s.useCallback(T=>T,[]),De=s.useCallback(()=>bo,[]),Ee=D===Te?null:j(D),ie=s.useCallback(()=>{const T=J.current;if(T===null||Ee===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",Ee),()=>{T.getAttribute("aria-activedescendant")===Ee&&T.removeAttribute("aria-activedescendant")}},[Ee]),fe=s.useCallback(T=>{const ue=T===t,pe=T===D;return $.jsx("div",{id:j(T),role:"option","aria-selected":ue,"aria-posinset":T+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":pe?"true":void 0,ref:pe?ie:void 0,className:"period-slider-date-option",style:{height:bo},onClick:()=>ve.current(T),children:e.labelAt(T)})},[e,t,D,j,ve,ie]),ke=s.useCallback(T=>(se.current=T,T.style.removeProperty("display"),()=>{se.current=null,T.style.setProperty("display","none","important")}),[]),ot=p&&d!==null&&O!==null&&ee>0,te=ot?$.jsx("div",{ref:ke,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":O,style:{top:d.top,left:d.left,width:d.width,height:d.height},onMouseDown:T=>{T.preventDefault()},children:$.jsx(ur.VirtualScroll,{ref:ne,itemCount:ee,getItem:_,getItemHeight:De,viewportSize:d.height-Ru,initialScrollIndex:D!==Te?D:void 0,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:u,labels:v,contentProps:{id:P,role:"listbox","aria-label":i},scrollBarOptions:{width:gl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:fe})}):null;return $.jsxs($.Fragment,{children:[$.jsx("input",{ref:J,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":p,"aria-controls":ot?P:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none",disabled:a,value:n,className:f,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:G,onMouseDown:T=>{a||J.current===null||(T.preventDefault(),J.current?.focus(),p?W():V(t!==Te?t:r))},onBlur:()=>{p&&W()}}),te===null?null:uc.createPortal(te,document.body)]})};pl.displayName="VirtualDateDropdown";const vn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Lu=Nn("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),$u=Nn('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Tu=31,Sn=(e,t,r)=>{if(!ye(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${E(t)})`);qe("DateSelector",e,t,"day",0,r)},ir=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},so=e=>ir(e,1,1),Ds=e=>ir(e,12,31),wl=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,Ms=(e,t,r,n)=>wl(e,t,r)&&e.getDate()===n,Ja=e=>Vn(e,"year",0)!==null,ei=e=>_o(e,"day",0),Cu=e=>Ja(e)?ei(e):Number.NaN,lo=(e,t,r)=>{if(!Ja(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: ${E(t)})${r}`)},ys=(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},ku=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedDates:f,variant:x="date",className:v="",style:P,disabled:j=!1,locale:p,labels:w,formatLocale:c,formatOption:g}=e;c!==void 0&&Vo("DateSelector","formatLocale",c);const d=x==="split-dropdown"?$u:Lu;if(t!==void 0&&Sn("value",t,""),r!==void 0&&Sn("initialDate",r,""),m!==void 0&&Sn("minDate",m,d),h!==void 0&&Sn("maxDate",h,d),x==="split-dropdown"&&(t!==void 0&&lo("value",t,""),r!==void 0&&lo("initialDate",r,""),m!==void 0&&lo("minDate",m,d),h!==void 0&&lo("maxDate",h,d)),i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: minYear must be an integer year (received: ${E(i)})`);if(u!==void 0&&!Number.isInteger(u))throw new RangeError(`DateSelector: maxYear must be an integer year (received: ${E(u)})`);if(i!==void 0&&Number.isNaN(so(i).getTime()))throw new RangeError(`DateSelector: minYear must name a year whose first day starts inside the Date range (received: ${E(i)})`);if(u!==void 0&&Number.isNaN(Ds(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${E(u)})`);if(x==="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');en("DateSelector","allowedDates",f);const re=t??r;if(re===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&&Za("DateSelector",o,t!==void 0);const O=ko(p,w),ae=t!==void 0,[J,se]=Qa(re,ae,ei,vn),ne=t?.getTime(),A=s.useMemo(()=>t!==void 0?vn(t):J,[ne,J]);if(x==="split-dropdown"&&!ae&&!Ja(A))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${E(A)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const ee=m?.getTime(),D=h?.getTime(),M=s.useMemo(()=>{const C=m?vn(m):null,Z=i!==void 0?so(i):null;return C===null?Z:Z===null||C.getTime()>=Z.getTime()?C:Z},[ee,i]),L=s.useMemo(()=>{const C=h?vn(h):null,Z=u!==void 0?Ds(u):null;return C===null?Z:Z===null||C.getTime()<=Z.getTime()?C:Z},[D,u]),k=M?.getTime()??null,U=L?.getTime()??null;if(M!==null&&L!==null&&M.getTime()>L.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${wn(M)}, upper: ${wn(L)})`);if(x!=="date"&&f===void 0&&(M===null||L===null))throw new RangeError(`DateSelector: variant=${E(x)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${x==="dropdown"?", or allowedDates":""}; the option list is never invented`);const F=s.useMemo(()=>f===void 0?null:f.map(C=>Dt(C,Z=>Z.getTime())).join(","),[f]),W=s.useMemo(()=>{if(f===void 0)return null;const C=uu(f,(Z,ze)=>Sn(`allowedDates[${Z}]`,ze,""));return{ascending:C,ascendingSerials:C.map(xt)}},[F]),V=s.useMemo(()=>W===null?null:{...W,...cu(W.ascending,M,L)},[W,k,U]),Q=s.useMemo(()=>V!==null?su(V.ascending,V.ascendingSerials,V.loIndex,V.hiIndex,c,g):M===null||L===null?lu:iu(M,L,c,g),[V,k,U,c,g]),ce=s.useMemo(()=>V!==null?{kind:"candidates",ascending:V.ascendingSerials,loIndex:V.loIndex,hiIndex:V.hiIndex}:{kind:"range",min:M===null?null:xt(M),max:L===null?null:xt(L)},[V,k,U]),ve=C=>!Number.isNaN(C.getTime())&&En(ce,xt(C)),G=C=>{if(j)return;const Z=vn(C);ve(Z)&&(ae||se(Z),n?.(Z))},_=A.getTime(),De=ve(A),Ee=s.useMemo(()=>{const C=Zt(ce,xt(A),-1);if(C===null)return null;const Z=Tn(C);return Number.isNaN(Z.getTime())?null:Z},[ce,_]),ie=s.useMemo(()=>{const C=Zt(ce,xt(A),1);if(C===null)return null;const Z=Tn(C);return Number.isNaN(Z.getTime())?null:Z},[ce,_]),fe=()=>{if(o!==void 0){o.onStep("previous");return}Ee!==null&&G(Ee)},ke=()=>{if(o!==void 0){o.onStep("next");return}ie!==null&&G(ie)},ot=C=>{if(C.target.value){const Z=cc.parseISO(C.target.value);Number.isNaN(Z.getTime())||G(Z)}},te=A.getFullYear(),T=A.getMonth()+1,ue=A.getDate(),pe=s.useCallback((C,Z)=>g?g(Z,C,"part"):dl(Z,C,"part",c),[g,c]),at=s.useMemo(()=>{if(x!=="split-dropdown"||M===null||L===null)return[];const C=[];for(let Z=L.getFullYear();Z>=M.getFullYear();Z--)C.push({value:Z,label:pe("year",so(Z))});return C},[x,k,U,pe]),$e=s.useMemo(()=>{if(x!=="split-dropdown"||M===null||L===null)return[];const C=M,Z=L,ze=te===C.getFullYear()?C.getMonth()+1:1,Se=te===Z.getFullYear()?Z.getMonth()+1:12;return ys(ze,Se,ge=>ir(te,ge,1),(ge,vt)=>wl(ge,te,vt),ge=>pe("month",ge))},[x,k,U,te,pe]),He=s.useMemo(()=>{if(x!=="split-dropdown"||M===null||L===null)return[];const C=M,Z=L,ze=te===C.getFullYear()&&T===C.getMonth()+1?C.getDate():1,Se=te===Z.getFullYear()&&T===Z.getMonth()+1?Z.getDate():Tu;return ys(ze,Se,ge=>ir(te,T,ge),(ge,vt)=>Ms(ge,te,T,vt),ge=>pe("day",ge))},[x,k,U,te,T,pe]),Ke=(C,Z,ze)=>{const Se=ir(C,Z,ze);return Ms(Se,C,Z,ze)&&ve(Se)},q=(C,Z,ze)=>{Ke(C,Z,ze)&&G(ir(C,Z,ze))},et=at.some(C=>C.value===te),it=$e.some(C=>C.value===T),gt=He.some(C=>C.value===ue),Pe=wn(A),st=x==="dropdown"?nt("day",A,g,c):"",Ve=M?wn(M):void 0,ft=L?wn(L):void 0,Ge="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 ${Mn} ${v}`,style:P,"data-variant":x,"data-out-of-range":De?void 0:"true",children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:j,canStep:o===void 0?Ee!==null:o.canStepPrevious,onStep:fe,ariaLabel:O.previousDay}),x==="dropdown"?$.jsx(pl,{domain:Q,selectedIndex:De?Q.indexOf(A):Te,openAnchorIndex:Q.nearestIndexOf(A),displayLabel:st,machineValue:Pe,disabled:j,ariaLabel:O.dateSelect,locale:p,labels:O,onCommitIndex:C=>G(Q.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"}):x==="split-dropdown"?$.jsxs("div",{className:"inline-flex items-center gap-1",children:[$.jsxs("select",{"aria-label":O.splitYear,disabled:j,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:et?te:"",onChange:C=>q(Number(C.target.value),T,ue),children:[et?null:$.jsx("option",{value:"",disabled:!0,className:Ge,children:pe("year",so(te))}),at.map(C=>$.jsx("option",{value:C.value,disabled:!Ke(C.value,T,ue),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":O.splitMonth,disabled:j,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:it?T:"",onChange:C=>q(te,Number(C.target.value),ue),children:[it?null:$.jsx("option",{value:"",disabled:!0,className:Ge,children:pe("month",ir(te,T,1))}),$e.map(C=>$.jsx("option",{value:C.value,disabled:!Ke(te,C.value,ue),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]}),$.jsxs("select",{"aria-label":O.splitDay,disabled:j,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:gt?ue:"",onChange:C=>q(te,T,Number(C.target.value)),children:[gt?null:$.jsx("option",{value:"",disabled:!0,className:Ge,children:pe("day",ir(te,T,ue))}),He.map(C=>$.jsx("option",{value:C.value,disabled:!Ke(te,T,C.value),className:"dark:bg-slate-700 dark:text-slate-100",children:C.label},C.value))]})]}):$.jsx("input",{"aria-label":O.dateSelect,disabled:j,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:Pe,min:Ve,max:ft,onChange:ot,type:"date"}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:j,canStep:o===void 0?ie!==null:o.canStepNext,onStep:ke,ariaLabel:O.nextDay}),a]})},Iu=(e,t)=>!(!Xa(e,t,t.variant==="split-dropdown"?Cu:ei)||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||!Co(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),bl=s.memo(ku,Iu);bl.displayName="DateSelector";function _n(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 Cn(e){const t=Vn(e,"month",0);return oe("month",t===null?Number.NaN:t,0)}const vl=e=>_o(e,"month",0);function Dr(e){return`${Oo(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Es=Nn("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function co(e,t,r){e!==void 0&&Sl(e,t,r)}function Sl(e,t,r){if(!ye(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${E(e)})`);qe("MonthSelector",t,e,"month",0,r)}function Ps(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`MonthSelector: ${t} must be an integer year (received: ${E(e)})`);if(Number.isNaN(_n(e,r).getTime()))throw new RangeError(`MonthSelector: ${t} must name a year whose ${r===0?"January":"December"} starts inside the Date range (received: ${E(e)})`)}}function Au(e,t){const r=e===void 0?null:_n(e,0),n=t===void 0?null:Cn(t);return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Ou(e,t){const r=e===void 0?null:_n(e,11),n=t===void 0?null:Cn(t);return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function sr(e){return e.getFullYear()*12+e.getMonth()}function Na(e){return _n(Math.floor(e/12),(e%12+12)%12)}function Ls(e){return Number.isNaN(e.getTime())?null:e}function Nu(e,t,r){const n=new Map;for(const o of e){const a=Cn(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 Vu(e,t){const r=[];for(let n=sr(e);n<=sr(t);n++)r.push(Na(n));return r}function $s(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:nt("month",e[o],r,t),value:Dr(e[o])});return n}const _u=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,variant:i="date",minYear:u,maxYear:m,minDate:h,maxDate:f,allowedMonths:x,isWarning:v=!1,className:P="",style:j,disabled:p=!1,locale:w,labels:c,formatLocale:g,formatOption:d}=e;if(g!==void 0&&Vo("MonthSelector","formatLocale",g),co(t,"value",""),co(r,"initialDate",""),co(h,"minDate",Es),co(f,"maxDate",Es),Ps(u,"minYear",0),Ps(m,"maxYear",11),en("MonthSelector","allowedMonths",x),x!==void 0)for(let q=0;q<x.length;q++)Sl(x[q],`allowedMonths[${q}]`,"");const re=t??r;if(re===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&&Za("MonthSelector",o,t!==void 0);const O=ko(w,c),ae=t!==void 0,[J,se]=Qa(re,ae,vl,Cn),ne=s.useMemo(()=>t!==void 0?Cn(t):J,[t?.getTime(),J]),A=h?.getTime(),ee=f?.getTime(),D=s.useMemo(()=>Au(u,h),[u,A]),M=s.useMemo(()=>Ou(m,f),[m,ee]),L=D?.getTime()??null,k=M?.getTime()??null;if(D!==null&&M!==null&&D>M)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Dr(D)}, upper: ${Dr(M)})`);if(i==="dropdown"&&x===void 0&&(D===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 U=x===void 0?null:x.map(q=>q.getTime()).join(","),F=s.useMemo(()=>x===void 0?null:Nu(x,D,M),[U,L,k]),W=s.useMemo(()=>{if(F!==null){const q=F.map(sr);return{kind:"candidates",ascending:q,loIndex:0,hiIndex:q.length-1}}return{kind:"range",min:D===null?null:sr(D),max:M===null?null:sr(M)}},[F,L,k]),V=q=>!Number.isNaN(q.getTime())&&En(W,sr(q)),Q=q=>{if(p)return;if(!V(q))throw new RangeError(`MonthSelector: refusing to emit ${Dr(q)}, which lies outside the selectable months`);ae||se(q);const et=q.getFullYear()*100+(q.getMonth()+1);n?.(q,et)},ce=ne.getTime(),ve=V(ne),G=s.useMemo(()=>{const q=Zt(W,sr(ne),-1);return q===null?null:Ls(Na(q))},[W,ce]),_=s.useMemo(()=>{const q=Zt(W,sr(ne),1);return q===null?null:Ls(Na(q))},[W,ce]),De=()=>{if(o!==void 0){o.onStep("previous");return}G!==null&&Q(G)},Ee=()=>{if(o!==void 0){o.onStep("next");return}_!==null&&Q(_)},ie=q=>{if(!q)return;const et=q.lastIndexOf("-");if(et<=0)return;const it=q.slice(0,et),gt=q.slice(et+1),Pe=Number(it),st=Number(gt)-1;if(!(Number.isInteger(Pe)&&Number.isInteger(st)))return;const Ve=_n(Pe,st);V(Ve)&&Q(Ve)},fe=q=>{ie(q.target.value)},ke=q=>{ie(q.target.value)},ot=Dr(ne),te=i==="dropdown"&&!ve?nt("month",ne,d,g):"",T=D?Dr(D):void 0,ue=M?Dr(M):void 0,pe=s.useMemo(()=>i!=="dropdown"?[]:F!==null?$s(F,g,d):D===null||M===null?[]:$s(Vu(D,M),g,d),[i,F,L,k,g,d]),at=ve?ot:"",$e=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",He=`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 ${$e}`,Ke=`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 ${$e}`;return $.jsxs("div",{className:`inline-flex items-center ${Mn} ${P}`,style:j,"data-out-of-range":ve?void 0:"true",children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:p,canStep:o===void 0?G!==null:o.canStepPrevious,onStep:De,ariaLabel:O.previousMonth}),i==="dropdown"?$.jsxs("select",{"aria-label":O.monthSelect,disabled:p,className:Ke,value:at,onChange:ke,children:[ve?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:te}),pe.map(q=>$.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))]}):$.jsx("input",{"aria-label":O.monthSelect,disabled:p,className:He,value:ot,min:T,max:ue,onChange:fe,type:"month"}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:p,canStep:o===void 0?_!==null:o.canStepNext,onStep:Ee,ariaLabel:O.nextMonth}),a]})},Yu=(e,t)=>!(!Xa(e,t,vl)||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||!Co(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),xl=s.memo(_u,Yu);xl.displayName="MonthSelector";const Va=Symbol("nothing handed");let ya=0;class Hu{constructor(t,r,n){this.states=t,this.base=r,this.superseded=n}states;base;superseded;drafts=new Map;handed=new Map;cells=new Set;notes=[];closed=!1;marked=!1;committed=!1;leadsTo(t){return t.every((r,n)=>r===(this.handed.has(n)?this.handed.get(n):this.states[n]))}read(t,r){return this.drafts.has(t)?this.drafts.get(t):r}write(t,r){this.drafts.set(t,r),this.cells.add(t)}hand(t,r){this.handed.set(t.slot,r),this.cells.add(t)}hasHanded(t){return this.handed.has(t)}lastHanded(t){return this.handed.get(t)}close(){this.closed=!0}}class ju{constructor(t,r,n){this.owner=t,this.setMark=n,this.slotWrites=r.map(()=>0),this.records=r.map(()=>Va),this.latest=this.open(r)}owner;setMark;latest;active=null;slotWrites;records;outbox=[];duringRender=t=>{if(typeof t!="function")throw new TypeError(`${this.owner}: duringRender(action) must be a function (received: ${E(t)})`);const r=this.latest;if(r.closed)throw new Error(`${this.owner}: duringRender(action) must be called during the host's render, after the hook call (call the returned functions directly from event handlers and effects)`);r.marked||(r.marked=!0,this.setMark(r));const n=this.active;this.active=r,ya+=1;try{t()}finally{ya-=1,this.active=n}};get pass(){if(this.active===null&&ya>0)throw new Error(`${this.owner}: a returned function was called during another hook's duringRender(action); call it inside this hook's own duringRender(action)`);return this.active}inFlight(t){return!this.latest.committed&&this.latest.hasHanded(t)}handedTo(t){return this.records[t]}recordHanded(t,r){this.records[t]=r}begin(t,r){const n=this.latest;return!n.committed&&r===n&&n.leadsTo(t)?(n.closed&&(n.closed=!1,this.closeAtEndOfRun(n)),n):(n.close(),this.latest=this.open(t),this.latest)}open(t){const r=t.map((o,a)=>this.records[a]!==Va&&this.records[a]!==o),n=new Hu(t,[...this.slotWrites],r);return this.closeAtEndOfRun(n),n}closeAtEndOfRun(t){queueMicrotask(()=>t.close())}applies(t,r){return!t.superseded[r]&&t.base[r]===this.slotWrites[r]}commit(t,r){t.close(),t.committed=!0;for(const n of t.cells)this.applies(t,n.slot)&&n.adopt(t,r);for(const n of t.notes)this.applies(t,n.slot)&&this.outbox.push(n.send);this.outbox.length>0&&queueMicrotask(()=>this.deliver())}deliver(){for(let t=this.outbox.shift();t!==void 0;t=this.outbox.shift())t()}wrote(t){this.deliver(),this.slotWrites[t]+=1}notify(t,r){const n=this.pass;if(n!==null){n.notes.push({slot:t,send:r});return}this.deliver(),r()}}class Uu extends ml{constructor(t,r,n){super(t),this.scope=r,this.slot=n}scope;slot;adopted=null;get current(){const t=this.scope.pass;return t===null?super.current:t.read(this,super.current)}set current(t){const r=this.scope.pass;if(r!==null){r.write(this,t);return}this.scope.wrote(this.slot),super.current=t}hand(t){const r=this.scope.pass;if(r!==null){r.hand(this,t);return}this.adopted=null,this.scope.wrote(this.slot),this.scope.recordHanded(this.slot,t)}get holdsHanded(){const t=this.scope.pass;return t===null?this.scope.handedTo(this.slot)===super.current&&!this.scope.inFlight(this.slot):(t.hasHanded(this.slot)?t.lastHanded(this.slot):this.scope.handedTo(this.slot))===t.read(this,super.current)}forgetHanded(t){this.scope.wrote(this.slot),this.scope.handedTo(this.slot)===t&&this.scope.recordHanded(this.slot,Va)}adopt(t,r){const n=r[this.slot];if(!t.hasHanded(this.slot)||n!==t.lastHanded(this.slot))return;this.scope.recordHanded(this.slot,n);const o=t.states[this.slot];n!==o&&(this.adopted={opening:o,handed:n})}recordAdopted(t){const r=this.adopted;r!==null&&(this.adopted=null,t(n=>n===r.opening?r.handed:n))}}class Wu{constructor(t,r,n){this.scope=r,this.slot=n,this.held=t}scope;slot;held;get current(){const t=this.scope.pass;return t===null?this.held:t.read(this,this.held)}set current(t){const r=this.scope.pass;if(r!==null){r.write(this,t);return}this.scope.wrote(this.slot),this.held=t}adopt(t){this.held=t.read(this,this.held)}}const zu=(e,t)=>t;function Yo(e,t){const[r,n]=s.useReducer(zu,null),[o]=s.useState(()=>new ju(e,t,n)),a=o.begin(t,r);return s.useInsertionEffect(()=>{o.commit(a,t)}),s.useLayoutEffect(()=>{o.deliver()}),o}function Kr(e,t,r,n){const o=fl(r,a=>new Uu(a,e,t));return s.useLayoutEffect(()=>{o.recordAdopted(n)}),o}function Gr(e,t,r){const[n]=s.useState(()=>new Wu(r,e,t));return n}function Ne(e,t,r){return e<t?t:e>r?r:e}const Bu=tn([],null,null);function kn(e,t,r,n){return r===null?Bu:_a(r,Y(t,e[0],n),Y(t,e[1],n))}function Mr(e,t,r,n,o){const a=Y(t,e,o),i=Ya(n)?null:Pn(n,a);return i===null?a<Y(t,r[0],o)?r[0]:a>Y(t,r[1],o)?r[1]:e:i===a?e:oe(t,i,o)}function Br(e,t,r,n,o,a){const i=Y(t,e[0],o),u=Y(t,e[1],o),m=po(a,{kind:"range",min:Y(t,r[0],o),max:Y(t,r[1],o)},i,u);if(m===null)return e;const h=Mr(m[0]===i?e[0]:oe(t,m[0],o),t,r,n,o),f=Mr(m[1]===u?e[1]:oe(t,m[1],o),t,r,n,o);return[h,f<h?h:f]}const Ts=(e,t,r,n,o,a,i)=>{if(en(e,t,r),r===void 0||r.length===0)return null;const u=tn(hl(e,t,r,n,i),Y(n,o,i),Y(n,a,i));if(u.hiIndex<u.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${E(o)}, maxDate: ${E(a)}, entries: ${r.length})`);return u},_a=(e,t,r)=>{const n=tn(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},Ya=e=>e.hiIndex<e.loIndex,Fu=e=>({stepEnd:(t,r)=>{let n=null;for(const o of e){const a=Zt(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=yn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Rt=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),Cs=(e,t,r,n,o)=>{if(!$t(r)||r.length!==2)throw new RangeError(`${e}: ${t} must be a [start, end] tuple of Dates (received: ${E(r)})`);const a=qt(e,`${t}[0]`,r[0],n,o),i=qt(e,`${t}[1]`,r[1],n,o);if(i<a)throw new RangeError(`${e}: ${t} must not be inverted at ${n} resolution (start: ${E(r[0])}, end: ${E(r[1])})`);return[a,i]},lr=e=>{const t="resolveVernierSelectorSteps";if(typeof e!="object"||e===null)throw new RangeError(`${t}: options must be an object (received: ${E(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: ${E(r)})`);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${E(n)})`);Ce(t,"macroUnit",o),Ce(t,"microUnit",a);const f=fr(t,e.yearStartMonth);for(const[D,M]of[["minDate",i],["maxDate",u]])if(!ye(M))throw new RangeError(`${t}: ${D} must be a valid Date (received: ${E(M)})`);if(u.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${E(i)}, maxDate: ${E(u)})`);qt(t,"minDate",i,o,f),qt(t,"minDate",i,a,f),Er(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const x=Cs(t,"macroRange",m,o,f);if(m[1].getTime()<m[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${E(m[0])}, end: ${E(m[1])})`);const v=Cs(t,"microSelection",h,a,f),P=Ts(t,"macroAllowedDates",e.macroAllowedDates,o,i,u,f),j=Ts(t,"microAllowedDates",e.microAllowedDates,a,i,u,f),p=[m[0],m[1]],w=[h[0],h[1]],c=D=>{const M=yt(o,a,[D[0],D[1]],i,u,f);return[Y(a,M[0],f),Y(a,M[1],f)]},g=(D,M)=>{if(j!==null){const L=_a(j,D,M);if(!Ya(L))return L}return{kind:"range",min:D,max:M}},d=(D,M)=>{const L=Rt(D,p)?p:D;return L===p&&Rt(M,w)?null:{macroRange:L,microSelection:M}};if(e.row==="macro"){const D=P??{kind:"range",min:Y(o,i,f),max:Y(o,u,f)},M=ho(D),L=(U,F)=>{const W=yt(o,a,U,i,u,f);return Br(w,a,W,kn(W,a,j,f),f,F)},k=(U,F)=>{const W=La(M,x[0],x[1],U,ka(F,n));if(W===null)return null;const V=Ia(W,x,p,o,f,F.motion==="single");if(V===null)return null;const Q=[Ne(V[0],i,u),Ne(V[1],i,u)],ce=Math.sign(W[0]-x[0])===U&&Math.sign(W[1]-x[1])===U;return d(Q,L(Q,ce?"pan":"resize"))};return{previous:k(-1,e.rules.previous),next:k(1,e.rules.next)}}const re=c(p);let O=[Y(a,i,f),Y(a,u,f)];if(P!==null){const D=c([oe(o,P.ascending[P.loIndex],f),oe(o,P.ascending[P.hiIndex],f)]);O=[Math.min(D[0],re[0]),Math.max(D[1],re[1])]}const ae=j===null?null:_a(j,O[0],O[1]);let J=ho({kind:"range",min:O[0],max:O[1]});if(ae!==null&&!Ya(ae)){const D=g(re[0],re[1]);J=D.kind==="candidates"?ho(ae):Fu([ae,D])}const se=D=>{if(P===null)return[Ne(bt(o,D[0],f),i,u),Ne(bt(o,D[1],f),i,u)];const M=fo(P,Y(o,D[0],f),-1),L=fo(P,Y(o,D[1],f),1);return M===null||L===null?null:[Ne(oe(o,M,f),i,u),Ne(oe(o,L,f),i,u)]},ne=(D,M,L)=>{const[k,U]=c(D),F=g(k,U),W=ce=>{const ve=Y(a,ce,f);if(En(F,ve))return ce;const G=fo(F,ve,L);return G===null?null:oe(a,G,f)},V=W(M[0]),Q=W(M[1]);return V===null||Q===null?null:[V,Q.getTime()<V.getTime()?V:Q]},A=(D,M)=>D>=re[0]&&M<=re[1],ee=(D,M)=>{const L=La(J,v[0],v[1],D,ka(M,n));if(L===null)return null;const k=Ia(L,v,w,a,f,M.motion==="single");if(k===null)return null;const U=M.window!=="follow",F=U&&A(L[0],L[1])?p:se(k);if(F===null)return null;const W=ne(F,k,D);if(W===null)return null;const V=U&&A(Y(a,W[0],f),Y(a,W[1],f))?p:se(W);return V===null?null:d(V,W)};return{previous:ee(-1,e.rules.previous),next:ee(1,e.rules.next)}};function Ha(e,t,r){if(!ye(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${E(r)})`)}function Le(e,t,r,n,o){Ha(e,t,r),qe(e,t,r,n,o,"")}function Ho(e,t,r,n,o){if(Ha(e,"minDate",t),Ha(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${E(t)}, maxDate: ${E(r)})`);for(const a of n)qe(e,"minDate",t,a,o,Bs)}function cr(e,t,r,n,o){if(!$t(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${E(r)})`);if(Le(e,`${t}[0]`,r[0],n,o),Le(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: ${E(r[0])}, upper: ${E(r[1])})`)}function Do(e,t,r,n,o,a,i,u){const m=Y(r,n,u);if(m<Y(r,o,u)||m>Y(r,a,u))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${E(n)}, lower: ${E(o)}, upper: ${E(a)})`)}function Mo(e,t,r,n,o,a,i,u){Do(e,`${t}[0]`,r,n[0],o,a,i,u),Do(e,`${t}[1]`,r,n[1],o,a,i,u)}function yo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${E(r)}, upper: ${E(n)})`)}function qr(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${E(r)})`)}function Ut(e,t,r,n,o,a){const i=Fs(e,t,r);return ye(i)&&Vn(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function Eo(e,t,r,n,o){const a=Me(e,r,t,o)+n;return e[Math.max(0,Math.min(e.length-1,a))]}function Dn(e,t,r,n,o,a){const i=Ne(e,r,n);if(o.length===0)return i;const u=o[Me(o,i,t,a)];return Y(t,u,a)===Y(t,i,a)?i:Ne(u,r,n)}function Ea(e,t,r,n,o,a){const i=Dn(e[0],t,r,n,o,a),u=Dn(e[1],t,r,n,o,a);return[i,u<i?i:u]}function In(e,t){return t[0]===e[0]&&t[1]===e[1]?e:t}const Ku={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function Wt(e,t){return t.length===0?{}:{[Ku[e]]:t}}function jo(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 Xt={previous:null,next:null},Gu=["motion","edge","window"];function An(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Gu.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const vo=(e,t)=>e.getTime()===t.getTime();function Xr(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 Zr(e,t,r){e.current=t,e.hand(t),r(t)}function qu(e,t){return typeof t=="function"?t(e):t}function Qr(e){return s.useReducer(qu,void 0,e)}function Jr(e,t,r,n){r===t||e.current!==r||(e.forgetHanded(t),n(o=>o===t?r:o))}function Xu(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:u,selectorStep:m,...h}=e;Ce("usePeriodSliderRange","unit",t);const f=fr("usePeriodSliderRange",i);Ho("usePeriodSliderRange",r,n,[t],f),cr("usePeriodSliderRange","initialRange",o,t,f),m!==void 0&&Er("usePeriodSliderRange","selectorStep",m,"motion");const x=jo(h),v=r.getTime(),P=n.getTime(),j=s.useMemo(()=>dr("usePeriodSliderRange",No(x.allowedDates),t,r,n,f).dates,[x.allowedDates,t,v,P,f]),p=s.useRef(o),[w,c]=Qr(()=>(Mo("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",f),In(o,Ea(o,t,r,n,j,f)))),g=Yo("usePeriodSliderRange",[w]);cr("usePeriodSliderRange","range",w,t,f);const d=In(w,Ea(w,t,r,n,j,f)),re=Kr(g,0,d,c);s.useLayoutEffect(()=>{Jr(re,w,d,c)});const O=Gr(g,0,o),ae=ut({minDate:r,maxDate:n,candidates:j}),J=ut(a),se=s.useCallback(G=>{const{minDate:_,maxDate:De,candidates:Ee}=ae.current,ie=Ea(G,t,_,De,Ee,f);Xr(re,ie,Rt,c);const fe=O.current;ie[0].getTime()===fe[0].getTime()&&ie[1].getTime()===fe[1].getTime()||(O.current=ie,g.notify(0,()=>J.current?.(ie[0],ie[1])))},[t,f]),ne=s.useCallback(G=>{const _=typeof G=="function"?G(re.current):G;O.current=_,Zr(re,_,c)},[]),A=s.useCallback(G=>{Le("usePeriodSliderRange","setLowerDate(date)",G,t,f);const _=re.current,De=G.getTime()>_[1].getTime()?G:_[1];se([G,De])},[se,t,f]),ee=s.useCallback(G=>{Le("usePeriodSliderRange","setUpperDate(date)",G,t,f);const _=re.current,De=G.getTime()<_[0].getTime()?G:_[0];se([De,G])},[se,t,f]),D=s.useCallback((G,_)=>{Le("usePeriodSliderRange","sliderProps.onChangeRange(lower)",G,t,f),Le("usePeriodSliderRange","sliderProps.onChangeRange(upper)",_,t,f),yo("usePeriodSliderRange","sliderProps.onChangeRange",G,_),se([G,_])},[se,t,f]),M=s.useCallback(G=>{qr("usePeriodSliderRange","shiftRange",G);const{minDate:_,maxDate:De,candidates:Ee}=ae.current,ie=re.current;if(Ee.length>0){se([Eo(Ee,t,ie[0],G,f),Eo(Ee,t,ie[1],G,f)]);return}se([Ut(t,ie[0],G,_,De,f).date,Ut(t,ie[1],G,_,De,f).date])},[t,se,f]),L=s.useCallback(()=>{se(p.current)},[se]),k=An(m),U=k!==void 0,F=s.useMemo(()=>{if(k===void 0)return{start:Xt,end:Xt};const G=j.length>0?x.allowedDates:void 0,_={selection:d,unit:t,yearStartMonth:f,minDate:r,maxDate:n,allowedDates:G,rules:k};return{start:Aa({..._,shows:"start"}),end:Aa({..._,shows:"end"})}},[k,d,t,f,v,P,j,x.allowedDates]),W=jt(F.start,se),V=jt(F.end,se),Q=s.useMemo(()=>({value:d[0],onChange:A,minDate:r,maxDate:d[1],unit:t,yearStartMonth:f,...Wt(t,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...U?{stepper:W}:{}}),[d[0],d[1],A,r,t,f,j,e.formatLocale,e.locale,e.labels,u,U,W]),ce=s.useMemo(()=>({value:d[1],onChange:ee,minDate:d[0],maxDate:n,unit:t,yearStartMonth:f,...Wt(t,j),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u,...U?{stepper:V}:{}}),[d[0],d[1],ee,n,t,f,j,e.formatLocale,e.locale,e.labels,u,U,V]),ve=s.useMemo(()=>({...x,mode:"range",unit:t,yearStartMonth:f,range:d,minDate:r,maxDate:n,onChangeRange:D}),[x,t,d,r,n,D,f]);return{range:d,lowerDate:d[0],upperDate:d[1],setRange:ne,setLowerDate:A,setUpperDate:ee,shiftRange:M,resetRange:L,startSelectorProps:Q,endSelectorProps:ce,sliderProps:ve,duringRender:g.duringRender}}function Zu(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:u,...m}=e;Ce("usePeriodSliderPoint","unit",t);const h=fr("usePeriodSliderPoint",i);Ho("usePeriodSliderPoint",r,n,[t],h),Le("usePeriodSliderPoint","initialValue",o,t,h);const f=jo(m),x=r.getTime(),v=n.getTime(),P=s.useMemo(()=>dr("usePeriodSliderPoint",No(f.allowedDates),t,r,n,h).dates,[f.allowedDates,t,x,v,h]),j=s.useRef(o),[p,w]=Qr(()=>(Do("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",h),Dn(o,t,r,n,P,h))),c=Yo("usePeriodSliderPoint",[p]);Le("usePeriodSliderPoint","value",p,t,h);const g=Dn(p,t,r,n,P,h),d=Kr(c,0,g,w);s.useLayoutEffect(()=>{Jr(d,p,g,w)});const re=Gr(c,0,o),O=ut({minDate:r,maxDate:n,candidates:P}),ae=ut(a),J=s.useCallback(k=>{const{minDate:U,maxDate:F,candidates:W}=O.current,V=Dn(k,t,U,F,W,h);Xr(d,V,vo,w),V.getTime()!==re.current.getTime()&&(re.current=V,c.notify(0,()=>ae.current?.(V)))},[t,h]),se=s.useCallback(k=>{const U=typeof k=="function"?k(d.current):k;re.current=U,Zr(d,U,w)},[]),ne=s.useCallback(k=>{Le("usePeriodSliderPoint","selectorProps.onChange(date)",k,t,h),J(k)},[J,t,h]),A=s.useCallback(k=>{Le("usePeriodSliderPoint","sliderProps.onChangePoint(value)",k,t,h),J(k)},[J,t,h]),ee=s.useCallback(k=>{qr("usePeriodSliderPoint","shiftValue",k);const{minDate:U,maxDate:F,candidates:W}=O.current;if(W.length>0){J(Eo(W,t,d.current,k,h));return}J(Ut(t,d.current,k,U,F,h).date)},[t,J,h]),D=s.useCallback(()=>{J(j.current)},[J]),M=s.useMemo(()=>({value:g,onChange:ne,minDate:r,maxDate:n,unit:t,yearStartMonth:h,...Wt(t,P),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:u}),[g,ne,r,n,t,h,P,e.formatLocale,e.locale,e.labels,u]),L=s.useMemo(()=>({...f,mode:"point",unit:t,yearStartMonth:h,value:g,minDate:r,maxDate:n,onChangePoint:A}),[f,t,g,r,n,A,h]);return{value:g,setValue:se,shiftValue:ee,resetValue:D,selectorProps:M,sliderProps:L,duringRender:c.duringRender}}function Qu(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroRange:h,yearStartMonth:f,formatOption:x,macroSelectorStep:v,microSelectorStep:P,...j}=e;Ce("useVernierSliderRange","unit",t);const p=Qt("useVernierSliderRange","macroUnit",i,t),w=Qt("useVernierSliderRange","microUnit",u,t),c=fr("useVernierSliderRange",f);Ho("useVernierSliderRange",r,n,[p,w,t],c),cr("useVernierSliderRange","initialMacroRange",o,p,c),cr("useVernierSliderRange","initialMicroRange",a,w,c),v!==void 0&&Er("useVernierSliderRange","macroSelectorStep",v,"motion"),P!==void 0&&Er("useVernierSliderRange","microSelectorStep",P,"vernierRange");const g=jo(j),d=s.useRef(o),re=s.useRef(a),[O,ae]=Qr(()=>(Mo("useVernierSliderRange","initialMacroRange",p,o,r,n,"[minDate, maxDate]",c),o)),[J,se]=Qr(()=>{const y=yt(p,w,o,r,n,c);return Mo("useVernierSliderRange","initialMicroRange",w,a,y[0],y[1],"the initial macro window",c),a}),ne=Yo("useVernierSliderRange",[O,J]);cr("useVernierSliderRange","macroRange",O,p,c);const A=In(O,[Ne(O[0],r,n),Ne(O[1],r,n)]),ee=r.getTime(),D=n.getTime(),M=s.useMemo(()=>yt(p,w,A,r,n,c),[p,w,A,ee,D,c]),L=s.useMemo(()=>Ht("micro",g)?Fa("useVernierSliderRange",Mt("micro",g),w,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,w,ee,D,c]),k=s.useMemo(()=>Ht("macro",g)?dr("useVernierSliderRange",Mt("macro",g),p,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,p,ee,D,c]),U=ut(k),F=s.useMemo(()=>kn(M,w,L,c),[M,w,L,c]),W=s.useMemo(()=>$n(L,F),[L,F]);cr("useVernierSliderRange","microRange",J,w,c);const V=In(J,Br(J,w,M,F,c,"resize")),Q=Kr(ne,0,A,ae),ce=Kr(ne,1,V,se);s.useLayoutEffect(()=>{Jr(Q,O,A,ae),Jr(ce,J,V,se)});const ve=Gr(ne,1,a),G=Gr(ne,0,o),_=ut({minDate:r,maxDate:n}),De=ut(m),Ee=ut(h),ie=s.useCallback(y=>{const{minDate:H,maxDate:de}=_.current;return yt(p,w,y,H,de,c)},[p,w,c]),fe=s.useCallback(y=>kn(y,w,L,c),[w,L,c]),ke=s.useCallback(y=>{Xr(Q,y,Rt,ae);const H=G.current;y[0].getTime()===H[0].getTime()&&y[1].getTime()===H[1].getTime()||(G.current=y,ne.notify(0,()=>De.current?.(y[0],y[1])))},[]),ot=s.useCallback(y=>{const H=typeof y=="function"?y(Q.current):y;G.current=H,Zr(Q,H,ae)},[]),te=s.useCallback((y,H,de)=>{const _e=de==="micro"&&Rt(Q.current,y)&&Rt(G.current,y),Ie=de==="macro"&&Rt(ce.current,H)&&Rt(ve.current,H);if(_e||ke(y),Ie)return;Xr(ce,H,Rt,se);const be=ve.current;(H[0].getTime()!==be[0].getTime()||H[1].getTime()!==be[1].getTime())&&(ve.current=H,ne.notify(1,()=>Ee.current?.(H[0],H[1])))},[ke]),T=s.useCallback(y=>{const H=typeof y=="function"?y(ce.current):y;ve.current=H,Zr(ce,H,se)},[]),ue=s.useCallback((y,H,de)=>{const{minDate:_e,maxDate:Ie}=_.current,be=[Ne(y,_e,Ie),Ne(H,_e,Ie)],je=ie(be);te(be,Br(ce.current,w,je,fe(je),c,de),"macro")},[w,ie,fe,te,c]),pe=s.useCallback((y,H)=>ue(y,H,"resize"),[ue]),at=s.useCallback((y,H)=>{Le("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",y,p,c),Le("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",H,p,c),yo("useVernierSliderRange","sliderProps.onChangeMacroRange",y,H);const{minDate:de,maxDate:_e}=_.current,Ie=[Ne(y,de,_e),Ne(H,de,_e)],be=ce.current,je=ie(Ie),Xe=Br(be,w,je,fe(je),c,"resize");if(Xe[0].getTime()!==be[0].getTime()||Xe[1].getTime()!==be[1].getTime()){ke(Ie);return}te(Ie,be,"macro")},[p,w,ie,fe,ke,te,c]),$e=s.useCallback((y,H)=>{const de=ie(Q.current);te(Q.current,Br([y,H],w,de,fe(de),c,"resize"),"micro")},[w,ie,fe,te,c]),He=s.useCallback((y,H)=>{Le("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",y,w,c),Le("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",H,w,c),yo("useVernierSliderRange","sliderProps.onChangeMicroRange",y,H),$e(y,H)},[$e,w,c]),Ke=s.useCallback(y=>{Le("useVernierSliderRange","setMacroLowerDate(date)",y,p,c);const H=Q.current[1],de=y>H?y:H;pe(y,de)},[pe,p,c]),q=s.useCallback(y=>{Le("useVernierSliderRange","setMacroUpperDate(date)",y,p,c);const H=Q.current[0],de=y<H?y:H;pe(de,y)},[pe,p,c]),et=s.useCallback(y=>{Le("useVernierSliderRange","setMicroLowerDate(date)",y,w,c);const H=ce.current[1],de=y>H?y:H;$e(y,de)},[$e,w,c]),it=s.useCallback(y=>{Le("useVernierSliderRange","setMicroUpperDate(date)",y,w,c);const H=ce.current[0],de=y<H?y:H;$e(de,y)},[$e,w,c]),gt=s.useCallback(y=>{qr("useVernierSliderRange","shiftMacroRange",y);const{minDate:H,maxDate:de}=_.current,_e=Q.current,Ie=U.current;if(Ie.length>0){const Xe=Me(Ie,_e[0],p,c)+y,kt=Me(Ie,_e[1],p,c)+y;if(Xe<0||kt>Ie.length-1)return;ue(Ie[Xe],Ie[kt],"pan");return}const be=Ut(p,_e[0],y,H,de,c),je=Ut(p,_e[1],y,H,de,c);be.pastDateRange||je.pastDateRange||be.date<H||je.date>de||ue(be.date,je.date,"pan")},[p,ue,c]),Pe=s.useCallback(y=>{qr("useVernierSliderRange","shiftMicroRange",y);const H=Q.current,de=ce.current,_e=ie(H),[Ie,be]=_e,je=$n(L,fe(_e));if(je.length>0){const zt=Me(je,de[0],w,c)+y,Ue=Me(je,de[1],w,c)+y;if(zt<0||Ue>je.length-1)return;$e(je[zt],je[Ue]);return}const Xe=Ut(w,de[0],y,Ie,be,c),kt=Ut(w,de[1],y,Ie,be,c);Xe.pastDateRange||kt.pastDateRange||Y(w,Xe.date,c)<Y(w,Ie,c)||Y(w,kt.date,c)>Y(w,be,c)||$e(Xe.date,kt.date)},[w,L,ie,fe,$e,c]),st=s.useCallback(()=>{const{minDate:y,maxDate:H}=_.current,de=[Ne(d.current[0],y,H),Ne(d.current[1],y,H)],_e=ie(de);te(de,Br(re.current,w,_e,fe(_e),c,"resize"),"both")},[w,ie,fe,te,c]),Ve=An(v),ft=An(P),Ge=Ve!==void 0,dt=ft!==void 0,C=s.useMemo(()=>{const y={macroUnit:p,microUnit:w,yearStartMonth:c,minDate:r,maxDate:n,macroRange:A,microSelection:V,macroAllowedDates:Ht("macro",g)?Mt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Mt("micro",g).list:void 0};return{macroStart:Ve===void 0?Xt:lr({...y,row:"macro",shows:"start",rules:Ve}),macroEnd:Ve===void 0?Xt:lr({...y,row:"macro",shows:"end",rules:Ve}),microStart:ft===void 0?Xt:lr({...y,row:"micro",shows:"start",rules:ft}),microEnd:ft===void 0?Xt:lr({...y,row:"micro",shows:"end",rules:ft})}},[Ve,ft,p,w,c,ee,D,A,V,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),Z=s.useCallback(y=>te(y.macroRange,y.microSelection,"macro"),[te]),ze=s.useCallback(y=>te(y.macroRange,y.microSelection,"micro"),[te]),Se=jt(C.macroStart,Z),ge=jt(C.macroEnd,Z),vt=jt(C.microStart,ze),Ct=jt(C.microEnd,ze),[z,Pr]=M,rn=s.useMemo(()=>({value:A[0],onChange:Ke,minDate:r,maxDate:A[1],unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ge?{stepper:Se}:{}}),[A,Ke,r,p,c,k,e.formatLocale,e.locale,e.labels,x,Ge,Se]),I=s.useMemo(()=>({value:A[1],onChange:q,minDate:A[0],maxDate:n,unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ge?{stepper:ge}:{}}),[A,q,n,p,c,k,e.formatLocale,e.locale,e.labels,x,Ge,ge]),le=s.useMemo(()=>({value:V[0],onChange:et,minDate:z,maxDate:V[1],unit:w,yearStartMonth:c,...Wt(w,W),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...dt?{stepper:vt}:{}}),[V,et,z,w,c,W,e.formatLocale,e.locale,e.labels,x,dt,vt]),we=s.useMemo(()=>({value:V[1],onChange:it,minDate:V[0],maxDate:Pr,unit:w,yearStartMonth:c,...Wt(w,W),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...dt?{stepper:Ct}:{}}),[V,it,Pr,w,c,W,e.formatLocale,e.locale,e.labels,x,dt,Ct]),Ye=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:p,microUnit:w,minDate:r,maxDate:n,macroRange:A,microRange:V,onChangeMacroRange:at,onChangeMicroRange:He}),[g,t,p,w,r,n,A,V,at,He,c]);return{macroRange:A,setMacroRange:ot,microRange:V,setMicroRange:T,setMacroLowerDate:Ke,setMacroUpperDate:q,setMicroLowerDate:et,setMicroUpperDate:it,shiftMacroRange:gt,shiftMicroRange:Pe,resetVernier:st,macroStartSelectorProps:rn,macroEndSelectorProps:I,microStartSelectorProps:le,microEndSelectorProps:we,sliderProps:Ye,duringRender:ne.duringRender}}function Ju(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:u,onChangeMacroRange:m,onChangeMicroPoint:h,yearStartMonth:f,formatOption:x,macroSelectorStep:v,microSelectorStep:P,...j}=e;Ce("useVernierSliderPoint","unit",t);const p=Qt("useVernierSliderPoint","macroUnit",i,t),w=Qt("useVernierSliderPoint","microUnit",u,t),c=fr("useVernierSliderPoint",f);Ho("useVernierSliderPoint",r,n,[p,w,t],c),cr("useVernierSliderPoint","initialMacroRange",o,p,c),Le("useVernierSliderPoint","initialMicroValue",a,w,c),v!==void 0&&Er("useVernierSliderPoint","macroSelectorStep",v,"motion"),P!==void 0&&Er("useVernierSliderPoint","microSelectorStep",P,"vernierPoint");const g=jo(j),d=s.useRef(o),re=s.useRef(a),[O,ae]=Qr(()=>(Mo("useVernierSliderPoint","initialMacroRange",p,o,r,n,"[minDate, maxDate]",c),o)),[J,se]=Qr(()=>{const I=yt(p,w,o,r,n,c);return Do("useVernierSliderPoint","initialMicroValue",w,a,I[0],I[1],"the initial macro window",c),a}),ne=Yo("useVernierSliderPoint",[O,J]);cr("useVernierSliderPoint","macroRange",O,p,c);const A=In(O,[Ne(O[0],r,n),Ne(O[1],r,n)]),ee=r.getTime(),D=n.getTime(),M=s.useMemo(()=>yt(p,w,A,r,n,c),[p,w,A,ee,D,c]),L=s.useMemo(()=>Ht("micro",g)?Fa("useVernierSliderPoint",Mt("micro",g),w,r,n,c):null,[g.microIsDiscrete,g.microAllowedDates,g.allowedDates,w,ee,D,c]),k=s.useMemo(()=>Ht("macro",g)?dr("useVernierSliderPoint",Mt("macro",g),p,r,n,c).dates:[],[g.macroIsDiscrete,g.macroAllowedDates,g.allowedDates,p,ee,D,c]),U=ut(k),F=s.useMemo(()=>kn(M,w,L,c),[M,w,L,c]),W=s.useMemo(()=>$n(L,F),[L,F]);Le("useVernierSliderPoint","microValue",J,w,c);const V=Mr(J,w,M,F,c),Q=Kr(ne,0,A,ae),ce=Kr(ne,1,V,se);s.useLayoutEffect(()=>{Jr(Q,O,A,ae),Jr(ce,J,V,se)});const ve=Gr(ne,1,a),G=Gr(ne,0,o),_=ut({minDate:r,maxDate:n}),De=ut(m),Ee=ut(h),ie=s.useCallback(I=>{const{minDate:le,maxDate:we}=_.current;return yt(p,w,I,le,we,c)},[p,w,c]),fe=s.useCallback(I=>kn(I,w,L,c),[w,L,c]),ke=s.useCallback(I=>{Xr(Q,I,Rt,ae);const le=G.current;I[0].getTime()===le[0].getTime()&&I[1].getTime()===le[1].getTime()||(G.current=I,ne.notify(0,()=>De.current?.(I[0],I[1])))},[]),ot=s.useCallback(I=>{const le=typeof I=="function"?I(Q.current):I;G.current=le,Zr(Q,le,ae)},[]),te=s.useCallback((I,le,we)=>{const Ye=we==="micro"&&Rt(Q.current,I)&&Rt(G.current,I),y=we==="macro"&&vo(ce.current,le)&&vo(ve.current,le);Ye||ke(I),!y&&(Xr(ce,le,vo,se),le.getTime()!==ve.current.getTime()&&(ve.current=le,ne.notify(1,()=>Ee.current?.(le))))},[ke]),T=s.useCallback(I=>{const le=typeof I=="function"?I(ce.current):I;ve.current=le,Zr(ce,le,se)},[]),ue=s.useCallback((I,le)=>{const{minDate:we,maxDate:Ye}=_.current,y=[Ne(I,we,Ye),Ne(le,we,Ye)],H=ie(y);te(y,Mr(ce.current,w,H,fe(H),c),"macro")},[w,ie,fe,te,c]),pe=s.useCallback(I=>{const le=ie(Q.current);te(Q.current,Mr(I,w,le,fe(le),c),"micro")},[w,ie,fe,te,c]),at=s.useCallback((I,le)=>{Le("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",I,p,c),Le("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",le,p,c),yo("useVernierSliderPoint","sliderProps.onChangeMacroRange",I,le);const{minDate:we,maxDate:Ye}=_.current,y=[Ne(I,we,Ye),Ne(le,we,Ye)],H=ce.current,de=ie(y);if(Mr(H,w,de,fe(de),c).getTime()!==H.getTime()){ke(y);return}te(y,H,"macro")},[p,w,ie,fe,ke,te,c]),$e=s.useCallback(I=>{Le("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",I,w,c),pe(I)},[pe,w,c]),He=s.useCallback(I=>{Le("useVernierSliderPoint","setMacroLowerDate(date)",I,p,c);const le=Q.current[1],we=I>le?I:le;ue(I,we)},[ue,p,c]),Ke=s.useCallback(I=>{Le("useVernierSliderPoint","setMacroUpperDate(date)",I,p,c);const le=Q.current[0],we=I<le?I:le;ue(we,I)},[ue,p,c]),q=s.useCallback(I=>{Le("useVernierSliderPoint","setMicroDate(date)",I,w,c),pe(I)},[pe,w,c]),et=s.useCallback(I=>{qr("useVernierSliderPoint","shiftMacroRange",I);const{minDate:le,maxDate:we}=_.current,Ye=Q.current,y=U.current;if(y.length>0){const _e=Me(y,Ye[0],p,c)+I,Ie=Me(y,Ye[1],p,c)+I;if(_e<0||Ie>y.length-1)return;ue(y[_e],y[Ie]);return}const H=Ut(p,Ye[0],I,le,we,c),de=Ut(p,Ye[1],I,le,we,c);H.pastDateRange||de.pastDateRange||H.date<le||de.date>we||ue(H.date,de.date)},[p,ue,c]),it=s.useCallback(I=>{qr("useVernierSliderPoint","shiftMicroValue",I);const le=Q.current,we=ie(le),Ye=$n(L,fe(we));if(Ye.length>0){pe(Eo(Ye,w,ce.current,I,c));return}pe(Ut(w,ce.current,I,we[0],we[1],c).date)},[w,L,ie,fe,pe,c]),gt=s.useCallback(()=>{const{minDate:I,maxDate:le}=_.current,we=[Ne(d.current[0],I,le),Ne(d.current[1],I,le)],Ye=ie(we);te(we,Mr(re.current,w,Ye,fe(Ye),c),"both")},[w,ie,fe,te,c]),Pe=An(v),st=An(P),Ve=Pe!==void 0,ft=st!==void 0,Ge=s.useMemo(()=>{const I={macroUnit:p,microUnit:w,yearStartMonth:c,minDate:r,maxDate:n,macroRange:A,microSelection:[V,V],macroAllowedDates:Ht("macro",g)?Mt("macro",g).list:void 0,microAllowedDates:Ht("micro",g)?Mt("micro",g).list:void 0};return{macroStart:Pe===void 0?Xt:lr({...I,row:"macro",shows:"start",rules:Pe}),macroEnd:Pe===void 0?Xt:lr({...I,row:"macro",shows:"end",rules:Pe}),micro:st===void 0?Xt:lr({...I,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:st.previous.window},next:{motion:"shift",window:st.next.window}}})}},[Pe,st,p,w,c,ee,D,A,V,g.macroIsDiscrete,g.macroAllowedDates,g.microIsDiscrete,g.microAllowedDates,g.allowedDates]),dt=s.useCallback(I=>te(I.macroRange,I.microSelection[0],"macro"),[te]),C=s.useCallback(I=>te(I.macroRange,I.microSelection[0],"micro"),[te]),Z=jt(Ge.macroStart,dt),ze=jt(Ge.macroEnd,dt),Se=jt(Ge.micro,C),[ge,vt]=M,Ct=s.useMemo(()=>({value:A[0],onChange:He,minDate:r,maxDate:A[1],unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ve?{stepper:Z}:{}}),[A,He,r,p,c,k,e.formatLocale,e.locale,e.labels,x,Ve,Z]),z=s.useMemo(()=>({value:A[1],onChange:Ke,minDate:A[0],maxDate:n,unit:p,yearStartMonth:c,...Wt(p,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ve?{stepper:ze}:{}}),[A,Ke,n,p,c,k,e.formatLocale,e.locale,e.labels,x,Ve,ze]),Pr=s.useMemo(()=>({value:V,onChange:q,minDate:ge,maxDate:vt,unit:w,yearStartMonth:c,...Wt(w,W),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ft?{stepper:Se}:{}}),[V,q,ge,vt,w,c,W,e.formatLocale,e.locale,e.labels,x,ft,Se]),rn=s.useMemo(()=>({...g,mode:"vernier",unit:t,yearStartMonth:c,macroUnit:p,microUnit:w,minDate:r,maxDate:n,macroRange:A,microValue:V,onChangeMacroRange:at,onChangeMicroPoint:$e}),[g,t,p,w,r,n,A,V,at,$e,c]);return{macroRange:A,setMacroRange:ot,microValue:V,setMicroValue:T,setMacroLowerDate:He,setMacroUpperDate:Ke,setMicroDate:q,shiftMacroRange:et,shiftMicroValue:it,resetVernier:gt,macroStartSelectorProps:Ct,macroEndSelectorProps:z,microSelectorProps:Pr,sliderProps:rn,duringRender:ne.duringRender}}function ja(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Po(e,t){const r=new Date(e.getTime());return Ao(r.getFullYear(),r.getMonth(),t)}function ks(e){return e===void 0?0:Ws(e)?e:Number.NaN}const Is=Nn("declare the years to offer with minYear / maxYear or allowedYears");function uo(e,t,r,n){e!==void 0&&Rl(e,t,r,n)}function Rl(e,t,r,n){if(!ye(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${E(e)})`);qe("YearSelector",t,e,"year",r,n)}function As(e,t,r){if(e!==void 0){if(!Number.isInteger(e))throw new RangeError(`YearSelector: ${t} must be an integer year (received: ${E(e)})`);if(Number.isNaN(ja(e,r).getTime()))throw new RangeError(`YearSelector: ${t} must name a year that starts inside the Date range (received: ${E(e)}); under yearStartMonth ${r} that year starts on month ${r+1}, day 1`)}}function Os(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Po(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function ed(e,t,r,n){const o=new Set;for(const a of e){const i=Po(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function td(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:ed(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function rd(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const nd=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,children:a,minYear:i,maxYear:u,minDate:m,maxDate:h,allowedYears:f,className:x="",style:v,disabled:P=!1,locale:j,labels:p,formatLocale:w,formatOption:c,yearStartMonth:g}=e,d=fr("YearSelector",g);if(uo(t,"value",d,""),uo(r,"initialDate",d,""),uo(m,"minDate",d,Is),uo(h,"maxDate",d,Is),As(i,"minYear",d),As(u,"maxYear",d),en("YearSelector","allowedYears",f),f!==void 0)for(let _=0;_<f.length;_++)Rl(f[_],`allowedYears[${_}]`,d,"");w!==void 0&&Vo("YearSelector","formatLocale",w);const re=t??r;if(re===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&&Za("YearSelector",o,t!==void 0);const O=ko(j,p),ae=t!==void 0,[J,se]=Qa(re,ae,_=>_o(_,"year",d),_=>Po(_,d)),ne=m?.getTime(),A=h?.getTime(),ee=s.useMemo(()=>Os(i,m,Math.max,d),[i,ne,d]),D=s.useMemo(()=>Os(u,h,Math.min,d),[u,A,d]);if(ee!==null&&D!==null&&ee>D)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${ee}, upper: ${D})`);const M=f===void 0?null:f.map(_=>_.getTime()).join(","),L=s.useMemo(()=>td(f,ee,D,d),[M,ee,D,d]);if(L===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 k=s.useMemo(()=>L.kind==="discrete"?{kind:"candidates",ascending:L.ascending,loIndex:0,hiIndex:L.ascending.length-1}:{kind:"range",min:L.minYear,max:L.maxYear},[L]),U=t!==void 0?Po(t,d):J,F=!En(k,U),W=_=>{if(!P){if(!En(k,_))throw new RangeError(`YearSelector: refusing to emit ${_}, which lies outside the selectable years`);ae||se(_),n?.(ja(_,d),_)}},V=Zt(k,U,-1),Q=Zt(k,U,1),ce=()=>{if(o!==void 0){o.onStep("previous");return}V!==null&&W(V)},ve=()=>{if(o!==void 0){o.onStep("next");return}Q!==null&&W(Q)},G=s.useMemo(()=>{const _=L.kind==="discrete"?[...L.ascending].reverse():rd(L.minYear,L.maxYear);return F&&(_.push(U),_.sort((De,Ee)=>Ee-De)),_.map(De=>({value:De,label:nt("year",ja(De,d),c,w)}))},[L,F,U,d,w,c]);return $.jsxs("div",{className:`inline-flex items-center ${Mn} ${x}`,style:v,"data-out-of-range":F?"true":void 0,children:[$.jsx(yr,{neighbour:"control",direction:"left",disabled:P,canStep:o===void 0?V!==null:o.canStepPrevious,onStep:ce,ariaLabel:O.previousYear}),$.jsx("select",{"aria-label":O.yearSelect,disabled:P,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:U,onChange:_=>{if(!_.target.value)return;const De=Number(_.target.value);Number.isInteger(De)&&W(De)},children:G.map(_=>$.jsx("option",{value:_.value,disabled:F&&_.value===U,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:_.label},_.value))}),$.jsx(yr,{neighbour:"control",direction:"right",disabled:P,canStep:o===void 0?Q!==null:o.canStepNext,onStep:ve,ariaLabel:O.nextYear}),a]})},od=(e,t)=>{const r=ks(t.yearStartMonth);return!(ks(e.yearStartMonth)!==r||!Xa(e,t,n=>_o(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||!Co(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},Dl=s.memo(nd,od);Dl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=Us;exports.DateSelector=bl;exports.MonthSelector=xl;exports.PERIOD_SLIDER_LABEL_CATALOGS=Hs;exports.PERIOD_SLIDER_LABEL_KEYS=To;exports.PeriodSlider=ul;exports.YearSelector=Dl;exports.addUnit=Fs;exports.areStylesEqual=cl;exports.calculateConnectDragValues=Xs;exports.calculateHandleDragValues=Ta;exports.calculateKeyboardActionValues=Zs;exports.calculateLabelSlant=Ga;exports.calculateVernierMacroDrag=al;exports.calculateVernierMicroDrag=il;exports.decode=oe;exports.encode=Y;exports.findNearestDateIndex=Me;exports.formatLabel=nt;exports.formatOptionText=dl;exports.formatQuarterLabel=Bc;exports.formatScreenReaderLabel=Rr;exports.getMacroWindowEndDate=Gs;exports.getMacroWindowStartDate=Ks;exports.getSortedAllowedDates=Fc;exports.normalizeDateByUnit=bt;exports.resolveDraggedEdge=$o;exports.resolveMacroWindow=yt;exports.resolvePeriodSliderLabels=js;exports.resolveQuarter=qs;exports.resolveSelectorSteps=Aa;exports.resolveVernierRailZone=qa;exports.resolveVernierSelectorSteps=lr;exports.resolveVernierTargetHandle=ol;exports.resolveWheelStep=nl;exports.usePeriodSliderPoint=Zu;exports.usePeriodSliderRange=Xu;exports.useSelectorStepper=jt;exports.useVernierSliderPoint=Ju;exports.useVernierSliderRange=Qu;
|