@aiquants/period-slider 0.2.0 → 0.3.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.
@@ -1,9 +1,20 @@
1
1
  import { default as React } from 'react';
2
2
  import { PeriodSliderUnit } from './PeriodSlider';
3
+ /**
4
+ * Props of the year-resolution selector.
5
+ * 年単位セレクタの Props。
6
+ *
7
+ * Accessible names default to English and option text to locale-independent ISO 8601, because a
8
+ * generic package cannot know the host application's language: localisation is the consumer's
9
+ * decision, expressed through `locale` or the aria-label props.
10
+ * アクセシブル名の既定は英語、選択肢テキストの既定はロケール非依存の ISO 8601 表記。
11
+ * 汎用パッケージは利用側アプリの言語を知り得ないため、地域化は `locale`・アクセシブル名 Props を
12
+ * 通じた利用側の選択。
13
+ */
3
14
  export interface YearSelectorProps {
4
- /** Controlled selected date / 選択日付(外部制御用) */
15
+ /** Controlled selected date; required unless `initialDate` is supplied / 選択日付(外部制御用・`initialDate` 未指定時は必須) */
5
16
  value?: Date;
6
- /** Initial selected date (defaults to current date) / 選択日付(未指定時は現在日) */
17
+ /** Initial selected date; required unless `value` is supplied / 選択日付(非制御用・`value` 未指定時は必須) */
7
18
  initialDate?: Date;
8
19
  /** Time resolution unit (ignored by selector, accepted for hook interoperability) / 時間解像度単位 (フック相互運用用) */
9
20
  unit?: PeriodSliderUnit;
@@ -11,13 +22,13 @@ export interface YearSelectorProps {
11
22
  onChange?(date: Date, year: number): void;
12
23
  /** Child elements / 子要素 */
13
24
  children?: React.ReactNode;
14
- /** Minimum selectable year / ドロップダウン・可能範囲の最小年 */
25
+ /** Minimum selectable year; combined with `minDate` as the stricter of the two, and at least one of them is required / 選択可能な最小年。`minDate` とは厳しい方を採用し、少なくとも一方が必須 */
15
26
  minYear?: number;
16
- /** Maximum selectable year / ドロップダウン・可能範囲の最大年 */
27
+ /** Maximum selectable year; combined with `maxDate` as the stricter of the two, and at least one of them is required / 選択可能な最大年。`maxDate` とは厳しい方を採用し、少なくとも一方が必須 */
17
28
  maxYear?: number;
18
- /** Minimum selectable date / 選択可能範囲の最小日付 */
29
+ /** Minimum selectable date (its year is used); combined with `minYear` as the stricter of the two / 選択可能範囲の最小日付 (年のみ使用)。`minYear` とは厳しい方を採用 */
19
30
  minDate?: Date;
20
- /** Maximum selectable date / 選択可能範囲の最大日付 */
31
+ /** Maximum selectable date (its year is used); combined with `maxYear` as the stricter of the two / 選択可能範囲の最大日付 (年のみ使用)。`maxYear` とは厳しい方を採用 */
21
32
  maxDate?: Date;
22
33
  /** Additional CSS class name / 追加の CSS クラス名 */
23
34
  className?: string;
@@ -25,12 +36,18 @@ export interface YearSelectorProps {
25
36
  style?: React.CSSProperties;
26
37
  /** Disabled flag / 無効化フラグ */
27
38
  disabled?: boolean;
28
- /** Accessible label for previous year button / 前年ボタンのアクセシブル名 */
39
+ /** Accessible label for previous year button / 前年ボタンのアクセシブル名 (既定: "Previous year") */
29
40
  prevYearAriaLabel?: string;
30
- /** Accessible label for next year button / 翌年ボタンのアクセシブル名 */
41
+ /** Accessible label for next year button / 翌年ボタンのアクセシブル名 (既定: "Next year") */
31
42
  nextYearAriaLabel?: string;
32
- /** Accessible label for year select combobox / 会計年セレクトのアクセシブル名 */
43
+ /** Accessible label for year select combobox / 年セレクトのアクセシブル名 (既定: "Year") */
33
44
  selectAriaLabel?: string;
45
+ /** BCP 47 language tag switching option text to Intl formatting; omitted keeps locale-independent ISO 8601 / 選択肢テキストを Intl 書式にする BCP 47 言語タグ (未指定時はロケール非依存の ISO 8601 表記) */
46
+ locale?: string;
34
47
  }
48
+ /**
49
+ * Year-resolution selector re-rendering only when a prop its output depends on changes.
50
+ * 描画結果が依存する Props の変化時のみ再描画する年単位セレクタ。
51
+ */
35
52
  export declare const YearSelector: React.MemoExoticComponent<(props: YearSelectorProps) => React.JSX.Element>;
36
53
  //# sourceMappingURL=YearSelector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"YearSelector.d.ts","sourceRoot":"","sources":["../src/YearSelector.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEtD,MAAM,WAAW,iBAAiB;IAC9B,6CAA6C;IAC7C,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,wEAAwE;IACxE,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,0GAA0G;IAC1G,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,wDAAwD;IACxD,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,4CAA4C;IAC5C,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,4DAA4D;IAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAA;CAC3B;AAgHD,eAAO,MAAM,YAAY,oCAzGa,iBAAiB,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CA4HzE,CAAA"}
1
+ {"version":3,"file":"YearSelector.d.ts","sourceRoot":"","sources":["../src/YearSelector.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,WAAW,iBAAiB;IAC9B,8GAA8G;IAC9G,KAAK,CAAC,EAAE,IAAI,CAAA;IACZ,8FAA8F;IAC9F,WAAW,CAAC,EAAE,IAAI,CAAA;IAClB,0GAA0G;IAC1G,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,wDAAwD;IACxD,QAAQ,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACzC,2BAA2B;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,mKAAmK;IACnK,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,mKAAmK;IACnK,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+IAA+I;IAC/I,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,+IAA+I;IAC/I,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,6BAA6B;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sFAAsF;IACtF,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,8EAA8E;IAC9E,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,6EAA6E;IAC7E,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,4KAA4K;IAC5K,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AAyMD;;;GAGG;AACH,eAAO,MAAM,YAAY,oCArHa,iBAAiB,KAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAyIzE,CAAA"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("react/jsx-runtime"),Ae=require("date-fns"),r=require("react");function za(e,t,a,o){if(o&&o.length>0)return o.filter(n=>n&&!Number.isNaN(n.getTime())).map(n=>{const x=new Date(n);return x.setHours(0,0,0,0),x}).sort((n,x)=>x.getTime()-n.getTime()).map(n=>{const x=Ae.format(n,"yyyy-MM-dd");return{label:x,value:x}});const s=e.getFullYear(),c=t??new Date(s-1,0,1),m=a??new Date(s+1,11,31),M=new Date(Math.min(c.getTime(),e.getTime()));M.setHours(0,0,0,0);const d=new Date(Math.max(m.getTime(),e.getTime()));d.setHours(0,0,0,0);const g=[];let T=d;for(;T>=M;){const $=Ae.format(T,"yyyy-MM-dd");g.push({label:$,value:$}),T=Ae.addDays(T,-1)}return g}const Ba=e=>{const{value:t,initialDate:a,onChange:o,children:s,minYear:c,maxYear:m,minDate:M,maxDate:d,allowedDates:g,variant:T="dropdown",className:$="",style:n,disabled:x=!1,prevDateAriaLabel:G="前日",nextDateAriaLabel:U="翌日",selectAriaLabel:H="年月日"}=e,A=t??a,[z,V]=r.useState(()=>{const i=new Date(A??new Date);return i.setHours(0,0,0,0),i}),I=t!==void 0,b=r.useMemo(()=>{if(I){if(t&&!Number.isNaN(t.getTime())){const F=new Date(t);return F.setHours(0,0,0,0),F}const i=new Date;return i.setHours(0,0,0,0),i}return z},[I,t?.getTime(),z]),E=M?.getTime(),y=d?.getTime(),w=r.useMemo(()=>{if(M){const i=new Date(M);return i.setHours(0,0,0,0),i}if(c!==void 0){const i=new Date(c,0,1);return i.setFullYear(c),i.setHours(0,0,0,0),i}return null},[E,c]),p=r.useMemo(()=>{if(d){const i=new Date(d);return i.setHours(0,0,0,0),i}if(m!==void 0){const i=new Date(m,11,31);return i.setFullYear(m),i.setHours(0,0,0,0),i}return null},[y,m]),ne=A?.getTime();r.useEffect(()=>{if(!I&&A&&!Number.isNaN(A.getTime())){const i=new Date(A);i.setHours(0,0,0,0),V(i)}},[I,ne]);const N=i=>{if(x)return;let F=new Date(i);F.setHours(0,0,0,0),w&&F<w&&(F=new Date(w)),p&&F>p&&(F=new Date(p)),I||V(F),o?.(F)},_=r.useMemo(()=>Ae.addDays(b,-1),[b]),Y=r.useMemo(()=>Ae.addDays(b,1),[b]),X=x||w!==null&&_<w,W=x||p!==null&&Y>p,me=()=>N(_),ce=()=>N(Y),oe=i=>{if(i.target.value){const F=Ae.parseISO(i.target.value);Number.isNaN(F.getTime())||N(F)}},Q=i=>{if(i.target.value){const F=Ae.parseISO(i.target.value);Number.isNaN(F.getTime())||N(F)}},B=b.getFullYear(),se=b.getMonth()+1,He=b.getDate(),be=w?.getTime()??null,Te=p?.getTime()??null,Ce=b.getTime(),he=r.useMemo(()=>{if(g&&g.length>0)return g.map(Ne=>Ne.getTime()).join(",");const i=be??new Date(B-1,0,1).getTime(),F=Te??new Date(B+1,11,31).getTime(),D=Math.min(i,Ce),we=Math.max(F,Ce);return`${D}_${we}`},[g,be,Te,Ce,B]),ze=r.useMemo(()=>T!=="dropdown"?[]:za(b,w,p,g),[T,he,b]),je=r.useMemo(()=>{if(T!=="split-dropdown")return[];const i=w?w.getFullYear():B-10,F=p?p.getFullYear():B+1,D=Math.min(i,B),we=Math.max(F,B),Ne=[];for(let Fe=we;Fe>=D;Fe--)Ne.push(Fe);return Ne},[T,w,p,B]),k=r.useMemo(()=>{if(T!=="split-dropdown")return[];let i=1,F=12;w&&B===w.getFullYear()&&(i=w.getMonth()+1),p&&B===p.getFullYear()&&(F=p.getMonth()+1);const D=[];for(let we=i;we<=F;we++)D.push(we);return D},[T,w,p,B]),j=r.useMemo(()=>{if(T!=="split-dropdown")return[];const i=Ae.getDaysInMonth(b);let F=1,D=i;w&&B===w.getFullYear()&&se===w.getMonth()+1&&(F=w.getDate()),p&&B===p.getFullYear()&&se===p.getMonth()+1&&(D=p.getDate());const we=[];for(let Ne=F;Ne<=D;Ne++)we.push(Ne);return we},[T,w,p,b,B,se]),q=(i,F,D)=>{const we=Ae.getDaysInMonth(new Date(i,F-1,1)),Ne=Math.min(D,we),Fe=new Date(i,F-1,Ne);Fe.setFullYear(i),N(Fe)},te=Ae.format(b,"yyyy-MM-dd"),L=w?Ae.format(w,"yyyy-MM-dd"):void 0,re=p?Ae.format(p,"yyyy-MM-dd"):void 0,ee=T==="split-dropdown"?"w-auto":"w-38";return h.jsxs("div",{className:`inline-flex items-center ${ee} ${$}`,style:n,children:[h.jsx("button",{type:"button","aria-label":G,disabled:X,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:me,children:h.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),T==="dropdown"?h.jsx("select",{"aria-label":H,disabled:x,className:"mx-1 my-auto 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",value:te,onChange:Q,children:ze.map(i=>h.jsx("option",{value:i.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:i.label},i.value))}):T==="split-dropdown"?h.jsxs("div",{className:"mx-1 my-auto inline-flex items-center gap-1",children:[h.jsx("select",{"aria-label":"年",disabled:x,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:B,onChange:i=>q(Number(i.target.value),se,He),children:je.map(i=>h.jsxs("option",{value:i,className:"dark:bg-slate-700 dark:text-slate-100",children:[i,"年"]},i))}),h.jsx("select",{"aria-label":"月",disabled:x,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:se,onChange:i=>q(B,Number(i.target.value),He),children:k.map(i=>h.jsxs("option",{value:i,className:"dark:bg-slate-700 dark:text-slate-100",children:[String(i).padStart(2,"0"),"月"]},i))}),h.jsx("select",{"aria-label":"日",disabled:x,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:He,onChange:i=>q(B,se,Number(i.target.value)),children:j.map(i=>h.jsxs("option",{value:i,className:"dark:bg-slate-700 dark:text-slate-100",children:[String(i).padStart(2,"0"),"日"]},i))})]}):h.jsx("input",{"aria-label":H,disabled:x,className:"mx-1 my-auto w-28 rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-gray-900 text-xs 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:te,min:L,max:re,onChange:oe,type:"date"}),h.jsx("button",{type:"button","aria-label":U,disabled:W,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:ce,children:h.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),s]})},Da=r.memo(Ba,(e,t)=>{const a=e.value??e.initialDate,o=t.value??t.initialDate,s=a&&!Number.isNaN(a.getTime())?a.getFullYear()*1e4+(a.getMonth()+1)*100+a.getDate():null,c=o&&!Number.isNaN(o.getTime())?o.getFullYear()*1e4+(o.getMonth()+1)*100+o.getDate():null;if(s!==c||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear)return!1;const m=e.minDate&&!Number.isNaN(e.minDate.getTime())?e.minDate.getFullYear()*1e4+(e.minDate.getMonth()+1)*100+e.minDate.getDate():null,M=t.minDate&&!Number.isNaN(t.minDate.getTime())?t.minDate.getFullYear()*1e4+(t.minDate.getMonth()+1)*100+t.minDate.getDate():null;if(m!==M)return!1;const d=e.maxDate&&!Number.isNaN(e.maxDate.getTime())?e.maxDate.getFullYear()*1e4+(e.maxDate.getMonth()+1)*100+e.maxDate.getDate():null,g=t.maxDate&&!Number.isNaN(t.maxDate.getTime())?t.maxDate.getFullYear()*1e4+(t.maxDate.getMonth()+1)*100+t.maxDate.getDate():null;return!(d!==g||e.onChange!==t.onChange||e.allowedDates!==t.allowedDates||e.children!==t.children||e.prevDateAriaLabel!==t.prevDateAriaLabel||e.nextDateAriaLabel!==t.nextDateAriaLabel||e.selectAriaLabel!==t.selectAriaLabel)});Da.displayName="DateSelector";function Xa(e,t,a,o,s){const c=e.getFullYear(),m=t??(o?o.getFullYear():c-5),M=a??(s?s.getFullYear():c+5),d=Math.min(m,c),g=Math.max(M,c),T=o?new Date(o.getFullYear(),o.getMonth(),1).getTime():null,$=s?new Date(s.getFullYear(),s.getMonth(),1).getTime():null,n=[];for(let x=g;x>=d;x--)for(let G=12;G>=1;G--){const U=new Date(x,G-1,1);U.setFullYear(x);const H=U.getTime();if(T!==null&&H<T||$!==null&&H>$)continue;const A=String(G).padStart(2,"0"),z=`${x}-${A}`;n.push({label:z,value:z})}return n}const Ka=e=>{const{value:t,initialDate:a,onChange:o,children:s,variant:c="date",minYear:m,maxYear:M,minDate:d,maxDate:g,isWarning:T=!1,className:$="",style:n,disabled:x=!1,prevMonthAriaLabel:G="前月",nextMonthAriaLabel:U="翌月",selectAriaLabel:H="年月"}=e,A=t??a,[z,V]=r.useState(()=>{const L=A??new Date,re=new Date(L.getFullYear(),L.getMonth(),1);return re.setFullYear(L.getFullYear()),re}),I=t!==void 0,b=r.useMemo(()=>{if(I){if(t&&!Number.isNaN(t.getTime())){const L=new Date(t.getFullYear(),t.getMonth(),1);return L.setFullYear(t.getFullYear()),L}return new Date}return z},[I,t?.getTime(),z]),E=d?.getTime(),y=g?.getTime(),w=r.useMemo(()=>{if(d){const L=new Date(d.getFullYear(),d.getMonth(),1);return L.setFullYear(d.getFullYear()),L}if(m!==void 0){const L=new Date(m,0,1);return L.setFullYear(m),L}return null},[E,m]),p=r.useMemo(()=>{if(g){const L=new Date(g.getFullYear(),g.getMonth(),1);return L.setFullYear(g.getFullYear()),L}if(M!==void 0){const L=new Date(M,11,1);return L.setFullYear(M),L}return null},[y,M]),ne=A?.getTime();r.useEffect(()=>{if(!I&&A&&!Number.isNaN(A.getTime())){const L=new Date(A.getFullYear(),A.getMonth(),1);L.setFullYear(A.getFullYear()),V(L)}},[I,ne]);const N=L=>{if(x)return;let re=L;w&&re<w&&(re=new Date(w)),p&&re>p&&(re=new Date(p)),I||V(re);const ee=re.getFullYear()*100+(re.getMonth()+1);o?.(re,ee)},_=r.useMemo(()=>{const L=new Date(b.getFullYear(),b.getMonth()-1,1);return L.setFullYear(b.getMonth()===0?b.getFullYear()-1:b.getFullYear()),L},[b]),Y=r.useMemo(()=>{const L=new Date(b.getFullYear(),b.getMonth()+1,1);return L.setFullYear(b.getMonth()===11?b.getFullYear()+1:b.getFullYear()),L},[b]),X=x||w!==null&&_<w,W=x||p!==null&&Y>p,me=()=>{N(_)},ce=()=>{N(Y)},oe=L=>{const re=L.target.value;if(!re)return;const[ee,ie]=re.split("-"),i=Number(ee),F=Number(ie)-1;if(!(Number.isNaN(i)||Number.isNaN(F))){const D=new Date(i,F,1);D.setFullYear(i),N(D)}},Q=L=>{const re=L.target.value;if(!re)return;const[ee,ie]=re.split("-"),i=Number(ee),F=Number(ie)-1;if(!(Number.isNaN(i)||Number.isNaN(F))){const D=new Date(i,F,1);D.setFullYear(i),N(D)}},B=`${b.getFullYear()}-${String(b.getMonth()+1).padStart(2,"0")}`,se=w?`${w.getFullYear()}-${String(w.getMonth()+1).padStart(2,"0")}`:void 0,He=p?`${p.getFullYear()}-${String(p.getMonth()+1).padStart(2,"0")}`:void 0,be=b.getFullYear(),Te=m??(d?d.getFullYear():be-5),Ce=M??(g?g.getFullYear():be+5),he=Math.min(Te,be),ze=Math.max(Ce,be),je=`${he}_${ze}_${E??"none"}_${y??"none"}`,k=r.useMemo(()=>c!=="dropdown"?[]:Xa(b,m,M,d,g),[c,je,b]),j=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",q=`mx-1 my-auto w-28 rounded-md border py-0.5 px-1 text-xs dark:placeholder:text-gray-400 disabled:opacity-50 ${j}`,te=`mx-1 my-auto 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] focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 ${j}`;return h.jsxs("div",{className:`inline-flex w-38 items-center ${$}`,style:n,children:[h.jsx("button",{type:"button","aria-label":G,disabled:X,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:me,children:h.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),c==="dropdown"?h.jsx("select",{"aria-label":H,disabled:x,className:te,value:B,onChange:Q,children:k.map(L=>h.jsx("option",{value:L.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:L.label},L.value))}):h.jsx("input",{"aria-label":H,disabled:x,className:q,value:B,min:se,max:He,onChange:oe,type:"month"}),h.jsx("button",{type:"button","aria-label":U,disabled:W,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:ce,children:h.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),s]})},va=r.memo(Ka,(e,t)=>{const a=e.value??e.initialDate,o=t.value??t.initialDate,s=a&&!Number.isNaN(a.getTime())?a.getFullYear()*12+a.getMonth():null,c=o&&!Number.isNaN(o.getTime())?o.getFullYear()*12+o.getMonth():null;if(s!==c||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear)return!1;const m=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,M=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(m!==M)return!1;const d=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,g=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(d!==g||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel)});va.displayName="MonthSelector";const zt={"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"}},le=(e,t)=>{if(!t||Number.isNaN(t.getTime()))return new Date;const a=new Date(t.getTime());return e==="year"?(a.setMonth(0,1),a.setHours(0,0,0,0)):(e==="month"&&a.setDate(1),a.setHours(0,0,0,0)),a},J=(e,t)=>{if(!t||Number.isNaN(t.getTime()))return 0;const a=le(e,t),o=a.getFullYear(),s=a.getMonth()+1,c=a.getDate();return e==="year"?o:e==="month"?o*12+(s-1):Math.floor(Date.UTC(o,s-1,c)/(1440*60*1e3))},de=(e,t)=>{if(e==="year")return new Date(t,0,1);if(e==="month"){const o=Math.floor(t/12),s=t%12;return new Date(o,s,1)}const a=new Date(t*24*60*60*1e3);return new Date(a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate())},xe=(e,t,a)=>{const o=new Date(t.getTime());return e==="year"?o.setFullYear(o.getFullYear()+a):e==="month"?o.setMonth(o.getMonth()+a):o.setDate(o.getDate()+a),o},jt=(e,t,a)=>{if(!a||Number.isNaN(a.getTime()))return new Date;if(e===t)return le(t,a);const o=a.getFullYear(),s=a.getMonth();if(e==="year"){if(t==="month")return new Date(o,11,1);if(t==="day")return new Date(o,11,31)}return e==="month"&&t==="day"?new Date(o,s+1,0):le(t,a)},Qe=(e,t,a)=>{if(!t||Number.isNaN(t.getTime()))return"";if(a)return a(t);const o=t.getFullYear(),s=String(t.getMonth()+1).padStart(2,"0"),c=String(t.getDate()).padStart(2,"0");return e==="year"?`${o}年`:e==="month"?`${o}年${s}月`:`${o}年${s}月${c}日`},at=(e,t,a)=>{if(!t||Number.isNaN(t.getTime()))return"";if(a)return a(t);const o=t.getFullYear(),s=t.getMonth()+1,c=t.getDate();return e==="year"?`${o}年`:e==="month"?`${o}年 ${s}月`:`${o}年 ${s}月 ${c}日`},Bt=(e,t,a)=>{if(!e||e.length===0||e.length===1)return 0;const o=J(a,t);let s=0,c=e.length-1;if(o<=J(a,e[s]))return 0;if(o>=J(a,e[c]))return c;for(;s<=c;){const d=s+c>>1,g=J(a,e[d]);if(g===o)return d;g<o?s=d+1:c=d-1}const m=Math.abs(J(a,e[s])-o),M=Math.abs(J(a,e[c])-o);return m<M?s:c},Ft=(e,t,a,o)=>{if(!Array.isArray(e)||e.length===0)return[];const s=e.filter(d=>d&&!Number.isNaN(d.getTime())).map(d=>le(t,d));if(s.length===0)return[];const c=new Map;for(const d of s){const g=J(t,d);c.has(g)||c.set(g,d)}let M=Array.from(c.keys()).sort((d,g)=>d-g).map(d=>c.get(d)).filter(d=>d!==void 0);if(a&&!Number.isNaN(a.getTime())){const d=J(t,a);M=M.filter(g=>J(t,g)>=d)}if(o&&!Number.isNaN(o.getTime())){const d=J(t,o);M=M.filter(g=>J(t,g)<=d)}return M},Xt=(e,t,a,o,s,c,m)=>{let M=a,d=o;return m?(M=t,d=t):e==="low"?t>o?(M=o,d=t):M=t:t<a?(d=a,M=t):d=t,[Math.max(s,Math.min(c,M)),Math.max(s,Math.min(c,d))]},_a=(e,t,a,o,s)=>s?"low":e==="low"?t>o?"high":"low":t<a?"low":"high",pa=(e,t,a,o,s,c,m)=>{const M=s-o;if(M<=0)return null;if(c){const $=Math.round(e*(m.length-1));if($===0)return null;let n=t+$,x=a+$;return n<0&&(x+=-n,n=0),x>m.length-1&&(n-=x-(m.length-1),x=m.length-1),n=Math.max(0,Math.min(m.length-1,n)),x=Math.max(0,Math.min(m.length-1,x)),[n,x]}const d=Math.round(e*M);if(d===0)return null;let g=t+d,T=a+d;return g<o&&(T+=o-g,g=o),T>s&&(g-=T-s,T=s),g=Math.max(o,Math.min(s,g)),T=Math.max(o,Math.min(s,T)),[g,T]},ya=(e,t,a,o,s,c,m,M)=>{let d=0,g=!1,T=!1;switch(e){case"ArrowRight":case"ArrowUp":d=M;break;case"ArrowLeft":case"ArrowDown":d=-M;break;case"PageUp":d=M*5;break;case"PageDown":d=-M*5;break;case"Home":g=!0;break;case"End":T=!0;break;default:return null}if(m){let x=a;return g?x=s:T?x=c:x=Math.max(s,Math.min(c,a+d)),[x,x]}let $=a,n=o;return t==="low"?g?$=s:T?$=o:$=Math.max(s,Math.min(o,a+d)):g?n=a:T?n=c:n=Math.max(a,Math.min(c,o+d)),[$,n]},Ta=(e,t,a,o="top",s="day",c)=>{const m=a>0?a:400,M=Math.max(0,t-e)/100*m,d=s==="year"?48:s==="month"?68:90,g=c?.estimatedWidthPx??d,T=c?.estimatedHeightPx??16,$=c?.paddingPx??12,n=c?.maxAngleDeg??90,x=8,G=c?.anchorGapY!==void 0?c.anchorGapY:2,U=x+G,H=U+T/2,A=o==="top"?-H:H,z=g+$;if(M>=z)return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:A,highOffsetY:A,isSlanted:!1,proximity:0};const V=Math.max(0,Math.min(1,(z-M)/z)),I=V*V*V*(V*(V*6-15)+10),b=I*n,E=o==="top"?-b:b,y=b*Math.PI/180,w=g/2*Math.abs(Math.sin(y))+T/2*Math.abs(Math.cos(y)),p=U+w,ne=o==="top"?-p:+p,_=T+4,Y=Math.max(0,_-M),X=I*(Y/2);return{lowAngleDeg:E,highAngleDeg:E,lowOffsetX:-X,highOffsetX:X,lowOffsetY:ne,highOffsetY:ne,isSlanted:V>.001,proximity:V}};function Ca(e,t,a,o,s,c,m="macro-top",M=.05){const d=m==="macro-top"||m==="macro-left",g=t<=0;if(d&&g||!(d||g)){const n=Math.abs(e-a),x=Math.abs(e-o);return n<=M&&n<=x?"macro-low":x<=M&&x<n?"macro-high":e>=a&&e<=o?"macro-connect":n<x?"macro-low":"macro-high"}const T=Math.abs(e-s),$=Math.abs(e-c);return T<=M&&T<=$?"micro-low":$<=M&&$<T?"micro-high":e>=s&&e<=c?"micro-connect":T<$?"micro-low":"micro-high"}function Na(e,t,a,o,s){if(e==="macro-connect"){const m=t-a,M=s-o,d=Math.max(0,Math.min(1-M,o+m)),g=d+M;return[d,g,"macro-connect"]}if(e==="macro-low"){const m=Math.max(0,Math.min(1,t));return m>s?[s,m,"macro-high"]:[m,s,"macro-low"]}const c=Math.max(0,Math.min(1,t));return c<o?[c,o,"macro-low"]:[o,c,"macro-high"]}function Ga(e,t,a,o,s){if(e==="micro-connect"){const m=t-a,M=s-o,d=Math.max(0,Math.min(1-M,o+m)),g=d+M;return[d,g,"micro-connect"]}if(e==="micro-low"){const m=Math.max(0,Math.min(1,t));return m>s?[s,m,"micro-high"]:[m,s,"micro-low"]}const c=Math.max(0,Math.min(1,t));return c<o?[c,o,"micro-low"]:[o,c,"micro-high"]}const Dt=r.memo(({type:e,isTop:t=!0,isVertical:a=!1,isLeft:o=!0})=>{let s,c;a?(s=o?"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",c=`period-slider-knob period-slider-knob-svg is-vertical ${o?"is-semicircle-left":"is-semicircle-right"}`):(s=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",c=`period-slider-knob period-slider-knob-svg ${t?"is-semicircle-top":"is-semicircle-bottom"}`);const m=e==="macro"?"period-slider-knob-path-macro":"period-slider-knob-path-micro";return h.jsx("svg",{className:c,width:a?"8":"16",height:a?"16":"8",viewBox:a?"0 0 8 16":"0 0 16 8",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:h.jsx("path",{d:s,className:m,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});Dt.displayName="VernierKnobSvg";const Wa=e=>{const{unit:t,minDate:a,maxDate:o,allowedDates:s,snapMode:c="index",disabled:m=!1,className:M="",showStepper:d=!0,tooltipStyle:g="always",labelPosition:T="top",autoSlantLabels:$=!0,isVertical:n=!1,hideConnectBar:x=!1,showTicks:G=!1,colorScheme:U="blue-rose"}=e,H=zt[U]??zt["blue-rose"],A=r.useId(),z=r.useRef(e);z.current=e;const V=a?.getTime(),I=o?.getTime(),b=r.useMemo(()=>Ft(s,t,a,o),[s,t,V,I]),E=b.length>0,{rangeMin:y,rangeMax:w}=r.useMemo(()=>{if(E)return{rangeMin:0,rangeMax:b.length-1};const l=le(t,a??new Date(2020,0,1));let u=le(t,o??new Date(2030,0,1));const f=J(t,l);let v=J(t,u);return v<=f&&(u=xe(t,l,1),v=J(t,u)),{rangeMin:f,rangeMax:v}},[E,b,t,V,I]),p=e.mode==="point",ne=r.useCallback(l=>{if(E){const u=Math.max(0,Math.min(b.length-1,Math.round(l)));return b[u]??new Date}return de(t,Math.round(l))},[E,b,t]),N=r.useCallback(l=>{if(!l||Number.isNaN(l.getTime()))return y;const u=le(t,l);return E?Bt(b,u,t):J(t,u)},[E,b,t,y]),_=e.mode==="range"?e.range?e.range[0]:e.lowerDate??e.defaultRange?.[0]??e.initialRange?.[0]??e.defaultLowerDate??e.initialLowerDate:e.mode==="vernier"?e.microRange?e.microRange[0]:e.lowerDate??e.defaultMicroRange?.[0]??e.initialMicroRange?.[0]??e.defaultLowerDate??e.initialLowerDate:void 0,Y=e.mode==="range"?e.range?e.range[1]:e.upperDate??e.defaultRange?.[1]??e.initialRange?.[1]??e.defaultUpperDate??e.initialUpperDate:e.mode==="vernier"?e.microRange?e.microRange[1]:e.upperDate??e.defaultMicroRange?.[1]??e.initialMicroRange?.[1]??e.defaultUpperDate??e.initialUpperDate:void 0,X=e.mode==="point"?e.value??e.valueDate??e.defaultValue??e.initialDate:void 0,W=_??(E?b[0]:de(t,y)),me=Y??(E?b[b.length-1]:de(t,w)),ce=e.mode==="point"?X?.getTime():_?.getTime(),oe=e.mode==="range"?Y?.getTime():ce,[Q,B]=r.useMemo(()=>{if(e.mode==="point"){const f=N(X);return[f,f]}const l=N(_),u=N(Y);return[Math.min(l,u),Math.max(l,u)]},[e.mode,ce,oe,N,X,_,Y]),se=e.mode==="point"?e.value!==void 0||e.valueDate!==void 0:e.mode==="range"?e.range!==void 0||e.lowerDate!==void 0||e.upperDate!==void 0:e.microRange!==void 0||e.lowerDate!==void 0||e.upperDate!==void 0,[He,be]=r.useState(()=>[Q,B]);r.useEffect(()=>{se&&be([Q,B])},[se,Q,B]);const[Te,Ce]=r.useState(null),[he,ze]=r.useState(null),je=r.useRef(null);je.current=he;const[k,j]=r.useState("high"),[q,te]=r.useState(null),[L,re]=r.useState(null),ee=Te?Te[0]:se?Q:He[0],ie=Te?Te[1]:se?B:He[1],i=e.mode==="vernier",F=e.mode==="vernier"?e.vernierOrientation??(n?"macro-left":"macro-top"):"macro-top",D=F==="macro-top"||F==="macro-left",we=e.mode==="vernier"?e.showVernierProjection??!0:!1,Ne=e.mode==="vernier"?e.showVernierTicks??!0:!1,Fe=e.mode==="vernier"?e.showHairline??!0:!1,O=i?e.macroUnit??t:t,P=i?e.microUnit??t:t,_t=i?e.macroIsDiscrete??!1:E,Gt=i?e.microIsDiscrete??!1:E,Wt=i?e.macroAllowedDates??s:s,qt=i?e.microAllowedDates??s:s,vt=i?e.formatMacroLabel??e.formatLabel:e.formatLabel,pt=i?e.formatMicroLabel??e.formatLabel:e.formatLabel,Zt=i&&e.macroRange?e.macroRange[0]?.getTime():void 0,Jt=i&&e.macroRange?e.macroRange[1]?.getTime():void 0,La=e.mode!=="point"?e.lowerDate?.getTime():void 0,Ya=e.mode!=="point"?e.upperDate?.getTime():void 0,[De,yt]=r.useState(null),et=r.useRef(null);et.current=De;const[Re,Tt]=r.useState("micro-high"),ve=r.useMemo(()=>i?J(O,le(O,a??new Date(2020,0,1))):0,[i,V,O,a]),nt=r.useMemo(()=>{if(!i)return 1;const l=le(O,o??new Date(2030,0,1)),u=J(O,l);return u<=ve?ve+1:u},[i,I,ve,O,o]),ct=r.useMemo(()=>i?Ft(Wt,O,a,o):[],[i,Wt,O,a,o]),ut=r.useMemo(()=>i?Ft(qt,P,a,o):[],[i,qt,P,a,o]),Be=r.useMemo(()=>i&&e.macroRange?J(O,le(O,e.macroRange[0])):ve,[i,Zt,ve,O]),Xe=r.useMemo(()=>i&&e.macroRange?J(O,le(O,e.macroRange[1])):nt,[i,Jt,nt,O]),ge=r.useMemo(()=>i&&e.macroRange?J(P,le(P,e.macroRange[0])):0,[i,Zt,P]),Ke=r.useMemo(()=>{if(!(i&&e.macroRange))return 1;const l=jt(O,P,e.macroRange[1]),u=J(P,le(P,l));return u<=ge?ge+1:u},[i,Jt,ge,O,P]),ke=r.useMemo(()=>i&&_?J(P,le(P,_)):ge,[i,La,ge,P,_]),Le=r.useMemo(()=>i&&Y?J(P,le(P,Y)):Ke,[i,Ya,Ke,P,Y]),dt=Math.max(1,nt-ve),Me=Math.max(0,Math.min(1,(Be-ve)/dt)),Ye=Math.max(Me,Math.min(1,(Xe-ve)/dt)),mt=Math.max(1,Ke-ge),Pe=Math.max(0,Math.min(1,(ke-ge)/mt)),tt=Math.max(Pe,Math.min(1,(Le-ge)/mt)),Ee=r.useRef(null);r.useEffect(()=>()=>{Ee.current&&clearTimeout(Ee.current)},[]);const Qt=r.useRef(null),Ve=r.useCallback((l,u,f=!1)=>{const v=z.current,R=ne(l),K=ne(u),ae=v.mode==="point"?`${R.getTime()}`:`${R.getTime()}-${K.getTime()}`;if(ae===Qt.current&&!Ee.current)return;const C=()=>{Qt.current=ae,v.mode==="point"?(v.onChangePoint?.(R),v.onChangeValue?.(R),v.onChange?.(R)):v.mode==="range"?(v.onChangeRange?.(R,K),v.onChangeRangeTuple?.([R,K]),v.onChange?.([R,K])):v.mode==="vernier"&&(v.onChangeRange?.(R,K),v.onChangeRangeTuple?.([R,K]),v.onChangeMicroRange?.(R,K),v.onChangeMicroRangeTuple?.([R,K]),v.onChangeMicro?.([R,K]))};f||!v.debounceMs||v.debounceMs===0?(Ee.current&&(clearTimeout(Ee.current),Ee.current=null),C()):(Ee.current&&clearTimeout(Ee.current),Ee.current=setTimeout(()=>{C(),Ee.current=null},v.debounceMs))},[ne]),Ct=r.useCallback(l=>{if(E&&c==="time"&&b.length>1){const v=Math.max(0,Math.min(b.length-1,Math.round(l))),R=b[0].getTime(),ae=b[b.length-1].getTime()-R;if(ae<=0)return 0;const C=b[v].getTime();return Math.max(0,Math.min(100,(C-R)/ae*100))}const u=w-y;if(u<=0)return 0;const f=(l-y)/u*100;return Math.max(0,Math.min(100,f))},[E,c,b,y,w]),Nt=r.useCallback(l=>{const u=Math.max(0,Math.min(100,l));if(E){if(c==="time"&&b.length>1){const R=b[0].getTime(),ae=b[b.length-1].getTime()-R,C=R+u/100*ae;return Bt(b,new Date(C),t)}const v=Math.round(u/100*(b.length-1));return Math.max(0,Math.min(b.length-1,v))}const f=y+u/100*(w-y);return Math.round(f)},[E,c,b,y,w,t]),Se=r.useRef(null),[Sa,ea]=r.useState(0),ta=Sa;r.useEffect(()=>{const l=Se.current;if(!l)return;const u=()=>{const f=l.getBoundingClientRect(),v=n?f.height:f.width;v>0&&ea(R=>Math.abs(R-v)<.5?R:v)};if(u(),typeof ResizeObserver<"u"){const f=new ResizeObserver(v=>{for(const R of v){const K=n?R.contentRect.height:R.contentRect.width;K>0&&ea(ae=>Math.abs(ae-K)<.5?ae:K)}});return f.observe(l),()=>f.disconnect()}return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[n]);const aa=r.useCallback((l,u,f)=>{if(n){const K=f.height>0?f.height:100,ae=f.bottom-u;return Math.max(0,Math.min(100,ae/K*100))}const v=f.width>0?f.width:100,R=l-f.left;return Math.max(0,Math.min(100,R/v*100))},[n]),Rt=r.useCallback((l,u)=>Se.current?aa(l,u,Se.current.getBoundingClientRect()):0,[aa]),kt=r.useRef(null),Ht=r.useRef(null),Ie=r.useRef(null),Pt=r.useRef(null),gt=r.useRef(null),na=r.useCallback(l=>{if(m)return;if(i){const S=Ht.current;if(!S||l.pointerId!==0&&l.pointerId!==S.pointerId||!Se.current)return;const fe=Se.current.getBoundingClientRect(),Ot=n?fe.height:fe.width;if(Ot<=0)return;const Ma=n?l.clientY:l.clientX,xa=Math.max(0,Math.min(1,n?(fe.bottom-Ma)/Ot:(Ma-fe.left)/Ot)),qe=z.current;if(!qe)return;if(S.handle==="macro-low"||S.handle==="macro-high"||S.handle==="macro-connect"){const[ft,ht,Ge]=Na(S.handle,xa,S.startPointerRatio,S.startMacroLowRatio,S.startMacroHighRatio);Ge!==et.current&&(et.current=Ge,yt(Ge),Tt(Ge));let ue,ye;if(_t&&ct.length>0){const Ue=ct.length-1,We=Math.max(0,Math.min(Ue,Math.round(ft*Ue))),Ze=Math.max(We,Math.min(Ue,Math.round(ht*Ue)));ue=ct[We]??new Date,ye=ct[Ze]??new Date}else{const Ue=Math.round(ve+ft*dt),We=Math.round(ve+ht*dt);ue=de(O,Ue),ye=de(O,We)}const bt=`${ue.getTime()}_${ye.getTime()}`;bt!==Pt.current&&(Pt.current=bt,qe.onChangeMacroRange?.(ue,ye),qe.onChangeMacroRangeTuple?.([ue,ye]),qe.onChangeMacro?.([ue,ye]));let $e,Oe;if(S.handle==="macro-connect"){const Ue=le(P,ue),We=jt(O,P,ye);let Ze,lt;if(O==="year"){const Je=ue.getFullYear()-S.startMacroLowDate.getFullYear();Ze=xe("year",S.initialMicroLowDate,Je),lt=xe("year",S.initialMicroHighDate,Je)}else if(O==="month"){const Je=(ue.getFullYear()-S.startMacroLowDate.getFullYear())*12+(ue.getMonth()-S.startMacroLowDate.getMonth());Ze=xe("month",S.initialMicroLowDate,Je),lt=xe("month",S.initialMicroHighDate,Je)}else{const Je=Math.round((ue.getTime()-S.startMacroLowDate.getTime())/864e5);Ze=xe("day",S.initialMicroLowDate,Je),lt=xe("day",S.initialMicroHighDate,Je)}const st=Ue.getTime(),Mt=We.getTime(),wa=S.initialMicroHighDate.getTime()-S.initialMicroLowDate.getTime();let xt=Ze.getTime(),wt=lt.getTime();xt<st&&(xt=st,wt=Math.min(Mt,xt+wa)),wt>Mt&&(wt=Mt,xt=Math.max(st,wt-wa)),$e=le(P,new Date(xt)),Oe=le(P,new Date(wt))}else{const Ue=ue.getTime(),We=jt(O,P,ye).getTime(),Ze=S.initialMicroLowDate.getTime(),lt=S.initialMicroHighDate.getTime(),st=Math.max(Ue,Math.min(We,Ze)),Mt=Math.max(st,Math.min(We,lt));$e=le(P,new Date(st)),Oe=le(P,new Date(Mt))}const At=`${$e.getTime()}_${Oe.getTime()}`;At!==gt.current&&(gt.current=At,qe.onChangeRange?.($e,Oe),qe.onChangeRangeTuple?.([$e,Oe]))}else if(S.handle==="micro-low"||S.handle==="micro-high"||S.handle==="micro-connect"){const[ft,ht,Ge]=Ga(S.handle,xa,S.startPointerRatio,S.startMicroLowRatio,S.startMicroHighRatio);Ge!==et.current&&(et.current=Ge,yt(Ge),Tt(Ge));let ue,ye;if(Gt&&ut.length>0){const $e=ut.length-1,Oe=Math.max(0,Math.min($e,Math.round(ft*$e))),At=Math.max(Oe,Math.min($e,Math.round(ht*$e)));ue=ut[Oe]??new Date,ye=ut[At]??new Date}else{const $e=Math.round(ge+ft*mt),Oe=Math.round(ge+ht*mt);ue=de(P,$e),ye=de(P,Oe)}const bt=`${ue.getTime()}_${ye.getTime()}`;bt!==gt.current&&(gt.current=bt,qe.onChangeRange?.(ue,ye),qe.onChangeRangeTuple?.([ue,ye]))}return}const u=kt.current;if(!u||l.pointerId!==0&&l.pointerId!==u.pointerId||!Se.current)return;const f=Se.current.getBoundingClientRect(),v=n?l.clientY:l.clientX,R=n?f.height:f.width;if(R<=0)return;if(u.handle==="connect"){const S=n?(u.startPointerPos-v)/R:(v-u.startPointerPos)/R,fe=pa(S,u.startLowVal,u.startHighVal,y,w,E,b);if(fe){if(Ie.current&&Ie.current[0]===fe[0]&&Ie.current[1]===fe[1])return;Ie.current=fe,Ce(fe),Ve(fe[0],fe[1],!1)}return}const K=Rt(l.clientX,l.clientY),ae=Nt(K),[C,Z]=Xt(u.handle,ae,u.startLowVal,u.startHighVal,y,w,p);if((!Ie.current||Ie.current[0]!==C||Ie.current[1]!==Z)&&(Ie.current=[C,Z],Ce([C,Z]),Ve(C,Z,!1)),!p&&(u.handle==="low"||u.handle==="high")){const S=_a(u.handle,ae,u.startLowVal,u.startHighVal,p);je.current!==S&&(je.current=S,ze(S),j(S))}},[m,i,n,O,P,_t,Gt,ct,ut,ve,dt,ge,mt,y,w,E,b,Rt,Nt,Ve,p]),ra=r.useCallback(l=>{if(i){Pt.current=null,gt.current=null,Ht.current=null,et.current=null,yt(null);return}const u=kt.current;if(!u||l.pointerId!==0&&l.pointerId!==u.pointerId)return;const f=Ie.current??Te;f&&(Ve(f[0],f[1],!0),be(f)),Ie.current=null,Ce(null),kt.current=null,je.current=null,ze(null)},[i,Te,Ve]),oa=r.useRef(na);oa.current=na;const ia=r.useRef(ra);ia.current=ra;const la=he!==null||De!==null;r.useEffect(()=>{if(!la)return;const l=f=>oa.current(f),u=f=>ia.current(f);return window.addEventListener("pointermove",l),window.addEventListener("pointerup",u),window.addEventListener("pointercancel",u),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",u),window.removeEventListener("pointercancel",u)}},[la]);const Et=r.useCallback((l,u,f)=>{kt.current={pointerId:l,handle:u,startPointerPos:f,startLowVal:ee,startHighVal:ie},je.current=u,ze(u),u!=="connect"&&j(u)},[ee,ie]),sa=r.useCallback((l,u,f)=>{const v=z.current;Ht.current={pointerId:l,handle:u,startPointerRatio:f,startMacroLowRatio:Me,startMacroHighRatio:Ye,startMicroLowRatio:Pe,startMicroHighRatio:tt,startMacroLowEnc:Be,startMacroHighEnc:Xe,startMicroLowEnc:ke,startMicroHighEnc:Le,startMacroLowDate:v.macroRange[0],startMacroHighDate:v.macroRange[1],initialMicroLowDate:W,initialMicroHighDate:me},et.current=u,yt(u),Tt(u)},[Me,Ye,Pe,tt,Be,Xe,ke,Le]),ca=l=>u=>{if(m)return;u.stopPropagation(),u.preventDefault(),j(l);const f=n?u.clientY:u.clientX;Et(u.pointerId,l,f)},rt=l=>u=>{if(m||(u.stopPropagation(),u.preventDefault(),!Se.current))return;const f=Se.current.getBoundingClientRect(),v=n?Math.max(0,Math.min(1,(f.bottom-u.clientY)/(f.height>0?f.height:100))):Math.max(0,Math.min(1,(u.clientX-f.left)/(f.width>0?f.width:100)));sa(u.pointerId,l,v)},$a=l=>{if(m||x)return;l.stopPropagation(),l.preventDefault();const u=n?l.clientY:l.clientX;Et(l.pointerId,"connect",u)},Aa=l=>{if(m)return;if(i){if(!Se.current)return;const C=Se.current.getBoundingClientRect(),Z=n?Math.max(0,Math.min(1,(C.bottom-l.clientY)/(C.height>0?C.height:100))):Math.max(0,Math.min(1,(l.clientX-C.left)/(C.width>0?C.width:100))),S=n?l.clientX-(C.left+C.width/2):l.clientY-(C.top+C.height/2),fe=Ca(Z,S,Me,Ye,Pe,tt,F);sa(l.pointerId,fe,Z);return}const u=Rt(l.clientX,l.clientY),f=Nt(u);let v="low";if(!p){const C=Math.abs(f-ee),Z=Math.abs(f-ie);C<Z?v="low":Z<C?v="high":v=f>ie?"high":"low"}j(v);const[R,K]=Xt(v,f,ee,ie,y,w,p);Ce([R,K]),Ve(R,K,!0);const ae=n?l.clientY:l.clientX;Et(l.pointerId,v,ae)},ja=l=>{if(m||he!==null)return;const u=Rt(l.clientX,l.clientY),f=Nt(u);te(f),re(Ct(f))},Fa=()=>{te(null),re(null)},ua=l=>u=>{if(m)return;j(l);const f=ya(u.key,l,ee,ie,y,w,p,1);f&&(u.preventDefault(),se||be(f),Ve(f[0],f[1],!0))},Lt=l=>u=>{if(m||!i||e.mode!=="vernier")return;Tt(l);let f=0,v=!1,R=!1;switch(u.key){case"ArrowRight":case"ArrowUp":f=1;break;case"ArrowLeft":case"ArrowDown":f=-1;break;case"PageUp":f=5;break;case"PageDown":f=-5;break;case"Home":v=!0;break;case"End":R=!0;break;default:return}u.preventDefault();const K=(C,Z)=>{e.onChangeMacroRange?.(C,Z),e.onChangeMacroRangeTuple?.([C,Z]),e.onChangeMacro?.([C,Z])},ae=(C,Z)=>{e.onChangeRange?.(C,Z),e.onChangeRangeTuple?.([C,Z]),e.onChangeMicroRange?.(C,Z),e.onChangeMicroRangeTuple?.([C,Z]),e.onChangeMicro?.([C,Z])};if(l==="macro-low"){let C;v?C=ve:R?C=Xe:C=Math.max(ve,Math.min(Xe,Be+f)),K(de(O,C),de(O,Xe))}else if(l==="macro-high"){let C;v?C=Be:R?C=nt:C=Math.max(Be,Math.min(nt,Xe+f)),K(de(O,Be),de(O,C))}else if(l==="micro-low"){let C;v?C=ge:R?C=Le:C=Math.max(ge,Math.min(Le,ke+f)),ae(de(P,C),de(P,Le))}else if(l==="micro-high"){let C;v?C=ke:R?C=Ke:C=Math.max(ke,Math.min(Ke,Le+f)),ae(de(P,ke),de(P,C))}},da=r.useCallback(l=>{const u=z.current;if(!u.disabled)if(u.mode==="point"){const f=Math.max(y,Math.min(w,ee+l));se||be([f,f]),Ve(f,f,!0)}else if(u.mode==="vernier"){const f=ke,v=Le,R=ge,K=Ke,ae=v-f;let C=f+l,Z=v+l;if(l<0&&C<R?(C=R,Z=Math.min(K,C+ae)):l>0&&Z>K&&(Z=K,C=Math.max(R,Z-ae)),C!==f||Z!==v){const S=de(P,C),fe=de(P,Z);u.onChangeRange?.(S,fe),u.onChangeRangeTuple?.([S,fe])}}else{const f=ie-ee;let v=ee+l,R=ie+l;l<0&&v<y?(v=y,R=Math.min(w,v+f)):l>0&&R>w&&(R=w,v=Math.max(y,R-f)),v<=R&&(se||be([v,R]),Ve(v,R,!0))}},[ee,ie,y,w,se,Ve,ke,Le,ge,Ke,P]),ot=Ct(ee),it=Ct(ie),Vt=ne(ee),It=ne(ie),pe=r.useMemo(()=>{const l=T==="top"?-18:18;return p||!$||n?{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:l,highOffsetY:l,isSlanted:!1,proximity:0}:Ta(ot,it,ta,T,t)},[p,$,n,ot,it,ta,T,t]),Yt=he==="low"||he!=="high"&&k==="low",St=!p&&(he==="high"||he!=="low"&&k==="high"),Ha=r.useMemo(()=>n?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${pe.lowOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${pe.lowOffsetY}px)`,"--ps-tooltip-rot":`${pe.lowAngleDeg}deg`},[n,pe.lowOffsetX,pe.lowOffsetY,pe.lowAngleDeg]),Pa=r.useMemo(()=>n?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${pe.highOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${pe.highOffsetY}px)`,"--ps-tooltip-rot":`${pe.highAngleDeg}deg`},[n,pe.highOffsetX,pe.highOffsetY,pe.highAngleDeg]),$t=Math.min(ot,it),ma=Math.max(ot,it),Ea=n?{bottom:`${$t}%`,height:`${ma-$t}%`,top:"auto",left:"0",right:"0"}:{left:`${$t}%`,width:`${ma-$t}%`,top:"0",bottom:"0"},Va=Math.max(.01,Ye-Me),ga=Math.max(.06,Math.min(.25,.28*Math.sqrt(Va))),Ia=n?{bottom:`${ot}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:Yt?40:30}:{left:`${ot}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:Yt?40:30},Oa=n?{bottom:`${it}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:St?40:30}:{left:`${it}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:St?40:30},Ua=n?{bottom:`${L}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${L}%`,top:"50%",transform:"translate(-50%, -50%)"},fa=q!==null?ne(q):null,ha=m||(i?ke<=ge:p?ee<=y:ee<=y&&ie<=y),ba=m||(i?Le>=Ke:(p||ee>=w)&&ie>=w),_e=m?"cursor-not-allowed opacity-50":"cursor-pointer";return h.jsxs("div",{style:e.style,className:`period-slider flex select-none items-center gap-2 ${n?"flex-col":"flex-row"} ${M}`,"data-disabled":m?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":n?"vertical":"horizontal","data-label-position":T,"data-color-scheme":U,children:[d&&h.jsx("button",{type:"button",className:`period-slider-stepper-btn relative after:absolute after:inset-[-10px] after:content-[''] ${n?"period-slider-stepper-next period-slider-stepper-up":"period-slider-stepper-prev"} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${_e}`,onClick:()=>da(n?1:-1),disabled:n?ba:ha,"aria-label":n?"1つ後へ":"1つ前へ",children:n?"▲":"◀"}),h.jsx("div",{ref:Se,"data-testid":"period-slider-track","data-orientation":n?"vertical":"horizontal","data-vernier-orientation":i?F:void 0,className:`period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${n?"h-48 w-2":"h-2 w-full"} ${_e}`,onPointerDown:Aa,onPointerMove:ja,onPointerLeave:Fa,children:i?h.jsxs(h.Fragment,{children:[we&&(n?h.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:[h.jsx("defs",{children:h.jsxs("linearGradient",{id:A,x1:"0",y1:"0",x2:"1",y2:"0",children:[h.jsx("stop",{offset:"0%",stopColor:D?H.macro:H.micro,stopOpacity:"0.28"}),h.jsx("stop",{offset:"100%",stopColor:D?H.micro:H.macro,stopOpacity:ga})]})}),h.jsx("polygon",{points:D?`12,${(1-Ye)*100} 12,${(1-Me)*100} 20,100 20,0`:`12,0 12,100 20,${(1-Me)*100} 20,${(1-Ye)*100}`,fill:`url(#${A})`})]}):h.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[h.jsx("defs",{children:h.jsxs("linearGradient",{id:A,x1:"0",y1:"0",x2:"0",y2:"1",children:[h.jsx("stop",{offset:"0%",stopColor:D?H.macro:H.micro,stopOpacity:"0.28"}),h.jsx("stop",{offset:"100%",stopColor:D?H.micro:H.macro,stopOpacity:ga})]})}),h.jsx("polygon",{points:D?`${Me*100},12 ${Ye*100},12 100,20 0,20`:`0,12 100,12 ${Ye*100},20 ${Me*100},20`,fill:`url(#${A})`})]})),h.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:n?{bottom:`calc(${Me*100}% - 8px)`,height:`calc(${Math.max(0,(Ye-Me)*100)}% + 16px)`}:{left:`calc(${Me*100}% - 8px)`,width:`calc(${Math.max(0,(Ye-Me)*100)}% + 16px)`},onPointerDown:rt("macro-connect")}),h.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:n?{bottom:`calc(${Pe*100}% - 8px)`,height:`calc(${Math.max(0,(tt-Pe)*100)}% + 16px)`}:{left:`calc(${Pe*100}% - 8px)`,width:`calc(${Math.max(0,(tt-Pe)*100)}% + 16px)`},onPointerDown:rt("micro-connect")}),Ne&&h.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>h.jsx("div",{className:"period-slider-tick period-slider-tick-macro",style:n?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>h.jsx("div",{className:"period-slider-tick period-slider-tick-micro",style:n?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),h.jsxs("div",{tabIndex:m?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"マクロ開始時期","aria-disabled":m?"true":void 0,"aria-valuemin":ve,"aria-valuemax":Xe,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(e.macroRange[0],O):at(O,e.macroRange[0],vt),"aria-orientation":n?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${n?"is-vertical":""} group absolute touch-none ${n?D?"after:absolute after:-inset-y-3 after:right-0 after:-left-3":"after:absolute after:-inset-y-3 after:-right-3 after:left-0":D?"after:absolute after:-inset-x-3 after:-top-3 after:bottom-0":"after:absolute after:-inset-x-3 after:top-0 after:-bottom-3"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${_e}`,style:n?{bottom:`${Me*100}%`,left:D?0:"auto",right:D?"auto":0,transform:D?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:De==="macro-low"||Re==="macro-low"?30:15}:{left:`${Me*100}%`,top:D?0:"auto",bottom:D?"auto":0,transform:D?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:De==="macro-low"||Re==="macro-low"?30:15},onPointerDown:rt("macro-low"),onKeyDown:Lt("macro-low"),"data-active":De==="macro-low"?"true":void 0,"data-front":Re==="macro-low"?"true":void 0,"data-vernier-pos":n?D?"left":"right":D?"top":"bottom","data-handle-type":"macro-low",children:[h.jsx(Dt,{type:"macro",isTop:D,isVertical:n,isLeft:D}),Fe&&h.jsx("div",{className:"period-slider-hairline"}),h.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Qe(O,e.macroRange[0],vt)})]}),h.jsxs("div",{tabIndex:m?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"マクロ終了時期","aria-disabled":m?"true":void 0,"aria-valuemin":Be,"aria-valuemax":nt,"aria-valuenow":Xe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(e.macroRange[1],O):at(O,e.macroRange[1],vt),"aria-orientation":n?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${n?"is-vertical":""} group absolute touch-none ${n?D?"after:absolute after:-inset-y-3 after:right-0 after:-left-3":"after:absolute after:-inset-y-3 after:-right-3 after:left-0":D?"after:absolute after:-inset-x-3 after:-top-3 after:bottom-0":"after:absolute after:-inset-x-3 after:top-0 after:-bottom-3"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${_e}`,style:n?{bottom:`${Ye*100}%`,left:D?0:"auto",right:D?"auto":0,transform:D?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:De==="macro-high"||Re==="macro-high"?30:15}:{left:`${Ye*100}%`,top:D?0:"auto",bottom:D?"auto":0,transform:D?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:De==="macro-high"||Re==="macro-high"?30:15},onPointerDown:rt("macro-high"),onKeyDown:Lt("macro-high"),"data-active":De==="macro-high"?"true":void 0,"data-front":Re==="macro-high"?"true":void 0,"data-vernier-pos":n?D?"left":"right":D?"top":"bottom","data-handle-type":"macro-high",children:[h.jsx(Dt,{type:"macro",isTop:D,isVertical:n,isLeft:D}),Fe&&h.jsx("div",{className:"period-slider-hairline"}),h.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Qe(O,e.macroRange[1],vt)})]}),h.jsxs("div",{tabIndex:m?-1:0,role:"slider","aria-label":e.lowerAriaLabel??"ミクロ開始時期","aria-disabled":m?"true":void 0,"aria-valuemin":ge,"aria-valuemax":Le,"aria-valuenow":ke,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(W,P):at(P,W,pt),"aria-orientation":n?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${n?"is-vertical":""} group absolute touch-none ${n?D?"after:absolute after:-inset-y-3 after:-right-3 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-3":D?"after:absolute after:-inset-x-3 after:top-0 after:-bottom-3":"after:absolute after:-inset-x-3 after:-top-3 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${_e}`,style:n?{bottom:`${Pe*100}%`,left:D?"auto":0,right:D?0:"auto",transform:D?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:De==="micro-low"||Re==="micro-low"?30:20}:{left:`${Pe*100}%`,top:D?"auto":0,bottom:D?0:"auto",transform:D?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:De==="micro-low"||Re==="micro-low"?30:20},onPointerDown:rt("micro-low"),onKeyDown:Lt("micro-low"),"data-active":De==="micro-low"?"true":void 0,"data-front":Re==="micro-low"?"true":void 0,"data-vernier-pos":n?D?"right":"left":D?"bottom":"top","data-handle-type":"micro-low",children:[h.jsx(Dt,{type:"micro",isTop:!D,isVertical:n,isLeft:!D}),Fe&&h.jsx("div",{className:"period-slider-hairline"}),h.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Qe(P,W,pt)})]}),h.jsxs("div",{tabIndex:m?-1:0,role:"slider","aria-label":e.upperAriaLabel??"ミクロ終了時期","aria-disabled":m?"true":void 0,"aria-valuemin":ke,"aria-valuemax":Ke,"aria-valuenow":Le,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(me,P):at(P,me,pt),"aria-orientation":n?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${n?"is-vertical":""} group absolute touch-none ${n?D?"after:absolute after:-inset-y-3 after:-right-3 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-3":D?"after:absolute after:-inset-x-3 after:top-0 after:-bottom-3":"after:absolute after:-inset-x-3 after:-top-3 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${_e}`,style:n?{bottom:`${tt*100}%`,left:D?"auto":0,right:D?0:"auto",transform:D?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:De==="micro-high"||Re==="micro-high"?30:20}:{left:`${tt*100}%`,top:D?"auto":0,bottom:D?0:"auto",transform:D?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:De==="micro-high"||Re==="micro-high"?30:20},onPointerDown:rt("micro-high"),onKeyDown:Lt("micro-high"),"data-active":De==="micro-high"?"true":void 0,"data-front":Re==="micro-high"?"true":void 0,"data-vernier-pos":n?D?"right":"left":D?"bottom":"top","data-handle-type":"micro-high",children:[h.jsx(Dt,{type:"micro",isTop:!D,isVertical:n,isLeft:!D}),Fe&&h.jsx("div",{className:"period-slider-hairline"}),h.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Qe(P,me,pt)})]})]}):h.jsxs(h.Fragment,{children:[!x&&h.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full bg-blue-500 hover:bg-blue-600 dark:bg-blue-400",style:Ea,onPointerDown:$a}),G&&E&&b.length>1&&h.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:b.map(l=>{const u=J(t,l),f=b.findIndex(K=>J(t,K)===u),v=Ct(f),R=n?{bottom:`${v}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${v}%`,top:"50%",transform:"translate(-50%, -50%)"};return h.jsx("div",{className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full bg-slate-400/60 dark:bg-slate-500/60",style:R},`tick-${u}`)})}),!m&&q!==null&&L!==null&&he===null&&fa&&h.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute z-20 h-2 w-2",style:Ua,children:[h.jsx("div",{className:"period-slider-hover-dot h-full w-full rounded-full border border-white/80 bg-sky-400/80 shadow-[0_0_6px_#38bdf8] dark:border-slate-800 dark:bg-sky-300/80"}),h.jsx("div",{className:`period-slider-hover-tooltip ${T==="bottom"&&!n?"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:Qe(t,fa,e.formatLabel)})]}),h.jsxs("div",{tabIndex:m?-1:0,role:"slider","aria-label":p?e.pointAriaLabel??"選択時期":e.lowerAriaLabel??"開始時期","aria-disabled":m?"true":void 0,"aria-valuemin":y,"aria-valuemax":p?w:ie,"aria-valuenow":ee,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Vt,t):at(t,Vt,e.formatLabel),"aria-orientation":n?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${_e}`,style:Ia,onPointerDown:ca("low"),onKeyDown:ua("low"),"data-active":he==="low"?"true":void 0,"data-front":Yt?"true":void 0,children:[h.jsx("div",{className:"period-slider-knob h-full w-full rounded-full border-2 border-white bg-blue-600 shadow-md group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-blue-400"}),g!=="hover"&&h.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":T,"data-slanted":pe.isSlanted?"true":void 0,"data-front":Yt?"true":void 0,style:Ha,children:Qe(t,Vt,e.formatLabel)})]}),!p&&h.jsxs("div",{tabIndex:m?-1:0,role:"slider","aria-label":e.upperAriaLabel??"終了時期","aria-disabled":m?"true":void 0,"aria-valuemin":ee,"aria-valuemax":w,"aria-valuenow":ie,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(It,t):at(t,It,e.formatLabel),"aria-orientation":n?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${_e}`,style:Oa,onPointerDown:ca("high"),onKeyDown:ua("high"),"data-active":he==="high"?"true":void 0,"data-front":St?"true":void 0,children:[h.jsx("div",{className:"period-slider-knob h-full w-full rounded-full border-2 border-white bg-blue-600 shadow-md group-focus-visible:ring-2 group-focus-visible:ring-blue-600 group-focus-visible:ring-offset-2 dark:border-slate-800 dark:bg-blue-400"}),g!=="hover"&&h.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${g==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":g,"data-label-position":T,"data-slanted":pe.isSlanted?"true":void 0,"data-front":St?"true":void 0,style:Pa,children:Qe(t,It,e.formatLabel)})]})]})}),d&&h.jsx("button",{type:"button",className:`period-slider-stepper-btn relative after:absolute after:inset-[-10px] after:content-[''] ${n?"period-slider-stepper-prev period-slider-stepper-down":"period-slider-stepper-next"} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${_e}`,onClick:()=>da(n?-1:1),disabled:n?ha:ba,"aria-label":n?"1つ前へ":"1つ後へ",children:n?"▼":"▶"})]})},Ut=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let a=0;a<e.length;a++)if(e[a].getTime()!==t[a].getTime())return!1;return!0},qa=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const a=Object.keys(e),o=Object.keys(t);if(a.length!==o.length)return!1;for(const s of a)if(e[s]!==t[s])return!1;return!0},Za=(e,t)=>{if(e===t)return!0;if(e.mode!==t.mode||e.unit!==t.unit||(e.minDate?.getTime()??null)!==(t.minDate?.getTime()??null)||(e.maxDate?.getTime()??null)!==(t.maxDate?.getTime()??null)||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.preventCollisionSlant!==t.preventCollisionSlant||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||!qa(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.lowerAriaLabel!==t.lowerAriaLabel||e.upperAriaLabel!==t.upperAriaLabel||e.pointAriaLabel!==t.pointAriaLabel||e.macroLowerAriaLabel!==t.macroLowerAriaLabel||e.macroUpperAriaLabel!==t.macroUpperAriaLabel||e.formatAriaValueText!==t.formatAriaValueText||!Ut(e.allowedDates,t.allowedDates))return!1;if(e.mode==="point"&&t.mode==="point"){const a=e.value?.getTime()??e.valueDate?.getTime()??null,o=t.value?.getTime()??t.valueDate?.getTime()??null;return!(a!==o||e.onChangePoint!==t.onChangePoint||e.onChangeValue!==t.onChangeValue||e.onChange!==t.onChange)}if(e.mode==="range"&&t.mode==="range"){const a=e.range?.[0]?.getTime()??e.lowerDate?.getTime()??null,o=e.range?.[1]?.getTime()??e.upperDate?.getTime()??null,s=t.range?.[0]?.getTime()??t.lowerDate?.getTime()??null,c=t.range?.[1]?.getTime()??t.upperDate?.getTime()??null;return!(a!==s||o!==c||e.onChangeRange!==t.onChangeRange||e.onChangeRangeTuple!==t.onChangeRangeTuple||e.onChange!==t.onChange)}if(e.mode==="vernier"&&t.mode==="vernier"){const a=e.microRange?.[0]?.getTime()??e.lowerDate?.getTime()??null,o=e.microRange?.[1]?.getTime()??e.upperDate?.getTime()??null,s=t.microRange?.[0]?.getTime()??t.lowerDate?.getTime()??null,c=t.microRange?.[1]?.getTime()??t.upperDate?.getTime()??null;if(a!==s||o!==c)return!1;const m=e.macroRange?.[0]?.getTime()??null,M=e.macroRange?.[1]?.getTime()??null,d=t.macroRange?.[0]?.getTime()??null,g=t.macroRange?.[1]?.getTime()??null;return!(m!==d||M!==g||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.adaptiveExpand!==t.adaptiveExpand||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.onChangeRange!==t.onChangeRange||e.onChangeRangeTuple!==t.onChangeRangeTuple||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMicroRangeTuple!==t.onChangeMicroRangeTuple||e.onChangeMicro!==t.onChangeMicro||e.onChangeMacroRange!==t.onChangeMacroRange||e.onChangeMacroRangeTuple!==t.onChangeMacroRangeTuple||e.onChangeMacro!==t.onChangeMacro||!Ut(e.macroAllowedDates,t.macroAllowedDates)||!Ut(e.microAllowedDates,t.microAllowedDates))}return!1},Ra=r.memo(Wa,Za);Ra.displayName="PeriodSlider";function Kt(e,t,a){return t&&e<t?t:a&&e>a?a:e}function Ja(e){const{unit:t,initialRange:a,defaultRange:o,minDate:s,maxDate:c,onChangeRange:m,onChangeRangeTuple:M,onChange:d,...g}=e,T=a??o??[s??new Date,c??new Date],$=r.useRef(T),[n,x]=r.useState(T),G=r.useRef(n);G.current=n;const U=r.useRef(m);U.current=m;const H=r.useRef(M);H.current=M;const A=r.useRef(d);A.current=d;const z=r.useCallback(N=>{let Y=G.current[1];N.getTime()>Y.getTime()&&(Y=N);const X=[N,Y];x(X),U.current?.(X[0],X[1]),H.current?.(X),A.current?.(X)},[]),V=r.useCallback(N=>{let Y=G.current[0];N.getTime()<Y.getTime()&&(Y=N);const X=[Y,N];x(X),U.current?.(X[0],X[1]),H.current?.(X),A.current?.(X)},[]),I=r.useCallback((N,_)=>{const Y=[N,_];x(Y),U.current?.(N,_),H.current?.(Y),A.current?.(Y)},[]),b=r.useCallback(N=>{x(N),U.current?.(N[0],N[1]),H.current?.(N),A.current?.(N)},[]),E=r.useCallback(N=>{const _=G.current,Y=xe(t,_[0],N),X=xe(t,_[1],N),W=Kt(Y,s,c),me=Kt(X,s,c),ce=[W,me];x(ce),U.current?.(ce[0],ce[1]),H.current?.(ce),A.current?.(ce)},[t,s,c]),y=r.useCallback(()=>{const N=$.current;x(N),U.current?.(N[0],N[1]),H.current?.(N),A.current?.(N)},[]),w=r.useMemo(()=>({value:n[0],onChange:z,minDate:s,maxDate:n[1],unit:t}),[n[0],n[1],z,s,t]),p=r.useMemo(()=>({value:n[1],onChange:V,minDate:n[0],maxDate:c,unit:t}),[n[0],n[1],V,c,t]),ne=r.useMemo(()=>({...g,mode:"range",unit:t,range:n,minDate:s,maxDate:c,onChangeRange:I,onChangeRangeTuple:b,onChange:b}),[g,t,n,s,c,I,b]);return{range:n,lowerDate:n[0],upperDate:n[1],setRange:x,setLowerDate:z,setUpperDate:V,shiftRange:E,resetRange:y,startSelectorProps:w,endSelectorProps:p,sliderProps:ne}}function Qa(e){const{unit:t,initialValue:a,initialDate:o,defaultValue:s,minDate:c,maxDate:m,onChangePoint:M,onChangeValue:d,onChange:g,...T}=e,$=a??o??s??c??new Date,n=r.useRef($),[x,G]=r.useState($),U=r.useRef(x);U.current=x;const H=r.useRef(M);H.current=M;const A=r.useRef(d);A.current=d;const z=r.useRef(g);z.current=g;const V=r.useCallback(w=>{G(w),H.current?.(w),A.current?.(w),z.current?.(w)},[]),I=r.useCallback(w=>{const p=U.current,ne=xe(t,p,w),N=Kt(ne,c,m);G(N),H.current?.(N),A.current?.(N),z.current?.(N)},[t,c,m]),b=r.useCallback(()=>{const w=n.current;G(w),H.current?.(w),A.current?.(w),z.current?.(w)},[]),E=r.useMemo(()=>({value:x,onChange:V,minDate:c,maxDate:m,unit:t}),[x,V,c,m,t]),y=r.useMemo(()=>({...T,mode:"point",unit:t,value:x,minDate:c,maxDate:m,onChangePoint:V,onChangeValue:V,onChange:V}),[T,t,x,c,m,V]);return{value:x,setValue:G,shiftValue:I,resetValue:b,selectorProps:E,sliderProps:y}}function en(e){const{minDate:t,maxDate:a,initialMacroRange:o,defaultMacroRange:s,initialMicroRange:c,defaultMicroRange:m,unit:M="month",macroUnit:d=M,microUnit:g=M,onChangeMacroRange:T,onChangeMacroRangeTuple:$,onChangeMacro:n,onChangeRange:x,onChangeRangeTuple:G,onChangeMicroRange:U,onChangeMicroRangeTuple:H,onChangeMicro:A,...z}=e,V=o??s??[t,a],I=c??m??V,b=r.useRef(V),E=r.useRef(I),[y,w]=r.useState(V),[p,ne]=r.useState(I),N=r.useRef(y);N.current=y;const _=r.useRef(p);_.current=p;const Y=r.useCallback((k,j)=>{w([k,j]),T?.(k,j),$?.([k,j]),n?.([k,j])},[T,$,n]),X=r.useCallback(k=>{Y(k[0],k[1])},[Y]),W=r.useCallback((k,j)=>{ne([k,j]),x?.(k,j),G?.([k,j]),U?.(k,j),H?.([k,j]),A?.([k,j])},[x,G,U,H,A]),me=r.useCallback(k=>{W(k[0],k[1])},[W]),ce=r.useCallback(k=>{const j=N.current[1],q=k<t?t:k,te=k>j?k:j;Y(q,te)},[t,Y]),oe=r.useCallback(k=>{const j=N.current[0],q=k>a?a:k,te=k<j?k:j;Y(te,q)},[a,Y]),Q=r.useCallback(k=>{const j=N.current,q=_.current,te=k<j[0]?j[0]:k,L=k>q[1]?k:q[1];W(te,L)},[W]),B=r.useCallback(k=>{const j=N.current,q=_.current,te=k>j[1]?j[1]:k,L=k<q[0]?k:q[0];W(L,te)},[W]),se=r.useCallback(k=>{const j=N.current,q=xe(d,j[0],k),te=xe(d,j[1],k);q<t||te>a||Y(q,te)},[d,t,a,Y]),He=r.useCallback(k=>{const j=N.current,q=_.current,te=xe(g,q[0],k),L=xe(g,q[1],k);te<j[0]||L>j[1]||W(te,L)},[g,W]),be=r.useCallback(()=>{const[k,j]=b.current,[q,te]=E.current;Y(k,j),W(q,te)},[Y,W]),Te=r.useMemo(()=>({value:y[0],onChange:ce,minDate:t,maxDate:y[1],unit:d}),[y,ce,t,d]),Ce=r.useMemo(()=>({value:y[1],onChange:oe,minDate:y[0],maxDate:a,unit:d}),[y,oe,a,d]),he=r.useMemo(()=>({value:p[0],onChange:Q,minDate:y[0],maxDate:p[1],unit:g}),[p,Q,y,g]),ze=r.useMemo(()=>({value:p[1],onChange:B,minDate:p[0],maxDate:y[1],unit:g}),[p,B,y,g]),je=r.useMemo(()=>({...z,mode:"vernier",unit:M,macroUnit:d,microUnit:g,minDate:t,maxDate:a,macroRange:y,microRange:p,onChangeMacroRange:Y,onChangeMacroRangeTuple:X,onChangeMacro:X,onChangeRange:W,onChangeRangeTuple:me,onChangeMicroRange:W,onChangeMicroRangeTuple:me,onChangeMicro:me}),[z,M,d,g,t,a,y,p,Y,X,W,me]);return{macroRange:y,setMacroRange:w,microRange:p,setMicroRange:ne,setMacroLowerDate:ce,setMacroUpperDate:oe,setMicroLowerDate:Q,setMicroUpperDate:B,shiftMacroRange:se,shiftMicroRange:He,resetVernier:be,macroStartSelectorProps:Te,macroEndSelectorProps:Ce,microStartSelectorProps:he,microEndSelectorProps:ze,sliderProps:je}}const tn=e=>{const{value:t,initialDate:a,onChange:o,children:s,minYear:c,maxYear:m,minDate:M,maxDate:d,className:g="",style:T,disabled:$=!1,prevYearAriaLabel:n="前年",nextYearAriaLabel:x="翌年",selectAriaLabel:G="会計年"}=e,U=t??a,[H,A]=r.useState(()=>(U??new Date).getFullYear()),z=M?.getTime(),V=d?.getTime(),I=r.useMemo(()=>{if(c!==void 0)return c;if(M)return M.getFullYear()},[c,z]),b=r.useMemo(()=>{if(m!==void 0)return m;if(d)return d.getFullYear()},[m,V]),E=t!==void 0,y=E?t&&!Number.isNaN(t.getTime())?t.getFullYear():I??new Date().getFullYear():H,w=U?.getTime();r.useEffect(()=>{!E&&U&&!Number.isNaN(U.getTime())&&A(U.getFullYear())},[E,w]);const p=oe=>{if($)return;let Q=oe;I!==void 0&&Q<I&&(Q=I),b!==void 0&&Q>b&&(Q=b),E||A(Q);const B=new Date(Q,0,1);B.setFullYear(Q),o?.(B,Q)},ne=$||I!==void 0&&y-1<I,N=$||b!==void 0&&y+1>b,_=I??Math.min(y-10,y),Y=b??Math.max(y+1,y),X=Math.min(_,y),W=Math.max(Y,y),me=`${X}_${W}`,ce=r.useMemo(()=>{const oe=[];for(let Q=W;Q>=X;Q--)oe.push(Q);return oe},[me]);return h.jsxs("div",{className:`inline-flex w-32 items-center ${g}`,style:T,children:[h.jsx("button",{type:"button","aria-label":n,disabled:ne,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:()=>p(y-1),children:h.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),h.jsx("select",{"aria-label":G,disabled:$,className:"mx-1 my-auto 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:oe=>{oe.target.value&&p(Number(oe.target.value))},children:ce.map(oe=>h.jsx("option",{value:oe,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},oe))}),h.jsx("button",{type:"button","aria-label":x,disabled:N,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:()=>p(y+1),children:h.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),s]})},ka=r.memo(tn,(e,t)=>{const a=e.value??e.initialDate,o=t.value??t.initialDate,s=a&&!Number.isNaN(a.getTime())?a.getFullYear():null,c=o&&!Number.isNaN(o.getTime())?o.getFullYear():null;return!(s!==c||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.minDate?.getFullYear()!==t.minDate?.getFullYear()||e.maxDate?.getFullYear()!==t.maxDate?.getFullYear()||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel)});ka.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=zt;exports.DateSelector=Da;exports.MonthSelector=va;exports.PeriodSlider=Ra;exports.YearSelector=ka;exports.addUnit=xe;exports.calculateConnectDragValues=pa;exports.calculateHandleDragValues=Xt;exports.calculateKeyboardActionValues=ya;exports.calculateLabelSlant=Ta;exports.calculateVernierMacroDrag=Na;exports.decode=de;exports.encode=J;exports.findNearestDateIndex=Bt;exports.formatLabel=Qe;exports.formatScreenReaderLabel=at;exports.getMacroWindowEndDate=jt;exports.getSortedAllowedDates=Ft;exports.normalizeDateByUnit=le;exports.resolveVernierTargetHandle=Ca;exports.usePeriodSliderPoint=Qa;exports.usePeriodSliderRange=Ja;exports.useVernierSlider=en;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),ge=require("date-fns"),n=require("react"),ca={"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"}},ct=e=>e instanceof Date&&!Number.isNaN(e.getTime()),he=e=>e instanceof Date?Number.isNaN(e.getTime())?"Invalid Date":e.toISOString():String(e),Oe=(e,t)=>{if(!ct(t))throw new RangeError(`normalizeDateByUnit: d must be a valid Date (received: ${he(t)})`);const r=new Date(t.getTime());return e==="year"?(r.setMonth(0,1),r.setHours(0,0,0,0)):(e==="month"&&r.setDate(1),r.setHours(0,0,0,0)),r},Q=(e,t)=>{const r=Oe(e,t),a=r.getFullYear(),o=r.getMonth()+1,c=r.getDate();return e==="year"?a:e==="month"?a*12+(o-1):Math.floor(Date.UTC(a,o-1,c)/(1440*60*1e3))},oe=(e,t)=>{if(e==="year")return new Date(t,0,1);if(e==="month"){const a=Math.floor(t/12),o=t%12;return new Date(a,o,1)}const r=new Date(t*24*60*60*1e3);return new Date(r.getUTCFullYear(),r.getUTCMonth(),r.getUTCDate())},Te=(e,t,r)=>{if(!ct(t))throw new RangeError(`addUnit: d must be a valid Date (received: ${he(t)})`);return e==="year"?ge.addYears(t,r):e==="month"?ge.addMonths(t,r):ge.addDays(t,r)},st=(e,t,r)=>{if(!ct(r))throw new RangeError(`getMacroWindowEndDate: d must be a valid Date (received: ${he(r)})`);if(e===t)return Oe(t,r);const a=r.getFullYear(),o=r.getMonth();if(e==="year"){if(t==="month")return new Date(a,11,1);if(t==="day")return new Date(a,11,31)}return e==="month"&&t==="day"?new Date(a,o+1,0):Oe(t,r)},Ba={year:{year:"numeric"},month:{year:"numeric",month:"2-digit"},day:{year:"numeric",month:"2-digit",day:"2-digit"}},ea=new Map,za=(e,t)=>{const r=`${e}\0${t}`,a=ea.get(r);if(a!==void 0)return a;const o=new Intl.DateTimeFormat(t,Ba[e]);return ea.set(r,o),o},_a=(e,t)=>{const r=String(t.getFullYear()).padStart(4,"0");if(e==="year")return r;const a=String(t.getMonth()+1).padStart(2,"0");if(e==="month")return`${r}-${a}`;const o=String(t.getDate()).padStart(2,"0");return`${r}-${a}-${o}`},Le=(e,t,r,a)=>ct(t)?r?r(t):a===void 0?_a(e,t):za(e,a).format(t):"",Mt=(e,t,r,a)=>Le(e,t,r,a),at=(e,t,r)=>{if(!e||e.length===0||e.length===1)return 0;const a=Q(r,t);let o=0,c=e.length-1;if(a<=Q(r,e[o]))return 0;if(a>=Q(r,e[c]))return c;for(;o<=c;){const b=o+c>>1,w=Q(r,e[b]);if(w===a)return b;w<a?o=b+1:c=b-1}const i=Math.abs(Q(r,e[o])-a),m=Math.abs(Q(r,e[c])-a);return i<m?o:c},Yt=(e,t,r,a)=>{if(!Array.isArray(e)||e.length===0)return[];const o=Q(t,r),c=Q(t,a),i=new Map;for(const m of e){const b=Oe(t,m),w=Q(t,b);w<o||w>c||i.has(w)||i.set(w,b)}if(i.size===0)throw new RangeError(`getSortedAllowedDates: every allowedDates entry falls outside [minDate, maxDate] (minDate: ${he(r)}, maxDate: ${he(a)}, entries: ${e.length})`);return Array.from(i.keys()).sort((m,b)=>m-b).map(m=>i.get(m))},Cr=(e,t,r,a,o,c,i)=>{let m=r,b=a;return i?(m=t,b=t):e==="low"?t>a?(m=a,b=t):m=t:t<r?(b=r,m=t):b=t,[Math.max(o,Math.min(c,m)),Math.max(o,Math.min(c,b))]},ua=(e,t,r,a,o)=>o?"low":e==="low"?t>a?"high":"low":t<r?"low":"high",da=({posDiffPct:e,startLowVal:t,startHighVal:r,rangeMin:a,rangeMax:o,isDiscrete:c,sortedAllowedDates:i,snapMode:m,unit:b})=>{if(c){const B=i.length-1;if(B<=0)return[0,0];const W=Math.max(0,Math.min(B,Math.round(t))),D=Math.max(W,Math.min(B,Math.round(r)));if(m==="time"){const A=i[0].getTime(),H=i[B].getTime(),T=i[W].getTime(),F=i[D].getTime()-T;let E=T+e*(H-A),g=E+F;E<A&&(E=A,g=A+F),g>H&&(g=H,E=H-F);const S=at(i,new Date(E),b),k=at(i,new Date(g),b);return[S,Math.max(S,k)]}const X=Math.round(e*B);let Y=W+X,J=D+X;return Y<0&&(J+=-Y,Y=0),J>B&&(Y-=J-B,J=B),[Math.max(0,Math.min(B,Y)),Math.max(0,Math.min(B,J))]}const w=B=>Math.max(a,Math.min(o,B)),p=o-a;if(p<=0)return[w(t),w(r)];const y=Math.round(e*p);let u=t+y,v=r+y;return u<a&&(v+=a-u,u=a),v>o&&(u-=v-o,v=o),[w(u),w(v)]},ma=(e,t,r,a,o,c,i,m)=>{let b=0,w=!1,p=!1;switch(e){case"ArrowRight":case"ArrowUp":b=m;break;case"ArrowLeft":case"ArrowDown":b=-m;break;case"PageUp":b=m*5;break;case"PageDown":b=-m*5;break;case"Home":w=!0;break;case"End":p=!0;break;default:return null}if(i){let v=r;return w?v=o:p?v=c:v=Math.max(o,Math.min(c,r+b)),[v,v]}let y=r,u=a;return t==="low"?w?y=o:p?y=a:y=Math.max(o,Math.min(a,r+b)):w?u=r:p?u=c:u=Math.max(r,Math.min(c,a+b)),[y,u]},fa=8,ga=2,ha=16,qa=12,Ka=90,ba=(e,t)=>{const r=t?.estimatedHeightPx??ha,o=fa+(t?.anchorGapY??ga)+r/2,c=e==="top"?-o:o;return{lowAngleDeg:0,highAngleDeg:0,lowOffsetX:0,highOffsetX:0,lowOffsetY:c,highOffsetY:c,isSlanted:!1,proximity:0}},wa=(e,t,r,a="top",o)=>{const c=o?.estimatedWidthPx,i=o?.estimatedHeightPx??ha,m=o?.paddingPx??qa,b=o?.maxAngleDeg??Ka,w=fa+(o?.anchorGapY??ga),p=ba(a,o);if(!(Number.isFinite(r)&&r>0)||c===void 0||!Number.isFinite(c)||c<=0)return p;const y=Math.max(0,t-e)/100*r,u=c+m;if(y>=u)return p;const v=Math.max(0,Math.min(1,(u-y)/u)),W=v*v*v*(v*(v*6-15)+10)*b,D=a==="top"?-W:W,X=W*Math.PI/180,Y=c/2*Math.abs(Math.sin(X))+i/2*Math.abs(Math.cos(X)),J=w+Y,A=a==="top"?-J:+J,H=c*Math.abs(Math.cos(X))+i*Math.abs(Math.sin(X)),T=Math.max(0,(H+m-y)/2);return{lowAngleDeg:D,highAngleDeg:D,lowOffsetX:-T,highOffsetX:T,lowOffsetY:A,highOffsetY:A,isSlanted:v>.001,proximity:v}};function xa(e,t,r,a,o,c,i="macro-top",m=.05){const b=i==="macro-top"||i==="macro-left",w=t<=0;if(b&&w||!(b||w)){const u=Math.abs(e-r),v=Math.abs(e-a);return u<=m&&u<=v?"macro-low":v<=m&&v<u?"macro-high":e>=r&&e<=a?"macro-connect":u<v?"macro-low":"macro-high"}const p=Math.abs(e-o),y=Math.abs(e-c);return p<=m&&p<=y?"micro-low":y<=m&&y<p?"micro-high":e>=o&&e<=c?"micro-connect":p<y?"micro-low":"micro-high"}function Ma(e,t,r,a,o){if(e==="macro-connect"){const i=t-r,m=o-a,b=Math.max(0,Math.min(1-m,a+i)),w=b+m;return[b,w,"macro-connect"]}if(e==="macro-low"){const i=Math.max(0,Math.min(1,t));return i>o?[o,i,"macro-high"]:[i,o,"macro-low"]}const c=Math.max(0,Math.min(1,t));return c<a?[c,a,"macro-low"]:[a,c,"macro-high"]}function va(e,t,r,a,o){if(e==="micro-connect"){const i=t-r,m=o-a,b=Math.max(0,Math.min(1-m,a+i)),w=b+m;return[b,w,"micro-connect"]}if(e==="micro-low"){const i=Math.max(0,Math.min(1,t));return i>o?[o,i,"micro-high"]:[i,o,"micro-low"]}const c=Math.max(0,Math.min(1,t));return c<a?[c,a,"micro-low"]:[a,c,"micro-high"]}const Kt=n.memo(({type:e,isTop:t=!0,isVertical:r=!1,isLeft:a=!0})=>{let o,c;r?(o=a?"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",c=`period-slider-knob period-slider-knob-svg is-vertical ${a?"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",c=`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 f.jsx("svg",{className:c,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:f.jsx("path",{d:o,className:i,shapeRendering:"geometricPrecision",strokeWidth:"1.25"})})});Kt.displayName="VernierKnobSvg";const Xa=(e,t)=>{if(!ct(e))throw new RangeError(`PeriodSlider: minDate is required and must be a valid Date (received: ${he(e)})`);if(!ct(t))throw new RangeError(`PeriodSlider: maxDate is required and must be a valid Date (received: ${he(t)})`);if(t.getTime()<=e.getTime())throw new RangeError(`PeriodSlider: maxDate must be strictly later than minDate (minDate: ${he(e)}, maxDate: ${he(t)})`)},Sr=(e,t)=>{if(!Array.isArray(t)||t.length!==2)throw new RangeError(`PeriodSlider: ${e} is required and must be a [start, end] Date tuple (received: ${he(t)})`);const[r,a]=t;if(!ct(r))throw new RangeError(`PeriodSlider: ${e}[0] must be a valid Date (received: ${he(r)})`);if(!ct(a))throw new RangeError(`PeriodSlider: ${e}[1] must be a valid Date (received: ${he(a)})`);if(a.getTime()<r.getTime())throw new RangeError(`PeriodSlider: ${e} must not be inverted (start: ${he(r)}, end: ${he(a)})`)},Ga=(e,t,r)=>{if(Sr("macroRange",e),t!==void 0)return Sr("microRange",t),t;if(r!==void 0)return Sr("defaultMicroRange",r),r;throw new RangeError("PeriodSlider: vernier mode requires a micro selection; supply microRange (controlled) or defaultMicroRange (uncontrolled)")},dr=(e,t,r,a,o,c,i,m)=>{const b=at(e,a,t),w=at(e,o,t);if(i)return e[b];if(m)return e[w];const p=Math.max(b,Math.min(w,at(e,r,t)+c));return e[p]},Lr=e=>{e.timerId!==null&&clearTimeout(e.timerId),e.timerId=null,e.emit=null},Wa=(e,t)=>{try{Intl.DateTimeFormat.supportedLocalesOf([t])}catch{throw new RangeError(`PeriodSlider: ${e} must be a valid BCP 47 language tag (received: ${JSON.stringify(t)})`)}},ta=()=>{const[e,t]=n.useState(null),r=n.useRef(null),a=n.useCallback(o=>{if(r.current?.disconnect(),r.current=null,o===null){t(null);return}if(typeof ResizeObserver>"u")return;const c=new ResizeObserver(i=>{for(const m of i){const b=m.borderBoxSize?.[0];b!==void 0&&t(w=>w!==null&&Math.abs(w.widthPx-b.inlineSize)<.5&&Math.abs(w.heightPx-b.blockSize)<.5?w:{widthPx:b.inlineSize,heightPx:b.blockSize})}});c.observe(o),r.current=c},[]);return n.useEffect(()=>()=>{r.current?.disconnect(),r.current=null},[]),[a,e]},Ja={horizontal:{decrease:"◀",increase:"▶"},vertical:{decrease:"▼",increase:"▲"}},Za={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"}},Qa=e=>{const{unit:t,minDate:r,maxDate:a,allowedDates:o,snapMode:c="index",disabled:i=!1,className:m="",showStepper:b=!0,tooltipStyle:w="always",labelPosition:p="top",autoSlantLabels:y=!0,isVertical:u=!1,hideConnectBar:v=!1,showTicks:B=!1,colorScheme:W="blue-rose",locale:D,decreaseAriaLabel:X="Decrease",increaseAriaLabel:Y="Increase"}=e;Xa(r,a),D!==void 0&&Wa("locale",D);const J=e.mode==="vernier"?Ga(e.macroRange,e.microRange,e.defaultMicroRange):null,A=ca[W],H=n.useId(),T=n.useRef(e);T.current=e;const F=r.getTime(),E=a.getTime(),g=n.useMemo(()=>Yt(o,t,r,a),[o,t,F,E]),S=g.length>0,{rangeMin:k,rangeMax:j}=n.useMemo(()=>S?{rangeMin:0,rangeMax:g.length-1}:{rangeMin:Q(t,r),rangeMax:Q(t,a)},[S,g,t,F,E]),P=e.mode==="point",te=n.useCallback(l=>{if(S){const s=Math.max(0,Math.min(g.length-1,Math.round(l)));return g[s]}return oe(t,Math.round(l))},[S,g,t]),_=n.useCallback(l=>{if(l===void 0)return k;const s=Oe(t,l);return S?at(g,s,t):Q(t,s)},[S,g,t,k]),[z,ee]=n.useState(()=>J),re=e.mode!=="vernier"?null:e.microRange!==void 0?e.microRange:z,ce=e.mode==="range"?e.range?.[0]??e.defaultRange?.[0]:e.mode==="vernier"?re?.[0]:void 0,Fe=e.mode==="range"?e.range?.[1]??e.defaultRange?.[1]:e.mode==="vernier"?re?.[1]:void 0,ae=e.mode==="point"?e.value??e.defaultValue:void 0,Ge=e.mode==="point"?ae?.getTime():ce?.getTime(),ut=e.mode==="range"?Fe?.getTime():Ge,[Re,be]=n.useMemo(()=>{if(e.mode==="point"){const d=_(ae);return[d,d]}const l=_(ce),s=_(Fe);return[Math.min(l,s),Math.max(l,s)]},[e.mode,Ge,ut,_,ae,ce,Fe]),le=e.mode==="point"?e.value!==void 0:e.mode==="range"?e.range!==void 0:e.microRange!==void 0,[I,O]=n.useState(()=>[Re,be]),[K,se]=n.useState(null),[$,me]=n.useState(null),Ne=n.useRef(null);Ne.current=$;const[We,ie]=n.useState("high"),[we,dt]=n.useState(null),[Et,Wt]=n.useState(null),ue=K?K[0]:le?Re:I[0],de=K?K[1]:le?be:I[1],G=e.mode==="vernier",mt=e.mode==="vernier"?e.vernierOrientation??(u?"macro-left":"macro-top"):"macro-top",R=mt==="macro-top"||mt==="macro-left",Jt=e.mode==="vernier"?e.showVernierProjection??!0:!1,Zt=e.mode==="vernier"?e.showVernierTicks??!0:!1,Dt=e.mode==="vernier"?e.showHairline??!0:!1,U=G?e.macroUnit??t:t,N=G?e.microUnit??t:t,It=G?e.macroIsDiscrete??!1:S,nt=G?e.microIsDiscrete??!1:S,Qt=G?e.macroAllowedDates??o:o,hr=G?e.microAllowedDates??o:o,h=G?e.formatMacroLabel??e.formatLabel:e.formatLabel,C=G?e.formatMicroLabel??e.formatLabel:e.formatLabel,Ae=e.mode==="vernier"?e.macroRange[0].getTime():void 0,pt=e.mode==="vernier"?e.macroRange[1].getTime():void 0,ft=ce?.getTime(),Je=Fe?.getTime(),[pe,er]=n.useState(null),gt=n.useRef(null);gt.current=pe;const[ke,tr]=n.useState("micro-high"),Se=n.useMemo(()=>Q(U,r),[F,U]),yt=n.useMemo(()=>{const l=Q(U,a);if(G&&l<=Se)throw new RangeError(`PeriodSlider: macroUnit "${U}" cannot distinguish minDate from maxDate (minDate: ${he(r)}, maxDate: ${he(a)})`);return l},[G,F,E,Se,U]),Ye=n.useMemo(()=>G?Yt(Qt,U,r,a):[],[G,Qt,U,F,E]),Ue=n.useMemo(()=>e.mode!=="vernier"?Se:Q(U,e.macroRange[0]),[e.mode,Ae,Se,U]),Be=n.useMemo(()=>e.mode!=="vernier"?yt:Q(U,e.macroRange[1]),[e.mode,pt,yt,U]),fe=n.useMemo(()=>e.mode!=="vernier"?Q(N,r):Math.max(Q(N,e.macroRange[0]),Q(N,r)),[e.mode,Ae,N,F]),Ee=n.useMemo(()=>e.mode!=="vernier"?Q(N,a):Math.min(Q(N,st(U,N,e.macroRange[1])),Q(N,a)),[e.mode,pt,U,N,E]),Ie=n.useMemo(()=>G?Yt(hr,N,r,a).filter(s=>{const d=Q(N,s);return d>=fe&&d<=Ee}):[],[G,hr,N,F,E,fe,Ee]),xe=n.useMemo(()=>re===null?fe:Q(N,re[0]),[ft,fe,N,re]),Me=n.useMemo(()=>re===null?Ee:Q(N,re[1]),[Je,Ee,N,re]),jt=n.useMemo(()=>oe(N,xe),[N,xe]),Ht=n.useMemo(()=>oe(N,Me),[N,Me]),Ot=Math.max(1,yt-Se),ve=Math.max(0,Math.min(1,(Ue-Se)/Ot)),$e=Math.max(ve,Math.min(1,(Be-Se)/Ot)),Vt=Math.max(1,Ee-fe),ze=Math.max(0,Math.min(1,(xe-fe)/Vt)),ht=Math.max(ze,Math.min(1,(Me-fe)/Vt)),br=n.useRef({timerId:null,emit:null}),wr=n.useRef({timerId:null,emit:null}),xr=n.useRef({timerId:null,emit:null});n.useEffect(()=>{const l=[br,wr,xr];return()=>{for(const s of l)Lr(s.current)}},[]);const Tt=n.useCallback((l,s,d)=>{Lr(l);const{debounceMs:x}=T.current;if(d||!x||x<=0){s();return}l.emit=s,l.timerId=setTimeout(()=>{l.timerId=null,l.emit=null,s()},x)},[]),Mr=n.useCallback(l=>{const s=l.emit;Lr(l),s?.()},[]),Rt=n.useCallback(l=>new Date(Math.min(Math.max(l.getTime(),F),E)),[F,E]),jr=n.useRef(null),_e=n.useCallback((l,s,d=!1)=>{const x=te(l),L=te(s),Z=T.current.mode==="point"?`${x.getTime()}`:`${x.getTime()}-${L.getTime()}`;if(Z===jr.current&&br.current.timerId===null)return;const ne=()=>{jr.current=Z;const V=T.current;V.mode==="point"?V.onChangePoint?.(x):V.mode==="range"&&V.onChangeRange?.(x,L)};Tt(br.current,ne,d)},[te,Tt]),St=n.useCallback((l,s,d=!1)=>{if(T.current.mode!=="vernier")return;const x=Rt(l),L=Rt(s);Tt(wr.current,()=>{const Z=T.current;Z.mode==="vernier"&&Z.onChangeMacroRange?.(x,L)},d)},[Rt,Tt]),Ze=n.useCallback((l,s,d=!1)=>{const x=T.current;if(x.mode!=="vernier")return;const L=Rt(l),Z=Rt(s);x.microRange===void 0&&ee([L,Z]),Tt(xr.current,()=>{const ne=T.current;ne.mode==="vernier"&&ne.onChangeMicroRange?.(L,Z)},d)},[Rt,Tt]),rr=n.useCallback(l=>{if(S&&c==="time"&&g.length>1){const x=Math.max(0,Math.min(g.length-1,Math.round(l))),L=g[0].getTime(),ne=g[g.length-1].getTime()-L;if(ne<=0)return 0;const V=g[x].getTime();return Math.max(0,Math.min(100,(V-L)/ne*100))}const s=j-k;if(s<=0)return 0;const d=(l-k)/s*100;return Math.max(0,Math.min(100,d))},[S,c,g,k,j]),ar=n.useCallback(l=>{const s=Math.max(0,Math.min(100,l));if(S){if(c==="time"&&g.length>1){const L=g[0].getTime(),ne=g[g.length-1].getTime()-L,V=L+s/100*ne;return at(g,new Date(V),t)}const x=Math.round(s/100*(g.length-1));return Math.max(0,Math.min(g.length-1,x))}const d=k+s/100*(j-k);return Math.round(d)},[S,c,g,k,j,t]),Qe=n.useRef(null),[Hr,Or]=n.useState(0),[La,bt]=ta(),[ka,nr]=ta();n.useEffect(()=>{const l=Qe.current;if(!l)return;const s=()=>{const d=l.getBoundingClientRect(),x=u?d.height:d.width;x>0&&Or(L=>Math.abs(L-x)<.5?L:x)};if(s(),typeof ResizeObserver<"u"){const d=new ResizeObserver(x=>{for(const L of x){const Z=u?L.contentRect.height:L.contentRect.width;Z>0&&Or(ne=>Math.abs(ne-Z)<.5?ne:Z)}});return d.observe(l),()=>d.disconnect()}return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[u]);const wt=n.useCallback((l,s,d)=>{const x=u?d.height:d.width;if(!(Number.isFinite(x)&&x>0))return null;const L=u?d.bottom-s:l-d.left;return Number.isFinite(L)?Math.max(0,Math.min(1,L/x)):null},[u]),Vr=n.useCallback((l,s)=>{const d=Qe.current;if(!d)return null;const x=wt(l,s,d.getBoundingClientRect());return x===null?null:x*100},[wt]),or=n.useRef(null),vr=n.useRef(null),qe=n.useRef(null),Dr=n.useRef(null),Ft=n.useRef(null),Fr=n.useCallback(l=>{if(i)return;if(G){const M=vr.current;if(!M||l.pointerId!==0&&l.pointerId!==M.pointerId||!Qe.current)return;const Ce=wt(l.clientX,l.clientY,Qe.current.getBoundingClientRect());if(Ce===null)return;if(M.handle==="macro-low"||M.handle==="macro-high"||M.handle==="macro-connect"){const[xt,Ut,et]=Ma(M.handle,Ce,M.startPointerRatio,M.startMacroLowRatio,M.startMacroHighRatio);et!==gt.current&&(gt.current=et,er(et),tr(et));let De,je;if(It&&Ye.length>0){const Ke=Ye.length-1,rt=Math.max(0,Math.min(Ke,Math.round(xt*Ke))),it=Math.max(rt,Math.min(Ke,Math.round(Ut*Ke)));De=Ye[rt],je=Ye[it]}else{const Ke=Math.round(Se+xt*Ot),rt=Math.round(Se+Ut*Ot);De=oe(U,Ke),je=oe(U,rt)}const Bt=`${De.getTime()}_${je.getTime()}`;Bt!==Dr.current&&(Dr.current=Bt,St(De,je));let He,tt;if(M.handle==="macro-connect"){const Ke=Oe(N,De),rt=st(U,N,je);let it,Ct;if(U==="year"){const lt=De.getFullYear()-M.startMacroLowDate.getFullYear();it=Te("year",M.initialMicroLowDate,lt),Ct=Te("year",M.initialMicroHighDate,lt)}else if(U==="month"){const lt=(De.getFullYear()-M.startMacroLowDate.getFullYear())*12+(De.getMonth()-M.startMacroLowDate.getMonth());it=Te("month",M.initialMicroLowDate,lt),Ct=Te("month",M.initialMicroHighDate,lt)}else{const lt=Math.round((De.getTime()-M.startMacroLowDate.getTime())/864e5);it=Te("day",M.initialMicroLowDate,lt),Ct=Te("day",M.initialMicroHighDate,lt)}const Pt=Ke.getTime(),zt=rt.getTime(),Qr=M.initialMicroHighDate.getTime()-M.initialMicroLowDate.getTime();let _t=it.getTime(),qt=Ct.getTime();_t<Pt&&(_t=Pt,qt=Math.min(zt,_t+Qr)),qt>zt&&(qt=zt,_t=Math.max(Pt,qt-Qr)),He=Oe(N,new Date(_t)),tt=Oe(N,new Date(qt))}else{const Ke=De.getTime(),rt=st(U,N,je).getTime(),it=M.initialMicroLowDate.getTime(),Ct=M.initialMicroHighDate.getTime(),Pt=Math.max(Ke,Math.min(rt,it)),zt=Math.max(Pt,Math.min(rt,Ct));He=Oe(N,new Date(Pt)),tt=Oe(N,new Date(zt))}const ur=`${He.getTime()}_${tt.getTime()}`;ur!==Ft.current&&(Ft.current=ur,Ze(He,tt))}else if(M.handle==="micro-low"||M.handle==="micro-high"||M.handle==="micro-connect"){const[xt,Ut,et]=va(M.handle,Ce,M.startPointerRatio,M.startMicroLowRatio,M.startMicroHighRatio);et!==gt.current&&(gt.current=et,er(et),tr(et));let De,je;if(nt&&Ie.length>0){const He=Ie.length-1,tt=Math.max(0,Math.min(He,Math.round(xt*He))),ur=Math.max(tt,Math.min(He,Math.round(Ut*He)));De=Ie[tt],je=Ie[ur]}else{const He=Math.round(fe+xt*Vt),tt=Math.round(fe+Ut*Vt);De=oe(N,He),je=oe(N,tt)}const Bt=`${De.getTime()}_${je.getTime()}`;Bt!==Ft.current&&(Ft.current=Bt,Ze(De,je))}return}const s=or.current;if(!s||l.pointerId!==0&&l.pointerId!==s.pointerId||!Qe.current)return;const d=Qe.current.getBoundingClientRect(),x=u?l.clientY:l.clientX,L=u?d.height:d.width;if(!(Number.isFinite(L)&&L>0))return;if(s.handle==="connect"){const M=u?(s.startPointerPos-x)/L:(x-s.startPointerPos)/L,Ce=da({posDiffPct:M,startLowVal:s.startLowVal,startHighVal:s.startHighVal,rangeMin:k,rangeMax:j,isDiscrete:S,sortedAllowedDates:g,snapMode:c,unit:t});if(qe.current&&qe.current[0]===Ce[0]&&qe.current[1]===Ce[1])return;qe.current=Ce,se(Ce),_e(Ce[0],Ce[1],!1);return}const Z=wt(l.clientX,l.clientY,d);if(Z===null)return;const ne=ar(Z*100),[V,q]=Cr(s.handle,ne,s.startLowVal,s.startHighVal,k,j,P);if((!qe.current||qe.current[0]!==V||qe.current[1]!==q)&&(qe.current=[V,q],se([V,q]),_e(V,q,!1)),!P&&(s.handle==="low"||s.handle==="high")){const M=ua(s.handle,ne,s.startLowVal,s.startHighVal,P);Ne.current!==M&&(Ne.current=M,me(M),ie(M))}},[i,G,u,U,N,It,nt,Ye,Ie,Se,Ot,fe,Vt,k,j,S,g,c,t,wt,ar,_e,St,Ze,P]),Ur=n.useCallback(l=>{if(G){Dr.current=null,Ft.current=null,vr.current=null,gt.current=null,er(null),Mr(wr.current),Mr(xr.current);return}const s=or.current;if(!s||l.pointerId!==0&&l.pointerId!==s.pointerId)return;const d=qe.current??K;d&&(_e(d[0],d[1],!0),O(d)),qe.current=null,se(null),or.current=null,Ne.current=null,me(null)},[G,K,_e,Mr]),Br=n.useRef(Fr);Br.current=Fr;const zr=n.useRef(Ur);zr.current=Ur;const _r=$!==null||pe!==null;n.useEffect(()=>{if(!_r)return;const l=d=>Br.current(d),s=d=>zr.current(d);return window.addEventListener("pointermove",l),window.addEventListener("pointerup",s),window.addEventListener("pointercancel",s),()=>{window.removeEventListener("pointermove",l),window.removeEventListener("pointerup",s),window.removeEventListener("pointercancel",s)}},[_r]);const pr=n.useCallback((l,s,d)=>{or.current={pointerId:l,handle:s,startPointerPos:d,startLowVal:ue,startHighVal:de},Ne.current=s,me(s),s!=="connect"&&ie(s)},[ue,de]),qr=n.useCallback((l,s,d)=>{const x=T.current;x.mode==="vernier"&&(vr.current={pointerId:l,handle:s,startPointerRatio:d,startMacroLowRatio:ve,startMacroHighRatio:$e,startMicroLowRatio:ze,startMicroHighRatio:ht,startMacroLowEnc:Ue,startMacroHighEnc:Be,startMicroLowEnc:xe,startMicroHighEnc:Me,startMacroLowDate:x.macroRange[0],startMacroHighDate:x.macroRange[1],initialMicroLowDate:jt,initialMicroHighDate:Ht},gt.current=s,er(s),tr(s))},[ve,$e,ze,ht,Ue,Be,xe,Me,jt,Ht]),Kr=l=>s=>{if(i)return;s.stopPropagation(),s.preventDefault(),ie(l);const d=u?s.clientY:s.clientX;pr(s.pointerId,l,d)},Lt=l=>s=>{if(i)return;s.stopPropagation(),s.preventDefault();const d=Qe.current;if(!d)return;const x=wt(s.clientX,s.clientY,d.getBoundingClientRect());x!==null&&qr(s.pointerId,l,x)},$a=l=>{if(i||v)return;l.stopPropagation(),l.preventDefault();const s=u?l.clientY:l.clientX;pr(l.pointerId,"connect",s)},Ca=l=>{if(i)return;if(G){const V=Qe.current;if(!V)return;const q=V.getBoundingClientRect(),M=wt(l.clientX,l.clientY,q);if(M===null)return;const Ce=u?l.clientX-(q.left+q.width/2):l.clientY-(q.top+q.height/2),xt=xa(M,Ce,ve,$e,ze,ht,mt);qr(l.pointerId,xt,M);return}const s=Vr(l.clientX,l.clientY);if(s===null)return;const d=ar(s);let x="low";if(!P){const V=Math.abs(d-ue),q=Math.abs(d-de);V<q?x="low":q<V?x="high":x=d>de?"high":"low"}ie(x);const[L,Z]=Cr(x,d,ue,de,k,j,P);se([L,Z]),_e(L,Z,!0);const ne=u?l.clientY:l.clientX;pr(l.pointerId,x,ne)},Pa=l=>{if(i||$!==null)return;const s=Vr(l.clientX,l.clientY);if(s===null)return;const d=ar(s);dt(d),Wt(rr(d))},Na=()=>{dt(null),Wt(null)},Xr=l=>s=>{if(i)return;ie(l);const d=ma(s.key,l,ue,de,k,j,P,1);d&&(s.preventDefault(),le||O(d),_e(d[0],d[1],!0))},ir=l=>s=>{if(i||!G||e.mode!=="vernier")return;tr(l);let d=0,x=!1,L=!1;switch(s.key){case"ArrowRight":case"ArrowUp":d=1;break;case"ArrowLeft":case"ArrowDown":d=-1;break;case"PageUp":d=5;break;case"PageDown":d=-5;break;case"Home":x=!0;break;case"End":L=!0;break;default:return}s.preventDefault();const Z=It&&Ye.length>0,ne=nt&&Ie.length>0;if(l==="macro-low"){const V=oe(U,Ue),q=oe(U,Be);if(Z){St(dr(Ye,U,V,Ye[0],q,d,x,L),q,!0);return}let M;x?M=Se:L?M=Be:M=Math.max(Se,Math.min(Be,Ue+d)),St(oe(U,M),q,!0)}else if(l==="macro-high"){const V=oe(U,Ue),q=oe(U,Be);if(Z){St(V,dr(Ye,U,q,V,Ye[Ye.length-1],d,x,L),!0);return}let M;x?M=Ue:L?M=yt:M=Math.max(Ue,Math.min(yt,Be+d)),St(V,oe(U,M),!0)}else if(l==="micro-low"){const V=oe(N,xe),q=oe(N,Me);if(ne){Ze(dr(Ie,N,V,Ie[0],q,d,x,L),q,!0);return}let M;x?M=fe:L?M=Me:M=Math.max(fe,Math.min(Me,xe+d)),Ze(oe(N,M),q,!0)}else if(l==="micro-high"){const V=oe(N,xe),q=oe(N,Me);if(ne){Ze(V,dr(Ie,N,q,V,Ie[Ie.length-1],d,x,L),!0);return}let M;x?M=xe:L?M=Ee:M=Math.max(xe,Math.min(Ee,Me+d)),Ze(V,oe(N,M),!0)}},Aa=n.useCallback(l=>{const s=T.current;if(!s.disabled)if(s.mode==="point"){const d=Math.max(k,Math.min(j,ue+l));le||O([d,d]),_e(d,d,!0)}else if(s.mode==="vernier"){const d=xe,x=Me,L=fe,Z=Ee,ne=x-d;let V=d+l,q=x+l;l<0&&V<L?(V=L,q=Math.min(Z,V+ne)):l>0&&q>Z&&(q=Z,V=Math.max(L,q-ne)),(V!==d||q!==x)&&Ze(oe(N,V),oe(N,q),!0)}else{const d=de-ue;let x=ue+l,L=de+l;l<0&&x<k?(x=k,L=Math.min(j,x+d)):l>0&&L>j&&(L=j,x=Math.max(k,L-d)),x<=L&&(le||O([x,L]),_e(x,L,!0))}},[ue,de,k,j,le,_e,Ze,xe,Me,fe,Ee,N]),kt=rr(ue),$t=rr(de),yr=te(ue),Tr=te(de),Rr=n.useMemo(()=>{if(P)return bt===null?void 0:{estimatedWidthPx:bt.widthPx,estimatedHeightPx:bt.heightPx};if(!(bt===null||nr===null))return{estimatedWidthPx:Math.max(bt.widthPx,nr.widthPx),estimatedHeightPx:Math.max(bt.heightPx,nr.heightPx)}},[P,bt,nr]),ye=n.useMemo(()=>P||!y||u?ba(p,Rr):wa(kt,$t,Hr,p,Rr),[P,y,u,kt,$t,Hr,p,Rr]),lr=$==="low"||$!=="high"&&We==="low",sr=!P&&($==="high"||$!=="low"&&We==="high"),Ya=n.useMemo(()=>u?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${ye.lowOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${ye.lowOffsetY}px)`,"--ps-tooltip-rot":`${ye.lowAngleDeg}deg`},[u,ye.lowOffsetX,ye.lowOffsetY,ye.lowAngleDeg]),Ea=n.useMemo(()=>u?{"--ps-tooltip-origin":"100% 50%","--ps-tooltip-tx":"0px","--ps-tooltip-ty":"-50%","--ps-tooltip-rot":"0deg"}:{"--ps-tooltip-origin":"50% 50%","--ps-tooltip-tx":`calc(-50% + ${ye.highOffsetX}px)`,"--ps-tooltip-ty":`calc(-50% + ${ye.highOffsetY}px)`,"--ps-tooltip-rot":`${ye.highAngleDeg}deg`},[u,ye.highOffsetX,ye.highOffsetY,ye.highAngleDeg]),cr=Math.min(kt,$t),Gr=Math.max(kt,$t),Ia=u?{bottom:`${cr}%`,height:`${Gr-cr}%`,top:"auto",left:"0",right:"0"}:{left:`${cr}%`,width:`${Gr-cr}%`,top:"0",bottom:"0"},ja=Math.max(.01,$e-ve),Wr=Math.max(.06,Math.min(.25,.28*Math.sqrt(ja))),Ha=u?{bottom:`${kt}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:lr?40:30}:{left:`${kt}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:lr?40:30},Oa=u?{bottom:`${$t}%`,left:"50%",transform:"translate(-50%, 50%)",zIndex:sr?40:30}:{left:`${$t}%`,top:"50%",transform:"translate(-50%, -50%)",zIndex:sr?40:30},Va=u?{bottom:`${Et}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${Et}%`,top:"50%",transform:"translate(-50%, -50%)"},Jr=we!==null?te(we):null,Fa=i||(G?xe<=fe:P?ue<=k:ue<=k&&de<=k),Ua=i||(G?Me>=Ee:(P||ue>=j)&&de>=j),ot=i?"cursor-not-allowed opacity-50":"cursor-pointer",Zr=l=>{const s=u?"vertical":"horizontal",d=l==="decrease",x=Za[s][l];return f.jsx("button",{type:"button",className:`period-slider-stepper-btn relative after:absolute after:inset-[-11px] after:content-[''] ${x} flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-slate-300 bg-white font-bold text-[10px] text-slate-700 leading-none shadow-2xs transition-all hover:bg-slate-100 hover:text-indigo-600 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 active:scale-95 disabled:cursor-not-allowed disabled:opacity-30 dark:border-slate-700 dark:bg-slate-800 dark:text-slate-200 dark:hover:bg-slate-700 ${ot}`,onClick:()=>Aa(d?-1:1),disabled:d?Fa:Ua,"aria-label":d?X:Y,children:Ja[s][l]})};return f.jsxs("div",{style:e.style,className:`period-slider flex select-none items-center gap-2 ${u?"flex-col":"flex-row"} ${m}`,"data-disabled":i?"true":void 0,"data-unit":t,"data-mode":e.mode,"data-orientation":u?"vertical":"horizontal","data-label-position":p,"data-color-scheme":W,children:[b&&Zr(u?"increase":"decrease"),f.jsx("div",{ref:Qe,"data-testid":"period-slider-track","data-orientation":u?"vertical":"horizontal","data-vernier-orientation":G?mt:void 0,className:`period-slider-track relative flex-1 touch-none rounded-full bg-slate-200 dark:bg-slate-700 ${u?"h-48 w-2":"h-2 w-full"} ${ot}`,onPointerDown:Ca,onPointerMove:Pa,onPointerLeave:Na,children:G?f.jsxs(f.Fragment,{children:[Jt&&(u?f.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:[f.jsx("defs",{children:f.jsxs("linearGradient",{id:H,x1:"0",y1:"0",x2:"1",y2:"0",children:[f.jsx("stop",{offset:"0%",stopColor:R?A.macro:A.micro,stopOpacity:"0.28"}),f.jsx("stop",{offset:"100%",stopColor:R?A.micro:A.macro,stopOpacity:Wr})]})}),f.jsx("polygon",{points:R?`12,${(1-$e)*100} 12,${(1-ve)*100} 20,100 20,0`:`12,0 12,100 20,${(1-ve)*100} 20,${(1-$e)*100}`,fill:`url(#${H})`})]}):f.jsxs("svg",{className:"period-slider-vernier-projection",role:"presentation","aria-hidden":"true",width:"100%",height:"32",viewBox:"0 0 100 32",preserveAspectRatio:"none",children:[f.jsx("defs",{children:f.jsxs("linearGradient",{id:H,x1:"0",y1:"0",x2:"0",y2:"1",children:[f.jsx("stop",{offset:"0%",stopColor:R?A.macro:A.micro,stopOpacity:"0.28"}),f.jsx("stop",{offset:"100%",stopColor:R?A.micro:A.macro,stopOpacity:Wr})]})}),f.jsx("polygon",{points:R?`${ve*100},12 ${$e*100},12 100,20 0,20`:`0,12 100,12 ${$e*100},20 ${ve*100},20`,fill:`url(#${H})`})]})),f.jsx("div",{"data-testid":"period-slider-connect-macro",className:"period-slider-connect-macro",style:u?{bottom:`calc(${ve*100}% - 8px)`,height:`calc(${Math.max(0,($e-ve)*100)}% + 16px)`}:{left:`calc(${ve*100}% - 8px)`,width:`calc(${Math.max(0,($e-ve)*100)}% + 16px)`},onPointerDown:Lt("macro-connect")}),f.jsx("div",{"data-testid":"period-slider-connect-micro",className:"period-slider-connect-micro",style:u?{bottom:`calc(${ze*100}% - 8px)`,height:`calc(${Math.max(0,(ht-ze)*100)}% + 16px)`}:{left:`calc(${ze*100}% - 8px)`,width:`calc(${Math.max(0,(ht-ze)*100)}% + 16px)`},onPointerDown:Lt("micro-connect")}),Zt&&f.jsxs("div",{className:"period-slider-vernier-ticks pointer-events-none absolute inset-0",children:[[.2,.4,.6,.8].map(l=>f.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"macro",className:"period-slider-tick period-slider-tick-macro",style:u?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`macro-tick-${l}`)),[.1,.2,.3,.4,.5,.6,.7,.8,.9].map(l=>f.jsx("div",{"data-testid":"period-slider-tick","data-tick-scale":"micro",className:"period-slider-tick period-slider-tick-micro",style:u?{bottom:`${l*100}%`}:{left:`${l*100}%`}},`micro-tick-${l}`))]}),f.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.macroLowerAriaLabel??"Macro range start","aria-disabled":i?"true":void 0,"aria-valuemin":Se,"aria-valuemax":Be,"aria-valuenow":Ue,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(e.macroRange[0],U):Mt(U,e.macroRange[0],h,D),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?R?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":R?"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0":"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${ot}`,style:u?{bottom:`${ve*100}%`,left:R?0:"auto",right:R?"auto":0,transform:R?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:pe==="macro-low"||ke==="macro-low"?30:15}:{left:`${ve*100}%`,top:R?0:"auto",bottom:R?"auto":0,transform:R?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:pe==="macro-low"||ke==="macro-low"?30:15},onPointerDown:Lt("macro-low"),onKeyDown:ir("macro-low"),"data-active":pe==="macro-low"?"true":void 0,"data-front":ke==="macro-low"?"true":void 0,"data-vernier-pos":u?R?"left":"right":R?"top":"bottom","data-handle-type":"macro-low",children:[f.jsx(Kt,{type:"macro",isTop:R,isVertical:u,isLeft:R}),Dt&&f.jsx("div",{className:"period-slider-hairline"}),f.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Le(U,e.macroRange[0],h,D)})]}),f.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.macroUpperAriaLabel??"Macro range end","aria-disabled":i?"true":void 0,"aria-valuemin":Ue,"aria-valuemax":yt,"aria-valuenow":Be,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(e.macroRange[1],U):Mt(U,e.macroRange[1],h,D),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?R?"after:absolute after:-inset-y-3 after:right-0 after:-left-4":"after:absolute after:-inset-y-3 after:-right-4 after:left-0":R?"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0":"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${ot}`,style:u?{bottom:`${$e*100}%`,left:R?0:"auto",right:R?"auto":0,transform:R?"translate(-100%, 50%)":"translate(100%, 50%)",zIndex:pe==="macro-high"||ke==="macro-high"?30:15}:{left:`${$e*100}%`,top:R?0:"auto",bottom:R?"auto":0,transform:R?"translate(-50%, -100%)":"translate(-50%, 100%)",zIndex:pe==="macro-high"||ke==="macro-high"?30:15},onPointerDown:Lt("macro-high"),onKeyDown:ir("macro-high"),"data-active":pe==="macro-high"?"true":void 0,"data-front":ke==="macro-high"?"true":void 0,"data-vernier-pos":u?R?"left":"right":R?"top":"bottom","data-handle-type":"macro-high",children:[f.jsx(Kt,{type:"macro",isTop:R,isVertical:u,isLeft:R}),Dt&&f.jsx("div",{className:"period-slider-hairline"}),f.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Le(U,e.macroRange[1],h,D)})]}),f.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.lowerAriaLabel??"Micro range start","aria-disabled":i?"true":void 0,"aria-valuemin":fe,"aria-valuemax":Me,"aria-valuenow":xe,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(jt,N):Mt(N,jt,C,D),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?R?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":R?"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4":"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${ot}`,style:u?{bottom:`${ze*100}%`,left:R?"auto":0,right:R?0:"auto",transform:R?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:pe==="micro-low"||ke==="micro-low"?30:20}:{left:`${ze*100}%`,top:R?"auto":0,bottom:R?0:"auto",transform:R?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:pe==="micro-low"||ke==="micro-low"?30:20},onPointerDown:Lt("micro-low"),onKeyDown:ir("micro-low"),"data-active":pe==="micro-low"?"true":void 0,"data-front":ke==="micro-low"?"true":void 0,"data-vernier-pos":u?R?"right":"left":R?"bottom":"top","data-handle-type":"micro-low",children:[f.jsx(Kt,{type:"micro",isTop:!R,isVertical:u,isLeft:!R}),Dt&&f.jsx("div",{className:"period-slider-hairline"}),f.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Le(N,jt,C,D)})]}),f.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Micro range end","aria-disabled":i?"true":void 0,"aria-valuemin":xe,"aria-valuemax":Ee,"aria-valuenow":Me,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Ht,N):Mt(N,Ht,C,D),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle period-slider-handle-vernier ${u?"is-vertical":""} group absolute touch-none ${u?R?"after:absolute after:-inset-y-3 after:-right-4 after:left-0":"after:absolute after:-inset-y-3 after:right-0 after:-left-4":R?"after:absolute after:-inset-x-3 after:top-0 after:-bottom-4":"after:absolute after:-inset-x-3 after:-top-4 after:bottom-0"} after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2 ${ot}`,style:u?{bottom:`${ht*100}%`,left:R?"auto":0,right:R?0:"auto",transform:R?"translate(100%, 50%)":"translate(-100%, 50%)",zIndex:pe==="micro-high"||ke==="micro-high"?30:20}:{left:`${ht*100}%`,top:R?"auto":0,bottom:R?0:"auto",transform:R?"translate(-50%, 100%)":"translate(-50%, -100%)",zIndex:pe==="micro-high"||ke==="micro-high"?30:20},onPointerDown:Lt("micro-high"),onKeyDown:ir("micro-high"),"data-active":pe==="micro-high"?"true":void 0,"data-front":ke==="micro-high"?"true":void 0,"data-vernier-pos":u?R?"right":"left":R?"bottom":"top","data-handle-type":"micro-high",children:[f.jsx(Kt,{type:"micro",isTop:!R,isVertical:u,isLeft:!R}),Dt&&f.jsx("div",{className:"period-slider-hairline"}),f.jsx("div",{className:"period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800",children:Le(N,Ht,C,D)})]})]}):f.jsxs(f.Fragment,{children:[!v&&f.jsx("div",{"data-testid":"period-slider-connect",className:"period-slider-connect absolute rounded-full",style:Ia,onPointerDown:$a}),B&&S&&g.length>1&&f.jsx("div",{className:"period-slider-ticks pointer-events-none absolute inset-0",children:g.map((l,s)=>{const d=Q(t,l),x=rr(s),L=u?{bottom:`${x}%`,left:"50%",transform:"translate(-50%, 50%)"}:{left:`${x}%`,top:"50%",transform:"translate(-50%, -50%)"};return f.jsx("div",{"data-testid":"period-slider-tick",className:"period-slider-tick absolute h-1.5 w-1.5 rounded-full bg-slate-400/60 dark:bg-slate-500/60",style:L},`tick-${d}`)})}),!i&&we!==null&&Et!==null&&$===null&&Jr&&f.jsxs("div",{"data-testid":"period-slider-hover-guide",className:"period-slider-hover-guide pointer-events-none absolute z-20 h-2 w-2",style:Va,children:[f.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"}),f.jsx("div",{className:`period-slider-hover-tooltip ${p==="bottom"&&!u?"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:Le(t,Jr,e.formatLabel,D)})]}),f.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":P?e.pointAriaLabel??"Selected date":e.lowerAriaLabel??"Range start","aria-disabled":i?"true":void 0,"aria-valuemin":k,"aria-valuemax":P?j:de,"aria-valuenow":ue,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(yr,t):Mt(t,yr,e.formatLabel,D),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${ot}`,style:Ha,onPointerDown:Kr("low"),onKeyDown:Xr("low"),"data-active":$==="low"?"true":void 0,"data-front":lr?"true":void 0,children:[f.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)] ${$==="low"?"":"shadow-md"}`}),w!=="hover"&&f.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${w==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":w,"data-label-position":p,"data-slanted":ye.isSlanted?"true":void 0,"data-front":lr?"true":void 0,ref:La,style:Ya,children:Le(t,yr,e.formatLabel,D)})]}),!P&&f.jsxs("div",{tabIndex:i?-1:0,role:"slider","aria-label":e.upperAriaLabel??"Range end","aria-disabled":i?"true":void 0,"aria-valuemin":ue,"aria-valuemax":j,"aria-valuenow":de,"aria-valuetext":e.formatAriaValueText?e.formatAriaValueText(Tr,t):Mt(t,Tr,e.formatLabel,D),"aria-orientation":u?"vertical":"horizontal",className:`period-slider-handle group absolute h-4 w-4 touch-none after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:outline-none ${ot}`,style:Oa,onPointerDown:Kr("high"),onKeyDown:Xr("high"),"data-active":$==="high"?"true":void 0,"data-front":sr?"true":void 0,children:[f.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)] ${$==="high"?"":"shadow-md"}`}),w!=="hover"&&f.jsx("div",{className:`period-slider-tooltip absolute whitespace-nowrap rounded bg-slate-900 px-2 py-0.5 font-medium text-white text-xs shadow-md dark:bg-slate-800 ${w==="balloon"?"period-slider-tooltip-balloon":""}`,"data-tooltip-style":w,"data-label-position":p,"data-slanted":ye.isSlanted?"true":void 0,"data-front":sr?"true":void 0,ref:ka,style:Ea,children:Le(t,Tr,e.formatLabel,D)})]})]})}),b&&Zr(u?"decrease":"increase")]})},kr=(e,t)=>{if(e===t)return!0;if(!(e&&t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r].getTime()!==t[r].getTime())return!1;return!0},Da=(e,t)=>{if(e===t)return!0;if(!(e&&t))return!1;const r=Object.keys(e),a=Object.keys(t);if(r.length!==a.length)return!1;for(const o of r)if(e[o]!==t[o])return!1;return!0},en=(e,t)=>e===t?!0:e.mode!==t.mode||e.unit!==t.unit||e.minDate.getTime()!==t.minDate.getTime()||e.maxDate.getTime()!==t.maxDate.getTime()||e.labelPosition!==t.labelPosition||e.autoSlantLabels!==t.autoSlantLabels||e.isVertical!==t.isVertical||e.hideConnectBar!==t.hideConnectBar||e.showTicks!==t.showTicks||e.disabled!==t.disabled||e.showStepper!==t.showStepper||e.debounceMs!==t.debounceMs||e.tooltipStyle!==t.tooltipStyle||e.colorScheme!==t.colorScheme||e.className!==t.className||!Da(e.style,t.style)||e.snapMode!==t.snapMode||e.formatLabel!==t.formatLabel||e.locale!==t.locale||e.lowerAriaLabel!==t.lowerAriaLabel||e.upperAriaLabel!==t.upperAriaLabel||e.pointAriaLabel!==t.pointAriaLabel||e.macroLowerAriaLabel!==t.macroLowerAriaLabel||e.macroUpperAriaLabel!==t.macroUpperAriaLabel||e.decreaseAriaLabel!==t.decreaseAriaLabel||e.increaseAriaLabel!==t.increaseAriaLabel||e.formatAriaValueText!==t.formatAriaValueText||!kr(e.allowedDates,t.allowedDates)?!1:e.mode==="point"&&t.mode==="point"?!((e.value?.getTime()??null)!==(t.value?.getTime()??null)||(e.defaultValue?.getTime()??null)!==(t.defaultValue?.getTime()??null)||e.onChangePoint!==t.onChangePoint):e.mode==="range"&&t.mode==="range"?!((e.range?.[0]?.getTime()??null)!==(t.range?.[0]?.getTime()??null)||(e.range?.[1]?.getTime()??null)!==(t.range?.[1]?.getTime()??null)||(e.defaultRange?.[0]?.getTime()??null)!==(t.defaultRange?.[0]?.getTime()??null)||(e.defaultRange?.[1]?.getTime()??null)!==(t.defaultRange?.[1]?.getTime()??null)||e.onChangeRange!==t.onChangeRange):e.mode==="vernier"&&t.mode==="vernier"?!((e.microRange?.[0]?.getTime()??null)!==(t.microRange?.[0]?.getTime()??null)||(e.microRange?.[1]?.getTime()??null)!==(t.microRange?.[1]?.getTime()??null)||(e.defaultMicroRange?.[0]?.getTime()??null)!==(t.defaultMicroRange?.[0]?.getTime()??null)||(e.defaultMicroRange?.[1]?.getTime()??null)!==(t.defaultMicroRange?.[1]?.getTime()??null)||e.macroRange[0].getTime()!==t.macroRange[0].getTime()||e.macroRange[1].getTime()!==t.macroRange[1].getTime()||e.vernierOrientation!==t.vernierOrientation||e.showVernierProjection!==t.showVernierProjection||e.showVernierTicks!==t.showVernierTicks||e.showHairline!==t.showHairline||e.macroUnit!==t.macroUnit||e.microUnit!==t.microUnit||e.macroIsDiscrete!==t.macroIsDiscrete||e.microIsDiscrete!==t.microIsDiscrete||e.formatMacroLabel!==t.formatMacroLabel||e.formatMicroLabel!==t.formatMicroLabel||e.onChangeMicroRange!==t.onChangeMicroRange||e.onChangeMacroRange!==t.onChangeMacroRange||!kr(e.macroAllowedDates,t.macroAllowedDates)||!kr(e.microAllowedDates,t.microAllowedDates)):!1,pa=n.memo(Qa,en);pa.displayName="PeriodSlider";const Xe=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t},Xt=(e,t)=>{if(Number.isNaN(t.getTime()))throw new RangeError(`DateSelector: "${e}" must be a valid Date (received ${String(t)})`)},tn=e=>{if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`DateSelector: "locale" must be a valid BCP 47 language tag (received ${JSON.stringify(e)})`)}},At=(e,t,r)=>{const a=new Date(e,t-1,r);return a.setFullYear(e),a.setHours(0,0,0,0),a},ra=e=>At(e,1,1),rn=e=>At(e,12,31),an={year:{year:"numeric"},month:{month:"2-digit"},day:{day:"2-digit"}},nn={year:4,month:2,day:2},on={year:e=>e.getFullYear(),month:e=>e.getMonth()+1,day:e=>e.getDate()},aa=new Map,ln=(e,t)=>{const r=`${e}\0${t}`,a=aa.get(r);if(a!==void 0)return a;const o=new Intl.DateTimeFormat(t,an[e]);return aa.set(r,o),o},$r=(e,t,r)=>r===void 0?String(on[e](t)).padStart(nn[e],"0"):ln(e,r).format(t),sn=(e,t,r)=>{const a=t?.getTime()??null,o=r?.getTime()??null,c=new Map;return e.forEach((i,m)=>{Xt(`allowedDates[${m}]`,i);const b=Xe(i),w=b.getTime();a!==null&&w<a||o!==null&&w>o||c.has(w)||c.set(w,b)}),Array.from(c.keys()).sort((i,m)=>i-m).map(i=>c.get(i))},cn=(e,t)=>{const r=[];let a=Xe(e);const o=Xe(t).getTime();for(;a.getTime()<=o;)r.push(a),a=ge.addDays(a,1);return r},na=(e,t)=>{const r=[];for(let a=e.length-1;a>=0;a--)r.push({label:Le("day",e[a],void 0,t),value:ge.format(e[a],"yyyy-MM-dd")});return r},un=e=>{const{value:t,initialDate:r,onChange:a,children:o,minYear:c,maxYear:i,minDate:m,maxDate:b,allowedDates:w,variant:p="date",className:y="",style:u,disabled:v=!1,prevDateAriaLabel:B="Previous day",nextDateAriaLabel:W="Next day",selectAriaLabel:D="Date",yearAriaLabel:X="Year",monthAriaLabel:Y="Month",dayAriaLabel:J="Day",locale:A,formatYearOption:H,formatMonthOption:T,formatDayOption:F}=e;if(tn(A),t!==void 0&&Xt("value",t),r!==void 0&&Xt("initialDate",r),m!==void 0&&Xt("minDate",m),b!==void 0&&Xt("maxDate",b),c!==void 0&&!Number.isInteger(c))throw new RangeError(`DateSelector: "minYear" must be an integer year (received ${String(c)})`);if(i!==void 0&&!Number.isInteger(i))throw new RangeError(`DateSelector: "maxYear" must be an integer year (received ${String(i)})`);if(p==="split-dropdown"&&w!==void 0)throw new RangeError('DateSelector: variant="split-dropdown" cannot honour "allowedDates"; use variant="dropdown" or variant="date" for a discrete date set');const E=t??r;if(E===void 0)throw new RangeError("DateSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected date is never inferred from the wall clock.");const[g,S]=n.useState(()=>Xe(E)),k=t!==void 0,j=t?.getTime(),P=n.useMemo(()=>t!==void 0?Xe(t):g,[j,g]),te=m?.getTime(),_=b?.getTime(),z=n.useMemo(()=>{const h=m?Xe(m):null,C=c!==void 0?ra(c):null;return h===null?C:C===null||h.getTime()>=C.getTime()?h:C},[te,c]),ee=n.useMemo(()=>{const h=b?Xe(b):null,C=i!==void 0?rn(i):null;return h===null?C:C===null||h.getTime()<=C.getTime()?h:C},[_,i]),re=z?.getTime()??null,ce=ee?.getTime()??null;if(z!==null&&ee!==null&&z.getTime()>ee.getTime())throw new RangeError(`DateSelector: the resolved range is empty (min ${ge.format(z,"yyyy-MM-dd")} is after max ${ge.format(ee,"yyyy-MM-dd")})`);if(p!=="date"&&w===void 0&&(z===null||ee===null))throw new RangeError(`DateSelector: variant="${p}" needs a bounded range; supply minDate/minYear and maxDate/maxYear${p==="dropdown"?' or supply "allowedDates"':""}`);const Fe=w===void 0?null:w.map(h=>h.getTime()).join(","),ae=n.useMemo(()=>w===void 0?null:sn(w,z,ee),[Fe,re,ce]),Ge=h=>{const C=h.getTime();return ae!==null?ae.some(Ae=>Ae.getTime()===C):!(re!==null&&C<re||ce!==null&&C>ce)},ut=E.getTime();n.useEffect(()=>{k||S(Xe(E))},[k,ut]);const Re=h=>{if(v)return;const C=Xe(h);Ge(C)&&(k||S(C),a?.(C))},be=P.getTime(),le=Ge(P),I=n.useMemo(()=>{if(ae!==null){for(let C=ae.length-1;C>=0;C--)if(ae[C].getTime()<be)return ae[C];return null}const h=ge.addDays(new Date(be),-1);return re!==null&&h.getTime()<re?null:h},[ae,be,re]),O=n.useMemo(()=>{if(ae!==null){for(const C of ae)if(C.getTime()>be)return C;return null}const h=ge.addDays(new Date(be),1);return ce!==null&&h.getTime()>ce?null:h},[ae,be,ce]),K=v||I===null,se=v||O===null,$=()=>{I!==null&&Re(I)},me=()=>{O!==null&&Re(O)},Ne=h=>{if(h.target.value){const C=ge.parseISO(h.target.value);Number.isNaN(C.getTime())||Re(C)}},We=h=>{if(h.target.value){const C=ge.parseISO(h.target.value);Number.isNaN(C.getTime())||Re(C)}},ie=P.getFullYear(),we=P.getMonth()+1,dt=P.getDate(),Et=n.useMemo(()=>p!=="dropdown"?[]:ae!==null?na(ae,A):z===null||ee===null?[]:na(cn(z,ee),A),[p,ae,re,ce,A]),Wt=n.useMemo(()=>{if(p!=="split-dropdown"||z===null||ee===null)return[];const h=[];for(let C=ee.getFullYear();C>=z.getFullYear();C--)h.push(C);return h},[p,re,ce]),ue=n.useMemo(()=>{if(p!=="split-dropdown"||z===null||ee===null)return[];const h=z,C=ee,Ae=ie===h.getFullYear()?h.getMonth()+1:1,pt=ie===C.getFullYear()?C.getMonth()+1:12,ft=[];for(let Je=Ae;Je<=pt;Je++)ft.push(Je);return ft},[p,re,ce,ie]),de=n.useMemo(()=>{if(p!=="split-dropdown"||z===null||ee===null)return[];const h=z,C=ee,Ae=ie===h.getFullYear()&&we===h.getMonth()+1?h.getDate():1,pt=ie===C.getFullYear()&&we===C.getMonth()+1?C.getDate():ge.getDaysInMonth(new Date(be)),ft=[];for(let Je=Ae;Je<=pt;Je++)ft.push(Je);return ft},[p,re,ce,be,ie,we]),G=(h,C,Ae)=>{Ae>ge.getDaysInMonth(At(h,C,1))||Re(At(h,C,Ae))},mt=h=>H?H(h):$r("year",ra(h),A),R=h=>T?T(h):$r("month",At(ie,h,1),A),Jt=h=>F?F(h):$r("day",At(ie,we,h),A),Zt=ge.format(P,"yyyy-MM-dd"),Dt=Le("day",P,void 0,A),U=z?ge.format(z,"yyyy-MM-dd"):void 0,N=ee?ge.format(ee,"yyyy-MM-dd"):void 0,It=le?Zt:"",nt="text-center font-mono text-gray-500 tabular-nums [text-align-last:center] [text-align:center] dark:bg-slate-700 dark:text-slate-400",Qt=p==="split-dropdown"?"w-auto":"w-38";return f.jsxs("div",{className:`inline-flex items-center ${Qt} ${y}`,style:u,"data-variant":p,"data-out-of-range":le?void 0:"true",children:[f.jsx("button",{type:"button","aria-label":B,disabled:K,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:$,children:f.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),p==="dropdown"?f.jsxs("select",{"aria-label":D,disabled:v,className:"mx-1 my-auto 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",value:It,onChange:We,children:[le?null:f.jsx("option",{value:"",disabled:!0,className:nt,children:Dt}),Et.map(h=>f.jsx("option",{value:h.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:h.label},h.value))]}):p==="split-dropdown"?f.jsxs("div",{className:"mx-1 my-auto inline-flex items-center gap-1",children:[f.jsxs("select",{"aria-label":X,disabled:v,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:le?ie:"",onChange:h=>G(Number(h.target.value),we,dt),children:[le?null:f.jsx("option",{value:"",disabled:!0,className:nt,children:mt(ie)}),Wt.map(h=>f.jsx("option",{value:h,className:"dark:bg-slate-700 dark:text-slate-100",children:mt(h)},h))]}),f.jsxs("select",{"aria-label":Y,disabled:v,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:le?we:"",onChange:h=>G(ie,Number(h.target.value),dt),children:[le?null:f.jsx("option",{value:"",disabled:!0,className:nt,children:R(we)}),ue.map(h=>f.jsx("option",{value:h,className:"dark:bg-slate-700 dark:text-slate-100",children:R(h)},h))]}),f.jsxs("select",{"aria-label":J,disabled:v,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:le?dt:"",onChange:h=>G(ie,we,Number(h.target.value)),children:[le?null:f.jsx("option",{value:"",disabled:!0,className:nt,children:Jt(dt)}),de.map(h=>f.jsx("option",{value:h,className:"dark:bg-slate-700 dark:text-slate-100",children:Jt(h)},h))]})]}):f.jsx("input",{"aria-label":D,disabled:v,className:"mx-1 my-auto w-28 rounded-md border border-gray-300 bg-gray-50 px-1 py-0.5 text-gray-900 text-xs 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:Zt,min:U,max:N,onChange:Ne,type:"date"}),f.jsx("button",{type:"button","aria-label":W,disabled:se,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:me,children:f.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),o]})},Nt=e=>e===void 0?null:Xe(e).getTime(),ya=n.memo(un,(e,t)=>!(Nt(e.value??e.initialDate)!==Nt(t.value??t.initialDate)||Nt(e.minDate)!==Nt(t.minDate)||Nt(e.maxDate)!==Nt(t.maxDate)||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.onChange!==t.onChange||e.allowedDates!==t.allowedDates||e.children!==t.children||e.prevDateAriaLabel!==t.prevDateAriaLabel||e.nextDateAriaLabel!==t.nextDateAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.yearAriaLabel!==t.yearAriaLabel||e.monthAriaLabel!==t.monthAriaLabel||e.dayAriaLabel!==t.dayAriaLabel||e.locale!==t.locale||e.formatYearOption!==t.formatYearOption||e.formatMonthOption!==t.formatMonthOption||e.formatDayOption!==t.formatDayOption));ya.displayName="DateSelector";function Ve(e,t){const r=e+Math.floor(t/12),a=(t%12+12)%12,o=new Date(r,a,1);return o.setFullYear(r),o}function vt(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}`}function mr(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`MonthSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function oa(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`MonthSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function dn(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`MonthSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function mn(e,t){const r=e===void 0?null:Ve(e,0),a=t===void 0?null:Ve(t.getFullYear(),t.getMonth());return r!==null&&a!==null?r>=a?r:a:r!==null?r:a}function fn(e,t){const r=e===void 0?null:Ve(e,11),a=t===void 0?null:Ve(t.getFullYear(),t.getMonth());return r!==null&&a!==null?r<=a?r:a:r!==null?r:a}function Ta(e,t){return{label:Le("month",e,void 0,t),value:vt(e)}}function gn(e,t,r){const a=e.getFullYear()*12+e.getMonth(),o=t.getFullYear()*12+t.getMonth(),c=[];for(let i=o;i>=a;i--)c.push(Ta(Ve(Math.floor(i/12),i%12),r));return c}const hn=e=>{const{value:t,initialDate:r,onChange:a,children:o,variant:c="date",minYear:i,maxYear:m,minDate:b,maxDate:w,isWarning:p=!1,className:y="",style:u,disabled:v=!1,prevMonthAriaLabel:B="Previous month",nextMonthAriaLabel:W="Next month",selectAriaLabel:D="Month",locale:X}=e;dn(X),mr(t,"value"),mr(r,"initialDate"),mr(b,"minDate"),mr(w,"maxDate"),oa(i,"minYear"),oa(m,"maxYear");const Y=t??r;if(Y===void 0)throw new RangeError("MonthSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected month is never inferred from the wall clock.");const[J,A]=n.useState(()=>Ve(Y.getFullYear(),Y.getMonth())),H=t!==void 0,T=n.useMemo(()=>t!==void 0?Ve(t.getFullYear(),t.getMonth()):J,[t?.getTime(),J]),F=b?.getTime(),E=w?.getTime(),g=n.useMemo(()=>mn(i,b),[i,F]),S=n.useMemo(()=>fn(m,w),[m,E]);if(g!==null&&S!==null&&g>S)throw new RangeError(`MonthSelector: the resolved lower bound ${vt(g)} is after the resolved upper bound ${vt(S)}.`);if(c==="dropdown"&&(g===null||S===null))throw new RangeError('MonthSelector: variant="dropdown" requires a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`); the option window is never invented.');const k=g!==null&&T<g||S!==null&&T>S,j=Y.getTime();n.useEffect(()=>{if(H)return;const $=Ve(Y.getFullYear(),Y.getMonth());A(me=>me.getTime()===$.getTime()?me:$)},[H,j]);const P=$=>(g===null||$>=g)&&(S===null||$<=S),te=$=>{if(v)return;if(!P($))throw new RangeError(`MonthSelector: refusing to emit ${vt($)}, which lies outside the declared bounds.`);H||A($);const me=$.getFullYear()*100+($.getMonth()+1);a?.($,me)},_=n.useMemo(()=>Ve(T.getFullYear(),T.getMonth()-1),[T]),z=n.useMemo(()=>Ve(T.getFullYear(),T.getMonth()+1),[T]),ee=v||g!==null&&_<g,re=v||S!==null&&z>S,ce=()=>{te(_)},Fe=()=>{te(z)},ae=$=>{if(!$)return;const[me,Ne]=$.split("-"),We=Number(me),ie=Number(Ne)-1;if(!(Number.isInteger(We)&&Number.isInteger(ie)))return;const we=Ve(We,ie);P(we)&&te(we)},Ge=$=>{ae($.target.value)},ut=$=>{ae($.target.value)},Re=vt(T),be=g?vt(g):void 0,le=S?vt(S):void 0,I=n.useMemo(()=>{if(c!=="dropdown"||g===null||S===null)return[];const $=gn(g,S,X);if(!k)return $;const me=Ta(T,X);return[...$,me].sort((Ne,We)=>We.value.localeCompare(Ne.value))},[c,g?.getTime(),S?.getTime(),k,T,X]),O=p?"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",K=`mx-1 my-auto w-28 rounded-md border py-0.5 px-1 text-xs dark:placeholder:text-gray-400 disabled:opacity-50 ${O}`,se=`mx-1 my-auto 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 ${O}`;return f.jsxs("div",{className:`inline-flex w-38 items-center ${y}`,style:u,children:[f.jsx("button",{type:"button","aria-label":B,disabled:ee,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:ce,children:f.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),c==="dropdown"?f.jsx("select",{"aria-label":D,disabled:v,className:se,value:Re,onChange:ut,children:I.map($=>f.jsx("option",{value:$.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:$.label},$.value))}):f.jsx("input",{"aria-label":D,disabled:v,className:K,value:Re,min:be,max:le,onChange:Ge,type:"month"}),f.jsx("button",{type:"button","aria-label":W,disabled:re,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:Fe,children:f.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),o]})},Ra=n.memo(hn,(e,t)=>{const r=e.value??e.initialDate,a=t.value??t.initialDate,o=r?r.getFullYear()*12+r.getMonth():null,c=a?a.getFullYear()*12+a.getMonth():null;if(o!==c||e.variant!==t.variant||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.isWarning!==t.isWarning||e.minYear!==t.minYear||e.maxYear!==t.maxYear)return!1;const i=e.minDate?e.minDate.getFullYear()*12+e.minDate.getMonth():null,m=t.minDate?t.minDate.getFullYear()*12+t.minDate.getMonth():null;if(i!==m)return!1;const b=e.maxDate?e.maxDate.getFullYear()*12+e.maxDate.getMonth():null,w=t.maxDate?t.maxDate.getFullYear()*12+t.maxDate.getMonth():null;return!(b!==w||e.onChange!==t.onChange||e.children!==t.children||e.prevMonthAriaLabel!==t.prevMonthAriaLabel||e.nextMonthAriaLabel!==t.nextMonthAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});Ra.displayName="MonthSelector";function Gt(e,t,r){if(!(r instanceof Date)||Number.isNaN(r.getTime()))throw new RangeError(`${e}: ${t} is required and must be a valid Date (received: ${String(r)})`)}function Er(e,t,r){if(Gt(e,"minDate",t),Gt(e,"maxDate",r),r.getTime()<=t.getTime())throw new RangeError(`${e}: maxDate must be strictly later than minDate (minDate: ${t.toISOString()}, maxDate: ${r.toISOString()})`)}function Pr(e,t,r){if(!Array.isArray(r)||r.length!==2)throw new RangeError(`${e}: ${t} is required and must be a [lower, upper] Date tuple (received: ${String(r)})`);if(Gt(e,`${t}[0]`,r[0]),Gt(e,`${t}[1]`,r[1]),r[0].getTime()>r[1].getTime())throw new RangeError(`${e}: ${t} upper must not be earlier than lower (lower: ${r[0].toISOString()}, upper: ${r[1].toISOString()})`)}function Nr(e,t,r,a,o,c){if(r.getTime()<a.getTime()||r.getTime()>o.getTime())throw new RangeError(`${e}: ${t} must lie within ${c} (value: ${r.toISOString()}, lower: ${a.toISOString()}, upper: ${o.toISOString()})`)}function Ar(e,t,r,a,o,c){Nr(e,`${t}[0]`,r[0],a,o,c),Nr(e,`${t}[1]`,r[1],a,o,c)}function Pe(e,t,r){return e<t?t:e>r?r:e}function fr(e,t,r,a){const o=st(t,r,a[1]);return[Pe(e[0],a[0],o),Pe(e[1],a[0],o)]}function Yr(e,t,r,a){const o=at(e,r,t)+a;return e[Math.max(0,Math.min(e.length-1,o))]}function Ir(e){const t=n.useRef(e),r=t.current,a=e,o=Object.keys(r),c=Object.keys(a);return o.length===c.length&&c.every(m=>Object.is(r[m],a[m]))||(t.current=e),t.current}function bn(e){const{unit:t,minDate:r,maxDate:a,initialRange:o,onChangeRange:c,...i}=e;Er("usePeriodSliderRange",r,a),Pr("usePeriodSliderRange","initialRange",o),Ar("usePeriodSliderRange","initialRange",o,r,a,"[minDate, maxDate]");const m=Ir(i),b=n.useRef(o),[w,p]=n.useState(o);let y=w;const u=[Pe(w[0],r,a),Pe(w[1],r,a)];(u[0]!==w[0]||u[1]!==w[1])&&(y=u,p(u));const v=n.useRef(y);v.current=y;const B=n.useRef({minDate:r,maxDate:a,allowedDates:m.allowedDates});B.current={minDate:r,maxDate:a,allowedDates:m.allowedDates};const W=n.useRef(c);W.current=c;const D=n.useCallback(g=>{const{minDate:S,maxDate:k}=B.current,j=Pe(g[0],S,k),P=Pe(g[1],S,k),te=v.current;j.getTime()===te[0].getTime()&&P.getTime()===te[1].getTime()||(v.current=[j,P],p([j,P]),W.current?.(j,P))},[]),X=n.useCallback(g=>{const S=v.current,k=g.getTime()>S[1].getTime()?g:S[1];D([g,k])},[D]),Y=n.useCallback(g=>{const S=v.current,k=g.getTime()<S[0].getTime()?g:S[0];D([k,g])},[D]),J=n.useCallback((g,S)=>{D([g,S])},[D]),A=n.useCallback(g=>{const{minDate:S,maxDate:k,allowedDates:j}=B.current,P=v.current,te=Yt(j,t,S,k);if(te.length>0){D([Yr(te,t,P[0],g),Yr(te,t,P[1],g)]);return}D([Te(t,P[0],g),Te(t,P[1],g)])},[t,D]),H=n.useCallback(()=>{D(b.current)},[D]),T=n.useMemo(()=>({value:y[0],onChange:X,minDate:r,maxDate:y[1],unit:t}),[y[0],y[1],X,r,t]),F=n.useMemo(()=>({value:y[1],onChange:Y,minDate:y[0],maxDate:a,unit:t}),[y[0],y[1],Y,a,t]),E=n.useMemo(()=>({...m,mode:"range",unit:t,range:y,minDate:r,maxDate:a,onChangeRange:J}),[m,t,y,r,a,J]);return{range:y,lowerDate:y[0],upperDate:y[1],setRange:p,setLowerDate:X,setUpperDate:Y,shiftRange:A,resetRange:H,startSelectorProps:T,endSelectorProps:F,sliderProps:E}}function wn(e){const{unit:t,minDate:r,maxDate:a,initialValue:o,onChangePoint:c,...i}=e;Er("usePeriodSliderPoint",r,a),Gt("usePeriodSliderPoint","initialValue",o),Nr("usePeriodSliderPoint","initialValue",o,r,a,"[minDate, maxDate]");const m=Ir(i),b=n.useRef(o),[w,p]=n.useState(o);let y=w;const u=Pe(w,r,a);u!==w&&(y=u,p(u));const v=n.useRef(y);v.current=y;const B=n.useRef({minDate:r,maxDate:a,allowedDates:m.allowedDates});B.current={minDate:r,maxDate:a,allowedDates:m.allowedDates};const W=n.useRef(c);W.current=c;const D=n.useCallback(H=>{const{minDate:T,maxDate:F}=B.current,E=Pe(H,T,F);E.getTime()!==v.current.getTime()&&(v.current=E,p(E),W.current?.(E))},[]),X=n.useCallback(H=>{const{minDate:T,maxDate:F,allowedDates:E}=B.current,g=Yt(E,t,T,F);if(g.length>0){D(Yr(g,t,v.current,H));return}D(Te(t,v.current,H))},[t,D]),Y=n.useCallback(()=>{D(b.current)},[D]),J=n.useMemo(()=>({value:y,onChange:D,minDate:r,maxDate:a,unit:t}),[y,D,r,a,t]),A=n.useMemo(()=>({...m,mode:"point",unit:t,value:y,minDate:r,maxDate:a,onChangePoint:D}),[m,t,y,r,a,D]);return{value:y,setValue:p,shiftValue:X,resetValue:Y,selectorProps:J,sliderProps:A}}function xn(e){const{unit:t,minDate:r,maxDate:a,initialMacroRange:o,initialMicroRange:c,macroUnit:i=t,microUnit:m=t,onChangeMacroRange:b,onChangeMicroRange:w,...p}=e;Er("useVernierSlider",r,a),Pr("useVernierSlider","initialMacroRange",o),Pr("useVernierSlider","initialMicroRange",c),Ar("useVernierSlider","initialMacroRange",o,r,a,"[minDate, maxDate]"),Ar("useVernierSlider","initialMicroRange",c,o[0],st(i,m,o[1]),"the initial macro window");const y=Ir(p),u=n.useRef(o),v=n.useRef(c),[B,W]=n.useState(o),[D,X]=n.useState(c);let Y=B;const J=[Pe(B[0],r,a),Pe(B[1],r,a)];(J[0]!==B[0]||J[1]!==B[1])&&(Y=J,W(J));let A=D;const H=fr(D,i,m,Y);(H[0]!==D[0]||H[1]!==D[1])&&(A=H,X(H));const T=n.useRef(Y);T.current=Y;const F=n.useRef(A);F.current=A;const E=n.useRef({minDate:r,maxDate:a});E.current={minDate:r,maxDate:a};const g=n.useRef(b);g.current=b;const S=n.useRef(w);S.current=w;const k=n.useCallback((I,O)=>{const K=T.current,se=F.current;(I[0].getTime()!==K[0].getTime()||I[1].getTime()!==K[1].getTime())&&(T.current=I,W(I),g.current?.(I[0],I[1])),(O[0].getTime()!==se[0].getTime()||O[1].getTime()!==se[1].getTime())&&(F.current=O,X(O),S.current?.(O[0],O[1]))},[]),j=n.useCallback((I,O)=>{const{minDate:K,maxDate:se}=E.current,$=[Pe(I,K,se),Pe(O,K,se)];k($,fr(F.current,i,m,$))},[i,m,k]),P=n.useCallback((I,O)=>{k(T.current,fr([I,O],i,m,T.current))},[i,m,k]),te=n.useCallback(I=>{const O=T.current[1],K=I>O?I:O;j(I,K)},[j]),_=n.useCallback(I=>{const O=T.current[0],K=I<O?I:O;j(K,I)},[j]),z=n.useCallback(I=>{const O=F.current[1],K=I>O?I:O;P(I,K)},[P]),ee=n.useCallback(I=>{const O=F.current[0],K=I<O?I:O;P(K,I)},[P]),re=n.useCallback(I=>{const{minDate:O,maxDate:K}=E.current,se=T.current,$=Te(i,se[0],I),me=Te(i,se[1],I);$<O||me>K||j($,me)},[i,j]),ce=n.useCallback(I=>{const O=T.current,K=F.current,se=Te(m,K[0],I),$=Te(m,K[1],I);se<O[0]||$>st(i,m,O[1])||P(se,$)},[i,m,P]),Fe=n.useCallback(()=>{const I=u.current;k(I,fr(v.current,i,m,I))},[i,m,k]),ae=n.useMemo(()=>st(i,m,Y[1]),[i,m,Y[1]]),Ge=n.useMemo(()=>({value:Y[0],onChange:te,minDate:r,maxDate:Y[1],unit:i}),[Y,te,r,i]),ut=n.useMemo(()=>({value:Y[1],onChange:_,minDate:Y[0],maxDate:a,unit:i}),[Y,_,a,i]),Re=n.useMemo(()=>({value:A[0],onChange:z,minDate:Y[0],maxDate:A[1],unit:m}),[A,z,Y,m]),be=n.useMemo(()=>({value:A[1],onChange:ee,minDate:A[0],maxDate:ae,unit:m}),[A,ee,ae,m]),le=n.useMemo(()=>({...y,mode:"vernier",unit:t,macroUnit:i,microUnit:m,minDate:r,maxDate:a,macroRange:Y,microRange:A,onChangeMacroRange:j,onChangeMicroRange:P}),[y,t,i,m,r,a,Y,A,j,P]);return{macroRange:Y,setMacroRange:W,microRange:A,setMicroRange:X,setMacroLowerDate:te,setMacroUpperDate:_,setMicroLowerDate:z,setMicroUpperDate:ee,shiftMacroRange:re,shiftMicroRange:ce,resetVernier:Fe,macroStartSelectorProps:Ge,macroEndSelectorProps:ut,microStartSelectorProps:Re,microEndSelectorProps:be,sliderProps:le}}function ia(e){const t=new Date(e,0,1);return t.setFullYear(e),t}function gr(e,t){if(e!==void 0&&(!(e instanceof Date)||Number.isNaN(e.getTime())))throw new RangeError(`YearSelector: \`${t}\` must be a valid Date, received ${String(e)}.`)}function la(e,t){if(e!==void 0&&!Number.isInteger(e))throw new RangeError(`YearSelector: \`${t}\` must be an integer year, received ${String(e)}.`)}function Mn(e){if(e!==void 0)try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{throw new RangeError(`YearSelector: \`locale\` must be a valid BCP 47 language tag, received ${JSON.stringify(e)}.`)}}function sa(e,t,r){const a=e===void 0?null:e,o=t===void 0?null:t.getFullYear();return a!==null&&o!==null?r(a,o):a!==null?a:o}const vn=e=>{const{value:t,initialDate:r,onChange:a,children:o,minYear:c,maxYear:i,minDate:m,maxDate:b,className:w="",style:p,disabled:y=!1,prevYearAriaLabel:u="Previous year",nextYearAriaLabel:v="Next year",selectAriaLabel:B="Year",locale:W}=e;gr(t,"value"),gr(r,"initialDate"),gr(m,"minDate"),gr(b,"maxDate"),la(c,"minYear"),la(i,"maxYear"),Mn(W);const D=t??r;if(D===void 0)throw new RangeError("YearSelector: either `value` (controlled) or `initialDate` (uncontrolled) is required; the selected year is never inferred from the wall clock.");const[X,Y]=n.useState(()=>D.getFullYear()),J=m?.getTime(),A=b?.getTime(),H=n.useMemo(()=>sa(c,m,Math.max),[c,J]),T=n.useMemo(()=>sa(i,b,Math.min),[i,A]);if(H===null||T===null)throw new RangeError("YearSelector: a lower bound (`minYear` or `minDate`) and an upper bound (`maxYear` or `maxDate`) are both required; the year option list is never invented.");if(H>T)throw new RangeError(`YearSelector: the resolved lower bound ${H} is after the resolved upper bound ${T}.`);const F=t!==void 0,E=t!==void 0?t.getFullYear():X,g=E<H||E>T,S=D.getTime();n.useEffect(()=>{F||Y(D.getFullYear())},[F,S]);const k=_=>{if(!y){if(_<H||_>T)throw new RangeError(`YearSelector: refusing to emit ${_}, which lies outside the declared bounds ${H}-${T}.`);F||Y(_),a?.(ia(_),_)}},j=y||E-1<H,P=y||E+1>T,te=n.useMemo(()=>{const _=[];for(let z=T;z>=H;z--)_.push(z);return g&&(_.push(E),_.sort((z,ee)=>ee-z)),_},[H,T,g,E]);return f.jsxs("div",{className:`inline-flex w-32 items-center ${w}`,style:p,children:[f.jsx("button",{type:"button","aria-label":u,disabled:j,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:()=>k(E-1),children:f.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-r-[6px] border-r-slate-500 border-solid hover:border-r-slate-700 dark:border-r-slate-400 dark:hover:border-r-slate-200"})}),f.jsx("select",{"aria-label":B,disabled:y,className:"mx-1 my-auto 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:E,onChange:_=>{if(!_.target.value)return;const z=Number(_.target.value);Number.isInteger(z)&&k(z)},children:te.map(_=>f.jsx("option",{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:Le("year",ia(_),void 0,W)},_))}),f.jsx("button",{type:"button","aria-label":v,disabled:P,className:"relative my-auto inline-flex h-5 w-4 cursor-pointer items-center justify-center rounded p-0 after:absolute after:inset-[-14px] after:content-[''] focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",onClick:()=>k(E+1),children:f.jsx("span",{className:"h-0 w-0 border-y-[6px] border-y-transparent border-l-[6px] border-l-slate-500 border-solid hover:border-l-slate-700 dark:border-l-slate-400 dark:hover:border-l-slate-200"})}),o]})},Sa=n.memo(vn,(e,t)=>{const r=e.value??e.initialDate,a=t.value??t.initialDate,o=r?r.getFullYear():null,c=a?a.getFullYear():null;return!(o!==c||e.disabled!==t.disabled||e.className!==t.className||e.style!==t.style||e.minYear!==t.minYear||e.maxYear!==t.maxYear||e.minDate?.getFullYear()!==t.minDate?.getFullYear()||e.maxDate?.getFullYear()!==t.maxDate?.getFullYear()||e.onChange!==t.onChange||e.children!==t.children||e.prevYearAriaLabel!==t.prevYearAriaLabel||e.nextYearAriaLabel!==t.nextYearAriaLabel||e.selectAriaLabel!==t.selectAriaLabel||e.locale!==t.locale)});Sa.displayName="YearSelector";exports.COLOR_SCHEME_PALETTES=ca;exports.DateSelector=ya;exports.MonthSelector=Ra;exports.PeriodSlider=pa;exports.YearSelector=Sa;exports.addUnit=Te;exports.areStylesEqual=Da;exports.calculateConnectDragValues=da;exports.calculateHandleDragValues=Cr;exports.calculateKeyboardActionValues=ma;exports.calculateLabelSlant=wa;exports.calculateVernierMacroDrag=Ma;exports.calculateVernierMicroDrag=va;exports.decode=oe;exports.encode=Q;exports.findNearestDateIndex=at;exports.formatLabel=Le;exports.formatScreenReaderLabel=Mt;exports.getActiveDragHandle=ua;exports.getMacroWindowEndDate=st;exports.getSortedAllowedDates=Yt;exports.normalizeDateByUnit=Oe;exports.resolveVernierTargetHandle=xa;exports.usePeriodSliderPoint=wn;exports.usePeriodSliderRange=bn;exports.useVernierSlider=xn;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * @fileoverview Period Slider and Date Selectors Package
3
+ * @package @aiquants/period-slider
4
+ *
5
+ * This package provides range and point period slider components as well as
6
+ * specialized year, month, and date selector inputs for time series analysis and navigation.
7
+ *
8
+ * Every built-in string is locale-neutral: accessible names default to English, and value text
9
+ * defaults to locale-independent ISO 8601. A `locale` (BCP 47) prop switches the built-in value
10
+ * text to `Intl.DateTimeFormat`, and the per-label and per-option formatter props override both.
11
+ *
12
+ * このパッケージは、時系列分析や期間移動のためのレンジ・ポイント期間スライダーコンポーネント、
13
+ * および年・年月・年月日セレクタを提供します。
14
+ * 組み込み文字列はロケール中立で、アクセシブル名の既定は英語、値テキストの既定はロケール非依存の
15
+ * ISO 8601 表記。`locale` (BCP 47) 指定で `Intl.DateTimeFormat` 書式へ切替、
16
+ * ラベル・選択肢のフォーマッタ Props はその双方に優先。
17
+ */
18
+ export type { DateSelectorProps } from './DateSelector';
19
+ export { DateSelector } from './DateSelector';
20
+ export type { MonthSelectorProps } from './MonthSelector';
21
+ export { MonthSelector } from './MonthSelector';
22
+ export type { AccessibleSliderLabels, BasePeriodSliderProps, ColorSchemePalette, ConnectDragValueOptions, LabelSlantConfig, LabelSlantResult, PeriodSliderColorScheme, PeriodSliderLabelPosition, PeriodSliderPointProps, PeriodSliderProps, PeriodSliderRangeProps, PeriodSliderSnapMode, PeriodSliderUnit, PeriodSliderVernierProps, VernierHandle, } from './PeriodSlider';
23
+ export { addUnit, areStylesEqual, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, calculateVernierMicroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel, getActiveDragHandle, getMacroWindowEndDate, getSortedAllowedDates, normalizeDateByUnit, PeriodSlider, resolveVernierTargetHandle, } from './PeriodSlider';
24
+ export type { SelectorProps, UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn, UseVernierSliderOptions, UseVernierSliderReturn, } from './usePeriodSlider';
25
+ export { usePeriodSliderPoint, usePeriodSliderRange, useVernierSlider, } from './usePeriodSlider';
26
+ export type { YearSelectorProps } from './YearSelector';
27
+ export { YearSelector } from './YearSelector';
28
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.d.ts CHANGED
@@ -5,16 +5,23 @@
5
5
  * This package provides range and point period slider components as well as
6
6
  * specialized year, month, and date selector inputs for time series analysis and navigation.
7
7
  *
8
+ * Every built-in string is locale-neutral: accessible names default to English, and value text
9
+ * defaults to locale-independent ISO 8601. A `locale` (BCP 47) prop switches the built-in value
10
+ * text to `Intl.DateTimeFormat`, and the per-label and per-option formatter props override both.
11
+ *
8
12
  * このパッケージは、時系列分析や期間移動のためのレンジ・ポイント期間スライダーコンポーネント、
9
13
  * および年・年月・年月日セレクタを提供します。
14
+ * 組み込み文字列はロケール中立で、アクセシブル名の既定は英語、値テキストの既定はロケール非依存の
15
+ * ISO 8601 表記。`locale` (BCP 47) 指定で `Intl.DateTimeFormat` 書式へ切替、
16
+ * ラベル・選択肢のフォーマッタ Props はその双方に優先。
10
17
  */
11
18
  export type { DateSelectorProps } from './DateSelector';
12
19
  export { DateSelector } from './DateSelector';
13
20
  export type { MonthSelectorProps } from './MonthSelector';
14
21
  export { MonthSelector } from './MonthSelector';
15
- export type { AccessibleSliderLabels, BasePeriodSliderProps, ColorSchemePalette, LabelSlantConfig, LabelSlantResult, PeriodSliderColorScheme, PeriodSliderLabelPosition, PeriodSliderPointProps, PeriodSliderProps, PeriodSliderRangeProps, PeriodSliderUnit, PeriodSliderVernierProps, VernierHandle, } from './PeriodSlider';
16
- export { addUnit, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel, getMacroWindowEndDate, getSortedAllowedDates, normalizeDateByUnit, PeriodSlider, resolveVernierTargetHandle, } from './PeriodSlider';
17
- export type { UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn, UseVernierSliderOptions, UseVernierSliderReturn, } from './usePeriodSlider';
22
+ export type { AccessibleSliderLabels, BasePeriodSliderProps, ColorSchemePalette, ConnectDragValueOptions, LabelSlantConfig, LabelSlantResult, PeriodSliderColorScheme, PeriodSliderLabelPosition, PeriodSliderPointProps, PeriodSliderProps, PeriodSliderRangeProps, PeriodSliderSnapMode, PeriodSliderUnit, PeriodSliderVernierProps, VernierHandle, } from './PeriodSlider';
23
+ export { addUnit, areStylesEqual, COLOR_SCHEME_PALETTES, calculateConnectDragValues, calculateHandleDragValues, calculateKeyboardActionValues, calculateLabelSlant, calculateVernierMacroDrag, calculateVernierMicroDrag, decode, encode, findNearestDateIndex, formatLabel, formatScreenReaderLabel, getActiveDragHandle, getMacroWindowEndDate, getSortedAllowedDates, normalizeDateByUnit, PeriodSlider, resolveVernierTargetHandle, } from './PeriodSlider';
24
+ export type { SelectorProps, UsePeriodSliderPointOptions, UsePeriodSliderPointReturn, UsePeriodSliderRangeOptions, UsePeriodSliderRangeReturn, UseVernierSliderOptions, UseVernierSliderReturn, } from './usePeriodSlider';
18
25
  export { usePeriodSliderPoint, usePeriodSliderRange, useVernierSlider, } from './usePeriodSlider';
19
26
  export type { YearSelectorProps } from './YearSelector';
20
27
  export { YearSelector } from './YearSelector';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EACR,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACH,OAAO,EACP,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACnB,yBAAyB,EACzB,MAAM,EACN,MAAM,EACN,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,0BAA0B,GAC7B,MAAM,gBAAgB,CAAA;AAIvB,YAAY,EACR,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,YAAY,EACR,sBAAsB,EACtB,qBAAqB,EACrB,kBAAkB,EAClB,uBAAuB,EACvB,gBAAgB,EAChB,gBAAgB,EAChB,uBAAuB,EACvB,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,EACtB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACxB,aAAa,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EACH,OAAO,EACP,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,yBAAyB,EACzB,6BAA6B,EAC7B,mBAAmB,EACnB,yBAAyB,EACzB,yBAAyB,EACzB,MAAM,EACN,MAAM,EACN,oBAAoB,EACpB,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,0BAA0B,GAC7B,MAAM,gBAAgB,CAAA;AAIvB,YAAY,EACR,aAAa,EACb,2BAA2B,EAC3B,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,uBAAuB,EACvB,sBAAsB,GACzB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EACH,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,GACnB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA"}