@motionscript/charts 0.1.0-alpha.6 → 0.1.0-alpha.8

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.
Files changed (66) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/NOTICE +15 -14
  3. package/dist/bar-chart/bar-chart.d.ts +46 -2
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  5. package/dist/bar-chart/bar-chart.js +13 -5
  6. package/dist/bar-chart/bar-chart.js.map +1 -1
  7. package/dist/bar-chart/category-axis.d.ts +12 -1
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  9. package/dist/bar-chart/chart-bars.d.ts +15 -1
  10. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  11. package/dist/bar-chart/chart-bars.js +6 -7
  12. package/dist/bar-chart/chart-bars.js.map +1 -1
  13. package/dist/browser/index.js +1 -1
  14. package/dist/browser/index.js.map +3 -3
  15. package/dist/browser/manifest.json +1 -1
  16. package/dist/kit/chart-border.d.ts +3 -1
  17. package/dist/kit/chart-border.d.ts.map +1 -1
  18. package/dist/kit/chart-canvas.d.ts +10 -1
  19. package/dist/kit/chart-canvas.d.ts.map +1 -1
  20. package/dist/kit/chart-legend.d.ts +48 -1
  21. package/dist/kit/chart-legend.d.ts.map +1 -1
  22. package/dist/kit/vertical-axis.d.ts +13 -1
  23. package/dist/kit/vertical-axis.d.ts.map +1 -1
  24. package/dist/line-chart/chart-line.d.ts +46 -37
  25. package/dist/line-chart/chart-line.d.ts.map +1 -1
  26. package/dist/line-chart/chart-line.js +11 -1
  27. package/dist/line-chart/chart-line.js.map +1 -1
  28. package/dist/line-chart/chart-region.d.ts +21 -22
  29. package/dist/line-chart/chart-region.d.ts.map +1 -1
  30. package/dist/line-chart/chart-region.js +5 -1
  31. package/dist/line-chart/chart-region.js.map +1 -1
  32. package/dist/line-chart/horizontal-axis.d.ts +43 -25
  33. package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
  34. package/dist/line-chart/horizontal-axis.js +10 -1
  35. package/dist/line-chart/horizontal-axis.js.map +1 -1
  36. package/dist/line-chart/line-chart.d.ts +47 -2
  37. package/dist/line-chart/line-chart.d.ts.map +1 -1
  38. package/dist/line-chart/line-chart.js +16 -7
  39. package/dist/line-chart/line-chart.js.map +1 -1
  40. package/dist/line-chart/x-scale.d.ts +3 -10
  41. package/dist/line-chart/x-scale.d.ts.map +1 -1
  42. package/dist/line-chart/x-scale.js +15 -4
  43. package/dist/line-chart/x-scale.js.map +1 -1
  44. package/dist/pie-chart/pie-chart.d.ts +35 -2
  45. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  46. package/dist/pie-chart/pie-chart.js +4 -1
  47. package/dist/pie-chart/pie-chart.js.map +1 -1
  48. package/dist/pie-chart/pie-legend.d.ts +31 -1
  49. package/dist/pie-chart/pie-legend.d.ts.map +1 -1
  50. package/dist/pie-chart/pie-ring.d.ts +19 -1
  51. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  52. package/dist/pie-chart/shared.d.ts +8 -2
  53. package/dist/pie-chart/shared.d.ts.map +1 -1
  54. package/dist/pie-chart/shared.js +10 -4
  55. package/dist/pie-chart/shared.js.map +1 -1
  56. package/package.json +5 -4
  57. package/src/bar-chart/bar-chart.ts +13 -5
  58. package/src/bar-chart/chart-bars.ts +6 -7
  59. package/src/line-chart/chart-line.ts +11 -36
  60. package/src/line-chart/chart-region.ts +5 -21
  61. package/src/line-chart/horizontal-axis.ts +10 -25
  62. package/src/line-chart/line-chart.ts +20 -7
  63. package/src/line-chart/x-scale.ts +18 -3
  64. package/src/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  65. package/src/pie-chart/pie-chart.ts +4 -1
  66. package/src/pie-chart/shared.ts +10 -4
@@ -1,2 +1,2 @@
1
- import{$ as Te,A as xe,B as $,C as j,D as ye,E as be,F as K,G as q,H as Gt,I as Ht,J as we,K as Se,L as Ut,M as Nt,N as Ho,O as F,P as Ae,Q as $e,R as C,S as ue,T as ke,U as Xt,V as I,W as Uo,X as ve,Y as Ee,Z as Re,_ as D,a as f,aa as Le,b as z,ba as Z,c as b,ca as No,d as S,e as Io,f as V,g as w,h as N,i as O,j as Y,k as ae,l as Do,m as le,n as ce,o as v,p as Bo,q as E,r as x,s as A,t as W,u as Go,v as T,w as ge,x as me,y as L,z as Bt}from"./chunks/chunk-XROBIRQK.js";import{Rect as Sn,Types as G,component2d as An,easeOut as B}from"@motionscript/sdk";import{formatNumber as kn}from"@motionscript/sdk/component";import{Graphics2D as et,Types as tt,component2d as dn,strokeOps as Wt}from"@motionscript/sdk";import{Fills as rn,fillOps as zt,lerpNumber as nn,strokeOps as Vt}from"@motionscript/sdk";var J={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function Q(e){return e.right>e.left&&e.top>e.bottom}function je(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return J;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let y=Math.min(d[0],d[1]),U=Math.max(d[0],d[1]),k=We=>g+(We-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,k(y))),Math.max(g,Math.min(p,k(U))),!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 Ke(e,t){if(e.length<2||!Q(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=sn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&on(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 on(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function sn(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 an={...L,markerStyle:{...L.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:T,yAxis:ge,plotArea:me,legend:an,region:{stroke:{weight:3,fill:v.regionColor,dash:[14,12],cap:"butt"},fill:rn.color(v.regionColor,{opacity:.08}),dimOpacity:E}};function ln(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:zt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function cn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:zt.lerp(e.fill,t.fill,r),dimOpacity:nn(e.dimOpacity,t.dimOpacity,r)}}function qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),region:ln(e?.region,r.region)}}function Ze(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),region:cn(e.region,t.region,r)}}function Je(e,t,r){return e.map((n,o)=>[t.at(o),A(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=A(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function Qe(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 un(o,s);let a=ue((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function un(e,t){if(e===0)return[0,1];let r=ue(Math.abs(e)/t);return[e-r,e+r]}function hn(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 Ce=dn({key:"chartLine",state:{points:f(()=>[]),stroke:tt.custom([],{resolve:Wt.resolve,lerp:Wt.lerp}),progress:1,enabled:!0,spotlight:f(()=>J),dimOpacity:E},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:tt.number(0,{min:0,max:1}),to:tt.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=b(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=hn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!Q(a)){e.draw(new et().line({points:o,radius:s}).stroke(i));return}e.draw(new et().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Ke(o,a))e.draw(new et().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as $t,Types as jt,component2d as pn,fillOps as Kt,strokeOps as qt}from"@motionscript/sdk";var rt=pn({key:"chartRegion",state:{box:f(()=>J),stroke:jt.custom(X.region.stroke,{resolve:qt.resolve,lerp:qt.lerp}),fill:jt.custom(X.region.fill,{resolve:Kt.resolve,lerp:Kt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!Q(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 $t().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 $t().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 Zt,Text as Jt,Types as nt,component2d as fn,insetsOps as Qt,textOps as er}from"@motionscript/sdk";var gn=24,Me=fn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:nt.custom(T),label:"",arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=Qt.resolve(e.axis.tickPadding).top,r=Qt.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 Jt({...er.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":Xt(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:()=>w(e.arrivals,u).opacity,y:()=>w(e.arrivals,u).shift});return d}),c=[new Zt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Jt({...er.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new Zt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:nt.custom(void 0),slide:nt.number(gn)},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:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=t.markers.map((p,y)=>({at:y*l,duration:u,piece:O(e,y,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:O(e,"label",s,h)}]:[];return e.together([c,S(e,[...m,...g])])}}}});import{formatNumber as mn}from"@motionscript/sdk/component";var _e=864e5,sr=["january","february","march","april","may","june","july","august","september","october","november","december"],tr=2024;function rr(e){return e.length<3?-1:sr.findIndex(t=>t.startsWith(e))}function xn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*_e+(t-1)*7*_e}function ir(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:xn(n[1]===void 0?tr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=rr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?tr: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=rr(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 r=new Date(e),n=r.getUTCFullYear(),o=sr[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*_e?String(n):t>60*_e?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function yn(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 bn(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=ir(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 nr(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 or(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 C([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 C([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function wn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}function ot(e,t,r){if(t!==""&&yn(e,t)){let s=e.map(a=>A(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:nr(s),label:a=>r===void 0?F(a):mn(a,r),ticks:C}}let n=e.map(s=>W(s,t)),o=t===""?null:bn(e,t);if(o){let s=nr(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>wn(o,n,c,l=>ar(l,a)),ticks:(c,l)=>or(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)=>or(i,s,a)}}var st=G.custom(0,{kind:"series",min:0,step:1}),lr=G.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),vn=20,it=5,En=.35,Rn=.5,Tn=.15;function lt(e,t=e.xAxis.format){return ot(e.data,e.xField,t)}function Ln(e,t){let r=lt(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,it-1)}}function Cn(e,t){let r=(t.ticks?.length??it)-1,n=Qe(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??C(n,it-1)}}function Pe(e){return{x:ce(e.xAxis,t=>Ln(e,t)),y:ce(e.yAxis,t=>Cn(e,t))}}function Mn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=Je(e.data,lt(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 cr(e,t,r){let{width:n,height:o}=r;return je(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function ur(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function dr(e){return e!=null&&typeof e=="object"?e:{}}function _n([e,t]){return e<=t?[e,t]:[t,e]}function hr(e,t){let r=_n(e);return{range:r,ticks:C(r,Math.max(2,t.length)-1)}}function pr(e,t,r){return{...t.x&&{xAxis:ae(e.x,t.x,r)},...t.y&&{yAxis:ae(e.y,t.y,r)}}}function at(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Me.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(Ce.is),legend:t.below.find(Z.is)??null}}function fr(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 gr(e,t,r,n){let o=at(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 ct=An({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:G.custom({},{resolve:Y,lerp:le}),yAxis:G.custom({},{resolve:Y,lerp:le}),theme:G.custom(X,{resolve:qe,lerp:Ze}),region:G.custom(null),regionReveal:0,showLegend:G.boolean(!0,{animatable:!1}),home:G.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},children:e=>{let t=()=>e.theme,r=()=>Pe(e),n,o=()=>Re(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,Ae(d)):kn(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Me({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=lt(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 Ce({points:()=>Mn(e,r(),h,o()),stroke:()=>Ut(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>cr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>Nt(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Sn({clip:!0,children:[new Le({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 rt({box:()=>cr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Te({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[...e.children,ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.duration,i=ur(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*En,c=s*Rn,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return S(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-vn}))]:[],{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*Tn,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:lr},easing:B(),run:(e,t)=>{let r=dr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?fr(e,t):n<=0||!ur(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)=>fr(e,t)},zoomTo:{args:{region:lr},easing:B(),run:(e,t)=>{let r=dr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Pe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...hr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...hr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...pr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Pe(t);return e.animate(o=>({home:null,...pr(n,r,o)}))}},showSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>gr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>gr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>{let n=at(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:E})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Wn,Types as _,component2d as $n,easeOut as ee}from"@motionscript/sdk";import{formatNumber as jn}from"@motionscript/sdk/component";import{Rect as ut,Text as mr,Types as dt,component2d as Pn,insetsOps as xr,textOps as yr}from"@motionscript/sdk";var On=24,Oe=Pn({key:"categoryAxis",state:{categories:f(()=>[]),axis:dt.custom(T),label:"",dims:f(()=>[]),arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=xr.resolve(e.axis.tickPadding).top,r=xr.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 ut({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[l]??1),x:()=>i(l),children:[new mr({...yr.styleProps(e.axis.labelStyle),text:c,opacity:()=>w(e.arrivals,l).opacity,y:()=>w(e.arrivals,l).shift})]})),a=[new ut({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new mr({...yr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new ut({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:dt.custom(void 0),slide:dt.number(On)},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:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=(o-1)*l+u,g=t.categories.map((y,U)=>({at:U*l,duration:u,piece:O(e,U,s,h)})),p=i?[{at:m,duration:d,piece:O(e,"label",s,h)}]:[];return e.together([c,S(e,[...g,...p])])}}}});import{Graphics2D as Bn,Text as Gn,Types as Be,component2d as Hn,fillOps as kr,shadowOps as vr,strokeOps as Er,textOps as Un}from"@motionscript/sdk";import{fillOps as Fn,lerpNumber as Fe,shadowOps as br,strokeOps as wr,textOps as Sr}from"@motionscript/sdk";function Ie(e,t,r){let n=0;return t.map(o=>{let i=A(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 ht(e,t){let r=-1;for(let n=0;n<t.length;n++)A(e,t[n].field)!==0&&(r=n);return r}function pt(e,t){return e.map(r=>W(r,t))}function Ar(e,t,r){let n=0,o=0;for(let i of e)for(let s of Ie(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 ft(e,t,r,n,o){if(n)return n;let[i,s]=Ar(e,t,r),a=Math.max(1,Math.round(o)),c=ue((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var M={seriesFills:xe,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...T,labelStyle:{...T.labelStyle,fontWeight:600},tickPadding:16},yAxis:ge,plotArea:me,legend:L,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:v.markerColor},spotlight:{dimOpacity:E}};function In(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:wr.resolve(e?.stroke??t.stroke),shadow:br.resolve(e?.shadow??t.shadow)}}function Dn(e,t,r){return{cornerRadius:Fe(e.cornerRadius,t.cornerRadius,r),slotFill:Fe(e.slotFill,t.slotFill,r),groupGap:Fe(e.groupGap,t.groupGap,r),stroke:wr.lerp(e.stroke,t.stroke,r),shadow:br.lerp(e.shadow,t.shadow,r)}}function gt(e,t){let r=t??M;return{seriesFills:we(e?.seriesFills,r.seriesFills),bar:In(e?.bar,r.bar),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),valueStyle:Sr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function mt(e,t,r){return{seriesFills:Se(e.seriesFills,t.seriesFills,r),bar:Dn(e.bar,t.bar,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),valueStyle:Sr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:Fe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function De(e,t,r){return t.fill!=null?Fn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var Nn=10,Xn=1.6,zn=24;function Rr(e,t){return e.enabled?x(e.dims[t]??1):0}function xt(e,t){let r=e.bars[t];if(!r)return null;let n=x(e.growth);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function Tr(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:zn}function Lr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function Vn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Lr(e,t)){let n=xt(e,t);if(!n||Math.abs(n.end-n.base)<Tr(e)*Xn)return""}return r.caption??F(r.value)}function Yn(e,t){let r=xt(e,t);if(!r)return 0;if(Lr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(Nn+Tr(e)/2)}var Ge=Hn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:Be.custom([],{resolve:kr.resolve,lerp:kr.lerp}),barStroke:Be.custom(M.bar.stroke,{resolve:Er.resolve,lerp:Er.lerp}),barShadow:Be.custom(M.bar.shadow,{resolve:vr.resolve,lerp:vr.lerp}),cornerRadius:M.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:Be.custom(M.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Gn({...Un.styleProps(e.valueStyle),text:()=>Vn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Yn(e,r),opacity:()=>Rr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=b(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=xt(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 Bn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Rr(t,r)))}e.children()}});var yt=_.custom(0,{kind:"series",min:0,step:1}),Kn=20,Cr=5,qn=.35,Zn=.5,Jn=.15;function Qn(e,t){let r=(t.ticks?.length??Cr)-1,n=ft(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??C(n,Cr-1)}}function St(e){return ce(e.valueAxis,t=>Qn(e,t))}function Pr(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ae(t.ticks)):jn(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 eo(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function de(e,t){return Math.max(0,e.weights[t]??1)}function to(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*de(e,o))}),r}function ro(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*x(e.theme.bar.slotFill),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=de(e,p);let h=l/(d>0?d:1),m=de(e,t),g=0;for(let p=0;p<t;p++)g+=de(e,p);return e.data.map((p,y)=>{let k=Ie(e.stacked?to(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},We=e.stacked?ht(p,e.series):t,Qr=c(y)-l/2,en=e.stacked?c(y):Qr+h*g+h*m/2,tn=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=A(p,o.field);return{x:en,width:tn,from:bt(i,r,k.from),to:bt(i,r,k.to),round:We===t,value:Dt,...n&&{caption:Pr(e,i,Dt)}}})}function Mr(e){let t=x(e.spotlightReveal),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=Ee(e);if(!t)return null;let r=t.below.find(Oe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ge.is),legend:t.below.find(Z.is)??null}}function _r(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)=>de(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=$n({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:_.custom({},{resolve:Y,lerp:le}),categoryAxis:_.custom({},{resolve:Y,lerp:ae}),theme:_.custom(M,{resolve:gt,lerp:mt}),growth:1,weights:f(()=>[]),spotlight:_.custom(null),spotlightReveal:0,showLegend:_.boolean(!0,{animatable:!1}),showValues:_.boolean(!1,{animatable:!1}),showing:_.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)},children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Re(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Pr(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Oe({categories:pt(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Mr(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ge({bars:()=>ro(e,h,o(),i),baseline:()=>eo(r(),o()),fill:()=>De(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Mr(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>De(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Wn({clip:!0,children:[new Le({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 Te({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[...e.children,ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*qn,s=o*Zn,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return S(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-Kn}))]:[],{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*Jn,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>_r(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>_r(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:yt},easing:ee(),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:_.number(0,{min:0,step:1})},easing:ee(),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:ee(),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 Jr,Types as se,component2d as Co,easeOut as oe}from"@motionscript/sdk";import{Flow as kt,Paint as he,Rect as vt,Shapes as Or,Text as no,Types as oo,component2d as so,textOps as io}from"@motionscript/sdk";var Fr=16,He=so({key:"pieLegend",state:{...he.state,...kt.state,...Or.corners,slices:f(()=>[]),legend:oo.custom(L),dims:f(()=>[]),arrivals:V()},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:()=>x(e.dims[n]??1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>w(e.arrivals,n).opacity,x:()=>w(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}),no({...io.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...he.commands,arm:(e,t)=>e.animate(()=>({arrivals:N([...t.slices.keys()],{opacity:0,shift:Fr})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Fr},o=e.animate(()=>({arrivals:N([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=b(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:O(e,u,n,a)}));return e.together([o,S(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,he.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,he.inset(t)),render:(e,t)=>he.draw(e,t,Or.rect(e.size,t))});import{Graphics2D as Br,PathBuilder as go,Rect as Mt,Text as re,Types as fe,component2d as mo,fillOps as Gr,shadowOps as xo,strokeOps as Hr,textOps as ne}from"@motionscript/sdk";import{lerpNumber as pe,shadowOps as Ir,strokeOps as Ue,textOps as R}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:W(o,t),value:A(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var ao=Math.PI/180;function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Dr(e){let t=0;for(let r of e)t+=Tt(r);return t}function te(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ne(e,t){let r=Dr(e);if(r<=0)return[];let n=[],o=t*ao;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 Xe(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:v.markerColor},P={sliceFills:xe,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:v.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:v.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:v.markerColor}},legend:L,spotlight:{dimOpacity:E}};function lo(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:Ue.resolve(e?.stroke??t.stroke),shadow:Ir.resolve(e?.shadow??t.shadow)}}function co(e,t,r){return{gap:pe(e.gap,t.gap,r),holeRadius:pe(e.holeRadius,t.holeRadius,r),startAngle:pe(e.startAngle,t.startAngle,r),selectedGrow:pe(e.selectedGrow,t.selectedGrow,r),stroke:Ue.lerp(e.stroke,t.stroke,r),shadow:Ir.lerp(e.shadow,t.shadow,r)}}function uo(e,t){return{textStyle:R.resolveStyle(e?.textStyle,t.textStyle),percentStyle:R.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:R.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:Ue.resolve(e?.leaderStroke??t.leaderStroke)}}function ho(e,t,r){return{textStyle:R.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:R.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:R.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:Ue.lerp(e.leaderStroke,t.leaderStroke,r)}}function po(e,t){return{labelStyle:R.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:R.resolveStyle(e?.captionStyle,t.captionStyle)}}function fo(e,t,r){return{labelStyle:R.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:R.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??P;return{sliceFills:we(e?.sliceFills,r.sliceFills),ring:lo(e?.ring,r.ring),label:uo(e?.label,r.label),center:po(e?.center,r.center),legend:K(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Ct(e,t,r){return{sliceFills:Se(e.sliceFills,t.sliceFills,r),ring:co(e.ring,t.ring,r),label:ho(e.label,t.label,r),center:fo(e.center,t.center,r),legend:q(e.legend,t.legend,r),spotlight:{dimOpacity:pe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var Ur=12,yo=14,_t=.62,bo=6,Nr=34,Xr=26,zr=8,wo=.18,So=240,Ao=8,Vr=2,jr=.44,Pt=.62,ko=.78,vo=.9,Yr=.001,Kr=26;function H(e,t=Kr){let r=e.fontSize;return typeof r=="number"?r:t}function Eo(e,t,r,n,o,i){let s=new go,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*So)),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,y=te(d,g+(p-g)*h/c);return{x:y.x+i,y:y.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 ze=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ne(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>Yr?o/s:1/0,l=a>Yr?(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"?$e(t.fraction).length:0,i=r==="category"?n:r==="both"?n*jr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,Kr*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*vo/(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*ko/(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:Vr,right:Vr};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Nr+Xr+zr+this.captionGlyphs(n.index)*r+yo,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+Nr}popOf(t){return x(this.s.pops[t]??0)}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=te(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){let r=this.selectionStrength;return r<=0?1:1-(1-x(this.s.dimOpacity))*r*(1-this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return $e(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=te(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return Xe(a,n+Ur,o,i),Xe(c,n+Ur,o,i),[...a,...c].map(l=>{let u=te(this.anchorRadius(l.index)+bo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*wo),m=s+l.side*(r+Xr);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*zr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var Ro={width:0,height:0},Wr=new WeakMap;function To(e){if(typeof e!="object"||e===null)return Gr.resolve(e);let t=Wr.get(e);return t===void 0&&Wr.set(e,t=Gr.resolve(e)),t}function $r(e){return e.map(t=>To(t.fill))}function Lo(e){let t=[],r=()=>new ze(e,t[0]?.parent?.layoutBounds??Ro),n=o=>{let i=()=>x(e.labelReveal)*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 re({...ne.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*jr})),new Mt({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 re({...ne.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new re({...ne.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Mt({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 Ne(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new re({...ne.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new re({...ne.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Mt({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>x(e.centerReveal),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var Ve=mo({key:"pieRing",state:{slices:f(()=>[]),ring:fe.custom(P.ring),label:fe.custom(P.label),centerStyle:fe.custom(P.center),labelMode:fe.custom("percent"),labelPlacement:fe.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:P.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Lo(e),load:(e,t)=>D(e,{fills:$r(t.slices),shadows:[xo.resolve(t.ring.shadow)],strokes:[Hr.resolve(t.ring.stroke),Hr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=b(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=b(e),n=x(t.centerReveal);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new ze(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=x(t.growth),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=$r(t.slices);for(let p of o){let y=Math.min(p.a1,s);if(y<=p.a0)continue;let U=Eo(p.a0,y,a,r.anchorRadius(p.index),c,l),k=new Br().path(U.toPathState({centerBounds:d,width:h,height:h}));k.shadow(t.ring.shadow),k.fill(m[p.index]??[]),k.stroke(t.ring.stroke),e.draw(k.opacity(r.sliceOpacity(p.index)))}let g=x(t.labelReveal);if(g>.001)for(let p of r.placements())e.draw(new Br().line({points:p.leader,radius:Ao}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Mo=.65,_o=.35,Ft=se.number(0,{min:0,step:1});function qr(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ie(e,t){return x(e.pops[t]??0)}function Po(e,t){return ie(e,t)>.5}function Oo(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ie(e,n));let r=e.theme.spotlight.dimOpacity;return t<=0?e.data.map(()=>1):e.data.map((n,o)=>1-(1-x(r))*t*(1-ie(e,o)))}function Ye(e,t,r){let n=t.data.map((i,s)=>ie(t,s)),o=t.data.map((i,s)=>x(r(s)));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 Zr(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=Jr.is(r)?r.children.find(Ve.is):void 0;if(n)return{ring:n,legend:r.children.find(He.is)??null}}return null}var It=Co({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:se.custom(P,{resolve:Lt,lerp:Ct}),labelMode:se.custom("percent"),labelPlacement:se.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:se.boolean(!0,{animatable:!1}),showCenter:se.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>qr(e).map(()=>0)},children:e=>{let t=()=>e.theme,r=()=>qr(e),n=[new Ve({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 He({slices:r,legend:()=>t().legend,dims:()=>Oo(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new Jr({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[...e.children,o]},commands:{enter:{args:{},easing:oe(),run:(e,t,r)=>{let n=Zr(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Mo,a=e.duration*_o,c=l=>({at:0,duration:0,piece:l});return S(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:oe(),run:(e,t,r)=>Zr(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return Ye(e,t,n=>n===r?1:ie(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return Ye(e,t,n=>n===r?0:ie(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return Ye(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:oe(),run:(e,t)=>Ye(e,t,()=>0)}}});var Fo=[ct,At,It];export{At as BarChart,v as CHART_PALETTE,Oe as CategoryAxis,Ge as ChartBars,Te as ChartBorder,Le as ChartCanvas,Z as ChartLegend,Ce as ChartLine,rt as ChartRegion,M as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,L as DEFAULT_LEGEND,P as DEFAULT_PIE_CHART_THEME,me as DEFAULT_PLOT_AREA,Bo as DEFAULT_SERIES_COLORS,xe as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,T as DEFAULT_X_AXIS,ge as DEFAULT_Y_AXIS,J as EMPTY_REGION_BOX,Me as HorizontalAxis,Io as LANDED,ct as LineChart,Fo as NODES,It as PieChart,He as PieLegend,Ve as PieRing,E as SPOTLIGHT_DIM,Uo as TOP_HEADROOM,I as VerticalAxis,N as armed,O as arrival,w as arrivalOf,V as arrivalsEntry,z as asParts,Do as axisTweenTarget,pt as barCategories,St as barChartDomain,Ie as barSpans,Ar as barValueExtent,S as beats,ve as cartesianFrame,Ee as cartesianViews,x as clampUnit,Ke as clipPolylineToBox,ke as enterBudget,ar as formatInstant,F as formatMarker,$e as formatPercent,b as frameEase,f as fresh,Q as hasRegion,Po as isSliceSelected,Re as laidOutSize,No as legendShows,j as lerpAxisConfig,ae as lerpAxisDomain,le as lerpAxisEntry,mt as lerpBarChartTheme,Ze as lerpChartTheme,q as lerpLegendConfig,Ct as lerpPieChartTheme,be as lerpPlotArea,Se as lerpSeriesFills,Ht as lerpSeriesStrokes,Pe as lineChartDomains,D as loadPaints,Xt as markerCaption,Ae as markerStep,C as markerValues,ue as niceStep,A as num,Go as numericFields,ir as parseInstant,Ne as pieArcs,Xe as relaxLabels,$ as resolveAxisConfig,Y as resolveAxisDomain,gt as resolveBarChartTheme,De as resolveBarFill,ft as resolveBarScale,qe as resolveChartTheme,K as resolveLegendConfig,Ho as resolvePalettePaint,Lt as resolvePieChartTheme,Rt as resolvePieSlices,ye as resolvePlotArea,je as resolveRegionBox,Nt as resolveSeriesFill,we as resolveSeriesFills,Ut as resolveSeriesStroke,Gt as resolveSeriesStrokes,ot as resolveXScale,Qe as resolveYScale,te as ringPoint,Je as seriesPoints,ce as settleAxisDomain,Dr as sliceTotal,Tt as sliceValue,ht as stackCapIndex,W as text,Yt as yExtent};
1
+ import{$ as Te,A as xe,B as $,C as j,D as ye,E as be,F as K,G as q,H as Gt,I as Ht,J as we,K as Se,L as Ut,M as Nt,N as Vo,O as F,P as Ae,Q as $e,R as L,S as ue,T as ke,U as Xt,V as I,W as Wo,X as ve,Y as Ee,Z as Re,_ as D,a as f,aa as Le,b as z,ba as Z,c as b,ca as Yo,d as S,e as Uo,f as V,g as w,h as N,i as P,j as W,k as ae,l as No,m as le,n as ce,o as v,p as Xo,q as O,r as x,s as A,t as Y,u as zo,v as R,w as ge,x as me,y as T,z as Bt}from"./chunks/chunk-XROBIRQK.js";import{Rect as En,Types as G,component2d as Rn,easeOut as B}from"@motionscript/sdk";import{formatNumber as Tn}from"@motionscript/sdk/component";import{Graphics2D as et,Types as tt,component2d as fn,strokeOps as Yt}from"@motionscript/sdk";import{Fills as sn,fillOps as zt,lerpNumber as an,strokeOps as Vt}from"@motionscript/sdk";var J={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function Q(e){return e.right>e.left&&e.top>e.bottom}function je(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return J;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let y=Math.min(d[0],d[1]),U=Math.max(d[0],d[1]),k=Ye=>g+(Ye-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,k(y))),Math.max(g,Math.min(p,k(U))),!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 Ke(e,t){if(e.length<2||!Q(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=cn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&ln(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 ln(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function cn(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 un={...T,markerStyle:{...T.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:R,yAxis:ge,plotArea:me,legend:un,region:{stroke:{weight:3,fill:v.regionColor,dash:[14,12],cap:"butt"},fill:sn.color(v.regionColor,{opacity:.08}),dimOpacity:O}};function dn(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:zt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function hn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:zt.lerp(e.fill,t.fill,r),dimOpacity:an(e.dimOpacity,t.dimOpacity,r)}}function qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),region:dn(e?.region,r.region)}}function Ze(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),region:hn(e.region,t.region,r)}}function Je(e,t,r){return e.map((n,o)=>[t.at(o),A(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Wt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=A(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function Qe(e,t,r,n){if(r)return r;let[o,i]=Wt(e,t),s=Math.max(1,Math.round(n));if(i===o)return pn(o,s);let a=ue((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function pn(e,t){if(e===0)return[0,1];let r=ue(Math.abs(e)/t);return[e-r,e+r]}function gn(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 Me=fn({key:"chartLine",state:{points:f(()=>[]),stroke:tt.custom([],{resolve:Yt.resolve,lerp:Yt.lerp}),progress:1,enabled:!0,spotlight:f(()=>J),dimOpacity:O},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:tt.number(0,{min:0,max:1}),to:tt.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=b(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=gn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!Q(a)){e.draw(new et().line({points:o,radius:s}).stroke(i));return}e.draw(new et().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Ke(o,a))e.draw(new et().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as $t,Types as jt,component2d as mn,fillOps as Kt,strokeOps as qt}from"@motionscript/sdk";var rt=mn({key:"chartRegion",state:{box:f(()=>J),stroke:jt.custom(X.region.stroke,{resolve:qt.resolve,lerp:qt.lerp}),fill:jt.custom(X.region.fill,{resolve:Kt.resolve,lerp:Kt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!Q(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 $t().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 $t().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 Zt,Text as Jt,Types as nt,component2d as xn,insetsOps as Qt,textOps as er}from"@motionscript/sdk";var yn=24,Ce=xn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:nt.custom(R),label:"",arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=Qt.resolve(e.axis.tickPadding).top,r=Qt.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 Jt({...er.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":Xt(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:()=>w(e.arrivals,u).opacity,y:()=>w(e.arrivals,u).shift});return d}),c=[new Zt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Jt({...er.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new Zt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:nt.custom(void 0),slide:nt.number(yn)},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:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=t.markers.map((p,y)=>({at:y*l,duration:u,piece:P(e,y,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,S(e,[...m,...g])])}}}});import{formatNumber as bn}from"@motionscript/sdk/component";var _e=864e5,ir=["january","february","march","april","may","june","july","august","september","october","november","december"],tr=2024;function rr(e){return e.length<3?-1:ir.findIndex(t=>t.startsWith(e))}function wn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*_e+(t-1)*7*_e}function ar(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:wn(n[1]===void 0?tr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=rr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?tr: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=rr(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 lr(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=ir[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*_e?String(n):t>60*_e?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function Sn(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 An(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=ar(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 nr(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 or(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 L([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 L([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function kn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}var sr=new WeakMap;function ot(e,t,r){let n=sr.get(e);n||sr.set(e,n=new Map);let o=JSON.stringify([t,r??null]),i=n.get(o);return i||n.set(o,i=vn(e,t,r)),i}function vn(e,t,r){if(t!==""&&Sn(e,t)){let s=e.map(a=>A(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:nr(s),label:a=>r===void 0?F(a):bn(a,r),ticks:L}}let n=e.map(s=>Y(s,t)),o=t===""?null:An(e,t);if(o){let s=nr(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>kn(o,n,c,l=>lr(l,a)),ticks:(c,l)=>or(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)=>or(i,s,a)}}var st=G.custom(0,{kind:"series",min:0,step:1}),cr=G.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),Ln=20,it=5,Mn=.35,Cn=.5,_n=.15;function lt(e,t=e.xAxis.format){return ot(e.data,e.xField,t)}function Pn(e,t){let r=lt(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,it-1)}}function On(e,t){let r=(t.ticks?.length??it)-1,n=Qe(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??L(n,it-1)}}var ur=new WeakMap;function Pe(e){let{data:t,xField:r,xAxis:n,yAxis:o,series:i}=e,s=ur.get(t);if(s&&s.xField===r&&s.xAxis===n&&s.yAxis===o&&s.series===i)return s.domains;let a={x:ce(n,c=>Pn(e,c)),y:ce(o,c=>On(e,c))};return ur.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=Je(e.data,lt(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 dr(e,t,r){let{width:n,height:o}=r;return je(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function hr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function pr(e){return e!=null&&typeof e=="object"?e:{}}function In([e,t]){return e<=t?[e,t]:[t,e]}function fr(e,t){let r=In(e);return{range:r,ticks:L(r,Math.max(2,t.length)-1)}}function gr(e,t,r){return{...t.x&&{xAxis:ae(e.x,t.x,r)},...t.y&&{yAxis:ae(e.y,t.y,r)}}}function at(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Ce.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(Me.is),legend:t.below.find(Z.is)??null}}function mr(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 xr(e,t,r,n){let o=at(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 ct=Rn({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:G.custom({},{resolve:W,lerp:le}),yAxis:G.custom({},{resolve:W,lerp:le}),theme:G.custom(X,{resolve:qe,lerp:Ze}),region:G.custom(null),regionReveal:0,showLegend:G.boolean(!0,{animatable:!1}),home:G.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Pe(e),n,o=()=>Re(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,Ae(d)):Tn(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Ce({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=lt(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 Me({points:()=>Fn(e,r(),h,o()),stroke:()=>Ut(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>dr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>Nt(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new En({clip:!0,children:[new Le({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 rt({box:()=>dr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Te({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[ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.duration,i=hr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*Mn,c=s*Cn,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return S(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-Ln}))]:[],{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*_n,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:cr},easing:B(),run:(e,t)=>{let r=pr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?mr(e,t):n<=0||!hr(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)=>mr(e,t)},zoomTo:{args:{region:cr},easing:B(),run:(e,t)=>{let r=pr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Pe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...fr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...fr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...gr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Pe(t);return e.animate(o=>({home:null,...gr(n,r,o)}))}},showSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>xr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>xr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>{let n=at(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 C,component2d as Zn,easeOut as ee}from"@motionscript/sdk";import{formatNumber as Jn}from"@motionscript/sdk/component";import{Rect as ut,Text as yr,Types as dt,component2d as Dn,insetsOps as br,textOps as wr}from"@motionscript/sdk";var Bn=24,Oe=Dn({key:"categoryAxis",state:{categories:f(()=>[]),axis:dt.custom(R),label:"",dims:f(()=>[]),arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=br.resolve(e.axis.tickPadding).top,r=br.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 ut({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[l]??1),x:()=>i(l),children:[new yr({...wr.styleProps(e.axis.labelStyle),text:c,opacity:()=>w(e.arrivals,l).opacity,y:()=>w(e.arrivals,l).shift})]})),a=[new ut({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new yr({...wr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new ut({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:dt.custom(void 0),slide:dt.number(Bn)},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:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=(o-1)*l+u,g=t.categories.map((y,U)=>({at:U*l,duration:u,piece:P(e,U,s,h)})),p=i?[{at:m,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,S(e,[...g,...p])])}}}});import{Graphics2D as Nn,Text as Xn,Types as Be,component2d as zn,fillOps as Er,shadowOps as Rr,strokeOps as Tr,textOps as Vn}from"@motionscript/sdk";import{fillOps as Gn,lerpNumber as Fe,shadowOps as Sr,strokeOps as Ar,textOps as kr}from"@motionscript/sdk";function Ie(e,t,r){let n=0;return t.map(o=>{let i=A(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 ht(e,t){let r=-1;for(let n=0;n<t.length;n++)A(e,t[n].field)!==0&&(r=n);return r}function pt(e,t){return e.map(r=>Y(r,t))}function vr(e,t,r){let n=0,o=0;for(let i of e)for(let s of Ie(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 ft(e,t,r,n,o){if(n)return n;let[i,s]=vr(e,t,r),a=Math.max(1,Math.round(o)),c=ue((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var M={seriesFills:xe,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...R,labelStyle:{...R.labelStyle,fontWeight:600},tickPadding:16},yAxis:ge,plotArea:me,legend:T,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:v.markerColor},spotlight:{dimOpacity:O}};function Hn(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:Ar.resolve(e?.stroke??t.stroke),shadow:Sr.resolve(e?.shadow??t.shadow)}}function Un(e,t,r){return{cornerRadius:Fe(e.cornerRadius,t.cornerRadius,r),slotFill:Fe(e.slotFill,t.slotFill,r),groupGap:Fe(e.groupGap,t.groupGap,r),stroke:Ar.lerp(e.stroke,t.stroke,r),shadow:Sr.lerp(e.shadow,t.shadow,r)}}function gt(e,t){let r=t??M;return{seriesFills:we(e?.seriesFills,r.seriesFills),bar:Hn(e?.bar,r.bar),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),valueStyle:kr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function mt(e,t,r){return{seriesFills:Se(e.seriesFills,t.seriesFills,r),bar:Un(e.bar,t.bar,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),valueStyle:kr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:Fe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function De(e,t,r){return t.fill!=null?Gn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var Wn=10,Yn=1.6,$n=24;function Lr(e,t){return e.enabled?x(e.dims[t]??1):0}function xt(e,t){let r=e.bars[t];if(!r)return null;let n=x(e.growth);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function Mr(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:$n}function Cr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function jn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Cr(e,t)){let n=xt(e,t);if(!n||Math.abs(n.end-n.base)<Mr(e)*Yn)return""}return r.caption??F(r.value)}function Kn(e,t){let r=xt(e,t);if(!r)return 0;if(Cr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(Wn+Mr(e)/2)}var Ge=zn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:Be.custom([],{resolve:Er.resolve,lerp:Er.lerp}),barStroke:Be.custom(M.bar.stroke,{resolve:Tr.resolve,lerp:Tr.lerp}),barShadow:Be.custom(M.bar.shadow,{resolve:Rr.resolve,lerp:Rr.lerp}),cornerRadius:M.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:Be.custom(M.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Xn({...Vn.styleProps(e.valueStyle),text:()=>jn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Kn(e,r),opacity:()=>Lr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=b(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=xt(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 Nn,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(Lr(t,r)))}e.children()}});var yt=C.custom(0,{kind:"series",min:0,step:1}),Qn=20,_r=5,eo=.35,to=.5,ro=.15;function no(e,t){let r=(t.ticks?.length??_r)-1,n=ft(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??L(n,_r-1)}}var Pr=new WeakMap;function St(e){let{data:t,series:r,stacked:n,valueAxis:o}=e,i=Pr.get(t);if(i&&i.series===r&&i.stacked===n&&i.valueAxis===o)return i.domain;let s=ce(o,a=>no(e,a));return Pr.set(t,{series:r,stacked:n,valueAxis:o,domain:s}),s}function Ir(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ae(t.ticks)):Jn(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 oo(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function de(e,t){return Math.max(0,e.weights[t]??1)}function so(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*de(e,o))}),r}function io(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*x(e.theme.bar.slotFill),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=de(e,p);let h=l/(d>0?d:1),m=de(e,t),g=0;for(let p=0;p<t;p++)g+=de(e,p);return e.data.map((p,y)=>{let k=Ie(e.stacked?so(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},Ye=e.stacked?ht(p,e.series):t,rn=c(y)-l/2,nn=e.stacked?c(y):rn+h*g+h*m/2,on=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=A(p,o.field);return{x:nn,width:on,from:bt(i,r,k.from),to:bt(i,r,k.to),round:Ye===t,value:Dt,...n&&{caption:Ir(e,i,Dt)}}})}function Or(e){let t=x(e.spotlightReveal),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=Ee(e);if(!t)return null;let r=t.below.find(Oe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ge.is),legend:t.below.find(Z.is)??null}}function Fr(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)=>de(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=Zn({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:C.custom({},{resolve:W,lerp:le}),categoryAxis:C.custom({},{resolve:W,lerp:ae}),theme:C.custom(M,{resolve:gt,lerp:mt}),growth:1,weights:f(()=>[]),spotlight:C.custom(null),spotlightReveal:0,showLegend:C.boolean(!0,{animatable:!1}),showValues:C.boolean(!1,{animatable:!1}),showing:C.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=()=>Re(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Ir(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Oe({categories:pt(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Or(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ge({bars:()=>io(e,h,o(),i),baseline:()=>oo(r(),o()),fill:()=>De(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Or(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>De(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new qn({clip:!0,children:[new Le({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 Te({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[ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*eo,s=o*to,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return S(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-Qn}))]:[],{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*ro,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>Fr(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>Fr(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:yt},easing:ee(),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:C.number(0,{min:0,step:1})},easing:ee(),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:ee(),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 tn,Types as se,component2d as Fo,easeOut as oe}from"@motionscript/sdk";import{Flow as kt,Paint as he,Rect as vt,Shapes as Dr,Text as ao,Types as lo,component2d as co,textOps as uo}from"@motionscript/sdk";var Br=16,He=co({key:"pieLegend",state:{...he.state,...kt.state,...Dr.corners,slices:f(()=>[]),legend:lo.custom(T),dims:f(()=>[]),arrivals:V()},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:()=>x(e.dims[n]??1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>w(e.arrivals,n).opacity,x:()=>w(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}),ao({...uo.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...he.commands,arm:(e,t)=>e.animate(()=>({arrivals:N([...t.slices.keys()],{opacity:0,shift:Br})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Br},o=e.animate(()=>({arrivals:N([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=b(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:P(e,u,n,a)}));return e.together([o,S(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,he.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,he.inset(t)),render:(e,t)=>he.draw(e,t,Dr.rect(e.size,t))});import{Graphics2D as Ur,PathBuilder as wo,Rect as Ct,Text as re,Types as fe,component2d as So,fillOps as Nr,shadowOps as Ao,strokeOps as Xr,textOps as ne}from"@motionscript/sdk";import{lerpNumber as pe,shadowOps as Gr,strokeOps as Ue,textOps as E}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:Y(o,t),value:A(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var ho=Math.PI/180;function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Hr(e){let t=0;for(let r of e)t+=Tt(r);return t}function te(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ne(e,t){let r=Hr(e);if(r<=0)return[];let n=[],o=t*ho;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 Xe(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:v.markerColor},po=.1,_={sliceFills:xe,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:v.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:v.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:v.markerColor}},legend:T,spotlight:{dimOpacity:po}};function fo(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:Ue.resolve(e?.stroke??t.stroke),shadow:Gr.resolve(e?.shadow??t.shadow)}}function go(e,t,r){return{gap:pe(e.gap,t.gap,r),holeRadius:pe(e.holeRadius,t.holeRadius,r),startAngle:pe(e.startAngle,t.startAngle,r),selectedGrow:pe(e.selectedGrow,t.selectedGrow,r),stroke:Ue.lerp(e.stroke,t.stroke,r),shadow:Gr.lerp(e.shadow,t.shadow,r)}}function mo(e,t){return{textStyle:E.resolveStyle(e?.textStyle,t.textStyle),percentStyle:E.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:E.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:Ue.resolve(e?.leaderStroke??t.leaderStroke)}}function xo(e,t,r){return{textStyle:E.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:E.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:E.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:Ue.lerp(e.leaderStroke,t.leaderStroke,r)}}function yo(e,t){return{labelStyle:E.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:E.resolveStyle(e?.captionStyle,t.captionStyle)}}function bo(e,t,r){return{labelStyle:E.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:E.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??_;return{sliceFills:we(e?.sliceFills,r.sliceFills),ring:fo(e?.ring,r.ring),label:mo(e?.label,r.label),center:yo(e?.center,r.center),legend:K(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Mt(e,t,r){return{sliceFills:Se(e.sliceFills,t.sliceFills,r),ring:go(e.ring,t.ring,r),label:xo(e.label,t.label,r),center:bo(e.center,t.center,r),legend:q(e.legend,t.legend,r),spotlight:{dimOpacity:pe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var zr=12,ko=14,_t=.62,vo=6,Vr=34,Wr=26,Yr=8,Eo=.18,Ro=240,To=8,$r=2,Zr=.44,Pt=.62,Lo=.78,Mo=.9,jr=.001,Jr=26;function H(e,t=Jr){let r=e.fontSize;return typeof r=="number"?r:t}function Co(e,t,r,n,o,i){let s=new wo,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*Ro)),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,y=te(d,g+(p-g)*h/c);return{x:y.x+i,y:y.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 ze=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ne(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>jr?o/s:1/0,l=a>jr?(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"?$e(t.fraction).length:0,i=r==="category"?n:r==="both"?n*Zr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,Jr*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*Mo/(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*Lo/(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:$r,right:$r};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Vr+Wr+Yr+this.captionGlyphs(n.index)*r+ko,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+Vr}popOf(t){return x(this.s.pops[t]??0)}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=te(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){let r=this.selectionStrength;return r<=0?1:1-(1-x(this.s.dimOpacity))*r*(1-this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return $e(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=te(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return Xe(a,n+zr,o,i),Xe(c,n+zr,o,i),[...a,...c].map(l=>{let u=te(this.anchorRadius(l.index)+vo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*Eo),m=s+l.side*(r+Wr);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*Yr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var _o={width:0,height:0},Kr=new WeakMap;function Po(e){if(typeof e!="object"||e===null)return Nr.resolve(e);let t=Kr.get(e);return t===void 0&&Kr.set(e,t=Nr.resolve(e)),t}function qr(e){return e.map(t=>Po(t.fill))}function Oo(e){let t=[],r=()=>new ze(e,t[0]?.parent?.layoutBounds??_o),n=o=>{let i=()=>x(e.labelReveal)*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 re({...ne.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*Zr})),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 re({...ne.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new re({...ne.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 Ne(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new re({...ne.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new re({...ne.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:()=>x(e.centerReveal),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var Ve=So({key:"pieRing",state:{slices:f(()=>[]),ring:fe.custom(_.ring),label:fe.custom(_.label),centerStyle:fe.custom(_.center),labelMode:fe.custom("percent"),labelPlacement:fe.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:_.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Oo(e),load:(e,t)=>D(e,{fills:qr(t.slices),shadows:[Ao.resolve(t.ring.shadow)],strokes:[Xr.resolve(t.ring.stroke),Xr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=b(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=b(e),n=x(t.centerReveal);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new ze(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=x(t.growth),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=qr(t.slices);for(let p of o){let y=Math.min(p.a1,s);if(y<=p.a0)continue;let U=Co(p.a0,y,a,r.anchorRadius(p.index),c,l),k=new Ur().path(U.toPathState({centerBounds:d,width:h,height:h}));k.shadow(t.ring.shadow),k.fill(m[p.index]??[]),k.stroke(t.ring.stroke),e.draw(k.opacity(r.sliceOpacity(p.index)))}let g=x(t.labelReveal);if(g>.001)for(let p of r.placements())e.draw(new Ur().line({points:p.leader,radius:To}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Io=.65,Do=.35,Ft=se.number(0,{min:0,step:1});function Qr(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ie(e,t){return x(e.pops[t]??0)}function Bo(e,t){return ie(e,t)>.5}function Go(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ie(e,n));let r=e.theme.spotlight.dimOpacity;return t<=0?e.data.map(()=>1):e.data.map((n,o)=>1-(1-x(r))*t*(1-ie(e,o)))}function We(e,t,r){let n=t.data.map((i,s)=>ie(t,s)),o=t.data.map((i,s)=>x(r(s)));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 en(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=tn.is(r)?r.children.find(Ve.is):void 0;if(n)return{ring:n,legend:r.children.find(He.is)??null}}return null}var It=Fo({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:se.custom(_,{resolve:Lt,lerp:Mt}),labelMode:se.custom("percent"),labelPlacement:se.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:se.boolean(!0,{animatable:!1}),showCenter:se.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>Qr(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Qr(e),n=[new Ve({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 He({slices:r,legend:()=>t().legend,dims:()=>Go(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new tn({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[o]},commands:{enter:{args:{},entrance:!0,easing:oe(),run:(e,t,r)=>{let n=en(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Io,a=e.duration*Do,c=l=>({at:0,duration:0,piece:l});return S(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:oe(),run:(e,t,r)=>en(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?1:ie(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?0:ie(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return We(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:oe(),run:(e,t)=>We(e,t,()=>0)}}});var Ho=[ct,At,It];export{At as BarChart,v as CHART_PALETTE,Oe as CategoryAxis,Ge as ChartBars,Te as ChartBorder,Le as ChartCanvas,Z as ChartLegend,Me as ChartLine,rt as ChartRegion,M as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,T as DEFAULT_LEGEND,_ as DEFAULT_PIE_CHART_THEME,me as DEFAULT_PLOT_AREA,Xo as DEFAULT_SERIES_COLORS,xe as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,R as DEFAULT_X_AXIS,ge as DEFAULT_Y_AXIS,J as EMPTY_REGION_BOX,Ce as HorizontalAxis,Uo as LANDED,ct as LineChart,Ho as NODES,It as PieChart,He as PieLegend,Ve as PieRing,O as SPOTLIGHT_DIM,Wo as TOP_HEADROOM,I as VerticalAxis,N as armed,P as arrival,w as arrivalOf,V as arrivalsEntry,z as asParts,No as axisTweenTarget,pt as barCategories,St as barChartDomain,Ie as barSpans,vr as barValueExtent,S as beats,ve as cartesianFrame,Ee as cartesianViews,x as clampUnit,Ke as clipPolylineToBox,ke as enterBudget,lr as formatInstant,F as formatMarker,$e as formatPercent,b as frameEase,f as fresh,Q as hasRegion,Bo as isSliceSelected,Re as laidOutSize,Yo as legendShows,j as lerpAxisConfig,ae as lerpAxisDomain,le as lerpAxisEntry,mt as lerpBarChartTheme,Ze as lerpChartTheme,q as lerpLegendConfig,Mt as lerpPieChartTheme,be as lerpPlotArea,Se as lerpSeriesFills,Ht as lerpSeriesStrokes,Pe as lineChartDomains,D as loadPaints,Xt as markerCaption,Ae as markerStep,L as markerValues,ue as niceStep,A as num,zo as numericFields,ar as parseInstant,Ne as pieArcs,Xe as relaxLabels,$ as resolveAxisConfig,W as resolveAxisDomain,gt as resolveBarChartTheme,De as resolveBarFill,ft as resolveBarScale,qe as resolveChartTheme,K as resolveLegendConfig,Vo as resolvePalettePaint,Lt as resolvePieChartTheme,Rt as resolvePieSlices,ye as resolvePlotArea,je as resolveRegionBox,Nt as resolveSeriesFill,we as resolveSeriesFills,Ut as resolveSeriesStroke,Gt as resolveSeriesStrokes,ot as resolveXScale,Qe as resolveYScale,te as ringPoint,Je as seriesPoints,ce as settleAxisDomain,Hr as sliceTotal,Tt as sliceValue,ht as stackCapIndex,Y as text,Wt as yExtent};
2
2
  //# sourceMappingURL=index.js.map