@ahmetilhn/hanui 5.3.1 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -643,8 +643,23 @@ Metinler aynı sağlayıcıdan, `labels.chat` altında:
643
643
  >
644
644
  ```
645
645
 
646
- Ayrıştırma ve vurgulama tüketicide kalır: `Prose` markdown ayrıştırmaz,
647
- `CodeBlock` önceden vurgulanmış HTML alır (`html` prop'u — güvenliği sizin).
646
+ `CodeBlock` kodu kendisi vurgular ve biçimlendirir — bağımlılık yok, renkler
647
+ temayla döner:
648
+
649
+ ```tsx
650
+ <CodeBlock language="json" code={JSON.stringify(payload)} />
651
+ ```
652
+
653
+ JSON iki boşlukla yeniden girintilenir (değerler metin olarak korunur: büyük
654
+ sayılar yuvarlanmaz), kenardaki boş satırlar atılır; başka dilde girintiye
655
+ dokunulmaz. 30'dan fazla dil tanınır (ts/tsx, json, bash, python, yaml, css,
656
+ html, sql, diff, go, rust…), tanınmayan dil düz çizilir. Kopyala düğmesi ekranda
657
+ görüneni kopyalar. Renkler `chat.css`teki `--hanui-syntax-keyword`, `-string`,
658
+ `-number`, `-name`, `-type` değişkenleridir; CSS'te ezilir. Shiki düzeyinde
659
+ doğruluk isterseniz önceden vurgulanmış HTML'i `html` olarak verin (güvenliği
660
+ sizin) — yerleşik vurgulayıcının yerine geçer.
661
+
662
+ Markdown ayrıştırması tüketicide kalır: `Prose` yalnızca tipografi kabıdır.
648
663
  Bileşen listesi ve kararlar: `CLAUDE.md` → "`@ahmetilhn/hanui/chat`".
649
664
 
650
665
  ## SCSS API — `@ahmetilhn/hanui/scss`
@@ -713,8 +728,10 @@ Her grafik tek bir sekme durağıdır: oklar öğeleri gezer (gelinen öğe
713
728
  duyurulur), `Home`/`End` uçlara gider, `Escape` vurguyu kaldırır. Ekran okuyucu
714
729
  grafiği gizli bir **veri tablosu** olarak da okur. Genişlik kapsayıcıdan ölçülür
715
730
  (`width` ile sabitlenebilir), yükseklik `height`. Sayılar `labels.locale`
716
- yereliyle biçimlenir; `formatValue` / `format` ile ezilir. Renkler kategorik
717
- paletten (`tone`: `cat-1`…`cat-5`, `series-1`, `series-2`, `muted`).
731
+ yereliyle biçimlenir; ipucu, duyuru ve tablo `formatValue` / `format` ile
732
+ ezilir. Eksen bölmeleri bunu KULLANMAZ: kısa gösterimde ("12 B", "0,005") ve
733
+ birimsiz kalır, basamak sayısı bölme adımından gelir. Renkler kategorik paletten
734
+ (`tone`: `cat-1`…`cat-5`, `series-1`, `series-2`, `muted`).
718
735
 
719
736
  ## 5.0'a geçiş
720
737
 
@@ -737,7 +754,7 @@ Görünüm değişiklikleri: açık sayfa krem (`#faf9f5`), koyu sayfa sıcak si
737
754
  (`#141413`), kart ve panel durgunken gölgesiz, `info` tonu nötr, `CodeBadge`
738
755
  mürekkep. Ayrıntı ve ölçümler: `CLAUDE.md` → "Renk kararları (5.0)".
739
756
 
740
- ## 5.1 – 5.3'te eklenenler
757
+ ## 5.1 – 5.4'te eklenenler
741
758
 
742
759
  Hepsi ekleme; 5.0'ın token sözleşmesi dışında kırıcı değişiklik yok.
743
760
 
@@ -746,6 +763,8 @@ Hepsi ekleme; 5.0'ın token sözleşmesi dışında kırıcı değişiklik yok.
746
763
  | 5.1 | `Disclosure`, `StatusDot`, `Kbd`; `useHanuiTokens`, `useStickToBottom`, `hasOpenSurface`; `Modal size="xl"`, `Button size={UISize.XSMALL}` + `shape="pill"`, `IconButton shape="round"`, `Textarea variant="bare"`, `Progress size="xs"`, etkileşimli `CodeBadge`, `Avatar` (`icon`, `shape="rounded"`, `tone="brand"`), `Stat variant="inline"`, `ScrollArea isFollowingEnd`; `CommandPalette` `hotkey` + komut kapanıştan SONRA çalışır |
747
764
  | 5.2 | `HanuiThemeScript`; `@ahmetilhn/hanui/chat` — 20 sohbet bileşeni |
748
765
  | 5.3 | `@ahmetilhn/hanui/charts` — 10 SVG grafiği; `@ahmetilhn/hanui/scss`; `Input --technical` dar ekranda ≥16px; `QuantityStepper` ve `DataTable` pasif/dinlenme hâli opacity yerine token |
766
+ | 5.3.2 | Düzeltme: kaydırma kapları kapsayıcı blok (`ChatThread`, `ScrollArea`, `TerminalOutput`, `ActionList` ve 12 kab daha) — görsel olarak gizli metin kabın dışına taşıp atalarını kaydırılabilir yapmıyor; grafik ekseni 0,1'in altındaki adımda sıfıra çökmüyor |
767
+ | 5.4 | `CodeBlock` yerleşik vurgulayıcı ve biçimlendirici (bağımlılıksız, 30+ dil); sözdizimi renkleri `--hanui-syntax-*` (yalnızca `chat.css`) |
749
768
 
750
769
  Ayrıntı ve ölçülmüş gerekçeler: `CLAUDE.md` → "Göç ve `@deprecated` yollar",
751
770
  "`@ahmetilhn/hanui/chat`", "`@ahmetilhn/hanui/charts`".
package/build/charts.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("react"),dt=require("@ahmetilhn/hanui"),at=(t,s)=>Object.assign(t,{displayName:s}),ue="hanui-axis-AqLAe",me="hanui-axis__label-dHxpo",de="hanui-axis__grid-RVxXW",xe="hanui-axis__baseline-jhG2z",st={axis:ue,axis__label:me,axis__grid:de,axis__baseline:xe},ce=6.4,ht=t=>t.length*ce,re=(t,s=8)=>{if(t.length<2)return[...t];const e=Math.max(...t.map(u=>ht(u.label))),n=Math.abs(t[1].position-t[0].position),r=n<=0?1:Math.max(1,Math.ceil((e+s)/n));return t.filter((u,m)=>m%r===0)},St=(t,s)=>{const e=Math.max(1,Math.floor(s/ce));return t.length<=e?t:`${t.slice(0,Math.max(1,e-1))}…`},ut=({area:t,ticks:s,side:e,hasGrid:n=!1})=>l.jsx("g",{className:st.axis,"aria-hidden":!0,children:s.map(r=>e==="bottom"?l.jsxs("g",{children:[n&&l.jsx("line",{className:st.axis__grid,x1:r.position,x2:r.position,y1:t.top,y2:t.bottom}),l.jsx("text",{className:st.axis__label,x:r.position,y:t.bottom+16,textAnchor:"middle",children:r.label})]},`${r.position}-${r.label}`):l.jsxs("g",{children:[n&&l.jsx("line",{className:st.axis__grid,x1:t.left,x2:t.right,y1:r.position,y2:r.position}),l.jsx("text",{className:st.axis__label,x:e==="left"?t.left-8:t.right+8,y:r.position,dy:"0.32em",textAnchor:e==="left"?"end":"start",children:r.label})]},`${r.position}-${r.label}`))}),qt=({area:t,ticks:s,side:e})=>l.jsx("g",{className:st.axis,"aria-hidden":!0,children:e==="bottom"?l.jsxs(l.Fragment,{children:[l.jsx("line",{className:st.axis__baseline,x1:t.left,x2:t.right,y1:t.bottom,y2:t.bottom}),re(s).map(n=>l.jsx("text",{className:st.axis__label,x:n.position,y:t.bottom+16,textAnchor:"middle",children:n.label},`${n.position}-${n.label}`))]}):l.jsxs(l.Fragment,{children:[l.jsx("line",{className:st.axis__baseline,x1:t.left,x2:t.left,y1:t.top,y2:t.bottom}),s.map(n=>l.jsx("text",{className:st.axis__label,x:t.left-8,y:n.position,dy:"0.32em",textAnchor:"end",children:St(n.label,t.left-12)},`${n.position}-${n.label}`))]})}),W=t=>Math.round(t*100)/100,fe=t=>{const s=[];let e=[];for(const n of t)n===null||!Number.isFinite(n.x)||!Number.isFinite(n.y)?(e.length>0&&s.push(e),e=[]):e.push(n);return e.length>0&&s.push(e),s},Ft=t=>t.map((s,e)=>`${e===0?"M":"L"}${W(s.x)},${W(s.y)}`).join(""),le=t=>{const s=t.length;if(s<3)return Ft(t);const e=[],n=[];for(let u=0;u<s-1;u+=1){const m=t[u+1].x-t[u].x;n.push(m===0?0:(t[u+1].y-t[u].y)/m)}e.push(n[0]);for(let u=1;u<s-1;u+=1)e.push(n[u-1]*n[u]<=0?0:(n[u-1]+n[u])/2);e.push(n[s-2]);for(let u=0;u<s-1;u+=1){if(n[u]===0){e[u]=0,e[u+1]=0;continue}const m=e[u]/n[u],d=e[u+1]/n[u],k=m*m+d*d;if(k>9){const T=3/Math.sqrt(k);e[u]=T*m*n[u],e[u+1]=T*d*n[u]}}let r=`M${W(t[0].x)},${W(t[0].y)}`;for(let u=0;u<s-1;u+=1){const m=t[u],d=t[u+1],k=(d.x-m.x)/3;r+=`C${W(m.x+k)},${W(m.y+e[u]*k)} ${W(d.x-k)},${W(d.y-e[u+1]*k)} ${W(d.x)},${W(d.y)}`}return r},pe=(t,s="linear")=>fe(t).map(e=>s==="monotone"?le(e):Ft(e)).join(""),ye=(t,s,e="linear")=>{const n=[];let r=[],u=[];const m=()=>{if(r.length>0){const d=e==="monotone"?le:Ft,k=d([...u].reverse()).replace(/^M/,"L");n.push(`${d(r)}${k}Z`)}r=[],u=[]};return t.forEach((d,k)=>{const T=s[k];d===null||T===null||T===void 0?m():(r.push(d),u.push(T))}),m(),n.join("")},tt=(t,s,e,n)=>({x:t+e*Math.sin(n),y:s-e*Math.cos(n)}),Xt=(t,s,e,n,r,u)=>{const m=u-r;if(m<=0||e<=0)return"";if(m>=Math.PI*2-1e-6){const M=(F,z)=>`M${W(t)},${W(s-F)}A${F},${F} 0 1 ${z} ${W(t)},${W(s+F)}A${F},${F} 0 1 ${z} ${W(t)},${W(s-F)}Z`;return M(e,1)+(n>0?M(n,0):"")}const d=m>Math.PI?1:0,k=tt(t,s,e,r),T=tt(t,s,e,u);if(n<=0)return`M${W(t)},${W(s)}L${W(k.x)},${W(k.y)}A${e},${e} 0 ${d} 1 ${W(T.x)},${W(T.y)}Z`;const A=tt(t,s,n,u),I=tt(t,s,n,r);return`M${W(k.x)},${W(k.y)}A${e},${e} 0 ${d} 1 ${W(T.x)},${W(T.y)}L${W(A.x)},${W(A.y)}A${n},${n} 0 ${d} 0 ${W(I.x)},${W(I.y)}Z`},Yt=t=>t.length===0?"":`${Ft(t)}Z`,mt=(t,s)=>{const[e,n]=t,[r,u]=s,m=n-e,d=k=>m===0?(r+u)/2:r+(k-e)/m*(u-r);return d.domain=t,d.range=s,d.invert=k=>u===r?e:e+(k-r)/(u-r)*m,d},Rt=(t,s,{paddingInner:e=.2,paddingOuter:n=.1}={})=>{const[r,u]=s,m=t.length,d=m===0?0:(u-r)/Math.max(1,m-e+n*2),k=d*(1-e),T=r+d*n,A=new Map(t.map((M,F)=>[M,F])),I=M=>{const F=A.get(M);return F===void 0?Number.NaN:T+F*d};return I.domain=t,I.range=s,I.bandwidth=k,I.step=d,I.indexAt=M=>m===0?-1:Math.min(m-1,Math.max(0,Math.floor((M-r-d*n+(d-k)/2)/d))),I},Ot=(t,s,e)=>{const n=Math.abs(s-t);if(n===0||!Number.isFinite(n)||e<=0)return 1;const r=n/e,u=10**Math.floor(Math.log10(r)),m=r/u;return(m>=7.5?10:m>=3.5?5:m>=1.5?2:1)*u},Gt=(t,s)=>{const e=Math.max(0,-Math.floor(Math.log10(s))+1);return Number(t.toFixed(Math.min(e,12)))},$t=(t,s,e=5)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return[0,1];let n=Math.min(t,s),r=Math.max(t,s);if(n===r){if(n===0)return[0,1];const m=Math.abs(n)*.5;n=n>0?0:n-m,r=r<0?0:r+m}const u=Ot(n,r,e);return[Gt(Math.floor(n/u)*u,u),Gt(Math.ceil(r/u)*u,u)]},ot=(t,s,e=5)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return[];if(t===s)return[t];const n=Ot(t,s,e),r=Math.ceil(t/n-1e-9),u=Math.floor(s/n+1e-9),m=[];for(let d=r;d<=u&&m.length<1e3;d+=1)m.push(Gt(d*n,n));return m},be=(t,s)=>{if(t.length===0)return-1;let e=0,n=t.length-1;for(;e<n;){const r=e+n>>1;t[r]<s?e=r+1:n=r}return e>0&&Math.abs(t[e-1]-s)<=Math.abs(t[e]-s)?e-1:e},Ht=t=>t.filter(s=>typeof s=="number"&&Number.isFinite(s)),xt=t=>{if(t.length===0)return[0,0];let s=t[0],e=t[0];for(const n of t)n<s&&(s=n),n>e&&(e=n);return[s,e]},zt=(t,s)=>{if(t.length===0)return Number.NaN;if(t.length===1)return t[0];const e=(t.length-1)*Math.min(1,Math.max(0,s)),n=Math.floor(e),r=e-n;return n+1<t.length?t[n]+(t[n+1]-t[n])*r:t[n]},ge=t=>{const s=Ht(t).sort((m,d)=>m-d);if(s.length===0)return null;const e=zt(s,.25),n=zt(s,.75),r=(n-e)*1.5,u=s.filter(m=>m>=e-r&&m<=n+r);return{count:s.length,min:s[0],q1:e,median:zt(s,.5),q3:n,max:s[s.length-1],whiskerLow:u[0]??e,whiskerHigh:u[u.length-1]??n,outliers:s.filter(m=>m<e-r||m>n+r)}},Me=(t,s)=>{const e=Ht(t);if(e.length===0)return[];const[n,r]=xt(e);if(n===r)return[{from:n,to:n+1,count:e.length}];const u=s??Math.ceil(Math.log2(e.length))+1,m=Ot(n,r,Math.max(1,u)),d=Math.floor(n/m)*m,k=Math.max(1,Math.ceil((r-d)/m-1e-9)),T=Array.from({length:k},(A,I)=>({from:d+I*m,to:d+(I+1)*m,count:0}));for(const A of e){const I=Math.min(T.length-1,Math.floor((A-d)/m));T[I].count+=1}return T},wt=t=>typeof t=="number"&&Number.isFinite(t)?t:null,ct={top:12,right:16,bottom:28,minLeft:32},_e=(t,s)=>{const e=t.map(()=>0),n=t.map(()=>0),r={};for(const u of s)r[u]=t.map((m,d)=>{const k=wt(m[u])??0;if(k>=0){const A=e[d];return e[d]+=k,{base:A,top:e[d]}}const T=n[d];return n[d]+=k,{base:T,top:n[d]}});return r},we=t=>{const{rows:s,xKey:e,series:n,width:r,height:u,isStacked:m,curve:d,formatX:k}=t,T=n.some(v=>v.type==="bar"),I=(T&&n.every(v=>v.type==="bar")?t.orientation:"vertical")==="horizontal",M=s.map(v=>v[e]),F=!T&&!I&&M.length>1&&M.every(v=>wt(v)!==null),z={};if(m)for(const v of["left","right"])for(const O of["bar","area"]){const B=n.filter(Y=>(Y.axis??"left")===v&&Y.type===O).map(Y=>Y.key);Object.assign(z,_e(s,B))}const H=(v,O)=>{if(z[v])return z[v][O];const B=wt(s[O][v]);return B===null?null:{base:0,top:B}},q=v=>{const O=n.filter(lt=>(lt.axis??"left")===v);if(O.length===0)return null;let B=Number.POSITIVE_INFINITY,Y=Number.NEGATIVE_INFINITY;for(const lt of O)for(let bt=0;bt<s.length;bt+=1){const it=H(lt.key,bt);it&&(B=Math.min(B,it.top,it.base),Y=Math.max(Y,it.top,it.base))}if(O.some(lt=>lt.type!=="line")&&(B=Math.min(B,0),Y=Math.max(Y,0)),!Number.isFinite(B)||!Number.isFinite(Y))return[0,1];const[et,J]=v==="left"?t.domain??[void 0,void 0]:[void 0,void 0],K=$t(et??B,J??Y);return[et??K[0],J??K[1]]},P=q("left")??[0,1],N=q("right"),R=N!==null&&!I,E=ot(P[0],P[1],5).map(t.formatLeft),w=N?ot(N[0],N[1],5).map(t.formatRight):[],j=s.map(v=>k(v[e])),h=I?Math.min(r*.4,Math.max(ct.minLeft,...j.map(ht))+12):Math.max(ct.minLeft,...E.map(ht))+10,y=R?Math.max(ct.minLeft,...w.map(ht))+10:ct.right,a={left:h,top:ct.top,right:Math.max(h+1,r-y),bottom:Math.max(ct.top+1,u-ct.bottom),width:Math.max(1,r-y-h),height:Math.max(1,u-ct.bottom-ct.top)},i=I?[a.top,a.bottom]:[a.left,a.right],c=I?[a.left,a.right]:[a.bottom,a.top],o=mt(P,c),x=N?mt(N,c):o,_=v=>(v.axis??"left")==="right"&&N?x:o;let $,b=0,p=null;if(F){const v=M.map(O=>wt(O));p=mt(xt(v),i),$=v.map(p)}else{const v=Rt(s.map((O,B)=>String(B)),i,T?{paddingInner:.24,paddingOuter:.12}:{paddingInner:0,paddingOuter:0});b=v.bandwidth,$=s.map((O,B)=>v(String(B))+v.bandwidth/2)}const C=(v,O)=>I?{x:O,y:v}:{x:v,y:O},G=[],V=n.filter(v=>v.type==="bar"),Z=m?1:Math.max(1,V.length),D=Z>1?Math.min(2,b*.04):0,g=Math.max(1,(b-D*(Z-1))/Z);V.forEach((v,O)=>{const B=_(v),Y=m?0:O;s.forEach((et,J)=>{const K=H(v.key,J);if(!K||K.top===K.base)return;const lt=$[J]-b/2+Y*(g+D),bt=B(K.base),it=B(K.top),Wt=Math.min(bt,it),Vt=Math.max(1,Math.abs(it-bt));G.push(I?{key:v.key,index:J,tone:v.tone,x:Wt,y:lt,width:Vt,height:g}:{key:v.key,index:J,tone:v.tone,x:lt,y:Wt,width:g,height:Vt})})});const S={},L=[],X=[];for(const v of n){if(v.type==="bar")continue;const O=_(v),B=s.map((Y,et)=>{const J=H(v.key,et);return J?C($[et],O(J.top)):null});if(S[v.key]=B,v.type==="area"){const Y=s.map((et,J)=>{const K=H(v.key,J);return K?C($[J],O(K.base)):null});X.push({key:v.key,tone:v.tone,d:ye(B,Y,d)})}L.push({key:v.key,tone:v.tone,d:pe(B,d)})}const rt=s.map((v,O)=>{let B=null;for(const et of n){const J=H(et.key,O);if(!J)continue;const K=_(et)(J.top);B=B===null?K:I?Math.max(B,K):Math.min(B,K)}const Y=I?a.left:a.bottom;return C($[O],B??Y)}),jt=(v,O,B)=>ot(O[0],O[1],I?Math.max(2,Math.floor(a.width/90)):Math.max(2,Math.floor(a.height/48))).map(Y=>({position:v(Y),label:B(Y)})),he=p?ot(p.domain[0],p.domain[1],Math.max(2,Math.floor(a.width/90))).map(v=>({position:p(v),label:k(v)})):s.map((v,O)=>({position:$[O],label:I?St(j[O],h-12):j[O]}));return{zero:P[0]<0&&P[1]>0?o(0):null,area:a,centers:$,bandwidth:b,isContinuous:F,categoryTicks:he,leftTicks:jt(o,P,t.formatLeft),rightTicks:R&&N?jt(x,N,t.formatRight):[],hasRightAxis:R,lines:L,areas:X,bars:G,points:S,anchors:rt}},Zt=(...t)=>{let s="";for(const e of t)e&&(s=s===""?e:`${s} ${e}`);return s},Ut=["cat-1","cat-2","cat-3","cat-4","cat-5","series-2"],vt=(t,s)=>s??Ut[t%Ut.length],U=t=>t==="muted"?"var(--hanui-text-3)":`var(--hanui-${t})`,$e="hanui-chart-iR-5u",je="hanui-chart__canvas-4wf8o",ke="hanui-chart__svg-yC5iw",Ne="hanui-chart__overlay-kbXEv",ve="hanui-chart__tooltip-wbhLY",Ae="hanui-chart__tooltipTitle-j-1Nw",Ce="hanui-chart__tooltipRow-phors",Te="hanui-chart__tooltipLabel-72x80",Ie="hanui-chart__tooltipValue-caeby",Re="hanui-chart__swatch--mk77",Se="hanui-chart__legend-EhXcQ",Fe="hanui-chart__legendItem--AaGe",He="hanui-chart__srOnly-Oyem2",Q={chart:$e,chart__canvas:je,chart__svg:ke,chart__overlay:Ne,chart__tooltip:ve,chart__tooltipTitle:Ae,chart__tooltipRow:Ce,chart__tooltipLabel:Te,chart__tooltipValue:Ie,chart__swatch:Re,chart__legend:Se,chart__legendItem:Fe,"chart__legendItem--hidden":"hanui-chart__legendItem--hidden-D3li8",chart__srOnly:He},Qt=12,ft=({label:t,description:s,containerRef:e,width:n,height:r,plot:u,overlay:m,underlay:d,itemCount:k,columns:T,pick:A,tooltip:I,anchor:M,tooltipSide:F="inward",announce:z,table:H,legend:q,className:P,testId:N})=>{const R=f.useId(),E=dt.useAnnounce(),[w,j]=f.useState(null),h=f.useRef(null),y=f.useRef(null),a=f.useRef(null);f.useEffect(()=>{w!==null&&w>=k&&j(k>0?k-1:null)},[w,k]),f.useEffect(()=>()=>{h.current!==null&&cancelAnimationFrame(h.current)},[]);const i=f.useCallback(b=>{const p=b.currentTarget.getBoundingClientRect();a.current={x:b.clientX-p.left,y:b.clientY-p.top},h.current===null&&(h.current=requestAnimationFrame(()=>{h.current=null;const C=a.current;C&&j(A(C.x,C.y))}))},[A]),c=b=>{const p=Math.min(k-1,Math.max(0,b));j(p),E(z(p))},o=b=>{if(k===0)return;const p=w??-1,C=T??1,G=b.key==="ArrowRight"?p+1:b.key==="ArrowLeft"?Math.max(0,p-1):b.key==="ArrowDown"?p<0?0:p+C:b.key==="ArrowUp"?Math.max(0,p-C):b.key==="Home"?0:b.key==="End"?k-1:null;if(b.key==="Escape"&&w!==null){b.preventDefault(),j(null);return}G!==null&&(b.preventDefault(),c(G))},x=w===null?null:I(w),_=w===null?null:M(w),$=_==null?void 0:_.x;return f.useLayoutEffect(()=>{const b=y.current;if(!b||$===void 0)return;const p=b.offsetWidth,C=$>n/2,G=F==="outward"?!C:C,V=$-Qt-p,Z=$+Qt,D=V>=0,g=Z+p<=n,S=F==="outward"?G?V:Z:G?D||!g?V:Z:g||!D?Z:V;b.style.left=`${Math.min(Math.max(0,S),Math.max(0,n-p))}px`},[w,$,n,F]),l.jsxs("figure",{className:Zt(Q.chart,P),"data-testid":N,children:[l.jsxs("div",{ref:e,className:Q.chart__canvas,style:{blockSize:r},children:[l.jsxs("svg",{className:Q.chart__svg,width:n,height:r,viewBox:`0 0 ${n} ${r}`,role:"img","aria-label":t,"aria-describedby":s?R:void 0,tabIndex:k>0?0:void 0,onPointerMove:i,onPointerDown:i,onPointerLeave:()=>j(null),onKeyDown:o,onBlur:()=>j(null),children:[w!==null&&d&&l.jsx("g",{className:Q.chart__overlay,children:d(w)}),u,w!==null&&l.jsx("g",{className:Q.chart__overlay,children:m(w)})]}),x&&_&&l.jsxs("div",{ref:y,"aria-hidden":!0,className:Q.chart__tooltip,style:{insetBlockStart:Math.max(24,Math.min(_.y,r-24))},children:[x.title&&l.jsx("span",{className:Q.chart__tooltipTitle,children:x.title}),x.rows.map(b=>l.jsxs("span",{className:Q.chart__tooltipRow,children:[b.tone&&l.jsx("span",{className:Q.chart__swatch,style:{backgroundColor:U(b.tone)}}),l.jsx("span",{className:Q.chart__tooltipLabel,children:b.label}),l.jsx("span",{className:Q.chart__tooltipValue,children:b.value})]},b.id))]})]}),q&&q.entries.length>1&&l.jsx("ul",{className:Q.chart__legend,children:q.entries.map(b=>{const p=q.hidden.has(b.id);return l.jsx("li",{children:l.jsxs("button",{type:"button",className:Zt(Q.chart__legendItem,p&&Q["chart__legendItem--hidden"]),"aria-pressed":!p,onClick:()=>q.onToggle(b.id),children:[l.jsx(Le,{tone:b.tone,isHidden:p}),b.label]})},b.id)})}),s&&l.jsx("p",{id:R,className:Q.chart__srOnly,children:s}),l.jsx("div",{className:Q.chart__srOnly,children:l.jsxs("table",{children:[l.jsx("caption",{children:t}),l.jsx("thead",{children:l.jsx("tr",{children:H.columns.map((b,p)=>l.jsx("th",{scope:"col",children:b},p))})}),l.jsx("tbody",{children:H.rows.map((b,p)=>l.jsx("tr",{children:b.map((C,G)=>G===0?l.jsx("th",{scope:"row",children:C},G):l.jsx("td",{children:C},G))},p))})]})})]})},Le=({tone:t,isHidden:s})=>l.jsx("span",{"aria-hidden":!0,className:Q.chart__swatch,style:s?{backgroundColor:"transparent",boxShadow:`inset 0 0 0 2px ${U(t)}`}:{backgroundColor:U(t)}}),Jt=new Map,ie=(t,s)=>{const e=`${t??""}|${JSON.stringify(s)}`;let n=Jt.get(e);return n||(n=new Intl.NumberFormat(t,s),Jt.set(e,n)),n},At=t=>s=>ie(t,{notation:"compact",maximumFractionDigits:1}).format(s),pt=t=>s=>ie(t,{maximumFractionDigits:2}).format(s),ze=640,Ee=typeof window>"u"?()=>{}:f.useLayoutEffect,yt=t=>{const s=f.useRef(null),[e,n]=f.useState(t??ze);return Ee(()=>{if(t!==void 0){n(t);return}const r=s.current;if(!r)return;const u=d=>{const k=Math.floor(d);k>0&&n(T=>T===k?T:k)};if(u(r.clientWidth),typeof ResizeObserver>"u")return;const m=new ResizeObserver(([d])=>u(d.contentRect.width));return m.observe(r),()=>m.disconnect()},[t]),[s,e]},Pe="hanui-line-CLpqU",De="hanui-area-LkWXB",qe="hanui-bar-260Bd",Ge="hanui-point-Vc-kX",Oe="hanui-marker-G-xZb",Be="hanui-crosshair-nV-xX",We="hanui-band-jnG7s",Ve="hanui-zero-GpHvw",nt={line:Pe,area:De,bar:qe,point:Ge,marker:Oe,crosshair:Be,band:We,zero:Ve},Xe=280,Kt="—",Ye=({label:t,description:s,data:e,xKey:n,xLabel:r,series:u,height:m=Xe,width:d,isStacked:k=!1,orientation:T="vertical",curve:A="monotone",hasPoints:I=!1,formatX:M=String,formatValue:F,domain:z,className:H,testId:q})=>{const{labels:P}=dt.useHanui(),N=P==null?void 0:P.locale,[R,E]=yt(d),[w,j]=f.useState(()=>new Set),h=f.useMemo(()=>F??pt(N),[F,N]),y=f.useMemo(()=>At(N),[N]),a=f.useCallback(g=>g==null?"":M(g),[M]),i=f.useMemo(()=>u.map((g,S)=>({...g,tone:vt(S,g.tone)})),[u]),c=f.useMemo(()=>i.filter(g=>!w.has(g.key)),[i,w]),o=f.useMemo(()=>we({rows:e,xKey:n,series:c,width:E,height:m,isStacked:k,orientation:T,curve:A,formatX:a,formatLeft:y,formatRight:y,domain:z}),[e,n,c,E,m,k,T,A,a,y,z]),x=T==="horizontal"&&c.length>0&&c.every(g=>g.type==="bar"),_=c.some(g=>g.type==="bar"),$=f.useMemo(()=>{const g=o.centers.map((S,L)=>({center:S,index:L})).sort((S,L)=>S.center-L.center);return{centers:g.map(S=>S.center),indices:g.map(S=>S.index)}},[o.centers]),b=f.useCallback((g,S)=>{const{area:L}=o;if(g<L.left-4||g>L.right+4||S<L.top-4||S>L.bottom+4)return null;const X=be($.centers,x?S:g);return X<0?null:$.indices[X]},[o,$,x]),p=f.useCallback(g=>{var S;return{title:a((S=e[g])==null?void 0:S[n]),rows:c.map(L=>{var rt;const X=wt((rt=e[g])==null?void 0:rt[L.key]);return{id:L.key,label:L.label,tone:L.tone,value:X===null?Kt:(L.format??h)(X)}})}},[e,n,c,h,a]),C=f.useCallback(g=>{const S=p(g);return`${S.title}: ${S.rows.map(L=>`${L.label} ${L.value}`).join(", ")}`},[p]),G=f.useMemo(()=>({columns:[r??n,...i.map(g=>g.label)],rows:e.map(g=>[a(g[n]),...i.map(S=>{const L=wt(g[S.key]);return L===null?Kt:(S.format??h)(L)})])}),[e,n,r,i,h,a]),V=f.useMemo(()=>l.jsxs("g",{children:[x?l.jsxs(l.Fragment,{children:[l.jsx(ut,{area:o.area,ticks:o.leftTicks,side:"bottom",hasGrid:!0}),l.jsx(qt,{area:o.area,ticks:o.categoryTicks,side:"left"})]}):l.jsxs(l.Fragment,{children:[l.jsx(ut,{area:o.area,ticks:o.leftTicks,side:"left",hasGrid:!0}),o.hasRightAxis&&l.jsx(ut,{area:o.area,ticks:o.rightTicks,side:"right"}),l.jsx(qt,{area:o.area,ticks:o.categoryTicks,side:"bottom"})]}),o.zero!==null&&(x?l.jsx("line",{className:nt.zero,x1:o.zero,x2:o.zero,y1:o.area.top,y2:o.area.bottom}):l.jsx("line",{className:nt.zero,x1:o.area.left,x2:o.area.right,y1:o.zero,y2:o.zero})),o.areas.map(g=>l.jsx("path",{d:g.d,className:nt.area,style:{fill:`color-mix(in srgb, ${U(g.tone)} 18%, transparent)`}},`area-${g.key}`)),o.bars.map(g=>l.jsx("rect",{className:nt.bar,x:g.x,y:g.y,width:g.width,height:g.height,rx:Math.min(3,g.width/4,g.height/4),style:{fill:U(g.tone)}},`bar-${g.key}-${g.index}`)),o.lines.map(g=>l.jsx("path",{d:g.d,className:nt.line,style:{stroke:U(g.tone)}},`line-${g.key}`)),c.filter(g=>g.type!=="bar").flatMap(g=>(o.points[g.key]??[]).map((S,L,X)=>S&&(I||!X[L-1]&&!X[L+1])?l.jsx("circle",{className:nt.point,cx:S.x,cy:S.y,r:3,style:{fill:U(g.tone)}},`point-${g.key}-${L}`):null))]}),[o,I,x,c]),Z=f.useCallback(g=>{if(!_||o.bandwidth<=0)return null;const{area:S}=o,L=o.centers[g],X=o.bandwidth*.12;return x?l.jsx("rect",{className:nt.band,x:S.left,width:S.width,y:L-o.bandwidth/2-X,height:o.bandwidth+X*2}):l.jsx("rect",{className:nt.band,y:S.top,height:S.height,x:L-o.bandwidth/2-X,width:o.bandwidth+X*2})},[o,x,_]),D=f.useCallback(g=>{const{area:S}=o,L=o.centers[g];return l.jsxs(l.Fragment,{children:[!_&&l.jsx("line",{className:nt.crosshair,x1:L,x2:L,y1:S.top,y2:S.bottom}),c.filter(X=>X.type!=="bar").map(X=>{var jt;const rt=(jt=o.points[X.key])==null?void 0:jt[g];return rt?l.jsx("circle",{className:nt.marker,cx:rt.x,cy:rt.y,r:4.5,style:{fill:U(X.tone)}},X.key):null})]})},[o,c,_]);return l.jsx(ft,{label:t,description:s,containerRef:R,width:E,height:m,plot:V,overlay:D,underlay:Z,itemCount:e.length,pick:b,tooltip:p,anchor:g=>o.anchors[g]??{x:0,y:0},announce:C,table:G,legend:{entries:i.map(g=>({id:g.key,label:g.label,tone:g.tone})),hidden:w,onToggle:g=>j(S=>{const L=new Set(S);return L.has(g)?L.delete(g):i.length-S.size>1&&L.add(g),L})},className:H,testId:q})},Lt=f.memo(Ye),Ze=({series:t,...s})=>{const e=f.useMemo(()=>t.map(n=>({...n,type:"line"})),[t]);return l.jsx(Lt,{...s,series:e})},Ue=f.memo(at(Ze,"LineChart")),Qe=({series:t,...s})=>{const e=f.useMemo(()=>t.map(n=>({...n,type:"area"})),[t]);return l.jsx(Lt,{...s,series:e})},Je=f.memo(at(Qe,"AreaChart")),Ke=({series:t,...s})=>{const e=f.useMemo(()=>t.map(n=>({...n,type:"bar"})),[t]);return l.jsx(Lt,{...s,series:e})},tn=f.memo(at(Ke,"BarChart")),en=t=>l.jsx(Lt,{...t}),nn=f.memo(at(en,"ComposedChart")),sn="hanui-slice-dFWuh",on="hanui-center__value-GnqKe",an="hanui-center__label-DsgTV",kt={slice:sn,center__value:on,center__label:an},Ct=6,te=1.5,cn=({label:t,description:s,data:e,variant:n="donut",centerValue:r,centerLabel:u,valueLabel:m,height:d=260,width:k,formatValue:T,className:A,testId:I})=>{const{labels:M}=dt.useHanui(),[F,z]=yt(k),[H,q]=f.useState(()=>new Set),P=f.useMemo(()=>pt(M==null?void 0:M.locale),[M==null?void 0:M.locale]),N=T??P,R=f.useMemo(()=>e.map((a,i)=>({...a,tone:vt(i,a.tone)})),[e]),E=f.useMemo(()=>{const a=R.filter(p=>!H.has(p.id)&&Number.isFinite(p.value)&&p.value>0),i=a.reduce((p,C)=>p+C.value,0),c=z/2,o=d/2,x=Math.max(8,Math.min(z,d)/2-Ct-4),_=n==="donut"?x*.62:0;let $=0;const b=a.map(p=>{const C=i>0?p.value/i*Math.PI*2:0,G=$;return $+=C,{...p,start:G,end:$,share:i>0?p.value/i:0}});return{cx:c,cy:o,outer:x,inner:_,total:i,slices:b}},[R,H,z,d,n]),w=f.useMemo(()=>{const a=new Intl.NumberFormat(M==null?void 0:M.locale,{style:"percent",maximumFractionDigits:1});return i=>a.format(i)},[M==null?void 0:M.locale]),j=f.useMemo(()=>{const{cx:a,cy:i,outer:c,inner:o,slices:x,total:_}=E;return l.jsxs("g",{children:[x.map($=>l.jsx("path",{className:kt.slice,d:Xt(a,i,c,o,$.start,$.end),style:{fill:U($.tone),strokeWidth:x.length>1?te:0}},$.id)),n==="donut"&&l.jsxs("g",{"aria-hidden":!0,className:kt.center,children:[l.jsx("text",{className:kt.center__value,x:a,y:u?i-4:i,dy:"0.32em",textAnchor:"middle",children:r??N(_)}),u&&l.jsx("text",{className:kt.center__label,x:a,y:i+16,dy:"0.32em",textAnchor:"middle",children:u})]})]})},[E,n,r,u,N]),h=f.useCallback((a,i)=>{const{cx:c,cy:o,outer:x,inner:_,slices:$}=E,b=Math.hypot(a-c,i-o);if(b>x+Ct||b<_)return null;let p=Math.atan2(a-c,-(i-o));p<0&&(p+=Math.PI*2);const C=$.findIndex(G=>p>=G.start&&p<G.end);return C<0?null:C},[E]),y=a=>{const i=E.slices[a];return`${N(i.value)} (${w(i.share)})`};return l.jsx(ft,{label:t,description:s,containerRef:F,width:z,height:d,plot:j,overlay:a=>{const{cx:i,cy:c,outer:o,inner:x,slices:_}=E,$=_[a],b=($.start+$.end)/2,p=tt(0,0,Ct,b);return l.jsx("path",{className:kt.slice,d:Xt(i+p.x,c+p.y,o,x,$.start,$.end),style:{fill:U($.tone),strokeWidth:te}})},itemCount:E.slices.length,pick:h,tooltip:a=>{const i=E.slices[a];return{rows:[{id:i.id,label:i.label,value:y(a),tone:i.tone}]}},anchor:a=>{const{cx:i,cy:c,outer:o,slices:x}=E,_=x[a];return tt(i,c,o+Ct,(_.start+_.end)/2)},tooltipSide:"outward",announce:a=>`${E.slices[a].label}: ${y(a)}`,table:{columns:[t,m],rows:R.map(a=>[a.label,Number.isFinite(a.value)?N(a.value):"—"])},legend:{entries:R.map(a=>({id:a.id,label:a.label,tone:a.tone})),hidden:H,onToggle:a=>q(i=>{const c=new Set(i);return c.has(a)?c.delete(a):R.length-i.size>1&&c.add(a),c})},className:A,testId:I})},rn=f.memo(at(cn,"PieChart")),Bt=(t,s,e,{top:n=12,right:r=16,bottom:u=28}={})=>{const m=Math.max(32,...e.map(ht))+10;return{left:m,top:n,right:Math.max(m+1,t-r),bottom:Math.max(n+1,s-u),width:Math.max(1,t-r-m),height:Math.max(1,s-n-u)}},Nt=(t,s)=>Math.max(2,Math.floor(t/(s?90:48))),ln=(t,s=24)=>{const e=new Map,n=(r,u)=>`${r}:${u}`;return t.forEach((r,u)=>{if(!Number.isFinite(r.x)||!Number.isFinite(r.y))return;const m=n(Math.floor(r.x/s),Math.floor(r.y/s)),d=e.get(m);d?d.push(u):e.set(m,[u])}),{nearest:(r,u,m)=>{const d=Math.ceil(m/s),k=Math.floor(r/s),T=Math.floor(u/s);let A=null,I=m*m;for(let M=-d;M<=d;M+=1)for(let F=-d;F<=d;F+=1)for(const z of e.get(n(k+M,T+F))??[]){const H=(t[z].x-r)**2+(t[z].y-u)**2;H<=I&&(I=H,A=z)}return A}}},hn="hanui-point-YKyMm",un="hanui-marker-ToO1T",ee={point:hn,marker:un},gt={plain:4,min:3,max:16},mn=22,dn=({label:t,description:s,series:e,xLabel:n,yLabel:r,sizeLabel:u,height:m=300,width:d,formatX:k,formatY:T,className:A,testId:I})=>{const{labels:M}=dt.useHanui(),[F,z]=yt(d),[H,q]=f.useState(()=>new Set),P=f.useMemo(()=>pt(M==null?void 0:M.locale),[M==null?void 0:M.locale]),N=f.useMemo(()=>At(M==null?void 0:M.locale),[M==null?void 0:M.locale]),R=k??P,E=T??P,w=f.useMemo(()=>e.map((c,o)=>({...c,tone:vt(o,c.tone)})),[e]),j=f.useMemo(()=>w.filter(c=>!H.has(c.id)).flatMap(c=>c.data.filter(o=>Number.isFinite(o.x)&&Number.isFinite(o.y)).map(o=>({...o,series:c}))).sort((c,o)=>c.x-o.x||c.y-o.y),[w,H]),h=f.useMemo(()=>{const c=$t(...xt(j.map(D=>D.x))),o=$t(...xt(j.map(D=>D.y))),x=ot(o[0],o[1],Nt(m,!1)),_=Bt(z,m,x.map(N),{right:20}),$=mt(c,[_.left,_.right]),b=mt(o,[_.bottom,_.top]),p=Ht(j.map(D=>D.size)),[C,G]=xt(p),V=D=>D===void 0||!Number.isFinite(D)||p.length===0?gt.plain:G===C?(gt.min+gt.max)/2:Math.sqrt(gt.min**2+(D-C)/(G-C)*(gt.max**2-gt.min**2)),Z=j.map(D=>({...D,cx:$(D.x),cy:b(D.y),r:V(D.size)}));return{area:_,placed:Z,index:ln(Z.map(D=>({x:D.cx,y:D.cy}))),xTicks:ot(c[0],c[1],Nt(_.width,!0)).map(D=>({position:$(D),label:N(D)})),yTicks:x.map(D=>({position:b(D),label:N(D)}))}},[j,z,m,N]),y=f.useMemo(()=>l.jsxs("g",{children:[l.jsx(ut,{area:h.area,ticks:h.yTicks,side:"left",hasGrid:!0}),l.jsx(ut,{area:h.area,ticks:h.xTicks,side:"bottom",hasGrid:!0}),h.placed.map((c,o)=>l.jsx("circle",{className:ee.point,cx:c.cx,cy:c.cy,r:c.r,style:{fill:`color-mix(in srgb, ${U(c.series.tone)} 72%, transparent)`,stroke:U(c.series.tone)}},o))]}),[h]),a=f.useCallback((c,o)=>h.index.nearest(c,o,mn),[h]),i=c=>{const o=h.placed[c];return{title:o.label??o.series.label,rows:[{id:"series",label:o.series.label,value:"",tone:o.series.tone},{id:"x",label:n,value:R(o.x)},{id:"y",label:r,value:E(o.y)},...o.size!==void 0&&u?[{id:"size",label:u,value:P(o.size)}]:[]]}};return l.jsx(ft,{label:t,description:s,containerRef:F,width:z,height:m,plot:y,overlay:c=>{const o=h.placed[c];return l.jsx("circle",{className:ee.marker,cx:o.cx,cy:o.cy,r:o.r+3,style:{stroke:U(o.series.tone)}})},itemCount:h.placed.length,pick:a,tooltip:i,anchor:c=>({x:h.placed[c].cx,y:h.placed[c].cy}),announce:c=>{const o=h.placed[c];return`${o.label?`${o.label}, `:""}${o.series.label}: ${n} ${R(o.x)}, ${r} ${E(o.y)}`},table:{columns:[t,n,r],rows:j.map(c=>[c.label??c.series.label,R(c.x),E(c.y)])},legend:{entries:w.map(c=>({id:c.id,label:c.label,tone:c.tone})),hidden:H,onToggle:c=>q(o=>{const x=new Set(o);return x.has(c)?x.delete(c):w.length-o.size>1&&x.add(c),x})},className:A,testId:I})},xn=f.memo(at(dn,"ScatterPlot")),fn="hanui-labels-MJWYF",pn="hanui-empty-AW7c9",yn="hanui-focus-hLQdB",Tt={labels:fn,empty:pn,focus:yn},Et=8,bn=28,Pt=140,ne=(t,s,e)=>{var r;const n=(r=t[s])==null?void 0:r[e];return typeof n=="number"&&Number.isFinite(n)?n:null},se=t=>t.map((s,e)=>String(e)),gn=({label:t,description:s,columns:e,rows:n,values:r,valueLabel:u,tone:m="cat-1",height:d=280,width:k,formatValue:T,className:A,testId:I})=>{const{labels:M}=dt.useHanui(),[F,z]=yt(k),H=f.useMemo(()=>pt(M==null?void 0:M.locale),[M==null?void 0:M.locale]),q=T??H,P=`hanui-heat-${f.useId().replace(/:/g,"")}`,N=f.useMemo(()=>{const y={left:Math.min(z*.3,Math.max(32,...n.map(ht))+12),top:8,right:z-8,bottom:d-28-bn},a=Rt(se(e),[y.left,y.right],{paddingInner:.06,paddingOuter:0}),i=Rt(se(n),[y.top,y.bottom],{paddingInner:.06,paddingOuter:0}),[c,o]=xt(Ht(r.flat())),x=$=>$===null?null:o===c?60:Et+($-c)/(o-c)*(100-Et),_=n.flatMap(($,b)=>e.map((p,C)=>{const G=ne(r,b,C);return{row:$,column:p,key:`${b}:${C}`,value:G,x:a(String(C)),y:i(String(b)),width:a.bandwidth,height:i.bandwidth,mix:x(G)}}));return{area:y,x:a,y:i,cells:_,min:c,max:o}},[e,n,r,z,d]),R=U(m),E=f.useMemo(()=>{const{area:h,x:y,y:a,cells:i}=N,c=q(N.max),o=h.right-ht(c)-8,x=re(e.map((_,$)=>({position:y(String($))+y.bandwidth/2,label:_})));return l.jsxs("g",{children:[i.map(_=>l.jsx("rect",{className:_.mix===null?Tt.empty:void 0,x:_.x,y:_.y,width:_.width,height:_.height,rx:2,style:_.mix===null?void 0:{fill:`color-mix(in srgb, ${R} ${_.mix}%, var(--hanui-surface))`}},_.key)),l.jsxs("g",{"aria-hidden":!0,className:Tt.labels,children:[n.map((_,$)=>l.jsx("text",{x:h.left-8,y:a(String($))+a.bandwidth/2,dy:"0.32em",textAnchor:"end",children:St(_,h.left-12)},$)),x.map(_=>l.jsx("text",{x:_.position,y:h.bottom+16,textAnchor:"middle",children:_.label},_.position))]}),l.jsx("defs",{children:l.jsxs("linearGradient",{id:P,children:[l.jsx("stop",{offset:"0%",style:{stopColor:`color-mix(in srgb, ${R} ${Et}%, var(--hanui-surface))`}}),l.jsx("stop",{offset:"100%",style:{stopColor:R}})]})}),l.jsxs("g",{"aria-hidden":!0,className:Tt.labels,children:[l.jsx("rect",{x:o-Pt,y:d-18,width:Pt,height:8,rx:4,style:{fill:`url(#${P})`}}),l.jsx("text",{x:o-Pt-8,y:d-14,dy:"0.32em",textAnchor:"end",children:q(N.min)}),l.jsx("text",{x:h.right,y:d-14,dy:"0.32em",textAnchor:"end",children:c})]})]})},[N,e,n,R,P,d,q]),w=f.useCallback((h,y)=>{const{area:a,x:i,y:c}=N;if(h<a.left||h>a.right||y<a.top||y>a.bottom)return null;const o=i.indexAt(h),x=c.indexAt(y);return o<0||x<0?null:x*e.length+o},[N,e.length]),j=h=>{const y=N.cells[h];return{cell:y,value:y.value===null?"—":q(y.value)}};return l.jsx(ft,{label:t,description:s,containerRef:F,width:z,height:d,plot:E,overlay:h=>{const y=N.cells[h];return l.jsx("rect",{className:Tt.focus,x:y.x-1,y:y.y-1,width:y.width+2,height:y.height+2,rx:3})},itemCount:N.cells.length,columns:e.length,pick:w,tooltip:h=>{const{cell:y,value:a}=j(h);return{title:`${y.row} · ${y.column}`,rows:[{id:"value",label:u,value:a,tone:m}]}},anchor:h=>{const y=N.cells[h];return{x:y.x+y.width/2,y:y.y+y.height/2}},announce:h=>{const{cell:y,value:a}=j(h);return`${y.row}, ${y.column}: ${u} ${a}`},table:{columns:[t,...e],rows:n.map((h,y)=>[h,...e.map((a,i)=>{const c=ne(r,y,i);return c===null?"—":q(c)})])},className:A,testId:I})},Mn=f.memo(at(gn,"Heatmap")),_n="hanui-box-7zEQ-",wn="hanui-median-J5g6o",$n="hanui-outlier-M0VN-",jn="hanui-band-kK09D",It={box:_n,median:wn,outlier:$n,band:jn},kn=({label:t,description:s,groups:e,groupLabel:n,labels:r,height:u=280,width:m,formatValue:d,className:k,testId:T})=>{const{labels:A}=dt.useHanui(),[I,M]=yt(m),F=f.useMemo(()=>pt(A==null?void 0:A.locale),[A==null?void 0:A.locale]),z=f.useMemo(()=>At(A==null?void 0:A.locale),[A==null?void 0:A.locale]),H=d??F,q=f.useMemo(()=>e.map((w,j)=>({group:w,tone:vt(j,w.tone),stats:ge(w.values)})),[e]),P=f.useMemo(()=>{const w=q.flatMap(x=>x.stats?[x.stats.min,x.stats.max]:[]),[j,h]=w.length?xt(w):[0,1],y=$t(j,h),a=ot(y[0],y[1],Nt(u,!1)),i=Bt(M,u,a.map(z)),c=Rt(e.map(x=>x.id),[i.left,i.right],{paddingInner:.4,paddingOuter:.2}),o=mt(y,[i.bottom,i.top]);return{area:i,band:c,y:o,yTicks:a.map(x=>({position:o(x),label:z(x)})),groupTicks:e.map(x=>({position:c(x.id)+c.bandwidth/2,label:x.label}))}},[q,e,M,u,z]),N=w=>[{id:"max",label:r.max,value:H(w.whiskerHigh)},{id:"q3",label:r.q3,value:H(w.q3)},{id:"median",label:r.median,value:H(w.median)},{id:"q1",label:r.q1,value:H(w.q1)},{id:"min",label:r.min,value:H(w.whiskerLow)},...w.outliers.length>0?[{id:"outliers",label:r.outliers,value:F(w.outliers.length)}]:[],{id:"count",label:r.count,value:F(w.count)}],R=f.useMemo(()=>{const{area:w,band:j,y:h}=P;return l.jsxs("g",{children:[l.jsx(ut,{area:w,ticks:P.yTicks,side:"left",hasGrid:!0}),l.jsx(qt,{area:w,ticks:P.groupTicks,side:"bottom"}),q.map(({group:y,tone:a,stats:i})=>{if(!i)return null;const c=j(y.id),o=c+j.bandwidth/2,x=j.bandwidth*.3,_=U(a);return l.jsxs("g",{style:{stroke:_},className:It.box,children:[l.jsx("line",{x1:o,x2:o,y1:h(i.whiskerHigh),y2:h(i.q3)}),l.jsx("line",{x1:o,x2:o,y1:h(i.q1),y2:h(i.whiskerLow)}),l.jsx("line",{x1:o-x,x2:o+x,y1:h(i.whiskerHigh),y2:h(i.whiskerHigh)}),l.jsx("line",{x1:o-x,x2:o+x,y1:h(i.whiskerLow),y2:h(i.whiskerLow)}),l.jsx("rect",{x:c,width:j.bandwidth,y:h(i.q3),height:Math.max(1,h(i.q1)-h(i.q3)),rx:2,style:{fill:`color-mix(in srgb, ${_} 22%, transparent)`}}),l.jsx("line",{className:It.median,x1:c,x2:c+j.bandwidth,y1:h(i.median),y2:h(i.median)}),i.outliers.map(($,b)=>l.jsx("circle",{className:It.outlier,cx:o,cy:h($),r:3},b))]},y.id)})]})},[P,q]),E=f.useCallback((w,j)=>{const{area:h,band:y}=P;if(w<h.left||w>h.right||j<h.top-4||j>h.bottom+4)return null;const a=y.indexAt(w);return a<0?null:a},[P]);return l.jsx(ft,{label:t,description:s,containerRef:I,width:M,height:u,plot:R,underlay:w=>{const{area:j,band:h}=P,y=h.step*.2;return l.jsx("rect",{className:It.band,x:h(e[w].id)-y,width:h.bandwidth+y*2,y:j.top,height:j.height})},overlay:()=>null,itemCount:e.length,pick:E,tooltip:w=>{const j=q[w];return{title:j.group.label,rows:j.stats?N(j.stats).map(h=>({...h,tone:h.id==="median"?j.tone:void 0})):[]}},anchor:w=>{const j=q[w],{band:h,y}=P;return{x:h(j.group.id)+h.bandwidth/2,y:j.stats?y(j.stats.q3):P.area.bottom}},announce:w=>{const j=q[w];return j.stats?`${j.group.label}: ${N(j.stats).map(h=>`${h.label} ${h.value}`).join(", ")}`:j.group.label},table:{columns:[n,r.min,r.q1,r.median,r.q3,r.max,r.count],rows:q.map(({group:w,stats:j})=>j?[w.label,H(j.whiskerLow),H(j.q1),H(j.median),H(j.q3),H(j.whiskerHigh),F(j.count)]:[w.label,"—","—","—","—","—","0"])},className:k,testId:T})},Nn=f.memo(at(kn,"BoxPlot")),vn="hanui-baseline-wWs7h",An="hanui-band-xvYtL",oe={baseline:vn,band:An},Mt=1,Cn=({label:t,description:s,values:e,bins:n,valueLabel:r,countLabel:u,tone:m="cat-1",height:d=260,width:k,formatValue:T,className:A,testId:I})=>{const{labels:M}=dt.useHanui(),[F,z]=yt(k),H=f.useMemo(()=>pt(M==null?void 0:M.locale),[M==null?void 0:M.locale]),q=f.useMemo(()=>At(M==null?void 0:M.locale),[M==null?void 0:M.locale]),P=T??H,N=f.useMemo(()=>Me(e,n),[e,n]),R=f.useMemo(()=>{var $,b;const h=Math.max(1,...N.map(p=>p.count)),y=$t(0,h),a=ot(0,y[1],Nt(d,!1)).filter(Number.isInteger),i=Bt(z,d,a.map(q)),c=(($=N[0])==null?void 0:$.from)??0,o=((b=N[N.length-1])==null?void 0:b.to)??1,x=mt([c,o],[i.left,i.right]),_=mt(y,[i.bottom,i.top]);return{area:i,columns:N.map(p=>({x:x(p.from)+Mt/2,width:Math.max(1,x(p.to)-x(p.from)-Mt),y:_(p.count),height:Math.max(0,i.bottom-_(p.count)),center:(x(p.from)+x(p.to))/2})),xTicks:ot(c,o,Nt(i.width,!0)).map(p=>({position:x(p),label:q(p)})),yTicks:a.map(p=>({position:_(p),label:q(p)}))}},[N,z,d,q]),E=h=>`${P(N[h].from)} – ${P(N[h].to)}`,w=f.useMemo(()=>l.jsxs("g",{children:[l.jsx(ut,{area:R.area,ticks:R.yTicks,side:"left",hasGrid:!0}),l.jsx(ut,{area:R.area,ticks:R.xTicks,side:"bottom"}),l.jsx("line",{className:oe.baseline,x1:R.area.left,x2:R.area.right,y1:R.area.bottom,y2:R.area.bottom}),R.columns.map((h,y)=>h.height>0?l.jsx("rect",{x:h.x,y:h.y,width:h.width,height:h.height,style:{fill:U(m)}},y):null)]}),[R,m]),j=f.useCallback((h,y)=>{const{area:a,columns:i}=R;if(h<a.left||h>a.right||y<a.top-4||y>a.bottom+4)return null;const c=i.findIndex(o=>h>=o.x-Mt&&h<=o.x+o.width+Mt);return c<0?null:c},[R]);return l.jsx(ft,{label:t,description:s,containerRef:F,width:z,height:d,plot:w,underlay:h=>{const y=R.columns[h];return l.jsx("rect",{className:oe.band,x:y.x-Mt/2,width:y.width+Mt,y:R.area.top,height:R.area.height})},overlay:()=>null,itemCount:N.length,pick:j,tooltip:h=>({title:E(h),rows:[{id:"count",label:u,value:H(N[h].count),tone:m}]}),anchor:h=>({x:R.columns[h].center,y:R.columns[h].y}),announce:h=>`${r} ${E(h)}: ${u} ${H(N[h].count)}`,table:{columns:[r,u],rows:N.map((h,y)=>[E(y),H(h.count)])},className:A,testId:I})},Tn=f.memo(at(Cn,"Histogram")),In="hanui-grid-fHioN",Rn="hanui-shape-Vbb9D",Sn="hanui-labels-nRfEk",Fn="hanui-axisLabel-UOZQ7",Hn="hanui-spoke-P-6cp",Ln="hanui-marker-xzn9h",_t={grid:In,shape:Rn,labels:Sn,axisLabel:Fn,spoke:Hn,marker:Ln},ae=10,zn=16,En=28,Dt=(t,s)=>{const e=t.values[s];return typeof e=="number"&&Number.isFinite(e)?e:null},Pn=({label:t,description:s,axes:e,series:n,max:r,height:u=320,width:m,formatValue:d,className:k,testId:T})=>{const{labels:A}=dt.useHanui(),[I,M]=yt(m),[F,z]=f.useState(()=>new Set),H=f.useMemo(()=>At(A==null?void 0:A.locale),[A==null?void 0:A.locale]),q=f.useMemo(()=>pt(A==null?void 0:A.locale),[A==null?void 0:A.locale]),P=d??q,N=f.useMemo(()=>n.map((a,i)=>({...a,tone:vt(i,a.tone)})),[n]),R=f.useMemo(()=>N.filter(a=>!F.has(a.id)),[N,F]),E=f.useMemo(()=>{const a=e.length,i=a>0?Math.PI*2/a:0,c=e.map((V,Z)=>Z*i),o=Math.min(M*.22,Math.max(0,...e.map(V=>ht(V.label)))),x=Math.max(24,Math.min(u/2-24,M/2-o-ae-4)),_=M/2,$=u/2;let b=0;for(const V of n)for(const Z of e){const D=Dt(V,Z.key);D!==null&&D>b&&(b=D)}const p=r!==void 0&&r>0?r:$t(0,b,4)[1],C=ot(0,p,4).filter(V=>V>0);return{cx:_,cy:$,radius:x,angles:c,step:i,top:p,rings:C,scale:V=>Math.min(Math.max(V,0),p)/p*x,labelRoom:o}},[e,n,r,M,u]),w=f.useMemo(()=>{const{cx:a,cy:i,angles:c,scale:o}=E;return R.map(x=>({...x,points:e.map((_,$)=>{const b=Dt(x,_.key);return{...tt(a,i,o(b??0),c[$]),value:b}})}))},[E,R,e]),j=f.useMemo(()=>{const{cx:a,cy:i,radius:c,angles:o,rings:x,scale:_,labelRoom:$}=E,b=x.length>0?_(x[0]):c,p=Math.max(1,Math.ceil(zn/Math.max(1,b)));return l.jsxs("g",{children:[l.jsxs("g",{"aria-hidden":!0,className:_t.grid,children:[x.map(C=>l.jsx("path",{d:Yt(o.map(G=>tt(a,i,_(C),G)))},C)),o.map((C,G)=>{const V=tt(a,i,c,C);return l.jsx("line",{x1:a,y1:i,x2:V.x,y2:V.y},e[G].key)})]}),w.map(C=>l.jsx("path",{className:_t.shape,d:Yt(C.points),style:{fill:`color-mix(in srgb, ${U(C.tone)} 14%, transparent)`,stroke:U(C.tone)}},C.id)),l.jsxs("g",{"aria-hidden":!0,className:_t.labels,children:[x.map((C,G)=>(x.length-1-G)%p===0?l.jsx("text",{x:a+4,y:i-_(C),dy:"1.1em",children:H(C)},C):null),e.map((C,G)=>{const V=o[G],Z=tt(a,i,c+ae,V),D=Math.sin(V),g=Math.cos(V),S=D>.3?"start":D<-.3?"end":"middle",L=g>.3?"-0.2em":g<-.3?"0.9em":"0.32em";return l.jsx("text",{className:_t.axisLabel,x:Z.x,y:Z.y,dy:L,textAnchor:S,children:St(C.label,S==="middle"?c*1.4:$)},C.key)})]})]})},[E,w,e,H]),h=f.useCallback((a,i)=>{const{cx:c,cy:o,radius:x,step:_}=E;if(e.length===0||Math.hypot(a-c,i-o)>x+En)return null;let $=Math.atan2(a-c,-(i-o));return $<0&&($+=Math.PI*2),Math.round($/_)%e.length},[E,e.length]),y=a=>w.map(i=>{const c=i.points[a].value;return{id:i.id,label:i.label,value:c===null?"—":P(c),tone:i.tone}});return l.jsx(ft,{label:t,description:s,containerRef:I,width:M,height:u,plot:j,overlay:a=>{const{cx:i,cy:c,radius:o,angles:x}=E,_=tt(i,c,o,x[a]);return l.jsxs("g",{children:[l.jsx("line",{className:_t.spoke,x1:i,y1:c,x2:_.x,y2:_.y}),w.map($=>{const b=$.points[a];return b.value===null?null:l.jsx("circle",{className:_t.marker,cx:b.x,cy:b.y,r:4.5,style:{fill:U($.tone)}},$.id)})]})},itemCount:e.length,pick:h,tooltip:a=>({title:e[a].label,rows:y(a)}),anchor:a=>{const{cx:i,cy:c,radius:o,angles:x}=E;let _=0;for(const $ of w){const b=$.points[a];_=Math.max(_,Math.hypot(b.x-i,b.y-c))}return tt(i,c,Math.min(o,_),x[a])},tooltipSide:"outward",announce:a=>`${e[a].label}: ${y(a).map(i=>`${i.label} ${i.value}`).join(", ")}`,table:{columns:[t,...N.map(a=>a.label)],rows:e.map(a=>[a.label,...N.map(i=>{const c=Dt(i,a.key);return c===null?"—":P(c)})])},legend:N.length>1?{entries:N.map(a=>({id:a.id,label:a.label,tone:a.tone})),hidden:F,onToggle:a=>z(i=>{const c=new Set(i);return c.has(a)?c.delete(a):N.length-i.size>1&&c.add(a),c})}:void 0,className:k,testId:T})},Dn=f.memo(at(Pn,"RadarChart"));exports.AreaChart=Je;exports.BarChart=tn;exports.BoxPlot=Nn;exports.ComposedChart=nn;exports.Heatmap=Mn;exports.Histogram=Tn;exports.LineChart=Ue;exports.PieChart=rn;exports.RadarChart=Dn;exports.ScatterPlot=xn;
1
+ "use client";"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react/jsx-runtime"),f=require("react"),dt=require("@ahmetilhn/hanui"),at=(t,s)=>Object.assign(t,{displayName:s}),de="hanui-axis-AqLAe",xe="hanui-axis__label-dHxpo",fe="hanui-axis__grid-RVxXW",pe="hanui-axis__baseline-jhG2z",st={axis:de,axis__label:xe,axis__grid:fe,axis__baseline:pe},wt=(t,s,e)=>{const n=e(t);return t.map((c,i)=>({position:s(c),label:n[i]}))},le=6.4,ht=t=>t.length*le,ie=(t,s=8)=>{if(t.length<2)return[...t];const e=Math.max(...t.map(i=>ht(i.label))),n=Math.abs(t[1].position-t[0].position),c=n<=0?1:Math.max(1,Math.ceil((e+s)/n));return t.filter((i,m)=>m%c===0)},St=(t,s)=>{const e=Math.max(1,Math.floor(s/le));return t.length<=e?t:`${t.slice(0,Math.max(1,e-1))}…`},ut=({area:t,ticks:s,side:e,hasGrid:n=!1})=>l.jsx("g",{className:st.axis,"aria-hidden":!0,children:s.map(c=>e==="bottom"?l.jsxs("g",{children:[n&&l.jsx("line",{className:st.axis__grid,x1:c.position,x2:c.position,y1:t.top,y2:t.bottom}),l.jsx("text",{className:st.axis__label,x:c.position,y:t.bottom+16,textAnchor:"middle",children:c.label})]},`${c.position}-${c.label}`):l.jsxs("g",{children:[n&&l.jsx("line",{className:st.axis__grid,x1:t.left,x2:t.right,y1:c.position,y2:c.position}),l.jsx("text",{className:st.axis__label,x:e==="left"?t.left-8:t.right+8,y:c.position,dy:"0.32em",textAnchor:e==="left"?"end":"start",children:c.label})]},`${c.position}-${c.label}`))}),Gt=({area:t,ticks:s,side:e})=>l.jsx("g",{className:st.axis,"aria-hidden":!0,children:e==="bottom"?l.jsxs(l.Fragment,{children:[l.jsx("line",{className:st.axis__baseline,x1:t.left,x2:t.right,y1:t.bottom,y2:t.bottom}),ie(s).map(n=>l.jsx("text",{className:st.axis__label,x:n.position,y:t.bottom+16,textAnchor:"middle",children:n.label},`${n.position}-${n.label}`))]}):l.jsxs(l.Fragment,{children:[l.jsx("line",{className:st.axis__baseline,x1:t.left,x2:t.left,y1:t.top,y2:t.bottom}),s.map(n=>l.jsx("text",{className:st.axis__label,x:t.left-8,y:n.position,dy:"0.32em",textAnchor:"end",children:St(n.label,t.left-12)},`${n.position}-${n.label}`))]})}),W=t=>Math.round(t*100)/100,ye=t=>{const s=[];let e=[];for(const n of t)n===null||!Number.isFinite(n.x)||!Number.isFinite(n.y)?(e.length>0&&s.push(e),e=[]):e.push(n);return e.length>0&&s.push(e),s},Ht=t=>t.map((s,e)=>`${e===0?"M":"L"}${W(s.x)},${W(s.y)}`).join(""),he=t=>{const s=t.length;if(s<3)return Ht(t);const e=[],n=[];for(let i=0;i<s-1;i+=1){const m=t[i+1].x-t[i].x;n.push(m===0?0:(t[i+1].y-t[i].y)/m)}e.push(n[0]);for(let i=1;i<s-1;i+=1)e.push(n[i-1]*n[i]<=0?0:(n[i-1]+n[i])/2);e.push(n[s-2]);for(let i=0;i<s-1;i+=1){if(n[i]===0){e[i]=0,e[i+1]=0;continue}const m=e[i]/n[i],d=e[i+1]/n[i],k=m*m+d*d;if(k>9){const A=3/Math.sqrt(k);e[i]=A*m*n[i],e[i+1]=A*d*n[i]}}let c=`M${W(t[0].x)},${W(t[0].y)}`;for(let i=0;i<s-1;i+=1){const m=t[i],d=t[i+1],k=(d.x-m.x)/3;c+=`C${W(m.x+k)},${W(m.y+e[i]*k)} ${W(d.x-k)},${W(d.y-e[i+1]*k)} ${W(d.x)},${W(d.y)}`}return c},ge=(t,s="linear")=>ye(t).map(e=>s==="monotone"?he(e):Ht(e)).join(""),be=(t,s,e="linear")=>{const n=[];let c=[],i=[];const m=()=>{if(c.length>0){const d=e==="monotone"?he:Ht,k=d([...i].reverse()).replace(/^M/,"L");n.push(`${d(c)}${k}Z`)}c=[],i=[]};return t.forEach((d,k)=>{const A=s[k];d===null||A===null||A===void 0?m():(c.push(d),i.push(A))}),m(),n.join("")},tt=(t,s,e,n)=>({x:t+e*Math.sin(n),y:s-e*Math.cos(n)}),Yt=(t,s,e,n,c,i)=>{const m=i-c;if(m<=0||e<=0)return"";if(m>=Math.PI*2-1e-6){const b=(R,E)=>`M${W(t)},${W(s-R)}A${R},${R} 0 1 ${E} ${W(t)},${W(s+R)}A${R},${R} 0 1 ${E} ${W(t)},${W(s-R)}Z`;return b(e,1)+(n>0?b(n,0):"")}const d=m>Math.PI?1:0,k=tt(t,s,e,c),A=tt(t,s,e,i);if(n<=0)return`M${W(t)},${W(s)}L${W(k.x)},${W(k.y)}A${e},${e} 0 ${d} 1 ${W(A.x)},${W(A.y)}Z`;const T=tt(t,s,n,i),C=tt(t,s,n,c);return`M${W(k.x)},${W(k.y)}A${e},${e} 0 ${d} 1 ${W(A.x)},${W(A.y)}L${W(T.x)},${W(T.y)}A${n},${n} 0 ${d} 0 ${W(C.x)},${W(C.y)}Z`},Zt=t=>t.length===0?"":`${Ht(t)}Z`,mt=(t,s)=>{const[e,n]=t,[c,i]=s,m=n-e,d=k=>m===0?(c+i)/2:c+(k-e)/m*(i-c);return d.domain=t,d.range=s,d.invert=k=>i===c?e:e+(k-c)/(i-c)*m,d},Rt=(t,s,{paddingInner:e=.2,paddingOuter:n=.1}={})=>{const[c,i]=s,m=t.length,d=m===0?0:(i-c)/Math.max(1,m-e+n*2),k=d*(1-e),A=c+d*n,T=new Map(t.map((b,R)=>[b,R])),C=b=>{const R=T.get(b);return R===void 0?Number.NaN:A+R*d};return C.domain=t,C.range=s,C.bandwidth=k,C.step=d,C.indexAt=b=>m===0?-1:Math.min(m-1,Math.max(0,Math.floor((b-c-d*n+(d-k)/2)/d))),C},Bt=(t,s,e)=>{const n=Math.abs(s-t);if(n===0||!Number.isFinite(n)||e<=0)return 1;const c=n/e,i=10**Math.floor(Math.log10(c)),m=c/i;return(m>=7.5?10:m>=3.5?5:m>=1.5?2:1)*i},Ot=(t,s)=>{const e=Math.max(0,-Math.floor(Math.log10(s))+1);return Number(t.toFixed(Math.min(e,12)))},jt=(t,s,e=5)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return[0,1];let n=Math.min(t,s),c=Math.max(t,s);if(n===c){if(n===0)return[0,1];const m=Math.abs(n)*.5;n=n>0?0:n-m,c=c<0?0:c+m}const i=Bt(n,c,e);return[Ot(Math.floor(n/i)*i,i),Ot(Math.ceil(c/i)*i,i)]},ot=(t,s,e=5)=>{if(!Number.isFinite(t)||!Number.isFinite(s))return[];if(t===s)return[t];const n=Bt(t,s,e),c=Math.ceil(t/n-1e-9),i=Math.floor(s/n+1e-9),m=[];for(let d=c;d<=i&&m.length<1e3;d+=1)m.push(Ot(d*n,n));return m},Me=(t,s)=>{if(t.length===0)return-1;let e=0,n=t.length-1;for(;e<n;){const c=e+n>>1;t[c]<s?e=c+1:n=c}return e>0&&Math.abs(t[e-1]-s)<=Math.abs(t[e]-s)?e-1:e},Lt=t=>t.filter(s=>typeof s=="number"&&Number.isFinite(s)),xt=t=>{if(t.length===0)return[0,0];let s=t[0],e=t[0];for(const n of t)n<s&&(s=n),n>e&&(e=n);return[s,e]},Pt=(t,s)=>{if(t.length===0)return Number.NaN;if(t.length===1)return t[0];const e=(t.length-1)*Math.min(1,Math.max(0,s)),n=Math.floor(e),c=e-n;return n+1<t.length?t[n]+(t[n+1]-t[n])*c:t[n]},_e=t=>{const s=Lt(t).sort((m,d)=>m-d);if(s.length===0)return null;const e=Pt(s,.25),n=Pt(s,.75),c=(n-e)*1.5,i=s.filter(m=>m>=e-c&&m<=n+c);return{count:s.length,min:s[0],q1:e,median:Pt(s,.5),q3:n,max:s[s.length-1],whiskerLow:i[0]??e,whiskerHigh:i[i.length-1]??n,outliers:s.filter(m=>m<e-c||m>n+c)}},$e=(t,s)=>{const e=Lt(t);if(e.length===0)return[];const[n,c]=xt(e);if(n===c)return[{from:n,to:n+1,count:e.length}];const i=s??Math.ceil(Math.log2(e.length))+1,m=Bt(n,c,Math.max(1,i)),d=Math.floor(n/m)*m,k=Math.max(1,Math.ceil((c-d)/m-1e-9)),A=Array.from({length:k},(T,C)=>({from:d+C*m,to:d+(C+1)*m,count:0}));for(const T of e){const C=Math.min(A.length-1,Math.floor((T-d)/m));A[C].count+=1}return A},$t=t=>typeof t=="number"&&Number.isFinite(t)?t:null,ct={top:12,right:16,bottom:28,minLeft:32},we=(t,s)=>{const e=t.map(()=>0),n=t.map(()=>0),c={};for(const i of s)c[i]=t.map((m,d)=>{const k=$t(m[i])??0;if(k>=0){const T=e[d];return e[d]+=k,{base:T,top:e[d]}}const A=n[d];return n[d]+=k,{base:A,top:n[d]}});return c},je=t=>{const{rows:s,xKey:e,series:n,width:c,height:i,isStacked:m,curve:d,formatX:k}=t,A=n.some(v=>v.type==="bar"),C=(A&&n.every(v=>v.type==="bar")?t.orientation:"vertical")==="horizontal",b=s.map(v=>v[e]),R=!A&&!C&&b.length>1&&b.every(v=>$t(v)!==null),E={};if(m)for(const v of["left","right"])for(const O of["bar","area"]){const B=n.filter(U=>(U.axis??"left")===v&&U.type===O).map(U=>U.key);Object.assign(E,we(s,B))}const S=(v,O)=>{if(E[v])return E[v][O];const B=$t(s[O][v]);return B===null?null:{base:0,top:B}},q=v=>{const O=n.filter(lt=>(lt.axis??"left")===v);if(O.length===0)return null;let B=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY;for(const lt of O)for(let gt=0;gt<s.length;gt+=1){const it=S(lt.key,gt);it&&(B=Math.min(B,it.top,it.base),U=Math.max(U,it.top,it.base))}if(O.some(lt=>lt.type!=="line")&&(B=Math.min(B,0),U=Math.max(U,0)),!Number.isFinite(B)||!Number.isFinite(U))return[0,1];const[et,J]=v==="left"?t.domain??[void 0,void 0]:[void 0,void 0],K=jt(et??B,J??U);return[et??K[0],J??K[1]]},z=q("left")??[0,1],N=q("right"),I=N!==null&&!C,P=t.formatLeft(ot(z[0],z[1],5)),$=N?t.formatRight(ot(N[0],N[1],5)):[],j=s.map(v=>k(v[e])),u=C?Math.min(c*.4,Math.max(ct.minLeft,...j.map(ht))+12):Math.max(ct.minLeft,...P.map(ht))+10,p=I?Math.max(ct.minLeft,...$.map(ht))+10:ct.right,a={left:u,top:ct.top,right:Math.max(u+1,c-p),bottom:Math.max(ct.top+1,i-ct.bottom),width:Math.max(1,c-p-u),height:Math.max(1,i-ct.bottom-ct.top)},h=C?[a.top,a.bottom]:[a.left,a.right],r=C?[a.left,a.right]:[a.bottom,a.top],o=mt(z,r),x=N?mt(N,r):o,M=v=>(v.axis??"left")==="right"&&N?x:o;let w,y=0,_=null;if(R){const v=b.map(O=>$t(O));_=mt(xt(v),h),w=v.map(_)}else{const v=Rt(s.map((O,B)=>String(B)),h,A?{paddingInner:.24,paddingOuter:.12}:{paddingInner:0,paddingOuter:0});y=v.bandwidth,w=s.map((O,B)=>v(String(B))+v.bandwidth/2)}const D=(v,O)=>C?{x:O,y:v}:{x:v,y:O},H=[],V=n.filter(v=>v.type==="bar"),X=m?1:Math.max(1,V.length),G=X>1?Math.min(2,y*.04):0,g=Math.max(1,(y-G*(X-1))/X);V.forEach((v,O)=>{const B=M(v),U=m?0:O;s.forEach((et,J)=>{const K=S(v.key,J);if(!K||K.top===K.base)return;const lt=w[J]-y/2+U*(g+G),gt=B(K.base),it=B(K.top),Vt=Math.min(gt,it),Xt=Math.max(1,Math.abs(it-gt));H.push(C?{key:v.key,index:J,tone:v.tone,x:Vt,y:lt,width:Xt,height:g}:{key:v.key,index:J,tone:v.tone,x:lt,y:Vt,width:g,height:Xt})})});const F={},L=[],Y=[];for(const v of n){if(v.type==="bar")continue;const O=M(v),B=s.map((U,et)=>{const J=S(v.key,et);return J?D(w[et],O(J.top)):null});if(F[v.key]=B,v.type==="area"){const U=s.map((et,J)=>{const K=S(v.key,J);return K?D(w[J],O(K.base)):null});Y.push({key:v.key,tone:v.tone,d:be(B,U,d)})}L.push({key:v.key,tone:v.tone,d:ge(B,d)})}const rt=s.map((v,O)=>{let B=null;for(const et of n){const J=S(et.key,O);if(!J)continue;const K=M(et)(J.top);B=B===null?K:C?Math.max(B,K):Math.min(B,K)}const U=C?a.left:a.bottom;return D(w[O],B??U)}),kt=(v,O,B)=>wt(ot(O[0],O[1],C?Math.max(2,Math.floor(a.width/90)):Math.max(2,Math.floor(a.height/48))),v,B),me=_?ot(_.domain[0],_.domain[1],Math.max(2,Math.floor(a.width/90))).map(v=>({position:_(v),label:k(v)})):s.map((v,O)=>({position:w[O],label:C?St(j[O],u-12):j[O]}));return{zero:z[0]<0&&z[1]>0?o(0):null,area:a,centers:w,bandwidth:y,isContinuous:R,categoryTicks:me,leftTicks:kt(o,z,t.formatLeft),rightTicks:I&&N?kt(x,N,t.formatRight):[],hasRightAxis:I,lines:L,areas:Y,bars:H,points:F,anchors:rt}},Ut=(...t)=>{let s="";for(const e of t)e&&(s=s===""?e:`${s} ${e}`);return s},Qt=["cat-1","cat-2","cat-3","cat-4","cat-5","series-2"],Tt=(t,s)=>s??Qt[t%Qt.length],Z=t=>t==="muted"?"var(--hanui-text-3)":`var(--hanui-${t})`,ke="hanui-chart-iR-5u",Ne="hanui-chart__canvas-4wf8o",ve="hanui-chart__svg-yC5iw",Te="hanui-chart__overlay-kbXEv",Ae="hanui-chart__tooltip-wbhLY",Ce="hanui-chart__tooltipTitle-j-1Nw",Ie="hanui-chart__tooltipRow-phors",Fe="hanui-chart__tooltipLabel-72x80",Re="hanui-chart__tooltipValue-caeby",Se="hanui-chart__swatch--mk77",He="hanui-chart__legend-EhXcQ",Le="hanui-chart__legendItem--AaGe",Ee="hanui-chart__srOnly-Oyem2",Q={chart:ke,chart__canvas:Ne,chart__svg:ve,chart__overlay:Te,chart__tooltip:Ae,chart__tooltipTitle:Ce,chart__tooltipRow:Ie,chart__tooltipLabel:Fe,chart__tooltipValue:Re,chart__swatch:Se,chart__legend:He,chart__legendItem:Le,"chart__legendItem--hidden":"hanui-chart__legendItem--hidden-D3li8",chart__srOnly:Ee},Jt=12,ft=({label:t,description:s,containerRef:e,width:n,height:c,plot:i,overlay:m,underlay:d,itemCount:k,columns:A,pick:T,tooltip:C,anchor:b,tooltipSide:R="inward",announce:E,table:S,legend:q,className:z,testId:N})=>{const I=f.useId(),P=dt.useAnnounce(),[$,j]=f.useState(null),u=f.useRef(null),p=f.useRef(null),a=f.useRef(null);f.useEffect(()=>{$!==null&&$>=k&&j(k>0?k-1:null)},[$,k]),f.useEffect(()=>()=>{u.current!==null&&cancelAnimationFrame(u.current)},[]);const h=f.useCallback(y=>{const _=y.currentTarget.getBoundingClientRect();a.current={x:y.clientX-_.left,y:y.clientY-_.top},u.current===null&&(u.current=requestAnimationFrame(()=>{u.current=null;const D=a.current;D&&j(T(D.x,D.y))}))},[T]),r=y=>{const _=Math.min(k-1,Math.max(0,y));j(_),P(E(_))},o=y=>{if(k===0)return;const _=$??-1,D=A??1,H=y.key==="ArrowRight"?_+1:y.key==="ArrowLeft"?Math.max(0,_-1):y.key==="ArrowDown"?_<0?0:_+D:y.key==="ArrowUp"?Math.max(0,_-D):y.key==="Home"?0:y.key==="End"?k-1:null;if(y.key==="Escape"&&$!==null){y.preventDefault(),j(null);return}H!==null&&(y.preventDefault(),r(H))},x=$===null?null:C($),M=$===null?null:b($),w=M==null?void 0:M.x;return f.useLayoutEffect(()=>{const y=p.current;if(!y||w===void 0)return;const _=y.offsetWidth,D=w>n/2,H=R==="outward"?!D:D,V=w-Jt-_,X=w+Jt,G=V>=0,g=X+_<=n,F=R==="outward"?H?V:X:H?G||!g?V:X:g||!G?X:V;y.style.left=`${Math.min(Math.max(0,F),Math.max(0,n-_))}px`},[$,w,n,R]),l.jsxs("figure",{className:Ut(Q.chart,z),"data-testid":N,children:[l.jsxs("div",{ref:e,className:Q.chart__canvas,style:{blockSize:c},children:[l.jsxs("svg",{className:Q.chart__svg,width:n,height:c,viewBox:`0 0 ${n} ${c}`,role:"img","aria-label":t,"aria-describedby":s?I:void 0,tabIndex:k>0?0:void 0,onPointerMove:h,onPointerDown:h,onPointerLeave:()=>j(null),onKeyDown:o,onBlur:()=>j(null),children:[$!==null&&d&&l.jsx("g",{className:Q.chart__overlay,children:d($)}),i,$!==null&&l.jsx("g",{className:Q.chart__overlay,children:m($)})]}),x&&M&&l.jsxs("div",{ref:p,"aria-hidden":!0,className:Q.chart__tooltip,style:{insetBlockStart:Math.max(24,Math.min(M.y,c-24))},children:[x.title&&l.jsx("span",{className:Q.chart__tooltipTitle,children:x.title}),x.rows.map(y=>l.jsxs("span",{className:Q.chart__tooltipRow,children:[y.tone&&l.jsx("span",{className:Q.chart__swatch,style:{backgroundColor:Z(y.tone)}}),l.jsx("span",{className:Q.chart__tooltipLabel,children:y.label}),l.jsx("span",{className:Q.chart__tooltipValue,children:y.value})]},y.id))]})]}),q&&q.entries.length>1&&l.jsx("ul",{className:Q.chart__legend,children:q.entries.map(y=>{const _=q.hidden.has(y.id);return l.jsx("li",{children:l.jsxs("button",{type:"button",className:Ut(Q.chart__legendItem,_&&Q["chart__legendItem--hidden"]),"aria-pressed":!_,onClick:()=>q.onToggle(y.id),children:[l.jsx(Pe,{tone:y.tone,isHidden:_}),y.label]})},y.id)})}),s&&l.jsx("p",{id:I,className:Q.chart__srOnly,children:s}),l.jsx("div",{className:Q.chart__srOnly,children:l.jsxs("table",{children:[l.jsx("caption",{children:t}),l.jsx("thead",{children:l.jsx("tr",{children:S.columns.map((y,_)=>l.jsx("th",{scope:"col",children:y},_))})}),l.jsx("tbody",{children:S.rows.map((y,_)=>l.jsx("tr",{children:y.map((D,H)=>H===0?l.jsx("th",{scope:"row",children:D},H):l.jsx("td",{children:D},H))},_))})]})})]})},Pe=({tone:t,isHidden:s})=>l.jsx("span",{"aria-hidden":!0,className:Q.chart__swatch,style:s?{backgroundColor:"transparent",boxShadow:`inset 0 0 0 2px ${Z(t)}`}:{backgroundColor:Z(t)}}),Kt=new Map,ue=(t,s)=>{const e=`${t??""}|${JSON.stringify(s)}`;let n=Kt.get(e);return n||(n=new Intl.NumberFormat(t,s),Kt.set(e,n)),n},te=t=>{if(t===0||!Number.isFinite(t))return null;const[s,e]=Math.abs(t).toExponential(9).split("e"),n=Number(e);return{first:n,last:n-(s.replace(".","").replace(/0+$/,"").length-1)}},At=t=>s=>{const e=s.reduce((n,c)=>{var i;return Math.min(n,((i=te(c))==null?void 0:i.last)??n)},Number.POSITIVE_INFINITY);return s.map(n=>{var c;return ue(t,{notation:"compact",maximumSignificantDigits:Math.min(21,Math.max(1,(((c=te(n))==null?void 0:c.first)??0)-e+1))}).format(n)})},pt=t=>s=>ue(t,{maximumFractionDigits:2}).format(s),ze=640,De=typeof window>"u"?()=>{}:f.useLayoutEffect,yt=t=>{const s=f.useRef(null),[e,n]=f.useState(t??ze);return De(()=>{if(t!==void 0){n(t);return}const c=s.current;if(!c)return;const i=d=>{const k=Math.floor(d);k>0&&n(A=>A===k?A:k)};if(i(c.clientWidth),typeof ResizeObserver>"u")return;const m=new ResizeObserver(([d])=>i(d.contentRect.width));return m.observe(c),()=>m.disconnect()},[t]),[s,e]},qe="hanui-line-CLpqU",Ge="hanui-area-LkWXB",Oe="hanui-bar-260Bd",Be="hanui-point-Vc-kX",We="hanui-marker-G-xZb",Ve="hanui-crosshair-nV-xX",Xe="hanui-band-jnG7s",Ye="hanui-zero-GpHvw",nt={line:qe,area:Ge,bar:Oe,point:Be,marker:We,crosshair:Ve,band:Xe,zero:Ye},Ze=280,ee="—",Ue=({label:t,description:s,data:e,xKey:n,xLabel:c,series:i,height:m=Ze,width:d,isStacked:k=!1,orientation:A="vertical",curve:T="monotone",hasPoints:C=!1,formatX:b=String,formatValue:R,domain:E,className:S,testId:q})=>{const{labels:z}=dt.useHanui(),N=z==null?void 0:z.locale,[I,P]=yt(d),[$,j]=f.useState(()=>new Set),u=f.useMemo(()=>R??pt(N),[R,N]),p=f.useMemo(()=>At(N),[N]),a=f.useCallback(g=>g==null?"":b(g),[b]),h=f.useMemo(()=>i.map((g,F)=>({...g,tone:Tt(F,g.tone)})),[i]),r=f.useMemo(()=>h.filter(g=>!$.has(g.key)),[h,$]),o=f.useMemo(()=>je({rows:e,xKey:n,series:r,width:P,height:m,isStacked:k,orientation:A,curve:T,formatX:a,formatLeft:p,formatRight:p,domain:E}),[e,n,r,P,m,k,A,T,a,p,E]),x=A==="horizontal"&&r.length>0&&r.every(g=>g.type==="bar"),M=r.some(g=>g.type==="bar"),w=f.useMemo(()=>{const g=o.centers.map((F,L)=>({center:F,index:L})).sort((F,L)=>F.center-L.center);return{centers:g.map(F=>F.center),indices:g.map(F=>F.index)}},[o.centers]),y=f.useCallback((g,F)=>{const{area:L}=o;if(g<L.left-4||g>L.right+4||F<L.top-4||F>L.bottom+4)return null;const Y=Me(w.centers,x?F:g);return Y<0?null:w.indices[Y]},[o,w,x]),_=f.useCallback(g=>{var F;return{title:a((F=e[g])==null?void 0:F[n]),rows:r.map(L=>{var rt;const Y=$t((rt=e[g])==null?void 0:rt[L.key]);return{id:L.key,label:L.label,tone:L.tone,value:Y===null?ee:(L.format??u)(Y)}})}},[e,n,r,u,a]),D=f.useCallback(g=>{const F=_(g);return`${F.title}: ${F.rows.map(L=>`${L.label} ${L.value}`).join(", ")}`},[_]),H=f.useMemo(()=>({columns:[c??n,...h.map(g=>g.label)],rows:e.map(g=>[a(g[n]),...h.map(F=>{const L=$t(g[F.key]);return L===null?ee:(F.format??u)(L)})])}),[e,n,c,h,u,a]),V=f.useMemo(()=>l.jsxs("g",{children:[x?l.jsxs(l.Fragment,{children:[l.jsx(ut,{area:o.area,ticks:o.leftTicks,side:"bottom",hasGrid:!0}),l.jsx(Gt,{area:o.area,ticks:o.categoryTicks,side:"left"})]}):l.jsxs(l.Fragment,{children:[l.jsx(ut,{area:o.area,ticks:o.leftTicks,side:"left",hasGrid:!0}),o.hasRightAxis&&l.jsx(ut,{area:o.area,ticks:o.rightTicks,side:"right"}),l.jsx(Gt,{area:o.area,ticks:o.categoryTicks,side:"bottom"})]}),o.zero!==null&&(x?l.jsx("line",{className:nt.zero,x1:o.zero,x2:o.zero,y1:o.area.top,y2:o.area.bottom}):l.jsx("line",{className:nt.zero,x1:o.area.left,x2:o.area.right,y1:o.zero,y2:o.zero})),o.areas.map(g=>l.jsx("path",{d:g.d,className:nt.area,style:{fill:`color-mix(in srgb, ${Z(g.tone)} 18%, transparent)`}},`area-${g.key}`)),o.bars.map(g=>l.jsx("rect",{className:nt.bar,x:g.x,y:g.y,width:g.width,height:g.height,rx:Math.min(3,g.width/4,g.height/4),style:{fill:Z(g.tone)}},`bar-${g.key}-${g.index}`)),o.lines.map(g=>l.jsx("path",{d:g.d,className:nt.line,style:{stroke:Z(g.tone)}},`line-${g.key}`)),r.filter(g=>g.type!=="bar").flatMap(g=>(o.points[g.key]??[]).map((F,L,Y)=>F&&(C||!Y[L-1]&&!Y[L+1])?l.jsx("circle",{className:nt.point,cx:F.x,cy:F.y,r:3,style:{fill:Z(g.tone)}},`point-${g.key}-${L}`):null))]}),[o,C,x,r]),X=f.useCallback(g=>{if(!M||o.bandwidth<=0)return null;const{area:F}=o,L=o.centers[g],Y=o.bandwidth*.12;return x?l.jsx("rect",{className:nt.band,x:F.left,width:F.width,y:L-o.bandwidth/2-Y,height:o.bandwidth+Y*2}):l.jsx("rect",{className:nt.band,y:F.top,height:F.height,x:L-o.bandwidth/2-Y,width:o.bandwidth+Y*2})},[o,x,M]),G=f.useCallback(g=>{const{area:F}=o,L=o.centers[g];return l.jsxs(l.Fragment,{children:[!M&&l.jsx("line",{className:nt.crosshair,x1:L,x2:L,y1:F.top,y2:F.bottom}),r.filter(Y=>Y.type!=="bar").map(Y=>{var kt;const rt=(kt=o.points[Y.key])==null?void 0:kt[g];return rt?l.jsx("circle",{className:nt.marker,cx:rt.x,cy:rt.y,r:4.5,style:{fill:Z(Y.tone)}},Y.key):null})]})},[o,r,M]);return l.jsx(ft,{label:t,description:s,containerRef:I,width:P,height:m,plot:V,overlay:G,underlay:X,itemCount:e.length,pick:y,tooltip:_,anchor:g=>o.anchors[g]??{x:0,y:0},announce:D,table:H,legend:{entries:h.map(g=>({id:g.key,label:g.label,tone:g.tone})),hidden:$,onToggle:g=>j(F=>{const L=new Set(F);return L.has(g)?L.delete(g):h.length-F.size>1&&L.add(g),L})},className:S,testId:q})},Et=f.memo(Ue),Qe=({series:t,...s})=>{const e=f.useMemo(()=>t.map(n=>({...n,type:"line"})),[t]);return l.jsx(Et,{...s,series:e})},Je=f.memo(at(Qe,"LineChart")),Ke=({series:t,...s})=>{const e=f.useMemo(()=>t.map(n=>({...n,type:"area"})),[t]);return l.jsx(Et,{...s,series:e})},tn=f.memo(at(Ke,"AreaChart")),en=({series:t,...s})=>{const e=f.useMemo(()=>t.map(n=>({...n,type:"bar"})),[t]);return l.jsx(Et,{...s,series:e})},nn=f.memo(at(en,"BarChart")),sn=t=>l.jsx(Et,{...t}),on=f.memo(at(sn,"ComposedChart")),an="hanui-slice-dFWuh",cn="hanui-center__value-GnqKe",rn="hanui-center__label-DsgTV",Nt={slice:an,center__value:cn,center__label:rn},Ct=6,ne=1.5,ln=({label:t,description:s,data:e,variant:n="donut",centerValue:c,centerLabel:i,valueLabel:m,height:d=260,width:k,formatValue:A,className:T,testId:C})=>{const{labels:b}=dt.useHanui(),[R,E]=yt(k),[S,q]=f.useState(()=>new Set),z=f.useMemo(()=>pt(b==null?void 0:b.locale),[b==null?void 0:b.locale]),N=A??z,I=f.useMemo(()=>e.map((a,h)=>({...a,tone:Tt(h,a.tone)})),[e]),P=f.useMemo(()=>{const a=I.filter(_=>!S.has(_.id)&&Number.isFinite(_.value)&&_.value>0),h=a.reduce((_,D)=>_+D.value,0),r=E/2,o=d/2,x=Math.max(8,Math.min(E,d)/2-Ct-4),M=n==="donut"?x*.62:0;let w=0;const y=a.map(_=>{const D=h>0?_.value/h*Math.PI*2:0,H=w;return w+=D,{..._,start:H,end:w,share:h>0?_.value/h:0}});return{cx:r,cy:o,outer:x,inner:M,total:h,slices:y}},[I,S,E,d,n]),$=f.useMemo(()=>{const a=new Intl.NumberFormat(b==null?void 0:b.locale,{style:"percent",maximumFractionDigits:1});return h=>a.format(h)},[b==null?void 0:b.locale]),j=f.useMemo(()=>{const{cx:a,cy:h,outer:r,inner:o,slices:x,total:M}=P;return l.jsxs("g",{children:[x.map(w=>l.jsx("path",{className:Nt.slice,d:Yt(a,h,r,o,w.start,w.end),style:{fill:Z(w.tone),strokeWidth:x.length>1?ne:0}},w.id)),n==="donut"&&l.jsxs("g",{"aria-hidden":!0,className:Nt.center,children:[l.jsx("text",{className:Nt.center__value,x:a,y:i?h-4:h,dy:"0.32em",textAnchor:"middle",children:c??N(M)}),i&&l.jsx("text",{className:Nt.center__label,x:a,y:h+16,dy:"0.32em",textAnchor:"middle",children:i})]})]})},[P,n,c,i,N]),u=f.useCallback((a,h)=>{const{cx:r,cy:o,outer:x,inner:M,slices:w}=P,y=Math.hypot(a-r,h-o);if(y>x+Ct||y<M)return null;let _=Math.atan2(a-r,-(h-o));_<0&&(_+=Math.PI*2);const D=w.findIndex(H=>_>=H.start&&_<H.end);return D<0?null:D},[P]),p=a=>{const h=P.slices[a];return`${N(h.value)} (${$(h.share)})`};return l.jsx(ft,{label:t,description:s,containerRef:R,width:E,height:d,plot:j,overlay:a=>{const{cx:h,cy:r,outer:o,inner:x,slices:M}=P,w=M[a],y=(w.start+w.end)/2,_=tt(0,0,Ct,y);return l.jsx("path",{className:Nt.slice,d:Yt(h+_.x,r+_.y,o,x,w.start,w.end),style:{fill:Z(w.tone),strokeWidth:ne}})},itemCount:P.slices.length,pick:u,tooltip:a=>{const h=P.slices[a];return{rows:[{id:h.id,label:h.label,value:p(a),tone:h.tone}]}},anchor:a=>{const{cx:h,cy:r,outer:o,slices:x}=P,M=x[a];return tt(h,r,o+Ct,(M.start+M.end)/2)},tooltipSide:"outward",announce:a=>`${P.slices[a].label}: ${p(a)}`,table:{columns:[t,m],rows:I.map(a=>[a.label,Number.isFinite(a.value)?N(a.value):"—"])},legend:{entries:I.map(a=>({id:a.id,label:a.label,tone:a.tone})),hidden:S,onToggle:a=>q(h=>{const r=new Set(h);return r.has(a)?r.delete(a):I.length-h.size>1&&r.add(a),r})},className:T,testId:C})},hn=f.memo(at(ln,"PieChart")),Wt=(t,s,e,{top:n=12,right:c=16,bottom:i=28}={})=>{const m=Math.max(32,...e.map(ht))+10;return{left:m,top:n,right:Math.max(m+1,t-c),bottom:Math.max(n+1,s-i),width:Math.max(1,t-c-m),height:Math.max(1,s-n-i)}},vt=(t,s)=>Math.max(2,Math.floor(t/(s?90:48))),un=(t,s=24)=>{const e=new Map,n=(c,i)=>`${c}:${i}`;return t.forEach((c,i)=>{if(!Number.isFinite(c.x)||!Number.isFinite(c.y))return;const m=n(Math.floor(c.x/s),Math.floor(c.y/s)),d=e.get(m);d?d.push(i):e.set(m,[i])}),{nearest:(c,i,m)=>{const d=Math.ceil(m/s),k=Math.floor(c/s),A=Math.floor(i/s);let T=null,C=m*m;for(let b=-d;b<=d;b+=1)for(let R=-d;R<=d;R+=1)for(const E of e.get(n(k+b,A+R))??[]){const S=(t[E].x-c)**2+(t[E].y-i)**2;S<=C&&(C=S,T=E)}return T}}},mn="hanui-point-YKyMm",dn="hanui-marker-ToO1T",se={point:mn,marker:dn},bt={plain:4,min:3,max:16},xn=22,fn=({label:t,description:s,series:e,xLabel:n,yLabel:c,sizeLabel:i,height:m=300,width:d,formatX:k,formatY:A,className:T,testId:C})=>{const{labels:b}=dt.useHanui(),[R,E]=yt(d),[S,q]=f.useState(()=>new Set),z=f.useMemo(()=>pt(b==null?void 0:b.locale),[b==null?void 0:b.locale]),N=f.useMemo(()=>At(b==null?void 0:b.locale),[b==null?void 0:b.locale]),I=k??z,P=A??z,$=f.useMemo(()=>e.map((r,o)=>({...r,tone:Tt(o,r.tone)})),[e]),j=f.useMemo(()=>$.filter(r=>!S.has(r.id)).flatMap(r=>r.data.filter(o=>Number.isFinite(o.x)&&Number.isFinite(o.y)).map(o=>({...o,series:r}))).sort((r,o)=>r.x-o.x||r.y-o.y),[$,S]),u=f.useMemo(()=>{const r=jt(...xt(j.map(G=>G.x))),o=jt(...xt(j.map(G=>G.y))),x=ot(o[0],o[1],vt(m,!1)),M=Wt(E,m,N(x),{right:20}),w=mt(r,[M.left,M.right]),y=mt(o,[M.bottom,M.top]),_=Lt(j.map(G=>G.size)),[D,H]=xt(_),V=G=>G===void 0||!Number.isFinite(G)||_.length===0?bt.plain:H===D?(bt.min+bt.max)/2:Math.sqrt(bt.min**2+(G-D)/(H-D)*(bt.max**2-bt.min**2)),X=j.map(G=>({...G,cx:w(G.x),cy:y(G.y),r:V(G.size)}));return{area:M,placed:X,index:un(X.map(G=>({x:G.cx,y:G.cy}))),xTicks:wt(ot(r[0],r[1],vt(M.width,!0)),w,N),yTicks:wt(x,y,N)}},[j,E,m,N]),p=f.useMemo(()=>l.jsxs("g",{children:[l.jsx(ut,{area:u.area,ticks:u.yTicks,side:"left",hasGrid:!0}),l.jsx(ut,{area:u.area,ticks:u.xTicks,side:"bottom",hasGrid:!0}),u.placed.map((r,o)=>l.jsx("circle",{className:se.point,cx:r.cx,cy:r.cy,r:r.r,style:{fill:`color-mix(in srgb, ${Z(r.series.tone)} 72%, transparent)`,stroke:Z(r.series.tone)}},o))]}),[u]),a=f.useCallback((r,o)=>u.index.nearest(r,o,xn),[u]),h=r=>{const o=u.placed[r];return{title:o.label??o.series.label,rows:[{id:"series",label:o.series.label,value:"",tone:o.series.tone},{id:"x",label:n,value:I(o.x)},{id:"y",label:c,value:P(o.y)},...o.size!==void 0&&i?[{id:"size",label:i,value:z(o.size)}]:[]]}};return l.jsx(ft,{label:t,description:s,containerRef:R,width:E,height:m,plot:p,overlay:r=>{const o=u.placed[r];return l.jsx("circle",{className:se.marker,cx:o.cx,cy:o.cy,r:o.r+3,style:{stroke:Z(o.series.tone)}})},itemCount:u.placed.length,pick:a,tooltip:h,anchor:r=>({x:u.placed[r].cx,y:u.placed[r].cy}),announce:r=>{const o=u.placed[r];return`${o.label?`${o.label}, `:""}${o.series.label}: ${n} ${I(o.x)}, ${c} ${P(o.y)}`},table:{columns:[t,n,c],rows:j.map(r=>[r.label??r.series.label,I(r.x),P(r.y)])},legend:{entries:$.map(r=>({id:r.id,label:r.label,tone:r.tone})),hidden:S,onToggle:r=>q(o=>{const x=new Set(o);return x.has(r)?x.delete(r):$.length-o.size>1&&x.add(r),x})},className:T,testId:C})},pn=f.memo(at(fn,"ScatterPlot")),yn="hanui-labels-MJWYF",gn="hanui-empty-AW7c9",bn="hanui-focus-hLQdB",It={labels:yn,empty:gn,focus:bn},zt=8,Mn=28,Dt=140,oe=(t,s,e)=>{var c;const n=(c=t[s])==null?void 0:c[e];return typeof n=="number"&&Number.isFinite(n)?n:null},ae=t=>t.map((s,e)=>String(e)),_n=({label:t,description:s,columns:e,rows:n,values:c,valueLabel:i,tone:m="cat-1",height:d=280,width:k,formatValue:A,className:T,testId:C})=>{const{labels:b}=dt.useHanui(),[R,E]=yt(k),S=f.useMemo(()=>pt(b==null?void 0:b.locale),[b==null?void 0:b.locale]),q=A??S,z=`hanui-heat-${f.useId().replace(/:/g,"")}`,N=f.useMemo(()=>{const p={left:Math.min(E*.3,Math.max(32,...n.map(ht))+12),top:8,right:E-8,bottom:d-28-Mn},a=Rt(ae(e),[p.left,p.right],{paddingInner:.06,paddingOuter:0}),h=Rt(ae(n),[p.top,p.bottom],{paddingInner:.06,paddingOuter:0}),[r,o]=xt(Lt(c.flat())),x=w=>w===null?null:o===r?60:zt+(w-r)/(o-r)*(100-zt),M=n.flatMap((w,y)=>e.map((_,D)=>{const H=oe(c,y,D);return{row:w,column:_,key:`${y}:${D}`,value:H,x:a(String(D)),y:h(String(y)),width:a.bandwidth,height:h.bandwidth,mix:x(H)}}));return{area:p,x:a,y:h,cells:M,min:r,max:o}},[e,n,c,E,d]),I=Z(m),P=f.useMemo(()=>{const{area:u,x:p,y:a,cells:h}=N,r=q(N.max),o=u.right-ht(r)-8,x=ie(e.map((M,w)=>({position:p(String(w))+p.bandwidth/2,label:M})));return l.jsxs("g",{children:[h.map(M=>l.jsx("rect",{className:M.mix===null?It.empty:void 0,x:M.x,y:M.y,width:M.width,height:M.height,rx:2,style:M.mix===null?void 0:{fill:`color-mix(in srgb, ${I} ${M.mix}%, var(--hanui-surface))`}},M.key)),l.jsxs("g",{"aria-hidden":!0,className:It.labels,children:[n.map((M,w)=>l.jsx("text",{x:u.left-8,y:a(String(w))+a.bandwidth/2,dy:"0.32em",textAnchor:"end",children:St(M,u.left-12)},w)),x.map(M=>l.jsx("text",{x:M.position,y:u.bottom+16,textAnchor:"middle",children:M.label},M.position))]}),l.jsx("defs",{children:l.jsxs("linearGradient",{id:z,children:[l.jsx("stop",{offset:"0%",style:{stopColor:`color-mix(in srgb, ${I} ${zt}%, var(--hanui-surface))`}}),l.jsx("stop",{offset:"100%",style:{stopColor:I}})]})}),l.jsxs("g",{"aria-hidden":!0,className:It.labels,children:[l.jsx("rect",{x:o-Dt,y:d-18,width:Dt,height:8,rx:4,style:{fill:`url(#${z})`}}),l.jsx("text",{x:o-Dt-8,y:d-14,dy:"0.32em",textAnchor:"end",children:q(N.min)}),l.jsx("text",{x:u.right,y:d-14,dy:"0.32em",textAnchor:"end",children:r})]})]})},[N,e,n,I,z,d,q]),$=f.useCallback((u,p)=>{const{area:a,x:h,y:r}=N;if(u<a.left||u>a.right||p<a.top||p>a.bottom)return null;const o=h.indexAt(u),x=r.indexAt(p);return o<0||x<0?null:x*e.length+o},[N,e.length]),j=u=>{const p=N.cells[u];return{cell:p,value:p.value===null?"—":q(p.value)}};return l.jsx(ft,{label:t,description:s,containerRef:R,width:E,height:d,plot:P,overlay:u=>{const p=N.cells[u];return l.jsx("rect",{className:It.focus,x:p.x-1,y:p.y-1,width:p.width+2,height:p.height+2,rx:3})},itemCount:N.cells.length,columns:e.length,pick:$,tooltip:u=>{const{cell:p,value:a}=j(u);return{title:`${p.row} · ${p.column}`,rows:[{id:"value",label:i,value:a,tone:m}]}},anchor:u=>{const p=N.cells[u];return{x:p.x+p.width/2,y:p.y+p.height/2}},announce:u=>{const{cell:p,value:a}=j(u);return`${p.row}, ${p.column}: ${i} ${a}`},table:{columns:[t,...e],rows:n.map((u,p)=>[u,...e.map((a,h)=>{const r=oe(c,p,h);return r===null?"—":q(r)})])},className:T,testId:C})},$n=f.memo(at(_n,"Heatmap")),wn="hanui-box-7zEQ-",jn="hanui-median-J5g6o",kn="hanui-outlier-M0VN-",Nn="hanui-band-kK09D",Ft={box:wn,median:jn,outlier:kn,band:Nn},vn=({label:t,description:s,groups:e,groupLabel:n,labels:c,height:i=280,width:m,formatValue:d,className:k,testId:A})=>{const{labels:T}=dt.useHanui(),[C,b]=yt(m),R=f.useMemo(()=>pt(T==null?void 0:T.locale),[T==null?void 0:T.locale]),E=f.useMemo(()=>At(T==null?void 0:T.locale),[T==null?void 0:T.locale]),S=d??R,q=f.useMemo(()=>e.map(($,j)=>({group:$,tone:Tt(j,$.tone),stats:_e($.values)})),[e]),z=f.useMemo(()=>{const $=q.flatMap(x=>x.stats?[x.stats.min,x.stats.max]:[]),[j,u]=$.length?xt($):[0,1],p=jt(j,u),a=ot(p[0],p[1],vt(i,!1)),h=Wt(b,i,E(a)),r=Rt(e.map(x=>x.id),[h.left,h.right],{paddingInner:.4,paddingOuter:.2}),o=mt(p,[h.bottom,h.top]);return{area:h,band:r,y:o,yTicks:wt(a,o,E),groupTicks:e.map(x=>({position:r(x.id)+r.bandwidth/2,label:x.label}))}},[q,e,b,i,E]),N=$=>[{id:"max",label:c.max,value:S($.whiskerHigh)},{id:"q3",label:c.q3,value:S($.q3)},{id:"median",label:c.median,value:S($.median)},{id:"q1",label:c.q1,value:S($.q1)},{id:"min",label:c.min,value:S($.whiskerLow)},...$.outliers.length>0?[{id:"outliers",label:c.outliers,value:R($.outliers.length)}]:[],{id:"count",label:c.count,value:R($.count)}],I=f.useMemo(()=>{const{area:$,band:j,y:u}=z;return l.jsxs("g",{children:[l.jsx(ut,{area:$,ticks:z.yTicks,side:"left",hasGrid:!0}),l.jsx(Gt,{area:$,ticks:z.groupTicks,side:"bottom"}),q.map(({group:p,tone:a,stats:h})=>{if(!h)return null;const r=j(p.id),o=r+j.bandwidth/2,x=j.bandwidth*.3,M=Z(a);return l.jsxs("g",{style:{stroke:M},className:Ft.box,children:[l.jsx("line",{x1:o,x2:o,y1:u(h.whiskerHigh),y2:u(h.q3)}),l.jsx("line",{x1:o,x2:o,y1:u(h.q1),y2:u(h.whiskerLow)}),l.jsx("line",{x1:o-x,x2:o+x,y1:u(h.whiskerHigh),y2:u(h.whiskerHigh)}),l.jsx("line",{x1:o-x,x2:o+x,y1:u(h.whiskerLow),y2:u(h.whiskerLow)}),l.jsx("rect",{x:r,width:j.bandwidth,y:u(h.q3),height:Math.max(1,u(h.q1)-u(h.q3)),rx:2,style:{fill:`color-mix(in srgb, ${M} 22%, transparent)`}}),l.jsx("line",{className:Ft.median,x1:r,x2:r+j.bandwidth,y1:u(h.median),y2:u(h.median)}),h.outliers.map((w,y)=>l.jsx("circle",{className:Ft.outlier,cx:o,cy:u(w),r:3},y))]},p.id)})]})},[z,q]),P=f.useCallback(($,j)=>{const{area:u,band:p}=z;if($<u.left||$>u.right||j<u.top-4||j>u.bottom+4)return null;const a=p.indexAt($);return a<0?null:a},[z]);return l.jsx(ft,{label:t,description:s,containerRef:C,width:b,height:i,plot:I,underlay:$=>{const{area:j,band:u}=z,p=u.step*.2;return l.jsx("rect",{className:Ft.band,x:u(e[$].id)-p,width:u.bandwidth+p*2,y:j.top,height:j.height})},overlay:()=>null,itemCount:e.length,pick:P,tooltip:$=>{const j=q[$];return{title:j.group.label,rows:j.stats?N(j.stats).map(u=>({...u,tone:u.id==="median"?j.tone:void 0})):[]}},anchor:$=>{const j=q[$],{band:u,y:p}=z;return{x:u(j.group.id)+u.bandwidth/2,y:j.stats?p(j.stats.q3):z.area.bottom}},announce:$=>{const j=q[$];return j.stats?`${j.group.label}: ${N(j.stats).map(u=>`${u.label} ${u.value}`).join(", ")}`:j.group.label},table:{columns:[n,c.min,c.q1,c.median,c.q3,c.max,c.count],rows:q.map(({group:$,stats:j})=>j?[$.label,S(j.whiskerLow),S(j.q1),S(j.median),S(j.q3),S(j.whiskerHigh),R(j.count)]:[$.label,"—","—","—","—","—","0"])},className:k,testId:A})},Tn=f.memo(at(vn,"BoxPlot")),An="hanui-baseline-wWs7h",Cn="hanui-band-xvYtL",ce={baseline:An,band:Cn},Mt=1,In=({label:t,description:s,values:e,bins:n,valueLabel:c,countLabel:i,tone:m="cat-1",height:d=260,width:k,formatValue:A,className:T,testId:C})=>{const{labels:b}=dt.useHanui(),[R,E]=yt(k),S=f.useMemo(()=>pt(b==null?void 0:b.locale),[b==null?void 0:b.locale]),q=f.useMemo(()=>At(b==null?void 0:b.locale),[b==null?void 0:b.locale]),z=A??S,N=f.useMemo(()=>$e(e,n),[e,n]),I=f.useMemo(()=>{var w,y;const u=Math.max(1,...N.map(_=>_.count)),p=jt(0,u),a=ot(0,p[1],vt(d,!1)).filter(Number.isInteger),h=Wt(E,d,q(a)),r=((w=N[0])==null?void 0:w.from)??0,o=((y=N[N.length-1])==null?void 0:y.to)??1,x=mt([r,o],[h.left,h.right]),M=mt(p,[h.bottom,h.top]);return{area:h,columns:N.map(_=>({x:x(_.from)+Mt/2,width:Math.max(1,x(_.to)-x(_.from)-Mt),y:M(_.count),height:Math.max(0,h.bottom-M(_.count)),center:(x(_.from)+x(_.to))/2})),xTicks:wt(ot(r,o,vt(h.width,!0)),x,q),yTicks:wt(a,M,q)}},[N,E,d,q]),P=u=>`${z(N[u].from)} – ${z(N[u].to)}`,$=f.useMemo(()=>l.jsxs("g",{children:[l.jsx(ut,{area:I.area,ticks:I.yTicks,side:"left",hasGrid:!0}),l.jsx(ut,{area:I.area,ticks:I.xTicks,side:"bottom"}),l.jsx("line",{className:ce.baseline,x1:I.area.left,x2:I.area.right,y1:I.area.bottom,y2:I.area.bottom}),I.columns.map((u,p)=>u.height>0?l.jsx("rect",{x:u.x,y:u.y,width:u.width,height:u.height,style:{fill:Z(m)}},p):null)]}),[I,m]),j=f.useCallback((u,p)=>{const{area:a,columns:h}=I;if(u<a.left||u>a.right||p<a.top-4||p>a.bottom+4)return null;const r=h.findIndex(o=>u>=o.x-Mt&&u<=o.x+o.width+Mt);return r<0?null:r},[I]);return l.jsx(ft,{label:t,description:s,containerRef:R,width:E,height:d,plot:$,underlay:u=>{const p=I.columns[u];return l.jsx("rect",{className:ce.band,x:p.x-Mt/2,width:p.width+Mt,y:I.area.top,height:I.area.height})},overlay:()=>null,itemCount:N.length,pick:j,tooltip:u=>({title:P(u),rows:[{id:"count",label:i,value:S(N[u].count),tone:m}]}),anchor:u=>({x:I.columns[u].center,y:I.columns[u].y}),announce:u=>`${c} ${P(u)}: ${i} ${S(N[u].count)}`,table:{columns:[c,i],rows:N.map((u,p)=>[P(p),S(u.count)])},className:T,testId:C})},Fn=f.memo(at(In,"Histogram")),Rn="hanui-grid-fHioN",Sn="hanui-shape-Vbb9D",Hn="hanui-labels-nRfEk",Ln="hanui-axisLabel-UOZQ7",En="hanui-spoke-P-6cp",Pn="hanui-marker-xzn9h",_t={grid:Rn,shape:Sn,labels:Hn,axisLabel:Ln,spoke:En,marker:Pn},re=10,zn=16,Dn=28,qt=(t,s)=>{const e=t.values[s];return typeof e=="number"&&Number.isFinite(e)?e:null},qn=({label:t,description:s,axes:e,series:n,max:c,height:i=320,width:m,formatValue:d,className:k,testId:A})=>{const{labels:T}=dt.useHanui(),[C,b]=yt(m),[R,E]=f.useState(()=>new Set),S=f.useMemo(()=>At(T==null?void 0:T.locale),[T==null?void 0:T.locale]),q=f.useMemo(()=>pt(T==null?void 0:T.locale),[T==null?void 0:T.locale]),z=d??q,N=f.useMemo(()=>n.map((a,h)=>({...a,tone:Tt(h,a.tone)})),[n]),I=f.useMemo(()=>N.filter(a=>!R.has(a.id)),[N,R]),P=f.useMemo(()=>{const a=e.length,h=a>0?Math.PI*2/a:0,r=e.map((V,X)=>X*h),o=Math.min(b*.22,Math.max(0,...e.map(V=>ht(V.label)))),x=Math.max(24,Math.min(i/2-24,b/2-o-re-4)),M=b/2,w=i/2;let y=0;for(const V of n)for(const X of e){const G=qt(V,X.key);G!==null&&G>y&&(y=G)}const _=c!==void 0&&c>0?c:jt(0,y,4)[1],D=ot(0,_,4).filter(V=>V>0);return{cx:M,cy:w,radius:x,angles:r,step:h,top:_,rings:D,scale:V=>Math.min(Math.max(V,0),_)/_*x,labelRoom:o}},[e,n,c,b,i]),$=f.useMemo(()=>{const{cx:a,cy:h,angles:r,scale:o}=P;return I.map(x=>({...x,points:e.map((M,w)=>{const y=qt(x,M.key);return{...tt(a,h,o(y??0),r[w]),value:y}})}))},[P,I,e]),j=f.useMemo(()=>{const{cx:a,cy:h,radius:r,angles:o,rings:x,scale:M,labelRoom:w}=P,y=x.length>0?M(x[0]):r,_=Math.max(1,Math.ceil(zn/Math.max(1,y))),D=S(x);return l.jsxs("g",{children:[l.jsxs("g",{"aria-hidden":!0,className:_t.grid,children:[x.map(H=>l.jsx("path",{d:Zt(o.map(V=>tt(a,h,M(H),V)))},H)),o.map((H,V)=>{const X=tt(a,h,r,H);return l.jsx("line",{x1:a,y1:h,x2:X.x,y2:X.y},e[V].key)})]}),$.map(H=>l.jsx("path",{className:_t.shape,d:Zt(H.points),style:{fill:`color-mix(in srgb, ${Z(H.tone)} 14%, transparent)`,stroke:Z(H.tone)}},H.id)),l.jsxs("g",{"aria-hidden":!0,className:_t.labels,children:[x.map((H,V)=>(x.length-1-V)%_===0?l.jsx("text",{x:a+4,y:h-M(H),dy:"1.1em",children:D[V]},H):null),e.map((H,V)=>{const X=o[V],G=tt(a,h,r+re,X),g=Math.sin(X),F=Math.cos(X),L=g>.3?"start":g<-.3?"end":"middle",Y=F>.3?"-0.2em":F<-.3?"0.9em":"0.32em";return l.jsx("text",{className:_t.axisLabel,x:G.x,y:G.y,dy:Y,textAnchor:L,children:St(H.label,L==="middle"?r*1.4:w)},H.key)})]})]})},[P,$,e,S]),u=f.useCallback((a,h)=>{const{cx:r,cy:o,radius:x,step:M}=P;if(e.length===0||Math.hypot(a-r,h-o)>x+Dn)return null;let w=Math.atan2(a-r,-(h-o));return w<0&&(w+=Math.PI*2),Math.round(w/M)%e.length},[P,e.length]),p=a=>$.map(h=>{const r=h.points[a].value;return{id:h.id,label:h.label,value:r===null?"—":z(r),tone:h.tone}});return l.jsx(ft,{label:t,description:s,containerRef:C,width:b,height:i,plot:j,overlay:a=>{const{cx:h,cy:r,radius:o,angles:x}=P,M=tt(h,r,o,x[a]);return l.jsxs("g",{children:[l.jsx("line",{className:_t.spoke,x1:h,y1:r,x2:M.x,y2:M.y}),$.map(w=>{const y=w.points[a];return y.value===null?null:l.jsx("circle",{className:_t.marker,cx:y.x,cy:y.y,r:4.5,style:{fill:Z(w.tone)}},w.id)})]})},itemCount:e.length,pick:u,tooltip:a=>({title:e[a].label,rows:p(a)}),anchor:a=>{const{cx:h,cy:r,radius:o,angles:x}=P;let M=0;for(const w of $){const y=w.points[a];M=Math.max(M,Math.hypot(y.x-h,y.y-r))}return tt(h,r,Math.min(o,M),x[a])},tooltipSide:"outward",announce:a=>`${e[a].label}: ${p(a).map(h=>`${h.label} ${h.value}`).join(", ")}`,table:{columns:[t,...N.map(a=>a.label)],rows:e.map(a=>[a.label,...N.map(h=>{const r=qt(h,a.key);return r===null?"—":z(r)})])},legend:N.length>1?{entries:N.map(a=>({id:a.id,label:a.label,tone:a.tone})),hidden:R,onToggle:a=>E(h=>{const r=new Set(h);return r.has(a)?r.delete(a):N.length-h.size>1&&r.add(a),r})}:void 0,className:k,testId:A})},Gn=f.memo(at(qn,"RadarChart"));exports.AreaChart=tn;exports.BarChart=nn;exports.BoxPlot=Tn;exports.ComposedChart=on;exports.Heatmap=$n;exports.Histogram=Fn;exports.LineChart=Je;exports.PieChart=hn;exports.RadarChart=Gn;exports.ScatterPlot=pn;
2
2
  //# sourceMappingURL=charts.cjs.map