@motionscript/charts 0.1.0-alpha.3 → 0.1.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +63 -0
- package/LICENSE +201 -201
- package/NOTICE +48 -0
- package/README.md +99 -0
- package/dist/bar-chart/bar-chart.d.ts +93 -231
- package/dist/bar-chart/bar-chart.d.ts.map +1 -1
- package/dist/bar-chart/bar-chart.js +378 -565
- package/dist/bar-chart/bar-chart.js.map +1 -1
- package/dist/bar-chart/category-axis.d.ts +24 -41
- package/dist/bar-chart/category-axis.d.ts.map +1 -1
- package/dist/bar-chart/category-axis.js +93 -115
- package/dist/bar-chart/category-axis.js.map +1 -1
- package/dist/bar-chart/chart-bars.d.ts +36 -70
- package/dist/bar-chart/chart-bars.d.ts.map +1 -1
- package/dist/bar-chart/chart-bars.js +156 -210
- package/dist/bar-chart/chart-bars.js.map +1 -1
- package/dist/bar-chart/index.d.ts +2 -2
- package/dist/bar-chart/index.d.ts.map +1 -1
- package/dist/bar-chart/index.js +1 -1
- package/dist/bar-chart/index.js.map +1 -1
- package/dist/bar-chart/shared.d.ts +6 -6
- package/dist/bar-chart/shared.d.ts.map +1 -1
- package/dist/bar-chart/shared.js +6 -6
- package/dist/bar-chart/shared.js.map +1 -1
- package/dist/browser/chunks/chunk-XROBIRQK.js +2 -0
- package/dist/browser/chunks/chunk-XROBIRQK.js.map +7 -0
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +3 -3
- package/dist/browser/kit.js +1 -1
- package/dist/browser/manifest.json +3 -2
- package/dist/engine.d.ts +8 -6
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +8 -6
- package/dist/engine.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kit/cartesian.d.ts +44 -0
- package/dist/kit/cartesian.d.ts.map +1 -0
- package/dist/kit/cartesian.js +59 -0
- package/dist/kit/cartesian.js.map +1 -0
- package/dist/kit/chart-border.d.ts +8 -11
- package/dist/kit/chart-border.d.ts.map +1 -1
- package/dist/kit/chart-border.js +15 -32
- package/dist/kit/chart-border.js.map +1 -1
- package/dist/kit/chart-canvas.d.ts +23 -21
- package/dist/kit/chart-canvas.d.ts.map +1 -1
- package/dist/kit/chart-canvas.js +33 -90
- package/dist/kit/chart-canvas.js.map +1 -1
- package/dist/kit/chart-legend.d.ts +79 -88
- package/dist/kit/chart-legend.d.ts.map +1 -1
- package/dist/kit/chart-legend.js +137 -186
- package/dist/kit/chart-legend.js.map +1 -1
- package/dist/kit/entries.d.ts +17 -0
- package/dist/kit/entries.d.ts.map +1 -0
- package/dist/kit/entries.js +19 -0
- package/dist/kit/entries.js.map +1 -0
- package/dist/kit/motion.d.ts +48 -0
- package/dist/kit/motion.d.ts.map +1 -0
- package/dist/kit/motion.js +63 -0
- package/dist/kit/motion.js.map +1 -0
- package/dist/kit/paints.d.ts +10 -0
- package/dist/kit/paints.d.ts.map +1 -0
- package/dist/kit/paints.js +12 -0
- package/dist/kit/paints.js.map +1 -0
- package/dist/kit/shared.d.ts +59 -8
- package/dist/kit/shared.d.ts.map +1 -1
- package/dist/kit/shared.js +105 -10
- package/dist/kit/shared.js.map +1 -1
- package/dist/kit/vertical-axis.d.ts +36 -61
- package/dist/kit/vertical-axis.d.ts.map +1 -1
- package/dist/kit/vertical-axis.js +97 -132
- package/dist/kit/vertical-axis.js.map +1 -1
- package/dist/line-chart/chart-line.d.ts +27 -53
- package/dist/line-chart/chart-line.d.ts.map +1 -1
- package/dist/line-chart/chart-line.js +89 -120
- package/dist/line-chart/chart-line.js.map +1 -1
- package/dist/line-chart/chart-region.d.ts +14 -14
- package/dist/line-chart/chart-region.d.ts.map +1 -1
- package/dist/line-chart/chart-region.js +26 -64
- package/dist/line-chart/chart-region.js.map +1 -1
- package/dist/line-chart/horizontal-axis.d.ts +32 -56
- package/dist/line-chart/horizontal-axis.d.ts.map +1 -1
- package/dist/line-chart/horizontal-axis.js +85 -123
- package/dist/line-chart/horizontal-axis.js.map +1 -1
- package/dist/line-chart/index.d.ts +2 -2
- package/dist/line-chart/index.d.ts.map +1 -1
- package/dist/line-chart/index.js +1 -1
- package/dist/line-chart/index.js.map +1 -1
- package/dist/line-chart/line-chart.d.ts +111 -311
- package/dist/line-chart/line-chart.d.ts.map +1 -1
- package/dist/line-chart/line-chart.js +403 -639
- package/dist/line-chart/line-chart.js.map +1 -1
- package/dist/line-chart/shared.d.ts +6 -6
- package/dist/line-chart/shared.d.ts.map +1 -1
- package/dist/line-chart/shared.js +22 -7
- package/dist/line-chart/shared.js.map +1 -1
- package/dist/line-chart/x-scale.d.ts +1 -1
- package/dist/line-chart/x-scale.js +1 -1
- package/dist/line-chart/x-scale.js.map +1 -1
- package/dist/nodes.d.ts +6 -9
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +7 -9
- package/dist/nodes.js.map +1 -1
- package/dist/pie-chart/index.d.ts +2 -2
- package/dist/pie-chart/index.d.ts.map +1 -1
- package/dist/pie-chart/index.js +1 -1
- package/dist/pie-chart/index.js.map +1 -1
- package/dist/pie-chart/pie-chart.d.ts +77 -134
- package/dist/pie-chart/pie-chart.d.ts.map +1 -1
- package/dist/pie-chart/pie-chart.js +199 -268
- package/dist/pie-chart/pie-chart.js.map +1 -1
- package/dist/pie-chart/pie-legend.d.ts +54 -31
- package/dist/pie-chart/pie-legend.d.ts.map +1 -1
- package/dist/pie-chart/pie-legend.js +93 -107
- package/dist/pie-chart/pie-legend.js.map +1 -1
- package/dist/pie-chart/pie-ring.d.ts +142 -122
- package/dist/pie-chart/pie-ring.d.ts.map +1 -1
- package/dist/pie-chart/pie-ring.js +333 -361
- package/dist/pie-chart/pie-ring.js.map +1 -1
- package/dist/pie-chart/shared.d.ts +3 -3
- package/dist/pie-chart/shared.js +3 -3
- package/dist/pie-chart/shared.js.map +1 -1
- package/package.json +6 -5
- package/registry.json +23 -23
- package/src/bar-chart/bar-chart.ts +534 -814
- package/src/bar-chart/category-axis.ts +162 -177
- package/src/bar-chart/chart-bars.ts +288 -310
- package/src/bar-chart/index.ts +31 -31
- package/src/bar-chart/shared.ts +354 -354
- package/src/engine.ts +28 -26
- package/src/index.ts +5 -5
- package/src/kit/cartesian.ts +81 -0
- package/src/kit/chart-border.ts +50 -61
- package/src/kit/chart-canvas.ts +122 -157
- package/src/kit/chart-legend.ts +229 -250
- package/src/kit/entries.ts +20 -0
- package/src/kit/motion.ts +90 -0
- package/src/kit/paints.ts +15 -0
- package/src/kit/shared.ts +782 -675
- package/src/kit/vertical-axis.ts +194 -224
- package/src/line-chart/chart-line.ts +181 -208
- package/src/line-chart/chart-region.ts +106 -135
- package/src/line-chart/horizontal-axis.ts +166 -202
- package/src/line-chart/index.ts +39 -39
- package/src/line-chart/line-chart.ts +585 -929
- package/src/line-chart/shared.ts +473 -459
- package/src/line-chart/x-scale.ts +367 -367
- package/src/nodes.ts +18 -20
- package/src/pie-chart/index.ts +37 -37
- package/src/pie-chart/pie-chart.ts +293 -381
- package/src/pie-chart/pie-legend.ts +169 -159
- package/src/pie-chart/pie-ring.ts +848 -903
- package/src/pie-chart/shared.ts +490 -490
- package/dist/browser/chunks/chunk-RMHQ6GYU.js +0 -2
- package/dist/browser/chunks/chunk-RMHQ6GYU.js.map +0 -7
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{A as Ot,B as Ar,C as F,D as Oe,E as z,F as Pe,G as Fe,H as De,I as Ie,J as Be,K as le,a as te,b as q,c as O,d as br,e as P,f,g as E,h as ie,i as Sr,j as H,k as Te,l as Ee,m as X,n as Mt,o as _e,p as se,q as re,r as Me,s as Le,t as oe,u as ne,v as Lt,w as kt,x as ke,y as Ce,z as Ct}from"./chunks/chunk-RMHQ6GYU.js";import{command as Z,node as Ji,Node2D as Qi,Rect as be,easeOut as $,property as Y}from"@motionscript/sdk";import{Graphics2D as rt,Node2D as Gi,command as Ui,easeOut as It,strokeOps as Bt,property as ce}from"@motionscript/sdk";import{Fills as Oi,fillOps as Pt,lerpNumber as Pi,strokeOps as Ft}from"@motionscript/sdk";var ae={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function he(o){return o.right>o.left&&o.top>o.bottom}function Je(o,e,t,i){if(!o||o.x===void 0&&o.y===void 0)return ae;let r=(c,[p,u],R,C)=>{if(c===void 0||u<=p)return[R,C,!1];let U=Math.min(c[0],c[1]),ki=Math.max(c[0],c[1]),_t=Ci=>R+(Ci-p)/(u-p)*(C-R);return[Math.max(R,Math.min(C,_t(U))),Math.max(R,Math.min(C,_t(ki))),!0]},[s,n,l]=r(o.x,t,e.left,e.right),[a,h,d]=r(o.y,i,e.bottom,e.top);return{left:s,right:n,bottom:a,top:h,xBounded:l,yBounded:d}}function Qe(o,e){if(o.length<2||!he(e))return[];let t=[],i=[];for(let r=1;r<o.length;r++){let s=Di(o[r-1],o[r],e);if(!s){i.length>=2&&t.push(i),i=[];continue}let[n,l]=s;i.length>0&&Fi(i[i.length-1],n)?i.push(l):(i.length>=2&&t.push(i),i=[n,l])}return i.length>=2&&t.push(i),t}function Fi(o,e){return Math.abs(o.x-e.x)<.5&&Math.abs(o.y-e.y)<.5}function Di(o,e,t){let i=e.x-o.x,r=e.y-o.y,s=0,n=1,l=[[-i,o.x-t.left],[i,t.right-o.x],[-r,o.y-t.bottom],[r,t.top-o.y]];for(let[a,h]of l){if(a===0){if(h<0)return null;continue}let d=h/a;if(a<0){if(d>n)return null;d>s&&(s=d)}else{if(d<s)return null;d<n&&(n=d)}}return[{x:o.x+s*i,y:o.y+s*r},{x:o.x+n*i,y:o.y+n*r}]}var Ii={...X,markerStyle:{...X.markerStyle,width:20,height:20,borderRadius:6}},Q={seriesStyles:Mt,xAxis:H,yAxis:Te,plotArea:Ee,legend:Ii,region:{stroke:{weight:3,fill:O.regionColor,dash:[14,12],cap:"butt"},fill:Oi.color(O.regionColor,{opacity:.08}),dimOpacity:P}};function Bi(o,e){return{stroke:Ft.resolve(o?.stroke??e.stroke),fill:Pt.resolve(o?.fill??e.fill),dimOpacity:o?.dimOpacity??e.dimOpacity}}function Ni(o,e,t){return{stroke:Ft.lerp(o.stroke,e.stroke,t),fill:Pt.lerp(o.fill,e.fill,t),dimOpacity:Pi(o.dimOpacity,e.dimOpacity,t)}}function et(o,e){let t=e??Q;return{seriesStyles:Lt(o?.seriesStyles,t.seriesStyles),xAxis:se(o?.xAxis,t.xAxis),yAxis:se(o?.yAxis,t.yAxis),plotArea:Me(o?.plotArea,t.plotArea),legend:oe(o?.legend,t.legend),region:Bi(o?.region,t.region)}}function tt(o,e,t){return{seriesStyles:kt(o.seriesStyles,e.seriesStyles,t),xAxis:re(o.xAxis,e.xAxis,t),yAxis:re(o.yAxis,e.yAxis,t),plotArea:Le(o.plotArea,e.plotArea,t),legend:ne(o.legend,e.legend,t),region:Ni(o.region,e.region,t)}}function it(o,e,t){return o.map((i,r)=>[e.at(r),E(i,t.field)]).sort((i,r)=>i[0]-r[0])}function Dt(o,e){let t=1/0,i=-1/0;for(let r of o)for(let s of e){let n=E(r,s.field);n<t&&(t=n),n>i&&(i=n)}return t<=i?[t,i]:[0,1]}function st(o,e,t,i){if(t)return t;let[r,s]=Dt(o,e),n=Math.max(1,Math.round(i)),l=Pe((s-r)/n||1);return[Math.floor(r/l)*l,Math.ceil(s/l)*l]}import{declarePaints as Hi}from"@motionscript/sdk/component";var ee=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},_=class extends Gi{declareAssets(e){super.declareAssets(e),Hi(this,e)}renderSelf(e){if(!this.enabled)return;let t=this.points;if(t.length<2)return;let i=Math.max(0,Math.min(1,this.progress));if(i<=0)return;let r=this.tracePoints(t,i);if(r.length<2)return;let s=this.stroke,n=(s[0]?.weight??0)*2,l=this.spotlight;if(!he(l)){e.draw(new rt().line({points:r,radius:n}).stroke(s));return}e.draw(new rt().line({points:r,radius:n}).stroke(s).opacity(Math.max(0,Math.min(1,this.dimOpacity))));for(let a of Qe(r,l))e.draw(new rt().line({points:a,radius:n}).stroke(s))}tracePoints(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let i=[],r=0;for(let l=1;l<e.length;l++){let a=Math.hypot(e[l].x-e[l-1].x,e[l].y-e[l-1].y);i.push(a),r+=a}if(r===0)return e;let s=r*t,n=[e[0]];for(let l=0;l<i.length;l++)if(s>=i[l])n.push(e[l+1]),s-=i[l];else{let a=i[l]===0?0:s/i[l];n.push({x:e[l].x+(e[l+1].x-e[l].x)*a,y:e[l].y+(e[l+1].y-e[l].y)*a});break}return n}enter(e){return this.enterFrom(0,e.duration,e.easing??It())}enterFrom(e,t,i=It(),r=1){return this.command(s=>{let n=e+(r-e)*s;return{progress:n,enabled:n>0}},t,i)}};ee([ce({default:()=>[]})],_.prototype,"points",void 0);ee([ce({default:[],mapper:Bt.resolve,tween:Bt.lerp})],_.prototype,"stroke",void 0);ee([ce({default:1})],_.prototype,"progress",void 0);ee([ce({default:!0})],_.prototype,"enabled",void 0);ee([ce({default:()=>ae})],_.prototype,"spotlight",void 0);ee([ce({default:P})],_.prototype,"dimOpacity",void 0);ee([Ui()],_.prototype,"enter",null);import{Graphics2D as Nt,Node2D as Xi,fillOps as Gt,strokeOps as Ut,property as Ge}from"@motionscript/sdk";import{declarePaints as zi}from"@motionscript/sdk/component";var Ne=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},j=class extends Xi{declareAssets(e){super.declareAssets(e),zi(this,e)}renderSelf(e){let t=this.box;if(!he(t))return;let i=Math.max(0,Math.min(1,this.reveal));if(i<=0)return;let r=t.right-t.left,s=t.top-t.bottom,n=(t.left+t.right)/2,l=(t.bottom+t.top)/2;if(this.fill.length>0&&e.draw(new Nt().rect({x:n,y:l,width:r,height:s}).fill(this.fill).opacity(i)),this.stroke.length===0)return;let d=c=>e.draw(new Nt().line({points:c}).stroke(this.stroke).opacity(i));if(t.xBounded){let c=s/2*i;for(let p of[t.left,t.right])d([{x:p,y:l-c},{x:p,y:l+c}])}if(t.yBounded){let c=r/2*i;for(let p of[t.bottom,t.top])d([{x:n-c,y:p},{x:n+c,y:p}])}}};Ne([Ge({default:()=>ae})],j.prototype,"box",void 0);Ne([Ge({default:Q.region.stroke,mapper:Ut.resolve,tween:Ut.lerp})],j.prototype,"stroke",void 0);Ne([Ge({default:Q.region.fill,mapper:Gt.resolve,tween:Gt.lerp})],j.prototype,"fill",void 0);Ne([Ge({default:0})],j.prototype,"reveal",void 0);import{command as ji,Node2D as Yi,Rect as Ht,Text as Xt,easeOut as Wi,property as Ue,insetsOps as zt,textOps as jt}from"@motionscript/sdk";import{at as Yt,compose as Wt}from"@motionscript/sdk/component";var ve=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},Vt=24,D=class extends Yi{labelFor=F;markerNodes=[];labelNode=null;get sortedMarkers(){return[...this.markers].sort((e,t)=>e-t)}valueAt(e){return this.sortedMarkers[e]}fracAt(e){let t=this.valueAt(e);if(t===void 0)return 0;let[i,r]=this.range;return r<=i?0:(t-i)/(r-i)}constructor(e){super(e);let t=zt.resolve(this.axis.tickPadding).top,i=zt.resolve(this.axis.titlePadding).top;this.markerNodes=this.markers.map((s,n)=>{let l=new Xt({...jt.styleProps(this.axis.labelStyle),text:()=>{let a=this.valueAt(n);return a===void 0?"":this.labelFor(a)},x:()=>{let a=this.layoutBounds.width,h=(this.fracAt(n)-.5)*a,d=a/2-l.layoutBounds.width/2;return Math.min(h,d)}});return l});let r=[new Ht({width:"fill",height:"hug",padding:{top:t},children:this.markerNodes})];this.label!==""&&(this.labelNode=new Xt({...jt.styleProps(this.axis.titleStyle),text:this.label}),r.push(this.labelNode)),this.add(new Ht({flow:"vertical",gap:i,height:"hug",width:"fill",children:r}))}arm(e=Vt){for(let t of this.markerNodes)t.set({opacity:0,y:e});this.labelNode?.set({opacity:0,y:e})}enter(e){let{stagger:t,slide:i=Vt}=e.data??{},r=e.duration,s=e.easing??Wi(),n=this.markerNodes;if(n.length===0)return Wt([]);let{step:l,per:a,caption:h}=Fe(r,n.length,this.labelNode!==null,t);this.arm(i);let d=n.map((p,u)=>Yt(u*l,p.to({data:{opacity:1,y:0},duration:a,easing:s}))),c=n.length===0?0:(n.length-1)*l+a;return Wt([...d,...this.labelNode?[Yt(c,this.labelNode.to({data:{opacity:1,y:0},duration:h,easing:s}))]:[]])}};ve([Ue({default:()=>[0,1]})],D.prototype,"range",void 0);ve([Ue({default:()=>[]})],D.prototype,"markers",void 0);ve([Ue({default:H})],D.prototype,"axis",void 0);ve([Ue({default:""})],D.prototype,"label",void 0);ve([ji()],D.prototype,"enter",null);import{formatNumber as Vi}from"@motionscript/sdk/component";var He=864e5,Jt=["january","february","march","april","may","june","july","august","september","october","november","december"],Kt=2024;function qt(o){return o.length<3?-1:Jt.findIndex(e=>e.startsWith(o))}function Ki(o,e){let t=Date.UTC(o,0,4),i=(new Date(t).getUTCDay()+6)%7;return t-i*He+(e-1)*7*He}function Qt(o){if(typeof o!="string")return null;let e=o.trim().toLowerCase();if(e==="")return null;let t=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(e);if(t){let n=Number(t[2]),l=t[3]===void 0?1:Number(t[3]);return n<1||n>12||l<1||l>31?null:Date.UTC(Number(t[1]),n-1,l)}let i=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(e);if(i){let n=Number(i[2]);return n<1||n>53?null:Ki(i[1]===void 0?Kt:Number(i[1]),n)}let r=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(e);if(r){let n=qt(r[2]);if(n>=0){let l=r[1]??r[3],a=l===void 0?Kt:Number(l);return Date.UTC(a,n,1)}}let s=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(e);if(s){let n=qt(s[2]??s[3]),l=Number(s[1]??s[4]);if(n>=0&&l>=1&&l<=31)return Date.UTC(Number(s[5]),n,l)}return null}function ei(o,e){let t=new Date(o),i=t.getUTCFullYear(),r=Jt[t.getUTCMonth()].slice(0,3),s=r.charAt(0).toUpperCase()+r.slice(1);return e>4*365*He?String(i):e>60*He?`${s} ${i}`:`${s} ${t.getUTCDate()}`}function qi(o,e){let t=!1;for(let i of o){let r=i[e];if(!(r==null||r==="")){if(typeof r!="number")return!1;t=!0}}return t}function $i(o,e){let t=[],i=!1;for(let n of o){let l=n[e];if(l==null||l===""){t.push(null);continue}let a=Qt(l);if(a===null)return null;t.push(a),i=!0}if(!i)return null;let s=t.find(n=>n!==null);return t.map(n=>n===null?s:s=n)}function $t(o){let e=1/0,t=-1/0;for(let i of o)i<e&&(e=i),i>t&&(t=i);return e<=t?[e,t]:[0,1]}function Zt(o,[e,t],i){let r=o.filter(a=>a>=e&&a<=t),s=[...new Set(r)].sort((a,h)=>a-h);if(s.length===0)return z([e,t],i);let n=a=>s.reduce((h,d)=>Math.abs(d-a)<Math.abs(h-a)?d:h),l=[];for(let a of z([e,t],i)){let h=n(a);l[l.length-1]!==h&&l.push(h)}return l}function Zi(o,e,t,i){let r=o.indexOf(t);return r>=0?e[r]:i(t)}function ot(o,e,t){if(e!==""&&qi(o,e)){let n=o.map(l=>E(l,e));return{kind:"numeric",at:l=>n[l]??0,extent:$t(n),label:l=>t===void 0?F(l):Vi(l,t),ticks:z}}let i=o.map(n=>ie(n,e)),r=e===""?null:$i(o,e);if(r){let n=$t(r),l=n[1]-n[0];return{kind:"time",at:a=>r[a]??0,extent:n,label:a=>Zi(r,i,a,h=>ei(h,l)),ticks:(a,h)=>Zt(r,a,h)}}let s=o.map((n,l)=>l);return{kind:"ordinal",at:n=>n,extent:s.length>0?[0,s.length-1]:[0,1],label:n=>i[Math.round(n)]??"",ticks:(n,l)=>Zt(s,n,l)}}import{asCommand as de,formatNumber as es,hold as ti,sequence as ii,together as Se}from"@motionscript/sdk/component";var v=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},I,ts=24,nt={key:"seriesIndex",kind:"series",default:0,min:0,step:1},is=20,si=.35,ss=.5,rs=.15,m=class extends Qi{static{I=this}vAxis;hAxis;plotRect;legend=null;lines=[];get resolvedTheme(){return this.theme}static DEFAULT_MARKERS=5;get xColumn(){return ot(this.data,this.xField,this.xAxis.format)}get xScale(){return this.xAxis.range??this.xColumn.extent}get yScale(){let e=(this.yAxis.ticks?.length??I.DEFAULT_MARKERS)-1;return st(this.data,this.series,this.yAxis.range,e)}get resolvedYMarkers(){return this.yAxis.ticks??z(this.yScale,I.DEFAULT_MARKERS-1)}get resolvedXMarkers(){return this.xAxis.ticks??this.xColumn.ticks(this.xScale,I.DEFAULT_MARKERS-1)}plotSize(){let{width:e,height:t}=this.plotRect.layoutBounds;return{width:e,height:t}}seriesPixels(e){let t=this.series[e];if(!t)return[];let i=it(this.data,this.xColumn,t);if(i.length===0)return[];let{width:r,height:s}=this.plotSize(),[n,l]=this.xScale,[a,h]=this.yScale,d=p=>l<=n?0:((p-n)/(l-n)-.5)*r,c=p=>h<=a?0:((p-a)/(h-a)-.5)*s;return i.map(([p,u])=>({x:d(p),y:c(u)}))}hasCallout(){let e=this.region;return e!=null&&(e.x!==void 0||e.y!==void 0)}regionBox(){let{width:e,height:t}=this.plotSize();return Je(this.region,{left:-e/2,right:e/2,bottom:-t/2,top:t/2},this.xScale,this.yScale)}constructor(e){super(e);let t=this.series.map(n=>n.enabled??!0),i=this.showLegend!==!1;this.vAxis=new le({range:()=>this.yScale,markers:()=>this.resolvedYMarkers,axis:()=>this.resolvedTheme.yAxis,label:this.yAxis.label??"",width:"hug",height:"fill"}),this.vAxis.labelFor=n=>this.yAxis.format===void 0?F(n):es(n,this.yAxis.format),this.hAxis=new D({range:()=>this.xScale,markers:()=>this.resolvedXMarkers,axis:()=>this.resolvedTheme.xAxis,label:this.xAxis.label??"",width:"fill",height:"hug"}),this.hAxis.labelFor=n=>this.xColumn.label(n),this.lines=this.series.map((n,l)=>new _({points:()=>this.seriesPixels(l),stroke:()=>Ct(this.resolvedTheme.seriesStyles,n,l),enabled:t[l],spotlight:()=>this.regionBox(),dimOpacity:()=>1-(1-this.resolvedTheme.region.dimOpacity)*this.regionReveal})),i&&(this.legend=new Be({series:this.series,swatches:()=>this.series.map((n,l)=>Ot(this.resolvedTheme.seriesStyles,n,l)),legend:()=>this.resolvedTheme.legend})),this.plotRect=new be({clip:!0,children:[new Ie({fill:()=>this.resolvedTheme.plotArea.fill,shadow:()=>this.resolvedTheme.plotArea.shadow,xGridStroke:()=>this.resolvedTheme.xAxis.lineStyle,yGridStroke:()=>this.resolvedTheme.yAxis.lineStyle,xMarkers:()=>this.resolvedXMarkers,yMarkers:()=>this.resolvedYMarkers,xExtent:()=>this.xScale,yExtent:()=>this.yScale}),new j({box:()=>this.regionBox(),stroke:()=>this.resolvedTheme.region.stroke,fill:()=>this.resolvedTheme.region.fill,reveal:()=>this.regionReveal}),...this.lines,new De({stroke:()=>this.resolvedTheme.plotArea.stroke})]});let r=new le({opacity:0,range:()=>this.yScale,markers:()=>this.resolvedYMarkers,axis:()=>this.resolvedTheme.yAxis,label:this.yAxis.label??"",width:"hug",height:0}),s=[this.hAxis];this.legend&&s.push(this.legend),this.add(new be({flow:"vertical",width:"fill",height:"fill",padding:{top:ts},children:[new be({flow:"horizontal",height:"fill",width:"fill",children:[this.vAxis,this.plotRect]}),new be({flow:"horizontal",width:"fill",children:[r,new be({flow:"vertical",width:"fill",gap:20,children:s})]})]}))}arm(){this.vAxis.arm(),this.hAxis.arm();for(let e of this.lines)e.set({progress:0});this.legend?.set({opacity:0,y:-is})}enter(e){let t=e.duration,i=e.easing??$();this.arm();let r=this.hasCallout()&&this.regionReveal===0,s=r?t*.75:t,n=Se(this.vAxis.enter({data:{slide:24},duration:s*si,easing:i}),this.hAxis.enter({data:{slide:24},duration:s*si,easing:i})),l=Se(...this.lines.map(d=>d.enter({duration:s*ss,easing:i}))),a=this.legend?[this.legend.to({data:{opacity:1,y:0},duration:s*rs,easing:i})]:[],h=ii(n,l,...a);return de(r?ii(h,this.command(d=>({regionReveal:d}),t*.25,i)):h,t)}spotlightRegion(e){let t=I.regionArg(e.data),i=e.duration??.5,r=e.easing??$(),s=this.regionReveal,n=this.region;return t.x===void 0&&t.y===void 0?this.clearRegion({duration:i,easing:r}):s<=0||!this.hasCallout()?this.command(l=>({region:t,regionReveal:s+(1-s)*l}),i,r):this.command(l=>l<.5?{region:n,regionReveal:s*(1-r(l*2))}:{region:t,regionReveal:r(l*2-1)},i)}clearRegion(e={}){let t=e.duration??.5,i=e.easing??$(),r=this.regionReveal;return r===0?this.command(()=>({region:null,regionReveal:0}),t):this.command(s=>s>=1?{region:null,regionReveal:0}:{regionReveal:r*(1-s)},t,i)}home=null;static regionArg(e){let t=e?.region;return t!=null&&typeof t=="object"?t:{}}static span([e,t]){return e<=t?[e,t]:[t,e]}static rescale(e,t){let i=I.span(e),r=Math.max(2,t.length);return{range:i,ticks:z(i,r-1)}}zoomTo(e){let t=I.regionArg(e.data),i=e.duration??.8,r=e.easing??$();if(!t.x&&!t.y)return this.command(()=>({}),i);let s=this._domains();return this.home??=s,this._tweenAxes(s,{...t.x&&{x:{...s.x,...I.rescale(t.x,s.x.ticks)}},...t.y&&{y:{...s.y,...I.rescale(t.y,s.y.ticks)}}},i,r)}resetZoom(e={}){let t=e.duration??.8,i=e.easing??$(),r=this.home;return r?(this.home=null,this._tweenAxes(this._domains(),r,t,i)):this.command(()=>({}),t)}showSeries(e){let t=e.data?.seriesIndex??0,i=e.duration??.35,r=e.easing??$(),s=this.lines[t];return s?de(Se(s.enterFrom(0,i,r),...this.legend?[this.legend.showSeries({data:{index:t},duration:i,easing:r})]:[]),i):de(ti(i))}hideSeries(e){let t=e.data?.seriesIndex??0,i=e.duration??.35,r=e.easing??$(),s=this.lines[t];return s?de(Se(s.enterFrom(1,i,r,0),...this.legend?[this.legend.hideSeries({data:{index:t},duration:i,easing:r})]:[]),i):de(ti(i))}spotlightSeries(e){let t=e.data?.seriesIndex??0,i=e.duration??.35,r=e.easing??$();return de(Se(...this.lines.map((s,n)=>s.to({data:{opacity:n===t?1:P},duration:i,easing:r})),...this.legend?[this.legend.spotlightSeries({data:{index:t},duration:i,easing:r})]:[]),i)}_domains(){return{x:{...this.xAxis,range:this.xScale,ticks:this.resolvedXMarkers},y:{...this.yAxis,range:this.yScale,ticks:this.resolvedYMarkers}}}_tweenAxes(e,t,i,r){return this.command(s=>({...t.x&&{xAxis:q(e.x,t.x,s)},...t.y&&{yAxis:q(e.y,t.y,s)}}),i,r)}};v([Y({default:()=>[],kind:"dataset"})],m.prototype,"data",void 0);v([Y({default:""})],m.prototype,"xField",void 0);v([Y({default:()=>[],kind:"series"})],m.prototype,"series",void 0);v([Y({default:{},mapper:te,tween:q})],m.prototype,"xAxis",void 0);v([Y({default:{},mapper:te,tween:q})],m.prototype,"yAxis",void 0);v([Y({default:Q,mapper:et,tween:tt})],m.prototype,"theme",void 0);v([Y({default:null})],m.prototype,"region",void 0);v([Y({default:0})],m.prototype,"regionReveal",void 0);v([Y({default:!0,animatable:!1})],m.prototype,"showLegend",void 0);v([Z()],m.prototype,"enter",null);v([Z({args:[{key:"region",kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}]})],m.prototype,"spotlightRegion",null);v([Z()],m.prototype,"clearRegion",null);v([Z({args:[{key:"region",kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}]})],m.prototype,"zoomTo",null);v([Z()],m.prototype,"resetZoom",null);v([Z({args:[nt]})],m.prototype,"showSeries",null);v([Z({args:[nt]})],m.prototype,"hideSeries",null);v([Z({args:[nt]})],m.prototype,"spotlightSeries",null);m=I=v([Ji({key:"lineChart",parentKey:"node",forkable:!0,layout:{children:"freeform",defaultWidthMode:"fixed",defaultHeightMode:"fixed",acceptsChildren:!0},seed:{width:760,height:460}})],m);import{command as ue,node as ws,Node2D as Rs,Rect as we,easeOut as pe,property as k}from"@motionscript/sdk";import{formatNumber as Ts}from"@motionscript/sdk/component";import{asCommand as We,drive as gi,hold as yi,sequence as Es,together as ut}from"@motionscript/sdk/component";import{command as os,Node2D as ns,Rect as lt,Text as ri,easeOut as ls,property as Xe,insetsOps as oi,textOps as ni}from"@motionscript/sdk";import{at as li,compose as as,hold as hs}from"@motionscript/sdk/component";var Ae=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},ai=24,B=class extends ns{captionNodes=[];labelNode=null;slotCenter(e){let t=this.categories.length;if(t<=0)return 0;let i=this.layoutBounds.width;return-i/2+i/t*(e+.5)}constructor(e){super(e);let t=oi.resolve(this.axis.tickPadding).top,i=oi.resolve(this.axis.titlePadding).top,r=this.categories.map((n,l)=>{let a=new ri({...ni.styleProps(this.axis.labelStyle),text:n});return this.captionNodes.push(a),new lt({width:"hug",height:"hug",flow:"freeform",opacity:()=>f(this.dims[l]??1),x:()=>this.slotCenter(l),children:[a]})}),s=[new lt({width:"fill",height:"hug",padding:{top:t},children:r})];this.label!==""&&(this.labelNode=new ri({...ni.styleProps(this.axis.titleStyle),text:this.label}),s.push(this.labelNode)),this.add(new lt({flow:"vertical",gap:i,height:"hug",width:"fill",children:s}))}arm(e=ai){for(let t of this.captionNodes)t.set({opacity:0,y:e});this.labelNode?.set({opacity:0,y:e})}enter(e){let{stagger:t,slide:i=ai}=e.data??{},r=e.easing??ls(),s=this.captionNodes;if(s.length===0)return hs(e.duration);let{step:n,per:l,caption:a}=Fe(e.duration,s.length,this.labelNode!==null,t);this.arm(i);let h=(s.length-1)*n+l;return as([...s.map((d,c)=>li(c*n,d.to({data:{opacity:1,y:0},duration:l,easing:r}))),...this.labelNode?[li(h,this.labelNode.to({data:{opacity:1,y:0},duration:a,easing:r}))]:[]])}};Ae([Xe({default:()=>[]})],B.prototype,"categories",void 0);Ae([Xe({default:H})],B.prototype,"axis",void 0);Ae([Xe({default:""})],B.prototype,"label",void 0);Ae([Xe({default:()=>[]})],B.prototype,"dims",void 0);Ae([os()],B.prototype,"enter",null);import{command as us,Graphics2D as fs,Node2D as ms,Text as gs,easeOut as ys,fillOps as ui,shadowOps as fi,strokeOps as mi,property as L,textOps as xs}from"@motionscript/sdk";import{fillOps as cs,lerpNumber as ze,shadowOps as hi,strokeOps as ci,textOps as di}from"@motionscript/sdk";function je(o,e,t){let i=0;return e.map(r=>{let s=E(o,r.field);if(!t)return{from:0,to:s,value:s};let n=i;return i+=s,{from:n,to:i,value:s}})}function at(o,e){let t=-1;for(let i=0;i<e.length;i++)E(o,e[i].field)!==0&&(t=i);return t}function ht(o,e){return o.map(t=>ie(t,e))}function pi(o,e,t){let i=0,r=0;for(let s of o)for(let n of je(s,e,t))i=Math.min(i,n.from,n.to),r=Math.max(r,n.from,n.to);return i<r?[i,r]:[0,1]}function ct(o,e,t,i,r){if(i)return i;let[s,n]=pi(o,e,t),l=Math.max(1,Math.round(r)),a=Pe((n-s)/l||1);return[Math.floor(s/a)*a,Math.ceil(n/a)*a]}var W={seriesFills:_e,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...H,labelStyle:{...H.labelStyle,fontWeight:600},tickPadding:16},yAxis:Te,plotArea:Ee,legend:X,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:O.markerColor},spotlight:{dimOpacity:P}};function ds(o,e){return{cornerRadius:o?.cornerRadius??e.cornerRadius,slotFill:o?.slotFill??e.slotFill,groupGap:o?.groupGap??e.groupGap,stroke:ci.resolve(o?.stroke??e.stroke),shadow:hi.resolve(o?.shadow??e.shadow)}}function ps(o,e,t){return{cornerRadius:ze(o.cornerRadius,e.cornerRadius,t),slotFill:ze(o.slotFill,e.slotFill,t),groupGap:ze(o.groupGap,e.groupGap,t),stroke:ci.lerp(o.stroke,e.stroke,t),shadow:hi.lerp(o.shadow,e.shadow,t)}}function dt(o,e){let t=e??W;return{seriesFills:ke(o?.seriesFills,t.seriesFills),bar:ds(o?.bar,t.bar),xAxis:se(o?.xAxis,t.xAxis),yAxis:se(o?.yAxis,t.yAxis),plotArea:Me(o?.plotArea,t.plotArea),legend:oe(o?.legend,t.legend),valueStyle:di.resolveStyle(o?.valueStyle,t.valueStyle),spotlight:{dimOpacity:o?.spotlight?.dimOpacity??t.spotlight.dimOpacity}}}function pt(o,e,t){return{seriesFills:Ce(o.seriesFills,e.seriesFills,t),bar:ps(o.bar,e.bar,t),xAxis:re(o.xAxis,e.xAxis,t),yAxis:re(o.yAxis,e.yAxis,t),plotArea:Le(o.plotArea,e.plotArea,t),legend:ne(o.legend,e.legend,t),valueStyle:di.lerpStyle(o.valueStyle,e.valueStyle,t),spotlight:{dimOpacity:ze(o.spotlight.dimOpacity,e.spotlight.dimOpacity,t)}}}function Ye(o,e,t){return e.fill!=null?cs.resolve(e.fill):o.length===0?"white":o[t%o.length]}import{declarePaints as vs}from"@motionscript/sdk/component";var M=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},bs=10,Ss=1.6,As=24,S=class extends ms{labelFor=F;constructor(e){if(super(e),!!this.showValues)for(let t=0;t<this.bars.length;t++)this.add(new gs({...xs.styleProps(this.valueStyle),text:()=>this.captionAt(t),x:()=>this.bars[t]?.x??0,y:()=>this.captionY(t),opacity:()=>this.dimAt(t)}))}dimAt(e){return this.enabled?f(this.dims[e]??1):0}endsAt(e){let t=this.bars[e];if(!t)return null;let i=f(this.growth),r=this.baseline+(t.from-this.baseline)*i,s=this.baseline+(t.to-this.baseline)*i;return{base:r,end:s}}get valueSize(){let e=this.valueStyle.fontSize;return typeof e=="number"?e:As}captionAt(e){let t=this.bars[e];if(!t||t.value===0)return"";if(this.insideAt(e)){let i=this.endsAt(e);if(!i||Math.abs(i.end-i.base)<this.valueSize*Ss)return""}return this.labelFor(t.value)}insideAt(e){let t=this.bars[e];return t!==void 0&&Math.abs(t.from-this.baseline)>.5}captionY(e){let t=this.endsAt(e);if(!t)return 0;if(this.insideAt(e))return(t.base+t.end)/2;let i=t.end>=t.base?1:-1;return t.end+i*(bs+this.valueSize/2)}declareAssets(e){super.declareAssets(e),vs(this,e,{fills:this.barShadow.map(t=>t.fill),strokes:[this.barStroke]})}renderSelf(e){if(this.enabled)for(let t=0;t<this.bars.length;t++){let i=this.bars[t],r=this.endsAt(t);if(!r||i.width<=0)continue;let s=Math.abs(r.end-r.base);if(s<=0)continue;let n=i.round?Math.min(this.cornerRadius,s):0,l=new fs,a=l.rect({x:i.x,y:(r.base+r.end)/2,width:i.width,height:s,cornerRadius:n>0?r.end>=r.base?{bottomLeft:n,bottomRight:n,topLeft:0,topRight:0}:{topLeft:n,topRight:n,bottomLeft:0,bottomRight:0}:0});a.shadow(this.barShadow),a.fill(this.fill),a.stroke(this.barStroke),e.draw(l.opacity(this.dimAt(t)))}}enter(e){return this.command(t=>({growth:t}),e.duration,e.easing??ys())}};M([L({default:()=>[]})],S.prototype,"bars",void 0);M([L({default:0})],S.prototype,"baseline",void 0);M([L({default:[],mapper:ui.resolve,tween:ui.lerp})],S.prototype,"fill",void 0);M([L({default:W.bar.stroke,mapper:mi.resolve,tween:mi.lerp})],S.prototype,"barStroke",void 0);M([L({default:W.bar.shadow,mapper:fi.resolve,tween:fi.lerp})],S.prototype,"barShadow",void 0);M([L({default:W.bar.cornerRadius})],S.prototype,"cornerRadius",void 0);M([L({default:1})],S.prototype,"growth",void 0);M([L({default:()=>[]})],S.prototype,"dims",void 0);M([L({default:!1})],S.prototype,"showValues",void 0);M([L({default:W.valueStyle})],S.prototype,"valueStyle",void 0);M([L({default:!0})],S.prototype,"enabled",void 0);M([us()],S.prototype,"enter",null);var b=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},Ve,_s=64,Ms=40,Ls=56,ks=34,Cs=30,Os=24,Ps=20,Fs=20,xi=.35,Ds=.5,Is=.15,g=class extends Rs{static{Ve=this}vAxis;cAxis;legend=null;barSets=[];get resolvedTheme(){return this.theme}static DEFAULT_MARKERS=5;get valueScale(){let e=(this.valueAxis.ticks?.length??Ve.DEFAULT_MARKERS)-1;return ct(this.data,this.series,this.stacked,this.valueAxis.range,e)}valueLabel(e){let t=this.valueAxis.format;return t===void 0?F(e):Ts(e,t)}get resolvedMarkers(){return this.valueAxis.ticks??z(this.valueScale,Ve.DEFAULT_MARKERS-1)}get hasValueLabel(){return this.valueAxis.label!==""}get hasCategoryLabel(){return this.categoryAxis.label!==""}get leftInset(){return _s+(this.hasValueLabel?ks:0)}get bottomInset(){return Ms+(this.hasCategoryLabel?Cs:0)}plotBox(){let e=this.layoutBounds.width,t=this.layoutBounds.height,i=t/2,r=-t/2+(this.legend?Ls:0),s=-e/2+this.leftInset,n=e/2-Ps,l=i-Os,a=r+this.bottomInset;return{left:s,right:n,top:l,bottom:a}}plotSize(){let{left:e,right:t,top:i,bottom:r}=this.plotBox();return{w:t-e,h:i-r}}valueToY(e){let[t,i]=this.valueScale,{h:r}=this.plotSize();return i<=t?-r/2:((e-t)/(i-t)-.5)*r}get baselinePx(){let[e,t]=this.valueScale;return this.valueToY(Math.min(Math.max(0,e),t))}get slotWidth(){let e=this.data.length;return e>0?this.plotSize().w/e:0}slotCenter(e){return-this.plotSize().w/2+this.slotWidth*(e+.5)}get slotInner(){return this.slotWidth*f(this.resolvedTheme.bar.slotFill)}weightAt(e){return Math.max(0,this.weights[e]??1)}get totalWeight(){let e=0;for(let t=0;t<this.series.length;t++)e+=this.weightAt(t);return e>0?e:1}weightBefore(e){let t=0;for(let i=0;i<e;i++)t+=this.weightAt(i);return t}seriesBars(e){let t=this.series[e];if(!t)return[];let i=this.stacked,r=this.slotInner,s=this.resolvedTheme.bar.groupGap,n=r/this.totalWeight,l=this.weightAt(e);return this.data.map((a,h)=>{let c=je(i?this.weightedRow(a):a,this.series,i)[e]??{from:0,to:0,value:0},p=i?at(a,this.series):e,u=this.slotCenter(h)-r/2,R=i?this.slotCenter(h):u+n*this.weightBefore(e)+n*l/2,C=i?r:Math.max(0,n*l-(this.series.length>1?s:0));return{x:R,width:C,from:this.valueToY(c.from),to:this.valueToY(c.to),round:p===e,value:E(a,t.field)}})}weightedRow(e){let t={...e};return this.series.forEach((i,r)=>{let s=e[i.field];typeof s=="number"&&(t[i.field]=s*this.weightAt(r))}),t}categoryDims(){let e=f(this.spotlightReveal),t=this.resolvedTheme.spotlight.dimOpacity,i=this.spotlight;return this.data.map((r,s)=>e<=0||i===s?1:1-(1-t)*e)}constructor(e){super(e);let t=this.series.map(a=>a.enabled??!0);this.weights=t.map(a=>a?1:0);let i=e?.showLegend!==!1,r=e?.showValues===!0;this.vAxis=new le({range:()=>this.valueScale,markers:()=>this.resolvedMarkers,axis:()=>this.resolvedTheme.yAxis,label:this.valueAxis.label??"",width:"hug",height:"fill"}),this.vAxis.labelFor=a=>this.valueLabel(a),this.cAxis=new B({categories:ht(this.data,this.categoryField),axis:()=>this.resolvedTheme.xAxis,label:this.categoryAxis.label??"",dims:()=>this.categoryDims(),width:"fill",height:"hug"}),this.barSets=this.series.map((a,h)=>new S({bars:()=>this.seriesBars(h),baseline:()=>this.baselinePx,fill:()=>Ye(this.resolvedTheme.seriesFills,a,h),barStroke:()=>this.resolvedTheme.bar.stroke,barShadow:()=>this.resolvedTheme.bar.shadow,cornerRadius:()=>this.resolvedTheme.bar.cornerRadius,growth:()=>this.growth,dims:()=>this.categoryDims(),showValues:r,valueStyle:this.resolvedTheme.valueStyle,enabled:t[h]}));for(let a of this.barSets)a.labelFor=h=>this.valueLabel(h);i&&(this.legend=new Be({series:this.series,swatches:()=>this.series.map((a,h)=>Ye(this.resolvedTheme.seriesFills,a,h)),legend:()=>this.resolvedTheme.legend}));let s=new we({clip:!0,children:[new Ie({fill:()=>this.resolvedTheme.plotArea.fill,shadow:()=>this.resolvedTheme.plotArea.shadow,xGridStroke:()=>this.resolvedTheme.xAxis.lineStyle,yGridStroke:()=>this.resolvedTheme.yAxis.lineStyle,xMarkers:[],yMarkers:()=>this.resolvedMarkers,xExtent:()=>[0,1],yExtent:()=>this.valueScale}),...this.barSets,new De({stroke:()=>this.resolvedTheme.plotArea.stroke})]}),n=new le({opacity:0,range:()=>this.valueScale,markers:()=>this.resolvedMarkers,axis:()=>this.resolvedTheme.yAxis,label:this.valueAxis.label??"",width:"hug",height:0}),l=[this.cAxis];this.legend&&l.push(this.legend),this.add(new we({flow:"vertical",width:"fill",height:"fill",children:[new we({flow:"horizontal",height:"fill",width:"fill",children:[this.vAxis,s]}),new we({flow:"horizontal",width:"fill",children:[n,new we({flow:"vertical",width:"fill",gap:20,children:l})]})]}))}arm(){this.vAxis.arm(),this.cAxis.arm(),this.growth=0,this.legend?.set({opacity:0,y:-Fs})}enter(e){let{duration:t}=e,i=e.easing??pe();return this.arm(),We(Es(ut(this.vAxis.enter({data:{slide:24},duration:t*xi,easing:i}),this.cAxis.enter({data:{slide:24},duration:t*xi,easing:i})),this.riseBars(t*Ds,i),...this.legend?[this.legend.to({data:{opacity:1,y:0},duration:t*Is,easing:i})]:[]),t)}riseBars(e,t){return this.command(i=>({growth:i}),e,t)}showSeries(e){let{seriesIndex:t=0}=e.data??{};return this.toggleSeries(t,1,e.duration??.35,e.easing??pe())}hideSeries(e){let{seriesIndex:t=0}=e.data??{};return this.toggleSeries(t,0,e.duration??.35,e.easing??pe())}toggleSeries(e,t,i,r){let s=this.barSets[e];return s?We(ut(this.tweenWeight(e,t,i,r),gi(i,n=>{let l=n>=1?t:Math.max(t,1-n);s.set({enabled:t>0||l>0})}),...this.legend?[t>0?this.legend.showSeries({data:{index:e},duration:i,easing:r}):this.legend.hideSeries({data:{index:e},duration:i,easing:r})]:[]),i):We(yi(i))}spotlightSeries(e){let{seriesIndex:t=0}=e.data??{},i=e.duration??.35,r=e.easing??pe(),s=this.resolvedTheme.spotlight.dimOpacity;return We(ut(...this.barSets.map((n,l)=>n.to({data:{opacity:l===t?1:s},duration:i,easing:r})),...this.legend?[this.legend.spotlightSeries({data:{index:t},duration:i,easing:r})]:[]),i)}tweenWeight(e,t,i,r){let s=this.series.map((l,a)=>this.weightAt(a)),n=s[e]??1;return n===t?yi(i):gi(i,l=>{let a=[...s];a[e]=n+(t-n)*r(l),this.weights=a})}spotlightCategory(e){let{categoryIndex:t=0}=e.data??{},i=e.duration??.4,r=e.easing??pe();if(t<0||t>=this.data.length)return this.holdSpotlight(i);let s=this.spotlightReveal;return this.command(n=>({spotlight:t,spotlightReveal:s+(1-s)*n}),i,r)}clearCategory(e){let t=e.duration??.4,i=e.easing??pe(),r=this.spotlightReveal;return r===0?this.holdSpotlight(t):this.command(s=>s>=1?{spotlight:null,spotlightReveal:0}:{spotlightReveal:r*(1-s)},t,i)}holdSpotlight(e){return this.command(()=>({}),e)}};b([k({default:()=>[]})],g.prototype,"data",void 0);b([k({default:""})],g.prototype,"categoryField",void 0);b([k({default:()=>[]})],g.prototype,"series",void 0);b([k({default:!1})],g.prototype,"stacked",void 0);b([k({default:{},mapper:te,tween:q})],g.prototype,"valueAxis",void 0);b([k({default:{},mapper:te,tween:q})],g.prototype,"categoryAxis",void 0);b([k({default:W,mapper:dt,tween:pt})],g.prototype,"theme",void 0);b([k({default:1})],g.prototype,"growth",void 0);b([k({default:()=>[]})],g.prototype,"weights",void 0);b([k({default:null})],g.prototype,"spotlight",void 0);b([k({default:0})],g.prototype,"spotlightReveal",void 0);b([ue()],g.prototype,"enter",null);b([ue({args:[{key:"seriesIndex",kind:"series",default:0,min:0,step:1}]})],g.prototype,"showSeries",null);b([ue({args:[{key:"seriesIndex",kind:"series",default:0,min:0,step:1}]})],g.prototype,"hideSeries",null);b([ue({args:[{key:"seriesIndex",kind:"series",default:0,min:0,step:1}]})],g.prototype,"spotlightSeries",null);b([ue({args:[{key:"categoryIndex",kind:"number",default:0,min:0,step:1}]})],g.prototype,"spotlightCategory",null);b([ue()],g.prototype,"clearCategory",null);g=Ve=b([ws({key:"barChart",parentKey:"node",forkable:!0,layout:{children:"freeform",defaultWidthMode:"fixed",defaultHeightMode:"fixed",acceptsChildren:!0},seed:{width:760,height:460}})],g);import{Rect as dr,command as xe,node as pr,Node2D as ur,easeOut as ye,property as G}from"@motionscript/sdk";import{command as Bs,Rect as Ke,Text as Ns,easeOut as Gs,property as ft,textOps as Us}from"@motionscript/sdk";import{at as Hs,compose as Xs,hold as zs}from"@motionscript/sdk/component";var qe=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},js=16,V=class extends Ke{items=[];constructor(e){super({...e,flow:"vertical",align:"centerLeft",width:"hug",height:"hug"}),this.set({gap:this.legend.itemGap/3,padding:this.legend.padding});for(let t=0;t<this.slices.length;t++){let i=this.buildItem(this.slices[t]);this.items.push(i),this.add(new Ke({width:"hug",height:"hug",flow:"freeform",opacity:()=>f(this.dims[t]??1),children:[i]}))}}buildItem(e){let t=this.legend.markerStyle;return new Ke({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",children:[new Ke({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:e.fill,stroke:t.stroke,shadow:t.shadow}),new Ns({...Us.styleProps(this.legend.textStyle),text:e.category})]})}arm(e=js){for(let t of this.items)t.set({opacity:0,x:e})}enter(e){let t=e.duration,i=e.easing??Gs(),r=this.items;if(r.length===0)return zs(t);this.arm();let s=t/(1+Math.max(0,r.length-1)/5),n=s/5;return Xs(r.map((l,a)=>Hs(a*n,l.to({data:{opacity:1,x:0},duration:s,easing:i}))))}};qe([ft({default:()=>[]})],V.prototype,"slices",void 0);qe([ft({default:X})],V.prototype,"legend",void 0);qe([ft({default:()=>[]})],V.prototype,"dims",void 0);qe([Bs()],V.prototype,"enter",null);import{Rect as St,command as Tt,Graphics2D as Si,Node2D as Js,PathBuilder as Qs,Text as me,easeOut as At,fillOps as er,property as T,strokeOps as tr,textOps as ge}from"@motionscript/sdk";import{lerpNumber as Re,shadowOps as vi,strokeOps as $e,textOps as N}from"@motionscript/sdk";function gt(o,e,t,i){return o.map((r,s)=>({category:ie(r,e),value:E(r,t),fill:i.length>0?i[s%i.length]:"white"}))}var Ys=Math.PI/180;function yt(o){return o.value>0&&Number.isFinite(o.value)?o.value:0}function bi(o){let e=0;for(let t of o)e+=yt(t);return e}function fe(o,e){return{x:o*Math.sin(e),y:o*Math.cos(e)}}function xt(o,e){let t=bi(o);if(t<=0)return[];let i=[],r=e*Ys;return o.forEach((s,n)=>{let l=yt(s);if(l<=0)return;let a=l/t,h=r,d=h+a*Math.PI*2;r=d,i.push({index:n,a0:h,a1:d,mid:(h+d)/2,fraction:a})}),i}function Ze(o,e,t,i){o.sort((n,l)=>l.ideal-n.ideal);let r=t;for(let n of o)n.y=Math.min(n.ideal,r),r=n.y-e;let s=i;for(let n=o.length-1;n>=0;n--)o[n].y=Math.max(o[n].y,s),s=o[n].y+e;return o}var mt={fontSize:26,fontWeight:600,textAlign:"center",fill:O.markerColor},K={sliceFills:_e,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:mt,percentStyle:{...mt,fontWeight:700},insideStyle:{...mt,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:O.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:O.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:O.markerColor}},legend:X,spotlight:{dimOpacity:P}};function Ws(o,e){return{gap:o?.gap??e.gap,holeRadius:o?.holeRadius??e.holeRadius,startAngle:o?.startAngle??e.startAngle,selectedGrow:o?.selectedGrow??e.selectedGrow,stroke:$e.resolve(o?.stroke??e.stroke),shadow:vi.resolve(o?.shadow??e.shadow)}}function Vs(o,e,t){return{gap:Re(o.gap,e.gap,t),holeRadius:Re(o.holeRadius,e.holeRadius,t),startAngle:Re(o.startAngle,e.startAngle,t),selectedGrow:Re(o.selectedGrow,e.selectedGrow,t),stroke:$e.lerp(o.stroke,e.stroke,t),shadow:vi.lerp(o.shadow,e.shadow,t)}}function Ks(o,e){return{textStyle:N.resolveStyle(o?.textStyle,e.textStyle),percentStyle:N.resolveStyle(o?.percentStyle,e.percentStyle),insideStyle:N.resolveStyle(o?.insideStyle,e.insideStyle),leaderStroke:$e.resolve(o?.leaderStroke??e.leaderStroke)}}function qs(o,e,t){return{textStyle:N.lerpStyle(o.textStyle,e.textStyle,t),percentStyle:N.lerpStyle(o.percentStyle,e.percentStyle,t),insideStyle:N.lerpStyle(o.insideStyle,e.insideStyle,t),leaderStroke:$e.lerp(o.leaderStroke,e.leaderStroke,t)}}function $s(o,e){return{labelStyle:N.resolveStyle(o?.labelStyle,e.labelStyle),captionStyle:N.resolveStyle(o?.captionStyle,e.captionStyle)}}function Zs(o,e,t){return{labelStyle:N.lerpStyle(o.labelStyle,e.labelStyle,t),captionStyle:N.lerpStyle(o.captionStyle,e.captionStyle,t)}}function vt(o,e){let t=e??K;return{sliceFills:ke(o?.sliceFills,t.sliceFills),ring:Ws(o?.ring,t.ring),label:Ks(o?.label,t.label),center:$s(o?.center,t.center),legend:oe(o?.legend,t.legend),spotlight:{dimOpacity:o?.spotlight?.dimOpacity??t.spotlight.dimOpacity}}}function bt(o,e,t){return{sliceFills:Ce(o.sliceFills,e.sliceFills,t),ring:Vs(o.ring,e.ring,t),label:qs(o.label,e.label,t),center:Zs(o.center,e.center,t),legend:ne(o.legend,e.legend,t),spotlight:{dimOpacity:Re(o.spotlight.dimOpacity,e.spotlight.dimOpacity,t)}}}import{declarePaints as ir}from"@motionscript/sdk/component";var w=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},Ai=12,sr=14,wt=.62,rr=6,wi=34,Ri=26,Ti=8,or=.18,nr=240,lr=8,Ei=2,_i=.44,Rt=.62,ar=.78,hr=.9,Mi=.001,Li=26;function J(o,e=Li){let t=o.fontSize;return typeof t=="number"?t:e}function cr(o,e,t,i,r,s){let n=new Qs,l=e-o,a=Math.max(2,Math.ceil(Math.abs(l)/(Math.PI*2)*nr)),h=c=>c<=0?0:Math.min(r/c,l/2.2),d=(c,p)=>{let u=h(c),R=o+u,C=e-u,U=fe(c,R+(C-R)*p/a);return{x:U.x+s,y:U.y}};if(t<=0){n.moveTo(s,0);for(let c=0;c<=a;c++){let p=d(i,c);n.lineTo(p.x,p.y)}return n.close(),n}for(let c=0;c<=a;c++){let p=d(i,c);c===0?n.moveTo(p.x,p.y):n.lineTo(p.x,p.y)}for(let c=a;c>=0;c--){let p=d(t,c);n.lineTo(p.x,p.y)}return n.close(),n}var y=class extends Js{fills=[];constructor(e){if(super(e),this.fills=this.slices.map(t=>er.resolve(t.fill)),this.labelPlacement!=="none"&&this.labelMode!=="none")for(let t of this.arcs)this.addLabel(t);this.hasCenterLabel&&this.addCenterLabel()}addLabel(e){let t=this.slices[e.index],i=()=>f(this.labelReveal)*this.sliceOpacity(e.index),r=this.labelMode==="both"||this.labelMode==="category",s=this.labelMode==="both"||this.labelMode==="percent";if(this.labelPlacement==="inside"){let h=[];s&&h.push(new me({...ge.styleProps(this.label.insideStyle),text:Oe(e.fraction),fontSize:()=>this.insideFont})),r&&h.push(new me({...ge.styleProps(this.label.insideStyle),text:t.category,fontSize:()=>this.labelMode==="category"?this.insideFont:this.insideFont*_i})),this.add(new St({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>this.insideAnchor(e.index),children:h}));return}let n=this.sideOf(e.mid),l=()=>this.placementFor(e.index)?.text??{x:0,y:0},a=[];r&&a.push(new me({...ge.styleProps(this.label.textStyle),text:t.category,textAlign:n>0?"left":"right"})),s&&a.push(new me({...ge.styleProps(this.label.percentStyle),text:Oe(e.fraction),textAlign:n>0?"left":"right"})),this.add(new St({flow:"vertical",width:"hug",height:"hug",gap:2,align:n>0?"centerLeft":"centerRight",opacity:i,centerLeft:n>0?l:void 0,centerRight:n>0?void 0:l,children:a}))}addCenterLabel(){let e=[];this.centerLabel!==""&&e.push(new me({...ge.styleProps(this.centerStyle.labelStyle),text:this.centerLabel,fontSize:()=>this.centerFont})),this.centerCaption!==""&&e.push(new me({...ge.styleProps(this.centerStyle.captionStyle),text:this.centerCaption,fontSize:()=>this.centerFont*(J(this.centerStyle.captionStyle,22)/J(this.centerStyle.labelStyle,46))})),this.add(new St({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>f(this.centerReveal),center:()=>({x:this.centerX,y:0}),children:e}))}get arcs(){return xt(this.slices,this.ring.startAngle)}sideOf(e){return Math.sin(e)>=0?1:-1}get hasLeaderLabels(){return this.labelPlacement==="leader"&&this.labelMode!=="none"&&this.arcs.length>0}insideRoom(e){let t=this.outerRadius,i=this.holeRadius,r=i>0?t-i:t*(1-Rt)*2,s=i>0?(i+t)/2:t*Rt,n=Math.abs(Math.sin(e.mid)),l=Math.abs(Math.cos(e.mid)),a=n>Mi?r/n:1/0,h=l>Mi?(e.a1-e.a0)*s/l:1/0;return Math.max(0,Math.min(a,h))}insideGlyphs(e){let t=this.slices[e.index]?.category.length??0,i=this.labelMode==="both"||this.labelMode==="percent"?Oe(e.fraction).length:0,r=this.labelMode==="category"?t:this.labelMode==="both"?t*_i:0;return Math.max(1,i,r)}get insideFont(){let e=J(this.label.insideStyle,Li*1.9);for(let t of this.arcs){let i=this.insideRoom(t)*hr/(this.insideGlyphs(t)*wt);e=Math.min(e,i)}return Math.max(1,e)}get hasCenterLabel(){return this.centerLabel!==""||this.centerCaption!==""}get centerFont(){let e=J(this.centerStyle.labelStyle,46),t=this.holeRadius;if(t<=0)return e;let i=J(this.centerStyle.captionStyle,22)/Math.max(1,e),r=Math.max(1,this.centerLabel.length,this.centerCaption.length*i);return Math.min(e,t*2*ar/(r*wt))}get growFactor(){return Math.max(1,Math.min(1.6,this.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let e=J(this.label.textStyle)*1.25,t=J(this.label.percentStyle)*1.25;return this.labelMode==="both"?e+t+2:this.labelMode==="category"?e:t}captionGlyphs(e){let t=this.labelMode==="percent"||this.labelMode==="both"?4:0,i=this.labelMode==="category"||this.labelMode==="both"?this.slices[e]?.category.length??0:0;return Math.max(t,i)}get labelGutters(){let e={left:Ei,right:Ei};if(!this.hasLeaderLabels)return e;let t=J(this.label.textStyle)*wt;for(let i of this.arcs){let r=wi+Ri+Ti+this.captionGlyphs(i.index)*t+sr,s=this.sideOf(i.mid)>0?"right":"left";e[s]=Math.max(e[s],r)}return e}get centerX(){let{left:e,right:t}=this.labelGutters;return(e-t)/2}get outerRadius(){let{left:e,right:t}=this.labelGutters,i=Math.min((this.layoutBounds.width-e-t)/2,this.layoutBounds.height/2-this.labelRowHeight-4);return Math.max(0,i/this.growFactor)}get holeRadius(){let e=this.ring.holeRadius;if(e<=0)return 0;let t=e<1?e*this.outerRadius:e;return Math.min(t,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+wi}popOf(e){return f(this.pops[e]??0)}anchorRadius(e){return this.outerRadius+this.maxPop*this.popOf(e)}bandMidRadius(e){let t=this.anchorRadius(e),i=this.holeRadius;return i>0?(i+t)/2:t*Rt}insideAnchor(e){let t=this.arcs.find(r=>r.index===e);if(t===void 0)return{x:this.centerX,y:0};let i=fe(this.bandMidRadius(e),t.mid);return{x:i.x+this.centerX,y:i.y}}get selectionStrength(){let e=0;for(let t=0;t<this.slices.length;t++)e=Math.max(e,this.popOf(t));return e}sliceOpacity(e){let t=this.selectionStrength;return t<=0?1:1-(1-f(this.dimOpacity))*t*(1-this.popOf(e))}placements(){if(!this.hasLeaderLabels)return[];let e=this.arcs;if(e.length===0||this.outerRadius<=0)return[];let t=this.elbowRadius,i=this.labelRowHeight,r=this.layoutBounds.height/2-i/2,s=-r,n=this.centerX,l=[],a=[];for(let h of e){let d=this.sideOf(h.mid),c=fe(t,h.mid).y;(d>0?l:a).push({index:h.index,side:d,mid:h.mid,ideal:c,y:c})}return Ze(l,i+Ai,r,s),Ze(a,i+Ai,r,s),[...l,...a].map(h=>{let d=fe(this.anchorRadius(h.index)+rr,h.mid),c=Math.sqrt(Math.max(0,t*t-h.y*h.y)),p=n+h.side*Math.max(c,t*or),u=n+h.side*(t+Ri);return{index:h.index,side:h.side,leader:[{x:d.x+n,y:d.y},{x:p,y:h.y},{x:u,y:h.y}],text:{x:u+h.side*Ti,y:h.y}}})}placementFor(e){return this.placements().find(t=>t.index===e)}declareAssets(e){super.declareAssets(e),ir(this,e,{fills:this.fills,strokes:[tr.resolve(this.label.leaderStroke)]})}renderSelf(e){let t=this.outerRadius;if(t<=0)return;let i=this.arcs;if(i.length===0)return;let r=f(this.growth),s=this.ring.startAngle*(Math.PI/180)+Math.PI*2*r,n=this.holeRadius,l=Math.max(0,this.ring.gap)/2,a=this.centerX,h=t+this.maxPop+1+Math.abs(a),d=[-h,-h,h,h],c=h*2;for(let u of i){let R=Math.min(u.a1,s);if(R<=u.a0)continue;let C=cr(u.a0,R,n,this.anchorRadius(u.index),l,a),U=new Si().path(C.toPathState({centerBounds:d,width:c,height:c}));U.shadow(this.ring.shadow),U.fill(this.fills[u.index]??[]),U.stroke(this.ring.stroke),e.draw(U.opacity(this.sliceOpacity(u.index)))}let p=f(this.labelReveal);if(!(p<=.001))for(let u of this.placements())e.draw(new Si().line({points:u.leader,radius:lr}).stroke(this.label.leaderStroke).opacity(p*this.sliceOpacity(u.index)))}sweep(e){return this.command(t=>({growth:t}),e.duration,e.easing??At())}revealLabels(e){return this.command(t=>({labelReveal:t}),e.duration,e.easing??At())}revealCenter(e={}){let t=f(this.centerReveal);return this.command(i=>({centerReveal:t+(1-t)*i}),e.duration??.6,e.easing??At())}};w([T({default:()=>[]})],y.prototype,"slices",void 0);w([T({default:K.ring})],y.prototype,"ring",void 0);w([T({default:K.label})],y.prototype,"label",void 0);w([T({default:K.center})],y.prototype,"centerStyle",void 0);w([T({default:"percent"})],y.prototype,"labelMode",void 0);w([T({default:"leader"})],y.prototype,"labelPlacement",void 0);w([T({default:1})],y.prototype,"growth",void 0);w([T({default:1})],y.prototype,"labelReveal",void 0);w([T({default:()=>[]})],y.prototype,"pops",void 0);w([T({default:K.spotlight.dimOpacity})],y.prototype,"dimOpacity",void 0);w([T({default:""})],y.prototype,"centerLabel",void 0);w([T({default:""})],y.prototype,"centerCaption",void 0);w([T({default:1})],y.prototype,"centerReveal",void 0);w([Tt()],y.prototype,"sweep",null);w([Tt()],y.prototype,"revealLabels",null);w([Tt()],y.prototype,"revealCenter",null);import{asCommand as fr,hold as mr,sequence as gr,together as yr}from"@motionscript/sdk/component";var A=function(o,e,t,i){var r=arguments.length,s=r<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,i);else for(var l=o.length-1;l>=0;l--)(n=o[l])&&(s=(r<3?n(s):r>3?n(e,t,s):n(e,t))||s);return r>3&&s&&Object.defineProperty(e,t,s),s},xr=.65,Et=.35,x=class extends ur{ring;legend=null;get resolvedTheme(){return this.theme}get slices(){return gt(this.data,this.categoryField,this.valueField,this.resolvedTheme.sliceFills)}sliceDims(){let e=0;for(let i=0;i<this.data.length;i++)e=Math.max(e,this.popAt(i));let t=this.resolvedTheme.spotlight.dimOpacity;return e<=0?this.data.map(()=>1):this.data.map((i,r)=>1-(1-f(t))*e*(1-this.popAt(r)))}popAt(e){return f(this.pops[e]??0)}constructor(e){super(e);let t=this.slices,i=e?.showLegend!==!1;this.pops=t.map(()=>0),this.ring=new y({width:"fill",height:"fill",slices:t,ring:()=>this.resolvedTheme.ring,label:()=>this.resolvedTheme.label,centerStyle:()=>this.resolvedTheme.center,labelMode:this.labelMode,labelPlacement:this.labelPlacement,pops:()=>this.pops,dimOpacity:()=>this.resolvedTheme.spotlight.dimOpacity,centerLabel:this.centerLabel,centerCaption:this.centerCaption,centerReveal:e?.showCenter===!1?0:1});let r=[this.ring];i&&(this.legend=new V({slices:t,legend:()=>this.resolvedTheme.legend,dims:()=>this.sliceDims()}),r.push(this.legend)),this.add(new dr({flow:"horizontal",width:"fill",height:"fill",gap:this.gap,align:"center",children:r}))}arm(){this.ring.set({growth:0,labelReveal:0}),this.legend?.arm()}enter(e){let t=e.duration,i=e.easing??ye();return this.arm(),fr(gr(this.ring.sweep({duration:t*xr,easing:i}),yr(this.ring.revealLabels({duration:t*Et,easing:i}),this.legend?this.legend.enter({duration:t*Et,easing:i}):mr(t*Et))),t)}revealCenter(e={}){return this.ring.revealCenter({duration:e.duration??.6,easing:e.easing??ye()})}isSelected(e){return this.popAt(e)>.5}selectSlice(e){let{sliceIndex:t}=e.data,i=e.duration??.45,r=e.easing??ye();return this.tweenPops(s=>s===t?1:this.popAt(s),i,r)}deselectSlice(e){let{sliceIndex:t}=e.data,i=e.duration??.45,r=e.easing??ye();return this.tweenPops(s=>s===t?0:this.popAt(s),i,r)}selectOnlySlice(e){let{sliceIndex:t}=e.data,i=e.duration??.45,r=e.easing??ye();return this.tweenPops(s=>s===t?1:0,i,r)}clearSelection(e={}){let t=e.duration??.45,i=e.easing??ye();return this.tweenPops(()=>0,t,i)}tweenPops(e,t,i){let r=this.data.map((n,l)=>this.popAt(l)),s=this.data.map((n,l)=>f(e(l)));return r.every((n,l)=>n===s[l])?this.command(()=>({}),t):this.command(n=>({pops:r.map((l,a)=>l+(s[a]-l)*n)}),t,i)}};A([G({default:()=>[]})],x.prototype,"data",void 0);A([G({default:""})],x.prototype,"categoryField",void 0);A([G({default:""})],x.prototype,"valueField",void 0);A([G({default:K,mapper:vt,tween:bt})],x.prototype,"theme",void 0);A([G({default:"percent"})],x.prototype,"labelMode",void 0);A([G({default:"leader"})],x.prototype,"labelPlacement",void 0);A([G({default:40})],x.prototype,"gap",void 0);A([G({default:""})],x.prototype,"centerLabel",void 0);A([G({default:""})],x.prototype,"centerCaption",void 0);A([G({default:()=>[]})],x.prototype,"pops",void 0);A([xe()],x.prototype,"enter",null);A([xe()],x.prototype,"revealCenter",null);A([xe({args:[{key:"sliceIndex",kind:"number",default:0,min:0,step:1}]})],x.prototype,"selectSlice",null);A([xe({args:[{key:"sliceIndex",kind:"number",default:0,min:0,step:1}]})],x.prototype,"deselectSlice",null);A([xe({args:[{key:"sliceIndex",kind:"number",default:0,min:0,step:1}]})],x.prototype,"selectOnlySlice",null);A([xe()],x.prototype,"clearSelection",null);x=A([pr({key:"pieChart",parentKey:"node",forkable:!0,layout:{children:"freeform",defaultWidthMode:"fixed",defaultHeightMode:"fixed",acceptsChildren:!0},seed:{width:680,height:480}})],x);var vr=[m,g,x];export{g as BarChart,O as CHART_PALETTE,B as CategoryAxis,S as ChartBars,De as ChartBorder,Ie as ChartCanvas,Be as ChartLegend,_ as ChartLine,j as ChartRegion,W as DEFAULT_BAR_CHART_THEME,Q as DEFAULT_CHART_THEME,X as DEFAULT_LEGEND,K as DEFAULT_PIE_CHART_THEME,Ee as DEFAULT_PLOT_AREA,br as DEFAULT_SERIES_COLORS,_e as DEFAULT_SERIES_FILLS,Mt as DEFAULT_SERIES_STROKES,H as DEFAULT_X_AXIS,Te as DEFAULT_Y_AXIS,ae as EMPTY_REGION_BOX,D as HorizontalAxis,m as LineChart,vr as NODES,x as PieChart,V as PieLegend,y as PieRing,P as SPOTLIGHT_DIM,le as VerticalAxis,ht as barCategories,je as barSpans,pi as barValueExtent,f as clampUnit,Qe as clipPolylineToBox,Fe as enterBudget,ei as formatInstant,F as formatMarker,Oe as formatPercent,he as hasRegion,re as lerpAxisConfig,q as lerpAxisDomain,pt as lerpBarChartTheme,tt as lerpChartTheme,ne as lerpLegendConfig,bt as lerpPieChartTheme,Le as lerpPlotArea,Ce as lerpSeriesFills,kt as lerpSeriesStrokes,z as markerValues,Pe as niceStep,E as num,Sr as numericFields,Qt as parseInstant,xt as pieArcs,Ze as relaxLabels,se as resolveAxisConfig,te as resolveAxisDomain,dt as resolveBarChartTheme,Ye as resolveBarFill,ct as resolveBarScale,et as resolveChartTheme,oe as resolveLegendConfig,Ar as resolvePalettePaint,vt as resolvePieChartTheme,gt as resolvePieSlices,Me as resolvePlotArea,Je as resolveRegionBox,Ot as resolveSeriesFill,ke as resolveSeriesFills,Ct as resolveSeriesStroke,Lt as resolveSeriesStrokes,ot as resolveXScale,st as resolveYScale,fe as ringPoint,it as seriesPoints,bi as sliceTotal,yt as sliceValue,at as stackCapIndex,ie as text,Dt as yExtent};
|
|
1
|
+
import{$ as Te,A as xe,B as $,C as j,D as ye,E as be,F as K,G as q,H as Gt,I as Ht,J as we,K as Se,L as Ut,M as Nt,N as Ho,O as F,P as Ae,Q as $e,R as C,S as ue,T as ke,U as Xt,V as I,W as Uo,X as ve,Y as Ee,Z as Re,_ as D,a as f,aa as Le,b as z,ba as Z,c as b,ca as No,d as S,e as Io,f as V,g as w,h as N,i as O,j as Y,k as ae,l as Do,m as le,n as ce,o as v,p as Bo,q as E,r as x,s as A,t as W,u as Go,v as T,w as ge,x as me,y as L,z as Bt}from"./chunks/chunk-XROBIRQK.js";import{Rect as Sn,Types as G,component2d as An,easeOut as B}from"@motionscript/sdk";import{formatNumber as kn}from"@motionscript/sdk/component";import{Graphics2D as et,Types as tt,component2d as dn,strokeOps as Wt}from"@motionscript/sdk";import{Fills as rn,fillOps as zt,lerpNumber as nn,strokeOps as Vt}from"@motionscript/sdk";var J={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function Q(e){return e.right>e.left&&e.top>e.bottom}function je(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return J;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let y=Math.min(d[0],d[1]),U=Math.max(d[0],d[1]),k=We=>g+(We-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,k(y))),Math.max(g,Math.min(p,k(U))),!0]},[i,s,a]=o(e.x,r,t.left,t.right),[c,l,u]=o(e.y,n,t.bottom,t.top);return{left:i,right:s,bottom:c,top:l,xBounded:a,yBounded:u}}function Ke(e,t){if(e.length<2||!Q(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=sn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&on(n[n.length-1],s)?n.push(a):(n.length>=2&&r.push(n),n=[s,a])}return n.length>=2&&r.push(n),r}function on(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function sn(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-n,e.x-r.left],[n,r.right-e.x],[-o,e.y-r.bottom],[o,r.top-e.y]];for(let[c,l]of a){if(c===0){if(l<0)return null;continue}let u=l/c;if(c<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*n,y:e.y+i*o},{x:e.x+s*n,y:e.y+s*o}]}var an={...L,markerStyle:{...L.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:T,yAxis:ge,plotArea:me,legend:an,region:{stroke:{weight:3,fill:v.regionColor,dash:[14,12],cap:"butt"},fill:rn.color(v.regionColor,{opacity:.08}),dimOpacity:E}};function ln(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:zt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function cn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:zt.lerp(e.fill,t.fill,r),dimOpacity:nn(e.dimOpacity,t.dimOpacity,r)}}function qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),region:ln(e?.region,r.region)}}function Ze(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),region:cn(e.region,t.region,r)}}function Je(e,t,r){return e.map((n,o)=>[t.at(o),A(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Yt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=A(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function Qe(e,t,r,n){if(r)return r;let[o,i]=Yt(e,t),s=Math.max(1,Math.round(n));if(i===o)return un(o,s);let a=ue((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function un(e,t){if(e===0)return[0,1];let r=ue(Math.abs(e)/t);return[e-r,e+r]}function hn(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let r=[],n=0;for(let s=1;s<e.length;s++){let a=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);r.push(a),n+=a}if(n===0)return e;let o=n*t,i=[e[0]];for(let s=0;s<r.length;s++)if(o>=r[s])i.push(e[s+1]),o-=r[s];else{let a=r[s]===0?0:o/r[s];i.push({x:e[s].x+(e[s+1].x-e[s].x)*a,y:e[s].y+(e[s+1].y-e[s].y)*a});break}return i}var Ce=dn({key:"chartLine",state:{points:f(()=>[]),stroke:tt.custom([],{resolve:Wt.resolve,lerp:Wt.lerp}),progress:1,enabled:!0,spotlight:f(()=>J),dimOpacity:E},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:tt.number(0,{min:0,max:1}),to:tt.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=b(e);return e.animate(o=>{let i=t+(r-t)*n(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let r=t.points;if(r.length<2)return;let n=Math.max(0,Math.min(1,t.progress));if(n<=0)return;let o=hn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!Q(a)){e.draw(new et().line({points:o,radius:s}).stroke(i));return}e.draw(new et().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Ke(o,a))e.draw(new et().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as $t,Types as jt,component2d as pn,fillOps as Kt,strokeOps as qt}from"@motionscript/sdk";var rt=pn({key:"chartRegion",state:{box:f(()=>J),stroke:jt.custom(X.region.stroke,{resolve:qt.resolve,lerp:qt.lerp}),fill:jt.custom(X.region.fill,{resolve:Kt.resolve,lerp:Kt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!Q(r))return;let n=Math.max(0,Math.min(1,t.reveal));if(n<=0)return;let o=r.right-r.left,i=r.top-r.bottom,s=(r.left+r.right)/2,a=(r.bottom+r.top)/2;if(t.fill.length>0&&e.draw(new $t().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(n)),t.stroke.length===0)return;let c=l=>e.draw(new $t().line({points:l}).stroke(t.stroke).opacity(n));if(r.xBounded){let l=i/2*n;for(let u of[r.left,r.right])c([{x:u,y:a-l},{x:u,y:a+l}])}if(r.yBounded){let l=o/2*n;for(let u of[r.bottom,r.top])c([{x:s-l,y:u},{x:s+l,y:u}])}}});import{Rect as Zt,Text as Jt,Types as nt,component2d as fn,insetsOps as Qt,textOps as er}from"@motionscript/sdk";var gn=24,Me=fn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:nt.custom(T),label:"",arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=Qt.resolve(e.axis.tickPadding).top,r=Qt.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds??{width:0,height:0},i=()=>[...e.markers].sort((l,u)=>l-u),s=l=>{if(l===void 0)return 0;let[u,d]=e.range;return d<=u?0:(l-u)/(d-u)},a=e.markers.map((l,u)=>{let d=new Jt({...er.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":Xt(e,h)},x:()=>{let h=o().width,m=(s(i()[u])-.5)*h,g=h/2-d.layoutBounds.width/2;return Math.min(m,g)},opacity:()=>w(e.arrivals,u).opacity,y:()=>w(e.arrivals,u).shift});return d}),c=[new Zt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Jt({...er.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new Zt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:nt.custom(void 0),slide:nt.number(gn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.markers.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.markers.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=t.markers.map((p,y)=>({at:y*l,duration:u,piece:O(e,y,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:O(e,"label",s,h)}]:[];return e.together([c,S(e,[...m,...g])])}}}});import{formatNumber as mn}from"@motionscript/sdk/component";var _e=864e5,sr=["january","february","march","april","may","june","july","august","september","october","november","december"],tr=2024;function rr(e){return e.length<3?-1:sr.findIndex(t=>t.startsWith(e))}function xn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*_e+(t-1)*7*_e}function ir(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let r=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(r){let s=Number(r[2]),a=r[3]===void 0?1:Number(r[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(r[1]),s-1,a)}let n=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(n){let s=Number(n[2]);return s<1||s>53?null:xn(n[1]===void 0?tr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=rr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?tr:Number(a);return Date.UTC(c,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=rr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function ar(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=sr[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*_e?String(n):t>60*_e?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function yn(e,t){let r=!1;for(let n of e){let o=n[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;r=!0}}return r}function bn(e,t){let r=[],n=!1;for(let s of e){let a=s[t];if(a==null||a===""){r.push(null);continue}let c=ir(a);if(c===null)return null;r.push(c),n=!0}if(!n)return null;let i=r.find(s=>s!==null);return r.map(s=>s===null?i:i=s)}function nr(e){let t=1/0,r=-1/0;for(let n of e)n<t&&(t=n),n>r&&(r=n);return t<=r?[t,r]:[0,1]}function or(e,[t,r],n){let o=e.filter(c=>c>=t&&c<=r),i=[...new Set(o)].sort((c,l)=>c-l);if(i.length===0)return C([t,r],n);let s=c=>i.reduce((l,u)=>Math.abs(u-c)<Math.abs(l-c)?u:l),a=[];for(let c of C([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function wn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}function ot(e,t,r){if(t!==""&&yn(e,t)){let s=e.map(a=>A(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:nr(s),label:a=>r===void 0?F(a):mn(a,r),ticks:C}}let n=e.map(s=>W(s,t)),o=t===""?null:bn(e,t);if(o){let s=nr(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>wn(o,n,c,l=>ar(l,a)),ticks:(c,l)=>or(o,c,l)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>n[Math.round(s)]??"",ticks:(s,a)=>or(i,s,a)}}var st=G.custom(0,{kind:"series",min:0,step:1}),lr=G.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),vn=20,it=5,En=.35,Rn=.5,Tn=.15;function lt(e,t=e.xAxis.format){return ot(e.data,e.xField,t)}function Ln(e,t){let r=lt(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,it-1)}}function Cn(e,t){let r=(t.ticks?.length??it)-1,n=Qe(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??C(n,it-1)}}function Pe(e){return{x:ce(e.xAxis,t=>Ln(e,t)),y:ce(e.yAxis,t=>Cn(e,t))}}function Mn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=Je(e.data,lt(e),o);if(i.length===0)return[];let{width:s,height:a}=n,[c,l]=t.x.range,[u,d]=t.y.range,h=g=>l<=c?0:((g-c)/(l-c)-.5)*s,m=g=>d<=u?0:((g-u)/(d-u)-.5)*a;return i.map(([g,p])=>({x:h(g),y:m(p)}))}function cr(e,t,r){let{width:n,height:o}=r;return je(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function ur(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function dr(e){return e!=null&&typeof e=="object"?e:{}}function _n([e,t]){return e<=t?[e,t]:[t,e]}function hr(e,t){let r=_n(e);return{range:r,ticks:C(r,Math.max(2,t.length)-1)}}function pr(e,t,r){return{...t.x&&{xAxis:ae(e.x,t.x,r)},...t.y&&{yAxis:ae(e.y,t.y,r)}}}function at(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Me.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(Ce.is),legend:t.below.find(Z.is)??null}}function fr(e,t){let r=t.regionReveal,n=t.region;return r===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:n,regionReveal:r*(1-o)})}function gr(e,t,r,n){let o=at(t),i=o?.lines[r];return!o||!i?e.wait(e.duration):e.together([i.run("enter",n?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(n?"showSeries":"hideSeries",{index:r})]:[]])}var ct=An({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:G.custom({},{resolve:Y,lerp:le}),yAxis:G.custom({},{resolve:Y,lerp:le}),theme:G.custom(X,{resolve:qe,lerp:Ze}),region:G.custom(null),regionReveal:0,showLegend:G.boolean(!0,{animatable:!1}),home:G.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},children:e=>{let t=()=>e.theme,r=()=>Pe(e),n,o=()=>Re(n),i=e.series.map(d=>d.enabled??!0),s=new I({range:()=>r().y.range,markers:()=>r().y.ticks,captions:()=>{let d=r().y.ticks,h=e.yAxis.format;return d.map(m=>h===void 0?F(m,Ae(d)):kn(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Me({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=lt(e);return r().x.ticks.map(h=>d.label(h))},axis:()=>t().xAxis,label:e.xAxis.label??"",width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ce({points:()=>Mn(e,r(),h,o()),stroke:()=>Ut(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>cr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>Nt(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Sn({clip:!0,children:[new Le({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:()=>r().x.ticks,yMarkers:()=>r().y.ticks,xExtent:()=>r().x.range,yExtent:()=>r().y.range}),new rt({box:()=>cr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Te({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().y.range,markers:()=>r().y.ticks,axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:0});return[...e.children,ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.duration,i=ur(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*En,c=s*Rn,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return S(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-vn}))]:[],{at:0,duration:a,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:a,piece:n.hAxis.run("enter",{slide:24})},...n.lines.map(d=>({at:a,duration:c,piece:d.run("enter")})),...l?[{at:a+c,duration:s*Tn,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:lr},easing:B(),run:(e,t)=>{let r=dr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?fr(e,t):n<=0||!ur(t)?e.animate(i=>({region:r,regionReveal:n+(1-n)*i})):e.animate(i=>i<.5?{region:o,regionReveal:n*(1-e.ease(i*2))}:{region:r,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:B(),run:(e,t)=>fr(e,t)},zoomTo:{args:{region:lr},easing:B(),run:(e,t)=>{let r=dr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Pe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...hr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...hr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...pr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Pe(t);return e.animate(o=>({home:null,...pr(n,r,o)}))}},showSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>gr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>gr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:st},easing:B(),run:(e,t,r)=>{let n=at(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...n.lines.map((i,s)=>i.to({opacity:s===o?1:E})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Wn,Types as _,component2d as $n,easeOut as ee}from"@motionscript/sdk";import{formatNumber as jn}from"@motionscript/sdk/component";import{Rect as ut,Text as mr,Types as dt,component2d as Pn,insetsOps as xr,textOps as yr}from"@motionscript/sdk";var On=24,Oe=Pn({key:"categoryAxis",state:{categories:f(()=>[]),axis:dt.custom(T),label:"",dims:f(()=>[]),arrivals:V()},defaults:{width:"fill",height:"fill"},children:e=>{let t=xr.resolve(e.axis.tickPadding).top,r=xr.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds.width??0,i=c=>{let l=e.categories.length;return l<=0?0:-o()/2+o()/l*(c+.5)},s=e.categories.map((c,l)=>new ut({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[l]??1),x:()=>i(l),children:[new mr({...yr.styleProps(e.axis.labelStyle),text:c,opacity:()=>w(e.arrivals,l).opacity,y:()=>w(e.arrivals,l).shift})]})),a=[new ut({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new mr({...yr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>w(e.arrivals,"label").opacity,y:()=>w(e.arrivals,"label").shift})),n.push(new ut({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:dt.custom(void 0),slide:dt.number(On)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.categories.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:N(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=ke(e.duration,o,i,r),h=b(e),m=(o-1)*l+u,g=t.categories.map((y,U)=>({at:U*l,duration:u,piece:O(e,U,s,h)})),p=i?[{at:m,duration:d,piece:O(e,"label",s,h)}]:[];return e.together([c,S(e,[...g,...p])])}}}});import{Graphics2D as Bn,Text as Gn,Types as Be,component2d as Hn,fillOps as kr,shadowOps as vr,strokeOps as Er,textOps as Un}from"@motionscript/sdk";import{fillOps as Fn,lerpNumber as Fe,shadowOps as br,strokeOps as wr,textOps as Sr}from"@motionscript/sdk";function Ie(e,t,r){let n=0;return t.map(o=>{let i=A(e,o.field);if(!r)return{from:0,to:i,value:i};let s=n;return n+=i,{from:s,to:n,value:i}})}function ht(e,t){let r=-1;for(let n=0;n<t.length;n++)A(e,t[n].field)!==0&&(r=n);return r}function pt(e,t){return e.map(r=>W(r,t))}function Ar(e,t,r){let n=0,o=0;for(let i of e)for(let s of Ie(i,t,r))n=Math.min(n,s.from,s.to),o=Math.max(o,s.from,s.to);return n<o?[n,o]:[0,1]}function ft(e,t,r,n,o){if(n)return n;let[i,s]=Ar(e,t,r),a=Math.max(1,Math.round(o)),c=ue((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var M={seriesFills:xe,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...T,labelStyle:{...T.labelStyle,fontWeight:600},tickPadding:16},yAxis:ge,plotArea:me,legend:L,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:v.markerColor},spotlight:{dimOpacity:E}};function In(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:wr.resolve(e?.stroke??t.stroke),shadow:br.resolve(e?.shadow??t.shadow)}}function Dn(e,t,r){return{cornerRadius:Fe(e.cornerRadius,t.cornerRadius,r),slotFill:Fe(e.slotFill,t.slotFill,r),groupGap:Fe(e.groupGap,t.groupGap,r),stroke:wr.lerp(e.stroke,t.stroke,r),shadow:br.lerp(e.shadow,t.shadow,r)}}function gt(e,t){let r=t??M;return{seriesFills:we(e?.seriesFills,r.seriesFills),bar:In(e?.bar,r.bar),xAxis:$(e?.xAxis,r.xAxis),yAxis:$(e?.yAxis,r.yAxis),plotArea:ye(e?.plotArea,r.plotArea),legend:K(e?.legend,r.legend),valueStyle:Sr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function mt(e,t,r){return{seriesFills:Se(e.seriesFills,t.seriesFills,r),bar:Dn(e.bar,t.bar,r),xAxis:j(e.xAxis,t.xAxis,r),yAxis:j(e.yAxis,t.yAxis,r),plotArea:be(e.plotArea,t.plotArea,r),legend:q(e.legend,t.legend,r),valueStyle:Sr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:Fe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function De(e,t,r){return t.fill!=null?Fn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var Nn=10,Xn=1.6,zn=24;function Rr(e,t){return e.enabled?x(e.dims[t]??1):0}function xt(e,t){let r=e.bars[t];if(!r)return null;let n=x(e.growth);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function Tr(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:zn}function Lr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function Vn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Lr(e,t)){let n=xt(e,t);if(!n||Math.abs(n.end-n.base)<Tr(e)*Xn)return""}return r.caption??F(r.value)}function Yn(e,t){let r=xt(e,t);if(!r)return 0;if(Lr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(Nn+Tr(e)/2)}var Ge=Hn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:Be.custom([],{resolve:kr.resolve,lerp:kr.lerp}),barStroke:Be.custom(M.bar.stroke,{resolve:Er.resolve,lerp:Er.lerp}),barShadow:Be.custom(M.bar.shadow,{resolve:vr.resolve,lerp:vr.lerp}),cornerRadius:M.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:Be.custom(M.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Gn({...Un.styleProps(e.valueStyle),text:()=>Vn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Yn(e,r),opacity:()=>Rr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))}},render:(e,t)=>{if(t.enabled)for(let r=0;r<t.bars.length;r++){let n=t.bars[r],o=xt(t,r);if(!o||n.width<=0)continue;let i=Math.abs(o.end-o.base);if(i<=0)continue;let s=n.round?Math.min(t.cornerRadius,i):0,a=new Bn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Rr(t,r)))}e.children()}});var yt=_.custom(0,{kind:"series",min:0,step:1}),Kn=20,Cr=5,qn=.35,Zn=.5,Jn=.15;function Qn(e,t){let r=(t.ticks?.length??Cr)-1,n=ft(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??C(n,Cr-1)}}function St(e){return ce(e.valueAxis,t=>Qn(e,t))}function Pr(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ae(t.ticks)):jn(r,n)}function bt(e,t,r){let[n,o]=e.range;return o<=n?-t.height/2:((r-n)/(o-n)-.5)*t.height}function eo(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function de(e,t){return Math.max(0,e.weights[t]??1)}function to(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*de(e,o))}),r}function ro(e,t,r,n){let o=e.series[t];if(!o)return[];let i=St(e),s=e.data.length,a=s>0?r.width/s:0,c=p=>-r.width/2+a*(p+.5),l=a*x(e.theme.bar.slotFill),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=de(e,p);let h=l/(d>0?d:1),m=de(e,t),g=0;for(let p=0;p<t;p++)g+=de(e,p);return e.data.map((p,y)=>{let k=Ie(e.stacked?to(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},We=e.stacked?ht(p,e.series):t,Qr=c(y)-l/2,en=e.stacked?c(y):Qr+h*g+h*m/2,tn=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=A(p,o.field);return{x:en,width:tn,from:bt(i,r,k.from),to:bt(i,r,k.to),round:We===t,value:Dt,...n&&{caption:Pr(e,i,Dt)}}})}function Mr(e){let t=x(e.spotlightReveal),r=e.theme.spotlight.dimOpacity,n=e.spotlight;return e.data.map((o,i)=>t<=0||n===i?1:1-(1-r)*t)}function wt(e){let t=Ee(e);if(!t)return null;let r=t.below.find(Oe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ge.is),legend:t.below.find(Z.is)??null}}function _r(e,t,r,n,o){let i=wt(r);if(!i||!i.bars[n])return e.wait(e.duration);let s=t.series.map((l,u)=>de(t,u)),a=s[n]??1,c=t.series.map((l,u)=>t.showing[u]??l.enabled??!0);return e.together([e.animate(l=>{let u=[...s];u[n]=a+(o-a)*e.ease(l);let d=[...c];return d[n]=o>0||l<1,{weights:u,showing:d}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:n})]:[]])}var At=$n({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:_.custom({},{resolve:Y,lerp:le}),categoryAxis:_.custom({},{resolve:Y,lerp:ae}),theme:_.custom(M,{resolve:gt,lerp:mt}),growth:1,weights:f(()=>[]),spotlight:_.custom(null),spotlightReveal:0,showLegend:_.boolean(!0,{animatable:!1}),showValues:_.boolean(!1,{animatable:!1}),showing:_.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Re(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Pr(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Oe({categories:pt(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Mr(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ge({bars:()=>ro(e,h,o(),i),baseline:()=>eo(r(),o()),fill:()=>De(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Mr(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Z({series:e.series,swatches:()=>e.series.map((d,h)=>De(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Wn({clip:!0,children:[new Le({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:[],yMarkers:()=>r().ticks,xExtent:()=>[0,1],yExtent:()=>r().range}),...c,new Te({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().range,markers:()=>r().ticks,axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:0});return[...e.children,ve({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*qn,s=o*Zn,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return S(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-Kn}))]:[],{at:0,duration:i,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:i,piece:n.cAxis.run("enter",{slide:24})},{at:i,duration:s,piece:e.animate(l=>({growth:l}))},...a?[{at:i+s,duration:o*Jn,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>_r(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>_r(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:yt},easing:ee(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex,i=t.theme.spotlight.dimOpacity;return e.together([...n.bars.map((s,a)=>s.to({opacity:a===o?1:i})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}},spotlightCategory:{args:{categoryIndex:_.number(0,{min:0,step:1})},easing:ee(),run:(e,t)=>{let r=e.args.categoryIndex;if(r<0||r>=t.data.length)return e.wait(e.duration);let n=t.spotlightReveal;return e.animate(o=>({spotlight:r,spotlightReveal:n+(1-n)*o}))}},clearCategory:{args:{},easing:ee(),run:(e,t)=>{let r=t.spotlightReveal;if(r===0)return e.wait(e.duration);let n=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:n,spotlightReveal:r*(1-o)})}}}});import{Rect as Jr,Types as se,component2d as Co,easeOut as oe}from"@motionscript/sdk";import{Flow as kt,Paint as he,Rect as vt,Shapes as Or,Text as no,Types as oo,component2d as so,textOps as io}from"@motionscript/sdk";var Fr=16,He=so({key:"pieLegend",state:{...he.state,...kt.state,...Or.corners,slices:f(()=>[]),legend:oo.custom(L),dims:f(()=>[]),arrivals:V()},defaults:{flow:"vertical",align:"centerLeft",width:"hug",height:"hug",gap:e=>e.legend.itemGap/3,padding:e=>e.legend.padding},children:e=>{let t=e.legend.markerStyle;return e.slices.map((r,n)=>vt({width:"hug",height:"hug",flow:"freeform",opacity:()=>x(e.dims[n]??1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>w(e.arrivals,n).opacity,x:()=>w(e.arrivals,n).shift,children:[vt({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:()=>e.slices[n]?.fill??"white",stroke:t.stroke,shadow:t.shadow}),no({...io.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...he.commands,arm:(e,t)=>e.animate(()=>({arrivals:N([...t.slices.keys()],{opacity:0,shift:Fr})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Fr},o=e.animate(()=>({arrivals:N([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=b(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:O(e,u,n,a)}));return e.together([o,S(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,he.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,he.inset(t)),render:(e,t)=>he.draw(e,t,Or.rect(e.size,t))});import{Graphics2D as Br,PathBuilder as go,Rect as Mt,Text as re,Types as fe,component2d as mo,fillOps as Gr,shadowOps as xo,strokeOps as Hr,textOps as ne}from"@motionscript/sdk";import{lerpNumber as pe,shadowOps as Ir,strokeOps as Ue,textOps as R}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:W(o,t),value:A(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var ao=Math.PI/180;function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Dr(e){let t=0;for(let r of e)t+=Tt(r);return t}function te(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ne(e,t){let r=Dr(e);if(r<=0)return[];let n=[],o=t*ao;return e.forEach((i,s)=>{let a=Tt(i);if(a<=0)return;let c=a/r,l=o,u=l+c*Math.PI*2;o=u,n.push({index:s,a0:l,a1:u,mid:(l+u)/2,fraction:c})}),n}function Xe(e,t,r,n){e.sort((s,a)=>a.ideal-s.ideal);let o=r;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=n;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Et={fontSize:26,fontWeight:600,textAlign:"center",fill:v.markerColor},P={sliceFills:xe,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:Et,percentStyle:{...Et,fontWeight:700},insideStyle:{...Et,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:v.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:v.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:v.markerColor}},legend:L,spotlight:{dimOpacity:E}};function lo(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:Ue.resolve(e?.stroke??t.stroke),shadow:Ir.resolve(e?.shadow??t.shadow)}}function co(e,t,r){return{gap:pe(e.gap,t.gap,r),holeRadius:pe(e.holeRadius,t.holeRadius,r),startAngle:pe(e.startAngle,t.startAngle,r),selectedGrow:pe(e.selectedGrow,t.selectedGrow,r),stroke:Ue.lerp(e.stroke,t.stroke,r),shadow:Ir.lerp(e.shadow,t.shadow,r)}}function uo(e,t){return{textStyle:R.resolveStyle(e?.textStyle,t.textStyle),percentStyle:R.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:R.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:Ue.resolve(e?.leaderStroke??t.leaderStroke)}}function ho(e,t,r){return{textStyle:R.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:R.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:R.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:Ue.lerp(e.leaderStroke,t.leaderStroke,r)}}function po(e,t){return{labelStyle:R.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:R.resolveStyle(e?.captionStyle,t.captionStyle)}}function fo(e,t,r){return{labelStyle:R.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:R.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??P;return{sliceFills:we(e?.sliceFills,r.sliceFills),ring:lo(e?.ring,r.ring),label:uo(e?.label,r.label),center:po(e?.center,r.center),legend:K(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Ct(e,t,r){return{sliceFills:Se(e.sliceFills,t.sliceFills,r),ring:co(e.ring,t.ring,r),label:ho(e.label,t.label,r),center:fo(e.center,t.center,r),legend:q(e.legend,t.legend,r),spotlight:{dimOpacity:pe(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var Ur=12,yo=14,_t=.62,bo=6,Nr=34,Xr=26,zr=8,wo=.18,So=240,Ao=8,Vr=2,jr=.44,Pt=.62,ko=.78,vo=.9,Yr=.001,Kr=26;function H(e,t=Kr){let r=e.fontSize;return typeof r=="number"?r:t}function Eo(e,t,r,n,o,i){let s=new go,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*So)),l=d=>d<=0?0:Math.min(o/d,a/2.2),u=(d,h)=>{let m=l(d),g=e+m,p=t-m,y=te(d,g+(p-g)*h/c);return{x:y.x+i,y:y.y}};if(r<=0){s.moveTo(i,0);for(let d=0;d<=c;d++){let h=u(n,d);s.lineTo(h.x,h.y)}return s.close(),s}for(let d=0;d<=c;d++){let h=u(n,d);d===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y)}for(let d=c;d>=0;d--){let h=u(r,d);s.lineTo(h.x,h.y)}return s.close(),s}var ze=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ne(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="leader"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let r=this.outerRadius,n=this.holeRadius,o=n>0?r-n:r*(1-Pt)*2,i=n>0?(n+r)/2:r*Pt,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),c=s>Yr?o/s:1/0,l=a>Yr?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(c,l))}insideGlyphs(t){let r=this.s.labelMode,n=this.s.slices[t.index]?.category.length??0,o=r==="both"||r==="percent"?$e(t.fraction).length:0,i=r==="category"?n:r==="both"?n*jr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,Kr*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*vo/(this.insideGlyphs(r)*_t);t=Math.min(t,n)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:r,centerCaption:n}=this.s,o=H(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=H(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,r.length,n.length*s);return Math.min(o,i*2*ko/(a*_t))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=H(this.s.label.textStyle)*1.25,r=H(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+r+2:this.s.labelMode==="category"?t:r}captionGlyphs(t){let r=this.s.labelMode,n=r==="percent"||r==="both"?4:0,o=r==="category"||r==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(n,o)}get labelGutters(){let t={left:Vr,right:Vr};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Nr+Xr+zr+this.captionGlyphs(n.index)*r+yo,i=Ot(n.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:r}=this.labelGutters;return(t-r)/2}get outerRadius(){let{left:t,right:r}=this.labelGutters,n=Math.min((this.box.width-t-r)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,n/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let r=t<1?t*this.outerRadius:t;return Math.min(r,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+Nr}popOf(t){return x(this.s.pops[t]??0)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let r=this.anchorRadius(t),n=this.holeRadius;return n>0?(n+r)/2:r*Pt}insideAnchor(t){let r=this.arcs.find(o=>o.index===t);if(r===void 0)return{x:this.centerX,y:0};let n=te(this.bandMidRadius(t),r.mid);return{x:n.x+this.centerX,y:n.y}}get selectionStrength(){let t=0;for(let r=0;r<this.s.slices.length;r++)t=Math.max(t,this.popOf(r));return t}sliceOpacity(t){let r=this.selectionStrength;return r<=0?1:1-(1-x(this.s.dimOpacity))*r*(1-this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return $e(r?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let r=this.elbowRadius,n=this.labelRowHeight,o=this.box.height/2-n/2,i=-o,s=this.centerX,a=[],c=[];for(let l of t){let u=Ot(l.mid),d=te(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return Xe(a,n+Ur,o,i),Xe(c,n+Ur,o,i),[...a,...c].map(l=>{let u=te(this.anchorRadius(l.index)+bo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*wo),m=s+l.side*(r+Xr);return{index:l.index,side:l.side,leader:[{x:u.x+s,y:u.y},{x:h,y:l.y},{x:m,y:l.y}],text:{x:m+l.side*zr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var Ro={width:0,height:0},Wr=new WeakMap;function To(e){if(typeof e!="object"||e===null)return Gr.resolve(e);let t=Wr.get(e);return t===void 0&&Wr.set(e,t=Gr.resolve(e)),t}function $r(e){return e.map(t=>To(t.fill))}function Lo(e){let t=[],r=()=>new ze(e,t[0]?.parent?.layoutBounds??Ro),n=o=>{let i=()=>x(e.labelReveal)*r().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let d=[];return a&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new re({...ne.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*jr})),new Mt({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>r().insideAnchor(o.index),children:d})}let c=Ot(o.mid),l=()=>r().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new re({...ne.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new re({...ne.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Mt({flow:"vertical",width:"hug",height:"hug",gap:2,align:c>0?"centerLeft":"centerRight",opacity:i,centerLeft:c>0?l:void 0,centerRight:c>0?void 0:l,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ne(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new re({...ne.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new re({...ne.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Mt({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>x(e.centerReveal),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var Ve=mo({key:"pieRing",state:{slices:f(()=>[]),ring:fe.custom(P.ring),label:fe.custom(P.label),centerStyle:fe.custom(P.center),labelMode:fe.custom("percent"),labelPlacement:fe.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:P.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Lo(e),load:(e,t)=>D(e,{fills:$r(t.slices),shadows:[xo.resolve(t.ring.shadow)],strokes:[Hr.resolve(t.ring.stroke),Hr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=b(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=b(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=b(e),n=x(t.centerReveal);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new ze(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=x(t.growth),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=r.holeRadius,c=Math.max(0,t.ring.gap)/2,l=r.centerX,u=n+r.maxPop+1+Math.abs(l),d=[-u,-u,u,u],h=u*2,m=$r(t.slices);for(let p of o){let y=Math.min(p.a1,s);if(y<=p.a0)continue;let U=Eo(p.a0,y,a,r.anchorRadius(p.index),c,l),k=new Br().path(U.toPathState({centerBounds:d,width:h,height:h}));k.shadow(t.ring.shadow),k.fill(m[p.index]??[]),k.stroke(t.ring.stroke),e.draw(k.opacity(r.sliceOpacity(p.index)))}let g=x(t.labelReveal);if(g>.001)for(let p of r.placements())e.draw(new Br().line({points:p.leader,radius:Ao}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Mo=.65,_o=.35,Ft=se.number(0,{min:0,step:1});function qr(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ie(e,t){return x(e.pops[t]??0)}function Po(e,t){return ie(e,t)>.5}function Oo(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ie(e,n));let r=e.theme.spotlight.dimOpacity;return t<=0?e.data.map(()=>1):e.data.map((n,o)=>1-(1-x(r))*t*(1-ie(e,o)))}function Ye(e,t,r){let n=t.data.map((i,s)=>ie(t,s)),o=t.data.map((i,s)=>x(r(s)));return n.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:n.map((s,a)=>s+(o[a]-s)*i)}))}function Zr(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=Jr.is(r)?r.children.find(Ve.is):void 0;if(n)return{ring:n,legend:r.children.find(He.is)??null}}return null}var It=Co({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:se.custom(P,{resolve:Lt,lerp:Ct}),labelMode:se.custom("percent"),labelPlacement:se.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:se.boolean(!0,{animatable:!1}),showCenter:se.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>qr(e).map(()=>0)},children:e=>{let t=()=>e.theme,r=()=>qr(e),n=[new Ve({width:"fill",height:"fill",slices:r,ring:()=>t().ring,label:()=>t().label,centerStyle:()=>t().center,labelMode:e.labelMode,labelPlacement:e.labelPlacement,pops:()=>e.pops,dimOpacity:()=>t().spotlight.dimOpacity,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})];e.showLegend!==!1&&n.push(new He({slices:r,legend:()=>t().legend,dims:()=>Oo(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new Jr({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[...e.children,o]},commands:{enter:{args:{},easing:oe(),run:(e,t,r)=>{let n=Zr(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Mo,a=e.duration*_o,c=l=>({at:0,duration:0,piece:l});return S(e,[c(o.to({growth:0,labelReveal:0})),...i?[c(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:oe(),run:(e,t,r)=>Zr(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return Ye(e,t,n=>n===r?1:ie(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return Ye(e,t,n=>n===r?0:ie(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:oe(),run:(e,t)=>{let r=e.args.sliceIndex;return Ye(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:oe(),run:(e,t)=>Ye(e,t,()=>0)}}});var Fo=[ct,At,It];export{At as BarChart,v as CHART_PALETTE,Oe as CategoryAxis,Ge as ChartBars,Te as ChartBorder,Le as ChartCanvas,Z as ChartLegend,Ce as ChartLine,rt as ChartRegion,M as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,L as DEFAULT_LEGEND,P as DEFAULT_PIE_CHART_THEME,me as DEFAULT_PLOT_AREA,Bo as DEFAULT_SERIES_COLORS,xe as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,T as DEFAULT_X_AXIS,ge as DEFAULT_Y_AXIS,J as EMPTY_REGION_BOX,Me as HorizontalAxis,Io as LANDED,ct as LineChart,Fo as NODES,It as PieChart,He as PieLegend,Ve as PieRing,E as SPOTLIGHT_DIM,Uo as TOP_HEADROOM,I as VerticalAxis,N as armed,O as arrival,w as arrivalOf,V as arrivalsEntry,z as asParts,Do as axisTweenTarget,pt as barCategories,St as barChartDomain,Ie as barSpans,Ar as barValueExtent,S as beats,ve as cartesianFrame,Ee as cartesianViews,x as clampUnit,Ke as clipPolylineToBox,ke as enterBudget,ar as formatInstant,F as formatMarker,$e as formatPercent,b as frameEase,f as fresh,Q as hasRegion,Po as isSliceSelected,Re as laidOutSize,No as legendShows,j as lerpAxisConfig,ae as lerpAxisDomain,le as lerpAxisEntry,mt as lerpBarChartTheme,Ze as lerpChartTheme,q as lerpLegendConfig,Ct as lerpPieChartTheme,be as lerpPlotArea,Se as lerpSeriesFills,Ht as lerpSeriesStrokes,Pe as lineChartDomains,D as loadPaints,Xt as markerCaption,Ae as markerStep,C as markerValues,ue as niceStep,A as num,Go as numericFields,ir as parseInstant,Ne as pieArcs,Xe as relaxLabels,$ as resolveAxisConfig,Y as resolveAxisDomain,gt as resolveBarChartTheme,De as resolveBarFill,ft as resolveBarScale,qe as resolveChartTheme,K as resolveLegendConfig,Ho as resolvePalettePaint,Lt as resolvePieChartTheme,Rt as resolvePieSlices,ye as resolvePlotArea,je as resolveRegionBox,Nt as resolveSeriesFill,we as resolveSeriesFills,Ut as resolveSeriesStroke,Gt as resolveSeriesStrokes,ot as resolveXScale,Qe as resolveYScale,te as ringPoint,Je as seriesPoints,ce as settleAxisDomain,Dr as sliceTotal,Tt as sliceValue,ht as stackCapIndex,W as text,Yt as yExtent};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|