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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +109 -28
  3. package/dist/bar-chart/bar-chart.d.ts +265 -39
  4. package/dist/bar-chart/bar-chart.d.ts.map +1 -1
  5. package/dist/bar-chart/bar-chart.js +219 -171
  6. package/dist/bar-chart/bar-chart.js.map +1 -1
  7. package/dist/bar-chart/category-axis.d.ts +12 -7
  8. package/dist/bar-chart/category-axis.d.ts.map +1 -1
  9. package/dist/bar-chart/category-axis.js +56 -42
  10. package/dist/bar-chart/category-axis.js.map +1 -1
  11. package/dist/bar-chart/chart-bars.d.ts +76 -52
  12. package/dist/bar-chart/chart-bars.d.ts.map +1 -1
  13. package/dist/bar-chart/chart-bars.js +105 -89
  14. package/dist/bar-chart/chart-bars.js.map +1 -1
  15. package/dist/bar-chart/index.d.ts +4 -4
  16. package/dist/bar-chart/index.d.ts.map +1 -1
  17. package/dist/bar-chart/index.js +2 -2
  18. package/dist/bar-chart/index.js.map +1 -1
  19. package/dist/bar-chart/shared.d.ts +41 -65
  20. package/dist/bar-chart/shared.d.ts.map +1 -1
  21. package/dist/bar-chart/shared.js +73 -117
  22. package/dist/bar-chart/shared.js.map +1 -1
  23. package/dist/browser/chunks/chunk-7XCRX6GE.js +2 -0
  24. package/dist/browser/chunks/chunk-7XCRX6GE.js.map +7 -0
  25. package/dist/browser/index.js +1 -1
  26. package/dist/browser/index.js.map +4 -4
  27. package/dist/browser/kit.js +1 -1
  28. package/dist/browser/manifest.json +1 -1
  29. package/dist/engine.d.ts +5 -2
  30. package/dist/engine.d.ts.map +1 -1
  31. package/dist/engine.js +5 -2
  32. package/dist/engine.js.map +1 -1
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +2 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/kit/cartesian.d.ts +51 -15
  38. package/dist/kit/cartesian.d.ts.map +1 -1
  39. package/dist/kit/cartesian.js +81 -29
  40. package/dist/kit/cartesian.js.map +1 -1
  41. package/dist/kit/chart-canvas.d.ts +32 -24
  42. package/dist/kit/chart-canvas.d.ts.map +1 -1
  43. package/dist/kit/chart-canvas.js +52 -46
  44. package/dist/kit/chart-canvas.js.map +1 -1
  45. package/dist/kit/chart-legend.d.ts +8 -4
  46. package/dist/kit/chart-legend.d.ts.map +1 -1
  47. package/dist/kit/chart-legend.js +30 -20
  48. package/dist/kit/chart-legend.js.map +1 -1
  49. package/dist/{line-chart → kit}/horizontal-axis.d.ts +31 -6
  50. package/dist/kit/horizontal-axis.d.ts.map +1 -0
  51. package/dist/{line-chart → kit}/horizontal-axis.js +23 -24
  52. package/dist/kit/horizontal-axis.js.map +1 -0
  53. package/dist/kit/motion.d.ts +5 -0
  54. package/dist/kit/motion.d.ts.map +1 -1
  55. package/dist/kit/motion.js +8 -0
  56. package/dist/kit/motion.js.map +1 -1
  57. package/dist/{pie-chart → kit}/pie-legend.d.ts +3 -3
  58. package/dist/kit/pie-legend.d.ts.map +1 -0
  59. package/dist/{pie-chart → kit}/pie-legend.js +11 -10
  60. package/dist/kit/pie-legend.js.map +1 -0
  61. package/dist/kit/polar.d.ts +31 -0
  62. package/dist/kit/polar.d.ts.map +1 -0
  63. package/dist/kit/polar.js +33 -0
  64. package/dist/kit/polar.js.map +1 -0
  65. package/dist/kit/shared.d.ts +11 -50
  66. package/dist/kit/shared.d.ts.map +1 -1
  67. package/dist/kit/shared.js +58 -141
  68. package/dist/kit/shared.js.map +1 -1
  69. package/dist/kit/style.d.ts +517 -0
  70. package/dist/kit/style.d.ts.map +1 -0
  71. package/dist/kit/style.js +292 -0
  72. package/dist/kit/style.js.map +1 -0
  73. package/dist/kit/vertical-axis.d.ts +22 -2
  74. package/dist/kit/vertical-axis.d.ts.map +1 -1
  75. package/dist/kit/vertical-axis.js +56 -43
  76. package/dist/kit/vertical-axis.js.map +1 -1
  77. package/dist/line-chart/chart-line.d.ts +95 -3
  78. package/dist/line-chart/chart-line.d.ts.map +1 -1
  79. package/dist/line-chart/chart-line.js +165 -53
  80. package/dist/line-chart/chart-line.js.map +1 -1
  81. package/dist/line-chart/chart-region.d.ts +1 -1
  82. package/dist/line-chart/chart-region.d.ts.map +1 -1
  83. package/dist/line-chart/chart-region.js +7 -8
  84. package/dist/line-chart/chart-region.js.map +1 -1
  85. package/dist/line-chart/index.d.ts +5 -6
  86. package/dist/line-chart/index.d.ts.map +1 -1
  87. package/dist/line-chart/index.js +3 -4
  88. package/dist/line-chart/index.js.map +1 -1
  89. package/dist/line-chart/line-chart.d.ts +281 -18
  90. package/dist/line-chart/line-chart.d.ts.map +1 -1
  91. package/dist/line-chart/line-chart.js +284 -134
  92. package/dist/line-chart/line-chart.js.map +1 -1
  93. package/dist/line-chart/shared.d.ts +51 -34
  94. package/dist/line-chart/shared.d.ts.map +1 -1
  95. package/dist/line-chart/shared.js +175 -83
  96. package/dist/line-chart/shared.js.map +1 -1
  97. package/dist/line-chart/x-scale.d.ts +2 -0
  98. package/dist/line-chart/x-scale.d.ts.map +1 -1
  99. package/dist/line-chart/x-scale.js +15 -0
  100. package/dist/line-chart/x-scale.js.map +1 -1
  101. package/dist/nodes.d.ts +3 -1
  102. package/dist/nodes.d.ts.map +1 -1
  103. package/dist/nodes.js +9 -1
  104. package/dist/nodes.js.map +1 -1
  105. package/dist/pie-chart/index.d.ts +2 -3
  106. package/dist/pie-chart/index.d.ts.map +1 -1
  107. package/dist/pie-chart/index.js +1 -2
  108. package/dist/pie-chart/index.js.map +1 -1
  109. package/dist/pie-chart/pie-chart.d.ts +114 -18
  110. package/dist/pie-chart/pie-chart.d.ts.map +1 -1
  111. package/dist/pie-chart/pie-chart.js +38 -24
  112. package/dist/pie-chart/pie-chart.js.map +1 -1
  113. package/dist/pie-chart/pie-ring.d.ts +16 -5
  114. package/dist/pie-chart/pie-ring.d.ts.map +1 -1
  115. package/dist/pie-chart/pie-ring.js +89 -55
  116. package/dist/pie-chart/pie-ring.js.map +1 -1
  117. package/dist/pie-chart/shared.d.ts +61 -62
  118. package/dist/pie-chart/shared.d.ts.map +1 -1
  119. package/dist/pie-chart/shared.js +44 -123
  120. package/dist/pie-chart/shared.js.map +1 -1
  121. package/dist/radar-chart/index.d.ts +5 -0
  122. package/dist/radar-chart/index.d.ts.map +1 -0
  123. package/dist/radar-chart/index.js +5 -0
  124. package/dist/radar-chart/index.js.map +1 -0
  125. package/dist/radar-chart/radar-chart.d.ts +212 -0
  126. package/dist/radar-chart/radar-chart.d.ts.map +1 -0
  127. package/dist/radar-chart/radar-chart.js +224 -0
  128. package/dist/radar-chart/radar-chart.js.map +1 -0
  129. package/dist/radar-chart/radar-grid.d.ts +49 -0
  130. package/dist/radar-chart/radar-grid.d.ts.map +1 -0
  131. package/dist/radar-chart/radar-grid.js +63 -0
  132. package/dist/radar-chart/radar-grid.js.map +1 -0
  133. package/dist/radar-chart/radar-series.d.ts +59 -0
  134. package/dist/radar-chart/radar-series.d.ts.map +1 -0
  135. package/dist/radar-chart/radar-series.js +71 -0
  136. package/dist/radar-chart/radar-series.js.map +1 -0
  137. package/dist/radar-chart/shared.d.ts +78 -0
  138. package/dist/radar-chart/shared.d.ts.map +1 -0
  139. package/dist/radar-chart/shared.js +129 -0
  140. package/dist/radar-chart/shared.js.map +1 -0
  141. package/dist/radial-chart/index.d.ts +6 -0
  142. package/dist/radial-chart/index.d.ts.map +1 -0
  143. package/dist/radial-chart/index.js +4 -0
  144. package/dist/radial-chart/index.js.map +1 -0
  145. package/dist/radial-chart/radial-chart.d.ts +210 -0
  146. package/dist/radial-chart/radial-chart.d.ts.map +1 -0
  147. package/dist/radial-chart/radial-chart.js +175 -0
  148. package/dist/radial-chart/radial-chart.js.map +1 -0
  149. package/dist/radial-chart/radial-rings.d.ts +121 -0
  150. package/dist/radial-chart/radial-rings.d.ts.map +1 -0
  151. package/dist/radial-chart/radial-rings.js +273 -0
  152. package/dist/radial-chart/radial-rings.js.map +1 -0
  153. package/dist/radial-chart/shared.d.ts +77 -0
  154. package/dist/radial-chart/shared.d.ts.map +1 -0
  155. package/dist/radial-chart/shared.js +78 -0
  156. package/dist/radial-chart/shared.js.map +1 -0
  157. package/package.json +4 -4
  158. package/registry.json +21 -6
  159. package/src/bar-chart/bar-chart.ts +263 -179
  160. package/src/bar-chart/category-axis.ts +46 -40
  161. package/src/bar-chart/chart-bars.ts +136 -117
  162. package/src/bar-chart/index.ts +7 -10
  163. package/src/bar-chart/shared.ts +88 -233
  164. package/src/engine.ts +5 -2
  165. package/src/index.ts +2 -0
  166. package/src/kit/cartesian.ts +121 -40
  167. package/src/kit/chart-canvas.ts +49 -54
  168. package/src/kit/chart-legend.ts +28 -20
  169. package/src/kit/horizontal-axis.ts +114 -0
  170. package/src/kit/motion.ts +7 -0
  171. package/src/{pie-chart → kit}/pie-legend.ts +12 -11
  172. package/src/kit/polar.ts +54 -0
  173. package/src/kit/shared.ts +55 -277
  174. package/src/kit/style.ts +353 -0
  175. package/src/kit/vertical-axis.ts +67 -48
  176. package/src/line-chart/chart-line.ts +176 -54
  177. package/src/line-chart/chart-region.ts +6 -10
  178. package/src/line-chart/index.ts +14 -10
  179. package/src/line-chart/line-chart.ts +353 -151
  180. package/src/line-chart/shared.ts +193 -174
  181. package/src/line-chart/x-scale.ts +13 -0
  182. package/src/nodes.ts +9 -1
  183. package/src/pie-chart/index.ts +2 -23
  184. package/src/pie-chart/pie-chart.ts +54 -35
  185. package/src/pie-chart/pie-ring.ts +92 -71
  186. package/src/pie-chart/shared.ts +80 -270
  187. package/src/radar-chart/index.ts +4 -0
  188. package/src/radar-chart/radar-chart.ts +290 -0
  189. package/src/radar-chart/radar-grid.ts +83 -0
  190. package/src/radar-chart/radar-series.ts +88 -0
  191. package/src/radar-chart/shared.ts +153 -0
  192. package/src/radial-chart/index.ts +5 -0
  193. package/src/radial-chart/radial-chart.ts +212 -0
  194. package/src/radial-chart/radial-rings.ts +328 -0
  195. package/src/radial-chart/shared.ts +126 -0
  196. package/dist/browser/chunks/chunk-4SMRCU24.js +0 -2
  197. package/dist/browser/chunks/chunk-4SMRCU24.js.map +0 -7
  198. package/dist/kit/chart-border.d.ts +0 -18
  199. package/dist/kit/chart-border.d.ts.map +0 -1
  200. package/dist/kit/chart-border.js +0 -23
  201. package/dist/kit/chart-border.js.map +0 -1
  202. package/dist/line-chart/horizontal-axis.d.ts.map +0 -1
  203. package/dist/line-chart/horizontal-axis.js.map +0 -1
  204. package/dist/pie-chart/pie-legend.d.ts.map +0 -1
  205. package/dist/pie-chart/pie-legend.js.map +0 -1
  206. package/src/kit/chart-border.ts +0 -36
  207. package/src/line-chart/horizontal-axis.ts +0 -122
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/kit/shared.ts", "../../../src/kit/style.ts", "../../../src/kit/cartesian.ts", "../../../src/kit/chart-canvas.ts", "../../../src/kit/entries.ts", "../../../src/kit/paints.ts", "../../../src/kit/horizontal-axis.ts", "../../../src/kit/motion.ts", "../../../src/kit/vertical-axis.ts", "../../../src/kit/chart-legend.ts", "../../../src/kit/pie-legend.ts", "../../../src/kit/polar.ts", "../../../src/engine.ts"],
4
+ "sourcesContent": ["/**\n * What every chart shares: series, axis scaling and formatting, and the theme\n * leaves each chart's theme is assembled from. No `Node` imports, so a host's\n * inspector mappings can build a partial theme without the components.\n *\n * A mapper merges partial input onto a `previous` resolved value (idempotent). A\n * tween interpolates two resolved values leaf by leaf, but categorical fields\n * (`fontFamily`, `textAlign`) and any field `undefined` on either side step at\n * the midpoint: defaulting the missing side to 0 would animate a font weight\n * down to nothing on the way to \"unset\".\n */\n\nimport {\n lerpNumber,\n type DataRecord,\n type Fill,\n type Insets,\n type Shadow,\n type Stroke,\n type TextStyle,\n} from \"@motionscript/sdk\"\nimport { niceStep } from \"@motionscript/sdk/component\"\n\n/** One series of a chart: a column of the table, captioned and painted. */\nexport interface ChartSeries {\n /** Key into each data row for this series' value. */\n field: string\n /** The legend caption; empty or absent shows `field`. */\n label?: string\n /** Overrides the theme palette's entry for this series' index, for its mark and legend swatch. */\n fill?: Fill\n /** Defaults to `true`. */\n enabled?: boolean\n}\n\n/** A `[min, max]` numeric range in data units. */\nexport type Range = [min: number, max: number]\n\n/** One axis's *data* domain, as opposed to {@link AxisConfig}, which is how it is styled. */\nexport interface AxisDomainConfig {\n /** Caption drawn alongside the axis; `\"\"` hides it. */\n label?: string\n /** Derived from the data bounds when omitted. */\n range?: Range\n /** Derived (five evenly spaced) when omitted. */\n ticks?: number[]\n /**\n * A `number-format` pattern such as `#,##0.00` or `$#,##0`. It lives here, not\n * in {@link AxisConfig}, because it says what the column holds and has to\n * survive a re-theme.\n */\n format?: string\n}\n\n/** An {@link AxisDomainConfig} with `range` and `ticks` worked out. */\nexport type ResolvedAxisDomain = AxisDomainConfig & { readonly range: Range; readonly ticks: number[] }\n\n/**\n * Merges partial input onto `previous`, so a later `.set({ yAxis: {...} })`\n * patches `label`/`range`/`ticks` independently. An unset `range`/`ticks` is the\n * auto-derive signal.\n */\nexport function resolveAxisDomain(\n domain: AxisDomainConfig | undefined,\n previous?: AxisDomainConfig\n): AxisDomainConfig {\n return {\n label: domain?.label ?? previous?.label ?? \"\",\n range: domain?.range ?? previous?.range,\n ticks: domain?.ticks ?? previous?.ticks,\n format: domain?.format ?? previous?.format,\n }\n}\n\n/**\n * Interpolates `range` and `ticks` numerically (ticks pairwise by index).\n * `label`, `format`, and either field when one side is auto, step at the\n * midpoint: there is no halfway between `$#,##0` and `0.0%`.\n */\nexport function lerpAxisDomain(\n from: AxisDomainConfig,\n to: AxisDomainConfig,\n t: number\n): AxisDomainConfig {\n return {\n label: t < 0.5 ? from.label : to.label,\n range: lerpOptionalRange(from.range, to.range, t),\n ticks: lerpOptionalTicks(from.ticks, to.ticks, t),\n format: t < 0.5 ? from.format : to.format,\n }\n}\n\nfunction lerpOptionalRange(\n from: Range | undefined,\n to: Range | undefined,\n t: number\n): Range | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n return [lerpNumber(from[0], to[0], t), lerpNumber(from[1], to[1], t)]\n}\n\nfunction lerpOptionalTicks(\n from: number[] | undefined,\n to: number[] | undefined,\n t: number\n): number[] | undefined {\n if (!from || !to) return t < 0.5 ? from : to\n const n = Math.max(from.length, to.length)\n const out: number[] = []\n for (let i = 0; i < n; i++) {\n out.push(lerpNumber(from[i] ?? to[i], to[i] ?? from[i], t))\n }\n return out\n}\n\n/**\n * An axis domain part-way through a tween that leaves or reaches a `range` or\n * `ticks` left to the data: both ends as stored, and how far along. Only the\n * chart knows what an auto side draws as, so {@link settleAxisDomain} resolves\n * it there. Its own fields are the plain {@link lerpAxisDomain} of its ends, so\n * a mapper merging onto one still reads a domain.\n */\nexport interface AxisDomainBlend extends AxisDomainConfig {\n readonly blend: { readonly from: AxisDomainConfig; readonly to: AxisDomainConfig; readonly t: number }\n}\n\nfunction blendOf(domain: AxisDomainConfig): AxisDomainBlend[\"blend\"] | undefined {\n return (domain as Partial<AxisDomainBlend>).blend\n}\n\n/**\n * The axis entry tween behind `to({ yAxis: { range } })`. Between explicit\n * domains it is {@link lerpAxisDomain}, and a restated `range` without `ticks`\n * spreads ticks across it, keeping their count. When either end leaves `range`\n * or `ticks` to the data, the value between is an {@link AxisDomainBlend}, so a\n * rescale from an auto axis is continuous rather than a cut at the midpoint.\n */\nexport function lerpAxisEntry(from: AxisDomainConfig, to: AxisDomainConfig, t: number): AxisDomainConfig {\n // The mapper merged the request onto `from`, so a field it left unstated is `from`'s own, by identity.\n const rangeMoved = to.range !== from.range\n const target = rangeMoved && to.range && to.ticks && to.ticks === from.ticks\n ? { ...to, ticks: markerValues(to.range, Math.max(2, to.ticks.length) - 1) }\n : to\n const blended = blendOf(from) !== undefined\n const moved = blended || rangeMoved || target.ticks !== from.ticks\n const auto = blended || from.range === undefined || from.ticks === undefined || target.range === undefined || target.ticks === undefined\n if (!moved || !auto) return lerpAxisDomain(from, target, t)\n if (t === 0) return from\n if (t === 1) return target\n const blend: AxisDomainBlend = { ...lerpAxisDomain(from, target, t), blend: { from, to: target, t } }\n return blend\n}\n\n/** `domain` as drawn: `drawn` resolves a plain domain's auto `range` and `ticks`; a blend is the lerp of what its ends draw. */\nexport function settleAxisDomain(domain: AxisDomainConfig, drawn: (domain: AxisDomainConfig) => AxisDomainConfig): AxisDomainConfig {\n const blend = blendOf(domain)\n if (!blend) return drawn(domain)\n return lerpAxisDomain(settleAxisDomain(blend.from, drawn), settleAxisDomain(blend.to, drawn), blend.t)\n}\n\n/** The colour tokens the default themes are built from: a dark plot panel with warm-grey axis furniture. */\nconst CHART_PALETTE = {\n plotFill: \"#15130e\",\n borderColor: \"#4a4036\",\n gridColor: \"#2c2820\",\n /** Axis markers, axis captions and legend labels. */\n markerColor: \"#8a7f70\",\n /** A spotlit region's dashed rules and wash. */\n regionColor: \"#d99a3a\",\n} as const\n\n/** Opacity an un-spotlighted series fades to, mark and legend entry alike. */\nexport const SPOTLIGHT_DIM = 0.2\n\n/**\n * Reads a numeric field off a row. A string column plots as 0, so a quoted or\n * unit-suffixed column needs the CSV parser's numeric coercion first.\n */\nexport function num(row: DataRecord, field: string | undefined): number {\n if (field === undefined) return 0\n const v = row[field]\n // A `NaN` or infinite cell is no more a measurement than a missing one: read\n // as 0, it cannot poison the scale and turn every point into `NaN`.\n return typeof v === \"number\" && Number.isFinite(v) ? v : 0\n}\n\n/** The counterpart to {@link num} for the columns a chart names things by; a missing cell reads as empty, not `\"undefined\"`. */\nexport function text(row: DataRecord, field: string | undefined): string {\n if (field === undefined || field === \"\") return \"\"\n const v = row[field]\n return v === undefined || v === null ? \"\" : String(v)\n}\n\n/**\n * Every numeric column of `data` in header order, skipping `exclude`. A column\n * is numeric only if every non-empty cell is a number, so a stray text cell\n * drops the column rather than plotting zeros.\n */\nexport function numericFields(\n data: DataRecord[],\n exclude: string[] = []\n): string[] {\n if (data.length === 0) return []\n const skip = new Set(exclude)\n const seen = new Set<string>()\n const order: string[] = []\n for (const row of data)\n for (const key of Object.keys(row))\n if (!skip.has(key) && !seen.has(key)) {\n seen.add(key)\n order.push(key)\n }\n\n return order.filter((key) => {\n let sawValue = false\n for (const row of data) {\n const v = row[key]\n if (v === undefined || v === \"\") continue\n if (typeof v !== \"number\") return false\n sawValue = true\n }\n return sawValue\n })\n}\n\n/** One axis's (x or y) style vocabulary. */\nexport interface AxisConfig {\n /** Style of each marker along the axis. */\n labelStyle: TextStyle\n titleStyle: TextStyle\n /** This axis's grid lines: weight and fill honoured, dash/cap/join ignored (they are filled rects). */\n lineStyle: Stroke\n /** Gap between the plot and the marker row; only the side facing the plot is read (`.top` horizontal, `.right` vertical). */\n tickPadding: Insets\n /** Gap between the marker row and the caption, read the same side. */\n titlePadding: Insets\n}\n\n/** A legend's per-series colour swatch. */\nexport interface LegendMarkerConfig {\n width: number\n height: number\n borderRadius: number\n stroke: Stroke\n shadow: Shadow\n}\n\nexport interface LegendConfig {\n padding: Insets\n /** Only the swatch carries the series colour. */\n textStyle: TextStyle\n itemGap: number\n markerStyle: LegendMarkerConfig\n}\n\nconst AXIS_LABEL_STYLE: TextStyle = {\n fontSize: 24,\n fontWeight: 700,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_TITLE_STYLE: TextStyle = {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"center\",\n fill: CHART_PALETTE.markerColor,\n}\nconst AXIS_LINE_STYLE: Stroke = { weight: 2, fill: CHART_PALETTE.gridColor }\n\nexport const DEFAULT_X_AXIS: AxisConfig = {\n labelStyle: AXIS_LABEL_STYLE,\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 20,\n titlePadding: 4,\n}\n\nexport const DEFAULT_Y_AXIS: AxisConfig = {\n labelStyle: { ...AXIS_LABEL_STYLE, fontWeight: 500, textAlign: \"right\" },\n titleStyle: AXIS_TITLE_STYLE,\n lineStyle: AXIS_LINE_STYLE,\n tickPadding: 40,\n titlePadding: 24,\n}\n\nexport const DEFAULT_LEGEND: LegendConfig = {\n padding: 0,\n textStyle: {\n fontSize: 30,\n fontWeight: 600,\n textAlign: \"left\",\n fill: CHART_PALETTE.markerColor,\n },\n itemGap: 44,\n markerStyle: {\n width: 60,\n height: 24,\n borderRadius: 6,\n stroke: [],\n shadow: [],\n },\n}\n\n/**\n * Format a marker value: integers plain, otherwise one decimal, or as many as\n * the tick `step` needs to tell neighbours apart (a unit axis ticked every 0.05\n * gets two, not `0.1 0.1 0.2 0.2 0.3`). Trailing zeros are dropped.\n */\nexport function formatMarker(value: number, step?: number): string {\n if (Number.isInteger(value)) return String(value)\n const decimals = Math.max(1, step === undefined ? 1 : decimalsFor(step))\n return value.toFixed(decimals).replace(/(\\.\\d*?)0+$/, \"$1\").replace(/\\.$/, \"\")\n}\n\n/** Decimal places needed to write `step` exactly, capped at six. */\nfunction decimalsFor(step: number): number {\n if (!(step > 0) || !Number.isFinite(step)) return 1\n for (let d = 0; d <= 6; d++) {\n const scaled = step * 10 ** d\n if (Math.abs(scaled - Math.round(scaled)) < 1e-6 * Math.max(1, scaled)) return d\n }\n // An irrational-looking step (a third): as many places as separate the ticks.\n return Math.min(6, Math.max(1, Math.ceil(-Math.log10(step)) + 1))\n}\n\n/** The gap between neighbouring tick values, or `undefined` for fewer than two distinct ones. */\nexport function markerStep(markers: readonly number[]): number | undefined {\n const sorted = [...markers].filter(Number.isFinite).sort((a, b) => a - b)\n let step: number | undefined\n for (let i = 1; i < sorted.length; i++) {\n const gap = sorted[i] - sorted[i - 1]\n if (gap > 1e-12 && (step === undefined || gap < step)) step = gap\n }\n return step\n}\n\n/** Format a fraction in `[0, 1]` as a percentage: integers plain, else one decimal. */\nexport function formatPercent(fraction: number): string {\n const pct = fraction * 100\n if (Number.isInteger(pct)) return `${pct}%`\n return `${pct.toFixed(1).replace(/\\.0$/, \"\")}%`\n}\n\n/** `markerCount` evenly-spaced tick values across `[min, max]`, ends inclusive. */\nexport function markerValues([min, max]: Range, markerCount: number): number[] {\n const n = Math.max(2, Math.round(markerCount))\n return Array.from({ length: n + 1 }, (_, i) => min + ((max - min) / n) * i)\n}\n\n/** `[lo, hi]` nudged out to bounds a whole number of tidy steps apart, about `divisions` of them. */\nexport function niceRange([lo, hi]: Range, divisions: number): Range {\n const segments = Math.max(1, Math.round(divisions))\n if (hi === lo) return constantScale(lo, segments)\n const step = niceStep((hi - lo) / segments)\n return [Math.floor(lo / step) * step, Math.ceil(hi / step) * step]\n}\n\n/**\n * The scale for constant data. A zero-width scale would put every tick on one\n * value and the line on the floor, so it widens by a step sized to the\n * magnitude (`5` gets `[3, 7]`), or `[0, 1]` for zero.\n */\nfunction constantScale(value: number, segments: number): Range {\n if (value === 0) return [0, 1]\n const step = niceStep(Math.abs(value) / segments)\n return [value - step, value + step]\n}\n\n/**\n * Ticks for a range worked out from the data: every multiple of the tidiest\n * step (1, 2 or 5 times a power of ten) that divides it into about `divisions`\n * parts, so zero is a tick whenever the range spans it. A range no such step\n * divides (an author's) is split evenly instead.\n */\nexport function niceTicks([lo, hi]: Range, divisions: number): number[] {\n const span = hi - lo\n const target = Math.max(1, Math.round(divisions))\n if (!(span > 0)) return markerValues([lo, hi], target)\n const whole = (v: number) => Math.abs(v - Math.round(v)) < 1e-6\n const base = niceStep(span / target)\n let best: number | undefined\n for (const step of ladder(base)) {\n const parts = span / step\n if (!whole(parts) || !whole(lo / step) || parts < 2 || parts > 8) continue\n if (best === undefined || Math.abs(parts - target) < Math.abs(span / best - target)) best = step\n }\n if (best === undefined) return markerValues([lo, hi], target)\n const first = Math.round(lo / best)\n return Array.from({ length: Math.round(span / best) + 1 }, (_, k) => Number(((first + k) * best).toPrecision(12)))\n}\n\n/** `step` and its neighbours on the 1-2-5 ladder, two either side. */\nfunction ladder(step: number): number[] {\n const mag = 10 ** Math.floor(Math.log10(step))\n const rungs: number[] = []\n for (const m of [mag / 10, mag, mag * 10]) for (const k of [1, 2, 5]) rungs.push(k * m)\n const at = rungs.findIndex((r) => Math.abs(r - step) < step * 1e-9)\n return rungs.slice(Math.max(0, at - 2), at + 3)\n}\n", "/**\n * The chart family's style: one `style` entry per chart, built from the groups\n * below, so a look saved off one chart lays onto any other (a field the other\n * chart does not draw is dropped). A chart spreads the shared groups and adds a\n * `marks` group of its own. Every run of text a chart draws is its own\n * `Types.typography` field, so axis labels, titles, values and the legend are\n * each set the way a text node is.\n */\n\nimport {\n Types,\n textOps,\n type Fill,\n type StrokeResolved,\n type Stroke as _Stroke,\n type StyleInput,\n type TextStyle,\n // Named so the emitted style types reach these through the sdk, not core.\n type FillResolved as _FillResolved,\n type Type as _Type,\n} from \"@motionscript/sdk\"\n\nimport type { AxisConfig, ChartSeries, LegendConfig } from \"./shared\"\n\n/** The style family every chart shares; the built-in presets are written for it. */\nexport const CHART_STYLE_FAMILY = \"chart\"\n\n/** The out-of-the-box series fills, cycled by series (or row) index. */\nexport const CHART_PALETTE_DEFAULT = [\"#4f8cff\", \"#2fbf8f\", \"#f5a524\", \"#e5547a\", \"#9b6cf0\"] as const\n\n/** The default ink of values, legend captions and centre text, on the dark stage. */\nexport const CHART_FOREGROUND = \"#f4f4f5\"\n/** The default ink of axis markers, axis captions and spoke labels. */\nexport const CHART_MUTED = \"#a1a1aa\"\n\nexport const CHART_SERIES = {\n /** A fill per series (a pie's or radial's per row), cycled; each may stack several paints. */\n seriesFills: Types.palette(CHART_PALETTE_DEFAULT),\n}\n\nexport const CHART_BACKGROUND = {\n /** Behind the whole chart, legend and axes included; none by default, so the chart reads against the stage. */\n background: Types.fill([]),\n}\n\nexport const GRID_BACKGROUND = {\n ...CHART_BACKGROUND,\n /** Behind the plot only, under the grid lines; none by default. */\n gridBackground: Types.fill([]),\n}\n\n/** The legend's captions, which every chart with a legend draws. */\nexport const LEGEND_TEXT = {\n legendText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_FOREGROUND }),\n}\n\nexport const CARTESIAN_TEXT = {\n /** The markers under the plot: categories on a column chart, values on a horizontal bar chart. */\n xLabelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),\n /** The caption under the plot. */\n xTitleText: Types.typography({ fontSize: 31, fontWeight: 600, fill: CHART_MUTED }),\n /** The markers beside the plot. */\n yLabelText: Types.typography({ fontSize: 28, fontWeight: 500, fill: CHART_MUTED }),\n /** The caption beside the plot, turned on its side. */\n yTitleText: Types.typography({ fontSize: 31, fontWeight: 600, fill: CHART_MUTED }),\n /** The figures printed by the marks. */\n valueText: Types.typography({ fontSize: 24, fontWeight: 600, fill: CHART_FOREGROUND }),\n ...LEGEND_TEXT,\n}\n\nexport const CARTESIAN_GRID = {\n /** The lines along the value ticks of a column chart (one per tick); empty draws none. */\n horizontalGrid: Types.stroke({ weight: 2, fill: \"white/15\" }),\n /** The lines under the category markers; empty draws none. */\n verticalGrid: Types.stroke([]),\n /** The baseline and the value-axis rule; empty draws none. */\n axisStroke: Types.stroke([]),\n /** Read as the chart is built: whether the category (x) axis row is drawn. */\n showXAxis: Types.boolean(true, { animatable: false }),\n /** Read as the chart is built: whether the value (y) axis column is drawn. */\n showYAxis: Types.boolean(true, { animatable: false }),\n}\n\nexport type LegendPosition = \"bottom\" | \"top\" | \"right\" | \"none\"\nexport type LegendSwatch = \"square\" | \"circle\" | \"line\"\n\nexport const CHART_LEGEND = {\n /** Read as the chart is built: where the legend sits, or `none`. */\n legend: Types.oneOf([\"bottom\", \"top\", \"right\", \"none\"] as const, { animatable: false }),\n swatch: Types.oneOf([\"square\", \"circle\", \"line\"] as const),\n}\n\n/** The fields every chart's style resolves, whichever groups it spreads. */\nexport interface ChartStyleBase {\n readonly seriesFills: readonly Fill[]\n readonly background: Fill\n readonly legendText: TextStyle\n readonly legend: LegendPosition\n readonly swatch: LegendSwatch\n}\n\n/** The cartesian fields, for the line and bar charts. */\nexport interface CartesianStyle extends ChartStyleBase {\n readonly gridBackground: Fill\n readonly xLabelText: TextStyle\n readonly xTitleText: TextStyle\n readonly yLabelText: TextStyle\n readonly yTitleText: TextStyle\n readonly valueText: TextStyle\n readonly horizontalGrid: StrokeResolved[]\n readonly verticalGrid: StrokeResolved[]\n readonly axisStroke: StrokeResolved[]\n readonly showXAxis: boolean\n readonly showYAxis: boolean\n}\n\n/** The fields a preset restates so its rules and text read on its background (a chart keeps those it draws). */\nconst _PRESET_FIELDS = {\n ...CHART_SERIES,\n ...GRID_BACKGROUND,\n ...CARTESIAN_TEXT,\n labelText: Types.typography(),\n centerText: Types.typography(),\n spokeText: Types.typography(),\n horizontalGrid: CARTESIAN_GRID.horizontalGrid,\n gridStroke: Types.stroke([]),\n spokeStroke: Types.stroke([]),\n track: Types.fill([]),\n}\n\n/** A preset's fields: any chart's, so one preset dresses every chart. */\nexport type ChartStylePreset = StyleInput<typeof _PRESET_FIELDS>\n\n/** Every text field's ink: `foreground` for values, the legend and centre text, `muted` for markers and captions. */\nfunction inks(foreground: string, muted: string) {\n const on = (fill: string) => ({ fill })\n return {\n xLabelText: on(muted),\n xTitleText: on(muted),\n yLabelText: on(muted),\n yTitleText: on(muted),\n valueText: on(foreground),\n legendText: on(foreground),\n labelText: on(muted),\n centerText: on(foreground),\n spokeText: on(muted),\n } satisfies ChartStylePreset\n}\n\n/** Every rule a chart draws, and a radial's track, in one paint. */\nfunction rules(fill: string) {\n return {\n horizontalGrid: { weight: 2, fill },\n gridStroke: { weight: 2, fill },\n spokeStroke: { weight: 2, fill },\n track: fill,\n } satisfies ChartStylePreset\n}\n\n/** Ready-made looks, each stating every colour so applying one replaces the last. */\nexport const CHART_STYLE_PRESETS = {\n midnight: {\n seriesFills: [...CHART_PALETTE_DEFAULT],\n ...inks(CHART_FOREGROUND, CHART_MUTED),\n ...rules(\"white/15\"),\n track: \"white/10\",\n background: [],\n gridBackground: [],\n },\n paper: {\n seriesFills: [\"#2563eb\", \"#059669\", \"#d97706\", \"#db2777\", \"#7c3aed\"],\n ...inks(\"#1c1917\", \"#57534e\"),\n ...rules(\"#1c1917/12\"),\n background: \"#fafaf9\",\n gridBackground: [],\n },\n ember: {\n seriesFills: [\"#d9603b\", \"#8194ad\", \"#e0a93b\", \"#5e9d6b\", \"#9ec85a\"],\n ...inks(\"#e9e1d4\", \"#8a7f70\"),\n ...rules(\"#2c2820\"),\n background: \"#15130e\",\n gridBackground: [],\n },\n neon: {\n seriesFills: [\"#22d3ee\", \"#a3e635\", \"#f472b6\", \"#facc15\", \"#818cf8\"],\n ...inks(\"#ffffff\", \"#94a3b8\"),\n ...rules(\"white/10\"),\n background: [],\n gridBackground: [],\n },\n ocean: {\n seriesFills: [\"#0ea5e9\", \"#14b8a6\", \"#6366f1\", \"#38bdf8\", \"#2dd4bf\"],\n ...inks(\"#e0f2fe\", \"#7dd3fc\"),\n ...rules(\"#7dd3fc/20\"),\n background: \"#082f49\",\n gridBackground: [],\n },\n sunset: {\n seriesFills: [\"#f97316\", \"#ef4444\", \"#ec4899\", \"#f59e0b\", \"#a855f7\"],\n ...inks(\"#fff7ed\", \"#fdba74\"),\n ...rules(\"#fdba74/20\"),\n background: [],\n gridBackground: [],\n },\n pastel: {\n seriesFills: [\"#a5b4fc\", \"#f9a8d4\", \"#86efac\", \"#fde68a\", \"#7dd3fc\"],\n ...inks(\"#f8fafc\", \"#cbd5e1\"),\n ...rules(\"white/12\"),\n background: [],\n gridBackground: [],\n },\n mono: {\n seriesFills: [\"#fafafa\", \"#a3a3a3\", \"#737373\", \"#d4d4d4\", \"#525252\"],\n ...inks(\"#fafafa\", \"#a3a3a3\"),\n ...rules(\"white/12\"),\n background: [],\n gridBackground: [],\n },\n} satisfies Record<string, ChartStylePreset>\n\n/** Series `index`'s fill: its own `fill`, else the style's series fills, cycled. */\nexport function paletteFill(style: Pick<ChartStyleBase, \"seriesFills\">, index: number, own?: Fill): Fill {\n if (own != null) return own\n const fills = style.seriesFills\n return fills.length > 0 ? fills[index % fills.length] : \"white\"\n}\n\n/** {@link paletteFill} for a series. */\nexport function seriesFill(style: Pick<ChartStyleBase, \"seriesFills\">, series: ChartSeries, index: number): Fill {\n return paletteFill(style, index, series.fill)\n}\n\n/** A text style's size in px; an autofit or unset size reads as `fallback`. */\nexport function sizeOf(text: TextStyle | undefined, fallback = 28): number {\n const size = text?.fontSize\n return typeof size === \"number\" && Number.isFinite(size) ? size : fallback\n}\n\n/**\n * `text` as a text node takes it, aligned where the chart puts it, with `over`\n * laid on top. Unset keys are dropped: an `undefined` spread onto a node is a\n * value, and an unset face must stay unset so the host's default applies.\n */\nexport function placedText(text: TextStyle, textAlign: TextStyle[\"textAlign\"] = \"center\", over?: TextStyle): TextStyle {\n return textOps.styleProps({ ...textOps.mergeStyle(text, over), textAlign }) as TextStyle\n}\n\n/** Axis markers on `axis`, aligned as that axis sets them. */\nexport function markerText(style: Pick<CartesianStyle, \"xLabelText\" | \"yLabelText\">, axis: \"x\" | \"y\"): TextStyle {\n return placedText(axis === \"x\" ? style.xLabelText : style.yLabelText, axis === \"x\" ? \"center\" : \"right\")\n}\n\n/** The figures printed by the marks. */\nexport function valueText(style: Pick<CartesianStyle, \"valueText\">, textAlign: TextStyle[\"textAlign\"] = \"center\"): TextStyle {\n return placedText(style.valueText, textAlign)\n}\n\n/**\n * The kit axis parts' config from a style. `x` is the axis under the plot;\n * its grid lines are vertical (one per x marker), the `y` axis's horizontal.\n */\nexport function axisConfigOf(\n style: Pick<CartesianStyle, \"verticalGrid\" | \"horizontalGrid\" | \"xLabelText\" | \"xTitleText\" | \"yLabelText\" | \"yTitleText\">,\n axis: \"x\" | \"y\"\n): AxisConfig {\n const gap = Math.round(sizeOf(axis === \"x\" ? style.xLabelText : style.yLabelText) * 0.6)\n return {\n labelStyle: markerText(style, axis),\n titleStyle: placedText(axis === \"x\" ? style.xTitleText : style.yTitleText),\n lineStyle: axis === \"x\" ? style.verticalGrid : style.horizontalGrid,\n tickPadding: axis === \"x\" ? { top: gap } : { right: gap },\n titlePadding: axis === \"x\" ? { top: Math.round(gap / 2) } : { right: gap },\n }\n}\n\n/** The kit legend's config: captions in `legendText`, the swatch shaped by `swatch` and sized off the captions. */\nexport function legendConfigOf(style: Pick<ChartStyleBase, \"swatch\" | \"legendText\">): LegendConfig {\n const type = sizeOf(style.legendText)\n const size = Math.max(8, Math.round(type * 0.6))\n const marker =\n style.swatch === \"line\"\n ? { width: Math.round(size * 2), height: Math.max(3, Math.round(size / 4)), borderRadius: size }\n : style.swatch === \"circle\"\n ? { width: size, height: size, borderRadius: size / 2 }\n : { width: size, height: size, borderRadius: Math.round(size / 4) }\n return {\n padding: 0,\n textStyle: placedText(style.legendText, \"left\"),\n itemGap: Math.round(type * 1.4),\n markerStyle: { ...marker, stroke: [], shadow: [] },\n }\n}\n\n/** Which text a chart drew from the retired shared text fields. */\nexport type ChartTextLayout = \"cartesian\" | \"pie\" | \"radar\" | \"radial\"\n\n/**\n * The `style` entry's hook for documents written before every run of text got\n * its own field (0.1.1-alpha.1): `barRadius` became `barCornerRadius`, `palette` became `seriesFills`; `foreground`,\n * `muted` and the one `fontFamily`/`fontSize`/`fontWeight` became the text\n * fields as each chart derived them; a cartesian or radar `background`, which\n * painted the plot, became `gridBackground`. A current style comes back as is.\n */\nexport function migrateChartStyle(layout: ChartTextLayout): (value: unknown) => unknown {\n return (value) => {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) return value\n const old = value as Record<string, unknown>\n const retired = [\"palette\", \"foreground\", \"muted\", \"fontFamily\", \"fontSize\", \"fontWeight\", \"barRadius\"]\n const plotBackground = layout === \"cartesian\" || layout === \"radar\"\n if (!retired.some((key) => key in old) && !(plotBackground && \"background\" in old && !(\"gridBackground\" in old))) return value\n\n const { palette, foreground, muted, fontFamily, fontSize, fontWeight, barRadius, ...rest } = old\n const out: Record<string, unknown> = { ...rest }\n // A bar radius rounded only the far end; its replacement states every corner.\n if (typeof barRadius === \"number\" && out.barCornerRadius === undefined) {\n out.barCornerRadius = { topLeft: barRadius, topRight: barRadius, bottomRight: 0, bottomLeft: 0 }\n }\n if (palette !== undefined && out.seriesFills === undefined) out.seriesFills = palette\n if (plotBackground && \"background\" in old && !(\"gridBackground\" in old)) {\n out.gridBackground = old.background\n delete out.background\n }\n const size = typeof fontSize === \"number\" ? fontSize : undefined\n const weight = typeof fontWeight === \"number\" ? fontWeight : undefined\n const text = (ink: unknown, scale = 1, heavier = 0): Record<string, unknown> | undefined => {\n const t: Record<string, unknown> = {}\n if (typeof fontFamily === \"string\" && fontFamily !== \"\") t.fontFamily = fontFamily\n if (size !== undefined) t.fontSize = Math.round(size * scale)\n if (weight !== undefined) t.fontWeight = Math.min(900, weight + heavier)\n if (ink !== undefined) t.fill = ink\n return Object.keys(t).length > 0 ? t : undefined\n }\n const fields: Record<string, Record<string, unknown> | undefined> = { legendText: text(foreground) }\n if (layout === \"cartesian\") {\n fields.xLabelText = text(muted)\n fields.yLabelText = text(muted)\n fields.xTitleText = text(muted, 1.1, 100)\n fields.yTitleText = text(muted, 1.1, 100)\n fields.valueText = text(foreground, 0.85, 100)\n } else if (layout === \"pie\") {\n fields.labelText = text(muted)\n fields.valueText = text(foreground, 1, 200)\n fields.centerText = text(foreground, 1.8, 300)\n } else if (layout === \"radar\") {\n fields.spokeText = text(muted)\n } else {\n fields.labelText = text(muted)\n fields.centerText = text(foreground, 1.8, 300)\n }\n for (const [key, field] of Object.entries(fields)) if (field && out[key] === undefined) out[key] = field\n return out\n }\n}\n", "import {\n Rect,\n RotatedBox,\n Text,\n textOps,\n type ChildView,\n type Fill,\n type FillResolved,\n type Insets,\n type Node2D,\n type Size2D,\n type TextStyle,\n} from \"@motionscript/sdk\"\n\nimport { sizeOf, type CartesianStyle, type LegendPosition } from \"./style\"\n\n/** Space between the frame's rows and columns: the plot and the legend, the axes and the legend. */\nexport function frameGap(style: Pick<CartesianStyle, \"legendText\">): number {\n return Math.round(sizeOf(style.legendText) * 0.9)\n}\n\n/** Room above the plot for the top value marker, which is centred on the top grid line. */\nexport function headroom(style: Pick<CartesianStyle, \"yLabelText\">): number {\n return Math.ceil(sizeOf(style.yLabelText) * 0.7)\n}\n\n/** How far an end marker of a horizontal value axis may hang past the plot: half a short caption. */\nexport function overhang(style: Pick<CartesianStyle, \"xLabelText\">): number {\n return Math.ceil(sizeOf(style.xLabelText) * 1.1)\n}\n\ninterface CartesianParts {\n /** Behind the whole chart, axes and legend included. */\n readonly background?: () => Fill\n /** The axis beside the plot, on its left. */\n readonly left?: Node2D\n /** An invisible twin of `left` under the plot, so the row there starts at the plot's left edge. */\n readonly ghost?: Node2D\n /** The box the grid and the marks share. */\n readonly plot: Node2D\n /** The axis under the plot. */\n readonly bottom?: Node2D\n readonly legend?: Node2D\n readonly legendAt: LegendPosition\n readonly gap: () => number\n readonly padding: () => Insets\n}\n\n/**\n * The frame the line and bar charts share. A legend above or below is centred\n * on the whole chart; one on the right is a column beside the plot. An axis the\n * style turns off is simply not here, and the plot takes its room.\n */\nexport function cartesianFrame(parts: CartesianParts): Node2D {\n const top = new Rect({ flow: \"horizontal\", width: \"fill\", height: \"fill\", children: [...(parts.left ? [parts.left] : []), parts.plot] })\n const rows: Node2D[] = [top as unknown as Node2D]\n if (parts.bottom) {\n rows.push(new Rect({ flow: \"horizontal\", width: \"fill\", height: \"hug\", children: [...(parts.ghost ? [parts.ghost] : []), parts.bottom] }) as unknown as Node2D)\n }\n const body = new Rect({ flow: \"vertical\", width: \"fill\", height: \"fill\", children: rows })\n const legend = parts.legend && parts.legendAt !== \"none\" ? parts.legend : undefined\n const main = new Rect({\n flow: \"horizontal\",\n width: \"fill\",\n height: \"fill\",\n align: \"center\",\n gap: parts.gap,\n children: [body, ...(legend && parts.legendAt === \"right\" ? [legend] : [])],\n })\n const across = (node: Node2D) => new Rect({ flow: \"horizontal\", width: \"fill\", height: \"hug\", align: \"center\", children: [node] })\n return new Rect({\n flow: \"vertical\",\n width: \"fill\",\n height: \"fill\",\n gap: parts.gap,\n padding: parts.padding,\n ...(parts.background ? { fill: parts.background } : {}),\n children: [\n ...(legend && parts.legendAt === \"top\" ? [across(legend)] : []),\n main,\n ...(legend && parts.legendAt === \"bottom\" ? [across(legend)] : []),\n ],\n }) as unknown as Node2D\n}\n\n/** Every view under `children`, depth first in build order: the axis beside the plot comes before its twin, which holds no parts. */\nexport function chartViews(children: readonly ChildView[]): ChildView[] {\n const out: ChildView[] = []\n const walk = (views: readonly ChildView[]) => {\n for (const view of views) {\n out.push(view)\n walk(view.children)\n }\n }\n walk(children)\n return out\n}\n\n/** A part's laid-out size; zero before it is built or laid out. */\nexport function laidOutSize(node: Node2D | undefined): Size2D {\n const bounds = node?.layoutBounds\n return { width: bounds?.width ?? 0, height: bounds?.height ?? 0 }\n}\n\n/**\n * A text style as props bound to `read`, so a style tween reaches text built\n * once. Only the keys set at build are bound: an unset family stays unset, so\n * the host's default face still applies.\n */\nexport function boundText(read: () => TextStyle): Record<string, unknown> {\n const keys = Object.keys(textOps.styleProps(read())) as (keyof TextStyle)[]\n const props: Record<string, unknown> = {}\n for (const key of keys) props[key] = () => read()[key]\n return props\n}\n\ninterface GhostSpec {\n readonly captions: () => readonly string[]\n /** How many captions the real axis built. */\n readonly count: number\n readonly text: () => TextStyle\n readonly title: string\n readonly titleText: () => TextStyle\n readonly tickPad: () => number\n readonly titlePad: () => number\n}\n\n/**\n * An invisible column as wide as a vertical axis built from the same captions:\n * the widest caption plus the tick padding, and the rotated title before it. A\n * plain tree, so a command looking for the axis never finds this instead.\n */\nexport function columnGhost(spec: GhostSpec): Node2D {\n const captions = Array.from({ length: spec.count }, (_, i) => new Text({ ...boundText(spec.text), text: () => spec.captions()[i] ?? \"\" }))\n const children: Node2D[] = []\n if (spec.title !== \"\") {\n children.push(new RotatedBox({ angle: -90, width: \"hug\", height: \"hug\", children: new Text({ ...boundText(spec.titleText), text: spec.title }) }) as unknown as Node2D)\n }\n children.push(new Rect({ flow: \"vertical\", width: \"hug\", height: \"hug\", padding: () => ({ right: spec.tickPad() }), children: captions }) as unknown as Node2D)\n return new Rect({ opacity: 0, flow: \"horizontal\", gap: spec.titlePad, width: \"hug\", height: 0, children }) as unknown as Node2D\n}\n\n/** `fill` with every layer's opacity scaled by `k`. */\nexport function fade(fill: Fill, k: number): Fill {\n const layers = (Array.isArray(fill) ? fill : [fill]) as FillResolved[]\n return layers.map((layer) => (typeof layer === \"object\" && layer !== null ? { ...layer, opacity: ((layer as { opacity?: number }).opacity ?? 1) * k } : layer)) as Fill\n}\n", "import {\n Graphics2D,\n Types,\n component2d,\n fillOps,\n strokeOps,\n type Fill,\n type FillResolved,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type RenderContext,\n type Stroke,\n type StrokeResolved,\n type Vector2,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"./entries\"\nimport { loadPaints } from \"./paints\"\nimport type { Range } from \"./shared\"\n\nconst strokeEntry = () => Types.custom<Stroke, StrokeResolved[]>([], { resolve: strokeOps.resolve, lerp: strokeOps.lerp })\n\n/** Where along a scale a fraction lands in a run of `length` px centred on 0. */\nfunction along(value: number, [min, max]: Range, length: number): number {\n return (max <= min ? 0 : (value - min) / (max - min) - 0.5) * length\n}\n\n/** One rule per draw: stroking a union of open paths paints nothing, and a dashed rule keeps its own phase. */\nexport function rule(ctx: RenderContext, from: Vector2, to: Vector2, stroke: StrokeResolved[], opacity = 1): void {\n ctx.draw(new Graphics2D().line({ points: [from, to] }).stroke(stroke).opacity(opacity))\n}\n\n/**\n * The plot backdrop: the panel fill, the grid and the axis rules, sized from its\n * box. Grid lines are placed from data-unit marker positions mapped through the\n * extents, so each lands under its marker however the markers are spaced; a line\n * on an edge is drawn just inside it.\n */\nexport const ChartCanvas = component2d({\n key: \"chartCanvas\",\n state: {\n fill: Types.custom<Fill, FillResolved[]>([], { resolve: fillOps.resolve, lerp: fillOps.lerp }),\n /** The vertical grid lines, one per `xMarkers` entry. */\n xGridStroke: strokeEntry(),\n /** The horizontal grid lines, one per `yMarkers` entry. */\n yGridStroke: strokeEntry(),\n xMarkers: fresh<number[]>(() => []),\n yMarkers: fresh<number[]>(() => []),\n /** `[min, max]` of each scale, mapping the markers into the panel. */\n xExtent: fresh<Range>(() => [0, 1]),\n yExtent: fresh<Range>(() => [0, 1]),\n /** The baseline and the value-axis rule. */\n axisStroke: strokeEntry(),\n /** Where the horizontal axis rule sits on the y scale, or `null` for none. */\n xAxisAt: Types.custom<number | null>(null),\n /** Where the vertical axis rule sits on the x scale, or `null` for none. */\n yAxisAt: Types.custom<number | null>(null),\n },\n load: (loader, state) => loadPaints(loader, { fills: [state.fill], strokes: [state.xGridStroke, state.yGridStroke, state.axisStroke] }),\n render: (ctx, state) => {\n const { width: W, height: H } = ctx.size\n if (W <= 0 || H <= 0) return\n if (state.fill.length > 0) ctx.draw(new Graphics2D().rect({ x: 0, y: 0, width: W, height: H }).fill(state.fill))\n\n const inside = (at: number, length: number, weight: number) => Math.max(-length / 2 + weight / 2, Math.min(length / 2 - weight / 2, at))\n const verticals = (values: readonly number[], stroke: StrokeResolved[]) => {\n const weight = stroke[0]?.weight ?? 0\n if (weight <= 0) return\n for (const v of values) {\n const x = inside(along(v, state.xExtent, W), W, weight)\n rule(ctx, { x, y: -H / 2 }, { x, y: H / 2 }, stroke)\n }\n }\n const horizontals = (values: readonly number[], stroke: StrokeResolved[]) => {\n const weight = stroke[0]?.weight ?? 0\n if (weight <= 0) return\n for (const v of values) {\n const y = inside(along(v, state.yExtent, H), H, weight)\n rule(ctx, { x: -W / 2, y }, { x: W / 2, y }, stroke)\n }\n }\n const within = ([min, max]: Range) => (v: number) => v >= Math.min(min, max) - 1e-9 && v <= Math.max(min, max) + 1e-9\n verticals(state.xMarkers.filter(within(state.xExtent)), state.xGridStroke)\n horizontals(state.yMarkers.filter(within(state.yExtent)), state.yGridStroke)\n if (state.xAxisAt !== null) horizontals([state.xAxisAt], state.axisStroke)\n if (state.yAxisAt !== null) verticals([state.yAxisAt], state.axisStroke)\n },\n})\n\nexport type ChartCanvas = NodeOf<typeof ChartCanvas>\n", "import { Types, type Element, type EntryOptions, type Node2D, type Type } from \"@motionscript/sdk\"\n\n/**\n * An entry made fresh for every node: each node gets its own array or box\n * rather than one shared literal, and a host is told no default for it.\n */\nexport function fresh<T, In = T>(make: () => T, options?: { readonly resolve?: (value: In) => T; readonly kind?: string }): Type<In, T> {\n // A function default is a factory: the component calls it once per node.\n return Types.custom<In, T>(make as unknown as In, options)\n}\n\n/**\n * Nodes a `children` builder made with `new`, as the elements it returns. A\n * part built that way can be read in a binding — its own box, or its parent's,\n * which is the component it was built for — where a call would hand back only\n * the element.\n */\nexport function asParts(nodes: readonly Node2D[]): readonly Element[] {\n return nodes as unknown as readonly Element[]\n}\n\n/** The argument every per-series command takes: an index into `series`, offered by name. */\nexport const SERIES_ARG = Types.custom<number, number, EntryOptions & { readonly min: number; readonly step: number }>(0, { kind: \"series\", min: 0, step: 1 })\n", "import type { FillResolved, Loader, ShadowResolved, StrokeResolved } from \"@motionscript/sdk\"\n\n/** Paints a chart part holds in entries of its own, which no paint entry loads for it. */\nexport interface PartPaints {\n readonly fills?: readonly (readonly FillResolved[])[]\n readonly strokes?: readonly (readonly StrokeResolved[])[]\n readonly shadows?: readonly (readonly ShadowResolved[])[]\n}\n\n/** Declare `paints` from a component's `load`. */\nexport function loadPaints(loader: Loader, paints: PartPaints): void {\n for (const fill of paints.fills ?? []) loader.fill(fill)\n for (const strokes of paints.strokes ?? []) for (const stroke of strokes) loader.fill(stroke.fill)\n for (const shadows of paints.shadows ?? []) for (const shadow of shadows) loader.fill(shadow.fill)\n}\n", "import {\n Rect,\n Text,\n Types,\n component2d,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\nimport { enterBudget } from \"@motionscript/sdk/component\"\n\nimport { boundText } from \"./cartesian\"\nimport { asParts, fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport { DEFAULT_X_AXIS, type AxisConfig, type Range } from \"./shared\"\nimport { axisPads, markerCaption } from \"./vertical-axis\"\n\nconst SLIDE = 24\n\n/**\n * A row of {@link Text} markers under the plot, the mirror of `VerticalAxis`\n * (bound text and positions, landed resting state). Markers are placed by value\n * across the range, whatever they say: `2026-03` sits three months along, not\n * three slots along, unlike a bar chart's category axis. An end marker may hang\n * past the row by `overhang` px on either side, then is held inside it.\n */\nexport const HorizontalAxis = component2d({\n key: \"horizontalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n /** Tick values in data units. */\n markers: fresh<number[]>(() => []),\n /** One caption per marker in its order; a missing one reads as the bare numeric value. */\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_X_AXIS),\n /** Caption centred beneath the markers; empty hides it. */\n label: \"\",\n /** How far past the row's left and right ends a marker may reach, in px. */\n overhang: Types.custom<{ left: number; right: number }>({ left: 0, right: 0 }),\n arrivals: arrivalsEntry(),\n },\n // A node made of markers would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const pads = () => axisPads(state.axis, \"top\")\n const sorted = () => [...state.markers].sort((a, b) => a - b)\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0\n const [min, max] = state.range\n return max <= min ? 0 : (value - min) / (max - min)\n }\n\n const markers = state.markers.map((_, i) => {\n const width = () => (marker.parent as Node2D | null)?.layoutBounds.width ?? 0\n const marker: Node2D = new Text({\n ...boundText(() => state.axis.labelStyle),\n text: () => {\n const value = sorted()[i]\n return value === undefined ? \"\" : markerCaption(state, value)\n },\n x: () => {\n const w = width()\n const half = marker.layoutBounds.width / 2\n const centred = (fracAt(sorted()[i]) - 0.5) * w\n return Math.max(-w / 2 - state.overhang.left + half, Math.min(w / 2 + state.overhang.right - half, centred))\n },\n opacity: () => arrivalOf(state.arrivals, i).opacity,\n y: () => arrivalOf(state.arrivals, i).shift,\n })\n return marker\n })\n\n const children: Node2D[] = [\n new Rect({ width: \"fill\", height: \"hug\", padding: () => ({ top: pads().tick }), children: markers }) as unknown as Node2D,\n ]\n if (state.label !== \"\") {\n children.push(\n new Text({\n ...boundText(() => state.axis.titleStyle),\n text: state.label,\n opacity: () => arrivalOf(state.arrivals, \"label\").opacity,\n y: () => arrivalOf(state.arrivals, \"label\").shift,\n }) as unknown as Node2D\n )\n }\n return asParts([new Rect({ flow: \"vertical\", gap: () => pads().title, height: \"hug\", width: \"fill\", children }) as unknown as Node2D])\n },\n commands: {\n /** Stagger markers in left to right, then the caption. The duration is the whole entrance ({@link enterBudget}). */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.markers.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n const markers = state.markers.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...markers, ...label])])\n },\n },\n },\n})\n\nexport type HorizontalAxis = NodeOf<typeof HorizontalAxis>\n", "import { Types, easeOut, type EasingFunction, type Piece, type Timeline } from \"@motionscript/sdk\"\n\nconst identity: EasingFunction = (t) => t\n\n/** Any component's timeline: these helpers only build pieces, which every timeline builds alike. */\nexport type AnyTimeline = Timeline<any, any>\n\n/** How far a legend starts below its slot when `enter` brings it in, in px. */\nexport const LEGEND_SLIDE = 20\n\n/** Where a legend waits before it comes up: below its place, above it, or to its right. */\nexport function legendAway(at: string): { x?: number; y?: number } {\n if (at === \"top\") return { y: LEGEND_SLIDE }\n if (at === \"right\") return { x: LEGEND_SLIDE }\n return { y: -LEGEND_SLIDE }\n}\n\n/** Marker count when an axis states no ticks. */\nexport const DEFAULT_MARKERS = 5\n\n/** How a cartesian `enter` splits its duration: axes arriving, marks drawing, legend coming up. Sums to 1. */\nexport const ENTER_SHARE = { axes: 0.35, marks: 0.5, legend: 0.15 } as const\n\n/**\n * The ease a part's own frames apply to `t`: none when its command was given\n * one, which already eases every frame the command builds, and otherwise the\n * ease-out every chart command defaults to.\n */\nexport function frameEase(timeline: { readonly easing: EasingFunction | undefined }): EasingFunction {\n return timeline.easing ? identity : easeOut()\n}\n\n/** A piece of a command placed at its own time: from `at` seconds, for `duration` seconds. */\nexport interface Beat {\n readonly at: number\n readonly duration: number\n readonly piece: Piece\n}\n\n/**\n * `beats` at their own offsets over the command, each eased on its own and held\n * at its last frame once it is done. A beat ahead of the playhead writes nothing,\n * so whatever stands before it is written by a piece ahead of these. Beats that\n * run past the command are played faster to end with it.\n */\nexport function beats(timeline: AnyTimeline, parts: readonly Beat[]): Piece {\n const total = timeline.duration\n const natural = parts.reduce((end, part) => Math.max(end, part.at + part.duration), 0)\n const k = natural > total && natural > 0 ? total / natural : 1\n return timeline.together(\n parts.map(({ at, duration, piece }) => {\n const start = at * k\n const length = duration * k\n return timeline.sequence([timeline.wait(start), piece, timeline.wait(Math.max(0, total - start - length))])\n })\n )\n}\n\n/** How far one piece of a staggered entrance has come: its opacity, and how far it still sits off its place. */\nexport interface Arrival {\n readonly opacity: number\n readonly shift: number\n}\n\n/** Each piece's arrival, by key. An unlisted piece has landed. */\nexport type Arrivals = Readonly<Record<string, Arrival>>\n\nconst LANDED: Arrival = { opacity: 1, shift: 0 }\n\n/**\n * A part's private record of its pieces' arrivals. A write merges into it, so\n * beats placed apart each write their own piece and leave the others as the\n * frame left them.\n */\nexport function arrivalsEntry() {\n return Types.custom<Arrivals>({}, { private: true, resolve: (next: Arrivals, previous?: Arrivals) => ({ ...previous, ...next }) })\n}\n\nexport function arrivalOf(arrivals: Arrivals, key: string | number): Arrival {\n return arrivals[key] ?? LANDED\n}\n\n/** Every piece in `keys` armed at `from`: the first frame of their entrance. */\nexport function armed(keys: readonly (string | number)[], from: Arrival): Arrivals {\n const record: Record<string, Arrival> = {}\n for (const key of keys) record[key] = from\n return record\n}\n\n/**\n * A piece arriving from `from` over its beat: a part armed at `from` tweened to\n * `{ opacity: 1, [axis]: 0 }`, eased by `ease`.\n */\nexport function arrival(timeline: AnyTimeline, key: string | number, from: Arrival, ease: EasingFunction): Piece {\n return timeline.animate((t) => {\n const e = ease(t)\n return {\n arrivals: {\n [key]: {\n opacity: from.opacity + (LANDED.opacity - from.opacity) * e,\n shift: from.shift + (LANDED.shift - from.shift) * e,\n },\n },\n }\n })\n}\n", "import {\n Rect,\n RotatedBox,\n Text,\n Types,\n component2d,\n insetsOps,\n type NodeOf,\n // Named so this component's emitted type reaches `Node2D` and its props through the sdk, not core.\n type Node2D,\n type Node2DProps as _Node2DProps,\n} from \"@motionscript/sdk\"\nimport { enterBudget } from \"@motionscript/sdk/component\"\n\nimport { boundText } from \"./cartesian\"\nimport { asParts, fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport {\n DEFAULT_Y_AXIS,\n formatMarker,\n type AxisConfig,\n type Range,\n} from \"./shared\"\n\nconst SLIDE = 24\n\n/** What a marker's caption reads: the one listed for its value, else its bare reading. */\nexport function markerCaption(s: { readonly markers: readonly number[]; readonly captions: readonly string[] }, value: number): string {\n const index = s.markers.indexOf(value)\n return (index >= 0 ? s.captions[index] : undefined) ?? formatMarker(value)\n}\n\n/** The gap between an axis's markers and the plot, and between the markers and the caption, read off its config. */\nexport function axisPads(axis: AxisConfig, side: \"top\" | \"right\"): { tick: number; title: number } {\n return { tick: insetsOps.resolve(axis.tickPadding)[side], title: insetsOps.resolve(axis.titlePadding)[side] }\n}\n\n/**\n * A column of right-aligned captions beside the plot: `place(i)` is caption\n * `i`'s centre height in the column (y-up), whose height it is handed. The\n * value axis and a horizontal bar chart's category axis are both this column.\n */\nexport function captionColumn(spec: {\n readonly count: number\n readonly axis: () => AxisConfig\n readonly text: (i: number) => string\n readonly place: (i: number, height: number) => number\n readonly arrivals: () => Readonly<Record<string, Arrival>>\n readonly opacity?: (i: number) => number\n readonly label: string\n}): Node2D {\n const pads = () => axisPads(spec.axis(), \"right\")\n const markers = Array.from({ length: spec.count }, (_, i) => {\n const column = () => (marker.parent as Node2D | null)?.layoutBounds ?? { width: 0, height: 0 }\n const marker: Node2D = new Text({\n ...boundText(() => spec.axis().labelStyle),\n text: () => spec.text(i),\n // Right-aligned against the tick padding: freeform children sit on the content box's centre.\n x: () => (column().width - pads().tick) / 2 - marker.layoutBounds.width / 2 + arrivalOf(spec.arrivals(), i).shift,\n y: () => spec.place(i, column().height),\n opacity: () => arrivalOf(spec.arrivals(), i).opacity * (spec.opacity?.(i) ?? 1),\n })\n return marker\n })\n const children: Node2D[] = []\n if (spec.label !== \"\") {\n // Node2D space is y-up and rotation is clockwise, so -90° reads bottom-to-top.\n children.push(\n new RotatedBox({\n angle: -90,\n width: \"hug\",\n height: \"hug\",\n children: new Text({\n ...boundText(() => spec.axis().titleStyle),\n text: spec.label,\n opacity: () => arrivalOf(spec.arrivals(), \"label\").opacity,\n x: () => arrivalOf(spec.arrivals(), \"label\").shift,\n }),\n }) as unknown as Node2D\n )\n }\n children.push(new Rect({ height: \"fill\", width: \"hug\", padding: () => ({ right: pads().tick }), children: markers }) as unknown as Node2D)\n return new Rect({ flow: \"horizontal\", gap: () => pads().title, height: \"fill\", children }) as unknown as Node2D\n}\n\n/**\n * The numeric vertical axis the cartesian charts share: a column of {@link Text}\n * markers, highest at the top, each centred on its value's fraction across\n * `range` and right-aligned against the plot. Caption and position are bound, so\n * a rescale tweens live; only the marker count is fixed at construction. The\n * resting state is landed.\n */\nexport const VerticalAxis = component2d({\n key: \"verticalAxis\",\n state: {\n range: fresh<Range>(() => [0, 1]),\n /** Tick values in data units, each placed by its fraction across `range`; need not be even or include the ends. */\n markers: fresh<number[]>(() => []),\n /** One caption per marker in its order; a missing one reads as the bare numeric value. */\n captions: fresh<string[]>(() => []),\n axis: Types.custom<AxisConfig>(DEFAULT_Y_AXIS),\n /** Rotated caption in the gutter left of the markers; empty builds no caption node and reserves no gutter. */\n label: \"\",\n arrivals: arrivalsEntry(),\n },\n // A node made of markers would otherwise hug them.\n defaults: { width: \"fill\", height: \"fill\" },\n children: (state) => {\n const sorted = () => [...state.markers].sort((a, b) => b - a)\n const fracAt = (value: number | undefined) => {\n if (value === undefined) return 0\n const [min, max] = state.range\n return max <= min ? 0 : (value - min) / (max - min)\n }\n // A slot with no value (the live list is shorter than the column built) renders empty, not its neighbour.\n return asParts([\n captionColumn({\n count: state.markers.length,\n axis: () => state.axis,\n text: (i) => {\n const value = sorted()[i]\n return value === undefined ? \"\" : markerCaption(state, value)\n },\n place: (i, height) => (fracAt(sorted()[i]) - 0.5) * height,\n arrivals: () => state.arrivals,\n label: state.label,\n }),\n ])\n },\n commands: {\n /**\n * Stagger markers in bottom to top, then the caption. The duration is the\n * whole entrance ({@link enterBudget}). `stagger` is seconds between markers\n * (derived when omitted); `slide` is the starting rightward offset in px.\n */\n enter: {\n args: {\n stagger: Types.custom<number | undefined>(undefined),\n slide: Types.number(SLIDE),\n },\n run: (timeline, state) => {\n const { stagger, slide } = timeline.args\n const count = state.markers.length\n const captioned = state.label !== \"\"\n const from: Arrival = { opacity: 0, shift: slide }\n const keys = [...state.markers.keys(), ...(captioned ? [\"label\"] : [])]\n const arm = timeline.animate(() => ({ arrivals: armed(keys, from) }))\n if (count === 0) return arm\n const { step, per, caption } = enterBudget(timeline.duration, count, captioned, stagger)\n const ease = frameEase(timeline)\n // The bottom marker leads, so walk the top-to-bottom column in reverse.\n const markers = state.markers.map((_, i) => ({ at: (count - 1 - i) * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n const label = captioned ? [{ at: (count - 1) * step + per, duration: caption, piece: arrival(timeline, \"label\", from, ease) }] : []\n return timeline.together([arm, beats(timeline, [...markers, ...label])])\n },\n },\n },\n})\n\nexport type VerticalAxis = NodeOf<typeof VerticalAxis>\n", "import {\n Flow,\n Paint,\n Rect,\n Shapes,\n Text,\n Types,\n component2d,\n type Fill,\n type NodeOf,\n // Named so the row's emitted type reaches the Rect surface it spreads through the sdk, not core.\n type Alignment as _Alignment,\n type CornerRadiusResolved as _CornerRadiusResolved,\n type CornerStyleResolved as _CornerStyleResolved,\n type FillResolved as _FillResolved,\n type FlowMode as _FlowMode,\n type FlowResolved as _FlowResolved,\n type GapSize as _GapSize,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type RectCornerRadius as _RectCornerRadius,\n type RectCornerStyle as _RectCornerStyle,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Vector2 as _Vector2,\n} from \"@motionscript/sdk\"\n\nimport { boundText } from \"./cartesian\"\nimport { fresh } from \"./entries\"\nimport { frameEase } from \"./motion\"\nimport {\n DEFAULT_LEGEND,\n SPOTLIGHT_DIM,\n type ChartSeries,\n type LegendConfig,\n} from \"./shared\"\n\nconst row = { ...Paint.state, ...Flow.state, ...Shapes.corners }\n\n/**\n * One legend entry, hugging its swatch and caption; `shown` scales its length\n * along the legend (`along`) from nothing. The length is measured from the\n * content at any reveal, so a frame never depends on the entry once having been\n * fully shown.\n */\nconst LegendEntry = component2d({\n key: \"legendEntry\",\n state: { ...row, shown: Types.number(1), along: Types.oneOf([\"horizontal\", \"vertical\"] as const) },\n commands: { ...Paint.commands },\n measure: (measurer, state, children) => {\n const size = Flow.measure(measurer, state, children, Paint.inset(state))\n if (state.shown >= 1) return size\n return state.along === \"vertical\" ? { ...size, height: state.shown * size.height } : { ...size, width: state.shown * size.width }\n },\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\n})\n\n/** Written whole, or one entry at a time as `{ [index]: reveal }`, which leaves the others as the frame left them so two series can move at once. */\nfunction revealOf(value: readonly number[] | Readonly<Record<number, number>>, previous?: number[]): number[] {\n if (Array.isArray(value)) return value as number[]\n const next = [...(previous ?? [])]\n for (const [index, reveal] of Object.entries(value)) next[Number(index)] = reveal\n return next\n}\n\n/**\n * A chart's legend: one entry per series, a colour swatch then its caption, in\n * a row (`flow: \"horizontal\"`) or a column (`\"vertical\"`, for a legend beside\n * the plot). This node is the row, so the parent places it.\n */\nexport const ChartLegend = component2d({\n key: \"chartLegend\",\n state: {\n ...row,\n series: fresh<ChartSeries[]>(() => []),\n /** Swatch colour by series index, resolved by the chart; a missing entry is white. */\n swatches: fresh<Fill[]>(() => []),\n legend: Types.custom<LegendConfig>(DEFAULT_LEGEND),\n /**\n * How far each entry is shown, `0`-`1`, driving its length, opacity and gap\n * together. Entries are never added or removed: \"is this node a child\" is not\n * a function of time, while collapsed-but-present is.\n */\n reveal: fresh<number[], number[] | Readonly<Record<number, number>>>(() => [], { resolve: revealOf }),\n },\n // The flow must be stated: a `Rect` with none lays children out `freeform`, stacking every entry on one spot.\n defaults: {\n flow: \"horizontal\",\n width: \"hug\",\n height: \"hug\",\n gap: (state) => (state.flow === \"vertical\" ? Math.round(state.legend.itemGap * 0.4) : state.legend.itemGap),\n padding: (state) => state.legend.padding,\n align: (state) => (state.flow === \"vertical\" ? \"centerLeft\" : \"center\"),\n reveal: (state) => state.series.map((s) => ((s.enabled ?? true) ? 1 : 0)),\n },\n // Every entry stays a child, so one always comes back where it belongs.\n children: (state) => {\n const marker = () => state.legend.markerStyle\n const along = state.flow === \"vertical\" ? \"vertical\" : \"horizontal\"\n return state.series.map((series, index) =>\n LegendEntry({\n flow: \"horizontal\",\n gap: () => Math.round(((state.legend.textStyle.fontSize as number | undefined) ?? 24) * 0.45),\n align: \"center\",\n width: \"hug\",\n height: \"hug\",\n along,\n // The length follows the reveal in `measure`, and the flanking gap closes with the entry.\n opacity: () => state.reveal[index] ?? 0,\n gapScale: () => state.reveal[index] ?? 0,\n shown: () => state.reveal[index] ?? 0,\n children: [\n Rect({\n width: () => marker().width,\n height: () => marker().height,\n cornerRadius: () => marker().borderRadius,\n fill: () => state.swatches[index] ?? \"white\",\n stroke: () => marker().stroke,\n shadow: () => marker().shadow,\n }),\n Text({ ...boundText(() => state.legend.textStyle), text: series.label || series.field }),\n ],\n })\n )\n },\n commands: {\n ...Paint.commands,\n /** Grow series `index`'s entry back in at its position, the siblings sliding over. */\n showSeries: {\n args: { index: Types.number(0, { min: 0, step: 1 }) },\n // An index that is not a series takes its slot and moves nothing.\n run: (timeline, state) => (timeline.args.index in state.series\n ? timeline.animate(revealFrame(state, timeline.args.index, 1, frameEase(timeline)))\n : timeline.wait(timeline.duration)),\n },\n /** The mirror of `showSeries`. */\n hideSeries: {\n args: { index: Types.number(0, { min: 0, step: 1 }) },\n run: (timeline, state) => (timeline.args.index in state.series\n ? timeline.animate(revealFrame(state, timeline.args.index, 0, frameEase(timeline)))\n : timeline.wait(timeline.duration)),\n },\n /** Dim every entry but `index` to {@link SPOTLIGHT_DIM}, in place. A hidden series' entry is left as `hideSeries` left it. */\n spotlightSeries: {\n args: { index: Types.number(0, { min: 0, step: 1 }) },\n run: (timeline, state, children) =>\n timeline.together(\n children.flatMap((entry, i) =>\n (state.reveal[i] ?? 0) > 0 ? [entry.to({ opacity: i === timeline.args.index ? 1 : SPOTLIGHT_DIM })] : []\n )\n ),\n },\n },\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\n})\n\n/** One entry's reveal ramping to `target` from where the command finds it, so a hide after a show starts where the show left it. */\nfunction revealFrame(state: { readonly reveal: readonly number[] }, index: number, target: number, ease: (t: number) => number) {\n const from = state.reveal[index] ?? 0\n return (t: number) => ({ reveal: { [index]: from + (target - from) * ease(t) } })\n}\n\nexport type ChartLegend = NodeOf<typeof ChartLegend>\n", "import {\n Flow,\n Paint,\n Rect,\n Shapes,\n Text,\n Types,\n clamp,\n component2d,\n textOps,\n type NodeOf,\n // Named so the column's emitted type reaches the Rect surface it spreads through the sdk, not core.\n type Alignment as _Alignment,\n type CornerRadiusResolved as _CornerRadiusResolved,\n type CornerStyleResolved as _CornerStyleResolved,\n type Fill as _Fill,\n type FillResolved as _FillResolved,\n type FlowMode as _FlowMode,\n type FlowResolved as _FlowResolved,\n type GapSize as _GapSize,\n type Node2D as _Node2D,\n type Node2DProps as _Node2DProps,\n type RectCornerRadius as _RectCornerRadius,\n type RectCornerStyle as _RectCornerStyle,\n type Shadow as _Shadow,\n type ShadowResolved as _ShadowResolved,\n type Stroke as _Stroke,\n type StrokeResolved as _StrokeResolved,\n type Vector2 as _Vector2,\n} from \"@motionscript/sdk\"\n\nimport { fresh } from \"./entries\"\nimport { armed, arrival, arrivalOf, arrivalsEntry, beats, frameEase, type Arrival } from \"./motion\"\nimport { DEFAULT_LEGEND, type LegendConfig } from \"./shared\"\nimport type { PieSlice } from \"./polar\"\n\nconst SLIDE = 16\n\n/**\n * The legend of a {@link PieChart}: a column (it sits beside the ring, in the\n * vertical strip it leaves) of caption-and-swatch entries, one per slice. No\n * show/hide: removing a row would re-cut every other wedge's share. Selection\n * arrives through `dims`.\n */\nexport const PieLegend = component2d({\n key: \"pieLegend\",\n state: {\n ...Paint.state,\n ...Flow.state,\n ...Shapes.corners,\n /** One entry per slice, in ring order. */\n slices: fresh<PieSlice[]>(() => []),\n legend: Types.custom<LegendConfig>(DEFAULT_LEGEND),\n /** Per-slice opacity multiplier, the signal that dims the ring, so an entry fades in step with its wedge. Missing reads as 1. */\n dims: fresh<number[]>(() => []),\n arrivals: arrivalsEntry(),\n },\n // The flow must be stated: a `Rect` with none lays children out `freeform`, every caption on top of the last.\n defaults: {\n flow: \"vertical\",\n align: \"centerLeft\",\n width: \"hug\",\n height: \"hug\",\n gap: (state) => state.legend.itemGap / 3,\n padding: (state) => state.legend.padding,\n },\n // The selection dim rides a wrapper, so the entrance animates the entry's own opacity without the two fighting over one value.\n children: (state) => {\n const marker = () => state.legend.markerStyle\n return state.slices.map((_, index) =>\n Rect({\n width: \"hug\",\n height: \"hug\",\n flow: \"freeform\",\n opacity: () => clamp(state.dims[index] ?? 1, 0, 1),\n children: [\n Rect({\n flow: \"horizontal\",\n gap: () => Math.round(state.legend.textStyle.fontSize === undefined ? 12 : Number(state.legend.textStyle.fontSize) * 0.4),\n align: \"center\",\n width: \"hug\",\n height: \"hug\",\n opacity: () => arrivalOf(state.arrivals, index).opacity,\n x: () => arrivalOf(state.arrivals, index).shift,\n children: [\n Rect({\n width: () => marker().width,\n height: () => marker().height,\n cornerRadius: () => marker().borderRadius,\n fill: () => state.slices[index]?.fill ?? \"white\",\n }),\n Text({\n ...textOps.styleProps(state.legend.textStyle),\n fill: () => state.legend.textStyle.fill ?? \"white\",\n fontSize: () => state.legend.textStyle.fontSize ?? 28,\n fontWeight: () => state.legend.textStyle.fontWeight ?? 500,\n text: () => state.slices[index]?.category ?? \"\",\n }),\n ],\n }),\n ],\n })\n )\n },\n commands: {\n ...Paint.commands,\n /** Every entry shifted right and transparent: what a chart shows ahead of this legend's beat, since `enter` arms only on its first frame. */\n arm: (timeline, state) =>\n timeline.animate(() => ({ arrivals: armed([...state.slices.keys()], { opacity: 0, shift: SLIDE }) })),\n /** Slide and fade entries in from the right, top to bottom. The duration is the whole entrance, the stagger carved out of it. */\n enter: (timeline, state) => {\n const count = state.slices.length\n if (count === 0) return timeline.wait(timeline.duration)\n const from: Arrival = { opacity: 0, shift: SLIDE }\n const arm = timeline.animate(() => ({ arrivals: armed([...state.slices.keys()], from) }))\n // Each gap is a fifth of an entry's move, the axes' rhythm, solved from the budget.\n const per = timeline.duration / (1 + Math.max(0, count - 1) / 5)\n const step = per / 5\n const ease = frameEase(timeline)\n const entries = state.slices.map((_, i) => ({ at: i * step, duration: per, piece: arrival(timeline, i, from, ease) }))\n return timeline.together([arm, beats(timeline, entries)])\n },\n },\n measure: (measurer, state, children) => Flow.measure(measurer, state, children, Paint.inset(state)),\n layout: (box, state, children) => Flow.layout(box, state, children, Paint.inset(state)),\n render: (ctx, state) => Paint.draw(ctx, state, Shapes.rect(ctx.size, state)),\n})\n\nexport type PieLegend = NodeOf<typeof PieLegend>\n", "/** What the polar charts (pie, radial) share: slices, ring geometry, the hole's summary and the selection fade. */\n\nimport { clamp, fillOps, type Fill, type FillResolved, type TextStyle, type Vector2 } from \"@motionscript/sdk\"\n\n/** One resolved slice, which the ring and legend consume; the chart resolves it from `data` and two field names. */\nexport interface PieSlice {\n /** Label and legend caption. */\n category: string\n /** The wedge covers `value / (sum of all values)`. */\n value: number\n /** Wedge and swatch paint. */\n fill: Fill\n}\n\nexport const DEG = Math.PI / 180\n\n/**\n * Opacity of a slice under the selection: 1 while nothing is out (`focus` is the\n * most-grown pop) and for the selected slice itself, falling toward `dimOpacity`\n * for the rest as the selection grows.\n */\nexport function selectionFade(focus: number, dimOpacity: number, pop: number): number {\n if (focus <= 0) return 1\n return 1 - (1 - clamp(dimOpacity, 0, 1)) * focus * (1 - pop)\n}\n\n/** The point at radius `r`, angle `a` on a ring about the origin in centred y-up space. Angles run clockwise from 12 o'clock. */\nexport function ringPoint(r: number, a: number): Vector2 {\n return { x: r * Math.sin(a), y: r * Math.cos(a) }\n}\n\n/** The summary set in the ring's hole. */\nexport interface CenterConfig {\n labelStyle: TextStyle\n captionStyle: TextStyle\n}\n\n/** How far everything outside the selection fades while any slice is selected; fainter than a gapless chart's, as a ring's slices touch. */\nexport const PIE_SPOTLIGHT_DIM = 0.15\n\nconst resolvedFills = new WeakMap<object, FillResolved[]>()\n\nexport function resolvedFill(fill: Fill): FillResolved[] {\n if (typeof fill !== \"object\" || fill === null) return fillOps.resolve(fill)\n let resolved = resolvedFills.get(fill)\n if (resolved === undefined) resolvedFills.set(fill, resolved = fillOps.resolve(fill))\n return resolved\n}\n\n/** Each slice's paint, resolved once per fill object. */\nexport function ringFills(slices: readonly PieSlice[]): FillResolved[][] {\n return slices.map((slice) => resolvedFill(slice.fill))\n}\n\n", "/**\n * The chart kit: what the five charts share, and what a copied chart does not\n * copy. A chart finds its parts by component identity (`VerticalAxis.is`), so a\n * second copy of `VerticalAxis` would be a second component that the chart never\n * finds, with no error. Copies import the kit from `@motionscript/charts`.\n */\nexport * from \"./kit/shared\"\nexport * from \"./kit/style\"\nexport * from \"./kit/cartesian\"\nexport * from \"./kit/chart-canvas\"\nexport * from \"./kit/horizontal-axis\"\nexport * from \"./kit/chart-legend\"\nexport * from \"./kit/entries\"\nexport * from \"./kit/motion\"\nexport * from \"./kit/paints\"\nexport * from \"./kit/pie-legend\"\nexport * from \"./kit/polar\"\nexport * from \"./kit/vertical-axis\"\nexport * from \"@motionscript/sdk/component\"\n"],
5
+ "mappings": "AAYA,OACE,cAAAA,MAOK,oBACP,OAAS,YAAAC,MAAgB,8BAyCnB,SAAUC,GACdC,EACAC,EAA2B,CAE3B,MAAO,CACL,MAAOD,GAAQ,OAASC,GAAU,OAAS,GAC3C,MAAOD,GAAQ,OAASC,GAAU,MAClC,MAAOD,GAAQ,OAASC,GAAU,MAClC,OAAQD,GAAQ,QAAUC,GAAU,OAExC,CAOM,SAAUC,EACdC,EACAC,EACAC,EAAS,CAET,MAAO,CACL,MAAOA,EAAI,GAAMF,EAAK,MAAQC,EAAG,MACjC,MAAOE,GAAkBH,EAAK,MAAOC,EAAG,MAAOC,CAAC,EAChD,MAAOE,GAAkBJ,EAAK,MAAOC,EAAG,MAAOC,CAAC,EAChD,OAAQA,EAAI,GAAMF,EAAK,OAASC,EAAG,OAEvC,CAEA,SAASE,GACPH,EACAC,EACAC,EAAS,CAET,MAAI,CAACF,GAAQ,CAACC,EAAWC,EAAI,GAAMF,EAAOC,EACnC,CAACP,EAAWM,EAAK,CAAC,EAAGC,EAAG,CAAC,EAAGC,CAAC,EAAGR,EAAWM,EAAK,CAAC,EAAGC,EAAG,CAAC,EAA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AAW,CAC1E,OAAIF,GAAS,EAAU,EAChB,GAAK,EAAIJ,GAAMK,EAAY,EAAG,CAAC,GAAKD,GAAS,EAAIE,EAC1D,CAGM,SAAUC,GAAUC,EAAWC,EAAS,CAC5C,MAAO,CAAE,EAAGD,EAAI,KAAK,IAAIC,CAAC,EAAG,EAAGD,EAAI,KAAK,IAAIC,CAAC,CAAC,CACjD,CASO,IAAMC,GAAoB,IAE3BC,GAAgB,IAAI,QAEpB,SAAUC,GAAaC,EAAU,CACrC,GAAI,OAAOA,GAAS,UAAYA,IAAS,KAAM,OAAOZ,GAAQ,QAAQY,CAAI,EAC1E,IAAIC,EAAWH,GAAc,IAAIE,CAAI,EACrC,OAAIC,IAAa,QAAWH,GAAc,IAAIE,EAAMC,EAAWb,GAAQ,QAAQY,CAAI,CAAC,EAC7EC,CACT,CAGM,SAAUC,GAAUC,EAA2B,CACnD,OAAOA,EAAO,IAAKC,GAAUL,GAAaK,EAAM,IAAI,CAAC,CACvD,CClCA,WAAc",
6
+ "names": ["lerpNumber", "niceStep", "resolveAxisDomain", "domain", "previous", "lerpAxisDomain", "from", "to", "t", "lerpOptionalRange", "lerpOptionalTicks", "out", "blendOf", "lerpAxisEntry", "rangeMoved", "target", "markerValues", "blended", "moved", "auto", "settleAxisDomain", "drawn", "blend", "CHART_PALETTE", "SPOTLIGHT_DIM", "num", "row", "field", "v", "text", "numericFields", "data", "exclude", "skip", "seen", "order", "key", "sawValue", "AXIS_LABEL_STYLE", "AXIS_TITLE_STYLE", "AXIS_LINE_STYLE", "DEFAULT_X_AXIS", "DEFAULT_Y_AXIS", "DEFAULT_LEGEND", "formatMarker", "value", "step", "decimals", "decimalsFor", "d", "scaled", "markerStep", "markers", "sorted", "a", "b", "i", "gap", "formatPercent", "fraction", "pct", "min", "max", "markerCount", "_", "niceRange", "lo", "hi", "divisions", "segments", "constantScale", "niceTicks", "span", "whole", "base", "best", "ladder", "parts", "first", "k", "mag", "rungs", "m", "at", "r", "Types", "textOps", "CHART_STYLE_FAMILY", "CHART_PALETTE_DEFAULT", "CHART_FOREGROUND", "CHART_MUTED", "CHART_SERIES", "CHART_BACKGROUND", "GRID_BACKGROUND", "LEGEND_TEXT", "CARTESIAN_TEXT", "CARTESIAN_GRID", "CHART_LEGEND", "_PRESET_FIELDS", "inks", "foreground", "muted", "on", "fill", "rules", "CHART_STYLE_PRESETS", "paletteFill", "style", "index", "own", "fills", "seriesFill", "series", "sizeOf", "text", "fallback", "size", "placedText", "textAlign", "over", "markerText", "axis", "valueText", "axisConfigOf", "gap", "legendConfigOf", "type", "marker", "migrateChartStyle", "layout", "value", "old", "retired", "plotBackground", "key", "palette", "fontFamily", "fontSize", "fontWeight", "barRadius", "rest", "out", "weight", "ink", "scale", "heavier", "t", "fields", "field", "Rect", "RotatedBox", "Text", "textOps", "frameGap", "style", "sizeOf", "headroom", "overhang", "cartesianFrame", "parts", "rows", "Rect", "body", "legend", "main", "across", "node", "chartViews", "children", "out", "walk", "views", "view", "laidOutSize", "bounds", "boundText", "read", "keys", "textOps", "props", "key", "columnGhost", "spec", "captions", "_", "i", "Text", "RotatedBox", "fade", "fill", "k", "layer", "Graphics2D", "Types", "component2d", "fillOps", "strokeOps", "Types", "fresh", "make", "options", "asParts", "nodes", "SERIES_ARG", "loadPaints", "loader", "paints", "fill", "strokes", "stroke", "shadows", "shadow", "strokeEntry", "Types", "strokeOps", "along", "value", "min", "max", "length", "rule", "ctx", "from", "to", "stroke", "opacity", "Graphics2D", "ChartCanvas", "component2d", "fillOps", "fresh", "loader", "state", "loadPaints", "W", "H", "inside", "at", "weight", "verticals", "values", "v", "x", "horizontals", "y", "within", "Rect", "Text", "Types", "component2d", "enterBudget", "Types", "easeOut", "identity", "t", "LEGEND_SLIDE", "legendAway", "at", "DEFAULT_MARKERS", "ENTER_SHARE", "frameEase", "timeline", "beats", "parts", "total", "natural", "end", "part", "k", "duration", "piece", "start", "length", "LANDED", "arrivalsEntry", "next", "previous", "arrivalOf", "arrivals", "key", "armed", "keys", "from", "record", "arrival", "ease", "e", "Rect", "RotatedBox", "Text", "Types", "component2d", "insetsOps", "enterBudget", "SLIDE", "markerCaption", "s", "value", "index", "formatMarker", "axisPads", "axis", "side", "insetsOps", "captionColumn", "spec", "pads", "markers", "_", "column", "marker", "Text", "boundText", "arrivalOf", "children", "RotatedBox", "Rect", "VerticalAxis", "component2d", "fresh", "Types", "DEFAULT_Y_AXIS", "arrivalsEntry", "state", "sorted", "a", "b", "fracAt", "min", "max", "i", "height", "timeline", "stagger", "slide", "count", "captioned", "from", "keys", "arm", "armed", "step", "per", "caption", "enterBudget", "ease", "frameEase", "arrival", "label", "beats", "SLIDE", "HorizontalAxis", "component2d", "fresh", "Types", "DEFAULT_X_AXIS", "arrivalsEntry", "state", "pads", "axisPads", "sorted", "b", "fracAt", "value", "min", "max", "markers", "_", "i", "width", "marker", "Text", "boundText", "markerCaption", "w", "half", "centred", "arrivalOf", "children", "Rect", "timeline", "stagger", "slide", "count", "captioned", "from", "keys", "arm", "armed", "step", "per", "caption", "enterBudget", "ease", "frameEase", "arrival", "label", "beats", "Flow", "Paint", "Rect", "Shapes", "Text", "Types", "component2d", "row", "Paint", "Flow", "Shapes", "LegendEntry", "component2d", "Types", "measurer", "state", "children", "size", "box", "ctx", "revealOf", "value", "previous", "next", "index", "reveal", "ChartLegend", "fresh", "DEFAULT_LEGEND", "s", "marker", "along", "series", "Rect", "Text", "boundText", "timeline", "revealFrame", "frameEase", "entry", "i", "SPOTLIGHT_DIM", "target", "ease", "from", "t", "Flow", "Paint", "Rect", "Shapes", "Text", "Types", "clamp", "component2d", "textOps", "SLIDE", "PieLegend", "component2d", "Paint", "Flow", "Shapes", "fresh", "Types", "DEFAULT_LEGEND", "arrivalsEntry", "state", "marker", "_", "index", "Rect", "clamp", "arrivalOf", "Text", "textOps", "timeline", "armed", "count", "from", "arm", "per", "step", "ease", "frameEase", "entries", "i", "arrival", "beats", "measurer", "children", "box", "ctx", "clamp", "fillOps", "DEG", "selectionFade", "focus", "dimOpacity", "pop", "ringPoint", "r", "a", "PIE_SPOTLIGHT_DIM", "resolvedFills", "resolvedFill", "fill", "resolved", "ringFills", "slices", "slice"]
7
+ }
@@ -1,2 +1,2 @@
1
- import{A as Bt,B as we,C as K,D as q,E as Se,F as Ae,G as Z,H as J,I as Gt,J as Ht,K as ke,L as ve,M as Nt,N as Ut,O as F,P as Ee,Q as qe,R as T,S as zt,T as I,U as Re,V as Te,W as Le,X as D,Y as Me,Z as Ce,_ as Q,a as f,b as W,c as C,d as xe,e as U,f as _,g as y,h as w,i as Y,j as b,k as z,l as P,m as $,n as ue,o as de,p as he,q as k,r as Uo,s as O,t as S,u as j,v as zo,w as E,x as ye,y as be,z as R}from"./chunks/chunk-4SMRCU24.js";import{Rect as Mn,Types as V,component2d as Cn,easeOut as B}from"@motionscript/sdk";import{formatNumber as _n}from"@motionscript/sdk/component";import{Graphics2D as nt,Types as ot,component2d as xn,strokeOps as $t}from"@motionscript/sdk";import{Fills as cn,fillOps as Xt,lerpNumber as un,strokeOps as Vt}from"@motionscript/sdk";import{niceStep as Wt}from"@motionscript/sdk/component";var ee={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function te(e){return e.right>e.left&&e.top>e.bottom}function Ze(e,t,r,n){if(!e||e.x===void 0&&e.y===void 0)return ee;let o=(d,[h,m],g,p)=>{if(d===void 0||m<=h)return[g,p,!1];let x=Math.min(d[0],d[1]),N=Math.max(d[0],d[1]),A=Ke=>g+(Ke-h)/(m-h)*(p-g);return[Math.max(g,Math.min(p,A(x))),Math.max(g,Math.min(p,A(N))),!0]},[i,s,a]=o(e.x,r,t.left,t.right),[c,l,u]=o(e.y,n,t.bottom,t.top);return{left:i,right:s,bottom:c,top:l,xBounded:a,yBounded:u}}function Je(e,t){if(e.length<2||!te(t))return[];let r=[],n=[];for(let o=1;o<e.length;o++){let i=hn(e[o-1],e[o],t);if(!i){n.length>=2&&r.push(n),n=[];continue}let[s,a]=i;n.length>0&&dn(n[n.length-1],s)?n.push(a):(n.length>=2&&r.push(n),n=[s,a])}return n.length>=2&&r.push(n),r}function dn(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function hn(e,t,r){let n=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-n,e.x-r.left],[n,r.right-e.x],[-o,e.y-r.bottom],[o,r.top-e.y]];for(let[c,l]of a){if(c===0){if(l<0)return null;continue}let u=l/c;if(c<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*n,y:e.y+i*o},{x:e.x+s*n,y:e.y+s*o}]}var pn={...R,markerStyle:{...R.markerStyle,width:20,height:20,borderRadius:6}},X={seriesStyles:Bt,xAxis:E,yAxis:ye,plotArea:be,legend:pn,region:{stroke:{weight:3,fill:k.regionColor,dash:[14,12],cap:"butt"},fill:cn.color(k.regionColor,{opacity:.08}),dimOpacity:O}};function fn(e,t){return{stroke:Vt.resolve(e?.stroke??t.stroke),fill:Xt.resolve(e?.fill??t.fill),dimOpacity:e?.dimOpacity??t.dimOpacity}}function gn(e,t,r){return{stroke:Vt.lerp(e.stroke,t.stroke,r),fill:Xt.lerp(e.fill,t.fill,r),dimOpacity:un(e.dimOpacity,t.dimOpacity,r)}}function Qe(e,t){let r=t??X;return{seriesStyles:Gt(e?.seriesStyles,r.seriesStyles),xAxis:K(e?.xAxis,r.xAxis),yAxis:K(e?.yAxis,r.yAxis),plotArea:Se(e?.plotArea,r.plotArea),legend:Z(e?.legend,r.legend),region:fn(e?.region,r.region)}}function et(e,t,r){return{seriesStyles:Ht(e.seriesStyles,t.seriesStyles,r),xAxis:q(e.xAxis,t.xAxis,r),yAxis:q(e.yAxis,t.yAxis,r),plotArea:Ae(e.plotArea,t.plotArea,r),legend:J(e.legend,t.legend,r),region:gn(e.region,t.region,r)}}function tt(e,t,r){return e.map((n,o)=>[t.at(o),S(n,r.field)]).sort((n,o)=>n[0]-o[0])}function Yt(e,t){let r=1/0,n=-1/0;for(let o of e)for(let i of t){let s=S(o,i.field);s<r&&(r=s),s>n&&(n=s)}return r<=n?[r,n]:[0,1]}function rt(e,t,r,n){if(r)return r;let[o,i]=Yt(e,t),s=Math.max(1,Math.round(n));if(i===o)return mn(o,s);let a=Wt((i-o)/s);return[Math.floor(o/a)*a,Math.ceil(i/a)*a]}function mn(e,t){if(e===0)return[0,1];let r=Wt(Math.abs(e)/t);return[e-r,e+r]}function yn(e,t){if(t>=1||e.length<2)return e;if(t<=0)return[];let r=[],n=0;for(let s=1;s<e.length;s++){let a=Math.hypot(e[s].x-e[s-1].x,e[s].y-e[s-1].y);r.push(a),n+=a}if(n===0)return e;let o=n*t,i=[e[0]];for(let s=0;s<r.length;s++)if(o>=r[s])i.push(e[s+1]),o-=r[s];else{let a=r[s]===0?0:o/r[s];i.push({x:e[s].x+(e[s+1].x-e[s].x)*a,y:e[s].y+(e[s+1].y-e[s].y)*a});break}return i}var _e=xn({key:"chartLine",state:{points:f(()=>[]),stroke:ot.custom([],{resolve:$t.resolve,lerp:$t.lerp}),progress:1,enabled:!0,spotlight:f(()=>ee),dimOpacity:O},load:(e,t)=>D(e,{strokes:[t.stroke]}),commands:{enter:{args:{from:ot.number(0,{min:0,max:1}),to:ot.number(1,{min:0,max:1})},run:e=>{let{from:t,to:r}=e.args,n=y(e);return e.animate(o=>{let i=t+(r-t)*n(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let r=t.points;if(r.length<2)return;let n=Math.max(0,Math.min(1,t.progress));if(n<=0)return;let o=yn(r,n);if(o.length<2)return;let i=t.stroke,s=(i[0]?.weight??0)*2,a=t.spotlight;if(!te(a)){e.draw(new nt().line({points:o,radius:s}).stroke(i));return}e.draw(new nt().line({points:o,radius:s}).stroke(i).opacity(Math.max(0,Math.min(1,t.dimOpacity))));for(let c of Je(o,a))e.draw(new nt().line({points:c,radius:s}).stroke(i))}});import{Graphics2D as jt,Types as Kt,component2d as bn,fillOps as qt,strokeOps as Zt}from"@motionscript/sdk";var st=bn({key:"chartRegion",state:{box:f(()=>ee),stroke:Kt.custom(X.region.stroke,{resolve:Zt.resolve,lerp:Zt.lerp}),fill:Kt.custom(X.region.fill,{resolve:qt.resolve,lerp:qt.lerp}),reveal:0},load:(e,t)=>D(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let r=t.box;if(!te(r))return;let n=Math.max(0,Math.min(1,t.reveal));if(n<=0)return;let o=r.right-r.left,i=r.top-r.bottom,s=(r.left+r.right)/2,a=(r.bottom+r.top)/2;if(t.fill.length>0&&e.draw(new jt().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(n)),t.stroke.length===0)return;let c=l=>e.draw(new jt().line({points:l}).stroke(t.stroke).opacity(n));if(r.xBounded){let l=i/2*n;for(let u of[r.left,r.right])c([{x:u,y:a-l},{x:u,y:a+l}])}if(r.yBounded){let l=o/2*n;for(let u of[r.bottom,r.top])c([{x:s-l,y:u},{x:s+l,y:u}])}}});import{Rect as Jt,Text as Qt,Types as it,component2d as wn,insetsOps as er,textOps as tr}from"@motionscript/sdk";import{enterBudget as Sn}from"@motionscript/sdk/component";var An=24,Pe=wn({key:"horizontalAxis",state:{range:f(()=>[0,1]),markers:f(()=>[]),captions:f(()=>[]),axis:it.custom(E),label:"",arrivals:Y()},defaults:{width:"fill",height:"fill"},children:e=>{let t=er.resolve(e.axis.tickPadding).top,r=er.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds??{width:0,height:0},i=()=>[...e.markers].sort((l,u)=>l-u),s=l=>{if(l===void 0)return 0;let[u,d]=e.range;return d<=u?0:(l-u)/(d-u)},a=e.markers.map((l,u)=>{let d=new Qt({...tr.styleProps(e.axis.labelStyle),text:()=>{let h=i()[u];return h===void 0?"":zt(e,h)},x:()=>{let h=o().width,m=(s(i()[u])-.5)*h,g=h/2-d.layoutBounds.width/2;return Math.min(m,g)},opacity:()=>b(e.arrivals,u).opacity,y:()=>b(e.arrivals,u).shift});return d}),c=[new Jt({width:"fill",height:"hug",padding:{top:t},children:a})];return e.label!==""&&c.push(new Qt({...tr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>b(e.arrivals,"label").opacity,y:()=>b(e.arrivals,"label").shift})),n.push(new Jt({flow:"vertical",gap:r,height:"hug",width:"fill",children:c})),n},commands:{enter:{args:{stagger:it.custom(void 0),slide:it.number(An)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.markers.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.markers.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:z(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=Sn(e.duration,o,i,r),h=y(e),m=t.markers.map((p,x)=>({at:x*l,duration:u,piece:P(e,x,s,h)})),g=i?[{at:(o-1)*l+u,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,w(e,[...m,...g])])}}}});import{formatNumber as kn}from"@motionscript/sdk/component";var Oe=864e5,ar=["january","february","march","april","may","june","july","august","september","october","november","december"],rr=2024;function nr(e){return e.length<3?-1:ar.findIndex(t=>t.startsWith(e))}function vn(e,t){let r=Date.UTC(e,0,4),n=(new Date(r).getUTCDay()+6)%7;return r-n*Oe+(t-1)*7*Oe}function lr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let r=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(r){let s=Number(r[2]),a=r[3]===void 0?1:Number(r[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(r[1]),s-1,a)}let n=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(n){let s=Number(n[2]);return s<1||s>53?null:vn(n[1]===void 0?rr:Number(n[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=nr(o[2]);if(s>=0){let a=o[1]??o[3],c=a===void 0?rr:Number(a);return Date.UTC(c,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=nr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function cr(e,t){let r=new Date(e),n=r.getUTCFullYear(),o=ar[r.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*Oe?String(n):t>60*Oe?`${i} ${n}`:`${i} ${r.getUTCDate()}`}function En(e,t){let r=!1;for(let n of e){let o=n[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;r=!0}}return r}function Rn(e,t){let r=[],n=!1;for(let s of e){let a=s[t];if(a==null||a===""){r.push(null);continue}let c=lr(a);if(c===null)return null;r.push(c),n=!0}if(!n)return null;let i=r.find(s=>s!==null);return r.map(s=>s===null?i:i=s)}function or(e){let t=1/0,r=-1/0;for(let n of e)n<t&&(t=n),n>r&&(r=n);return t<=r?[t,r]:[0,1]}function sr(e,[t,r],n){let o=e.filter(c=>c>=t&&c<=r),i=[...new Set(o)].sort((c,l)=>c-l);if(i.length===0)return T([t,r],n);let s=c=>i.reduce((l,u)=>Math.abs(u-c)<Math.abs(l-c)?u:l),a=[];for(let c of T([t,r],n)){let l=s(c);a[a.length-1]!==l&&a.push(l)}return a}function Tn(e,t,r,n){let o=e.indexOf(r);return o>=0?t[o]:n(r)}var ir=new WeakMap;function at(e,t,r){let n=ir.get(e);n||ir.set(e,n=new Map);let o=JSON.stringify([t,r??null]),i=n.get(o);return i||n.set(o,i=Ln(e,t,r)),i}function Ln(e,t,r){if(t!==""&&En(e,t)){let s=e.map(a=>S(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:or(s),label:a=>r===void 0?F(a):kn(a,r),ticks:T}}let n=e.map(s=>j(s,t)),o=t===""?null:Rn(e,t);if(o){let s=or(o),a=s[1]-s[0];return{kind:"time",at:c=>o[c]??0,extent:s,label:c=>Tn(o,n,c,l=>cr(l,a)),ticks:(c,l)=>sr(o,c,l)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>n[Math.round(s)]??"",ticks:(s,a)=>sr(i,s,a)}}var ur=V.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}});function ct(e,t=e.xAxis.format){return at(e.data,e.xField,t)}function Pn(e,t){let r=ct(e,t.format),n=t.range??r.extent;return{...t,range:n,ticks:t.ticks??r.ticks(n,U-1)}}function On(e,t){let r=(t.ticks?.length??U)-1,n=rt(e.data,e.series,t.range,r);return{...t,range:n,ticks:t.ticks??T(n,U-1)}}var dr=new WeakMap;function Fe(e){let{data:t,xField:r,xAxis:n,yAxis:o,series:i}=e,s=dr.get(t);if(s&&s.xField===r&&s.xAxis===n&&s.yAxis===o&&s.series===i)return s.domains;let a={x:he(n,c=>Pn(e,c)),y:he(o,c=>On(e,c))};return dr.set(t,{xField:r,xAxis:n,yAxis:o,series:i,domains:a}),a}function Fn(e,t,r,n){let o=e.series[r];if(!o)return[];let i=tt(e.data,ct(e),o);if(i.length===0)return[];let{width:s,height:a}=n,[c,l]=t.x.range,[u,d]=t.y.range,h=g=>l<=c?0:((g-c)/(l-c)-.5)*s,m=g=>d<=u?0:((g-u)/(d-u)-.5)*a;return i.map(([g,p])=>({x:h(g),y:m(p)}))}function hr(e,t,r){let{width:n,height:o}=r;return Ze(e.region,{left:-n/2,right:n/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function pr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function fr(e){return e!=null&&typeof e=="object"?e:{}}function In([e,t]){return e<=t?[e,t]:[t,e]}function gr(e,t){let r=In(e);return{range:r,ticks:T(r,Math.max(2,t.length)-1)}}function mr(e,t,r){return{...t.x&&{xAxis:ue(e.x,t.x,r)},...t.y&&{yAxis:ue(e.y,t.y,r)}}}function lt(e){let t=Te(e);if(!t)return null;let r=t.below.find(Pe.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,hAxis:r,lines:t.plot.filter(_e.is),legend:t.below.find(Q.is)??null}}function xr(e,t){let r=t.regionReveal,n=t.region;return r===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:n,regionReveal:r*(1-o)})}function yr(e,t,r,n){let o=lt(t),i=o?.lines[r];return!o||!i?e.wait(e.duration):e.together([i.run("enter",n?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(n?"showSeries":"hideSeries",{index:r})]:[]])}var ut=Cn({key:"lineChart",state:{data:f(()=>[],{kind:"dataset"}),xField:"",series:f(()=>[],{kind:"series"}),xAxis:V.custom({},{resolve:$,lerp:de}),yAxis:V.custom({},{resolve:$,lerp:de}),theme:V.custom(X,{resolve:Qe,lerp:et}),region:V.custom(null),regionReveal:0,showLegend:V.boolean(!0,{animatable:!1}),home:V.custom(null,{private:!0})},defaults:{width:"fill",height:"fill"},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>Fe(e),n,o=()=>Le(n),i=e.series.map(d=>d.enabled??!0),s=new I({range:()=>r().y.range,markers:()=>r().y.ticks,captions:()=>{let d=r().y.ticks,h=e.yAxis.format;return d.map(m=>h===void 0?F(m,Ee(d)):_n(m,h))},axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:"fill"}),a=new Pe({range:()=>r().x.range,markers:()=>r().x.ticks,captions:()=>{let d=ct(e);return r().x.ticks.map(h=>d.label(h))},axis:()=>t().xAxis,label:e.xAxis.label??"",width:"fill",height:"hug"}),c=e.series.map((d,h)=>new _e({points:()=>Fn(e,r(),h,o()),stroke:()=>Nt(t().seriesStyles,d,h),enabled:i[h],spotlight:()=>hr(e,r(),o()),dimOpacity:()=>1-(1-t().region.dimOpacity)*e.regionReveal})),l=[a];e.showLegend!==!1&&l.push(new Q({series:e.series,swatches:()=>e.series.map((d,h)=>Ut(t().seriesStyles,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Mn({clip:!0,children:[new Ce({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:()=>r().x.ticks,yMarkers:()=>r().y.ticks,xExtent:()=>r().x.range,yExtent:()=>r().y.range}),new st({box:()=>hr(e,r(),o()),stroke:()=>t().region.stroke,fill:()=>t().region.fill,reveal:()=>e.regionReveal}),...c,new Me({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().y.range,markers:()=>r().y.ticks,axis:()=>t().yAxis,label:e.yAxis.label??"",width:"hug",height:0});return[Re({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:B(),run:(e,t,r)=>{let n=lt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=pr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*_.axes,c=s*_.marks,{legend:l}=n,u=d=>({at:0,duration:0,piece:d});return w(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...n.lines.map(d=>u(d.to({progress:0}))),...l?[u(l.to({opacity:0,y:-xe}))]:[],{at:0,duration:a,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:a,piece:n.hAxis.run("enter",{slide:24})},...n.lines.map(d=>({at:a,duration:c,piece:d.run("enter")})),...l?[{at:a+c,duration:s*_.legend,piece:l.to({opacity:1,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(d=>({regionReveal:d}))}]:[]])}},spotlightRegion:{args:{region:ur},easing:B(),run:(e,t)=>{let r=fr(e.args.region),n=t.regionReveal,o=t.region;return r.x===void 0&&r.y===void 0?xr(e,t):n<=0||!pr(t)?e.animate(i=>({region:r,regionReveal:n+(1-n)*i})):e.animate(i=>i<.5?{region:o,regionReveal:n*(1-e.ease(i*2))}:{region:r,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:B(),run:(e,t)=>xr(e,t)},zoomTo:{args:{region:ur},easing:B(),run:(e,t)=>{let r=fr(e.args.region);if(!r.x&&!r.y)return e.wait(e.duration);let n=Fe(t),o=t.home??n,i={...r.x&&{x:{...n.x,...gr(r.x,n.x.ticks)}},...r.y&&{y:{...n.y,...gr(r.y,n.y.ticks)}}};return e.animate(s=>({home:o,...mr(n,i,s)}))}},resetZoom:{args:{},easing:B(),run:(e,t)=>{let r=t.home;if(!r)return e.wait(e.duration);let n=Fe(t);return e.animate(o=>({home:null,...mr(n,r,o)}))}},showSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>yr(e,r,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>yr(e,r,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:C},easing:B(),run:(e,t,r)=>{let n=lt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...n.lines.map((i,s)=>i.to({opacity:s===o?1:O})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Qn,Types as G,clamp as Dr,component2d as eo,easeOut as re}from"@motionscript/sdk";import{formatNumber as to}from"@motionscript/sdk/component";import{Rect as dt,Text as br,Types as ht,clamp as Dn,component2d as Bn,insetsOps as wr,textOps as Sr}from"@motionscript/sdk";import{enterBudget as Gn}from"@motionscript/sdk/component";var Hn=24,Ie=Bn({key:"categoryAxis",state:{categories:f(()=>[]),axis:ht.custom(E),label:"",dims:f(()=>[]),arrivals:Y()},defaults:{width:"fill",height:"fill"},children:e=>{let t=wr.resolve(e.axis.tickPadding).top,r=wr.resolve(e.axis.titlePadding).top,n=[],o=()=>n[0]?.parent?.layoutBounds.width??0,i=c=>{let l=e.categories.length;return l<=0?0:-o()/2+o()/l*(c+.5)},s=e.categories.map((c,l)=>new dt({width:"hug",height:"hug",flow:"freeform",opacity:()=>Dn(e.dims[l]??1,0,1),x:()=>i(l),children:[new br({...Sr.styleProps(e.axis.labelStyle),text:c,opacity:()=>b(e.arrivals,l).opacity,y:()=>b(e.arrivals,l).shift})]})),a=[new dt({width:"fill",height:"hug",padding:{top:t},children:s})];return e.label!==""&&a.push(new br({...Sr.styleProps(e.axis.titleStyle),text:e.label,opacity:()=>b(e.arrivals,"label").opacity,y:()=>b(e.arrivals,"label").shift})),n.push(new dt({flow:"vertical",gap:r,height:"hug",width:"fill",children:a})),n},commands:{enter:{args:{stagger:ht.custom(void 0),slide:ht.number(Hn)},run:(e,t)=>{let{stagger:r,slide:n}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:n},a=[...t.categories.keys(),...i?["label"]:[]],c=e.animate(()=>({arrivals:z(a,s)}));if(o===0)return c;let{step:l,per:u,caption:d}=Gn(e.duration,o,i,r),h=y(e),m=(o-1)*l+u,g=t.categories.map((x,N)=>({at:N*l,duration:u,piece:P(e,N,s,h)})),p=i?[{at:m,duration:d,piece:P(e,"label",s,h)}]:[];return e.together([c,w(e,[...g,...p])])}}}});import{Graphics2D as Vn,Text as Wn,Types as He,clamp as Cr,component2d as Yn,fillOps as Rr,shadowOps as Tr,strokeOps as Lr,textOps as $n}from"@motionscript/sdk";import{fillOps as Nn,lerpNumber as De,shadowOps as Ar,strokeOps as kr,textOps as vr}from"@motionscript/sdk";import{niceStep as Un}from"@motionscript/sdk/component";function Be(e,t,r){let n=0;return t.map(o=>{let i=S(e,o.field);if(!r)return{from:0,to:i,value:i};let s=n;return n+=i,{from:s,to:n,value:i}})}function pt(e,t){let r=-1;for(let n=0;n<t.length;n++)S(e,t[n].field)!==0&&(r=n);return r}function ft(e,t){return e.map(r=>j(r,t))}function Er(e,t,r){let n=0,o=0;for(let i of e)for(let s of Be(i,t,r))n=Math.min(n,s.from,s.to),o=Math.max(o,s.from,s.to);return n<o?[n,o]:[0,1]}function gt(e,t,r,n,o){if(n)return n;let[i,s]=Er(e,t,r),a=Math.max(1,Math.round(o)),c=Un((s-i)/a||1);return[Math.floor(i/c)*c,Math.ceil(s/c)*c]}var L={seriesFills:we,bar:{cornerRadius:6,slotFill:.72,groupGap:6,stroke:[],shadow:[]},xAxis:{...E,labelStyle:{...E.labelStyle,fontWeight:600},tickPadding:16},yAxis:ye,plotArea:be,legend:R,valueStyle:{fontSize:24,fontWeight:700,textAlign:"center",fill:k.markerColor},spotlight:{dimOpacity:O}};function zn(e,t){return{cornerRadius:e?.cornerRadius??t.cornerRadius,slotFill:e?.slotFill??t.slotFill,groupGap:e?.groupGap??t.groupGap,stroke:kr.resolve(e?.stroke??t.stroke),shadow:Ar.resolve(e?.shadow??t.shadow)}}function Xn(e,t,r){return{cornerRadius:De(e.cornerRadius,t.cornerRadius,r),slotFill:De(e.slotFill,t.slotFill,r),groupGap:De(e.groupGap,t.groupGap,r),stroke:kr.lerp(e.stroke,t.stroke,r),shadow:Ar.lerp(e.shadow,t.shadow,r)}}function mt(e,t){let r=t??L;return{seriesFills:ke(e?.seriesFills,r.seriesFills),bar:zn(e?.bar,r.bar),xAxis:K(e?.xAxis,r.xAxis),yAxis:K(e?.yAxis,r.yAxis),plotArea:Se(e?.plotArea,r.plotArea),legend:Z(e?.legend,r.legend),valueStyle:vr.resolveStyle(e?.valueStyle,r.valueStyle),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function xt(e,t,r){return{seriesFills:ve(e.seriesFills,t.seriesFills,r),bar:Xn(e.bar,t.bar,r),xAxis:q(e.xAxis,t.xAxis,r),yAxis:q(e.yAxis,t.yAxis,r),plotArea:Ae(e.plotArea,t.plotArea,r),legend:J(e.legend,t.legend,r),valueStyle:vr.lerpStyle(e.valueStyle,t.valueStyle,r),spotlight:{dimOpacity:De(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}function Ge(e,t,r){return t.fill!=null?Nn.resolve(t.fill):e.length===0?"white":e[r%e.length]}var jn=10,Kn=1.6,qn=24;function Mr(e,t){return e.enabled?Cr(e.dims[t]??1,0,1):0}function yt(e,t){let r=e.bars[t];if(!r)return null;let n=Cr(e.growth,0,1);return{base:e.baseline+(r.from-e.baseline)*n,end:e.baseline+(r.to-e.baseline)*n}}function _r(e){let t=e.valueStyle.fontSize;return typeof t=="number"?t:qn}function Pr(e,t){let r=e.bars[t];return r!==void 0&&Math.abs(r.from-e.baseline)>.5}function Zn(e,t){let r=e.bars[t];if(!r||r.value===0)return"";if(Pr(e,t)){let n=yt(e,t);if(!n||Math.abs(n.end-n.base)<_r(e)*Kn)return""}return r.caption??F(r.value)}function Jn(e,t){let r=yt(e,t);if(!r)return 0;if(Pr(e,t))return(r.base+r.end)/2;let n=r.end>=r.base?1:-1;return r.end+n*(jn+_r(e)/2)}var Ne=Yn({key:"chartBars",state:{bars:f(()=>[]),baseline:0,fill:He.custom([],{resolve:Rr.resolve,lerp:Rr.lerp}),barStroke:He.custom(L.bar.stroke,{resolve:Lr.resolve,lerp:Lr.lerp}),barShadow:He.custom(L.bar.shadow,{resolve:Tr.resolve,lerp:Tr.lerp}),cornerRadius:L.bar.cornerRadius,growth:1,dims:f(()=>[]),showValues:!1,valueStyle:He.custom(L.valueStyle),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.showValues?e.bars.map((t,r)=>Wn({...$n.styleProps(e.valueStyle),text:()=>Zn(e,r),x:()=>e.bars[r]?.x??0,y:()=>Jn(e,r),opacity:()=>Mr(e,r)})):[],load:(e,t)=>D(e,{fills:[t.fill],shadows:[t.barShadow],strokes:[t.barStroke]}),commands:{enter:e=>{let t=y(e);return e.animate(r=>({growth:t(r)}))}},render:(e,t)=>{if(t.enabled)for(let r=0;r<t.bars.length;r++){let n=t.bars[r],o=yt(t,r);if(!o||n.width<=0)continue;let i=Math.abs(o.end-o.base);if(i<=0)continue;let s=n.round?Math.min(t.cornerRadius,i):0,a=new Vn,c=a.rect({x:n.x,y:(o.base+o.end)/2,width:n.width,height:i,cornerRadius:s>0?o.end>=o.base?{topLeft:s,topRight:s,bottomLeft:0,bottomRight:0}:{bottomLeft:s,bottomRight:s,topLeft:0,topRight:0}:0});c.shadow(t.barShadow),c.fill(t.fill),c.stroke(t.barStroke),e.draw(a.opacity(Mr(t,r)))}e.children()}});function ro(e,t){let r=(t.ticks?.length??U)-1,n=gt(e.data,e.series,e.stacked,t.range,r);return{...t,range:n,ticks:t.ticks??T(n,U-1)}}var Or=new WeakMap;function St(e){let{data:t,series:r,stacked:n,valueAxis:o}=e,i=Or.get(t);if(i&&i.series===r&&i.stacked===n&&i.valueAxis===o)return i.domain;let s=he(o,a=>ro(e,a));return Or.set(t,{series:r,stacked:n,valueAxis:o,domain:s}),s}function Br(e,t,r){let n=e.valueAxis.format;return n===void 0?F(r,Ee(t.ticks)):to(r,n)}function bt(e,t,r){let[n,o]=e.range;return o<=n?-t.height/2:((r-n)/(o-n)-.5)*t.height}function no(e,t){let[r,n]=e.range;return bt(e,t,Math.min(Math.max(0,r),n))}function pe(e,t){return Math.max(0,e.weights[t]??1)}function oo(e,t){let r={...t};return e.series.forEach((n,o)=>{let i=t[n.field];typeof i=="number"&&(r[n.field]=i*pe(e,o))}),r}function so(e,t,r,n){let o=e.series[t];if(!o)return[];let i=St(e),s=e.data.length,a=s>0?r.width/s:0,c=p=>-r.width/2+a*(p+.5),l=a*Dr(e.theme.bar.slotFill,0,1),u=e.theme.bar.groupGap,d=0;for(let p=0;p<e.series.length;p++)d+=pe(e,p);let h=l/(d>0?d:1),m=pe(e,t),g=0;for(let p=0;p<t;p++)g+=pe(e,p);return e.data.map((p,x)=>{let A=Be(e.stacked?oo(e,p):p,e.series,e.stacked)[t]??{from:0,to:0,value:0},Ke=e.stacked?pt(p,e.series):t,sn=c(x)-l/2,an=e.stacked?c(x):sn+h*g+h*m/2,ln=e.stacked?l:Math.max(0,h*m-(e.series.length>1?u:0)),Dt=S(p,o.field);return{x:an,width:ln,from:bt(i,r,A.from),to:bt(i,r,A.to),round:Ke===t,value:Dt,...n&&{caption:Br(e,i,Dt)}}})}function Fr(e){let t=Dr(e.spotlightReveal,0,1),r=e.theme.spotlight.dimOpacity,n=e.spotlight;return e.data.map((o,i)=>t<=0||n===i?1:1-(1-r)*t)}function wt(e){let t=Te(e);if(!t)return null;let r=t.below.find(Ie.is);return!I.is(t.axis)||!r?null:{vAxis:t.axis,cAxis:r,bars:t.plot.filter(Ne.is),legend:t.below.find(Q.is)??null}}function Ir(e,t,r,n,o){let i=wt(r);if(!i||!i.bars[n])return e.wait(e.duration);let s=t.series.map((l,u)=>pe(t,u)),a=s[n]??1,c=t.series.map((l,u)=>t.showing[u]??l.enabled??!0);return e.together([e.animate(l=>{let u=[...s];u[n]=a+(o-a)*e.ease(l);let d=[...c];return d[n]=o>0||l<1,{weights:u,showing:d}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:n})]:[]])}var At=eo({key:"barChart",state:{data:f(()=>[]),categoryField:"",series:f(()=>[]),stacked:!1,valueAxis:G.custom({},{resolve:$,lerp:de}),categoryAxis:G.custom({},{resolve:$,lerp:ue}),theme:G.custom(L,{resolve:mt,lerp:xt}),growth:1,weights:f(()=>[]),spotlight:G.custom(null),spotlightReveal:0,showLegend:G.boolean(!0,{animatable:!1}),showValues:G.boolean(!1,{animatable:!1}),showing:G.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>St(e),n,o=()=>Le(n),i=e.showValues===!0,s=new I({range:()=>r().range,markers:()=>r().ticks,captions:()=>{let d=r();return d.ticks.map(h=>Br(e,d,h))},axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:"fill"}),a=new Ie({categories:ft(e.data,e.categoryField),axis:()=>t().xAxis,label:e.categoryAxis.label??"",dims:()=>Fr(e),width:"fill",height:"hug"}),c=e.series.map((d,h)=>new Ne({bars:()=>so(e,h,o(),i),baseline:()=>no(r(),o()),fill:()=>Ge(t().seriesFills,d,h),barStroke:()=>t().bar.stroke,barShadow:()=>t().bar.shadow,cornerRadius:()=>t().bar.cornerRadius,growth:()=>e.growth,dims:()=>Fr(e),showValues:i,valueStyle:e.theme.valueStyle,enabled:()=>e.showing[h]??d.enabled??!0})),l=[a];e.showLegend!==!1&&l.push(new Q({series:e.series,swatches:()=>e.series.map((d,h)=>Ge(t().seriesFills,d,h)),legend:()=>t().legend,gap:e.theme.legend.itemGap,padding:e.theme.legend.padding})),n=new Qn({clip:!0,children:[new Ce({fill:()=>t().plotArea.fill,shadow:()=>t().plotArea.shadow,xGridStroke:()=>t().xAxis.lineStyle,yGridStroke:()=>t().yAxis.lineStyle,xMarkers:[],yMarkers:()=>r().ticks,xExtent:()=>[0,1],yExtent:()=>r().range}),...c,new Me({stroke:()=>t().plotArea.stroke})]});let u=new I({opacity:0,range:()=>r().range,markers:()=>r().ticks,axis:()=>t().yAxis,label:e.valueAxis.label??"",width:"hug",height:0});return[Re({axis:s,plot:n,gutter:u,below:l})]},commands:{enter:{args:{},entrance:!0,easing:re(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.duration,i=o*_.axes,s=o*_.marks,{legend:a}=n,c=l=>({at:0,duration:0,piece:l});return w(e,[c(e.animate(()=>({growth:0}))),...a?[c(a.to({opacity:0,y:-xe}))]:[],{at:0,duration:i,piece:n.vAxis.run("enter",{slide:24})},{at:0,duration:i,piece:n.cAxis.run("enter",{slide:24})},{at:i,duration:s,piece:e.animate(l=>({growth:l}))},...a?[{at:i+s,duration:o*_.legend,piece:a.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>Ir(e,t,r,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>Ir(e,t,r,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:C},easing:re(),run:(e,t,r)=>{let n=wt(r);if(!n)return e.wait(e.duration);let o=e.args.seriesIndex,i=t.theme.spotlight.dimOpacity;return e.together([...n.bars.map((s,a)=>s.to({opacity:a===o?1:i})),...n.legend?[n.legend.run("spotlightSeries",{index:o})]:[]])}},spotlightCategory:{args:{categoryIndex:G.number(0,{min:0,step:1})},easing:re(),run:(e,t)=>{let r=e.args.categoryIndex;if(r<0||r>=t.data.length)return e.wait(e.duration);let n=t.spotlightReveal;return e.animate(o=>({spotlight:r,spotlightReveal:n+(1-n)*o}))}},clearCategory:{args:{},easing:re(),run:(e,t)=>{let r=t.spotlightReveal;if(r===0)return e.wait(e.duration);let n=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:n,spotlightReveal:r*(1-o)})}}}});import{Rect as nn,Types as le,clamp as on,component2d as Io,easeOut as ae}from"@motionscript/sdk";import{Flow as kt,Paint as fe,Rect as vt,Shapes as Gr,Text as io,Types as ao,clamp as lo,component2d as co,textOps as uo}from"@motionscript/sdk";var Hr=16,Ue=co({key:"pieLegend",state:{...fe.state,...kt.state,...Gr.corners,slices:f(()=>[]),legend:ao.custom(R),dims:f(()=>[]),arrivals:Y()},defaults:{flow:"vertical",align:"centerLeft",width:"hug",height:"hug",gap:e=>e.legend.itemGap/3,padding:e=>e.legend.padding},children:e=>{let t=e.legend.markerStyle;return e.slices.map((r,n)=>vt({width:"hug",height:"hug",flow:"freeform",opacity:()=>lo(e.dims[n]??1,0,1),children:[vt({flow:"horizontal",gap:12,align:"center",width:"hug",height:"hug",opacity:()=>b(e.arrivals,n).opacity,x:()=>b(e.arrivals,n).shift,children:[vt({width:t.height,height:t.height,cornerRadius:t.borderRadius,fill:()=>e.slices[n]?.fill??"white",stroke:t.stroke,shadow:t.shadow}),io({...uo.styleProps(e.legend.textStyle),text:()=>e.slices[n]?.category??""})]})]}))},commands:{...fe.commands,arm:(e,t)=>e.animate(()=>({arrivals:z([...t.slices.keys()],{opacity:0,shift:Hr})})),enter:(e,t)=>{let r=t.slices.length;if(r===0)return e.wait(e.duration);let n={opacity:0,shift:Hr},o=e.animate(()=>({arrivals:z([...t.slices.keys()],n)})),i=e.duration/(1+Math.max(0,r-1)/5),s=i/5,a=y(e),c=t.slices.map((l,u)=>({at:u*s,duration:i,piece:P(e,u,n,a)}));return e.together([o,w(e,c)])}},measure:(e,t,r)=>kt.measure(e,t,r,fe.inset(t)),layout:(e,t,r)=>kt.layout(e,t,r,fe.inset(t)),render:(e,t)=>fe.draw(e,t,Gr.rect(e.size,t))});import{Graphics2D as zr,PathBuilder as So,Rect as Ct,Text as oe,Types as me,clamp as ie,component2d as Ao,fillOps as Xr,shadowOps as ko,strokeOps as Vr,textOps as se}from"@motionscript/sdk";import{clamp as ho,lerpNumber as ge,shadowOps as Nr,strokeOps as ze,textOps as v}from"@motionscript/sdk";function Rt(e,t,r,n){return e.map((o,i)=>({category:j(o,t),value:S(o,r),fill:n.length>0?n[i%n.length]:"white"}))}var po=Math.PI/180;function Xe(e,t,r){return e<=0?1:1-(1-ho(t,0,1))*e*(1-r)}function Tt(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Ur(e){let t=0;for(let r of e)t+=Tt(r);return t}function ne(e,t){return{x:e*Math.sin(t),y:e*Math.cos(t)}}function Ve(e,t){let r=Ur(e);if(r<=0)return[];let n=[],o=t*po;return e.forEach((i,s)=>{let a=Tt(i);if(a<=0)return;let c=a/r,l=o,u=l+c*Math.PI*2;o=u,n.push({index:s,a0:l,a1:u,mid:(l+u)/2,fraction:c})}),n}function We(e,t,r,n){e.sort((s,a)=>a.ideal-s.ideal);let o=r;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=n;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Et={fontSize:26,fontWeight:600,textAlign:"center",fill:k.markerColor},fo=.1,M={sliceFills:we,ring:{gap:6,holeRadius:.6,startAngle:0,selectedGrow:1.08,stroke:[],shadow:[]},label:{textStyle:Et,percentStyle:{...Et,fontWeight:700},insideStyle:{...Et,fontWeight:800,fill:"#15130e"},leaderStroke:{weight:2,fill:k.markerColor}},center:{labelStyle:{fontSize:46,fontWeight:800,textAlign:"center",fill:k.markerColor},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:k.markerColor}},legend:R,spotlight:{dimOpacity:fo}};function go(e,t){return{gap:e?.gap??t.gap,holeRadius:e?.holeRadius??t.holeRadius,startAngle:e?.startAngle??t.startAngle,selectedGrow:e?.selectedGrow??t.selectedGrow,stroke:ze.resolve(e?.stroke??t.stroke),shadow:Nr.resolve(e?.shadow??t.shadow)}}function mo(e,t,r){return{gap:ge(e.gap,t.gap,r),holeRadius:ge(e.holeRadius,t.holeRadius,r),startAngle:ge(e.startAngle,t.startAngle,r),selectedGrow:ge(e.selectedGrow,t.selectedGrow,r),stroke:ze.lerp(e.stroke,t.stroke,r),shadow:Nr.lerp(e.shadow,t.shadow,r)}}function xo(e,t){return{textStyle:v.resolveStyle(e?.textStyle,t.textStyle),percentStyle:v.resolveStyle(e?.percentStyle,t.percentStyle),insideStyle:v.resolveStyle(e?.insideStyle,t.insideStyle),leaderStroke:ze.resolve(e?.leaderStroke??t.leaderStroke)}}function yo(e,t,r){return{textStyle:v.lerpStyle(e.textStyle,t.textStyle,r),percentStyle:v.lerpStyle(e.percentStyle,t.percentStyle,r),insideStyle:v.lerpStyle(e.insideStyle,t.insideStyle,r),leaderStroke:ze.lerp(e.leaderStroke,t.leaderStroke,r)}}function bo(e,t){return{labelStyle:v.resolveStyle(e?.labelStyle,t.labelStyle),captionStyle:v.resolveStyle(e?.captionStyle,t.captionStyle)}}function wo(e,t,r){return{labelStyle:v.lerpStyle(e.labelStyle,t.labelStyle,r),captionStyle:v.lerpStyle(e.captionStyle,t.captionStyle,r)}}function Lt(e,t){let r=t??M;return{sliceFills:ke(e?.sliceFills,r.sliceFills),ring:go(e?.ring,r.ring),label:xo(e?.label,r.label),center:bo(e?.center,r.center),legend:Z(e?.legend,r.legend),spotlight:{dimOpacity:e?.spotlight?.dimOpacity??r.spotlight.dimOpacity}}}function Mt(e,t,r){return{sliceFills:ve(e.sliceFills,t.sliceFills,r),ring:mo(e.ring,t.ring,r),label:yo(e.label,t.label,r),center:wo(e.center,t.center,r),legend:J(e.legend,t.legend,r),spotlight:{dimOpacity:ge(e.spotlight.dimOpacity,t.spotlight.dimOpacity,r)}}}var Wr=12,vo=14,_t=.62,Eo=6,Yr=34,$r=26,jr=8,Ro=.18,To=240,Lo=8,Kr=2,Qr=.44,Pt=.62,Mo=.78,Co=.9,qr=.001,en=26;function H(e,t=en){let r=e.fontSize;return typeof r=="number"?r:t}function _o(e,t,r,n,o,i){let s=new So,a=t-e,c=Math.max(2,Math.ceil(Math.abs(a)/(Math.PI*2)*To)),l=d=>d<=0?0:Math.min(o/d,a/2.2),u=(d,h)=>{let m=l(d),g=e+m,p=t-m,x=ne(d,g+(p-g)*h/c);return{x:x.x+i,y:x.y}};if(r<=0){s.moveTo(i,0);for(let d=0;d<=c;d++){let h=u(n,d);s.lineTo(h.x,h.y)}return s.close(),s}for(let d=0;d<=c;d++){let h=u(n,d);d===0?s.moveTo(h.x,h.y):s.lineTo(h.x,h.y)}for(let d=c;d>=0;d--){let h=u(r,d);s.lineTo(h.x,h.y)}return s.close(),s}var Ye=class{s;box;constructor(t,r){this.s=t,this.box=r}get arcs(){return Ve(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="leader"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let r=this.outerRadius,n=this.holeRadius,o=n>0?r-n:r*(1-Pt)*2,i=n>0?(n+r)/2:r*Pt,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),c=s>qr?o/s:1/0,l=a>qr?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(c,l))}insideGlyphs(t){let r=this.s.labelMode,n=this.s.slices[t.index]?.category.length??0,o=r==="both"||r==="percent"?qe(t.fraction).length:0,i=r==="category"?n:r==="both"?n*Qr:0;return Math.max(1,o,i)}get insideFont(){let t=H(this.s.label.insideStyle,en*1.9);for(let r of this.arcs){let n=this.insideRoom(r)*Co/(this.insideGlyphs(r)*_t);t=Math.min(t,n)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:r,centerCaption:n}=this.s,o=H(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=H(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,r.length,n.length*s);return Math.min(o,i*2*Mo/(a*_t))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=H(this.s.label.textStyle)*1.25,r=H(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+r+2:this.s.labelMode==="category"?t:r}captionGlyphs(t){let r=this.s.labelMode,n=r==="percent"||r==="both"?4:0,o=r==="category"||r==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(n,o)}get labelGutters(){let t={left:Kr,right:Kr};if(!this.hasLeaderLabels)return t;let r=H(this.s.label.textStyle)*_t;for(let n of this.arcs){let o=Yr+$r+jr+this.captionGlyphs(n.index)*r+vo,i=Ot(n.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:r}=this.labelGutters;return(t-r)/2}get outerRadius(){let{left:t,right:r}=this.labelGutters,n=Math.min((this.box.width-t-r)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,n/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let r=t<1?t*this.outerRadius:t;return Math.min(r,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+Yr}popOf(t){return ie(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let r=this.anchorRadius(t),n=this.holeRadius;return n>0?(n+r)/2:r*Pt}insideAnchor(t){let r=this.arcs.find(o=>o.index===t);if(r===void 0)return{x:this.centerX,y:0};let n=ne(this.bandMidRadius(t),r.mid);return{x:n.x+this.centerX,y:n.y}}get selectionStrength(){let t=0;for(let r=0;r<this.s.slices.length;r++)t=Math.max(t,this.popOf(r));return t}sliceOpacity(t){return Xe(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let r=this.arcs.find(n=>n.index===t);return qe(r?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let r=this.elbowRadius,n=this.labelRowHeight,o=this.box.height/2-n/2,i=-o,s=this.centerX,a=[],c=[];for(let l of t){let u=Ot(l.mid),d=ne(r,l.mid).y;(u>0?a:c).push({index:l.index,side:u,mid:l.mid,ideal:d,y:d})}return We(a,n+Wr,o,i),We(c,n+Wr,o,i),[...a,...c].map(l=>{let u=ne(this.anchorRadius(l.index)+Eo,l.mid),d=Math.sqrt(Math.max(0,r*r-l.y*l.y)),h=s+l.side*Math.max(d,r*Ro),m=s+l.side*(r+$r);return{index:l.index,side:l.side,leader:[{x:u.x+s,y:u.y},{x:h,y:l.y},{x:m,y:l.y}],text:{x:m+l.side*jr,y:l.y}}})}placementFor(t){return this.placements().find(r=>r.index===t)}};function Ot(e){return Math.sin(e)>=0?1:-1}var Po={width:0,height:0},Zr=new WeakMap;function Oo(e){if(typeof e!="object"||e===null)return Xr.resolve(e);let t=Zr.get(e);return t===void 0&&Zr.set(e,t=Xr.resolve(e)),t}function Jr(e){return e.map(t=>Oo(t.fill))}function Fo(e){let t=[],r=()=>new Ye(e,t[0]?.parent?.layoutBounds??Po),n=o=>{let i=()=>ie(e.labelReveal,0,1)*r().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let d=[];return a&&d.push(new oe({...se.styleProps(e.label.insideStyle),text:()=>r().percentText(o.index),fontSize:()=>r().insideFont})),s&&d.push(new oe({...se.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fontSize:()=>e.labelMode==="category"?r().insideFont:r().insideFont*Qr})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>r().insideAnchor(o.index),children:d})}let c=Ot(o.mid),l=()=>r().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new oe({...se.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:c>0?"left":"right"})),a&&u.push(new oe({...se.styleProps(e.label.percentStyle),text:()=>r().percentText(o.index),textAlign:c>0?"left":"right"})),new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:c>0?"centerLeft":"centerRight",opacity:i,centerLeft:c>0?l:void 0,centerRight:c>0?void 0:l,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ve(e.slices,e.ring.startAngle))t.push(n(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new oe({...se.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>r().centerFont})),e.centerCaption!==""&&o.push(new oe({...se.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>r().centerFont*(H(e.centerStyle.captionStyle,22)/H(e.centerStyle.labelStyle,46))})),t.push(new Ct({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>ie(e.centerReveal,0,1),center:()=>({x:r().centerX,y:0}),children:o}))}return t}var $e=Ao({key:"pieRing",state:{slices:f(()=>[]),ring:me.custom(M.ring),label:me.custom(M.label),centerStyle:me.custom(M.center),labelMode:me.custom("percent"),labelPlacement:me.custom("leader"),growth:1,labelReveal:1,pops:f(()=>[]),dimOpacity:M.spotlight.dimOpacity,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Fo(e),load:(e,t)=>D(e,{fills:Jr(t.slices),shadows:[ko.resolve(t.ring.shadow)],strokes:[Vr.resolve(t.ring.stroke),Vr.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=y(e);return e.animate(r=>({growth:t(r)}))},revealLabels:e=>{let t=y(e);return e.animate(r=>({labelReveal:t(r)}))},revealCenter:(e,t)=>{let r=y(e),n=ie(t.centerReveal,0,1);return e.animate(o=>({centerReveal:n+(1-n)*r(o)}))}},render:(e,t)=>{let r=new Ye(t,e.size),n=r.outerRadius,o=n>0?r.arcs:[];if(o.length>0){let i=ie(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=r.holeRadius,c=Math.max(0,t.ring.gap)/2,l=r.centerX,u=n+r.maxPop+1+Math.abs(l),d=[-u,-u,u,u],h=u*2,m=Jr(t.slices);for(let p of o){let x=Math.min(p.a1,s);if(x<=p.a0)continue;let N=_o(p.a0,x,a,r.anchorRadius(p.index),c,l),A=new zr().path(N.toPathState({centerBounds:d,width:h,height:h}));A.shadow(t.ring.shadow),A.fill(m[p.index]??[]),A.stroke(t.ring.stroke),e.draw(A.opacity(r.sliceOpacity(p.index)))}let g=ie(t.labelReveal,0,1);if(g>.001)for(let p of r.placements())e.draw(new zr().line({points:p.leader,radius:Lo}).stroke(t.label.leaderStroke).opacity(g*r.sliceOpacity(p.index)))}e.children()}});var Do=.65,Bo=.35,Ft=le.number(0,{min:0,step:1});function tn(e){return Rt(e.data,e.categoryField,e.valueField,e.theme.sliceFills)}function ce(e,t){return on(e.pops[t]??0,0,1)}function Go(e,t){return ce(e,t)>.5}function Ho(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,ce(e,n));let r=e.theme.spotlight.dimOpacity;return e.data.map((n,o)=>Xe(t,r,ce(e,o)))}function je(e,t,r){let n=t.data.map((i,s)=>ce(t,s)),o=t.data.map((i,s)=>on(r(s),0,1));return n.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:n.map((s,a)=>s+(o[a]-s)*i)}))}function rn(e){for(let t=e.length-1;t>=0;t--){let r=e[t],n=nn.is(r)?r.children.find($e.is):void 0;if(n)return{ring:n,legend:r.children.find(Ue.is)??null}}return null}var It=Io({key:"pieChart",state:{data:f(()=>[]),categoryField:"",valueField:"",theme:le.custom(M,{resolve:Lt,lerp:Mt}),labelMode:le.custom("percent"),labelPlacement:le.custom("leader"),gap:40,centerLabel:"",centerCaption:"",pops:f(()=>[]),showLegend:le.boolean(!0,{animatable:!1}),showCenter:le.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>tn(e).map(()=>0)},allowedChildren:[],children:e=>{let t=()=>e.theme,r=()=>tn(e),n=[new $e({width:"fill",height:"fill",slices:r,ring:()=>t().ring,label:()=>t().label,centerStyle:()=>t().center,labelMode:e.labelMode,labelPlacement:e.labelPlacement,pops:()=>e.pops,dimOpacity:()=>t().spotlight.dimOpacity,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})];e.showLegend!==!1&&n.push(new Ue({slices:r,legend:()=>t().legend,dims:()=>Ho(e),gap:e.theme.legend.itemGap/3,padding:e.theme.legend.padding}));let o=new nn({flow:"horizontal",width:"fill",height:"fill",gap:e.gap,align:"center",children:n});return[o]},commands:{enter:{args:{},entrance:!0,easing:ae(),run:(e,t,r)=>{let n=rn(r);if(!n)return e.wait(e.duration);let{ring:o,legend:i}=n,s=e.duration*Do,a=e.duration*Bo,c=l=>({at:0,duration:0,piece:l});return w(e,[c(o.to({growth:0,labelReveal:0})),...i?[c(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:ae(),run:(e,t,r)=>rn(r)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?1:ce(t,n))}},deselectSlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?0:ce(t,n))}},selectOnlySlice:{args:{sliceIndex:Ft},easing:ae(),run:(e,t)=>{let r=e.args.sliceIndex;return je(e,t,n=>n===r?1:0)}},clearSelection:{args:{},easing:ae(),run:(e,t)=>je(e,t,()=>0)}}});var No=[ut,At,It];export{At as BarChart,k as CHART_PALETTE,Ie as CategoryAxis,Ne as ChartBars,Me as ChartBorder,Ce as ChartCanvas,Q as ChartLegend,_e as ChartLine,st as ChartRegion,L as DEFAULT_BAR_CHART_THEME,X as DEFAULT_CHART_THEME,R as DEFAULT_LEGEND,U as DEFAULT_MARKERS,M as DEFAULT_PIE_CHART_THEME,be as DEFAULT_PLOT_AREA,Uo as DEFAULT_SERIES_COLORS,we as DEFAULT_SERIES_FILLS,Bt as DEFAULT_SERIES_STROKES,E as DEFAULT_X_AXIS,ye as DEFAULT_Y_AXIS,ee as EMPTY_REGION_BOX,_ as ENTER_SHARE,Pe as HorizontalAxis,xe as LEGEND_SLIDE,ut as LineChart,No as NODES,It as PieChart,Ue as PieLegend,$e as PieRing,C as SERIES_ARG,O as SPOTLIGHT_DIM,I as VerticalAxis,z as armed,P as arrival,b as arrivalOf,Y as arrivalsEntry,W as asParts,ft as barCategories,St as barChartDomain,Be as barSpans,Er as barValueExtent,w as beats,Re as cartesianFrame,Te as cartesianViews,Je as clipPolylineToBox,cr as formatInstant,F as formatMarker,qe as formatPercent,y as frameEase,f as fresh,te as hasRegion,Go as isSliceSelected,Le as laidOutSize,q as lerpAxisConfig,ue as lerpAxisDomain,de as lerpAxisEntry,xt as lerpBarChartTheme,et as lerpChartTheme,J as lerpLegendConfig,Mt as lerpPieChartTheme,Ae as lerpPlotArea,ve as lerpSeriesFills,Ht as lerpSeriesStrokes,Fe as lineChartDomains,D as loadPaints,zt as markerCaption,Ee as markerStep,T as markerValues,S as num,zo as numericFields,lr as parseInstant,Ve as pieArcs,We as relaxLabels,K as resolveAxisConfig,$ as resolveAxisDomain,mt as resolveBarChartTheme,Ge as resolveBarFill,gt as resolveBarScale,Qe as resolveChartTheme,Z as resolveLegendConfig,Lt as resolvePieChartTheme,Rt as resolvePieSlices,Se as resolvePlotArea,Ze as resolveRegionBox,Ut as resolveSeriesFill,ke as resolveSeriesFills,Nt as resolveSeriesStroke,Gt as resolveSeriesStrokes,at as resolveXScale,rt as resolveYScale,ne as ringPoint,tt as seriesPoints,he as settleAxisDomain,Ur as sliceTotal,Tt as sliceValue,pt as stackCapIndex,j as text,Yt as yExtent};
1
+ import{$ as Ys,A as ve,B as Z,C as xt,D as Ue,E as y,F as J,G as O,H as C,I as $t,J as yt,K as ir,L as bt,M as Q,N as D,O as L,P as G,Q as sr,R as Xe,S as ar,T as jt,U as Me,V as We,W as Ve,X as Ke,Y as N,Z as k,_ as $,a as H,aa as lr,b as Ns,ba as Us,c as Ye,ca as Xs,d as Re,da as Ee,e as Y,ea as wt,f as lt,fa as qt,g as Se,ga as ee,h as Ae,ha as Te,i as ct,ia as Rt,j as ut,ja as te,k as U,ka as Ws,l as X,la as le,m as ft,ma as cr,n as P,na as Le,o as W,oa as Ce,p as F,pa as _e,q as Hs,qa as Oe,r as ht,ra as ne,s as ke,sa as j,t as B,ta as ce,u as V,ua as ur,v as dt,va as Ie,w as pt,x as K,y as gt,z as mt}from"./chunks/chunk-7XCRX6GE.js";import{Rect as hi,Text as di,Types as re,clamp as un,component2d as pi,easeOut as he}from"@motionscript/sdk";import{formatNumber as gi}from"@motionscript/sdk/component";import{Graphics2D as $e,Types as fe,clamp as je,component2d as xr,fillOps as qe,strokeOps as gr}from"@motionscript/sdk";import{Types as ge}from"@motionscript/sdk";var me={left:0,right:0,bottom:0,top:0,xBounded:!1,yBounded:!1};function ue(e){return e.right>e.left&&e.top>e.bottom}function Zt(e,t,n,r){if(!e||e.x===void 0&&e.y===void 0)return me;let o=(f,[h,d],p,g)=>{if(f===void 0||d<=h)return[p,g,!1];let m=Math.min(f[0],f[1]),x=Math.max(f[0],f[1]),R=v=>p+(v-h)/(d-h)*(g-p);return[Math.max(p,Math.min(g,R(m))),Math.max(p,Math.min(g,R(x))),!0]},[i,s,a]=o(e.x,n,t.left,t.right),[l,c,u]=o(e.y,r,t.bottom,t.top);return{left:i,right:s,bottom:l,top:c,xBounded:a,yBounded:u}}function Jt(e,t){if(e.length<2||!ue(t))return[];let n=[],r=[];for(let o=1;o<e.length;o++){let i=Zo(e[o-1],e[o],t);if(!i){r.length>=2&&n.push(r),r=[];continue}let[s,a]=i;r.length>0&&qo(r[r.length-1],s)?r.push(a):(r.length>=2&&n.push(r),r=[s,a])}return r.length>=2&&n.push(r),n}function qo(e,t){return Math.abs(e.x-t.x)<.5&&Math.abs(e.y-t.y)<.5}function Zo(e,t,n){let r=t.x-e.x,o=t.y-e.y,i=0,s=1,a=[[-r,e.x-n.left],[r,n.right-e.x],[-o,e.y-n.bottom],[o,n.top-e.y]];for(let[l,c]of a){if(l===0){if(c<0)return null;continue}let u=c/l;if(l<0){if(u>s)return null;u>i&&(i=u)}else{if(u<i)return null;u<s&&(s=u)}}return[{x:e.x+i*r,y:e.y+i*o},{x:e.x+s*r,y:e.y+s*o}]}function Jo(e,t,n){return e.map((r,o)=>[t.at(o),k(r,n.field)]).sort((r,o)=>r[0]-o[0])}function pr(e,t){let n=1/0,r=-1/0;for(let o of e)for(let i of t){let s=k(o,i.field);s<n&&(n=s),s>r&&(r=s)}return n<=r?[n,r]:[0,1]}function Qo(e,t,n,r){return n??Te(pr(e,t),r)}function Qt(e,t,n,r,o=[]){let i=e.map((c,u)=>u).sort((c,u)=>t.at(c)-t.at(u));if(r!=="stacked"&&r!=="percent")return n.map(c=>({points:i.map(u=>[t.at(u),k(e[u],c.field)]),base:null}));let s=c=>Math.max(0,o[c]??1),a=i.map(c=>n.reduce((u,f,h)=>u+Math.abs(k(e[c],f.field)*s(h)),0)),l=i.map(()=>0);return n.map((c,u)=>{let f=i.map((d,p)=>[t.at(d),l[p]]);return{points:i.map((d,p)=>{let g=k(e[d],c.field)*s(u);return l[p]+=r==="percent"?a[p]>0?g/a[p]*100:0:g,[t.at(d),l[p]]}),base:f}})}function St(e){let t=1/0,n=-1/0;for(let{points:r,base:o}of e)for(let[,i]of[...r,...o??[]])i<t&&(t=i),i>n&&(n=i);return t<=n?[t,n]:[0,1]}var fr=16;function en(e,t){if(t==="step"){let o=e.length>0?[e[0]]:[];for(let i=1;i<e.length;i++){let s=(e[i-1].x+e[i].x)/2;o.push({x:s,y:e[i-1].y},{x:s,y:e[i].y},e[i])}return o}if(t!=="smooth"||e.length<3)return[...e];let n=ei(e),r=[e[0]];for(let o=1;o<e.length;o++){let i=e[o-1],s=e[o],a=(s.x-i.x)/3,l={x:i.x+a,y:i.y+a*n[o-1]},c={x:s.x-a,y:s.y-a*n[o]};for(let u=1;u<=fr;u++){let f=u/fr,h=1-f;r.push({x:h*h*h*i.x+3*h*h*f*l.x+3*h*f*f*c.x+f*f*f*s.x,y:h*h*h*i.y+3*h*h*f*l.y+3*h*f*f*c.y+f*f*f*s.y})}}return r}function ei(e){let t=e.length,n=o=>{let i=e[o+1].x-e[o].x;return i===0?0:(e[o+1].y-e[o].y)/i},r=new Array(t).fill(0);for(let o=1;o<t-1;o++){let i=e[o].x-e[o-1].x,s=e[o+1].x-e[o].x,a=n(o-1),l=n(o),c=i+s===0?0:(a*s+l*i)/(i+s);r[o]=(Math.sign(a)+Math.sign(l))*Math.min(Math.abs(a),Math.abs(l),.5*Math.abs(c))||0}return r[0]=hr(n(0),r[1]),r[t-1]=hr(n(t-2),r[t-2]),r}function hr(e,t){let n=(3*e-t)/2;return e===0||Math.sign(n)!==Math.sign(e)?0:Math.abs(n)>3*Math.abs(e)?3*e:n}function tn(e,t){if(e.length===0||t<e[0].x)return[];let n=[];for(let r=0;r<e.length;r++){let o=e[r];if(o.x<=t){n.push(o);continue}let i=e[r-1];i&&o.x>i.x&&n.push({x:t,y:i.y+(o.y-i.y)*(t-i.x)/(o.x-i.x)});break}return n}function nn(e,t){if(e.length<3||!ue(t))return[];let n=[o=>o.x-t.left,o=>t.right-o.x,o=>o.y-t.bottom,o=>t.top-o.y],r=[...e];for(let o of n){let i=r;r=[];for(let s=0;s<i.length;s++){let a=i[s],l=i[(s+i.length-1)%i.length],c=o(a),u=o(l);c>=0?(u<0&&r.push(dr(l,a,u,c)),r.push(a)):u>=0&&r.push(dr(l,a,u,c))}if(r.length===0)return[]}return r}function dr(e,t,n,r){let o=n/(n-r);return{x:e.x+(t.x-e.x)*o,y:e.y+(t.y-e.y)*o}}var rn={strokeWidth:ge.number(4,{min:0,max:24,step:.5,unit:"px"}),curve:ge.oneOf(["smooth","linear","step"]),dots:ge.boolean(!1),dotSize:ge.number(12,{min:0,max:48,step:1,unit:"px"}),area:ge.oneOf(["none","solid","gradient"]),areaOpacity:ge.number(.4,{min:0,max:1,step:.05})},on={values:ge.oneOf(["none","above","below"],{animatable:!1})};function Ze(e,t){if(e.length===0)return 0;let n=e[0].x,r=e[e.length-1].x;return t>=1?1/0:n+(r-n)*t}function sn(e,t,n){let r=en(e,t);return n>=1?r:tn(r,Ze(e,n))}var yr=()=>fe.custom("smooth");function ti(e){return[...e.map((t,n)=>({type:n===0?"M":"L",x:t.x,y:t.y})),{type:"Z"}]}function ni(e,t,n,r){if(t.length<3||r<=0)return;let{width:o,height:i}=e.size,s=[-o/2,-i/2,o/2,i/2];e.draw(new $e().path({data:ti(t),centerBounds:s}).fill(n).opacity(r))}var At=xr({key:"chartLine",state:{points:y(()=>[]),curve:yr(),stroke:fe.custom([],{resolve:gr.resolve,lerp:gr.lerp}),dotSize:0,dotFill:fe.custom([],{resolve:qe.resolve,lerp:qe.lerp}),progress:1,enabled:!0,spotlight:y(()=>me),dimOpacity:N},load:(e,t)=>C(e,{fills:[t.dotFill],strokes:[t.stroke]}),commands:{enter:{args:{from:fe.number(0,{min:0,max:1}),to:fe.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=L(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}},hold:{args:{shown:fe.boolean(!0)},run:e=>{let{shown:t}=e.args;return e.animate(n=>({progress:1,enabled:t||n<1}),{eased:!1})}}},render:(e,t)=>{if(!t.enabled)return;let n=t.points,r=je(t.progress,0,1);if(n.length===0||r<=0)return;let o=t.spotlight,i=ue(o),s=je(t.dimOpacity,0,1),a=t.stroke,l=a[0]?.weight??0,c=sn(n,t.curve,r);if(c.length>=2&&l>0){let m=t.curve==="linear"?l*2:0;if(e.draw(new $e().line({points:c,radius:m}).stroke(a).opacity(i?s:1)),i)for(let x of Jt(c,o))e.draw(new $e().line({points:x,radius:m}).stroke(a))}let u=t.dotSize;if(u<=0)return;let f=Ze(n,r),h=new $e,d=new $e,p=!1,g=!1;for(let m of n){let x=f===1/0?1:je((f-m.x)/(u*2),0,1);if(x<=0)continue;let R=!i||m.x>=o.left&&m.x<=o.right&&m.y>=o.bottom&&m.y<=o.top;(R?h:d).ellipse({x:m.x,y:m.y,width:u*x,height:u*x}),R?p=!0:g=!0}g&&e.draw(d.fill(t.dotFill).opacity(s)),p&&e.draw(h.fill(t.dotFill))}}),an=xr({key:"chartArea",state:{points:y(()=>[]),base:y(()=>[]),baseline:0,curve:yr(),area:fe.custom("solid"),fill:fe.custom([],{resolve:qe.resolve,lerp:qe.lerp}),areaOpacity:.4,progress:1,enabled:!0,spotlight:y(()=>me),dimOpacity:N},load:(e,t)=>C(e,{fills:[t.fill]}),render:(e,t)=>{let n=t.points,r=je(t.progress,0,1);if(!t.enabled||t.area==="none"||n.length<2||r<=0||t.fill.length===0)return;let o=c=>{let u=sn(n,t.curve,c);if(u.length<2)return[];let f=t.base.length===n.length?sn(t.base,t.curve,c):[{x:u[0].x,y:t.baseline},{x:u[u.length-1].x,y:t.baseline}];return[...u,...[...f].reverse()]},i=mr(o(1)),s=(c,u)=>ni(e,c,br(t.fill,t.area,t.areaOpacity,i,mr(c)),u),a=o(r),l=t.spotlight;if(!ue(l)){s(a,1);return}s(a,je(t.dimOpacity,0,1)),s(nn(a,l),1)}});function mr(e){let t=-1/0,n=1/0;for(let r of e)r.y>t&&(t=r.y),r.y<n&&(n=r.y);return{top:t,bottom:n}}function br(e,t,n,r,o){let i=e[e.length-1];if(t!=="gradient"||i?.type!=="solid"||!(o.top>o.bottom))return Ue(e,n);let[s,a,l,c]=i.color,u=(o.top+o.bottom)/2,f=(o.top-o.bottom)/2;return qe.resolve({type:"linear-gradient",colors:[[s,a,l,c*n],[s,a,l,c*n*.04]],start:{x:0,y:(r.top-u)/f},end:{x:0,y:(r.bottom-u)/f}})}import{Graphics2D as ri,Types as wr,component2d as oi,fillOps as Rr,strokeOps as Sr}from"@motionscript/sdk";var ln=oi({key:"chartRegion",state:{box:y(()=>me),stroke:wr.custom({weight:2,fill:"white/70",dash:[14,12],cap:"butt",align:"center"},{resolve:Sr.resolve,lerp:Sr.lerp}),fill:wr.custom("white/6",{resolve:Rr.resolve,lerp:Rr.lerp}),reveal:0},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),render:(e,t)=>{let n=t.box;if(!ue(n))return;let r=Math.max(0,Math.min(1,t.reveal));if(r<=0)return;let o=n.right-n.left,i=n.top-n.bottom,s=(n.left+n.right)/2,a=(n.bottom+n.top)/2;if(t.fill.length>0&&e.draw(new ri().rect({x:s,y:a,width:o,height:i}).fill(t.fill).opacity(r)),t.stroke.length!==0){if(n.xBounded){let l=i/2*r;for(let c of[n.left,n.right])$t(e,{x:c,y:a-l},{x:c,y:a+l},t.stroke,r)}if(n.yBounded){let l=o/2*r;for(let c of[n.bottom,n.top])$t(e,{x:s-l,y:c},{x:s+l,y:c},t.stroke,r)}}}});import{formatNumber as ii}from"@motionscript/sdk/component";var kt=864e5,Tr=["january","february","march","april","may","june","july","august","september","october","november","december"],Ar=2024;function kr(e){return e.length<3?-1:Tr.findIndex(t=>t.startsWith(e))}function si(e,t){let n=Date.UTC(e,0,4),r=(new Date(n).getUTCDay()+6)%7;return n-r*kt+(t-1)*7*kt}function Lr(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();if(t==="")return null;let n=/^(\d{4})[-/](\d{1,2})(?:[-/](\d{1,2}))?$/.exec(t);if(n){let s=Number(n[2]),a=n[3]===void 0?1:Number(n[3]);return s<1||s>12||a<1||a>31?null:Date.UTC(Number(n[1]),s-1,a)}let r=/^(?:(\d{4})[-\s]?)?w(?:ee)?k?[-\s]?(\d{1,2})$/.exec(t);if(r){let s=Number(r[2]);return s<1||s>53?null:si(r[1]===void 0?Ar:Number(r[1]),s)}let o=/^(?:(\d{4})[-\s]+)?([a-z]+)(?:[-\s]+(\d{4}))?$/.exec(t);if(o){let s=kr(o[2]);if(s>=0){let a=o[1]??o[3],l=a===void 0?Ar:Number(a);return Date.UTC(l,s,1)}}let i=/^(?:(\d{1,2})[-\s]+([a-z]+)|([a-z]+)[-\s]+(\d{1,2}),?)[-\s]+(\d{4})$/.exec(t);if(i){let s=kr(i[2]??i[3]),a=Number(i[1]??i[4]);if(s>=0&&a>=1&&a<=31)return Date.UTC(Number(i[5]),s,a)}return null}function Cr(e,t){let n=new Date(e),r=n.getUTCFullYear(),o=Tr[n.getUTCMonth()].slice(0,3),i=o.charAt(0).toUpperCase()+o.slice(1);return t>4*365*kt?String(r):t>60*kt?`${i} ${r}`:`${i} ${n.getUTCDate()}`}function ai(e,t){let n=!1;for(let r of e){let o=r[t];if(!(o==null||o==="")){if(typeof o!="number")return!1;n=!0}}return n}function li(e,t){let n=[],r=!1;for(let s of e){let a=s[t];if(a==null||a===""){n.push(null);continue}let l=Lr(a);if(l===null)return null;n.push(l),r=!0}if(!r)return null;let i=n.find(s=>s!==null);return n.map(s=>s===null?i:i=s)}function vr(e){let t=1/0,n=-1/0;for(let r of e)r<t&&(t=r),r>n&&(n=r);return t<=n?[t,n]:[0,1]}var _r=12;function Mr(e,[t,n],r){let o=e.filter(l=>l>=t&&l<=n),i=[...new Set(o)].sort((l,c)=>l-c);if(i.length===0)return ee([t,n],r);if(i.length<=_r&&ci(i))return i;let s=l=>i.reduce((c,u)=>Math.abs(u-l)<Math.abs(c-l)?u:c),a=[];for(let l of ee([t,n],r)){let c=s(l);a[a.length-1]!==c&&a.push(c)}return a}function ci(e){if(e.length<3)return!0;let t=(e[e.length-1]-e[0])/(e.length-1);for(let n=1;n<e.length;n++)if(e[n]-e[n-1]<t*.75)return!1;return!0}function ui(e,t,n,r){let o=e.indexOf(n);return o>=0?t[o]:r(n)}var Er=new WeakMap;function cn(e,t,n){let r=Er.get(e);r||Er.set(e,r=new Map);let o=JSON.stringify([t,n??null]),i=r.get(o);return i||r.set(o,i=fi(e,t,n)),i}function fi(e,t,n){if(t!==""&&ai(e,t)){let s=e.map(a=>k(a,t));return{kind:"numeric",at:a=>s[a]??0,extent:vr(s),label:a=>n===void 0?Ee(a):ii(a,n),ticks:ee}}let r=e.map(s=>$(s,t)),o=t===""?null:li(e,t);if(o){let s=vr(o),a=s[1]-s[0];return{kind:"time",at:l=>o[l]??0,extent:s,label:l=>ui(o,r,l,c=>Cr(c,a)),ticks:(l,c)=>Mr(o,l,c)}}let i=e.map((s,a)=>a);return{kind:"ordinal",at:s=>s,extent:i.length>0?[0,i.length-1]:[0,1],label:s=>r[Math.round(s)]??"",ticks:(s,a)=>Mr(i,s,a)}}var mi=re.style(H,{series:Y,background:Se,text:ct,grid:ut,marks:rn,labels:on,legend:U},{presets:X}),Or=re.custom(void 0,{kind:"region",properties:{x:{kind:"range",default:!0,defaultMin:0,defaultMax:100},y:{kind:"range",default:!1,defaultMin:0,defaultMax:100}}}),Yr=[0,100];function vt(e,t=e.xAxis.format){return cn(e.data,e.xField,t)}function hn(e,t=!0){return Qt(e.data,vt(e),e.series,e.stack,t?e.weights:void 0)}function xi(e,t){let n=vt(e,t.format),r=t.range??n.extent;return{...t,range:r,ticks:t.ticks??n.ticks(r,Q-1)}}function yi(e,t){let[n,r]=St(hn(e,!1));if(e.stack==="percent"&&n>=0)return Yr;let o=e.stack!=="none"||(e.style?.area??"none")!=="none";return Te(o?[Math.min(0,n),Math.max(0,r)]:[n,r],t)}function bi(e,t){let n=(t.ticks?.length??Q)-1,r=t.range??yi(e,n),o=t.range!==void 0||e.stack==="percent"&&r===Yr;return{...t,range:r,ticks:t.ticks??(o?ee(r,Q-1):Rt(r,Q-1))}}var Ir=new WeakMap;function Je(e){let t=[e.xField,e.xAxis,e.yAxis,e.series,e.stack,e.style?.area],n=Ir.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domains;let r={x:Ke(e.xAxis,o=>xi(e,o)),y:Ke(e.yAxis,o=>bi(e,o))};return Ir.set(e.data,{key:t,domains:r}),r}function Ur(e,t){let[n,r]=e.x.range,[o,i]=e.y.range;return{x:s=>r<=n?0:((s-n)/(r-n)-.5)*t.width,y:s=>i===o?0:((s-o)/(i-o)-.5)*t.height}}var wi={points:[],base:[],values:[]};function Ri(e,t,n,r){let o=hn(e)[n];if(!o)return wi;let i=Ur(t,r),s=([a,l])=>({x:i.x(a),y:i.y(l)});return{points:o.points.map(s),base:o.base?o.base.map(s):[],values:o.points.map(([,a],l)=>a-(o.base?.[l]?.[1]??0))}}function Pr(e){let[t,n]=e.y.range;return un(0,Math.min(t,n),Math.max(t,n))}function Si(e,t){let[n,r]=St(hn(e,!1)),[o,i]=vt(e).extent,s=(a,[l,c])=>a>=Math.min(l,c)-1e-9&&a<=Math.max(l,c)+1e-9;return!(s(n,t.y.range)&&s(r,t.y.range)&&s(o,t.x.range)&&s(i,t.x.range))}function Ai(e,t,n){let{width:r,height:o}=n;return Zt(e.region,{left:-r/2,right:r/2,bottom:-o/2,top:o/2},t.x.range,t.y.range)}function Dr(e){let t=e.region;return t!=null&&(t.x!==void 0||t.y!==void 0)}function Gr(e){return e!=null&&typeof e=="object"?e:{}}function ki([e,t]){return e<=t?[e,t]:[t,e]}function zr(e,t){let n=ki(e);return{range:n,ticks:ee(n,Math.max(2,t.length)-1)}}function Fr(e,t,n){return{...t.x&&{xAxis:We(e.x,t.x,n)},...t.y&&{yAxis:We(e.y,t.y,n)}}}function Br(e,t,n){let r=e.yAxis.format;if(r!==void 0)return gi(t,r);let o=Ee(t,wt(n));return e.stack==="percent"?`${o}%`:o}function vi(e,t){return Math.max(0,e.weights[t]??1)}function fn(e){let t=mt(e);return{vAxis:t.find(Le.is)??null,hAxis:t.find(Ce.is)??null,lines:t.filter(At.is),legend:t.find(te.is)??null}}function Nr(e,t){let n=t.regionReveal,r=t.region;return n===0?e.animate(()=>({region:null,regionReveal:0}),{eased:!1}):e.animate(o=>o>=1?{region:null,regionReveal:0}:{region:r,regionReveal:n*(1-o)})}function Hr(e,t,n,r,o){let i=fn(n),s=i.lines[r];if(!s)return e.wait(e.duration);let a=i.legend?[i.legend.run(o?"showSeries":"hideSeries",{index:r})]:[];if(t.stack==="none")return e.together([s.run("enter",o?{from:0,to:1}:{from:1,to:0}),...a]);let l=t.series.map((f,h)=>vi(t,h)),c=l[r]??1,u=o?1:0;return e.together([e.animate(f=>{let h=[...l];return h[r]=c+(u-c)*e.ease(f),{weights:h}},{eased:!1}),s.run("hold",{shown:o}),...a])}var dn=pi({key:"lineChart",state:{data:y(()=>[],{kind:"dataset"}),xField:"",series:y(()=>[],{kind:"series"}),stack:re.oneOf(["none","stacked","percent"]),xAxis:re.custom({},{resolve:Me,lerp:Ve}),yAxis:re.custom({},{resolve:Me,lerp:Ve}),style:mi,region:re.custom(null),regionReveal:0,home:re.custom(null,{private:!0}),weights:re.custom([],{private:!0}),clipped:re.boolean(!1,{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0)},migrate:{style:V("cartesian")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>Je(e),r,o=()=>ve(r),i=w=>Ri(e,n(),w,o()),s=e.series.map(w=>w.enabled??!0),a=e.style,l=()=>ke(t(),"y"),c=()=>ke(t(),"x"),u=()=>{let w=n().y.ticks;return w.map(b=>Br(e,b,w))},f=a.showYAxis?new Le({range:()=>n().y.range,markers:()=>n().y.ticks,captions:u,axis:l,label:e.yAxis.label??"",width:"hug",height:"fill"}):void 0,h=a.showXAxis?new Ce({range:()=>n().x.range,markers:()=>n().x.ticks,captions:()=>{let w=vt(e);return n().x.ticks.map(b=>w.label(b))},axis:c,label:e.xAxis.label??"",overhang:()=>({left:K(t()),right:K(t())}),width:"fill",height:"hug"}):void 0,d=f&&h?xt({captions:u,count:Je(e).y.ticks.length,text:()=>l().labelStyle,title:e.yAxis.label??"",titleText:()=>l().titleStyle,tickPad:()=>le(l(),"right").tick,titlePad:()=>le(l(),"right").title}):void 0,p=()=>Ai(e,n(),o()),g=()=>1-(1-N)*e.regionReveal,m=e.series.map((w,b)=>new At({points:()=>i(b).points,curve:()=>t().curve,stroke:()=>({weight:t().strokeWidth,fill:P(t(),w,b),align:"center",cap:"round",join:"round"}),dotSize:()=>t().dots?t().dotSize:0,dotFill:()=>P(t(),w,b),enabled:s[b],spotlight:p,dimOpacity:g})),x=e.series.map((w,b)=>new an({points:()=>i(b).points,base:()=>i(b).base,baseline:()=>Ur(n(),o()).y(Pr(n())),curve:()=>t().curve,area:()=>t().area,fill:()=>P(t(),w,b),areaOpacity:()=>t().areaOpacity,progress:()=>m[b].progress,enabled:()=>m[b].enabled,opacity:()=>m[b].opacity,spotlight:p,dimOpacity:g})),R=[];if(a.values!=="none"){let w=a.values==="below";e.series.forEach((b,M)=>{e.data.forEach((z,E)=>{let T=m[M],pe=new di({...Z(()=>ht(t())),text:()=>{let _=i(M).values[E];return _===void 0?"":Br(e,_,n().y.ticks)},x:()=>{let _=(o().width-pe.layoutBounds.width)/2;return un(i(M).points[E]?.x??0,-Math.max(0,_),Math.max(0,_))},y:()=>{let _=i(M).points[E],ae=pe.layoutBounds.height/2+(t().dots?t().dotSize/2:t().strokeWidth/2)+Math.round(W(t().valueText)*.25);return(_?.y??0)+(w?-ae:ae)},opacity:()=>{let _=i(M).points[E];if(!T.enabled||!_)return 0;let ae=Ze(i(M).points,T.progress);return T.opacity*(ae===1/0?1:un((ae-_.x)/24,0,1))}});R.push(pe)})})}let v=a.legend,S=v!=="none"?new te({series:e.series,swatches:()=>e.series.map((w,b)=>P(t(),w,b)),legend:()=>B(t()),flow:v==="right"?"vertical":"horizontal"}):void 0;return r=new hi({clip:()=>e.clipped||Si(e,n()),children:[new yt({fill:()=>t().gridBackground,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:()=>n().x.ticks,yMarkers:()=>n().y.ticks,xExtent:()=>n().x.range,yExtent:()=>n().y.range,axisStroke:()=>t().axisStroke,xAxisAt:()=>Pr(n()),yAxisAt:()=>n().x.range[0]}),new ln({box:p,stroke:()=>({weight:2,fill:Ue(t().valueText.fill??"white",.7),dash:[14,12],cap:"butt",align:"center"}),fill:()=>Ue(t().valueText.fill??"white",.06),reveal:()=>e.regionReveal}),...x,...m,...R]}),[gt({background:()=>t().background,left:f,ghost:d,plot:r,bottom:h,legend:S,legendAt:v,gap:()=>dt(t()),padding:()=>({top:pt(t()),right:h?K(t()):0,left:h&&!f?K(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:he(),run:(e,t,n)=>{let r=fn(n),o=e.duration,i=Dr(t)&&t.regionReveal===0,s=i?o*.75:o,a=s*D.axes,l=s*D.marks,{legend:c}=r,u=h=>({at:0,duration:0,piece:h}),f=bt(t.style.legend);return G(e,[...i?[u(e.animate(()=>({regionReveal:0})))]:[],...r.lines.map(h=>u(h.to({progress:0}))),...c?[u(c.to({opacity:0,...f}))]:[],...r.vAxis?[{at:0,duration:a,piece:r.vAxis.run("enter",{slide:24})}]:[],...r.hAxis?[{at:0,duration:a,piece:r.hAxis.run("enter",{slide:24})}]:[],...r.lines.map(h=>({at:a,duration:l,piece:h.run("enter")})),...c?[{at:a+l,duration:s*D.legend,piece:c.to({opacity:1,x:0,y:0})}]:[],...i?[{at:s,duration:o*.25,piece:e.animate(h=>({regionReveal:h}))}]:[],{at:0,duration:o,piece:e.wait(o)}])}},spotlightRegion:{args:{region:Or},easing:he(),run:(e,t)=>{let n=Gr(e.args.region),r=t.regionReveal,o=t.region;return n.x===void 0&&n.y===void 0?Nr(e,t):r<=0||!Dr(t)?e.animate(i=>({region:n,regionReveal:r+(1-r)*i})):e.animate(i=>i<.5?{region:o,regionReveal:r*(1-e.ease(i*2))}:{region:n,regionReveal:e.ease(i*2-1)},{eased:!1})}},clearRegion:{args:{},easing:he(),run:(e,t)=>Nr(e,t)},zoomTo:{args:{region:Or},easing:he(),run:(e,t)=>{let n=Gr(e.args.region);if(!n.x&&!n.y)return e.wait(e.duration);let r=Je(t),o=t.home??r,i={...n.x&&{x:{...r.x,...zr(n.x,r.x.ticks)}},...n.y&&{y:{...r.y,...zr(n.y,r.y.ticks)}}};return e.animate(s=>({home:o,clipped:!0,...Fr(r,i,s)}))}},resetZoom:{args:{},easing:he(),run:(e,t)=>{let n=t.home;if(!n)return e.wait(e.duration);let r=Je(t);return e.animate(o=>({home:null,clipped:o<1,...Fr(r,n,o)}))}},showSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>Hr(e,t,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>Hr(e,t,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:O},easing:he(),run:(e,t,n)=>{let r=fn(n),o=e.args.seriesIndex;return e.together([...r.lines.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}}}});import{Rect as zi,Types as oe,clamp as Mn,component2d as Fi,easeOut as Pe}from"@motionscript/sdk";import{formatNumber as Bi}from"@motionscript/sdk/component";import{Rect as pn,Text as Xr,Types as Mt,clamp as Mi,component2d as Ei}from"@motionscript/sdk";import{enterBudget as Ti}from"@motionscript/sdk/component";var Li=24;function Qe(e,t,n){return t<=0?0:-n/2+n/t*(e+.5)}var Et=Ei({key:"categoryAxis",state:{categories:y(()=>[]),axis:Mt.custom(lr),label:"",orientation:Mt.oneOf(["horizontal","vertical"]),dims:y(()=>[]),arrivals:sr()},defaults:{width:"fill",height:"fill"},children:e=>{let t=e.categories.length,n=s=>Mi(e.dims[s]??1,0,1);if(e.orientation==="vertical")return[cr({count:t,axis:()=>e.axis,text:s=>e.categories[s]??"",place:(s,a)=>-Qe(s,e.categories.length,a),arrivals:()=>e.arrivals,opacity:n,label:e.label})];let r=()=>le(e.axis,"top"),o=e.categories.map((s,a)=>{let l=new pn({width:"hug",height:"hug",flow:"freeform",opacity:()=>n(a),x:()=>Qe(a,e.categories.length,l.parent?.layoutBounds.width??0),children:[new Xr({...Z(()=>e.axis.labelStyle),text:s,opacity:()=>Xe(e.arrivals,a).opacity,y:()=>Xe(e.arrivals,a).shift})]});return l}),i=[new pn({width:"fill",height:"hug",padding:()=>({top:r().tick}),children:o})];return e.label!==""&&i.push(new Xr({...Z(()=>e.axis.titleStyle),text:e.label,opacity:()=>Xe(e.arrivals,"label").opacity,y:()=>Xe(e.arrivals,"label").shift})),[new pn({flow:"vertical",gap:()=>r().title,height:"hug",width:"fill",children:i})]},commands:{enter:{args:{stagger:Mt.custom(void 0),slide:Mt.number(Li)},run:(e,t)=>{let{stagger:n,slide:r}=e.args,o=t.categories.length,i=t.label!=="",s={opacity:0,shift:r},a=[...t.categories.keys(),...i?["label"]:[]],l=e.animate(()=>({arrivals:ar(a,s)}));if(o===0)return l;let{step:c,per:u,caption:f}=Ti(e.duration,o,i,n),h=L(e),d=t.categories.map((g,m)=>({at:m*c,duration:u,piece:jt(e,m,s,h)})),p=i?[{at:(o-1)*c+u,duration:f,piece:jt(e,"label",s,h)}]:[];return e.together([l,G(e,[...d,...p])])}}}});import{Graphics2D as _i,Text as Oi,Types as tt,clamp as wn,component2d as Ii,fillOps as Vr}from"@motionscript/sdk";import{Types as et,fillOps as Ci}from"@motionscript/sdk";function Tt(e,t,n,r=[]){let o=h=>Math.max(0,r[h]??1);if(n!=="stacked"&&n!=="percent")return t.map(h=>{let d=k(e,h.field);return{from:0,to:d,value:d,outer:!0}});let i=t.map((h,d)=>k(e,h.field)*o(d)),s=i.reduce((h,d)=>h+Math.abs(d),0),a=n==="percent"?i.map(h=>s>0?h/s*100:0):i,l=-1,c=-1;a.forEach((h,d)=>{h>0?l=d:h<0&&(c=d)});let u=0,f=0;return a.map((h,d)=>{if(h<0){let g=f;return f+=h,{from:g,to:f,value:h,outer:d===c}}let p=u;return u+=h,{from:p,to:u,value:h,outer:d===l}})}function gn(e,t){return e.map(n=>$(n,t))}function Wr(e,t,n,r){let o=0,i=0;for(let s of e)for(let a of Tt(s,t,n,r))o=Math.min(o,a.from,a.to),i=Math.max(i,a.from,a.to);return o<i?[o,i]:[0,1]}function mn(e,t,n,r,o,i){if(r)return r;let[s,a]=Wr(e,t,n,i);return n==="percent"?[s<0?-100:0,a>0?100:0]:Te([s,a],o)}function xn(e){let t=Ci.resolve(e),n=t[t.length-1];if(n?.type!=="solid")return"white";let[r,o,i]=n.color,s=l=>l<=.03928?l/12.92:((l+.055)/1.055)**2.4;return .2126*s(r)+.7152*s(o)+.0722*s(i)>.4?"#0a0a0a":"white"}var yn={barCornerRadius:et.cornerRadius({topLeft:10,topRight:10,bottomRight:0,bottomLeft:0}),barCornerStyle:et.cornerStyle("rounded"),barWidth:et.number(.7,{min:.05,max:1,step:.05,unit:"%",scale:100}),barGap:et.number(6,{min:0,max:40,step:1,unit:"px"})},bn={values:et.oneOf(["none","end","inside"],{animatable:!1})};var Pi=.6;function Kr(e,t){return e.enabled?wn(e.dims[t]??1,0,1):0}function Rn(e,t){let n=e.bars[t];if(!n)return null;let r=wn(e.growth,0,1);return{base:e.baseline+(n.from-e.baseline)*r,end:e.baseline+(n.to-e.baseline)*r}}function qr(e){return typeof e.fontSize=="number"?e.fontSize:24}function $r(e,t,n){let r=Rn(e,t);if(!r)return 0;if(e.values==="inside")return(r.base+r.end)/2;let o=r.end>=r.base?1:-1;return r.end+o*(qr(e.valueStyle)*.4+n/2)}function Di(e,t,n,r){let o=e.bars[t],i=Rn(e,t);if(!o||!i)return!1;let s=qr(e.valueStyle)*Pi;return Math.abs(i.end-i.base)>=n+s&&o.thickness>=r}var Lt=Ii({key:"chartBars",state:{bars:y(()=>[]),baseline:0,horizontal:!1,fill:tt.custom([],{resolve:Vr.resolve,lerp:Vr.lerp}),cornerRadius:tt.cornerRadius(8),cornerStyle:tt.cornerStyle("rounded"),growth:1,dims:y(()=>[]),values:tt.custom("none"),valueStyle:tt.custom({fontSize:24,fill:"white"}),enabled:!0},defaults:{width:"fill",height:"fill"},children:e=>e.values==="none"?[]:e.bars.map((t,n)=>{let r=new Oi({...Z(()=>({...e.valueStyle,...e.values==="inside"&&{fill:xn(e.fill)}})),text:()=>e.bars[n]?.caption??"",x:()=>e.horizontal?$r(e,n,r.layoutBounds.width):e.bars[n]?.center??0,y:()=>e.horizontal?e.bars[n]?.center??0:$r(e,n,r.layoutBounds.height),opacity:()=>{let o=r.layoutBounds,i=e.horizontal?o.width:o.height,s=e.horizontal?o.height:o.width;return e.values==="inside"&&!Di(e,n,i,s)?0:Kr(e,n)*wn((e.growth-.6)/.4,0,1)}});return r}),load:(e,t)=>C(e,{fills:[t.fill]}),commands:{enter:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))}},render:(e,t)=>{if(t.enabled)for(let n=0;n<t.bars.length;n++){let r=t.bars[n],o=Rn(t,n);if(!o||r.thickness<=0)continue;let i=r.round?0:1,s=Math.abs(o.end-o.base)+i;if(s<=i)continue;let a=o.end>=o.base,l=(o.base+o.end)/2+(a?i:-i)/2,c=Gi(t,r,a,s),u=new _i().rect(t.horizontal?{x:l,y:r.center,width:s,height:r.thickness,...c}:{x:r.center,y:l,width:r.thickness,height:s,...c});u.fill(t.fill),e.draw(u.opacity(Kr(t,n)))}e.children()}});function jr(e,t,n){return t?n?{topLeft:e.bottomLeft,topRight:e.topLeft,bottomRight:e.topRight,bottomLeft:e.bottomRight}:{topLeft:e.topLeft,topRight:e.bottomLeft,bottomRight:e.bottomRight,bottomLeft:e.topRight}:n?e:{topLeft:e.bottomLeft,topRight:e.bottomRight,bottomRight:e.topRight,bottomLeft:e.topLeft}}function Gi(e,t,n,r){let o=t.grounded??!0,i=e.cornerRadius,s=(t.round?1:0)+(o?1:0),a=Math.max(0,Math.min(t.thickness/2,s>1?r/2:r)),l=(u,f)=>f?Math.max(0,Math.min(u,a)):0,c={topLeft:l(i.topLeft,t.round),topRight:l(i.topRight,t.round),bottomRight:l(i.bottomRight,o),bottomLeft:l(i.bottomLeft,o)};return{cornerRadius:jr(c,e.horizontal,n),cornerStyle:jr(e.cornerStyle,e.horizontal,n)}}var Ni=oe.style(H,{series:Y,background:Se,text:ct,grid:ut,marks:yn,labels:bn,legend:U},{presets:X});function Hi(e,t){let n=(t.ticks?.length??Q)-1,r=mn(e.data,e.series,e.stack,t.range,n),o=t.range!==void 0||e.stack==="percent";return{...t,range:r,ticks:t.ticks??(o?ee(r,Q-1):Rt(r,Q-1))}}var Zr=new WeakMap;function _t(e){let t=[e.series,e.stack,e.valueAxis],n=Zr.get(e.data);if(n&&n.key.every((o,i)=>o===t[i]))return n.domain;let r=Ke(e.valueAxis,o=>Hi(e,o));return Zr.set(e.data,{key:t,domain:r}),r}function An(e,t,n){let r=e.valueAxis.format;if(r!==void 0)return Bi(n,r);let o=Ee(n,wt(t.ticks));return e.stack==="percent"?`${o}%`:o}function kn(e,t,n){let[r,o]=e.range;return o===r?-t/2:((n-r)/(o-r)-.5)*t}function Sn(e){let[t,n]=e.range;return Mn(0,Math.min(t,n),Math.max(t,n))}function Ct(e,t){return Math.max(0,e.weights[t]??1)}function eo(e,t){return e.orientation==="horizontal"?{along:t.width,across:t.height}:{along:t.height,across:t.width}}function Yi(e,t,n){let r=Qe(t,e.data.length,n);return e.orientation==="horizontal"?-r:r}function Ui(e,t,n){let r=e.series[t];if(!r)return[];let o=_t(e),{along:i,across:s}=eo(e,n),a=e.data.length,c=(a>0?s/a:0)*Mn(e.style.barWidth,0,1),u=e.stack!=="none",f=0;for(let x=0;x<e.series.length;x++)f+=Ct(e,x);let h=c/(f>0?f:1),d=Ct(e,t),p=0;for(let x=0;x<t;x++)p+=Ct(e,x);let g=e.series.length>1?e.style.barGap:0,m=e.style.values;return e.data.map((x,R)=>{let S=Tt(x,e.series,e.stack,e.weights)[t]??{from:0,to:0,value:0,outer:!1},w=Yi(e,R,s),b=-c/2+h*p+h*d/2,M="";return m!=="none"&&S.value!==0&&(!u||m==="inside"||e.stack==="percent"?M=An(e,o,u?S.value:k(x,r.field)):S.outer&&(M=An(e,o,S.to))),{center:u?w:w+(e.orientation==="horizontal"?-b:b),thickness:u?c:Math.max(0,h*d-g),from:kn(o,i,S.from),to:kn(o,i,S.to),round:S.outer,grounded:!u||S.from===0,caption:M}})}function Jr(e){let t=Mn(e.spotlightReveal,0,1),n=e.spotlight;return e.data.map((r,o)=>t<=0||n===o?1:1-(1-N)*t)}function vn(e){let t=mt(e);return{valueAxis:t.find(n=>Le.is(n)||Ce.is(n))??null,categoryAxis:t.find(Et.is)??null,bars:t.filter(Lt.is),legend:t.find(te.is)??null}}function Qr(e,t,n,r,o){let i=vn(n);if(!i.bars[r])return e.wait(e.duration);let s=t.series.map((c,u)=>Ct(t,u)),a=s[r]??1,l=t.series.map((c,u)=>t.showing[u]??c.enabled??!0);return e.together([e.animate(c=>{let u=[...s];u[r]=a+(o-a)*e.ease(c);let f=[...l];return f[r]=o>0||c<1,{weights:u,showing:f}},{eased:!1}),...i.legend?[i.legend.run(o>0?"showSeries":"hideSeries",{index:r})]:[]])}var En=Fi({key:"barChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),orientation:oe.oneOf(["vertical","horizontal"],{animatable:!1}),stack:oe.oneOf(["none","stacked","percent"]),valueAxis:oe.custom({},{resolve:Me,lerp:Ve}),categoryAxis:oe.custom({},{resolve:Me,lerp:We}),style:Ni,growth:1,spotlight:oe.custom(null),spotlightReveal:0,weights:oe.custom([],{private:!0}),showing:oe.custom([],{private:!0})},defaults:{width:"fill",height:"fill",weights:e=>e.series.map(t=>t.enabled??!0?1:0),showing:e=>e.series.map(t=>t.enabled??!0)},migrate:{style:V("cartesian")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>_t(e),r,o=()=>ve(r),i=e.style,s=e.orientation==="horizontal",a=gn(e.data,e.categoryField),l=()=>ke(t(),s?"x":"y"),c=()=>ke(t(),s?"y":"x"),u=()=>{let E=n();return E.ticks.map(T=>An(e,E,T))},f=s?i.showXAxis:i.showYAxis,h=s?i.showYAxis:i.showXAxis,d=f?s?new Ce({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",overhang:()=>({left:K(t()),right:K(t())}),width:"fill",height:"hug"}):new Le({range:()=>n().range,markers:()=>n().ticks,captions:u,axis:l,label:e.valueAxis.label??"",width:"hug",height:"fill"}):void 0,p=h?new Et({categories:a,axis:c,label:e.categoryAxis.label??"",orientation:s?"vertical":"horizontal",dims:()=>Jr(e),width:s?"hug":"fill",height:s?"fill":"hug"}):void 0,g=s?p:d,m=s?d:p,x=s?c:l,R=g&&m?xt({captions:s?()=>a:u,count:s?a.length:_t(e).ticks.length,text:()=>x().labelStyle,title:(s?e.categoryAxis.label:e.valueAxis.label)??"",titleText:()=>x().titleStyle,tickPad:()=>le(x(),"right").tick,titlePad:()=>le(x(),"right").title}):void 0,v=e.series.map((E,T)=>new Lt({bars:()=>Ui(e,T,o()),baseline:()=>kn(n(),eo(e,o()).along,Sn(n())),horizontal:s,fill:()=>P(t(),E,T),cornerRadius:()=>t().barCornerRadius,cornerStyle:()=>t().barCornerStyle,growth:()=>e.growth,dims:()=>Jr(e),values:()=>i.values==="end"&&e.stack==="percent"?"inside":i.values,valueStyle:()=>ht(t()),enabled:()=>e.showing[T]??E.enabled??!0})),S=i.legend,w=S!=="none"?new te({series:e.series,swatches:()=>e.series.map((E,T)=>P(t(),E,T)),legend:()=>B(t()),flow:S==="right"?"vertical":"horizontal"}):void 0,b=e.data.length,M=()=>Array.from({length:Math.max(0,b-1)},(E,T)=>T+1),z=()=>[0,Math.max(1,b)];return r=new zi({children:[new yt({fill:()=>t().gridBackground,xGridStroke:()=>t().verticalGrid,yGridStroke:()=>t().horizontalGrid,xMarkers:s?()=>n().ticks:M,yMarkers:s?M:()=>n().ticks,xExtent:s?()=>n().range:z,yExtent:s?z:()=>n().range,axisStroke:()=>t().axisStroke,xAxisAt:()=>s?0:Sn(n()),yAxisAt:()=>s?Sn(n()):0}),...v]}),[gt({background:()=>t().background,left:g,ghost:R,plot:r,bottom:m,legend:w,legendAt:S,gap:()=>dt(t()),padding:()=>({top:pt(t()),right:s&&m?K(t()):0,left:s&&m&&!g?K(t()):0,bottom:0})})]},commands:{enter:{args:{},entrance:!0,easing:Pe(),run:(e,t,n)=>{let r=vn(n),o=e.duration,i=o*D.axes,s=o*D.marks,{legend:a}=r,l=c=>({at:0,duration:0,piece:c});return G(e,[l(e.animate(()=>({growth:0}))),...a?[l(a.to({opacity:0,...bt(t.style.legend)}))]:[],...r.valueAxis?[{at:0,duration:i,piece:r.valueAxis.run("enter",{slide:24})}]:[],...r.categoryAxis?[{at:0,duration:i,piece:r.categoryAxis.run("enter",{slide:24})}]:[],{at:i,duration:s,piece:e.animate(c=>({growth:c}))},...a?[{at:i+s,duration:o*D.legend,piece:a.to({opacity:1,x:0,y:0})}]:[]])}},showSeries:{args:{seriesIndex:O},easing:Pe(),run:(e,t,n)=>Qr(e,t,n,e.args.seriesIndex,1)},hideSeries:{args:{seriesIndex:O},easing:Pe(),run:(e,t,n)=>Qr(e,t,n,e.args.seriesIndex,0)},spotlightSeries:{args:{seriesIndex:O},easing:Pe(),run:(e,t,n)=>{let r=vn(n),o=e.args.seriesIndex;return e.together([...r.bars.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[],e.wait(e.duration)])}},spotlightCategory:{args:{categoryIndex:oe.number(0,{min:0,step:1})},easing:Pe(),run:(e,t)=>{let n=e.args.categoryIndex;if(n<0||n>=t.data.length)return e.wait(e.duration);let r=t.spotlightReveal;return e.animate(o=>({spotlight:n,spotlightReveal:r+(1-r)*o}))}},clearCategory:{args:{},easing:Pe(),run:(e,t)=>{let n=t.spotlightReveal;if(n===0)return e.wait(e.duration);let r=t.spotlight;return e.animate(o=>o>=1?{spotlight:null,spotlightReveal:0}:{spotlight:r,spotlightReveal:n*(1-o)})}}}});import{Rect as yo,Types as Ft,clamp as bo,component2d as ss,easeOut as ze}from"@motionscript/sdk";import{Graphics2D as io,PathBuilder as Xi,Rect as _n,Text as De,Types as nt,clamp as ye,component2d as Wi,strokeOps as Vi,textOps as Ge}from"@motionscript/sdk";import{Types as xe}from"@motionscript/sdk";function Tn(e,t,n,r){return e.map((o,i)=>({category:$(o,t),value:k(o,n),fill:r.length>0?r[i%r.length]:"white"}))}function Ln(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function to(e){let t=0;for(let n of e)t+=Ln(n);return t}function Ot(e,t){let n=to(e);if(n<=0)return[];let r=[],o=t*Oe;return e.forEach((i,s)=>{let a=Ln(i);if(a<=0)return;let l=a/n,c=o,u=c+l*Math.PI*2;o=u,r.push({index:s,a0:c,a1:u,mid:(c+u)/2,fraction:l})}),r}function It(e,t,n,r){e.sort((s,a)=>a.ideal-s.ideal);let o=n;for(let s of e)s.y=Math.min(s.ideal,o),o=s.y-t;let i=r;for(let s=e.length-1;s>=0;s--)e[s].y=Math.max(e[s].y,i),i=e[s].y+t;return e}var Cn={series:Y,background:lt,text:{labelText:xe.typography({fontSize:28,fontWeight:500,fill:Re}),valueText:xe.typography({fontSize:28,fontWeight:700,fill:Ye}),centerText:xe.typography({fontSize:50,fontWeight:800,fill:Ye}),...Ae},marks:{innerRadius:xe.number(0,{min:0,max:.9,step:.05}),sliceGap:xe.number(3,{min:0,max:40,step:1,unit:"px"}),sliceRadius:xe.number(4,{min:0,max:60,step:1,unit:"px"})},labels:{labelPlacement:xe.oneOf(["inside","outside","none"],{animatable:!1})},legend:U};function Pt(e){return B(e)}function no(e){return{gap:e.sliceGap,holeRadius:e.innerRadius,startAngle:0,selectedGrow:1.08,cornerRadius:e.sliceRadius}}function ro(e){let t=F(e.labelText),n=F(e.valueText);return{textStyle:t,percentStyle:n,insideStyle:{...n,fontSize:Math.round(W(e.valueText)*1.9),fill:"#111113"},leaderStroke:{weight:2,fill:e.labelText.fill??"white"}}}function oo(e){let t=W(e.centerText,50);return{labelStyle:F(e.centerText),captionStyle:F(e.labelText,"center",{fontSize:Math.round(t*.45)})}}var Ki={gap:3,holeRadius:0,startAngle:0,selectedGrow:1.08,cornerRadius:4},$i={textStyle:{fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},percentStyle:{fontSize:28,fontWeight:700,textAlign:"center",fill:"#f4f4f5"},insideStyle:{fontSize:52,fontWeight:700,textAlign:"center",fill:"#111113"},leaderStroke:{weight:2,fill:"#a1a1aa"}},ji={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function so(e){let n=ur(e).find(s=>s.type==="solid");if(!n)return"#111113";let[r,o,i]=n.color;return .2126*r+.7152*o+.0722*i>.45?"#111113":"#ffffff"}var ao=12,qi=14,On=.62,Zi=6,lo=34,co=26,uo=8,Ji=.18,Qi=240,es=8,fo=2,po=.44,In=.62,ts=.78,ns=.9,ho=.001,go=26;function de(e,t=go){let n=e.fontSize;return typeof n=="number"?n:t}function rs(e,t,n,r,o,i,s){let a=new Xi,l=t-e,c=Math.max(2,Math.ceil(Math.abs(l)/(Math.PI*2)*Qi)),u=A=>A<=0?0:Math.min(o/A,l/2.2),f=(A,I)=>{let we=j(A,I);return{x:we.x+s,y:we.y}},h=n>0,d=e+u(r),p=t-u(r),g=e+u(n),m=t-u(n),x=f(r,d),R=f(r,p),v=Math.max(.001,Math.min(l/2,Math.PI/2)),S=f(o>0?Math.min(o/Math.sin(v),r*.8):0,(e+t)/2),w=h?f(n,g):S,b=h?f(n,m):S,M=h?r-n:r,z=Math.max(0,Math.min(i,M/2.2,(p-d)*r/2.2,h?(m-g)*n/2.2:1/0)),E=z>=.5,T=(A,I,we)=>{let Ne=Math.hypot(I.x-A.x,I.y-A.y)||1,He=Math.min(.5,we/Ne);return{x:A.x+(I.x-A.x)*He,y:A.y+(I.y-A.y)*He}},pe=E?z/Math.max(1,r):0,_=E&&h?z/n:0,ae=(A,I,we)=>{for(let Ne=0;Ne<=c;Ne++){let He=f(A,I+(we-I)*Ne/c);a.lineTo(He.x,He.y)}},at=(A,I)=>{E?a.quadraticCurveTo(A.x,A.y,I.x,I.y):a.lineTo(A.x,A.y)},Kt=f(r,d+pe);if(a.moveTo(Kt.x,Kt.y),ae(r,d+pe,p-pe),at(R,T(R,b,z)),h){let A=T(b,R,z);a.lineTo(A.x,A.y),at(b,f(n,m-_)),ae(n,m-_,g+_),at(w,T(w,x,z))}else a.lineTo(S.x,S.y);let or=T(x,w,E?z:0);return a.lineTo(or.x,or.y),at(x,Kt),a.close(),a}var Dt=class{s;box;constructor(t,n){this.s=t,this.box=n}get arcs(){return Ot(this.s.slices,this.s.ring.startAngle)}get hasLeaderLabels(){return this.s.labelPlacement==="outside"&&this.s.labelMode!=="none"&&this.arcs.length>0}insideRoom(t){let n=this.outerRadius,r=this.holeRadius,o=r>0?n-r:n*(1-In)*2,i=r>0?(r+n)/2:n*In,s=Math.abs(Math.sin(t.mid)),a=Math.abs(Math.cos(t.mid)),l=s>ho?o/s:1/0,c=a>ho?(t.a1-t.a0)*i/a:1/0;return Math.max(0,Math.min(l,c))}insideGlyphs(t){let n=this.s.labelMode,r=this.s.slices[t.index]?.category.length??0,o=n==="both"||n==="percent"?qt(t.fraction).length:0,i=n==="category"?r:n==="both"?r*po:0;return Math.max(1,o,i)}get insideFont(){let t=de(this.s.label.insideStyle,go*1.9);for(let n of this.arcs){let r=this.insideRoom(n)*ns/(this.insideGlyphs(n)*On);t=Math.min(t,r)}return Math.max(1,t)}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=de(t.labelStyle,46),i=this.holeRadius;if(i<=0)return o;let s=de(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*ts/(a*On))}get growFactor(){return Math.max(1,Math.min(1.6,this.s.ring.selectedGrow))}get maxPop(){return this.outerRadius*(this.growFactor-1)}get labelRowHeight(){if(!this.hasLeaderLabels)return 0;let t=de(this.s.label.textStyle)*1.25,n=de(this.s.label.percentStyle)*1.25;return this.s.labelMode==="both"?t+n+2:this.s.labelMode==="category"?t:n}captionGlyphs(t){let n=this.s.labelMode,r=n==="percent"||n==="both"?4:0,o=n==="category"||n==="both"?this.s.slices[t]?.category.length??0:0;return Math.max(r,o)}get labelGutters(){let t={left:fo,right:fo};if(!this.hasLeaderLabels)return t;let n=de(this.s.label.textStyle)*On;for(let r of this.arcs){let o=lo+co+uo+this.captionGlyphs(r.index)*n+qi,i=Pn(r.mid)>0?"right":"left";t[i]=Math.max(t[i],o)}return t}get centerX(){let{left:t,right:n}=this.labelGutters;return(t-n)/2}get outerRadius(){let{left:t,right:n}=this.labelGutters,r=Math.min((this.box.width-t-n)/2,this.box.height/2-this.labelRowHeight-4);return Math.max(0,r/this.growFactor)}get holeRadius(){let t=this.s.ring.holeRadius;if(t<=0)return 0;let n=t<1?t*this.outerRadius:t;return Math.min(n,this.outerRadius*.95)}get elbowRadius(){return this.outerRadius+this.maxPop+lo}popOf(t){return ye(this.s.pops[t]??0,0,1)}anchorRadius(t){return this.outerRadius+this.maxPop*this.popOf(t)}bandMidRadius(t){let n=this.anchorRadius(t),r=this.holeRadius;return r>0?(r+n)/2:n*In}insideAnchor(t){let n=this.arcs.find(o=>o.index===t);if(n===void 0)return{x:this.centerX,y:0};let r=j(this.bandMidRadius(t),n.mid);return{x:r.x+this.centerX,y:r.y}}get selectionStrength(){let t=0;for(let n=0;n<this.s.slices.length;n++)t=Math.max(t,this.popOf(n));return t}sliceOpacity(t){return ne(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}percentText(t){let n=this.arcs.find(r=>r.index===t);return qt(n?.fraction??0)}placements(){if(!this.hasLeaderLabels)return[];let t=this.arcs;if(t.length===0||this.outerRadius<=0)return[];let n=this.elbowRadius,r=this.labelRowHeight,o=this.box.height/2-r/2,i=-o,s=this.centerX,a=[],l=[];for(let c of t){let u=Pn(c.mid),f=j(n,c.mid).y;(u>0?a:l).push({index:c.index,side:u,mid:c.mid,ideal:f,y:f})}return It(a,r+ao,o,i),It(l,r+ao,o,i),[...a,...l].map(c=>{let u=j(this.anchorRadius(c.index)+Zi,c.mid),f=Math.sqrt(Math.max(0,n*n-c.y*c.y)),h=s+c.side*Math.max(f,n*Ji),d=s+c.side*(n+co);return{index:c.index,side:c.side,leader:[{x:u.x+s,y:u.y},{x:h,y:c.y},{x:d,y:c.y}],text:{x:d+c.side*uo,y:c.y}}})}placementFor(t){return this.placements().find(n=>n.index===t)}};function Pn(e){return Math.sin(e)>=0?1:-1}var os={width:0,height:0};function is(e){let t=[],n=()=>new Dt(e,t[0]?.parent?.layoutBounds??os),r=o=>{let i=()=>ye(e.labelReveal,0,1)*n().sliceOpacity(o.index),s=e.labelMode==="both"||e.labelMode==="category",a=e.labelMode==="both"||e.labelMode==="percent";if(e.labelPlacement==="inside"){let f=[];return a&&f.push(new De({...Ge.styleProps(e.label.insideStyle),text:()=>n().percentText(o.index),fill:()=>so(e.slices[o.index]?.fill??"white"),fontSize:()=>n().insideFont})),s&&f.push(new De({...Ge.styleProps(e.label.insideStyle),text:()=>e.slices[o.index]?.category??"",fill:()=>so(e.slices[o.index]?.fill??"white"),fontSize:()=>e.labelMode==="category"?n().insideFont:n().insideFont*po})),new _n({flow:"vertical",width:"hug",height:"hug",gap:0,align:"center",opacity:i,center:()=>n().insideAnchor(o.index),children:f})}let l=Pn(o.mid),c=()=>n().placementFor(o.index)?.text??{x:0,y:0},u=[];return s&&u.push(new De({...Ge.styleProps(e.label.textStyle),text:()=>e.slices[o.index]?.category??"",textAlign:l>0?"left":"right"})),a&&u.push(new De({...Ge.styleProps(e.label.percentStyle),text:()=>n().percentText(o.index),textAlign:l>0?"left":"right"})),new _n({flow:"vertical",width:"hug",height:"hug",gap:2,align:l>0?"centerLeft":"centerRight",opacity:i,centerLeft:l>0?c:void 0,centerRight:l>0?void 0:c,children:u})};if(e.labelPlacement!=="none"&&e.labelMode!=="none")for(let o of Ot(e.slices,e.ring.startAngle))t.push(r(o));if(e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new De({...Ge.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new De({...Ge.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(de(e.centerStyle.captionStyle,22)/de(e.centerStyle.labelStyle,46))})),t.push(new _n({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>ye(e.centerReveal,0,1)*ye(n().holeRadius/20,0,1),center:()=>({x:n().centerX,y:0}),children:o}))}return t}var Gt=Wi({key:"pieRing",state:{slices:y(()=>[]),ring:nt.custom(Ki),label:nt.custom($i),centerStyle:nt.custom(ji),labelMode:nt.custom("percent"),labelPlacement:nt.custom("outside"),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:ce,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>is(e),load:(e,t)=>C(e,{fills:Ie(t.slices),strokes:[Vi.resolve(t.label.leaderStroke)]}),commands:{sweep:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=L(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=L(e),r=ye(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new Dt(t,e.size),r=n.outerRadius,o=r>0?n.arcs:[];if(o.length>0){let i=ye(t.growth,0,1),s=t.ring.startAngle*(Math.PI/180)+Math.PI*2*i,a=n.holeRadius,l=Math.max(0,t.ring.gap)/2,c=n.centerX,u=r+n.maxPop+1+Math.abs(c),f=[-u,-u,u,u],h=u*2,d=Ie(t.slices);for(let g of o){let m=Math.min(g.a1,s);if(m<=g.a0)continue;let x=rs(g.a0,m,a,n.anchorRadius(g.index),l,Math.max(0,t.ring.cornerRadius),c),R=new io().path(x.toPathState({centerBounds:f,width:h,height:h}));R.fill(d[g.index]??[]),e.draw(R.opacity(n.sliceOpacity(g.index)))}let p=ye(t.labelReveal,0,1);if(p>.001)for(let g of n.placements())e.draw(new io().line({points:g.leader,radius:es}).stroke(t.label.leaderStroke).opacity(p*n.sliceOpacity(g.index)))}e.children()}});var as=.65,ls=.35,Dn=Ft.number(0,{min:0,step:1});function mo(e){return Tn(e.data,e.categoryField,e.valueField,e.data.map((t,n)=>ft(e.style,n)))}function Fe(e,t){return bo(e.pops[t]??0,0,1)}function cs(e,t){return Fe(e,t)>.5}function us(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Fe(e,n));return e.data.map((n,r)=>ne(t,ce,Fe(e,r)))}function zt(e,t,n){let r=t.data.map((i,s)=>Fe(t,s)),o=t.data.map((i,s)=>bo(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function xo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=yo.is(n)?n.children.find(Gt.is):void 0;if(r)return{ring:r,legend:n.children.find(_e.is)??null}}return null}var Gn=ss({key:"pieChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",style:Ft.style(H,Cn,{presets:X}),labelMode:Ft.custom("percent"),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:Ft.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>mo(e).map(()=>0)},migrate:{style:V("pie")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>mo(e),r=[new Gt({width:"fill",height:"fill",slices:n,ring:()=>no(t()),label:()=>ro(t()),centerStyle:()=>oo(t()),labelMode:e.labelMode,labelPlacement:e.style.labelPlacement,pops:()=>e.pops,dimOpacity:ce,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=new _e({slices:n,legend:()=>Pt(t()),dims:()=>us(e),flow:s?"vertical":"horizontal",align:"center",gap:s?Pt(e.style).itemGap/3:Pt(e.style).itemGap,padding:0});o==="top"?r.unshift(a):r.push(a)}let i=new yo({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:ze(),run:(e,t,n)=>{let r=xo(n);if(!r)return e.wait(e.duration);let{ring:o,legend:i}=r,s=e.duration*as,a=e.duration*ls,l=c=>({at:0,duration:0,piece:c});return G(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:ze(),run:(e,t,n)=>xo(n)?.ring.run("revealCenter")??e.wait(e.duration)},selectSlice:{args:{sliceIndex:Dn},easing:ze(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?1:Fe(t,r))}},deselectSlice:{args:{sliceIndex:Dn},easing:ze(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?0:Fe(t,r))}},selectOnlySlice:{args:{sliceIndex:Dn},easing:ze(),run:(e,t)=>{let n=e.args.sliceIndex;return zt(e,t,r=>r===n?1:0)}},clearSelection:{args:{},easing:ze(),run:(e,t)=>zt(e,t,()=>0)}}});import{Rect as Be,Text as ys,Types as bs,component2d as ws,easeOut as Ut}from"@motionscript/sdk";import{Graphics2D as Xn,Types as Bt,clamp as gs,component2d as ms,fillOps as Eo,strokeOps as Nt}from"@motionscript/sdk";import{Types as q}from"@motionscript/sdk";var Fn={spokeText:q.typography({fontSize:28,fontWeight:500,fill:Re}),...Ae},Bn={gridShape:q.oneOf(["polygon","circle"]),gridLevels:q.number(4,{min:1,max:10,step:1}),gridStroke:q.stroke({weight:2,fill:"white/15"}),spokeStroke:q.stroke({weight:2,fill:"white/15"}),spokeLabels:q.boolean(!0,{animatable:!1})},Nn={strokeWidth:q.number(4,{min:0,max:24,step:1,unit:"px"}),areaOpacity:q.number(.25,{min:0,max:1,step:.05}),dots:q.boolean(!0),dotSize:q.number(10,{min:2,max:40,step:1,unit:"px"})},fs=.55,hs=.58,zn=10,wo=.35;function ie(e,t){let n=e/Math.max(1,t)*Math.PI*2;return{x:Math.sin(n),y:Math.cos(n)}}function Hn(e,t){return e.map(n=>$(n,t))}function Ro(e,t){return t.map(n=>e.map(r=>k(r,n.field)))}var ds=[1,1.2,1.5,2,2.5,3,4,5,6,8,10];function So(e){if(!(e>0))return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(ds.find(o=>o>=n-1e-9)??10)*t}function Ao(e,t,n){if(n>t)return{min:t,max:n};let r=t;for(let i of e)for(let s of i)r=Math.max(r,s);let o=So(r-t);return{min:t,max:t+o}}function ko(e,t){let n=t.max-t.min;return n<=0?0:Math.min(1,Math.max(0,(e-t.min)/n))}function Yn(e,t){let{x:n,y:r}=ie(e,t);return n>wo?"centerLeft":n<-wo?"centerRight":r>=0?"bottomCenter":"topCenter"}function vo(e){return e*fs}function ps(e,t){return{width:e.length*t*hs,height:t*1.25}}function Un(e,t,n,r){let o=Math.min(e.width,e.height)/2-zn;if(!r)return Math.max(0,o);let i=vo(n),s=t.length;return t.forEach((a,l)=>{let{x:c,y:u}=ie(l,s),f=ps(a,n),h=Yn(l,s),d=h==="centerLeft"||h==="centerRight"?f.width:f.width/2,p=h==="bottomCenter"||h==="topCenter"?f.height:f.height/2;Math.abs(c)>1e-6&&(o=Math.min(o,(e.width/2-d-zn/2)/Math.abs(c)-i)),Math.abs(u)>1e-6&&(o=Math.min(o,(e.height/2-p-zn/2)/Math.abs(u)-i))}),Math.max(0,o)}function Mo(e,t,n,r){let{x:o,y:i}=ie(e,t),s=n+vo(r);return{x:o*s,y:i*s}}var rt=ms({key:"radarGrid",state:{count:0,radius:0,levels:4,fill:Bt.custom([],{resolve:Eo.resolve,lerp:Eo.lerp}),shape:Bt.custom("polygon"),stroke:Bt.custom([],{resolve:Nt.resolve,lerp:Nt.lerp}),spokeStroke:Bt.custom([],{resolve:Nt.resolve,lerp:Nt.lerp}),reveal:1},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke,t.spokeStroke]}),render:(e,t)=>{let n=gs(t.reveal,0,1),r=t.radius*n;if(r<=0||n<=0)return;let o=Math.max(0,Math.round(t.count)),i=Math.max(1,Math.round(t.levels)),s=t.shape==="circle"||o<3,a=(l,c)=>{if(s)return l.ellipse({width:c*2,height:c*2});let u=[];for(let f=0;f<o;f++){let h=ie(f,o);u.push({x:h.x*c,y:h.y*c})}return l.line({points:u,closed:!0})};t.fill.length>0&&e.draw(a(new Xn,r).fill(t.fill).opacity(n));for(let l=1;t.stroke.length>0&&l<=i;l++){let c=r*l/i;e.draw(a(new Xn,c).stroke(t.stroke).opacity(n))}if(t.spokeStroke.length!==0)for(let l=0;l<o;l++){let c=ie(l,o);e.draw(new Xn().line({points:[{x:0,y:0},{x:c.x*r,y:c.y*r}]}).stroke(t.spokeStroke).opacity(n))}}});import{Graphics2D as Wn,Types as Ht,clamp as To,component2d as xs,fillOps as Lo,strokeOps as Co}from"@motionscript/sdk";function _o(e,t,n=1){return e.map((r,o)=>{let i=ie(o,e.length),s=t*r*n;return{x:i.x*s,y:i.y*s}})}var Yt=xs({key:"radarSeries",state:{fractions:y(()=>[]),radius:0,fill:Ht.custom([],{resolve:Lo.resolve,lerp:Lo.lerp}),stroke:Ht.custom([],{resolve:Co.resolve,lerp:Co.lerp}),areaOpacity:.25,dots:!0,dotSize:10,progress:1,enabled:!0},defaults:{width:"fill",height:"fill"},load:(e,t)=>C(e,{fills:[t.fill],strokes:[t.stroke]}),commands:{enter:{args:{from:Ht.number(0,{min:0,max:1}),to:Ht.number(1,{min:0,max:1})},run:e=>{let{from:t,to:n}=e.args,r=L(e);return e.animate(o=>{let i=t+(n-t)*r(o);return{progress:i,enabled:i>0}})}}},render:(e,t)=>{if(!t.enabled)return;let n=To(t.progress,0,1);if(n<=0||t.radius<=0||t.fractions.length===0)return;let r=_o(t.fractions,t.radius,n);if(r.length>=2){let o=new Wn().line({points:r,closed:!0});t.areaOpacity>0&&t.fill.length>0&&e.draw(o.fill(t.fill).opacity(To(t.areaOpacity,0,1))),t.stroke.length>0&&e.draw(new Wn().line({points:r,closed:!0}).stroke(t.stroke))}if(t.dots&&t.dotSize>0&&t.fill.length>0){let o=new Wn;for(let i of r)o.ellipse({x:i.x,y:i.y,width:t.dotSize,height:t.dotSize});e.draw(o.fill(t.fill))}}});function Po(e){return Ao(Ro(e.data,e.series),e.min,e.max)}function Do(e,t){let n=e.series[t];if(!n)return[];let r=Po(e);return e.data.map(o=>{let i=o[n.field];return ko(typeof i=="number"&&Number.isFinite(i)?i:0,r)})}function Vn(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!Be.is(n))continue;let r=n.children.find(o=>Be.is(o)&&o.children.some(rt.is));if(r)return{grid:r.children.find(rt.is),series:r.children.filter(Yt.is),labels:r.children.find(Be.is)??null,legend:n.children.find(te.is)??null}}return null}function Oo(e,t,n,r){let o=Vn(t),i=o?.series[n];return!o||!i?e.wait(e.duration):e.together([i.run("enter",r?{from:0,to:1}:{from:1,to:0}),...o.legend?[o.legend.run(r?"showSeries":"hideSeries",{index:n})]:[]])}var Io=.3,Kn=ws({key:"radarChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",series:y(()=>[],{kind:"series"}),min:0,max:0,style:bs.style(H,{series:Y,background:Se,text:Fn,grid:Bn,marks:Nn,legend:U},{presets:X})},defaults:{width:"fill",height:"fill"},migrate:{style:V("radar")},allowedChildren:[],children:e=>{let t=()=>e.style,n,r=()=>ve(n),o=()=>Un(r(),Hn(e.data,e.categoryField),W(t().spokeText),t().spokeLabels),i=e.data.length,s=e.series.map(d=>d.enabled??!0),a=new rt({count:()=>e.data.length,radius:o,levels:()=>t().gridLevels,fill:()=>t().gridBackground,shape:()=>t().gridShape,stroke:()=>t().gridStroke,spokeStroke:()=>t().spokeStroke}),l=e.series.map((d,p)=>new Yt({fractions:()=>Do(e,p),radius:o,fill:()=>P(t(),d,p),stroke:()=>{let g=t().strokeWidth;return g>0?{weight:g,fill:P(t(),d,p),align:"center",join:"round"}:[]},areaOpacity:()=>t().areaOpacity,dots:()=>t().dots,dotSize:()=>t().dotSize,enabled:s[p]})),c=[a,...l];if(e.style.spokeLabels){let d=[];for(let p=0;p<i;p++){let g=Yn(p,i),m=g==="centerLeft"?"left":g==="centerRight"?"right":"center",x=()=>Mo(p,i,o(),W(t().spokeText));d.push(new ys({...Z(()=>F(t().spokeText,m)),text:()=>Hn(e.data,e.categoryField)[p]??"",[g]:x}))}c.push(new Be({width:"fill",height:"fill",children:d}))}n=new Be({width:"fill",height:"fill",children:c});let u=[n],f=e.style.legend;if(f!=="none"){let d=f==="right",p=B(e.style),g=new te({series:e.series,swatches:()=>e.series.map((m,x)=>P(t(),m,x)),legend:()=>B(t()),flow:d?"vertical":"horizontal",gap:d?Math.round(p.itemGap/2):p.itemGap,padding:p.padding});f==="top"?u.unshift(g):u.push(g)}let h=new Be({flow:f==="right"?"horizontal":"vertical",width:"fill",height:"fill",gap:24,align:"center",fill:()=>t().background,children:u});return[h]},commands:{enter:{args:{},entrance:!0,easing:Ut(),run:(e,t,n)=>{let r=Vn(n);if(!r)return e.wait(e.duration);let o=e.duration,i=o*D.axes,s=o*D.marks,a=o*D.legend,l=Math.max(1,r.series.length),c=s/(1+Io*(l-1)),{legend:u,labels:f}=r,h=d=>({at:0,duration:0,piece:d});return G(e,[h(r.grid.to({reveal:0})),...r.series.map(d=>h(d.to({progress:0}))),...f?[h(f.to({opacity:0}))]:[],...u?[h(u.to({opacity:0,y:-ir}))]:[],{at:0,duration:i,piece:r.grid.to({reveal:1})},...r.series.map((d,p)=>({at:i+p*c*Io,duration:c,piece:d.to({progress:1})})),...f?[{at:i+s*.6,duration:a+s*.4,piece:f.to({opacity:1})}]:[],...u?[{at:i+s,duration:a,piece:u.to({opacity:1,y:0})}]:[]])}},showSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>Oo(e,n,e.args.seriesIndex,!0)},hideSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>Oo(e,n,e.args.seriesIndex,!1)},spotlightSeries:{args:{seriesIndex:O},easing:Ut(),run:(e,t,n)=>{let r=Vn(n);if(!r)return e.wait(e.duration);let o=e.args.seriesIndex;return e.together([...r.series.map((i,s)=>i.to({opacity:s===o?1:N})),...r.legend?[r.legend.run("spotlightSeries",{index:o})]:[]])}}}});import{Rect as Ko,Types as nr,clamp as $o,component2d as Ps,easeOut as Wt}from"@motionscript/sdk";import{Graphics2D as No,PathBuilder as Ss,Rect as Ho,Text as Qn,Types as ot,clamp as be,component2d as As,fillOps as ks,textOps as er}from"@motionscript/sdk";import{Types as se,clamp as Rs}from"@motionscript/sdk";function $n(e,t,n,r){return e.map((o,i)=>({category:$(o,t),value:k(o,n),fill:ft(r,i)}))}function jn(e){return e.value>0&&Number.isFinite(e.value)?e.value:0}function Go(e,t){if(t>0&&Number.isFinite(t))return t;let n=0;for(let r of e)n=Math.max(n,jn(r));return n>0?n:1}function qn(e,t){let n=Go(e,t);return e.map(r=>Rs(jn(r)/n,0,1))}var Zn={series:Y,background:lt,text:{labelText:se.typography({fontSize:28,fontWeight:500,fill:Re}),centerText:se.typography({fontSize:50,fontWeight:800,fill:Ye}),...Ae},marks:{innerRadius:se.number(.3,{min:0,max:.9,step:.05}),ringGap:se.number(8,{min:0,max:60,step:1,unit:"px"}),sweep:se.number(360,{min:30,max:360,step:5,unit:"deg"}),startAngle:se.number(0,{min:-360,max:360,step:5,unit:"deg"}),track:se.fill("white/10"),roundCaps:se.boolean(!0)},labels:{ringLabels:se.boolean(!1)},legend:U};function zo(e){return{innerRadius:e.innerRadius,ringGap:e.ringGap,sweep:e.sweep,startAngle:e.startAngle,track:e.track.length>0,roundCaps:e.roundCaps}}function Jn(e){return B(e)}function Fo(e){return F(e.labelText)}function Bo(e){let t=W(e.centerText,50);return{labelStyle:F(e.centerText),captionStyle:F(e.labelText,"center",{fontSize:Math.round(t*.45)})}}var Yo=.12,vs=.12,Ms=4*Oe,Uo=10,Es=.78,Ts=.62,Xo=4,Ls={innerRadius:.3,ringGap:8,sweep:360,startAngle:0,track:!0,roundCaps:!0},Cs={fontSize:28,fontWeight:500,textAlign:"center",fill:"#a1a1aa"},_s={labelStyle:{fontSize:50,fontWeight:800,textAlign:"center",fill:"#f4f4f5"},captionStyle:{fontSize:22,fontWeight:500,textAlign:"center",fill:"#a1a1aa"}};function it(e,t){return typeof e.fontSize=="number"?e.fontSize:t}var st=class{s;box;constructor(t,n){this.s=t,this.box=n}get count(){return this.s.rows.length}get outerRadius(){return Math.max(0,Math.min(this.box.width,this.box.height)/2-Xo)}get holeRadius(){return be(this.s.marks.innerRadius,0,.9)*this.outerRadius}get thickness(){let t=this.count;return t===0?0:Math.max(0,(this.outerRadius-this.holeRadius-(t-1)*Math.max(0,this.s.marks.ringGap))/t)}ringOuter(t){return this.outerRadius-t*(this.thickness+Math.max(0,this.s.marks.ringGap))}ringMid(t){return this.ringOuter(t)-this.thickness/2}get fractions(){return qn(this.s.rows,this.s.max)}get startRad(){return this.s.marks.startAngle*Oe}get sweepRad(){return be(this.s.marks.sweep,0,360)*Oe}popOf(t){return be(this.s.pops[t]??0,0,1)}get selectionStrength(){let t=0;for(let n=0;n<this.count;n++)t=Math.max(t,this.popOf(n));return t}ringOpacity(t){return ne(this.selectionStrength,this.s.dimOpacity,this.popOf(t))}progress(t,n){let r=1+Yo*Math.max(0,this.count-1);return be(n*r-t*Yo,0,1)}get labelFont(){return Math.max(1,Math.min(it(this.s.label,28),this.thickness*.62))}labelAnchor(t){let n=this.startRad,r={x:-Math.cos(n),y:Math.sin(n)},o=j(this.ringMid(t),n),i=r.x<=0?-1:1;return{at:{x:o.x+r.x*Uo,y:o.y+r.y*Uo},side:i}}get centerFont(){let{centerStyle:t,centerLabel:n,centerCaption:r}=this.s,o=it(t.labelStyle,50),i=this.holeRadius;if(i<=0)return o;let s=it(t.captionStyle,22)/Math.max(1,o),a=Math.max(1,n.length,r.length*s);return Math.min(o,i*2*Es/(a*Ts))}};function tr(e,t,n,r,o){let i=new Ss,s=(n+r)/2,a=(r-n)/2,l=o&&s>0?Math.min(a/s,(t-e)/2):0,c=e+l,u=t-l,f=Math.max(2,Math.ceil(Math.abs(u-c)/Ms)),h=(p,g,m,x)=>{for(let R=0;R<=f;R++){let v=j(p,g+(m-g)*R/f);x&&R===0?i.moveTo(v.x,v.y):i.lineTo(v.x,v.y)}},d=(p,g,m)=>{let x=j(s,p),R={x:Math.sin(p),y:Math.cos(p)},v={x:Math.cos(p)*g,y:-Math.sin(p)*g},S=12;for(let w=1;w<S;w++){let b=Math.PI*w/S,M=m?Math.cos(b):-Math.cos(b);i.lineTo(x.x+a*(R.x*M+v.x*Math.sin(b)),x.y+a*(R.y*M+v.y*Math.sin(b)))}};return h(r,c,u,!0),o&&d(u,1,!0),h(n,u,c,!1),o&&d(c,-1,!1),i.close(),i}var Os={width:0,height:0};function Is(e){let t=[],n=()=>new st(e,t[0]?.parent?.layoutBounds??Os),r=n().labelAnchor(0).side;if(e.rows.forEach((o,i)=>{let s=()=>n().labelAnchor(i).at;t.push(new Ho({flow:"vertical",width:"hug",height:"hug",align:r>0?"centerLeft":"centerRight",opacity:()=>e.ringLabels?be(e.labelReveal,0,1)*n().ringOpacity(i):0,centerLeft:r>0?s:void 0,centerRight:r>0?void 0:s,children:[new Qn({...er.styleProps(e.label),text:()=>e.rows[i]?.category??"",textAlign:r>0?"left":"right",fontSize:()=>n().labelFont})]}))}),e.centerLabel!==""||e.centerCaption!==""){let o=[];e.centerLabel!==""&&o.push(new Qn({...er.styleProps(e.centerStyle.labelStyle),text:e.centerLabel,fontSize:()=>n().centerFont})),e.centerCaption!==""&&o.push(new Qn({...er.styleProps(e.centerStyle.captionStyle),text:e.centerCaption,fontSize:()=>n().centerFont*(it(e.centerStyle.captionStyle,22)/it(e.centerStyle.labelStyle,50))})),t.push(new Ho({flow:"vertical",width:"hug",height:"hug",gap:2,align:"center",opacity:()=>be(e.centerReveal,0,1),center:{x:0,y:0},children:o}))}return t}var Xt=As({key:"radialRings",state:{rows:y(()=>[]),max:0,marks:ot.custom(Ls),label:ot.custom(Cs),centerStyle:ot.custom(_s),trackFill:ot.fill("white/15"),ringLabels:ot.boolean(!1),growth:1,labelReveal:1,pops:y(()=>[]),dimOpacity:.25,centerLabel:"",centerCaption:"",centerReveal:1},defaults:{width:"fill",height:"fill"},children:e=>Is(e),load:(e,t)=>C(e,{fills:[...Ie(t.rows),ks.resolve(t.trackFill)]}),commands:{sweep:e=>{let t=L(e);return e.animate(n=>({growth:t(n)}))},revealLabels:e=>{let t=L(e);return e.animate(n=>({labelReveal:t(n)}))},revealCenter:(e,t)=>{let n=L(e),r=be(t.centerReveal,0,1);return e.animate(o=>({centerReveal:r+(1-r)*n(o)}))}},render:(e,t)=>{let n=new st(t,e.size),r=n.thickness;if(n.outerRadius>0&&n.count>0&&r>0){let o=n.outerRadius+Xo+1,i={centerBounds:[-o,-o,o,o],width:o*2,height:o*2},s=Ie(t.rows),a=n.fractions,l=n.startRad,c=t.marks.roundCaps,u=[...t.rows.keys()].sort((f,h)=>n.popOf(f)-n.popOf(h));for(let f of u){let h=r*vs*n.popOf(f),d=n.ringOuter(f)+h,p=n.ringOuter(f)-r-h,g=n.ringOpacity(f);t.marks.track&&n.sweepRad>0&&e.draw(new No().path(tr(l,l+n.sweepRad,p,d,c).toPathState(i)).fill(t.trackFill).opacity(g));let m=n.sweepRad*a[f]*n.progress(f,t.growth);m<=1e-4||e.draw(new No().path(tr(l,l+m,p,d,c).toPathState(i)).fill(s[f]??[]).opacity(g))}}e.children()}});var Ds=.7,Gs=.3;function zs(e){return $n(e.data,e.categoryField,e.valueField,e.style)}function Vt(e,t){return $o(e.pops[t]??0,0,1)}function Fs(e){let t=0;for(let n=0;n<e.data.length;n++)t=Math.max(t,Vt(e,n));return e.data.map((n,r)=>ne(t,jo,Vt(e,r)))}var jo=Math.max(ce,.25);function Wo(e,t,n){let r=t.data.map((i,s)=>Vt(t,s)),o=t.data.map((i,s)=>$o(n(s),0,1));return r.every((i,s)=>i===o[s])?e.wait(e.duration):e.animate(i=>({pops:r.map((s,a)=>s+(o[a]-s)*i)}))}function Vo(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=Ko.is(n)?n.children.find(Xt.is):void 0;if(r)return{rings:r,legend:n.children.find(_e.is)??null}}return null}var rr=Ps({key:"radialChart",state:{data:y(()=>[],{kind:"dataset"}),categoryField:"",valueField:"",max:nr.number(0,{min:0,step:1}),style:nr.style(H,Zn,{presets:X}),gap:40,centerLabel:"",centerCaption:"",pops:y(()=>[]),showCenter:nr.boolean(!0,{animatable:!1})},defaults:{width:"fill",height:"fill",pops:e=>e.data.map(()=>0)},migrate:{style:V("radial")},allowedChildren:[],children:e=>{let t=()=>e.style,n=()=>zs(e),r=[new Xt({width:"fill",height:"fill",rows:n,max:()=>e.max,marks:()=>zo(t()),label:()=>Fo(t()),centerStyle:()=>Bo(t()),trackFill:()=>t().track,ringLabels:()=>t().ringLabels,pops:()=>e.pops,dimOpacity:jo,centerLabel:e.centerLabel,centerCaption:e.centerCaption,centerReveal:e.showCenter===!1?0:1})],o=e.style.legend;if(o!=="none"){let s=o==="right",a=Jn(e.style),l=new _e({slices:n,legend:()=>Jn(t()),dims:()=>Fs(e),flow:s?"vertical":"horizontal",align:"center",gap:s?a.itemGap/3:a.itemGap,padding:0});o==="top"?r.unshift(l):r.push(l)}let i=new Ko({flow:o==="right"||o==="none"?"horizontal":"vertical",width:"fill",height:"fill",gap:e.gap,padding:24,align:"center",fill:()=>e.style.background,children:r});return[i]},commands:{enter:{args:{},entrance:!0,easing:Wt(),run:(e,t,n)=>{let r=Vo(n);if(!r)return e.wait(e.duration);let{rings:o,legend:i}=r,s=e.duration*Ds,a=e.duration*Gs,l=c=>({at:0,duration:0,piece:c});return G(e,[l(o.to({growth:0,labelReveal:0})),...i?[l(i.run("arm"))]:[],{at:0,duration:s,piece:o.run("sweep")},{at:s,duration:a,piece:o.run("revealLabels")},...i?[{at:s,duration:a,piece:i.run("enter")}]:[]])}},revealCenter:{args:{},easing:Wt(),run:(e,t,n)=>Vo(n)?.rings.run("revealCenter")??e.wait(e.duration)},selectRing:{args:{ringIndex:O},easing:Wt(),run:(e,t)=>{let n=e.args.ringIndex;return Wo(e,t,r=>r===n?1:Vt(t,r))}},clearSelection:{args:{},easing:Wt(),run:(e,t)=>Wo(e,t,()=>0)}}});var Bs=[dn,En,Gn,Kn,rr];export{bn as BAR_LABELS,yn as BAR_MARKS,En as BarChart,ut as CARTESIAN_GRID,ct as CARTESIAN_TEXT,lt as CHART_BACKGROUND,Ye as CHART_FOREGROUND,U as CHART_LEGEND,Re as CHART_MUTED,Ns as CHART_PALETTE_DEFAULT,Y as CHART_SERIES,H as CHART_STYLE_FAMILY,X as CHART_STYLE_PRESETS,Et as CategoryAxis,an as ChartArea,Lt as ChartBars,yt as ChartCanvas,te as ChartLegend,At as ChartLine,ln as ChartRegion,Xs as DEFAULT_LEGEND,Q as DEFAULT_MARKERS,lr as DEFAULT_X_AXIS,Us as DEFAULT_Y_AXIS,Oe as DEG,me as EMPTY_REGION_BOX,D as ENTER_SHARE,_r as EVERY_SAMPLE,Se as GRID_BACKGROUND,Ce as HorizontalAxis,ir as LEGEND_SLIDE,Ae as LEGEND_TEXT,on as LINE_LABELS,rn as LINE_MARKS,dn as LineChart,Bs as NODES,ce as PIE_SPOTLIGHT_DIM,Cn as PIE_STYLE_GROUPS,Gn as PieChart,_e as PieLegend,Gt as PieRing,Bn as RADAR_GRID,Nn as RADAR_MARKS,Fn as RADAR_TEXT,Zn as RADIAL_STYLE_GROUPS,Kn as RadarChart,rt as RadarGrid,Yt as RadarSeries,rr as RadialChart,st as RadialGeometry,Xt as RadialRings,O as SERIES_ARG,N as SPOTLIGHT_DIM,Le as VerticalAxis,br as areaFill,ar as armed,jt as arrival,Xe as arrivalOf,sr as arrivalsEntry,J as asParts,ke as axisConfigOf,le as axisPads,tr as bandPath,gn as barCategories,_t as barChartDomain,Tt as barSpans,Wr as barValueExtent,G as beats,Z as boundText,cr as captionColumn,gt as cartesianFrame,mt as chartViews,nn as clipPolygonToBox,Jt as clipPolylineToBox,xt as columnGhost,en as curvePoints,tn as cutAt,Ue as fade,Un as fitRadius,Cr as formatInstant,Ee as formatMarker,qt as formatPercent,L as frameEase,dt as frameGap,y as fresh,ue as hasRegion,pt as headroom,xn as inkOn,cs as isSliceSelected,ve as laidOutSize,bt as legendAway,B as legendConfigOf,We as lerpAxisDomain,Ve as lerpAxisEntry,Je as lineChartDomains,C as loadPaints,Ws as markerCaption,wt as markerStep,Hs as markerText,ee as markerValues,V as migrateChartStyle,So as niceCeil,Te as niceRange,Rt as niceTicks,k as num,Ys as numericFields,K as overhang,ft as paletteFill,Lr as parseInstant,Ot as pieArcs,F as placedText,Do as radarFractions,Po as radarScale,qn as radialFractions,Go as radialMax,It as relaxLabels,Me as resolveAxisDomain,mn as resolveBarScale,Tn as resolvePieSlices,$n as resolveRadialRows,Zt as resolveRegionBox,cn as resolveXScale,Qo as resolveYScale,ur as resolvedFill,Ie as ringFills,j as ringPoint,jn as rowValue,$t as rule,ne as selectionFade,P as seriesFill,Jo as seriesPoints,_o as seriesVertices,Ke as settleAxisDomain,W as sizeOf,to as sliceTotal,Ln as sliceValue,Qe as slotCentre,ie as spokeDirection,St as stackExtent,Qt as stackSeries,$ as text,Ze as traceX,ht as valueText,pr as yExtent};
2
2
  //# sourceMappingURL=index.js.map