@motionscript/charts 0.1.1-alpha.0 → 0.1.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +98 -28
- package/dist/bar-chart/bar-chart.d.ts +233 -39
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +215 -171
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +12 -7
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +56 -42
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +52 -52
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +80 -89
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +4 -4
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +2 -2
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +36 -65
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +68 -117
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-R3Q5EE6E.js +2 -0
- package/dist/browser/chunks/chunk-R3Q5EE6E.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +4 -4
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +1 -1
- package/dist/engine.d.ts +5 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +5 -2
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.d.ts +49 -15
- package/dist/kit/cartesian.d.ts.map +1 -1
- package/dist/kit/cartesian.js +79 -29
- package/dist/kit/cartesian.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +32 -24
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +52 -46
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +8 -4
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +30 -20
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/{line-chart → kit}/horizontal-axis.d.ts +31 -6
- package/dist/kit/horizontal-axis.d.ts.map +1 -0
- package/dist/{line-chart → kit}/horizontal-axis.js +23 -24
- package/dist/kit/horizontal-axis.js.map +1 -0
- package/dist/kit/motion.d.ts +5 -0
- package/dist/kit/motion.d.ts.map +1 -1
- package/dist/kit/motion.js +8 -0
- package/dist/kit/motion.js.map +1 -1
- package/dist/{pie-chart → kit}/pie-legend.d.ts +3 -3
- package/dist/kit/pie-legend.d.ts.map +1 -0
- package/dist/{pie-chart → kit}/pie-legend.js +11 -10
- package/dist/kit/pie-legend.js.map +1 -0
- package/dist/kit/polar.d.ts +31 -0
- package/dist/kit/polar.d.ts.map +1 -0
- package/dist/kit/polar.js +33 -0
- package/dist/kit/polar.js.map +1 -0
- package/dist/kit/shared.d.ts +11 -50
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +58 -141
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/style.d.ts +254 -0
- package/dist/kit/style.d.ts.map +1 -0
- package/dist/kit/style.js +197 -0
- package/dist/kit/style.js.map +1 -0
- package/dist/kit/vertical-axis.d.ts +22 -2
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +56 -43
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +95 -3
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +165 -53
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +1 -1
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +7 -8
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/index.d.ts +5 -6
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +3 -4
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +257 -18
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +282 -134
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +51 -34
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +175 -83
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +2 -0
- package/dist/line-chart/x-scale.d.ts.map +1 -1
- package/dist/line-chart/x-scale.js +15 -0
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +3 -1
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +9 -1
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +2 -3
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -2
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +114 -18
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +37 -24
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +16 -5
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +89 -55
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +53 -61
- package/dist/pie-chart/shared.d.ts.map +1 -1
- package/dist/pie-chart/shared.js +41 -121
- package/dist/pie-chart/shared.js.map +1 -1
- package/dist/radar-chart/index.d.ts +5 -0
- package/dist/radar-chart/index.d.ts.map +1 -0
- package/dist/radar-chart/index.js +5 -0
- package/dist/radar-chart/index.js.map +1 -0
- package/dist/radar-chart/radar-chart.d.ts +218 -0
- package/dist/radar-chart/radar-chart.d.ts.map +1 -0
- package/dist/radar-chart/radar-chart.js +224 -0
- package/dist/radar-chart/radar-chart.js.map +1 -0
- package/dist/radar-chart/radar-grid.d.ts +43 -0
- package/dist/radar-chart/radar-grid.d.ts.map +1 -0
- package/dist/radar-chart/radar-grid.js +61 -0
- package/dist/radar-chart/radar-grid.js.map +1 -0
- package/dist/radar-chart/radar-series.d.ts +59 -0
- package/dist/radar-chart/radar-series.d.ts.map +1 -0
- package/dist/radar-chart/radar-series.js +71 -0
- package/dist/radar-chart/radar-series.js.map +1 -0
- package/dist/radar-chart/shared.d.ts +73 -0
- package/dist/radar-chart/shared.d.ts.map +1 -0
- package/dist/radar-chart/shared.js +123 -0
- package/dist/radar-chart/shared.js.map +1 -0
- package/dist/radial-chart/index.d.ts +6 -0
- package/dist/radial-chart/index.d.ts.map +1 -0
- package/dist/radial-chart/index.js +4 -0
- package/dist/radial-chart/index.js.map +1 -0
- package/dist/radial-chart/radial-chart.d.ts +216 -0
- package/dist/radial-chart/radial-chart.d.ts.map +1 -0
- package/dist/radial-chart/radial-chart.js +174 -0
- package/dist/radial-chart/radial-chart.js.map +1 -0
- package/dist/radial-chart/radial-rings.d.ts +121 -0
- package/dist/radial-chart/radial-rings.d.ts.map +1 -0
- package/dist/radial-chart/radial-rings.js +273 -0
- package/dist/radial-chart/radial-rings.js.map +1 -0
- package/dist/radial-chart/shared.d.ts +73 -0
- package/dist/radial-chart/shared.d.ts.map +1 -0
- package/dist/radial-chart/shared.js +79 -0
- package/dist/radial-chart/shared.js.map +1 -0
- package/package.json +4 -4
- package/registry.json +21 -6
- package/src/bar-chart/bar-chart.ts +252 -179
- package/src/bar-chart/category-axis.ts +46 -40
- package/src/bar-chart/chart-bars.ts +97 -117
- package/src/bar-chart/index.ts +7 -10
- package/src/bar-chart/shared.ts +78 -238
- package/src/engine.ts +5 -2
- package/src/index.ts +2 -0
- package/src/kit/cartesian.ts +118 -40
- package/src/kit/chart-canvas.ts +49 -54
- package/src/kit/chart-legend.ts +28 -20
- package/src/kit/horizontal-axis.ts +114 -0
- package/src/kit/motion.ts +7 -0
- package/src/{pie-chart → kit}/pie-legend.ts +12 -11
- package/src/kit/polar.ts +54 -0
- package/src/kit/shared.ts +55 -277
- package/src/kit/style.ts +257 -0
- package/src/kit/vertical-axis.ts +67 -48
- package/src/line-chart/chart-line.ts +176 -54
- package/src/line-chart/chart-region.ts +6 -10
- package/src/line-chart/index.ts +14 -10
- package/src/line-chart/line-chart.ts +347 -151
- package/src/line-chart/shared.ts +193 -174
- package/src/line-chart/x-scale.ts +13 -0
- package/src/nodes.ts +9 -1
- package/src/pie-chart/index.ts +2 -23
- package/src/pie-chart/pie-chart.ts +52 -35
- package/src/pie-chart/pie-ring.ts +92 -71
- package/src/pie-chart/shared.ts +68 -266
- package/src/radar-chart/index.ts +4 -0
- package/src/radar-chart/radar-chart.ts +287 -0
- package/src/radar-chart/radar-grid.ts +78 -0
- package/src/radar-chart/radar-series.ts +88 -0
- package/src/radar-chart/shared.ts +146 -0
- package/src/radial-chart/index.ts +5 -0
- package/src/radial-chart/radial-chart.ts +210 -0
- package/src/radial-chart/radial-rings.ts +328 -0
- package/src/radial-chart/shared.ts +114 -0
- package/dist/browser/chunks/chunk-4SMRCU24.js +0 -2
- package/dist/browser/chunks/chunk-4SMRCU24.js.map +0 -7
- package/dist/kit/chart-border.d.ts +0 -18
- package/dist/kit/chart-border.d.ts.map +0 -1
- package/dist/kit/chart-border.js +0 -23
- package/dist/kit/chart-border.js.map +0 -1
- package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
- package/dist/line-chart/horizontal-axis.js.map +0 -1
- package/dist/pie-chart/pie-legend.d.ts.map +0 -1
- package/dist/pie-chart/pie-legend.js.map +0 -1
- package/src/kit/chart-border.ts +0 -36
- package/src/line-chart/horizontal-axis.ts +0 -122
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as Bt,B as we,C as K,D as q,E as Se,F as Ae,G as Z,H as J,I as Gt,J as Ht,K as ke,L as ve,M as Nt,N as Ut,O as F,P as Ee,Q as qe,R as T,S as zt,T as I,U as Re,V as Te,W as Le,X as D,Y as Me,Z as Ce,_ as Q,a as f,b as W,c as C,d as xe,e as U,f as _,g as y,h as w,i as Y,j as b,k as z,l as P,m as $,n as ue,o as de,p as he,q as k,r as Uo,s as O,t as S,u as j,v as zo,w as E,x as ye,y as be,z as R}from"./chunks/chunk-4SMRCU24.js";import{Rect as Mn,Types as V,component2d as Cn,easeOut as B}from"@motionscript/sdk";import{formatNumber as _n}from"@motionscript/sdk/component";import{Graphics2D as nt,Types as ot,component2d as xn,strokeOps as $t}from"@motionscript/sdk";import{Fills as cn,fillOps as Xt,lerpNumber as un,strokeOps as Vt}from"@motionscript/sdk";import{niceStep as Wt}from"@motionscript/sdk/component";var ee={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function te(e){return e.right>e.left&&e.top>e.bottom}function Ze(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return ee;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let x=Math.min(d[0],d[1]),N=Math.max(d[0],d[1]),A=Ke=>g+(Ke-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,A(x))),Math.max(g,Math.min(p,A(N))),!0]},[i,s,a]=o(e.x,r,t.left,t.right),[c,l,u]=o(e.y,n,t.bottom,t.top);return{left:i,right:s,bottom:c,top:l,xBounded:a,yBounded:u}}function Je(e,t){if(e.length<2||!te(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=hn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&dn(n[n.length-1],s)?n.push(a):(n.length>=2&&r.push(n),n=[s,a])}return n.length>=2&&r.push(n),r}function dn(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function hn(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-n,e.x-r.left],[n,r.right-e.x],[-o,e.y-r.bottom],[o,r.top-e.y]];for(let[c,l]of a){if(c===0){if(l<0)return null;continue}let u=l/c;if(c<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*n,y:e.y+i*o},{x:e.x+s*n,y:e.y+s*o}]}var pn={...R,markerStyle:{...R.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:E,yAxis:ye,plotArea:be,legend:pn,region:{stroke:{weight:3,fill:k.regionColor,dash:[14,12],cap:"butt"},fill:cn.color(k.regionColor,{opacity:.08}),dimOpacity:O}};function fn(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:Xt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function gn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:Xt.lerp(e.fill,t.fill,r),dimOpacity:un(e.dimOpacity,t.dimOpacity,r)}}function Qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:K(e?.xAxis,r.xAxis),yAxis:K(e?.yAxis,r.yAxis),plotArea:Se(e?.plotArea,r.plotArea),legend:Z(e?.legend,r.legend),region:fn(e?.region,r.region)}}function et(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:q(e.xAxis,t.xAxis,r),yAxis:q(e.yAxis,t.yAxis,r),plotArea:Ae(e.plotArea,t.plotArea,r),legend:J(e.legend,t.legend,r),region:gn(e.region,t.region,r)}}function tt(e,t,r){return e.map((n,o)=>[t.at(o),S(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Yt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=S(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function rt(e,t,r,n){if(r)return r;let[o,i]=Yt(e,t),s=Math.max(1,Math.round(n));if(i===o)return mn(o,s);let a=Wt((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function mn(e,t){if(e===0)return[0,1];let r=Wt(Math.abs(e)/t);return[e-r,e+r]}function yn(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let r=[],n=0;for(let s=1;s<e.length;s++){let a=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);r.push(a),n+=a}if(n===0)return e;let o=n*t,i=[e[0]];for(let s=0;s<r.length;s++)if(o>=r[s])i.push(e[s+1]),o-=r[s];else{let a=r[s]===0?0:o/r[s];i.push({x:e[s].x+(e[s+1].x-e[s].x)*a,y:e[s].y+(e[s+1].y-e[s].y)*a});break}return i}var _e=xn({key:"chartLine",state:{points:f(()=>[]),stroke:ot.custom([],{resolve:$t.resolve,lerp:$t.lerp}),progress:1,enabled:!0,spotlight:f(()=>ee),dimOpacity:O},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:ot.number(0,{min:0,max:1}),to:ot.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=y(e);return e.animate(o=>{let i=t+(r-t)*n(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let r=t.points;if(r.length<2)return;let n=Math.max(0,Math.min(1,t.progress));if(n<=0)return;let o=yn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!te(a)){e.draw(new nt().line({points:o,radius:s}).stroke(i));return}e.draw(new nt().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Je(o,a))e.draw(new nt().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as jt,Types as Kt,component2d as bn,fillOps as qt,strokeOps as Zt}from"@motionscript/sdk";var st=bn({key:"chartRegion",state:{box:f(()=>ee),stroke:Kt.custom(X.region.stroke,{resolve:Zt.resolve,lerp:Zt.lerp}),fill:Kt.custom(X.region.fill,{resolve:qt.resolve,lerp:qt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!te(r))return;let n=Math.max(0,Math.min(1,t.reveal));if(n<=0)return;let o=r.right-r.left,i=r.top-r.bottom,s=(r.left+r.right)/2,a=(r.bottom+r.top)/2;if(t.fill.length>0&&e.draw(new jt().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(n)),t.stroke.length===0)return;let c=l=>e.draw(new jt().line({points:l}).stroke(t.stroke).opacity(n));if(r.xBounded){let l=i/2*n;for(let u of[r.left,r.right])c([{x:u,y:a-l},{x:u,y:a+l}])}if(r.yBounded){let l=o/2*n;for(let u of[r.bottom,r.top])c([{x:s-l,y:u},{x:s+l,y:u}])}}});import{Rect as Jt,Text as Qt,Types as it,component2d as wn,insetsOps as er,textOps as tr}from"@motionscript/sdk";import{enterBudget as Sn}from"@motionscript/sdk/component";var An=24,Pe=wn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:it.custom(E),label:"",arrivals:Y()},defaults:{width:"fill",height:"fill"},children:e=>{let t=er.resolve(e.axis.tickPadding).top,r=er.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds??{width:0,height:0},i=()=>[...e.markers].sort((l,u)=>l-u),s=l=>{if(l===void 0)return 0;let[u,d]=e.range;return d<=u?0:(l-u)/(d-u)},a=e.markers.map((l,u)=>{let d=new Qt({...tr.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":zt(e,h)},x:()=>{let h=o().width,m=(s(i()[u])-.5)*h,g=h/2-d.layoutBounds.width/2;return Math.min(m,g)},opacity:()=>b(e.arrivals,u).opacity,y:()=>b(e.arrivals,u).shift});return d}),c=[new Jt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Qt({...tr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>b(e.arrivals,"label").opacity,y:()=>b(e.arrivals,"label").shift})),n.push(new Jt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:it.custom(void 0),slide:it.number(An)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.markers.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.markers.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:z(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=Sn(e.duration,o,i,r),h=y(e),m=t.markers.map((p,x)=>({at:x*l,duration:u,piece:P(e,x,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,w(e,[...m,...g])])}}}});import{formatNumber as kn}from"@motionscript/sdk/component";var Oe=864e5,ar=["january","february","march","april","may","june","july","august","september","october","november","december"],rr=2024;function nr(e){return e.length<3?-1:ar.findIndex(t=>t.startsWith(e))}function vn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*Oe+(t-1)*7*Oe}function lr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let r=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(r){let s=Number(r[2]),a=r[3]===void 0?1:Number(r[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(r[1]),s-1,a)}let n=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(n){let s=Number(n[2]);return s<1||s>53?null:vn(n[1]===void 0?rr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=nr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?rr:Number(a);return Date.UTC(c,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=nr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function cr(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=ar[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*Oe?String(n):t>60*Oe?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function En(e,t){let r=!1;for(let n of e){let o=n[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;r=!0}}return r}function Rn(e,t){let r=[],n=!1;for(let s of e){let a=s[t];if(a==null||a===""){r.push(null);continue}let c=lr(a);if(c===null)return null;r.push(c),n=!0}if(!n)return null;let i=r.find(s=>s!==null);return r.map(s=>s===null?i:i=s)}function or(e){let t=1/0,r=-1/0;for(let n of e)n<t&&(t=n),n>r&&(r=n);return t<=r?[t,r]:[0,1]}function sr(e,[t,r],n){let o=e.filter(c=>c>=t&&c<=r),i=[...new Set(o)].sort((c,l)=>c-l);if(i.length===0)return T([t,r],n);let s=c=>i.reduce((l,u)=>Math.abs(u-c)<Math.abs(l-c)?u:l),a=[];for(let c of T([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function Tn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}var ir=new WeakMap;function at(e,t,r){let n=ir.get(e);n||ir.set(e,n=new Map);let o=JSON.stringify([t,r??null]),i=n.get(o);return i||n.set(o,i=Ln(e,t,r)),i}function Ln(e,t,r){if(t!==""&&En(e,t)){let s=e.map(a=>S(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:or(s),label:a=>r===void 0?F(a):kn(a,r),ticks:T}}let n=e.map(s=>j(s,t)),o=t===""?null:Rn(e,t);if(o){let s=or(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>Tn(o,n,c,l=>cr(l,a)),ticks:(c,l)=>sr(o,c,l)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>n[Math.round(s)]??"",ticks:(s,a)=>sr(i,s,a)}}var ur=V.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}});function ct(e,t=e.xAxis.format){return at(e.data,e.xField,t)}function Pn(e,t){let r=ct(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,U-1)}}function On(e,t){let r=(t.ticks?.length??U)-1,n=rt(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??T(n,U-1)}}var dr=new WeakMap;function Fe(e){let{data:t,xField:r,xAxis:n,yAxis:o,series:i}=e,s=dr.get(t);if(s&&s.xField===r&&s.xAxis===n&&s.yAxis===o&&s.series===i)return s.domains;let a={x:he(n,c=>Pn(e,c)),y:he(o,c=>On(e,c))};return dr.set(t,{xField:r,xAxis:n,yAxis:o,series:i,domains:a}),a}function Fn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=tt(e.data,ct(e),o);if(i.length===0)return[];let{width:s,height:a}=n,[c,l]=t.x.range,[u,d]=t.y.range,h=g=>l<=c?0:((g-c)/(l-c)-.5)*s,m=g=>d<=u?0:((g-u)/(d-u)-.5)*a;return i.map(([g,p])=>({x:h(g),y:m(p)}))}function hr(e,t,r){let{width:n,height:o}=r;return Ze(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function pr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function fr(e){return e!=null&&typeof e=="object"?e:{}}function In([e,t]){return e<=t?[e,t]:[t,e]}function gr(e,t){let r=In(e);return{range:r,ticks:T(r,Math.max(2,t.length)-1)}}function mr(e,t,r){return{...t.x&&{xAxis:ue(e.x,t.x,r)},...t.y&&{yAxis:ue(e.y,t.y,r)}}}function lt(e){let t=Te(e);if(!t)return null;let r=t.below.find(Pe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(_e.is),legend:t.below.find(Q.is)??null}}function xr(e,t){let r=t.regionReveal,n=t.region;return r===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:n,regionReveal:r*(1-o)})}function yr(e,t,r,n){let o=lt(t),i=o?.lines[r];return!o||!i?e.wait(e.duration):e.together([i.run("enter",n?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(n?"showSeries":"hideSeries",{index:r})]:[]])}var ut=Cn({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:V.custom({},{resolve:$,lerp:de}),yAxis:V.custom({},{resolve:$,lerp:de}),theme:V.custom(X,{resolve:Qe,lerp:et}),region:V.custom(null),regionReveal:0,showLegend:V.boolean(!0,{animatable:!1}),home:V.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Fe(e),n,o=()=>Le(n),i=e.series.map(d=>d.enabled??!0),s=new I({range:()=>r().y.range,markers:()=>r().y.ticks,captions:()=>{let d=r().y.ticks,h=e.yAxis.format;return d.map(m=>h===void 0?F(m,Ee(d)):_n(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Pe({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=ct(e);return r().x.ticks.map(h=>d.label(h))},axis:()=>t().xAxis,label:e.xAxis.label??"",width:"fill",height:"hug"}),c=e.series.map((d,h)=>new _e({points:()=>Fn(e,r(),h,o()),stroke:()=>Nt(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>hr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Q({series:e.series,swatches:()=>e.series.map((d,h)=>Ut(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Mn({clip:!0,children:[new Ce({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:()=>r().x.ticks,yMarkers:()=>r().y.ticks,xExtent:()=>r().x.range,yExtent:()=>r().y.range}),new st({box:()=>hr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Me({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().y.range,markers:()=>r().y.ticks,axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:0});return[Re({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:B(),run:(e,t,r)=>{let n=lt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=pr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*_.axes,c=s*_.marks,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return w(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-xe}))]:[],{at:0,duration:a,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:a,piece:n.hAxis.run("enter",{slide:24})},...n.lines.map(d=>({at:a,duration:c,piece:d.run("enter")})),...l?[{at:a+c,duration:s*_.legend,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:ur},easing:B(),run:(e,t)=>{let r=fr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?xr(e,t):n<=0||!pr(t)?e.animate(i=>({region:r,regionReveal:n+(1-n)*i})):e.animate(i=>i<.5?{region:o,regionReveal:n*(1-e.ease(i*2))}:{region:r,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:B(),run:(e,t)=>xr(e,t)},zoomTo:{args:{region:ur},easing:B(),run:(e,t)=>{let r=fr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Fe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...gr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...gr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...mr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Fe(t);return e.animate(o=>({home:null,...mr(n,r,o)}))}},showSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>yr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>yr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>{let n=lt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...n.lines.map((i,s)=>i.to({opacity:s===o?1:O})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Qn,Types as G,clamp as Dr,component2d as eo,easeOut as re}from"@motionscript/sdk";import{formatNumber as to}from"@motionscript/sdk/component";import{Rect as dt,Text as br,Types as ht,clamp as Dn,component2d as Bn,insetsOps as wr,textOps as Sr}from"@motionscript/sdk";import{enterBudget as Gn}from"@motionscript/sdk/component";var Hn=24,Ie=Bn({key:"categoryAxis",state:{categories:f(()=>[]),axis:ht.custom(E),label:"",dims:f(()=>[]),arrivals:Y()},defaults:{width:"fill",height:"fill"},children:e=>{let t=wr.resolve(e.axis.tickPadding).top,r=wr.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds.width??0,i=c=>{let l=e.categories.length;return l<=0?0:-o()/2+o()/l*(c+.5)},s=e.categories.map((c,l)=>new dt({width:"hug",height:"hug",flow:"freeform",opacity:()=>Dn(e.dims[l]??1,0,1),x:()=>i(l),children:[new br({...Sr.styleProps(e.axis.labelStyle),text:c,opacity:()=>b(e.arrivals,l).opacity,y:()=>b(e.arrivals,l).shift})]})),a=[new dt({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new br({...Sr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>b(e.arrivals,"label").opacity,y:()=>b(e.arrivals,"label").shift})),n.push(new dt({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:ht.custom(void 0),slide:ht.number(Hn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.categories.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:z(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=Gn(e.duration,o,i,r),h=y(e),m=(o-1)*l+u,g=t.categories.map((x,N)=>({at:N*l,duration:u,piece:P(e,N,s,h)})),p=i?[{at:m,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,w(e,[...g,...p])])}}}});import{Graphics2D as Vn,Text as Wn,Types as He,clamp as Cr,component2d as Yn,fillOps as Rr,shadowOps as Tr,strokeOps as Lr,textOps as $n}from"@motionscript/sdk";import{fillOps as Nn,lerpNumber as De,shadowOps as Ar,strokeOps as kr,textOps as vr}from"@motionscript/sdk";import{niceStep as Un}from"@motionscript/sdk/component";function Be(e,t,r){let n=0;return t.map(o=>{let i=S(e,o.field);if(!r)return{from:0,to:i,value:i};let s=n;return n+=i,{from:s,to:n,value:i}})}function pt(e,t){let r=-1;for(let n=0;n<t.length;n++)S(e,t[n].field)!==0&&(r=n);return r}function ft(e,t){return e.map(r=>j(r,t))}function Er(e,t,r){let n=0,o=0;for(let i of e)for(let s of Be(i,t,r))n=Math.min(n,s.from,s.to),o=Math.max(o,s.from,s.to);return n<o?[n,o]:[0,1]}function gt(e,t,r,n,o){if(n)return n;let[i,s]=Er(e,t,r),a=Math.max(1,Math.round(o)),c=Un((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var L={seriesFills:we,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...E,labelStyle:{...E.labelStyle,fontWeight:600},tickPadding:16},yAxis:ye,plotArea:be,legend:R,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:k.markerColor},spotlight:{dimOpacity:O}};function zn(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:kr.resolve(e?.stroke??t.stroke),shadow:Ar.resolve(e?.shadow??t.shadow)}}function Xn(e,t,r){return{cornerRadius:De(e.cornerRadius,t.cornerRadius,r),slotFill:De(e.slotFill,t.slotFill,r),groupGap:De(e.groupGap,t.groupGap,r),stroke:kr.lerp(e.stroke,t.stroke,r),shadow:Ar.lerp(e.shadow,t.shadow,r)}}function mt(e,t){let r=t??L;return{seriesFills:ke(e?.seriesFills,r.seriesFills),bar:zn(e?.bar,r.bar),xAxis:K(e?.xAxis,r.xAxis),yAxis:K(e?.yAxis,r.yAxis),plotArea:Se(e?.plotArea,r.plotArea),legend:Z(e?.legend,r.legend),valueStyle:vr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function xt(e,t,r){return{seriesFills:ve(e.seriesFills,t.seriesFills,r),bar:Xn(e.bar,t.bar,r),xAxis:q(e.xAxis,t.xAxis,r),yAxis:q(e.yAxis,t.yAxis,r),plotArea:Ae(e.plotArea,t.plotArea,r),legend:J(e.legend,t.legend,r),valueStyle:vr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:De(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function Ge(e,t,r){return t.fill!=null?Nn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var jn=10,Kn=1.6,qn=24;function Mr(e,t){return e.enabled?Cr(e.dims[t]??1,0,1):0}function yt(e,t){let r=e.bars[t];if(!r)return null;let n=Cr(e.growth,0,1);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function _r(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:qn}function Pr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function Zn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Pr(e,t)){let n=yt(e,t);if(!n||Math.abs(n.end-n.base)<_r(e)*Kn)return""}return r.caption??F(r.value)}function Jn(e,t){let r=yt(e,t);if(!r)return 0;if(Pr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(jn+_r(e)/2)}var Ne=Yn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:He.custom([],{resolve:Rr.resolve,lerp:Rr.lerp}),barStroke:He.custom(L.bar.stroke,{resolve:Lr.resolve,lerp:Lr.lerp}),barShadow:He.custom(L.bar.shadow,{resolve:Tr.resolve,lerp:Tr.lerp}),cornerRadius:L.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:He.custom(L.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Wn({...$n.styleProps(e.valueStyle),text:()=>Zn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Jn(e,r),opacity:()=>Mr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=y(e);return e.animate(r=>({growth:t(r)}))}},render:(e,t)=>{if(t.enabled)for(let r=0;r<t.bars.length;r++){let n=t.bars[r],o=yt(t,r);if(!o||n.width<=0)continue;let i=Math.abs(o.end-o.base);if(i<=0)continue;let s=n.round?Math.min(t.cornerRadius,i):0,a=new Vn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Mr(t,r)))}e.children()}});function ro(e,t){let r=(t.ticks?.length??U)-1,n=gt(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??T(n,U-1)}}var Or=new WeakMap;function St(e){let{data:t,series:r,stacked:n,valueAxis:o}=e,i=Or.get(t);if(i&&i.series===r&&i.stacked===n&&i.valueAxis===o)return i.domain;let s=he(o,a=>ro(e,a));return Or.set(t,{series:r,stacked:n,valueAxis:o,domain:s}),s}function Br(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ee(t.ticks)):to(r,n)}function bt(e,t,r){let[n,o]=e.range;return o<=n?-t.height/2:((r-n)/(o-n)-.5)*t.height}function no(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function pe(e,t){return Math.max(0,e.weights[t]??1)}function oo(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*pe(e,o))}),r}function so(e,t,r,n){let o=e.series[t];if(!o)return[];let i=St(e),s=e.data.length,a=s>0?r.width/s:0,c=p=>-r.width/2+a*(p+.5),l=a*Dr(e.theme.bar.slotFill,0,1),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=pe(e,p);let h=l/(d>0?d:1),m=pe(e,t),g=0;for(let p=0;p<t;p++)g+=pe(e,p);return e.data.map((p,x)=>{let A=Be(e.stacked?oo(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},Ke=e.stacked?pt(p,e.series):t,sn=c(x)-l/2,an=e.stacked?c(x):sn+h*g+h*m/2,ln=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=S(p,o.field);return{x:an,width:ln,from:bt(i,r,A.from),to:bt(i,r,A.to),round:Ke===t,value:Dt,...n&&{caption:Br(e,i,Dt)}}})}function Fr(e){let t=Dr(e.spotlightReveal,0,1),r=e.theme.spotlight.dimOpacity,n=e.spotlight;return e.data.map((o,i)=>t<=0||n===i?1:1-(1-r)*t)}function wt(e){let t=Te(e);if(!t)return null;let r=t.below.find(Ie.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ne.is),legend:t.below.find(Q.is)??null}}function Ir(e,t,r,n,o){let i=wt(r);if(!i||!i.bars[n])return e.wait(e.duration);let s=t.series.map((l,u)=>pe(t,u)),a=s[n]??1,c=t.series.map((l,u)=>t.showing[u]??l.enabled??!0);return e.together([e.animate(l=>{let u=[...s];u[n]=a+(o-a)*e.ease(l);let d=[...c];return d[n]=o>0||l<1,{weights:u,showing:d}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:n})]:[]])}var At=eo({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:G.custom({},{resolve:$,lerp:de}),categoryAxis:G.custom({},{resolve:$,lerp:ue}),theme:G.custom(L,{resolve:mt,lerp:xt}),growth:1,weights:f(()=>[]),spotlight:G.custom(null),spotlightReveal:0,showLegend:G.boolean(!0,{animatable:!1}),showValues:G.boolean(!1,{animatable:!1}),showing:G.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Le(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Br(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Ie({categories:ft(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Fr(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ne({bars:()=>so(e,h,o(),i),baseline:()=>no(r(),o()),fill:()=>Ge(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Fr(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Q({series:e.series,swatches:()=>e.series.map((d,h)=>Ge(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Qn({clip:!0,children:[new Ce({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:[],yMarkers:()=>r().ticks,xExtent:()=>[0,1],yExtent:()=>r().range}),...c,new Me({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().range,markers:()=>r().ticks,axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:0});return[Re({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:re(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*_.axes,s=o*_.marks,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return w(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-xe}))]:[],{at:0,duration:i,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:i,piece:n.cAxis.run("enter",{slide:24})},{at:i,duration:s,piece:e.animate(l=>({growth:l}))},...a?[{at:i+s,duration:o*_.legend,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>Ir(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>Ir(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex,i=t.theme.spotlight.dimOpacity;return e.together([...n.bars.map((s,a)=>s.to({opacity:a===o?1:i})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}},spotlightCategory:{args:{categoryIndex:G.number(0,{min:0,step:1})},easing:re(),run:(e,t)=>{let r=e.args.categoryIndex;if(r<0||r>=t.data.length)return e.wait(e.duration);let n=t.spotlightReveal;return e.animate(o=>({spotlight:r,spotlightReveal:n+(1-n)*o}))}},clearCategory:{args:{},easing:re(),run:(e,t)=>{let r=t.spotlightReveal;if(r===0)return e.wait(e.duration);let n=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:n,spotlightReveal:r*(1-o)})}}}});import{Rect as nn,Types as le,clamp as on,component2d as Io,easeOut as ae}from"@motionscript/sdk";import{Flow as kt,Paint as fe,Rect as vt,Shapes as Gr,Text as io,Types as ao,clamp as lo,component2d as co,textOps as uo}from"@motionscript/sdk";var Hr=16,Ue=co({key:"pieLegend",state:{...fe.state,...kt.state,...Gr.corners,slices:f(()=>[]),legend:ao.custom(R),dims:f(()=>[]),arrivals:Y()},defaults:{flow:"vertical",align:"centerLeft",width:"hug",height:"hug",gap:e=>e.legend.itemGap/3,padding:e=>e.legend.padding},children:e=>{let t=e.legend.markerStyle;return e.slices.map((r,n)=>vt({width:"hug",height:"hug",flow:"freeform",opacity:()=>lo(e.dims[n]??1,0,1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>b(e.arrivals,n).opacity,x:()=>b(e.arrivals,n).shift,children:[vt({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:()=>e.slices[n]?.fill??"white",stroke:t.stroke,shadow:t.shadow}),io({...uo.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...fe.commands,arm:(e,t)=>e.animate(()=>({arrivals:z([...t.slices.keys()],{opacity:0,shift:Hr})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Hr},o=e.animate(()=>({arrivals:z([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=y(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:P(e,u,n,a)}));return e.together([o,w(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,fe.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,fe.inset(t)),render:(e,t)=>fe.draw(e,t,Gr.rect(e.size,t))});import{Graphics2D as zr,PathBuilder as So,Rect as Ct,Text as oe,Types as me,clamp as ie,component2d as Ao,fillOps as Xr,shadowOps as ko,strokeOps as Vr,textOps as se}from"@motionscript/sdk";import{clamp as ho,lerpNumber as ge,shadowOps as Nr,strokeOps as ze,textOps as v}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:j(o,t),value:S(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var po=Math.PI/180;function Xe(e,t,r){return e<=0?1:1-(1-ho(t,0,1))*e*(1-r)}function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Ur(e){let t=0;for(let r of e)t+=Tt(r);return t}function ne(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ve(e,t){let r=Ur(e);if(r<=0)return[];let n=[],o=t*po;return e.forEach((i,s)=>{let a=Tt(i);if(a<=0)return;let c=a/r,l=o,u=l+c*Math.PI*2;o=u,n.push({index:s,a0:l,a1:u,mid:(l+u)/2,fraction:c})}),n}function We(e,t,r,n){e.sort((s,a)=>a.ideal-s.ideal);let o=r;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=n;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Et={fontSize:26,fontWeight:600,textAlign:"center",fill:k.markerColor},fo=.1,M={sliceFills:we,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:Et,percentStyle:{...Et,fontWeight:700},insideStyle:{...Et,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:k.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:k.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:k.markerColor}},legend:R,spotlight:{dimOpacity:fo}};function go(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:ze.resolve(e?.stroke??t.stroke),shadow:Nr.resolve(e?.shadow??t.shadow)}}function mo(e,t,r){return{gap:ge(e.gap,t.gap,r),holeRadius:ge(e.holeRadius,t.holeRadius,r),startAngle:ge(e.startAngle,t.startAngle,r),selectedGrow:ge(e.selectedGrow,t.selectedGrow,r),stroke:ze.lerp(e.stroke,t.stroke,r),shadow:Nr.lerp(e.shadow,t.shadow,r)}}function xo(e,t){return{textStyle:v.resolveStyle(e?.textStyle,t.textStyle),percentStyle:v.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:v.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:ze.resolve(e?.leaderStroke??t.leaderStroke)}}function yo(e,t,r){return{textStyle:v.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:v.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:v.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:ze.lerp(e.leaderStroke,t.leaderStroke,r)}}function bo(e,t){return{labelStyle:v.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:v.resolveStyle(e?.captionStyle,t.captionStyle)}}function wo(e,t,r){return{labelStyle:v.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:v.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??M;return{sliceFills:ke(e?.sliceFills,r.sliceFills),ring:go(e?.ring,r.ring),label:xo(e?.label,r.label),center:bo(e?.center,r.center),legend:Z(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Mt(e,t,r){return{sliceFills:ve(e.sliceFills,t.sliceFills,r),ring:mo(e.ring,t.ring,r),label:yo(e.label,t.label,r),center:wo(e.center,t.center,r),legend:J(e.legend,t.legend,r),spotlight:{dimOpacity:ge(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var Wr=12,vo=14,_t=.62,Eo=6,Yr=34,$r=26,jr=8,Ro=.18,To=240,Lo=8,Kr=2,Qr=.44,Pt=.62,Mo=.78,Co=.9,qr=.001,en=26;function H(e,t=en){let r=e.fontSize;return typeof r=="number"?r:t}function _o(e,t,r,n,o,i){let s=new So,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*To)),l=d=>d<=0?0:Math.min(o/d,a/2.2),u=(d,h)=>{let m=l(d),g=e+m,p=t-m,x=ne(d,g+(p-g)*h/c);return{x:x.x+i,y:x.y}};if(r<=0){s.moveTo(i,0);for(let d=0;d<=c;d++){let h=u(n,d);s.lineTo(h.x,h.y)}return s.close(),s}for(let d=0;d<=c;d++){let h=u(n,d);d===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y)}for(let d=c;d>=0;d--){let h=u(r,d);s.lineTo(h.x,h.y)}return s.close(),s}var Ye=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ve(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="leader"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let r=this.outerRadius,n=this.holeRadius,o=n>0?r-n:r*(1-Pt)*2,i=n>0?(n+r)/2:r*Pt,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),c=s>qr?o/s:1/0,l=a>qr?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(c,l))}insideGlyphs(t){let r=this.s.labelMode,n=this.s.slices[t.index]?.category.length??0,o=r==="both"||r==="percent"?qe(t.fraction).length:0,i=r==="category"?n:r==="both"?n*Qr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,en*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*Co/(this.insideGlyphs(r)*_t);t=Math.min(t,n)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:r,centerCaption:n}=this.s,o=H(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=H(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,r.length,n.length*s);return Math.min(o,i*2*Mo/(a*_t))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=H(this.s.label.textStyle)*1.25,r=H(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+r+2:this.s.labelMode==="category"?t:r}captionGlyphs(t){let r=this.s.labelMode,n=r==="percent"||r==="both"?4:0,o=r==="category"||r==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(n,o)}get labelGutters(){let t={left:Kr,right:Kr};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Yr+$r+jr+this.captionGlyphs(n.index)*r+vo,i=Ot(n.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:r}=this.labelGutters;return(t-r)/2}get outerRadius(){let{left:t,right:r}=this.labelGutters,n=Math.min((this.box.width-t-r)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,n/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let r=t<1?t*this.outerRadius:t;return Math.min(r,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+Yr}popOf(t){return ie(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let r=this.anchorRadius(t),n=this.holeRadius;return n>0?(n+r)/2:r*Pt}insideAnchor(t){let r=this.arcs.find(o=>o.index===t);if(r===void 0)return{x:this.centerX,y:0};let n=ne(this.bandMidRadius(t),r.mid);return{x:n.x+this.centerX,y:n.y}}get selectionStrength(){let t=0;for(let r=0;r<this.s.slices.length;r++)t=Math.max(t,this.popOf(r));return t}sliceOpacity(t){return Xe(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return qe(r?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let r=this.elbowRadius,n=this.labelRowHeight,o=this.box.height/2-n/2,i=-o,s=this.centerX,a=[],c=[];for(let l of t){let u=Ot(l.mid),d=ne(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return We(a,n+Wr,o,i),We(c,n+Wr,o,i),[...a,...c].map(l=>{let u=ne(this.anchorRadius(l.index)+Eo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*Ro),m=s+l.side*(r+$r);return{index:l.index,side:l.side,leader:[{x:u.x+s,y:u.y},{x:h,y:l.y},{x:m,y:l.y}],text:{x:m+l.side*jr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var Po={width:0,height:0},Zr=new WeakMap;function Oo(e){if(typeof e!="object"||e===null)return Xr.resolve(e);let t=Zr.get(e);return t===void 0&&Zr.set(e,t=Xr.resolve(e)),t}function Jr(e){return e.map(t=>Oo(t.fill))}function Fo(e){let t=[],r=()=>new Ye(e,t[0]?.parent?.layoutBounds??Po),n=o=>{let i=()=>ie(e.labelReveal,0,1)*r().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let d=[];return a&&d.push(new oe({...se.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new oe({...se.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*Qr})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>r().insideAnchor(o.index),children:d})}let c=Ot(o.mid),l=()=>r().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new oe({...se.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new oe({...se.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:c>0?"centerLeft":"centerRight",opacity:i,centerLeft:c>0?l:void 0,centerRight:c>0?void 0:l,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ve(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new oe({...se.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new oe({...se.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>ie(e.centerReveal,0,1),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var $e=Ao({key:"pieRing",state:{slices:f(()=>[]),ring:me.custom(M.ring),label:me.custom(M.label),centerStyle:me.custom(M.center),labelMode:me.custom("percent"),labelPlacement:me.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:M.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Fo(e),load:(e,t)=>D(e,{fills:Jr(t.slices),shadows:[ko.resolve(t.ring.shadow)],strokes:[Vr.resolve(t.ring.stroke),Vr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=y(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=y(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=y(e),n=ie(t.centerReveal,0,1);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new Ye(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=ie(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=r.holeRadius,c=Math.max(0,t.ring.gap)/2,l=r.centerX,u=n+r.maxPop+1+Math.abs(l),d=[-u,-u,u,u],h=u*2,m=Jr(t.slices);for(let p of o){let x=Math.min(p.a1,s);if(x<=p.a0)continue;let N=_o(p.a0,x,a,r.anchorRadius(p.index),c,l),A=new zr().path(N.toPathState({centerBounds:d,width:h,height:h}));A.shadow(t.ring.shadow),A.fill(m[p.index]??[]),A.stroke(t.ring.stroke),e.draw(A.opacity(r.sliceOpacity(p.index)))}let g=ie(t.labelReveal,0,1);if(g>.001)for(let p of r.placements())e.draw(new zr().line({points:p.leader,radius:Lo}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Do=.65,Bo=.35,Ft=le.number(0,{min:0,step:1});function tn(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ce(e,t){return on(e.pops[t]??0,0,1)}function Go(e,t){return ce(e,t)>.5}function Ho(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ce(e,n));let r=e.theme.spotlight.dimOpacity;return e.data.map((n,o)=>Xe(t,r,ce(e,o)))}function je(e,t,r){let n=t.data.map((i,s)=>ce(t,s)),o=t.data.map((i,s)=>on(r(s),0,1));return n.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:n.map((s,a)=>s+(o[a]-s)*i)}))}function rn(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=nn.is(r)?r.children.find($e.is):void 0;if(n)return{ring:n,legend:r.children.find(Ue.is)??null}}return null}var It=Io({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:le.custom(M,{resolve:Lt,lerp:Mt}),labelMode:le.custom("percent"),labelPlacement:le.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:le.boolean(!0,{animatable:!1}),showCenter:le.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>tn(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>tn(e),n=[new $e({width:"fill",height:"fill",slices:r,ring:()=>t().ring,label:()=>t().label,centerStyle:()=>t().center,labelMode:e.labelMode,labelPlacement:e.labelPlacement,pops:()=>e.pops,dimOpacity:()=>t().spotlight.dimOpacity,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})];e.showLegend!==!1&&n.push(new Ue({slices:r,legend:()=>t().legend,dims:()=>Ho(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new nn({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[o]},commands:{enter:{args:{},entrance:!0,easing:ae(),run:(e,t,r)=>{let n=rn(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Do,a=e.duration*Bo,c=l=>({at:0,duration:0,piece:l});return w(e,[c(o.to({growth:0,labelReveal:0})),...i?[c(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:ae(),run:(e,t,r)=>rn(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?1:ce(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?0:ce(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:ae(),run:(e,t)=>je(e,t,()=>0)}}});var No=[ut,At,It];export{At as BarChart,k as CHART_PALETTE,Ie as CategoryAxis,Ne as ChartBars,Me as ChartBorder,Ce as ChartCanvas,Q as ChartLegend,_e as ChartLine,st as ChartRegion,L as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,R as DEFAULT_LEGEND,U as DEFAULT_MARKERS,M as DEFAULT_PIE_CHART_THEME,be as DEFAULT_PLOT_AREA,Uo as DEFAULT_SERIES_COLORS,we as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,E as DEFAULT_X_AXIS,ye as DEFAULT_Y_AXIS,ee as EMPTY_REGION_BOX,_ as ENTER_SHARE,Pe as HorizontalAxis,xe as LEGEND_SLIDE,ut as LineChart,No as NODES,It as PieChart,Ue as PieLegend,$e as PieRing,C as SERIES_ARG,O as SPOTLIGHT_DIM,I as VerticalAxis,z as armed,P as arrival,b as arrivalOf,Y as arrivalsEntry,W as asParts,ft as barCategories,St as barChartDomain,Be as barSpans,Er as barValueExtent,w as beats,Re as cartesianFrame,Te as cartesianViews,Je as clipPolylineToBox,cr as formatInstant,F as formatMarker,qe as formatPercent,y as frameEase,f as fresh,te as hasRegion,Go as isSliceSelected,Le as laidOutSize,q as lerpAxisConfig,ue as lerpAxisDomain,de as lerpAxisEntry,xt as lerpBarChartTheme,et as lerpChartTheme,J as lerpLegendConfig,Mt as lerpPieChartTheme,Ae as lerpPlotArea,ve as lerpSeriesFills,Ht as lerpSeriesStrokes,Fe as lineChartDomains,D as loadPaints,zt as markerCaption,Ee as markerStep,T as markerValues,S as num,zo as numericFields,lr as parseInstant,Ve as pieArcs,We as relaxLabels,K as resolveAxisConfig,$ as resolveAxisDomain,mt as resolveBarChartTheme,Ge as resolveBarFill,gt as resolveBarScale,Qe as resolveChartTheme,Z as resolveLegendConfig,Lt as resolvePieChartTheme,Rt as resolvePieSlices,Se as resolvePlotArea,Ze as resolveRegionBox,Ut as resolveSeriesFill,ke as resolveSeriesFills,Nt as resolveSeriesStroke,Gt as resolveSeriesStrokes,at as resolveXScale,rt as resolveYScale,ne as ringPoint,tt as seriesPoints,he as settleAxisDomain,Ur as sliceTotal,Tt as sliceValue,pt as stackCapIndex,j as text,Yt as yExtent};
|
|
1
|
+
import{$ as U,A as De,B as Be,C as Ne,D,E as k,F as H,G as _s,H as er,I as Ps,J as Is,K as we,L as st,M as Nt,N as q,O as Se,P as at,Q as Z,R as zs,S as oe,T as tr,U as Re,V as Ae,W as Y,X as Gs,Y as W,Z as X,_ as lt,a as Qe,aa as V,b as et,ba as ct,c as N,ca as G,d as tt,da as nr,e as nt,ea as Fs,f as ye,fa as ut,g as fe,ga as ke,h as rt,ha as B,i as Ge,ia as Me,j as y,ja as ve,k as $,ka as J,l as _,la as K,m as C,ma as ie,n as Dt,na as rr,o as ot,oa as Ee,p as Zn,q as it,r as j,s as I,t as T,u as z,v as Jn,w as Fe,x as Qn,y as Bt,z as be}from"./chunks/chunk-R3Q5EE6E.js";import{Rect as oi,Text as ii,Types as Q,clamp as Qt,component2d as si,easeOut as le}from"@motionscript/sdk";import{formatNumber as ai}from"@motionscript/sdk/component";import{Graphics2D as He,Types as ae,clamp as Ye,component2d as ur,fillOps as We,strokeOps as lr}from"@motionscript/sdk";import{Types as he}from"@motionscript/sdk";var de={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function se(e){return e.right>e.left&&e.top>e.bottom}function Ht(e,t,n,r){if(!e||e.x===void 0&&e.y===void 0)return de;let o=(f,[h,d],p,g)=>{if(f===void 0||d<=h)return[p,g,!1];let m=Math.min(f[0],f[1]),x=Math.max(f[0],f[1]),S=M=>p+(M-h)/(d-h)*(g-p);return[Math.max(p,Math.min(g,S(m))),Math.max(p,Math.min(g,S(x))),!0]},[i,s,a]=o(e.x,n,t.left,t.right),[l,c,u]=o(e.y,r,t.bottom,t.top);return{left:i,right:s,bottom:l,top:c,xBounded:a,yBounded:u}}function Yt(e,t){if(e.length<2||!se(t))return[];let n=[],r=[];for(let o=1;o<e.length;o++){let i=Wo(e[o-1],e[o],t);if(!i){r.length>=2&&n.push(r),r=[];continue}let[s,a]=i;r.length>0&&Yo(r[r.length-1],s)?r.push(a):(r.length>=2&&n.push(r),r=[s,a])}return r.length>=2&&n.push(r),n}function Yo(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function Wo(e,t,n){let r=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-r,e.x-n.left],[r,n.right-e.x],[-o,e.y-n.bottom],[o,n.top-e.y]];for(let[l,c]of a){if(l===0){if(c<0)return null;continue}let u=c/l;if(l<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*r,y:e.y+i*o},{x:e.x+s*r,y:e.y+s*o}]}function Xo(e,t,n){return e.map((r,o)=>[t.at(o),k(r,n.field)]).sort((r,o)=>r[0]-o[0])}function ar(e,t){let n=1/0,r=-1/0;for(let o of e)for(let i of t){let s=k(o,i.field);s<n&&(n=s),s>r&&(r=s)}return n<=r?[n,r]:[0,1]}function Uo(e,t,n,r){return n??Se(ar(e,t),r)}function Wt(e,t,n,r,o=[]){let i=e.map((c,u)=>u).sort((c,u)=>t.at(c)-t.at(u));if(r!=="stacked"&&r!=="percent")return n.map(c=>({points:i.map(u=>[t.at(u),k(e[u],c.field)]),base:null}));let s=c=>Math.max(0,o[c]??1),a=i.map(c=>n.reduce((u,f,h)=>u+Math.abs(k(e[c],f.field)*s(h)),0)),l=i.map(()=>0);return n.map((c,u)=>{let f=i.map((d,p)=>[t.at(d),l[p]]);return{points:i.map((d,p)=>{let g=k(e[d],c.field)*s(u);return l[p]+=r==="percent"?a[p]>0?g/a[p]*100:0:g,[t.at(d),l[p]]}),base:f}})}function ft(e){let t=1/0,n=-1/0;for(let{points:r,base:o}of e)for(let[,i]of[...r,...o??[]])i<t&&(t=i),i>n&&(n=i);return t<=n?[t,n]:[0,1]}var or=16;function Xt(e,t){if(t==="step"){let o=e.length>0?[e[0]]:[];for(let i=1;i<e.length;i++){let s=(e[i-1].x+e[i].x)/2;o.push({x:s,y:e[i-1].y},{x:s,y:e[i].y},e[i])}return o}if(t!=="smooth"||e.length<3)return[...e];let n=Vo(e),r=[e[0]];for(let o=1;o<e.length;o++){let i=e[o-1],s=e[o],a=(s.x-i.x)/3,l={x:i.x+a,y:i.y+a*n[o-1]},c={x:s.x-a,y:s.y-a*n[o]};for(let u=1;u<=or;u++){let f=u/or,h=1-f;r.push({x:h*h*h*i.x+3*h*h*f*l.x+3*h*f*f*c.x+f*f*f*s.x,y:h*h*h*i.y+3*h*h*f*l.y+3*h*f*f*c.y+f*f*f*s.y})}}return r}function Vo(e){let t=e.length,n=o=>{let i=e[o+1].x-e[o].x;return i===0?0:(e[o+1].y-e[o].y)/i},r=new Array(t).fill(0);for(let o=1;o<t-1;o++){let i=e[o].x-e[o-1].x,s=e[o+1].x-e[o].x,a=n(o-1),l=n(o),c=i+s===0?0:(a*s+l*i)/(i+s);r[o]=(Math.sign(a)+Math.sign(l))*Math.min(Math.abs(a),Math.abs(l),.5*Math.abs(c))||0}return r[0]=ir(n(0),r[1]),r[t-1]=ir(n(t-2),r[t-2]),r}function ir(e,t){let n=(3*e-t)/2;return e===0||Math.sign(n)!==Math.sign(e)?0:Math.abs(n)>3*Math.abs(e)?3*e:n}function Ut(e,t){if(e.length===0||t<e[0].x)return[];let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.x<=t){n.push(o);continue}let i=e[r-1];i&&o.x>i.x&&n.push({x:t,y:i.y+(o.y-i.y)*(t-i.x)/(o.x-i.x)});break}return n}function Vt(e,t){if(e.length<3||!se(t))return[];let n=[o=>o.x-t.left,o=>t.right-o.x,o=>o.y-t.bottom,o=>t.top-o.y],r=[...e];for(let o of n){let i=r;r=[];for(let s=0;s<i.length;s++){let a=i[s],l=i[(s+i.length-1)%i.length],c=o(a),u=o(l);c>=0?(u<0&&r.push(sr(l,a,u,c)),r.push(a)):u>=0&&r.push(sr(l,a,u,c))}if(r.length===0)return[]}return r}function sr(e,t,n,r){let o=n/(n-r);return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}var Kt={strokeWidth:he.number(4,{min:0,max:24,step:.5,unit:"px"}),curve:he.oneOf(["smooth","linear","step"]),dots:he.boolean(!1),dotSize:he.number(12,{min:0,max:48,step:1,unit:"px"}),area:he.oneOf(["none","solid","gradient"]),areaOpacity:he.number(.4,{min:0,max:1,step:.05})},$t={values:he.oneOf(["none","above","below"],{animatable:!1})};function Xe(e,t){if(e.length===0)return 0;let n=e[0].x,r=e[e.length-1].x;return t>=1?1/0:n+(r-n)*t}function jt(e,t,n){let r=Xt(e,t);return n>=1?r:Ut(r,Xe(e,n))}var fr=()=>ae.custom("smooth");function Ko(e){return[...e.map((t,n)=>({type:n===0?"M":"L",x:t.x,y:t.y})),{type:"Z"}]}function $o(e,t,n,r){if(t.length<3||r<=0)return;let{width:o,height:i}=e.size,s=[-o/2,-i/2,o/2,i/2];e.draw(new He().path({data:Ko(t),centerBounds:s}).fill(n).opacity(r))}var ht=ur({key:"chartLine",state:{points:y(()=>[]),curve:fr(),stroke:ae.custom([],{resolve:lr.resolve,lerp:lr.lerp}),dotSize:0,dotFill:ae.custom([],{resolve:We.resolve,lerp:We.lerp}),progress:1,enabled:!0,spotlight:y(()=>de),dimOpacity:D},load:(e,t)=>C(e,{fills:[t.dotFill],strokes:[t.stroke]}),commands:{enter:{args:{from:ae.number(0,{min:0,max:1}),to:ae.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=T(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}},hold:{args:{shown:ae.boolean(!0)},run:e=>{let{shown:t}=e.args;return e.animate(n=>({progress:1,enabled:t||n<1}),{eased:!1})}}},render:(e,t)=>{if(!t.enabled)return;let n=t.points,r=Ye(t.progress,0,1);if(n.length===0||r<=0)return;let o=t.spotlight,i=se(o),s=Ye(t.dimOpacity,0,1),a=t.stroke,l=a[0]?.weight??0,c=jt(n,t.curve,r);if(c.length>=2&&l>0){let m=t.curve==="linear"?l*2:0;if(e.draw(new He().line({points:c,radius:m}).stroke(a).opacity(i?s:1)),i)for(let x of Yt(c,o))e.draw(new He().line({points:x,radius:m}).stroke(a))}let u=t.dotSize;if(u<=0)return;let f=Xe(n,r),h=new He,d=new He,p=!1,g=!1;for(let m of n){let x=f===1/0?1:Ye((f-m.x)/(u*2),0,1);if(x<=0)continue;let S=!i||m.x>=o.left&&m.x<=o.right&&m.y>=o.bottom&&m.y<=o.top;(S?h:d).ellipse({x:m.x,y:m.y,width:u*x,height:u*x}),S?p=!0:g=!0}g&&e.draw(d.fill(t.dotFill).opacity(s)),p&&e.draw(h.fill(t.dotFill))}}),qt=ur({key:"chartArea",state:{points:y(()=>[]),base:y(()=>[]),baseline:0,curve:fr(),area:ae.custom("solid"),fill:ae.custom([],{resolve:We.resolve,lerp:We.lerp}),areaOpacity:.4,progress:1,enabled:!0,spotlight:y(()=>de),dimOpacity:D},load:(e,t)=>C(e,{fills:[t.fill]}),render:(e,t)=>{let n=t.points,r=Ye(t.progress,0,1);if(!t.enabled||t.area==="none"||n.length<2||r<=0||t.fill.length===0)return;let o=c=>{let u=jt(n,t.curve,c);if(u.length<2)return[];let f=t.base.length===n.length?jt(t.base,t.curve,c):[{x:u[0].x,y:t.baseline},{x:u[u.length-1].x,y:t.baseline}];return[...u,...[...f].reverse()]},i=cr(o(1)),s=(c,u)=>$o(e,c,hr(t.fill,t.area,t.areaOpacity,i,cr(c)),u),a=o(r),l=t.spotlight;if(!se(l)){s(a,1);return}s(a,Ye(t.dimOpacity,0,1)),s(Vt(a,l),1)}});function cr(e){let t=-1/0,n=1/0;for(let r of e)r.y>t&&(t=r.y),r.y<n&&(n=r.y);return{top:t,bottom:n}}function hr(e,t,n,r,o){let i=e[e.length-1];if(t!=="gradient"||i?.type!=="solid"||!(o.top>o.bottom))return Ge(e,n);let[s,a,l,c]=i.color,u=(o.top+o.bottom)/2,f=(o.top-o.bottom)/2;return We.resolve({type:"linear-gradient",colors:[[s,a,l,c*n],[s,a,l,c*n*.04]],start:{x:0,y:(r.top-u)/f},end:{x:0,y:(r.bottom-u)/f}})}import{Graphics2D as jo,Types as dr,component2d as qo,fillOps as pr,strokeOps as gr}from"@motionscript/sdk";var Zt=qo({key:"chartRegion",state:{box:y(()=>de),stroke:dr.custom({weight:2,fill:"white/70",dash:[14,12],cap:"butt",align:"center"},{resolve:gr.resolve,lerp:gr.lerp}),fill:dr.custom("white/6",{resolve:pr.resolve,lerp:pr.lerp}),reveal:0},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let n=t.box;if(!se(n))return;let r=Math.max(0,Math.min(1,t.reveal));if(r<=0)return;let o=n.right-n.left,i=n.top-n.bottom,s=(n.left+n.right)/2,a=(n.bottom+n.top)/2;if(t.fill.length>0&&e.draw(new jo().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(r)),t.stroke.length!==0){if(n.xBounded){let l=i/2*r;for(let c of[n.left,n.right])Dt(e,{x:c,y:a-l},{x:c,y:a+l},t.stroke,r)}if(n.yBounded){let l=o/2*r;for(let c of[n.bottom,n.top])Dt(e,{x:s-l,y:c},{x:s+l,y:c},t.stroke,r)}}}});import{formatNumber as Zo}from"@motionscript/sdk/component";var dt=864e5,Sr=["january","february","march","april","may","june","july","august","september","october","november","december"],mr=2024;function xr(e){return e.length<3?-1:Sr.findIndex(t=>t.startsWith(e))}function Jo(e,t){let n=Date.UTC(e,0,4),r=(new Date(n).getUTCDay()+6)%7;return n-r*dt+(t-1)*7*dt}function Rr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let n=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(n){let s=Number(n[2]),a=n[3]===void 0?1:Number(n[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(n[1]),s-1,a)}let r=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(r){let s=Number(r[2]);return s<1||s>53?null:Jo(r[1]===void 0?mr:Number(r[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=xr(o[2]);if(s>=0){let a=o[1]??o[3],l=a===void 0?mr:Number(a);return Date.UTC(l,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=xr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function Ar(e,t){let n=new Date(e),r=n.getUTCFullYear(),o=Sr[n.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*dt?String(r):t>60*dt?`${i} ${r}`:`${i} ${n.getUTCDate()}`}function Qo(e,t){let n=!1;for(let r of e){let o=r[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;n=!0}}return n}function ei(e,t){let n=[],r=!1;for(let s of e){let a=s[t];if(a==null||a===""){n.push(null);continue}let l=Rr(a);if(l===null)return null;n.push(l),r=!0}if(!r)return null;let i=n.find(s=>s!==null);return n.map(s=>s===null?i:i=s)}function yr(e){let t=1/0,n=-1/0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return t<=n?[t,n]:[0,1]}var kr=12;function br(e,[t,n],r){let o=e.filter(l=>l>=t&&l<=n),i=[...new Set(o)].sort((l,c)=>l-c);if(i.length===0)return q([t,n],r);if(i.length<=kr&&ti(i))return i;let s=l=>i.reduce((c,u)=>Math.abs(u-l)<Math.abs(c-l)?u:c),a=[];for(let l of q([t,n],r)){let c=s(l);a[a.length-1]!==c&&a.push(c)}return a}function ti(e){if(e.length<3)return!0;let t=(e[e.length-1]-e[0])/(e.length-1);for(let n=1;n<e.length;n++)if(e[n]-e[n-1]<t*.75)return!1;return!0}function ni(e,t,n,r){let o=e.indexOf(n);return o>=0?t[o]:r(n)}var wr=new WeakMap;function Jt(e,t,n){let r=wr.get(e);r||wr.set(e,r=new Map);let o=JSON.stringify([t,n??null]),i=r.get(o);return i||r.set(o,i=ri(e,t,n)),i}function ri(e,t,n){if(t!==""&&Qo(e,t)){let s=e.map(a=>k(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:yr(s),label:a=>n===void 0?we(a):Zo(a,n),ticks:q}}let r=e.map(s=>H(s,t)),o=t===""?null:ei(e,t);if(o){let s=yr(o),a=s[1]-s[0];return{kind:"time",at:l=>o[l]??0,extent:s,label:l=>ni(o,r,l,c=>Ar(c,a)),ticks:(l,c)=>br(o,l,c)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>r[Math.round(s)]??"",ticks:(s,a)=>br(i,s,a)}}var li=Q.style(Y,{colors:W,text:X,grid:lt,marks:Kt,labels:$t,legend:U},{presets:V}),Mr=Q.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),zr=[0,100];function pt(e,t=e.xAxis.format){return Jt(e.data,e.xField,t)}function tn(e,t=!0){return Wt(e.data,pt(e),e.series,e.stack,t?e.weights:void 0)}function ci(e,t){let n=pt(e,t.format),r=t.range??n.extent;return{...t,range:r,ticks:t.ticks??n.ticks(r,j-1)}}function ui(e,t){let[n,r]=ft(tn(e,!1));if(e.stack==="percent"&&n>=0)return zr;let o=e.stack!=="none"||(e.style?.area??"none")!=="none";return Se(o?[Math.min(0,n),Math.max(0,r)]:[n,r],t)}function fi(e,t){let n=(t.ticks?.length??j)-1,r=t.range??ui(e,n),o=t.range!==void 0||e.stack==="percent"&&r===zr;return{...t,range:r,ticks:t.ticks??(o?q(r,j-1):at(r,j-1))}}var vr=new WeakMap;function Ue(e){let t=[e.xField,e.xAxis,e.yAxis,e.series,e.stack,e.style?.area],n=vr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domains;let r={x:Ne(e.xAxis,o=>ci(e,o)),y:Ne(e.yAxis,o=>fi(e,o))};return vr.set(e.data,{key:t,domains:r}),r}function Gr(e,t){let[n,r]=e.x.range,[o,i]=e.y.range;return{x:s=>r<=n?0:((s-n)/(r-n)-.5)*t.width,y:s=>i===o?0:((s-o)/(i-o)-.5)*t.height}}var hi={points:[],base:[],values:[]};function di(e,t,n,r){let o=tn(e)[n];if(!o)return hi;let i=Gr(t,r),s=([a,l])=>({x:i.x(a),y:i.y(l)});return{points:o.points.map(s),base:o.base?o.base.map(s):[],values:o.points.map(([,a],l)=>a-(o.base?.[l]?.[1]??0))}}function Er(e){let[t,n]=e.y.range;return Qt(0,Math.min(t,n),Math.max(t,n))}function pi(e,t){let[n,r]=ft(tn(e,!1)),[o,i]=pt(e).extent,s=(a,[l,c])=>a>=Math.min(l,c)-1e-9&&a<=Math.max(l,c)+1e-9;return!(s(n,t.y.range)&&s(r,t.y.range)&&s(o,t.x.range)&&s(i,t.x.range))}function gi(e,t,n){let{width:r,height:o}=n;return Ht(e.region,{left:-r/2,right:r/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function Lr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function Tr(e){return e!=null&&typeof e=="object"?e:{}}function mi([e,t]){return e<=t?[e,t]:[t,e]}function Cr(e,t){let n=mi(e);return{range:n,ticks:q(n,Math.max(2,t.length)-1)}}function Or(e,t,n){return{...t.x&&{xAxis:De(e.x,t.x,n)},...t.y&&{yAxis:De(e.y,t.y,n)}}}function _r(e,t,n){let r=e.yAxis.format;if(r!==void 0)return ai(t,r);let o=we(t,st(n));return e.stack==="percent"?`${o}%`:o}function xi(e,t){return Math.max(0,e.weights[t]??1)}function en(e){let t=nt(e);return{vAxis:t.find(Re.is)??null,hAxis:t.find(Ae.is)??null,lines:t.filter(ht.is),legend:t.find(Z.is)??null}}function Pr(e,t){let n=t.regionReveal,r=t.region;return n===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:r,regionReveal:n*(1-o)})}function Ir(e,t,n,r,o){let i=en(n),s=i.lines[r];if(!s)return e.wait(e.duration);let a=i.legend?[i.legend.run(o?"showSeries":"hideSeries",{index:r})]:[];if(t.stack==="none")return e.together([s.run("enter",o?{from:0,to:1}:{from:1,to:0}),...a]);let l=t.series.map((f,h)=>xi(t,h)),c=l[r]??1,u=o?1:0;return e.together([e.animate(f=>{let h=[...l];return h[r]=c+(u-c)*e.ease(f),{weights:h}},{eased:!1}),s.run("hold",{shown:o}),...a])}var nn=si({key:"lineChart",state:{data:y(()=>[],{kind:"dataset"}),xField:"",series:y(()=>[],{kind:"series"}),stack:Q.oneOf(["none","stacked","percent"]),xAxis:Q.custom({},{resolve:be,lerp:Be}),yAxis:Q.custom({},{resolve:be,lerp:Be}),style:li,region:Q.custom(null),regionReveal:0,home:Q.custom(null,{private:!0}),weights:Q.custom([],{private:!0}),clipped:Q.boolean(!1,{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Ue(e),r,o=()=>ye(r),i=w=>di(e,n(),w,o()),s=e.series.map(w=>w.enabled??!0),a=e.style,l=()=>ke(t(),"y"),c=()=>ke(t(),"x"),u=()=>{let w=n().y.ticks;return w.map(b=>_r(e,b,w))},f=a.showYAxis?new Re({range:()=>n().y.range,markers:()=>n().y.ticks,captions:u,axis:l,label:e.yAxis.label??"",width:"hug",height:"fill"}):void 0,h=a.showXAxis?new Ae({range:()=>n().x.range,markers:()=>n().x.ticks,captions:()=>{let w=pt(e);return n().x.ticks.map(b=>w.label(b))},axis:c,label:e.xAxis.label??"",overhang:()=>({left:N(t()),right:N(t())}),width:"fill",height:"hug"}):void 0,d=f&&h?rt({captions:u,count:Ue(e).y.ticks.length,text:()=>l().labelStyle,title:e.yAxis.label??"",titleText:()=>l().titleStyle,tickPad:()=>oe(l(),"right").tick,titlePad:()=>oe(l(),"right").title}):void 0,p=()=>gi(e,n(),o()),g=()=>1-(1-D)*e.regionReveal,m=e.series.map((w,b)=>new ht({points:()=>i(b).points,curve:()=>t().curve,stroke:()=>({weight:t().strokeWidth,fill:G(t(),w,b),align:"center",cap:"round",join:"round"}),dotSize:()=>t().dots?t().dotSize:0,dotFill:()=>G(t(),w,b),enabled:s[b],spotlight:p,dimOpacity:g})),x=e.series.map((w,b)=>new qt({points:()=>i(b).points,base:()=>i(b).base,baseline:()=>Gr(n(),o()).y(Er(n())),curve:()=>t().curve,area:()=>t().area,fill:()=>G(t(),w,b),areaOpacity:()=>t().areaOpacity,progress:()=>m[b].progress,enabled:()=>m[b].enabled,opacity:()=>m[b].opacity,spotlight:p,dimOpacity:g})),S=[];if(a.values!=="none"){let w=a.values==="below";e.series.forEach((b,v)=>{e.data.forEach((F,E)=>{let L=m[v],ue=new ii({...fe(()=>({...ut(t()),fontSize:Math.round(t().fontSize*.8)})),text:()=>{let O=i(v).values[E];return O===void 0?"":_r(e,O,n().y.ticks)},x:()=>{let O=(o().width-ue.layoutBounds.width)/2;return Qt(i(v).points[E]?.x??0,-Math.max(0,O),Math.max(0,O))},y:()=>{let O=i(v).points[E],re=ue.layoutBounds.height/2+(t().dots?t().dotSize/2:t().strokeWidth/2)+Math.round(t().fontSize*.25);return(O?.y??0)+(w?-re:re)},opacity:()=>{let O=i(v).points[E];if(!L.enabled||!O)return 0;let re=Xe(i(v).points,L.progress);return L.opacity*(re===1/0?1:Qt((re-O.x)/24,0,1))}});S.push(ue)})})}let M=a.legend,R=M!=="none"?new Z({series:e.series,swatches:()=>e.series.map((w,b)=>G(t(),w,b)),legend:()=>B(t()),flow:M==="right"?"vertical":"horizontal"}):void 0;return r=new oi({clip:()=>e.clipped||pi(e,n()),children:[new ot({fill:()=>t().background,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:()=>n().x.ticks,yMarkers:()=>n().y.ticks,xExtent:()=>n().x.range,yExtent:()=>n().y.range,axisStroke:()=>t().axisStroke,xAxisAt:()=>Er(n()),yAxisAt:()=>n().x.range[0]}),new Zt({box:p,stroke:()=>({weight:2,fill:Ge(t().foreground,.7),dash:[14,12],cap:"butt",align:"center"}),fill:()=>Ge(t().foreground,.06),reveal:()=>e.regionReveal}),...x,...m,...S]}),[tt({left:f,ghost:d,plot:r,bottom:h,legend:R,legendAt:M,gap:()=>Qe(t()),padding:()=>({top:et(t()),right:h?N(t()):0,left:h&&!f?N(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:le(),run:(e,t,n)=>{let r=en(n),o=e.duration,i=Lr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*I.axes,l=s*I.marks,{legend:c}=r,u=h=>({at:0,duration:0,piece:h}),f=it(t.style.legend);return z(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...r.lines.map(h=>u(h.to({progress:0}))),...c?[u(c.to({opacity:0,...f}))]:[],...r.vAxis?[{at:0,duration:a,piece:r.vAxis.run("enter",{slide:24})}]:[],...r.hAxis?[{at:0,duration:a,piece:r.hAxis.run("enter",{slide:24})}]:[],...r.lines.map(h=>({at:a,duration:l,piece:h.run("enter")})),...c?[{at:a+l,duration:s*I.legend,piece:c.to({opacity:1,x:0,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(h=>({regionReveal:h}))}]:[],{at:0,duration:o,piece:e.wait(o)}])}},spotlightRegion:{args:{region:Mr},easing:le(),run:(e,t)=>{let n=Tr(e.args.region),r=t.regionReveal,o=t.region;return n.x===void 0&&n.y===void 0?Pr(e,t):r<=0||!Lr(t)?e.animate(i=>({region:n,regionReveal:r+(1-r)*i})):e.animate(i=>i<.5?{region:o,regionReveal:r*(1-e.ease(i*2))}:{region:n,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:le(),run:(e,t)=>Pr(e,t)},zoomTo:{args:{region:Mr},easing:le(),run:(e,t)=>{let n=Tr(e.args.region);if(!n.x&&!n.y)return e.wait(e.duration);let r=Ue(t),o=t.home??r,i={...n.x&&{x:{...r.x,...Cr(n.x,r.x.ticks)}},...n.y&&{y:{...r.y,...Cr(n.y,r.y.ticks)}}};return e.animate(s=>({home:o,clipped:!0,...Or(r,i,s)}))}},resetZoom:{args:{},easing:le(),run:(e,t)=>{let n=t.home;if(!n)return e.wait(e.duration);let r=Ue(t);return e.animate(o=>({home:null,clipped:o<1,...Or(r,n,o)}))}},showSeries:{args:{seriesIndex:_},easing:le(),run:(e,t,n)=>Ir(e,t,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:_},easing:le(),run:(e,t,n)=>Ir(e,t,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:_},easing:le(),run:(e,t,n)=>{let r=en(n),o=e.args.seriesIndex;return e.together([...r.lines.map((i,s)=>i.to({opacity:s===o?1:D})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}}}});import{Rect as Li,Types as ee,clamp as xn,component2d as Ti,easeOut as Le}from"@motionscript/sdk";import{formatNumber as Ci}from"@motionscript/sdk/component";import{Rect as rn,Text as Fr,Types as gt,clamp as yi,component2d as bi}from"@motionscript/sdk";import{enterBudget as wi}from"@motionscript/sdk/component";var Si=24;function Ve(e,t,n){return t<=0?0:-n/2+n/t*(e+.5)}var mt=bi({key:"categoryAxis",state:{categories:y(()=>[]),axis:gt.custom(er),label:"",orientation:gt.oneOf(["horizontal","vertical"]),dims:y(()=>[]),arrivals:Jn()},defaults:{width:"fill",height:"fill"},children:e=>{let t=e.categories.length,n=s=>yi(e.dims[s]??1,0,1);if(e.orientation==="vertical")return[tr({count:t,axis:()=>e.axis,text:s=>e.categories[s]??"",place:(s,a)=>-Ve(s,e.categories.length,a),arrivals:()=>e.arrivals,opacity:n,label:e.label})];let r=()=>oe(e.axis,"top"),o=e.categories.map((s,a)=>{let l=new rn({width:"hug",height:"hug",flow:"freeform",opacity:()=>n(a),x:()=>Ve(a,e.categories.length,l.parent?.layoutBounds.width??0),children:[new Fr({...fe(()=>e.axis.labelStyle),text:s,opacity:()=>Fe(e.arrivals,a).opacity,y:()=>Fe(e.arrivals,a).shift})]});return l}),i=[new rn({width:"fill",height:"hug",padding:()=>({top:r().tick}),children:o})];return e.label!==""&&i.push(new Fr({...fe(()=>e.axis.titleStyle),text:e.label,opacity:()=>Fe(e.arrivals,"label").opacity,y:()=>Fe(e.arrivals,"label").shift})),[new rn({flow:"vertical",gap:()=>r().title,height:"hug",width:"fill",children:i})]},commands:{enter:{args:{stagger:gt.custom(void 0),slide:gt.number(Si)},run:(e,t)=>{let{stagger:n,slide:r}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:r},a=[...t.categories.keys(),...i?["label"]:[]],l=e.animate(()=>({arrivals:Qn(a,s)}));if(o===0)return l;let{step:c,per:u,caption:f}=wi(e.duration,o,i,n),h=T(e),d=t.categories.map((g,m)=>({at:m*c,duration:u,piece:Bt(e,m,s,h)})),p=i?[{at:(o-1)*c+u,duration:f,piece:Bt(e,"label",s,h)}]:[];return e.together([l,z(e,[...d,...p])])}}}});import{Graphics2D as Ai,Text as ki,Types as un,clamp as fn,component2d as Mi,fillOps as Br}from"@motionscript/sdk";import{Types as xt,fillOps as Ri}from"@motionscript/sdk";function yt(e,t,n,r=[]){let o=h=>Math.max(0,r[h]??1);if(n!=="stacked"&&n!=="percent")return t.map(h=>{let d=k(e,h.field);return{from:0,to:d,value:d,outer:!0}});let i=t.map((h,d)=>k(e,h.field)*o(d)),s=i.reduce((h,d)=>h+Math.abs(d),0),a=n==="percent"?i.map(h=>s>0?h/s*100:0):i,l=-1,c=-1;a.forEach((h,d)=>{h>0?l=d:h<0&&(c=d)});let u=0,f=0;return a.map((h,d)=>{if(h<0){let g=f;return f+=h,{from:g,to:f,value:h,outer:d===c}}let p=u;return u+=h,{from:p,to:u,value:h,outer:d===l}})}function on(e,t){return e.map(n=>H(n,t))}function Dr(e,t,n,r){let o=0,i=0;for(let s of e)for(let a of yt(s,t,n,r))o=Math.min(o,a.from,a.to),i=Math.max(i,a.from,a.to);return o<i?[o,i]:[0,1]}function sn(e,t,n,r,o,i){if(r)return r;let[s,a]=Dr(e,t,n,i);return n==="percent"?[s<0?-100:0,a>0?100:0]:Se([s,a],o)}function an(e){let t=Ri.resolve(e),n=t[t.length-1];if(n?.type!=="solid")return"white";let[r,o,i]=n.color,s=l=>l<=.03928?l/12.92:((l+.055)/1.055)**2.4;return .2126*s(r)+.7152*s(o)+.0722*s(i)>.4?"#0a0a0a":"white"}var ln={barRadius:xt.number(10,{min:0,max:64,step:1,unit:"px"}),barWidth:xt.number(.7,{min:.05,max:1,step:.05}),barGap:xt.number(6,{min:0,max:40,step:1,unit:"px"})},cn={values:xt.oneOf(["none","end","inside"],{animatable:!1})};var vi=.6;function Nr(e,t){return e.enabled?fn(e.dims[t]??1,0,1):0}function hn(e,t){let n=e.bars[t];if(!n)return null;let r=fn(e.growth,0,1);return{base:e.baseline+(n.from-e.baseline)*r,end:e.baseline+(n.to-e.baseline)*r}}function Yr(e){return typeof e.fontSize=="number"?e.fontSize:24}function Hr(e,t,n){let r=hn(e,t);if(!r)return 0;if(e.values==="inside")return(r.base+r.end)/2;let o=r.end>=r.base?1:-1;return r.end+o*(Yr(e.valueStyle)*.4+n/2)}function Ei(e,t,n,r){let o=e.bars[t],i=hn(e,t);if(!o||!i)return!1;let s=Yr(e.valueStyle)*vi;return Math.abs(i.end-i.base)>=n+s&&o.thickness>=r}var bt=Mi({key:"chartBars",state:{bars:y(()=>[]),baseline:0,horizontal:!1,fill:un.custom([],{resolve:Br.resolve,lerp:Br.lerp}),cornerRadius:8,growth:1,dims:y(()=>[]),values:un.custom("none"),valueStyle:un.custom({fontSize:24,fill:"white"}),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.values==="none"?[]:e.bars.map((t,n)=>{let r=new ki({...fe(()=>({...e.valueStyle,...e.values==="inside"&&{fill:an(e.fill)}})),text:()=>e.bars[n]?.caption??"",x:()=>e.horizontal?Hr(e,n,r.layoutBounds.width):e.bars[n]?.center??0,y:()=>e.horizontal?e.bars[n]?.center??0:Hr(e,n,r.layoutBounds.height),opacity:()=>{let o=r.layoutBounds,i=e.horizontal?o.width:o.height,s=e.horizontal?o.height:o.width;return e.values==="inside"&&!Ei(e,n,i,s)?0:Nr(e,n)*fn((e.growth-.6)/.4,0,1)}});return r}),load:(e,t)=>C(e,{fills:[t.fill]}),commands:{enter:e=>{let t=T(e);return e.animate(n=>({growth:t(n)}))}},render:(e,t)=>{if(t.enabled)for(let n=0;n<t.bars.length;n++){let r=t.bars[n],o=hn(t,n);if(!o||r.thickness<=0)continue;let i=r.round?0:1,s=Math.abs(o.end-o.base)+i;if(s<=i)continue;let a=r.round?Math.max(0,Math.min(t.cornerRadius,s,r.thickness/2)):0,l=o.end>=o.base,c=(o.base+o.end)/2+(l?i:-i)/2,u=t.horizontal?l?{topRight:a,bottomRight:a,topLeft:0,bottomLeft:0}:{topLeft:a,bottomLeft:a,topRight:0,bottomRight:0}:l?{topLeft:a,topRight:a,bottomLeft:0,bottomRight:0}:{bottomLeft:a,bottomRight:a,topLeft:0,topRight:0},f=new Ai().rect(t.horizontal?{x:c,y:r.center,width:s,height:r.thickness,cornerRadius:a>0?u:0}:{x:r.center,y:c,width:r.thickness,height:s,cornerRadius:a>0?u:0});f.fill(t.fill),e.draw(f.opacity(Nr(t,n)))}e.children()}});var Oi=ee.style(Y,{colors:W,text:X,grid:lt,marks:ln,labels:cn,legend:U},{presets:V});function _i(e,t){let n=(t.ticks?.length??j)-1,r=sn(e.data,e.series,e.stack,t.range,n),o=t.range!==void 0||e.stack==="percent";return{...t,range:r,ticks:t.ticks??(o?q(r,j-1):at(r,j-1))}}var Wr=new WeakMap;function St(e){let t=[e.series,e.stack,e.valueAxis],n=Wr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domain;let r=Ne(e.valueAxis,o=>_i(e,o));return Wr.set(e.data,{key:t,domain:r}),r}function pn(e,t,n){let r=e.valueAxis.format;if(r!==void 0)return Ci(n,r);let o=we(n,st(t.ticks));return e.stack==="percent"?`${o}%`:o}function gn(e,t,n){let[r,o]=e.range;return o===r?-t/2:((n-r)/(o-r)-.5)*t}function dn(e){let[t,n]=e.range;return xn(0,Math.min(t,n),Math.max(t,n))}function wt(e,t){return Math.max(0,e.weights[t]??1)}function Vr(e,t){return e.orientation==="horizontal"?{along:t.width,across:t.height}:{along:t.height,across:t.width}}function Pi(e,t,n){let r=Ve(t,e.data.length,n);return e.orientation==="horizontal"?-r:r}function Ii(e,t,n){let r=e.series[t];if(!r)return[];let o=St(e),{along:i,across:s}=Vr(e,n),a=e.data.length,c=(a>0?s/a:0)*xn(e.style.barWidth,0,1),u=e.stack!=="none",f=0;for(let x=0;x<e.series.length;x++)f+=wt(e,x);let h=c/(f>0?f:1),d=wt(e,t),p=0;for(let x=0;x<t;x++)p+=wt(e,x);let g=e.series.length>1?e.style.barGap:0,m=e.style.values;return e.data.map((x,S)=>{let R=yt(x,e.series,e.stack,e.weights)[t]??{from:0,to:0,value:0,outer:!1},w=Pi(e,S,s),b=-c/2+h*p+h*d/2,v="";return m!=="none"&&R.value!==0&&(!u||m==="inside"||e.stack==="percent"?v=pn(e,o,u?R.value:k(x,r.field)):R.outer&&(v=pn(e,o,R.to))),{center:u?w:w+(e.orientation==="horizontal"?-b:b),thickness:u?c:Math.max(0,h*d-g),from:gn(o,i,R.from),to:gn(o,i,R.to),round:R.outer,caption:v}})}function Xr(e){let t=xn(e.spotlightReveal,0,1),n=e.spotlight;return e.data.map((r,o)=>t<=0||n===o?1:1-(1-D)*t)}function mn(e){let t=nt(e);return{valueAxis:t.find(n=>Re.is(n)||Ae.is(n))??null,categoryAxis:t.find(mt.is)??null,bars:t.filter(bt.is),legend:t.find(Z.is)??null}}function Ur(e,t,n,r,o){let i=mn(n);if(!i.bars[r])return e.wait(e.duration);let s=t.series.map((c,u)=>wt(t,u)),a=s[r]??1,l=t.series.map((c,u)=>t.showing[u]??c.enabled??!0);return e.together([e.animate(c=>{let u=[...s];u[r]=a+(o-a)*e.ease(c);let f=[...l];return f[r]=o>0||c<1,{weights:u,showing:f}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:r})]:[]])}var yn=Ti({key:"barChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),orientation:ee.oneOf(["vertical","horizontal"],{animatable:!1}),stack:ee.oneOf(["none","stacked","percent"]),valueAxis:ee.custom({},{resolve:be,lerp:Be}),categoryAxis:ee.custom({},{resolve:be,lerp:De}),style:Oi,growth:1,spotlight:ee.custom(null),spotlightReveal:0,weights:ee.custom([],{private:!0}),showing:ee.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>St(e),r,o=()=>ye(r),i=e.style,s=e.orientation==="horizontal",a=on(e.data,e.categoryField),l=()=>ke(t(),s?"x":"y"),c=()=>ke(t(),s?"y":"x"),u=()=>{let E=n();return E.ticks.map(L=>pn(e,E,L))},f=s?i.showXAxis:i.showYAxis,h=s?i.showYAxis:i.showXAxis,d=f?s?new Ae({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",overhang:()=>({left:N(t()),right:N(t())}),width:"fill",height:"hug"}):new Re({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",width:"hug",height:"fill"}):void 0,p=h?new mt({categories:a,axis:c,label:e.categoryAxis.label??"",orientation:s?"vertical":"horizontal",dims:()=>Xr(e),width:s?"hug":"fill",height:s?"fill":"hug"}):void 0,g=s?p:d,m=s?d:p,x=s?c:l,S=g&&m?rt({captions:s?()=>a:u,count:s?a.length:St(e).ticks.length,text:()=>x().labelStyle,title:(s?e.categoryAxis.label:e.valueAxis.label)??"",titleText:()=>x().titleStyle,tickPad:()=>oe(x(),"right").tick,titlePad:()=>oe(x(),"right").title}):void 0,M=e.series.map((E,L)=>new bt({bars:()=>Ii(e,L,o()),baseline:()=>gn(n(),Vr(e,o()).along,dn(n())),horizontal:s,fill:()=>G(t(),E,L),cornerRadius:()=>t().barRadius,growth:()=>e.growth,dims:()=>Xr(e),values:()=>i.values==="end"&&e.stack==="percent"?"inside":i.values,valueStyle:()=>({...ut(t()),fontSize:Math.round(t().fontSize*.85)}),enabled:()=>e.showing[L]??E.enabled??!0})),R=i.legend,w=R!=="none"?new Z({series:e.series,swatches:()=>e.series.map((E,L)=>G(t(),E,L)),legend:()=>B(t()),flow:R==="right"?"vertical":"horizontal"}):void 0,b=e.data.length,v=()=>Array.from({length:Math.max(0,b-1)},(E,L)=>L+1),F=()=>[0,Math.max(1,b)];return r=new Li({children:[new ot({fill:()=>t().background,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:s?()=>n().ticks:v,yMarkers:s?v:()=>n().ticks,xExtent:s?()=>n().range:F,yExtent:s?F:()=>n().range,axisStroke:()=>t().axisStroke,xAxisAt:()=>s?0:dn(n()),yAxisAt:()=>s?dn(n()):0}),...M]}),[tt({left:g,ghost:S,plot:r,bottom:m,legend:w,legendAt:R,gap:()=>Qe(t()),padding:()=>({top:et(t()),right:s&&m?N(t()):0,left:s&&m&&!g?N(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:Le(),run:(e,t,n)=>{let r=mn(n),o=e.duration,i=o*I.axes,s=o*I.marks,{legend:a}=r,l=c=>({at:0,duration:0,piece:c});return z(e,[l(e.animate(()=>({growth:0}))),...a?[l(a.to({opacity:0,...it(t.style.legend)}))]:[],...r.valueAxis?[{at:0,duration:i,piece:r.valueAxis.run("enter",{slide:24})}]:[],...r.categoryAxis?[{at:0,duration:i,piece:r.categoryAxis.run("enter",{slide:24})}]:[],{at:i,duration:s,piece:e.animate(c=>({growth:c}))},...a?[{at:i+s,duration:o*I.legend,piece:a.to({opacity:1,x:0,y:0})}]:[]])}},showSeries:{args:{seriesIndex:_},easing:Le(),run:(e,t,n)=>Ur(e,t,n,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:_},easing:Le(),run:(e,t,n)=>Ur(e,t,n,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:_},easing:Le(),run:(e,t,n)=>{let r=mn(n),o=e.args.seriesIndex;return e.together([...r.bars.map((i,s)=>i.to({opacity:s===o?1:D})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}},spotlightCategory:{args:{categoryIndex:ee.number(0,{min:0,step:1})},easing:Le(),run:(e,t)=>{let n=e.args.categoryIndex;if(n<0||n>=t.data.length)return e.wait(e.duration);let r=t.spotlightReveal;return e.animate(o=>({spotlight:n,spotlightReveal:r+(1-r)*o}))}},clearCategory:{args:{},easing:Le(),run:(e,t)=>{let n=t.spotlightReveal;if(n===0)return e.wait(e.duration);let r=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:r,spotlightReveal:n*(1-o)})}}}});import{Rect as co,Types as Tt,clamp as uo,component2d as Zi,easeOut as Oe}from"@motionscript/sdk";import{Graphics2D as Zr,PathBuilder as zi,Rect as An,Text as Te,Types as Ke,clamp as pe,component2d as Gi,strokeOps as Fi,textOps as Ce}from"@motionscript/sdk";import{Types as Rt}from"@motionscript/sdk";function wn(e,t,n,r){return e.map((o,i)=>({category:H(o,t),value:k(o,n),fill:r.length>0?r[i%r.length]:"white"}))}function Sn(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Kr(e){let t=0;for(let n of e)t+=Sn(n);return t}function At(e,t){let n=Kr(e);if(n<=0)return[];let r=[],o=t*ve;return e.forEach((i,s)=>{let a=Sn(i);if(a<=0)return;let l=a/n,c=o,u=c+l*Math.PI*2;o=u,r.push({index:s,a0:c,a1:u,mid:(c+u)/2,fraction:l})}),r}function kt(e,t,n,r){e.sort((s,a)=>a.ideal-s.ideal);let o=n;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=r;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Rn={colors:W,text:X,marks:{innerRadius:Rt.number(0,{min:0,max:.9,step:.05}),sliceGap:Rt.number(3,{min:0,max:40,step:1,unit:"px"}),sliceRadius:Rt.number(4,{min:0,max:60,step:1,unit:"px"})},labels:{labelPlacement:Rt.oneOf(["inside","outside","none"],{animatable:!1})},legend:U};function Mt(e){return B(e)}function bn(e){return e.fontFamily?{fontFamily:e.fontFamily}:{}}function $r(e){return{gap:e.sliceGap,holeRadius:e.innerRadius,startAngle:0,selectedGrow:1.08,cornerRadius:e.sliceRadius}}function jr(e){let t={...bn(e),fontSize:e.fontSize,fontWeight:e.fontWeight,textAlign:"center",fill:e.muted},n=Math.min(900,e.fontWeight+200);return{textStyle:t,percentStyle:{...t,fontWeight:n,fill:e.foreground},insideStyle:{...t,fontSize:Math.round(e.fontSize*1.9),fontWeight:n,fill:"#111113"},leaderStroke:{weight:2,fill:e.muted}}}function qr(e){return{labelStyle:{...bn(e),fontSize:Math.round(e.fontSize*1.8),fontWeight:Math.min(900,e.fontWeight+300),textAlign:"center",fill:e.foreground},captionStyle:{...bn(e),fontSize:Math.round(e.fontSize*.8),fontWeight:e.fontWeight,textAlign:"center",fill:e.muted}}}var Di={gap:3,holeRadius:0,startAngle:0,selectedGrow:1.08,cornerRadius:4},Bi={textStyle:{fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},percentStyle:{fontSize:28,fontWeight:700,textAlign:"center",fill:"#f4f4f5"},insideStyle:{fontSize:52,fontWeight:700,textAlign:"center",fill:"#111113"},leaderStroke:{weight:2,fill:"#a1a1aa"}},Ni={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function Jr(e){let n=rr(e).find(s=>s.type==="solid");if(!n)return"#111113";let[r,o,i]=n.color;return .2126*r+.7152*o+.0722*i>.45?"#111113":"#ffffff"}var Qr=12,Hi=14,kn=.62,Yi=6,eo=34,to=26,no=8,Wi=.18,Xi=240,Ui=8,ro=2,io=.44,Mn=.62,Vi=.78,Ki=.9,oo=.001,so=26;function ce(e,t=so){let n=e.fontSize;return typeof n=="number"?n:t}function $i(e,t,n,r,o,i,s){let a=new zi,l=t-e,c=Math.max(2,Math.ceil(Math.abs(l)/(Math.PI*2)*Xi)),u=A=>A<=0?0:Math.min(o/A,l/2.2),f=(A,P)=>{let xe=K(A,P);return{x:xe.x+s,y:xe.y}},h=n>0,d=e+u(r),p=t-u(r),g=e+u(n),m=t-u(n),x=f(r,d),S=f(r,p),M=Math.max(.001,Math.min(l/2,Math.PI/2)),R=f(o>0?Math.min(o/Math.sin(M),r*.8):0,(e+t)/2),w=h?f(n,g):R,b=h?f(n,m):R,v=h?r-n:r,F=Math.max(0,Math.min(i,v/2.2,(p-d)*r/2.2,h?(m-g)*n/2.2:1/0)),E=F>=.5,L=(A,P,xe)=>{let Ie=Math.hypot(P.x-A.x,P.y-A.y)||1,ze=Math.min(.5,xe/Ie);return{x:A.x+(P.x-A.x)*ze,y:A.y+(P.y-A.y)*ze}},ue=E?F/Math.max(1,r):0,O=E&&h?F/n:0,re=(A,P,xe)=>{for(let Ie=0;Ie<=c;Ie++){let ze=f(A,P+(xe-P)*Ie/c);a.lineTo(ze.x,ze.y)}},Je=(A,P)=>{E?a.quadraticCurveTo(A.x,A.y,P.x,P.y):a.lineTo(A.x,A.y)},Ft=f(r,d+ue);if(a.moveTo(Ft.x,Ft.y),re(r,d+ue,p-ue),Je(S,L(S,b,F)),h){let A=L(b,S,F);a.lineTo(A.x,A.y),Je(b,f(n,m-O)),re(n,m-O,g+O),Je(w,L(w,x,F))}else a.lineTo(R.x,R.y);let qn=L(x,w,E?F:0);return a.lineTo(qn.x,qn.y),Je(x,Ft),a.close(),a}var vt=class{s;box;constructor(t,n){this.s=t,this.box=n}get arcs(){return At(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="outside"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let n=this.outerRadius,r=this.holeRadius,o=r>0?n-r:n*(1-Mn)*2,i=r>0?(r+n)/2:n*Mn,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),l=s>oo?o/s:1/0,c=a>oo?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(l,c))}insideGlyphs(t){let n=this.s.labelMode,r=this.s.slices[t.index]?.category.length??0,o=n==="both"||n==="percent"?Nt(t.fraction).length:0,i=n==="category"?r:n==="both"?r*io:0;return Math.max(1,o,i)}get insideFont(){let t=ce(this.s.label.insideStyle,so*1.9);for(let n of this.arcs){let r=this.insideRoom(n)*Ki/(this.insideGlyphs(n)*kn);t=Math.min(t,r)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=ce(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=ce(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*Vi/(a*kn))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=ce(this.s.label.textStyle)*1.25,n=ce(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+n+2:this.s.labelMode==="category"?t:n}captionGlyphs(t){let n=this.s.labelMode,r=n==="percent"||n==="both"?4:0,o=n==="category"||n==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(r,o)}get labelGutters(){let t={left:ro,right:ro};if(!this.hasLeaderLabels)return t;let n=ce(this.s.label.textStyle)*kn;for(let r of this.arcs){let o=eo+to+no+this.captionGlyphs(r.index)*n+Hi,i=vn(r.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:n}=this.labelGutters;return(t-n)/2}get outerRadius(){let{left:t,right:n}=this.labelGutters,r=Math.min((this.box.width-t-n)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,r/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let n=t<1?t*this.outerRadius:t;return Math.min(n,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+eo}popOf(t){return pe(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let n=this.anchorRadius(t),r=this.holeRadius;return r>0?(r+n)/2:n*Mn}insideAnchor(t){let n=this.arcs.find(o=>o.index===t);if(n===void 0)return{x:this.centerX,y:0};let r=K(this.bandMidRadius(t),n.mid);return{x:r.x+this.centerX,y:r.y}}get selectionStrength(){let t=0;for(let n=0;n<this.s.slices.length;n++)t=Math.max(t,this.popOf(n));return t}sliceOpacity(t){return J(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let n=this.arcs.find(r=>r.index===t);return Nt(n?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let n=this.elbowRadius,r=this.labelRowHeight,o=this.box.height/2-r/2,i=-o,s=this.centerX,a=[],l=[];for(let c of t){let u=vn(c.mid),f=K(n,c.mid).y;(u>0?a:l).push({index:c.index,side:u,mid:c.mid,ideal:f,y:f})}return kt(a,r+Qr,o,i),kt(l,r+Qr,o,i),[...a,...l].map(c=>{let u=K(this.anchorRadius(c.index)+Yi,c.mid),f=Math.sqrt(Math.max(0,n*n-c.y*c.y)),h=s+c.side*Math.max(f,n*Wi),d=s+c.side*(n+to);return{index:c.index,side:c.side,leader:[{x:u.x+s,y:u.y},{x:h,y:c.y},{x:d,y:c.y}],text:{x:d+c.side*no,y:c.y}}})}placementFor(t){return this.placements().find(n=>n.index===t)}};function vn(e){return Math.sin(e)>=0?1:-1}var ji={width:0,height:0};function qi(e){let t=[],n=()=>new vt(e,t[0]?.parent?.layoutBounds??ji),r=o=>{let i=()=>pe(e.labelReveal,0,1)*n().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let f=[];return a&&f.push(new Te({...Ce.styleProps(e.label.insideStyle),text:()=>n().percentText(o.index),fill:()=>Jr(e.slices[o.index]?.fill??"white"),fontSize:()=>n().insideFont})),s&&f.push(new Te({...Ce.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fill:()=>Jr(e.slices[o.index]?.fill??"white"),fontSize:()=>e.labelMode==="category"?n().insideFont:n().insideFont*io})),new An({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>n().insideAnchor(o.index),children:f})}let l=vn(o.mid),c=()=>n().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new Te({...Ce.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:l>0?"left":"right"})),a&&u.push(new Te({...Ce.styleProps(e.label.percentStyle),text:()=>n().percentText(o.index),textAlign:l>0?"left":"right"})),new An({flow:"vertical",width:"hug",height:"hug",gap:2,align:l>0?"centerLeft":"centerRight",opacity:i,centerLeft:l>0?c:void 0,centerRight:l>0?void 0:c,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of At(e.slices,e.ring.startAngle))t.push(r(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Te({...Ce.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Te({...Ce.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(ce(e.centerStyle.captionStyle,22)/ce(e.centerStyle.labelStyle,46))})),t.push(new An({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>pe(e.centerReveal,0,1)*pe(n().holeRadius/20,0,1),center:()=>({x:n().centerX,y:0}),children:o}))}return t}var Et=Gi({key:"pieRing",state:{slices:y(()=>[]),ring:Ke.custom(Di),label:Ke.custom(Bi),centerStyle:Ke.custom(Ni),labelMode:Ke.custom("percent"),labelPlacement:Ke.custom("outside"),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:ie,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>qi(e),load:(e,t)=>C(e,{fills:Ee(t.slices),strokes:[Fi.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=T(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=T(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=T(e),r=pe(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new vt(t,e.size),r=n.outerRadius,o=r>0?n.arcs:[];if(o.length>0){let i=pe(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=n.holeRadius,l=Math.max(0,t.ring.gap)/2,c=n.centerX,u=r+n.maxPop+1+Math.abs(c),f=[-u,-u,u,u],h=u*2,d=Ee(t.slices);for(let g of o){let m=Math.min(g.a1,s);if(m<=g.a0)continue;let x=$i(g.a0,m,a,n.anchorRadius(g.index),l,Math.max(0,t.ring.cornerRadius),c),S=new Zr().path(x.toPathState({centerBounds:f,width:h,height:h}));S.fill(d[g.index]??[]),e.draw(S.opacity(n.sliceOpacity(g.index)))}let p=pe(t.labelReveal,0,1);if(p>.001)for(let g of n.placements())e.draw(new Zr().line({points:g.leader,radius:Ui}).stroke(t.label.leaderStroke).opacity(p*n.sliceOpacity(g.index)))}e.children()}});var Ji=.65,Qi=.35,En=Tt.number(0,{min:0,step:1});function ao(e){return wn(e.data,e.categoryField,e.valueField,e.data.map((t,n)=>ct(e.style,n)))}function _e(e,t){return uo(e.pops[t]??0,0,1)}function es(e,t){return _e(e,t)>.5}function ts(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,_e(e,n));return e.data.map((n,r)=>J(t,ie,_e(e,r)))}function Lt(e,t,n){let r=t.data.map((i,s)=>_e(t,s)),o=t.data.map((i,s)=>uo(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function lo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=co.is(n)?n.children.find(Et.is):void 0;if(r)return{ring:r,legend:n.children.find(Me.is)??null}}return null}var Ln=Zi({key:"pieChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",style:Tt.style(Y,Rn,{presets:V}),labelMode:Tt.custom("percent"),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:Tt.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>ao(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>ao(e),r=[new Et({width:"fill",height:"fill",slices:n,ring:()=>$r(t()),label:()=>jr(t()),centerStyle:()=>qr(t()),labelMode:e.labelMode,labelPlacement:e.style.labelPlacement,pops:()=>e.pops,dimOpacity:ie,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=new Me({slices:n,legend:()=>Mt(t()),dims:()=>ts(e),flow:s?"vertical":"horizontal",align:"center",gap:s?Mt(e.style).itemGap/3:Mt(e.style).itemGap,padding:0});o==="top"?r.unshift(a):r.push(a)}let i=new co({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:Oe(),run:(e,t,n)=>{let r=lo(n);if(!r)return e.wait(e.duration);let{ring:o,legend:i}=r,s=e.duration*Ji,a=e.duration*Qi,l=c=>({at:0,duration:0,piece:c});return z(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:Oe(),run:(e,t,n)=>lo(n)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:En},easing:Oe(),run:(e,t)=>{let n=e.args.sliceIndex;return Lt(e,t,r=>r===n?1:_e(t,r))}},deselectSlice:{args:{sliceIndex:En},easing:Oe(),run:(e,t)=>{let n=e.args.sliceIndex;return Lt(e,t,r=>r===n?0:_e(t,r))}},selectOnlySlice:{args:{sliceIndex:En},easing:Oe(),run:(e,t)=>{let n=e.args.sliceIndex;return Lt(e,t,r=>r===n?1:0)}},clearSelection:{args:{},easing:Oe(),run:(e,t)=>Lt(e,t,()=>0)}}});import{Rect as Pe,Text as cs,Types as us,component2d as fs,easeOut as Pt,textOps as hs}from"@motionscript/sdk";import{Graphics2D as bo,Types as zn,clamp as ss,component2d as as,strokeOps as Ct}from"@motionscript/sdk";import{Types as te}from"@motionscript/sdk";var Cn={gridShape:te.oneOf(["polygon","circle"]),gridLevels:te.number(4,{min:1,max:10,step:1}),gridStroke:te.stroke({weight:2,fill:"white/15"}),spokeStroke:te.stroke({weight:2,fill:"white/15"}),spokeLabels:te.boolean(!0,{animatable:!1})},On={strokeWidth:te.number(4,{min:0,max:24,step:1,unit:"px"}),areaOpacity:te.number(.25,{min:0,max:1,step:.05}),dots:te.boolean(!0),dotSize:te.number(10,{min:2,max:40,step:1,unit:"px"})},ns=.55,rs=.58,Tn=10,fo=.35;function ne(e,t){let n=e/Math.max(1,t)*Math.PI*2;return{x:Math.sin(n),y:Math.cos(n)}}function _n(e,t){return e.map(n=>H(n,t))}function ho(e,t){return t.map(n=>e.map(r=>k(r,n.field)))}var os=[1,1.2,1.5,2,2.5,3,4,5,6,8,10];function po(e){if(!(e>0))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(os.find(o=>o>=n-1e-9)??10)*t}function go(e,t,n){if(n>t)return{min:t,max:n};let r=t;for(let i of e)for(let s of i)r=Math.max(r,s);let o=po(r-t);return{min:t,max:t+o}}function mo(e,t){let n=t.max-t.min;return n<=0?0:Math.min(1,Math.max(0,(e-t.min)/n))}function Pn(e,t){let{x:n,y:r}=ne(e,t);return n>fo?"centerLeft":n<-fo?"centerRight":r>=0?"bottomCenter":"topCenter"}function xo(e){return e*ns}function is(e,t){return{width:e.length*t*rs,height:t*1.25}}function In(e,t,n,r){let o=Math.min(e.width,e.height)/2-Tn;if(!r)return Math.max(0,o);let i=xo(n),s=t.length;return t.forEach((a,l)=>{let{x:c,y:u}=ne(l,s),f=is(a,n),h=Pn(l,s),d=h==="centerLeft"||h==="centerRight"?f.width:f.width/2,p=h==="bottomCenter"||h==="topCenter"?f.height:f.height/2;Math.abs(c)>1e-6&&(o=Math.min(o,(e.width/2-d-Tn/2)/Math.abs(c)-i)),Math.abs(u)>1e-6&&(o=Math.min(o,(e.height/2-p-Tn/2)/Math.abs(u)-i))}),Math.max(0,o)}function yo(e,t,n,r){let{x:o,y:i}=ne(e,t),s=n+xo(r);return{x:o*s,y:i*s}}var $e=as({key:"radarGrid",state:{count:0,radius:0,levels:4,shape:zn.custom("polygon"),stroke:zn.custom([],{resolve:Ct.resolve,lerp:Ct.lerp}),spokeStroke:zn.custom([],{resolve:Ct.resolve,lerp:Ct.lerp}),reveal:1},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{strokes:[t.stroke,t.spokeStroke]}),render:(e,t)=>{let n=ss(t.reveal,0,1),r=t.radius*n;if(r<=0||n<=0)return;let o=Math.max(0,Math.round(t.count)),i=Math.max(1,Math.round(t.levels)),s=t.shape==="circle"||o<3;for(let a=1;t.stroke.length>0&&a<=i;a++){let l=r*a/i,c=new bo;if(s)c.ellipse({width:l*2,height:l*2});else{let u=[];for(let f=0;f<o;f++){let h=ne(f,o);u.push({x:h.x*l,y:h.y*l})}c.line({points:u,closed:!0})}e.draw(c.stroke(t.stroke).opacity(n))}if(t.spokeStroke.length!==0)for(let a=0;a<o;a++){let l=ne(a,o);e.draw(new bo().line({points:[{x:0,y:0},{x:l.x*r,y:l.y*r}]}).stroke(t.spokeStroke).opacity(n))}}});import{Graphics2D as Gn,Types as Ot,clamp as wo,component2d as ls,fillOps as So,strokeOps as Ro}from"@motionscript/sdk";function Ao(e,t,n=1){return e.map((r,o)=>{let i=ne(o,e.length),s=t*r*n;return{x:i.x*s,y:i.y*s}})}var _t=ls({key:"radarSeries",state:{fractions:y(()=>[]),radius:0,fill:Ot.custom([],{resolve:So.resolve,lerp:So.lerp}),stroke:Ot.custom([],{resolve:Ro.resolve,lerp:Ro.lerp}),areaOpacity:.25,dots:!0,dotSize:10,progress:1,enabled:!0},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),commands:{enter:{args:{from:Ot.number(0,{min:0,max:1}),to:Ot.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=T(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let n=wo(t.progress,0,1);if(n<=0||t.radius<=0||t.fractions.length===0)return;let r=Ao(t.fractions,t.radius,n);if(r.length>=2){let o=new Gn().line({points:r,closed:!0});t.areaOpacity>0&&t.fill.length>0&&e.draw(o.fill(t.fill).opacity(wo(t.areaOpacity,0,1))),t.stroke.length>0&&e.draw(new Gn().line({points:r,closed:!0}).stroke(t.stroke))}if(t.dots&&t.dotSize>0&&t.fill.length>0){let o=new Gn;for(let i of r)o.ellipse({x:i.x,y:i.y,width:t.dotSize,height:t.dotSize});e.draw(o.fill(t.fill))}}});function vo(e){return go(ho(e.data,e.series),e.min,e.max)}function Eo(e,t){let n=e.series[t];if(!n)return[];let r=vo(e);return e.data.map(o=>{let i=o[n.field];return mo(typeof i=="number"&&Number.isFinite(i)?i:0,r)})}function Fn(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Pe.is(n))continue;let r=n.children.find(o=>Pe.is(o)&&o.children.some($e.is));if(r)return{grid:r.children.find($e.is),series:r.children.filter(_t.is),labels:r.children.find(Pe.is)??null,legend:n.children.find(Z.is)??null}}return null}function ko(e,t,n,r){let o=Fn(t),i=o?.series[n];return!o||!i?e.wait(e.duration):e.together([i.run("enter",r?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(r?"showSeries":"hideSeries",{index:n})]:[]])}var Mo=.3,Dn=fs({key:"radarChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),min:0,max:0,style:us.style(Y,{colors:W,text:X,grid:Cn,marks:On,legend:U},{presets:V})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.style,n,r=()=>ye(n),o=()=>In(r(),_n(e.data,e.categoryField),t().fontSize,t().spokeLabels),i=e.data.length,s=e.series.map(d=>d.enabled??!0),a=new $e({count:()=>e.data.length,radius:o,levels:()=>t().gridLevels,shape:()=>t().gridShape,stroke:()=>t().gridStroke,spokeStroke:()=>t().spokeStroke}),l=e.series.map((d,p)=>new _t({fractions:()=>Eo(e,p),radius:o,fill:()=>G(t(),d,p),stroke:()=>{let g=t().strokeWidth;return g>0?{weight:g,fill:G(t(),d,p),align:"center",join:"round"}:[]},areaOpacity:()=>t().areaOpacity,dots:()=>t().dots,dotSize:()=>t().dotSize,enabled:s[p]})),c=[a,...l];if(e.style.spokeLabels){let d=[];for(let p=0;p<i;p++){let g=Pn(p,i),m=g==="centerLeft"?"left":g==="centerRight"?"right":"center",x=()=>yo(p,i,o(),t().fontSize);d.push(new cs({...hs.styleProps(nr(e.style,m)),text:()=>_n(e.data,e.categoryField)[p]??"",fontSize:()=>t().fontSize,fontWeight:()=>t().fontWeight,fill:()=>t().muted,[g]:x}))}c.push(new Pe({width:"fill",height:"fill",children:d}))}n=new Pe({width:"fill",height:"fill",children:c});let u=[n],f=e.style.legend;if(f!=="none"){let d=f==="right",p=B(e.style),g=new Z({series:e.series,swatches:()=>e.series.map((m,x)=>G(t(),m,x)),legend:()=>B(t()),flow:d?"vertical":"horizontal",gap:d?Math.round(p.itemGap/2):p.itemGap,padding:p.padding});f==="top"?u.unshift(g):u.push(g)}let h=new Pe({flow:f==="right"?"horizontal":"vertical",width:"fill",height:"fill",gap:24,align:"center",fill:()=>t().background,children:u});return[h]},commands:{enter:{args:{},entrance:!0,easing:Pt(),run:(e,t,n)=>{let r=Fn(n);if(!r)return e.wait(e.duration);let o=e.duration,i=o*I.axes,s=o*I.marks,a=o*I.legend,l=Math.max(1,r.series.length),c=s/(1+Mo*(l-1)),{legend:u,labels:f}=r,h=d=>({at:0,duration:0,piece:d});return z(e,[h(r.grid.to({reveal:0})),...r.series.map(d=>h(d.to({progress:0}))),...f?[h(f.to({opacity:0}))]:[],...u?[h(u.to({opacity:0,y:-Zn}))]:[],{at:0,duration:i,piece:r.grid.to({reveal:1})},...r.series.map((d,p)=>({at:i+p*c*Mo,duration:c,piece:d.to({progress:1})})),...f?[{at:i+s*.6,duration:a+s*.4,piece:f.to({opacity:1})}]:[],...u?[{at:i+s,duration:a,piece:u.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:_},easing:Pt(),run:(e,t,n)=>ko(e,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:_},easing:Pt(),run:(e,t,n)=>ko(e,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:_},easing:Pt(),run:(e,t,n)=>{let r=Fn(n);if(!r)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...r.series.map((i,s)=>i.to({opacity:s===o?1:D})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Bo,Types as $n,clamp as No,component2d as vs,easeOut as zt}from"@motionscript/sdk";import{Graphics2D as _o,PathBuilder as ps,Rect as Po,Text as Un,Types as je,clamp as me,component2d as gs,fillOps as ms,textOps as Vn}from"@motionscript/sdk";import{Types as ge,clamp as ds}from"@motionscript/sdk";function Nn(e,t,n,r){return e.map((o,i)=>({category:H(o,t),value:k(o,n),fill:ct(r,i)}))}function Hn(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Lo(e,t){if(t>0&&Number.isFinite(t))return t;let n=0;for(let r of e)n=Math.max(n,Hn(r));return n>0?n:1}function Yn(e,t){let n=Lo(e,t);return e.map(r=>ds(Hn(r)/n,0,1))}var Wn={colors:W,text:X,marks:{innerRadius:ge.number(.3,{min:0,max:.9,step:.05}),ringGap:ge.number(8,{min:0,max:60,step:1,unit:"px"}),sweep:ge.number(360,{min:30,max:360,step:5,unit:"deg"}),startAngle:ge.number(0,{min:-360,max:360,step:5,unit:"deg"}),track:ge.fill("white/10"),roundCaps:ge.boolean(!0)},labels:{ringLabels:ge.boolean(!1)},legend:U};function To(e){return{innerRadius:e.innerRadius,ringGap:e.ringGap,sweep:e.sweep,startAngle:e.startAngle,track:e.track.length>0,roundCaps:e.roundCaps}}function Xn(e){return B(e)}function Bn(e){return e.fontFamily?{fontFamily:e.fontFamily}:{}}function Co(e){return{...Bn(e),fontSize:e.fontSize,fontWeight:e.fontWeight,textAlign:"center",fill:e.muted}}function Oo(e){return{labelStyle:{...Bn(e),fontSize:Math.round(e.fontSize*1.8),fontWeight:Math.min(900,e.fontWeight+300),textAlign:"center",fill:e.foreground},captionStyle:{...Bn(e),fontSize:Math.round(e.fontSize*.8),fontWeight:e.fontWeight,textAlign:"center",fill:e.muted}}}var Io=.12,xs=.12,ys=4*ve,zo=10,bs=.78,ws=.62,Go=4,Ss={innerRadius:.3,ringGap:8,sweep:360,startAngle:0,track:!0,roundCaps:!0},Rs={fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},As={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function qe(e,t){return typeof e.fontSize=="number"?e.fontSize:t}var Ze=class{s;box;constructor(t,n){this.s=t,this.box=n}get count(){return this.s.rows.length}get outerRadius(){return Math.max(0,Math.min(this.box.width,this.box.height)/2-Go)}get holeRadius(){return me(this.s.marks.innerRadius,0,.9)*this.outerRadius}get thickness(){let t=this.count;return t===0?0:Math.max(0,(this.outerRadius-this.holeRadius-(t-1)*Math.max(0,this.s.marks.ringGap))/t)}ringOuter(t){return this.outerRadius-t*(this.thickness+Math.max(0,this.s.marks.ringGap))}ringMid(t){return this.ringOuter(t)-this.thickness/2}get fractions(){return Yn(this.s.rows,this.s.max)}get startRad(){return this.s.marks.startAngle*ve}get sweepRad(){return me(this.s.marks.sweep,0,360)*ve}popOf(t){return me(this.s.pops[t]??0,0,1)}get selectionStrength(){let t=0;for(let n=0;n<this.count;n++)t=Math.max(t,this.popOf(n));return t}ringOpacity(t){return J(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}progress(t,n){let r=1+Io*Math.max(0,this.count-1);return me(n*r-t*Io,0,1)}get labelFont(){return Math.max(1,Math.min(qe(this.s.label,28),this.thickness*.62))}labelAnchor(t){let n=this.startRad,r={x:-Math.cos(n),y:Math.sin(n)},o=K(this.ringMid(t),n),i=r.x<=0?-1:1;return{at:{x:o.x+r.x*zo,y:o.y+r.y*zo},side:i}}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=qe(t.labelStyle,50),i=this.holeRadius;if(i<=0)return o;let s=qe(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*bs/(a*ws))}};function Kn(e,t,n,r,o){let i=new ps,s=(n+r)/2,a=(r-n)/2,l=o&&s>0?Math.min(a/s,(t-e)/2):0,c=e+l,u=t-l,f=Math.max(2,Math.ceil(Math.abs(u-c)/ys)),h=(p,g,m,x)=>{for(let S=0;S<=f;S++){let M=K(p,g+(m-g)*S/f);x&&S===0?i.moveTo(M.x,M.y):i.lineTo(M.x,M.y)}},d=(p,g,m)=>{let x=K(s,p),S={x:Math.sin(p),y:Math.cos(p)},M={x:Math.cos(p)*g,y:-Math.sin(p)*g},R=12;for(let w=1;w<R;w++){let b=Math.PI*w/R,v=m?Math.cos(b):-Math.cos(b);i.lineTo(x.x+a*(S.x*v+M.x*Math.sin(b)),x.y+a*(S.y*v+M.y*Math.sin(b)))}};return h(r,c,u,!0),o&&d(u,1,!0),h(n,u,c,!1),o&&d(c,-1,!1),i.close(),i}var ks={width:0,height:0};function Ms(e){let t=[],n=()=>new Ze(e,t[0]?.parent?.layoutBounds??ks),r=n().labelAnchor(0).side;if(e.rows.forEach((o,i)=>{let s=()=>n().labelAnchor(i).at;t.push(new Po({flow:"vertical",width:"hug",height:"hug",align:r>0?"centerLeft":"centerRight",opacity:()=>e.ringLabels?me(e.labelReveal,0,1)*n().ringOpacity(i):0,centerLeft:r>0?s:void 0,centerRight:r>0?void 0:s,children:[new Un({...Vn.styleProps(e.label),text:()=>e.rows[i]?.category??"",textAlign:r>0?"left":"right",fontSize:()=>n().labelFont})]}))}),e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Un({...Vn.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Un({...Vn.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(qe(e.centerStyle.captionStyle,22)/qe(e.centerStyle.labelStyle,50))})),t.push(new Po({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>me(e.centerReveal,0,1),center:{x:0,y:0},children:o}))}return t}var It=gs({key:"radialRings",state:{rows:y(()=>[]),max:0,marks:je.custom(Ss),label:je.custom(Rs),centerStyle:je.custom(As),trackFill:je.fill("white/15"),ringLabels:je.boolean(!1),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:.25,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Ms(e),load:(e,t)=>C(e,{fills:[...Ee(t.rows),ms.resolve(t.trackFill)]}),commands:{sweep:e=>{let t=T(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=T(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=T(e),r=me(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new Ze(t,e.size),r=n.thickness;if(n.outerRadius>0&&n.count>0&&r>0){let o=n.outerRadius+Go+1,i={centerBounds:[-o,-o,o,o],width:o*2,height:o*2},s=Ee(t.rows),a=n.fractions,l=n.startRad,c=t.marks.roundCaps,u=[...t.rows.keys()].sort((f,h)=>n.popOf(f)-n.popOf(h));for(let f of u){let h=r*xs*n.popOf(f),d=n.ringOuter(f)+h,p=n.ringOuter(f)-r-h,g=n.ringOpacity(f);t.marks.track&&n.sweepRad>0&&e.draw(new _o().path(Kn(l,l+n.sweepRad,p,d,c).toPathState(i)).fill(t.trackFill).opacity(g));let m=n.sweepRad*a[f]*n.progress(f,t.growth);m<=1e-4||e.draw(new _o().path(Kn(l,l+m,p,d,c).toPathState(i)).fill(s[f]??[]).opacity(g))}}e.children()}});var Es=.7,Ls=.3;function Ts(e){return Nn(e.data,e.categoryField,e.valueField,e.style)}function Gt(e,t){return No(e.pops[t]??0,0,1)}function Cs(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Gt(e,n));return e.data.map((n,r)=>J(t,Ho,Gt(e,r)))}var Ho=Math.max(ie,.25);function Fo(e,t,n){let r=t.data.map((i,s)=>Gt(t,s)),o=t.data.map((i,s)=>No(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function Do(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=Bo.is(n)?n.children.find(It.is):void 0;if(r)return{rings:r,legend:n.children.find(Me.is)??null}}return null}var jn=vs({key:"radialChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",max:$n.number(0,{min:0,step:1}),style:$n.style(Y,Wn,{presets:V}),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:$n.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>e.data.map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Ts(e),r=[new It({width:"fill",height:"fill",rows:n,max:()=>e.max,marks:()=>To(t()),label:()=>Co(t()),centerStyle:()=>Oo(t()),trackFill:()=>t().track,ringLabels:()=>t().ringLabels,pops:()=>e.pops,dimOpacity:Ho,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=Xn(e.style),l=new Me({slices:n,legend:()=>Xn(t()),dims:()=>Cs(e),flow:s?"vertical":"horizontal",align:"center",gap:s?a.itemGap/3:a.itemGap,padding:0});o==="top"?r.unshift(l):r.push(l)}let i=new Bo({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:zt(),run:(e,t,n)=>{let r=Do(n);if(!r)return e.wait(e.duration);let{rings:o,legend:i}=r,s=e.duration*Es,a=e.duration*Ls,l=c=>({at:0,duration:0,piece:c});return z(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:zt(),run:(e,t,n)=>Do(n)?.rings.run("revealCenter")??e.wait(e.duration)},selectRing:{args:{ringIndex:_},easing:zt(),run:(e,t)=>{let n=e.args.ringIndex;return Fo(e,t,r=>r===n?1:Gt(t,r))}},clearSelection:{args:{},easing:zt(),run:(e,t)=>Fo(e,t,()=>0)}}});var Os=[nn,yn,Ln,Dn,jn];export{cn as BAR_LABELS,ln as BAR_MARKS,yn as BarChart,lt as CARTESIAN_GRID,W as CHART_COLORS,U as CHART_LEGEND,Gs as CHART_PALETTE_DEFAULT,Y as CHART_STYLE_FAMILY,V as CHART_STYLE_PRESETS,X as CHART_TEXT,mt as CategoryAxis,qt as ChartArea,bt as ChartBars,ot as ChartCanvas,Z as ChartLegend,ht as ChartLine,Zt as ChartRegion,Is as DEFAULT_LEGEND,j as DEFAULT_MARKERS,er as DEFAULT_X_AXIS,Ps as DEFAULT_Y_AXIS,ve as DEG,de as EMPTY_REGION_BOX,I as ENTER_SHARE,kr as EVERY_SAMPLE,Ae as HorizontalAxis,Zn as LEGEND_SLIDE,$t as LINE_LABELS,Kt as LINE_MARKS,nn as LineChart,Os as NODES,ie as PIE_SPOTLIGHT_DIM,Rn as PIE_STYLE_GROUPS,Ln as PieChart,Me as PieLegend,Et as PieRing,Cn as RADAR_GRID,On as RADAR_MARKS,Wn as RADIAL_STYLE_GROUPS,Dn as RadarChart,$e as RadarGrid,_t as RadarSeries,jn as RadialChart,Ze as RadialGeometry,It as RadialRings,_ as SERIES_ARG,D as SPOTLIGHT_DIM,Re as VerticalAxis,hr as areaFill,Qn as armed,Bt as arrival,Fe as arrivalOf,Jn as arrivalsEntry,$ as asParts,ke as axisConfigOf,oe as axisPads,Kn as bandPath,on as barCategories,St as barChartDomain,yt as barSpans,Dr as barValueExtent,z as beats,fe as boundText,tr as captionColumn,tt as cartesianFrame,nt as chartViews,Vt as clipPolygonToBox,Yt as clipPolylineToBox,rt as columnGhost,Xt as curvePoints,Ut as cutAt,Ge as fade,In as fitRadius,Ar as formatInstant,we as formatMarker,Nt as formatPercent,T as frameEase,Qe as frameGap,y as fresh,se as hasRegion,et as headroom,an as inkOn,es as isSliceSelected,ye as laidOutSize,it as legendAway,B as legendConfigOf,De as lerpAxisDomain,Be as lerpAxisEntry,Ue as lineChartDomains,C as loadPaints,zs as markerCaption,st as markerStep,nr as markerText,q as markerValues,po as niceCeil,Se as niceRange,at as niceTicks,k as num,_s as numericFields,N as overhang,ct as paletteFill,Rr as parseInstant,At as pieArcs,Eo as radarFractions,vo as radarScale,Yn as radialFractions,Lo as radialMax,kt as relaxLabels,be as resolveAxisDomain,sn as resolveBarScale,wn as resolvePieSlices,Nn as resolveRadialRows,Ht as resolveRegionBox,Jt as resolveXScale,Uo as resolveYScale,rr as resolvedFill,Ee as ringFills,K as ringPoint,Hn as rowValue,Dt as rule,J as selectionFade,G as seriesFill,Xo as seriesPoints,Ao as seriesVertices,Ne as settleAxisDomain,Kr as sliceTotal,Sn as sliceValue,Ve as slotCentre,ne as spokeDirection,ft as stackExtent,Wt as stackSeries,H as text,Fs as titleText,Xe as traceX,ut as valueText,ar as yExtent};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|