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