@aiquants/period-slider 0.23.0 → 0.24.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 +44 -0
- package/README.md +31 -7
- package/dist/DateSelector.d.ts.map +1 -1
- package/dist/MonthSelector.d.ts.map +1 -1
- package/dist/PeriodSlider.d.ts +0 -7
- package/dist/PeriodSlider.d.ts.map +1 -1
- package/dist/YearSelector.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +991 -992
- package/dist/selectorField.d.ts +20 -0
- package/dist/selectorField.d.ts.map +1 -0
- package/dist/styles/period-slider.css +1 -1
- package/dist/styles/period-slider.standalone.css +1 -1
- package/package.json +2 -2
- package/src/DateSelector.tsx +6 -6
- package/src/MonthSelector.tsx +3 -2
- package/src/PeriodSlider.tsx +24 -17
- package/src/YearSelector.tsx +2 -1
- package/src/selectorField.ts +22 -0
- package/src/styles/period-slider.css +34 -13
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),jc=require("date-fns"),s=require("react"),mr=require("@aiquants/virtualscroll"),Fc=require("react-dom"),ai="an object that cannot be converted to a string",Uc=3,De=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},At=e=>{try{return Array.isArray(e)}catch{return!1}},zc=e=>e===void 0||At(e);function sn(e,t,r){if(!zc(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(De(e))return Date.prototype.toISOString.call(e);if(At(e))return Bc(e);try{return String(e)}catch{return ai}},Bc=e=>{let t;try{t=e.length}catch{return ai}const r=Math.min(t,Uc),n=[];for(let a=0;a<r;a++)n.push(Wc(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},Wc=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return At(r)?`Array(${r.length})`:y(r)}catch{return ai}},Pt=(e,t)=>De(e)?t(e):Number.NaN,gt=(e,t)=>e===void 0?null:Pt(e,t),vs=120,$a="data-drag-snap",Ta="--ps-drag-snap-duration",Pn={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"]},ll=["low","high"],cl=["tx","ty","rot","leader-length","leader-angle"],Ho={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"}},ii=(e,t)=>`${e}-${t}`,Ln=(e,t,r)=>`var(${ii(e,t)}, ${r})`,Gc=(e,t,r)=>{const n=Ho[t];for(const o of ll)for(const a of cl)e.style.setProperty(ii(n[o],a),r[o][a])},ul=e=>Math.max(0,Math.min(1,e)),$o=(e,t,r,n)=>{const o=ul(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},si=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},jo=(e,t,r,n)=>{const o=ul(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},Ca=(e,t,r,n)=>{if(r){const i=(1-e)*100,l=(1-t)*100;return n?`M 12 ${l} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${l} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},sr=(e,t)=>`var(${e}, ${t}%)`,Kc=(e,t,r,n)=>{const[o,a]=Pn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},qc=e=>{for(const[t,r]of Object.values(Pn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Ho))for(const r of ll)for(const n of cl)e.style.removeProperty(ii(t[r],n))},Xc=["transform","translate","scale","rotate","perspective","filter","backdrop-filter"],Zc=["transform","translate","scale","rotate","perspective","filter"],Qc=["paint","layout","strict","content"],Jc=["paint","strict","content"],eu=new Set(["hidden","clip","auto","scroll","overlay"]),tu=(e,t)=>{const r=e.getPropertyValue("position");if(t==="absolute"&&r!==""&&r!=="static"||Xc.some(a=>!["","none"].includes(e.getPropertyValue(a)))||!["","normal"].includes(e.getPropertyValue("container-type")))return!0;const n=e.getPropertyValue("will-change");if(Zc.some(a=>n.includes(a)))return!0;const o=e.getPropertyValue("contain");return Qc.some(a=>o.includes(a))},ru=e=>{const t=e.getPropertyValue("display");if(t==="contents"||t==="inline")return!1;if(eu.has(e.getPropertyValue("overflow-y")))return!0;const r=e.getPropertyValue("contain");return Jc.some(n=>r.includes(n))},Ss=e=>{if(e.assignedSlot!==null)return e.assignedSlot;if(e.parentElement!==null)return e.parentElement;const t=e.parentNode;return t!==null&&t.nodeType===11&&"host"in t?t.host:null},nu=e=>{const t=e.ownerDocument,r=t.defaultView;if(r===null)return[];const n=[];let o=r.getComputedStyle(e).getPropertyValue("position");for(let a=Ss(e);a!==null&&a!==t.documentElement&&a!==t.body;a=Ss(a)){const i=r.getComputedStyle(a);(o==="absolute"||o==="fixed")&&!tu(i,o)||(ru(i)&&n.push(a),o=i.getPropertyValue("position"))}return n},ou=e=>{const t=e.getBoundingClientRect(),r="offsetHeight"in e&&typeof e.offsetHeight=="number"?e.offsetHeight:0,n=r>0?t.height/r:1,o=t.top+e.clientTop*n;return{top:o,bottom:o+e.clientHeight*n}},au=(e,t,r)=>{const n=e.getBoundingClientRect(),o=e.ownerDocument.documentElement.clientHeight;if(!(n.height>0&&o>0))return null;const a=n.top+n.height/2;let i=0,l=o;for(const u of nu(e)){const d=ou(u);i=Math.max(i,d.top),l=Math.min(l,d.bottom)}return t?.isConnected&&(i=Math.max(i,t.getBoundingClientRect().bottom)),r?.isConnected&&(l=Math.min(l,r.getBoundingClientRect().top)),{topPx:Math.max(0,a-i),bottomPx:Math.max(0,l-a)}},iu=(e,t,r,n)=>{const o=e.ownerDocument.defaultView;if(o===null)return null;const a=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(!(a.height>0&&i.height>0))return null;const l=a.top+a.height/2,u=Number.parseFloat(o.getComputedStyle(r).getPropertyValue(n==="top"?"bottom":"top"));if(!Number.isFinite(u))return null;const d=n==="top"?i.bottom-u:i.top+u;return{anchorPx:Math.abs(d-l),knobCentrePx:Math.abs(i.top+i.height/2-l)}},dl=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],Fo=[...mr.VIRTUAL_SCROLL_LABEL_KEYS,...dl],Ua=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:"日"})}),ml=Object.freeze({en:Object.freeze({...mr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Ua.en}),ja:Object.freeze({...mr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Ua.ja})}),xs=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,su=e=>Fo.includes(e),lu=(e,t)=>{const r={};let n=!1;for(const o of mr.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},cu=e=>{try{return mr.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}},fl=(e,t)=>{const r=cu(e);if(t===void 0)return ml[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${xs(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const l of o)if(!su(l))throw new RangeError(`[period-slider] labels.${l} is not a known label key; expected one of ${Fo.join(", ")}`);const i={...mr.resolveVirtualScrollLabels(r,lu(t,o)),...Ua[r]};for(const l of dl){const u=o.has(l)?t[l]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[period-slider] labels.${l} must be a non-blank string; got ${xs(u)}`);i[l]=u}}return Object.freeze(i)},uu=e=>{const t={};for(const r of mr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},du=(e,t)=>e===t||Fo.every(r=>e[r]===t[r]),Uo=(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]))},Ia=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Rs=new Set(["hidden","clip","scroll","auto","overlay"]),Ms=["paint","strict","content"],mu=["layout","paint","strict","content"],fu=["transform","perspective","filter"],vn=e=>e!==void 0&&e!==""&&e!=="none",hu=e=>e!==void 0&&e!==""&&e!=="normal",lo=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},gu=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,pu=(e,t)=>t==="absolute"&&vn(e.position)&&e.position!=="static"||vn(e.transform)||vn(e.perspective)||vn(e.filter)||vn(e.backdropFilter)||hu(e.containerType)||mu.some(r=>e.contain.includes(r))?!0:fu.some(r=>e.willChange.includes(r)),bu=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const l=e.getBoundingClientRect();if(l.width===0||l.height===0)return!1;const u=n?0:r,d=n?r:0;if(o<l.left-u||o>=l.right+u||a<l.top-d||a>=l.bottom+d)return!1;const m=i.getComputedStyle(t);if(m.visibility!=="visible")return!1;let x=null;for(let L=t;L!==null;L=L.parentElement){const T=L===t?m:i.getComputedStyle(L);if(x!==null&&!pu(T,x))continue;const b=Rs.has(T.overflowX)||Ms.some(w=>T.contain.includes(w)),g=Rs.has(T.overflowY)||Ms.some(w=>T.contain.includes(w));if(b||g){const w=L.getBoundingClientRect();if(b&&(o<w.left+lo(T.borderLeftWidth)||o>=w.right-lo(T.borderRightWidth))||g&&(a<w.top+lo(T.borderTopWidth)||a>=w.bottom-lo(T.borderBottomWidth)))return!1}x=gu(T)}return!0},ka=new Map,wu=(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)},vu=(e,t)=>{let r=ka.get(e);if(r===void 0){const a=new Set,i=l=>wu(a,l);r={participants:a,listener:i},ka.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)&&(ka.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Tn="gap-[11px]",Su={single:1,double:2},yn=6,Er=yn*2,co=(e,t)=>{const r=Su[e],n=(r-1)*yn+yn*4/3,o=Er/2,a=Array.from({length:r},(l,u)=>{const d=u*yn,m=d+yn;return{left:`${d},${o} ${m},0 ${m},${Er}`,right:`${n-d},${o} ${n-m},0 ${n-m},${Er}`,up:`${o},${d} 0,${m} ${Er},${m}`,down:`${o},${n-d} 0,${n-m} ${Er},${n-m}`}[t]}),i=t==="up"||t==="down";return{widthPx:i?Er:n,heightPx:i?n:Er,triangles:a}},Ds=e=>({left:co(e,"left"),right:co(e,"right"),up:co(e,"up"),down:co(e,"down")}),xu={single:Ds("single"),double:Ds("double")},li=(e,t)=>{if(t===void 0)return"single";if(t==="single"||t==="double")return t;throw new RangeError(`${e}: stepGlyph must be "single" or "double" (received: ${y(t)})`)},Aa=e=>{e.preventDefault(),e.stopPropagation()},Ru={onMouseDownCapture:Aa,onMouseUpCapture:Aa,onClickCapture:Aa},Mu="period-slider-step",Du=`${Mu} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,yu="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]",Eu={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"},uo="after:inset-[calc((100%-var(--ps-target-size))/2)]",ys={horizontal:"px-[19px]",vertical:"py-[19px]"},Pu={control:{left:uo,right:uo,up:uo,down:uo},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)]"}},Tr=({direction:e,glyph:t,neighbour:r,disabled:n,canStep:o,onStep:a,ariaLabel:i,className:l,ref:u})=>{const{widthPx:d,heightPx:m,triangles:x}=xu[t][e],L=n||!o;return C.jsx("button",{ref:u,type:"button","aria-label":i,disabled:n,"aria-disabled":L?!0:void 0,...L?Ru:null,onClick:L?void 0:a,className:`${l===void 0?"":`${l} `}${Du} ${yu} ${Eu[r]} ${Pu[r][e]}`,children:C.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,"data-glyph":t,width:d,height:m,viewBox:`0 0 ${d} ${m}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:x.map(T=>C.jsx("polygon",{points:T},T))})})},zo=(e,t)=>{const r=s.useMemo(()=>fl(e,t),[e,t]),n=s.useRef(r);return du(n.current,r)||(n.current=r),n.current},dt=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${y(r)})`)},hr=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&dt(e,"values.min",t.min),t.max!==null&&dt(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}dt(e,"values.loIndex",t.loIndex),dt(e,"values.hiIndex",t.hiIndex)},jn=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Bo=(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},Cn=(e,t)=>(hr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:jn(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),In=(e,t)=>{if(hr("drawnValuesHas",e),dt("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(jn(e))return!1;const r=Bo(e,t);return r<=e.hiIndex&&e.ascending[r]===t},kn=(e,t)=>{if(hr("drawnValuesNearest",e),dt("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(jn(e))return null;const r=Bo(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(hr("drawnValuesNeighbour",e),dt("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(jn(e))return null;const n=Bo(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(hr("clampPairIntoDrawnValues",e),dt("clampPairIntoDrawnValues","low",t),dt("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=kn(e,t),o=kn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},Lu=(e,t,r)=>{if(hr("carryPairIntoDrawnValues",e),dt("carryPairIntoDrawnValues","low",t),dt("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(jn(e))return null;const n=Cn(e,-1),o=Cn(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)},xo=(e,t,r)=>(hr("drawnValuesAtOrBeyond",e),dt("drawnValuesAtOrBeyond","target",t),Zt(e,t-r,r)),ln=(e,t,r)=>{if(t!==null&&dt("drawnValuesWithin","min",t),r!==null&&dt("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:Bo(n,t),hiIndex:o-1}},Ro=e=>(hr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Zt(e,t,r),edge:t=>Cn(e,t)}),za=(e,t,r,n,o)=>{if(dt("stepPair","low",t),dt("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,l=e.stepEnd(i,n);if(l===null)return null;let u=e.stepEnd(a,n);if(u===null){const d=e.edge(n);if(o.edge==="disable"||d===null||(n===1?a>d:a<d))return null;u=d}return n===1?[l,u]:[u,l]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${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)})`)}},hl={"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"}},gl=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Nt=(e,t)=>{if(!gl(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${y(t)})`)},gr=(e,t)=>t===void 0?0:(Nt(e,t),t),Le=(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:(Le(e,t,r),r),$u=[31,28,31,30,31,30,31,31,30,31,30,31],pl=719468,Mo=146097,Ba=(e,t)=>t!==1?$u[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,ci=(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,Ba(a,i))]},An=(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,l=Math.floor((153*i+2)/5)+r-1,u=a*365+Math.floor(a/4)-Math.floor(a/100)+l;return o*Mo+u-pl},Es=e=>{const t=e+pl,r=Math.floor(t/Mo),n=t-r*Mo,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(Mo-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),l=i<10?i+2:i-10;return[r*400+o+(l<2?1:0),l,a-Math.floor((153*i+2)/5)+1]},Wo=(e,t,r)=>e-(t<r?1:0),Rt=(e,t,r=0)=>{if(Le("normalizeDateByUnit","unit",e),!De(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${y(t)})`);Nt("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(Wo(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},U=(e,t,r=0)=>{Le("encode","unit",e),Nt("encode",r);const n=Rt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:An(o,a,n.getDate())},se=(e,t,r=0)=>{Le("decode","unit",e),Nt("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},Fn=e=>`; ${e} instead of a sentinel for "no bound"`,bl=Fn("minDate is required, so pass the earliest date to offer"),Ke=(e,t,r,n,o,a)=>{const i=Un(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},Un=(e,t,r)=>{const n=U(t,e,r);return Number.isInteger(n)?n:null},wl=(e,t,r)=>{if(Le("addUnit","unit",e),!De(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(...ci(n.getFullYear(),n.getMonth(),n.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},Ps=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,l,u]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:Es(t),[d,m,x]=r==="year"||r==="month"?ci(i,l,u,r==="year"?n*12:n):Es(An(i,l,u)+n);return e==="year"?Wo(d,m,o):e==="month"?d*12+m:An(d,m,x)},vl=(e,t,r,n=0)=>{if(Le("getMacroWindowStartDate","macroUnit",e),Le("getMacroWindowStartDate","microUnit",t),!De(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${y(r)})`);return Nt("getMacroWindowStartDate",n),Ke("getMacroWindowStartDate","d",r,e,n,""),Ke("getMacroWindowStartDate","d",r,t,n,""),Rt(t,Rt(e,r,n),n)},Sl=(e,t,r,n=0)=>{if(Le("getMacroWindowEndDate","macroUnit",e),Le("getMacroWindowEndDate","microUnit",t),!De(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${y(r)})`);Nt("getMacroWindowEndDate",n);let o;const a=new Date(r.getTime());if(e==="year"&&t!=="year"){const[l,u]=ci(Wo(a.getFullYear(),a.getMonth(),n),n,1,11);o=t==="month"?l*12+u:An(l,u,Ba(l,u))}else if(e==="month"&&t==="day")o=An(a.getFullYear(),a.getMonth(),Ba(a.getFullYear(),a.getMonth()));else return Ke("getMacroWindowEndDate","d",r,t,n,""),Rt(t,r,n);const i=se(t,o,n);if(!De(i))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${y(r)})`);return i},Ls=(e,t,r)=>e<t?t:e>r?r:e,$t=(e,t,r,n,o,a=0)=>{if(Le("resolveMacroWindow","macroUnit",e),Le("resolveMacroWindow","microUnit",t),Nt("resolveMacroWindow",a),Co("macroRange",r,!0,"resolveMacroWindow"),!De(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${y(n)})`);if(!De(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)})`);Ke("resolveMacroWindow","maxDate",o,t,a,""),Ke("resolveMacroWindow","macroRange[0]",r[0],e,a,""),Ke("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=U(e,r[1],a)<U(e,o,a)?Ls(Sl(e,t,r[1],a),n,o):o;return[Rt(t,Ls(vl(e,t,r[0],a),n,o),a),Rt(t,i,a)]},xl=(e,t)=>{if(!De(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${y(e)})`);Nt("resolveQuarter",t);const r=Rt("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}},Tu={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},$s=new Map,Cu=(e,t)=>{const r=`${e}\0${t}`,n=$s.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Tu[e]);return $s.set(r,o),o},Iu=4,ku=6,Go=e=>e>=0?String(e).padStart(Iu,"0"):`-${String(-e).padStart(ku,"0")}`,Au=(e,t)=>{const r=new Date(t.getTime()),n=Go(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}`},it=(e,t,r,n)=>(Le("formatLabel","unit",e),De(t)?r?r(t,e,"period"):n===void 0?Au(e,t):Cu(e,n).format(t):""),Pr=(e,t,r,n)=>(Le("formatScreenReaderLabel","unit",e),it(e,t,r,n)),Nu=(e,t)=>{if(!De(e))return"";Nt("formatQuarterLabel",t);const{quarter:r}=xl(e,t);return`${it("year",Rt("year",e,t))}-Q${r}`},Me=(e,t,r,n=0)=>{if(Le("findNearestDateIndex","unit",r),Nt("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!De(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${y(t)})`);const o=Ke("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=U(r,e[a],n))return 0;if(o>=U(r,e[i],n))return i;for(;a<=i;){const d=a+i>>1,m=U(r,e[d],n);if(m===o)return d;m<o?a=d+1:i=d-1}const l=Math.abs(U(r,e[a],n)-o),u=Math.abs(U(r,e[i],n)-o);return l<u?a:i},Vu=(e,t,r,n,o=0)=>(Le("getSortedAllowedDates","unit",t),fr("getSortedAllowedDates",Ko(e),t,r,n,o).dates),Ko=e=>({list:e,path:"allowedDates",inheritedBy:null}),fr=(e,t,r,n,o,a)=>{Nt(e,a);const{list:i,path:l}=t,u=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(sn(e,`${l}${u}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[T,b]of[["minDate",n],["maxDate",o]])if(!De(b))throw new RangeError(`${e}: ${T} must be a valid Date (received: ${y(b)})`);const d=Ke(e,"minDate",n,r,a,""),m=Ke(e,"maxDate",o,r,a,""),x=new Map;for(let T=0;T<i.length;T++){const b=i[T];if(!De(b))throw new RangeError(`${e}: ${l}[${T}]${u} must be a valid Date (received: ${y(b)})`);const g=Ke(e,`${l}[${T}]${u}`,b,r,a,"");g<d||g>m||x.has(g)||x.set(g,Rt(r,b,a))}if(x.size===0)throw new RangeError(`${e}: every ${l} entry${u} falls outside [minDate, maxDate] (minDate: ${y(n)}, maxDate: ${y(o)}, entries: ${i.length})`);const L=Array.from(x.keys()).sort((T,b)=>T-b);return{keys:L,dates:L.map(T=>x.get(T))}},ui=(e,t,r,n,o,a)=>{const{keys:i,dates:l}=fr(e,t,r,n,o,a);return l.length===0?null:{...ln(i,null,null),dates:l}},Nn=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),mo=(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 l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-l)/u))}return i/a},fo=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Me(e,new Date(l+i*u),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},Wa=(e,t,r,n,o,a,i)=>{let l=r,u=n;return i?(l=t,u=t):e==="low"?t>n?(l=n,u=t):l=t:t<r?(u=r,l=t):u=t,[Math.max(o,Math.min(a,l)),Math.max(o,Math.min(a,u))]},Rl=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:l,unit:u,yearStartMonth:d=0})=>{if(Le("calculateConnectDragValues","unit",u),a){const g=i.length-1;if(g<=0)return[0,0];const w=Math.max(0,Math.min(g,Math.round(t))),h=Math.max(w,Math.min(g,Math.round(r)));if(l==="time"){const f=i[0].getTime(),ue=i[g].getTime(),K=i[w].getTime(),re=i[h].getTime()-K;let ee=K+e*(ue-f),B=ee+re;ee<f&&(ee=f,B=f+re),B>ue&&(B=ue,ee=ue-re);const ne=Me(i,new Date(ee),u,d),A=Me(i,new Date(B),u,d);return[ne,Math.max(ne,A)]}const D=Math.round(e*g);let M=w+D,v=h+D;return M<0&&(v+=-M,M=0),v>g&&(M-=v-g,v=g),[Math.max(0,Math.min(g,M)),Math.max(0,Math.min(g,v))]}const m=g=>Math.max(n,Math.min(o,g)),x=o-n;if(x<=0)return[m(t),m(r)];const L=Math.round(e*x);let T=t+L,b=r+L;return T<n&&(b+=n-T,T=n),b>o&&(T-=b-o,b=o),[m(T),m(b)]},Ml=(e,t,r,n,o,a,i,l)=>{let u=0,d=!1,m=!1;switch(e){case"ArrowRight":case"ArrowUp":u=l;break;case"ArrowLeft":case"ArrowDown":u=-l;break;case"PageUp":u=l*5;break;case"PageDown":u=-l*5;break;case"Home":d=!0;break;case"End":m=!0;break;default:return null}if(i){let T=r;return d?T=o:m?T=a:T=Math.max(o,Math.min(a,r+u)),[T,T]}let x=r,L=n;return t==="low"?d?x=o:m?x=n:x=Math.max(o,Math.min(n,r+u)):d?L=r:m?L=a:L=Math.max(r,Math.min(a,n+u)),[x,L]},Dl=8,yl=2,El=16,Ou=12,_u=90,di=1.15,qo=(e,t,r)=>{const n=r*Math.PI/180,o=Math.abs(Math.sin(n)),a=Math.abs(Math.cos(n));return{alongPx:(e*a+t*o)/2,acrossPx:(e*o+t*a)/2}},To=e=>Dl+(e?.anchorGapY??yl),Xo=(e,t)=>{const r=t?.estimatedHeightPx??El,o=To(t)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,isFlipped:!1,proximity:0}},Yu=e=>{for(const t of["topPx","bottomPx"]){const r=e[t];if(typeof r!="number"||Number.isNaN(r)||r<0)throw new RangeError(`calculateLabelSlant: config.room.${t} must be a number of pixels, zero or more (Infinity for unbounded) (received: ${y(r)})`)}},Hu=(e,t,r)=>{if(r<=t/2)return 0;const n=Math.min(1,2*r/Math.hypot(e,t));return(Math.asin(n)-Math.atan2(t,e))*180/Math.PI},ju=(e,t,r,n,o,a,i,l)=>{if(i===void 0)return{side:t,angleDeg:e};const u=t==="top"?"bottom":"top",d=b=>b==="top"?i.topPx:i.bottomPx,m=b=>b===t?o:a,x=b=>m(b)+(1+l)*qo(r,n,e).acrossPx;if(x(t)<=d(t))return{side:t,angleDeg:e};if(x(u)<=d(u))return{side:u,angleDeg:e};const L=d(u)-m(u)>d(t)-m(t)?u:t,T=(d(L)-m(L))/(1+l);return{side:L,angleDeg:Math.min(e,Hu(r,n,T))}},Pl=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??El,l=o?.paddingPx??Ou,u=o?.maxAngleDeg??_u,d=o?.room,m=o?.drawnScale??1;if(d!==void 0&&Yu(d),typeof m!="number"||!Number.isFinite(m)||m<=0)throw new RangeError(`calculateLabelSlant: config.drawnScale must be a positive finite number (received: ${y(m)})`);const x=To(o),L=o?.flipClearancePx??x;if(typeof L!="number"||!Number.isFinite(L)||L<0)throw new RangeError(`calculateLabelSlant: config.flipClearancePx must be a finite number of pixels, zero or more (received: ${y(L)})`);const T=Xo(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return T;const b=Math.max(0,t-e)/100*r,g=a+l;if(b>=g)return T;const w=Math.max(0,Math.min(1,(g-b)/g)),h=w*w*w*(w*(w*6-15)+10),D=ju(h*u,n,a,i,x,L,d,m),M=D.angleDeg===0?0:D.side==="top"?-D.angleDeg:D.angleDeg,v=qo(a,i,D.angleDeg),f=(D.side===n?x:L)+v.acrossPx,ue=D.side==="top"?-f:+f,K=2*v.alongPx,re=Math.max(0,(K+l-b)/2);return{lowAngleDeg:M,highAngleDeg:M,lowOffsetX:-re,highOffsetX:re,lowOffsetY:ue,highOffsetY:ue,isSlanted:w>.001,isFlipped:D.side!==n,proximity:w}},Fu=e=>({...e,lowOffsetX:0,highOffsetX:0}),mi=(e,t,r,n)=>{if(r.isMerged&&r.keepMergedLabelUpright)return Xo(r.labelPosition,n);const o=Pl(e,t,r.trackLengthPx,r.labelPosition,n);return r.isMerged?Fu(o):o},Ht=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Lt=(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}},Do=(e,t,r,n)=>e==="pan"?Lu(t,r,Math.max(r,n)):So(t,r,Math.max(r,n)),fi=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},Ll=(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 $l(e,t,r,n,o,a,i="macro-top",l=.05,u=!0,d="range"){if(fi(t,i)==="macro"){const L=Math.abs(e-r),T=Math.abs(e-n);return L<=l&&L<=T?"macro-low":T<=l&&T<L?"macro-high":u&&e>=r&&e<=n?"macro-connect":L<T?"macro-low":"macro-high"}if(d==="point")return"micro-point";const m=Math.abs(e-o),x=Math.abs(e-a);return m<=l&&m<=x?"micro-low":x<=l&&x<m?"micro-high":u&&e>=o&&e<=a?"micro-connect":m<x?"micro-low":"micro-high"}function Tl(e,t,r,n,o){if(e==="macro-connect"){const[d,m]=si(t-r,n,o);return[d,m,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,l]=$o(a,t,n,o),u=jo(a,t,n,o);return[i,l,u==="low"?"macro-low":"macro-high"]}function Cl(e,t,r,n,o){if(e==="micro-point"){const[d]=$o("point",t,n,o);return[d,d,"micro-point"]}if(e==="micro-connect"){const[d,m]=si(t-r,n,o);return[d,m,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,l]=$o(a,t,n,o),u=jo(a,t,n,o);return[i,l,u==="low"?"micro-low":"micro-high"]}const En=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 C.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:C.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});En.displayName="VernierKnobSvg";const Uu=(e,t,r,n)=>{if(!De(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${y(e)})`);if(!De(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)Ke("PeriodSlider","minDate",e,o,n,bl)},Co=(e,t,r,n="PeriodSlider")=>{if(!At(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(!De(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${y(o)})`);if(!De(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)})`)},Il=(e,t)=>{if(!De(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${y(t)})`)},Qr=(e,t,r,n,o,a)=>{const i=Ke("PeriodSlider",e,t,r,a,"");if(i<U(r,n,a)||i>U(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${y(t)}, minDate: ${y(n)}, maxDate: ${y(o)})`)},zu=(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&&(Co(o,a,!1),Qr(`${o}[0]`,a[0],e.unit,t,r,n),Qr(`${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&&(Il(o,a),Qr(o,a,e.unit,t,r,n))}},Bu=(e,t,r)=>{const n=e.yearStartMonth??0;Co("macroRange",e.macroRange,!0),Ke("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 d of["microValue","defaultMicroValue"]){const m=e[d];m!==void 0&&(Il(d,m),Qr(d,m,o,t,r,n))}const u=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(u===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[u,u]}}for(const u of["microRange","defaultMicroRange"]){const d=e[u];d!==void 0&&(Co(u,d,!1),Qr(`${u}[0]`,d[0],o,t,r,n),Qr(`${u}[1]`,d[1],o,t,r,n))}const l=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(l!==void 0)return{shape:"range",selection:l};throw a?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},Sn=(e,t,r,n,o,a,i,l,u)=>{const d=Me(e,n,t,u),m=Me(e,o,t,u);return i?d:l?m:Math.max(d,Math.min(m,Me(e,r,t,u)+a))},Na=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function Wu(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Gu(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const Ts=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback((a,i)=>{const l=r.current;if(l!==null&&l[0].getTime()===a.getTime()&&l[1].getTime()===i.getTime())return;const u=[a,i];r.current=u,t(u)},[]),o=s.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Zo=(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)})`)}},Ku=e=>{if(typeof e!="object"||e===null)return!1;try{return e.nodeType===1&&typeof e.getBoundingClientRect=="function"}catch{return!1}},Cs=(e,t)=>{if(t==null)return null;if(Ku(t))return t;let r=!1;try{r=typeof t=="object"&&"current"in t}catch{r=!1}throw new RangeError(`PeriodSlider: ${e} must be an Element or null (received: ${y(t)})${r?"; pass the element itself (ref.current), not the ref object":""}`)},Xr=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const l of i){const u=l.borderBoxSize?.[0];u!==void 0&&t(d=>d!==null&&Math.abs(d.widthPx-u.inlineSize)<.5&&Math.abs(d.heightPx-u.blockSize)<.5?d:{widthPx:u.inlineSize,heightPx:u.blockSize})}});a.observe(o),r.current=a},[]);return s.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},Is=(e,t)=>{const r=e.querySelector(`[data-handle-type^="${t}-"]`);if(r===null)return null;const n=r.querySelector("[data-tooltip-style]"),o=r.getAttribute("data-vernier-pos");return n===null||o!=="top"&&o!=="bottom"?null:iu(e,r,n,o)},qu=(e,t,r)=>{const n=au(e,t,r);return n===null?null:{room:n,macro:Is(e,"macro"),micro:Is(e,"micro")}},Xu=.5,Io=(e,t)=>e===t||Math.abs(e-t)<Xu,ks=(e,t)=>e===null||t===null?e===t:Io(e.anchorPx,t.anchorPx)&&Io(e.knobCentrePx,t.knobCentrePx),Zu=(e,t)=>e===null||t===null?e===t:Io(e.room.topPx,t.room.topPx)&&Io(e.room.bottomPx,t.room.bottomPx)&&ks(e.macro,t.macro)&&ks(e.micro,t.micro),Qu=(e,t)=>yo(Eo(e,t)),yo=e=>e===null?void 0:{estimatedWidthPx:e.widthPx,estimatedHeightPx:e.heightPx},Eo=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},Ju=e=>{const t=new Map;let r=0;for(const a of e){const{side:i,box:l}=a;if(l===null)continue;let u;if(a.reach==="inline-size")u=l.widthPx,r=Math.max(r,l.heightPx/2);else{const m=qo(l.widthPx,l.heightPx,a.angleDeg);u=a.centreFromAnchorPx+m.acrossPx,r=Math.max(r,m.alongPx+Math.abs(a.alongPushPx))}const d=t.get(i);t.set(i,d===void 0?u:Math.max(d,u))}if(t.size===0)return;const n={};for(const[a,i]of t)n[`--ps-label-reach-${a}`]=`${Math.ceil(i)}px`;const o=Math.ceil(r);return n["--ps-label-reach-main"]=`${o}px`,{style:n,mainPx:o}},Ga=(e,t,r)=>({"leader-length":`${r?Math.hypot(e,t):0}px`,"leader-angle":`${Math.atan2(t,e)*180/Math.PI}deg`}),As=(e,t,r,n)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`,...n}),Ns=(e,t,r,n)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`,...Ga(e,t,n)}),ko=(e,t)=>({"--ps-tooltip-tx":Ln(e,"tx",t.tx),"--ps-tooltip-ty":Ln(e,"ty",t.ty),"--ps-tooltip-rot":Ln(e,"rot",t.rot)}),Ao=(e,t)=>({"--ps-label-leader-length":Ln(e,"leader-length",t["leader-length"]),"--ps-label-leader-angle":Ln(e,"leader-angle",t["leader-angle"])}),Va=(e,t,r,n)=>{const o=ed(n),a=o===null?n.config:o.config,i=Xo(n.labelPosition,a);if(!n.isSlantable)return{slant:i,lowStyle:void 0,highStyle:void 0,lowLeaderStyle:void 0,highLeaderStyle:void 0,centreFromAnchorPx:Math.abs(i.lowOffsetY)-To(a),placements:null};const l=mi(t*100,r*100,n,a),u=Ho[e],d=o!==null&&l.isFlipped?o.oppositeAnchorPx:To(a),m=n.anchor===null?0:(n.labelPosition==="top"?-1:1)*n.anchor.knobCentrePx,x={low:As(l.lowOffsetX,l.lowOffsetY-i.lowOffsetY,l.lowAngleDeg,Ga(l.lowOffsetX,l.lowOffsetY-m,l.isFlipped)),high:As(l.highOffsetX,l.highOffsetY-i.highOffsetY,l.highAngleDeg,Ga(l.highOffsetX,l.highOffsetY-m,l.isFlipped))};return{slant:l,lowStyle:ko(u.low,x.low),highStyle:ko(u.high,x.high),lowLeaderStyle:Ao(u.low,x.low),highLeaderStyle:Ao(u.high,x.high),centreFromAnchorPx:Math.abs(l.lowOffsetY)-d,placements:x}},ed=e=>e.config===void 0||e.anchor===null||e.opposite===null||e.room===void 0?null:{config:{...e.config,anchorGapY:e.anchor.anchorPx-Dl,flipClearancePx:e.opposite.anchorPx+e.opposite.reachPx+yl,room:e.room,drawnScale:di},oppositeAnchorPx:e.opposite.anchorPx},Vs=(e,t,r,n)=>{if(r.anchor===null||n===null)return null;const o=r.isSlantable?mi(e*100,t*100,r,r.config).lowAngleDeg:0;return{anchorPx:r.anchor.anchorPx,reachPx:(1+di)*qo(n.widthPx,n.heightPx,o).acrossPx}},Os={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},_s=(e,t,r)=>{const n=Xo(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:Os,highStyle:Os,lowLeaderStyle:void 0,highLeaderStyle:void 0,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const u=r.config===void 0||r.room===void 0?r.config:{...r.config,room:r.room,drawnScale:di};a=mi(e,t,r,u)}const i=Ho.flat,l={low:Ns(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg,a.isFlipped),high:Ns(a.highOffsetX,a.highOffsetY,a.highAngleDeg,a.isFlipped)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...ko(i.low,l.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...ko(i.high,l.high)},lowLeaderStyle:o?Ao(i.low,l.low):void 0,highLeaderStyle:o?Ao(i.high,l.high):void 0,placements:o?l:null}},td={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},rd={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"}},Ys={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},nd={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Tn} ${ys.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Ys.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Tn} ${ys.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Ys.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"}},js=(e,t)=>{e.setPointerCapture(t)},od=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:l="",showStepper:u=!0,tooltipStyle:d="always",labelPosition:m="top",autoSlantLabels:x=!0,keepMergedLabelUpright:L=!1,showLabelLeaderLines:T=!1,isVertical:b=!1,hideConnectBar:g=!1,showTicks:w=!1,colorScheme:h="blue-rose",formatLocale:D}=e;Le("PeriodSlider","unit",t);const M=e.mode==="vernier"?Qt("PeriodSlider","macroUnit",e.macroUnit,t):t,v=e.mode==="vernier"?Qt("PeriodSlider","microUnit",e.microUnit,t):t,f=gr("PeriodSlider",e.yearStartMonth);Uu(r,n,e.mode==="vernier"?[M,v,t]:[t],f),zu(e,r,n),D!==void 0&&Zo("PeriodSlider","formatLocale",D);const ue=Cs("labelCeiling",e.labelCeiling),K=Cs("labelFloor",e.labelFloor),re=e.mode==="vernier"?Bu(e,r,n):null,ee=re!==null&&re.shape==="point",B=zo(e.locale,e.labels),ne=hl[h],A=s.useId(),q=s.useRef(e),j=r.getTime(),k=n.getTime(),$=e.mode==="vernier",H=s.useMemo(()=>$?[]:fr("PeriodSlider",Ko(o),t,r,n,f).dates,[$,o,t,j,k,f]),Y=H.length>0,{rangeMin:N,rangeMax:F}=s.useMemo(()=>Y?{rangeMin:0,rangeMax:H.length-1}:{rangeMin:U(t,r,f),rangeMax:U(t,n,f)},[Y,H,t,j,k,f]),G=e.mode==="point",he=s.useCallback(c=>{if(Y){const p=Math.max(0,Math.min(H.length-1,Math.round(c)));return H[p]}return se(t,Math.round(c),f)},[Y,H,t,f]),te=s.useCallback(c=>{if(c===void 0)return N;const p=Rt(t,c,f);return Y?Me(H,p,t,f):U(t,p,f)},[Y,H,t,N,f]),[le,Se]=s.useState(()=>re===null?null:re.selection),ae=le??(re===null?null:re.selection),ie=ae===null?null:Wu(ae,ee);s.useLayoutEffect(()=>{ie!==ae&&Se(c=>c===le?ie:c)});const pe=e.mode==="vernier"?e.microValue?.getTime():void 0,je=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,pe]),ft=Ts(),ge=Ts(),V=e.mode!=="vernier"?null:ee?je??ie:e.microRange!==void 0?e.microRange:ie,X=V===null?null:ge.shown??V,de=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?X?.[0]:void 0,Oe=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?X?.[1]:void 0,we=e.mode==="point"?e.value??e.defaultValue:void 0,tt=e.mode==="point"?we?.getTime():de?.getTime(),qe=e.mode==="range"?Oe?.getTime():tt,[Fe,st]=s.useMemo(()=>{if(e.mode==="point"){const S=te(we);return[S,S]}const c=te(de),p=te(Oe);return[Math.min(c,p),Math.max(c,p)]},[e.mode,tt,qe,te,we,de,Oe]),oe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:ee?e.microValue!==void 0:e.microRange!==void 0,[pt,Xe]=s.useState(()=>$?null:[Fe,st]),ht=pt??[Fe,st],[Ae,We]=s.useState(null),[ye,bt]=s.useState(null),rt=s.useRef(null),[zt,I]=s.useState("high"),[J,Ue]=s.useState(null),[lt,Ge]=s.useState(null),Re=Ae?Ae[0]:oe?Fe:ht[0],$e=Ae?Ae[1]:oe?st:ht[1],Ir=s.useRef([Re,$e]),_=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",P=_==="macro-top"||_==="macro-left",xe=e.mode==="vernier"?e.showVernierProjection??!0:!1,_e=e.mode==="vernier"?e.showVernierTicks??!0:!1,E=e.mode==="vernier"?e.showHairline??!0:!1,z=$?Ht("macro",e):Y,ce=$?Ht("micro",e):Y,Ne=$?Lt("macro",e).list:o,Te=$?Lt("micro",e).list:o,Ve=$?e.formatMacroLabel??e.formatLabel:e.formatLabel,Ye=$?e.formatMicroLabel??e.formatLabel:e.formatLabel,Tt=de?.getTime(),Jt=Oe?.getTime(),[nt,pr]=s.useState(null),er=s.useRef(null),[ra,kr]=s.useState(()=>ee?"micro-point":"micro-high"),Ze=Gu(ra,ee);s.useLayoutEffect(()=>{Ze!==ra&&kr(c=>c===ra?Ze:c)});const wt=s.useMemo(()=>U(M,r,f),[j,M,f]),Vt=s.useMemo(()=>U(M,n,f),[k,M,f]),Bn=s.useMemo(()=>$&&ce?ui("PeriodSlider",Lt("micro",e),v,r,n,f):null,[$,ce,Te,v,j,k,f]),Ce=s.useMemo(()=>$&&z?fr("PeriodSlider",Lt("macro",e),M,r,n,f).dates:[],[$,z,Ne,M,j,k,f]),vi=c=>[Math.max(wt,Math.min(Vt,U(M,c[0],f))),Math.max(wt,Math.min(Vt,U(M,c[1],f)))],[Si,xi]=e.mode!=="vernier"?[wt,Vt]:vi(e.macroRange),[Qe,ct]=ft.shown===null?[Si,xi]:vi(ft.shown),br=s.useMemo(()=>se(M,Qe,f),[M,Qe,f]),wr=s.useMemo(()=>se(M,ct,f),[M,ct,f]),Wn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:$t(M,v,[br,wr],r,n,f),[e.mode,br,wr,M,v,j,k,f]),He=s.useMemo(()=>U(v,Wn[0],f),[v,Wn,f]),ot=s.useMemo(()=>U(v,Wn[1],f),[v,Wn,f]),na=(c,p)=>Bn===null?[]:Nn(Bn,ln(Bn.ascending,c,p)),be=s.useMemo(()=>na(He,ot),[Bn,He,ot]),tr=z&&Ce.length>0,Ct=ce&&be.length>0,Ri=tr?U(M,Ce[0],f):wt,Mi=tr?U(M,Ce[Ce.length-1],f):Vt,Di=Ct?U(v,be[0],f):He,oa=Ct?U(v,be[be.length-1],f):ot,ql=Math.min(Ri,Qe),Xl=Math.max(Mi,ct),rr=(c,p,S,R)=>p.length>0?U(v,p[Me(p,c,v,f)],f):Math.max(S,Math.min(R,U(v,c,f))),Ar=Ct?be:[],ze=s.useMemo(()=>X===null?He:rr(X[0],Ar,He,ot),[Tt,He,ot,v,X,Ar]),at=s.useMemo(()=>X===null?ot:rr(X[1],Ar,He,ot),[Jt,He,ot,v,X,Ar]),Nr=s.useMemo(()=>se(v,ze,f),[v,ze,f]),Vr=s.useMemo(()=>se(v,at,f),[v,at,f]),yi=!$||V===null?null:{macroUnit:M,macroLowEnc:Si,macroHighEnc:xi,microUnit:v,microLowEnc:U(v,V[0],f),microHighEnc:U(v,V[1],f)},aa=s.useRef(yi),ia=Math.max(1,Vt-wt),Mt=tr?mo(Ce,M,a,br,f):Math.max(0,Math.min(1,(Qe-wt)/ia)),It=Math.max(Mt,tr?mo(Ce,M,a,wr,f):Math.min(1,(ct-wt)/ia)),Ei=c=>Math.max(Ri,Math.min(Mi,Math.round(wt+c*ia))),Gn=Math.max(1,ot-He),vr=Ct?mo(be,v,a,Nr,f):Math.max(0,Math.min(1,(ze-He)/Gn)),Or=Math.max(vr,Ct?mo(be,v,a,Vr,f):Math.min(1,(at-He)/Gn)),sa=s.useRef({timerId:null,emit:null}),Kn=s.useRef({timerId:null,emit:null}),qn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const c=[sa,Kn,qn];return()=>{for(const p of c)Na(p.current)}},[]);const _r=s.useCallback((c,p,S)=>{Na(c);const{debounceMs:R}=q.current;if(S||!R||R<=0){p();return}c.emit=p,c.timerId=setTimeout(()=>{c.timerId=null,c.emit=null,p()},R)},[]),Pi=s.useCallback(c=>{const p=c.emit;Na(c),p?.()},[]),Yr=s.useCallback(c=>new Date(Math.min(Math.max(c.getTime(),j),k)),[j,k]),nr=s.useCallback((c,p,S=!1)=>{const[R,O]=Ir.current;if((q.current.mode==="point"?c===R:c===R&&p===O)&&sa.current.timerId===null)return;const Z=he(c),Q=he(p),fe=()=>{const ve=q.current;ve.mode==="point"?ve.onChangePoint?.(Z):ve.mode==="range"&&ve.onChangeRange?.(Z,Q)};_r(sa.current,fe,S)},[he,_r]),Sr=s.useCallback((c,p,S=!1)=>{const R=aa.current;if(q.current.mode!=="vernier"||R===null)return;const O=Yr(c),W=Yr(p);U(R.macroUnit,O,f)===R.macroLowEnc&&U(R.macroUnit,W,f)===R.macroHighEnc&&Kn.current.timerId===null||_r(Kn.current,()=>{const Z=q.current;Z.mode==="vernier"&&Z.onChangeMacroRange?.(O,W)},S)},[Yr,_r,f]),Dt=s.useCallback((c,p,S=!1)=>{const R=q.current,O=aa.current;if(R.mode!=="vernier"||O===null)return;const W=Yr(c),Z=Yr(p);U(O.microUnit,W,f)===O.microLowEnc&&U(O.microUnit,Z,f)===O.microHighEnc&&qn.current.timerId===null||((ee?R.microValue===void 0:R.microRange===void 0)&&Se([W,Z]),_r(qn.current,()=>{const Q=q.current;if(Q.mode==="vernier"){if(ee){Q.onChangeMicroPoint?.(W);return}Q.onChangeMicroRange?.(W,Z)}},S))},[Yr,_r,ee,f]),Li=s.useCallback((c,p=!1)=>{Dt(c,c,p)},[Dt]),xr=s.useCallback(c=>{if(Y&&a==="time"&&H.length>1){const R=Math.max(0,Math.min(H.length-1,Math.round(c))),O=H[0].getTime(),Z=H[H.length-1].getTime()-O;if(Z<=0)return 0;const Q=H[R].getTime();return Math.max(0,Math.min(100,(Q-O)/Z*100))}const p=F-N;if(p<=0)return 0;const S=(c-N)/p*100;return Math.max(0,Math.min(100,S))},[Y,a,H,N,F]),la=s.useCallback(c=>{const p=Math.max(0,Math.min(100,c));if(Y){if(a==="time"&&H.length>1){const O=H[0].getTime(),Z=H[H.length-1].getTime()-O,Q=O+p/100*Z;return Me(H,new Date(Q),t,f)}const R=Math.round(p/100*(H.length-1));return Math.max(0,Math.min(H.length-1,R))}const S=N+p/100*(F-N);return Math.round(S)},[Y,a,H,N,F,t,f]),cn=s.useRef(null),$i=s.useRef(null),Ti=s.useRef(0),ut=s.useRef(null),ca=s.useRef(null),Ci=s.useRef(null),Ii=s.useRef(null),[ua,ki]=s.useState(0),[Zl,Xn]=Xr(),[Ql,Ai]=Xr(),[Jl,ec]=Xr(),[tc,rc]=Xr(),[nc,Ni]=Xr(),[oc,ac]=Xr(),[ic,sc]=s.useState(null),da=!b&&d!=="hover",Hr=da?ic:null,lc=G?yo(Xn):Qu(Xn,Ai),ma=!G&&Re===$e,fa=Qe===ct,ha=!ee&&ze===at,cc=P?"top":"bottom",uc=P?"bottom":"top",Vi=x&&!b,dc=Vi&&!ee,ga=Hr===null?void 0:Hr.room,pa={isPointMode:G,isVertical:b,autoSlantLabels:x,isMerged:ma,keepMergedLabelUpright:L,trackLengthPx:ua,labelPosition:m,config:lc,room:ga},ba=Eo(ec,rc),wa=ee?Ni:Eo(Ni,ac),Oi={trackLengthPx:ua,labelPosition:cc,config:yo(ba),isMerged:fa,keepMergedLabelUpright:L,isSlantable:Vi,room:ga,anchor:Hr===null?null:Hr.macro},_i={trackLengthPx:ua,labelPosition:uc,config:yo(wa),isMerged:ha,keepMergedLabelUpright:L,isSlantable:dc,room:ga,anchor:Hr===null?null:Hr.micro},va={...Oi,opposite:Vs(vr,Or,_i,wa)},Sa={..._i,opposite:Vs(Mt,It,Oi,ba)};s.useEffect(()=>{const c=ut.current;if(!c)return;const p=()=>{const R=c.getBoundingClientRect(),O=b?R.height:R.width;O>0&&ki(W=>Math.abs(W-O)<.5?W:O)};if(p(),typeof ResizeObserver<"u"){const R=new ResizeObserver(O=>{for(const W of O){const Z=b?W.contentRect.height:W.contentRect.width;Z>0&&ki(Q=>Math.abs(Q-Z)<.5?Q:Z)}});return R.observe(c),()=>R.disconnect()}const S=c.ownerDocument.defaultView;if(S)return S.addEventListener("resize",p),()=>S.removeEventListener("resize",p)},[b]);const jr=s.useCallback((c,p,S)=>{const R=b?S.height:S.width;if(!(Number.isFinite(R)&&R>0))return null;const O=b?S.bottom-p:c-S.left;return Number.isFinite(O)?Math.max(0,Math.min(1,O/R)):null},[b]),Yi=s.useCallback((c,p)=>{const S=ut.current;if(!S)return null;const R=jr(c,p,S.getBoundingClientRect());return R===null?null:R*100},[jr]),un=s.useRef(null),Bt=s.useRef(null),Zn=s.useRef({macroLowRatio:Mt,macroHighRatio:It,isVertical:b,isMacroFirstRail:P}),Hi=s.useRef({flat:pa,macro:va,micro:Sa}),ji=s.useRef({ceiling:ue,floor:K,isMeasured:da});s.useLayoutEffect(()=>{Zn.current={macroLowRatio:Mt,macroHighRatio:It,isVertical:b,isMacroFirstRail:P},Hi.current={flat:pa,macro:va,micro:Sa},ji.current={ceiling:ue,floor:K,isMeasured:da},q.current=e,Ir.current=[Re,$e],aa.current=yi,rt.current=ye,er.current=nt});const Fi=(c,p)=>{const S=Zn.current;ca.current?.setAttribute("d",Ca(c,p,S.isVertical,S.isMacroFirstRail))},mc=(c,p,S)=>{const R=Hi.current;return c==="flat"?_s(p*100,S*100,R.flat).placements:Va(c,p,S,c==="macro"?R.macro:R.micro).placements},dn=s.useCallback(()=>{const c=ut.current,p=ji.current;if(c===null||!p.isMeasured)return;const S=qu(c,p.ceiling,p.floor);sc(R=>Zu(R,S)?R:S)},[]),mn=(c,p,S)=>{const R=ut.current;if(!R)return;un.current={rail:c,lowRatio:p,highRatio:S},Kc(R,c,p,S);const O=mc(c,p,S);O!==null&&Gc(R,c,O),c==="macro"&&Fi(p,S)},Rr=s.useCallback(()=>{Bt.current!==null&&(clearTimeout(Bt.current),Bt.current=null);const c=ut.current;c&&(c.removeAttribute($a),c.style.removeProperty(Ta))},[]),Ui=()=>{const c=ut.current;if(un.current===null||!c){un.current=null;return}un.current=null,Bt.current!==null&&clearTimeout(Bt.current),c.style.setProperty(Ta,`${vs}ms`),c.setAttribute($a,"true"),qc(c),Fi(Zn.current.macroLowRatio,Zn.current.macroHighRatio),Bt.current=setTimeout(()=>{Bt.current=null,c.removeAttribute($a),c.style.removeProperty(Ta)},vs)};s.useLayoutEffect(()=>{const c=un.current;c!==null&&mn(c.rail,c.lowRatio,c.highRatio)}),s.useEffect(()=>()=>{Bt.current!==null&&clearTimeout(Bt.current)},[]);const Fr=s.useRef(null),Ur=s.useRef(null),Ot=s.useRef(null),xa=s.useRef(null),fn=s.useRef(null),or=s.useCallback(()=>Fr.current!==null||Ur.current!==null,[]),zi=c=>{if(i)return;if($){const me=Ur.current;if(!me||c.pointerId!==me.pointerId||!ut.current)return;const kt=jr(c.clientX,c.clientY,ut.current.getBoundingClientRect());if(kt===null)return;if(me.handle==="macro-low"||me.handle==="macro-high"||me.handle==="macro-connect"){const[Je,Be,Wt]=Tl(me.handle,kt,me.startPointerRatio,me.startMacroLowRatio,me.startMacroHighRatio);mn("macro",Je,Be),Wt!==er.current&&(er.current=Wt,pr(Wt),kr(Wt));let Yt,xt,Gt;if(tr){const Kt=fo(Ce,M,a,Je,f),wn=Math.max(Kt,fo(Ce,M,a,Be,f));xt=Ce[Kt],Gt=Ce[wn],Yt=U(M,xt,f)}else Yt=Ei(Je),xt=se(M,Yt,f),Gt=se(M,Ei(Be),f);ft.show(xt,Gt);const ir=`${xt.getTime()}_${Gt.getTime()}`;ir!==xa.current&&(xa.current=ir,Sr(xt,Gt));const[bn,Yc]=$t(M,v,[xt,Gt],r,n,f),io=U(v,bn,f),so=U(v,Yc,f),gs=ce?na(io,so):[],ps={kind:"range",min:io,max:so};let Dr,yr;if(me.handle==="macro-connect"){const Kt=Yt-me.startMacroLowEnc,wn=Do("pan",ps,Ps(v,me.initialMicroLowEnc,M,Kt,f),Ps(v,me.initialMicroHighEnc,M,Kt,f));if(wn===null)return;Dr=se(v,wn[0],f),yr=se(v,wn[1],f)}else{const Kt=Do("resize",ps,me.initialMicroLowEnc,me.initialMicroHighEnc);if(Kt===null)return;Dr=se(v,Kt[0],f),yr=se(v,Kt[1],f)}const bs=rr(Dr,gs,io,so),Hc=Math.max(bs,rr(yr,gs,io,so));Dr=se(v,bs,f),yr=se(v,Hc,f),ge.show(Dr,yr);const ws=`${Dr.getTime()}_${yr.getTime()}`;ws!==fn.current&&(fn.current=ws,Dt(Dr,yr))}else if(me.handle==="micro-low"||me.handle==="micro-high"||me.handle==="micro-connect"||me.handle==="micro-point"){const[Je,Be,Wt]=Cl(me.handle,kt,me.startPointerRatio,me.startMicroLowRatio,me.startMicroHighRatio);mn("micro",Je,Be),Wt!==er.current&&(er.current=Wt,pr(Wt),kr(Wt));let Yt,xt;if(Ct){const ir=fo(be,v,a,Je,f),bn=Math.max(ir,fo(be,v,a,Be,f));Yt=be[ir],xt=be[bn]}else{const ir=rr(se(v,Math.round(He+Je*Gn),f),Ar,He,ot),bn=Math.max(ir,rr(se(v,Math.round(He+Be*Gn),f),Ar,He,ot));Yt=se(v,ir,f),xt=se(v,bn,f)}ge.show(Yt,xt);const Gt=`${Yt.getTime()}_${xt.getTime()}`;Gt!==fn.current&&(fn.current=Gt,Dt(Yt,xt))}return}const p=Fr.current;if(!p||c.pointerId!==p.pointerId||!ut.current)return;const S=ut.current.getBoundingClientRect(),R=b?c.clientY:c.clientX,O=b?S.height:S.width;if(!(Number.isFinite(O)&&O>0))return;if(p.handle==="connect"){const me=b?(p.startPointerPos-R)/O:(R-p.startPointerPos)/O,[kt,Je]=si(me,p.startLowRatio,p.startHighRatio);mn("flat",kt,Je);const Be=Rl({posDiffPct:me,startLowVal:p.startLowVal,startHighVal:p.startHighVal,rangeMin:N,rangeMax:F,isDiscrete:Y,sortedAllowedDates:H,snapMode:a,unit:t,yearStartMonth:f});if(Ot.current&&Ot.current[0]===Be[0]&&Ot.current[1]===Be[1])return;Ot.current=Be,We(Be),nr(Be[0],Be[1],!1);return}const W=jr(c.clientX,c.clientY,S);if(W===null)return;const[Z,Q]=$o(G?"point":p.handle,W,p.startLowRatio,p.startHighRatio);mn("flat",Z,Q);const fe=la(W*100),[ve,Ie]=Wa(p.handle,fe,p.startLowVal,p.startHighVal,N,F,G);if((!Ot.current||Ot.current[0]!==ve||Ot.current[1]!==Ie)&&(Ot.current=[ve,Ie],We([ve,Ie]),nr(ve,Ie,!1)),!G&&(p.handle==="low"||p.handle==="high")){const me=jo(p.handle,W,p.startLowRatio,p.startHighRatio);rt.current!==me&&(rt.current=me,bt(me),I(me))}},Bi=()=>{Ui(),xa.current=null,fn.current=null,Ur.current=null,er.current=null,pr(null),ft.release(),ge.release(),Pi(Kn.current),Pi(qn.current)},Wi=()=>{Ui();const c=Ot.current??Ae;c&&(nr(c[0],c[1],!0),Xe(c)),Ot.current=null,We(null),Fr.current=null,rt.current=null,bt(null)},Gi=c=>{if($){const S=Ur.current;if(!S||c.pointerId!==S.pointerId)return;Bi();return}const p=Fr.current;!p||c.pointerId!==p.pointerId||Wi()},Ki=()=>{Ur.current!==null&&Bi(),Fr.current!==null&&Wi()},Ra=s.useRef(zi),qi=s.useRef(Gi),Xi=s.useRef(Ki);s.useLayoutEffect(()=>{Ra.current=zi,qi.current=Gi,Xi.current=Ki});const Zi=s.useRef($);s.useEffect(()=>{Zi.current!==$&&(Zi.current=$,Xi.current())},[$]);const Ma=ye!==null||nt!==null;s.useEffect(()=>{if(!Ma)return;const c=cn.current?.ownerDocument.defaultView;if(!c)return;const p=R=>Ra.current(R),S=R=>qi.current(R);return c.addEventListener("pointermove",p),c.addEventListener("pointerup",S),c.addEventListener("pointercancel",S),c.addEventListener("lostpointercapture",S),()=>{c.removeEventListener("pointermove",p),c.removeEventListener("pointerup",S),c.removeEventListener("pointercancel",S),c.removeEventListener("lostpointercapture",S)}},[Ma]);const Da=s.useCallback((c,p,S,R)=>{Rr(),js(c,p),dn(),Fr.current={pointerId:p,handle:S,startPointerPos:R,startLowVal:Re,startHighVal:$e,startLowRatio:xr(Re)/100,startHighRatio:xr($e)/100},rt.current=S,bt(S),S!=="connect"&&I(S)},[Re,$e,xr]),Qi=s.useCallback((c,p,S,R)=>{q.current.mode==="vernier"&&(Rr(),js(c,p),dn(),Ur.current={pointerId:p,handle:S,startPointerRatio:R,startMacroLowRatio:Mt,startMacroHighRatio:It,startMicroLowRatio:vr,startMicroHighRatio:Or,startMacroLowEnc:Qe,initialMicroLowEnc:ze,initialMicroHighEnc:at},er.current=S,pr(S),kr(S))},[Mt,It,vr,Or,Qe,ze,at]),Ji=c=>p=>{if(i||or())return;p.stopPropagation(),p.preventDefault(),I(c);const S=b?p.clientY:p.clientX;Da(p.currentTarget,p.pointerId,c,S)},es=c=>()=>{i||rt.current!==null||I(c)},Qn=c=>()=>{i||er.current!==null||kr(c)},zr=c=>p=>{if(i||or())return;p.stopPropagation(),p.preventDefault();const S=ut.current;if(!S)return;const R=jr(p.clientX,p.clientY,S.getBoundingClientRect());R!==null&&Qi(p.currentTarget,p.pointerId,c,R)},fc=c=>{if(i||g||or())return;c.stopPropagation(),c.preventDefault();const p=b?c.clientY:c.clientX;Da(c.currentTarget,c.pointerId,"connect",p)},hc=c=>{if(i||or())return;if($){const Q=ut.current;if(!Q)return;const fe=Q.getBoundingClientRect(),ve=jr(c.clientX,c.clientY,fe);if(ve===null)return;const Ie=b?c.clientX-(fe.left+fe.width/2):c.clientY-(fe.top+fe.height/2),me=$l(ve,Ie,Mt,It,vr,Or,_,void 0,!g,ee?"point":"range");Qi(c.currentTarget,c.pointerId,me,ve),Ra.current(c.nativeEvent);return}const p=Yi(c.clientX,c.clientY);if(p===null)return;const S=la(p);let R="low";if(!G){const Q=Math.abs(S-Re),fe=Math.abs(S-$e);Q<fe?R="low":fe<Q?R="high":R=S>$e?"high":"low"}I(R);const[O,W]=Wa(R,S,Re,$e,N,F,G);We([O,W]),nr(O,W,!0);const Z=b?c.clientY:c.clientX;Da(c.currentTarget,c.pointerId,R,Z)},gc=c=>{if(i||$||ye!==null)return;const p=Yi(c.clientX,c.clientY);if(p===null)return;const S=la(p);Ue(S),Ge(xr(S))},pc=()=>{Ue(null),Ge(null)},ts=c=>p=>{if(i||or())return;I(c);const S=Ml(p.key,c,Re,$e,N,F,G,1);S&&(p.preventDefault(),Rr(),oe||Xe(S),nr(S[0],S[1],!0))},Br=(c,p,S)=>{if(V===null)return;const[R,O]=$t(M,v,[c,p],r,n,f),W=U(v,R,f),Z=U(v,O,f),Q=ce?na(W,Z):[],fe=Do(S,{kind:"range",min:W,max:Z},U(v,V[0],f),U(v,V[1],f));if(fe===null)return;const ve=rr(se(v,fe[0],f),Q,W,Z),Ie=Math.max(ve,rr(se(v,fe[1],f),Q,W,Z));Dt(se(v,ve,f),se(v,Ie,f),!0)},Jn=c=>p=>{if(i||!$||e.mode!=="vernier"||or())return;kr(c);let S=0,R=!1,O=!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":O=!0;break;default:return}if(p.preventDefault(),Rr(),c==="macro-low"){const W=se(M,Qe,f),Z=se(M,ct,f);if(tr){const ve=Sn(Ce,M,W,Ce[0],Z,S,R,O,f);if(ve===Me(Ce,W,M,f))return;const Ie=Ce[ve];Sr(Ie,Z,!0),Br(Ie,Z,"resize");return}let Q;if(R?Q=wt:O?Q=ct:Q=Math.max(wt,Math.min(ct,Qe+S)),Q===Qe)return;const fe=se(M,Q,f);Sr(fe,Z,!0),Br(fe,Z,"resize")}else if(c==="macro-high"){const W=se(M,Qe,f),Z=se(M,ct,f);if(tr){const ve=Sn(Ce,M,Z,W,Ce[Ce.length-1],S,R,O,f);if(ve===Me(Ce,Z,M,f))return;const Ie=Ce[ve];Sr(W,Ie,!0),Br(W,Ie,"resize");return}let Q;if(R?Q=Qe:O?Q=Vt:Q=Math.max(Qe,Math.min(Vt,ct+S)),Q===ct)return;const fe=se(M,Q,f);Sr(W,fe,!0),Br(W,fe,"resize")}else if(c==="micro-low"){const W=se(v,ze,f),Z=se(v,at,f);if(Ct){const fe=Sn(be,v,W,be[0],Z,S,R,O,f);if(fe===Me(be,W,v,f))return;Dt(be[fe],Z,!0);return}let Q;if(R?Q=He:O?Q=at:Q=Math.max(He,Math.min(at,ze+S)),Q===ze)return;Dt(se(v,Q,f),Z,!0)}else if(c==="micro-high"){const W=se(v,ze,f),Z=se(v,at,f);if(Ct){const fe=Sn(be,v,Z,W,be[be.length-1],S,R,O,f);if(fe===Me(be,Z,v,f))return;Dt(W,be[fe],!0);return}let Q;if(R?Q=ze:O?Q=ot:Q=Math.max(ze,Math.min(ot,at+S)),Q===at)return;Dt(W,se(v,Q,f),!0)}else if(c==="micro-point"){const W=se(v,ze,f);if(Ct){const Q=Sn(be,v,W,be[0],be[be.length-1],S,R,O,f);if(Q===Me(be,W,v,f))return;Li(be[Q],!0);return}let Z;if(R?Z=He:O?Z=ot:Z=Math.max(He,Math.min(ot,ze+S)),Z===ze)return;Li(se(v,Z,f),!0)}},bc=c=>{if(e.mode!=="vernier")return;if(Rr(),tr){const Z=Ce.length-1,Q=Me(Ce,br,M,f),fe=Me(Ce,wr,M,f),ve=fe-Q;let Ie=Q+c,me=fe+c;if(c<0&&Ie<0?(Ie=0,me=Math.min(Z,ve)):c>0&&me>Z&&(me=Z,Ie=Math.max(0,Z-ve)),Ie===Q&&me===fe)return;const kt=Ce[Ie],Je=Ce[me];Sr(kt,Je,!0),Br(kt,Je,"pan");return}const p=ct-Qe;let S=Qe+c,R=ct+c;if(c<0&&S<wt?(S=wt,R=Math.min(Vt,S+p)):c>0&&R>Vt&&(R=Vt,S=Math.max(wt,R-p)),S===Qe&&R===ct)return;const O=se(M,S,f),W=se(M,R,f);Sr(O,W,!0),Br(O,W,"pan")},ya=s.useCallback(c=>{const p=q.current;if(!(p.disabled||or()))if(Rr(),p.mode==="point"){const S=Math.max(N,Math.min(F,Re+c));oe||Xe([S,S]),nr(S,S,!0)}else if(p.mode==="vernier"){if(Ct){const ve=be.length-1,Ie=Me(be,Nr,v,f),me=Me(be,Vr,v,f),kt=me-Ie;let Je=Ie+c,Be=me+c;c<0&&Je<0?(Je=0,Be=Math.min(ve,kt)):c>0&&Be>ve&&(Be=ve,Je=Math.max(0,ve-kt)),(Je!==Ie||Be!==me)&&Dt(be[Je],be[Be],!0);return}const S=ze,R=at,O=He,W=ot,Z=R-S;let Q=S+c,fe=R+c;c<0&&Q<O?(Q=O,fe=Math.min(W,Q+Z)):c>0&&fe>W&&(fe=W,Q=Math.max(O,fe-Z)),(Q!==S||fe!==R)&&Dt(se(v,Q,f),se(v,fe,f),!0)}else{const S=$e-Re;let R=Re+c,O=$e+c;c<0&&R<N?(R=N,O=Math.min(F,R+S)):c>0&&O>F&&(O=F,R=Math.max(N,O-S)),R<=O&&(oe||Xe([R,O]),nr(R,O,!0))}},[Re,$e,N,F,oe,nr,Dt,ze,at,He,ot,v,Ct,be,Nr,Vr,Rr,f]),rs=c=>!i&&Ia(cn.current,c),ns=(c,p)=>{const S=$i.current,R=ut.current,O=cn.current;if(i||S===null||R===null||O===null||!bu(S,O,Ti.current,b,c,p))return null;const W=R.getBoundingClientRect();return Math.abs(b?c-(W.left+W.width/2):p-(W.top+W.height/2))},os=c=>{if(i||or())return;const p=Ll(c.deltaX,c.deltaY,b);if(p===0)return;c.preventDefault();const S=c.target,R=Ia(Ci.current,S)||Ia(Ii.current,S);if(!$||R){ya(p);return}const O=ut.current;if(!O)return;const W=O.getBoundingClientRect(),Z=b?c.clientX-(W.left+W.width/2):c.clientY-(W.top+W.height/2);if(fi(Z,_)==="macro"){bc(p);return}ya(p)},eo=s.useRef({ownsWheelHit:rs,distanceToRailPx:ns,stepFromRangeAreaWheel:os});s.useLayoutEffect(()=>{eo.current={ownsWheelHit:rs,distanceToRailPx:ns,stepFromRangeAreaWheel:os}});const hn=s.useRef(null);s.useEffect(()=>{const c=cn.current?.ownerDocument.defaultView??null,p=hn.current;if(p!==null&&p.view===c)return;if(p?.unregister(),c===null){hn.current=null;return}const S=vu(c,{ownsHit:R=>eo.current.ownsWheelHit(R),distanceToRailPx:(R,O)=>eo.current.distanceToRailPx(R,O),step:R=>eo.current.stepFromRangeAreaWheel(R)});hn.current={view:c,unregister:S}}),s.useEffect(()=>()=>{hn.current?.unregister(),hn.current=null},[]);const to=xr(Re),ro=xr($e),Ea=he(Re),Pa=he($e),Wr=_s(to,ro,pa),ar=Wr.slant,gn=ye==="low"||ye!=="high"&&zt==="low",pn=!G&&(ye==="high"||ye!=="low"&&zt==="high"),wc=fa&&Ze!=="macro-low",vc=fa&&Ze==="macro-low",Sc=ha&&Ze!=="micro-low",xc=ha&&Ze==="micro-low",vt=Va("macro",Mt,It,va),St=Va("micro",vr,Or,Sa),as=Wr.slant.isSlanted||vt.slant.isSlanted||St.slant.isSlanted;s.useLayoutEffect(()=>{as&&dn()});const is=as||Ma;s.useEffect(()=>{if(!is)return;const c=ut.current,p=c===null?null:c.ownerDocument.defaultView;if(c===null||p===null)return;const S=c.ownerDocument;let R=null;const O=()=>{R===null&&(R=p.requestAnimationFrame(()=>{R=null,dn()}))};S.addEventListener("scroll",O,{capture:!0,passive:!0}),p.addEventListener("resize",O);const W=typeof ResizeObserver>"u"?null:new ResizeObserver(O);for(const Z of[ue,K])Z!==null&&W?.observe(Z);return()=>{S.removeEventListener("scroll",O,{capture:!0}),p.removeEventListener("resize",O),W?.disconnect(),R!==null&&p.cancelAnimationFrame(R)}},[is,ue,K,dn]);const Rc=Math.min(to,ro),Mc=Math.max(to,ro),[ss,ls]=Pn.flat,[Dc,yc]=Pn.macro,[Ec,Pc]=Pn.micro,cs=sr(ss,to),us=sr(ls,ro),La=sr(ss,Rc),ds=`calc(${sr(ls,Mc)} - ${La})`,Gr=sr(Dc,Mt*100),no=sr(yc,It*100),Kr=sr(Ec,vr*100),oo=sr(Pc,Or*100),Lc=b?{bottom:La,height:ds,top:"auto",left:"0",right:"0"}:{left:La,width:ds,top:"0",bottom:"0"},$c=Math.max(.01,It-Mt),ms=Math.max(.06,Math.min(.25,.28*Math.sqrt($c))),Tc=b?{bottom:cs,left:"50%",transform:"translate(-50%, 50%)",zIndex:gn?40:30}:{left:cs,top:"50%",transform:"translate(-50%, -50%)",zIndex:gn?40:30},Cc=b?{bottom:us,left:"50%",transform:"translate(-50%, 50%)",zIndex:pn?40:30}:{left:us,top:"50%",transform:"translate(-50%, -50%)",zIndex:pn?40:30},Ic=b?{bottom:`${lt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${lt}%`,top:"50%",transform:"translate(-50%, -50%)"},fs=J!==null?he(J):null,kc=d!=="hover"&&J!==null&&(J===Re||!G&&J===$e),Ac=$?ze>Di:Re>N,Nc=$?at<oa:$e<F,Vc=P!==vt.slant.isFlipped?"before":"after",Oc=P===St.slant.isFlipped?"before":"after",ao=Ju($?[{side:Vc,box:ba,...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:vt.slant.lowAngleDeg,centreFromAnchorPx:vt.centreFromAnchorPx,alongPushPx:vt.slant.lowOffsetX}},{side:Oc,box:wa,...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:St.slant.lowAngleDeg,centreFromAnchorPx:St.centreFromAnchorPx,alongPushPx:St.slant.lowOffsetX}}]:[{side:b||m==="top"!==ar.isFlipped?"before":"after",box:G?Xn:Eo(Xn,Ai),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:ar.lowAngleDeg,centreFromAnchorPx:Math.abs(ar.lowOffsetY),alongPushPx:ar.lowOffsetX}}]),_c=ao===void 0?e.style:{...e.style,...ao.style};s.useLayoutEffect(()=>{Ti.current=ao===void 0?0:ao.mainPx});const _t=ee?"micro-point":"micro-low",Mr=i?"cursor-not-allowed opacity-50":"cursor-pointer",qr=c=>d==="hover"||!T||c===void 0?null:C.jsx("span",{"data-label-leader":"true","aria-hidden":"true",className:"period-slider-label-leader",style:c}),hs=c=>{const p=b?"vertical":"horizontal",S=c==="decrease",R=b?!S:S;return C.jsx(Tr,{ref:S?Ci:Ii,neighbour:"rail",direction:td[p][c],glyph:"single",disabled:i,canStep:S?Ac:Nc,onStep:()=>ya(S?-1:1),ariaLabel:S?B.decrease:B.increase,className:`period-slider-stepper-btn ${rd[p][c]} ${Hs[p][R?"leading":"trailing"]}`})};return C.jsxs("div",{ref:cn,style:_c,className:`period-slider grid select-none place-items-center ${nd[b?"vertical":"horizontal"][u?"withSteppers":"railOnly"]} ${l}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":m,"data-color-scheme":h,children:[C.jsx("div",{ref:$i,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),u&&hs(b?"increase":"decrease"),C.jsx("div",{ref:ut,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":$?_:void 0,className:`period-slider-track relative touch-none rounded-full ${Hs[b?"vertical":"horizontal"][u?"rail":"railOnly"]} ${Mr}`,onPointerDown:hc,onPointerMove:gc,onPointerLeave:pc,children:$?C.jsxs(C.Fragment,{children:[xe&&(b?C.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:[C.jsx("defs",{children:C.jsxs("linearGradient",{id:A,x1:"0",y1:"0",x2:"1",y2:"0",children:[C.jsx("stop",{offset:"0%",stopColor:P?ne.macro:ne.micro,stopOpacity:"0.28"}),C.jsx("stop",{offset:"100%",stopColor:P?ne.micro:ne.macro,stopOpacity:ms})]})}),C.jsx("path",{ref:ca,"data-testid":"period-slider-vernier-projection",d:Ca(Mt,It,b,P),fill:`url(#${A})`})]}):C.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[C.jsx("defs",{children:C.jsxs("linearGradient",{id:A,x1:"0",y1:"0",x2:"0",y2:"1",children:[C.jsx("stop",{offset:"0%",stopColor:P?ne.macro:ne.micro,stopOpacity:"0.28"}),C.jsx("stop",{offset:"100%",stopColor:P?ne.micro:ne.macro,stopOpacity:ms})]})}),C.jsx("path",{ref:ca,"data-testid":"period-slider-vernier-projection",d:Ca(Mt,It,b,P),fill:`url(#${A})`})]})),!g&&C.jsxs(C.Fragment,{children:[C.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${Gr} - 8px)`,height:`calc(${no} - ${Gr} + 16px)`}:{left:`calc(${Gr} - 8px)`,width:`calc(${no} - ${Gr} + 16px)`},onPointerDown:zr("macro-connect")}),!ee&&C.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${Kr} - 8px)`,height:`calc(${oo} - ${Kr} + 16px)`}:{left:`calc(${Kr} - 8px)`,width:`calc(${oo} - ${Kr} + 16px)`},onPointerDown:zr("micro-connect")})]}),_e&&C.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(c=>C.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`macro-tick-${c}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(c=>C.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`micro-tick-${c}`))]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":ql,"aria-valuemax":ct,"aria-valuenow":Qe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(br,M,"period"):Pr(M,br,Ve,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:Gr,left:P?0:"auto",right:P?"auto":0,transform:P?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:nt==="macro-low"||Ze==="macro-low"?30:15}:{left:Gr,top:P?0:"auto",bottom:P?"auto":0,transform:P?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:nt==="macro-low"||Ze==="macro-low"?30:15},onPointerDown:zr("macro-low"),onKeyDown:Jn("macro-low"),onFocus:Qn("macro-low"),"data-active":nt==="macro-low"?"true":void 0,"data-front":Ze==="macro-low"?"true":void 0,"data-vernier-pos":b?P?"left":"right":P?"top":"bottom","data-handle-type":"macro-low",children:[C.jsx(En,{type:"macro",isTop:P,isVertical:b,isLeft:P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":wc?"true":void 0,"data-slanted":vt.slant.isSlanted?"true":void 0,"data-flipped":vt.slant.isFlipped?"true":void 0,ref:Jl,style:vt.lowStyle,children:it(M,br,Ve,D)}),qr(vt.lowLeaderStyle)]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Qe,"aria-valuemax":Xl,"aria-valuenow":ct,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(wr,M,"period"):Pr(M,wr,Ve,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:no,left:P?0:"auto",right:P?"auto":0,transform:P?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:nt==="macro-high"||Ze==="macro-high"?30:15}:{left:no,top:P?0:"auto",bottom:P?"auto":0,transform:P?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:nt==="macro-high"||Ze==="macro-high"?30:15},onPointerDown:zr("macro-high"),onKeyDown:Jn("macro-high"),onFocus:Qn("macro-high"),"data-active":nt==="macro-high"?"true":void 0,"data-front":Ze==="macro-high"?"true":void 0,"data-vernier-pos":b?P?"left":"right":P?"top":"bottom","data-handle-type":"macro-high",children:[C.jsx(En,{type:"macro",isTop:P,isVertical:b,isLeft:P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":vc?"true":void 0,"data-slanted":vt.slant.isSlanted?"true":void 0,"data-flipped":vt.slant.isFlipped?"true":void 0,ref:tc,style:vt.highStyle,children:it(M,wr,Ve,D)}),qr(vt.highLeaderStyle)]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ee?B.microSelectedDate:B.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Di,"aria-valuemax":ee?oa:at,"aria-valuenow":ze,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Nr,v,"period"):Pr(v,Nr,Ye,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:Kr,left:P?"auto":0,right:P?0:"auto",transform:P?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:nt===_t||Ze===_t?30:20}:{left:Kr,top:P?"auto":0,bottom:P?0:"auto",transform:P?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:nt===_t||Ze===_t?30:20},onPointerDown:zr(_t),onKeyDown:Jn(_t),onFocus:Qn(_t),"data-active":nt===_t?"true":void 0,"data-front":Ze===_t?"true":void 0,"data-vernier-pos":b?P?"right":"left":P?"bottom":"top","data-handle-type":_t,children:[C.jsx(En,{type:"micro",isTop:!P,isVertical:b,isLeft:!P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":Sc?"true":void 0,"data-slanted":St.slant.isSlanted?"true":void 0,"data-flipped":St.slant.isFlipped?"true":void 0,ref:nc,style:St.lowStyle,children:it(v,Nr,Ye,D)}),qr(St.lowLeaderStyle)]}),!ee&&C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":ze,"aria-valuemax":oa,"aria-valuenow":at,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Vr,v,"period"):Pr(v,Vr,Ye,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:oo,left:P?"auto":0,right:P?0:"auto",transform:P?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:nt==="micro-high"||Ze==="micro-high"?30:20}:{left:oo,top:P?"auto":0,bottom:P?0:"auto",transform:P?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:nt==="micro-high"||Ze==="micro-high"?30:20},onPointerDown:zr("micro-high"),onKeyDown:Jn("micro-high"),onFocus:Qn("micro-high"),"data-active":nt==="micro-high"?"true":void 0,"data-front":Ze==="micro-high"?"true":void 0,"data-vernier-pos":b?P?"right":"left":P?"bottom":"top","data-handle-type":"micro-high",children:[C.jsx(En,{type:"micro",isTop:!P,isVertical:b,isLeft:!P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":xc?"true":void 0,"data-slanted":St.slant.isSlanted?"true":void 0,"data-flipped":St.slant.isFlipped?"true":void 0,ref:oc,style:St.highStyle,children:it(v,Vr,Ye,D)}),qr(St.highLeaderStyle)]})]}):C.jsxs(C.Fragment,{children:[!g&&C.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Lc,onPointerDown:fc}),w&&Y&&H.length>1&&C.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:H.map((c,p)=>{const S=U(t,c,f),R=xr(p),O=b?{bottom:`${R}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${R}%`,top:"50%",transform:"translate(-50%, -50%)"};return C.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:O},`tick-${S}`)})}),!i&&J!==null&<!==null&&ye===null&&fs&&C.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Ic,children:[C.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"}),C.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":kc?"true":void 0,className:`period-slider-hover-tooltip ${m==="bottom"&&!b?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:it(t,fs,e.formatLabel,D)})]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":G?B.selectedDate:B.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":N,"aria-valuemax":G?F:$e,"aria-valuenow":Re,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Ea,t,"period"):Pr(t,Ea,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Mr}`,style:Tc,onPointerDown:Ji("low"),onKeyDown:ts("low"),onFocus:es("low"),"data-active":ye==="low"?"true":void 0,"data-front":gn?"true":void 0,children:[C.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 ${ye==="low"?"":"shadow-md"}`}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-label-position":m,"data-slanted":ar.isSlanted?"true":void 0,"data-flipped":ar.isFlipped?"true":void 0,"data-front":gn?"true":void 0,"data-duplicate":ma&&!gn?"true":void 0,ref:Zl,style:Wr.lowStyle,children:it(t,Ea,e.formatLabel,D)}),qr(Wr.lowLeaderStyle)]}),!G&&C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Re,"aria-valuemax":F,"aria-valuenow":$e,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Pa,t,"period"):Pr(t,Pa,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Mr}`,style:Cc,onPointerDown:Ji("high"),onKeyDown:ts("high"),onFocus:es("high"),"data-active":ye==="high"?"true":void 0,"data-front":pn?"true":void 0,children:[C.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 ${ye==="high"?"":"shadow-md"}`}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-label-position":m,"data-slanted":ar.isSlanted?"true":void 0,"data-flipped":ar.isFlipped?"true":void 0,"data-front":pn?"true":void 0,"data-duplicate":ma&&!pn?"true":void 0,ref:Ql,style:Wr.highStyle,children:it(t,Pa,e.formatLabel,D)}),qr(Wr.highLeaderStyle)]})]})}),u&&hs(b?"decrease":"increase")]})},et=e=>e.getTime(),kl=(e,t)=>!(At(e)&&At(t))||e.length!==2||t.length!==2?!1:Pt(e[0],et)===Pt(t[0],et)&&Pt(e[1],et)===Pt(t[1],et),ho=(e,t)=>e===void 0||t===void 0?e===t:kl(e,t),Oa=(e,t)=>{if(e===t)return!0;if(!(At(e)&&At(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(Pt(e[r],et)!==Pt(t[r],et))return!1;return!0},Al=(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},ad=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||Pt(e.minDate,et)!==Pt(t.minDate,et)||Pt(e.maxDate,et)!==Pt(t.maxDate,et)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.keepMergedLabelUpright!==t.keepMergedLabelUpright||e.labelCeiling!==t.labelCeiling||e.labelFloor!==t.labelFloor||e.showLabelLeaderLines!==t.showLabelLeaderLines||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||!Al(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Uo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!Oa(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(gt(e.value,et)!==gt(t.value,et)||gt(e.defaultValue,et)!==gt(t.defaultValue,et)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!ho(e.range,t.range)||!ho(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!ho(e.microRange,t.microRange)||!ho(e.defaultMicroRange,t.defaultMicroRange)||gt(e.microValue,et)!==gt(t.microValue,et)||gt(e.defaultMicroValue,et)!==gt(t.defaultMicroValue,et)||!kl(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||!Oa(e.macroAllowedDates,t.macroAllowedDates)||!Oa(e.microAllowedDates,t.microAllowedDates)):!1,Nl=s.memo(od,ad);Nl.displayName="PeriodSlider";const Fs=2,Pe=-1,yt=e=>U("day",e),Vn=e=>se("day",e),xn=e=>`${Go(e.getFullYear())}-${String(e.getMonth()+1).padStart(Fs,"0")}-${String(e.getDate()).padStart(Fs,"0")}`,id=(e,t,r,n)=>{const o=yt(e),a=yt(t),i=a>=o?a-o+1:0,l=d=>Vn(a-d),u={kind:"range",min:o,max:a};return{count:i,dateAt:l,labelAt:d=>it("day",l(d),n,r),indexOf:d=>{const m=yt(d);return m<o||m>a?Pe:a-m},nearestIndexOf:d=>{if(i===0)return Pe;const m=kn(u,yt(d));return m===null?Pe:a-m}}},sd=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,l=x=>e[n-x],u={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},d=x=>{const L=x.getTime();let T=r,b=n;for(;T<=b;){const g=T+b>>1,w=e[g].getTime();if(w===L)return n-g;w<L?T=g+1:b=g-1}return Pe},m=x=>x===null?Pe:d(Vn(x));return{count:i,dateAt:l,labelAt:x=>it("day",l(x),a,o),indexOf:d,nearestIndexOf:x=>m(kn(u,yt(x)))}},ld={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:()=>Pe,nearestIndexOf:()=>Pe},cd=(e,t,r)=>{const n=l=>{let u=0,d=e.length;for(;u<d;){const m=u+d>>1;e[m].getTime()<l?u=m+1:d=m}return u},o=l=>{let u=0,d=e.length;for(;u<d;){const m=u+d>>1;e[m].getTime()<=l?u=m+1:d=m}return u},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},ud=(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))},dd={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},md={month:2,day:2},Us={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},zs=new Map,fd=(e,t)=>{const r=`${e}\0${t}`,n=zs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,dd[e]);return zs.set(r,o),o},hd=(e,t,r)=>{if(r!==void 0)return fd(e,r).format(t);const n=new Date(t.getTime());return e==="year"?Go(Us.year(n)):String(Us[e](n)).padStart(md[e],"0")},Vl=(e,t,r,n)=>{if(Le("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${y(r)})`);return De(e)?r==="part"?hd(t,e,n):it(t,e,void 0,n):""},gd=12,Qo=(e,t,r)=>{const n=Un(e,t,r);return n===null?Number.NaN:n*gd+r},hi=(e,t,r)=>{const n=o=>o.value!==void 0?o.value:o.initialDate;return gt(n(e),r)!==gt(n(t),r)||t.value!==void 0&&Number.isNaN(gt(t.initialDate,r))||gt(e.minDate,r)!==gt(t.minDate,r)?!1:gt(e.maxDate,r)===gt(t.maxDate,r)};class Ol{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 _l(e,t){const[r]=s.useState(()=>t(e)),n=r.writes;return s.useInsertionEffect(()=>{r.commit(e,n)}),r}function mt(e){return _l(e,t=>new Ol(t))}const pd={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},bd=["shift","start","end","single"],wd=["disable","clamp"],vd=["follow","keep"],Bs={day:{day:1},month:{month:1,year:12},year:{year:1}},Ws=new WeakMap,Ka=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${y(r)})`)},Gs=(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)})`)},Cr=(e,t,r,n)=>{Ka(e,t,r),Gs(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Ka(e,a,i),Gs(e,a,i,pd[n]);const{motion:l,edge:u,window:d}=i;if(n!=="vernierPoint"&&(typeof l!="string"||!bd.includes(l)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${y(l)})`);if(u!==void 0){if(l!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${y(u)} with motion ${y(l)})`);if(typeof u!="string"||!wd.includes(u))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${y(u)})`)}if(d!==void 0&&(typeof d!="string"||!vd.includes(d)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${y(d)})`)}},gi=(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(!De(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${y(r)})`);return Ke(e,t,r,n,o,"")},Yl=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=Ws.get(r),l=i?.get(a);if(l!==void 0)return l;const u=[];for(let m=0;m<r.length;m++)u.push(qt(e,`${t}[${m}]`,r[m],n,o));const d=Array.from(new Set(u)).sort((m,x)=>m-x);return i===void 0?Ws.set(r,new Map([[a,d]])):i.set(a,d),d},Sd=(e,t)=>t===1?Ro(e):{stepEnd:(r,n)=>xo(e,r+t*n,n),edge:r=>Cn(e,r)},qa=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},Xa=(e,t,r,n,o,a)=>{if(a){const u=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:se(n,e[0],o);return Number.isNaN(u.getTime())?null:[u,u]}const i=e[0]===t[0]?r[0]:se(n,e[0],o),l=e[1]===t[1]?r[1]:se(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(l.getTime())?null:[i,l.getTime()<i.getTime()?i:l]},Za=e=>{const t="resolveSelectorSteps";Ka(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:l,rules:u}=e;Le(t,"unit",o);const d=Qt(t,"stepUnit",e.stepUnit,o),m=Bs[o][d];if(m===void 0){const M=Object.keys(Bs[o]).map(v=>`"${v}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${M} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${y(d)})`)}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(!At(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${y(r)})`);Cr(t,"rules",u,"motion");const L=qt(t,"selection[0]",r[0],o,x),T=qt(t,"selection[1]",r[1],o,x);if(T<L)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${y(r[0])}, end: ${y(r[1])})`);const b=a===void 0?null:qt(t,"minDate",a,o,x),g=i===void 0?null:qt(t,"maxDate",i,o,x);if(b!==null&&g!==null&&g<b)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${y(a)}, maxDate: ${y(i)})`);sn(t,"allowedDates",l);const w=l===void 0?{kind:"range",min:b,max:g}:ln(Yl(t,"allowedDates",l,o,x),b,g),h=Sd(w,m),D=(M,v)=>{const f=za(h,L,T,M,qa(v,n));return f===null?null:Xa(f,[L,T],r,o,x,v.motion==="single")};return{previous:D(-1,u.previous),next:D(1,u.next)}},jt=(e,t)=>{const r=mt({targets:e,onStepTo:t}),n=s.useCallback(i=>{const{targets:l,onStepTo:u}=r.current,d=l[i];d!==null&&u(d,i)},[]),o=e.previous!==null,a=e.next!==null;return s.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function xd(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function pi(e,t,r,n){const o=t?null:r(e),[a,i]=s.useState(()=>({source:o,held:n(e)})),l=s.useCallback(d=>i(m=>({source:m.source,held:d})),[]),u=xd(a,o,e,n);return s.useLayoutEffect(()=>{u!==a&&i(d=>d===a?u:d)}),[u.held,l]}const Po=44,Ks=7,go=8,Rd=2,Hl=10,Md=1e3,Qa=8,_a=6,Ya=4,Ha=12,Rn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),yt(r)},Dd=(e,t)=>{if(e.length<Ya||t.count===0)return Pe;const r=Number(e.slice(0,Ya));if(!Number.isInteger(r))return Pe;const n=e.length>=_a,o=n?Number(e.slice(Ya,_a)):Ha;if(o<1||o>Ha)return Pe;const a=e.length>=Qa,i=a?Number(e.slice(_a,Qa)):0,l=Rn(r,o),u=(o===Ha?Rn(r+1,1):Rn(r,o+1))-1,d=a?l+i-1:n?l:Rn(r,1),m=a?d:n?u:Rn(r+1,1)-1;if(a&&(i<1||d>u))return Pe;for(let x=m;x>=d;x--){const L=t.indexOf(Vn(x));if(L!==Pe)return L}return Pe},yd=e=>e.closest(".dark")===null?"light":"dark",Ed=(e,t,r,n)=>{const o=r-e.bottom-go,a=e.top-go,i=o>=t||o>=a,u=Math.max(Po,Math.min(t,i?o:a)),d=i?e.bottom:e.top-u,m=e.width+Hl,x=Math.max(go,Math.min(e.left,n-m-go));return{top:d,left:x,width:m,height:u}},Pd=(e,t)=>e<t?e:t>0?t-1:Pe,jl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:l,labels:u,onCommitIndex:d,controlClassName:m})=>{const x=s.useId(),L=s.useMemo(()=>uu(u),[u]),T=`period-slider-date-listbox-${x}`,b=s.useCallback(V=>`period-slider-date-option-${x}-${V}`,[x]),[g,w]=s.useState(!1),[h,D]=s.useState(Pe),[M,v]=s.useState(null),[f,ue]=s.useState(null),K=s.useRef(null),re=s.useRef(null),ee=s.useRef(null),B=s.useRef({buffer:"",at:0}),ne=e.count,A=Pd(h,ne),q=mt(A);s.useLayoutEffect(()=>{A!==h&&D(V=>V===h?A:V)});const j=Math.min(ne,Ks)*Po,k=Math.max(1,Math.min(ne,Ks)),$=s.useCallback(()=>{const V=K.current;if(V===null)return;const X=V.getBoundingClientRect();v(Ed(X,j,window.innerHeight,window.innerWidth))},[j]),H=mt(g),Y=s.useCallback(()=>{w(!1),D(Pe),B.current={buffer:"",at:0},H.current=!1},[H]);s.useLayoutEffect(()=>()=>{H.current&&Y()},[H,Y]);const N=s.useCallback(V=>{a||ne===0||(D(V),w(!0),H.current=!0)},[a,ne,H]);s.useLayoutEffect(()=>{if(!g){v(null),ue(null);return}const V=K.current;return V!==null&&ue(yd(V)),$(),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[g,$]),s.useEffect(()=>{if(!g)return;const V=X=>{const de=X.target;de!==null&&re.current?.contains(de)!==!0&&K.current?.contains(de)!==!0&&Y()};return document.addEventListener("pointerdown",V,!0),()=>document.removeEventListener("pointerdown",V,!0)},[g,Y]),s.useEffect(()=>{g&&(a||ne===0)&&Y()},[g,a,ne,Y]),s.useEffect(()=>{if(!g)return;const V=q.current;V!==Pe&&ee.current?.scrollToIndex(V,{align:"center"})},[ne,g,q]);const F=V=>{if(ne===0)return;const X=Math.max(0,Math.min(V,ne-1));D(X),ee.current?.scrollToIndex(X,{align:"center"})},G=V=>{V<0||V>=ne||(d(V),Y(),K.current?.focus())},he=mt(G),te=V=>{if(a||K.current===null)return;const X=A!==Pe?A:t!==Pe?t:r;switch(V.key){case"ArrowDown":if(V.preventDefault(),!g){N(X);return}F(X+1);return;case"ArrowUp":if(V.preventDefault(),!g){N(X);return}F(X-1);return;case"Home":if(!g)return;V.preventDefault(),F(0);return;case"End":if(!g)return;V.preventDefault(),F(ne-1);return;case"PageDown":if(!g)return;V.preventDefault(),F(X+k);return;case"PageUp":if(!g)return;V.preventDefault(),F(X-k);return;case"Enter":if(V.preventDefault(),!g){N(X);return}G(A!==Pe?A:X);return;case"Escape":if(!g)return;V.preventDefault(),Y();return;case"Tab":g&&Y();return}if(V.key.length!==1)return;const de=V.key>="0"&&V.key<="9",Oe=V.key==="-"||V.key==="/"||V.key===".";if(!(de||Oe))return;V.preventDefault();const we=Date.now(),tt=we-B.current.at>Md?"":B.current.buffer,qe=de?`${tt}${V.key}`.slice(0,Qa):tt;B.current={buffer:qe,at:we};const Fe=Dd(qe,e);if(Fe!==Pe){if(!g){N(Fe);return}F(Fe)}},le=s.useCallback(V=>V,[]),Se=s.useCallback(()=>Po,[]),ae=A===Pe?null:b(A),ie=s.useCallback(()=>{const V=K.current;if(V===null||ae===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 V.setAttribute("aria-activedescendant",ae),()=>{V.getAttribute("aria-activedescendant")===ae&&V.removeAttribute("aria-activedescendant")}},[ae]),pe=s.useCallback(V=>{const X=V===t,de=V===A;return C.jsx("div",{id:b(V),role:"option","aria-selected":X,"aria-posinset":V+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":de?"true":void 0,ref:de?ie:void 0,className:"period-slider-date-option",style:{height:Po},onClick:()=>he.current(V),children:e.labelAt(V)})},[e,t,A,b,he,ie]),je=s.useCallback(V=>(re.current=V,V.style.removeProperty("display"),()=>{re.current=null,V.style.setProperty("display","none","important")}),[]),ft=g&&M!==null&&f!==null&&ne>0,ge=ft?C.jsx("div",{ref:je,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":f,style:{top:M.top,left:M.left,width:M.width,height:M.height},onMouseDown:V=>{V.preventDefault()},children:C.jsx(mr.VirtualScroll,{ref:ee,itemCount:ne,getItem:le,getItemHeight:Se,viewportSize:M.height-Rd,initialScrollIndex:A!==Pe?A:void 0,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:l,labels:L,contentProps:{id:T,role:"listbox","aria-label":i},scrollBarOptions:{width:Hl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:pe})}):null;return C.jsxs(C.Fragment,{children:[C.jsx("input",{ref:K,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":g,"aria-controls":ft?T:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none",disabled:a,value:n,className:m,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:te,onMouseDown:V=>{a||K.current===null||(V.preventDefault(),K.current?.focus(),g?Y():N(t!==Pe?t:r))},onBlur:()=>{g&&Y()}}),ge===null?null:Fc.createPortal(ge,document.body)]})};jl.displayName="VirtualDateDropdown";const Mn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Ld=Fn("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),$d=Fn('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Td=31,Dn=(e,t,r)=>{if(!De(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${y(t)})`);Ke("DateSelector",e,t,"day",0,r)},lr=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},po=e=>lr(e,1,1),qs=e=>lr(e,12,31),Fl=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,Xs=(e,t,r,n)=>Fl(e,t,r)&&e.getDate()===n,bi=e=>Un(e,"year",0)!==null,wi=e=>Qo(e,"day",0),Cd=e=>bi(e)?wi(e):Number.NaN,bo=(e,t,r)=>{if(!bi(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}`)},Zs=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const l=r(i);if(Number.isNaN(l.getTime()))break;n(l,i)&&a.push({value:i,label:o(l)})}return a},Id=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,minYear:l,maxYear:u,minDate:d,maxDate:m,allowedDates:x,variant:L="date",className:T="",style:b,disabled:g=!1,locale:w,labels:h,formatLocale:D,formatOption:M}=e;D!==void 0&&Zo("DateSelector","formatLocale",D);const v=L==="split-dropdown"?$d:Ld;if(t!==void 0&&Dn("value",t,""),r!==void 0&&Dn("initialDate",r,""),d!==void 0&&Dn("minDate",d,v),m!==void 0&&Dn("maxDate",m,v),L==="split-dropdown"&&(t!==void 0&&bo("value",t,""),r!==void 0&&bo("initialDate",r,""),d!==void 0&&bo("minDate",d,v),m!==void 0&&bo("maxDate",m,v)),l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: minYear must be an integer year (received: ${y(l)})`);if(u!==void 0&&!Number.isInteger(u))throw new RangeError(`DateSelector: maxYear must be an integer year (received: ${y(u)})`);if(l!==void 0&&Number.isNaN(po(l).getTime()))throw new RangeError(`DateSelector: minYear must name a year whose first day starts inside the Date range (received: ${y(l)})`);if(u!==void 0&&Number.isNaN(qs(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${y(u)})`);if(L==="split-dropdown"&&x!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour allowedDates; use variant="dropdown" or variant="date" for a discrete date set');sn("DateSelector","allowedDates",x);const f=t??r;if(f===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&&gi("DateSelector",o,t!==void 0);const ue=li("DateSelector",a),K=zo(w,h),re=t!==void 0,[ee,B]=pi(f,re,wi,Mn),ne=t?.getTime(),A=s.useMemo(()=>t!==void 0?Mn(t):ee,[ne,ee]);if(L==="split-dropdown"&&!re&&!bi(A))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${y(A)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const q=d?.getTime(),j=m?.getTime(),k=s.useMemo(()=>{const I=d?Mn(d):null,J=l!==void 0?po(l):null;return I===null?J:J===null||I.getTime()>=J.getTime()?I:J},[q,l]),$=s.useMemo(()=>{const I=m?Mn(m):null,J=u!==void 0?qs(u):null;return I===null?J:J===null||I.getTime()<=J.getTime()?I:J},[j,u]),H=k?.getTime()??null,Y=$?.getTime()??null;if(k!==null&&$!==null&&k.getTime()>$.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${xn(k)}, upper: ${xn($)})`);if(L!=="date"&&x===void 0&&(k===null||$===null))throw new RangeError(`DateSelector: variant=${y(L)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${L==="dropdown"?", or allowedDates":""}; the option list is never invented`);const N=s.useMemo(()=>x===void 0?null:x.map(I=>Pt(I,J=>J.getTime())).join(","),[x]),F=s.useMemo(()=>{if(x===void 0)return null;const I=ud(x,(J,Ue)=>Dn(`allowedDates[${J}]`,Ue,""));return{ascending:I,ascendingSerials:I.map(yt)}},[N]),G=s.useMemo(()=>F===null?null:{...F,...cd(F.ascending,k,$)},[F,H,Y]),he=s.useMemo(()=>G!==null?sd(G.ascending,G.ascendingSerials,G.loIndex,G.hiIndex,D,M):k===null||$===null?ld:id(k,$,D,M),[G,H,Y,D,M]),te=s.useMemo(()=>G!==null?{kind:"candidates",ascending:G.ascendingSerials,loIndex:G.loIndex,hiIndex:G.hiIndex}:{kind:"range",min:k===null?null:yt(k),max:$===null?null:yt($)},[G,H,Y]),le=I=>!Number.isNaN(I.getTime())&&In(te,yt(I)),Se=I=>{if(g)return;const J=Mn(I);le(J)&&(re||B(J),n?.(J))},ae=A.getTime(),ie=le(A),pe=s.useMemo(()=>{const I=Zt(te,yt(A),-1);if(I===null)return null;const J=Vn(I);return Number.isNaN(J.getTime())?null:J},[te,ae]),je=s.useMemo(()=>{const I=Zt(te,yt(A),1);if(I===null)return null;const J=Vn(I);return Number.isNaN(J.getTime())?null:J},[te,ae]),ft=()=>{if(o!==void 0){o.onStep("previous");return}pe!==null&&Se(pe)},ge=()=>{if(o!==void 0){o.onStep("next");return}je!==null&&Se(je)},V=I=>{if(I.target.value){const J=jc.parseISO(I.target.value);Number.isNaN(J.getTime())||Se(J)}},X=A.getFullYear(),de=A.getMonth()+1,Oe=A.getDate(),we=s.useCallback((I,J)=>M?M(J,I,"part"):Vl(J,I,"part",D),[M,D]),tt=s.useMemo(()=>{if(L!=="split-dropdown"||k===null||$===null)return[];const I=[];for(let J=$.getFullYear();J>=k.getFullYear();J--)I.push({value:J,label:we("year",po(J))});return I},[L,H,Y,we]),qe=s.useMemo(()=>{if(L!=="split-dropdown"||k===null||$===null)return[];const I=k,J=$,Ue=X===I.getFullYear()?I.getMonth()+1:1,lt=X===J.getFullYear()?J.getMonth()+1:12;return Zs(Ue,lt,Ge=>lr(X,Ge,1),(Ge,Re)=>Fl(Ge,X,Re),Ge=>we("month",Ge))},[L,H,Y,X,we]),Fe=s.useMemo(()=>{if(L!=="split-dropdown"||k===null||$===null)return[];const I=k,J=$,Ue=X===I.getFullYear()&&de===I.getMonth()+1?I.getDate():1,lt=X===J.getFullYear()&&de===J.getMonth()+1?J.getDate():Td;return Zs(Ue,lt,Ge=>lr(X,de,Ge),(Ge,Re)=>Xs(Ge,X,de,Re),Ge=>we("day",Ge))},[L,H,Y,X,de,we]),st=(I,J,Ue)=>{const lt=lr(I,J,Ue);return Xs(lt,I,J,Ue)&&le(lt)},oe=(I,J,Ue)=>{st(I,J,Ue)&&Se(lr(I,J,Ue))},pt=tt.some(I=>I.value===X),Xe=qe.some(I=>I.value===de),ht=Fe.some(I=>I.value===Oe),Ae=xn(A),We=L==="dropdown"?it("day",A,M,D):"",ye=k?xn(k):void 0,bt=$?xn($):void 0,rt="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 C.jsxs("div",{className:`inline-flex items-center ${Tn} ${T}`,style:b,"data-variant":L,"data-out-of-range":ie?void 0:"true",children:[C.jsx(Tr,{neighbour:"control",direction:"left",glyph:ue,disabled:g,canStep:o===void 0?pe!==null:o.canStepPrevious,onStep:ft,ariaLabel:K.previousDay}),L==="dropdown"?C.jsx(jl,{domain:he,selectedIndex:ie?he.indexOf(A):Pe,openAnchorIndex:he.nearestIndexOf(A),displayLabel:We,machineValue:Ae,disabled:g,ariaLabel:K.dateSelect,locale:w,labels:K,onCommitIndex:I=>Se(he.dateAt(I)),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"}):L==="split-dropdown"?C.jsxs("div",{className:"inline-flex items-center gap-1",children:[C.jsxs("select",{"aria-label":K.splitYear,disabled:g,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:pt?X:"",onChange:I=>oe(Number(I.target.value),de,Oe),children:[pt?null:C.jsx("option",{value:"",disabled:!0,className:rt,children:we("year",po(X))}),tt.map(I=>C.jsx("option",{value:I.value,disabled:!st(I.value,de,Oe),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]}),C.jsxs("select",{"aria-label":K.splitMonth,disabled:g,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:Xe?de:"",onChange:I=>oe(X,Number(I.target.value),Oe),children:[Xe?null:C.jsx("option",{value:"",disabled:!0,className:rt,children:we("month",lr(X,de,1))}),qe.map(I=>C.jsx("option",{value:I.value,disabled:!st(X,I.value,Oe),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]}),C.jsxs("select",{"aria-label":K.splitDay,disabled:g,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:ht?Oe:"",onChange:I=>oe(X,de,Number(I.target.value)),children:[ht?null:C.jsx("option",{value:"",disabled:!0,className:rt,children:we("day",lr(X,de,Oe))}),Fe.map(I=>C.jsx("option",{value:I.value,disabled:!st(X,de,I.value),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]})]}):C.jsx("input",{"aria-label":K.dateSelect,disabled:g,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:Ae,min:ye,max:bt,onChange:V,type:"date"}),C.jsx(Tr,{neighbour:"control",direction:"right",glyph:ue,disabled:g,canStep:o===void 0?je!==null:o.canStepNext,onStep:ge,ariaLabel:K.nextDay}),i]})},kd=(e,t)=>!(!hi(e,t,t.variant==="split-dropdown"?Cd:wi)||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.stepGlyph!==t.stepGlyph||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!Uo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Ul=s.memo(Id,kd);Ul.displayName="DateSelector";function zn(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 On(e){const t=Un(e,"month",0);return se("month",t===null?Number.NaN:t,0)}const zl=e=>Qo(e,"month",0);function Lr(e){return`${Go(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Qs=Fn("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function wo(e,t,r){e!==void 0&&Bl(e,t,r)}function Bl(e,t,r){if(!De(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${y(e)})`);Ke("MonthSelector",t,e,"month",0,r)}function Js(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(zn(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 Ad(e,t){const r=e===void 0?null:zn(e,0),n=t===void 0?null:On(t);return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Nd(e,t){const r=e===void 0?null:zn(e,11),n=t===void 0?null:On(t);return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function cr(e){return e.getFullYear()*12+e.getMonth()}function Ja(e){return zn(Math.floor(e/12),(e%12+12)%12)}function el(e){return Number.isNaN(e.getTime())?null:e}function Vd(e,t,r){const n=new Map;for(const o of e){const a=On(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 Od(e,t){const r=[];for(let n=cr(e);n<=cr(t);n++)r.push(Ja(n));return r}function tl(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:it("month",e[o],r,t),value:Lr(e[o])});return n}const _d=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,variant:l="date",minYear:u,maxYear:d,minDate:m,maxDate:x,allowedMonths:L,isWarning:T=!1,className:b="",style:g,disabled:w=!1,locale:h,labels:D,formatLocale:M,formatOption:v}=e;if(M!==void 0&&Zo("MonthSelector","formatLocale",M),wo(t,"value",""),wo(r,"initialDate",""),wo(m,"minDate",Qs),wo(x,"maxDate",Qs),Js(u,"minYear",0),Js(d,"maxYear",11),sn("MonthSelector","allowedMonths",L),L!==void 0)for(let oe=0;oe<L.length;oe++)Bl(L[oe],`allowedMonths[${oe}]`,"");const f=t??r;if(f===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&&gi("MonthSelector",o,t!==void 0);const ue=li("MonthSelector",a),K=zo(h,D),re=t!==void 0,[ee,B]=pi(f,re,zl,On),ne=s.useMemo(()=>t!==void 0?On(t):ee,[t?.getTime(),ee]),A=m?.getTime(),q=x?.getTime(),j=s.useMemo(()=>Ad(u,m),[u,A]),k=s.useMemo(()=>Nd(d,x),[d,q]),$=j?.getTime()??null,H=k?.getTime()??null;if(j!==null&&k!==null&&j>k)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Lr(j)}, upper: ${Lr(k)})`);if(l==="dropdown"&&L===void 0&&(j===null||k===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 Y=L===void 0?null:L.map(oe=>oe.getTime()).join(","),N=s.useMemo(()=>L===void 0?null:Vd(L,j,k),[Y,$,H]),F=s.useMemo(()=>{if(N!==null){const oe=N.map(cr);return{kind:"candidates",ascending:oe,loIndex:0,hiIndex:oe.length-1}}return{kind:"range",min:j===null?null:cr(j),max:k===null?null:cr(k)}},[N,$,H]),G=oe=>!Number.isNaN(oe.getTime())&&In(F,cr(oe)),he=oe=>{if(w)return;if(!G(oe))throw new RangeError(`MonthSelector: refusing to emit ${Lr(oe)}, which lies outside the selectable months`);re||B(oe);const pt=oe.getFullYear()*100+(oe.getMonth()+1);n?.(oe,pt)},te=ne.getTime(),le=G(ne),Se=s.useMemo(()=>{const oe=Zt(F,cr(ne),-1);return oe===null?null:el(Ja(oe))},[F,te]),ae=s.useMemo(()=>{const oe=Zt(F,cr(ne),1);return oe===null?null:el(Ja(oe))},[F,te]),ie=()=>{if(o!==void 0){o.onStep("previous");return}Se!==null&&he(Se)},pe=()=>{if(o!==void 0){o.onStep("next");return}ae!==null&&he(ae)},je=oe=>{if(!oe)return;const pt=oe.lastIndexOf("-");if(pt<=0)return;const Xe=oe.slice(0,pt),ht=oe.slice(pt+1),Ae=Number(Xe),We=Number(ht)-1;if(!(Number.isInteger(Ae)&&Number.isInteger(We)))return;const ye=zn(Ae,We);G(ye)&&he(ye)},ft=oe=>{je(oe.target.value)},ge=oe=>{je(oe.target.value)},V=Lr(ne),X=l==="dropdown"&&!le?it("month",ne,v,M):"",de=j?Lr(j):void 0,Oe=k?Lr(k):void 0,we=s.useMemo(()=>l!=="dropdown"?[]:N!==null?tl(N,M,v):j===null||k===null?[]:tl(Od(j,k),M,v),[l,N,$,H,M,v]),tt=le?V:"",qe=T?"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",Fe=`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 ${qe}`,st=`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 ${qe}`;return C.jsxs("div",{className:`inline-flex items-center ${Tn} ${b}`,style:g,"data-out-of-range":le?void 0:"true",children:[C.jsx(Tr,{neighbour:"control",direction:"left",glyph:ue,disabled:w,canStep:o===void 0?Se!==null:o.canStepPrevious,onStep:ie,ariaLabel:K.previousMonth}),l==="dropdown"?C.jsxs("select",{"aria-label":K.monthSelect,disabled:w,className:st,value:tt,onChange:ge,children:[le?null:C.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:X}),we.map(oe=>C.jsx("option",{value:oe.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:oe.label},oe.value))]}):C.jsx("input",{"aria-label":K.monthSelect,disabled:w,className:Fe,value:V,min:de,max:Oe,onChange:ft,type:"month"}),C.jsx(Tr,{neighbour:"control",direction:"right",glyph:ue,disabled:w,canStep:o===void 0?ae!==null:o.canStepNext,onStep:pe,ariaLabel:K.nextMonth}),i]})},Yd=(e,t)=>!(!hi(e,t,zl)||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.stepGlyph!==t.stepGlyph||e.children!==t.children||e.locale!==t.locale||!Uo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Wl=s.memo(_d,Yd);Wl.displayName="MonthSelector";const ei=Symbol("nothing handed");let ja=0;class Hd{constructor(t,r,n,o){this.states=t,this.base=r,this.superseded=n,this.setMark=o}states;base;superseded;setMark;drafts=new Map;handed=new Map;cells=new Set;notes=[];closed=!1;marked=!1;committed=!1;record(){this.marked||(this.marked=!0,this.setMark(this))}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),this.record()}hand(t,r){this.handed.set(t.slot,r),this.cells.add(t),this.record()}note(t){this.notes.push(t),this.record()}hasHanded(t){return this.handed.has(t)}lastHanded(t){return this.handed.get(t)}close(){this.closed=!0}}class jd{constructor(t,r,n){this.owner=t,this.setMark=n,this.slotWrites=r.map(()=>0),this.records=r.map(()=>ei),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: ${y(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)`);const n=this.active;this.active=r,ja+=1;try{t()}finally{ja-=1,this.active=n}};get pass(){if(this.active===null&&ja>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]!==ei&&this.records[a]!==o),n=new Hd(t,[...this.slotWrites],r,this.setMark);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.note({slot:t,send:r});return}this.deliver(),r()}}class Fd extends Ol{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,ei)}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 Ud{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 zd=(e,t)=>t;function Jo(e,t){const[r,n]=s.useReducer(zd,null),[o]=s.useState(()=>new jd(e,t,n)),a=o.begin(t,r);return s.useInsertionEffect(()=>{o.commit(a,t)}),s.useLayoutEffect(()=>{o.deliver()}),o}function Jr(e,t,r,n){const o=_l(r,a=>new Fd(a,e,t));return s.useLayoutEffect(()=>{o.recordAdopted(n)}),o}function en(e,t,r){const[n]=s.useState(()=>new Ud(r,e,t));return n}function ke(e,t,r){return e<t?t:e>r?r:e}const Bd=ln([],null,null);function _n(e,t,r,n){return r===null?Bd:ti(r,U(t,e[0],n),U(t,e[1],n))}function $r(e,t,r,n,o){const a=U(t,e,o),i=ri(n)?null:kn(n,a);return i===null?a<U(t,r[0],o)?r[0]:a>U(t,r[1],o)?r[1]:e:i===a?e:se(t,i,o)}function Zr(e,t,r,n,o,a){const i=U(t,e[0],o),l=U(t,e[1],o),u=Do(a,{kind:"range",min:U(t,r[0],o),max:U(t,r[1],o)},i,l);if(u===null)return e;const d=$r(u[0]===i?e[0]:se(t,u[0],o),t,r,n,o),m=$r(u[1]===l?e[1]:se(t,u[1],o),t,r,n,o);return[d,m<d?d:m]}const rl=(e,t,r,n,o,a,i)=>{if(sn(e,t,r),r===void 0||r.length===0)return null;const l=ln(Yl(e,t,r,n,i),U(n,o,i),U(n,a,i));if(l.hiIndex<l.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${y(o)}, maxDate: ${y(a)}, entries: ${r.length})`);return l},ti=(e,t,r)=>{const n=ln(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},ri=e=>e.hiIndex<e.loIndex,Wd=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=Cn(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Et=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),nl=(e,t,r,n,o)=>{if(!At(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]},ur=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:l,macroRange:u,microSelection:d}=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)})`);Le(t,"macroUnit",o),Le(t,"microUnit",a);const m=gr(t,e.yearStartMonth);for(const[A,q]of[["minDate",i],["maxDate",l]])if(!De(q))throw new RangeError(`${t}: ${A} must be a valid Date (received: ${y(q)})`);if(l.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${y(i)}, maxDate: ${y(l)})`);qt(t,"minDate",i,o,m),qt(t,"minDate",i,a,m),Cr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const x=nl(t,"macroRange",u,o,m);if(u[1].getTime()<u[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${y(u[0])}, end: ${y(u[1])})`);const L=nl(t,"microSelection",d,a,m),T=rl(t,"macroAllowedDates",e.macroAllowedDates,o,i,l,m),b=rl(t,"microAllowedDates",e.microAllowedDates,a,i,l,m),g=[u[0],u[1]],w=[d[0],d[1]],h=A=>{const q=$t(o,a,[A[0],A[1]],i,l,m);return[U(a,q[0],m),U(a,q[1],m)]},D=(A,q)=>{if(b!==null){const j=ti(b,A,q);if(!ri(j))return j}return{kind:"range",min:A,max:q}},M=(A,q)=>{const j=Et(A,g)?g:A;return j===g&&Et(q,w)?null:{macroRange:j,microSelection:q}};if(e.row==="macro"){const A=T??{kind:"range",min:U(o,i,m),max:U(o,l,m)},q=Ro(A),j=($,H)=>{const Y=$t(o,a,$,i,l,m);return Zr(w,a,Y,_n(Y,a,b,m),m,H)},k=($,H)=>{const Y=za(q,x[0],x[1],$,qa(H,n));if(Y===null)return null;const N=Xa(Y,x,g,o,m,H.motion==="single");if(N===null)return null;const F=[ke(N[0],i,l),ke(N[1],i,l)],G=Math.sign(Y[0]-x[0])===$&&Math.sign(Y[1]-x[1])===$;return M(F,j(F,G?"pan":"resize"))};return{previous:k(-1,e.rules.previous),next:k(1,e.rules.next)}}const v=h(g);let f=[U(a,i,m),U(a,l,m)];if(T!==null){const A=h([se(o,T.ascending[T.loIndex],m),se(o,T.ascending[T.hiIndex],m)]);f=[Math.min(A[0],v[0]),Math.max(A[1],v[1])]}const ue=b===null?null:ti(b,f[0],f[1]);let K=Ro({kind:"range",min:f[0],max:f[1]});if(ue!==null&&!ri(ue)){const A=D(v[0],v[1]);K=A.kind==="candidates"?Ro(ue):Wd([ue,A])}const re=A=>{if(T===null)return[ke(Rt(o,A[0],m),i,l),ke(Rt(o,A[1],m),i,l)];const q=xo(T,U(o,A[0],m),-1),j=xo(T,U(o,A[1],m),1);return q===null||j===null?null:[ke(se(o,q,m),i,l),ke(se(o,j,m),i,l)]},ee=(A,q,j)=>{const[k,$]=h(A),H=D(k,$),Y=G=>{const he=U(a,G,m);if(In(H,he))return G;const te=xo(H,he,j);return te===null?null:se(a,te,m)},N=Y(q[0]),F=Y(q[1]);return N===null||F===null?null:[N,F.getTime()<N.getTime()?N:F]},B=(A,q)=>A>=v[0]&&q<=v[1],ne=(A,q)=>{const j=za(K,L[0],L[1],A,qa(q,n));if(j===null)return null;const k=Xa(j,L,w,a,m,q.motion==="single");if(k===null)return null;const $=q.window!=="follow",H=$&&B(j[0],j[1])?g:re(k);if(H===null)return null;const Y=ee(H,k,A);if(Y===null)return null;const N=$&&B(U(a,Y[0],m),U(a,Y[1],m))?g:re(Y);return N===null?null:M(N,Y)};return{previous:ne(-1,e.rules.previous),next:ne(1,e.rules.next)}};function ni(e,t,r){if(!De(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${y(r)})`)}function Ee(e,t,r,n,o){ni(e,t,r),Ke(e,t,r,n,o,"")}function ea(e,t,r,n,o){if(ni(e,"minDate",t),ni(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)Ke(e,"minDate",t,a,o,bl)}function dr(e,t,r,n,o){if(!At(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${y(r)})`);if(Ee(e,`${t}[0]`,r[0],n,o),Ee(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 No(e,t,r,n,o,a,i,l){const u=U(r,n,l);if(u<U(r,o,l)||u>U(r,a,l))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,l){No(e,`${t}[0]`,r,n[0],o,a,i,l),No(e,`${t}[1]`,r,n[1],o,a,i,l)}function Oo(e,t,r,n){if(n.getTime()<r.getTime())throw new RangeError(`${e}: ${t}(upper) must not be earlier than lower (lower: ${y(r)}, upper: ${y(n)})`)}function tn(e,t,r){if(!Number.isInteger(r))throw new RangeError(`${e}: ${t}(delta) must be an integer number of units (received: ${y(r)})`)}function Ft(e,t,r,n,o,a){const i=wl(e,t,r);return De(i)&&Un(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function _o(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 $n(e,t,r,n,o,a){const i=ke(e,r,n);if(o.length===0)return i;const l=o[Me(o,i,t,a)];return U(t,l,a)===U(t,i,a)?i:ke(l,r,n)}function Fa(e,t,r,n,o,a){const i=$n(e[0],t,r,n,o,a),l=$n(e[1],t,r,n,o,a);return[i,l<i?i:l]}function Yn(e,t){return t[0]===e[0]&&t[1]===e[1]?e:t}const Gd={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function Ut(e,t){return t.length===0?{}:{[Gd[e]]:t}}function ta(e){const t=s.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(l=>Object.is(r[l],n[l]))||(t.current=e),t.current}const Xt={previous:null,next:null},Kd=["motion","edge","window"];function Hn(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Kd.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const Lo=(e,t)=>e.getTime()===t.getTime();function rn(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 nn(e,t,r){e.current=t,e.hand(t),r(t)}function qd(e,t){return typeof t=="function"?t(e):t}function on(e){return s.useReducer(qd,void 0,e)}function an(e,t,r,n){r===t||e.current!==r||(e.forgetHanded(t),n(o=>o===t?r:o))}function Xd(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:l,selectorStep:u,...d}=e;Le("usePeriodSliderRange","unit",t);const m=gr("usePeriodSliderRange",i);ea("usePeriodSliderRange",r,n,[t],m),dr("usePeriodSliderRange","initialRange",o,t,m),u!==void 0&&Cr("usePeriodSliderRange","selectorStep",u,"motion");const x=ta(d),L=r.getTime(),T=n.getTime(),b=s.useMemo(()=>fr("usePeriodSliderRange",Ko(x.allowedDates),t,r,n,m).dates,[x.allowedDates,t,L,T,m]),g=s.useRef(o),[w,h]=on(()=>(Vo("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",m),Yn(o,Fa(o,t,r,n,b,m)))),D=Jo("usePeriodSliderRange",[w]);dr("usePeriodSliderRange","range",w,t,m);const M=Yn(w,Fa(w,t,r,n,b,m)),v=Jr(D,0,M,h);s.useLayoutEffect(()=>{an(v,w,M,h)});const f=en(D,0,o),ue=mt({minDate:r,maxDate:n,candidates:b}),K=mt(a),re=s.useCallback(te=>{const{minDate:le,maxDate:Se,candidates:ae}=ue.current,ie=Fa(te,t,le,Se,ae,m);rn(v,ie,Et,h);const pe=f.current;ie[0].getTime()===pe[0].getTime()&&ie[1].getTime()===pe[1].getTime()||(f.current=ie,D.notify(0,()=>K.current?.(ie[0],ie[1])))},[t,m]),ee=s.useCallback(te=>{const le=typeof te=="function"?te(v.current):te;f.current=le,nn(v,le,h)},[]),B=s.useCallback(te=>{Ee("usePeriodSliderRange","setLowerDate(date)",te,t,m);const le=v.current,Se=te.getTime()>le[1].getTime()?te:le[1];re([te,Se])},[re,t,m]),ne=s.useCallback(te=>{Ee("usePeriodSliderRange","setUpperDate(date)",te,t,m);const le=v.current,Se=te.getTime()<le[0].getTime()?te:le[0];re([Se,te])},[re,t,m]),A=s.useCallback((te,le)=>{Ee("usePeriodSliderRange","sliderProps.onChangeRange(lower)",te,t,m),Ee("usePeriodSliderRange","sliderProps.onChangeRange(upper)",le,t,m),Oo("usePeriodSliderRange","sliderProps.onChangeRange",te,le),re([te,le])},[re,t,m]),q=s.useCallback(te=>{tn("usePeriodSliderRange","shiftRange",te);const{minDate:le,maxDate:Se,candidates:ae}=ue.current,ie=v.current;if(ae.length>0){re([_o(ae,t,ie[0],te,m),_o(ae,t,ie[1],te,m)]);return}re([Ft(t,ie[0],te,le,Se,m).date,Ft(t,ie[1],te,le,Se,m).date])},[t,re,m]),j=s.useCallback(()=>{re(g.current)},[re]),k=Hn(u),$=k!==void 0,H=s.useMemo(()=>{if(k===void 0)return{start:Xt,end:Xt};const te=b.length>0?x.allowedDates:void 0,le={selection:M,unit:t,yearStartMonth:m,minDate:r,maxDate:n,allowedDates:te,rules:k};return{start:Za({...le,shows:"start"}),end:Za({...le,shows:"end"})}},[k,M,t,m,L,T,b,x.allowedDates]),Y=jt(H.start,re),N=jt(H.end,re),F=s.useMemo(()=>({value:M[0],onChange:B,minDate:r,maxDate:M[1],unit:t,yearStartMonth:m,...Ut(t,b),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...$?{stepper:Y}:{}}),[M[0],M[1],B,r,t,m,b,e.formatLocale,e.locale,e.labels,l,$,Y]),G=s.useMemo(()=>({value:M[1],onChange:ne,minDate:M[0],maxDate:n,unit:t,yearStartMonth:m,...Ut(t,b),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...$?{stepper:N}:{}}),[M[0],M[1],ne,n,t,m,b,e.formatLocale,e.locale,e.labels,l,$,N]),he=s.useMemo(()=>({...x,mode:"range",unit:t,yearStartMonth:m,range:M,minDate:r,maxDate:n,onChangeRange:A}),[x,t,M,r,n,A,m]);return{range:M,lowerDate:M[0],upperDate:M[1],setRange:ee,setLowerDate:B,setUpperDate:ne,shiftRange:q,resetRange:j,startSelectorProps:F,endSelectorProps:G,sliderProps:he,duringRender:D.duringRender}}function Zd(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:l,...u}=e;Le("usePeriodSliderPoint","unit",t);const d=gr("usePeriodSliderPoint",i);ea("usePeriodSliderPoint",r,n,[t],d),Ee("usePeriodSliderPoint","initialValue",o,t,d);const m=ta(u),x=r.getTime(),L=n.getTime(),T=s.useMemo(()=>fr("usePeriodSliderPoint",Ko(m.allowedDates),t,r,n,d).dates,[m.allowedDates,t,x,L,d]),b=s.useRef(o),[g,w]=on(()=>(No("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",d),$n(o,t,r,n,T,d))),h=Jo("usePeriodSliderPoint",[g]);Ee("usePeriodSliderPoint","value",g,t,d);const D=$n(g,t,r,n,T,d),M=Jr(h,0,D,w);s.useLayoutEffect(()=>{an(M,g,D,w)});const v=en(h,0,o),f=mt({minDate:r,maxDate:n,candidates:T}),ue=mt(a),K=s.useCallback(k=>{const{minDate:$,maxDate:H,candidates:Y}=f.current,N=$n(k,t,$,H,Y,d);rn(M,N,Lo,w),N.getTime()!==v.current.getTime()&&(v.current=N,h.notify(0,()=>ue.current?.(N)))},[t,d]),re=s.useCallback(k=>{const $=typeof k=="function"?k(M.current):k;v.current=$,nn(M,$,w)},[]),ee=s.useCallback(k=>{Ee("usePeriodSliderPoint","selectorProps.onChange(date)",k,t,d),K(k)},[K,t,d]),B=s.useCallback(k=>{Ee("usePeriodSliderPoint","sliderProps.onChangePoint(value)",k,t,d),K(k)},[K,t,d]),ne=s.useCallback(k=>{tn("usePeriodSliderPoint","shiftValue",k);const{minDate:$,maxDate:H,candidates:Y}=f.current;if(Y.length>0){K(_o(Y,t,M.current,k,d));return}K(Ft(t,M.current,k,$,H,d).date)},[t,K,d]),A=s.useCallback(()=>{K(b.current)},[K]),q=s.useMemo(()=>({value:D,onChange:ee,minDate:r,maxDate:n,unit:t,yearStartMonth:d,...Ut(t,T),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l}),[D,ee,r,n,t,d,T,e.formatLocale,e.locale,e.labels,l]),j=s.useMemo(()=>({...m,mode:"point",unit:t,yearStartMonth:d,value:D,minDate:r,maxDate:n,onChangePoint:B}),[m,t,D,r,n,B,d]);return{value:D,setValue:re,shiftValue:ne,resetValue:A,selectorProps:q,sliderProps:j,duringRender:h.duringRender}}function Qd(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:l,onChangeMacroRange:u,onChangeMicroRange:d,yearStartMonth:m,formatOption:x,macroSelectorStep:L,microSelectorStep:T,...b}=e;Le("useVernierSliderRange","unit",t);const g=Qt("useVernierSliderRange","macroUnit",i,t),w=Qt("useVernierSliderRange","microUnit",l,t),h=gr("useVernierSliderRange",m);ea("useVernierSliderRange",r,n,[g,w,t],h),dr("useVernierSliderRange","initialMacroRange",o,g,h),dr("useVernierSliderRange","initialMicroRange",a,w,h),L!==void 0&&Cr("useVernierSliderRange","macroSelectorStep",L,"motion"),T!==void 0&&Cr("useVernierSliderRange","microSelectorStep",T,"vernierRange");const D=ta(b),M=s.useRef(o),v=s.useRef(a),[f,ue]=on(()=>(Vo("useVernierSliderRange","initialMacroRange",g,o,r,n,"[minDate, maxDate]",h),o)),[K,re]=on(()=>{const E=$t(g,w,o,r,n,h);return Vo("useVernierSliderRange","initialMicroRange",w,a,E[0],E[1],"the initial macro window",h),a}),ee=Jo("useVernierSliderRange",[f,K]);dr("useVernierSliderRange","macroRange",f,g,h);const B=Yn(f,[ke(f[0],r,n),ke(f[1],r,n)]),ne=r.getTime(),A=n.getTime(),q=s.useMemo(()=>$t(g,w,B,r,n,h),[g,w,B,ne,A,h]),j=s.useMemo(()=>Ht("micro",D)?ui("useVernierSliderRange",Lt("micro",D),w,r,n,h):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,w,ne,A,h]),k=s.useMemo(()=>Ht("macro",D)?fr("useVernierSliderRange",Lt("macro",D),g,r,n,h).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,g,ne,A,h]),$=mt(k),H=s.useMemo(()=>_n(q,w,j,h),[q,w,j,h]),Y=s.useMemo(()=>Nn(j,H),[j,H]);dr("useVernierSliderRange","microRange",K,w,h);const N=Yn(K,Zr(K,w,q,H,h,"resize")),F=Jr(ee,0,B,ue),G=Jr(ee,1,N,re);s.useLayoutEffect(()=>{an(F,f,B,ue),an(G,K,N,re)});const he=en(ee,1,a),te=en(ee,0,o),le=mt({minDate:r,maxDate:n}),Se=mt(u),ae=mt(d),ie=s.useCallback(E=>{const{minDate:z,maxDate:ce}=le.current;return $t(g,w,E,z,ce,h)},[g,w,h]),pe=s.useCallback(E=>_n(E,w,j,h),[w,j,h]),je=s.useCallback(E=>{rn(F,E,Et,ue);const z=te.current;E[0].getTime()===z[0].getTime()&&E[1].getTime()===z[1].getTime()||(te.current=E,ee.notify(0,()=>Se.current?.(E[0],E[1])))},[]),ft=s.useCallback(E=>{const z=typeof E=="function"?E(F.current):E;te.current=z,nn(F,z,ue)},[]),ge=s.useCallback((E,z,ce)=>{const Ne=ce==="micro"&&Et(F.current,E)&&Et(te.current,E),Te=ce==="macro"&&Et(G.current,z)&&Et(he.current,z);if(Ne||je(E),Te)return;rn(G,z,Et,re);const Ve=he.current;(z[0].getTime()!==Ve[0].getTime()||z[1].getTime()!==Ve[1].getTime())&&(he.current=z,ee.notify(1,()=>ae.current?.(z[0],z[1])))},[je]),V=s.useCallback(E=>{const z=typeof E=="function"?E(G.current):E;he.current=z,nn(G,z,re)},[]),X=s.useCallback((E,z,ce)=>{const{minDate:Ne,maxDate:Te}=le.current,Ve=[ke(E,Ne,Te),ke(z,Ne,Te)],Ye=ie(Ve);ge(Ve,Zr(G.current,w,Ye,pe(Ye),h,ce),"macro")},[w,ie,pe,ge,h]),de=s.useCallback((E,z)=>X(E,z,"resize"),[X]),Oe=s.useCallback((E,z)=>{Ee("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",E,g,h),Ee("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",z,g,h),Oo("useVernierSliderRange","sliderProps.onChangeMacroRange",E,z);const{minDate:ce,maxDate:Ne}=le.current,Te=[ke(E,ce,Ne),ke(z,ce,Ne)],Ve=G.current,Ye=ie(Te),Tt=Zr(Ve,w,Ye,pe(Ye),h,"resize");if(Tt[0].getTime()!==Ve[0].getTime()||Tt[1].getTime()!==Ve[1].getTime()){je(Te);return}ge(Te,Ve,"macro")},[g,w,ie,pe,je,ge,h]),we=s.useCallback((E,z)=>{const ce=ie(F.current);ge(F.current,Zr([E,z],w,ce,pe(ce),h,"resize"),"micro")},[w,ie,pe,ge,h]),tt=s.useCallback((E,z)=>{Ee("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",E,w,h),Ee("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",z,w,h),Oo("useVernierSliderRange","sliderProps.onChangeMicroRange",E,z),we(E,z)},[we,w,h]),qe=s.useCallback(E=>{Ee("useVernierSliderRange","setMacroLowerDate(date)",E,g,h);const z=F.current[1],ce=E>z?E:z;de(E,ce)},[de,g,h]),Fe=s.useCallback(E=>{Ee("useVernierSliderRange","setMacroUpperDate(date)",E,g,h);const z=F.current[0],ce=E<z?E:z;de(ce,E)},[de,g,h]),st=s.useCallback(E=>{Ee("useVernierSliderRange","setMicroLowerDate(date)",E,w,h);const z=G.current[1],ce=E>z?E:z;we(E,ce)},[we,w,h]),oe=s.useCallback(E=>{Ee("useVernierSliderRange","setMicroUpperDate(date)",E,w,h);const z=G.current[0],ce=E<z?E:z;we(ce,E)},[we,w,h]),pt=s.useCallback(E=>{tn("useVernierSliderRange","shiftMacroRange",E);const{minDate:z,maxDate:ce}=le.current,Ne=F.current,Te=$.current;if(Te.length>0){const Tt=Me(Te,Ne[0],g,h)+E,Jt=Me(Te,Ne[1],g,h)+E;if(Tt<0||Jt>Te.length-1)return;X(Te[Tt],Te[Jt],"pan");return}const Ve=Ft(g,Ne[0],E,z,ce,h),Ye=Ft(g,Ne[1],E,z,ce,h);Ve.pastDateRange||Ye.pastDateRange||Ve.date<z||Ye.date>ce||X(Ve.date,Ye.date,"pan")},[g,X,h]),Xe=s.useCallback(E=>{tn("useVernierSliderRange","shiftMicroRange",E);const z=F.current,ce=G.current,Ne=ie(z),[Te,Ve]=Ne,Ye=Nn(j,pe(Ne));if(Ye.length>0){const nt=Me(Ye,ce[0],w,h)+E,pr=Me(Ye,ce[1],w,h)+E;if(nt<0||pr>Ye.length-1)return;we(Ye[nt],Ye[pr]);return}const Tt=Ft(w,ce[0],E,Te,Ve,h),Jt=Ft(w,ce[1],E,Te,Ve,h);Tt.pastDateRange||Jt.pastDateRange||U(w,Tt.date,h)<U(w,Te,h)||U(w,Jt.date,h)>U(w,Ve,h)||we(Tt.date,Jt.date)},[w,j,ie,pe,we,h]),ht=s.useCallback(()=>{const{minDate:E,maxDate:z}=le.current,ce=[ke(M.current[0],E,z),ke(M.current[1],E,z)],Ne=ie(ce);ge(ce,Zr(v.current,w,Ne,pe(Ne),h,"resize"),"both")},[w,ie,pe,ge,h]),Ae=Hn(L),We=Hn(T),ye=Ae!==void 0,bt=We!==void 0,rt=s.useMemo(()=>{const E={macroUnit:g,microUnit:w,yearStartMonth:h,minDate:r,maxDate:n,macroRange:B,microSelection:N,macroAllowedDates:Ht("macro",D)?Lt("macro",D).list:void 0,microAllowedDates:Ht("micro",D)?Lt("micro",D).list:void 0};return{macroStart:Ae===void 0?Xt:ur({...E,row:"macro",shows:"start",rules:Ae}),macroEnd:Ae===void 0?Xt:ur({...E,row:"macro",shows:"end",rules:Ae}),microStart:We===void 0?Xt:ur({...E,row:"micro",shows:"start",rules:We}),microEnd:We===void 0?Xt:ur({...E,row:"micro",shows:"end",rules:We})}},[Ae,We,g,w,h,ne,A,B,N,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),zt=s.useCallback(E=>ge(E.macroRange,E.microSelection,"macro"),[ge]),I=s.useCallback(E=>ge(E.macroRange,E.microSelection,"micro"),[ge]),J=jt(rt.macroStart,zt),Ue=jt(rt.macroEnd,zt),lt=jt(rt.microStart,I),Ge=jt(rt.microEnd,I),[Re,$e]=q,Ir=s.useMemo(()=>({value:B[0],onChange:qe,minDate:r,maxDate:B[1],unit:g,yearStartMonth:h,...Ut(g,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ye?{stepper:J}:{}}),[B,qe,r,g,h,k,e.formatLocale,e.locale,e.labels,x,ye,J]),_=s.useMemo(()=>({value:B[1],onChange:Fe,minDate:B[0],maxDate:n,unit:g,yearStartMonth:h,...Ut(g,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...ye?{stepper:Ue}:{}}),[B,Fe,n,g,h,k,e.formatLocale,e.locale,e.labels,x,ye,Ue]),P=s.useMemo(()=>({value:N[0],onChange:st,minDate:Re,maxDate:N[1],unit:w,yearStartMonth:h,...Ut(w,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...bt?{stepper:lt}:{}}),[N,st,Re,w,h,Y,e.formatLocale,e.locale,e.labels,x,bt,lt]),xe=s.useMemo(()=>({value:N[1],onChange:oe,minDate:N[0],maxDate:$e,unit:w,yearStartMonth:h,...Ut(w,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...bt?{stepper:Ge}:{}}),[N,oe,$e,w,h,Y,e.formatLocale,e.locale,e.labels,x,bt,Ge]),_e=s.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:g,microUnit:w,minDate:r,maxDate:n,macroRange:B,microRange:N,onChangeMacroRange:Oe,onChangeMicroRange:tt}),[D,t,g,w,r,n,B,N,Oe,tt,h]);return{macroRange:B,setMacroRange:ft,microRange:N,setMicroRange:V,setMacroLowerDate:qe,setMacroUpperDate:Fe,setMicroLowerDate:st,setMicroUpperDate:oe,shiftMacroRange:pt,shiftMicroRange:Xe,resetVernier:ht,macroStartSelectorProps:Ir,macroEndSelectorProps:_,microStartSelectorProps:P,microEndSelectorProps:xe,sliderProps:_e,duringRender:ee.duringRender}}function Jd(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:l,onChangeMacroRange:u,onChangeMicroPoint:d,yearStartMonth:m,formatOption:x,macroSelectorStep:L,microSelectorStep:T,...b}=e;Le("useVernierSliderPoint","unit",t);const g=Qt("useVernierSliderPoint","macroUnit",i,t),w=Qt("useVernierSliderPoint","microUnit",l,t),h=gr("useVernierSliderPoint",m);ea("useVernierSliderPoint",r,n,[g,w,t],h),dr("useVernierSliderPoint","initialMacroRange",o,g,h),Ee("useVernierSliderPoint","initialMicroValue",a,w,h),L!==void 0&&Cr("useVernierSliderPoint","macroSelectorStep",L,"motion"),T!==void 0&&Cr("useVernierSliderPoint","microSelectorStep",T,"vernierPoint");const D=ta(b),M=s.useRef(o),v=s.useRef(a),[f,ue]=on(()=>(Vo("useVernierSliderPoint","initialMacroRange",g,o,r,n,"[minDate, maxDate]",h),o)),[K,re]=on(()=>{const _=$t(g,w,o,r,n,h);return No("useVernierSliderPoint","initialMicroValue",w,a,_[0],_[1],"the initial macro window",h),a}),ee=Jo("useVernierSliderPoint",[f,K]);dr("useVernierSliderPoint","macroRange",f,g,h);const B=Yn(f,[ke(f[0],r,n),ke(f[1],r,n)]),ne=r.getTime(),A=n.getTime(),q=s.useMemo(()=>$t(g,w,B,r,n,h),[g,w,B,ne,A,h]),j=s.useMemo(()=>Ht("micro",D)?ui("useVernierSliderPoint",Lt("micro",D),w,r,n,h):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,w,ne,A,h]),k=s.useMemo(()=>Ht("macro",D)?fr("useVernierSliderPoint",Lt("macro",D),g,r,n,h).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,g,ne,A,h]),$=mt(k),H=s.useMemo(()=>_n(q,w,j,h),[q,w,j,h]),Y=s.useMemo(()=>Nn(j,H),[j,H]);Ee("useVernierSliderPoint","microValue",K,w,h);const N=$r(K,w,q,H,h),F=Jr(ee,0,B,ue),G=Jr(ee,1,N,re);s.useLayoutEffect(()=>{an(F,f,B,ue),an(G,K,N,re)});const he=en(ee,1,a),te=en(ee,0,o),le=mt({minDate:r,maxDate:n}),Se=mt(u),ae=mt(d),ie=s.useCallback(_=>{const{minDate:P,maxDate:xe}=le.current;return $t(g,w,_,P,xe,h)},[g,w,h]),pe=s.useCallback(_=>_n(_,w,j,h),[w,j,h]),je=s.useCallback(_=>{rn(F,_,Et,ue);const P=te.current;_[0].getTime()===P[0].getTime()&&_[1].getTime()===P[1].getTime()||(te.current=_,ee.notify(0,()=>Se.current?.(_[0],_[1])))},[]),ft=s.useCallback(_=>{const P=typeof _=="function"?_(F.current):_;te.current=P,nn(F,P,ue)},[]),ge=s.useCallback((_,P,xe)=>{const _e=xe==="micro"&&Et(F.current,_)&&Et(te.current,_),E=xe==="macro"&&Lo(G.current,P)&&Lo(he.current,P);_e||je(_),!E&&(rn(G,P,Lo,re),P.getTime()!==he.current.getTime()&&(he.current=P,ee.notify(1,()=>ae.current?.(P))))},[je]),V=s.useCallback(_=>{const P=typeof _=="function"?_(G.current):_;he.current=P,nn(G,P,re)},[]),X=s.useCallback((_,P)=>{const{minDate:xe,maxDate:_e}=le.current,E=[ke(_,xe,_e),ke(P,xe,_e)],z=ie(E);ge(E,$r(G.current,w,z,pe(z),h),"macro")},[w,ie,pe,ge,h]),de=s.useCallback(_=>{const P=ie(F.current);ge(F.current,$r(_,w,P,pe(P),h),"micro")},[w,ie,pe,ge,h]),Oe=s.useCallback((_,P)=>{Ee("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",_,g,h),Ee("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",P,g,h),Oo("useVernierSliderPoint","sliderProps.onChangeMacroRange",_,P);const{minDate:xe,maxDate:_e}=le.current,E=[ke(_,xe,_e),ke(P,xe,_e)],z=G.current,ce=ie(E);if($r(z,w,ce,pe(ce),h).getTime()!==z.getTime()){je(E);return}ge(E,z,"macro")},[g,w,ie,pe,je,ge,h]),we=s.useCallback(_=>{Ee("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",_,w,h),de(_)},[de,w,h]),tt=s.useCallback(_=>{Ee("useVernierSliderPoint","setMacroLowerDate(date)",_,g,h);const P=F.current[1],xe=_>P?_:P;X(_,xe)},[X,g,h]),qe=s.useCallback(_=>{Ee("useVernierSliderPoint","setMacroUpperDate(date)",_,g,h);const P=F.current[0],xe=_<P?_:P;X(xe,_)},[X,g,h]),Fe=s.useCallback(_=>{Ee("useVernierSliderPoint","setMicroDate(date)",_,w,h),de(_)},[de,w,h]),st=s.useCallback(_=>{tn("useVernierSliderPoint","shiftMacroRange",_);const{minDate:P,maxDate:xe}=le.current,_e=F.current,E=$.current;if(E.length>0){const Ne=Me(E,_e[0],g,h)+_,Te=Me(E,_e[1],g,h)+_;if(Ne<0||Te>E.length-1)return;X(E[Ne],E[Te]);return}const z=Ft(g,_e[0],_,P,xe,h),ce=Ft(g,_e[1],_,P,xe,h);z.pastDateRange||ce.pastDateRange||z.date<P||ce.date>xe||X(z.date,ce.date)},[g,X,h]),oe=s.useCallback(_=>{tn("useVernierSliderPoint","shiftMicroValue",_);const P=F.current,xe=ie(P),_e=Nn(j,pe(xe));if(_e.length>0){de(_o(_e,w,G.current,_,h));return}de(Ft(w,G.current,_,xe[0],xe[1],h).date)},[w,j,ie,pe,de,h]),pt=s.useCallback(()=>{const{minDate:_,maxDate:P}=le.current,xe=[ke(M.current[0],_,P),ke(M.current[1],_,P)],_e=ie(xe);ge(xe,$r(v.current,w,_e,pe(_e),h),"both")},[w,ie,pe,ge,h]),Xe=Hn(L),ht=Hn(T),Ae=Xe!==void 0,We=ht!==void 0,ye=s.useMemo(()=>{const _={macroUnit:g,microUnit:w,yearStartMonth:h,minDate:r,maxDate:n,macroRange:B,microSelection:[N,N],macroAllowedDates:Ht("macro",D)?Lt("macro",D).list:void 0,microAllowedDates:Ht("micro",D)?Lt("micro",D).list:void 0};return{macroStart:Xe===void 0?Xt:ur({..._,row:"macro",shows:"start",rules:Xe}),macroEnd:Xe===void 0?Xt:ur({..._,row:"macro",shows:"end",rules:Xe}),micro:ht===void 0?Xt:ur({..._,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:ht.previous.window},next:{motion:"shift",window:ht.next.window}}})}},[Xe,ht,g,w,h,ne,A,B,N,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),bt=s.useCallback(_=>ge(_.macroRange,_.microSelection[0],"macro"),[ge]),rt=s.useCallback(_=>ge(_.macroRange,_.microSelection[0],"micro"),[ge]),zt=jt(ye.macroStart,bt),I=jt(ye.macroEnd,bt),J=jt(ye.micro,rt),[Ue,lt]=q,Ge=s.useMemo(()=>({value:B[0],onChange:tt,minDate:r,maxDate:B[1],unit:g,yearStartMonth:h,...Ut(g,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ae?{stepper:zt}:{}}),[B,tt,r,g,h,k,e.formatLocale,e.locale,e.labels,x,Ae,zt]),Re=s.useMemo(()=>({value:B[1],onChange:qe,minDate:B[0],maxDate:n,unit:g,yearStartMonth:h,...Ut(g,k),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...Ae?{stepper:I}:{}}),[B,qe,n,g,h,k,e.formatLocale,e.locale,e.labels,x,Ae,I]),$e=s.useMemo(()=>({value:N,onChange:Fe,minDate:Ue,maxDate:lt,unit:w,yearStartMonth:h,...Ut(w,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:x,...We?{stepper:J}:{}}),[N,Fe,Ue,lt,w,h,Y,e.formatLocale,e.locale,e.labels,x,We,J]),Ir=s.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:g,microUnit:w,minDate:r,maxDate:n,macroRange:B,microValue:N,onChangeMacroRange:Oe,onChangeMicroPoint:we}),[D,t,g,w,r,n,B,N,Oe,we,h]);return{macroRange:B,setMacroRange:ft,microValue:N,setMicroValue:V,setMacroLowerDate:tt,setMacroUpperDate:qe,setMicroDate:Fe,shiftMacroRange:st,shiftMicroValue:oe,resetVernier:pt,macroStartSelectorProps:Ge,macroEndSelectorProps:Re,microSelectorProps:$e,sliderProps:Ir,duringRender:ee.duringRender}}function oi(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function Yo(e,t){const r=new Date(e.getTime());return Wo(r.getFullYear(),r.getMonth(),t)}function ol(e){return e===void 0?0:gl(e)?e:Number.NaN}const al=Fn("declare the years to offer with minYear / maxYear or allowedYears");function vo(e,t,r,n){e!==void 0&&Gl(e,t,r,n)}function Gl(e,t,r,n){if(!De(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${y(e)})`);Ke("YearSelector",t,e,"year",r,n)}function il(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(oi(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 sl(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:Yo(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function em(e,t,r,n){const o=new Set;for(const a of e){const i=Yo(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function tm(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:em(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function rm(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const nm=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,minYear:l,maxYear:u,minDate:d,maxDate:m,allowedYears:x,className:L="",style:T,disabled:b=!1,locale:g,labels:w,formatLocale:h,formatOption:D,yearStartMonth:M}=e,v=gr("YearSelector",M);if(vo(t,"value",v,""),vo(r,"initialDate",v,""),vo(d,"minDate",v,al),vo(m,"maxDate",v,al),il(l,"minYear",v),il(u,"maxYear",v),sn("YearSelector","allowedYears",x),x!==void 0)for(let ae=0;ae<x.length;ae++)Gl(x[ae],`allowedYears[${ae}]`,v,"");h!==void 0&&Zo("YearSelector","formatLocale",h);const f=t??r;if(f===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&&gi("YearSelector",o,t!==void 0);const ue=li("YearSelector",a),K=zo(g,w),re=t!==void 0,[ee,B]=pi(f,re,ae=>Qo(ae,"year",v),ae=>Yo(ae,v)),ne=d?.getTime(),A=m?.getTime(),q=s.useMemo(()=>sl(l,d,Math.max,v),[l,ne,v]),j=s.useMemo(()=>sl(u,m,Math.min,v),[u,A,v]);if(q!==null&&j!==null&&q>j)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${q}, upper: ${j})`);const k=x===void 0?null:x.map(ae=>ae.getTime()).join(","),$=s.useMemo(()=>tm(x,q,j,v),[k,q,j,v]);if($===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(()=>$.kind==="discrete"?{kind:"candidates",ascending:$.ascending,loIndex:0,hiIndex:$.ascending.length-1}:{kind:"range",min:$.minYear,max:$.maxYear},[$]),Y=t!==void 0?Yo(t,v):ee,N=!In(H,Y),F=ae=>{if(!b){if(!In(H,ae))throw new RangeError(`YearSelector: refusing to emit ${ae}, which lies outside the selectable years`);re||B(ae),n?.(oi(ae,v),ae)}},G=Zt(H,Y,-1),he=Zt(H,Y,1),te=()=>{if(o!==void 0){o.onStep("previous");return}G!==null&&F(G)},le=()=>{if(o!==void 0){o.onStep("next");return}he!==null&&F(he)},Se=s.useMemo(()=>{const ae=$.kind==="discrete"?[...$.ascending].reverse():rm($.minYear,$.maxYear);return N&&(ae.push(Y),ae.sort((ie,pe)=>pe-ie)),ae.map(ie=>({value:ie,label:it("year",oi(ie,v),D,h)}))},[$,N,Y,v,h,D]);return C.jsxs("div",{className:`inline-flex items-center ${Tn} ${L}`,style:T,"data-out-of-range":N?"true":void 0,children:[C.jsx(Tr,{neighbour:"control",direction:"left",glyph:ue,disabled:b,canStep:o===void 0?G!==null:o.canStepPrevious,onStep:te,ariaLabel:K.previousYear}),C.jsx("select",{"aria-label":K.yearSelect,disabled:b,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:Y,onChange:ae=>{if(!ae.target.value)return;const ie=Number(ae.target.value);Number.isInteger(ie)&&F(ie)},children:Se.map(ae=>C.jsx("option",{value:ae.value,disabled:N&&ae.value===Y,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:ae.label},ae.value))}),C.jsx(Tr,{neighbour:"control",direction:"right",glyph:ue,disabled:b,canStep:o===void 0?he!==null:o.canStepNext,onStep:le,ariaLabel:K.nextYear}),i]})},om=(e,t)=>{const r=ol(t.yearStartMonth);return!(ol(e.yearStartMonth)!==r||!hi(e,t,n=>Qo(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.stepGlyph!==t.stepGlyph||e.children!==t.children||e.locale!==t.locale||!Uo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},Kl=s.memo(nm,om);Kl.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=hl;exports.DateSelector=Ul;exports.MonthSelector=Wl;exports.PERIOD_SLIDER_LABEL_CATALOGS=ml;exports.PERIOD_SLIDER_LABEL_KEYS=Fo;exports.PeriodSlider=Nl;exports.YearSelector=Kl;exports.addUnit=wl;exports.areStylesEqual=Al;exports.calculateConnectDragValues=Rl;exports.calculateHandleDragValues=Wa;exports.calculateKeyboardActionValues=Ml;exports.calculateLabelSlant=Pl;exports.calculateVernierMacroDrag=Tl;exports.calculateVernierMicroDrag=Cl;exports.decode=se;exports.encode=U;exports.findNearestDateIndex=Me;exports.formatLabel=it;exports.formatOptionText=Vl;exports.formatQuarterLabel=Nu;exports.formatScreenReaderLabel=Pr;exports.getMacroWindowEndDate=Sl;exports.getMacroWindowStartDate=vl;exports.getSortedAllowedDates=Vu;exports.normalizeDateByUnit=Rt;exports.resolveDraggedEdge=jo;exports.resolveMacroWindow=$t;exports.resolvePeriodSliderLabels=fl;exports.resolveQuarter=xl;exports.resolveSelectorSteps=Za;exports.resolveVernierRailZone=fi;exports.resolveVernierSelectorSteps=ur;exports.resolveVernierTargetHandle=$l;exports.resolveWheelStep=Ll;exports.usePeriodSliderPoint=Zd;exports.usePeriodSliderRange=Xd;exports.useSelectorStepper=jt;exports.useVernierSliderPoint=Jd;exports.useVernierSliderRange=Qd;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("react/jsx-runtime"),Fc=require("date-fns"),s=require("react"),mr=require("@aiquants/virtualscroll"),Uc=require("react-dom"),si="an object that cannot be converted to a string",zc=3,De=e=>{try{return e instanceof Date&&!Number.isNaN(Date.prototype.getTime.call(e))}catch{return!1}},kt=e=>{try{return Array.isArray(e)}catch{return!1}},Bc=e=>e===void 0||kt(e);function sn(e,t,r){if(!Bc(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(De(e))return Date.prototype.toISOString.call(e);if(kt(e))return Wc(e);try{return String(e)}catch{return si}},Wc=e=>{let t;try{t=e.length}catch{return si}const r=Math.min(t,zc),n=[];for(let a=0;a<r;a++)n.push(Gc(e,a));const o=t-r;return`[${n.join(", ")}${o>0?`, ... ${o} more`:""}]`},Gc=(e,t)=>{try{if(!(t in e))return"empty";const r=e[t];return kt(r)?`Array(${r.length})`:y(r)}catch{return si}},Pt=(e,t)=>De(e)?t(e):Number.NaN,gt=(e,t)=>e===void 0?null:Pt(e,t),Ss=120,Ca="data-drag-snap",Ia="--ps-drag-snap-duration",Pn={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"]},cl=["low","high"],ul=["tx","ty","rot","leader-length","leader-angle"],Fo={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"}},li=(e,t)=>`${e}-${t}`,Ln=(e,t,r)=>`var(${li(e,t)}, ${r})`,Kc=(e,t,r)=>{const n=Fo[t];for(const o of cl)for(const a of ul)e.style.setProperty(li(n[o],a),r[o][a])},dl=e=>Math.max(0,Math.min(1,e)),To=(e,t,r,n)=>{const o=dl(t);if(e==="point")return[o,o];const a=e==="low"?n:r;return[Math.min(o,a),Math.max(o,a)]},ci=(e,t,r)=>{const n=r-t,o=Math.max(0,Math.min(1-n,t+e));return[o,o+n]},Uo=(e,t,r,n)=>{const o=dl(t);return e==="low"?o>n?"high":"low":o<r?"low":"high"},Aa=(e,t,r,n)=>{if(r){const i=(1-e)*100,l=(1-t)*100;return n?`M 12 ${l} L 12 ${i} L 20 100 L 20 0 Z`:`M 12 0 L 12 100 L 20 ${i} L 20 ${l} Z`}const o=e*100,a=t*100;return n?`M ${o} 12 L ${a} 12 L 100 20 L 0 20 Z`:`M 0 12 L 100 12 L ${a} 20 L ${o} 20 Z`},sr=(e,t)=>`var(${e}, ${t}%)`,qc=(e,t,r,n)=>{const[o,a]=Pn[t];e.style.setProperty(o,`${r*100}%`),e.style.setProperty(a,`${n*100}%`)},Xc=e=>{for(const[t,r]of Object.values(Pn))e.style.removeProperty(t),e.style.removeProperty(r);for(const t of Object.values(Fo))for(const r of cl)for(const n of ul)e.style.removeProperty(li(t[r],n))},Zc=["transform","translate","scale","rotate","perspective","filter","backdrop-filter"],Qc=["transform","translate","scale","rotate","perspective","filter"],Jc=["paint","layout","strict","content"],eu=["paint","strict","content"],tu=new Set(["hidden","clip","auto","scroll","overlay"]),ru=(e,t)=>{const r=e.getPropertyValue("position");if(t==="absolute"&&r!==""&&r!=="static"||Zc.some(a=>!["","none"].includes(e.getPropertyValue(a)))||!["","normal"].includes(e.getPropertyValue("container-type")))return!0;const n=e.getPropertyValue("will-change");if(Qc.some(a=>n.includes(a)))return!0;const o=e.getPropertyValue("contain");return Jc.some(a=>o.includes(a))},nu=e=>{const t=e.getPropertyValue("display");if(t==="contents"||t==="inline")return!1;if(tu.has(e.getPropertyValue("overflow-y")))return!0;const r=e.getPropertyValue("contain");return eu.some(n=>r.includes(n))},Rs=e=>{if(e.assignedSlot!==null)return e.assignedSlot;if(e.parentElement!==null)return e.parentElement;const t=e.parentNode;return t!==null&&t.nodeType===11&&"host"in t?t.host:null},ou=e=>{const t=e.ownerDocument,r=t.defaultView;if(r===null)return[];const n=[];let o=r.getComputedStyle(e).getPropertyValue("position");for(let a=Rs(e);a!==null&&a!==t.documentElement&&a!==t.body;a=Rs(a)){const i=r.getComputedStyle(a);(o==="absolute"||o==="fixed")&&!ru(i,o)||(nu(i)&&n.push(a),o=i.getPropertyValue("position"))}return n},au=e=>{const t=e.getBoundingClientRect(),r="offsetHeight"in e&&typeof e.offsetHeight=="number"?e.offsetHeight:0,n=r>0?t.height/r:1,o=t.top+e.clientTop*n;return{top:o,bottom:o+e.clientHeight*n}},iu=(e,t,r)=>{const n=e.getBoundingClientRect(),o=e.ownerDocument.documentElement.clientHeight;if(!(n.height>0&&o>0))return null;const a=n.top+n.height/2;let i=0,l=o;for(const u of ou(e)){const d=au(u);i=Math.max(i,d.top),l=Math.min(l,d.bottom)}return t?.isConnected&&(i=Math.max(i,t.getBoundingClientRect().bottom)),r?.isConnected&&(l=Math.min(l,r.getBoundingClientRect().top)),{topPx:Math.max(0,a-i),bottomPx:Math.max(0,l-a)}},su=(e,t,r,n)=>{const o=e.ownerDocument.defaultView;if(o===null)return null;const a=e.getBoundingClientRect(),i=t.getBoundingClientRect();if(!(a.height>0&&i.height>0))return null;const l=a.top+a.height/2,u=Number.parseFloat(o.getComputedStyle(r).getPropertyValue(n==="top"?"bottom":"top"));if(!Number.isFinite(u))return null;const d=n==="top"?i.bottom-u:i.top+u;return{anchorPx:Math.abs(d-l),knobCentrePx:Math.abs(i.top+i.height/2-l)}},ml=["rangeStart","rangeEnd","selectedDate","macroRangeStart","macroRangeEnd","microRangeStart","microRangeEnd","microSelectedDate","decrease","increase","previousYear","nextYear","yearSelect","previousMonth","nextMonth","monthSelect","previousDay","nextDay","dateSelect","splitYear","splitMonth","splitDay"],zo=[...mr.VIRTUAL_SCROLL_LABEL_KEYS,...ml],Ba=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:"日"})}),fl=Object.freeze({en:Object.freeze({...mr.VIRTUAL_SCROLL_LABEL_CATALOGS.en,...Ba.en}),ja:Object.freeze({...mr.VIRTUAL_SCROLL_LABEL_CATALOGS.ja,...Ba.ja})}),xs=e=>typeof e=="string"?JSON.stringify(e):e===null?"null":typeof e,lu=e=>zo.includes(e),cu=(e,t)=>{const r={};let n=!1;for(const o of mr.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},uu=e=>{try{return mr.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}},hl=(e,t)=>{const r=uu(e);if(t===void 0)return fl[r];if(t===null||typeof t!="object")throw new RangeError(`[period-slider] labels must be an object; got ${xs(t)}`);const n=Object.getPrototypeOf(t);if(n!==Object.prototype&&n!==null)throw new RangeError(`[period-slider] labels must be a plain object (prototype Object.prototype or null); got ${Array.isArray(t)?"an array":"an object with a non-plain prototype"}`);const o=new Set(Object.keys(t));for(const l of o)if(!lu(l))throw new RangeError(`[period-slider] labels.${l} is not a known label key; expected one of ${zo.join(", ")}`);const i={...mr.resolveVirtualScrollLabels(r,cu(t,o)),...Ba[r]};for(const l of ml){const u=o.has(l)?t[l]:void 0;if(u!==void 0){if(typeof u!="string"||u.trim()==="")throw new RangeError(`[period-slider] labels.${l} must be a non-blank string; got ${xs(u)}`);i[l]=u}}return Object.freeze(i)},du=e=>{const t={};for(const r of mr.VIRTUAL_SCROLL_LABEL_KEYS)t[r]=e[r];return Object.freeze(t)},mu=(e,t)=>e===t||zo.every(r=>e[r]===t[r]),Bo=(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]))},ka=(e,t)=>e!==null&&t!==null&&"nodeType"in t&&e.contains(t),Ms=new Set(["hidden","clip","scroll","auto","overlay"]),Ds=["paint","strict","content"],fu=["layout","paint","strict","content"],hu=["transform","perspective","filter"],vn=e=>e!==void 0&&e!==""&&e!=="none",gu=e=>e!==void 0&&e!==""&&e!=="normal",co=e=>{const t=Number.parseFloat(e??"");return Number.isFinite(t)?t:0},pu=e=>e.position==="fixed"?"fixed":e.position==="absolute"?"absolute":null,bu=(e,t)=>t==="absolute"&&vn(e.position)&&e.position!=="static"||vn(e.transform)||vn(e.perspective)||vn(e.filter)||vn(e.backdropFilter)||gu(e.containerType)||fu.some(r=>e.contain.includes(r))?!0:hu.some(r=>e.willChange.includes(r)),wu=(e,t,r,n,o,a)=>{const i=t.ownerDocument.defaultView;if(i===null)return!1;const l=e.getBoundingClientRect();if(l.width===0||l.height===0)return!1;const u=n?0:r,d=n?r:0;if(o<l.left-u||o>=l.right+u||a<l.top-d||a>=l.bottom+d)return!1;const m=i.getComputedStyle(t);if(m.visibility!=="visible")return!1;let R=null;for(let L=t;L!==null;L=L.parentElement){const T=L===t?m:i.getComputedStyle(L);if(R!==null&&!bu(T,R))continue;const b=Ms.has(T.overflowX)||Ds.some(w=>T.contain.includes(w)),g=Ms.has(T.overflowY)||Ds.some(w=>T.contain.includes(w));if(b||g){const w=L.getBoundingClientRect();if(b&&(o<w.left+co(T.borderLeftWidth)||o>=w.right-co(T.borderRightWidth))||g&&(a<w.top+co(T.borderTopWidth)||a>=w.bottom-co(T.borderBottomWidth)))return!1}R=pu(T)}return!0},Na=new Map,vu=(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)},Su=(e,t)=>{let r=Na.get(e);if(r===void 0){const a=new Set,i=l=>vu(a,l);r={participants:a,listener:i},Na.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)&&(Na.delete(e),e.removeEventListener("wheel",o,{capture:!0}))}},Cn="gap-[11px]",Ru={single:1,double:2},yn=6,Er=yn*2,uo=(e,t)=>{const r=Ru[e],n=(r-1)*yn+yn*4/3,o=Er/2,a=Array.from({length:r},(l,u)=>{const d=u*yn,m=d+yn;return{left:`${d},${o} ${m},0 ${m},${Er}`,right:`${n-d},${o} ${n-m},0 ${n-m},${Er}`,up:`${o},${d} 0,${m} ${Er},${m}`,down:`${o},${n-d} 0,${n-m} ${Er},${n-m}`}[t]}),i=t==="up"||t==="down";return{widthPx:i?Er:n,heightPx:i?n:Er,triangles:a}},ys=e=>({left:uo(e,"left"),right:uo(e,"right"),up:uo(e,"up"),down:uo(e,"down")}),xu={single:ys("single"),double:ys("double")},ui=(e,t)=>{if(t===void 0)return"single";if(t==="single"||t==="double")return t;throw new RangeError(`${e}: stepGlyph must be "single" or "double" (received: ${y(t)})`)},Oa=e=>{e.preventDefault(),e.stopPropagation()},Mu={onMouseDownCapture:Oa,onMouseUpCapture:Oa,onClickCapture:Oa},Du="period-slider-step",yu=`${Du} relative inline-flex size-[22px] shrink-0 items-center justify-center rounded-md after:absolute after:content-['']`,Eu="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]",Pu={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"},mo="after:inset-[calc((100%-var(--ps-target-size))/2)]",Es={horizontal:"px-[19px]",vertical:"py-[19px]"},Lu={control:{left:mo,right:mo,up:mo,down:mo},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)]"}},Tr=({direction:e,glyph:t,neighbour:r,disabled:n,canStep:o,onStep:a,ariaLabel:i,className:l,ref:u})=>{const{widthPx:d,heightPx:m,triangles:R}=xu[t][e],L=n||!o;return C.jsx("button",{ref:u,type:"button","aria-label":i,disabled:n,"aria-disabled":L?!0:void 0,...L?Mu:null,onClick:L?void 0:a,className:`${l===void 0?"":`${l} `}${yu} ${Eu} ${Pu[r]} ${Lu[r][e]}`,children:C.jsx("svg",{"aria-hidden":"true",focusable:"false","data-arrow":e,"data-glyph":t,width:d,height:m,viewBox:`0 0 ${d} ${m}`,fill:"currentColor",className:"pointer-events-none block shrink-0",children:R.map(T=>C.jsx("polygon",{points:T},T))})})},Wo=(e,t)=>{const r=s.useMemo(()=>hl(e,t),[e,t]),n=s.useRef(r);return mu(n.current,r)||(n.current=r),n.current},dt=(e,t,r)=>{if(!Number.isInteger(r))throw new RangeError(`${e}: ${t} must be a finite integer (received: ${y(r)})`)},hr=(e,t)=>{if(t.kind==="range"){if(t.min!==null&&dt(e,"values.min",t.min),t.max!==null&&dt(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}dt(e,"values.loIndex",t.loIndex),dt(e,"values.hiIndex",t.hiIndex)},Fn=e=>e.kind==="candidates"&&e.hiIndex<e.loIndex,Go=(e,t)=>{let r=e.loIndex,n=e.hiIndex+1;for(;r<n;){const o=r+n>>1;e.ascending[o]<t?r=o+1:n=o}return r},In=(e,t)=>(hr("drawnValuesEdge",e),e.kind==="range"?t===-1?e.min:e.max:Fn(e)?null:e.ascending[t===-1?e.loIndex:e.hiIndex]),An=(e,t)=>{if(hr("drawnValuesHas",e),dt("drawnValuesHas","value",t),e.kind==="range")return(e.min===null||t>=e.min)&&(e.max===null||t<=e.max);if(Fn(e))return!1;const r=Go(e,t);return r<=e.hiIndex&&e.ascending[r]===t},kn=(e,t)=>{if(hr("drawnValuesNearest",e),dt("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(Fn(e))return null;const r=Go(e,t);if(r>e.hiIndex)return e.ascending[e.hiIndex];if(e.ascending[r]===t||r===e.loIndex)return e.ascending[r];const n=e.ascending[r-1],o=e.ascending[r];return t-n<=o-t?n:o},Zt=(e,t,r)=>{if(hr("drawnValuesNeighbour",e),dt("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(Fn(e))return null;const n=Go(e,t);if(r===-1){const a=n-1;return a<e.loIndex?null:e.ascending[a]}const o=n<=e.hiIndex&&e.ascending[n]===t?n+1:n;return o>e.hiIndex?null:e.ascending[o]},Ro=(e,t,r)=>{if(hr("clampPairIntoDrawnValues",e),dt("clampPairIntoDrawnValues","low",t),dt("clampPairIntoDrawnValues","high",r),r<t)throw new RangeError(`clampPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);const n=kn(e,t),o=kn(e,r);return n===null||o===null?null:[n,Math.max(n,o)]},$u=(e,t,r)=>{if(hr("carryPairIntoDrawnValues",e),dt("carryPairIntoDrawnValues","low",t),dt("carryPairIntoDrawnValues","high",r),r<t)throw new RangeError(`carryPairIntoDrawnValues: high must not precede low (low: ${t}, high: ${r})`);if(Fn(e))return null;const n=In(e,-1),o=In(e,1),a=r-t;return o!==null&&r>o?Ro(e,o-a,o):n!==null&&t<n?Ro(e,n,n+a):Ro(e,t,r)},xo=(e,t,r)=>(hr("drawnValuesAtOrBeyond",e),dt("drawnValuesAtOrBeyond","target",t),Zt(e,t-r,r)),ln=(e,t,r)=>{if(t!==null&&dt("drawnValuesWithin","min",t),r!==null&&dt("drawnValuesWithin","max",r),t!==null&&r!==null&&r<t)throw new RangeError(`drawnValuesWithin: max must not precede min (min: ${t}, max: ${r})`);const n={ascending:e,loIndex:0,hiIndex:e.length-1};let o=e.length;if(r!==null){let a=0;for(;a<o;){const i=a+o>>1;e[i]<=r?a=i+1:o=i}}return{kind:"candidates",ascending:e,loIndex:t===null?0:Go(n,t),hiIndex:o-1}},Mo=e=>(hr("drawnValuesStepGeometry",e),{stepEnd:(t,r)=>Zt(e,t,r),edge:t=>In(e,t)}),Wa=(e,t,r,n,o)=>{if(dt("stepPair","low",t),dt("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,l=e.stepEnd(i,n);if(l===null)return null;let u=e.stepEnd(a,n);if(u===null){const d=e.edge(n);if(o.edge==="disable"||d===null||(n===1?a>d:a<d))return null;u=d}return n===1?[l,u]:[u,l]}case"start":{const a=e.stepEnd(t,n);return a===null?null:[a,Math.max(r,a)]}case"end":{const a=e.stepEnd(r,n);return a===null?null:[Math.min(t,a),a]}case"single":{if(o.shows!=="start"&&o.shows!=="end")throw new RangeError(`stepPair: rule.shows must be "start" or "end" (received: ${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)})`)}},gl={"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"}},pl=e=>typeof e=="number"&&Number.isInteger(e)&&e>=0&&e<=11,Nt=(e,t)=>{if(!pl(t))throw new RangeError(`${e}: yearStartMonth must be an integer between 0 and 11 (received: ${y(t)})`)},gr=(e,t)=>t===void 0?0:(Nt(e,t),t),Le=(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:(Le(e,t,r),r),Tu=[31,28,31,30,31,30,31,31,30,31,30,31],bl=719468,Do=146097,Ga=(e,t)=>t!==1?Tu[t]:e%4===0&&(e%100!==0||e%400===0)?29:28,di=(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,Ga(a,i))]},Nn=(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,l=Math.floor((153*i+2)/5)+r-1,u=a*365+Math.floor(a/4)-Math.floor(a/100)+l;return o*Do+u-bl},Ps=e=>{const t=e+bl,r=Math.floor(t/Do),n=t-r*Do,o=Math.floor((n-Math.floor(n/1460)+Math.floor(n/36524)-Math.floor(n/(Do-1)))/365),a=n-(o*365+Math.floor(o/4)-Math.floor(o/100)),i=Math.floor((5*a+2)/153),l=i<10?i+2:i-10;return[r*400+o+(l<2?1:0),l,a-Math.floor((153*i+2)/5)+1]},Ko=(e,t,r)=>e-(t<r?1:0),xt=(e,t,r=0)=>{if(Le("normalizeDateByUnit","unit",e),!De(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${y(t)})`);Nt("normalizeDateByUnit",r);const n=new Date(t.getTime());return e==="year"?(n.setFullYear(Ko(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},U=(e,t,r=0)=>{Le("encode","unit",e),Nt("encode",r);const n=xt(e,t,r),o=n.getFullYear(),a=n.getMonth();return e==="year"?o:e==="month"?o*12+a:Nn(o,a,n.getDate())},se=(e,t,r=0)=>{Le("decode","unit",e),Nt("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},Un=e=>`; ${e} instead of a sentinel for "no bound"`,wl=Un("minDate is required, so pass the earliest date to offer"),Ke=(e,t,r,n,o,a)=>{const i=zn(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},zn=(e,t,r)=>{const n=U(t,e,r);return Number.isInteger(n)?n:null},vl=(e,t,r)=>{if(Le("addUnit","unit",e),!De(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(...di(n.getFullYear(),n.getMonth(),n.getDate(),e==="year"?r*12:r)),n):(n.setDate(n.getDate()+r),n)},Ls=(e,t,r,n,o)=>{const a=Math.floor(t/12),[i,l,u]=e==="year"?[t,o,1]:e==="month"?[a,t-a*12,1]:Ps(t),[d,m,R]=r==="year"||r==="month"?di(i,l,u,r==="year"?n*12:n):Ps(Nn(i,l,u)+n);return e==="year"?Ko(d,m,o):e==="month"?d*12+m:Nn(d,m,R)},Sl=(e,t,r,n=0)=>{if(Le("getMacroWindowStartDate","macroUnit",e),Le("getMacroWindowStartDate","microUnit",t),!De(r))throw new RangeError(`getMacroWindowStartDate: d must be a valid Date (received: ${y(r)})`);return Nt("getMacroWindowStartDate",n),Ke("getMacroWindowStartDate","d",r,e,n,""),Ke("getMacroWindowStartDate","d",r,t,n,""),xt(t,xt(e,r,n),n)},Rl=(e,t,r,n=0)=>{if(Le("getMacroWindowEndDate","macroUnit",e),Le("getMacroWindowEndDate","microUnit",t),!De(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${y(r)})`);Nt("getMacroWindowEndDate",n);let o;const a=new Date(r.getTime());if(e==="year"&&t!=="year"){const[l,u]=di(Ko(a.getFullYear(),a.getMonth(),n),n,1,11);o=t==="month"?l*12+u:Nn(l,u,Ga(l,u))}else if(e==="month"&&t==="day")o=Nn(a.getFullYear(),a.getMonth(),Ga(a.getFullYear(),a.getMonth()));else return Ke("getMacroWindowEndDate","d",r,t,n,""),xt(t,r,n);const i=se(t,o,n);if(!De(i))throw new RangeError(`getMacroWindowEndDate: d must fall in a ${e} whose last ${t} starts inside the Date range (received: ${y(r)})`);return i},$s=(e,t,r)=>e<t?t:e>r?r:e,$t=(e,t,r,n,o,a=0)=>{if(Le("resolveMacroWindow","macroUnit",e),Le("resolveMacroWindow","microUnit",t),Nt("resolveMacroWindow",a),Io("macroRange",r,!0,"resolveMacroWindow"),!De(n))throw new RangeError(`resolveMacroWindow: minDate must be a valid Date (received: ${y(n)})`);if(!De(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)})`);Ke("resolveMacroWindow","maxDate",o,t,a,""),Ke("resolveMacroWindow","macroRange[0]",r[0],e,a,""),Ke("resolveMacroWindow","macroRange[0]",r[0],t,a,"");const i=U(e,r[1],a)<U(e,o,a)?$s(Rl(e,t,r[1],a),n,o):o;return[xt(t,$s(Sl(e,t,r[0],a),n,o),a),xt(t,i,a)]},xl=(e,t)=>{if(!De(e))throw new RangeError(`resolveQuarter: d must be a valid Date (received: ${y(e)})`);Nt("resolveQuarter",t);const r=xt("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}},Cu={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},Ts=new Map,Iu=(e,t)=>{const r=`${e}\0${t}`,n=Ts.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,Cu[e]);return Ts.set(r,o),o},Au=4,ku=6,qo=e=>e>=0?String(e).padStart(Au,"0"):`-${String(-e).padStart(ku,"0")}`,Nu=(e,t)=>{const r=new Date(t.getTime()),n=qo(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}`},it=(e,t,r,n)=>(Le("formatLabel","unit",e),De(t)?r?r(t,e,"period"):n===void 0?Nu(e,t):Iu(e,n).format(t):""),Pr=(e,t,r,n)=>(Le("formatScreenReaderLabel","unit",e),it(e,t,r,n)),Ou=(e,t)=>{if(!De(e))return"";Nt("formatQuarterLabel",t);const{quarter:r}=xl(e,t);return`${it("year",xt("year",e,t))}-Q${r}`},Me=(e,t,r,n=0)=>{if(Le("findNearestDateIndex","unit",r),Nt("findNearestDateIndex",n),!e||e.length===0||e.length===1)return 0;if(!De(t))throw new RangeError(`findNearestDateIndex: target must be a valid Date (received: ${y(t)})`);const o=Ke("findNearestDateIndex","target",t,r,n,"");let a=0,i=e.length-1;if(o<=U(r,e[a],n))return 0;if(o>=U(r,e[i],n))return i;for(;a<=i;){const d=a+i>>1,m=U(r,e[d],n);if(m===o)return d;m<o?a=d+1:i=d-1}const l=Math.abs(U(r,e[a],n)-o),u=Math.abs(U(r,e[i],n)-o);return l<u?a:i},Vu=(e,t,r,n,o=0)=>(Le("getSortedAllowedDates","unit",t),fr("getSortedAllowedDates",Xo(e),t,r,n,o).dates),Xo=e=>({list:e,path:"allowedDates",inheritedBy:null}),fr=(e,t,r,n,o,a)=>{Nt(e,a);const{list:i,path:l}=t,u=t.inheritedBy===null?"":` (inherited by the ${t.inheritedBy} row)`;if(sn(e,`${l}${u}`,i),i===void 0||i.length===0)return{keys:[],dates:[]};for(const[T,b]of[["minDate",n],["maxDate",o]])if(!De(b))throw new RangeError(`${e}: ${T} must be a valid Date (received: ${y(b)})`);const d=Ke(e,"minDate",n,r,a,""),m=Ke(e,"maxDate",o,r,a,""),R=new Map;for(let T=0;T<i.length;T++){const b=i[T];if(!De(b))throw new RangeError(`${e}: ${l}[${T}]${u} must be a valid Date (received: ${y(b)})`);const g=Ke(e,`${l}[${T}]${u}`,b,r,a,"");g<d||g>m||R.has(g)||R.set(g,xt(r,b,a))}if(R.size===0)throw new RangeError(`${e}: every ${l} entry${u} falls outside [minDate, maxDate] (minDate: ${y(n)}, maxDate: ${y(o)}, entries: ${i.length})`);const L=Array.from(R.keys()).sort((T,b)=>T-b);return{keys:L,dates:L.map(T=>R.get(T))}},mi=(e,t,r,n,o,a)=>{const{keys:i,dates:l}=fr(e,t,r,n,o,a);return l.length===0?null:{...ln(i,null,null),dates:l}},On=(e,t)=>e===null?[]:e.dates.slice(t.loIndex,t.hiIndex+1),fo=(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 l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Math.max(0,Math.min(1,(e[i].getTime()-l)/u))}return i/a},ho=(e,t,r,n,o)=>{const a=e.length-1;if(a<=0)return 0;const i=Math.max(0,Math.min(1,n));if(r==="time"){const l=e[0].getTime(),u=e[a].getTime()-l;return u<=0?0:Me(e,new Date(l+i*u),t,o)}return Math.max(0,Math.min(a,Math.round(i*a)))},Ka=(e,t,r,n,o,a,i)=>{let l=r,u=n;return i?(l=t,u=t):e==="low"?t>n?(l=n,u=t):l=t:t<r?(u=r,l=t):u=t,[Math.max(o,Math.min(a,l)),Math.max(o,Math.min(a,u))]},Ml=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:n,rangeMax:o,isDiscrete:a,sortedAllowedDates:i,snapMode:l,unit:u,yearStartMonth:d=0})=>{if(Le("calculateConnectDragValues","unit",u),a){const g=i.length-1;if(g<=0)return[0,0];const w=Math.max(0,Math.min(g,Math.round(t))),h=Math.max(w,Math.min(g,Math.round(r)));if(l==="time"){const f=i[0].getTime(),ue=i[g].getTime(),K=i[w].getTime(),re=i[h].getTime()-K;let ee=K+e*(ue-f),B=ee+re;ee<f&&(ee=f,B=f+re),B>ue&&(B=ue,ee=ue-re);const ne=Me(i,new Date(ee),u,d),k=Me(i,new Date(B),u,d);return[ne,Math.max(ne,k)]}const D=Math.round(e*g);let M=w+D,v=h+D;return M<0&&(v+=-M,M=0),v>g&&(M-=v-g,v=g),[Math.max(0,Math.min(g,M)),Math.max(0,Math.min(g,v))]}const m=g=>Math.max(n,Math.min(o,g)),R=o-n;if(R<=0)return[m(t),m(r)];const L=Math.round(e*R);let T=t+L,b=r+L;return T<n&&(b+=n-T,T=n),b>o&&(T-=b-o,b=o),[m(T),m(b)]},Dl=(e,t,r,n,o,a,i,l)=>{let u=0,d=!1,m=!1;switch(e){case"ArrowRight":case"ArrowUp":u=l;break;case"ArrowLeft":case"ArrowDown":u=-l;break;case"PageUp":u=l*5;break;case"PageDown":u=-l*5;break;case"Home":d=!0;break;case"End":m=!0;break;default:return null}if(i){let T=r;return d?T=o:m?T=a:T=Math.max(o,Math.min(a,r+u)),[T,T]}let R=r,L=n;return t==="low"?d?R=o:m?R=n:R=Math.max(o,Math.min(n,r+u)):d?L=r:m?L=a:L=Math.max(r,Math.min(a,n+u)),[R,L]},yl=8,El=2,Pl=16,_u=12,Yu=90,Zo=(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}},Co=e=>yl+(e?.anchorGapY??El),Qo=(e,t)=>{const r=t?.estimatedHeightPx??Pl,o=Co(t)+r/2,a=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:a,highOffsetY:a,isSlanted:!1,isFlipped:!1,proximity:0}},Hu=e=>{for(const t of["topPx","bottomPx"]){const r=e[t];if(typeof r!="number"||Number.isNaN(r)||r<0)throw new RangeError(`calculateLabelSlant: config.room.${t} must be a number of pixels, zero or more (Infinity for unbounded) (received: ${y(r)})`)}},ju=(e,t,r)=>{if(r<=t/2)return 0;const n=Math.min(1,2*r/Math.hypot(e,t));return(Math.asin(n)-Math.atan2(t,e))*180/Math.PI},Fu=(e,t,r,n,o,a,i,l)=>{if(i===void 0)return{side:t,angleDeg:e};const u=t==="top"?"bottom":"top",d=b=>b==="top"?i.topPx:i.bottomPx,m=b=>b===t?o:a,R=b=>m(b)+(1+l)*Zo(r,n,e).acrossPx;if(R(t)<=d(t))return{side:t,angleDeg:e};if(R(u)<=d(u))return{side:u,angleDeg:e};const L=d(u)-m(u)>d(t)-m(t)?u:t,T=(d(L)-m(L))/(1+l);return{side:L,angleDeg:Math.min(e,ju(r,n,T))}},Ll=(e,t,r,n="top",o)=>{const a=o?.estimatedWidthPx,i=o?.estimatedHeightPx??Pl,l=o?.paddingPx??_u,u=o?.maxAngleDeg??Yu,d=o?.room,m=o?.drawnScale??1;if(d!==void 0&&Hu(d),typeof m!="number"||!Number.isFinite(m)||m<=0)throw new RangeError(`calculateLabelSlant: config.drawnScale must be a positive finite number (received: ${y(m)})`);const R=Co(o),L=o?.flipClearancePx??R;if(typeof L!="number"||!Number.isFinite(L)||L<0)throw new RangeError(`calculateLabelSlant: config.flipClearancePx must be a finite number of pixels, zero or more (received: ${y(L)})`);const T=Qo(n,o);if(!(Number.isFinite(r)&&r>0)||a===void 0||!Number.isFinite(a)||a<=0)return T;const b=Math.max(0,t-e)/100*r,g=a+l;if(b>=g)return T;const w=Math.max(0,Math.min(1,(g-b)/g)),h=w*w*w*(w*(w*6-15)+10),D=Fu(h*u,n,a,i,R,L,d,m),M=D.angleDeg===0?0:D.side==="top"?-D.angleDeg:D.angleDeg,v=Zo(a,i,D.angleDeg),f=(D.side===n?R:L)+v.acrossPx,ue=D.side==="top"?-f:+f,K=2*v.alongPx,re=Math.max(0,(K+l-b)/2);return{lowAngleDeg:M,highAngleDeg:M,lowOffsetX:-re,highOffsetX:re,lowOffsetY:ue,highOffsetY:ue,isSlanted:w>.001,isFlipped:D.side!==n,proximity:w}},Uu=e=>({...e,lowOffsetX:0,highOffsetX:0}),fi=(e,t,r,n)=>{if(r.isMerged&&r.keepMergedLabelUpright)return Qo(r.labelPosition,n);const o=Ll(e,t,r.trackLengthPx,r.labelPosition,n);return r.isMerged?Uu(o):o},jt=(e,t)=>(e==="macro"?t.macroIsDiscrete:t.microIsDiscrete)===!0,Lt=(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}},yo=(e,t,r,n)=>e==="pan"?$u(t,r,Math.max(r,n)):Ro(t,r,Math.max(r,n)),hi=(e,t)=>{const r=t==="macro-top"||t==="macro-left",n=e<0;return r&&n||!(r||n)?"macro":"micro"},$l=(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 Tl(e,t,r,n,o,a,i="macro-top",l=.05,u=!0,d="range"){if(hi(t,i)==="macro"){const L=Math.abs(e-r),T=Math.abs(e-n);return L<=l&&L<=T?"macro-low":T<=l&&T<L?"macro-high":u&&e>=r&&e<=n?"macro-connect":L<T?"macro-low":"macro-high"}if(d==="point")return"micro-point";const m=Math.abs(e-o),R=Math.abs(e-a);return m<=l&&m<=R?"micro-low":R<=l&&R<m?"micro-high":u&&e>=o&&e<=a?"micro-connect":m<R?"micro-low":"micro-high"}function Cl(e,t,r,n,o){if(e==="macro-connect"){const[d,m]=ci(t-r,n,o);return[d,m,"macro-connect"]}const a=e==="macro-low"?"low":"high",[i,l]=To(a,t,n,o),u=Uo(a,t,n,o);return[i,l,u==="low"?"macro-low":"macro-high"]}function Il(e,t,r,n,o){if(e==="micro-point"){const[d]=To("point",t,n,o);return[d,d,"micro-point"]}if(e==="micro-connect"){const[d,m]=ci(t-r,n,o);return[d,m,"micro-connect"]}const a=e==="micro-low"?"low":"high",[i,l]=To(a,t,n,o),u=Uo(a,t,n,o);return[i,l,u==="low"?"micro-low":"micro-high"]}const En=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 C.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:C.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});En.displayName="VernierKnobSvg";const zu=(e,t,r,n)=>{if(!De(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${y(e)})`);if(!De(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)Ke("PeriodSlider","minDate",e,o,n,wl)},Io=(e,t,r,n="PeriodSlider")=>{if(!kt(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(!De(o))throw new RangeError(`${n}: ${e}[0] must be a valid Date (received: ${y(o)})`);if(!De(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)})`)},Al=(e,t)=>{if(!De(t))throw new RangeError(`PeriodSlider: ${e} must be a valid Date (received: ${y(t)})`)},Qr=(e,t,r,n,o,a)=>{const i=Ke("PeriodSlider",e,t,r,a,"");if(i<U(r,n,a)||i>U(r,o,a))throw new RangeError(`PeriodSlider: ${e} must lie within [minDate, maxDate] (received: ${y(t)}, minDate: ${y(n)}, maxDate: ${y(o)})`)},Bu=(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&&(Io(o,a,!1),Qr(`${o}[0]`,a[0],e.unit,t,r,n),Qr(`${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&&(Al(o,a),Qr(o,a,e.unit,t,r,n))}},Wu=(e,t,r)=>{const n=e.yearStartMonth??0;Io("macroRange",e.macroRange,!0),Ke("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 d of["microValue","defaultMicroValue"]){const m=e[d];m!==void 0&&(Al(d,m),Qr(d,m,o,t,r,n))}const u=e.microValue!==void 0?e.microValue:e.defaultMicroValue;if(u===void 0)throw new RangeError("PeriodSlider: vernier point mode requires a micro selection; supply microValue (controlled) or defaultMicroValue (uncontrolled)");return{shape:"point",selection:[u,u]}}for(const u of["microRange","defaultMicroRange"]){const d=e[u];d!==void 0&&(Io(u,d,!1),Qr(`${u}[0]`,d[0],o,t,r,n),Qr(`${u}[1]`,d[1],o,t,r,n))}const l=e.microRange!==void 0?e.microRange:e.defaultMicroRange;if(l!==void 0)return{shape:"range",selection:l};throw a?new RangeError("PeriodSlider: vernier range mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)"):new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange / defaultMicroRange for a period, or microValue / defaultMicroValue for a point")},Sn=(e,t,r,n,o,a,i,l,u)=>{const d=Me(e,n,t,u),m=Me(e,o,t,u);return i?d:l?m:Math.max(d,Math.min(m,Me(e,r,t,u)+a))},Va=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null};function Gu(e,t){return t&&e[0].getTime()!==e[1].getTime()?[e[0],e[0]]:e}function Ku(e,t){return t?e==="micro-low"||e==="micro-high"||e==="micro-connect"?"micro-point":e:e==="micro-point"?"micro-high":e}const Cs=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback((a,i)=>{const l=r.current;if(l!==null&&l[0].getTime()===a.getTime()&&l[1].getTime()===i.getTime())return;const u=[a,i];r.current=u,t(u)},[]),o=s.useCallback(()=>{r.current!==null&&(r.current=null,t(null))},[]);return{shown:e,show:n,release:o}},Jo=(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)})`)}},qu=e=>{if(typeof e!="object"||e===null)return!1;try{return e.nodeType===1&&typeof e.getBoundingClientRect=="function"}catch{return!1}},Is=(e,t)=>{if(t==null)return null;if(qu(t))return t;let r=!1;try{r=typeof t=="object"&&"current"in t}catch{r=!1}throw new RangeError(`PeriodSlider: ${e} must be an Element or null (received: ${y(t)})${r?"; pass the element itself (ref.current), not the ref object":""}`)},Xr=()=>{const[e,t]=s.useState(null),r=s.useRef(null),n=s.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const a=new ResizeObserver(i=>{for(const l of i){const u=l.borderBoxSize?.[0];u!==void 0&&t(d=>d!==null&&Math.abs(d.widthPx-u.inlineSize)<.5&&Math.abs(d.heightPx-u.blockSize)<.5?d:{widthPx:u.inlineSize,heightPx:u.blockSize})}});a.observe(o),r.current=a},[]);return s.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[n,e]},As=(e,t)=>{const r=e.querySelector(`[data-handle-type^="${t}-"]`);if(r===null)return null;const n=r.querySelector("[data-tooltip-style]"),o=r.getAttribute("data-vernier-pos");return n===null||o!=="top"&&o!=="bottom"?null:su(e,r,n,o)},Xu=(e,t,r)=>{const n=iu(e,t,r);return n===null?null:{room:n,macro:As(e,"macro"),micro:As(e,"micro")}},Zu=.5,Ao=(e,t)=>e===t||Math.abs(e-t)<Zu,ks=(e,t)=>e===null||t===null?e===t:Ao(e.anchorPx,t.anchorPx)&&Ao(e.knobCentrePx,t.knobCentrePx),Qu=(e,t)=>e===null||t===null?e===t:Ao(e.room.topPx,t.room.topPx)&&Ao(e.room.bottomPx,t.room.bottomPx)&&ks(e.macro,t.macro)&&ks(e.micro,t.micro),Ju=(e,t)=>Eo(Po(e,t)),Eo=e=>e===null?void 0:{estimatedWidthPx:e.widthPx,estimatedHeightPx:e.heightPx},Po=(e,t)=>e===null||t===null?null:{widthPx:Math.max(e.widthPx,t.widthPx),heightPx:Math.max(e.heightPx,t.heightPx)},ed=e=>{const t=new Map;let r=0;for(const a of e){const{side:i,box:l}=a;if(l===null)continue;let u;if(a.reach==="inline-size")u=l.widthPx,r=Math.max(r,l.heightPx/2);else{const m=Zo(l.widthPx,l.heightPx,a.angleDeg);u=a.centreFromAnchorPx+m.acrossPx,r=Math.max(r,m.alongPx+Math.abs(a.alongPushPx))}const d=t.get(i);t.set(i,d===void 0?u:Math.max(d,u))}if(t.size===0)return;const n={};for(const[a,i]of t)n[`--ps-label-reach-${a}`]=`${Math.ceil(i)}px`;const o=Math.ceil(r);return n["--ps-label-reach-main"]=`${o}px`,{style:n,mainPx:o}},qa=(e,t,r)=>({"leader-length":`${r?Math.hypot(e,t):0}px`,"leader-angle":`${Math.atan2(t,e)*180/Math.PI}deg`}),Ns=(e,t,r,n)=>({tx:`calc(-50% + ${e}px)`,ty:`${t}px`,rot:`${r}deg`,...n}),Os=(e,t,r,n)=>({tx:`calc(-50% + ${e}px)`,ty:`calc(-50% + ${t}px)`,rot:`${r}deg`,...qa(e,t,n)}),ko=(e,t)=>({"--ps-tooltip-tx":Ln(e,"tx",t.tx),"--ps-tooltip-ty":Ln(e,"ty",t.ty),"--ps-tooltip-rot":Ln(e,"rot",t.rot)}),No=(e,t)=>({"--ps-label-leader-length":Ln(e,"leader-length",t["leader-length"]),"--ps-label-leader-angle":Ln(e,"leader-angle",t["leader-angle"])}),_a=(e,t,r,n)=>{const o=td(n),a=o===null?n.config:o.config,i=Qo(n.labelPosition,a);if(!n.isSlantable)return{slant:i,lowStyle:void 0,highStyle:void 0,lowLeaderStyle:void 0,highLeaderStyle:void 0,centreFromAnchorPx:Math.abs(i.lowOffsetY)-Co(a),placements:null};const l=fi(t*100,r*100,n,a),u=Fo[e],d=o!==null&&l.isFlipped?o.oppositeAnchorPx:Co(a),m=n.anchor===null?0:(n.labelPosition==="top"?-1:1)*n.anchor.knobCentrePx,R={low:Ns(l.lowOffsetX,l.lowOffsetY-i.lowOffsetY,l.lowAngleDeg,qa(l.lowOffsetX,l.lowOffsetY-m,l.isFlipped)),high:Ns(l.highOffsetX,l.highOffsetY-i.highOffsetY,l.highAngleDeg,qa(l.highOffsetX,l.highOffsetY-m,l.isFlipped))};return{slant:l,lowStyle:ko(u.low,R.low),highStyle:ko(u.high,R.high),lowLeaderStyle:No(u.low,R.low),highLeaderStyle:No(u.high,R.high),centreFromAnchorPx:Math.abs(l.lowOffsetY)-d,placements:R}},td=e=>e.config===void 0||e.anchor===null||e.opposite===null||e.room===void 0?null:{config:{...e.config,anchorGapY:e.anchor.anchorPx-yl,flipClearancePx:e.opposite.anchorPx+e.opposite.reachPx+El,room:e.room},oppositeAnchorPx:e.opposite.anchorPx},Vs=(e,t,r,n)=>{if(r.anchor===null||n===null)return null;const o=r.isSlantable?fi(e*100,t*100,r,r.config).lowAngleDeg:0;return{anchorPx:r.anchor.anchorPx,reachPx:2*Zo(n.widthPx,n.heightPx,o).acrossPx}},_s={"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"},Ys=(e,t,r)=>{const n=Qo(r.labelPosition,r.config);if(r.isVertical)return{slant:n,lowStyle:_s,highStyle:_s,lowLeaderStyle:void 0,highLeaderStyle:void 0,placements:null};const o=r.autoSlantLabels&&!r.isPointMode;let a=n;if(o){const u=r.config===void 0||r.room===void 0?r.config:{...r.config,room:r.room};a=fi(e,t,r,u)}const i=Fo.flat,l={low:Os(a.lowOffsetX,a.lowOffsetY,a.lowAngleDeg,a.isFlipped),high:Os(a.highOffsetX,a.highOffsetY,a.highAngleDeg,a.isFlipped)};return{slant:a,lowStyle:{"--ps-tooltip-origin":"50% 50%",...ko(i.low,l.low)},highStyle:{"--ps-tooltip-origin":"50% 50%",...ko(i.high,l.high)},lowLeaderStyle:o?No(i.low,l.low):void 0,highLeaderStyle:o?No(i.high,l.high):void 0,placements:o?l:null}},rd={horizontal:{decrease:"left",increase:"right"},vertical:{decrease:"down",increase:"up"}},nd={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"}},Hs={horizontal:"px-[calc(var(--ps-target-size)/2)]",vertical:"py-[calc(var(--ps-target-size)/2)]"},od={horizontal:{withSteppers:`grid-cols-[auto_minmax(0,1fr)_auto] ${Cn} ${Es.horizontal}`,railOnly:`grid-cols-[minmax(0,1fr)] ${Hs.horizontal}`},vertical:{withSteppers:`grid-rows-[auto_minmax(0,1fr)_auto] ${Cn} ${Es.vertical}`,railOnly:`grid-rows-[minmax(0,1fr)] ${Hs.vertical}`}},js={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"}},Fs=(e,t)=>{e.setPointerCapture(t)},ad=e=>{const{unit:t,minDate:r,maxDate:n,allowedDates:o,snapMode:a="index",disabled:i=!1,className:l="",showStepper:u=!0,tooltipStyle:d="always",labelPosition:m="top",autoSlantLabels:R=!0,keepMergedLabelUpright:L=!1,showLabelLeaderLines:T=!1,isVertical:b=!1,hideConnectBar:g=!1,showTicks:w=!1,colorScheme:h="blue-rose",formatLocale:D}=e;Le("PeriodSlider","unit",t);const M=e.mode==="vernier"?Qt("PeriodSlider","macroUnit",e.macroUnit,t):t,v=e.mode==="vernier"?Qt("PeriodSlider","microUnit",e.microUnit,t):t,f=gr("PeriodSlider",e.yearStartMonth);zu(r,n,e.mode==="vernier"?[M,v,t]:[t],f),Bu(e,r,n),D!==void 0&&Jo("PeriodSlider","formatLocale",D);const ue=Is("labelCeiling",e.labelCeiling),K=Is("labelFloor",e.labelFloor),re=e.mode==="vernier"?Wu(e,r,n):null,ee=re!==null&&re.shape==="point",B=Wo(e.locale,e.labels),ne=gl[h],k=s.useId(),q=s.useRef(e),j=r.getTime(),A=n.getTime(),$=e.mode==="vernier",H=s.useMemo(()=>$?[]:fr("PeriodSlider",Xo(o),t,r,n,f).dates,[$,o,t,j,A,f]),Y=H.length>0,{rangeMin:N,rangeMax:F}=s.useMemo(()=>Y?{rangeMin:0,rangeMax:H.length-1}:{rangeMin:U(t,r,f),rangeMax:U(t,n,f)},[Y,H,t,j,A,f]),G=e.mode==="point",he=s.useCallback(c=>{if(Y){const p=Math.max(0,Math.min(H.length-1,Math.round(c)));return H[p]}return se(t,Math.round(c),f)},[Y,H,t,f]),te=s.useCallback(c=>{if(c===void 0)return N;const p=xt(t,c,f);return Y?Me(H,p,t,f):U(t,p,f)},[Y,H,t,N,f]),[le,Se]=s.useState(()=>re===null?null:re.selection),ae=le??(re===null?null:re.selection),ie=ae===null?null:Gu(ae,ee);s.useLayoutEffect(()=>{ie!==ae&&Se(c=>c===le?ie:c)});const pe=e.mode==="vernier"?e.microValue?.getTime():void 0,Fe=s.useMemo(()=>e.mode!=="vernier"||e.microValue===void 0?null:[e.microValue,e.microValue],[e.mode,pe]),ft=Cs(),ge=Cs(),O=e.mode!=="vernier"?null:ee?Fe??ie:e.microRange!==void 0?e.microRange:ie,X=O===null?null:ge.shown??O,de=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?X?.[0]:void 0,Ve=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?X?.[1]:void 0,we=e.mode==="point"?e.value??e.defaultValue:void 0,tt=e.mode==="point"?we?.getTime():de?.getTime(),qe=e.mode==="range"?Ve?.getTime():tt,[Ue,st]=s.useMemo(()=>{if(e.mode==="point"){const S=te(we);return[S,S]}const c=te(de),p=te(Ve);return[Math.min(c,p),Math.max(c,p)]},[e.mode,tt,qe,te,we,de,Ve]),oe=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:ee?e.microValue!==void 0:e.microRange!==void 0,[pt,Xe]=s.useState(()=>$?null:[Ue,st]),ht=pt??[Ue,st],[ke,Ge]=s.useState(null),[ye,bt]=s.useState(null),rt=s.useRef(null),[Ot,I]=s.useState("high"),[J,Ye]=s.useState(null),[lt,ze]=s.useState(null),xe=ke?ke[0]:oe?Ue:ht[0],$e=ke?ke[1]:oe?st:ht[1],Ir=s.useRef([xe,$e]),_=e.mode==="vernier"?e.vernierOrientation??(b?"macro-left":"macro-top"):"macro-top",P=_==="macro-top"||_==="macro-left",Re=e.mode==="vernier"?e.showVernierProjection??!0:!1,_e=e.mode==="vernier"?e.showVernierTicks??!0:!1,E=e.mode==="vernier"?e.showHairline??!0:!1,z=$?jt("macro",e):Y,ce=$?jt("micro",e):Y,Ne=$?Lt("macro",e).list:o,Te=$?Lt("micro",e).list:o,Oe=$?e.formatMacroLabel??e.formatLabel:e.formatLabel,He=$?e.formatMicroLabel??e.formatLabel:e.formatLabel,Tt=de?.getTime(),Jt=Ve?.getTime(),[nt,pr]=s.useState(null),er=s.useRef(null),[oa,Ar]=s.useState(()=>ee?"micro-point":"micro-high"),Ze=Ku(oa,ee);s.useLayoutEffect(()=>{Ze!==oa&&Ar(c=>c===oa?Ze:c)});const wt=s.useMemo(()=>U(M,r,f),[j,M,f]),Vt=s.useMemo(()=>U(M,n,f),[A,M,f]),Wn=s.useMemo(()=>$&&ce?mi("PeriodSlider",Lt("micro",e),v,r,n,f):null,[$,ce,Te,v,j,A,f]),Ce=s.useMemo(()=>$&&z?fr("PeriodSlider",Lt("macro",e),M,r,n,f).dates:[],[$,z,Ne,M,j,A,f]),Si=c=>[Math.max(wt,Math.min(Vt,U(M,c[0],f))),Math.max(wt,Math.min(Vt,U(M,c[1],f)))],[Ri,xi]=e.mode!=="vernier"?[wt,Vt]:Si(e.macroRange),[Qe,ct]=ft.shown===null?[Ri,xi]:Si(ft.shown),br=s.useMemo(()=>se(M,Qe,f),[M,Qe,f]),wr=s.useMemo(()=>se(M,ct,f),[M,ct,f]),Gn=s.useMemo(()=>e.mode!=="vernier"?[r,n]:$t(M,v,[br,wr],r,n,f),[e.mode,br,wr,M,v,j,A,f]),je=s.useMemo(()=>U(v,Gn[0],f),[v,Gn,f]),ot=s.useMemo(()=>U(v,Gn[1],f),[v,Gn,f]),aa=(c,p)=>Wn===null?[]:On(Wn,ln(Wn.ascending,c,p)),be=s.useMemo(()=>aa(je,ot),[Wn,je,ot]),tr=z&&Ce.length>0,Ct=ce&&be.length>0,Mi=tr?U(M,Ce[0],f):wt,Di=tr?U(M,Ce[Ce.length-1],f):Vt,yi=Ct?U(v,be[0],f):je,ia=Ct?U(v,be[be.length-1],f):ot,Xl=Math.min(Mi,Qe),Zl=Math.max(Di,ct),rr=(c,p,S,x)=>p.length>0?U(v,p[Me(p,c,v,f)],f):Math.max(S,Math.min(x,U(v,c,f))),kr=Ct?be:[],Be=s.useMemo(()=>X===null?je:rr(X[0],kr,je,ot),[Tt,je,ot,v,X,kr]),at=s.useMemo(()=>X===null?ot:rr(X[1],kr,je,ot),[Jt,je,ot,v,X,kr]),Nr=s.useMemo(()=>se(v,Be,f),[v,Be,f]),Or=s.useMemo(()=>se(v,at,f),[v,at,f]),Ei=!$||O===null?null:{macroUnit:M,macroLowEnc:Ri,macroHighEnc:xi,microUnit:v,microLowEnc:U(v,O[0],f),microHighEnc:U(v,O[1],f)},sa=s.useRef(Ei),la=Math.max(1,Vt-wt),Mt=tr?fo(Ce,M,a,br,f):Math.max(0,Math.min(1,(Qe-wt)/la)),It=Math.max(Mt,tr?fo(Ce,M,a,wr,f):Math.min(1,(ct-wt)/la)),Pi=c=>Math.max(Mi,Math.min(Di,Math.round(wt+c*la))),Kn=Math.max(1,ot-je),vr=Ct?fo(be,v,a,Nr,f):Math.max(0,Math.min(1,(Be-je)/Kn)),Vr=Math.max(vr,Ct?fo(be,v,a,Or,f):Math.min(1,(at-je)/Kn)),ca=s.useRef({timerId:null,emit:null}),qn=s.useRef({timerId:null,emit:null}),Xn=s.useRef({timerId:null,emit:null});s.useEffect(()=>{const c=[ca,qn,Xn];return()=>{for(const p of c)Va(p.current)}},[]);const _r=s.useCallback((c,p,S)=>{Va(c);const{debounceMs:x}=q.current;if(S||!x||x<=0){p();return}c.emit=p,c.timerId=setTimeout(()=>{c.timerId=null,c.emit=null,p()},x)},[]),Li=s.useCallback(c=>{const p=c.emit;Va(c),p?.()},[]),Yr=s.useCallback(c=>new Date(Math.min(Math.max(c.getTime(),j),A)),[j,A]),nr=s.useCallback((c,p,S=!1)=>{const[x,V]=Ir.current;if((q.current.mode==="point"?c===x:c===x&&p===V)&&ca.current.timerId===null)return;const Z=he(c),Q=he(p),fe=()=>{const ve=q.current;ve.mode==="point"?ve.onChangePoint?.(Z):ve.mode==="range"&&ve.onChangeRange?.(Z,Q)};_r(ca.current,fe,S)},[he,_r]),Sr=s.useCallback((c,p,S=!1)=>{const x=sa.current;if(q.current.mode!=="vernier"||x===null)return;const V=Yr(c),W=Yr(p);U(x.macroUnit,V,f)===x.macroLowEnc&&U(x.macroUnit,W,f)===x.macroHighEnc&&qn.current.timerId===null||_r(qn.current,()=>{const Z=q.current;Z.mode==="vernier"&&Z.onChangeMacroRange?.(V,W)},S)},[Yr,_r,f]),Dt=s.useCallback((c,p,S=!1)=>{const x=q.current,V=sa.current;if(x.mode!=="vernier"||V===null)return;const W=Yr(c),Z=Yr(p);U(V.microUnit,W,f)===V.microLowEnc&&U(V.microUnit,Z,f)===V.microHighEnc&&Xn.current.timerId===null||((ee?x.microValue===void 0:x.microRange===void 0)&&Se([W,Z]),_r(Xn.current,()=>{const Q=q.current;if(Q.mode==="vernier"){if(ee){Q.onChangeMicroPoint?.(W);return}Q.onChangeMicroRange?.(W,Z)}},S))},[Yr,_r,ee,f]),$i=s.useCallback((c,p=!1)=>{Dt(c,c,p)},[Dt]),Rr=s.useCallback(c=>{if(Y&&a==="time"&&H.length>1){const x=Math.max(0,Math.min(H.length-1,Math.round(c))),V=H[0].getTime(),Z=H[H.length-1].getTime()-V;if(Z<=0)return 0;const Q=H[x].getTime();return Math.max(0,Math.min(100,(Q-V)/Z*100))}const p=F-N;if(p<=0)return 0;const S=(c-N)/p*100;return Math.max(0,Math.min(100,S))},[Y,a,H,N,F]),ua=s.useCallback(c=>{const p=Math.max(0,Math.min(100,c));if(Y){if(a==="time"&&H.length>1){const V=H[0].getTime(),Z=H[H.length-1].getTime()-V,Q=V+p/100*Z;return Me(H,new Date(Q),t,f)}const x=Math.round(p/100*(H.length-1));return Math.max(0,Math.min(H.length-1,x))}const S=N+p/100*(F-N);return Math.round(S)},[Y,a,H,N,F,t,f]),cn=s.useRef(null),Ti=s.useRef(null),Ci=s.useRef(0),ut=s.useRef(null),da=s.useRef(null),Ii=s.useRef(null),Ai=s.useRef(null),[ma,ki]=s.useState(0),[Ql,Zn]=Xr(),[Jl,Ni]=Xr(),[ec,tc]=Xr(),[rc,nc]=Xr(),[oc,Oi]=Xr(),[ac,ic]=Xr(),[sc,lc]=s.useState(null),fa=!b&&d!=="hover",Hr=fa?sc:null,cc=G?Eo(Zn):Ju(Zn,Ni),ha=!G&&xe===$e,ga=Qe===ct,pa=!ee&&Be===at,uc=P?"top":"bottom",dc=P?"bottom":"top",Vi=R&&!b,mc=Vi&&!ee,ba=Hr===null?void 0:Hr.room,wa={isPointMode:G,isVertical:b,autoSlantLabels:R,isMerged:ha,keepMergedLabelUpright:L,trackLengthPx:ma,labelPosition:m,config:cc,room:ba},va=Po(tc,nc),Sa=ee?Oi:Po(Oi,ic),_i={trackLengthPx:ma,labelPosition:uc,config:Eo(va),isMerged:ga,keepMergedLabelUpright:L,isSlantable:Vi,room:ba,anchor:Hr===null?null:Hr.macro},Yi={trackLengthPx:ma,labelPosition:dc,config:Eo(Sa),isMerged:pa,keepMergedLabelUpright:L,isSlantable:mc,room:ba,anchor:Hr===null?null:Hr.micro},Ra={..._i,opposite:Vs(vr,Vr,Yi,Sa)},xa={...Yi,opposite:Vs(Mt,It,_i,va)};s.useEffect(()=>{const c=ut.current;if(!c)return;const p=()=>{const x=c.getBoundingClientRect(),V=b?x.height:x.width;V>0&&ki(W=>Math.abs(W-V)<.5?W:V)};if(p(),typeof ResizeObserver<"u"){const x=new ResizeObserver(V=>{for(const W of V){const Z=b?W.contentRect.height:W.contentRect.width;Z>0&&ki(Q=>Math.abs(Q-Z)<.5?Q:Z)}});return x.observe(c),()=>x.disconnect()}const S=c.ownerDocument.defaultView;if(S)return S.addEventListener("resize",p),()=>S.removeEventListener("resize",p)},[b]);const jr=s.useCallback((c,p,S)=>{const x=b?S.height:S.width;if(!(Number.isFinite(x)&&x>0))return null;const V=b?S.bottom-p:c-S.left;return Number.isFinite(V)?Math.max(0,Math.min(1,V/x)):null},[b]),Hi=s.useCallback((c,p)=>{const S=ut.current;if(!S)return null;const x=jr(c,p,S.getBoundingClientRect());return x===null?null:x*100},[jr]),un=s.useRef(null),Bt=s.useRef(null),Qn=s.useRef({macroLowRatio:Mt,macroHighRatio:It,isVertical:b,isMacroFirstRail:P}),ji=s.useRef({flat:wa,macro:Ra,micro:xa}),Fi=s.useRef({ceiling:ue,floor:K,isMeasured:fa});s.useLayoutEffect(()=>{Qn.current={macroLowRatio:Mt,macroHighRatio:It,isVertical:b,isMacroFirstRail:P},ji.current={flat:wa,macro:Ra,micro:xa},Fi.current={ceiling:ue,floor:K,isMeasured:fa},q.current=e,Ir.current=[xe,$e],sa.current=Ei,rt.current=ye,er.current=nt});const Ui=(c,p)=>{const S=Qn.current;da.current?.setAttribute("d",Aa(c,p,S.isVertical,S.isMacroFirstRail))},fc=(c,p,S)=>{const x=ji.current;return c==="flat"?Ys(p*100,S*100,x.flat).placements:_a(c,p,S,c==="macro"?x.macro:x.micro).placements},dn=s.useCallback(()=>{const c=ut.current,p=Fi.current;if(c===null||!p.isMeasured)return;const S=Xu(c,p.ceiling,p.floor);lc(x=>Qu(x,S)?x:S)},[]),mn=(c,p,S)=>{const x=ut.current;if(!x)return;un.current={rail:c,lowRatio:p,highRatio:S},qc(x,c,p,S);const V=fc(c,p,S);V!==null&&Kc(x,c,V),c==="macro"&&Ui(p,S)},xr=s.useCallback(()=>{Bt.current!==null&&(clearTimeout(Bt.current),Bt.current=null);const c=ut.current;c&&(c.removeAttribute(Ca),c.style.removeProperty(Ia))},[]),zi=()=>{const c=ut.current;if(un.current===null||!c){un.current=null;return}un.current=null,Bt.current!==null&&clearTimeout(Bt.current),c.style.setProperty(Ia,`${Ss}ms`),c.setAttribute(Ca,"true"),Xc(c),Ui(Qn.current.macroLowRatio,Qn.current.macroHighRatio),Bt.current=setTimeout(()=>{Bt.current=null,c.removeAttribute(Ca),c.style.removeProperty(Ia)},Ss)};s.useLayoutEffect(()=>{const c=un.current;c!==null&&mn(c.rail,c.lowRatio,c.highRatio)}),s.useEffect(()=>()=>{Bt.current!==null&&clearTimeout(Bt.current)},[]);const Fr=s.useRef(null),Ur=s.useRef(null),_t=s.useRef(null),Ma=s.useRef(null),fn=s.useRef(null),or=s.useCallback(()=>Fr.current!==null||Ur.current!==null,[]),Bi=c=>{if(i)return;if($){const me=Ur.current;if(!me||c.pointerId!==me.pointerId||!ut.current)return;const At=jr(c.clientX,c.clientY,ut.current.getBoundingClientRect());if(At===null)return;if(me.handle==="macro-low"||me.handle==="macro-high"||me.handle==="macro-connect"){const[Je,We,Wt]=Cl(me.handle,At,me.startPointerRatio,me.startMacroLowRatio,me.startMacroHighRatio);mn("macro",Je,We),Wt!==er.current&&(er.current=Wt,pr(Wt),Ar(Wt));let Ht,Rt,Gt;if(tr){const Kt=ho(Ce,M,a,Je,f),wn=Math.max(Kt,ho(Ce,M,a,We,f));Rt=Ce[Kt],Gt=Ce[wn],Ht=U(M,Rt,f)}else Ht=Pi(Je),Rt=se(M,Ht,f),Gt=se(M,Pi(We),f);ft.show(Rt,Gt);const ir=`${Rt.getTime()}_${Gt.getTime()}`;ir!==Ma.current&&(Ma.current=ir,Sr(Rt,Gt));const[bn,Hc]=$t(M,v,[Rt,Gt],r,n,f),so=U(v,bn,f),lo=U(v,Hc,f),ps=ce?aa(so,lo):[],bs={kind:"range",min:so,max:lo};let Dr,yr;if(me.handle==="macro-connect"){const Kt=Ht-me.startMacroLowEnc,wn=yo("pan",bs,Ls(v,me.initialMicroLowEnc,M,Kt,f),Ls(v,me.initialMicroHighEnc,M,Kt,f));if(wn===null)return;Dr=se(v,wn[0],f),yr=se(v,wn[1],f)}else{const Kt=yo("resize",bs,me.initialMicroLowEnc,me.initialMicroHighEnc);if(Kt===null)return;Dr=se(v,Kt[0],f),yr=se(v,Kt[1],f)}const ws=rr(Dr,ps,so,lo),jc=Math.max(ws,rr(yr,ps,so,lo));Dr=se(v,ws,f),yr=se(v,jc,f),ge.show(Dr,yr);const vs=`${Dr.getTime()}_${yr.getTime()}`;vs!==fn.current&&(fn.current=vs,Dt(Dr,yr))}else if(me.handle==="micro-low"||me.handle==="micro-high"||me.handle==="micro-connect"||me.handle==="micro-point"){const[Je,We,Wt]=Il(me.handle,At,me.startPointerRatio,me.startMicroLowRatio,me.startMicroHighRatio);mn("micro",Je,We),Wt!==er.current&&(er.current=Wt,pr(Wt),Ar(Wt));let Ht,Rt;if(Ct){const ir=ho(be,v,a,Je,f),bn=Math.max(ir,ho(be,v,a,We,f));Ht=be[ir],Rt=be[bn]}else{const ir=rr(se(v,Math.round(je+Je*Kn),f),kr,je,ot),bn=Math.max(ir,rr(se(v,Math.round(je+We*Kn),f),kr,je,ot));Ht=se(v,ir,f),Rt=se(v,bn,f)}ge.show(Ht,Rt);const Gt=`${Ht.getTime()}_${Rt.getTime()}`;Gt!==fn.current&&(fn.current=Gt,Dt(Ht,Rt))}return}const p=Fr.current;if(!p||c.pointerId!==p.pointerId||!ut.current)return;const S=ut.current.getBoundingClientRect(),x=b?c.clientY:c.clientX,V=b?S.height:S.width;if(!(Number.isFinite(V)&&V>0))return;if(p.handle==="connect"){const me=b?(p.startPointerPos-x)/V:(x-p.startPointerPos)/V,[At,Je]=ci(me,p.startLowRatio,p.startHighRatio);mn("flat",At,Je);const We=Ml({posDiffPct:me,startLowVal:p.startLowVal,startHighVal:p.startHighVal,rangeMin:N,rangeMax:F,isDiscrete:Y,sortedAllowedDates:H,snapMode:a,unit:t,yearStartMonth:f});if(_t.current&&_t.current[0]===We[0]&&_t.current[1]===We[1])return;_t.current=We,Ge(We),nr(We[0],We[1],!1);return}const W=jr(c.clientX,c.clientY,S);if(W===null)return;const[Z,Q]=To(G?"point":p.handle,W,p.startLowRatio,p.startHighRatio);mn("flat",Z,Q);const fe=ua(W*100),[ve,Ie]=Ka(p.handle,fe,p.startLowVal,p.startHighVal,N,F,G);if((!_t.current||_t.current[0]!==ve||_t.current[1]!==Ie)&&(_t.current=[ve,Ie],Ge([ve,Ie]),nr(ve,Ie,!1)),!G&&(p.handle==="low"||p.handle==="high")){const me=Uo(p.handle,W,p.startLowRatio,p.startHighRatio);rt.current!==me&&(rt.current=me,bt(me),I(me))}},Wi=()=>{zi(),Ma.current=null,fn.current=null,Ur.current=null,er.current=null,pr(null),ft.release(),ge.release(),Li(qn.current),Li(Xn.current)},Gi=()=>{zi();const c=_t.current??ke;c&&(nr(c[0],c[1],!0),Xe(c)),_t.current=null,Ge(null),Fr.current=null,rt.current=null,bt(null)},Ki=c=>{if($){const S=Ur.current;if(!S||c.pointerId!==S.pointerId)return;Wi();return}const p=Fr.current;!p||c.pointerId!==p.pointerId||Gi()},qi=()=>{Ur.current!==null&&Wi(),Fr.current!==null&&Gi()},Da=s.useRef(Bi),Xi=s.useRef(Ki),Zi=s.useRef(qi);s.useLayoutEffect(()=>{Da.current=Bi,Xi.current=Ki,Zi.current=qi});const Qi=s.useRef($);s.useEffect(()=>{Qi.current!==$&&(Qi.current=$,Zi.current())},[$]);const ya=ye!==null||nt!==null;s.useEffect(()=>{if(!ya)return;const c=cn.current?.ownerDocument.defaultView;if(!c)return;const p=x=>Da.current(x),S=x=>Xi.current(x);return c.addEventListener("pointermove",p),c.addEventListener("pointerup",S),c.addEventListener("pointercancel",S),c.addEventListener("lostpointercapture",S),()=>{c.removeEventListener("pointermove",p),c.removeEventListener("pointerup",S),c.removeEventListener("pointercancel",S),c.removeEventListener("lostpointercapture",S)}},[ya]);const Ea=s.useCallback((c,p,S,x)=>{xr(),Fs(c,p),Ye(null),ze(null),dn(),Fr.current={pointerId:p,handle:S,startPointerPos:x,startLowVal:xe,startHighVal:$e,startLowRatio:Rr(xe)/100,startHighRatio:Rr($e)/100},rt.current=S,bt(S),S!=="connect"&&I(S)},[xe,$e,Rr]),Ji=s.useCallback((c,p,S,x)=>{q.current.mode==="vernier"&&(xr(),Fs(c,p),dn(),Ur.current={pointerId:p,handle:S,startPointerRatio:x,startMacroLowRatio:Mt,startMacroHighRatio:It,startMicroLowRatio:vr,startMicroHighRatio:Vr,startMacroLowEnc:Qe,initialMicroLowEnc:Be,initialMicroHighEnc:at},er.current=S,pr(S),Ar(S))},[Mt,It,vr,Vr,Qe,Be,at]),es=c=>p=>{if(i||or())return;p.stopPropagation(),p.preventDefault(),I(c);const S=b?p.clientY:p.clientX;Ea(p.currentTarget,p.pointerId,c,S)},ts=c=>()=>{i||rt.current!==null||I(c)},Jn=c=>()=>{i||er.current!==null||Ar(c)},zr=c=>p=>{if(i||or())return;p.stopPropagation(),p.preventDefault();const S=ut.current;if(!S)return;const x=jr(p.clientX,p.clientY,S.getBoundingClientRect());x!==null&&Ji(p.currentTarget,p.pointerId,c,x)},hc=c=>{if(i||g||or())return;c.stopPropagation(),c.preventDefault();const p=b?c.clientY:c.clientX;Ea(c.currentTarget,c.pointerId,"connect",p)},gc=c=>{if(i||or())return;if($){const Q=ut.current;if(!Q)return;const fe=Q.getBoundingClientRect(),ve=jr(c.clientX,c.clientY,fe);if(ve===null)return;const Ie=b?c.clientX-(fe.left+fe.width/2):c.clientY-(fe.top+fe.height/2),me=Tl(ve,Ie,Mt,It,vr,Vr,_,void 0,!g,ee?"point":"range");Ji(c.currentTarget,c.pointerId,me,ve),Da.current(c.nativeEvent);return}const p=Hi(c.clientX,c.clientY);if(p===null)return;const S=ua(p);let x="low";if(!G){const Q=Math.abs(S-xe),fe=Math.abs(S-$e);Q<fe?x="low":fe<Q?x="high":x=S>$e?"high":"low"}I(x);const[V,W]=Ka(x,S,xe,$e,N,F,G);Ge([V,W]),nr(V,W,!0);const Z=b?c.clientY:c.clientX;Ea(c.currentTarget,c.pointerId,x,Z)},pc=c=>{if(i||$||ye!==null)return;const p=Hi(c.clientX,c.clientY);if(p===null)return;const S=ua(p);Ye(S),ze(Rr(S))},bc=()=>{Ye(null),ze(null)},rs=c=>p=>{if(i||or())return;I(c);const S=Dl(p.key,c,xe,$e,N,F,G,1);S&&(p.preventDefault(),xr(),oe||Xe(S),nr(S[0],S[1],!0))},Br=(c,p,S)=>{if(O===null)return;const[x,V]=$t(M,v,[c,p],r,n,f),W=U(v,x,f),Z=U(v,V,f),Q=ce?aa(W,Z):[],fe=yo(S,{kind:"range",min:W,max:Z},U(v,O[0],f),U(v,O[1],f));if(fe===null)return;const ve=rr(se(v,fe[0],f),Q,W,Z),Ie=Math.max(ve,rr(se(v,fe[1],f),Q,W,Z));Dt(se(v,ve,f),se(v,Ie,f),!0)},eo=c=>p=>{if(i||!$||e.mode!=="vernier"||or())return;Ar(c);let S=0,x=!1,V=!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":x=!0;break;case"End":V=!0;break;default:return}if(p.preventDefault(),xr(),c==="macro-low"){const W=se(M,Qe,f),Z=se(M,ct,f);if(tr){const ve=Sn(Ce,M,W,Ce[0],Z,S,x,V,f);if(ve===Me(Ce,W,M,f))return;const Ie=Ce[ve];Sr(Ie,Z,!0),Br(Ie,Z,"resize");return}let Q;if(x?Q=wt:V?Q=ct:Q=Math.max(wt,Math.min(ct,Qe+S)),Q===Qe)return;const fe=se(M,Q,f);Sr(fe,Z,!0),Br(fe,Z,"resize")}else if(c==="macro-high"){const W=se(M,Qe,f),Z=se(M,ct,f);if(tr){const ve=Sn(Ce,M,Z,W,Ce[Ce.length-1],S,x,V,f);if(ve===Me(Ce,Z,M,f))return;const Ie=Ce[ve];Sr(W,Ie,!0),Br(W,Ie,"resize");return}let Q;if(x?Q=Qe:V?Q=Vt:Q=Math.max(Qe,Math.min(Vt,ct+S)),Q===ct)return;const fe=se(M,Q,f);Sr(W,fe,!0),Br(W,fe,"resize")}else if(c==="micro-low"){const W=se(v,Be,f),Z=se(v,at,f);if(Ct){const fe=Sn(be,v,W,be[0],Z,S,x,V,f);if(fe===Me(be,W,v,f))return;Dt(be[fe],Z,!0);return}let Q;if(x?Q=je:V?Q=at:Q=Math.max(je,Math.min(at,Be+S)),Q===Be)return;Dt(se(v,Q,f),Z,!0)}else if(c==="micro-high"){const W=se(v,Be,f),Z=se(v,at,f);if(Ct){const fe=Sn(be,v,Z,W,be[be.length-1],S,x,V,f);if(fe===Me(be,Z,v,f))return;Dt(W,be[fe],!0);return}let Q;if(x?Q=Be:V?Q=ot:Q=Math.max(Be,Math.min(ot,at+S)),Q===at)return;Dt(W,se(v,Q,f),!0)}else if(c==="micro-point"){const W=se(v,Be,f);if(Ct){const Q=Sn(be,v,W,be[0],be[be.length-1],S,x,V,f);if(Q===Me(be,W,v,f))return;$i(be[Q],!0);return}let Z;if(x?Z=je:V?Z=ot:Z=Math.max(je,Math.min(ot,Be+S)),Z===Be)return;$i(se(v,Z,f),!0)}},wc=c=>{if(e.mode!=="vernier")return;if(xr(),tr){const Z=Ce.length-1,Q=Me(Ce,br,M,f),fe=Me(Ce,wr,M,f),ve=fe-Q;let Ie=Q+c,me=fe+c;if(c<0&&Ie<0?(Ie=0,me=Math.min(Z,ve)):c>0&&me>Z&&(me=Z,Ie=Math.max(0,Z-ve)),Ie===Q&&me===fe)return;const At=Ce[Ie],Je=Ce[me];Sr(At,Je,!0),Br(At,Je,"pan");return}const p=ct-Qe;let S=Qe+c,x=ct+c;if(c<0&&S<wt?(S=wt,x=Math.min(Vt,S+p)):c>0&&x>Vt&&(x=Vt,S=Math.max(wt,x-p)),S===Qe&&x===ct)return;const V=se(M,S,f),W=se(M,x,f);Sr(V,W,!0),Br(V,W,"pan")},Pa=s.useCallback(c=>{const p=q.current;if(!(p.disabled||or()))if(xr(),p.mode==="point"){const S=Math.max(N,Math.min(F,xe+c));oe||Xe([S,S]),nr(S,S,!0)}else if(p.mode==="vernier"){if(Ct){const ve=be.length-1,Ie=Me(be,Nr,v,f),me=Me(be,Or,v,f),At=me-Ie;let Je=Ie+c,We=me+c;c<0&&Je<0?(Je=0,We=Math.min(ve,At)):c>0&&We>ve&&(We=ve,Je=Math.max(0,ve-At)),(Je!==Ie||We!==me)&&Dt(be[Je],be[We],!0);return}const S=Be,x=at,V=je,W=ot,Z=x-S;let Q=S+c,fe=x+c;c<0&&Q<V?(Q=V,fe=Math.min(W,Q+Z)):c>0&&fe>W&&(fe=W,Q=Math.max(V,fe-Z)),(Q!==S||fe!==x)&&Dt(se(v,Q,f),se(v,fe,f),!0)}else{const S=$e-xe;let x=xe+c,V=$e+c;c<0&&x<N?(x=N,V=Math.min(F,x+S)):c>0&&V>F&&(V=F,x=Math.max(N,V-S)),x<=V&&(oe||Xe([x,V]),nr(x,V,!0))}},[xe,$e,N,F,oe,nr,Dt,Be,at,je,ot,v,Ct,be,Nr,Or,xr,f]),ns=c=>!i&&ka(cn.current,c),os=(c,p)=>{const S=Ti.current,x=ut.current,V=cn.current;if(i||S===null||x===null||V===null||!wu(S,V,Ci.current,b,c,p))return null;const W=x.getBoundingClientRect();return Math.abs(b?c-(W.left+W.width/2):p-(W.top+W.height/2))},as=c=>{if(i||or())return;const p=$l(c.deltaX,c.deltaY,b);if(p===0)return;c.preventDefault();const S=c.target,x=ka(Ii.current,S)||ka(Ai.current,S);if(!$||x){Pa(p);return}const V=ut.current;if(!V)return;const W=V.getBoundingClientRect(),Z=b?c.clientX-(W.left+W.width/2):c.clientY-(W.top+W.height/2);if(hi(Z,_)==="macro"){wc(p);return}Pa(p)},to=s.useRef({ownsWheelHit:ns,distanceToRailPx:os,stepFromRangeAreaWheel:as});s.useLayoutEffect(()=>{to.current={ownsWheelHit:ns,distanceToRailPx:os,stepFromRangeAreaWheel:as}});const hn=s.useRef(null);s.useEffect(()=>{const c=cn.current?.ownerDocument.defaultView??null,p=hn.current;if(p!==null&&p.view===c)return;if(p?.unregister(),c===null){hn.current=null;return}const S=Su(c,{ownsHit:x=>to.current.ownsWheelHit(x),distanceToRailPx:(x,V)=>to.current.distanceToRailPx(x,V),step:x=>to.current.stepFromRangeAreaWheel(x)});hn.current={view:c,unregister:S}}),s.useEffect(()=>()=>{hn.current?.unregister(),hn.current=null},[]);const ro=Rr(xe),no=Rr($e),La=he(xe),$a=he($e),Wr=Ys(ro,no,wa),ar=Wr.slant,gn=ye==="low"||ye!=="high"&&Ot==="low",pn=!G&&(ye==="high"||ye!=="low"&&Ot==="high"),vc=ga&&Ze!=="macro-low",Sc=ga&&Ze==="macro-low",Rc=pa&&Ze!=="micro-low",xc=pa&&Ze==="micro-low",vt=_a("macro",Mt,It,Ra),St=_a("micro",vr,Vr,xa),is=Wr.slant.isSlanted||vt.slant.isSlanted||St.slant.isSlanted;s.useLayoutEffect(()=>{is&&dn()});const ss=is||ya;s.useEffect(()=>{if(!ss)return;const c=ut.current,p=c===null?null:c.ownerDocument.defaultView;if(c===null||p===null)return;const S=c.ownerDocument;let x=null;const V=()=>{x===null&&(x=p.requestAnimationFrame(()=>{x=null,dn()}))};S.addEventListener("scroll",V,{capture:!0,passive:!0}),p.addEventListener("resize",V);const W=typeof ResizeObserver>"u"?null:new ResizeObserver(V);for(const Z of[ue,K])Z!==null&&W?.observe(Z);return()=>{S.removeEventListener("scroll",V,{capture:!0}),p.removeEventListener("resize",V),W?.disconnect(),x!==null&&p.cancelAnimationFrame(x)}},[ss,ue,K,dn]);const Mc=Math.min(ro,no),Dc=Math.max(ro,no),[ls,cs]=Pn.flat,[yc,Ec]=Pn.macro,[Pc,Lc]=Pn.micro,us=sr(ls,ro),ds=sr(cs,no),Ta=sr(ls,Mc),ms=`calc(${sr(cs,Dc)} - ${Ta})`,Gr=sr(yc,Mt*100),oo=sr(Ec,It*100),Kr=sr(Pc,vr*100),ao=sr(Lc,Vr*100),$c=b?{bottom:Ta,height:ms,top:"auto",left:"0",right:"0"}:{left:Ta,width:ms,top:"0",bottom:"0"},Tc=Math.max(.01,It-Mt),fs=Math.max(.06,Math.min(.25,.28*Math.sqrt(Tc))),Cc=b?{bottom:us,left:"50%",transform:"translate(-50%, 50%)",zIndex:gn?40:30}:{left:us,top:"50%",transform:"translate(-50%, -50%)",zIndex:gn?40:30},Ic=b?{bottom:ds,left:"50%",transform:"translate(-50%, 50%)",zIndex:pn?40:30}:{left:ds,top:"50%",transform:"translate(-50%, -50%)",zIndex:pn?40:30},Ac=b?{bottom:`${lt}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${lt}%`,top:"50%",transform:"translate(-50%, -50%)"},hs=J!==null?he(J):null,kc=d!=="hover"&&J!==null&&(J===xe||!G&&J===$e),Nc=$?Be>yi:xe>N,Oc=$?at<ia:$e<F,Vc=P!==vt.slant.isFlipped?"before":"after",_c=P===St.slant.isFlipped?"before":"after",io=ed($?[{side:Vc,box:va,...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:vt.slant.lowAngleDeg,centreFromAnchorPx:vt.centreFromAnchorPx,alongPushPx:vt.slant.lowOffsetX}},{side:_c,box:Sa,...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:St.slant.lowAngleDeg,centreFromAnchorPx:St.centreFromAnchorPx,alongPushPx:St.slant.lowOffsetX}}]:[{side:b||m==="top"!==ar.isFlipped?"before":"after",box:G?Zn:Po(Zn,Ni),...b?{reach:"inline-size"}:{reach:"rotated",angleDeg:ar.lowAngleDeg,centreFromAnchorPx:Math.abs(ar.lowOffsetY),alongPushPx:ar.lowOffsetX}}]),Yc=io===void 0?e.style:{...e.style,...io.style};s.useLayoutEffect(()=>{Ci.current=io===void 0?0:io.mainPx});const Yt=ee?"micro-point":"micro-low",Mr=i?"cursor-not-allowed opacity-50":"cursor-pointer",qr=c=>d==="hover"||!T||c===void 0?null:C.jsx("span",{"data-label-leader":"true","aria-hidden":"true",className:"period-slider-label-leader",style:c}),gs=c=>{const p=b?"vertical":"horizontal",S=c==="decrease",x=b?!S:S;return C.jsx(Tr,{ref:S?Ii:Ai,neighbour:"rail",direction:rd[p][c],glyph:"single",disabled:i,canStep:S?Nc:Oc,onStep:()=>Pa(S?-1:1),ariaLabel:S?B.decrease:B.increase,className:`period-slider-stepper-btn ${nd[p][c]} ${js[p][x?"leading":"trailing"]}`})};return C.jsxs("div",{ref:cn,style:Yc,className:`period-slider grid select-none place-items-center ${od[b?"vertical":"horizontal"][u?"withSteppers":"railOnly"]} ${l}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":b?"vertical":"horizontal","data-label-position":m,"data-color-scheme":h,children:[C.jsx("div",{ref:Ti,"data-range-area":"true","aria-hidden":"true",className:"period-slider-range-area"}),u&&gs(b?"increase":"decrease"),C.jsx("div",{ref:ut,"data-testid":"period-slider-track","data-orientation":b?"vertical":"horizontal","data-vernier-orientation":$?_:void 0,className:`period-slider-track relative touch-none rounded-full ${js[b?"vertical":"horizontal"][u?"rail":"railOnly"]} ${Mr}`,onPointerDown:gc,onPointerMove:pc,onPointerLeave:bc,children:$?C.jsxs(C.Fragment,{children:[Re&&(b?C.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:[C.jsx("defs",{children:C.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"1",y2:"0",children:[C.jsx("stop",{offset:"0%",stopColor:P?ne.macro:ne.micro,stopOpacity:"0.28"}),C.jsx("stop",{offset:"100%",stopColor:P?ne.micro:ne.macro,stopOpacity:fs})]})}),C.jsx("path",{ref:da,"data-testid":"period-slider-vernier-projection",d:Aa(Mt,It,b,P),fill:`url(#${k})`})]}):C.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[C.jsx("defs",{children:C.jsxs("linearGradient",{id:k,x1:"0",y1:"0",x2:"0",y2:"1",children:[C.jsx("stop",{offset:"0%",stopColor:P?ne.macro:ne.micro,stopOpacity:"0.28"}),C.jsx("stop",{offset:"100%",stopColor:P?ne.micro:ne.macro,stopOpacity:fs})]})}),C.jsx("path",{ref:da,"data-testid":"period-slider-vernier-projection",d:Aa(Mt,It,b,P),fill:`url(#${k})`})]})),!g&&C.jsxs(C.Fragment,{children:[C.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:b?{bottom:`calc(${Gr} - 8px)`,height:`calc(${oo} - ${Gr} + 16px)`}:{left:`calc(${Gr} - 8px)`,width:`calc(${oo} - ${Gr} + 16px)`},onPointerDown:zr("macro-connect")}),!ee&&C.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:b?{bottom:`calc(${Kr} - 8px)`,height:`calc(${ao} - ${Kr} + 16px)`}:{left:`calc(${Kr} - 8px)`,width:`calc(${ao} - ${Kr} + 16px)`},onPointerDown:zr("micro-connect")})]}),_e&&C.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(c=>C.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`macro-tick-${c}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(c=>C.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:b?{bottom:`${c*100}%`}:{left:`${c*100}%`}},`micro-tick-${c}`))]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.macroRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":Xl,"aria-valuemax":ct,"aria-valuenow":Qe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(br,M,"period"):Pr(M,br,Oe,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:Gr,left:P?0:"auto",right:P?"auto":0,transform:P?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:nt==="macro-low"||Ze==="macro-low"?30:15}:{left:Gr,top:P?0:"auto",bottom:P?"auto":0,transform:P?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:nt==="macro-low"||Ze==="macro-low"?30:15},onPointerDown:zr("macro-low"),onKeyDown:eo("macro-low"),onFocus:Jn("macro-low"),"data-active":nt==="macro-low"?"true":void 0,"data-front":Ze==="macro-low"?"true":void 0,"data-vernier-pos":b?P?"left":"right":P?"top":"bottom","data-handle-type":"macro-low",children:[C.jsx(En,{type:"macro",isTop:P,isVertical:b,isLeft:P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":vc?"true":void 0,"data-slanted":vt.slant.isSlanted?"true":void 0,"data-flipped":vt.slant.isFlipped?"true":void 0,ref:ec,style:vt.lowStyle,children:it(M,br,Oe,D)}),qr(vt.lowLeaderStyle)]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.macroRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Qe,"aria-valuemax":Zl,"aria-valuenow":ct,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(wr,M,"period"):Pr(M,wr,Oe,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:oo,left:P?0:"auto",right:P?"auto":0,transform:P?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:nt==="macro-high"||Ze==="macro-high"?30:15}:{left:oo,top:P?0:"auto",bottom:P?"auto":0,transform:P?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:nt==="macro-high"||Ze==="macro-high"?30:15},onPointerDown:zr("macro-high"),onKeyDown:eo("macro-high"),onFocus:Jn("macro-high"),"data-active":nt==="macro-high"?"true":void 0,"data-front":Ze==="macro-high"?"true":void 0,"data-vernier-pos":b?P?"left":"right":P?"top":"bottom","data-handle-type":"macro-high",children:[C.jsx(En,{type:"macro",isTop:P,isVertical:b,isLeft:P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":Sc?"true":void 0,"data-slanted":vt.slant.isSlanted?"true":void 0,"data-flipped":vt.slant.isFlipped?"true":void 0,ref:rc,style:vt.highStyle,children:it(M,wr,Oe,D)}),qr(vt.highLeaderStyle)]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":ee?B.microSelectedDate:B.microRangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":yi,"aria-valuemax":ee?ia:at,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Nr,v,"period"):Pr(v,Nr,He,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:Kr,left:P?"auto":0,right:P?0:"auto",transform:P?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:nt===Yt||Ze===Yt?30:20}:{left:Kr,top:P?"auto":0,bottom:P?0:"auto",transform:P?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:nt===Yt||Ze===Yt?30:20},onPointerDown:zr(Yt),onKeyDown:eo(Yt),onFocus:Jn(Yt),"data-active":nt===Yt?"true":void 0,"data-front":Ze===Yt?"true":void 0,"data-vernier-pos":b?P?"right":"left":P?"bottom":"top","data-handle-type":Yt,children:[C.jsx(En,{type:"micro",isTop:!P,isVertical:b,isLeft:!P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":Rc?"true":void 0,"data-slanted":St.slant.isSlanted?"true":void 0,"data-flipped":St.slant.isFlipped?"true":void 0,ref:oc,style:St.lowStyle,children:it(v,Nr,He,D)}),qr(St.lowLeaderStyle)]}),!ee&&C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.microRangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":Be,"aria-valuemax":ia,"aria-valuenow":at,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Or,v,"period"):Pr(v,Or,He,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${b?"is-vertical":""} group absolute touch-none ${b?P?"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":P?"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 ${Mr}`,style:b?{bottom:ao,left:P?"auto":0,right:P?0:"auto",transform:P?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:nt==="micro-high"||Ze==="micro-high"?30:20}:{left:ao,top:P?"auto":0,bottom:P?0:"auto",transform:P?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:nt==="micro-high"||Ze==="micro-high"?30:20},onPointerDown:zr("micro-high"),onKeyDown:eo("micro-high"),onFocus:Jn("micro-high"),"data-active":nt==="micro-high"?"true":void 0,"data-front":Ze==="micro-high"?"true":void 0,"data-vernier-pos":b?P?"right":"left":P?"bottom":"top","data-handle-type":"micro-high",children:[C.jsx(En,{type:"micro",isTop:!P,isVertical:b,isLeft:!P}),E&&C.jsx("div",{"data-testid":"period-slider-hairline",className:"period-slider-hairline"}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-duplicate":xc?"true":void 0,"data-slanted":St.slant.isSlanted?"true":void 0,"data-flipped":St.slant.isFlipped?"true":void 0,ref:ac,style:St.highStyle,children:it(v,Or,He,D)}),qr(St.highLeaderStyle)]})]}):C.jsxs(C.Fragment,{children:[!g&&C.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:$c,onPointerDown:hc}),w&&Y&&H.length>1&&C.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:H.map((c,p)=>{const S=U(t,c,f),x=Rr(p),V=b?{bottom:`${x}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${x}%`,top:"50%",transform:"translate(-50%, -50%)"};return C.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full",style:V},`tick-${S}`)})}),!i&&J!==null&<!==null&&ye===null&&hs&&C.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute h-2 w-2",style:Ac,children:[C.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"}),C.jsx("div",{"data-testid":"period-slider-hover-tooltip","data-duplicate":kc?"true":void 0,className:`period-slider-hover-tooltip ${m==="bottom"&&!b?"period-slider-hover-tooltip-bottom":""} rounded bg-slate-800/90 px-2 py-0.5 font-medium text-white text-xs shadow-lg backdrop-blur-xs dark:bg-slate-900/90`,children:it(t,hs,e.formatLabel,D)})]}),C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":G?B.selectedDate:B.rangeStart,"aria-disabled":i?"true":void 0,"aria-valuemin":N,"aria-valuemax":G?F:$e,"aria-valuenow":xe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(La,t,"period"):Pr(t,La,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Mr}`,style:Cc,onPointerDown:es("low"),onKeyDown:rs("low"),onFocus:ts("low"),"data-active":ye==="low"?"true":void 0,"data-front":gn?"true":void 0,children:[C.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 ${ye==="low"?"":"shadow-md"}`}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-label-position":m,"data-slanted":ar.isSlanted?"true":void 0,"data-flipped":ar.isFlipped?"true":void 0,"data-front":gn?"true":void 0,"data-duplicate":ha&&!gn?"true":void 0,ref:Ql,style:Wr.lowStyle,children:it(t,La,e.formatLabel,D)}),qr(Wr.lowLeaderStyle)]}),!G&&C.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":B.rangeEnd,"aria-disabled":i?"true":void 0,"aria-valuemin":xe,"aria-valuemax":F,"aria-valuenow":$e,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText($a,t,"period"):Pr(t,$a,e.formatLabel,D),"aria-orientation":b?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[calc((100%-var(--ps-target-size))/2)] after:content-[''] focus-visible:outline-hidden ${Mr}`,style:Ic,onPointerDown:es("high"),onKeyDown:rs("high"),onFocus:ts("high"),"data-active":ye==="high"?"true":void 0,"data-front":pn?"true":void 0,children:[C.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 ${ye==="high"?"":"shadow-md"}`}),d!=="hover"&&C.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap font-medium shadow-md ${d==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":d,"data-label-position":m,"data-slanted":ar.isSlanted?"true":void 0,"data-flipped":ar.isFlipped?"true":void 0,"data-front":pn?"true":void 0,"data-duplicate":ha&&!pn?"true":void 0,ref:Jl,style:Wr.highStyle,children:it(t,$a,e.formatLabel,D)}),qr(Wr.highLeaderStyle)]})]})}),u&&gs(b?"decrease":"increase")]})},et=e=>e.getTime(),kl=(e,t)=>!(kt(e)&&kt(t))||e.length!==2||t.length!==2?!1:Pt(e[0],et)===Pt(t[0],et)&&Pt(e[1],et)===Pt(t[1],et),go=(e,t)=>e===void 0||t===void 0?e===t:kl(e,t),Ya=(e,t)=>{if(e===t)return!0;if(!(kt(e)&&kt(t))||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(Pt(e[r],et)!==Pt(t[r],et))return!1;return!0},Nl=(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},id=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.yearStartMonth!==t.yearStartMonth||Pt(e.minDate,et)!==Pt(t.minDate,et)||Pt(e.maxDate,et)!==Pt(t.maxDate,et)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.keepMergedLabelUpright!==t.keepMergedLabelUpright||e.labelCeiling!==t.labelCeiling||e.labelFloor!==t.labelFloor||e.showLabelLeaderLines!==t.showLabelLeaderLines||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||!Nl(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.formatLocale!==t.formatLocale||e.locale!==t.locale||!Bo(e.labels,t.labels)||e.formatAriaValueText!==t.formatAriaValueText||!Ya(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!(gt(e.value,et)!==gt(t.value,et)||gt(e.defaultValue,et)!==gt(t.defaultValue,et)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!(!go(e.range,t.range)||!go(e.defaultRange,t.defaultRange)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!(!go(e.microRange,t.microRange)||!go(e.defaultMicroRange,t.defaultMicroRange)||gt(e.microValue,et)!==gt(t.microValue,et)||gt(e.defaultMicroValue,et)!==gt(t.defaultMicroValue,et)||!kl(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||!Ya(e.macroAllowedDates,t.macroAllowedDates)||!Ya(e.microAllowedDates,t.microAllowedDates)):!1,Ol=s.memo(ad,id);Ol.displayName="PeriodSlider";const Us=2,Pe=-1,yt=e=>U("day",e),Vn=e=>se("day",e),Rn=e=>`${qo(e.getFullYear())}-${String(e.getMonth()+1).padStart(Us,"0")}-${String(e.getDate()).padStart(Us,"0")}`,sd=(e,t,r,n)=>{const o=yt(e),a=yt(t),i=a>=o?a-o+1:0,l=d=>Vn(a-d),u={kind:"range",min:o,max:a};return{count:i,dateAt:l,labelAt:d=>it("day",l(d),n,r),indexOf:d=>{const m=yt(d);return m<o||m>a?Pe:a-m},nearestIndexOf:d=>{if(i===0)return Pe;const m=kn(u,yt(d));return m===null?Pe:a-m}}},ld=(e,t,r,n,o,a)=>{const i=n>=r?n-r+1:0,l=R=>e[n-R],u={kind:"candidates",ascending:t,loIndex:r,hiIndex:n},d=R=>{const L=R.getTime();let T=r,b=n;for(;T<=b;){const g=T+b>>1,w=e[g].getTime();if(w===L)return n-g;w<L?T=g+1:b=g-1}return Pe},m=R=>R===null?Pe:d(Vn(R));return{count:i,dateAt:l,labelAt:R=>it("day",l(R),a,o),indexOf:d,nearestIndexOf:R=>m(kn(u,yt(R)))}},cd={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:()=>Pe,nearestIndexOf:()=>Pe},ud=(e,t,r)=>{const n=l=>{let u=0,d=e.length;for(;u<d;){const m=u+d>>1;e[m].getTime()<l?u=m+1:d=m}return u},o=l=>{let u=0,d=e.length;for(;u<d;){const m=u+d>>1;e[m].getTime()<=l?u=m+1:d=m}return u},a=t===null?0:n(t.getTime()),i=(r===null?e.length:o(r.getTime()))-1;return{loIndex:a,hiIndex:i}},dd=(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))},md={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},fd={month:2,day:2},zs={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},Bs=new Map,hd=(e,t)=>{const r=`${e}\0${t}`,n=Bs.get(r);if(n!==void 0)return n;const o=new Intl.DateTimeFormat(t,md[e]);return Bs.set(r,o),o},gd=(e,t,r)=>{if(r!==void 0)return hd(e,r).format(t);const n=new Date(t.getTime());return e==="year"?qo(zs.year(n)):String(zs[e](n)).padStart(fd[e],"0")},Vl=(e,t,r,n)=>{if(Le("formatOptionText","unit",t),r!=="period"&&r!=="part")throw new RangeError(`formatOptionText: scope must be "period" or "part" (received: ${y(r)})`);return De(e)?r==="part"?gd(t,e,n):it(t,e,void 0,n):""},$n="period-slider-selector-field",pd=`${$n} period-slider-selector-field-year`,Oo=`${$n} period-slider-selector-field-date`,bd=12,ea=(e,t,r)=>{const n=zn(e,t,r);return n===null?Number.NaN:n*bd+r},gi=(e,t,r)=>{const n=o=>o.value!==void 0?o.value:o.initialDate;return gt(n(e),r)!==gt(n(t),r)||t.value!==void 0&&Number.isNaN(gt(t.initialDate,r))||gt(e.minDate,r)!==gt(t.minDate,r)?!1:gt(e.maxDate,r)===gt(t.maxDate,r)};class _l{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 Yl(e,t){const[r]=s.useState(()=>t(e)),n=r.writes;return s.useInsertionEffect(()=>{r.commit(e,n)}),r}function mt(e){return Yl(e,t=>new _l(t))}const wd={motion:["motion","edge"],vernierRange:["motion","edge","window"],vernierPoint:["window"]},vd=["shift","start","end","single"],Sd=["disable","clamp"],Rd=["follow","keep"],Ws={day:{day:1},month:{month:1,year:12},year:{year:1}},Gs=new WeakMap,Xa=(e,t,r)=>{if(typeof r!="object"||r===null)throw new RangeError(`${e}: ${t} must be an object (received: ${y(r)})`)},Ks=(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)})`)},Cr=(e,t,r,n)=>{Xa(e,t,r),Ks(e,t,r,["previous","next"]);for(const o of["previous","next"]){const a=`${t}.${o}`,i=r[o];Xa(e,a,i),Ks(e,a,i,wd[n]);const{motion:l,edge:u,window:d}=i;if(n!=="vernierPoint"&&(typeof l!="string"||!vd.includes(l)))throw new RangeError(`${e}: ${a}.motion must be one of "shift", "start", "end", "single" (received: ${y(l)})`);if(u!==void 0){if(l!=="shift")throw new RangeError(`${e}: ${a}.edge applies to motion "shift" only; a motion that moves one value either can move or cannot (received: edge ${y(u)} with motion ${y(l)})`);if(typeof u!="string"||!Sd.includes(u))throw new RangeError(`${e}: ${a}.edge must be "disable" or "clamp" (received: ${y(u)})`)}if(d!==void 0&&(typeof d!="string"||!Rd.includes(d)))throw new RangeError(`${e}: ${a}.window must be "follow" or "keep" (received: ${y(d)})`)}},pi=(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(!De(r))throw new RangeError(`${e}: ${t} must be a valid Date (received: ${y(r)})`);return Ke(e,t,r,n,o,"")},Hl=(e,t,r,n,o)=>{const a=`${n}:${o}`,i=Gs.get(r),l=i?.get(a);if(l!==void 0)return l;const u=[];for(let m=0;m<r.length;m++)u.push(qt(e,`${t}[${m}]`,r[m],n,o));const d=Array.from(new Set(u)).sort((m,R)=>m-R);return i===void 0?Gs.set(r,new Map([[a,d]])):i.set(a,d),d},xd=(e,t)=>t===1?Mo(e):{stepEnd:(r,n)=>xo(e,r+t*n,n),edge:r=>In(e,r)},Za=(e,t)=>e.motion==="shift"?{motion:"shift",edge:e.edge==="clamp"?"clamp":"disable"}:e.motion==="single"?{motion:"single",shows:t}:{motion:e.motion},Qa=(e,t,r,n,o,a)=>{if(a){const u=e[0]===t[0]?r[0]:e[0]===t[1]?r[1]:se(n,e[0],o);return Number.isNaN(u.getTime())?null:[u,u]}const i=e[0]===t[0]?r[0]:se(n,e[0],o),l=e[1]===t[1]?r[1]:se(n,e[1],o);return Number.isNaN(i.getTime())||Number.isNaN(l.getTime())?null:[i,l.getTime()<i.getTime()?i:l]},Ja=e=>{const t="resolveSelectorSteps";Xa(t,"options",e);const{selection:r,shows:n,unit:o,minDate:a,maxDate:i,allowedDates:l,rules:u}=e;Le(t,"unit",o);const d=Qt(t,"stepUnit",e.stepUnit,o),m=Ws[o][d];if(m===void 0){const M=Object.keys(Ws[o]).map(v=>`"${v}"`).join(" or ");throw new RangeError(`${t}: stepUnit must be ${M} for a ${o} selection, the steps that move every ${o} by a whole number of ${o}s (received: ${y(d)})`)}const R=gr(t,e.yearStartMonth);if(n!=="start"&&n!=="end")throw new RangeError(`${t}: shows must be "start" or "end" (received: ${y(n)})`);if(!kt(r)||r.length!==2)throw new RangeError(`${t}: selection must be a [start, end] tuple of Dates (received: ${y(r)})`);Cr(t,"rules",u,"motion");const L=qt(t,"selection[0]",r[0],o,R),T=qt(t,"selection[1]",r[1],o,R);if(T<L)throw new RangeError(`${t}: selection must not be inverted at ${o} resolution (start: ${y(r[0])}, end: ${y(r[1])})`);const b=a===void 0?null:qt(t,"minDate",a,o,R),g=i===void 0?null:qt(t,"maxDate",i,o,R);if(b!==null&&g!==null&&g<b)throw new RangeError(`${t}: maxDate must not precede minDate at ${o} resolution (minDate: ${y(a)}, maxDate: ${y(i)})`);sn(t,"allowedDates",l);const w=l===void 0?{kind:"range",min:b,max:g}:ln(Hl(t,"allowedDates",l,o,R),b,g),h=xd(w,m),D=(M,v)=>{const f=Wa(h,L,T,M,Za(v,n));return f===null?null:Qa(f,[L,T],r,o,R,v.motion==="single")};return{previous:D(-1,u.previous),next:D(1,u.next)}},Ft=(e,t)=>{const r=mt({targets:e,onStepTo:t}),n=s.useCallback(i=>{const{targets:l,onStepTo:u}=r.current,d=l[i];d!==null&&u(d,i)},[]),o=e.previous!==null,a=e.next!==null;return s.useMemo(()=>({onStep:n,canStepPrevious:o,canStepNext:a}),[n,o,a])};function Md(e,t,r,n){return e.source===t?e:t===null?{source:t,held:e.held}:{source:t,held:n(r)}}function bi(e,t,r,n){const o=t?null:r(e),[a,i]=s.useState(()=>({source:o,held:n(e)})),l=s.useCallback(d=>i(m=>({source:m.source,held:d})),[]),u=Md(a,o,e,n);return s.useLayoutEffect(()=>{u!==a&&i(d=>d===a?u:d)}),[u.held,l]}const Lo=44,qs=7,po=8,Dd=2,jl=10,yd=1e3,ei=8,Ha=6,ja=4,Fa=12,xn=(e,t)=>{const r=new Date(e,t-1,1);return r.setFullYear(e),yt(r)},Ed=(e,t)=>{if(e.length<ja||t.count===0)return Pe;const r=Number(e.slice(0,ja));if(!Number.isInteger(r))return Pe;const n=e.length>=Ha,o=n?Number(e.slice(ja,Ha)):Fa;if(o<1||o>Fa)return Pe;const a=e.length>=ei,i=a?Number(e.slice(Ha,ei)):0,l=xn(r,o),u=(o===Fa?xn(r+1,1):xn(r,o+1))-1,d=a?l+i-1:n?l:xn(r,1),m=a?d:n?u:xn(r+1,1)-1;if(a&&(i<1||d>u))return Pe;for(let R=m;R>=d;R--){const L=t.indexOf(Vn(R));if(L!==Pe)return L}return Pe},Pd=e=>e.closest(".dark")===null?"light":"dark",Ld=(e,t,r,n)=>{const o=r-e.bottom-po,a=e.top-po,i=o>=t||o>=a,u=Math.max(Lo,Math.min(t,i?o:a)),d=i?e.bottom:e.top-u,m=e.width+jl,R=Math.max(po,Math.min(e.left,n-m-po));return{top:d,left:R,width:m,height:u}},$d=(e,t)=>e<t?e:t>0?t-1:Pe,Fl=({domain:e,selectedIndex:t,openAnchorIndex:r,displayLabel:n,machineValue:o,disabled:a,ariaLabel:i,locale:l,labels:u,onCommitIndex:d,controlClassName:m})=>{const R=s.useId(),L=s.useMemo(()=>du(u),[u]),T=`period-slider-date-listbox-${R}`,b=s.useCallback(O=>`period-slider-date-option-${R}-${O}`,[R]),[g,w]=s.useState(!1),[h,D]=s.useState(Pe),[M,v]=s.useState(null),[f,ue]=s.useState(null),K=s.useRef(null),re=s.useRef(null),ee=s.useRef(null),B=s.useRef({buffer:"",at:0}),ne=e.count,k=$d(h,ne),q=mt(k);s.useLayoutEffect(()=>{k!==h&&D(O=>O===h?k:O)});const j=Math.min(ne,qs)*Lo,A=Math.max(1,Math.min(ne,qs)),$=s.useCallback(()=>{const O=K.current;if(O===null)return;const X=O.getBoundingClientRect();v(Ld(X,j,window.innerHeight,window.innerWidth))},[j]),H=mt(g),Y=s.useCallback(()=>{w(!1),D(Pe),B.current={buffer:"",at:0},H.current=!1},[H]);s.useLayoutEffect(()=>()=>{H.current&&Y()},[H,Y]);const N=s.useCallback(O=>{a||ne===0||(D(O),w(!0),H.current=!0)},[a,ne,H]);s.useLayoutEffect(()=>{if(!g){v(null),ue(null);return}const O=K.current;return O!==null&&ue(Pd(O)),$(),window.addEventListener("scroll",$,!0),window.addEventListener("resize",$),()=>{window.removeEventListener("scroll",$,!0),window.removeEventListener("resize",$)}},[g,$]),s.useEffect(()=>{if(!g)return;const O=X=>{const de=X.target;de!==null&&re.current?.contains(de)!==!0&&K.current?.contains(de)!==!0&&Y()};return document.addEventListener("pointerdown",O,!0),()=>document.removeEventListener("pointerdown",O,!0)},[g,Y]),s.useEffect(()=>{g&&(a||ne===0)&&Y()},[g,a,ne,Y]),s.useEffect(()=>{if(!g)return;const O=q.current;O!==Pe&&ee.current?.scrollToIndex(O,{align:"center"})},[ne,g,q]);const F=O=>{if(ne===0)return;const X=Math.max(0,Math.min(O,ne-1));D(X),ee.current?.scrollToIndex(X,{align:"center"})},G=O=>{O<0||O>=ne||(d(O),Y(),K.current?.focus())},he=mt(G),te=O=>{if(a||K.current===null)return;const X=k!==Pe?k:t!==Pe?t:r;switch(O.key){case"ArrowDown":if(O.preventDefault(),!g){N(X);return}F(X+1);return;case"ArrowUp":if(O.preventDefault(),!g){N(X);return}F(X-1);return;case"Home":if(!g)return;O.preventDefault(),F(0);return;case"End":if(!g)return;O.preventDefault(),F(ne-1);return;case"PageDown":if(!g)return;O.preventDefault(),F(X+A);return;case"PageUp":if(!g)return;O.preventDefault(),F(X-A);return;case"Enter":if(O.preventDefault(),!g){N(X);return}G(k!==Pe?k:X);return;case"Escape":if(!g)return;O.preventDefault(),Y();return;case"Tab":g&&Y();return}if(O.key.length!==1)return;const de=O.key>="0"&&O.key<="9",Ve=O.key==="-"||O.key==="/"||O.key===".";if(!(de||Ve))return;O.preventDefault();const we=Date.now(),tt=we-B.current.at>yd?"":B.current.buffer,qe=de?`${tt}${O.key}`.slice(0,ei):tt;B.current={buffer:qe,at:we};const Ue=Ed(qe,e);if(Ue!==Pe){if(!g){N(Ue);return}F(Ue)}},le=s.useCallback(O=>O,[]),Se=s.useCallback(()=>Lo,[]),ae=k===Pe?null:b(k),ie=s.useCallback(()=>{const O=K.current;if(O===null||ae===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 O.setAttribute("aria-activedescendant",ae),()=>{O.getAttribute("aria-activedescendant")===ae&&O.removeAttribute("aria-activedescendant")}},[ae]),pe=s.useCallback(O=>{const X=O===t,de=O===k;return C.jsx("div",{id:b(O),role:"option","aria-selected":X,"aria-posinset":O+1,"aria-setsize":e.count,"data-testid":"period-slider-date-option","data-active":de?"true":void 0,ref:de?ie:void 0,className:"period-slider-date-option",style:{height:Lo},onClick:()=>he.current(O),children:e.labelAt(O)})},[e,t,k,b,he,ie]),Fe=s.useCallback(O=>(re.current=O,O.style.removeProperty("display"),()=>{re.current=null,O.style.setProperty("display","none","important")}),[]),ft=g&&M!==null&&f!==null&&ne>0,ge=ft?C.jsx("div",{ref:Fe,className:"period-slider-date-popup","data-testid":"period-slider-date-popup","data-color-mode":f,style:{top:M.top,left:M.left,width:M.width,height:M.height},onMouseDown:O=>{O.preventDefault()},children:C.jsx(mr.VirtualScroll,{ref:ee,itemCount:ne,getItem:le,getItemHeight:Se,viewportSize:M.height-Dd,initialScrollIndex:k!==Pe?k:void 0,className:"h-full w-full",testId:"period-slider-date-listbox-pane",locale:l,labels:L,contentProps:{id:T,role:"listbox","aria-label":i},scrollBarOptions:{width:jl,enableArrowButtons:!1,enableThumbDrag:!0,enableTrackClick:!0,tapScrollCircleOptions:{enabled:!1}},behaviorOptions:{enableKeyboardNavigation:!1,overscrollBehavior:"contain"},children:pe})}):null;return C.jsxs(C.Fragment,{children:[C.jsx("input",{ref:K,type:"text",role:"combobox",readOnly:!0,"aria-label":i,"aria-expanded":g,"aria-controls":ft?T:void 0,"aria-haspopup":"listbox","aria-autocomplete":"none",disabled:a,value:n,className:m,"data-testid":"period-slider-date-combobox","data-value":o,onKeyDown:te,onMouseDown:O=>{a||K.current===null||(O.preventDefault(),K.current?.focus(),g?Y():N(t!==Pe?t:r))},onBlur:()=>{g&&Y()}}),ge===null?null:Uc.createPortal(ge,document.body)]})};Fl.displayName="VirtualDateDropdown";const Mn=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Td=Un("leave the bound out where the variant allows it, or declare the days to offer with minYear / maxYear or allowedDates"),Cd=Un('variant="split-dropdown" requires both bounds, so declare the years to offer with minYear / maxYear'),Id=31,Dn=(e,t,r)=>{if(!De(t))throw new RangeError(`DateSelector: ${e} must be a valid Date (received: ${y(t)})`);Ke("DateSelector",e,t,"day",0,r)},lr=(e,t,r)=>{const n=new Date(0);return n.setHours(0,0,0,0),n.setFullYear(e,t-1,r),n},bo=e=>lr(e,1,1),Xs=e=>lr(e,12,31),Ul=(e,t,r)=>e.getFullYear()===t&&e.getMonth()+1===r,Zs=(e,t,r,n)=>Ul(e,t,r)&&e.getDate()===n,wi=e=>zn(e,"year",0)!==null,vi=e=>ea(e,"day",0),Ad=e=>wi(e)?vi(e):Number.NaN,wo=(e,t,r)=>{if(!wi(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}`)},Qs=(e,t,r,n,o)=>{const a=[];for(let i=e;i<=t;i++){const l=r(i);if(Number.isNaN(l.getTime()))break;n(l,i)&&a.push({value:i,label:o(l)})}return a},kd=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,minYear:l,maxYear:u,minDate:d,maxDate:m,allowedDates:R,variant:L="date",className:T="",style:b,disabled:g=!1,locale:w,labels:h,formatLocale:D,formatOption:M}=e;D!==void 0&&Jo("DateSelector","formatLocale",D);const v=L==="split-dropdown"?Cd:Td;if(t!==void 0&&Dn("value",t,""),r!==void 0&&Dn("initialDate",r,""),d!==void 0&&Dn("minDate",d,v),m!==void 0&&Dn("maxDate",m,v),L==="split-dropdown"&&(t!==void 0&&wo("value",t,""),r!==void 0&&wo("initialDate",r,""),d!==void 0&&wo("minDate",d,v),m!==void 0&&wo("maxDate",m,v)),l!==void 0&&!Number.isInteger(l))throw new RangeError(`DateSelector: minYear must be an integer year (received: ${y(l)})`);if(u!==void 0&&!Number.isInteger(u))throw new RangeError(`DateSelector: maxYear must be an integer year (received: ${y(u)})`);if(l!==void 0&&Number.isNaN(bo(l).getTime()))throw new RangeError(`DateSelector: minYear must name a year whose first day starts inside the Date range (received: ${y(l)})`);if(u!==void 0&&Number.isNaN(Xs(u).getTime()))throw new RangeError(`DateSelector: maxYear must name a year whose last day starts inside the Date range (received: ${y(u)})`);if(L==="split-dropdown"&&R!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour allowedDates; use variant="dropdown" or variant="date" for a discrete date set');sn("DateSelector","allowedDates",R);const f=t??r;if(f===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&&pi("DateSelector",o,t!==void 0);const ue=ui("DateSelector",a),K=Wo(w,h),re=t!==void 0,[ee,B]=bi(f,re,vi,Mn),ne=t?.getTime(),k=s.useMemo(()=>t!==void 0?Mn(t):ee,[ne,ee]);if(L==="split-dropdown"&&!re&&!wi(k))throw new RangeError(`DateSelector: variant="split-dropdown" cannot draw the uncontrolled selection held from an earlier render (holding ${y(k)}), because that selection's year starts outside the Date range; control the date with value to decide what the split dropdown holds`);const q=d?.getTime(),j=m?.getTime(),A=s.useMemo(()=>{const I=d?Mn(d):null,J=l!==void 0?bo(l):null;return I===null?J:J===null||I.getTime()>=J.getTime()?I:J},[q,l]),$=s.useMemo(()=>{const I=m?Mn(m):null,J=u!==void 0?Xs(u):null;return I===null?J:J===null||I.getTime()<=J.getTime()?I:J},[j,u]),H=A?.getTime()??null,Y=$?.getTime()??null;if(A!==null&&$!==null&&A.getTime()>$.getTime())throw new RangeError(`DateSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Rn(A)}, upper: ${Rn($)})`);if(L!=="date"&&R===void 0&&(A===null||$===null))throw new RangeError(`DateSelector: variant=${y(L)} requires a lower bound (minYear or minDate) and an upper bound (maxYear or maxDate)${L==="dropdown"?", or allowedDates":""}; the option list is never invented`);const N=s.useMemo(()=>R===void 0?null:R.map(I=>Pt(I,J=>J.getTime())).join(","),[R]),F=s.useMemo(()=>{if(R===void 0)return null;const I=dd(R,(J,Ye)=>Dn(`allowedDates[${J}]`,Ye,""));return{ascending:I,ascendingSerials:I.map(yt)}},[N]),G=s.useMemo(()=>F===null?null:{...F,...ud(F.ascending,A,$)},[F,H,Y]),he=s.useMemo(()=>G!==null?ld(G.ascending,G.ascendingSerials,G.loIndex,G.hiIndex,D,M):A===null||$===null?cd:sd(A,$,D,M),[G,H,Y,D,M]),te=s.useMemo(()=>G!==null?{kind:"candidates",ascending:G.ascendingSerials,loIndex:G.loIndex,hiIndex:G.hiIndex}:{kind:"range",min:A===null?null:yt(A),max:$===null?null:yt($)},[G,H,Y]),le=I=>!Number.isNaN(I.getTime())&&An(te,yt(I)),Se=I=>{if(g)return;const J=Mn(I);le(J)&&(re||B(J),n?.(J))},ae=k.getTime(),ie=le(k),pe=s.useMemo(()=>{const I=Zt(te,yt(k),-1);if(I===null)return null;const J=Vn(I);return Number.isNaN(J.getTime())?null:J},[te,ae]),Fe=s.useMemo(()=>{const I=Zt(te,yt(k),1);if(I===null)return null;const J=Vn(I);return Number.isNaN(J.getTime())?null:J},[te,ae]),ft=()=>{if(o!==void 0){o.onStep("previous");return}pe!==null&&Se(pe)},ge=()=>{if(o!==void 0){o.onStep("next");return}Fe!==null&&Se(Fe)},O=I=>{if(I.target.value){const J=Fc.parseISO(I.target.value);Number.isNaN(J.getTime())||Se(J)}},X=k.getFullYear(),de=k.getMonth()+1,Ve=k.getDate(),we=s.useCallback((I,J)=>M?M(J,I,"part"):Vl(J,I,"part",D),[M,D]),tt=s.useMemo(()=>{if(L!=="split-dropdown"||A===null||$===null)return[];const I=[];for(let J=$.getFullYear();J>=A.getFullYear();J--)I.push({value:J,label:we("year",bo(J))});return I},[L,H,Y,we]),qe=s.useMemo(()=>{if(L!=="split-dropdown"||A===null||$===null)return[];const I=A,J=$,Ye=X===I.getFullYear()?I.getMonth()+1:1,lt=X===J.getFullYear()?J.getMonth()+1:12;return Qs(Ye,lt,ze=>lr(X,ze,1),(ze,xe)=>Ul(ze,X,xe),ze=>we("month",ze))},[L,H,Y,X,we]),Ue=s.useMemo(()=>{if(L!=="split-dropdown"||A===null||$===null)return[];const I=A,J=$,Ye=X===I.getFullYear()&&de===I.getMonth()+1?I.getDate():1,lt=X===J.getFullYear()&&de===J.getMonth()+1?J.getDate():Id;return Qs(Ye,lt,ze=>lr(X,de,ze),(ze,xe)=>Zs(ze,X,de,xe),ze=>we("day",ze))},[L,H,Y,X,de,we]),st=(I,J,Ye)=>{const lt=lr(I,J,Ye);return Zs(lt,I,J,Ye)&&le(lt)},oe=(I,J,Ye)=>{st(I,J,Ye)&&Se(lr(I,J,Ye))},pt=tt.some(I=>I.value===X),Xe=qe.some(I=>I.value===de),ht=Ue.some(I=>I.value===Ve),ke=Rn(k),Ge=L==="dropdown"?it("day",k,M,D):"",ye=A?Rn(A):void 0,bt=$?Rn($):void 0,rt="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",Ot=`period-slider-date-combobox-field ${Oo} appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 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`;return C.jsxs("div",{className:`inline-flex items-center ${Cn} ${T}`,style:b,"data-variant":L,"data-out-of-range":ie?void 0:"true",children:[C.jsx(Tr,{neighbour:"control",direction:"left",glyph:ue,disabled:g,canStep:o===void 0?pe!==null:o.canStepPrevious,onStep:ft,ariaLabel:K.previousDay}),L==="dropdown"?C.jsx(Fl,{domain:he,selectedIndex:ie?he.indexOf(k):Pe,openAnchorIndex:he.nearestIndexOf(k),displayLabel:Ge,machineValue:ke,disabled:g,ariaLabel:K.dateSelect,locale:w,labels:K,onCommitIndex:I=>Se(he.dateAt(I)),controlClassName:Ot}):L==="split-dropdown"?C.jsxs("div",{className:"inline-flex items-center gap-1",children:[C.jsxs("select",{"aria-label":K.splitYear,disabled:g,className:`${$n} rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 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:pt?X:"",onChange:I=>oe(Number(I.target.value),de,Ve),children:[pt?null:C.jsx("option",{value:"",disabled:!0,className:rt,children:we("year",bo(X))}),tt.map(I=>C.jsx("option",{value:I.value,disabled:!st(I.value,de,Ve),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]}),C.jsxs("select",{"aria-label":K.splitMonth,disabled:g,className:`${$n} rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 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:Xe?de:"",onChange:I=>oe(X,Number(I.target.value),Ve),children:[Xe?null:C.jsx("option",{value:"",disabled:!0,className:rt,children:we("month",lr(X,de,1))}),qe.map(I=>C.jsx("option",{value:I.value,disabled:!st(X,I.value,Ve),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]}),C.jsxs("select",{"aria-label":K.splitDay,disabled:g,className:`${$n} rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-center font-mono text-gray-900 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:ht?Ve:"",onChange:I=>oe(X,de,Number(I.target.value)),children:[ht?null:C.jsx("option",{value:"",disabled:!0,className:rt,children:we("day",lr(X,de,Ve))}),Ue.map(I=>C.jsx("option",{value:I.value,disabled:!st(X,de,I.value),className:"dark:bg-slate-700 dark:text-slate-100",children:I.label},I.value))]})]}):C.jsx("input",{"aria-label":K.dateSelect,disabled:g,className:`period-slider-native-date-field ${Oo} rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 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:ke,min:ye,max:bt,onChange:O,type:"date"}),C.jsx(Tr,{neighbour:"control",direction:"right",glyph:ue,disabled:g,canStep:o===void 0?Fe!==null:o.canStepNext,onStep:ge,ariaLabel:K.nextDay}),i]})},Nd=(e,t)=>!(!gi(e,t,t.variant==="split-dropdown"?Ad:vi)||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.stepGlyph!==t.stepGlyph||e.allowedDates!==t.allowedDates||e.children!==t.children||e.locale!==t.locale||!Bo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),zl=s.memo(kd,Nd);zl.displayName="DateSelector";function Bn(e,t){const r=e+Math.floor(t/12),n=(t%12+12)%12,o=new Date(0);return o.setHours(0,0,0,0),o.setFullYear(r,n,1),o}function _n(e){const t=zn(e,"month",0);return se("month",t===null?Number.NaN:t,0)}const Bl=e=>ea(e,"month",0);function Lr(e){return`${qo(e.getFullYear())}-${String(e.getMonth()+1).padStart(2,"0")}`}const Js=Un("leave the bound out where the variant allows it, or declare the months to offer with minYear / maxYear or allowedMonths");function vo(e,t,r){e!==void 0&&Wl(e,t,r)}function Wl(e,t,r){if(!De(e))throw new RangeError(`MonthSelector: ${t} must be a valid Date (received: ${y(e)})`);Ke("MonthSelector",t,e,"month",0,r)}function el(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(Bn(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 Od(e,t){const r=e===void 0?null:Bn(e,0),n=t===void 0?null:_n(t);return r!==null&&n!==null?r>=n?r:n:r!==null?r:n}function Vd(e,t){const r=e===void 0?null:Bn(e,11),n=t===void 0?null:_n(t);return r!==null&&n!==null?r<=n?r:n:r!==null?r:n}function cr(e){return e.getFullYear()*12+e.getMonth()}function ti(e){return Bn(Math.floor(e/12),(e%12+12)%12)}function tl(e){return Number.isNaN(e.getTime())?null:e}function _d(e,t,r){const n=new Map;for(const o of e){const a=_n(o);t!==null&&a<t||r!==null&&a>r||n.has(a.getTime())||n.set(a.getTime(),a)}return Array.from(n.values()).sort((o,a)=>o.getTime()-a.getTime())}function Yd(e,t){const r=[];for(let n=cr(e);n<=cr(t);n++)r.push(ti(n));return r}function rl(e,t,r){const n=[];for(let o=e.length-1;o>=0;o--)n.push({label:it("month",e[o],r,t),value:Lr(e[o])});return n}const Hd=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,variant:l="date",minYear:u,maxYear:d,minDate:m,maxDate:R,allowedMonths:L,isWarning:T=!1,className:b="",style:g,disabled:w=!1,locale:h,labels:D,formatLocale:M,formatOption:v}=e;if(M!==void 0&&Jo("MonthSelector","formatLocale",M),vo(t,"value",""),vo(r,"initialDate",""),vo(m,"minDate",Js),vo(R,"maxDate",Js),el(u,"minYear",0),el(d,"maxYear",11),sn("MonthSelector","allowedMonths",L),L!==void 0)for(let oe=0;oe<L.length;oe++)Wl(L[oe],`allowedMonths[${oe}]`,"");const f=t??r;if(f===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&&pi("MonthSelector",o,t!==void 0);const ue=ui("MonthSelector",a),K=Wo(h,D),re=t!==void 0,[ee,B]=bi(f,re,Bl,_n),ne=s.useMemo(()=>t!==void 0?_n(t):ee,[t?.getTime(),ee]),k=m?.getTime(),q=R?.getTime(),j=s.useMemo(()=>Od(u,m),[u,k]),A=s.useMemo(()=>Vd(d,R),[d,q]),$=j?.getTime()??null,H=A?.getTime()??null;if(j!==null&&A!==null&&j>A)throw new RangeError(`MonthSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${Lr(j)}, upper: ${Lr(A)})`);if(l==="dropdown"&&L===void 0&&(j===null||A===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 Y=L===void 0?null:L.map(oe=>oe.getTime()).join(","),N=s.useMemo(()=>L===void 0?null:_d(L,j,A),[Y,$,H]),F=s.useMemo(()=>{if(N!==null){const oe=N.map(cr);return{kind:"candidates",ascending:oe,loIndex:0,hiIndex:oe.length-1}}return{kind:"range",min:j===null?null:cr(j),max:A===null?null:cr(A)}},[N,$,H]),G=oe=>!Number.isNaN(oe.getTime())&&An(F,cr(oe)),he=oe=>{if(w)return;if(!G(oe))throw new RangeError(`MonthSelector: refusing to emit ${Lr(oe)}, which lies outside the selectable months`);re||B(oe);const pt=oe.getFullYear()*100+(oe.getMonth()+1);n?.(oe,pt)},te=ne.getTime(),le=G(ne),Se=s.useMemo(()=>{const oe=Zt(F,cr(ne),-1);return oe===null?null:tl(ti(oe))},[F,te]),ae=s.useMemo(()=>{const oe=Zt(F,cr(ne),1);return oe===null?null:tl(ti(oe))},[F,te]),ie=()=>{if(o!==void 0){o.onStep("previous");return}Se!==null&&he(Se)},pe=()=>{if(o!==void 0){o.onStep("next");return}ae!==null&&he(ae)},Fe=oe=>{if(!oe)return;const pt=oe.lastIndexOf("-");if(pt<=0)return;const Xe=oe.slice(0,pt),ht=oe.slice(pt+1),ke=Number(Xe),Ge=Number(ht)-1;if(!(Number.isInteger(ke)&&Number.isInteger(Ge)))return;const ye=Bn(ke,Ge);G(ye)&&he(ye)},ft=oe=>{Fe(oe.target.value)},ge=oe=>{Fe(oe.target.value)},O=Lr(ne),X=l==="dropdown"&&!le?it("month",ne,v,M):"",de=j?Lr(j):void 0,Ve=A?Lr(A):void 0,we=s.useMemo(()=>l!=="dropdown"?[]:N!==null?rl(N,M,v):j===null||A===null?[]:rl(Yd(j,A),M,v),[l,N,$,H,M,v]),tt=le?O:"",qe=T?"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",Ue=`period-slider-native-date-field ${Oo} rounded-md border py-0.5 px-1 text-center font-mono tabular-nums dark:placeholder:text-gray-400 disabled:opacity-50 ${qe}`,st=`${Oo} appearance-none rounded-md border px-1 py-0.5 text-center font-mono tabular-nums [text-align-last:center] [text-align:center] disabled:opacity-50 ${qe}`;return C.jsxs("div",{className:`inline-flex items-center ${Cn} ${b}`,style:g,"data-out-of-range":le?void 0:"true",children:[C.jsx(Tr,{neighbour:"control",direction:"left",glyph:ue,disabled:w,canStep:o===void 0?Se!==null:o.canStepPrevious,onStep:ie,ariaLabel:K.previousMonth}),l==="dropdown"?C.jsxs("select",{"aria-label":K.monthSelect,disabled:w,className:st,value:tt,onChange:ge,children:[le?null:C.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:X}),we.map(oe=>C.jsx("option",{value:oe.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:oe.label},oe.value))]}):C.jsx("input",{"aria-label":K.monthSelect,disabled:w,className:Ue,value:O,min:de,max:Ve,onChange:ft,type:"month"}),C.jsx(Tr,{neighbour:"control",direction:"right",glyph:ue,disabled:w,canStep:o===void 0?ae!==null:o.canStepNext,onStep:pe,ariaLabel:K.nextMonth}),i]})},jd=(e,t)=>!(!gi(e,t,Bl)||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.stepGlyph!==t.stepGlyph||e.children!==t.children||e.locale!==t.locale||!Bo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption),Gl=s.memo(Hd,jd);Gl.displayName="MonthSelector";const ri=Symbol("nothing handed");let Ua=0;class Fd{constructor(t,r,n,o){this.states=t,this.base=r,this.superseded=n,this.setMark=o}states;base;superseded;setMark;drafts=new Map;handed=new Map;cells=new Set;notes=[];closed=!1;marked=!1;committed=!1;record(){this.marked||(this.marked=!0,this.setMark(this))}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),this.record()}hand(t,r){this.handed.set(t.slot,r),this.cells.add(t),this.record()}note(t){this.notes.push(t),this.record()}hasHanded(t){return this.handed.has(t)}lastHanded(t){return this.handed.get(t)}close(){this.closed=!0}}class Ud{constructor(t,r,n){this.owner=t,this.setMark=n,this.slotWrites=r.map(()=>0),this.records=r.map(()=>ri),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: ${y(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)`);const n=this.active;this.active=r,Ua+=1;try{t()}finally{Ua-=1,this.active=n}};get pass(){if(this.active===null&&Ua>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]!==ri&&this.records[a]!==o),n=new Fd(t,[...this.slotWrites],r,this.setMark);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.note({slot:t,send:r});return}this.deliver(),r()}}class zd extends _l{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,ri)}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 Bd{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 Wd=(e,t)=>t;function ta(e,t){const[r,n]=s.useReducer(Wd,null),[o]=s.useState(()=>new Ud(e,t,n)),a=o.begin(t,r);return s.useInsertionEffect(()=>{o.commit(a,t)}),s.useLayoutEffect(()=>{o.deliver()}),o}function Jr(e,t,r,n){const o=Yl(r,a=>new zd(a,e,t));return s.useLayoutEffect(()=>{o.recordAdopted(n)}),o}function en(e,t,r){const[n]=s.useState(()=>new Bd(r,e,t));return n}function Ae(e,t,r){return e<t?t:e>r?r:e}const Gd=ln([],null,null);function Yn(e,t,r,n){return r===null?Gd:ni(r,U(t,e[0],n),U(t,e[1],n))}function $r(e,t,r,n,o){const a=U(t,e,o),i=oi(n)?null:kn(n,a);return i===null?a<U(t,r[0],o)?r[0]:a>U(t,r[1],o)?r[1]:e:i===a?e:se(t,i,o)}function Zr(e,t,r,n,o,a){const i=U(t,e[0],o),l=U(t,e[1],o),u=yo(a,{kind:"range",min:U(t,r[0],o),max:U(t,r[1],o)},i,l);if(u===null)return e;const d=$r(u[0]===i?e[0]:se(t,u[0],o),t,r,n,o),m=$r(u[1]===l?e[1]:se(t,u[1],o),t,r,n,o);return[d,m<d?d:m]}const nl=(e,t,r,n,o,a,i)=>{if(sn(e,t,r),r===void 0||r.length===0)return null;const l=ln(Hl(e,t,r,n,i),U(n,o,i),U(n,a,i));if(l.hiIndex<l.loIndex)throw new RangeError(`${e}: every ${t} entry falls outside [minDate, maxDate] (minDate: ${y(o)}, maxDate: ${y(a)}, entries: ${r.length})`);return l},ni=(e,t,r)=>{const n=ln(e.ascending,t,r);return{kind:"candidates",ascending:e.ascending,loIndex:Math.max(e.loIndex,n.loIndex),hiIndex:Math.min(e.hiIndex,n.hiIndex)}},oi=e=>e.hiIndex<e.loIndex,Kd=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=In(n,t);o!==null&&(r===null||(t===1?o>r:o<r))&&(r=o)}return r}}),Et=(e,t)=>e[0].getTime()===t[0].getTime()&&e[1].getTime()===t[1].getTime(),ol=(e,t,r,n,o)=>{if(!kt(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]},ur=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:l,macroRange:u,microSelection:d}=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)})`);Le(t,"macroUnit",o),Le(t,"microUnit",a);const m=gr(t,e.yearStartMonth);for(const[k,q]of[["minDate",i],["maxDate",l]])if(!De(q))throw new RangeError(`${t}: ${k} must be a valid Date (received: ${y(q)})`);if(l.getTime()<=i.getTime())throw new RangeError(`${t}: maxDate must be strictly later than minDate (minDate: ${y(i)}, maxDate: ${y(l)})`);qt(t,"minDate",i,o,m),qt(t,"minDate",i,a,m),Cr(t,"rules",e.rules,r==="macro"?"motion":"vernierRange");const R=ol(t,"macroRange",u,o,m);if(u[1].getTime()<u[0].getTime())throw new RangeError(`${t}: macroRange must not be inverted (start: ${y(u[0])}, end: ${y(u[1])})`);const L=ol(t,"microSelection",d,a,m),T=nl(t,"macroAllowedDates",e.macroAllowedDates,o,i,l,m),b=nl(t,"microAllowedDates",e.microAllowedDates,a,i,l,m),g=[u[0],u[1]],w=[d[0],d[1]],h=k=>{const q=$t(o,a,[k[0],k[1]],i,l,m);return[U(a,q[0],m),U(a,q[1],m)]},D=(k,q)=>{if(b!==null){const j=ni(b,k,q);if(!oi(j))return j}return{kind:"range",min:k,max:q}},M=(k,q)=>{const j=Et(k,g)?g:k;return j===g&&Et(q,w)?null:{macroRange:j,microSelection:q}};if(e.row==="macro"){const k=T??{kind:"range",min:U(o,i,m),max:U(o,l,m)},q=Mo(k),j=($,H)=>{const Y=$t(o,a,$,i,l,m);return Zr(w,a,Y,Yn(Y,a,b,m),m,H)},A=($,H)=>{const Y=Wa(q,R[0],R[1],$,Za(H,n));if(Y===null)return null;const N=Qa(Y,R,g,o,m,H.motion==="single");if(N===null)return null;const F=[Ae(N[0],i,l),Ae(N[1],i,l)],G=Math.sign(Y[0]-R[0])===$&&Math.sign(Y[1]-R[1])===$;return M(F,j(F,G?"pan":"resize"))};return{previous:A(-1,e.rules.previous),next:A(1,e.rules.next)}}const v=h(g);let f=[U(a,i,m),U(a,l,m)];if(T!==null){const k=h([se(o,T.ascending[T.loIndex],m),se(o,T.ascending[T.hiIndex],m)]);f=[Math.min(k[0],v[0]),Math.max(k[1],v[1])]}const ue=b===null?null:ni(b,f[0],f[1]);let K=Mo({kind:"range",min:f[0],max:f[1]});if(ue!==null&&!oi(ue)){const k=D(v[0],v[1]);K=k.kind==="candidates"?Mo(ue):Kd([ue,k])}const re=k=>{if(T===null)return[Ae(xt(o,k[0],m),i,l),Ae(xt(o,k[1],m),i,l)];const q=xo(T,U(o,k[0],m),-1),j=xo(T,U(o,k[1],m),1);return q===null||j===null?null:[Ae(se(o,q,m),i,l),Ae(se(o,j,m),i,l)]},ee=(k,q,j)=>{const[A,$]=h(k),H=D(A,$),Y=G=>{const he=U(a,G,m);if(An(H,he))return G;const te=xo(H,he,j);return te===null?null:se(a,te,m)},N=Y(q[0]),F=Y(q[1]);return N===null||F===null?null:[N,F.getTime()<N.getTime()?N:F]},B=(k,q)=>k>=v[0]&&q<=v[1],ne=(k,q)=>{const j=Wa(K,L[0],L[1],k,Za(q,n));if(j===null)return null;const A=Qa(j,L,w,a,m,q.motion==="single");if(A===null)return null;const $=q.window!=="follow",H=$&&B(j[0],j[1])?g:re(A);if(H===null)return null;const Y=ee(H,A,k);if(Y===null)return null;const N=$&&B(U(a,Y[0],m),U(a,Y[1],m))?g:re(Y);return N===null?null:M(N,Y)};return{previous:ne(-1,e.rules.previous),next:ne(1,e.rules.next)}};function ai(e,t,r){if(!De(r))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${y(r)})`)}function Ee(e,t,r,n,o){ai(e,t,r),Ke(e,t,r,n,o,"")}function ra(e,t,r,n,o){if(ai(e,"minDate",t),ai(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)Ke(e,"minDate",t,a,o,wl)}function dr(e,t,r,n,o){if(!kt(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${y(r)})`);if(Ee(e,`${t}[0]`,r[0],n,o),Ee(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 Vo(e,t,r,n,o,a,i,l){const u=U(r,n,l);if(u<U(r,o,l)||u>U(r,a,l))throw new RangeError(`${e}: ${t} must lie within ${i} (value: ${y(n)}, lower: ${y(o)}, upper: ${y(a)})`)}function _o(e,t,r,n,o,a,i,l){Vo(e,`${t}[0]`,r,n[0],o,a,i,l),Vo(e,`${t}[1]`,r,n[1],o,a,i,l)}function Yo(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 tn(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=vl(e,t,r);return De(i)&&zn(i,e,a)!==null?{date:i,pastDateRange:!1}:{date:r>0?o:n,pastDateRange:!0}}function Ho(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 Tn(e,t,r,n,o,a){const i=Ae(e,r,n);if(o.length===0)return i;const l=o[Me(o,i,t,a)];return U(t,l,a)===U(t,i,a)?i:Ae(l,r,n)}function za(e,t,r,n,o,a){const i=Tn(e[0],t,r,n,o,a),l=Tn(e[1],t,r,n,o,a);return[i,l<i?i:l]}function Hn(e,t){return t[0]===e[0]&&t[1]===e[1]?e:t}const qd={year:"allowedYears",month:"allowedMonths",day:"allowedDates"};function zt(e,t){return t.length===0?{}:{[qd[e]]:t}}function na(e){const t=s.useRef(e),r=t.current,n=e,o=Object.keys(r),a=Object.keys(n);return o.length===a.length&&a.every(l=>Object.is(r[l],n[l]))||(t.current=e),t.current}const Xt={previous:null,next:null},Xd=["motion","edge","window"];function jn(e){const t=s.useRef(e),r=t.current;return r===e||r!==void 0&&e!==void 0&&["previous","next"].every(o=>Xd.every(a=>r[o][a]===e[o][a]))||(t.current=e),t.current}const $o=(e,t)=>e.getTime()===t.getTime();function rn(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 nn(e,t,r){e.current=t,e.hand(t),r(t)}function Zd(e,t){return typeof t=="function"?t(e):t}function on(e){return s.useReducer(Zd,void 0,e)}function an(e,t,r,n){r===t||e.current!==r||(e.forgetHanded(t),n(o=>o===t?r:o))}function Qd(e){const{unit:t,minDate:r,maxDate:n,initialRange:o,onChangeRange:a,yearStartMonth:i,formatOption:l,selectorStep:u,...d}=e;Le("usePeriodSliderRange","unit",t);const m=gr("usePeriodSliderRange",i);ra("usePeriodSliderRange",r,n,[t],m),dr("usePeriodSliderRange","initialRange",o,t,m),u!==void 0&&Cr("usePeriodSliderRange","selectorStep",u,"motion");const R=na(d),L=r.getTime(),T=n.getTime(),b=s.useMemo(()=>fr("usePeriodSliderRange",Xo(R.allowedDates),t,r,n,m).dates,[R.allowedDates,t,L,T,m]),g=s.useRef(o),[w,h]=on(()=>(_o("usePeriodSliderRange","initialRange",t,o,r,n,"[minDate, maxDate]",m),Hn(o,za(o,t,r,n,b,m)))),D=ta("usePeriodSliderRange",[w]);dr("usePeriodSliderRange","range",w,t,m);const M=Hn(w,za(w,t,r,n,b,m)),v=Jr(D,0,M,h);s.useLayoutEffect(()=>{an(v,w,M,h)});const f=en(D,0,o),ue=mt({minDate:r,maxDate:n,candidates:b}),K=mt(a),re=s.useCallback(te=>{const{minDate:le,maxDate:Se,candidates:ae}=ue.current,ie=za(te,t,le,Se,ae,m);rn(v,ie,Et,h);const pe=f.current;ie[0].getTime()===pe[0].getTime()&&ie[1].getTime()===pe[1].getTime()||(f.current=ie,D.notify(0,()=>K.current?.(ie[0],ie[1])))},[t,m]),ee=s.useCallback(te=>{const le=typeof te=="function"?te(v.current):te;f.current=le,nn(v,le,h)},[]),B=s.useCallback(te=>{Ee("usePeriodSliderRange","setLowerDate(date)",te,t,m);const le=v.current,Se=te.getTime()>le[1].getTime()?te:le[1];re([te,Se])},[re,t,m]),ne=s.useCallback(te=>{Ee("usePeriodSliderRange","setUpperDate(date)",te,t,m);const le=v.current,Se=te.getTime()<le[0].getTime()?te:le[0];re([Se,te])},[re,t,m]),k=s.useCallback((te,le)=>{Ee("usePeriodSliderRange","sliderProps.onChangeRange(lower)",te,t,m),Ee("usePeriodSliderRange","sliderProps.onChangeRange(upper)",le,t,m),Yo("usePeriodSliderRange","sliderProps.onChangeRange",te,le),re([te,le])},[re,t,m]),q=s.useCallback(te=>{tn("usePeriodSliderRange","shiftRange",te);const{minDate:le,maxDate:Se,candidates:ae}=ue.current,ie=v.current;if(ae.length>0){re([Ho(ae,t,ie[0],te,m),Ho(ae,t,ie[1],te,m)]);return}re([Ut(t,ie[0],te,le,Se,m).date,Ut(t,ie[1],te,le,Se,m).date])},[t,re,m]),j=s.useCallback(()=>{re(g.current)},[re]),A=jn(u),$=A!==void 0,H=s.useMemo(()=>{if(A===void 0)return{start:Xt,end:Xt};const te=b.length>0?R.allowedDates:void 0,le={selection:M,unit:t,yearStartMonth:m,minDate:r,maxDate:n,allowedDates:te,rules:A};return{start:Ja({...le,shows:"start"}),end:Ja({...le,shows:"end"})}},[A,M,t,m,L,T,b,R.allowedDates]),Y=Ft(H.start,re),N=Ft(H.end,re),F=s.useMemo(()=>({value:M[0],onChange:B,minDate:r,maxDate:M[1],unit:t,yearStartMonth:m,...zt(t,b),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...$?{stepper:Y}:{}}),[M[0],M[1],B,r,t,m,b,e.formatLocale,e.locale,e.labels,l,$,Y]),G=s.useMemo(()=>({value:M[1],onChange:ne,minDate:M[0],maxDate:n,unit:t,yearStartMonth:m,...zt(t,b),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l,...$?{stepper:N}:{}}),[M[0],M[1],ne,n,t,m,b,e.formatLocale,e.locale,e.labels,l,$,N]),he=s.useMemo(()=>({...R,mode:"range",unit:t,yearStartMonth:m,range:M,minDate:r,maxDate:n,onChangeRange:k}),[R,t,M,r,n,k,m]);return{range:M,lowerDate:M[0],upperDate:M[1],setRange:ee,setLowerDate:B,setUpperDate:ne,shiftRange:q,resetRange:j,startSelectorProps:F,endSelectorProps:G,sliderProps:he,duringRender:D.duringRender}}function Jd(e){const{unit:t,minDate:r,maxDate:n,initialValue:o,onChangePoint:a,yearStartMonth:i,formatOption:l,...u}=e;Le("usePeriodSliderPoint","unit",t);const d=gr("usePeriodSliderPoint",i);ra("usePeriodSliderPoint",r,n,[t],d),Ee("usePeriodSliderPoint","initialValue",o,t,d);const m=na(u),R=r.getTime(),L=n.getTime(),T=s.useMemo(()=>fr("usePeriodSliderPoint",Xo(m.allowedDates),t,r,n,d).dates,[m.allowedDates,t,R,L,d]),b=s.useRef(o),[g,w]=on(()=>(Vo("usePeriodSliderPoint","initialValue",t,o,r,n,"[minDate, maxDate]",d),Tn(o,t,r,n,T,d))),h=ta("usePeriodSliderPoint",[g]);Ee("usePeriodSliderPoint","value",g,t,d);const D=Tn(g,t,r,n,T,d),M=Jr(h,0,D,w);s.useLayoutEffect(()=>{an(M,g,D,w)});const v=en(h,0,o),f=mt({minDate:r,maxDate:n,candidates:T}),ue=mt(a),K=s.useCallback(A=>{const{minDate:$,maxDate:H,candidates:Y}=f.current,N=Tn(A,t,$,H,Y,d);rn(M,N,$o,w),N.getTime()!==v.current.getTime()&&(v.current=N,h.notify(0,()=>ue.current?.(N)))},[t,d]),re=s.useCallback(A=>{const $=typeof A=="function"?A(M.current):A;v.current=$,nn(M,$,w)},[]),ee=s.useCallback(A=>{Ee("usePeriodSliderPoint","selectorProps.onChange(date)",A,t,d),K(A)},[K,t,d]),B=s.useCallback(A=>{Ee("usePeriodSliderPoint","sliderProps.onChangePoint(value)",A,t,d),K(A)},[K,t,d]),ne=s.useCallback(A=>{tn("usePeriodSliderPoint","shiftValue",A);const{minDate:$,maxDate:H,candidates:Y}=f.current;if(Y.length>0){K(Ho(Y,t,M.current,A,d));return}K(Ut(t,M.current,A,$,H,d).date)},[t,K,d]),k=s.useCallback(()=>{K(b.current)},[K]),q=s.useMemo(()=>({value:D,onChange:ee,minDate:r,maxDate:n,unit:t,yearStartMonth:d,...zt(t,T),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:l}),[D,ee,r,n,t,d,T,e.formatLocale,e.locale,e.labels,l]),j=s.useMemo(()=>({...m,mode:"point",unit:t,yearStartMonth:d,value:D,minDate:r,maxDate:n,onChangePoint:B}),[m,t,D,r,n,B,d]);return{value:D,setValue:re,shiftValue:ne,resetValue:k,selectorProps:q,sliderProps:j,duringRender:h.duringRender}}function em(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroRange:a,macroUnit:i,microUnit:l,onChangeMacroRange:u,onChangeMicroRange:d,yearStartMonth:m,formatOption:R,macroSelectorStep:L,microSelectorStep:T,...b}=e;Le("useVernierSliderRange","unit",t);const g=Qt("useVernierSliderRange","macroUnit",i,t),w=Qt("useVernierSliderRange","microUnit",l,t),h=gr("useVernierSliderRange",m);ra("useVernierSliderRange",r,n,[g,w,t],h),dr("useVernierSliderRange","initialMacroRange",o,g,h),dr("useVernierSliderRange","initialMicroRange",a,w,h),L!==void 0&&Cr("useVernierSliderRange","macroSelectorStep",L,"motion"),T!==void 0&&Cr("useVernierSliderRange","microSelectorStep",T,"vernierRange");const D=na(b),M=s.useRef(o),v=s.useRef(a),[f,ue]=on(()=>(_o("useVernierSliderRange","initialMacroRange",g,o,r,n,"[minDate, maxDate]",h),o)),[K,re]=on(()=>{const E=$t(g,w,o,r,n,h);return _o("useVernierSliderRange","initialMicroRange",w,a,E[0],E[1],"the initial macro window",h),a}),ee=ta("useVernierSliderRange",[f,K]);dr("useVernierSliderRange","macroRange",f,g,h);const B=Hn(f,[Ae(f[0],r,n),Ae(f[1],r,n)]),ne=r.getTime(),k=n.getTime(),q=s.useMemo(()=>$t(g,w,B,r,n,h),[g,w,B,ne,k,h]),j=s.useMemo(()=>jt("micro",D)?mi("useVernierSliderRange",Lt("micro",D),w,r,n,h):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,w,ne,k,h]),A=s.useMemo(()=>jt("macro",D)?fr("useVernierSliderRange",Lt("macro",D),g,r,n,h).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,g,ne,k,h]),$=mt(A),H=s.useMemo(()=>Yn(q,w,j,h),[q,w,j,h]),Y=s.useMemo(()=>On(j,H),[j,H]);dr("useVernierSliderRange","microRange",K,w,h);const N=Hn(K,Zr(K,w,q,H,h,"resize")),F=Jr(ee,0,B,ue),G=Jr(ee,1,N,re);s.useLayoutEffect(()=>{an(F,f,B,ue),an(G,K,N,re)});const he=en(ee,1,a),te=en(ee,0,o),le=mt({minDate:r,maxDate:n}),Se=mt(u),ae=mt(d),ie=s.useCallback(E=>{const{minDate:z,maxDate:ce}=le.current;return $t(g,w,E,z,ce,h)},[g,w,h]),pe=s.useCallback(E=>Yn(E,w,j,h),[w,j,h]),Fe=s.useCallback(E=>{rn(F,E,Et,ue);const z=te.current;E[0].getTime()===z[0].getTime()&&E[1].getTime()===z[1].getTime()||(te.current=E,ee.notify(0,()=>Se.current?.(E[0],E[1])))},[]),ft=s.useCallback(E=>{const z=typeof E=="function"?E(F.current):E;te.current=z,nn(F,z,ue)},[]),ge=s.useCallback((E,z,ce)=>{const Ne=ce==="micro"&&Et(F.current,E)&&Et(te.current,E),Te=ce==="macro"&&Et(G.current,z)&&Et(he.current,z);if(Ne||Fe(E),Te)return;rn(G,z,Et,re);const Oe=he.current;(z[0].getTime()!==Oe[0].getTime()||z[1].getTime()!==Oe[1].getTime())&&(he.current=z,ee.notify(1,()=>ae.current?.(z[0],z[1])))},[Fe]),O=s.useCallback(E=>{const z=typeof E=="function"?E(G.current):E;he.current=z,nn(G,z,re)},[]),X=s.useCallback((E,z,ce)=>{const{minDate:Ne,maxDate:Te}=le.current,Oe=[Ae(E,Ne,Te),Ae(z,Ne,Te)],He=ie(Oe);ge(Oe,Zr(G.current,w,He,pe(He),h,ce),"macro")},[w,ie,pe,ge,h]),de=s.useCallback((E,z)=>X(E,z,"resize"),[X]),Ve=s.useCallback((E,z)=>{Ee("useVernierSliderRange","sliderProps.onChangeMacroRange(lower)",E,g,h),Ee("useVernierSliderRange","sliderProps.onChangeMacroRange(upper)",z,g,h),Yo("useVernierSliderRange","sliderProps.onChangeMacroRange",E,z);const{minDate:ce,maxDate:Ne}=le.current,Te=[Ae(E,ce,Ne),Ae(z,ce,Ne)],Oe=G.current,He=ie(Te),Tt=Zr(Oe,w,He,pe(He),h,"resize");if(Tt[0].getTime()!==Oe[0].getTime()||Tt[1].getTime()!==Oe[1].getTime()){Fe(Te);return}ge(Te,Oe,"macro")},[g,w,ie,pe,Fe,ge,h]),we=s.useCallback((E,z)=>{const ce=ie(F.current);ge(F.current,Zr([E,z],w,ce,pe(ce),h,"resize"),"micro")},[w,ie,pe,ge,h]),tt=s.useCallback((E,z)=>{Ee("useVernierSliderRange","sliderProps.onChangeMicroRange(lower)",E,w,h),Ee("useVernierSliderRange","sliderProps.onChangeMicroRange(upper)",z,w,h),Yo("useVernierSliderRange","sliderProps.onChangeMicroRange",E,z),we(E,z)},[we,w,h]),qe=s.useCallback(E=>{Ee("useVernierSliderRange","setMacroLowerDate(date)",E,g,h);const z=F.current[1],ce=E>z?E:z;de(E,ce)},[de,g,h]),Ue=s.useCallback(E=>{Ee("useVernierSliderRange","setMacroUpperDate(date)",E,g,h);const z=F.current[0],ce=E<z?E:z;de(ce,E)},[de,g,h]),st=s.useCallback(E=>{Ee("useVernierSliderRange","setMicroLowerDate(date)",E,w,h);const z=G.current[1],ce=E>z?E:z;we(E,ce)},[we,w,h]),oe=s.useCallback(E=>{Ee("useVernierSliderRange","setMicroUpperDate(date)",E,w,h);const z=G.current[0],ce=E<z?E:z;we(ce,E)},[we,w,h]),pt=s.useCallback(E=>{tn("useVernierSliderRange","shiftMacroRange",E);const{minDate:z,maxDate:ce}=le.current,Ne=F.current,Te=$.current;if(Te.length>0){const Tt=Me(Te,Ne[0],g,h)+E,Jt=Me(Te,Ne[1],g,h)+E;if(Tt<0||Jt>Te.length-1)return;X(Te[Tt],Te[Jt],"pan");return}const Oe=Ut(g,Ne[0],E,z,ce,h),He=Ut(g,Ne[1],E,z,ce,h);Oe.pastDateRange||He.pastDateRange||Oe.date<z||He.date>ce||X(Oe.date,He.date,"pan")},[g,X,h]),Xe=s.useCallback(E=>{tn("useVernierSliderRange","shiftMicroRange",E);const z=F.current,ce=G.current,Ne=ie(z),[Te,Oe]=Ne,He=On(j,pe(Ne));if(He.length>0){const nt=Me(He,ce[0],w,h)+E,pr=Me(He,ce[1],w,h)+E;if(nt<0||pr>He.length-1)return;we(He[nt],He[pr]);return}const Tt=Ut(w,ce[0],E,Te,Oe,h),Jt=Ut(w,ce[1],E,Te,Oe,h);Tt.pastDateRange||Jt.pastDateRange||U(w,Tt.date,h)<U(w,Te,h)||U(w,Jt.date,h)>U(w,Oe,h)||we(Tt.date,Jt.date)},[w,j,ie,pe,we,h]),ht=s.useCallback(()=>{const{minDate:E,maxDate:z}=le.current,ce=[Ae(M.current[0],E,z),Ae(M.current[1],E,z)],Ne=ie(ce);ge(ce,Zr(v.current,w,Ne,pe(Ne),h,"resize"),"both")},[w,ie,pe,ge,h]),ke=jn(L),Ge=jn(T),ye=ke!==void 0,bt=Ge!==void 0,rt=s.useMemo(()=>{const E={macroUnit:g,microUnit:w,yearStartMonth:h,minDate:r,maxDate:n,macroRange:B,microSelection:N,macroAllowedDates:jt("macro",D)?Lt("macro",D).list:void 0,microAllowedDates:jt("micro",D)?Lt("micro",D).list:void 0};return{macroStart:ke===void 0?Xt:ur({...E,row:"macro",shows:"start",rules:ke}),macroEnd:ke===void 0?Xt:ur({...E,row:"macro",shows:"end",rules:ke}),microStart:Ge===void 0?Xt:ur({...E,row:"micro",shows:"start",rules:Ge}),microEnd:Ge===void 0?Xt:ur({...E,row:"micro",shows:"end",rules:Ge})}},[ke,Ge,g,w,h,ne,k,B,N,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),Ot=s.useCallback(E=>ge(E.macroRange,E.microSelection,"macro"),[ge]),I=s.useCallback(E=>ge(E.macroRange,E.microSelection,"micro"),[ge]),J=Ft(rt.macroStart,Ot),Ye=Ft(rt.macroEnd,Ot),lt=Ft(rt.microStart,I),ze=Ft(rt.microEnd,I),[xe,$e]=q,Ir=s.useMemo(()=>({value:B[0],onChange:qe,minDate:r,maxDate:B[1],unit:g,yearStartMonth:h,...zt(g,A),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...ye?{stepper:J}:{}}),[B,qe,r,g,h,A,e.formatLocale,e.locale,e.labels,R,ye,J]),_=s.useMemo(()=>({value:B[1],onChange:Ue,minDate:B[0],maxDate:n,unit:g,yearStartMonth:h,...zt(g,A),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...ye?{stepper:Ye}:{}}),[B,Ue,n,g,h,A,e.formatLocale,e.locale,e.labels,R,ye,Ye]),P=s.useMemo(()=>({value:N[0],onChange:st,minDate:xe,maxDate:N[1],unit:w,yearStartMonth:h,...zt(w,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...bt?{stepper:lt}:{}}),[N,st,xe,w,h,Y,e.formatLocale,e.locale,e.labels,R,bt,lt]),Re=s.useMemo(()=>({value:N[1],onChange:oe,minDate:N[0],maxDate:$e,unit:w,yearStartMonth:h,...zt(w,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...bt?{stepper:ze}:{}}),[N,oe,$e,w,h,Y,e.formatLocale,e.locale,e.labels,R,bt,ze]),_e=s.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:g,microUnit:w,minDate:r,maxDate:n,macroRange:B,microRange:N,onChangeMacroRange:Ve,onChangeMicroRange:tt}),[D,t,g,w,r,n,B,N,Ve,tt,h]);return{macroRange:B,setMacroRange:ft,microRange:N,setMicroRange:O,setMacroLowerDate:qe,setMacroUpperDate:Ue,setMicroLowerDate:st,setMicroUpperDate:oe,shiftMacroRange:pt,shiftMicroRange:Xe,resetVernier:ht,macroStartSelectorProps:Ir,macroEndSelectorProps:_,microStartSelectorProps:P,microEndSelectorProps:Re,sliderProps:_e,duringRender:ee.duringRender}}function tm(e){const{unit:t,minDate:r,maxDate:n,initialMacroRange:o,initialMicroValue:a,macroUnit:i,microUnit:l,onChangeMacroRange:u,onChangeMicroPoint:d,yearStartMonth:m,formatOption:R,macroSelectorStep:L,microSelectorStep:T,...b}=e;Le("useVernierSliderPoint","unit",t);const g=Qt("useVernierSliderPoint","macroUnit",i,t),w=Qt("useVernierSliderPoint","microUnit",l,t),h=gr("useVernierSliderPoint",m);ra("useVernierSliderPoint",r,n,[g,w,t],h),dr("useVernierSliderPoint","initialMacroRange",o,g,h),Ee("useVernierSliderPoint","initialMicroValue",a,w,h),L!==void 0&&Cr("useVernierSliderPoint","macroSelectorStep",L,"motion"),T!==void 0&&Cr("useVernierSliderPoint","microSelectorStep",T,"vernierPoint");const D=na(b),M=s.useRef(o),v=s.useRef(a),[f,ue]=on(()=>(_o("useVernierSliderPoint","initialMacroRange",g,o,r,n,"[minDate, maxDate]",h),o)),[K,re]=on(()=>{const _=$t(g,w,o,r,n,h);return Vo("useVernierSliderPoint","initialMicroValue",w,a,_[0],_[1],"the initial macro window",h),a}),ee=ta("useVernierSliderPoint",[f,K]);dr("useVernierSliderPoint","macroRange",f,g,h);const B=Hn(f,[Ae(f[0],r,n),Ae(f[1],r,n)]),ne=r.getTime(),k=n.getTime(),q=s.useMemo(()=>$t(g,w,B,r,n,h),[g,w,B,ne,k,h]),j=s.useMemo(()=>jt("micro",D)?mi("useVernierSliderPoint",Lt("micro",D),w,r,n,h):null,[D.microIsDiscrete,D.microAllowedDates,D.allowedDates,w,ne,k,h]),A=s.useMemo(()=>jt("macro",D)?fr("useVernierSliderPoint",Lt("macro",D),g,r,n,h).dates:[],[D.macroIsDiscrete,D.macroAllowedDates,D.allowedDates,g,ne,k,h]),$=mt(A),H=s.useMemo(()=>Yn(q,w,j,h),[q,w,j,h]),Y=s.useMemo(()=>On(j,H),[j,H]);Ee("useVernierSliderPoint","microValue",K,w,h);const N=$r(K,w,q,H,h),F=Jr(ee,0,B,ue),G=Jr(ee,1,N,re);s.useLayoutEffect(()=>{an(F,f,B,ue),an(G,K,N,re)});const he=en(ee,1,a),te=en(ee,0,o),le=mt({minDate:r,maxDate:n}),Se=mt(u),ae=mt(d),ie=s.useCallback(_=>{const{minDate:P,maxDate:Re}=le.current;return $t(g,w,_,P,Re,h)},[g,w,h]),pe=s.useCallback(_=>Yn(_,w,j,h),[w,j,h]),Fe=s.useCallback(_=>{rn(F,_,Et,ue);const P=te.current;_[0].getTime()===P[0].getTime()&&_[1].getTime()===P[1].getTime()||(te.current=_,ee.notify(0,()=>Se.current?.(_[0],_[1])))},[]),ft=s.useCallback(_=>{const P=typeof _=="function"?_(F.current):_;te.current=P,nn(F,P,ue)},[]),ge=s.useCallback((_,P,Re)=>{const _e=Re==="micro"&&Et(F.current,_)&&Et(te.current,_),E=Re==="macro"&&$o(G.current,P)&&$o(he.current,P);_e||Fe(_),!E&&(rn(G,P,$o,re),P.getTime()!==he.current.getTime()&&(he.current=P,ee.notify(1,()=>ae.current?.(P))))},[Fe]),O=s.useCallback(_=>{const P=typeof _=="function"?_(G.current):_;he.current=P,nn(G,P,re)},[]),X=s.useCallback((_,P)=>{const{minDate:Re,maxDate:_e}=le.current,E=[Ae(_,Re,_e),Ae(P,Re,_e)],z=ie(E);ge(E,$r(G.current,w,z,pe(z),h),"macro")},[w,ie,pe,ge,h]),de=s.useCallback(_=>{const P=ie(F.current);ge(F.current,$r(_,w,P,pe(P),h),"micro")},[w,ie,pe,ge,h]),Ve=s.useCallback((_,P)=>{Ee("useVernierSliderPoint","sliderProps.onChangeMacroRange(lower)",_,g,h),Ee("useVernierSliderPoint","sliderProps.onChangeMacroRange(upper)",P,g,h),Yo("useVernierSliderPoint","sliderProps.onChangeMacroRange",_,P);const{minDate:Re,maxDate:_e}=le.current,E=[Ae(_,Re,_e),Ae(P,Re,_e)],z=G.current,ce=ie(E);if($r(z,w,ce,pe(ce),h).getTime()!==z.getTime()){Fe(E);return}ge(E,z,"macro")},[g,w,ie,pe,Fe,ge,h]),we=s.useCallback(_=>{Ee("useVernierSliderPoint","sliderProps.onChangeMicroPoint(value)",_,w,h),de(_)},[de,w,h]),tt=s.useCallback(_=>{Ee("useVernierSliderPoint","setMacroLowerDate(date)",_,g,h);const P=F.current[1],Re=_>P?_:P;X(_,Re)},[X,g,h]),qe=s.useCallback(_=>{Ee("useVernierSliderPoint","setMacroUpperDate(date)",_,g,h);const P=F.current[0],Re=_<P?_:P;X(Re,_)},[X,g,h]),Ue=s.useCallback(_=>{Ee("useVernierSliderPoint","setMicroDate(date)",_,w,h),de(_)},[de,w,h]),st=s.useCallback(_=>{tn("useVernierSliderPoint","shiftMacroRange",_);const{minDate:P,maxDate:Re}=le.current,_e=F.current,E=$.current;if(E.length>0){const Ne=Me(E,_e[0],g,h)+_,Te=Me(E,_e[1],g,h)+_;if(Ne<0||Te>E.length-1)return;X(E[Ne],E[Te]);return}const z=Ut(g,_e[0],_,P,Re,h),ce=Ut(g,_e[1],_,P,Re,h);z.pastDateRange||ce.pastDateRange||z.date<P||ce.date>Re||X(z.date,ce.date)},[g,X,h]),oe=s.useCallback(_=>{tn("useVernierSliderPoint","shiftMicroValue",_);const P=F.current,Re=ie(P),_e=On(j,pe(Re));if(_e.length>0){de(Ho(_e,w,G.current,_,h));return}de(Ut(w,G.current,_,Re[0],Re[1],h).date)},[w,j,ie,pe,de,h]),pt=s.useCallback(()=>{const{minDate:_,maxDate:P}=le.current,Re=[Ae(M.current[0],_,P),Ae(M.current[1],_,P)],_e=ie(Re);ge(Re,$r(v.current,w,_e,pe(_e),h),"both")},[w,ie,pe,ge,h]),Xe=jn(L),ht=jn(T),ke=Xe!==void 0,Ge=ht!==void 0,ye=s.useMemo(()=>{const _={macroUnit:g,microUnit:w,yearStartMonth:h,minDate:r,maxDate:n,macroRange:B,microSelection:[N,N],macroAllowedDates:jt("macro",D)?Lt("macro",D).list:void 0,microAllowedDates:jt("micro",D)?Lt("micro",D).list:void 0};return{macroStart:Xe===void 0?Xt:ur({..._,row:"macro",shows:"start",rules:Xe}),macroEnd:Xe===void 0?Xt:ur({..._,row:"macro",shows:"end",rules:Xe}),micro:ht===void 0?Xt:ur({..._,row:"micro",shows:"end",rules:{previous:{motion:"shift",window:ht.previous.window},next:{motion:"shift",window:ht.next.window}}})}},[Xe,ht,g,w,h,ne,k,B,N,D.macroIsDiscrete,D.macroAllowedDates,D.microIsDiscrete,D.microAllowedDates,D.allowedDates]),bt=s.useCallback(_=>ge(_.macroRange,_.microSelection[0],"macro"),[ge]),rt=s.useCallback(_=>ge(_.macroRange,_.microSelection[0],"micro"),[ge]),Ot=Ft(ye.macroStart,bt),I=Ft(ye.macroEnd,bt),J=Ft(ye.micro,rt),[Ye,lt]=q,ze=s.useMemo(()=>({value:B[0],onChange:tt,minDate:r,maxDate:B[1],unit:g,yearStartMonth:h,...zt(g,A),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...ke?{stepper:Ot}:{}}),[B,tt,r,g,h,A,e.formatLocale,e.locale,e.labels,R,ke,Ot]),xe=s.useMemo(()=>({value:B[1],onChange:qe,minDate:B[0],maxDate:n,unit:g,yearStartMonth:h,...zt(g,A),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...ke?{stepper:I}:{}}),[B,qe,n,g,h,A,e.formatLocale,e.locale,e.labels,R,ke,I]),$e=s.useMemo(()=>({value:N,onChange:Ue,minDate:Ye,maxDate:lt,unit:w,yearStartMonth:h,...zt(w,Y),formatLocale:e.formatLocale,locale:e.locale,labels:e.labels,formatOption:R,...Ge?{stepper:J}:{}}),[N,Ue,Ye,lt,w,h,Y,e.formatLocale,e.locale,e.labels,R,Ge,J]),Ir=s.useMemo(()=>({...D,mode:"vernier",unit:t,yearStartMonth:h,macroUnit:g,microUnit:w,minDate:r,maxDate:n,macroRange:B,microValue:N,onChangeMacroRange:Ve,onChangeMicroPoint:we}),[D,t,g,w,r,n,B,N,Ve,we,h]);return{macroRange:B,setMacroRange:ft,microValue:N,setMicroValue:O,setMacroLowerDate:tt,setMacroUpperDate:qe,setMicroDate:Ue,shiftMacroRange:st,shiftMicroValue:oe,resetVernier:pt,macroStartSelectorProps:ze,macroEndSelectorProps:xe,microSelectorProps:$e,sliderProps:Ir,duringRender:ee.duringRender}}function ii(e,t){const r=new Date(0);return r.setHours(0,0,0,0),r.setFullYear(e,t,1),r}function jo(e,t){const r=new Date(e.getTime());return Ko(r.getFullYear(),r.getMonth(),t)}function al(e){return e===void 0?0:pl(e)?e:Number.NaN}const il=Un("declare the years to offer with minYear / maxYear or allowedYears");function So(e,t,r,n){e!==void 0&&Kl(e,t,r,n)}function Kl(e,t,r,n){if(!De(e))throw new RangeError(`YearSelector: ${t} must be a valid Date (received: ${y(e)})`);Ke("YearSelector",t,e,"year",r,n)}function sl(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(ii(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 ll(e,t,r,n){const o=e===void 0?null:e,a=t===void 0?null:jo(t,n);return o!==null&&a!==null?r(o,a):o!==null?o:a}function rm(e,t,r,n){const o=new Set;for(const a of e){const i=jo(a,n);t!==null&&i<t||r!==null&&i>r||o.add(i)}return Array.from(o).sort((a,i)=>a-i)}function nm(e,t,r,n){return e!==void 0?{kind:"discrete",ascending:rm(e,t,r,n)}:t===null||r===null?null:{kind:"bounded",minYear:t,maxYear:r}}function om(e,t){const r=[];for(let n=t;n>=e;n--)r.push(n);return r}const am=e=>{const{value:t,initialDate:r,onChange:n,stepper:o,stepGlyph:a,children:i,minYear:l,maxYear:u,minDate:d,maxDate:m,allowedYears:R,className:L="",style:T,disabled:b=!1,locale:g,labels:w,formatLocale:h,formatOption:D,yearStartMonth:M}=e,v=gr("YearSelector",M);if(So(t,"value",v,""),So(r,"initialDate",v,""),So(d,"minDate",v,il),So(m,"maxDate",v,il),sl(l,"minYear",v),sl(u,"maxYear",v),sn("YearSelector","allowedYears",R),R!==void 0)for(let ae=0;ae<R.length;ae++)Kl(R[ae],`allowedYears[${ae}]`,v,"");h!==void 0&&Jo("YearSelector","formatLocale",h);const f=t??r;if(f===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&&pi("YearSelector",o,t!==void 0);const ue=ui("YearSelector",a),K=Wo(g,w),re=t!==void 0,[ee,B]=bi(f,re,ae=>ea(ae,"year",v),ae=>jo(ae,v)),ne=d?.getTime(),k=m?.getTime(),q=s.useMemo(()=>ll(l,d,Math.max,v),[l,ne,v]),j=s.useMemo(()=>ll(u,m,Math.min,v),[u,k,v]);if(q!==null&&j!==null&&q>j)throw new RangeError(`YearSelector: the resolved upper bound must not precede the resolved lower bound (lower: ${q}, upper: ${j})`);const A=R===void 0?null:R.map(ae=>ae.getTime()).join(","),$=s.useMemo(()=>nm(R,q,j,v),[A,q,j,v]);if($===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(()=>$.kind==="discrete"?{kind:"candidates",ascending:$.ascending,loIndex:0,hiIndex:$.ascending.length-1}:{kind:"range",min:$.minYear,max:$.maxYear},[$]),Y=t!==void 0?jo(t,v):ee,N=!An(H,Y),F=ae=>{if(!b){if(!An(H,ae))throw new RangeError(`YearSelector: refusing to emit ${ae}, which lies outside the selectable years`);re||B(ae),n?.(ii(ae,v),ae)}},G=Zt(H,Y,-1),he=Zt(H,Y,1),te=()=>{if(o!==void 0){o.onStep("previous");return}G!==null&&F(G)},le=()=>{if(o!==void 0){o.onStep("next");return}he!==null&&F(he)},Se=s.useMemo(()=>{const ae=$.kind==="discrete"?[...$.ascending].reverse():om($.minYear,$.maxYear);return N&&(ae.push(Y),ae.sort((ie,pe)=>pe-ie)),ae.map(ie=>({value:ie,label:it("year",ii(ie,v),D,h)}))},[$,N,Y,v,h,D]);return C.jsxs("div",{className:`inline-flex items-center ${Cn} ${L}`,style:T,"data-out-of-range":N?"true":void 0,children:[C.jsx(Tr,{neighbour:"control",direction:"left",glyph:ue,disabled:b,canStep:o===void 0?G!==null:o.canStepPrevious,onStep:te,ariaLabel:K.previousYear}),C.jsx("select",{"aria-label":K.yearSelect,disabled:b,className:`${pd} appearance-none rounded-md border border-gray-300 bg-gray-100 px-1 py-0.5 text-center font-mono text-gray-900 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:Y,onChange:ae=>{if(!ae.target.value)return;const ie=Number(ae.target.value);Number.isInteger(ie)&&F(ie)},children:Se.map(ae=>C.jsx("option",{value:ae.value,disabled:N&&ae.value===Y,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:ae.label},ae.value))}),C.jsx(Tr,{neighbour:"control",direction:"right",glyph:ue,disabled:b,canStep:o===void 0?he!==null:o.canStepNext,onStep:le,ariaLabel:K.nextYear}),i]})},im=(e,t)=>{const r=al(t.yearStartMonth);return!(al(e.yearStartMonth)!==r||!gi(e,t,n=>ea(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.stepGlyph!==t.stepGlyph||e.children!==t.children||e.locale!==t.locale||!Bo(e.labels,t.labels)||e.formatLocale!==t.formatLocale||e.formatOption!==t.formatOption)},ql=s.memo(am,im);ql.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=gl;exports.DateSelector=zl;exports.MonthSelector=Gl;exports.PERIOD_SLIDER_LABEL_CATALOGS=fl;exports.PERIOD_SLIDER_LABEL_KEYS=zo;exports.PeriodSlider=Ol;exports.YearSelector=ql;exports.addUnit=vl;exports.areStylesEqual=Nl;exports.calculateConnectDragValues=Ml;exports.calculateHandleDragValues=Ka;exports.calculateKeyboardActionValues=Dl;exports.calculateLabelSlant=Ll;exports.calculateVernierMacroDrag=Cl;exports.calculateVernierMicroDrag=Il;exports.decode=se;exports.encode=U;exports.findNearestDateIndex=Me;exports.formatLabel=it;exports.formatOptionText=Vl;exports.formatQuarterLabel=Ou;exports.formatScreenReaderLabel=Pr;exports.getMacroWindowEndDate=Rl;exports.getMacroWindowStartDate=Sl;exports.getSortedAllowedDates=Vu;exports.normalizeDateByUnit=xt;exports.resolveDraggedEdge=Uo;exports.resolveMacroWindow=$t;exports.resolvePeriodSliderLabels=hl;exports.resolveQuarter=xl;exports.resolveSelectorSteps=Ja;exports.resolveVernierRailZone=hi;exports.resolveVernierSelectorSteps=ur;exports.resolveVernierTargetHandle=Tl;exports.resolveWheelStep=$l;exports.usePeriodSliderPoint=Jd;exports.usePeriodSliderRange=Qd;exports.useSelectorStepper=Ft;exports.useVernierSliderPoint=tm;exports.useVernierSliderRange=em;
|