@cascivo/charts 1.1.0 → 1.2.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/dist/chart-frame.module-B498IKO9.js +1 -0
- package/dist/index.d.ts +197 -14
- package/dist/index.js +1 -1
- package/dist/node/chart-frame.module-B498IKO9.js +1 -0
- package/dist/node/index.js +1 -1
- package/dist/node/sparkline.js +1 -1
- package/dist/sparkline.js +1 -1
- package/package.json +3 -3
- package/dist/chart-frame.module-lX184FYg.js +0 -1
- package/dist/node/chart-frame.module-lX184FYg.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import './charts.css';
|
|
3
|
-
import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./chart-frame.module-lX184FYg.js";import{computed as d,createStreamBuffer as f,sentimentOf as p,signal as m,useComputed as h,useSignal as g,useSignalEffect as _,useSignals as v}from"@cascivo/core";import{useId as y,useRef as b}from"react";import{builtin as x,currentLocale as S,t as C}from"@cascivo/i18n";import{Fragment as w,jsx as T,jsxs as E}from"react/jsx-runtime";function D(e,t){let[n,r]=e;if(n<=0||r<=0)throw Error(`logScale: domain must be strictly positive, got [${n}, ${r}]`);let[i,a]=t,o=Math.log10(n),s=Math.log10(r),c=s-o;return{domain:e,range:t,map:e=>c===0?i:i+(Math.log10(e)-o)/c*(a-i),invert:e=>10**(o+(e-i)/(a-i)*c),ticks:()=>{let e=Math.ceil(o),t=Math.floor(s),i=[];for(let n=e;n<=t;n++)i.push(10**n);if(i.length<3){let e=[];for(let t=Math.floor(o);t<=Math.ceil(s);t++)for(let i of[2,5]){let a=i*10**t;a>n&&a<r&&e.push(a)}i.push(...e),i.sort((e,t)=>e-t)}return i.filter(e=>e>=n&&e<=r)}}}var O={minute:6e4,hour:36e5,day:864e5,week:6048e5,month:26298e5,quarter:78894e5,year:315576e5},k=[{unit:`minute`,step:1},{unit:`minute`,step:5},{unit:`minute`,step:15},{unit:`minute`,step:30},{unit:`hour`,step:1},{unit:`hour`,step:2},{unit:`hour`,step:3},{unit:`hour`,step:6},{unit:`hour`,step:12},{unit:`day`,step:1},{unit:`day`,step:2},{unit:`week`,step:1},{unit:`month`,step:1},{unit:`month`,step:3},{unit:`year`,step:1},{unit:`year`,step:2},{unit:`year`,step:5},{unit:`year`,step:10}];function A(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth(),a=e.getUTCDate();return t===`year`?new Date(Date.UTC(Math.floor(r/n)*n,0,1)):t===`quarter`?new Date(Date.UTC(r,Math.floor(i/3)*3,1)):t===`month`?new Date(Date.UTC(r,Math.floor(i/n)*n,1)):t===`week`?new Date(Date.UTC(r,i,a-e.getUTCDay())):t===`day`?new Date(Date.UTC(r,i,a)):t===`hour`?new Date(Date.UTC(r,i,a,Math.floor(e.getUTCHours()/n)*n)):new Date(Date.UTC(r,i,a,e.getUTCHours(),Math.floor(e.getUTCMinutes()/n)*n))}function j(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth();return t===`year`?new Date(Date.UTC(r+n,i,1)):t===`quarter`?new Date(Date.UTC(r,i+3*n,1)):t===`month`?new Date(Date.UTC(r,i+n,1)):new Date(e.getTime()+O[t]*n)}function M(e){return e===`minute`?{hour:`numeric`,minute:`2-digit`}:e===`hour`?{hour:`numeric`}:e===`day`||e===`week`?{month:`short`,day:`numeric`}:e===`month`||e===`quarter`?{month:`short`,year:`numeric`}:{year:`numeric`}}function N(e,t){let[n,r]=e,[i,a]=t,o=r.getTime()-n.getTime();function s(e){let t=Math.max(2,e),n=k[k.length-1],r=1/0;for(let e of k){let i=o/(O[e.unit]*e.step);if(i<1.5)continue;let a=Math.abs(Math.log(i/t));a<r&&(r=a,n=e)}return n}return{domain:e,range:t,map:e=>o===0?i:i+(e.getTime()-n.getTime())/o*(a-i),invert:e=>new Date(n.getTime()+(e-i)/(a-i)*o),tickInterval:(e=5)=>s(e).unit,tickFormat:(e=5)=>M(s(e).unit),ticks:(e=5)=>{let{unit:t,step:i}=s(e),a=A(n,t,i),o=[],c=a.getTime()>=n.getTime()?a:j(a,t,i),l=0;for(;c.getTime()<=r.getTime()&&l++<500;)o.push(c),c=j(c,t,i);return o}}}function P(e){let t=[],n=new Map;for(let r of e)for(let e of r.segments)n.has(e.key)?n.get(e.key)==null&&e.color!=null&&n.set(e.key,e.color):(t.push(e.key),n.set(e.key,e.color));return{series:t.map(t=>{let r=n.get(t);return{id:t,label:t,...r!=null&&{color:r},data:e.map(e=>({x:e.label,y:e.segments.find(e=>e.key===t)?.value??0}))}}),x:e=>e.x,y:e=>e.y}}function F(e,t){if(e.length===0)return-1;if(e.length===1)return 0;let n=0,r=e.length-1;for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n>0&&Math.abs(e[n-1]-t)<Math.abs(e[n]-t)?n-1:n}function I(e,t,n){let r=-1,i=1/0;for(let a=0;a<e.length;a++){let o=e[a][0]-t,s=e[a][1]-n,c=o*o+s*s;c<i&&(i=c,r=a)}return r}function ee(e,t,n,r,i){if(e.length===0)return e;let a=[],o=e=>(e[0]-r)*t+(e[1]-i)*n;for(let t=0;t<e.length;t++){let n=e[t],r=e[(t+1)%e.length],i=o(n),s=o(r);if(i<=0&&a.push(n),i<0&&s>0||i>0&&s<0){let e=i/(i-s);a.push([n[0]+e*(r[0]-n[0]),n[1]+e*(r[1]-n[1])])}}return a}function L(e,t){let n=[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]];return e.map((t,r)=>{let i=n.slice();for(let n=0;n<e.length&&i.length>0;n++){if(n===r)continue;let a=e[n];i=ee(i,a[0]-t[0],a[1]-t[1],(t[0]+a[0])/2,(t[1]+a[1])/2)}return i})}function R(e){return e.length===0?``:`M${e.map(e=>`${e[0]},${e[1]}`).join(`L`)}Z`}function te(e){let t=e.length,n=e[Math.floor(t*.25)]??0;return(e[Math.floor(t*.75)]??0)-n}function ne(e,t){if(e.length===0)return[];let n=[...e].sort((e,t)=>e-t),r=n.length,i=n[0]??0,a=n[r-1]??0;if(i===a)return[{x0:i,x1:i+1,count:r}];let o;if(t!==void 0&&t>0)o=t;else{let e=2*te(n)*r**(-1/3);o=Math.ceil(e>0?(a-i)/e:Math.sqrt(r)),o=Math.max(1,Math.min(o,200))}let s=(a-i)/o;if(!Number.isFinite(s)||s<=0)return[{x0:i,x1:a,count:r}];let c=Array.from({length:o},(e,t)=>({x0:i+t*s,x1:t===o-1?a:i+(t+1)*s,count:0}));for(let t of e){let e=Math.floor((t-i)/s),n=c[Number.isFinite(e)?Math.min(Math.max(e,0),o-1):o-1];n&&n.count++}return c}function z(e){if(e.length===0)return{min:0,q1:0,median:0,q3:0,max:0,outliers:[]};let t=[...e].sort((e,t)=>e-t),n=t.length,r=e=>{let t=Math.floor(e.length/2);return e.length%2==0?((e[t-1]??0)+(e[t]??0))/2:e[t]??0},i=r(t.slice(0,Math.floor(n/2))),a=r(t.slice(Math.ceil(n/2))),o=r(t),s=a-i,c=i-1.5*s,l=a+1.5*s,u=t.filter(e=>e>=c&&e<=l),d=t.filter(e=>e<c||e>l);return{min:u[0]??t[0]??0,q1:i,median:o,q3:a,max:u[u.length-1]??t[n-1]??0,outliers:d}}function B(e){if(e.length===0)return[0,1];let t=e[0]??0,n=e[0]??0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return[t,n]}function re(e,t,n){let r=Math.max(...e),i=Math.min(...e);return Math.max(t*t*r/(n*n),n*n/(t*t*i))}function V(e,t,n,r,i,a,o){let s=e.reduce((e,t)=>e+t,0),c=t,l=n;for(let t=0;t<e.length;t++){let n=e[t]??0,u=a[t]??``;if(r>=i){let e=(s>0?n/s:0)*r;o.push({id:u,x:c,y:l,w:e,h:i}),c+=e}else{let e=(s>0?n/s:0)*i;o.push({id:u,x:c,y:l,w:r,h:e}),l+=e}}}function H(e,t,n,r,i,a){if(e.length===0||r<=0||i<=0)return;let o=e.reduce((e,t)=>e+t.value,0);if(o===0)return;let s=r*i,c=e.map(e=>e.value/o*s),l=e.map(e=>e.id),u=[],d=[],f=Math.min(r,i),p=0,m=0;for(;m<c.length;){let o=c[m]??0,h=l[m]??``,g=[...u,o],_=p+o;if(u.length===0||re(g,f,_)<=re(u,f,p))u=g,d=[...d,h],p=_,m++;else{let o=p/s;if(r>=i){let s=o*r;V(u,t,n,s,i,d,a),H(e.slice(m),t+s,n,r-s,i,a)}else{let s=o*i;V(u,t,n,r,s,d,a),H(e.slice(m),t,n+s,r,i-s,a)}return}}if(u.length>0){let e=p/s;r>=i?V(u,t,n,e*r,i,d,a):V(u,t,n,r,e*i,d,a)}}function U(e,t,n){if(e.length===0||t<=0||n<=0)return[];let r=[...e].sort((e,t)=>t.value-e.value),i=[];return H(r,0,0,t,n,i),i}function W(e,t=`silhouette`){let n=c(e);if(t===`zero`)return n;let r=e[0]?.length??0,i=Array.from({length:r},(t,n)=>e.reduce((e,t)=>e+(t[n]??0),0));return n.map(e=>e.map(([e,t],n)=>{let r=i[n]/2;return[e-r,t-r]}))}function G(e){let t=0,n=0;for(let r of e)for(let[e,i]of r)t=Math.min(t,e,i),n=Math.max(n,e,i);return[t,n]}function K(e){return e.children&&e.children.length>0?e.children.reduce((e,t)=>e+K(t),0):e.value??0}function ie(e,t=2*Math.PI){let n=[],r=(e,t,i,a)=>{if(n.push({node:e,depth:t,a0:i,a1:a,value:K(e)}),!e.children)return;let o=a-i,s=K(e)||1,c=i;for(let n of e.children){let e=c+o*K(n)/s;r(n,t+1,c,e),c=e}};return r(e,0,0,t),n}function ae(e){return e.reduce((e,t)=>Math.max(e,t.depth),0)}function q(e,t,{width:n,height:r,nodeWidth:i=16,nodePadding:a=12}){let o=new Map;for(let t of e)o.set(t.id,{...t,rank:0,value:0,x0:0,x1:0,y0:0,y1:0});let s=t.filter(e=>o.has(e.source)&&o.has(e.target)),c=new Map;for(let e of s)c.has(e.target)||c.set(e.target,[]),c.get(e.target).push(e);let l=!0,u=0;for(;l&&u++<e.length+1;){l=!1;for(let e of s){let t=o.get(e.source),n=o.get(e.target);n.rank<t.rank+1&&(n.rank=t.rank+1,l=!0)}}let d=e.length?Math.max(...[...o.values()].map(e=>e.rank)):0;for(let e of o.values()){let t=s.filter(t=>t.target===e.id).reduce((e,t)=>e+t.value,0),n=s.filter(t=>t.source===e.id).reduce((e,t)=>e+t.value,0);e.value=Math.max(t,n,0)}let f=Array.from({length:d+1},()=>[]);for(let e of o.values())f[e.rank].push(e);let p=1;for(let e of f){let t=e.reduce((e,t)=>e+t.value,0),n=r-a*Math.max(0,e.length-1);t>0&&(p=Math.max(p,t/Math.max(1,n)))}let m=e=>e/p,h=d>0?(n-i)/d:0;for(let e=0;e<=d;e++){let t=f[e],n=t.reduce((e,t)=>e+m(t.value),0)+a*Math.max(0,t.length-1),o=Math.max(0,(r-n)/2);for(let n of t)n.x0=e*h,n.x1=n.x0+i,n.y0=o,n.y1=o+m(n.value),o=n.y1+a}let g=new Map,_=new Map,v=s.map(e=>{let t=o.get(e.source),n=o.get(e.target),r=m(e.value),i=t.y0+(g.get(t.id)??0),a=n.y0+(_.get(n.id)??0);return g.set(t.id,(g.get(t.id)??0)+r),_.set(n.id,(_.get(n.id)??0)+r),{source:t,target:n,value:e.value,sy:i,ty:a,width:r}});return{nodes:[...o.values()],links:v}}function J(e){let t=e.source.x1,n=e.target.x0,r=(t+n)/2,i=e.sy,a=e.sy+e.width,o=e.ty,s=e.ty+e.width;return`M${t},${i}C${r},${i} ${r},${o} ${n},${o}L${n},${s}C${r},${s} ${r},${a} ${t},${a}Z`}var Y=e=>e<0?0:e>1?1:e,X=(e,t,n)=>e+(t-e)*n,oe=(e,t,n)=>({l:X(e.l,t.l,n),c:X(e.c,t.c,n),h:X(e.h,t.h,n)}),se=({l:e,c:t,h:n})=>`oklch(${e.toFixed(4)} ${t.toFixed(4)} ${n.toFixed(2)})`,ce={l:.95,c:.04,h:232},le={l:.34,c:.15,h:274},ue={l:.48,c:.14,h:248},de={l:.96,c:.02,h:110},fe={l:.52,c:.15,h:42};function pe(e){return se(oe(ce,le,Y(e)))}function Z(e){let t=Y(e);return se(t<.5?oe(ue,de,t*2):oe(de,fe,(t-.5)*2))}function me(e){return e===`diverging`?Z:pe}function he(e,t=`sequential`){let n=me(t);return e<=1?[n(0)]:Array.from({length:e},(t,r)=>n(r/(e-1)))}function ge(e){let t=/oklch\(([\d.]+)/.exec(e);return t?Number(t[1]):NaN}function _e(t,n,r,i){return[e(t+r*Math.sin(i)),e(n-r*Math.cos(i))]}function ve(e,t=[0,2*Math.PI]){let n=Math.max(1,e.length),r=(t[1]-t[0])/n,i=new Map(e.map((e,t)=>[e,t])),a=e=>{let n=i.get(e);return n===void 0?void 0:t[0]+n*r};return{map:a,center:e=>{let t=a(e);return t===void 0?void 0:t+r/2},bandwidth:r,step:r}}function ye(e,t){return i(e,t)}function be(e,t){return e.filter((e,n)=>t(e,n))}function xe(e,t){return e==null&&t==null?0:e==null?-1:t==null?1:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t))}function Se(e,t,n=`asc`){let r=typeof t==`function`?t:e=>e[t],i=n===`desc`?-1:1;return e.map((e,t)=>({row:e,i:t})).sort((e,t)=>xe(r(e.row),r(t.row))*i||e.i-t.i).map(e=>e.row)}function Ce(e,t){if(e===`count`)return t.length;if(t.length===0)return 0;switch(e){case`sum`:return t.reduce((e,t)=>e+t,0);case`mean`:return t.reduce((e,t)=>e+t,0)/t.length;case`min`:return Math.min(...t);case`max`:return Math.max(...t);case`median`:{let e=[...t].sort((e,t)=>e-t),n=Math.floor(e.length/2);return e.length%2==0?(e[n-1]+e[n])/2:e[n]}}}function we(e,t){let n=typeof t.groupBy==`string`?[t.groupBy]:t.groupBy,r=new Map,i=[];for(let t of e){let e=n.map(e=>String(t[e])).join(`\0`),a=r.get(e);a||(a=[],r.set(e,a),i.push(e)),a.push(t)}return i.map(e=>{let i=r.get(e),a={};for(let e of n)a[e]=i[0][e];for(let[e,n]of Object.entries(t.ops))a[e]=Ce(n,i.map(t=>t[e]).filter(e=>typeof e==`number`&&Number.isFinite(e)));return a})}function Te(e,t={}){let n=e.filter(e=>Number.isFinite(e)),[r,i]=t.range??[Math.min(...n),Math.max(...n)],a=Math.max(1,t.bins??(Math.ceil(Math.sqrt(n.length))||1)),o=(i-r)/a||1,s=Array.from({length:a},(e,t)=>({x0:r+t*o,x1:r+(t+1)*o,count:0,values:[]}));for(let e of n){if(e<r||e>i)continue;let t=Math.floor((e-r)/o);t>=a&&(t=a-1),t<0&&(t=0),s[t].values.push(e),s[t].count++}return s}function Ee(e,t){let n=t.length,r=e.map((e,n)=>[...e,t[n]]);for(let e=0;e<n;e++){let t=e;for(let i=e+1;i<n;i++)Math.abs(r[i][e])>Math.abs(r[t][e])&&(t=i);[r[e],r[t]]=[r[t],r[e]];let i=r[e][e];if(!(Math.abs(i)<1e-12))for(let t=0;t<n;t++){if(t===e)continue;let a=r[t][e]/i;for(let i=e;i<=n;i++)r[t][i]-=a*r[e][i]}}return Array.from({length:n},(e,t)=>{let i=r[t][t];return Math.abs(i)<1e-12?0:r[t][n]/i})}function De(e,t){let n=e.map(e=>e[1]),r=n.reduce((e,t)=>e+t,0)/n.length,i=0,a=0;for(let[n,o]of e)i+=(o-t(n))**2,a+=(o-r)**2;return a===0?1:1-i/a}function Oe(e,t={}){let n=t.type??`linear`,r=[...e].sort((e,t)=>e[0]-t[0]),i=r.map(e=>e[0]),a=()=>{let e=r.length?r.reduce((e,t)=>e+t[1],0)/r.length:0;return{predict:()=>e,points:i.map(t=>[t,e]),r2:0,coefficients:[e]}};if(r.length<2)return a();if(n===`exponential`){let e=r.filter(e=>e[1]>0);if(e.length<2)return a();let t=Oe(e.map(e=>[e[0],Math.log(e[1])]),{type:`linear`}),n=Math.exp(t.coefficients[0]),o=t.coefficients[1],s=e=>n*Math.exp(o*e);return{predict:s,points:i.map(e=>[e,s(e)]),r2:De(r,s),coefficients:[n,o]}}let o=(n===`linear`?1:Math.max(1,n.order))+1,s=Array.from({length:o},()=>Array(o).fill(0)),c=Array(o).fill(0);for(let[e,t]of r){let n=Array.from({length:o},(t,n)=>e**n);for(let e=0;e<o;e++){c[e]+=n[e]*t;for(let t=0;t<o;t++)s[e][t]+=n[e]*n[t]}}let l=Ee(s,c),u=e=>l.reduce((t,n,r)=>t+n*e**r,0);return{predict:u,points:i.map(e=>[e,u(e)]),r2:De(r,u),coefficients:l}}var ke=e=>typeof e==`number`?e:Number(e);function Ae(e,t){let n=e=>e.x,r=e=>e.y;if(!t.series)return{series:[{id:t.y,label:t.label??t.y,data:e.map(e=>({x:e[t.x],y:ke(e[t.y])}))}],x:n,y:r};let i=new Map,a=[];for(let n of e){let e=String(n[t.series]),r=i.get(e);r||(r={id:e,label:e,data:[]},i.set(e,r),a.push(e)),r.data.push({x:n[t.x],y:ke(n[t.y])})}return{series:a.map(e=>i.get(e)),x:n,y:r}}function je(e,t){return e.map(e=>({label:String(e[t.category]),value:ke(e[t.value])}))}function Me(e,t){let n=e.length;if(t>=n||t<3)return e.slice();let r=[e[0]],i=(n-2)/(t-2),a=0;for(let o=0;o<t-2;o++){let t=Math.floor((o+1)*i)+1,s=Math.min(Math.floor((o+2)*i)+1,n),c=Math.max(1,s-t),l=0,u=0;for(let n=t;n<s;n++)l+=e[n][0],u+=e[n][1];l/=c,u/=c;let d=Math.floor(o*i)+1,f=Math.floor((o+1)*i)+1,[p,m]=e[a],h=-1,g=d;for(let t=d;t<f&&t<n;t++){let n=Math.abs((p-l)*(e[t][1]-m)-(p-e[t][0])*(u-m));n>h&&(h=n,g=t)}r.push(e[g]),a=g}return r.push(e[n-1]),r}function Ne(e,t){let n=e.length;if(t>=n||t<4)return e.slice();let r=Math.max(1,Math.floor(t/2)),i=n/r,a=[e[0]];for(let t=0;t<r;t++){let r=Math.floor(t*i),o=Math.min(n,Math.floor((t+1)*i));if(o<=r)continue;let s=e[r],c=e[r];for(let t=r;t<o;t++)e[t][1]<s[1]&&(s=e[t]),e[t][1]>c[1]&&(c=e[t]);s[0]<=c[0]?(a.push(s),c!==s&&a.push(c)):(a.push(c),a.push(s))}return a.push(e[n-1]),a}function Pe(e,t,n=`lttb`){return n===`minmax`?Ne(e,t):Me(e,t)}function Fe(e,t){return e.length<=t.to?e:Pe(e.map((e,n)=>[n,t.y(e)]),t.to,t.method).map(([t])=>e[t])}function Ie(e){let{capacity:t,source:n,decimate:r}=e,i=b(f({capacity:t})).current,a=b(n);return a.current=n,_(()=>{let e=a.current(e=>i.append(e));return()=>{e(),i.dispose()}}),h(()=>r?Fe(i.signal.value,r):i.signal.value)}function Le(e){let{capacity:t,source:n,decimate:r}=e,i=f({capacity:t}),a=n(e=>i.append(e));return{signal:r?d(()=>Fe(i.signal.value,r)):i.signal,stop:()=>{a(),i.dispose()}}}function Re(e=400,t=300){let n=b(null),r=g(e),i=g(t);return _(()=>{let e=n.current;if(!e)return;let t=(e,t)=>{e>0&&e!==r.peek()&&(r.value=e),t>0&&t!==i.peek()&&(i.value=t)};if(typeof ResizeObserver>`u`){let n=e.getBoundingClientRect();t(n.width,n.height);return}let a=0,o=new ResizeObserver(e=>{let n=e[e.length-1];if(!n)return;let{width:r,height:i}=n.contentRect;cancelAnimationFrame(a),a=requestAnimationFrame(()=>t(r,i))});return o.observe(e),()=>{cancelAnimationFrame(a),o.disconnect()}}),{ref:n,width:r,height:i}}var ze={top:8,right:8,bottom:24,left:36},Be={top:2,right:2,bottom:2,left:2},Ve=6.5;function He(e,t){if(t)return Be.left;let n=e.reduce((e,t)=>Math.max(e,t.length),0);return Math.max(ze.left,Math.ceil(n*Ve+12))}function Ue(e={}){let{rightAxisLabels:t=[],bottomAxisLabels:n=[],rightAxisTitle:r=!1,plain:i}=e;if(i)return Be.right;let a=t.reduce((e,t)=>Math.max(e,t.length),0),o=r?20:0,s=a>0?Math.ceil(a*Ve+12+o):0,c=n[n.length-1]??``,l=c?Math.ceil(c.length*Ve/2+2):0;return Math.max(ze.right,s,l)}var We=14;function Ge(e,t,n=`horizontal`){if(e.length<=1||t<=0)return;let r=t/e.length,i=n===`vertical`?14:e.reduce((e,t)=>Math.max(e,t.length),0)*Ve+6;if(!(r>=i))return Math.ceil(i/r)}function Ke(e){return`${e.label}: ${e.value}`}function qe({point:e,model:t}){let n=t.format?t.format(e):Ke(e),r=e.segments?.filter(e=>e.value!==0);return T(`div`,{role:`tooltip`,style:{position:`absolute`,left:e.cx+8,top:Math.max(0,e.cy-32),pointerEvents:`none`,background:`var(--cascivo-surface-overlay, var(--cascivo-color-background))`,color:`var(--cascivo-color-text, currentColor)`,border:`1px solid var(--cascivo-color-border)`,borderRadius:`var(--cascivo-radius-sm, 4px)`,padding:`0.25rem 0.5rem`,fontSize:`0.8125rem`,whiteSpace:`nowrap`,boxShadow:`var(--cascivo-shadow-sm, 0 1px 4px rgba(0,0,0,0.1))`,zIndex:10},children:r&&r.length>0?E(`span`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`},children:[E(`span`,{style:{fontWeight:600},"data-tooltip-header":``,children:[e.label,` · `,e.value]}),r.map(e=>E(`span`,{style:e.color?{color:e.color}:void 0,children:[e.label,`: `,e.value]},e.label))]}):T(`span`,{style:e.color?{color:e.color}:void 0,children:n})})}function Je(e,t,n,r=`xy`){if(e.length===0)return-1;let i=0,a=1/0;for(let o=0;o<e.length;o++){let s=e[o],c=r===`x`?Math.abs(s.cx-t):Math.hypot(s.cx-t,s.cy-n);c<a&&(a=c,i=o)}return i}function Ye({size:e,paint:t}){let n=b(null);return _(()=>{let{width:r,height:i}=e(),a=n.current;if(!a||r<=0||i<=0)return;let o=typeof globalThis<`u`&&`devicePixelRatio`in globalThis&&globalThis.devicePixelRatio||1;a.width=Math.max(1,Math.round(r*o)),a.height=Math.max(1,Math.round(i*o));let s=a.getContext(`2d`);s&&(s.setTransform(o,0,0,o,0,0),s.clearRect(0,0,r,i),t(s,{width:r,height:i}))}),T(`canvas`,{ref:n,"aria-hidden":`true`,"data-canvas-layer":``,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,pointerEvents:`none`}})}function Xe(e,t){let n=/var\((--[^,)]+)/.exec(t);return!n||typeof getComputedStyle!=`function`?t:getComputedStyle(e.canvas).getPropertyValue(n[1]).trim()||t}var Ze=1;function Qe(e,t,n,r){if(t<=1)return[0,Math.max(0,t-1)];let[i,a]=e,o=i+r*(a-i),s=Math.round(o-(o-i)*n),c=Math.round(o+(a-o)*n);return s=Math.max(0,s),c=Math.min(t-1,c),c-s<Ze&&(s=Math.max(0,Math.min(Math.round(o)-1,t-1-Ze)),c=Math.min(t-1,s+Ze)),[s,c]}function $e(e,t,n){let[r,i]=e,a=i-r,o=Math.max(0,Math.min(t-1-a,Math.round(r+n)));return[o,o+a]}function et(e,t){return e[0]>0||e[1]<t-1}var tt={display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minBlockSize:`var(--cascivo-target-min-coarse, 1.75rem)`,minInlineSize:`1.75rem`,padding:`0.2rem 0.5rem`,fontSize:`0.75rem`,lineHeight:1.2,borderRadius:`0.375rem`,border:`1px solid var(--cascivo-chart-grid, currentColor)`,background:`var(--cascivo-color-background, white)`,color:`var(--cascivo-color-foreground, inherit)`,cursor:`pointer`};function nt({options:e,onPng:t,onSvg:n,onToggleData:r,onRestore:i,showData:a}){let o=e;return E(`div`,{role:`group`,"aria-label":`Chart toolbox`,style:{display:`inline-flex`,gap:`0.25rem`},children:[o.png!==!1&&T(`button`,{type:`button`,style:tt,onClick:t,children:C(x.charts.exportPng)}),o.svg!==!1&&T(`button`,{type:`button`,style:tt,onClick:n,children:C(x.charts.exportSvg)}),o.dataView!==!1&&T(`button`,{type:`button`,style:tt,"aria-pressed":a,onClick:r,children:C(x.charts.dataView)}),o.restore!==!1&&T(`button`,{type:`button`,style:tt,onClick:i,children:C(x.charts.restore)})]})}var rt=[`fill`,`stroke`,`stop-color`,`color`];function it(e){let t=e.cloneNode(!0);if(typeof getComputedStyle==`function`){let n=e.querySelectorAll(`*`),r=t.querySelectorAll(`*`);for(let e=0;e<n.length;e++){let t=getComputedStyle(n[e]),i=r[e];if(i)for(let e of rt){let n=t.getPropertyValue(e);n&&n!==`none`&&!n.includes(`var(`)&&i.setAttribute(e,n)}}}return t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),new XMLSerializer().serializeToString(t)}function at(e,t){if(typeof document>`u`||typeof Image>`u`)return Promise.resolve(null);let n=t.dpr??1,r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n));let i=r.getContext(`2d`);return i?new Promise(t=>{let n=new Image;n.addEventListener(`load`,()=>{try{i.drawImage(n,0,0,r.width,r.height),typeof r.toBlob==`function`?r.toBlob(e=>t(e),`image/png`):t(null)}catch{t(null)}}),n.addEventListener(`error`,()=>t(null)),n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}):Promise.resolve(null)}function ot(e,t){if(typeof document>`u`||typeof URL>`u`||!URL.createObjectURL)return;let n=typeof e==`string`?new Blob([e],{type:`image/svg+xml`}):e,r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var st={position:`absolute`,insetInlineStart:`-9999px`,inlineSize:`1px`,blockSize:`1px`,overflow:`hidden`,clipPath:`inset(50%)`,whiteSpace:`nowrap`};function Q({title:e,description:t,width:n,height:r,fallback:i,children:a,className:o,"data-state":s,emptyLabel:c,plain:u,tooltip:d,onSelect:f,hover:p=`rect`,renderer:m=`svg`,paint:h,zoom:S,toolbox:D,onRestore:O,transition:k,onBeforeDraw:A,onAfterDraw:j}){v();let M=y(),N=`${M}-desc`,P=`${M}-live`,{ref:F,width:ee,height:L}=Re(n??400,300),R=g(null),te=g(!1),ne=b(null),z=b(null),B=b(null),re=b(null);_(()=>{let e=re.current;if(!e||!S)return;let t=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=n.width?(t.clientX-n.left)/n.width:.5,i=t.deltaY>0?1.25:1/1.25;S.window.value=Qe(S.window.value,S.count,i,r)};return e.addEventListener(`wheel`,t,{passive:!1}),()=>e.removeEventListener(`wheel`,t)});let V=()=>{S&&(S.window.value=[0,Math.max(0,S.count-1)])},H=n??ee.value,U=r??L.value,W=D===!0?{}:D||null,G=()=>z.current?it(z.current):null,K=()=>{let t=G();t&&ot(t,`${e||`chart`}.svg`)},ie=()=>{let t=G();t&&at(t,{width:H,height:U,dpr:2}).then(t=>{t&&ot(t,`${e||`chart`}.png`)})},ae=()=>{V(),O?.()},q=typeof d==`function`?d({width:H,height:U}):d;_(()=>{let e=R.value;if(!q||!ne.current)return;let t=e===null?void 0:q.points[e];ne.current.textContent=t?(q.format??Ke)(t):``});let J={position:`absolute`,inset:0,cursor:S?`grab`:f?`pointer`:`crosshair`,background:`transparent`,touchAction:S?`none`:void 0},Y=m===`canvas`&&h!==void 0,X=q!==void 0||S!==void 0,oe={};if(k&&typeof k==`object`){let e=oe;k.duration!==void 0&&(e[`--cascivo-chart-anim-dur`]=`${k.duration}ms`),k.easing&&(e[`--cascivo-chart-anim-ease`]=k.easing),k.properties&&(e[`--cascivo-chart-anim-props`]=k.properties.join(`, `))}let se=X||Y||W||Object.keys(oe).length>0?{...oe,...X||Y||W?{position:`relative`}:{}}:void 0;return E(`div`,{ref:F,className:[l.frame,o].filter(Boolean).join(` `),style:se,...s!==void 0&&{"data-state":s},...u===!0&&{"data-plain":``},...k===!1&&{"data-no-anim":``},children:[W&&T(`div`,{style:{position:`absolute`,top:4,right:4,zIndex:12},children:T(nt,{options:W,onPng:ie,onSvg:K,onToggleData:()=>{te.value=!te.value},onRestore:ae,showData:te.value})}),Y&&T(Ye,{size:()=>({width:n??ee.value,height:r??L.value}),paint:h}),E(`svg`,{ref:z,role:`img`,"aria-label":e,"aria-describedby":t?N:void 0,width:H,height:U,viewBox:`0 0 ${H} ${U}`,children:[t&&T(`desc`,{id:N,children:t}),A?.({width:H,height:U}),a({width:H,height:U}),j?.({width:H,height:U}),s===`empty`&&T(`text`,{x:H/2,y:U/2,textAnchor:`middle`,dominantBaseline:`central`,fill:`var(--cascivo-color-foreground-muted)`,fontSize:`0.875rem`,"data-empty":``,children:c??C(x.charts.noData)})]}),i&&T(`div`,{className:l.fallback,style:st,children:i}),W&&te.value&&i&&T(`div`,{"data-data-view":``,style:{overflowX:`auto`},children:i}),X&&E(w,{children:[q!==void 0&&E(w,{children:[T(`span`,{id:P,ref:ne,"aria-live":`polite`,style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0,0,0,0)`,whiteSpace:`nowrap`,border:0}}),q.mode===`axis`&&R.value!==null&&q.points[R.value]!==void 0&&T(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:q.points[R.value].cx,top:0,width:1,height:U,background:`var(--cascivo-chart-grid, currentColor)`,pointerEvents:`none`,zIndex:9}}),R.value!==null&&q.points[R.value]!==void 0&&(()=>{let e=q.points[R.value];return T(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:e.cx-4,top:e.cy-4,width:8,height:8,borderRadius:`50%`,border:`2px solid var(--cascivo-focus-ring, var(--cascivo-color-accent))`,background:`var(--cascivo-color-background, white)`,pointerEvents:`none`,zIndex:10}})})(),R.value!==null&&q.points[R.value]!==void 0&&T(qe,{point:q.points[R.value],model:q})]}),S&&!W&&et(S.window.value,S.count)&&T(`button`,{type:`button`,onClick:V,style:{position:`absolute`,top:4,right:4,zIndex:11,padding:`0.25rem 0.5rem`,fontSize:`0.75rem`,lineHeight:1.2,borderRadius:`0.375rem`,border:`1px solid var(--cascivo-chart-grid, currentColor)`,background:`var(--cascivo-color-background, white)`,color:`var(--cascivo-color-foreground, inherit)`,cursor:`pointer`},children:C(x.charts.resetZoom)}),T(`div`,{ref:re,role:`application`,"aria-label":S?`Chart — arrow keys navigate points; + and - zoom, 0 resets, drag to pan`:`Chart data — use arrow keys to navigate points`,tabIndex:0,style:J,onPointerDown:e=>{S&&(B.current={x:e.clientX,win:[...S.window.value]},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(S&&B.current&&e.buttons===1){let t=e.currentTarget.getBoundingClientRect(),n=B.current.win[1]-B.current.win[0]+1,r=e.clientX-B.current.x,i=t.width?-(r/t.width)*n:0;S.window.value=$e(B.current.win,S.count,i);return}if(!q||!q.points.length)return;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;R.value=q.mode===`axis`?Je(q.points,n,r,`x`):p===`voronoi`?I(q.points.map(e=>[e.cx,e.cy]),n,r):Je(q.points,n,r,`xy`)},onPointerUp:()=>{B.current=null},onPointerLeave:()=>{B.current=null,q&&(R.value=null)},onKeyDown:e=>{if(S){if(e.key===`+`||e.key===`=`){e.preventDefault(),S.window.value=Qe(S.window.value,S.count,1/1.25,.5);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),S.window.value=Qe(S.window.value,S.count,1.25,.5);return}if(e.key===`0`){e.preventDefault(),V();return}}if(!q||!q.points.length)return;let t=R.value;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),R.value=t===null?0:Math.min(t+1,q.points.length-1);else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),R.value=t===null?q.points.length-1:Math.max(t-1,0);else if(e.key===`Home`)e.preventDefault(),R.value=0;else if(e.key===`End`)e.preventDefault(),R.value=q.points.length-1;else if(e.key===`Escape`)R.value=null;else if(f&&(e.key===`Enter`||e.key===` `)){e.preventDefault();let t=R.value,n=t===null?void 0:q.points[t];n&&f(n)}},onClick:()=>{if(!q)return;let e=R.value,t=e===null?void 0:q.points[e];f&&t&&f(t)},onFocus:()=>{q&&q.points.length>0&&R.value===null&&(R.value=0)},onBlur:()=>{q&&(R.value=null)}})]})]})}var ct=new Map;function lt(e){let t=ct.get(e);return t||(t={group:{window:m(null),hoverX:m(null)},refs:0},ct.set(e,t)),t.refs++,t.group}function ut(e){let t=ct.get(e);t&&(t.refs--,t.refs<=0&&ct.delete(e))}function dt(){return ct.size}function ft(e){return`bandwidth`in e}function pt(e){return`tickInterval`in e}function mt(e){return e instanceof Date?e.toLocaleDateString():typeof e==`number`?e.toLocaleString():String(e)}function ht(e,t){let n=new Intl.DateTimeFormat(void 0,e.tickFormat(t));return e=>n.format(e)}function $({scale:e,orientation:t,length:n,format:r,tickCount:i=5,labelEvery:a,title:o,titleOffset:s=36,transform:c}){let l;if(ft(e)){let t=r??mt,n=e.domain.length-1,i=a!=null&&a>1,o=i?Math.floor(n/a)*a:-1,s=!1;if(i&&o!==n&&o>=0){let r=t=>(e.map(e.domain[t])??0)+e.bandwidth/2,i=e.domain.reduce((e,n)=>Math.max(e,t(n).length),0)*Ve;s=r(n)-r(o)<i}l=e.domain.map((n,r)=>({position:(e.map(n)??0)+e.bandwidth/2,label:t(n),i:r})).filter(({i:e})=>!i||e===n?!0:s&&e===o?!1:e%a===0)}else if(pt(e)){let t=r??ht(e,i);l=e.ticks(i).map(n=>({position:e.map(n),label:t(n)}))}else{let t=e;l=t.ticks(i).map(e=>({position:t.map(e),label:(r??mt)(e)}))}let u=t===`x`,d=t===`y-right`,f=u?0:d?4:-4,p=u?0:d?8:-8,m=u?`middle`:d?`start`:`end`;return E(`g`,{transform:c,"aria-hidden":`true`,children:[T(`line`,{x1:0,y1:0,x2:u?n:0,y2:u?0:n,stroke:`var(--cascivo-chart-axis)`,strokeWidth:1}),l.map(({position:e,label:t},n)=>E(`g`,{transform:u?`translate(${e},0)`:`translate(0,${e})`,children:[T(`line`,{x1:0,y1:0,x2:f,y2:u?4:0,stroke:`var(--cascivo-chart-axis)`,strokeWidth:1}),T(`text`,{x:p,y:u?16:4,textAnchor:m,fill:`var(--cascivo-chart-axis)`,fontSize:11,children:t})]},n)),o!==void 0&&o!==``&&T(`text`,{transform:u?`translate(${n/2},${s})`:`translate(${d?s:-s},${n/2}) rotate(${d?90:-90})`,textAnchor:`middle`,fill:`var(--cascivo-chart-axis)`,fontSize:11,fontWeight:500,children:o})]})}function gt({scale:e,orientation:t,length:n,tickCount:r=5,transform:i}){let a=e.ticks(r),o=t===`x`;return T(`g`,{transform:i,"aria-hidden":`true`,children:a.map(t=>{let r=e.map(t);return T(`line`,{x1:o?r:0,y1:o?0:r,x2:o?r:n,y2:o?n:r,stroke:`var(--cascivo-chart-grid)`,strokeWidth:1,strokeDasharray:`2 4`},t)})})}var _t=`var(--cascivo-color-foreground-muted)`,vt=`var(--cascivo-color-accent)`;function yt(e,t){let n=e.map(t);if(!(n==null||Number.isNaN(n)))return e.bandwidth?n+e.bandwidth/2:n}function bt(e,t,n){let{xScale:r,yScale:i,innerW:a,innerH:o}=t;if(e.kind===`line`){let t=yt(e.axis===`x`?r:i,e.value);if(t==null)return null;let s=e.color??_t,c=e.dash!==!1,l=e.axis===`x`;return E(`g`,{"data-annotation":`line`,"aria-hidden":`true`,children:[T(`line`,{x1:l?t:0,y1:l?0:t,x2:l?t:a,y2:l?o:t,stroke:s,strokeWidth:1.5,...c&&{strokeDasharray:`4 3`},children:T(`title`,{children:e.label??String(e.value)})}),e.label!=null&&(l?T(`text`,{x:t+4,y:10,fontSize:`0.6875rem`,fill:s,textAnchor:`start`,children:e.label}):T(`text`,{x:a-4,y:t-4,fontSize:`0.6875rem`,fill:s,textAnchor:`end`,children:e.label}))]},n)}if(e.kind===`area`){let t=e.axis===`x`?r:i,s=yt(t,e.from),c=yt(t,e.to);if(s==null||c==null)return null;let l=e.color??vt,u=e.axis===`x`,d=Math.min(s,c),f=Math.abs(c-s);return T(`g`,{"data-annotation":`area`,"aria-hidden":`true`,children:T(`rect`,{x:u?d:0,y:u?0:d,width:u?f:a,height:u?o:f,fill:l,fillOpacity:.12,children:T(`title`,{children:e.label??`${String(e.from)}–${String(e.to)}`})})},n)}if(e.kind===`note`){let t=yt(r,e.x),s=yt(i,e.y);if(t==null||s==null)return null;let c=e.color??vt,l=e.dx??24,u=e.dy??-24,d=Math.max(2,Math.min(a-2,t+l)),f=Math.max(8,Math.min(o-2,s+u));return E(`g`,{"data-annotation":`note`,children:[T(`line`,{x1:t,y1:s,x2:d,y2:f,stroke:c,strokeWidth:1,"aria-hidden":`true`}),T(`circle`,{cx:t,cy:s,r:3.5,fill:c,"aria-hidden":`true`}),T(`text`,{x:d,y:f,dy:u<0?`-0.2em`:`1em`,fontSize:`0.6875rem`,fontWeight:500,fill:c,textAnchor:l<0?`end`:`start`,children:e.label})]},n)}if(e.kind===`threshold`){let t=i.map(e.value);if(t==null||Number.isNaN(t))return null;let r=e.color??vt,s=e.side===`above`?0:t,c=e.side===`above`?t:o-t;return T(`g`,{"data-annotation":`threshold`,"aria-hidden":`true`,children:T(`rect`,{x:0,y:s,width:a,height:Math.max(0,c),fill:r,fillOpacity:.1,children:T(`title`,{children:e.label??`${e.side} ${e.value}`})})},n)}let s=yt(r,e.x),c=yt(i,e.y);if(s==null||c==null)return null;let l=e.color??vt;return E(`g`,{"data-annotation":`dot`,"aria-hidden":`true`,children:[T(`circle`,{cx:s,cy:c,r:4,fill:l,stroke:`var(--cascivo-color-background)`,strokeWidth:1.5,children:T(`title`,{children:e.label??`${String(e.x)}, ${e.y}`})}),e.label!=null&&T(`text`,{x:s+6,y:c-6,fontSize:`0.6875rem`,fill:l,textAnchor:`start`,children:e.label})]},n)}function xt(e,t){return!e||e.length===0?null:T(`g`,{"data-annotations":``,children:e.map((e,n)=>bt(e,t,n))})}function St(e){return e.kind===`line`?e.label??`${e.axis}=${String(e.value)}`:e.kind===`area`?e.label??`${e.axis} ${String(e.from)}–${String(e.to)}`:e.kind===`threshold`?e.label??`${e.side} ${e.value}`:e.kind===`note`?e.label:e.label??`(${String(e.x)}, ${e.y})`}var Ct=e=>e.toLocaleString();function wt(e){return e?e===!0?{format:Ct,position:`auto`}:{format:e.format??Ct,position:e.position??`auto`}:null}function Tt({x:e,y:t,text:n,tone:r=`default`,anchor:i=`middle`}){return T(`text`,{x:e,y:t,textAnchor:i,fontSize:`0.6875rem`,fontWeight:500,fill:r===`muted`?`var(--cascivo-color-background)`:`var(--cascivo-color-foreground)`,"aria-hidden":`true`,"data-data-label":``,style:{pointerEvents:`none`},children:n})}function Et(e){return e.replace(/[^a-zA-Z0-9_-]/g,``)}function Dt(e,t){return`${Et(e)}-grad-${Et(t)}`}function Ot(e,t){return`${Et(e)}-pat-${Et(t)}`}function kt(e,t,n,r){return n===`gradient`?`url(#${Dt(e,t)})`:n===`pattern`?`url(#${Ot(e,t)})`:r}function At({prefix:e,series:t,fill:n,patternKind:r=`dots`}){return n===`solid`?null:T(`defs`,{children:t.map(t=>n===`gradient`?E(`linearGradient`,{id:Dt(e,t.id),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[T(`stop`,{offset:`0%`,stopColor:t.color,stopOpacity:.9}),T(`stop`,{offset:`100%`,stopColor:t.color,stopOpacity:.1})]},t.id):E(`pattern`,{id:Ot(e,t.id),patternUnits:`userSpaceOnUse`,width:6,height:6,patternTransform:`rotate(45)`,children:[T(`rect`,{width:6,height:6,fill:t.color,fillOpacity:.12}),r===`dots`&&T(`circle`,{cx:3,cy:3,r:1.2,fill:t.color}),r===`lines`&&T(`line`,{x1:0,y1:0,x2:0,y2:6,stroke:t.color,strokeWidth:1.2}),r===`cross`&&E(w,{children:[T(`line`,{x1:0,y1:3,x2:6,y2:3,stroke:t.color,strokeWidth:1}),T(`line`,{x1:3,y1:0,x2:3,y2:6,stroke:t.color,strokeWidth:1})]})]},t.id))})}function jt(e,t){let n=t/2;switch(e){case`square`:return`M${-n},${-n}h${t}v${t}h${-t}Z`;case`diamond`:return`M0,${-n}L${n},0L0,${n}L${-n},0Z`;case`triangle`:return`M0,${-n}L${n},${n}L${-n},${n}Z`;case`cross`:{let e=n*.4;return`M${-e},${-n}h${2*e}v${n-e}h${n-e}v${2*e}h${-(n-e)}v${n-e}h${-2*e}v${-(n-e)}h${-(n-e)}v${-2*e}h${n-e}Z`}case`star`:{let e=[];for(let t=0;t<10;t++){let r=t%2==0?n:n*.4,i=Math.PI/5*t-Math.PI/2;e.push(`${(Math.cos(i)*r).toFixed(3)},${(Math.sin(i)*r).toFixed(3)}`)}return`M${e.join(`L`)}Z`}default:return``}}function Mt({shape:e,x:t,y:n,size:r,color:i,opacity:a=.85,stroke:o,strokeWidth:s}){let c={fill:i,fillOpacity:a,...o!=null&&{stroke:o},...s!=null&&{strokeWidth:s},"aria-hidden":!0,"data-glyph":e};return e===`circle`?T(`circle`,{cx:t,cy:n,r:r/2,...c}):T(`path`,{d:jt(e,r),transform:`translate(${t},${n})`,...c})}var Nt;function Pt(e,t){if(Nt===void 0&&(Nt=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):null),Nt){Nt.font=`${t}px sans-serif`;let n=Nt.measureText(e).width;if(n>0)return n}return e.length*t*.55}function Ft(e,t,n){if(!t||t<=0)return[e];let r=e.split(/\s+/).filter(Boolean),i=[],a=``;for(let e of r){let r=a?`${a} ${e}`:e;a&&Pt(r,n)>t?(i.push(a),a=e):a=r}return a&&i.push(a),i.length?i:[e]}function It({x:e,y:t,children:n,width:r,fontSize:i=12,anchor:a=`start`,fill:o,lineHeight:s=1.2,className:c}){let l=r?Ft(n,r,i):[n];return T(`text`,{x:e,y:t,fontSize:i,textAnchor:a,...o!=null&&{fill:o},...c!=null&&{className:c},children:l.map((t,n)=>T(`tspan`,{x:e,...n>0&&{dy:`${s}em`},children:t},n))})}function Lt({count:e,height:t=28,window:n,label:r=`Range`}){v();let i=Math.max(1,e-1),a=e=>e/i*100,[o,s]=n.value,c=t-8,l=(t,r)=>{let i=Math.max(0,Math.min(e-1,r)),[a,o]=n.value;n.value=t===0?[Math.min(i,o),o]:[a,Math.max(i,a)]},u=e=>t=>{if(t.buttons!==1)return;let n=t.currentTarget.ownerSVGElement;if(!n)return;let r=n.getBoundingClientRect();r.width!==0&&l(e,Math.round((t.clientX-r.left)/r.width*i))},d=(t,n)=>r=>{r.key===`ArrowLeft`?(r.preventDefault(),l(t,n-1)):r.key===`ArrowRight`?(r.preventDefault(),l(t,n+1)):r.key===`Home`?(r.preventDefault(),l(t,0)):r.key===`End`&&(r.preventDefault(),l(t,e-1))},f=(n,i)=>T(`rect`,{"data-brush-handle":n===0?`start`:`end`,role:`slider`,tabIndex:0,"aria-label":`${r} ${n===0?`start`:`end`}`,"aria-valuemin":0,"aria-valuemax":e-1,"aria-valuenow":i,x:a(i)-.8,y:0,width:1.6,height:t,rx:.6,fill:`var(--cascivo-color-accent)`,style:{cursor:`ew-resize`,touchAction:`none`},onPointerDown:e=>e.currentTarget.setPointerCapture(e.pointerId),onPointerMove:u(n),onKeyDown:d(n,i)});return E(`svg`,{width:`100%`,height:t,viewBox:`0 0 100 ${t}`,preserveAspectRatio:`none`,role:`group`,"aria-label":`${r} — showing ${o+1}–${s+1} of ${e}`,style:{display:`block`,touchAction:`none`},children:[T(`rect`,{x:0,y:4,width:100,height:c,rx:3,fill:`var(--cascivo-chart-grid)`,fillOpacity:.3}),T(`rect`,{x:a(o),y:4,width:Math.max(0,a(s)-a(o)),height:c,fill:`var(--cascivo-color-accent)`,fillOpacity:.2}),f(0,o),f(1,s)]})}function Rt({count:e,height:t=28,window:n,label:r=`Range`}){v();let i=Math.max(1,e-1),a=e=>e/i*100,[o,s]=n.value,c=t-8,l=g(0),u=(e,t)=>{let n=t.getBoundingClientRect();return n.width===0?0:Math.round((e-n.left)/n.width*i)},d=(t,r)=>{let i=Math.max(0,Math.min(e-1,r)),[a,o]=n.value;n.value=t===0?[Math.min(i,o),o]:[a,Math.max(i,a)]},f=t=>{let[r,i]=n.value,a=i-r,o=Math.max(0,Math.min(e-1-a,t));n.value=[o,o+a]},p=e=>t=>{t.buttons!==1||!t.currentTarget.ownerSVGElement||d(e,u(t.clientX,t.currentTarget.ownerSVGElement))},m=(t,n)=>r=>{let i=r.key;i===`ArrowLeft`?(r.preventDefault(),d(t,n-1)):i===`ArrowRight`?(r.preventDefault(),d(t,n+1)):i===`Home`?(r.preventDefault(),d(t,0)):i===`End`&&(r.preventDefault(),d(t,e-1))},h=(n,i)=>T(`rect`,{"data-zoom-handle":n===0?`start`:`end`,role:`slider`,tabIndex:0,"aria-label":`${r} ${n===0?`start`:`end`}`,"aria-valuemin":0,"aria-valuemax":e-1,"aria-valuenow":i,x:a(i)-.8,y:0,width:1.6,height:t,rx:.6,fill:`var(--cascivo-color-accent)`,style:{cursor:`ew-resize`,touchAction:`none`},onPointerDown:e=>e.currentTarget.setPointerCapture(e.pointerId),onPointerMove:p(n),onKeyDown:m(n,i)});return E(`svg`,{width:`100%`,height:t,viewBox:`0 0 100 ${t}`,preserveAspectRatio:`none`,role:`group`,"aria-label":`${r} — showing ${o+1}–${s+1} of ${e}`,style:{display:`block`,touchAction:`none`},children:[T(`rect`,{x:0,y:4,width:100,height:c,rx:3,fill:`var(--cascivo-chart-grid)`,fillOpacity:.3}),T(`rect`,{"data-zoom-body":``,role:`slider`,tabIndex:0,"aria-label":`${r} window`,"aria-valuemin":0,"aria-valuemax":e-1,"aria-valuenow":o,x:a(o),y:4,width:Math.max(0,a(s)-a(o)),height:c,fill:`var(--cascivo-color-accent)`,fillOpacity:.2,style:{cursor:`grab`,touchAction:`none`},onPointerDown:e=>{let t=e.currentTarget.ownerSVGElement;t&&(l.value=u(e.clientX,t)-n.value[0]),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.buttons!==1||!e.currentTarget.ownerSVGElement||f(u(e.clientX,e.currentTarget.ownerSVGElement)-l.value)},onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),f(n.value[0]-1)):e.key===`ArrowRight`&&(e.preventDefault(),f(n.value[0]+1))}}),h(0,o),h(1,s)]})}var zt=5,Bt=[3,14],Vt=e=>e<0?0:e>1?1:e,Ht=(e,t,n)=>e+(t-e)*n,Ut=(e,t)=>Vt((e-t.min)/(t.max-t.min||1));function Wt(e,t){let n=t.pieces??zt;return Math.min(n-1,Math.max(0,Math.floor(Ut(e,t)*n)))}function Gt(e,t){let n=t.channel??`color`,r=t.ramp??`sequential`,i=Ut(e,t),a={};if((n===`color`||n===`both`)&&(a.color=(t.mode??`continuous`)===`piecewise`?he(t.pieces??zt,r)[Wt(e,t)]:me(r)(i)),n===`size`||n===`both`){let[e,n]=t.sizeRange??Bt;a.size=Ht(e,n,i)}return a}function Kt(e,t,n,r){return(t.mode??`continuous`)===`piecewise`?!r?.has(Wt(e,t)):n?e>=n[0]&&e<=n[1]:!0}function qt({options:e,range:t,hidden:n,label:r=`Value`,format:i}){v();let a=i??(e=>String(Math.round(e)));if((e.mode??`continuous`)===`piecewise`){let t=e.pieces??zt,i=he(t,e.ramp??`sequential`),o=(e.max-e.min)/t,s=n?.value??new Set,c=e=>{if(!n)return;let t=new Set(n.value);t.has(e)?t.delete(e):t.add(e),n.value=t};return T(`div`,{role:`group`,"aria-label":`${r} — colour buckets`,style:{display:`flex`,flexWrap:`wrap`,gap:`0.25rem`,alignItems:`center`},children:i.map((t,n)=>{let r=e.min+n*o,i=e.min+(n+1)*o,l=s.has(n);return E(`button`,{type:`button`,"aria-pressed":!l,onClick:()=>c(n),style:{display:`inline-flex`,alignItems:`center`,gap:`0.35rem`,padding:`0.2rem 0.45rem`,minBlockSize:`var(--cascivo-target-min-coarse, 1.75rem)`,border:`1px solid var(--cascivo-chart-grid, currentColor)`,borderRadius:`0.375rem`,background:`transparent`,color:`var(--cascivo-color-foreground, inherit)`,fontSize:`0.75rem`,cursor:`pointer`,opacity:l?.4:1},children:[T(`span`,{"aria-hidden":`true`,style:{width:12,height:12,borderRadius:2,background:t,display:`inline-block`}}),`${a(r)}–${a(i)}`]},n)})})}let{min:o,max:s}=e,c=s-o||1,l=he(8,e.ramp??`sequential`),u=e=>(e-o)/c*100,d=t?.value[0]??o,f=t?.value[1]??s,p=`vm-grad-${l.length}`,m=(e,t)=>{let n=t.getBoundingClientRect();return n.width===0?o:o+Vt((e-n.left)/n.width)*c},h=(e,n)=>{if(!t)return;let r=Math.max(o,Math.min(s,n)),[i,a]=t.value;t.value=e===0?[Math.min(r,a),a]:[i,Math.max(r,i)]},g=c/100,_=(e,t)=>n=>{n.key===`ArrowLeft`?(n.preventDefault(),h(e,t-g)):n.key===`ArrowRight`?(n.preventDefault(),h(e,t+g)):n.key===`Home`?(n.preventDefault(),h(e,o)):n.key===`End`&&(n.preventDefault(),h(e,s))},y=e=>t=>{t.buttons!==1||!t.currentTarget.ownerSVGElement||h(e,m(t.clientX,t.currentTarget.ownerSVGElement))},b=(e,t)=>T(`rect`,{"data-visual-thumb":e===0?`low`:`high`,role:`slider`,tabIndex:0,"aria-label":`${r} ${e===0?`minimum`:`maximum`}`,"aria-valuemin":o,"aria-valuemax":s,"aria-valuenow":Math.round(t),x:u(t)-.8,y:0,width:1.6,height:20,rx:.6,fill:`var(--cascivo-color-foreground, currentColor)`,style:{cursor:`ew-resize`,touchAction:`none`},onPointerDown:e=>e.currentTarget.setPointerCapture(e.pointerId),onPointerMove:y(e),onKeyDown:_(e,t)});return E(`svg`,{width:`100%`,height:20,viewBox:`0 0 100 20`,preserveAspectRatio:`none`,role:`group`,"aria-label":`${r} — showing ${a(d)} to ${a(f)}`,style:{display:`block`,touchAction:`none`},children:[T(`defs`,{children:T(`linearGradient`,{id:p,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:l.map((e,t)=>T(`stop`,{offset:`${t/(l.length-1)*100}%`,stopColor:e},t))})}),T(`rect`,{x:0,y:6,width:100,height:8,rx:2,fill:`url(#${p})`}),t&&E(w,{children:[T(`rect`,{x:0,y:6,width:Math.max(0,u(d)),height:8,fill:`var(--cascivo-surface-base, white)`,fillOpacity:.6}),T(`rect`,{x:u(f),y:6,width:Math.max(0,100-u(f)),height:8,fill:`var(--cascivo-surface-base, white)`,fillOpacity:.6}),b(0,d),b(1,f)]})]})}var Jt={legend:`_legend_1pign_2`,item:`_item_1pign_9`,swatch:`_swatch_1pign_27`};function Yt({series:e,hidden:t}){return v(),T(`div`,{className:Jt.legend,role:`group`,"aria-label":`Chart legend`,children:e.map((e,n)=>{let r=t.value.has(e.id);return E(`button`,{type:`button`,className:Jt.item,"data-state":r?`off`:`on`,"aria-pressed":!r,"aria-label":C(x.charts.legendToggle,{name:e.label}),onClick:()=>{let n=new Set(t.value);r?n.delete(e.id):n.add(e.id),t.value=n},children:[T(`span`,{className:Jt.swatch,style:{background:e.color||`var(--cascivo-chart-${n+1})`},"aria-hidden":`true`}),e.label]},e.id)})})}function Xt(){return typeof process<`u`&&process.env.NODE_ENV===`production`}var Zt=new Set;function Qt(e,t){if(Xt()||Zt.has(e))return;let n=0;for(let e of t())Number.isFinite(e)||n++;n!==0&&(Zt.add(e),console.warn(`[cascivo charts] ${e}: ${n} non-finite value(s) (NaN/Infinity/null) in series data. These are dropped from the chart, which can make it look wrong — check your data source.`))}function $t(e,t){Xt()||Zt.has(e)||(Zt.add(e),console.warn(`[cascivo charts] ${t}`))}function en(e,t){if(Xt())return;let n=t.filter(e=>Number.isFinite(e.max)&&e.max>0);if(n.length<2)return;let r=[...n].sort((e,t)=>t.max-e.max),i=r[0],a=r[r.length-1];i.max/a.max<20||$t(`${e}:scale-mismatch`,`${e}: "${a.label}" (max ${a.max.toLocaleString()}) is more than 20× smaller than "${i.label}" (max ${i.max.toLocaleString()}) on the same axis, so it renders as a flat line at the baseline while the legend still names both. Put the smaller series on its own scale with \`axis: 'right'\` + \`secondAxis\`, or split it into a second chart.`)}function tn(e,t){if(Xt()||t.length<2)return;let[n,r]=[t[0],t[t.length-1]];$t(`${e}:dual-axis-areas`,`${e}: "${n}" and "${r}" are on different axes but both paint an area fill, so they composite to a third colour wherever they cross. Dual-axis comparisons read as line-over-area: set \`type: 'line'\` on "${r}" (the secondary series), or split it into a second chart.`)}function nn(e,t,n){Xt()||n||typeof t!=`number`||!Number.isFinite(t)||Math.abs(t)<1e11||$t(`${e}:epoch-ms`,`${e}: \`x\` returned ${t}, which looks like epoch milliseconds but is typed \`number\`, so the axis uses a LINEAR scale and labels it with the raw value. Return a Date for a time axis: \`x={(d) => new Date(d.t)}\`. Pass \`format\` to control tick text (and to silence this if the values really are numeric).`)}var rn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function an(e){return[Math.min(0,...e),Math.max(...e)]}function on({series:e,x:t,y:n,title:a,description:s,curve:c=`monotone`,width:l,height:u,xTicks:d=5,yTicks:f=5,format:p,legend:m,tooltip:h,formatTooltip:y,className:x,plain:S,annotations:C,labels:D,connectNulls:O,onSelect:k,brush:A,dataZoom:j,zoom:M,syncId:P,tooltipMode:F,secondAxis:I,decimate:ee,toolbox:L,transition:R,onBeforeDraw:te,onAfterDraw:ne}){v();let z=g(new Set),B=S?null:wt(D),re=ee===!0?{method:`lttb`,threshold:1e3}:ee?{method:ee.method??`lttb`,threshold:ee.threshold??1e3}:null,V=e.reduce((e,t)=>Math.max(e,t.data.length),0),H=(A||j||M||P!==void 0)&&V>0,U=g([0,Math.max(0,V-1)]),W=b(null);P&&!W.current&&(W.current=lt(P)),_(()=>()=>{P&&ut(P)}),_(()=>{let e=W.current;if(!e)return;let t=e.window.value,n=U.peek();t&&(t[0]!==n[0]||t[1]!==n[1])&&(U.value=t)}),_(()=>{let e=W.current;if(!e)return;let t=U.value,n=e.window.peek();(!n||n[0]!==t[0]||n[1]!==t[1])&&(e.window.value=t)});let G=H?e.map(e=>({...e,data:e.data.slice(U.value[0],U.value[1]+1)})):e,K=!S&&G.some(e=>e.axis===`right`),ie=u??(S?48:300),ae=S?!1:m??G.length>1,q=e=>e.y??n,J=G.flatMap(e=>e.data.map(e=>t(e))),Y=e=>e.flatMap(e=>e.data.map(t=>q(e)(t))).filter(e=>Number.isFinite(e)),X=Y(K?G.filter(e=>e.axis!==`right`):G),oe=K?Y(G.filter(e=>e.axis===`right`)):[];Qt(`LineChart`,()=>G.flatMap(e=>e.data.map(t=>q(e)(t))));let se=J.length>0,ce=i(an(X),[0,1]).ticks(f).map(e=>e.toLocaleString()),le=se&&J[0]instanceof Date;nn(`LineChart`,J[0],p!==void 0);let ue=K?i(an(oe),[0,1]).ticks(f).map(e=>I?.format?I.format(e):e.toLocaleString()):[],de=J.filter(e=>typeof e==`number`),fe=J.filter(e=>e instanceof Date),pe=se?le?N([new Date(Math.min(...fe.map(e=>e.getTime()))),new Date(Math.max(...fe.map(e=>e.getTime())))],[0,1]).ticks(d).map(e=>e.toLocaleDateString()):i([Math.min(...de),Math.max(...de)],[0,1]).ticks(d).map(e=>e.toLocaleString()):[],Z=S?Be:{...ze,left:He(ce,S),right:Ue({rightAxisLabels:ue,bottomAxisLabels:pe,rightAxisTitle:I?.label!==void 0&&I.label!==``,plain:S})};return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:a,description:s,width:l,height:ie,fallback:E(`table`,{children:[T(`caption`,{children:a}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`X`}),G.map(e=>T(`th`,{children:e.label},e.id))]})}),T(`tbody`,{children:(G[0]?.data??[]).map((e,n)=>E(`tr`,{children:[T(`td`,{children:String(G[0]?t(G[0].data[n]):``)}),G.map(e=>T(`td`,{children:e.data[n]==null?``:q(e)(e.data[n])},e.id))]},n))})]}),className:x,"data-state":se?void 0:`empty`,plain:S,tooltip:h!==!1&&se?({width:e,height:n})=>{if(h===!1||!se)return;let r=e-Z.left-Z.right,a=n-Z.top-Z.bottom,o=Math.min(...le?J.map(e=>e.getTime()):J),s=Math.max(...le?J.map(e=>e.getTime()):J),c=le?N([new Date(o),new Date(s)],[0,r]):i([o,s],[0,r]),l=i(an(X),[a,0]),u=K?i(an(oe),[a,0]):l,d=e=>e.axis===`right`?u:l,f=e=>c.map(e);if(F===`axis`){let e=G.reduce((e,t)=>Math.max(e,t.data.length),0),n=[];for(let r=0;r<e;r++){let e=[],i=0,a=0,o=1/0,s=``;G.forEach((n,c)=>{if(z.value.has(n.id))return;let l=n.data[r];if(l===void 0)return;let u=q(n)(l);if(!Number.isFinite(u))return;let p=t(l);i+=f(p),a++,o=Math.min(o,d(n).map(u)),s=p instanceof Date?p.toLocaleDateString():String(p),e.push({label:n.label,value:u,color:n.color??rn[c%rn.length]})}),a!==0&&n.push({id:`x-${r}`,cx:Z.left+i/a,cy:Z.top+(o===1/0?0:o),label:s,value:s,segments:e})}return{points:n,mode:`axis`,format:e=>`${e.label}: ${(e.segments??[]).map(e=>`${e.label} ${e.value}`).join(`, `)}`}}let p=G.flatMap(e=>z.value.has(e.id)?[]:e.data.flatMap((n,r)=>{let i=q(e)(n);if(!Number.isFinite(i))return[];let a=t(n),o=c.map(a),s=d(e).map(i),l=a instanceof Date?a.toLocaleDateString():String(a);return{id:`${e.id}-${r}`,cx:Z.left+o,cy:Z.top+s,label:l,value:q(e)(n),seriesId:e.id}}));return y?{points:p,format:e=>{let t=G.find(t=>t.id===e.seriesId),n=parseInt(e.id.split(`-`).pop()??`0`,10);return t&&t.data[n]!==void 0?y(t.data[n],t):`${e.label}: ${e.value}`}}:{points:p}}:void 0,onSelect:k,zoom:M&&V>1?{window:U,count:V}:void 0,toolbox:L,onRestore:H?()=>{U.value=[0,Math.max(0,V-1)]}:void 0,transition:R,onBeforeDraw:te,onAfterDraw:ne,children:({width:e,height:n})=>{let a=e-Z.left-Z.right,s=n-Z.top-Z.bottom,l=Math.min(...le?J.map(e=>e.getTime()):J),u=Math.max(...le?J.map(e=>e.getTime()):J),m=le?N([new Date(l),new Date(u)],[0,a]):i([l,u],[0,a]),h=i(an(X),[s,0]),g=K?i(an(oe),[s,0]):h;return T(`g`,{children:E(`g`,{transform:`translate(${Z.left},${Z.top})`,children:[!S&&T(gt,{scale:h,orientation:`y`,length:a,tickCount:f}),!S&&xt(C,{xScale:m,yScale:h,innerW:a,innerH:s}),G.map((e,n)=>{if(z.value.has(e.id))return null;let i=e.color??rn[n%rn.length],a=e.axis===`right`?g:h,s=e=>m.map(e);if(re&&e.data.length>re.threshold){let n=[];for(let r of e.data){let i=q(e)(r);Number.isFinite(i)&&n.push([s(t(r)),a.map(i)])}return T(`path`,{d:r(Pe(n,re.threshold,re.method).map(e=>[e[0],e[1]]),c),fill:`none`,stroke:i,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"data-series":e.id},e.id)}let l=e.data.map(n=>{let r=q(e)(n);return Number.isFinite(r)?[s(t(n)),a.map(r)]:null});return E(`g`,{children:[o(l,O).map((t,n)=>T(`path`,{d:r(t,c),fill:`none`,stroke:i,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"data-series":e.id},n)),B&&e.data.map((t,n)=>{let r=l[n];return r?T(Tt,{x:r[0],y:r[1]-8,text:B.format(q(e)(t))},n):null})]},e.id)}),!S&&E(w,{children:[T($,{scale:m,orientation:`x`,length:a,tickCount:d,transform:`translate(0,${s})`,...p?{format:p}:{}}),T($,{scale:h,orientation:`y`,length:s,tickCount:f}),K&&T($,{scale:g,orientation:`y-right`,length:s,tickCount:f,transform:`translate(${a},0)`,...I?.format?{format:e=>I.format(Number(e))}:{},...I?.label!==void 0&&I.label!==``?{title:I.label,titleOffset:8+Math.ceil(ue.reduce((e,t)=>Math.max(e,t.length),0)*6.5)+10}:{}})]})]})})}}),A&&!j&&V>1&&T(Lt,{count:V,window:U,label:`Time range`}),j&&V>1&&T(Rt,{count:V,window:U,label:`Time range`}),ae&&T(Yt,{series:G.map((e,t)=>({id:e.id,label:e.label,color:e.color??rn[t%rn.length]})),hidden:z})]})}var sn={fillOpacity:`var(--cascivo-chart-fill-opacity, 0.25)`};function cn(e,t){return t||e<=1?sn:{fillOpacity:`var(--cascivo-chart-fill-opacity-overlap, 0.12)`}}var ln=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function un({series:e,x:t,y:n,title:a,description:o,stacked:l=!1,curve:u=`monotone`,fill:d,patternKind:f,width:p,height:m,xTicks:h=5,yTicks:x=5,legend:S,tooltip:C,className:D,plain:O,annotations:k,labels:A,onSelect:j,brush:M,dataZoom:P,zoom:F,syncId:I,tooltipMode:ee,secondAxis:L,decimate:R,toolbox:te,format:ne}){v();let z=y(),B=g(new Set),re=O?null:wt(A),V=R===!0?{method:`lttb`,threshold:1e3}:R?{method:R.method??`lttb`,threshold:R.threshold??1e3}:null,H=e.reduce((e,t)=>Math.max(e,t.data.length),0),U=(M||P||F||I!==void 0)&&H>0,W=g([0,Math.max(0,H-1)]),G=b(null);I&&!G.current&&(G.current=lt(I)),_(()=>()=>{I&&ut(I)}),_(()=>{let e=G.current;if(!e)return;let t=e.window.value,n=W.peek();t&&(t[0]!==n[0]||t[1]!==n[1])&&(W.value=t)}),_(()=>{let e=G.current;if(!e)return;let t=W.value,n=e.window.peek();(!n||n[0]!==t[0]||n[1]!==t[1])&&(e.window.value=t)});let K=U?e.map(e=>({...e,data:e.data.slice(W.value[0],W.value[1]+1)})):e,ie=d??(K.length===1&&!l?`gradient`:`solid`),ae=!O&&!l&&K.some(e=>e.axis===`right`),q=m??(O?48:300),J=O?!1:S??K.length>1,Y=cn(K.filter(e=>e.type!==`line`).length,l),X=e=>e.y??n,oe=(K[0]?.data??[]).map(e=>t(e)),se=(ae?K.filter(e=>e.axis!==`right`):K).flatMap(e=>e.data.map(t=>X(e)(t))),ce=ae?K.filter(e=>e.axis===`right`).flatMap(e=>e.data.map(t=>X(e)(t))):[];!ae&&!l&&K.length>1&&en(`AreaChart`,K.map(e=>({label:e.label,max:Math.max(0,...e.data.map(t=>X(e)(t)).filter(e=>Number.isFinite(e)))}))),ae&&tn(`AreaChart`,K.filter(e=>e.type!==`line`).map(e=>e.label)),Qt(`AreaChart`,()=>[...se,...ce]);let le=oe.length>0,ue=le&&oe[0]instanceof Date;nn(`AreaChart`,oe[0],ne!==void 0);let de=oe.map(e=>e instanceof Date?e.getTime():e),fe=le?Math.min(...de):0,pe=le?Math.max(...de):1,Z=e=>ue?N([new Date(fe),new Date(pe)],[0,e]):i([fe,pe],[0,e]),me=(e,n)=>e.map(t(n)),he=e=>{let n=t(e);return n instanceof Date?n.toLocaleDateString():String(n)},ge=l?0:Math.min(0,...se),_e=Math.max(...l?(K[0]?.data??[]).map((e,t)=>K.reduce((e,n)=>e+X(n)(n.data[t]),0)):se),ve=ae?Math.min(0,...ce):ge,ye=ae?Math.max(...ce):_e,be=i([ge,_e],[0,1]).ticks(x).map(e=>e.toLocaleString()),xe=ae?i([ve,ye],[0,1]).ticks(x).map(e=>L?.format?L.format(e):e.toLocaleString()):[],Se=ue?N([new Date(fe),new Date(pe)],[0,1]).ticks(h).map(e=>e.toLocaleDateString()):i([fe,pe],[0,1]).ticks(h).map(e=>e.toLocaleString()),Ce=O?Be:{...ze,left:He(be,O),right:Ue({rightAxisLabels:xe,bottomAxisLabels:Se,rightAxisTitle:L?.label!==void 0&&L.label!==``,plain:O})};return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:a,description:o,width:p,height:q,fallback:E(`table`,{children:[T(`caption`,{children:a}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`X`}),K.map(e=>T(`th`,{children:e.label},e.id))]})}),T(`tbody`,{children:(K[0]?.data??[]).map((e,t)=>E(`tr`,{children:[T(`td`,{children:K[0]?he(K[0].data[t]):``}),K.map(e=>T(`td`,{children:e.data[t]==null?``:X(e)(e.data[t])},e.id))]},t))})]}),className:D,"data-state":le?void 0:`empty`,plain:O,tooltip:C!==!1&&le?({width:e,height:t})=>{if(C===!1||!le)return;let n=e-Ce.left-Ce.right,r=t-Ce.top-Ce.bottom,a=Z(n),o=i([ge,_e],[r,0]),s=ae?i([ve,ye],[r,0]):o,c=e=>e.axis===`right`?s:o;if(ee===`axis`){let e=K.reduce((e,t)=>Math.max(e,t.data.length),0),t=[];for(let n=0;n<e;n++){let e=[],r=1/0,i=``,o=Ce.left;K.forEach((t,s)=>{if(B.value.has(t.id))return;let l=t.data[n];if(l===void 0)return;let u=X(t)(l);Number.isFinite(u)&&(o=Ce.left+me(a,l),r=Math.min(r,c(t).map(u)),i=he(l),e.push({label:t.label,value:u,color:t.color??ln[s%ln.length]}))}),e.length!==0&&t.push({id:`x-${n}`,cx:o,cy:Ce.top+(r===1/0?0:r),label:i,value:i,segments:e})}return{points:t,mode:`axis`,format:e=>`${e.label}: ${(e.segments??[]).map(e=>`${e.label} ${e.value}`).join(`, `)}`}}return{points:K.flatMap(e=>B.value.has(e.id)?[]:e.data.map((t,n)=>({id:`${e.id}-${n}`,cx:Ce.left+me(a,t),cy:Ce.top+c(e).map(X(e)(t)),label:he(t),value:X(e)(t),seriesId:e.id})))}}:void 0,onSelect:j,zoom:F&&H>1?{window:W,count:H}:void 0,toolbox:te,onRestore:U?()=>{W.value=[0,Math.max(0,H-1)]}:void 0,children:({width:e,height:t})=>{let n=e-Ce.left-Ce.right,a=t-Ce.top-Ce.bottom,o=Z(n),d=i([ge,_e],[a,0]),p=ae?i([ve,ye],[a,0]):d,m=[];return l&&(m=c(K.map(e=>e.data.map(t=>X(e)(t))))),E(`g`,{children:[ie!==`solid`&&T(At,{prefix:z,fill:ie,patternKind:f,series:K.map((e,t)=>({id:e.id,color:e.color??ln[t%ln.length]}))}),E(`g`,{transform:`translate(${Ce.left},${Ce.top})`,children:[!O&&T(gt,{scale:d,orientation:`y`,length:n,tickCount:x}),!O&&xt(k,{xScale:o,yScale:d,innerW:n,innerH:a}),K.map((e,t)=>{if(B.value.has(e.id))return null;let n=e.color??ln[t%ln.length],i,a;if(l&&m[t]){let s=m[t];i=e.data.map((e,t)=>[me(o,e),d.map(s[t][1])]);let c=e.data.map((e,t)=>[me(o,e),d.map(s[t][0])]);a=d.map(0);let l=r(i,u),f=c[c.length-1],p=c[0],h=[...c].reverse().map(([e,t])=>`L${e},${t}`).join(``),g=`${l}L${f[0]},${f[1]}${h}L${p[0]},${p[1]}Z`;return E(`g`,{"data-series":e.id,children:[T(`path`,{d:g,fill:kt(z,e.id,ie,n),style:ie===`solid`?Y:void 0,stroke:`none`}),T(`path`,{d:r(i,u),fill:`none`,stroke:n,strokeWidth:2}),re&&i.map((t,n)=>T(Tt,{x:t[0],y:t[1]-8,text:re.format(X(e)(e.data[n]))},n))]},e.id)}else{let t=e.axis===`right`?p:d;if(i=e.data.map(n=>[me(o,n),t.map(X(e)(n))]),a=t.map(0),V&&i.length>V.threshold){let t=Pe(i,V.threshold,V.method).map(e=>[e[0],e[1]]);return E(`g`,{"data-series":e.id,children:[e.type!==`line`&&T(`path`,{d:s(t,a,u),fill:kt(z,e.id,ie,n),style:ie===`solid`?Y:void 0,stroke:`none`}),T(`path`,{d:r(t,u),fill:`none`,stroke:n,strokeWidth:2})]},e.id)}return E(`g`,{"data-series":e.id,children:[e.type!==`line`&&T(`path`,{d:s(i,a,u),fill:kt(z,e.id,ie,n),style:ie===`solid`?Y:void 0,stroke:`none`}),T(`path`,{d:r(i,u),fill:`none`,stroke:n,strokeWidth:2}),re&&i.map((t,n)=>T(Tt,{x:t[0],y:t[1]-8,text:re.format(X(e)(e.data[n]))},n))]},e.id)}}),!O&&E(w,{children:[T($,{scale:o,orientation:`x`,length:n,tickCount:h,transform:`translate(0,${a})`,...ne?{format:ne}:{}}),T($,{scale:d,orientation:`y`,length:a,tickCount:x}),ae&&T($,{scale:p,orientation:`y-right`,length:a,tickCount:x,transform:`translate(${n},0)`,...L?.format?{format:e=>L.format(Number(e))}:{},...L?.label!==void 0&&L.label!==``?{title:L.label,titleOffset:8+Math.ceil(xe.reduce((e,t)=>Math.max(e,t.length),0)*6.5)+10}:{}})]})]})]})}}),M&&!P&&H>1&&T(Lt,{count:H,window:W,label:`Range`}),P&&H>1&&T(Rt,{count:H,window:W,label:`Range`}),J&&T(Yt,{series:K.map((e,t)=>({id:e.id,label:e.label,color:e.color??ln[t%ln.length]})),hidden:B})]})}function dn(e,t,n,r){return typeof e==`function`?t===void 0?r:e(t,n):e??r}var fn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function pn(e){let t=e.segments?.filter(e=>e.value!==0)??[],n=`${e.label} · ${e.value}`;return t.length>0?`${n} — ${t.map(e=>`${e.label}: ${e.value}`).join(`, `)}`:n}function mn({series:e,x:n,y:r,title:a,description:o,orientation:s=`vertical`,mode:l=`grouped`,width:u,height:d,valueAxisTicks:f,categoryAxisTicks:p,xLabelEvery:m,categoryLabelEvery:h,legend:_,tooltip:b,tooltipFormat:x,className:S,plain:C,annotations:D,labels:O,onSelect:k,fill:A=`solid`,patternKind:j,format:M}){v();let N=y(),P=C?null:wt(O),F=g(new Set),I=d??(C?48:300),ee=C?!1:_??e.length>1,L=e=>e.y??r,R=(e[0]?.data??[]).map(e=>n(e)),te=e.flatMap(e=>e.data.map(t=>L(e)(t))),ne=R.length>0,z=l===`stacked`||l===`percent`,B=R.map((t,n)=>e.reduce((e,t)=>e+L(t)(t.data[n]),0)),re=()=>{let t=c(e.map(e=>e.data.map(t=>L(e)(t))));return l===`percent`?t.map(e=>e.map(([e,t],n)=>{let r=B[n]||1;return[e/r,t/r]})):t},V=z?0:Math.min(0,...te),H=ne?Math.max(...B):1,U=l===`percent`?1:l===`stacked`?H:Math.max(1,...te),W=l===`percent`?e=>`${Math.round(Number(e)*100)}%`:void 0,G=s===`vertical`,K=(G?f:p)??5,ie=(G?p:f)??5,ae=h??m,q=G?i([V,U],[0,1]).ticks(K).map(e=>W?W(e):e.toLocaleString()):R.map(e=>String(e)),J=G?R.map(e=>String(e)):i([V,U],[0,1]).ticks(ie).map(e=>W?W(e):e.toLocaleString()),Y=C?Be:{...ze,left:He(q,C),right:Ue({bottomAxisLabels:J,plain:C})};return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:a,description:o,width:u,height:I,fallback:E(`table`,{children:[T(`caption`,{children:a}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Category`}),e.map(e=>T(`th`,{children:e.label},e.id))]})}),T(`tbody`,{children:R.map((t,n)=>E(`tr`,{children:[T(`td`,{children:t}),e.map(e=>T(`td`,{children:e.data[n]==null?``:L(e)(e.data[n])},e.id))]},t))})]}),className:S,"data-state":ne?void 0:`empty`,plain:C,tooltip:b&&ne?({width:r,height:a})=>{if(!b||!ne)return;let o=r-Y.left-Y.right,c=a-Y.top-Y.bottom,u=s===`vertical`,d=t(R,u?[0,o]:[0,c],.2),f=i([V,U],u?[c,0]:[0,o]),p=e.filter(e=>!F.value.has(e.id)),m=[];z&&(m=re());let h=z&&!x,g=R.map((t,n)=>{let r=p.map(t=>({label:t.label,value:L(t)(t.data[n]),color:dn(t.color,t.data[n],n,fn[e.indexOf(t)%fn.length])}));return{segs:r,total:r.reduce((e,t)=>e+t.value,0)}}),_=p.flatMap(t=>{let r=e.indexOf(t),i=l===`grouped`?d.bandwidth/p.length:d.bandwidth;return t.data.map((e,a)=>{let o=d.map(n(e))??0,s,c;if(z&&m[r]){let e=m[r][a];s=e[1],c=e[0]}else s=L(t)(e),c=V;let _=p.indexOf(t),v=o+(l===`grouped`?_*i:0)+i/2,y=(Math.min(f.map(s),f.map(c))+Math.max(f.map(s),f.map(c)))/2;return{id:`${t.id}-${a}`,cx:Y.left+(u?v:y),cy:Y.top+(u?y:v),label:n(e),value:h?g[a].total:L(t)(e),seriesId:t.id,...h&&{segments:g[a].segs}}})}),v=x??(h?pn:void 0);return v?{points:_,format:v}:{points:_}}:void 0,onSelect:k,children:({width:r,height:a})=>{let o=r-Y.left-Y.right,c=a-Y.top-Y.bottom,u=s===`vertical`,d=ae??Ge(R,u?o:c,u?`horizontal`:`vertical`),f=t(R,u?[0,o]:[0,c],.2),p=i([V,U],u?[c,0]:[0,o]),m=e.filter(e=>!F.value.has(e.id)),h=[];return z&&(h=re()),E(`g`,{children:[A!==`solid`&&T(At,{prefix:N,fill:A,patternKind:j,series:e.map((e,t)=>({id:e.id,color:dn(e.color,e.data[0],0,fn[t%fn.length])}))}),E(`g`,{transform:`translate(${Y.left},${Y.top})`,children:[!C&&u&&T(gt,{scale:p,orientation:`y`,length:o,tickCount:K}),!C&&!u&&T(gt,{scale:p,orientation:`x`,length:c,tickCount:ie}),!C&&xt(D,{xScale:u?f:p,yScale:u?p:f,innerW:o,innerH:c}),m.map((t,r)=>{let i=fn[e.indexOf(t)%fn.length],a=e.indexOf(t),o=l===`grouped`?f.bandwidth/m.length:f.bandwidth;return t.data.map((e,s)=>{let c=f.map(n(e))??0,d,m;if(z&&h[a]){let e=h[a][s];d=e[1],m=e[0]}else d=L(t)(e),m=V;let g=c+(l===`grouped`?r*o:0),_=Math.min(p.map(d),p.map(m)),v=Math.abs(p.map(d)-p.map(m)),y=null;if(P){let n=P.format(L(t)(e)),r=g+o/2,i=z||v<18||_<14;if(u)y=T(Tt,{x:r,y:i?_+13:_-4,text:n,tone:i?`muted`:`default`});else{let e=_+v;y=T(Tt,{x:i?e-4:e+4,y:r+4,text:n,anchor:i?`end`:`start`,tone:i?`muted`:`default`})}z&&v<14&&(y=null)}let b=dn(t.color,e,s,i);return E(`g`,{children:[u?T(`rect`,{x:g,y:_,width:o,height:v,fill:kt(N,t.id,A,b),rx:2,"data-series":t.id,"data-x":String(n(e))}):T(`rect`,{x:_,y:g,width:v,height:o,fill:kt(N,t.id,A,b),rx:2,"data-series":t.id,"data-x":String(n(e))}),y]},`${t.id}-${s}`)})}),!C&&u&&E(w,{children:[T($,{scale:f,orientation:`x`,length:o,tickCount:ie,labelEvery:d,transform:`translate(0,${c})`,...M?{format:M}:{}}),T($,{scale:p,orientation:`y`,length:c,tickCount:K,...W&&{format:W}})]}),!C&&!u&&E(w,{children:[T($,{scale:p,orientation:`x`,length:o,tickCount:ie,...W&&{format:W},transform:`translate(0,${c})`}),T($,{scale:f,orientation:`y`,length:c,tickCount:K,labelEvery:d})]})]})]})}}),ee&&T(Yt,{series:e.map((e,t)=>({id:e.id,label:e.label,color:dn(e.color,e.data[0],0,fn[t%fn.length])})),hidden:F})]})}function hn(e){let t=e.percent==null?0:Math.round(e.percent);return`${e.value} (${t}%)`}var gn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function _n({data:t,title:n,description:r,donut:i=!1,width:o,height:s,size:c,thickness:l,innerRadius:u,centerValue:d,centerLabel:f,centerSlot:p,emptyLabel:m,tooltip:h,tooltipFormat:_,legend:y,className:b,plain:x,labels:S,onSelect:C}){let w=x?null:wt(S),D=typeof S==`object`&&!!S&&S.format!=null,O=o??c,k=s??c??(x?48:300),A=x?!1:y??!0;v();let j=g(new Set),M=t.length>0;return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:n,description:r,width:O,height:k,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Label`}),T(`th`,{children:`Value`}),T(`th`,{children:`Percent`})]})}),T(`tbody`,{children:t.map(e=>{let n=t.reduce((e,t)=>e+t.value,0),r=n>0?(e.value/n*100).toFixed(1):`0`;return E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.value}),E(`td`,{children:[r,`%`]})]},e.id)})})]}),className:b,"data-state":M?void 0:`empty`,emptyLabel:m,plain:x,tooltip:h!==!1&&M?({width:n,height:r})=>{if(!M)return;let i=n/2,a=r/2,o=Math.min(i,a)-8,s=t.filter(e=>!j.value.has(e.id)),c=s.reduce((e,t)=>e+t.value,0),l=0;return{points:s.map((t,n)=>{let r=c>0?t.value/c*2*Math.PI:0,s=l+r,u=(l+s)/2;return l=s,{id:t.id,cx:e(i+Math.sin(u)*o*.65),cy:e(a-Math.cos(u)*o*.65),label:t.label,value:t.value,seriesId:String(n),percent:c>0?t.value/c*100:0,color:t.color??gn[n%gn.length]}}),format:_??hn}}:void 0,onSelect:C,children:({width:n,height:r})=>{let o=n/2,s=r/2,c=Math.min(o,s)-8,m=u??(l==null?c*.6:c-l),h=i?Math.max(0,Math.min(m,c)):0,g=t.filter(e=>!j.value.has(e.id)),_=g.reduce((e,t)=>e+t.value,0),v=0,y=i&&(d!=null||f!=null||p!=null);return E(`g`,{children:[g.map((t,n)=>{let r=_>0?t.value/_*2*Math.PI:0,i=v+r,l=(v+i)/2,u=t.color??gn[n%gn.length],d=a(o,s,c,h,v,i);v=i;let f=_>0?t.value/_*100:0,p=w&&f>=4,m=h>0?(h+c)/2:c*.6;return E(`g`,{children:[T(`path`,{d,fill:u,stroke:`var(--cascivo-color-surface)`,strokeWidth:1,"data-series":t.id}),p&&T(Tt,{x:e(o+Math.sin(l)*m),y:e(s-Math.cos(l)*m+4),text:D?w.format(t.value):`${Math.round(f)}%`,tone:`muted`})]},t.id)}),y&&(p==null?E(`g`,{"data-center":``,children:[d!=null&&T(`text`,{x:o,y:f==null?s:s-8,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`1.5rem`,fontWeight:700,fill:`var(--cascivo-color-foreground)`,children:d}),f!=null&&T(`text`,{x:o,y:d==null?s:s+14,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`0.8125rem`,fill:`var(--cascivo-color-foreground-muted)`,children:f})]}):T(`foreignObject`,{x:o-h,y:s-h,width:h*2,height:h*2,"data-center-slot":``,children:T(`div`,{style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,textAlign:`center`},children:p})}))]})}}),A&&T(Yt,{series:t.map((e,t)=>({id:e.id,label:e.label,color:e.color??gn[t%gn.length]})),hidden:j})]})}var vn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function yn({series:e,title:t,description:n,r=4,width:a,height:o,xTicks:s=5,yTicks:c=5,legend:l,tooltip:u,className:d,plain:f,annotations:p,onSelect:m,glyph:h,renderer:_=`svg`,visualMap:y,toolbox:b,format:x}){v();let S=g(new Set),C=f?Be:ze,D=o??(f?48:300),O=f?!1:l??e.length>1,k=e.reduce((e,t)=>e+t.data.length,0),A=!y&&(_===`canvas`||_===`auto`&&k>2e3),j=g([y?.min??0,y?.max??1]),M=g(new Set),N=(t,{width:n,height:a})=>{let o=n-C.left-C.right,s=a-C.top-C.bottom;if(o<=0||s<=0)return;let c=i([ee,L],[0,o]),l=i([R,te],[s,0]);e.forEach((e,n)=>{if(!S.value.has(e.id)){t.fillStyle=Xe(t,e.color??vn[n%vn.length]),t.globalAlpha=.7;for(let n of e.data){let e=typeof r==`function`?r(n):n.r??r;t.beginPath(),t.arc(C.left+c.map(n.x),C.top+l.map(n.y),e,0,Math.PI*2),t.fill()}}}),t.globalAlpha=1},P=e.flatMap(e=>e.data.map(e=>e.x)),F=e.flatMap(e=>e.data.map(e=>e.y)),I=P.length>0,ee=I?Math.min(...P):0,L=I?Math.max(...P):1,R=I?Math.min(0,...F):0,te=I?Math.max(...F):1;return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:t,description:n,width:a,height:D,fallback:E(`table`,{children:[T(`caption`,{children:t}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Series`}),T(`th`,{children:`X`}),T(`th`,{children:`Y`})]})}),T(`tbody`,{children:e.flatMap(e=>e.data.map((t,n)=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:t.x}),T(`td`,{children:t.y})]},`${e.id}-${n}`)))})]}),className:d,"data-state":I?void 0:`empty`,plain:f,tooltip:u!==!1&&I?({width:t,height:n})=>{if(u===!1||!I)return;let r=t-C.left-C.right,a=n-C.top-C.bottom,o=i([ee,L],[0,r]),s=i([R,te],[a,0]);return{points:e.flatMap(e=>S.value.has(e.id)?[]:e.data.map((t,n)=>({id:`${e.id}-${n}`,cx:C.left+o.map(t.x),cy:C.top+s.map(t.y),label:`(${t.x}, ${t.y})`,value:t.y,seriesId:e.id})))}}:void 0,onSelect:m,hover:`voronoi`,renderer:A?`canvas`:`svg`,paint:A?N:void 0,toolbox:b,onRestore:y?()=>{j.value=[y.min,y.max],M.value=new Set}:void 0,children:({width:t,height:n})=>{let a=t-C.left-C.right,o=n-C.top-C.bottom,l=i([ee,L],[0,a]),u=i([R,te],[o,0]);return T(`g`,{children:E(`g`,{transform:`translate(${C.left},${C.top})`,children:[!f&&T(gt,{scale:u,orientation:`y`,length:a,tickCount:c}),!f&&xt(p,{xScale:l,yScale:u,innerW:a,innerH:o}),!A&&e.map((e,t)=>{if(S.value.has(e.id))return null;let n=e.color??vn[t%vn.length];return T(`g`,{"data-series":e.id,children:e.data.map((t,i)=>{let a=typeof r==`function`?r(t):t.r??r,o=y?Gt(t.y,y):void 0,s=o?.size??a,c=o?.color??n,d=y?Kt(t.y,y,j.value,M.value):!0,f=d?.7:.1,p=typeof h==`function`?h(t,e.id):h;return p&&p!==`circle`?T(Mt,{shape:p,x:l.map(t.x),y:u.map(t.y),size:s*2,color:c,opacity:d?.75:.1,stroke:c,strokeWidth:1},i):T(`circle`,{cx:l.map(t.x),cy:u.map(t.y),r:s,fill:c,fillOpacity:f,stroke:c,strokeWidth:1},i)})},e.id)}),!f&&E(w,{children:[T($,{scale:l,orientation:`x`,length:a,tickCount:s,transform:`translate(0,${o})`,...x?{format:x}:{}}),T($,{scale:u,orientation:`y`,length:o,tickCount:c})]})]})})}}),y&&I&&T(qt,{options:y,range:j,hidden:M,label:t}),O&&T(Yt,{series:e.map((e,t)=>({id:e.id,label:e.label,color:e.color??vn[t%vn.length]})),hidden:S})]})}function bn({data:e,width:t=120,height:n=32,label:a,ariaLabel:o,color:s=`var(--cascivo-chart-1)`,endDot:c=!0}){return T(Q,{title:a??o,width:t,height:n,plain:!0,tooltip:e.length>0?(()=>{if(e.length===0)return;let r=i([0,e.length-1],[2,t-2]),a=Math.min(...e),o=Math.max(...e),s=i([a===o?a-1:a,o],[n-2,2]);return{points:e.map((e,t)=>({id:String(t),cx:r.map(t),cy:s.map(e),label:String(t),value:e}))}})():void 0,children:()=>{if(e.length===0)return null;let a=i([0,e.length-1],[2,t-2]),o=Math.min(...e),l=Math.max(...e),u=i([o===l?o-1:o,l],[n-2,2]),d=e.map((e,t)=>[a.map(t),u.map(e)]),f=r(d,`monotone`),p=d[d.length-1];return E(w,{children:[T(`path`,{d:f,fill:`none`,stroke:s,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}),c&&T(`circle`,{cx:p[0],cy:p[1],r:2.5,fill:s})]})}})}var xn={meter:`_meter_cns3q_2`,svg:`_svg_cns3q_9`,label:`_label_cns3q_16`,gaugeLabel:`_gaugeLabel_cns3q_22`,fill:`_fill_cns3q_28`};function Sn(e,t){if(!t)return`var(--cascivo-chart-1)`;let{warning:n,critical:r}=t;return r!=null&&e>=r?`var(--cascivo-color-destructive)`:n!=null&&e>=n?`var(--cascivo-color-warning)`:`var(--cascivo-color-success)`}function Cn({value:e,min:t=0,max:n=100,label:r,variant:i=`bar`,thresholds:o,width:s,height:c}){let{ref:l,width:u}=Re(200,100),d=s??u.value,f=n>t?(Math.min(n,Math.max(t,e))-t)/(n-t):0,p=Sn(e,o);if(i===`gauge`){let i=c??100,o=d,s=o/2,u=i*.9,m=Math.min(s,u)-4,h=m*.65,g=Math.PI,_=a(s,u,m,h,g,2*Math.PI),v=g+f*Math.PI,y=f>0?a(s,u,m,h,g,v):``;return E(`div`,{ref:l,className:xn.meter,"aria-label":r,role:`meter`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,children:[E(`svg`,{className:xn.svg,width:o,height:i,viewBox:`0 0 ${o} ${i}`,"aria-hidden":`true`,children:[T(`path`,{d:_,fill:`var(--cascivo-color-border)`}),y&&T(`path`,{d:y,fill:p})]}),E(`div`,{className:xn.gaugeLabel,children:[r,`: `,e]})]})}let m=c??12,h=d;return E(`div`,{ref:l,className:xn.meter,"aria-label":r,role:`meter`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,children:[E(`svg`,{className:xn.svg,width:h,height:m,viewBox:`0 0 ${h} ${m}`,"aria-hidden":`true`,children:[T(`rect`,{x:0,y:0,width:h,height:m,rx:m/2,fill:`var(--cascivo-color-border)`}),T(`rect`,{x:0,y:0,width:h,height:m,rx:m/2,fill:p,className:xn.fill,style:{transform:`scaleX(${f})`}})]}),T(`div`,{className:xn.label,children:r})]})}var wn={kpi:`_kpi_nrb8p_7`,head:`_head_nrb8p_19`,label:`_label_nrb8p_27`,valueRow:`_valueRow_nrb8p_34`,value:`_value_nrb8p_34`,delta:`_delta_nrb8p_49`};function Tn(e,t){if(typeof t==`function`)return t(e);let n=e>=0?`+`:``,r=e.toLocaleString(S());return t===`percent`?`${n}${r}%`:`${n}${r}`}function En({value:e,label:t,delta:n,deltaFormat:r=`number`,goodDirection:i=`up`,deltaLabel:a,icon:o,sparkline:s,className:c}){let l=n!=null&&n>=0,u=n!=null&&n<0,d=l?`up`:u?`down`:`flat`;return E(`div`,{className:[wn.kpi,c].filter(Boolean).join(` `),children:[E(`div`,{className:wn.head,children:[T(`span`,{className:wn.label,children:t}),o&&T(`span`,{"aria-hidden":`true`,children:o})]}),E(`div`,{className:wn.valueRow,children:[T(`span`,{className:wn.value,children:typeof e==`number`?e.toLocaleString(S()):e}),n!=null&&E(`span`,{role:`img`,className:wn.delta,"data-trend":d,"data-sentiment":p(d,i),"aria-label":`Trend: ${Tn(n,r)}${a?` ${a}`:``}`,children:[l?`▲`:u?`▼`:`–`,` `,Tn(n,r),a&&` ${a}`]})]}),s&&s.length>0&&T(bn,{data:s,label:`${t} trend`,height:32})]})}function Dn({data:e,bins:t,title:n,label:r,description:a,width:o,height:s,className:c,plain:l,format:u}){v();let d=l?Be:r===``?ze:{...ze,bottom:48},f=s??(l?48:300),p=ne(e,t),m=p.reduce((e,t)=>Math.max(e,t.count),0);return T(Q,{title:n,description:a,width:o,height:f,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Range`}),T(`th`,{children:`Count`})]})}),T(`tbody`,{children:p.map((e,t)=>E(`tr`,{children:[E(`td`,{children:[e.x0.toFixed(2),` – `,e.x1.toFixed(2)]}),T(`td`,{children:e.count})]},t))})]}),className:c,plain:l,tooltip:p.length>0?({width:e,height:t})=>{if(p.length===0)return;let n=e-d.left-d.right,r=t-d.top-d.bottom,a=i([p[0]?.x0??0,p[p.length-1]?.x1??1],[0,n]),o=i([0,m||1],[r,0]);return{points:p.map((e,t)=>{let n=a.map(e.x0),r=Math.max(0,a.map(e.x1)-n-1);return{id:`bin-${t}`,cx:d.left+n+r/2,cy:d.top+o.map(e.count),label:`${e.x0.toFixed(2)}–${e.x1.toFixed(2)}`,value:e.count}})}}:void 0,children:({width:e,height:t})=>{let n={width:e-d.left-d.right,height:t-d.top-d.bottom};if(n.width<=0||p.length===0)return null;let a=i([p[0]?.x0??0,p[p.length-1]?.x1??1],[0,n.width]),o=i([0,m||1],[n.height,0]);return E(`g`,{transform:`translate(${d.left},${d.top})`,children:[!l&&T(gt,{scale:o,orientation:`y`,length:n.width}),p.map((e,t)=>{let r=a.map(e.x0),i=Math.max(0,a.map(e.x1)-r-1),s=o.map(e.count),c=n.height-s;return T(`rect`,{x:r,y:s,width:i,height:Math.max(0,c),fill:`var(--cascivo-chart-1)`,opacity:.85},t)}),!l&&E(w,{children:[T($,{scale:a,orientation:`x`,length:n.width,transform:`translate(0,${n.height})`,title:r,...u?{format:u}:{}}),T($,{scale:o,orientation:`y`,length:n.height})]})]})}})}var On=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function kn({series:e,title:n,description:r,width:a,height:o,className:s,plain:c,format:l}){v();let u=c?Be:ze,d=o??(c?48:320),f=e.map(e=>({...e,stats:z(e.values)})),p=e.flatMap(e=>e.values),[m,h]=p.length>0?B(p):[0,1];return T(Q,{title:n,description:r,width:a,height:d,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Series`}),T(`th`,{children:`Min`}),T(`th`,{children:`Q1`}),T(`th`,{children:`Median`}),T(`th`,{children:`Q3`}),T(`th`,{children:`Max`})]})}),T(`tbody`,{children:f.map(e=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.stats.min.toFixed(2)}),T(`td`,{children:e.stats.q1.toFixed(2)}),T(`td`,{children:e.stats.median.toFixed(2)}),T(`td`,{children:e.stats.q3.toFixed(2)}),T(`td`,{children:e.stats.max.toFixed(2)})]},e.id))})]}),className:s,plain:c,tooltip:f.length>0?({width:e,height:n})=>{if(f.length===0)return;let r=e-u.left-u.right,a=n-u.top-u.bottom;if(r<=0)return;let o=t(f.map(e=>e.id),[0,r],.3),s=(h-m)*.05||1,c=i([m-s,h+s],[a,0]);return{points:f.map(e=>{let t=(o.map(e.id)??0)+o.bandwidth/2;return{id:e.id,cx:u.left+t,cy:u.top+c.map(e.stats.median),label:e.label,value:e.stats.median}}),format:e=>{let t=f.find(t=>t.id===e.id);return t?`${t.label}: min ${t.stats.min.toFixed(2)} / Q1 ${t.stats.q1.toFixed(2)} / med ${t.stats.median.toFixed(2)} / Q3 ${t.stats.q3.toFixed(2)} / max ${t.stats.max.toFixed(2)}`:`${e.label}: ${e.value}`}}}:void 0,children:({width:e,height:n})=>{let r={width:e-u.left-u.right,height:n-u.top-u.bottom};if(r.width<=0||f.length===0)return null;let a=t(f.map(e=>e.id),[0,r.width],.3),o=(h-m)*.05||1,s=i([m-o,h+o],[r.height,0]);return E(`g`,{transform:`translate(${u.left},${u.top})`,children:[f.map((e,t)=>{let n=On[t%On.length]??`var(--cascivo-chart-1)`,r=(a.map(e.id)??0)+a.bandwidth/2,i=a.bandwidth*.6,o=r-i/2,c=s.map(e.stats.q1),l=s.map(e.stats.q3),u=s.map(e.stats.median),d=s.map(e.stats.min),f=s.map(e.stats.max);return E(`g`,{children:[T(`line`,{x1:r,y1:l,x2:r,y2:f,stroke:n,strokeWidth:1.5}),T(`line`,{x1:r,y1:c,x2:r,y2:d,stroke:n,strokeWidth:1.5}),T(`line`,{x1:r-i/4,y1:f,x2:r+i/4,y2:f,stroke:n,strokeWidth:1.5}),T(`line`,{x1:r-i/4,y1:d,x2:r+i/4,y2:d,stroke:n,strokeWidth:1.5}),T(`rect`,{x:o,y:l,width:i,height:Math.max(0,c-l),fill:n,fillOpacity:.25,stroke:n,strokeWidth:1.5}),T(`line`,{x1:o,y1:u,x2:o+i,y2:u,stroke:n,strokeWidth:2.5}),e.stats.outliers.map((e,t)=>T(`circle`,{cx:r,cy:s.map(e),r:3,fill:`none`,stroke:n,strokeWidth:1.5},t))]},e.id)}),!c&&E(w,{children:[T($,{scale:a,orientation:`x`,length:r.width,transform:`translate(0,${r.height})`,...l?{format:l}:{}}),T($,{scale:s,orientation:`y`,length:r.height})]})]})}})}var An=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`),jn=3,Mn=24;function Nn({series:e,title:t,description:r,width:a,height:o,tooltip:s,className:c,plain:l,glyph:u,format:d}){v();let f=g(null),p=l?Be:ze,m=o??(l?48:320),h=e.flatMap(e=>e.data),[_,y]=h.length>0?B(h.map(e=>e.x)):[0,1],[b,x]=h.length>0?B(h.map(e=>e.y)):[0,1],[S,C]=h.length>0?B(h.map(e=>e.size)):[0,1],D=n([S,C],[jn,Mn]),O=h.length>0;return T(Q,{title:t,description:r,width:a,height:m,fallback:E(`table`,{children:[T(`caption`,{children:t}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Series`}),T(`th`,{children:`X`}),T(`th`,{children:`Y`}),T(`th`,{children:`Size`})]})}),T(`tbody`,{children:e.flatMap(e=>e.data.map((t,n)=>E(`tr`,{children:[T(`td`,{children:e.name}),T(`td`,{children:t.x}),T(`td`,{children:t.y}),T(`td`,{children:t.size})]},`${e.name}-${n}`)))})]}),className:c,plain:l,tooltip:s!==!1&&O?({width:t,height:n})=>{if(s===!1||!O)return;let r={width:t-p.left-p.right,height:n-p.top-p.bottom};if(r.width<=0)return;let a=(y-_)*.05||1,o=(x-b)*.05||1,c=i([_-a,y+a],[0,r.width]),l=i([b-o,x+o],[r.height,0]);return{points:e.flatMap((e,t)=>e.data.map((n,r)=>({id:`${t}-${r}`,cx:p.left+c.map(n.x),cy:p.top+l.map(n.y),label:`${e.name} (${n.x}, ${n.y})`,value:n.y,seriesId:e.name})))}}:void 0,hover:`voronoi`,children:({width:t,height:n})=>{let r={width:t-p.left-p.right,height:n-p.top-p.bottom};if(r.width<=0||h.length===0)return null;let a=(y-_)*.05||1,o=(x-b)*.05||1,s=i([_-a,y+a],[0,r.width]),c=i([b-o,x+o],[r.height,0]);return E(`g`,{transform:`translate(${p.left},${p.top})`,children:[!l&&T(gt,{scale:c,orientation:`y`,length:r.width}),e.map((e,t)=>{let n=An[t%An.length]??`var(--cascivo-chart-1)`;return T(`g`,{opacity:f.value!==null&&f.value!==e.name?.2:1,onMouseEnter:()=>{f.value=e.name},onMouseLeave:()=>{f.value=null},children:e.data.map((t,r)=>{let i=typeof u==`function`?u(t,e.name):u;return i&&i!==`circle`?T(`g`,{children:T(Mt,{shape:i,x:s.map(t.x),y:c.map(t.y),size:D(t.size)*2,color:n,opacity:.6,stroke:n,strokeWidth:1})},r):T(`circle`,{cx:s.map(t.x),cy:c.map(t.y),r:D(t.size),fill:n,fillOpacity:.6,stroke:n,strokeWidth:1},r)})},e.name)}),!l&&E(w,{children:[T($,{scale:s,orientation:`x`,length:r.width,transform:`translate(0,${r.height})`,...d?{format:d}:{}}),T($,{scale:c,orientation:`y`,length:r.height})]})]})}})}var Pn=`var(--cascivo-chart-1)`,Fn=`var(--cascivo-chart-2)`;function In({bars:e,line:n,title:a,description:o,secondAxis:s=!1,barsLabel:c=`Bars`,lineLabel:l=`Line`,legend:u,xLabelEvery:d,width:f,height:p,tooltip:m,className:h,plain:_,annotations:y,format:b}){v();let x=g(new Set),S=p??(_?48:320),C=e.reduce((e,t)=>Math.max(e,t.value),0)||1,D=n.length>0?Math.min(...n.map(e=>e.y)):0,O=n.length>0?Math.max(...n.map(e=>e.y)):1,k=e.length>0,A=_?!1:u??(e.length>0&&n.length>0);n.length>0&&e.length>0&&n.length!==e.length&&$t(`ComboChart:length-mismatch`,`ComboChart: \`line\` has ${n.length} point(s) but \`bars\` has ${e.length}. The two are correlated by array index, so the line is drawn against the wrong categories. Pass one line point per bar (use a null-valued point for a gap).`),!s&&n.length>0&&e.length>0&&en(`ComboChart`,[{label:c,max:C},{label:l,max:O}]);let j=i([0,C],[0,1]).ticks(5).map(e=>e.toLocaleString()),M=s?i([D,O||D+1],[0,1]).ticks(5).map(e=>e.toLocaleString()):[],N=e.map(e=>e.label),P=_?Be:{...ze,left:He(j,_),right:Ue({rightAxisLabels:M,plain:_})};return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--cascivo-space-2)`},className:h,children:[T(Q,{title:a,description:o,width:f,height:S,fallback:E(`table`,{children:[T(`caption`,{children:a}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Label`}),T(`th`,{children:c}),n.length>0&&T(`th`,{children:l})]})}),T(`tbody`,{children:e.map((e,t)=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.value}),n.length>0&&T(`td`,{children:n[t]?.y??``})]},e.label))})]}),plain:_,tooltip:m!==!1&&k?({width:r,height:a})=>{if(m===!1||!k)return;let o={width:r-P.left-P.right,height:a-P.top-P.bottom};if(o.width<=0)return;let c=t(e.map(e=>e.label),[0,o.width],.2),l=i([0,C],[o.height,0]),u=s?i([D,O||D+1],[o.height,0]):l,d=e.map((e,t)=>({id:`bar-${t}`,cx:P.left+(c.map(e.label)??0)+c.bandwidth/2,cy:P.top+l.map(e.value),label:e.label,value:e.value,seriesId:`bars`})),f=n.map((t,r)=>{let i=e[r]?(c.map(e[r].label)??0)+c.bandwidth/2:o.width*t.x/Math.max(1,n.length-1);return{id:`line-${r}`,cx:P.left+i,cy:P.top+u.map(t.y),label:e[r]?.label??String(t.x),value:t.y,seriesId:`line`}});return{points:[...d,...f]}}:void 0,children:({width:a,height:o})=>{let c={width:a-P.left-P.right,height:o-P.top-P.bottom};if(c.width<=0||e.length===0)return null;let l=t(e.map(e=>e.label),[0,c.width],.2),u=i([0,C],[c.height,0]),f=s?i([D,O||D+1],[c.height,0]):u,p=n.map((t,r)=>[e[r]?(l.map(e[r].label)??0)+l.bandwidth/2:c.width*t.x/Math.max(1,n.length-1),f.map(t.y)]),m=p.length>1?r(p,`monotone`):``,h=d??Ge(N,c.width),g=x.value.has(`bars`),v=x.value.has(`line`);return E(`g`,{transform:`translate(${P.left},${P.top})`,children:[!_&&T(gt,{scale:u,orientation:`y`,length:c.width}),!_&&xt(y,{xScale:l,yScale:u,innerW:c.width,innerH:c.height}),!g&&e.map(e=>{let t=l.map(e.label)??0,n=u.map(e.value);return T(`rect`,{x:t,y:n,width:l.bandwidth,height:Math.max(0,c.height-n),fill:Pn,opacity:.75},e.label)}),m&&!v&&T(`path`,{d:m,fill:`none`,stroke:Fn,strokeWidth:2.5,strokeLinejoin:`round`,strokeLinecap:`round`}),!_&&E(w,{children:[T($,{scale:l,orientation:`x`,length:c.width,labelEvery:h,transform:`translate(0,${c.height})`,...b?{format:b}:{}}),T($,{scale:u,orientation:`y`,length:c.height}),s&&T($,{scale:f,orientation:`y-right`,length:c.height,transform:`translate(${c.width},0)`})]})]})}}),A&&T(Yt,{series:[{id:`bars`,label:c,color:Pn},...n.length>0?[{id:`line`,label:l,color:Fn}]:[]],hidden:x})]})}function Ln({data:e,title:n,description:r,width:i,height:a,className:o,plain:s,visualMap:c,toolbox:l,format:u}){v();let d=a??(s?48:320),f=s?Be:{top:20,right:20,bottom:60,left:60},p=[...new Set(e.map(e=>e.x))],m=[...new Set(e.map(e=>e.y))],[h,_]=e.length>0?B(e.map(e=>e.value)):[0,1],y=_-h||1,b=e=>Math.max(0,Math.min(1,(e-h)/y)),x=g([c?.min??h,c?.max??_]),S=g(new Set),C=T(Q,{title:n,description:r,width:i,height:d,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`X`}),T(`th`,{children:`Y`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:e.map((e,t)=>E(`tr`,{children:[T(`td`,{children:e.x}),T(`td`,{children:e.y}),T(`td`,{children:e.value})]},t))})]}),className:o,plain:s,tooltip:e.length>0?({width:n,height:r})=>{if(e.length===0)return;let i=n-f.left-f.right,a=r-f.top-f.bottom;if(i<=0)return;let o=t(p,[0,i],.05),s=t(m,[0,a],.05);return{points:e.map((e,t)=>{let n=o.map(e.x)??0,r=s.map(e.y)??0;return{id:`cell-${t}`,cx:f.left+n+o.bandwidth/2,cy:f.top+r+s.bandwidth/2,label:`${e.x}×${e.y}`,value:e.value}})}}:void 0,toolbox:l,onRestore:c?()=>{x.value=[c.min,c.max],S.value=new Set}:void 0,children:({width:n,height:r})=>{let i={width:n-f.left-f.right,height:r-f.top-f.bottom};if(i.width<=0||e.length===0)return null;let a=t(p,[0,i.width],.05),o=t(m,[0,i.height],.05);return E(`g`,{transform:`translate(${f.left},${f.top})`,children:[e.map((e,t)=>{let n=a.map(e.x)??0,r=o.map(e.y)??0,i=Math.round(b(e.value)*100),s=c?Gt(e.value,c).color??`var(--cascivo-chart-1)`:`color-mix(in oklab, var(--cascivo-chart-1) ${i}%, var(--cascivo-gray-100))`,l=c?Kt(e.value,c,x.value,S.value):!0;return T(`rect`,{x:n,y:r,width:a.bandwidth,height:o.bandwidth,fill:s,fillOpacity:l?1:.12,stroke:`var(--cascivo-surface-base)`,strokeWidth:1},t)}),!s&&E(w,{children:[T($,{scale:a,orientation:`x`,length:i.width,transform:`translate(0,${i.height})`,...u?{format:u}:{}}),T($,{scale:o,orientation:`y`,length:i.height})]})]})}});return!c||e.length===0?C:E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[C,T(qt,{options:c,range:x,hidden:S,label:n})]})}var Rn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function zn({data:e,title:t,description:n,width:r,height:i,className:a,plain:o}){v();let s=y();return T(Q,{title:t,description:n,width:r,height:i??(o?48:320),fallback:E(`table`,{children:[T(`caption`,{children:t}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Label`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:e.map(e=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.value})]},e.id))})]}),className:a,plain:o,tooltip:e.length>0?({width:t,height:n})=>{if(e.length!==0)return{points:U(e.map(e=>({id:e.id,value:e.value})),t,n).map(t=>{let n=e.find(e=>e.id===t.id);return{id:t.id,cx:t.x+t.w/2,cy:t.y+t.h/2,label:n?.label??t.id,value:n?.value??0}})}}:void 0,children:({width:t,height:n})=>{if(e.length===0)return null;let r=U(e.map(e=>({id:e.id,value:e.value})),t,n),i=new Map(e.map(e=>[e.id,e.label]));return E(w,{children:[T(`defs`,{children:r.map(e=>T(`clipPath`,{id:`${s}-${e.id}`,children:T(`rect`,{x:e.x+2,y:e.y+2,width:Math.max(0,e.w-4),height:Math.max(0,e.h-4)})},e.id))}),r.map((e,t)=>{let n=Rn[t%Rn.length]??`var(--cascivo-chart-1)`,r=i.get(e.id)??e.id;return E(`g`,{children:[T(`rect`,{x:e.x,y:e.y,width:Math.max(0,e.w-1),height:Math.max(0,e.h-1),fill:n,fillOpacity:.8,stroke:`var(--cascivo-surface-base)`,strokeWidth:1}),!o&&e.w>30&&e.h>18&&T(`text`,{x:e.x+4,y:e.y+14,fontSize:Math.min(12,e.w/5),fill:`currentColor`,clipPath:`url(#${s}-${e.id})`,children:r})]},e.id)})]})}})}var Bn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`),Vn=4;function Hn(t,n,r,i,a){let o=t.length;return t.map((t,s)=>{let c=s/o*2*Math.PI-Math.PI/2,l=t/n*a;return{x:e(r+Math.cos(c)*l),y:e(i+Math.sin(c)*l)}})}function Un({axes:t,series:n,max:r,title:i,description:a,width:o,height:s,className:c,plain:l}){let u=s??(l?48:320);v();let d=r??Math.max(1,...n.flatMap(e=>e.values)),f=t.length;return T(Q,{title:i,description:a,width:o,height:u,fallback:E(`table`,{children:[T(`caption`,{children:i}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Series`}),t.map(e=>T(`th`,{children:e},e))]})}),T(`tbody`,{children:n.map(e=>E(`tr`,{children:[T(`td`,{children:e.label}),e.values.map((e,t)=>T(`td`,{children:e},t))]},e.id))})]}),className:c,plain:l,tooltip:n.length>0?({width:r,height:i})=>{if(n.length===0||f===0)return;let a=r/2,o=i/2,s=Math.min(a,o)*.72;return{points:n.flatMap(n=>n.values.map((r,i)=>{let c=i/f*2*Math.PI-Math.PI/2,l=r/d*s;return{id:`${n.id}-${i}`,cx:e(a+Math.cos(c)*l),cy:e(o+Math.sin(c)*l),label:t[i]??String(i),value:r,seriesId:n.id}}))}}:void 0,children:({width:r,height:i})=>{let a=r/2,o=i/2,s=Math.min(a,o)*.72,c=Array.from({length:Vn},(e,t)=>(t+1)/Vn*s),u=Array.from({length:f},(t,n)=>{let r=n/f*2*Math.PI-Math.PI/2;return{x:e(a+Math.cos(r)*s),y:e(o+Math.sin(r)*s)}}),p=c.map(t=>Array.from({length:f},(n,r)=>{let i=r/f*2*Math.PI-Math.PI/2;return`${e(a+Math.cos(i)*t)},${e(o+Math.sin(i)*t)}`}).join(` `));return E(w,{children:[!l&&p.map((e,t)=>T(`polygon`,{points:e,fill:`none`,stroke:`var(--cascivo-border-subtle)`,strokeWidth:1},t)),!l&&u.map((e,t)=>T(`line`,{x1:a,y1:o,x2:e.x,y2:e.y,stroke:`var(--cascivo-border-subtle)`,strokeWidth:1},t)),!l&&u.map((n,r)=>{let i=r/f*2*Math.PI-Math.PI/2;return T(`text`,{x:e(a+Math.cos(i)*(s+18)),y:e(o+Math.sin(i)*(s+18)),fontSize:11,textAnchor:`middle`,dominantBaseline:`middle`,fill:`var(--cascivo-color-text-subtle)`,children:t[r]},r)}),n.map((e,t)=>{let n=Hn(e.values,d,a,o,s).map(e=>`${e.x},${e.y}`).join(` `),r=Bn[t%Bn.length]??`var(--cascivo-chart-1)`;return T(`polygon`,{points:n,fill:r,fillOpacity:.15,stroke:r,strokeWidth:2},e.id)})]})}})}var Wn=[`var(--cascivo-gray-200)`,`var(--cascivo-gray-300)`,`var(--cascivo-gray-400)`];function Gn({value:e,target:t,ranges:n,label:r,min:a=0,max:o,width:s=300,height:c=40,className:l}){v();let u=[...n].sort((e,t)=>e-t),d=i([a,o??u[u.length-1]??(Math.max(e,t)*1.2||1)],[0,s]),f=c*.35,p=(c-f)/2,m=c*.7,h=(c-m)/2;return E(`figure`,{className:l,"aria-label":`${r}: value ${e}, target ${t}`,style:{margin:0},children:[T(Q,{title:`${r} bullet chart`,width:s,height:c,plain:!0,tooltip:{points:[{id:`measure`,cx:d.map(e),cy:c/2,label:r,value:e}]},children:()=>E(w,{children:[u.map((e,t)=>{let n=t===0?a:u[t-1]??a,r=d.map(e)-d.map(n);return T(`rect`,{x:d.map(n),y:0,width:Math.max(0,r),height:c,fill:Wn[t%Wn.length]??`var(--cascivo-gray-200)`},t)}),T(`rect`,{x:d.map(a),y:p,width:Math.max(0,d.map(e)-d.map(a)),height:f,fill:`var(--cascivo-chart-1)`}),T(`line`,{x1:d.map(t),y1:h,x2:d.map(t),y2:h+m,stroke:`var(--cascivo-color-text)`,strokeWidth:2.5})]})}),T(`figcaption`,{style:{fontSize:12},children:r})]})}var Kn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function qn({data:t,title:n,description:r,size:i,width:o,height:s,max:c,sweep:l=270,centerValue:u,centerLabel:d,centerSlot:f,tooltip:p,legend:m,className:h,plain:_}){v();let y=g(new Set),b=o??i,x=s??i??(_?48:300),S=_?!1:m??t.length>1,C=t.length>0,w=c??Math.max(1,...t.map(e=>e.value)),D=Math.min(360,Math.max(0,l))*Math.PI/180,O=-D/2,k=(e,n)=>{let r=e/2,i=n/2,a=Math.min(r,i)-8,o=a*.32,s=t.filter(e=>!y.value.has(e.id));return{cx:r,cy:i,maxR:a,holeR:o,span:s.length>0?(a-o)/s.length:0,visible:s}},A=({width:t,height:n})=>{if(p===!1||!C)return;let{cx:r,cy:i,maxR:a,span:o,visible:s}=k(t,n);return{points:s.map((t,n)=>{let s=a-n*o,c=(s+(s-o*.7))/2,l=O+D*Math.min(1,t.value/w);return{id:t.id,cx:e(r+Math.sin(l)*c),cy:e(i-Math.cos(l)*c),label:t.label,value:t.value,seriesId:t.id,percent:w>0?t.value/w*100:0,color:t.color??Kn[n%Kn.length]}})}},j=E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Label`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:t.map(e=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.value})]},e.id))})]}),M=u!=null||d!=null||f!=null;return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:n,description:r,width:b,height:x,fallback:j,className:h,"data-state":C?void 0:`empty`,plain:_,tooltip:p!==!1&&C?A:void 0,children:({width:e,height:t})=>{let{cx:n,cy:r,maxR:i,holeR:o,span:s,visible:c}=k(e,t);return E(`g`,{children:[c.map((e,t)=>{let o=i-t*s,c=o-s*.7,l=e.color??Kn[t%Kn.length],u=Math.max(0,Math.min(1,e.value/w)),d=O+D*u;return E(`g`,{"data-series":e.id,children:[T(`path`,{d:a(n,r,o,c,O,O+D),fill:`var(--cascivo-chart-grid)`,fillOpacity:.35}),u>0&&T(`path`,{d:a(n,r,o,c,O,d),fill:l})]},e.id)}),!_&&M&&(f==null?E(`g`,{"data-center":``,children:[u!=null&&T(`text`,{x:n,y:d==null?r:r-8,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`1.5rem`,fontWeight:700,fill:`var(--cascivo-color-foreground)`,children:u}),d!=null&&T(`text`,{x:n,y:u==null?r:r+14,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`0.8125rem`,fill:`var(--cascivo-color-foreground-muted)`,children:d})]}):T(`foreignObject`,{x:n-o,y:r-o,width:o*2,height:o*2,"data-center-slot":``,children:T(`div`,{style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,textAlign:`center`},children:f})}))]})}}),S&&T(Yt,{series:t.map((e,t)=>({id:e.id,label:e.label,color:e.color??Kn[t%Kn.length]})),hidden:y})]})}var Jn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Yn({data:e,title:t,description:n,width:r,height:a,showConversion:o=!1,tooltip:s,className:c,plain:l}){v();let u=l?Be:ze,d=a??(l?48:320),f=e.length>0,p=e[0]?.value??0,m=Math.max(1,...e.map(e=>e.value));return T(Q,{title:t,description:n,width:r,height:d,fallback:E(`table`,{children:[T(`caption`,{children:t}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Stage`}),T(`th`,{children:`Value`}),T(`th`,{children:`% of first`})]})}),T(`tbody`,{children:e.map(e=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.value}),E(`td`,{children:[p>0?Math.round(e.value/p*100):0,`%`]})]},e.id))})]}),className:c,"data-state":f?void 0:`empty`,plain:l,tooltip:s!==!1&&f?({width:t,height:n})=>{if(s===!1||!f)return;let r=t-u.left-u.right,i=(n-u.top-u.bottom)/e.length;return{points:e.map((e,t)=>({id:e.id,cx:u.left+r/2,cy:u.top+t*i+i/2,label:e.label,value:e.value,seriesId:e.id,percent:p>0?e.value/p*100:0,color:e.color??Jn[t%Jn.length]})),format:e=>`${e.label}: ${e.value} (${Math.round(e.percent??0)}%)`}}:void 0,children:({width:t,height:n})=>{let r=t-u.left-u.right,a=n-u.top-u.bottom;if(r<=0||e.length===0)return null;let s=a/e.length,c=i([0,m],[0,r]),d=e=>c.map(e)/2,f=u.left+r/2;return T(`g`,{children:e.map((t,n)=>{let r=e[n+1],i=d(t.value),a=d(r?r.value:t.value),c=u.top+n*s,m=c+s*(r?1:.9),h=t.color??Jn[n%Jn.length],g=[[f-i,c],[f+i,c],[f+a,m],[f-a,m]].map(e=>e.join(`,`)).join(` `),_=p>0?Math.round(t.value/p*100):0;return E(`g`,{"data-series":t.id,children:[T(`polygon`,{points:g,fill:h,fillOpacity:.85}),!l&&T(Tt,{x:f,y:c+s/2,text:o?`${t.label} · ${t.value} (${_}%)`:`${t.label} · ${t.value}`,tone:`muted`})]},t.id)})})}})}var Xn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Zn({series:e,categories:n,title:a,description:o,offset:s=`silhouette`,curve:c=`basis`,width:l,height:u,legend:d,tooltip:f,className:p,plain:m,format:h}){v();let _=g(new Set),y=m?Be:ze,b=u??(m?48:300),x=m?!1:d??e.length>1,S=n.length>0&&e.length>0,C=W(e.map(e=>e.values),s),[w,D]=G(C);return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:a,description:o,width:l,height:b,fallback:E(`table`,{children:[T(`caption`,{children:a}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Category`}),e.map(e=>T(`th`,{children:e.label},e.id))]})}),T(`tbody`,{children:n.map((t,n)=>E(`tr`,{children:[T(`td`,{children:String(t)}),e.map(e=>T(`td`,{children:e.values[n]??``},e.id))]},String(t)))})]}),className:p,"data-state":S?void 0:`empty`,plain:m,tooltip:f&&S?({width:r,height:a})=>{if(!f||!S)return;let o=r-y.left-y.right,s=a-y.top-y.bottom,c=t(n.map(String),[0,o],0),l=i([w,D],[s,0]);return{points:e.flatMap((e,t)=>{if(_.value.has(e.id))return[];let r=C[t];return n.map((n,i)=>{let a=(r[i][0]+r[i][1])/2;return{id:`${e.id}-${i}`,cx:y.left+(c.map(String(n))??0)+c.bandwidth/2,cy:y.top+l.map(a),label:`${e.label} · ${String(n)}`,value:e.values[i]??0,seriesId:e.id,color:e.color??Xn[t%Xn.length]}})})}}:void 0,children:({width:a,height:o})=>{let s=a-y.left-y.right,l=o-y.top-y.bottom;if(s<=0||!S)return null;let u=t(n.map(String),[0,s],0),d=i([w,D],[l,0]),f=e=>(u.map(String(n[e]))??0)+u.bandwidth/2;return E(`g`,{transform:`translate(${y.left},${y.top})`,children:[e.map((e,t)=>{if(_.value.has(e.id))return null;let i=C[t],a=e.color??Xn[t%Xn.length],o=n.map((e,t)=>[f(t),d.map(i[t][1])]),s=n.map((e,t)=>[f(t),d.map(i[t][0])]);return T(`path`,{d:`${r(o,c)}${r([...s].reverse(),c).replace(/^M/,`L`)}Z`,fill:a,fillOpacity:.85,"data-series":e.id},e.id)}),!m&&T($,{scale:u,orientation:`x`,length:s,transform:`translate(0,${l})`,...h?{format:h}:{}})]})}}),x&&T(Yt,{series:e.map((e,t)=>({id:e.id,label:e.label,color:e.color??Xn[t%Xn.length]})),hidden:_})]})}var Qn=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function $n({data:t,title:n,description:r,size:i,width:o,height:s,tooltip:c,className:l,plain:u}){v();let d=o??i,f=s??i??(u?48:300),p=K(t),m=p>0,h=ie(t),g=Math.max(1,ae(h));return T(Q,{title:n,description:r,width:d,height:f,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Path`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:h.filter(e=>e.depth>0).map((e,t)=>E(`tr`,{children:[T(`td`,{children:e.node.label}),T(`td`,{children:e.value})]},`${e.node.label}-${t}`))})]}),className:l,"data-state":m?void 0:`empty`,plain:u,tooltip:c&&m?({width:t,height:n})=>{if(!c||!m)return;let r=t/2,i=n/2,a=(Math.min(r,i)-8)/g;return{points:h.filter(e=>e.depth>0).map((t,n)=>{let o=(t.a0+t.a1)/2,s=(t.depth-.5)*a;return{id:`${t.node.label}-${n}`,cx:e(r+Math.sin(o)*s),cy:e(i-Math.cos(o)*s),label:t.node.label,value:t.value,percent:p>0?t.value/p*100:0,color:t.node.color??Qn[n%Qn.length]}}),format:e=>`${e.label}: ${e.value} (${Math.round(e.percent??0)}%)`}}:void 0,children:({width:e,height:t})=>{let n=e/2,r=t/2,i=(Math.min(n,r)-8)/g;return T(`g`,{children:h.filter(e=>e.depth>0).map((e,t)=>{let o=(e.depth-1)*i,s=e.depth*i,c=e.node.color??Qn[t%Qn.length];return T(`path`,{d:a(n,r,s,o,e.a0,e.a1),fill:c,fillOpacity:1-(e.depth-1)*.18,stroke:`var(--cascivo-color-surface)`,strokeWidth:1,"data-depth":e.depth},`${e.node.label}-${t}`)})})}})}var er=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function tr({nodes:e,links:t,title:n,description:r,width:i,height:a,tooltip:o,className:s,plain:c}){v();let l=c?Be:ze,u=a??(c?48:320),d=e.length>0&&t.length>0,f=(t,n)=>e.find(e=>e.id===t)?.color??er[n%er.length];return T(Q,{title:n,description:r,width:i,height:u,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`From`}),T(`th`,{children:`To`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:t.map((t,n)=>E(`tr`,{children:[T(`td`,{children:e.find(e=>e.id===t.source)?.label??t.source}),T(`td`,{children:e.find(e=>e.id===t.target)?.label??t.target}),T(`td`,{children:t.value})]},n))})]}),className:s,"data-state":d?void 0:`empty`,plain:c,tooltip:o&&d?({width:n,height:r})=>{if(!o||!d)return;let{nodes:i}=q(e,t,{width:n-l.left-l.right,height:r-l.top-l.bottom});return{points:i.map((e,t)=>({id:e.id,cx:l.left+(e.x0+e.x1)/2,cy:l.top+(e.y0+e.y1)/2,label:e.label,value:e.value,color:f(e.id,t)}))}}:void 0,children:({width:n,height:r})=>{let i=n-l.left-l.right,a=r-l.top-l.bottom;if(i<=0||!d)return null;let{nodes:o,links:s}=q(e,t,{width:i,height:a});return E(`g`,{transform:`translate(${l.left},${l.top})`,children:[s.map((e,t)=>T(`path`,{d:J(e),fill:f(e.source.id,o.indexOf(e.source)),fillOpacity:.32,"data-link":``},t)),o.map((e,t)=>E(`g`,{"data-node":e.id,children:[T(`rect`,{x:e.x0,y:e.y0,width:e.x1-e.x0,height:Math.max(1,e.y1-e.y0),fill:f(e.id,t),rx:1}),!c&&T(`text`,{x:e.x0<i/2?e.x1+4:e.x0-4,y:(e.y0+e.y1)/2,dominantBaseline:`central`,textAnchor:e.x0<i/2?`start`:`end`,fontSize:`0.6875rem`,fill:`var(--cascivo-color-foreground)`,children:e.label})]},e.id))]})}})}var nr=864e5,rr=2,ir=7;function ar(e,t,n,r){let i=(e-(n-1)*rr)/n,a=(t-(ir-1)*rr+1)/ir;return Math.max(2,Math.min(i,r===void 0?a:Math.min(a,r)))}var or=e=>e instanceof Date?e:new Date(e),sr=e=>e.toISOString().slice(0,10);function cr(e){let t=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return t.setUTCDate(t.getUTCDate()-t.getUTCDay()),t}function lr({data:e,title:t,description:n,from:r,to:i,width:a,height:o,maxCellSize:s,tooltip:c,className:l,plain:u,visualMap:d}){v();let f=e.length>0,p=g([d?.min??0,d?.max??1]),m=g(new Set),h=new Map;for(let t of e)h.set(sr(or(t.day)),t.value);let _=e.map(e=>or(e.day)),y=cr(r?or(r):_.reduce((e,t)=>t<e?t:e,_[0]??new Date)),b=i?or(i):_.reduce((e,t)=>t>e?t:e,_[0]??new Date),x=f?Math.max(1,Math.ceil((b.getTime()-y.getTime())/nr/7)):1,S=Math.max(1,...e.map(e=>e.value)),C=o??(u?48:160),w=[];for(let e=0;e<x;e++)for(let t=0;t<7;t++){let n=new Date(y.getTime()+(e*7+t)*nr);n>b||w.push({col:e,row:t,date:n,value:h.get(sr(n))??0})}let D=T(Q,{title:t,description:n,width:a,height:C,fallback:E(`table`,{children:[T(`caption`,{children:t}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Day`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:e.map((e,t)=>E(`tr`,{children:[T(`td`,{children:sr(or(e.day))}),T(`td`,{children:e.value})]},t))})]}),className:l,"data-state":f?void 0:`empty`,plain:u,tooltip:c&&f?({width:e,height:t})=>{if(!c||!f)return;let n=rr,r=ar(e,t,x,s);return{points:w.map((e,t)=>({id:`${sr(e.date)}-${t}`,cx:e.col*(r+n)+r/2,cy:e.row*(r+n)+r/2,label:sr(e.date),value:e.value})),format:e=>`${e.label}: ${e.value}`}}:void 0,children:({width:e,height:t})=>{let n=rr,r=ar(e,t,x,s);return T(`g`,{children:w.map((e,t)=>{let i=d?Gt(e.value,d).color:void 0,a=d?Kt(e.value,d,p.value,m.value):!0;return T(`rect`,{x:e.col*(r+n),y:e.row*(r+n),width:r-1,height:r-1,rx:1.5,fill:i??`var(--cascivo-chart-2)`,fillOpacity:d?e.value>0&&a?1:.08:e.value>0?.15+.85*(e.value/S):.06,"data-day":sr(e.date)},t)})})}});return!d||!f?D:E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D,T(qt,{options:d,range:p,hidden:m,label:t})]})}function ur({data:e,title:n,description:r,width:a,height:o,yTicks:s=5,upColor:c=`var(--cascivo-chart-2)`,downColor:l=`var(--cascivo-chart-4)`,volume:u,tooltip:d,className:f,plain:p,annotations:m,brush:h,dataZoom:y,zoom:x,syncId:S,tooltipMode:C,format:D}){v();let O=p?Be:ze,k=o??(p?64:320),A=e.length,j=(h||y||x||S!==void 0)&&A>0,M=g([0,Math.max(0,A-1)]),N=b(null);S&&!N.current&&(N.current=lt(S)),_(()=>()=>{S&&ut(S)}),_(()=>{let e=N.current;if(!e)return;let t=e.window.value,n=M.peek();t&&(t[0]!==n[0]||t[1]!==n[1])&&(M.value=t)}),_(()=>{let e=N.current;if(!e)return;let t=M.value,n=e.window.peek();(!n||n[0]!==t[0]||n[1]!==t[1])&&(e.window.value=t)});let P=j?e.slice(M.value[0],M.value[1]+1):e,F=P.length>0,I=F?Math.min(...P.map(e=>e.low)):0,ee=F?Math.max(...P.map(e=>e.high)):1,L=F?Math.max(1,...P.map(e=>e.volume??0)):1,R=P.map(e=>e.t);return E(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[T(Q,{title:n,description:r,width:a,height:k,fallback:E(`table`,{children:[T(`caption`,{children:n}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Period`}),T(`th`,{children:`Open`}),T(`th`,{children:`High`}),T(`th`,{children:`Low`}),T(`th`,{children:`Close`})]})}),T(`tbody`,{children:P.map((e,t)=>E(`tr`,{children:[T(`td`,{children:e.t}),T(`td`,{children:e.open}),T(`td`,{children:e.high}),T(`td`,{children:e.low}),T(`td`,{children:e.close})]},t))})]}),className:f,"data-state":F?void 0:`empty`,plain:p,tooltip:d!==!1&&F?({width:e,height:n})=>{if(d===!1||!F)return;let r=e-O.left-O.right,a=n-O.top-O.bottom;if(r<=0)return;let o=t(R,[0,r],.3),s=a-(u?Math.min(a*.2,60):0),c=i([I,ee],[s,0]);if(C===`axis`)return{points:P.map((e,t)=>({id:`c-${t}`,cx:O.left+(o.map(e.t)??0)+o.bandwidth/2,cy:O.top+c.map(e.high),label:e.t,value:e.close,segments:[{label:`O`,value:e.open},{label:`H`,value:e.high},{label:`L`,value:e.low},{label:`C`,value:e.close}]})),mode:`axis`,format:e=>{let t=P[parseInt(e.id.split(`-`)[1]??`0`,10)];return t?`${t.t} — O ${t.open} H ${t.high} L ${t.low} C ${t.close}`:`${e.label}: ${e.value}`}};let l=i([I,ee],[a,0]);return{points:P.map((e,t)=>({id:`c-${t}`,cx:O.left+(o.map(e.t)??0)+o.bandwidth/2,cy:O.top+l.map(e.high),label:e.t,value:e.close})),format:e=>{let t=P[parseInt(e.id.split(`-`)[1]??`0`,10)];return t?`${t.t} — O ${t.open} H ${t.high} L ${t.low} C ${t.close}`:`${e.label}: ${e.value}`}}}:void 0,zoom:x&&A>1?{window:M,count:A}:void 0,onRestore:j?()=>{M.value=[0,Math.max(0,A-1)]}:void 0,children:({width:e,height:n})=>{let r=e-O.left-O.right,a=n-O.top-O.bottom;if(r<=0||!F)return null;let o=t(R,[0,r],.3),d=i([I,ee],[a,0]),f=u?Math.min(a*.2,60):0,h=a-f,g=i([I,ee],[h,0]),_=o.bandwidth;return E(`g`,{transform:`translate(${O.left},${O.top})`,children:[!p&&T(gt,{scale:d,orientation:`y`,length:r,tickCount:s}),P.map((e,t)=>{let n=(o.map(e.t)??0)+_/2,r=e.close>=e.open,i=r?c:l,a=g.map(e.open),s=g.map(e.close),d=Math.min(a,s),p=Math.max(1,Math.abs(s-a));return E(`g`,{"data-candle":r?`up`:`down`,children:[T(`line`,{x1:n,x2:n,y1:g.map(e.high),y2:g.map(e.low),stroke:i,strokeWidth:1,"data-wick":``}),T(`rect`,{x:n-_/2,y:d,width:_,height:p,fill:i,"data-body":``}),u&&e.volume!==void 0&&T(`rect`,{x:n-_/2,y:h+(f-e.volume/L*f),width:_,height:e.volume/L*f,fill:i,fillOpacity:.4,"data-volume":``})]},t)}),!p&&xt(m,{xScale:o,yScale:g,innerW:r,innerH:h}),!p&&E(w,{children:[T($,{scale:o,orientation:`x`,length:r,transform:`translate(0,${a})`,...D?{format:D}:{}}),T($,{scale:d,orientation:`y`,length:h,tickCount:s})]})]})}}),h&&!y&&A>1&&T(Lt,{count:A,window:M,label:`Time range`}),y&&A>1&&T(Rt,{count:A,window:M,label:`Time range`})]})}var dr=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function fr({data:e,title:t,description:n,mode:i=`bar`,width:o,height:s,rings:c=4,max:l,tooltip:u,className:d,plain:f}){v();let p=s??320,m=e.length>0,h=e.map(e=>e.label),g=l??(m?Math.max(1,...e.map(e=>e.value)):1),_=ve(h),y=E(`table`,{children:[T(`caption`,{children:t}),T(`thead`,{children:E(`tr`,{children:[T(`th`,{children:`Category`}),T(`th`,{children:`Value`})]})}),T(`tbody`,{children:e.map((e,t)=>E(`tr`,{children:[T(`td`,{children:e.label}),T(`td`,{children:e.value})]},t))})]}),b=(e,t)=>{let n=e/2,r=t/2,i=Math.max(0,Math.min(e,t)/2-(f?6:28));return{cx:n,cy:r,outerR:i,rScale:ye([0,g],[0,i])}};return T(Q,{title:t,description:n,width:o,height:p,fallback:y,className:d,"data-state":m?void 0:`empty`,plain:f,tooltip:u!==!1&&m?({width:t,height:n})=>{if(u===!1||!m)return;let{cx:r,cy:i,rScale:a}=b(t,n);return{points:e.map((e,t)=>{let n=_.center(e.label)??0,[o,s]=_e(r,i,a.map(e.value),n);return{id:`p-${t}`,cx:o,cy:s,label:e.label,value:e.value}}),format:e=>`${e.label}: ${e.value}`}}:void 0,children:({width:t,height:n})=>{if(!m)return null;let{cx:o,cy:s,outerR:l,rScale:u}=b(t,n),d=Array.from({length:c},(e,t)=>l*(t+1)/c),p=e.map(e=>{let t=_.center(e.label)??0;return _e(o,s,u.map(e.value),t)});return E(`g`,{children:[!f&&d.map((e,t)=>T(`circle`,{cx:o,cy:s,r:e,fill:`none`,stroke:`var(--cascivo-chart-grid)`,strokeOpacity:.4,"data-ring":``},t)),i===`bar`?e.map((e,t)=>{let n=_.map(e.label)??0,r=_.bandwidth*.1;return T(`path`,{d:a(o,s,u.map(e.value),0,n+r,n+_.bandwidth-r),fill:e.color??dr[t%dr.length],fillOpacity:.85,"data-wedge":``},t)}):(()=>{let t=[...p,p[0]],n=e[0]?.color??dr[0];return E(w,{children:[i===`area`&&T(`path`,{d:`${r(t,`linear`)}Z`,fill:n,fillOpacity:.25,stroke:`none`,"data-area":``}),T(`path`,{d:r(t,`linear`),fill:`none`,stroke:n,strokeWidth:2,"data-polyline":``})]})})(),!f&&e.map((e,t)=>{let n=_.center(e.label)??0,[r,i]=_e(o,s,l+12,n);return T(`text`,{x:r,y:i,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`0.75rem`,fill:`var(--cascivo-color-foreground-muted)`,"data-angle-label":``,children:e.label},t)})]})}})}var pr=Math.PI/180;function mr({value:e,min:t=0,max:n=100,thresholds:r,unit:i=``,sweep:o=270,ticks:s=5,title:c,description:l,width:u,height:d,className:f,plain:p}){v();let m=d??240,h=n-t||1,g=Math.max(t,Math.min(n,e)),_=(g-t)/h,y=o*pr,b=-y/2,x=e=>b+(e-t)/h*y;return T(Q,{title:c,description:l,width:u,height:m,fallback:E(`table`,{children:[T(`caption`,{children:c}),E(`tbody`,{children:[E(`tr`,{children:[T(`th`,{children:`Value`}),E(`td`,{children:[e,i]})]}),E(`tr`,{children:[T(`th`,{children:`Range`}),E(`td`,{children:[t,`–`,n]})]})]})]}),className:f,plain:p,children:({width:o,height:c})=>{let l=o/2,u=c/2,d=Math.max(0,Math.min(o,c)/2-(p?6:24)),f=Math.max(6,d*.18),m=d-f,v=m-4,S=r&&r.length>0?r:[{upTo:g,color:`var(--cascivo-color-accent)`}],C=t,w=Array.from({length:s+1},(e,n)=>t+h*n/s);return E(`g`,{children:[T(`path`,{d:a(l,u,d,m,b,b+y),fill:`var(--cascivo-chart-grid)`,fillOpacity:.25,"data-track":``}),S.map((e,t)=>{let r=x(C),i=x(Math.min(n,e.upTo));return C=e.upTo,T(`path`,{d:a(l,u,d,m,r,i),fill:e.color,"data-zone":``},t)}),!p&&w.map((e,t)=>{let n=x(e),[r,i]=_e(l,u,m-2,n),[a,o]=_e(l,u,m-8,n),[s,c]=_e(l,u,m-18,n);return E(`g`,{children:[T(`line`,{x1:r,y1:i,x2:a,y2:o,stroke:`var(--cascivo-color-foreground-muted)`,strokeWidth:1,"data-tick":``}),T(`text`,{x:s,y:c,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`0.625rem`,fill:`var(--cascivo-color-foreground-muted)`,children:Math.round(e)})]},t)}),(()=>{let[e,t]=_e(l,u,v,x(g));return T(`line`,{x1:l,y1:u,x2:e,y2:t,stroke:`var(--cascivo-color-foreground)`,strokeWidth:2.5,strokeLinecap:`round`,"data-needle":``,"data-frac":_.toFixed(3)})})(),T(`circle`,{cx:l,cy:u,r:Math.max(3,f*.25),fill:`var(--cascivo-color-foreground)`}),E(`text`,{x:l,y:u+d*.5,textAnchor:`middle`,fontSize:`1.25rem`,fontWeight:600,fill:`var(--cascivo-color-foreground)`,"data-readout":``,children:[e,i]})]})}})}export{Ve as AXIS_CHAR_PX,We as AXIS_LINE_PX,un as AreaChart,$ as Axis,mn as BarChart,kn as Boxplot,Lt as Brush,Nn as BubbleChart,Gn as Bullet,lr as CalendarHeatmap,ur as Candlestick,Ye as CanvasLayer,At as ChartDefs,Q as ChartFrame,It as ChartText,In as ComboChart,ze as DEFAULT_MARGINS,Tt as DataLabel,Rt as DataZoom,Yn as Funnel,mr as Gauge,Mt as Glyph,gt as GridLines,Ln as Heatmap,Dn as Histogram,En as Kpi,Yt as Legend,on as LineChart,Cn as Meter,Be as PLAIN_MARGINS,_n as PieChart,fr as Polar,Un as Radar,qn as RadialBar,tr as Sankey,yn as ScatterChart,bn as Sparkline,Zn as Stream,$n as Sunburst,nt as Toolbox,zn as Treemap,qt as VisualMap,dt as _syncGroupCount,we as aggregate,ve as angleBand,St as annotationSummary,a as arcPath,s as areaPath,Ge as autoLabelStride,t as bandScale,Te as bin,ne as binValues,Le as bindStream,z as boxStats,R as cellPath,Pe as decimate,Z as divergingRamp,ot as download,Ae as encode,je as encodeCategory,B as extent,kt as fillFor,be as filter,lt as getSyncGroup,jt as glyphPath,Dt as gradientId,et as isZoomed,He as leftMarginForLabels,r as linePath,i as linearScale,J as linkPath,D as logScale,Me as lttb,Gt as mapVisual,ae as maxDepth,Ne as minmax,F as nearestIndex,u as niceTicks,$e as panWindow,ie as partition,Ot as patternId,Wt as pieceIndex,_e as polarPoint,e as quantize,ye as radiusScale,ge as rampLightness,me as rampOf,he as rampStops,Oe as regression,ut as releaseSyncGroup,bt as renderAnnotation,xt as renderAnnotations,Xe as resolveColor,wt as resolveLabels,Ue as rightMarginForLabels,q as sankeyLayout,pe as sequentialRamp,it as serializeSvg,Se as sort,o as splitDefined,n as sqrtScale,U as squarify,c as stackSeries,G as streamExtent,W as streamLayout,K as sumValue,at as svgToPngBlob,N as timeScale,P as toStackedSeries,Re as useChartSize,Ie as useStreamSeries,Kt as visualVisible,L as voronoiCells,I as voronoiFind,Ft as wrapText,Qe as zoomWindow};
|
|
3
|
+
import{a as e,c as t,d as n,i as r,l as i,n as a,o,r as s,s as c,t as l,u}from"./chart-frame.module-B498IKO9.js";import{computed as d,createStreamBuffer as f,sentimentOf as p,signal as m,useComputed as h,useSignal as g,useSignalEffect as _,useSignals as v}from"@cascivo/core";import{useId as b,useRef as S}from"react";import{builtin as C,currentLocale as w,t as T}from"@cascivo/i18n";import{Fragment as E,jsx as D,jsxs as O}from"react/jsx-runtime";function logScale(e,t){let[n,r]=e;if(n<=0||r<=0)throw Error(`logScale: domain must be strictly positive, got [${n}, ${r}]`);let[i,a]=t,o=Math.log10(n),s=Math.log10(r),c=s-o;return{domain:e,range:t,map:e=>c===0?i:i+(Math.log10(e)-o)/c*(a-i),invert:e=>10**(o+(e-i)/(a-i)*c),ticks:()=>{let e=Math.ceil(o),t=Math.floor(s),i=[];for(let n=e;n<=t;n++)i.push(10**n);if(i.length<3){let e=[];for(let t=Math.floor(o);t<=Math.ceil(s);t++)for(let i of[2,5]){let a=i*10**t;a>n&&a<r&&e.push(a)}i.push(...e),i.sort((e,t)=>e-t)}return i.filter(e=>e>=n&&e<=r)}}}var k={minute:6e4,hour:36e5,day:864e5,week:6048e5,month:26298e5,quarter:78894e5,year:315576e5},A=[{unit:`minute`,step:1},{unit:`minute`,step:5},{unit:`minute`,step:15},{unit:`minute`,step:30},{unit:`hour`,step:1},{unit:`hour`,step:2},{unit:`hour`,step:3},{unit:`hour`,step:6},{unit:`hour`,step:12},{unit:`day`,step:1},{unit:`day`,step:2},{unit:`week`,step:1},{unit:`month`,step:1},{unit:`month`,step:3},{unit:`year`,step:1},{unit:`year`,step:2},{unit:`year`,step:5},{unit:`year`,step:10}];function floorToInterval(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth(),a=e.getUTCDate();return t===`year`?new Date(Date.UTC(Math.floor(r/n)*n,0,1)):t===`quarter`?new Date(Date.UTC(r,Math.floor(i/3)*3,1)):t===`month`?new Date(Date.UTC(r,Math.floor(i/n)*n,1)):t===`week`?new Date(Date.UTC(r,i,a-e.getUTCDay())):t===`day`?new Date(Date.UTC(r,i,a)):t===`hour`?new Date(Date.UTC(r,i,a,Math.floor(e.getUTCHours()/n)*n)):new Date(Date.UTC(r,i,a,e.getUTCHours(),Math.floor(e.getUTCMinutes()/n)*n))}function addInterval(e,t,n){let r=e.getUTCFullYear(),i=e.getUTCMonth();return t===`year`?new Date(Date.UTC(r+n,i,1)):t===`quarter`?new Date(Date.UTC(r,i+3*n,1)):t===`month`?new Date(Date.UTC(r,i+n,1)):new Date(e.getTime()+k[t]*n)}function formatForStep(e){return e===`minute`?{hour:`numeric`,minute:`2-digit`}:e===`hour`?{hour:`numeric`}:e===`day`||e===`week`?{month:`short`,day:`numeric`}:e===`month`||e===`quarter`?{month:`short`,year:`numeric`}:{year:`numeric`}}function timeScale(e,t){let[n,r]=e,[i,a]=t,o=r.getTime()-n.getTime();function pickStep(e){let t=Math.max(2,e),n=A[A.length-1],r=1/0;for(let e of A){let i=o/(k[e.unit]*e.step);if(i<1.5)continue;let a=Math.abs(Math.log(i/t));a<r&&(r=a,n=e)}return n}return{domain:e,range:t,map:e=>o===0?i:i+(e.getTime()-n.getTime())/o*(a-i),invert:e=>new Date(n.getTime()+(e-i)/(a-i)*o),tickInterval:(e=5)=>pickStep(e).unit,tickFormat:(e=5)=>formatForStep(pickStep(e).unit),ticks:(e=5)=>{let{unit:t,step:i}=pickStep(e),a=floorToInterval(n,t,i),o=[],s=a.getTime()>=n.getTime()?a:addInterval(a,t,i),c=0;for(;s.getTime()<=r.getTime()&&c++<500;)o.push(s),s=addInterval(s,t,i);return o}}}function toStackedSeries(e){let t=[],n=new Map;for(let r of e)for(let e of r.segments)n.has(e.key)?n.get(e.key)==null&&e.color!=null&&n.set(e.key,e.color):(t.push(e.key),n.set(e.key,e.color));return{series:t.map(t=>{let r=n.get(t);return{id:t,label:t,...r!=null&&{color:r},data:e.map(e=>({x:e.label,y:e.segments.find(e=>e.key===t)?.value??0}))}}),x:e=>e.x,y:e=>e.y}}function nearestIndex(e,t){if(e.length===0)return-1;if(e.length===1)return 0;let n=0,r=e.length-1;for(;n<r;){let i=n+r>>1;e[i]<t?n=i+1:r=i}return n>0&&Math.abs(e[n-1]-t)<Math.abs(e[n]-t)?n-1:n}function voronoiFind(e,t,n){let r=-1,i=1/0;for(let a=0;a<e.length;a++){let o=e[a][0]-t,s=e[a][1]-n,c=o*o+s*s;c<i&&(i=c,r=a)}return r}function clipHalfPlane(e,t,n,r,i){if(e.length===0)return e;let a=[],side=e=>(e[0]-r)*t+(e[1]-i)*n;for(let t=0;t<e.length;t++){let n=e[t],r=e[(t+1)%e.length],i=side(n),o=side(r);if(i<=0&&a.push(n),i<0&&o>0||i>0&&o<0){let e=i/(i-o);a.push([n[0]+e*(r[0]-n[0]),n[1]+e*(r[1]-n[1])])}}return a}function voronoiCells(e,t){let n=[[t.x0,t.y0],[t.x1,t.y0],[t.x1,t.y1],[t.x0,t.y1]];return e.map((t,r)=>{let i=n.slice();for(let n=0;n<e.length&&i.length>0;n++){if(n===r)continue;let a=e[n];i=clipHalfPlane(i,a[0]-t[0],a[1]-t[1],(t[0]+a[0])/2,(t[1]+a[1])/2)}return i})}function cellPath(e){return e.length===0?``:`M${e.map(e=>`${e[0]},${e[1]}`).join(`L`)}Z`}function iqr(e){let t=e.length,n=e[Math.floor(t*.25)]??0;return(e[Math.floor(t*.75)]??0)-n}function binValues(e,t){if(e.length===0)return[];let n=[...e].sort((e,t)=>e-t),r=n.length,i=n[0]??0,a=n[r-1]??0;if(i===a)return[{x0:i,x1:i+1,count:r}];let o;if(t!==void 0&&t>0)o=t;else{let e=2*iqr(n)*r**(-1/3);o=Math.ceil(e>0?(a-i)/e:Math.sqrt(r)),o=Math.max(1,Math.min(o,200))}let s=(a-i)/o;if(!Number.isFinite(s)||s<=0)return[{x0:i,x1:a,count:r}];let c=Array.from({length:o},(e,t)=>({x0:i+t*s,x1:t===o-1?a:i+(t+1)*s,count:0}));for(let t of e){let e=Math.floor((t-i)/s),n=c[Number.isFinite(e)?Math.min(Math.max(e,0),o-1):o-1];n&&n.count++}return c}function boxStats(e){if(e.length===0)return{min:0,q1:0,median:0,q3:0,max:0,outliers:[]};let t=[...e].sort((e,t)=>e-t),n=t.length,median=e=>{let t=Math.floor(e.length/2);return e.length%2==0?((e[t-1]??0)+(e[t]??0))/2:e[t]??0},r=median(t.slice(0,Math.floor(n/2))),i=median(t.slice(Math.ceil(n/2))),a=median(t),o=i-r,s=r-1.5*o,c=i+1.5*o,l=t.filter(e=>e>=s&&e<=c),u=t.filter(e=>e<s||e>c);return{min:l[0]??t[0]??0,q1:r,median:a,q3:i,max:l[l.length-1]??t[n-1]??0,outliers:u}}function extent(e){if(e.length===0)return[0,1];let t=e[0]??0,n=e[0]??0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return[t,n]}function worst(e,t,n){let r=Math.max(...e),i=Math.min(...e);return Math.max(t*t*r/(n*n),n*n/(t*t*i))}function layoutRow(e,t,n,r,i,a,o){let s=e.reduce((e,t)=>e+t,0),c=t,l=n;for(let t=0;t<e.length;t++){let n=e[t]??0,u=a[t]??``;if(r>=i){let e=(s>0?n/s:0)*r;o.push({id:u,x:c,y:l,w:e,h:i}),c+=e}else{let e=(s>0?n/s:0)*i;o.push({id:u,x:c,y:l,w:r,h:e}),l+=e}}}function squarifyRecurse(e,t,n,r,i,a){if(e.length===0||r<=0||i<=0)return;let o=e.reduce((e,t)=>e+t.value,0);if(o===0)return;let s=r*i,c=e.map(e=>e.value/o*s),l=e.map(e=>e.id),u=[],d=[],f=Math.min(r,i),p=0,m=0;for(;m<c.length;){let o=c[m]??0,h=l[m]??``,g=[...u,o],_=p+o;if(u.length===0||worst(g,f,_)<=worst(u,f,p))u=g,d=[...d,h],p=_,m++;else{let o=p/s;if(r>=i){let s=o*r;layoutRow(u,t,n,s,i,d,a),squarifyRecurse(e.slice(m),t+s,n,r-s,i,a)}else{let s=o*i;layoutRow(u,t,n,r,s,d,a),squarifyRecurse(e.slice(m),t,n+s,r,i-s,a)}return}}if(u.length>0){let e=p/s;r>=i?layoutRow(u,t,n,e*r,i,d,a):layoutRow(u,t,n,r,e*i,d,a)}}function squarify(e,t,n){if(e.length===0||t<=0||n<=0)return[];let r=[...e].sort((e,t)=>t.value-e.value),i=[];return squarifyRecurse(r,0,0,t,n,i),i}function streamLayout(e,t=`silhouette`){let n=c(e);if(t===`zero`)return n;let r=e[0]?.length??0,i=Array.from({length:r},(t,n)=>e.reduce((e,t)=>e+(t[n]??0),0));return n.map(e=>e.map(([e,t],n)=>{let r=i[n]/2;return[e-r,t-r]}))}function streamExtent(e){let t=0,n=0;for(let r of e)for(let[e,i]of r)t=Math.min(t,e,i),n=Math.max(n,e,i);return[t,n]}function sumValue(e){return e.children&&e.children.length>0?e.children.reduce((e,t)=>e+sumValue(t),0):e.value??0}function partition(e,t=2*Math.PI){let n=[],walk=(e,t,r,i)=>{if(n.push({node:e,depth:t,a0:r,a1:i,value:sumValue(e)}),!e.children)return;let a=i-r,o=sumValue(e)||1,s=r;for(let n of e.children){let e=s+a*sumValue(n)/o;walk(n,t+1,s,e),s=e}};return walk(e,0,0,t),n}function maxDepth(e){return e.reduce((e,t)=>Math.max(e,t.depth),0)}function sankeyLayout(e,t,{width:n,height:r,nodeWidth:i=16,nodePadding:a=12}){let o=new Map;for(let t of e)o.set(t.id,{...t,rank:0,value:0,x0:0,x1:0,y0:0,y1:0});let s=t.filter(e=>o.has(e.source)&&o.has(e.target)),c=new Map;for(let e of s)c.has(e.target)||c.set(e.target,[]),c.get(e.target).push(e);let l=!0,u=0;for(;l&&u++<e.length+1;){l=!1;for(let e of s){let t=o.get(e.source),n=o.get(e.target);n.rank<t.rank+1&&(n.rank=t.rank+1,l=!0)}}let d=e.length?Math.max(...[...o.values()].map(e=>e.rank)):0;for(let e of o.values()){let t=s.filter(t=>t.target===e.id).reduce((e,t)=>e+t.value,0),n=s.filter(t=>t.source===e.id).reduce((e,t)=>e+t.value,0);e.value=Math.max(t,n,0)}let f=Array.from({length:d+1},()=>[]);for(let e of o.values())f[e.rank].push(e);let p=1;for(let e of f){let t=e.reduce((e,t)=>e+t.value,0),n=r-a*Math.max(0,e.length-1);t>0&&(p=Math.max(p,t/Math.max(1,n)))}let valueToPx=e=>e/p,m=d>0?(n-i)/d:0;for(let e=0;e<=d;e++){let t=f[e],n=t.reduce((e,t)=>e+valueToPx(t.value),0)+a*Math.max(0,t.length-1),o=Math.max(0,(r-n)/2);for(let n of t)n.x0=e*m,n.x1=n.x0+i,n.y0=o,n.y1=o+valueToPx(n.value),o=n.y1+a}let h=new Map,g=new Map,_=s.map(e=>{let t=o.get(e.source),n=o.get(e.target),r=valueToPx(e.value),i=t.y0+(h.get(t.id)??0),a=n.y0+(g.get(n.id)??0);return h.set(t.id,(h.get(t.id)??0)+r),g.set(n.id,(g.get(n.id)??0)+r),{source:t,target:n,value:e.value,sy:i,ty:a,width:r}});return{nodes:[...o.values()],links:_}}function linkPath(e){let t=e.source.x1,n=e.target.x0,r=(t+n)/2,i=e.sy,a=e.sy+e.width,o=e.ty,s=e.ty+e.width;return`M${t},${i}C${r},${i} ${r},${o} ${n},${o}L${n},${s}C${r},${s} ${r},${a} ${t},${a}Z`}var clamp01$1=e=>e<0?0:e>1?1:e,lerp$1=(e,t,n)=>e+(t-e)*n,mix=(e,t,n)=>({l:lerp$1(e.l,t.l,n),c:lerp$1(e.c,t.c,n),h:lerp$1(e.h,t.h,n)}),css=({l:e,c:t,h:n})=>`oklch(${e.toFixed(4)} ${t.toFixed(4)} ${n.toFixed(2)})`,j={l:.95,c:.04,h:232},M={l:.34,c:.15,h:274},ee={l:.48,c:.14,h:248},N={l:.96,c:.02,h:110},P={l:.52,c:.15,h:42};function sequentialRamp(e){return css(mix(j,M,clamp01$1(e)))}function divergingRamp(e){let t=clamp01$1(e);return css(t<.5?mix(ee,N,t*2):mix(N,P,(t-.5)*2))}function rampOf(e){return e===`diverging`?divergingRamp:sequentialRamp}function rampStops(e,t=`sequential`){let n=rampOf(t);return e<=1?[n(0)]:Array.from({length:e},(t,r)=>n(r/(e-1)))}function rampLightness(e){let t=/oklch\(([\d.]+)/.exec(e);return t?Number(t[1]):NaN}function polarPoint(t,n,r,i){return[e(t+r*Math.sin(i)),e(n-r*Math.cos(i))]}function angleBand(e,t=[0,2*Math.PI]){let n=Math.max(1,e.length),r=(t[1]-t[0])/n,i=new Map(e.map((e,t)=>[e,t])),start=e=>{let n=i.get(e);return n===void 0?void 0:t[0]+n*r};return{map:start,center:e=>{let t=start(e);return t===void 0?void 0:t+r/2},bandwidth:r,step:r}}function radiusScale(e,t){return i(e,t)}function filter(e,t){return e.filter((e,n)=>t(e,n))}function compare(e,t){return e==null&&t==null?0:e==null?-1:t==null?1:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t))}function sort(e,t,n=`asc`){let r=typeof t==`function`?t:e=>e[t],i=n===`desc`?-1:1;return e.map((e,t)=>({row:e,i:t})).sort((e,t)=>compare(r(e.row),r(t.row))*i||e.i-t.i).map(e=>e.row)}function reduceOp(e,t){if(e===`count`)return t.length;if(t.length===0)return 0;switch(e){case`sum`:return t.reduce((e,t)=>e+t,0);case`mean`:return t.reduce((e,t)=>e+t,0)/t.length;case`min`:return Math.min(...t);case`max`:return Math.max(...t);case`median`:{let e=[...t].sort((e,t)=>e-t),n=Math.floor(e.length/2);return e.length%2==0?(e[n-1]+e[n])/2:e[n]}}}function aggregate(e,t){let n=typeof t.groupBy==`string`?[t.groupBy]:t.groupBy,r=new Map,i=[];for(let t of e){let e=n.map(e=>String(t[e])).join(`\0`),a=r.get(e);a||(a=[],r.set(e,a),i.push(e)),a.push(t)}return i.map(e=>{let i=r.get(e),a={};for(let e of n)a[e]=i[0][e];for(let[e,n]of Object.entries(t.ops))a[e]=reduceOp(n,i.map(t=>t[e]).filter(e=>typeof e==`number`&&Number.isFinite(e)));return a})}function bin(e,t={}){let n=e.filter(e=>Number.isFinite(e)),[r,i]=t.range??[Math.min(...n),Math.max(...n)],a=Math.max(1,t.bins??(Math.ceil(Math.sqrt(n.length))||1)),o=(i-r)/a||1,s=Array.from({length:a},(e,t)=>({x0:r+t*o,x1:r+(t+1)*o,count:0,values:[]}));for(let e of n){if(e<r||e>i)continue;let t=Math.floor((e-r)/o);t>=a&&(t=a-1),t<0&&(t=0),s[t].values.push(e),s[t].count++}return s}function solve(e,t){let n=t.length,r=e.map((e,n)=>[...e,t[n]]);for(let e=0;e<n;e++){let t=e;for(let i=e+1;i<n;i++)Math.abs(r[i][e])>Math.abs(r[t][e])&&(t=i);[r[e],r[t]]=[r[t],r[e]];let i=r[e][e];if(!(Math.abs(i)<1e-12))for(let t=0;t<n;t++){if(t===e)continue;let a=r[t][e]/i;for(let i=e;i<=n;i++)r[t][i]-=a*r[e][i]}}return Array.from({length:n},(e,t)=>{let i=r[t][t];return Math.abs(i)<1e-12?0:r[t][n]/i})}function rSquared(e,t){let n=e.map(e=>e[1]),r=n.reduce((e,t)=>e+t,0)/n.length,i=0,a=0;for(let[n,o]of e)i+=(o-t(n))**2,a+=(o-r)**2;return a===0?1:1-i/a}function regression(e,t={}){let n=t.type??`linear`,r=[...e].sort((e,t)=>e[0]-t[0]),i=r.map(e=>e[0]),constant=()=>{let e=r.length?r.reduce((e,t)=>e+t[1],0)/r.length:0;return{predict:()=>e,points:i.map(t=>[t,e]),r2:0,coefficients:[e]}};if(r.length<2)return constant();if(n===`exponential`){let e=r.filter(e=>e[1]>0);if(e.length<2)return constant();let t=regression(e.map(e=>[e[0],Math.log(e[1])]),{type:`linear`}),n=Math.exp(t.coefficients[0]),a=t.coefficients[1],predict=e=>n*Math.exp(a*e);return{predict,points:i.map(e=>[e,predict(e)]),r2:rSquared(r,predict),coefficients:[n,a]}}let a=(n===`linear`?1:Math.max(1,n.order))+1,o=Array.from({length:a},()=>Array(a).fill(0)),s=Array(a).fill(0);for(let[e,t]of r){let n=Array.from({length:a},(t,n)=>e**n);for(let e=0;e<a;e++){s[e]+=n[e]*t;for(let t=0;t<a;t++)o[e][t]+=n[e]*n[t]}}let c=solve(o,s),predict=e=>c.reduce((t,n,r)=>t+n*e**r,0);return{predict,points:i.map(e=>[e,predict(e)]),r2:rSquared(r,predict),coefficients:c}}var num=e=>typeof e==`number`?e:Number(e);function encode(e,t){let x=e=>e.x,y=e=>e.y;if(!t.series)return{series:[{id:t.y,label:t.label??t.y,data:e.map(e=>({x:e[t.x],y:num(e[t.y])}))}],x,y};let n=new Map,r=[];for(let i of e){let e=String(i[t.series]),a=n.get(e);a||(a={id:e,label:e,data:[]},n.set(e,a),r.push(e)),a.data.push({x:i[t.x],y:num(i[t.y])})}return{series:r.map(e=>n.get(e)),x,y}}function encodeCategory(e,t){return e.map(e=>({label:String(e[t.category]),value:num(e[t.value])}))}function lttb(e,t){let n=e.length;if(t>=n||t<3)return e.slice();let r=[e[0]],i=(n-2)/(t-2),a=0;for(let o=0;o<t-2;o++){let t=Math.floor((o+1)*i)+1,s=Math.min(Math.floor((o+2)*i)+1,n),c=Math.max(1,s-t),l=0,u=0;for(let n=t;n<s;n++)l+=e[n][0],u+=e[n][1];l/=c,u/=c;let d=Math.floor(o*i)+1,f=Math.floor((o+1)*i)+1,[p,m]=e[a],h=-1,g=d;for(let t=d;t<f&&t<n;t++){let n=Math.abs((p-l)*(e[t][1]-m)-(p-e[t][0])*(u-m));n>h&&(h=n,g=t)}r.push(e[g]),a=g}return r.push(e[n-1]),r}function minmax(e,t){let n=e.length;if(t>=n||t<4)return e.slice();let r=Math.max(1,Math.floor(t/2)),i=n/r,a=[e[0]];for(let t=0;t<r;t++){let r=Math.floor(t*i),o=Math.min(n,Math.floor((t+1)*i));if(o<=r)continue;let s=e[r],c=e[r];for(let t=r;t<o;t++)e[t][1]<s[1]&&(s=e[t]),e[t][1]>c[1]&&(c=e[t]);s[0]<=c[0]?(a.push(s),c!==s&&a.push(c)):(a.push(c),a.push(s))}return a.push(e[n-1]),a}function decimate(e,t,n=`lttb`){return n===`minmax`?minmax(e,t):lttb(e,t)}function decimateItems(e,t){return e.length<=t.to?e:decimate(e.map((e,n)=>[n,t.y(e)]),t.to,t.method).map(([t])=>e[t])}function useStreamSeries(e){let{capacity:t,source:n,decimate:r}=e,i=S(f({capacity:t})).current,a=S(n);return a.current=n,_(()=>{let e=a.current(e=>i.append(e));return()=>{e(),i.dispose()}}),h(()=>r?decimateItems(i.signal.value,r):i.signal.value)}function bindStream(e){let{capacity:t,source:n,decimate:r}=e,i=f({capacity:t}),a=n(e=>i.append(e));return{signal:r?d(()=>decimateItems(i.signal.value,r)):i.signal,stop:()=>{a(),i.dispose()}}}function useChartSize(e=400,t=300){let n=S(null),r=g(e),i=g(t);return _(()=>{let e=n.current;if(!e)return;let apply=(e,t)=>{e>0&&e!==r.peek()&&(r.value=e),t>0&&t!==i.peek()&&(i.value=t)};if(typeof ResizeObserver>`u`){let t=e.getBoundingClientRect();apply(t.width,t.height);return}let t=0,a=new ResizeObserver(e=>{let n=e[e.length-1];if(!n)return;let{width:r,height:i}=n.contentRect;cancelAnimationFrame(t),t=requestAnimationFrame(()=>apply(r,i))});return a.observe(e),()=>{cancelAnimationFrame(t),a.disconnect()}}),{ref:n,width:r,height:i}}var F={top:8,right:8,bottom:24,left:36},te={top:2,right:2,bottom:2,left:2},I=6.5;function leftMarginForLabels(e,t){if(t)return te.left;let n=e.reduce((e,t)=>Math.max(e,t.length),0);return Math.max(F.left,Math.ceil(n*I+12))}function rightMarginForLabels(e={}){let{rightAxisLabels:t=[],bottomAxisLabels:n=[],rightAxisTitle:r=!1,plain:i}=e;if(i)return te.right;let a=t.reduce((e,t)=>Math.max(e,t.length),0),o=r?20:0,s=a>0?Math.ceil(a*I+12+o):0,c=n[n.length-1]??``,l=c?Math.ceil(c.length*I/2+2):0;return Math.max(F.right,s,l)}var L=14;function autoLabelStride(e,t,n=`horizontal`){if(e.length<=1||t<=0)return;let r=t/e.length,i=n===`vertical`?14:e.reduce((e,t)=>Math.max(e,t.length),0)*I+6;if(!(r>=i))return Math.ceil(i/r)}function defaultFormat$2(e){return`${e.label}: ${e.value}`}function ChartTooltip({point:e,model:t}){let n=t.format?t.format(e):defaultFormat$2(e),r=e.segments?.filter(e=>e.value!==0);return D(`div`,{role:`tooltip`,style:{position:`absolute`,left:e.cx+8,top:Math.max(0,e.cy-32),pointerEvents:`none`,background:`var(--cascivo-surface-overlay, var(--cascivo-color-background))`,color:`var(--cascivo-color-text, currentColor)`,border:`1px solid var(--cascivo-color-border)`,borderRadius:`var(--cascivo-radius-sm, 4px)`,padding:`0.25rem 0.5rem`,fontSize:`0.8125rem`,whiteSpace:`nowrap`,boxShadow:`var(--cascivo-shadow-sm, 0 1px 4px rgba(0,0,0,0.1))`,zIndex:10},children:r&&r.length>0?O(`span`,{style:{display:`flex`,flexDirection:`column`,gap:`2px`},children:[O(`span`,{style:{fontWeight:600},"data-tooltip-header":``,children:[e.label,` · `,e.value]}),r.map(e=>O(`span`,{style:e.color?{color:e.color}:void 0,children:[e.label,`: `,e.value]},e.label))]}):D(`span`,{style:e.color?{color:e.color}:void 0,children:n})})}function nearest(e,t,n,r=`xy`){if(e.length===0)return-1;let i=0,a=1/0;for(let o=0;o<e.length;o++){let s=e[o],c=r===`x`?Math.abs(s.cx-t):Math.hypot(s.cx-t,s.cy-n);c<a&&(a=c,i=o)}return i}function CanvasLayer({size:e,paint:t}){let n=S(null);return _(()=>{let{width:r,height:i}=e(),a=n.current;if(!a||r<=0||i<=0)return;let o=typeof globalThis<`u`&&`devicePixelRatio`in globalThis&&globalThis.devicePixelRatio||1;a.width=Math.max(1,Math.round(r*o)),a.height=Math.max(1,Math.round(i*o));let s=a.getContext(`2d`);s&&(s.setTransform(o,0,0,o,0,0),s.clearRect(0,0,r,i),t(s,{width:r,height:i}))}),D(`canvas`,{ref:n,"aria-hidden":`true`,"data-canvas-layer":``,style:{position:`absolute`,inset:0,width:`100%`,height:`100%`,pointerEvents:`none`}})}function resolveColor(e,t){let n=/var\((--[^,)]+)/.exec(t);return!n||typeof getComputedStyle!=`function`?t:getComputedStyle(e.canvas).getPropertyValue(n[1]).trim()||t}var R=1;function zoomWindow(e,t,n,r){if(t<=1)return[0,Math.max(0,t-1)];let[i,a]=e,o=i+r*(a-i),s=Math.round(o-(o-i)*n),c=Math.round(o+(a-o)*n);return s=Math.max(0,s),c=Math.min(t-1,c),c-s<R&&(s=Math.max(0,Math.min(Math.round(o)-1,t-1-R)),c=Math.min(t-1,s+R)),[s,c]}function panWindow(e,t,n){let[r,i]=e,a=i-r,o=Math.max(0,Math.min(t-1-a,Math.round(r+n)));return[o,o+a]}function isZoomed(e,t){return e[0]>0||e[1]<t-1}var z={display:`inline-flex`,alignItems:`center`,justifyContent:`center`,minBlockSize:`var(--cascivo-target-min-coarse, 1.75rem)`,minInlineSize:`1.75rem`,padding:`0.2rem 0.5rem`,fontSize:`0.75rem`,lineHeight:1.2,borderRadius:`0.375rem`,border:`1px solid var(--cascivo-chart-grid, currentColor)`,background:`var(--cascivo-color-background, white)`,color:`var(--cascivo-color-foreground, inherit)`,cursor:`pointer`};function Toolbox({options:e,onPng:t,onSvg:n,onToggleData:r,onRestore:i,showData:a}){let o=e;return O(`div`,{role:`group`,"aria-label":`Chart toolbox`,style:{display:`inline-flex`,gap:`0.25rem`},children:[o.png!==!1&&D(`button`,{type:`button`,style:z,onClick:t,children:T(C.charts.exportPng)}),o.svg!==!1&&D(`button`,{type:`button`,style:z,onClick:n,children:T(C.charts.exportSvg)}),o.dataView!==!1&&D(`button`,{type:`button`,style:z,"aria-pressed":a,onClick:r,children:T(C.charts.dataView)}),o.restore!==!1&&D(`button`,{type:`button`,style:z,onClick:i,children:T(C.charts.restore)})]})}var B=[`fill`,`stroke`,`stop-color`,`color`];function serializeSvg(e){let t=e.cloneNode(!0);if(typeof getComputedStyle==`function`){let n=e.querySelectorAll(`*`),r=t.querySelectorAll(`*`);for(let e=0;e<n.length;e++){let t=getComputedStyle(n[e]),i=r[e];if(i)for(let e of B){let n=t.getPropertyValue(e);n&&n!==`none`&&!n.includes(`var(`)&&i.setAttribute(e,n)}}}return t.setAttribute(`xmlns`,`http://www.w3.org/2000/svg`),new XMLSerializer().serializeToString(t)}function svgToPngBlob(e,t){if(typeof document>`u`||typeof Image>`u`)return Promise.resolve(null);let n=t.dpr??1,r=document.createElement(`canvas`);r.width=Math.max(1,Math.round(t.width*n)),r.height=Math.max(1,Math.round(t.height*n));let i=r.getContext(`2d`);return i?new Promise(t=>{let n=new Image;n.addEventListener(`load`,()=>{try{i.drawImage(n,0,0,r.width,r.height),typeof r.toBlob==`function`?r.toBlob(e=>t(e),`image/png`):t(null)}catch{t(null)}}),n.addEventListener(`error`,()=>t(null)),n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`}):Promise.resolve(null)}function download(e,t){if(typeof document>`u`||typeof URL>`u`||!URL.createObjectURL)return;let n=typeof e==`string`?new Blob([e],{type:`image/svg+xml`}):e,r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,i.style.display=`none`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}var ne={position:`absolute`,insetInlineStart:`-9999px`,inlineSize:`1px`,blockSize:`1px`,overflow:`hidden`,clipPath:`inset(50%)`,whiteSpace:`nowrap`};function ChartFrame({title:e,description:t,width:n,height:r,fallback:i,children:a,className:o,"data-state":s,emptyLabel:c,plain:u,tooltip:d,onSelect:f,hover:p=`rect`,renderer:m=`svg`,paint:h,zoom:w,toolbox:k,onRestore:A,transition:j,onBeforeDraw:M,onAfterDraw:ee}){v();let N=b(),P=`${N}-desc`,F=`${N}-live`,{ref:te,width:I,height:L}=useChartSize(n??400,300),R=g(null),z=g(!1),B=S(null),re=S(null),V=S(null),ie=S(null);_(()=>{let e=ie.current;if(!e||!w)return;let onWheel=t=>{t.preventDefault();let n=e.getBoundingClientRect(),r=n.width?(t.clientX-n.left)/n.width:.5,i=t.deltaY>0?1.25:1/1.25;w.window.value=zoomWindow(w.window.value,w.count,i,r)};return e.addEventListener(`wheel`,onWheel,{passive:!1}),()=>e.removeEventListener(`wheel`,onWheel)});let resetZoom=()=>{w&&(w.window.value=[0,Math.max(0,w.count-1)])},H=n??I.value,U=r??L.value,W=k===!0?{}:k||null,exportSvgString=()=>re.current?serializeSvg(re.current):null,onExportSvg=()=>{let t=exportSvgString();t&&download(t,`${e||`chart`}.svg`)},onExportPng=()=>{let t=exportSvgString();t&&svgToPngBlob(t,{width:H,height:U,dpr:2}).then(t=>{t&&download(t,`${e||`chart`}.png`)})},onRestoreAll=()=>{resetZoom(),A?.()},G=typeof d==`function`?d({width:H,height:U}):d;_(()=>{let e=R.value;if(!G||!B.current)return;let t=e===null?void 0:G.points[e];B.current.textContent=t?(G.format??defaultFormat$2)(t):``});let K={position:`absolute`,inset:0,cursor:w?`grab`:f?`pointer`:`crosshair`,background:`transparent`,touchAction:w?`none`:void 0},q=m===`canvas`&&h!==void 0,ae=G!==void 0||w!==void 0,J={};if(j&&typeof j==`object`){let e=J;j.duration!==void 0&&(e[`--cascivo-chart-anim-dur`]=`${j.duration}ms`),j.easing&&(e[`--cascivo-chart-anim-ease`]=j.easing),j.properties&&(e[`--cascivo-chart-anim-props`]=j.properties.join(`, `))}let Y=ae||q||W||Object.keys(J).length>0?{...J,...ae||q||W?{position:`relative`}:{}}:void 0;return O(`div`,{ref:te,className:[l.frame,o].filter(Boolean).join(` `),style:Y,...s!==void 0&&{"data-state":s},...u===!0&&{"data-plain":``},...j===!1&&{"data-no-anim":``},children:[W&&D(`div`,{style:{position:`absolute`,top:4,right:4,zIndex:12},children:D(Toolbox,{options:W,onPng:onExportPng,onSvg:onExportSvg,onToggleData:()=>{z.value=!z.value},onRestore:onRestoreAll,showData:z.value})}),q&&D(CanvasLayer,{size:()=>({width:n??I.value,height:r??L.value}),paint:h}),O(`svg`,{ref:re,role:`img`,"aria-label":e,"aria-describedby":t?P:void 0,width:H,height:U,viewBox:`0 0 ${H} ${U}`,children:[t&&D(`desc`,{id:P,children:t}),M?.({width:H,height:U}),a({width:H,height:U}),ee?.({width:H,height:U}),s===`empty`&&D(`text`,{x:H/2,y:U/2,textAnchor:`middle`,dominantBaseline:`central`,fill:`var(--cascivo-color-foreground-muted)`,fontSize:`0.875rem`,"data-empty":``,children:c??T(C.charts.noData)})]}),i&&D(`div`,{className:l.fallback,style:ne,children:i}),W&&z.value&&i&&D(`div`,{"data-data-view":``,style:{overflowX:`auto`},children:i}),ae&&O(E,{children:[G!==void 0&&O(E,{children:[D(`span`,{id:F,ref:B,"aria-live":`polite`,style:{position:`absolute`,width:`1px`,height:`1px`,padding:0,margin:`-1px`,overflow:`hidden`,clip:`rect(0,0,0,0)`,whiteSpace:`nowrap`,border:0}}),G.mode===`axis`&&R.value!==null&&G.points[R.value]!==void 0&&D(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:G.points[R.value].cx,top:0,width:1,height:U,background:`var(--cascivo-chart-grid, currentColor)`,pointerEvents:`none`,zIndex:9}}),R.value!==null&&G.points[R.value]!==void 0&&(()=>{let e=G.points[R.value];return D(`div`,{"aria-hidden":`true`,style:{position:`absolute`,left:e.cx-4,top:e.cy-4,width:8,height:8,borderRadius:`50%`,border:`2px solid var(--cascivo-focus-ring, var(--cascivo-color-accent))`,background:`var(--cascivo-color-background, white)`,pointerEvents:`none`,zIndex:10}})})(),R.value!==null&&G.points[R.value]!==void 0&&D(ChartTooltip,{point:G.points[R.value],model:G})]}),w&&!W&&isZoomed(w.window.value,w.count)&&D(`button`,{type:`button`,onClick:resetZoom,style:{position:`absolute`,top:4,right:4,zIndex:11,padding:`0.25rem 0.5rem`,fontSize:`0.75rem`,lineHeight:1.2,borderRadius:`0.375rem`,border:`1px solid var(--cascivo-chart-grid, currentColor)`,background:`var(--cascivo-color-background, white)`,color:`var(--cascivo-color-foreground, inherit)`,cursor:`pointer`},children:T(C.charts.resetZoom)}),D(`div`,{ref:ie,role:`application`,"aria-label":w?`Chart — arrow keys navigate points; + and - zoom, 0 resets, drag to pan`:`Chart data — use arrow keys to navigate points`,tabIndex:0,style:K,onPointerDown:e=>{w&&(V.current={x:e.clientX,win:[...w.window.value]},e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(w&&V.current&&e.buttons===1){let t=e.currentTarget.getBoundingClientRect(),n=V.current.win[1]-V.current.win[0]+1,r=e.clientX-V.current.x,i=t.width?-(r/t.width)*n:0;w.window.value=panWindow(V.current.win,w.count,i);return}if(!G||!G.points.length)return;let t=e.currentTarget.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;R.value=G.mode===`axis`?nearest(G.points,n,r,`x`):p===`voronoi`?voronoiFind(G.points.map(e=>[e.cx,e.cy]),n,r):nearest(G.points,n,r,`xy`)},onPointerUp:()=>{V.current=null},onPointerLeave:()=>{V.current=null,G&&(R.value=null)},onKeyDown:e=>{if(w){if(e.key===`+`||e.key===`=`){e.preventDefault(),w.window.value=zoomWindow(w.window.value,w.count,1/1.25,.5);return}if(e.key===`-`||e.key===`_`){e.preventDefault(),w.window.value=zoomWindow(w.window.value,w.count,1.25,.5);return}if(e.key===`0`){e.preventDefault(),resetZoom();return}}if(!G||!G.points.length)return;let t=R.value;if(e.key===`ArrowRight`||e.key===`ArrowDown`)e.preventDefault(),R.value=t===null?0:Math.min(t+1,G.points.length-1);else if(e.key===`ArrowLeft`||e.key===`ArrowUp`)e.preventDefault(),R.value=t===null?G.points.length-1:Math.max(t-1,0);else if(e.key===`Home`)e.preventDefault(),R.value=0;else if(e.key===`End`)e.preventDefault(),R.value=G.points.length-1;else if(e.key===`Escape`)R.value=null;else if(f&&(e.key===`Enter`||e.key===` `)){e.preventDefault();let t=R.value,n=t===null?void 0:G.points[t];n&&f(n)}},onClick:()=>{if(!G)return;let e=R.value,t=e===null?void 0:G.points[e];f&&t&&f(t)},onFocus:()=>{G&&G.points.length>0&&R.value===null&&(R.value=0)},onBlur:()=>{G&&(R.value=null)}})]})]})}var re=new Map;function getSyncGroup(e){let t=re.get(e);return t||(t={group:{window:m(null),hoverX:m(null)},refs:0},re.set(e,t)),t.refs++,t.group}function releaseSyncGroup(e){let t=re.get(e);t&&(t.refs--,t.refs<=0&&re.delete(e))}function _syncGroupCount(){return re.size}function isBand(e){return`bandwidth`in e}function isTime(e){return`tickInterval`in e}function defaultFormat$1(e){return e instanceof Date?e.toLocaleDateString():typeof e==`number`?e.toLocaleString():String(e)}function timeFormatter(e,t){let n=new Intl.DateTimeFormat(void 0,e.tickFormat(t));return e=>n.format(e)}function Axis({scale:e,orientation:t,length:n,format:r,tickCount:i=5,labelEvery:a,title:o,titleOffset:s=36,transform:c}){let l;if(isBand(e)){let t=r??defaultFormat$1,n=e.domain.length-1,i=a!=null&&a>1,o=i?Math.floor(n/a)*a:-1,s=!1;if(i&&o!==n&&o>=0){let posOf=t=>(e.map(e.domain[t])??0)+e.bandwidth/2,r=e.domain.reduce((e,n)=>Math.max(e,t(n).length),0)*I;s=posOf(n)-posOf(o)<r}l=e.domain.map((n,r)=>({position:(e.map(n)??0)+e.bandwidth/2,label:t(n),i:r})).filter(({i:e})=>!i||e===n?!0:s&&e===o?!1:e%a===0)}else if(isTime(e)){let t=r??timeFormatter(e,i);l=e.ticks(i).map(n=>({position:e.map(n),label:t(n)}))}else{let t=e;l=t.ticks(i).map(e=>({position:t.map(e),label:(r??defaultFormat$1)(e)}))}let u=t===`x`,d=t===`y-right`,f=u?0:d?4:-4,p=u?0:d?8:-8,m=u?`middle`:d?`start`:`end`;return O(`g`,{transform:c,"aria-hidden":`true`,children:[D(`line`,{x1:0,y1:0,x2:u?n:0,y2:u?0:n,stroke:`var(--cascivo-chart-axis)`,strokeWidth:1}),l.map(({position:e,label:t},n)=>O(`g`,{transform:u?`translate(${e},0)`:`translate(0,${e})`,children:[D(`line`,{x1:0,y1:0,x2:f,y2:u?4:0,stroke:`var(--cascivo-chart-axis)`,strokeWidth:1}),D(`text`,{x:p,y:u?16:4,textAnchor:m,fill:`var(--cascivo-chart-axis)`,fontSize:11,children:t})]},n)),o!==void 0&&o!==``&&D(`text`,{transform:u?`translate(${n/2},${s})`:`translate(${d?s:-s},${n/2}) rotate(${d?90:-90})`,textAnchor:`middle`,fill:`var(--cascivo-chart-axis)`,fontSize:11,fontWeight:500,children:o})]})}function GridLines({scale:e,orientation:t,length:n,tickCount:r=5,transform:i}){let a=e.ticks(r),o=t===`x`;return D(`g`,{transform:i,"aria-hidden":`true`,children:a.map(t=>{let r=e.map(t);return D(`line`,{x1:o?r:0,y1:o?0:r,x2:o?r:n,y2:o?n:r,stroke:`var(--cascivo-chart-grid)`,strokeWidth:1,strokeDasharray:`2 4`},t)})})}var V=`var(--cascivo-color-foreground-muted)`,ie=`var(--cascivo-color-accent)`;function center(e,t){let n=e.map(t);if(!(n==null||Number.isNaN(n)))return e.bandwidth?n+e.bandwidth/2:n}function renderAnnotation(e,t,n){let{xScale:r,yScale:i,innerW:a,innerH:o}=t;if(e.kind===`line`){let t=center(e.axis===`x`?r:i,e.value);if(t==null)return null;let s=e.color??V,c=e.dash!==!1,l=e.axis===`x`;return O(`g`,{"data-annotation":`line`,"aria-hidden":`true`,children:[D(`line`,{x1:l?t:0,y1:l?0:t,x2:l?t:a,y2:l?o:t,stroke:s,strokeWidth:1.5,...c&&{strokeDasharray:`4 3`},children:D(`title`,{children:e.label??String(e.value)})}),e.label!=null&&(l?D(`text`,{x:t+4,y:10,fontSize:`0.6875rem`,fill:s,textAnchor:`start`,children:e.label}):D(`text`,{x:a-4,y:t-4,fontSize:`0.6875rem`,fill:s,textAnchor:`end`,children:e.label}))]},n)}if(e.kind===`area`){let t=e.axis===`x`?r:i,s=center(t,e.from),c=center(t,e.to);if(s==null||c==null)return null;let l=e.color??ie,u=e.axis===`x`,d=Math.min(s,c),f=Math.abs(c-s);return D(`g`,{"data-annotation":`area`,"aria-hidden":`true`,children:D(`rect`,{x:u?d:0,y:u?0:d,width:u?f:a,height:u?o:f,fill:l,fillOpacity:.12,children:D(`title`,{children:e.label??`${String(e.from)}–${String(e.to)}`})})},n)}if(e.kind===`note`){let t=center(r,e.x),s=center(i,e.y);if(t==null||s==null)return null;let c=e.color??ie,l=e.dx??24,u=e.dy??-24,d=Math.max(2,Math.min(a-2,t+l)),f=Math.max(8,Math.min(o-2,s+u));return O(`g`,{"data-annotation":`note`,children:[D(`line`,{x1:t,y1:s,x2:d,y2:f,stroke:c,strokeWidth:1,"aria-hidden":`true`}),D(`circle`,{cx:t,cy:s,r:3.5,fill:c,"aria-hidden":`true`}),D(`text`,{x:d,y:f,dy:u<0?`-0.2em`:`1em`,fontSize:`0.6875rem`,fontWeight:500,fill:c,textAnchor:l<0?`end`:`start`,children:e.label})]},n)}if(e.kind===`threshold`){let t=i.map(e.value);if(t==null||Number.isNaN(t))return null;let r=e.color??ie,s=e.side===`above`?0:t,c=e.side===`above`?t:o-t;return D(`g`,{"data-annotation":`threshold`,"aria-hidden":`true`,children:D(`rect`,{x:0,y:s,width:a,height:Math.max(0,c),fill:r,fillOpacity:.1,children:D(`title`,{children:e.label??`${e.side} ${e.value}`})})},n)}let s=center(r,e.x),c=center(i,e.y);if(s==null||c==null)return null;let l=e.color??ie;return O(`g`,{"data-annotation":`dot`,"aria-hidden":`true`,children:[D(`circle`,{cx:s,cy:c,r:4,fill:l,stroke:`var(--cascivo-color-background)`,strokeWidth:1.5,children:D(`title`,{children:e.label??`${String(e.x)}, ${e.y}`})}),e.label!=null&&D(`text`,{x:s+6,y:c-6,fontSize:`0.6875rem`,fill:l,textAnchor:`start`,children:e.label})]},n)}function renderAnnotations(e,t){return!e||e.length===0?null:D(`g`,{"data-annotations":``,children:e.map((e,n)=>renderAnnotation(e,t,n))})}function annotationSummary(e){return e.kind===`line`?e.label??`${e.axis}=${String(e.value)}`:e.kind===`area`?e.label??`${e.axis} ${String(e.from)}–${String(e.to)}`:e.kind===`threshold`?e.label??`${e.side} ${e.value}`:e.kind===`note`?e.label:e.label??`(${String(e.x)}, ${e.y})`}var defaultFormat=e=>e.toLocaleString();function resolveLabels(e){return e?e===!0?{format:defaultFormat,position:`auto`}:{format:e.format??defaultFormat,position:e.position??`auto`}:null}function DataLabel({x:e,y:t,text:n,tone:r=`default`,anchor:i=`middle`}){return D(`text`,{x:e,y:t,textAnchor:i,fontSize:`0.6875rem`,fontWeight:500,fill:r===`muted`?`var(--cascivo-color-background)`:`var(--cascivo-color-foreground)`,"aria-hidden":`true`,"data-data-label":``,style:{pointerEvents:`none`},children:n})}function safe(e){return e.replace(/[^a-zA-Z0-9_-]/g,``)}function gradientId(e,t){return`${safe(e)}-grad-${safe(t)}`}function patternId(e,t){return`${safe(e)}-pat-${safe(t)}`}function fillFor(e,t,n,r){return n===`gradient`?`url(#${gradientId(e,t)})`:n===`pattern`?`url(#${patternId(e,t)})`:r}function ChartDefs({prefix:e,series:t,fill:n,patternKind:r=`dots`}){return n===`solid`?null:D(`defs`,{children:t.map(t=>n===`gradient`?O(`linearGradient`,{id:gradientId(e,t.id),x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[D(`stop`,{offset:`0%`,stopColor:t.color,stopOpacity:.9}),D(`stop`,{offset:`100%`,stopColor:t.color,stopOpacity:.1})]},t.id):O(`pattern`,{id:patternId(e,t.id),patternUnits:`userSpaceOnUse`,width:6,height:6,patternTransform:`rotate(45)`,children:[D(`rect`,{width:6,height:6,fill:t.color,fillOpacity:.12}),r===`dots`&&D(`circle`,{cx:3,cy:3,r:1.2,fill:t.color}),r===`lines`&&D(`line`,{x1:0,y1:0,x2:0,y2:6,stroke:t.color,strokeWidth:1.2}),r===`cross`&&O(E,{children:[D(`line`,{x1:0,y1:3,x2:6,y2:3,stroke:t.color,strokeWidth:1}),D(`line`,{x1:3,y1:0,x2:3,y2:6,stroke:t.color,strokeWidth:1})]})]},t.id))})}function glyphPath(e,t){let n=t/2;switch(e){case`square`:return`M${-n},${-n}h${t}v${t}h${-t}Z`;case`diamond`:return`M0,${-n}L${n},0L0,${n}L${-n},0Z`;case`triangle`:return`M0,${-n}L${n},${n}L${-n},${n}Z`;case`cross`:{let e=n*.4;return`M${-e},${-n}h${2*e}v${n-e}h${n-e}v${2*e}h${-(n-e)}v${n-e}h${-2*e}v${-(n-e)}h${-(n-e)}v${-2*e}h${n-e}Z`}case`star`:{let e=[];for(let t=0;t<10;t++){let r=t%2==0?n:n*.4,i=Math.PI/5*t-Math.PI/2;e.push(`${(Math.cos(i)*r).toFixed(3)},${(Math.sin(i)*r).toFixed(3)}`)}return`M${e.join(`L`)}Z`}default:return``}}function Glyph({shape:e,x:t,y:n,size:r,color:i,opacity:a=.85,stroke:o,strokeWidth:s}){let c={fill:i,fillOpacity:a,...o!=null&&{stroke:o},...s!=null&&{strokeWidth:s},"aria-hidden":!0,"data-glyph":e};return e===`circle`?D(`circle`,{cx:t,cy:n,r:r/2,...c}):D(`path`,{d:glyphPath(e,r),transform:`translate(${t},${n})`,...c})}var H;function measureWidth(e,t){if(H===void 0&&(H=typeof document<`u`?document.createElement(`canvas`).getContext(`2d`):null),H){H.font=`${t}px sans-serif`;let n=H.measureText(e).width;if(n>0)return n}return e.length*t*.55}function wrapText(e,t,n){if(!t||t<=0)return[e];let r=e.split(/\s+/).filter(Boolean),i=[],a=``;for(let e of r){let r=a?`${a} ${e}`:e;a&&measureWidth(r,n)>t?(i.push(a),a=e):a=r}return a&&i.push(a),i.length?i:[e]}function ChartText({x:e,y:t,children:n,width:r,fontSize:i=12,anchor:a=`start`,fill:o,lineHeight:s=1.2,className:c}){let l=r?wrapText(n,r,i):[n];return D(`text`,{x:e,y:t,fontSize:i,textAnchor:a,...o!=null&&{fill:o},...c!=null&&{className:c},children:l.map((t,n)=>D(`tspan`,{x:e,...n>0&&{dy:`${s}em`},children:t},n))})}function Brush({count:e,height:t=28,window:n,label:r=`Range`}){v();let i=Math.max(1,e-1),xOf=e=>e/i*100,[a,o]=n.value,s=t-8,move=(t,r)=>{let i=Math.max(0,Math.min(e-1,r)),[a,o]=n.value;n.value=t===0?[Math.min(i,o),o]:[a,Math.max(i,a)]},onMove=e=>t=>{if(t.buttons!==1)return;let n=t.currentTarget.ownerSVGElement;if(!n)return;let r=n.getBoundingClientRect();r.width!==0&&move(e,Math.round((t.clientX-r.left)/r.width*i))},onKey=(t,n)=>r=>{r.key===`ArrowLeft`?(r.preventDefault(),move(t,n-1)):r.key===`ArrowRight`?(r.preventDefault(),move(t,n+1)):r.key===`Home`?(r.preventDefault(),move(t,0)):r.key===`End`&&(r.preventDefault(),move(t,e-1))},handle=(n,i)=>D(`rect`,{"data-brush-handle":n===0?`start`:`end`,role:`slider`,tabIndex:0,"aria-label":`${r} ${n===0?`start`:`end`}`,"aria-valuemin":0,"aria-valuemax":e-1,"aria-valuenow":i,x:xOf(i)-.8,y:0,width:1.6,height:t,rx:.6,fill:`var(--cascivo-color-accent)`,style:{cursor:`ew-resize`,touchAction:`none`},onPointerDown:e=>e.currentTarget.setPointerCapture(e.pointerId),onPointerMove:onMove(n),onKeyDown:onKey(n,i)});return O(`svg`,{width:`100%`,height:t,viewBox:`0 0 100 ${t}`,preserveAspectRatio:`none`,role:`group`,"aria-label":`${r} — showing ${a+1}–${o+1} of ${e}`,style:{display:`block`,touchAction:`none`},children:[D(`rect`,{x:0,y:4,width:100,height:s,rx:3,fill:`var(--cascivo-chart-grid)`,fillOpacity:.3}),D(`rect`,{x:xOf(a),y:4,width:Math.max(0,xOf(o)-xOf(a)),height:s,fill:`var(--cascivo-color-accent)`,fillOpacity:.2}),handle(0,a),handle(1,o)]})}function DataZoom({count:e,height:t=28,window:n,label:r=`Range`}){v();let i=Math.max(1,e-1),xOf=e=>e/i*100,[a,o]=n.value,s=t-8,c=g(0),idxAt=(e,t)=>{let n=t.getBoundingClientRect();return n.width===0?0:Math.round((e-n.left)/n.width*i)},resize=(t,r)=>{let i=Math.max(0,Math.min(e-1,r)),[a,o]=n.value;n.value=t===0?[Math.min(i,o),o]:[a,Math.max(i,a)]},panTo=t=>{let[r,i]=n.value,a=i-r,o=Math.max(0,Math.min(e-1-a,t));n.value=[o,o+a]},onResizeMove=e=>t=>{t.buttons!==1||!t.currentTarget.ownerSVGElement||resize(e,idxAt(t.clientX,t.currentTarget.ownerSVGElement))},onHandleKey=(t,n)=>r=>{let i=r.key;i===`ArrowLeft`?(r.preventDefault(),resize(t,n-1)):i===`ArrowRight`?(r.preventDefault(),resize(t,n+1)):i===`Home`?(r.preventDefault(),resize(t,0)):i===`End`&&(r.preventDefault(),resize(t,e-1))},handle=(n,i)=>D(`rect`,{"data-zoom-handle":n===0?`start`:`end`,role:`slider`,tabIndex:0,"aria-label":`${r} ${n===0?`start`:`end`}`,"aria-valuemin":0,"aria-valuemax":e-1,"aria-valuenow":i,x:xOf(i)-.8,y:0,width:1.6,height:t,rx:.6,fill:`var(--cascivo-color-accent)`,style:{cursor:`ew-resize`,touchAction:`none`},onPointerDown:e=>e.currentTarget.setPointerCapture(e.pointerId),onPointerMove:onResizeMove(n),onKeyDown:onHandleKey(n,i)});return O(`svg`,{width:`100%`,height:t,viewBox:`0 0 100 ${t}`,preserveAspectRatio:`none`,role:`group`,"aria-label":`${r} — showing ${a+1}–${o+1} of ${e}`,style:{display:`block`,touchAction:`none`},children:[D(`rect`,{x:0,y:4,width:100,height:s,rx:3,fill:`var(--cascivo-chart-grid)`,fillOpacity:.3}),D(`rect`,{"data-zoom-body":``,role:`slider`,tabIndex:0,"aria-label":`${r} window`,"aria-valuemin":0,"aria-valuemax":e-1,"aria-valuenow":a,x:xOf(a),y:4,width:Math.max(0,xOf(o)-xOf(a)),height:s,fill:`var(--cascivo-color-accent)`,fillOpacity:.2,style:{cursor:`grab`,touchAction:`none`},onPointerDown:e=>{let t=e.currentTarget.ownerSVGElement;t&&(c.value=idxAt(e.clientX,t)-n.value[0]),e.currentTarget.setPointerCapture(e.pointerId)},onPointerMove:e=>{e.buttons!==1||!e.currentTarget.ownerSVGElement||panTo(idxAt(e.clientX,e.currentTarget.ownerSVGElement)-c.value)},onKeyDown:e=>{e.key===`ArrowLeft`?(e.preventDefault(),panTo(n.value[0]-1)):e.key===`ArrowRight`&&(e.preventDefault(),panTo(n.value[0]+1))}}),handle(0,a),handle(1,o)]})}var U=5,W=[3,14],clamp01=e=>e<0?0:e>1?1:e,lerp=(e,t,n)=>e+(t-e)*n,norm=(e,t)=>clamp01((e-t.min)/(t.max-t.min||1));function pieceIndex(e,t){let n=t.pieces??U;return Math.min(n-1,Math.max(0,Math.floor(norm(e,t)*n)))}function mapVisual(e,t){let n=t.channel??`color`,r=t.ramp??`sequential`,i=norm(e,t),a={};if((n===`color`||n===`both`)&&(a.color=(t.mode??`continuous`)===`piecewise`?rampStops(t.pieces??U,r)[pieceIndex(e,t)]:rampOf(r)(i)),n===`size`||n===`both`){let[e,n]=t.sizeRange??W;a.size=lerp(e,n,i)}return a}function visualVisible(e,t,n,r){return(t.mode??`continuous`)===`piecewise`?!r?.has(pieceIndex(e,t)):n?e>=n[0]&&e<=n[1]:!0}function VisualMap({options:e,range:t,hidden:n,label:r=`Value`,format:i}){v();let a=i??(e=>String(Math.round(e)));if((e.mode??`continuous`)===`piecewise`){let t=e.pieces??U,i=rampStops(t,e.ramp??`sequential`),o=(e.max-e.min)/t,s=n?.value??new Set,toggle=e=>{if(!n)return;let t=new Set(n.value);t.has(e)?t.delete(e):t.add(e),n.value=t};return D(`div`,{role:`group`,"aria-label":`${r} — colour buckets`,style:{display:`flex`,flexWrap:`wrap`,gap:`0.25rem`,alignItems:`center`},children:i.map((t,n)=>{let r=e.min+n*o,i=e.min+(n+1)*o,c=s.has(n);return O(`button`,{type:`button`,"aria-pressed":!c,onClick:()=>toggle(n),style:{display:`inline-flex`,alignItems:`center`,gap:`0.35rem`,padding:`0.2rem 0.45rem`,minBlockSize:`var(--cascivo-target-min-coarse, 1.75rem)`,border:`1px solid var(--cascivo-chart-grid, currentColor)`,borderRadius:`0.375rem`,background:`transparent`,color:`var(--cascivo-color-foreground, inherit)`,fontSize:`0.75rem`,cursor:`pointer`,opacity:c?.4:1},children:[D(`span`,{"aria-hidden":`true`,style:{width:12,height:12,borderRadius:2,background:t,display:`inline-block`}}),`${a(r)}–${a(i)}`]},n)})})}let{min:o,max:s}=e,c=s-o||1,l=rampStops(8,e.ramp??`sequential`),fracOf=e=>(e-o)/c*100,u=t?.value[0]??o,d=t?.value[1]??s,f=`vm-grad-${l.length}`,valAt=(e,t)=>{let n=t.getBoundingClientRect();return n.width===0?o:o+clamp01((e-n.left)/n.width)*c},move=(e,n)=>{if(!t)return;let r=Math.max(o,Math.min(s,n)),[i,a]=t.value;t.value=e===0?[Math.min(r,a),a]:[i,Math.max(r,i)]},p=c/100,onKey=(e,t)=>n=>{n.key===`ArrowLeft`?(n.preventDefault(),move(e,t-p)):n.key===`ArrowRight`?(n.preventDefault(),move(e,t+p)):n.key===`Home`?(n.preventDefault(),move(e,o)):n.key===`End`&&(n.preventDefault(),move(e,s))},onPointer=e=>t=>{t.buttons!==1||!t.currentTarget.ownerSVGElement||move(e,valAt(t.clientX,t.currentTarget.ownerSVGElement))},thumb=(e,t)=>D(`rect`,{"data-visual-thumb":e===0?`low`:`high`,role:`slider`,tabIndex:0,"aria-label":`${r} ${e===0?`minimum`:`maximum`}`,"aria-valuemin":o,"aria-valuemax":s,"aria-valuenow":Math.round(t),x:fracOf(t)-.8,y:0,width:1.6,height:20,rx:.6,fill:`var(--cascivo-color-foreground, currentColor)`,style:{cursor:`ew-resize`,touchAction:`none`},onPointerDown:e=>e.currentTarget.setPointerCapture(e.pointerId),onPointerMove:onPointer(e),onKeyDown:onKey(e,t)});return O(`svg`,{width:`100%`,height:20,viewBox:`0 0 100 20`,preserveAspectRatio:`none`,role:`group`,"aria-label":`${r} — showing ${a(u)} to ${a(d)}`,style:{display:`block`,touchAction:`none`},children:[D(`defs`,{children:D(`linearGradient`,{id:f,x1:`0`,y1:`0`,x2:`1`,y2:`0`,children:l.map((e,t)=>D(`stop`,{offset:`${t/(l.length-1)*100}%`,stopColor:e},t))})}),D(`rect`,{x:0,y:6,width:100,height:8,rx:2,fill:`url(#${f})`}),t&&O(E,{children:[D(`rect`,{x:0,y:6,width:Math.max(0,fracOf(u)),height:8,fill:`var(--cascivo-surface-base, white)`,fillOpacity:.6}),D(`rect`,{x:fracOf(d),y:6,width:Math.max(0,100-fracOf(d)),height:8,fill:`var(--cascivo-surface-base, white)`,fillOpacity:.6}),thumb(0,u),thumb(1,d)]})]})}var G={legend:`_legend_1pign_2`,item:`_item_1pign_9`,swatch:`_swatch_1pign_27`};function Legend({series:e,hidden:t}){return v(),D(`div`,{className:G.legend,role:`group`,"aria-label":`Chart legend`,children:e.map((e,n)=>{let r=t.value.has(e.id);return O(`button`,{type:`button`,className:G.item,"data-state":r?`off`:`on`,"aria-pressed":!r,"aria-label":T(C.charts.legendToggle,{name:e.label}),onClick:()=>{let n=new Set(t.value);r?n.delete(e.id):n.add(e.id),t.value=n},children:[D(`span`,{className:G.swatch,style:{background:e.color||`var(--cascivo-chart-${n+1})`},"aria-hidden":`true`}),e.label]},e.id)})})}function isProd(){return typeof process<`u`&&process.env.NODE_ENV===`production`}var K=new Set;function warnNonFinite(e,t){if(isProd()||K.has(e))return;let n=0;for(let e of t())Number.isFinite(e)||n++;n!==0&&(K.add(e),console.warn(`[cascivo charts] ${e}: ${n} non-finite value(s) (NaN/Infinity/null) in series data. These are dropped from the chart, which can make it look wrong — check your data source.`))}function warnOnce(e,t){isProd()||K.has(e)||(K.add(e),console.warn(`[cascivo charts] ${t}`))}function warnScaleMismatch(e,t){if(isProd())return;let n=t.filter(e=>Number.isFinite(e.max)&&e.max>0);if(n.length<2)return;let r=[...n].sort((e,t)=>t.max-e.max),i=r[0],a=r[r.length-1];i.max/a.max<20||warnOnce(`${e}:scale-mismatch`,`${e}: "${a.label}" (max ${a.max.toLocaleString()}) is more than 20× smaller than "${i.label}" (max ${i.max.toLocaleString()}) on the same axis, so it renders as a flat line at the baseline while the legend still names both. Put the smaller series on its own scale with \`axis: 'right'\` + \`secondAxis\`, or split it into a second chart.`)}function warnDualAxisAreas(e,t){if(isProd()||t.length<2)return;let[n,r]=[t[0],t[t.length-1]];warnOnce(`${e}:dual-axis-areas`,`${e}: "${n}" and "${r}" are on different axes but both paint an area fill, so they composite to a third colour wherever they cross. Dual-axis comparisons read as line-over-area: set \`type: 'line'\` on "${r}" (the secondary series), or split it into a second chart.`)}function warnEpochMilliseconds(e,t,n){isProd()||n||typeof t!=`number`||!Number.isFinite(t)||Math.abs(t)<1e11||warnOnce(`${e}:epoch-ms`,`${e}: \`x\` returned ${t}, which looks like epoch milliseconds but is typed \`number\`, so the axis uses a LINEAR scale and labels it with the raw value. Return a Date for a time axis: \`x={(d) => new Date(d.t)}\`. Pass \`format\` to control tick text (and to silence this if the values really are numeric).`)}var q=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function yDomain(e){return[Math.min(0,...e),Math.max(...e)]}function LineChart({series:e,x:t,y:n,title:a,description:s,curve:c=`monotone`,width:l,height:u,xTicks:d=5,yTicks:f=5,format:p,legend:m,tooltip:h,formatTooltip:b,className:C,plain:w,annotations:T,labels:k,connectNulls:A,onSelect:j,brush:M,dataZoom:ee,zoom:N,syncId:P,tooltipMode:I,secondAxis:L,decimate:R,toolbox:z,transition:B,onBeforeDraw:ne,onAfterDraw:re}){let V=t;v();let ie=g(new Set),H=w?null:resolveLabels(k),U=R===!0?{method:`lttb`,threshold:1e3}:R?{method:R.method??`lttb`,threshold:R.threshold??1e3}:null,W=e.reduce((e,t)=>Math.max(e,t.data.length),0),G=(M||ee||N||P!==void 0)&&W>0,K=g([0,Math.max(0,W-1)]),ae=S(null);P&&!ae.current&&(ae.current=getSyncGroup(P)),_(()=>()=>{P&&releaseSyncGroup(P)}),_(()=>{let e=ae.current;if(!e)return;let t=e.window.value,n=K.peek();t&&(t[0]!==n[0]||t[1]!==n[1])&&(K.value=t)}),_(()=>{let e=ae.current;if(!e)return;let t=K.value,n=e.window.peek();(!n||n[0]!==t[0]||n[1]!==t[1])&&(e.window.value=t)});let J=G?e.map(e=>({...e,data:e.data.slice(K.value[0],K.value[1]+1)})):e,Y=!w&&J.some(e=>e.axis===`right`),oe=u??(w?48:300),X=w?!1:m??J.length>1,yFor=e=>e.y??n,Z=J.flatMap(e=>e.data.map(e=>V(e))),finiteY=e=>e.flatMap(e=>e.data.map(t=>yFor(e)(t))).filter(e=>Number.isFinite(e)),se=finiteY(Y?J.filter(e=>e.axis!==`right`):J),ce=Y?finiteY(J.filter(e=>e.axis===`right`)):[];warnNonFinite(`LineChart`,()=>J.flatMap(e=>e.data.map(t=>yFor(e)(t))));let le=Z.length>0,ue=i(yDomain(se),[0,1]).ticks(f).map(e=>e.toLocaleString()),de=le&&Z[0]instanceof Date;warnEpochMilliseconds(`LineChart`,Z[0],p!==void 0);let fe=Y?i(yDomain(ce),[0,1]).ticks(f).map(e=>L?.format?L.format(e):e.toLocaleString()):[],pe=Z.filter(e=>typeof e==`number`),me=Z.filter(e=>e instanceof Date),he=le?de?timeScale([new Date(Math.min(...me.map(e=>e.getTime()))),new Date(Math.max(...me.map(e=>e.getTime())))],[0,1]).ticks(d).map(e=>e.toLocaleDateString()):i([Math.min(...pe),Math.max(...pe)],[0,1]).ticks(d).map(e=>e.toLocaleString()):[],Q=w?te:{...F,left:leftMarginForLabels(ue,w),right:rightMarginForLabels({rightAxisLabels:fe,bottomAxisLabels:he,rightAxisTitle:L?.label!==void 0&&L.label!==``,plain:w})};return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:a,description:s,width:l,height:oe,fallback:O(`table`,{children:[D(`caption`,{children:a}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`X`}),J.map(e=>D(`th`,{children:e.label},e.id))]})}),D(`tbody`,{children:(J[0]?.data??[]).map((e,t)=>O(`tr`,{children:[D(`td`,{children:String(J[0]?V(J[0].data[t]):``)}),J.map(e=>D(`td`,{children:e.data[t]==null?``:yFor(e)(e.data[t])},e.id))]},t))})]}),className:C,"data-state":le?void 0:`empty`,plain:w,tooltip:h!==!1&&le?({width:e,height:t})=>{if(h===!1||!le)return;let n=e-Q.left-Q.right,r=t-Q.top-Q.bottom,a=Math.min(...de?Z.map(e=>e.getTime()):Z),o=Math.max(...de?Z.map(e=>e.getTime()):Z),s=de?timeScale([new Date(a),new Date(o)],[0,n]):i([a,o],[0,n]),c=i(yDomain(se),[r,0]),l=Y?i(yDomain(ce),[r,0]):c,yOf=e=>e.axis===`right`?l:c,xPosOf=e=>s.map(e);if(I===`axis`){let e=J.reduce((e,t)=>Math.max(e,t.data.length),0),t=[];for(let n=0;n<e;n++){let e=[],r=0,i=0,a=1/0,o=``;J.forEach((t,s)=>{if(ie.value.has(t.id))return;let c=t.data[n];if(c===void 0)return;let l=yFor(t)(c);if(!Number.isFinite(l))return;let u=V(c);r+=xPosOf(u),i++,a=Math.min(a,yOf(t).map(l)),o=u instanceof Date?u.toLocaleDateString():String(u),e.push({label:t.label,value:l,color:t.color??q[s%q.length]})}),i!==0&&t.push({id:`x-${n}`,cx:Q.left+r/i,cy:Q.top+(a===1/0?0:a),label:o,value:o,segments:e})}return{points:t,mode:`axis`,format:e=>`${e.label}: ${(e.segments??[]).map(e=>`${e.label} ${e.value}`).join(`, `)}`}}let u=J.flatMap(e=>ie.value.has(e.id)?[]:e.data.flatMap((t,n)=>{let r=yFor(e)(t);if(!Number.isFinite(r))return[];let i=V(t),a=s.map(i),o=yOf(e).map(r),c=i instanceof Date?i.toLocaleDateString():String(i);return{id:`${e.id}-${n}`,cx:Q.left+a,cy:Q.top+o,label:c,value:yFor(e)(t),seriesId:e.id}}));return b?{points:u,format:e=>{let t=J.find(t=>t.id===e.seriesId),n=parseInt(e.id.split(`-`).pop()??`0`,10);return t&&t.data[n]!==void 0?b(t.data[n],t):`${e.label}: ${e.value}`}}:{points:u}}:void 0,onSelect:j,zoom:N&&W>1?{window:K,count:W}:void 0,toolbox:z,onRestore:G?()=>{K.value=[0,Math.max(0,W-1)]}:void 0,transition:B,onBeforeDraw:ne,onAfterDraw:re,children:({width:e,height:t})=>{let n=e-Q.left-Q.right,a=t-Q.top-Q.bottom,s=Math.min(...de?Z.map(e=>e.getTime()):Z),l=Math.max(...de?Z.map(e=>e.getTime()):Z),u=de?timeScale([new Date(s),new Date(l)],[0,n]):i([s,l],[0,n]),m=i(yDomain(se),[a,0]),h=Y?i(yDomain(ce),[a,0]):m;return D(`g`,{children:O(`g`,{transform:`translate(${Q.left},${Q.top})`,children:[!w&&D(GridLines,{scale:m,orientation:`y`,length:n,tickCount:f}),!w&&renderAnnotations(T,{xScale:u,yScale:m,innerW:n,innerH:a}),J.map((e,t)=>{if(ie.value.has(e.id))return null;let n=e.color??q[t%q.length],i=e.axis===`right`?h:m,xPos=e=>u.map(e);if(U&&e.data.length>U.threshold){let t=[];for(let n of e.data){let r=yFor(e)(n);Number.isFinite(r)&&t.push([xPos(V(n)),i.map(r)])}return D(`path`,{d:r(decimate(t,U.threshold,U.method).map(e=>[e[0],e[1]]),c),fill:`none`,stroke:n,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"data-series":e.id},e.id)}let a=e.data.map(t=>{let n=yFor(e)(t);return Number.isFinite(n)?[xPos(V(t)),i.map(n)]:null});return O(`g`,{children:[o(a,A).map((t,i)=>D(`path`,{d:r(t,c),fill:`none`,stroke:n,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,"data-series":e.id},i)),H&&e.data.map((t,n)=>{let r=a[n];return r?D(DataLabel,{x:r[0],y:r[1]-8,text:H.format(yFor(e)(t))},n):null})]},e.id)}),!w&&O(E,{children:[D(Axis,{scale:u,orientation:`x`,length:n,tickCount:d,transform:`translate(0,${a})`,...p?{format:e=>p(e)}:{}}),D(Axis,{scale:m,orientation:`y`,length:a,tickCount:f}),Y&&D(Axis,{scale:h,orientation:`y-right`,length:a,tickCount:f,transform:`translate(${n},0)`,...L?.format?{format:e=>L.format(Number(e))}:{},...L?.label!==void 0&&L.label!==``?{title:L.label,titleOffset:8+Math.ceil(fe.reduce((e,t)=>Math.max(e,t.length),0)*6.5)+10}:{}})]})]})})}}),M&&!ee&&W>1&&D(Brush,{count:W,window:K,label:`Time range`}),ee&&W>1&&D(DataZoom,{count:W,window:K,label:`Time range`}),X&&D(Legend,{series:J.map((e,t)=>({id:e.id,label:e.label,color:e.color??q[t%q.length]})),hidden:ie})]})}var ae={fillOpacity:`var(--cascivo-chart-fill-opacity, 0.25)`};function solidFillStyle(e,t){return t||e<=1?ae:{fillOpacity:`var(--cascivo-chart-fill-opacity-overlap, 0.12)`}}var J=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function AreaChart({series:e,x:t,y:n,title:a,description:o,stacked:l=!1,curve:u=`monotone`,fill:d,patternKind:f,width:p,height:m,xTicks:h=5,yTicks:C=5,legend:w,tooltip:T,className:k,plain:A,annotations:j,labels:M,onSelect:ee,brush:N,dataZoom:P,zoom:I,syncId:L,tooltipMode:R,secondAxis:z,decimate:B,toolbox:ne,format:re}){let V=t;v();let ie=b(),H=g(new Set),U=A?null:resolveLabels(M),W=B===!0?{method:`lttb`,threshold:1e3}:B?{method:B.method??`lttb`,threshold:B.threshold??1e3}:null,G=e.reduce((e,t)=>Math.max(e,t.data.length),0),K=(N||P||I||L!==void 0)&&G>0,q=g([0,Math.max(0,G-1)]),ae=S(null);L&&!ae.current&&(ae.current=getSyncGroup(L)),_(()=>()=>{L&&releaseSyncGroup(L)}),_(()=>{let e=ae.current;if(!e)return;let t=e.window.value,n=q.peek();t&&(t[0]!==n[0]||t[1]!==n[1])&&(q.value=t)}),_(()=>{let e=ae.current;if(!e)return;let t=q.value,n=e.window.peek();(!n||n[0]!==t[0]||n[1]!==t[1])&&(e.window.value=t)});let Y=K?e.map(e=>({...e,data:e.data.slice(q.value[0],q.value[1]+1)})):e,oe=d??(Y.length===1&&!l?`gradient`:`solid`),X=!A&&!l&&Y.some(e=>e.axis===`right`),Z=m??(A?48:300),se=A?!1:w??Y.length>1,ce=solidFillStyle(Y.filter(e=>e.type!==`line`).length,l),yFor=e=>e.y??n,le=(Y[0]?.data??[]).map(e=>V(e)),ue=(X?Y.filter(e=>e.axis!==`right`):Y).flatMap(e=>e.data.map(t=>yFor(e)(t))),de=X?Y.filter(e=>e.axis===`right`).flatMap(e=>e.data.map(t=>yFor(e)(t))):[];!X&&!l&&Y.length>1&&warnScaleMismatch(`AreaChart`,Y.map(e=>({label:e.label,max:Math.max(0,...e.data.map(t=>yFor(e)(t)).filter(e=>Number.isFinite(e)))}))),X&&warnDualAxisAreas(`AreaChart`,Y.filter(e=>e.type!==`line`).map(e=>e.label)),warnNonFinite(`AreaChart`,()=>[...ue,...de]);let fe=le.length>0,pe=fe&&le[0]instanceof Date;warnEpochMilliseconds(`AreaChart`,le[0],re!==void 0);let me=le.map(e=>e instanceof Date?e.getTime():e),he=fe?Math.min(...me):0,Q=fe?Math.max(...me):1,makeXScale=e=>pe?timeScale([new Date(he),new Date(Q)],[0,e]):i([he,Q],[0,e]),mapX=(e,t)=>e.map(V(t)),labelOf=e=>{let t=V(e);return t instanceof Date?t.toLocaleDateString():String(t)},ge=l?0:Math.min(0,...ue),_e=Math.max(...l?(Y[0]?.data??[]).map((e,t)=>Y.reduce((e,n)=>e+yFor(n)(n.data[t]),0)):ue),ve=X?Math.min(0,...de):ge,ye=X?Math.max(...de):_e,be=i([ge,_e],[0,1]).ticks(C).map(e=>e.toLocaleString()),xe=X?i([ve,ye],[0,1]).ticks(C).map(e=>z?.format?z.format(e):e.toLocaleString()):[],Se=pe?timeScale([new Date(he),new Date(Q)],[0,1]).ticks(h).map(e=>e.toLocaleDateString()):i([he,Q],[0,1]).ticks(h).map(e=>e.toLocaleString()),$=A?te:{...F,left:leftMarginForLabels(be,A),right:rightMarginForLabels({rightAxisLabels:xe,bottomAxisLabels:Se,rightAxisTitle:z?.label!==void 0&&z.label!==``,plain:A})};return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:a,description:o,width:p,height:Z,fallback:O(`table`,{children:[D(`caption`,{children:a}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`X`}),Y.map(e=>D(`th`,{children:e.label},e.id))]})}),D(`tbody`,{children:(Y[0]?.data??[]).map((e,t)=>O(`tr`,{children:[D(`td`,{children:Y[0]?labelOf(Y[0].data[t]):``}),Y.map(e=>D(`td`,{children:e.data[t]==null?``:yFor(e)(e.data[t])},e.id))]},t))})]}),className:k,"data-state":fe?void 0:`empty`,plain:A,tooltip:T!==!1&&fe?({width:e,height:t})=>{if(T===!1||!fe)return;let n=e-$.left-$.right,r=t-$.top-$.bottom,a=makeXScale(n),o=i([ge,_e],[r,0]),s=X?i([ve,ye],[r,0]):o,yOf=e=>e.axis===`right`?s:o;if(R===`axis`){let e=Y.reduce((e,t)=>Math.max(e,t.data.length),0),t=[];for(let n=0;n<e;n++){let e=[],r=1/0,i=``,o=$.left;Y.forEach((t,s)=>{if(H.value.has(t.id))return;let c=t.data[n];if(c===void 0)return;let l=yFor(t)(c);Number.isFinite(l)&&(o=$.left+mapX(a,c),r=Math.min(r,yOf(t).map(l)),i=labelOf(c),e.push({label:t.label,value:l,color:t.color??J[s%J.length]}))}),e.length!==0&&t.push({id:`x-${n}`,cx:o,cy:$.top+(r===1/0?0:r),label:i,value:i,segments:e})}return{points:t,mode:`axis`,format:e=>`${e.label}: ${(e.segments??[]).map(e=>`${e.label} ${e.value}`).join(`, `)}`}}return{points:Y.flatMap(e=>H.value.has(e.id)?[]:e.data.map((t,n)=>({id:`${e.id}-${n}`,cx:$.left+mapX(a,t),cy:$.top+yOf(e).map(yFor(e)(t)),label:labelOf(t),value:yFor(e)(t),seriesId:e.id})))}}:void 0,onSelect:ee,zoom:I&&G>1?{window:q,count:G}:void 0,toolbox:ne,onRestore:K?()=>{q.value=[0,Math.max(0,G-1)]}:void 0,children:({width:e,height:t})=>{let n=e-$.left-$.right,a=t-$.top-$.bottom,o=makeXScale(n),d=i([ge,_e],[a,0]),p=X?i([ve,ye],[a,0]):d,m=[];return l&&(m=c(Y.map(e=>e.data.map(t=>yFor(e)(t))))),O(`g`,{children:[oe!==`solid`&&D(ChartDefs,{prefix:ie,fill:oe,patternKind:f,series:Y.map((e,t)=>({id:e.id,color:e.color??J[t%J.length]}))}),O(`g`,{transform:`translate(${$.left},${$.top})`,children:[!A&&D(GridLines,{scale:d,orientation:`y`,length:n,tickCount:C}),!A&&renderAnnotations(j,{xScale:o,yScale:d,innerW:n,innerH:a}),Y.map((e,t)=>{if(H.value.has(e.id))return null;let n=e.color??J[t%J.length],i,a;if(l&&m[t]){let s=m[t];i=e.data.map((e,t)=>[mapX(o,e),d.map(s[t][1])]);let c=e.data.map((e,t)=>[mapX(o,e),d.map(s[t][0])]);a=d.map(0);let l=r(i,u),f=c[c.length-1],p=c[0],h=[...c].reverse().map(([e,t])=>`L${e},${t}`).join(``),g=`${l}L${f[0]},${f[1]}${h}L${p[0]},${p[1]}Z`;return O(`g`,{"data-series":e.id,children:[D(`path`,{d:g,fill:fillFor(ie,e.id,oe,n),style:oe===`solid`?ce:void 0,stroke:`none`}),D(`path`,{d:r(i,u),fill:`none`,stroke:n,strokeWidth:2}),U&&i.map((t,n)=>D(DataLabel,{x:t[0],y:t[1]-8,text:U.format(yFor(e)(e.data[n]))},n))]},e.id)}else{let t=e.axis===`right`?p:d;if(i=e.data.map(n=>[mapX(o,n),t.map(yFor(e)(n))]),a=t.map(0),W&&i.length>W.threshold){let t=decimate(i,W.threshold,W.method).map(e=>[e[0],e[1]]);return O(`g`,{"data-series":e.id,children:[e.type!==`line`&&D(`path`,{d:s(t,a,u),fill:fillFor(ie,e.id,oe,n),style:oe===`solid`?ce:void 0,stroke:`none`}),D(`path`,{d:r(t,u),fill:`none`,stroke:n,strokeWidth:2})]},e.id)}return O(`g`,{"data-series":e.id,children:[e.type!==`line`&&D(`path`,{d:s(i,a,u),fill:fillFor(ie,e.id,oe,n),style:oe===`solid`?ce:void 0,stroke:`none`}),D(`path`,{d:r(i,u),fill:`none`,stroke:n,strokeWidth:2}),U&&i.map((t,n)=>D(DataLabel,{x:t[0],y:t[1]-8,text:U.format(yFor(e)(e.data[n]))},n))]},e.id)}}),!A&&O(E,{children:[D(Axis,{scale:o,orientation:`x`,length:n,tickCount:h,transform:`translate(0,${a})`,...re?{format:e=>re(e)}:{}}),D(Axis,{scale:d,orientation:`y`,length:a,tickCount:C}),X&&D(Axis,{scale:p,orientation:`y-right`,length:a,tickCount:C,transform:`translate(${n},0)`,...z?.format?{format:e=>z.format(Number(e))}:{},...z?.label!==void 0&&z.label!==``?{title:z.label,titleOffset:8+Math.ceil(xe.reduce((e,t)=>Math.max(e,t.length),0)*6.5)+10}:{}})]})]})]})}}),N&&!P&&G>1&&D(Brush,{count:G,window:q,label:`Range`}),P&&G>1&&D(DataZoom,{count:G,window:q,label:`Range`}),se&&D(Legend,{series:Y.map((e,t)=>({id:e.id,label:e.label,color:e.color??J[t%J.length]})),hidden:H})]})}function resolveColor$1(e,t,n,r){return typeof e==`function`?t===void 0?r:e(t,n):e??r}var Y=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function stackedFormat(e){let t=e.segments?.filter(e=>e.value!==0)??[],n=`${e.label} · ${e.value}`;return t.length>0?`${n} — ${t.map(e=>`${e.label}: ${e.value}`).join(`, `)}`:n}function BarChart({series:e,x:n,y:r,title:a,description:o,orientation:s=`vertical`,mode:l=`grouped`,width:u,height:d,valueAxisTicks:f,categoryAxisTicks:p,xLabelEvery:m,categoryLabelEvery:h,legend:_,tooltip:S,tooltipFormat:C,className:w,plain:T,annotations:k,labels:A,onSelect:j,fill:M=`solid`,patternKind:ee,format:N}){v();let P=b(),I=T?null:resolveLabels(A),L=g(new Set),R=d??(T?48:300),z=T?!1:_??e.length>1,yFor=e=>e.y??r,B=(e[0]?.data??[]).map(e=>n(e)),ne=e.flatMap(e=>e.data.map(t=>yFor(e)(t))),re=B.length>0,V=l===`stacked`||l===`percent`,ie=B.map((t,n)=>e.reduce((e,t)=>e+yFor(t)(t.data[n]),0)),computeOffsets=()=>{let t=c(e.map(e=>e.data.map(t=>yFor(e)(t))));return l===`percent`?t.map(e=>e.map(([e,t],n)=>{let r=ie[n]||1;return[e/r,t/r]})):t},H=V?0:Math.min(0,...ne),U=re?Math.max(...ie):1,W=l===`percent`?1:l===`stacked`?U:Math.max(1,...ne),G=l===`percent`?e=>`${Math.round(Number(e)*100)}%`:void 0,K=s===`vertical`,q=(K?f:p)??5,ae=(K?p:f)??5,J=h??m,oe=K?i([H,W],[0,1]).ticks(q).map(e=>G?G(e):e.toLocaleString()):B.map(e=>String(e)),X=K?B.map(e=>String(e)):i([H,W],[0,1]).ticks(ae).map(e=>G?G(e):e.toLocaleString()),Z=T?te:{...F,left:leftMarginForLabels(oe,T),right:rightMarginForLabels({bottomAxisLabels:X,plain:T})};return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:a,description:o,width:u,height:R,fallback:O(`table`,{children:[D(`caption`,{children:a}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Category`}),e.map(e=>D(`th`,{children:e.label},e.id))]})}),D(`tbody`,{children:B.map((t,n)=>O(`tr`,{children:[D(`td`,{children:t}),e.map(e=>D(`td`,{children:e.data[n]==null?``:yFor(e)(e.data[n])},e.id))]},t))})]}),className:w,"data-state":re?void 0:`empty`,plain:T,tooltip:S&&re?({width:r,height:a})=>{if(!S||!re)return;let o=r-Z.left-Z.right,c=a-Z.top-Z.bottom,u=s===`vertical`,d=t(B,u?[0,o]:[0,c],.2),f=i([H,W],u?[c,0]:[0,o]),p=e.filter(e=>!L.value.has(e.id)),m=[];V&&(m=computeOffsets());let h=V&&!C,g=B.map((t,n)=>{let r=p.map(t=>({label:t.label,value:yFor(t)(t.data[n]),color:resolveColor$1(t.color,t.data[n],n,Y[e.indexOf(t)%Y.length])}));return{segs:r,total:r.reduce((e,t)=>e+t.value,0)}}),_=p.flatMap(t=>{let r=e.indexOf(t),i=l===`grouped`?d.bandwidth/p.length:d.bandwidth;return t.data.map((e,a)=>{let o=d.map(n(e))??0,s,c;if(V&&m[r]){let e=m[r][a];s=e[1],c=e[0]}else s=yFor(t)(e),c=H;let _=p.indexOf(t),v=o+(l===`grouped`?_*i:0)+i/2,b=(Math.min(f.map(s),f.map(c))+Math.max(f.map(s),f.map(c)))/2;return{id:`${t.id}-${a}`,cx:Z.left+(u?v:b),cy:Z.top+(u?b:v),label:n(e),value:h?g[a].total:yFor(t)(e),seriesId:t.id,...h&&{segments:g[a].segs}}})}),v=C??(h?stackedFormat:void 0);return v?{points:_,format:v}:{points:_}}:void 0,onSelect:j,children:({width:r,height:a})=>{let o=r-Z.left-Z.right,c=a-Z.top-Z.bottom,u=s===`vertical`,d=J??autoLabelStride(B,u?o:c,u?`horizontal`:`vertical`),f=t(B,u?[0,o]:[0,c],.2),p=i([H,W],u?[c,0]:[0,o]),m=e.filter(e=>!L.value.has(e.id)),h=[];return V&&(h=computeOffsets()),O(`g`,{children:[M!==`solid`&&D(ChartDefs,{prefix:P,fill:M,patternKind:ee,series:e.map((e,t)=>({id:e.id,color:resolveColor$1(e.color,e.data[0],0,Y[t%Y.length])}))}),O(`g`,{transform:`translate(${Z.left},${Z.top})`,children:[!T&&u&&D(GridLines,{scale:p,orientation:`y`,length:o,tickCount:q}),!T&&!u&&D(GridLines,{scale:p,orientation:`x`,length:c,tickCount:ae}),!T&&renderAnnotations(k,{xScale:u?f:p,yScale:u?p:f,innerW:o,innerH:c}),m.map((t,r)=>{let i=Y[e.indexOf(t)%Y.length],a=e.indexOf(t),o=l===`grouped`?f.bandwidth/m.length:f.bandwidth;return t.data.map((e,s)=>{let c=f.map(n(e))??0,d,m;if(V&&h[a]){let e=h[a][s];d=e[1],m=e[0]}else d=yFor(t)(e),m=H;let g=c+(l===`grouped`?r*o:0),_=Math.min(p.map(d),p.map(m)),v=Math.abs(p.map(d)-p.map(m)),b=null;if(I){let n=I.format(yFor(t)(e)),r=g+o/2,i=V||v<18||_<14;if(u)b=D(DataLabel,{x:r,y:i?_+13:_-4,text:n,tone:i?`muted`:`default`});else{let e=_+v;b=D(DataLabel,{x:i?e-4:e+4,y:r+4,text:n,anchor:i?`end`:`start`,tone:i?`muted`:`default`})}V&&v<14&&(b=null)}let S=resolveColor$1(t.color,e,s,i);return O(`g`,{children:[u?D(`rect`,{x:g,y:_,width:o,height:v,fill:fillFor(P,t.id,M,S),rx:2,"data-series":t.id,"data-x":String(n(e))}):D(`rect`,{x:_,y:g,width:v,height:o,fill:fillFor(P,t.id,M,S),rx:2,"data-series":t.id,"data-x":String(n(e))}),b]},`${t.id}-${s}`)})}),!T&&u&&O(E,{children:[D(Axis,{scale:f,orientation:`x`,length:o,tickCount:ae,labelEvery:d,transform:`translate(0,${c})`,...N?{format:N}:{}}),D(Axis,{scale:p,orientation:`y`,length:c,tickCount:q,...G&&{format:G}})]}),!T&&!u&&O(E,{children:[D(Axis,{scale:p,orientation:`x`,length:o,tickCount:ae,...G&&{format:G},transform:`translate(0,${c})`}),D(Axis,{scale:f,orientation:`y`,length:c,tickCount:q,labelEvery:d})]})]})]})}}),z&&D(Legend,{series:e.map((e,t)=>({id:e.id,label:e.label,color:resolveColor$1(e.color,e.data[0],0,Y[t%Y.length])})),hidden:L})]})}function pieDefaultFormat(e){let t=e.percent==null?0:Math.round(e.percent);return`${e.value} (${t}%)`}var oe=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function PieChart({data:t,title:n,description:r,donut:i=!1,width:o,height:s,size:c,thickness:l,innerRadius:u,centerValue:d,centerLabel:f,centerSlot:p,emptyLabel:m,tooltip:h,tooltipFormat:_,legend:b,className:S,plain:C,labels:w,onSelect:T}){let E=C?null:resolveLabels(w),k=typeof w==`object`&&!!w&&w.format!=null,A=o??c,j=s??c??(C?48:300),M=C?!1:b??!0;v();let ee=g(new Set),N=t.length>0;return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:n,description:r,width:A,height:j,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Label`}),D(`th`,{children:`Value`}),D(`th`,{children:`Percent`})]})}),D(`tbody`,{children:t.map(e=>{let n=t.reduce((e,t)=>e+t.value,0),r=n>0?(e.value/n*100).toFixed(1):`0`;return O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.value}),O(`td`,{children:[r,`%`]})]},e.id)})})]}),className:S,"data-state":N?void 0:`empty`,emptyLabel:m,plain:C,tooltip:h!==!1&&N?({width:n,height:r})=>{if(!N)return;let i=n/2,a=r/2,o=Math.min(i,a)-8,s=t.filter(e=>!ee.value.has(e.id)),c=s.reduce((e,t)=>e+t.value,0),l=0;return{points:s.map((t,n)=>{let r=c>0?t.value/c*2*Math.PI:0,s=l+r,u=(l+s)/2;return l=s,{id:t.id,cx:e(i+Math.sin(u)*o*.65),cy:e(a-Math.cos(u)*o*.65),label:t.label,value:t.value,seriesId:String(n),percent:c>0?t.value/c*100:0,color:t.color??oe[n%oe.length]}}),format:_??pieDefaultFormat}}:void 0,onSelect:T,children:({width:n,height:r})=>{let o=n/2,s=r/2,c=Math.min(o,s)-8,m=u??(l==null?c*.6:c-l),h=i?Math.max(0,Math.min(m,c)):0,g=t.filter(e=>!ee.value.has(e.id)),_=g.reduce((e,t)=>e+t.value,0),v=0,b=i&&(d!=null||f!=null||p!=null);return O(`g`,{children:[g.map((t,n)=>{let r=_>0?t.value/_*2*Math.PI:0,i=v+r,l=(v+i)/2,u=t.color??oe[n%oe.length],d=a(o,s,c,h,v,i);v=i;let f=_>0?t.value/_*100:0,p=E&&f>=4,m=h>0?(h+c)/2:c*.6;return O(`g`,{children:[D(`path`,{d,fill:u,stroke:`var(--cascivo-color-surface)`,strokeWidth:1,"data-series":t.id}),p&&D(DataLabel,{x:e(o+Math.sin(l)*m),y:e(s-Math.cos(l)*m+4),text:k?E.format(t.value):`${Math.round(f)}%`,tone:`muted`})]},t.id)}),b&&(p==null?O(`g`,{"data-center":``,children:[d!=null&&D(`text`,{x:o,y:f==null?s:s-8,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`1.5rem`,fontWeight:700,fill:`var(--cascivo-color-foreground)`,children:d}),f!=null&&D(`text`,{x:o,y:d==null?s:s+14,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`0.8125rem`,fill:`var(--cascivo-color-foreground-muted)`,children:f})]}):D(`foreignObject`,{x:o-h,y:s-h,width:h*2,height:h*2,"data-center-slot":``,children:D(`div`,{style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,textAlign:`center`},children:p})}))]})}}),M&&D(Legend,{series:t.map((e,t)=>({id:e.id,label:e.label,color:e.color??oe[t%oe.length]})),hidden:ee})]})}var X=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function ScatterChart({series:e,title:t,description:n,r=4,width:a,height:o,xTicks:s=5,yTicks:c=5,legend:l,tooltip:u,className:d,plain:f,annotations:p,onSelect:m,glyph:h,renderer:_=`svg`,visualMap:b,toolbox:S,format:C}){v();let w=g(new Set),T=f?te:F,k=o??(f?48:300),A=f?!1:l??e.length>1,j=e.reduce((e,t)=>e+t.data.length,0),M=!b&&(_===`canvas`||_===`auto`&&j>2e3),ee=g([b?.min??0,b?.max??1]),N=g(new Set),paint=(t,{width:n,height:a})=>{let o=n-T.left-T.right,s=a-T.top-T.bottom;if(o<=0||s<=0)return;let c=i([R,z],[0,o]),l=i([B,ne],[s,0]);e.forEach((e,n)=>{if(!w.value.has(e.id)){t.fillStyle=resolveColor(t,e.color??X[n%X.length]),t.globalAlpha=.7;for(let n of e.data){let e=typeof r==`function`?r(n):n.r??r;t.beginPath(),t.arc(T.left+c.map(n.x),T.top+l.map(n.y),e,0,Math.PI*2),t.fill()}}}),t.globalAlpha=1},P=e.flatMap(e=>e.data.map(e=>e.x)),I=e.flatMap(e=>e.data.map(e=>e.y)),L=P.length>0,R=L?Math.min(...P):0,z=L?Math.max(...P):1,B=L?Math.min(0,...I):0,ne=L?Math.max(...I):1;return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:t,description:n,width:a,height:k,fallback:O(`table`,{children:[D(`caption`,{children:t}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Series`}),D(`th`,{children:`X`}),D(`th`,{children:`Y`})]})}),D(`tbody`,{children:e.flatMap(e=>e.data.map((t,n)=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:t.x}),D(`td`,{children:t.y})]},`${e.id}-${n}`)))})]}),className:d,"data-state":L?void 0:`empty`,plain:f,tooltip:u!==!1&&L?({width:t,height:n})=>{if(u===!1||!L)return;let r=t-T.left-T.right,a=n-T.top-T.bottom,o=i([R,z],[0,r]),s=i([B,ne],[a,0]);return{points:e.flatMap(e=>w.value.has(e.id)?[]:e.data.map((t,n)=>({id:`${e.id}-${n}`,cx:T.left+o.map(t.x),cy:T.top+s.map(t.y),label:`(${t.x}, ${t.y})`,value:t.y,seriesId:e.id})))}}:void 0,onSelect:m,hover:`voronoi`,renderer:M?`canvas`:`svg`,paint:M?paint:void 0,toolbox:S,onRestore:b?()=>{ee.value=[b.min,b.max],N.value=new Set}:void 0,children:({width:t,height:n})=>{let a=t-T.left-T.right,o=n-T.top-T.bottom,l=i([R,z],[0,a]),u=i([B,ne],[o,0]);return D(`g`,{children:O(`g`,{transform:`translate(${T.left},${T.top})`,children:[!f&&D(GridLines,{scale:u,orientation:`y`,length:a,tickCount:c}),!f&&renderAnnotations(p,{xScale:l,yScale:u,innerW:a,innerH:o}),!M&&e.map((e,t)=>{if(w.value.has(e.id))return null;let n=e.color??X[t%X.length];return D(`g`,{"data-series":e.id,children:e.data.map((t,i)=>{let a=typeof r==`function`?r(t):t.r??r,o=b?mapVisual(t.y,b):void 0,s=o?.size??a,c=o?.color??n,d=b?visualVisible(t.y,b,ee.value,N.value):!0,f=d?.7:.1,p=typeof h==`function`?h(t,e.id):h;return p&&p!==`circle`?D(Glyph,{shape:p,x:l.map(t.x),y:u.map(t.y),size:s*2,color:c,opacity:d?.75:.1,stroke:c,strokeWidth:1},i):D(`circle`,{cx:l.map(t.x),cy:u.map(t.y),r:s,fill:c,fillOpacity:f,stroke:c,strokeWidth:1},i)})},e.id)}),!f&&O(E,{children:[D(Axis,{scale:l,orientation:`x`,length:a,tickCount:s,transform:`translate(0,${o})`,...C?{format:C}:{}}),D(Axis,{scale:u,orientation:`y`,length:o,tickCount:c})]})]})})}}),b&&L&&D(VisualMap,{options:b,range:ee,hidden:N,label:t}),A&&D(Legend,{series:e.map((e,t)=>({id:e.id,label:e.label,color:e.color??X[t%X.length]})),hidden:w})]})}function Sparkline({data:e,width:t=120,height:n=32,label:a,ariaLabel:o,color:s=`var(--cascivo-chart-1)`,endDot:c=!0}){return D(ChartFrame,{title:a??o,width:t,height:n,plain:!0,tooltip:e.length>0?(()=>{if(e.length===0)return;let r=i([0,e.length-1],[2,t-2]),a=Math.min(...e),o=Math.max(...e),s=i([a===o?a-1:a,o],[n-2,2]);return{points:e.map((e,t)=>({id:String(t),cx:r.map(t),cy:s.map(e),label:String(t),value:e}))}})():void 0,children:()=>{if(e.length===0)return null;let a=i([0,e.length-1],[2,t-2]),o=Math.min(...e),l=Math.max(...e),u=i([o===l?o-1:o,l],[n-2,2]),d=e.map((e,t)=>[a.map(t),u.map(e)]),f=r(d,`monotone`),p=d[d.length-1];return O(E,{children:[D(`path`,{d:f,fill:`none`,stroke:s,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}),c&&D(`circle`,{cx:p[0],cy:p[1],r:2.5,fill:s})]})}})}var Z={meter:`_meter_cns3q_2`,svg:`_svg_cns3q_9`,label:`_label_cns3q_16`,gaugeLabel:`_gaugeLabel_cns3q_22`,fill:`_fill_cns3q_28`};function fillColor(e,t){if(!t)return`var(--cascivo-chart-1)`;let{warning:n,critical:r}=t;return r!=null&&e>=r?`var(--cascivo-color-destructive)`:n!=null&&e>=n?`var(--cascivo-color-warning)`:`var(--cascivo-color-success)`}function Meter({value:e,min:t=0,max:n=100,label:r,variant:i=`bar`,thresholds:o,width:s,height:c}){let{ref:l,width:u}=useChartSize(200,100),d=s??u.value,f=n>t?(Math.min(n,Math.max(t,e))-t)/(n-t):0,p=fillColor(e,o);if(i===`gauge`){let i=c??100,o=d,s=o/2,u=i*.9,m=Math.min(s,u)-4,h=m*.65,g=Math.PI,_=a(s,u,m,h,g,2*Math.PI),v=g+f*Math.PI,b=f>0?a(s,u,m,h,g,v):``;return O(`div`,{ref:l,className:Z.meter,"aria-label":r,role:`meter`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,children:[O(`svg`,{className:Z.svg,width:o,height:i,viewBox:`0 0 ${o} ${i}`,"aria-hidden":`true`,children:[D(`path`,{d:_,fill:`var(--cascivo-color-border)`}),b&&D(`path`,{d:b,fill:p})]}),O(`div`,{className:Z.gaugeLabel,children:[r,`: `,e]})]})}let m=c??12,h=d;return O(`div`,{ref:l,className:Z.meter,"aria-label":r,role:`meter`,"aria-valuenow":e,"aria-valuemin":t,"aria-valuemax":n,children:[O(`svg`,{className:Z.svg,width:h,height:m,viewBox:`0 0 ${h} ${m}`,"aria-hidden":`true`,children:[D(`rect`,{x:0,y:0,width:h,height:m,rx:m/2,fill:`var(--cascivo-color-border)`}),D(`rect`,{x:0,y:0,width:h,height:m,rx:m/2,fill:p,className:Z.fill,style:{transform:`scaleX(${f})`}})]}),D(`div`,{className:Z.label,children:r})]})}var se={kpi:`_kpi_nrb8p_7`,head:`_head_nrb8p_19`,label:`_label_nrb8p_27`,valueRow:`_valueRow_nrb8p_34`,value:`_value_nrb8p_34`,delta:`_delta_nrb8p_49`};function formatDelta(e,t){if(typeof t==`function`)return t(e);let n=e>=0?`+`:``,r=e.toLocaleString(w());return t===`percent`?`${n}${r}%`:`${n}${r}`}function Kpi({value:e,label:t,delta:n,deltaFormat:r=`number`,goodDirection:i=`up`,deltaLabel:a,icon:o,sparkline:s,className:c}){let l=n!=null&&n>=0,u=n!=null&&n<0,d=l?`up`:u?`down`:`flat`;return O(`div`,{className:[se.kpi,c].filter(Boolean).join(` `),children:[O(`div`,{className:se.head,children:[D(`span`,{className:se.label,children:t}),o&&D(`span`,{"aria-hidden":`true`,children:o})]}),O(`div`,{className:se.valueRow,children:[D(`span`,{className:se.value,children:typeof e==`number`?e.toLocaleString(w()):e}),n!=null&&O(`span`,{role:`img`,className:se.delta,"data-trend":d,"data-sentiment":p(d,i),"aria-label":`Trend: ${formatDelta(n,r)}${a?` ${a}`:``}`,children:[l?`▲`:u?`▼`:`–`,` `,formatDelta(n,r),a&&` ${a}`]})]}),s&&s.length>0&&D(Sparkline,{data:s,label:`${t} trend`,height:32})]})}function Histogram({data:e,bins:t,title:n,label:r,description:a,width:o,height:s,className:c,plain:l,format:u}){v();let d=l?te:r===``?F:{...F,bottom:48},f=s??(l?48:300),p=binValues(e,t),m=p.reduce((e,t)=>Math.max(e,t.count),0);return D(ChartFrame,{title:n,description:a,width:o,height:f,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Range`}),D(`th`,{children:`Count`})]})}),D(`tbody`,{children:p.map((e,t)=>O(`tr`,{children:[O(`td`,{children:[e.x0.toFixed(2),` – `,e.x1.toFixed(2)]}),D(`td`,{children:e.count})]},t))})]}),className:c,plain:l,tooltip:p.length>0?({width:e,height:t})=>{if(p.length===0)return;let n=e-d.left-d.right,r=t-d.top-d.bottom,a=i([p[0]?.x0??0,p[p.length-1]?.x1??1],[0,n]),o=i([0,m||1],[r,0]);return{points:p.map((e,t)=>{let n=a.map(e.x0),r=Math.max(0,a.map(e.x1)-n-1);return{id:`bin-${t}`,cx:d.left+n+r/2,cy:d.top+o.map(e.count),label:`${e.x0.toFixed(2)}–${e.x1.toFixed(2)}`,value:e.count}})}}:void 0,children:({width:e,height:t})=>{let n={width:e-d.left-d.right,height:t-d.top-d.bottom};if(n.width<=0||p.length===0)return null;let a=i([p[0]?.x0??0,p[p.length-1]?.x1??1],[0,n.width]),o=i([0,m||1],[n.height,0]);return O(`g`,{transform:`translate(${d.left},${d.top})`,children:[!l&&D(GridLines,{scale:o,orientation:`y`,length:n.width}),p.map((e,t)=>{let r=a.map(e.x0),i=Math.max(0,a.map(e.x1)-r-1),s=o.map(e.count),c=n.height-s;return D(`rect`,{x:r,y:s,width:i,height:Math.max(0,c),fill:`var(--cascivo-chart-1)`,opacity:.85},t)}),!l&&O(E,{children:[D(Axis,{scale:a,orientation:`x`,length:n.width,transform:`translate(0,${n.height})`,title:r,...u?{format:u}:{}}),D(Axis,{scale:o,orientation:`y`,length:n.height})]})]})}})}var ce=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Boxplot({series:e,title:n,description:r,width:a,height:o,className:s,plain:c,format:l}){v();let u=c?te:F,d=o??(c?48:320),f=e.map(e=>({...e,stats:boxStats(e.values)})),p=e.flatMap(e=>e.values),[m,h]=p.length>0?extent(p):[0,1];return D(ChartFrame,{title:n,description:r,width:a,height:d,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Series`}),D(`th`,{children:`Min`}),D(`th`,{children:`Q1`}),D(`th`,{children:`Median`}),D(`th`,{children:`Q3`}),D(`th`,{children:`Max`})]})}),D(`tbody`,{children:f.map(e=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.stats.min.toFixed(2)}),D(`td`,{children:e.stats.q1.toFixed(2)}),D(`td`,{children:e.stats.median.toFixed(2)}),D(`td`,{children:e.stats.q3.toFixed(2)}),D(`td`,{children:e.stats.max.toFixed(2)})]},e.id))})]}),className:s,plain:c,tooltip:f.length>0?({width:e,height:n})=>{if(f.length===0)return;let r=e-u.left-u.right,a=n-u.top-u.bottom;if(r<=0)return;let o=t(f.map(e=>e.id),[0,r],.3),s=(h-m)*.05||1,c=i([m-s,h+s],[a,0]);return{points:f.map(e=>{let t=(o.map(e.id)??0)+o.bandwidth/2;return{id:e.id,cx:u.left+t,cy:u.top+c.map(e.stats.median),label:e.label,value:e.stats.median}}),format:e=>{let t=f.find(t=>t.id===e.id);return t?`${t.label}: min ${t.stats.min.toFixed(2)} / Q1 ${t.stats.q1.toFixed(2)} / med ${t.stats.median.toFixed(2)} / Q3 ${t.stats.q3.toFixed(2)} / max ${t.stats.max.toFixed(2)}`:`${e.label}: ${e.value}`}}}:void 0,children:({width:e,height:n})=>{let r={width:e-u.left-u.right,height:n-u.top-u.bottom};if(r.width<=0||f.length===0)return null;let a=t(f.map(e=>e.id),[0,r.width],.3),o=(h-m)*.05||1,s=i([m-o,h+o],[r.height,0]);return O(`g`,{transform:`translate(${u.left},${u.top})`,children:[f.map((e,t)=>{let n=ce[t%ce.length]??`var(--cascivo-chart-1)`,r=(a.map(e.id)??0)+a.bandwidth/2,i=a.bandwidth*.6,o=r-i/2,c=s.map(e.stats.q1),l=s.map(e.stats.q3),u=s.map(e.stats.median),d=s.map(e.stats.min),f=s.map(e.stats.max);return O(`g`,{children:[D(`line`,{x1:r,y1:l,x2:r,y2:f,stroke:n,strokeWidth:1.5}),D(`line`,{x1:r,y1:c,x2:r,y2:d,stroke:n,strokeWidth:1.5}),D(`line`,{x1:r-i/4,y1:f,x2:r+i/4,y2:f,stroke:n,strokeWidth:1.5}),D(`line`,{x1:r-i/4,y1:d,x2:r+i/4,y2:d,stroke:n,strokeWidth:1.5}),D(`rect`,{x:o,y:l,width:i,height:Math.max(0,c-l),fill:n,fillOpacity:.25,stroke:n,strokeWidth:1.5}),D(`line`,{x1:o,y1:u,x2:o+i,y2:u,stroke:n,strokeWidth:2.5}),e.stats.outliers.map((e,t)=>D(`circle`,{cx:r,cy:s.map(e),r:3,fill:`none`,stroke:n,strokeWidth:1.5},t))]},e.id)}),!c&&O(E,{children:[D(Axis,{scale:a,orientation:`x`,length:r.width,transform:`translate(0,${r.height})`,...l?{format:l}:{}}),D(Axis,{scale:s,orientation:`y`,length:r.height})]})]})}})}var le=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`),ue=3,de=24;function BubbleChart({series:e,title:t,description:r,width:a,height:o,tooltip:s,className:c,plain:l,glyph:u,format:d}){v();let f=g(null),p=l?te:F,m=o??(l?48:320),h=e.flatMap(e=>e.data),[_,b]=h.length>0?extent(h.map(e=>e.x)):[0,1],[S,C]=h.length>0?extent(h.map(e=>e.y)):[0,1],[w,T]=h.length>0?extent(h.map(e=>e.size)):[0,1],k=n([w,T],[ue,de]),A=h.length>0;return D(ChartFrame,{title:t,description:r,width:a,height:m,fallback:O(`table`,{children:[D(`caption`,{children:t}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Series`}),D(`th`,{children:`X`}),D(`th`,{children:`Y`}),D(`th`,{children:`Size`})]})}),D(`tbody`,{children:e.flatMap(e=>e.data.map((t,n)=>O(`tr`,{children:[D(`td`,{children:e.name}),D(`td`,{children:t.x}),D(`td`,{children:t.y}),D(`td`,{children:t.size})]},`${e.name}-${n}`)))})]}),className:c,plain:l,tooltip:s!==!1&&A?({width:t,height:n})=>{if(s===!1||!A)return;let r={width:t-p.left-p.right,height:n-p.top-p.bottom};if(r.width<=0)return;let a=(b-_)*.05||1,o=(C-S)*.05||1,c=i([_-a,b+a],[0,r.width]),l=i([S-o,C+o],[r.height,0]);return{points:e.flatMap((e,t)=>e.data.map((n,r)=>({id:`${t}-${r}`,cx:p.left+c.map(n.x),cy:p.top+l.map(n.y),label:`${e.name} (${n.x}, ${n.y})`,value:n.y,seriesId:e.name})))}}:void 0,hover:`voronoi`,children:({width:t,height:n})=>{let r={width:t-p.left-p.right,height:n-p.top-p.bottom};if(r.width<=0||h.length===0)return null;let a=(b-_)*.05||1,o=(C-S)*.05||1,s=i([_-a,b+a],[0,r.width]),c=i([S-o,C+o],[r.height,0]);return O(`g`,{transform:`translate(${p.left},${p.top})`,children:[!l&&D(GridLines,{scale:c,orientation:`y`,length:r.width}),e.map((e,t)=>{let n=le[t%le.length]??`var(--cascivo-chart-1)`;return D(`g`,{opacity:f.value!==null&&f.value!==e.name?.2:1,onMouseEnter:()=>{f.value=e.name},onMouseLeave:()=>{f.value=null},children:e.data.map((t,r)=>{let i=typeof u==`function`?u(t,e.name):u;return i&&i!==`circle`?D(`g`,{children:D(Glyph,{shape:i,x:s.map(t.x),y:c.map(t.y),size:k(t.size)*2,color:n,opacity:.6,stroke:n,strokeWidth:1})},r):D(`circle`,{cx:s.map(t.x),cy:c.map(t.y),r:k(t.size),fill:n,fillOpacity:.6,stroke:n,strokeWidth:1},r)})},e.name)}),!l&&O(E,{children:[D(Axis,{scale:s,orientation:`x`,length:r.width,transform:`translate(0,${r.height})`,...d?{format:d}:{}}),D(Axis,{scale:c,orientation:`y`,length:r.height})]})]})}})}var fe=`var(--cascivo-chart-1)`,pe=`var(--cascivo-chart-2)`;function ComboChart({bars:e,line:n,title:a,description:o,secondAxis:s=!1,barsLabel:c=`Bars`,lineLabel:l=`Line`,legend:u,xLabelEvery:d,width:f,height:p,tooltip:m,className:h,plain:_,annotations:b,format:S}){v();let C=g(new Set),w=p??(_?48:320),T=e.reduce((e,t)=>Math.max(e,t.value),0)||1,k=n.length>0?Math.min(...n.map(e=>e.y)):0,A=n.length>0?Math.max(...n.map(e=>e.y)):1,j=e.length>0,M=_?!1:u??(e.length>0&&n.length>0);n.length>0&&e.length>0&&n.length!==e.length&&warnOnce(`ComboChart:length-mismatch`,`ComboChart: \`line\` has ${n.length} point(s) but \`bars\` has ${e.length}. The two are correlated by array index, so the line is drawn against the wrong categories. Pass one line point per bar (use a null-valued point for a gap).`),!s&&n.length>0&&e.length>0&&warnScaleMismatch(`ComboChart`,[{label:c,max:T},{label:l,max:A}]);let ee=i([0,T],[0,1]).ticks(5).map(e=>e.toLocaleString()),N=s?i([k,A||k+1],[0,1]).ticks(5).map(e=>e.toLocaleString()):[],P=e.map(e=>e.label),I=_?te:{...F,left:leftMarginForLabels(ee,_),right:rightMarginForLabels({rightAxisLabels:N,plain:_})};return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`var(--cascivo-space-2)`},className:h,children:[D(ChartFrame,{title:a,description:o,width:f,height:w,fallback:O(`table`,{children:[D(`caption`,{children:a}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Label`}),D(`th`,{children:c}),n.length>0&&D(`th`,{children:l})]})}),D(`tbody`,{children:e.map((e,t)=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.value}),n.length>0&&D(`td`,{children:n[t]?.y??``})]},e.label))})]}),plain:_,tooltip:m!==!1&&j?({width:r,height:a})=>{if(m===!1||!j)return;let o={width:r-I.left-I.right,height:a-I.top-I.bottom};if(o.width<=0)return;let c=t(e.map(e=>e.label),[0,o.width],.2),l=i([0,T],[o.height,0]),u=s?i([k,A||k+1],[o.height,0]):l,d=e.map((e,t)=>({id:`bar-${t}`,cx:I.left+(c.map(e.label)??0)+c.bandwidth/2,cy:I.top+l.map(e.value),label:e.label,value:e.value,seriesId:`bars`})),f=n.map((t,r)=>{let i=e[r]?(c.map(e[r].label)??0)+c.bandwidth/2:o.width*t.x/Math.max(1,n.length-1);return{id:`line-${r}`,cx:I.left+i,cy:I.top+u.map(t.y),label:e[r]?.label??String(t.x),value:t.y,seriesId:`line`}});return{points:[...d,...f]}}:void 0,children:({width:a,height:o})=>{let c={width:a-I.left-I.right,height:o-I.top-I.bottom};if(c.width<=0||e.length===0)return null;let l=t(e.map(e=>e.label),[0,c.width],.2),u=i([0,T],[c.height,0]),f=s?i([k,A||k+1],[c.height,0]):u,p=n.map((t,r)=>[e[r]?(l.map(e[r].label)??0)+l.bandwidth/2:c.width*t.x/Math.max(1,n.length-1),f.map(t.y)]),m=p.length>1?r(p,`monotone`):``,h=d??autoLabelStride(P,c.width),g=C.value.has(`bars`),v=C.value.has(`line`);return O(`g`,{transform:`translate(${I.left},${I.top})`,children:[!_&&D(GridLines,{scale:u,orientation:`y`,length:c.width}),!_&&renderAnnotations(b,{xScale:l,yScale:u,innerW:c.width,innerH:c.height}),!g&&e.map(e=>{let t=l.map(e.label)??0,n=u.map(e.value);return D(`rect`,{x:t,y:n,width:l.bandwidth,height:Math.max(0,c.height-n),fill:fe,opacity:.75},e.label)}),m&&!v&&D(`path`,{d:m,fill:`none`,stroke:pe,strokeWidth:2.5,strokeLinejoin:`round`,strokeLinecap:`round`}),!_&&O(E,{children:[D(Axis,{scale:l,orientation:`x`,length:c.width,labelEvery:h,transform:`translate(0,${c.height})`,...S?{format:S}:{}}),D(Axis,{scale:u,orientation:`y`,length:c.height}),s&&D(Axis,{scale:f,orientation:`y-right`,length:c.height,transform:`translate(${c.width},0)`})]})]})}}),M&&D(Legend,{series:[{id:`bars`,label:c,color:fe},...n.length>0?[{id:`line`,label:l,color:pe}]:[]],hidden:C})]})}function Heatmap({data:e,title:n,description:r,width:i,height:a,className:o,plain:s,visualMap:c,toolbox:l,format:u}){v();let d=a??(s?48:320),f=s?te:{top:20,right:20,bottom:60,left:60},p=[...new Set(e.map(e=>e.x))],m=[...new Set(e.map(e=>e.y))],[h,_]=e.length>0?extent(e.map(e=>e.value)):[0,1],b=_-h||1,norm=e=>Math.max(0,Math.min(1,(e-h)/b)),S=g([c?.min??h,c?.max??_]),C=g(new Set),w=D(ChartFrame,{title:n,description:r,width:i,height:d,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`X`}),D(`th`,{children:`Y`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:e.map((e,t)=>O(`tr`,{children:[D(`td`,{children:e.x}),D(`td`,{children:e.y}),D(`td`,{children:e.value})]},t))})]}),className:o,plain:s,tooltip:e.length>0?({width:n,height:r})=>{if(e.length===0)return;let i=n-f.left-f.right,a=r-f.top-f.bottom;if(i<=0)return;let o=t(p,[0,i],.05),s=t(m,[0,a],.05);return{points:e.map((e,t)=>{let n=o.map(e.x)??0,r=s.map(e.y)??0;return{id:`cell-${t}`,cx:f.left+n+o.bandwidth/2,cy:f.top+r+s.bandwidth/2,label:`${e.x}×${e.y}`,value:e.value}})}}:void 0,toolbox:l,onRestore:c?()=>{S.value=[c.min,c.max],C.value=new Set}:void 0,children:({width:n,height:r})=>{let i={width:n-f.left-f.right,height:r-f.top-f.bottom};if(i.width<=0||e.length===0)return null;let a=t(p,[0,i.width],.05),o=t(m,[0,i.height],.05);return O(`g`,{transform:`translate(${f.left},${f.top})`,children:[e.map((e,t)=>{let n=a.map(e.x)??0,r=o.map(e.y)??0,i=Math.round(norm(e.value)*100),s=c?mapVisual(e.value,c).color??`var(--cascivo-chart-1)`:`color-mix(in oklab, var(--cascivo-chart-1) ${i}%, var(--cascivo-gray-100))`,l=c?visualVisible(e.value,c,S.value,C.value):!0;return D(`rect`,{x:n,y:r,width:a.bandwidth,height:o.bandwidth,fill:s,fillOpacity:l?1:.12,stroke:`var(--cascivo-surface-base)`,strokeWidth:1},t)}),!s&&O(E,{children:[D(Axis,{scale:a,orientation:`x`,length:i.width,transform:`translate(0,${i.height})`,...u?{format:u}:{}}),D(Axis,{scale:o,orientation:`y`,length:i.height})]})]})}});return!c||e.length===0?w:O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[w,D(VisualMap,{options:c,range:S,hidden:C,label:n})]})}var me=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Treemap({data:e,title:t,description:n,width:r,height:i,className:a,plain:o}){v();let s=b();return D(ChartFrame,{title:t,description:n,width:r,height:i??(o?48:320),fallback:O(`table`,{children:[D(`caption`,{children:t}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Label`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:e.map(e=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.value})]},e.id))})]}),className:a,plain:o,tooltip:e.length>0?({width:t,height:n})=>{if(e.length!==0)return{points:squarify(e.map(e=>({id:e.id,value:e.value})),t,n).map(t=>{let n=e.find(e=>e.id===t.id);return{id:t.id,cx:t.x+t.w/2,cy:t.y+t.h/2,label:n?.label??t.id,value:n?.value??0}})}}:void 0,children:({width:t,height:n})=>{if(e.length===0)return null;let r=squarify(e.map(e=>({id:e.id,value:e.value})),t,n),i=new Map(e.map(e=>[e.id,e.label]));return O(E,{children:[D(`defs`,{children:r.map(e=>D(`clipPath`,{id:`${s}-${e.id}`,children:D(`rect`,{x:e.x+2,y:e.y+2,width:Math.max(0,e.w-4),height:Math.max(0,e.h-4)})},e.id))}),r.map((e,t)=>{let n=me[t%me.length]??`var(--cascivo-chart-1)`,r=i.get(e.id)??e.id;return O(`g`,{children:[D(`rect`,{x:e.x,y:e.y,width:Math.max(0,e.w-1),height:Math.max(0,e.h-1),fill:n,fillOpacity:.8,stroke:`var(--cascivo-surface-base)`,strokeWidth:1}),!o&&e.w>30&&e.h>18&&D(`text`,{x:e.x+4,y:e.y+14,fontSize:Math.min(12,e.w/5),fill:`currentColor`,clipPath:`url(#${s}-${e.id})`,children:r})]},e.id)})]})}})}var he=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`),Q=4;function polarPoints(t,n,r,i,a){let o=t.length;return t.map((t,s)=>{let c=s/o*2*Math.PI-Math.PI/2,l=t/n*a;return{x:e(r+Math.cos(c)*l),y:e(i+Math.sin(c)*l)}})}function Radar({axes:t,series:n,max:r,title:i,description:a,width:o,height:s,className:c,plain:l}){let u=s??(l?48:320);v();let d=r??Math.max(1,...n.flatMap(e=>e.values)),f=t.length;return D(ChartFrame,{title:i,description:a,width:o,height:u,fallback:O(`table`,{children:[D(`caption`,{children:i}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Series`}),t.map(e=>D(`th`,{children:e},e))]})}),D(`tbody`,{children:n.map(e=>O(`tr`,{children:[D(`td`,{children:e.label}),e.values.map((e,t)=>D(`td`,{children:e},t))]},e.id))})]}),className:c,plain:l,tooltip:n.length>0?({width:r,height:i})=>{if(n.length===0||f===0)return;let a=r/2,o=i/2,s=Math.min(a,o)*.72;return{points:n.flatMap(n=>n.values.map((r,i)=>{let c=i/f*2*Math.PI-Math.PI/2,l=r/d*s;return{id:`${n.id}-${i}`,cx:e(a+Math.cos(c)*l),cy:e(o+Math.sin(c)*l),label:t[i]??String(i),value:r,seriesId:n.id}}))}}:void 0,children:({width:r,height:i})=>{let a=r/2,o=i/2,s=Math.min(a,o)*.72,c=Array.from({length:Q},(e,t)=>(t+1)/Q*s),u=Array.from({length:f},(t,n)=>{let r=n/f*2*Math.PI-Math.PI/2;return{x:e(a+Math.cos(r)*s),y:e(o+Math.sin(r)*s)}}),p=c.map(t=>Array.from({length:f},(n,r)=>{let i=r/f*2*Math.PI-Math.PI/2;return`${e(a+Math.cos(i)*t)},${e(o+Math.sin(i)*t)}`}).join(` `));return O(E,{children:[!l&&p.map((e,t)=>D(`polygon`,{points:e,fill:`none`,stroke:`var(--cascivo-border-subtle)`,strokeWidth:1},t)),!l&&u.map((e,t)=>D(`line`,{x1:a,y1:o,x2:e.x,y2:e.y,stroke:`var(--cascivo-border-subtle)`,strokeWidth:1},t)),!l&&u.map((n,r)=>{let i=r/f*2*Math.PI-Math.PI/2;return D(`text`,{x:e(a+Math.cos(i)*(s+18)),y:e(o+Math.sin(i)*(s+18)),fontSize:11,textAnchor:`middle`,dominantBaseline:`middle`,fill:`var(--cascivo-color-text-subtle)`,children:t[r]},r)}),n.map((e,t)=>{let n=polarPoints(e.values,d,a,o,s).map(e=>`${e.x},${e.y}`).join(` `),r=he[t%he.length]??`var(--cascivo-chart-1)`;return D(`polygon`,{points:n,fill:r,fillOpacity:.15,stroke:r,strokeWidth:2},e.id)})]})}})}var ge=[`var(--cascivo-gray-200)`,`var(--cascivo-gray-300)`,`var(--cascivo-gray-400)`];function Bullet({value:e,target:t,ranges:n,label:r,min:a=0,max:o,width:s=300,height:c=40,className:l}){v();let u=[...n].sort((e,t)=>e-t),d=i([a,o??u[u.length-1]??(Math.max(e,t)*1.2||1)],[0,s]),f=c*.35,p=(c-f)/2,m=c*.7,h=(c-m)/2;return O(`figure`,{className:l,"aria-label":`${r}: value ${e}, target ${t}`,style:{margin:0},children:[D(ChartFrame,{title:`${r} bullet chart`,width:s,height:c,plain:!0,tooltip:{points:[{id:`measure`,cx:d.map(e),cy:c/2,label:r,value:e}]},children:()=>O(E,{children:[u.map((e,t)=>{let n=t===0?a:u[t-1]??a,r=d.map(e)-d.map(n);return D(`rect`,{x:d.map(n),y:0,width:Math.max(0,r),height:c,fill:ge[t%ge.length]??`var(--cascivo-gray-200)`},t)}),D(`rect`,{x:d.map(a),y:p,width:Math.max(0,d.map(e)-d.map(a)),height:f,fill:`var(--cascivo-chart-1)`}),D(`line`,{x1:d.map(t),y1:h,x2:d.map(t),y2:h+m,stroke:`var(--cascivo-color-text)`,strokeWidth:2.5})]})}),D(`figcaption`,{style:{fontSize:12},children:r})]})}var _e=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function RadialBar({data:t,title:n,description:r,size:i,width:o,height:s,max:c,sweep:l=270,centerValue:u,centerLabel:d,centerSlot:f,tooltip:p,legend:m,className:h,plain:_}){v();let b=g(new Set),S=o??i,C=s??i??(_?48:300),w=_?!1:m??t.length>1,T=t.length>0,E=c??Math.max(1,...t.map(e=>e.value)),k=Math.min(360,Math.max(0,l))*Math.PI/180,A=-k/2,ringGeometry=(e,n)=>{let r=e/2,i=n/2,a=Math.min(r,i)-8,o=a*.32,s=t.filter(e=>!b.value.has(e.id));return{cx:r,cy:i,maxR:a,holeR:o,span:s.length>0?(a-o)/s.length:0,visible:s}},buildTooltip=({width:t,height:n})=>{if(p===!1||!T)return;let{cx:r,cy:i,maxR:a,span:o,visible:s}=ringGeometry(t,n);return{points:s.map((t,n)=>{let s=a-n*o,c=(s+(s-o*.7))/2,l=A+k*Math.min(1,t.value/E);return{id:t.id,cx:e(r+Math.sin(l)*c),cy:e(i-Math.cos(l)*c),label:t.label,value:t.value,seriesId:t.id,percent:E>0?t.value/E*100:0,color:t.color??_e[n%_e.length]}})}},j=O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Label`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:t.map(e=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.value})]},e.id))})]}),M=u!=null||d!=null||f!=null;return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:n,description:r,width:S,height:C,fallback:j,className:h,"data-state":T?void 0:`empty`,plain:_,tooltip:p!==!1&&T?buildTooltip:void 0,children:({width:e,height:t})=>{let{cx:n,cy:r,maxR:i,holeR:o,span:s,visible:c}=ringGeometry(e,t);return O(`g`,{children:[c.map((e,t)=>{let o=i-t*s,c=o-s*.7,l=e.color??_e[t%_e.length],u=Math.max(0,Math.min(1,e.value/E)),d=A+k*u;return O(`g`,{"data-series":e.id,children:[D(`path`,{d:a(n,r,o,c,A,A+k),fill:`var(--cascivo-chart-grid)`,fillOpacity:.35}),u>0&&D(`path`,{d:a(n,r,o,c,A,d),fill:l})]},e.id)}),!_&&M&&(f==null?O(`g`,{"data-center":``,children:[u!=null&&D(`text`,{x:n,y:d==null?r:r-8,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`1.5rem`,fontWeight:700,fill:`var(--cascivo-color-foreground)`,children:u}),d!=null&&D(`text`,{x:n,y:u==null?r:r+14,textAnchor:`middle`,dominantBaseline:`central`,fontSize:`0.8125rem`,fill:`var(--cascivo-color-foreground-muted)`,children:d})]}):D(`foreignObject`,{x:n-o,y:r-o,width:o*2,height:o*2,"data-center-slot":``,children:D(`div`,{style:{width:`100%`,height:`100%`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,textAlign:`center`},children:f})}))]})}}),w&&D(Legend,{series:t.map((e,t)=>({id:e.id,label:e.label,color:e.color??_e[t%_e.length]})),hidden:b})]})}var ve=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Funnel({data:e,title:t,description:n,width:r,height:a,showConversion:o=!1,tooltip:s,className:c,plain:l}){v();let u=l?te:F,d=a??(l?48:320),f=e.length>0,p=e[0]?.value??0,m=Math.max(1,...e.map(e=>e.value));return D(ChartFrame,{title:t,description:n,width:r,height:d,fallback:O(`table`,{children:[D(`caption`,{children:t}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Stage`}),D(`th`,{children:`Value`}),D(`th`,{children:`% of first`})]})}),D(`tbody`,{children:e.map(e=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.value}),O(`td`,{children:[p>0?Math.round(e.value/p*100):0,`%`]})]},e.id))})]}),className:c,"data-state":f?void 0:`empty`,plain:l,tooltip:s!==!1&&f?({width:t,height:n})=>{if(s===!1||!f)return;let r=t-u.left-u.right,i=(n-u.top-u.bottom)/e.length;return{points:e.map((e,t)=>({id:e.id,cx:u.left+r/2,cy:u.top+t*i+i/2,label:e.label,value:e.value,seriesId:e.id,percent:p>0?e.value/p*100:0,color:e.color??ve[t%ve.length]})),format:e=>`${e.label}: ${e.value} (${Math.round(e.percent??0)}%)`}}:void 0,children:({width:t,height:n})=>{let r=t-u.left-u.right,a=n-u.top-u.bottom;if(r<=0||e.length===0)return null;let s=a/e.length,c=i([0,m],[0,r]),half=e=>c.map(e)/2,d=u.left+r/2;return D(`g`,{children:e.map((t,n)=>{let r=e[n+1],i=half(t.value),a=half(r?r.value:t.value),c=u.top+n*s,f=c+s*(r?1:.9),m=t.color??ve[n%ve.length],h=[[d-i,c],[d+i,c],[d+a,f],[d-a,f]].map(e=>e.join(`,`)).join(` `),g=p>0?Math.round(t.value/p*100):0;return O(`g`,{"data-series":t.id,children:[D(`polygon`,{points:h,fill:m,fillOpacity:.85}),!l&&D(DataLabel,{x:d,y:c+s/2,text:o?`${t.label} · ${t.value} (${g}%)`:`${t.label} · ${t.value}`,tone:`muted`})]},t.id)})})}})}var ye=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Stream({series:e,categories:n,title:a,description:o,offset:s=`silhouette`,curve:c=`basis`,width:l,height:u,legend:d,tooltip:f,className:p,plain:m,format:h}){v();let _=g(new Set),b=m?te:F,S=u??(m?48:300),C=m?!1:d??e.length>1,w=n.length>0&&e.length>0,T=streamLayout(e.map(e=>e.values),s),[E,k]=streamExtent(T);return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:a,description:o,width:l,height:S,fallback:O(`table`,{children:[D(`caption`,{children:a}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Category`}),e.map(e=>D(`th`,{children:e.label},e.id))]})}),D(`tbody`,{children:n.map((t,n)=>O(`tr`,{children:[D(`td`,{children:String(t)}),e.map(e=>D(`td`,{children:e.values[n]??``},e.id))]},String(t)))})]}),className:p,"data-state":w?void 0:`empty`,plain:m,tooltip:f&&w?({width:r,height:a})=>{if(!f||!w)return;let o=r-b.left-b.right,s=a-b.top-b.bottom,c=t(n.map(String),[0,o],0),l=i([E,k],[s,0]);return{points:e.flatMap((e,t)=>{if(_.value.has(e.id))return[];let r=T[t];return n.map((n,i)=>{let a=(r[i][0]+r[i][1])/2;return{id:`${e.id}-${i}`,cx:b.left+(c.map(String(n))??0)+c.bandwidth/2,cy:b.top+l.map(a),label:`${e.label} · ${String(n)}`,value:e.values[i]??0,seriesId:e.id,color:e.color??ye[t%ye.length]}})})}}:void 0,children:({width:a,height:o})=>{let s=a-b.left-b.right,l=o-b.top-b.bottom;if(s<=0||!w)return null;let u=t(n.map(String),[0,s],0),d=i([E,k],[l,0]),xOf=e=>(u.map(String(n[e]))??0)+u.bandwidth/2;return O(`g`,{transform:`translate(${b.left},${b.top})`,children:[e.map((e,t)=>{if(_.value.has(e.id))return null;let i=T[t],a=e.color??ye[t%ye.length],o=n.map((e,t)=>[xOf(t),d.map(i[t][1])]),s=n.map((e,t)=>[xOf(t),d.map(i[t][0])]);return D(`path`,{d:`${r(o,c)}${r([...s].reverse(),c).replace(/^M/,`L`)}Z`,fill:a,fillOpacity:.85,"data-series":e.id},e.id)}),!m&&D(Axis,{scale:u,orientation:`x`,length:s,transform:`translate(0,${l})`,...h?{format:h}:{}})]})}}),C&&D(Legend,{series:e.map((e,t)=>({id:e.id,label:e.label,color:e.color??ye[t%ye.length]})),hidden:_})]})}var be=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Sunburst({data:t,title:n,description:r,size:i,width:o,height:s,tooltip:c,className:l,plain:u}){v();let d=o??i,f=s??i??(u?48:300),p=sumValue(t),m=p>0,h=partition(t),g=Math.max(1,maxDepth(h));return D(ChartFrame,{title:n,description:r,width:d,height:f,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Path`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:h.filter(e=>e.depth>0).map((e,t)=>O(`tr`,{children:[D(`td`,{children:e.node.label}),D(`td`,{children:e.value})]},`${e.node.label}-${t}`))})]}),className:l,"data-state":m?void 0:`empty`,plain:u,tooltip:c&&m?({width:t,height:n})=>{if(!c||!m)return;let r=t/2,i=n/2,a=(Math.min(r,i)-8)/g;return{points:h.filter(e=>e.depth>0).map((t,n)=>{let o=(t.a0+t.a1)/2,s=(t.depth-.5)*a;return{id:`${t.node.label}-${n}`,cx:e(r+Math.sin(o)*s),cy:e(i-Math.cos(o)*s),label:t.node.label,value:t.value,percent:p>0?t.value/p*100:0,color:t.node.color??be[n%be.length]}}),format:e=>`${e.label}: ${e.value} (${Math.round(e.percent??0)}%)`}}:void 0,children:({width:e,height:t})=>{let n=e/2,r=t/2,i=(Math.min(n,r)-8)/g;return D(`g`,{children:h.filter(e=>e.depth>0).map((e,t)=>{let o=(e.depth-1)*i,s=e.depth*i,c=e.node.color??be[t%be.length];return D(`path`,{d:a(n,r,s,o,e.a0,e.a1),fill:c,fillOpacity:1-(e.depth-1)*.18,stroke:`var(--cascivo-color-surface)`,strokeWidth:1,"data-depth":e.depth},`${e.node.label}-${t}`)})})}})}var xe=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Sankey({nodes:e,links:t,title:n,description:r,width:i,height:a,tooltip:o,className:s,plain:c}){v();let l=c?te:F,u=a??(c?48:320),d=e.length>0&&t.length>0,colorOf=(t,n)=>e.find(e=>e.id===t)?.color??xe[n%xe.length];return D(ChartFrame,{title:n,description:r,width:i,height:u,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`From`}),D(`th`,{children:`To`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:t.map((t,n)=>O(`tr`,{children:[D(`td`,{children:e.find(e=>e.id===t.source)?.label??t.source}),D(`td`,{children:e.find(e=>e.id===t.target)?.label??t.target}),D(`td`,{children:t.value})]},n))})]}),className:s,"data-state":d?void 0:`empty`,plain:c,tooltip:o&&d?({width:n,height:r})=>{if(!o||!d)return;let{nodes:i}=sankeyLayout(e,t,{width:n-l.left-l.right,height:r-l.top-l.bottom});return{points:i.map((e,t)=>({id:e.id,cx:l.left+(e.x0+e.x1)/2,cy:l.top+(e.y0+e.y1)/2,label:e.label,value:e.value,color:colorOf(e.id,t)}))}}:void 0,children:({width:n,height:r})=>{let i=n-l.left-l.right,a=r-l.top-l.bottom;if(i<=0||!d)return null;let{nodes:o,links:s}=sankeyLayout(e,t,{width:i,height:a});return O(`g`,{transform:`translate(${l.left},${l.top})`,children:[s.map((e,t)=>D(`path`,{d:linkPath(e),fill:colorOf(e.source.id,o.indexOf(e.source)),fillOpacity:.32,"data-link":``},t)),o.map((e,t)=>O(`g`,{"data-node":e.id,children:[D(`rect`,{x:e.x0,y:e.y0,width:e.x1-e.x0,height:Math.max(1,e.y1-e.y0),fill:colorOf(e.id,t),rx:1}),!c&&D(`text`,{x:e.x0<i/2?e.x1+4:e.x0-4,y:(e.y0+e.y1)/2,dominantBaseline:`central`,textAnchor:e.x0<i/2?`start`:`end`,fontSize:`0.6875rem`,fill:`var(--cascivo-color-foreground)`,children:e.label})]},e.id))]})}})}var Se=864e5,$=2,Ce=7;function cellSize(e,t,n,r){let i=(e-(n-1)*$)/n,a=(t-(Ce-1)*$+1)/Ce;return Math.max(2,Math.min(i,r===void 0?a:Math.min(a,r)))}var toDate=e=>e instanceof Date?e:new Date(e),iso=e=>e.toISOString().slice(0,10);function weekStart(e){let t=new Date(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()));return t.setUTCDate(t.getUTCDate()-t.getUTCDay()),t}function CalendarHeatmap({data:e,title:t,description:n,from:r,to:i,width:a,height:o,maxCellSize:s,tooltip:c,className:l,plain:u,visualMap:d}){v();let f=e.length>0,p=g([d?.min??0,d?.max??1]),m=g(new Set),h=new Map;for(let t of e)h.set(iso(toDate(t.day)),t.value);let _=e.map(e=>toDate(e.day)),b=weekStart(r?toDate(r):_.reduce((e,t)=>t<e?t:e,_[0]??new Date)),S=i?toDate(i):_.reduce((e,t)=>t>e?t:e,_[0]??new Date),C=f?Math.max(1,Math.ceil((S.getTime()-b.getTime())/Se/7)):1,w=Math.max(1,...e.map(e=>e.value)),T=o??(u?48:160),E=[];for(let e=0;e<C;e++)for(let t=0;t<7;t++){let n=new Date(b.getTime()+(e*7+t)*Se);n>S||E.push({col:e,row:t,date:n,value:h.get(iso(n))??0})}let k=D(ChartFrame,{title:t,description:n,width:a,height:T,fallback:O(`table`,{children:[D(`caption`,{children:t}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Day`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:e.map((e,t)=>O(`tr`,{children:[D(`td`,{children:iso(toDate(e.day))}),D(`td`,{children:e.value})]},t))})]}),className:l,"data-state":f?void 0:`empty`,plain:u,tooltip:c&&f?({width:e,height:t})=>{if(!c||!f)return;let n=$,r=cellSize(e,t,C,s);return{points:E.map((e,t)=>({id:`${iso(e.date)}-${t}`,cx:e.col*(r+n)+r/2,cy:e.row*(r+n)+r/2,label:iso(e.date),value:e.value})),format:e=>`${e.label}: ${e.value}`}}:void 0,children:({width:e,height:t})=>{let n=$,r=cellSize(e,t,C,s);return D(`g`,{children:E.map((e,t)=>{let i=d?mapVisual(e.value,d).color:void 0,a=d?visualVisible(e.value,d,p.value,m.value):!0;return D(`rect`,{x:e.col*(r+n),y:e.row*(r+n),width:r-1,height:r-1,rx:1.5,fill:i??`var(--cascivo-chart-2)`,fillOpacity:d?e.value>0&&a?1:.08:e.value>0?.15+.85*(e.value/w):.06,"data-day":iso(e.date)},t)})})}});return!d||!f?k:O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[k,D(VisualMap,{options:d,range:p,hidden:m,label:t})]})}function Candlestick({data:e,title:n,description:r,width:a,height:o,yTicks:s=5,upColor:c=`var(--cascivo-chart-2)`,downColor:l=`var(--cascivo-chart-4)`,volume:u,tooltip:d,className:f,plain:p,annotations:m,brush:h,dataZoom:b,zoom:C,syncId:w,tooltipMode:T,format:k}){v();let A=p?te:F,j=o??(p?64:320),M=e.length,ee=(h||b||C||w!==void 0)&&M>0,N=g([0,Math.max(0,M-1)]),P=S(null);w&&!P.current&&(P.current=getSyncGroup(w)),_(()=>()=>{w&&releaseSyncGroup(w)}),_(()=>{let e=P.current;if(!e)return;let t=e.window.value,n=N.peek();t&&(t[0]!==n[0]||t[1]!==n[1])&&(N.value=t)}),_(()=>{let e=P.current;if(!e)return;let t=N.value,n=e.window.peek();(!n||n[0]!==t[0]||n[1]!==t[1])&&(e.window.value=t)});let I=ee?e.slice(N.value[0],N.value[1]+1):e,L=I.length>0,R=L?Math.min(...I.map(e=>e.low)):0,z=L?Math.max(...I.map(e=>e.high)):1,B=L?Math.max(1,...I.map(e=>e.volume??0)):1,ne=I.map(e=>e.t);return O(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[D(ChartFrame,{title:n,description:r,width:a,height:j,fallback:O(`table`,{children:[D(`caption`,{children:n}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Period`}),D(`th`,{children:`Open`}),D(`th`,{children:`High`}),D(`th`,{children:`Low`}),D(`th`,{children:`Close`})]})}),D(`tbody`,{children:I.map((e,t)=>O(`tr`,{children:[D(`td`,{children:e.t}),D(`td`,{children:e.open}),D(`td`,{children:e.high}),D(`td`,{children:e.low}),D(`td`,{children:e.close})]},t))})]}),className:f,"data-state":L?void 0:`empty`,plain:p,tooltip:d!==!1&&L?({width:e,height:n})=>{if(d===!1||!L)return;let r=e-A.left-A.right,a=n-A.top-A.bottom;if(r<=0)return;let o=t(ne,[0,r],.3),s=a-(u?Math.min(a*.2,60):0),c=i([R,z],[s,0]);if(T===`axis`)return{points:I.map((e,t)=>({id:`c-${t}`,cx:A.left+(o.map(e.t)??0)+o.bandwidth/2,cy:A.top+c.map(e.high),label:e.t,value:e.close,segments:[{label:`O`,value:e.open},{label:`H`,value:e.high},{label:`L`,value:e.low},{label:`C`,value:e.close}]})),mode:`axis`,format:e=>{let t=I[parseInt(e.id.split(`-`)[1]??`0`,10)];return t?`${t.t} — O ${t.open} H ${t.high} L ${t.low} C ${t.close}`:`${e.label}: ${e.value}`}};let l=i([R,z],[a,0]);return{points:I.map((e,t)=>({id:`c-${t}`,cx:A.left+(o.map(e.t)??0)+o.bandwidth/2,cy:A.top+l.map(e.high),label:e.t,value:e.close})),format:e=>{let t=I[parseInt(e.id.split(`-`)[1]??`0`,10)];return t?`${t.t} — O ${t.open} H ${t.high} L ${t.low} C ${t.close}`:`${e.label}: ${e.value}`}}}:void 0,zoom:C&&M>1?{window:N,count:M}:void 0,onRestore:ee?()=>{N.value=[0,Math.max(0,M-1)]}:void 0,children:({width:e,height:n})=>{let r=e-A.left-A.right,a=n-A.top-A.bottom;if(r<=0||!L)return null;let o=t(ne,[0,r],.3),d=i([R,z],[a,0]),f=u?Math.min(a*.2,60):0,h=a-f,g=i([R,z],[h,0]),_=o.bandwidth;return O(`g`,{transform:`translate(${A.left},${A.top})`,children:[!p&&D(GridLines,{scale:d,orientation:`y`,length:r,tickCount:s}),I.map((e,t)=>{let n=(o.map(e.t)??0)+_/2,r=e.close>=e.open,i=r?c:l,a=g.map(e.open),s=g.map(e.close),d=Math.min(a,s),p=Math.max(1,Math.abs(s-a));return O(`g`,{"data-candle":r?`up`:`down`,children:[D(`line`,{x1:n,x2:n,y1:g.map(e.high),y2:g.map(e.low),stroke:i,strokeWidth:1,"data-wick":``}),D(`rect`,{x:n-_/2,y:d,width:_,height:p,fill:i,"data-body":``}),u&&e.volume!==void 0&&D(`rect`,{x:n-_/2,y:h+(f-e.volume/B*f),width:_,height:e.volume/B*f,fill:i,fillOpacity:.4,"data-volume":``})]},t)}),!p&&renderAnnotations(m,{xScale:o,yScale:g,innerW:r,innerH:h}),!p&&O(E,{children:[D(Axis,{scale:o,orientation:`x`,length:r,transform:`translate(0,${a})`,...k?{format:k}:{}}),D(Axis,{scale:d,orientation:`y`,length:h,tickCount:s})]})]})}}),h&&!b&&M>1&&D(Brush,{count:M,window:N,label:`Time range`}),b&&M>1&&D(DataZoom,{count:M,window:N,label:`Time range`})]})}var we=Array.from({length:8},(e,t)=>`var(--cascivo-chart-${t+1})`);function Polar({data:e,title:t,description:n,mode:i=`bar`,width:o,height:s,rings:c=4,max:l,tooltip:u,className:d,plain:f}){v();let p=s??320,m=e.length>0,h=e.map(e=>e.label),g=l??(m?Math.max(1,...e.map(e=>e.value)):1),_=angleBand(h),b=O(`table`,{children:[D(`caption`,{children:t}),D(`thead`,{children:O(`tr`,{children:[D(`th`,{children:`Category`}),D(`th`,{children:`Value`})]})}),D(`tbody`,{children:e.map((e,t)=>O(`tr`,{children:[D(`td`,{children:e.label}),D(`td`,{children:e.value})]},t))})]}),geom=(e,t)=>{let n=e/2,r=t/2,i=Math.max(0,Math.min(e,t)/2-(f?6:28));return{cx:n,cy:r,outerR:i,rScale:radiusScale([0,g],[0,i])}};return D(ChartFrame,{title:t,description:n,width:o,height:p,fallback:b,className:d,"data-state":m?void 0:`empty`,plain:f,tooltip:u!==!1&&m?({width:t,height:n})=>{if(u===!1||!m)return;let{cx:r,cy:i,rScale:a}=geom(t,n);return{points:e.map((e,t)=>{let n=_.center(e.label)??0,[o,s]=polarPoint(r,i,a.map(e.value),n);return{id:`p-${t}`,cx:o,cy:s,label:e.label,value:e.value}}),format:e=>`${e.label}: ${e.value}`}}:void 0,children:({width:t,height:n})=>{if(!m)return null;let{cx:o,cy:s,outerR:l,rScale:u}=geom(t,n),d=Array.from({length:c},(e,t)=>l*(t+1)/c),p=e.map(e=>{let t=_.center(e.label)??0;return polarPoint(o,s,u.map(e.value),t)});return O(`g`,{children:[!f&&d.map((e,t)=>D(`circle`,{cx:o,cy:s,r:e,fill:`none`,stroke:`var(--cascivo-chart-grid)`,strokeOpacity:.4,"data-ring":``},t)),i===`bar`?e.map((e,t)=>{let n=_.map(e.label)??0,r=_.bandwidth*.1;return D(`path`,{d:a(o,s,u.map(e.value),0,n+r,n+_.bandwidth-r),fill:e.color??we[t%we.length],fillOpacity:.85,"data-wedge":``},t)}):(()=>{let t=[...p,p[0]],n=e[0]?.color??we[0];return O(E,{children:[i===`area`&&D(`path`,{d:`${r(t,`linear`)}Z`,fill:n,fillOpacity:.25,stroke:`none`,"data-area":``}),D(`path`,{d:r(t,`linear`),fill:`none`,stroke:n,strokeWidth:2,"data-polyline":``})]})})(),!f&&e.map((e,t)=>{let n=_.center(e.label)??0,[r,i]=polarPoint(o,s,l+12,n);return D(`text`,{x:r,y:i,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`0.75rem`,fill:`var(--cascivo-color-foreground-muted)`,"data-angle-label":``,children:e.label},t)})]})}})}var Te=Math.PI/180;function Gauge({value:e,min:t=0,max:n=100,thresholds:r,unit:i=``,sweep:o=270,ticks:s=5,title:c,description:l,width:u,height:d,className:f,plain:p}){v();let m=d??240,h=n-t||1,g=Math.max(t,Math.min(n,e)),_=(g-t)/h,b=o*Te,S=-b/2,angleOf=e=>S+(e-t)/h*b;return D(ChartFrame,{title:c,description:l,width:u,height:m,fallback:O(`table`,{children:[D(`caption`,{children:c}),O(`tbody`,{children:[O(`tr`,{children:[D(`th`,{children:`Value`}),O(`td`,{children:[e,i]})]}),O(`tr`,{children:[D(`th`,{children:`Range`}),O(`td`,{children:[t,`–`,n]})]})]})]}),className:f,plain:p,children:({width:o,height:c})=>{let l=o/2,u=c/2,d=Math.max(0,Math.min(o,c)/2-(p?6:24)),f=Math.max(6,d*.18),m=d-f,v=m-4,C=r&&r.length>0?r:[{upTo:g,color:`var(--cascivo-color-accent)`}],w=t,T=Array.from({length:s+1},(e,n)=>t+h*n/s);return O(`g`,{children:[D(`path`,{d:a(l,u,d,m,S,S+b),fill:`var(--cascivo-chart-grid)`,fillOpacity:.25,"data-track":``}),C.map((e,t)=>{let r=angleOf(w),i=angleOf(Math.min(n,e.upTo));return w=e.upTo,D(`path`,{d:a(l,u,d,m,r,i),fill:e.color,"data-zone":``},t)}),!p&&T.map((e,t)=>{let n=angleOf(e),[r,i]=polarPoint(l,u,m-2,n),[a,o]=polarPoint(l,u,m-8,n),[s,c]=polarPoint(l,u,m-18,n);return O(`g`,{children:[D(`line`,{x1:r,y1:i,x2:a,y2:o,stroke:`var(--cascivo-color-foreground-muted)`,strokeWidth:1,"data-tick":``}),D(`text`,{x:s,y:c,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`0.625rem`,fill:`var(--cascivo-color-foreground-muted)`,children:Math.round(e)})]},t)}),(()=>{let[e,t]=polarPoint(l,u,v,angleOf(g));return D(`line`,{x1:l,y1:u,x2:e,y2:t,stroke:`var(--cascivo-color-foreground)`,strokeWidth:2.5,strokeLinecap:`round`,"data-needle":``,"data-frac":_.toFixed(3)})})(),D(`circle`,{cx:l,cy:u,r:Math.max(3,f*.25),fill:`var(--cascivo-color-foreground)`}),O(`text`,{x:l,y:u+d*.5,textAnchor:`middle`,fontSize:`1.25rem`,fontWeight:600,fill:`var(--cascivo-color-foreground)`,"data-readout":``,children:[e,i]})]})}})}export{I as AXIS_CHAR_PX,L as AXIS_LINE_PX,AreaChart,Axis,BarChart,Boxplot,Brush,BubbleChart,Bullet,CalendarHeatmap,Candlestick,CanvasLayer,ChartDefs,ChartFrame,ChartText,ComboChart,F as DEFAULT_MARGINS,DataLabel,DataZoom,Funnel,Gauge,Glyph,GridLines,Heatmap,Histogram,Kpi,Legend,LineChart,Meter,te as PLAIN_MARGINS,PieChart,Polar,Radar,RadialBar,Sankey,ScatterChart,Sparkline,Stream,Sunburst,Toolbox,Treemap,VisualMap,_syncGroupCount,aggregate,angleBand,annotationSummary,a as arcPath,s as areaPath,autoLabelStride,t as bandScale,bin,binValues,bindStream,boxStats,cellPath,decimate,divergingRamp,download,encode,encodeCategory,extent,fillFor,filter,getSyncGroup,glyphPath,gradientId,isZoomed,leftMarginForLabels,r as linePath,i as linearScale,linkPath,logScale,lttb,mapVisual,maxDepth,minmax,nearestIndex,u as niceTicks,panWindow,partition,patternId,pieceIndex,polarPoint,e as quantize,radiusScale,rampLightness,rampOf,rampStops,regression,releaseSyncGroup,renderAnnotation,renderAnnotations,resolveColor,resolveLabels,rightMarginForLabels,sankeyLayout,sequentialRamp,serializeSvg,sort,o as splitDefined,n as sqrtScale,squarify,c as stackSeries,streamExtent,streamLayout,sumValue,svgToPngBlob,timeScale,toStackedSeries,useChartSize,useStreamSeries,visualVisible,voronoiCells,voronoiFind,wrapText,zoomWindow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";function linearScale(e,t){let[n,r]=e,[i,a]=t,o=r-n;return{domain:e,range:t,map:e=>o===0?i:i+(e-n)/o*(a-i),invert:e=>a-i===0?n:n+(e-i)/(a-i)*o,ticks:(e=5,t)=>niceTicks(n,r,e,t)}}function niceTicks(e,t,n=5,r){if(!Number.isFinite(e)||!Number.isFinite(t)||e===t)return[e];e>t&&([e,t]=[t,e]);let i=r??!(Number.isInteger(e)&&Number.isInteger(t)),a=(t-e)/Math.max(1,n),o=10**Math.floor(Math.log10(a)),s=i?[1,2,2.5,5,10]:[1,2,5,10],c=a/o,l=(s.find(e=>e>=c)??10)*o;i||(l=Math.max(1,Math.round(l)));let u=Math.ceil(e/l),d=Math.floor(t/l+1e-9),f=[],m=Math.max(0,Math.ceil(-Math.log10(l))+2);for(let e=u;e<=d;e++)f.push(parseFloat((e*l).toFixed(m)));return f}function bandScale(e,t,n=.1){let[r,i]=t,a=e.length,o=(i-r)/Math.max(1,a+n*(a+1)),s=o,c=o*n,l=new Map(e.map((e,t)=>[e,t]));return{domain:e,range:t,bandwidth:s,map:e=>{let t=l.get(e);return t===void 0?void 0:r+c+t*(o+c)}}}function sqrtScale(e,t){let[n,r]=e,[i,a]=t,o=Math.sqrt(Math.max(0,n)),s=Math.sqrt(Math.max(0,r))-o;return e=>s===0?(i+a)/2:i+(Math.sqrt(Math.max(0,e))-o)/s*(a-i)}function quantize(e){return Math.round(e*100)/100}function splitDefined(e,t=!1){if(t){let t=e.filter(e=>e!==null);return t.length>0?[t]:[]}let n=[],r=[];for(let t of e)t===null?(r.length>0&&n.push(r),r=[]):r.push(t);return r.length>0&&n.push(r),n}function linePath(e,t=`linear`){if(e.length===0)return``;if(e.length===1||t===`linear`)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);switch(t){case`monotone`:return monotonePath(e);case`step`:case`stepBefore`:case`stepAfter`:return stepPath(e,t);case`natural`:return naturalPath(e);case`basis`:return basisPath(e);case`cardinal`:return cardinalPath(e,0);case`catmullRom`:return catmullRomPath(e,.5);default:return monotonePath(e)}}function stepPath(e,t){let n=`M${e[0][0]},${e[0][1]}`;for(let r=0;r<e.length-1;r++){let[i,a]=e[r],[o,s]=e[r+1];if(t===`stepBefore`)n+=`L${i},${s}L${o},${s}`;else if(t===`stepAfter`)n+=`L${o},${a}L${o},${s}`;else{let e=(i+o)/2;n+=`L${e},${a}L${e},${s}L${o},${s}`}}return n}function naturalControls(e){let t=e.length-1;if(t<1)return[[],[]];let n=Array(t),r=Array(t),i=Array(t);r[0]=2,i[0]=e[0]+2*e[1];for(let a=1;a<t-1;a++)n[a]=1,r[a]=4,i[a]=4*e[a]+2*e[a+1];n[t-1]=2,r[t-1]=7,i[t-1]=8*e[t-1]+e[t];for(let e=1;e<t;e++){let t=(n[e]??0)/r[e-1];r[e]=r[e]-t,i[e]=i[e]-t*i[e-1]}let a=Array(t),o=Array(t);a[t-1]=i[t-1]/r[t-1];for(let e=t-2;e>=0;e--)a[e]=(i[e]-a[e+1])/r[e];for(let n=0;n<t-1;n++)o[n]=2*e[n+1]-a[n+1];return o[t-1]=(e[t]+a[t-1])/2,[a,o]}function naturalPath(e){let t=e.length;if(t<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let n=e.map(e=>e[0]),r=e.map(e=>e[1]),[i,a]=naturalControls(n),[o,s]=naturalControls(r),c=`M${n[0]},${r[0]}`;for(let e=0;e<t-1;e++)c+=`C${i[e]},${o[e]} ${a[e]},${s[e]} ${n[e+1]},${r[e+1]}`;return c}function basisPath(e){let t=e.length;if(t<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let px=n=>e[Math.max(0,Math.min(t-1,n))][0],py=n=>e[Math.max(0,Math.min(t-1,n))][1],n=`M${px(0)},${py(0)}`;for(let e=0;e<t-1;e++){let t=px(e-1),r=py(e-1),i=px(e),a=py(e),o=px(e+1),s=py(e+1),c=(2*t+i)/3,l=(2*r+a)/3,u=(t+2*i)/3,d=(r+2*a)/3,f=(t+4*i+o)/6,m=(r+4*a+s)/6;n+=`C${c},${l} ${u},${d} ${f},${m}`}let r=e[t-1];return n+=`L${r[0]},${r[1]}`,n}function cardinalPath(e,t){let n=e.length;if(n<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let r=(1-t)/6,p=t=>e[Math.max(0,Math.min(n-1,t))],i=`M${e[0][0]},${e[0][1]}`;for(let e=0;e<n-1;e++){let t=p(e-1),n=p(e),a=p(e+1),o=p(e+2),s=n[0]+r*(a[0]-t[0]),c=n[1]+r*(a[1]-t[1]),l=a[0]-r*(o[0]-n[0]),u=a[1]-r*(o[1]-n[1]);i+=`C${s},${c} ${l},${u} ${a[0]},${a[1]}`}return i}function catmullRomPath(e,t){let n=e.length;if(n<3)return e.map(([e,t],n)=>`${n===0?`M`:`L`}${e},${t}`).join(``);let p=t=>e[Math.max(0,Math.min(n-1,t))],dist=(e,t)=>Math.hypot(t[0]-e[0],t[1]-e[1]),r=`M${e[0][0]},${e[0][1]}`;for(let e=0;e<n-1;e++){let n=p(e-1),i=p(e),a=p(e+1),o=p(e+2),s=dist(n,i)**+t||1e-6,c=dist(i,a)**+t||1e-6,l=dist(a,o)**+t||1e-6,u=a[0]-i[0]+c*((i[0]-n[0])/s-(a[0]-n[0])/(s+c)),d=a[1]-i[1]+c*((i[1]-n[1])/s-(a[1]-n[1])/(s+c)),f=a[0]-i[0]+c*((o[0]-a[0])/l-(o[0]-i[0])/(c+l)),m=a[1]-i[1]+c*((o[1]-a[1])/l-(o[1]-i[1])/(c+l)),h=i[0]+u/3,g=i[1]+d/3,_=a[0]-f/3,v=a[1]-m/3;r+=`C${h},${g} ${_},${v} ${a[0]},${a[1]}`}return r}function monotonePath(e){let t=e.length,n=[],r=[],i=[];for(let a=0;a<t-1;a++)n[a]=e[a+1][0]-e[a][0],r[a]=e[a+1][1]-e[a][1],i[a]=n[a]===0?0:r[a]/n[a];let a=[i[0]??0];for(let e=1;e<t-1;e++){let t=i[e-1],n=i[e];a[e]=t*n<=0?0:2*t*n/(t+n)}a[t-1]=i[t-2]??0;let o=`M${e[0][0]},${e[0][1]}`;for(let n=0;n<t-1;n++){let[t,r]=e[n],[i,s]=e[n+1],c=(i-t)/3;o+=`C${t+c},${r+c*a[n]} ${i-c},${s-c*a[n+1]} ${i},${s}`}return o}function areaPath(e,t,n=`linear`){if(e.length===0)return``;let r=linePath(e,n),i=e[e.length-1],a=e[0];return`${r}L${i[0]},${t}L${a[0]},${t}Z`}function arcPath(e,t,n,r,i,a){let o=2*Math.PI;if(Math.abs(a-i)>=o-1e-9){let a=i+Math.PI;return arcPath(e,t,n,r,i,a)+arcPath(e,t,n,r,a,i+o-1e-9)}let point=(n,r)=>[quantize(e+n*Math.sin(r)),quantize(t-n*Math.cos(r))],s=+(a-i>Math.PI),c=quantize(n),l=quantize(r),[u,d]=point(n,i),[f,m]=point(n,a);if(r<=0)return`M${quantize(e)},${quantize(t)}L${u},${d}A${c},${c} 0 ${s} 1 ${f},${m}Z`;let[h,g]=point(r,a),[_,v]=point(r,i);return`M${u},${d}A${c},${c} 0 ${s} 1 ${f},${m}L${h},${g}A${l},${l} 0 ${s} 0 ${_},${v}Z`}function stackSeries(e){let t=e[0]?.length??0,n=Array.from({length:t},()=>0);return e.map(e=>e.map((e,t)=>{let r=n[t];return n[t]=r+e,[r,n[t]]}))}var e={frame:`_frame_1gm0a_2`,"cascivo-chart-in":`_cascivo-chart-in_1gm0a_1`,fallback:`_fallback_1gm0a_78`};export{quantize as a,bandScale as c,sqrtScale as d,linePath as i,linearScale as l,arcPath as n,splitDefined as o,areaPath as r,stackSeries as s,e as t,niceTicks as u};
|