@motionscript/charts 0.1.1-alpha.1 → 0.1.1-alpha.2

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