@motionscript/math 0.1.0-alpha.5 → 0.1.0-alpha.7

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 (233) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +39 -33
  3. package/dist/annotate/angle-mark.d.ts +77 -27
  4. package/dist/annotate/angle-mark.d.ts.map +1 -1
  5. package/dist/annotate/angle-mark.js +80 -115
  6. package/dist/annotate/angle-mark.js.map +1 -1
  7. package/dist/annotate/curly-brace.d.ts +94 -25
  8. package/dist/annotate/curly-brace.d.ts.map +1 -1
  9. package/dist/annotate/curly-brace.js +85 -100
  10. package/dist/annotate/curly-brace.js.map +1 -1
  11. package/dist/annotate/emphasis-mark.d.ts +69 -9
  12. package/dist/annotate/emphasis-mark.d.ts.map +1 -1
  13. package/dist/annotate/emphasis-mark.js +33 -34
  14. package/dist/annotate/emphasis-mark.js.map +1 -1
  15. package/dist/browser/chunks/chunk-ABYBW64J.js +2 -0
  16. package/dist/browser/chunks/chunk-ABYBW64J.js.map +7 -0
  17. package/dist/browser/chunks/chunk-K77KLQX4.js +2 -0
  18. package/dist/browser/chunks/chunk-K77KLQX4.js.map +7 -0
  19. package/dist/browser/index.js +1 -1
  20. package/dist/browser/index.js.map +3 -3
  21. package/dist/browser/kit.js +1 -1
  22. package/dist/browser/manifest.json +1 -1
  23. package/dist/browser/tex.js +1 -1
  24. package/dist/browser/tex.js.map +2 -2
  25. package/dist/engine.d.ts +26 -19
  26. package/dist/engine.d.ts.map +1 -1
  27. package/dist/engine.js +17 -14
  28. package/dist/engine.js.map +1 -1
  29. package/dist/kit/component.d.ts +51 -0
  30. package/dist/kit/component.d.ts.map +1 -0
  31. package/dist/kit/component.js +30 -0
  32. package/dist/kit/component.js.map +1 -0
  33. package/dist/kit/curve.d.ts +22 -11
  34. package/dist/kit/curve.d.ts.map +1 -1
  35. package/dist/kit/curve.js +25 -18
  36. package/dist/kit/curve.js.map +1 -1
  37. package/dist/kit/field-mark.d.ts +56 -35
  38. package/dist/kit/field-mark.d.ts.map +1 -1
  39. package/dist/kit/field-mark.js +100 -120
  40. package/dist/kit/field-mark.js.map +1 -1
  41. package/dist/kit/follow.d.ts +67 -29
  42. package/dist/kit/follow.d.ts.map +1 -1
  43. package/dist/kit/follow.js +114 -110
  44. package/dist/kit/follow.js.map +1 -1
  45. package/dist/kit/furniture.d.ts +3 -1
  46. package/dist/kit/furniture.d.ts.map +1 -1
  47. package/dist/kit/furniture.js +5 -0
  48. package/dist/kit/furniture.js.map +1 -1
  49. package/dist/kit/graph.d.ts +46 -0
  50. package/dist/kit/graph.d.ts.map +1 -0
  51. package/dist/kit/graph.js +90 -0
  52. package/dist/kit/graph.js.map +1 -0
  53. package/dist/kit/mark.d.ts +64 -39
  54. package/dist/kit/mark.d.ts.map +1 -1
  55. package/dist/kit/mark.js +80 -96
  56. package/dist/kit/mark.js.map +1 -1
  57. package/dist/kit/place.d.ts +10 -8
  58. package/dist/kit/place.d.ts.map +1 -1
  59. package/dist/kit/place.js +28 -30
  60. package/dist/kit/place.js.map +1 -1
  61. package/dist/kit/system.d.ts +27 -29
  62. package/dist/kit/system.d.ts.map +1 -1
  63. package/dist/kit/system.js +62 -58
  64. package/dist/kit/system.js.map +1 -1
  65. package/dist/kit/withdrawn.d.ts +3 -3
  66. package/dist/kit/withdrawn.js +3 -3
  67. package/dist/kit/withdrawn.js.map +1 -1
  68. package/dist/marks/curve-area.d.ts +37 -18
  69. package/dist/marks/curve-area.d.ts.map +1 -1
  70. package/dist/marks/curve-area.js +50 -73
  71. package/dist/marks/curve-area.js.map +1 -1
  72. package/dist/marks/drop-lines.d.ts +45 -10
  73. package/dist/marks/drop-lines.d.ts.map +1 -1
  74. package/dist/marks/drop-lines.js +37 -52
  75. package/dist/marks/drop-lines.js.map +1 -1
  76. package/dist/marks/plot-point.d.ts +56 -20
  77. package/dist/marks/plot-point.d.ts.map +1 -1
  78. package/dist/marks/plot-point.js +65 -91
  79. package/dist/marks/plot-point.js.map +1 -1
  80. package/dist/marks/riemann-sum.d.ts +47 -26
  81. package/dist/marks/riemann-sum.d.ts.map +1 -1
  82. package/dist/marks/riemann-sum.js +57 -85
  83. package/dist/marks/riemann-sum.js.map +1 -1
  84. package/dist/marks/tangent-line.d.ts +58 -14
  85. package/dist/marks/tangent-line.d.ts.map +1 -1
  86. package/dist/marks/tangent-line.js +73 -87
  87. package/dist/marks/tangent-line.js.map +1 -1
  88. package/dist/marks/vector-arrow.d.ts +48 -20
  89. package/dist/marks/vector-arrow.d.ts.map +1 -1
  90. package/dist/marks/vector-arrow.js +58 -78
  91. package/dist/marks/vector-arrow.js.map +1 -1
  92. package/dist/nodes.d.ts +13 -5
  93. package/dist/nodes.d.ts.map +1 -1
  94. package/dist/nodes.js +0 -6
  95. package/dist/nodes.js.map +1 -1
  96. package/dist/plots/function-plot.d.ts +135 -43
  97. package/dist/plots/function-plot.d.ts.map +1 -1
  98. package/dist/plots/function-plot.js +146 -177
  99. package/dist/plots/function-plot.js.map +1 -1
  100. package/dist/plots/points-plot.d.ts +55 -19
  101. package/dist/plots/points-plot.d.ts.map +1 -1
  102. package/dist/plots/points-plot.js +31 -58
  103. package/dist/plots/points-plot.js.map +1 -1
  104. package/dist/plots/stream-lines.d.ts +60 -19
  105. package/dist/plots/stream-lines.d.ts.map +1 -1
  106. package/dist/plots/stream-lines.js +60 -79
  107. package/dist/plots/stream-lines.js.map +1 -1
  108. package/dist/plots/traced-path.d.ts +54 -15
  109. package/dist/plots/traced-path.d.ts.map +1 -1
  110. package/dist/plots/traced-path.js +33 -48
  111. package/dist/plots/traced-path.js.map +1 -1
  112. package/dist/plots/vector-field.d.ts +48 -11
  113. package/dist/plots/vector-field.d.ts.map +1 -1
  114. package/dist/plots/vector-field.js +50 -64
  115. package/dist/plots/vector-field.js.map +1 -1
  116. package/dist/structures/network-graph.d.ts +140 -49
  117. package/dist/structures/network-graph.d.ts.map +1 -1
  118. package/dist/structures/network-graph.js +168 -217
  119. package/dist/structures/network-graph.js.map +1 -1
  120. package/dist/structures/sample-space.d.ts +90 -38
  121. package/dist/structures/sample-space.d.ts.map +1 -1
  122. package/dist/structures/sample-space.js +132 -170
  123. package/dist/structures/sample-space.js.map +1 -1
  124. package/dist/systems/axes2d.d.ts +159 -37
  125. package/dist/systems/axes2d.d.ts.map +1 -1
  126. package/dist/systems/axes2d.js +147 -183
  127. package/dist/systems/axes2d.js.map +1 -1
  128. package/dist/systems/number-line.d.ts +80 -28
  129. package/dist/systems/number-line.d.ts.map +1 -1
  130. package/dist/systems/number-line.js +82 -118
  131. package/dist/systems/number-line.js.map +1 -1
  132. package/dist/systems/number-plane.d.ts +140 -31
  133. package/dist/systems/number-plane.d.ts.map +1 -1
  134. package/dist/systems/number-plane.js +142 -149
  135. package/dist/systems/number-plane.js.map +1 -1
  136. package/dist/systems/polar-plane.d.ts +76 -26
  137. package/dist/systems/polar-plane.d.ts.map +1 -1
  138. package/dist/systems/polar-plane.js +107 -133
  139. package/dist/systems/polar-plane.js.map +1 -1
  140. package/dist/tex/index.d.ts.map +1 -1
  141. package/dist/tex/index.js +1 -0
  142. package/dist/tex/index.js.map +1 -1
  143. package/dist/tex/matrix.d.ts +88 -18
  144. package/dist/tex/matrix.d.ts.map +1 -1
  145. package/dist/tex/matrix.js +33 -50
  146. package/dist/tex/matrix.js.map +1 -1
  147. package/dist/tex/node.d.ts +84 -201
  148. package/dist/tex/node.d.ts.map +1 -1
  149. package/dist/tex/node.js +23 -593
  150. package/dist/tex/node.js.map +1 -1
  151. package/dist/tex/typeset.d.ts +133 -0
  152. package/dist/tex/typeset.d.ts.map +1 -0
  153. package/dist/tex/typeset.js +403 -0
  154. package/dist/tex/typeset.js.map +1 -0
  155. package/dist/three/axes3d.d.ts +214 -54
  156. package/dist/three/axes3d.d.ts.map +1 -1
  157. package/dist/three/axes3d.js +163 -204
  158. package/dist/three/axes3d.js.map +1 -1
  159. package/dist/three/curve-plot3d.d.ts +108 -42
  160. package/dist/three/curve-plot3d.d.ts.map +1 -1
  161. package/dist/three/curve-plot3d.js +97 -132
  162. package/dist/three/curve-plot3d.js.map +1 -1
  163. package/dist/three/entries.d.ts +17 -0
  164. package/dist/three/entries.d.ts.map +1 -0
  165. package/dist/three/entries.js +15 -0
  166. package/dist/three/entries.js.map +1 -0
  167. package/dist/three/plot-point3d.d.ts +85 -12
  168. package/dist/three/plot-point3d.d.ts.map +1 -1
  169. package/dist/three/plot-point3d.js +27 -53
  170. package/dist/three/plot-point3d.js.map +1 -1
  171. package/dist/three/space.d.ts +17 -2
  172. package/dist/three/space.d.ts.map +1 -1
  173. package/dist/three/space.js +19 -8
  174. package/dist/three/space.js.map +1 -1
  175. package/dist/three/surface-plot3d.d.ts +176 -49
  176. package/dist/three/surface-plot3d.d.ts.map +1 -1
  177. package/dist/three/surface-plot3d.js +227 -261
  178. package/dist/three/surface-plot3d.js.map +1 -1
  179. package/dist/three/vector-arrow3d.d.ts +87 -16
  180. package/dist/three/vector-arrow3d.d.ts.map +1 -1
  181. package/dist/three/vector-arrow3d.js +48 -67
  182. package/dist/three/vector-arrow3d.js.map +1 -1
  183. package/package.json +4 -4
  184. package/src/annotate/angle-mark.ts +95 -105
  185. package/src/annotate/curly-brace.ts +107 -85
  186. package/src/annotate/emphasis-mark.ts +55 -26
  187. package/src/engine.ts +35 -21
  188. package/src/kit/component.ts +57 -0
  189. package/src/kit/curve.ts +38 -20
  190. package/src/kit/field-mark.ts +124 -108
  191. package/src/kit/follow.ts +146 -120
  192. package/src/kit/furniture.ts +6 -1
  193. package/src/kit/graph.ts +116 -0
  194. package/src/kit/mark.ts +135 -114
  195. package/src/kit/place.ts +32 -56
  196. package/src/kit/system.ts +77 -71
  197. package/src/kit/withdrawn.ts +3 -3
  198. package/src/marks/curve-area.ts +65 -65
  199. package/src/marks/drop-lines.ts +50 -42
  200. package/src/marks/plot-point.ts +77 -82
  201. package/src/marks/riemann-sum.ts +73 -72
  202. package/src/marks/tangent-line.ts +87 -71
  203. package/src/marks/vector-arrow.ts +73 -73
  204. package/src/nodes.ts +41 -5
  205. package/src/plots/function-plot.ts +155 -171
  206. package/src/plots/points-plot.ts +46 -50
  207. package/src/plots/stream-lines.ts +75 -66
  208. package/src/plots/traced-path.ts +51 -33
  209. package/src/plots/vector-field.ts +68 -49
  210. package/src/structures/network-graph.ts +168 -185
  211. package/src/structures/sample-space.ts +149 -148
  212. package/src/systems/axes2d.ts +165 -156
  213. package/src/systems/number-line.ts +91 -92
  214. package/src/systems/number-plane.ts +149 -120
  215. package/src/systems/polar-plane.ts +117 -116
  216. package/src/tex/index.ts +2 -1
  217. package/src/tex/matrix.ts +62 -40
  218. package/src/tex/node.ts +54 -621
  219. package/src/tex/typeset.ts +461 -0
  220. package/src/three/axes3d.ts +187 -160
  221. package/src/three/curve-plot3d.ts +107 -110
  222. package/src/three/entries.ts +42 -0
  223. package/src/three/plot-point3d.ts +42 -45
  224. package/src/three/space.ts +34 -9
  225. package/src/three/surface-plot3d.ts +312 -323
  226. package/src/three/vector-arrow3d.ts +65 -54
  227. package/dist/browser/chunks/chunk-3GJB6AVO.js +0 -2
  228. package/dist/browser/chunks/chunk-3GJB6AVO.js.map +0 -7
  229. package/dist/browser/chunks/chunk-D5WHCVBC.js +0 -2
  230. package/dist/browser/chunks/chunk-D5WHCVBC.js.map +0 -7
  231. package/dist/browser/chunks/chunk-WL4KEX7Y.js +0 -2
  232. package/dist/browser/chunks/chunk-WL4KEX7Y.js.map +0 -7
  233. package/src/kit/placement.ts +0 -8
@@ -1,20 +1,30 @@
1
1
  import {
2
- command,
2
+ component3d,
3
3
  Graphics3D,
4
4
  lerpVector3,
5
- Mesh3D,
6
- node,
7
- property,
5
+ Material,
8
6
  resolveVector3,
9
- type Command,
10
- type CommandArgs,
7
+ Types,
11
8
  type Mesh3DProps,
12
- type NodeConfig,
9
+ type NodeOf,
10
+ type Values,
13
11
  type Vector3,
14
12
  type Vector3Input,
13
+ // Named so the emitted declaration reaches these through the sdk, not core.
14
+ type Blend3D as _Blend3D,
15
+ type Color as _Color,
16
+ type Faces3D as _Faces3D,
17
+ type Fill3D as _Fill3D,
18
+ type Geometry3D as _Geometry3D,
19
+ type Material3D as _Material3D,
20
+ type Node3D as _Node3D,
21
+ type Node3DProps as _Node3DProps,
22
+ type NormalizedColor as _NormalizedColor,
23
+ type Shading3D as _Shading3D,
24
+ type Texture3D as _Texture3D,
15
25
  } from "@motionscript/sdk";
16
- import { stated } from "../kit/geometry";
17
- import { aim, spaceOf } from "./space";
26
+ import { meshEntries } from "./entries";
27
+ import { aim, graphEntry, graphOf } from "./space";
18
28
 
19
29
  export interface VectorArrow3dProps extends Mesh3DProps {
20
30
  tail?: Vector3Input;
@@ -23,55 +33,56 @@ export interface VectorArrow3dProps extends Mesh3DProps {
23
33
  tip?: boolean;
24
34
  }
25
35
 
26
- /** An arrow between two points of a 3D graph: a vector from the origin by default. */
27
- @node({
28
- key: "vectorArrow3d",
29
- within: ["axes3d"],
30
- forkable: true,
31
- layout: { acceptsChildren: false },
32
- seed: { head: { x: 2, y: 1, z: 1.5 }, fill: "#f97316" },
33
- })
34
- export class VectorArrow3d extends Mesh3D<VectorArrow3dProps> {
35
- @property({ default: { x: 0, y: 0, z: 0 }, mapper: resolveVector3, tween: lerpVector3, kind: "vector3" }) declare tail: Vector3;
36
- @property({ default: { x: 1, y: 1, z: 1 }, mapper: resolveVector3, tween: lerpVector3, kind: "vector3" }) declare head: Vector3;
36
+ function point(initial: Vector3) {
37
+ return Types.custom<Vector3Input, Vector3>(initial, { resolve: resolveVector3, lerp: lerpVector3, kind: "vector3" });
38
+ }
39
+
40
+ const state = {
41
+ ...meshEntries,
42
+ tail: point({ x: 0, y: 0, z: 0 }),
43
+ head: point({ x: 1, y: 1, z: 1 }),
37
44
  /** The radius of the shaft, in scene units; the tip is sized from it. */
38
- @property({ default: 0.035, min: 0.001, step: 0.005 }) declare thickness: number;
39
- @property({ default: true, animatable: false }) declare tip: boolean;
45
+ thickness: Types.number(0.035, { min: 0.001, step: 0.005 }),
46
+ tip: Types.boolean(true, { animatable: false }),
47
+ graph: graphEntry(),
48
+ };
40
49
 
41
- constructor(props?: NodeConfig<VectorArrow3d, VectorArrow3dProps>) {
42
- super(props ?? {});
43
- }
50
+ /** An arrow between two points of a 3D graph: a vector from the origin by default. */
51
+ export const VectorArrow3d = component3d({
52
+ key: "vectorArrow3d",
53
+ state,
54
+ commands: {
55
+ /** Animate either end, or both. */
56
+ endpointsTo: { args: ["tail", "head"] },
57
+ },
58
+ render: (ctx, s) => ctx.draw(drawArrow(s)),
59
+ });
44
60
 
45
- /** Animate either end, or both. */
46
- @command({ args: ["tail", "head"] })
47
- endpointsTo(args: CommandArgs<{ tail?: Vector3Input; head?: Vector3Input }> & { duration: number }): Command<VectorArrow3dProps> {
48
- return this.to({ data: stated(args.data), duration: args.duration, easing: args.easing });
49
- }
61
+ export type VectorArrow3d = NodeOf<typeof VectorArrow3d>;
50
62
 
51
- protected override buildGraphics3D(): Graphics3D {
52
- const g3 = new Graphics3D();
53
- const space = spaceOf(this);
54
- const { tail, head, thickness } = this;
55
- // Outside a graph an arrow is drawn in the scene's own units.
56
- const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;
57
- const to = space ? space.offset(head.x, head.y, head.z) : head;
58
- const along: Vector3 = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };
59
- const length = Math.hypot(along.x, along.y, along.z);
60
- if (!(length > 0)) return g3;
63
+ function drawArrow(s: Values<typeof state>): Graphics3D {
64
+ const g3 = new Graphics3D();
65
+ const space = graphOf(s);
66
+ const { tail, head, thickness } = s;
67
+ // Outside a graph an arrow is drawn in the scene's own units.
68
+ const from = space ? space.offset(tail.x, tail.y, tail.z) : tail;
69
+ const to = space ? space.offset(head.x, head.y, head.z) : head;
70
+ const along: Vector3 = { x: to.x - from.x, y: to.y - from.y, z: to.z - from.z };
71
+ const length = Math.hypot(along.x, along.y, along.z);
72
+ if (!(length > 0)) return g3;
61
73
 
62
- const paint = this.materialShorthand();
63
- const quaternion = aim(along);
64
- const tipLength = this.tip ? Math.min(thickness * 8, length) : 0;
65
- const shaft = length - tipLength;
66
- const at = (distance: number): Vector3 => ({
67
- x: from.x + (along.x * distance) / length,
68
- y: from.y + (along.y * distance) / length,
69
- z: from.z + (along.z * distance) / length,
70
- });
71
- if (shaft > 0) g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });
72
- if (tipLength > 0) {
73
- g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });
74
- }
75
- return g3;
74
+ const paint = Material.shorthand(s);
75
+ const quaternion = aim(along);
76
+ const tipLength = s.tip ? Math.min(thickness * 8, length) : 0;
77
+ const shaft = length - tipLength;
78
+ const at = (distance: number): Vector3 => ({
79
+ x: from.x + (along.x * distance) / length,
80
+ y: from.y + (along.y * distance) / length,
81
+ z: from.z + (along.z * distance) / length,
82
+ });
83
+ if (shaft > 0) g3.cylinder({ ...paint, radius: thickness, height: shaft, segments: [12, 1], position: at(shaft / 2), quaternion });
84
+ if (tipLength > 0) {
85
+ g3.cone({ ...paint, radius: thickness * 2.8, height: tipLength, segments: [20, 1], position: at(shaft + tipLength / 2), quaternion });
76
86
  }
87
+ return g3;
77
88
  }
@@ -1,2 +0,0 @@
1
- import{a as P,b as It,c as Tt,f as bt,h as Nt,p as X,r as Lt}from"./chunk-WL4KEX7Y.js";import{Clip as Jn,flowOps as Kn,Graphics2D as Zn,insetsOps as fn,PaintNode as te}from"@motionscript/sdk";import{flowOps as Gn}from"@motionscript/sdk";function Hn(e){return typeof e.anchorAt=="function"}function Vn(e){return typeof e._resolve=="function"}function V(e,t,n,r,o){let i=new WeakMap,s=[];for(let u of e){if(!Vn(u)){s.push(u);continue}let c=u._resolve(t),f=c?(c.minX+c.maxX)/2:n.x,l=c?(c.minY+c.maxY)/2:n.y;u.layout({x:f-n.x,y:n.y-l,width:c?c.maxX-c.minX:0,height:c?c.maxY-c.minY:0},o),i.set(u,Qn(t,f,l))}if(s.length===0)return i;let a=Gn.measure({},s,r,o).sizes;return s.forEach((u,c)=>{u.layout({x:-n.x,y:n.y,width:a[c].width,height:a[c].height},o),i.set(u,Wn(t,u))}),i}function W(e,t){return{toOffset:(n,r)=>{let o=e.toPoint(n,r);return{x:o.x-t.x,y:o.y-t.y}},toCoords:(n,r)=>e.toCoords(n+t.x,r+t.y)}}function Wn(e,t){let n={x:0,y:0},r=Hn(t)?t:null;return{toOffset:(o,i)=>{let s=r?.anchorAt(o,i);return s?e.toPoint(s.x,s.y,n):e.toPoint(o,i,n)},toCoords:(o,i)=>e.toCoords(o,i)}}function Qn(e,t,n){let r={x:0,y:0};return{toOffset:()=>r,toCoords:(o,i)=>e.toCoords(t+o,n+i)}}var ne={width:0,height:0},ln={x:0,y:0},Q=class extends te{get coordinates(){return this._map??(this._map=this.mapFor(this._area(this.layoutBounds)))}measure(t){return Kn.size(this,t,this.effectivePadding(),ne)}layoutChildren(t,n){let r=this.mapFor(this._area(t));this._map=r;let o=fn.insetBounds(t.width,t.height,this.effectivePadding());this._planes=V(this.flowChildren(),r,ln,o,n)}_planeOf(t){return t?this._planes.get(t)??null:W(this.coordinates,ln)}shapeGraphics(){let t=this.layoutBounds;return new Zn().rect({x:0,y:0,width:t.width,height:t.height})}renderSelf(t){super.renderSelf(t);let n=this.coordinates,r=n.spills?this.clipSelf():null;r&&t.beginClip(r);for(let o of this.furniture(n))t.draw(o);r&&t.endClip()}renderStroke(){}clipSelf(){let{minX:t,minY:n,maxX:r,maxY:o}=this.coordinates.area;return new Jn().rect({x:(t+r)/2,y:(n+o)/2,width:r-t,height:o-n})}_map=null;_planes=new WeakMap;_area(t){let n=fn.insetBounds(t.width,t.height,this.effectivePadding());return{minX:n.x-n.width/2,maxX:n.x+n.width/2,minY:-n.y-n.height/2,maxY:-n.y+n.height/2}}};import{colorProperty as _e,command as we,Graphics2D as wn,node as Ee,property as O,strokeProperty as Se}from"@motionscript/sdk";function ut(e,t="linear"){let[n,r]=e??[0,1];return(!Number.isFinite(n)||!Number.isFinite(r))&&([n,r]=[0,1]),n>r&&([n,r]=[r,n]),t==="log"&&(r>0||(r=10),n>0||(n=r/1e3)),r>n?[n,r]:[n,n+1]}function Ct(e,t,n,r="linear"){let[o,i]=e;if(r==="log"){let a=Math.log10(o),u=(n-t)/(Math.log10(i)-a);return{to:c=>t+(Math.log10(c)-a)*u,from:c=>10**(a+(c-t)/u)}}let s=(n-t)/(i-o);return{to:a=>t+(a-o)*s,from:a=>o+(a-t)/s}}function Ft({xRange:e,yRange:t,area:n,xScaling:r="linear",yScaling:o="linear"}){let i=Ct(e,n.minX,n.maxX,r),s=Ct(t,n.minY,n.maxY,o);return{toPoint:(a,u,c={x:0,y:0})=>(c.x=i.to(a),c.y=s.to(u),c),toCoords:(a,u,c={x:0,y:0})=>(c.x=i.from(a),c.y=s.from(u),c),area:n,xRange:e,yRange:t,revision:[e,t,n.minX,n.minY,n.maxX,n.maxY,r,o].join("|")}}var ee={minX:-1/0,minY:-1/0,maxX:1/0,maxY:1/0},ft={toPoint:(e,t,n={x:0,y:0})=>(n.x=e,n.y=t,n),toCoords:(e,t,n={x:0,y:0})=>(n.x=e,n.y=t,n),area:ee,xRange:[-1/0,1/0],yRange:[-1/0,1/0],revision:"pixels"},dn=[1,0,0,1];function re(e,t=dn){let n=Array.isArray(e)?e.flat():[];return n.length!==4||n.some(r=>typeof r!="number"||!Number.isFinite(r))?t:[n[0],n[1],n[2],n[3]]}function oe(e,t,n){return[0,1,2,3].map(r=>e[r]+(t[r]-e[r])*n)}function ie([e,t,n,r]){return e===1&&t===0&&n===0&&r===1}var se=4;function pn([e,t]){let n=(e+t)/2,r=(t-e)/2*se;return[n-r,n+r]}function ae(e,t){let[n,r,o,i]=t,s=n*i-r*o,a=Math.abs(s)<1e-9,u=(y,d,m)=>(a?(m.x=y,m.y=d):(m.x=(i*y-r*d)/s,m.y=(n*d-o*y)/s),m),c=pn(e.xRange),f=pn(e.yRange),l=c,x=f;if(!a){let y={x:0,y:0},d=1/0,m=1/0,_=-1/0,p=-1/0;for(let M of e.xRange)for(let h of e.yRange)u(M,h,y),d=Math.min(d,y.x),_=Math.max(_,y.x),m=Math.min(m,y.y),p=Math.max(p,y.y);l=[Math.max(d,c[0]),Math.min(_,c[1])],x=[Math.max(m,f[0]),Math.min(p,f[1])]}return{toPoint:(y,d,m={x:0,y:0})=>e.toPoint(n*y+r*d,o*y+i*d,m),toCoords:(y,d,m={x:0,y:0})=>(e.toCoords(y,d,m),u(m.x,m.y,m)),area:e.area,xRange:l,yRange:x,revision:`${e.revision}|m${t.join(",")}`,spills:!0}}function ce(e,t,n){let r=(u,c,f)=>(t(u,c,f)||(f.x=u,f.y=c),f),o={x:0,y:0},i={x:0,y:0},s={x:0,y:0},a=1e-4;return{toPoint:(u,c,f={x:0,y:0})=>(r(u,c,f),e.toPoint(f.x,f.y,f)),toCoords:(u,c,f={x:0,y:0})=>{let l=e.toCoords(u,c),x=l.x,y=l.y;for(let d=0;d<8;d++){r(x,y,o);let m=o.x-l.x,_=o.y-l.y;if(Math.abs(m)+Math.abs(_)<1e-9)break;r(x+a,y,i),r(x,y+a,s);let p=(i.x-o.x)/a,M=(i.y-o.y)/a,h=(s.x-o.x)/a,g=(s.y-o.y)/a,w=p*g-h*M;if(!(Math.abs(w)>1e-12))break;x-=(g*m-h*_)/w,y-=(p*_-M*m)/w}return f.x=Number.isFinite(x)?x:l.x,f.y=Number.isFinite(y)?y:l.y,f},area:e.area,xRange:hn(e.xRange),yRange:hn(e.yRange),revision:`${e.revision}|w${n}`,curved:!0,spills:!0}}var ue=.3;function hn([e,t]){let n=(t-e)*ue;return Number.isFinite(n)?[e-n,t+n]:[e,t]}var xn=48;function lt(e,t,n,r,o){if(!e.curved)return[e.toPoint(t,n),e.toPoint(r,o)];let i=[];for(let s=0;s<=xn;s++){let a=s/xn;i.push(e.toPoint(t+(r-t)*a,n+(o-n)*a))}return i}function J(e,t=!1){let n=[];for(let r of e)if(!(r.length<2)){n.push({type:"M",x:r[0].x,y:r[0].y});for(let o=1;o<r.length;o++)n.push({type:"L",x:r[o].x,y:r[o].y});t&&n.push({type:"Z"})}return n}function K(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let i of e)if(!(i.length<2))for(let s of i)s.x<t&&(t=s.x),s.x>r&&(r=s.x),s.y<n&&(n=s.y),s.y>o&&(o=s.y);return t<=r?{minX:t,minY:n,maxX:r,maxY:o}:null}function fe(e,t){return{minX:e.minX-t,minY:e.minY-t,maxX:e.maxX+t,maxY:e.maxY+t}}function Y(e,t,n){return e<t?t:e>n?n:e}function T(e){let t={};if(!e)return t;for(let n of Object.keys(e))e[n]!==void 0&&(t[n]=e[n]);return t}import{niceStep as le}from"@motionscript/sdk/component";var yn=200,pe=64;function pt(e,t,n,r="linear"){let[o,i]=e;if(r==="log")return he(o,i);let s=i-o;if(!(s>0))return{values:[],step:1};let a=t>0?t:le(pe/Math.max(1,n)*s);return{values:xe(o,i,a),step:a}}function he(e,t){let n=[];for(let r=Math.ceil(Math.log10(e)-1e-9);r<=Math.floor(Math.log10(t)+1e-9)&&n.length<yn;r++)n.push(10**r);return{values:n,step:0}}function xe(e,t,n){let r=Math.ceil(e/n-1e-9),i=Math.floor(t/n+1e-9)-r+1;if(!Number.isFinite(i)||i<=0||i>yn)return[];let s=new Array(i);for(let a=0;a<i;a++)s[a]=(r+a)*n;return s}function vt(e){return Math.floor(Math.log10(e)+1e-12)}function ht(e,t){if(e===0)return"0";if(!Number.isFinite(e))return"";if(!(t>0)){let s=vt(Math.abs(e));return s>=6||s<=-5?mn(e.toExponential(0)):String(Number(e.toPrecision(12)))}let n=vt(Math.abs(e)),r=Math.max(1,n-vt(t)+1);if((n>=6||n<=-5)&&r<=6)return mn(e.toExponential(r-1));let o=de(t),i=e.toFixed(o);return o>0?i.replace(/\.?0+$/,""):i}function de(e){for(let t=0;t<12;t++){let n=e*10**t;if(Math.abs(n-Math.round(n))<1e-9*Math.max(1,n))return t}return 12}function mn(e){let[t,n]=e.split("e");return`${t.replace(/\.?0+$/,"")}e${Number(n)}`}import{Fills as me,Graphics2D as gn,toPathString as ye}from"@motionscript/sdk";var xt="#9ca3af",Rt="#58a6ff";function Xt(e){return e.map(t=>({...t,startCap:void 0,endCap:void 0}))}var ge=8,Mn=/^\$([\s\S]+)\$$/;function _n(e,t){t.some(n=>Mn.test(n.trim()))&&e.loader(It,Tt,{gate:"layout"})}function Yt(e,t){let n=[],r=me.color(t.color),o=new gn,i=t.fontSize*ge,s=!1;for(let a of e){let u=Mn.exec(a.text.trim()),c=u?Me(u[1],a,t.fontSize):null;if(c){for(let x of c)n.push(x.fill(r));continue}let{at:f,align:l}=a;s=!0,o.text({text:a.text,fontSize:t.fontSize,...t.fontFamily===""?{}:{fontFamily:t.fontFamily},wrap:!1,width:i,textAlign:l,x:l==="center"?f.x:l==="right"?f.x-i/2:f.x+i/2,y:f.y})}return s&&n.push(o.fill(r)),n}function Me(e,{at:t,align:n},r){let o;try{o=Nt(e,r)}catch(l){return l instanceof bt?[]:null}let[i,s,a,u]=o.bounds,c=t.x+(n==="left"?o.width/2:n==="right"?-o.width/2:0),f=[i-c,s+t.y,a-c,u+t.y];return o.tokens.map(l=>new gn().path({data:ye(l.path),centerBounds:f}))}function Dt(e,t,n){return e>=t-1e-9&&e<=n+1e-9}function qt(e,t,n){let r=n.x-t.x,o=n.y-t.y,i=r*r+o*o;return i===0?0:((e.x-t.x)*r+(e.y-t.y)*o)/i}function dt(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}function mt(e,t){let[n,r]=Array.isArray(e)?e:t??[0,1];return[Number(n),Number(r)]}var A=function(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i},E=class extends Q{constructor(t){super(t??{})}rangeTo(t){return this.to({data:T(t.data),duration:t.duration,easing:t.easing})}declareAssets(t){super.declareAssets(t),this.fontFamily!==""&&t.font(this.fontFamily),_n(t,[this.xLabel,this.yLabel])}mapFor(t){let n=ut(this.xRange,this.xScaling),r=ut(this.yRange,this.yScaling),o=t.maxX-t.minX;if(this.squareUnits&&this.xScaling==="linear"&&this.yScaling==="linear"&&o>0){let i=(n[1]-n[0])*(t.maxY-t.minY)/o,s=(r[0]+r[1])/2;i>0&&(r=[s-i/2,s+i/2])}return Ft({xRange:n,yRange:r,area:t,xScaling:this.xScaling,yScaling:this.yScaling})}furniture(t){let n=this.stroke,{start:r,end:o}=this,[i,s]=this.axes(t),a=[...this.backdrop(t,i,s)];if(n.length===0&&!this.labels)return a;n.length>0&&a.push(new wn().line({points:i.line,radius:0,start:r,end:o}).line({points:s.line,radius:0,start:r,end:o}).stroke(n));let u=this.tickSize/2,c=u+this.labelSize*.35,f=new wn,l=[],x=!1,y=(d,m)=>{for(let _ of d.marks.values){if(Math.abs(_-d.crossing)<1e-9*Math.max(1,Math.abs(_)))continue;let p=d.at(_);Dt(qt(p,d.from,d.to),r,o)&&(this.ticks&&u>0&&(f.line({points:m?[{x:p.x,y:p.y-u},{x:p.x,y:p.y+u}]:[{x:p.x-u,y:p.y},{x:p.x+u,y:p.y}],radius:0}),x=!0),this.labels&&l.push(m?{text:ht(_,d.marks.step),at:{x:p.x,y:p.y-c-this.labelSize/2},align:"center"}:{text:ht(_,d.marks.step),at:{x:p.x-c,y:p.y},align:"right"}))}};return y(i,!0),y(s,!1),x&&n.length>0&&a.push(f.stroke(Xt(n))),this.xLabel!==""&&o>=1&&l.push({text:this.xLabel,at:{x:i.to.x,y:i.to.y+c+this.labelSize/2},align:"right"}),this.yLabel!==""&&o>=1&&l.push({text:this.yLabel,at:{x:s.to.x+c,y:s.to.y-this.labelSize/2},align:"left"}),a.push(...Yt(l,{fontSize:this.labelSize,fontFamily:this.fontFamily,color:this.labelColor})),a}backdrop(t,n,r){return[]}axes(t){let[n,r]=t.xRange,[o,i]=t.yRange,s=this.xScaling==="log"?n:Y(0,n,r),a=this.yScaling==="log"?o:Y(0,o,i),u=t.toPoint(n,a),c=t.toPoint(r,a),f=t.toPoint(s,o),l=t.toPoint(s,i);return[{from:u,to:c,line:lt(t,n,a,r,a),marks:pt(t.xRange,this.xStep,Math.hypot(c.x-u.x,c.y-u.y),this.xScaling),crossing:s,at:x=>t.toPoint(x,a)},{from:f,to:l,line:lt(t,s,o,s,i),marks:pt(t.yRange,this.yStep,Math.hypot(l.x-f.x,l.y-f.y),this.yScaling),crossing:a,at:x=>t.toPoint(s,x)}]}};A([O({default:[-5,5],mapper:mt,tween:dt})],E.prototype,"xRange",void 0);A([O({default:[-3,3],mapper:mt,tween:dt})],E.prototype,"yRange",void 0);A([O({default:0,min:0})],E.prototype,"xStep",void 0);A([O({default:0,min:0})],E.prototype,"yStep",void 0);A([O({default:"linear",options:["linear","log"],animatable:!1})],E.prototype,"xScaling",void 0);A([O({default:"linear",options:["linear","log"],animatable:!1})],E.prototype,"yScaling",void 0);A([O({default:!1,animatable:!1})],E.prototype,"squareUnits",void 0);A([O({default:!0,animatable:!1})],E.prototype,"ticks",void 0);A([O({default:10,min:0,unit:"px"})],E.prototype,"tickSize",void 0);A([O({default:!0,animatable:!1})],E.prototype,"labels",void 0);A([O({default:18,min:1,unit:"px"})],E.prototype,"labelSize",void 0);A([_e({default:xt})],E.prototype,"labelColor",void 0);A([O({default:"",animatable:!1})],E.prototype,"fontFamily",void 0);A([O({default:"",animatable:!1})],E.prototype,"xLabel",void 0);A([O({default:"",animatable:!1})],E.prototype,"yLabel",void 0);A([Se({default:{weight:2,fill:xt,align:"center",endCap:"triangle",capScale:5}})],E.prototype,"stroke",void 0);A([we({args:["xRange","yRange"]})],E.prototype,"rangeTo",null);E=A([Ee({key:"axes2d",parentKey:"node",forkable:!0,layout:{children:"freeform",defaultWidthMode:"fixed",defaultHeightMode:"fixed",acceptsChildren:!0},seed:{width:800,height:500,padding:32}})],E);import{Graphics2D as Ae,PaintNode as ke}from"@motionscript/sdk";var D=class extends ke{isClosed(){return!1}shift(){return this._inSystem?{x:this.x,y:this.y}:En}ownPoint(t){let n=this.shift(),r=this._map.toPoint(t.x+n.x,t.y+n.y),o=this._centre();return{x:r.x-o.x,y:r.y-o.y}}graphPoint(t){let n=this.shift(),r=this._centre(),o=this._map.toCoords(t.x+r.x,t.y+r.y);return{x:o.x-n.x,y:o.y-n.y}}paintsFill(){return!0}measure(){let t=this._resolve(ft,!1);return t?{width:t.maxX-t.minX,height:t.maxY-t.minY}:{width:0,height:0}}shapeGraphics(){let t=this._ink;return!t||this._data.length===0?null:new Ae().path({data:this._data,centerBounds:[t.minX,t.minY,t.maxX,t.maxY],start:this.start,end:this.end})}renderSelf(t){this.paintsFill()&&super.renderSelf(t),this.renderInk(t)}renderInk(t){super.renderStroke(t)}renderStroke(){}layoutChildren(t,n){let r=this.flowChildren();if(r.length===0)return;let o={x:0,y:0,width:t.width,height:t.height};this._planes=V(r,this._map,this._centre(),o,n)}_planeOf(t){return t?this._planes.get(t)??null:W(this._map,this._centre())}_data=[];_ink=null;_inSystem=!1;_map=ft;_planes=new WeakMap;_centre(){let t=this._ink;return t?{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2}:En}_resolve(t,n=!0){this._inSystem=n,this._map=t;let r=this.trace(t);return this._data=J(r,this.isClosed()),this._ink=K(r),this._ink}},En={x:0,y:0};import{expressionOps as Oe}from"@motionscript/sdk";var jt={sin:Math.sin,cos:Math.cos,tan:Math.tan,asin:Math.asin,acos:Math.acos,atan:Math.atan,sinh:Math.sinh,cosh:Math.cosh,tanh:Math.tanh,sqrt:Math.sqrt,cbrt:Math.cbrt,abs:Math.abs,exp:Math.exp,log:Math.log,ln:Math.log,log2:Math.log2,log10:Math.log10,floor:Math.floor,ceil:Math.ceil,round:Math.round,sign:Math.sign,trunc:Math.trunc},Ut={atan2:{fn:Math.atan2,arity:[2,2]},pow:{fn:Math.pow,arity:[2,2]},mod:{fn:(e,t)=>e%t,arity:[2,2]},hypot:{fn:Math.hypot,arity:[1,1/0]},min:{fn:Math.min,arity:[1,1/0]},max:{fn:Math.max,arity:[1,1/0]}},An={pi:Math.PI,PI:Math.PI,e:Math.E,E:Math.E,tau:Math.PI*2,phi:(1+Math.sqrt(5))/2},tt={functions:{...Object.fromEntries(Object.keys(jt).map(e=>[e,{arity:[1,1]}])),...Object.fromEntries(Object.entries(Ut).map(([e,{arity:t}])=>[e,{arity:t}]))},constants:An,refs:"bare",unknownName:e=>`Unknown name '${e}'`};function Pe(e){return{variables:e,functions:[...Object.keys(jt),...Object.keys(Ut)].sort(),constants:["pi","e","tau","phi"]}}function kn(e,t,n=[]){for(let r of[...t,...n])if(Object.hasOwn(An,r))throw new Error(`'${r}' is a constant, so it cannot be a variable`);return Z(Oe.parse(e,tt).root,t,n)}function Z(e,t,n){switch(e.kind){case"const":{let{value:r}=e;return()=>r}case"ref":{let{name:r}=e,o=t.indexOf(r);if(o===0)return i=>i;if(o===1)return(i,s)=>s;if(n.includes(r))return(i,s,a)=>a?.[r]??NaN;throw new Error(tt.unknownName(r))}case"unary":{let r=Z(e.operand,t,n);return(o,i,s)=>-r(o,i,s)}case"binary":{let r=Z(e.left,t,n),o=Z(e.right,t,n);switch(e.op){case"+":return(i,s,a)=>r(i,s,a)+o(i,s,a);case"-":return(i,s,a)=>r(i,s,a)-o(i,s,a);case"*":return(i,s,a)=>r(i,s,a)*o(i,s,a);case"/":return(i,s,a)=>r(i,s,a)/o(i,s,a);case"%":return(i,s,a)=>r(i,s,a)%o(i,s,a);case"^":return(i,s,a)=>Math.pow(r(i,s,a),o(i,s,a))}break}case"call":{let r=e.args.map(s=>Z(s,t,n)),o=jt[e.name];if(o){let[s]=r;return(a,u,c)=>o(s(a,u,c))}let{fn:i}=Ut[e.name];if(r.length===2){let[s,a]=r;return(u,c,f)=>i(s(u,c,f),a(u,c,f))}return(s,a,u)=>i(...r.map(c=>c(s,a,u)))}}throw new Error("Unsupported expression")}var Sn=P(256);function q(e,t,n=[]){let r=`${t.join(",")}|${n.join(",")}|${e}`,o=Sn.get(r);if(o!==void 0)return o;let i;try{i=kn(e,t,n)}catch(s){i=s instanceof Error?s:new Error(String(s))}return Sn.set(r,i),i}import{expressionOps as Ie}from"@motionscript/sdk";var yt={function:["x"],polar:["theta"],parametric:["t"],implicit:["x","y"]},On=P(256);function gt(e,t=[]){let n=`${t.join(",")}|${e}`,r=On.get(n);if(r!==void 0)return r;let o;try{o=be(e.trim(),t)}catch(i){o=i instanceof Error?i:new Error(String(i))}return On.set(n,o),o}function zt(e){if(e.trim()==="")return null;let t=gt(e,L(e));return t instanceof Error?t.message:null}var Te=new Set(["r",...Object.values(yt).flat()]),Pn=P(256);function $(e){let t=Pn.get(e);if(t!==void 0)return t;let n=new Set,r=e.trim();try{for(let i of j(r)??et(r,"="))nt(Ie.parse(i.trim(),tt).root,n)}catch{n.clear()}let o=[...n];return Pn.set(e,o),o}function L(e){return $(e).filter(t=>!Te.has(t))}function nt(e,t){switch(e.kind){case"ref":t.add(e.name);return;case"unary":nt(e.operand,t);return;case"binary":nt(e.left,t),nt(e.right,t);return;case"call":for(let n of e.args)nt(n,t);return;default:}}function be(e,t){if(e==="")throw new Error("Empty equation");let n=(c,f)=>{let l=q(c.trim(),f,t);if(l instanceof Error)throw l;return l},r=j(e);if(r?.length===2)return{kind:"parametric",x:n(r[0],["t"]),y:n(r[1],["t"])};let o=et(e,"=");if(o.length>2)throw new Error("An equation has one '='");if(o.length===1)return{kind:"function",of:"x",f:n(e,["x"])};let[i,s]=o,a=i.trim(),u=()=>{let c=n(i,["x","y"]),f=n(s,["x","y"]);return{kind:"implicit",f:(l,x,y)=>c(l,x,y)-f(l,x,y)}};if(a==="r")return{kind:"polar",f:n(s,["theta"])};if(a==="y"||a==="x"){let c=a==="y"?"x":"y";try{return{kind:"function",of:c,f:n(s,[c])}}catch(f){try{return u()}catch{throw f}}}return u()}function j(e){if(!e.startsWith("(")||!e.endsWith(")"))return null;let t=0;for(let r=0;r<e.length-1;r++)if(e[r]==="(")t++;else if(e[r]===")"&&--t===0)return null;let n=et(e.slice(1,-1),",");return n.length>=2?n:null}function et(e,t){let n=[],r=0,o=0;for(let i=0;i<e.length;i++){let s=e[i];s==="("?r++:s===")"?r--:s===t&&r===0&&(n.push(e.slice(o,i)),o=i+1)}return n.push(e.slice(o)),n}function rt(e){return typeof e=="string"?{source:e}:e??{source:""}}function ot(e,t,n){return n<=0||e.source===t.source?n<=0?e:t:n>=1?t:{source:t.source,blend:{from:e.source,t:n}}}function Bt(e,t,n){return!e||!t?n<1?e:t:[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n]}var $t=1;function it(e,t,n){let r={...e};for(let[o,i]of Object.entries(t)){let s=e[o]??$t;r[o]=s+(i-s)*n}return r}function U(e,t){let n=null;for(let r of e)typeof t[r]!="number"&&((n??={...t})[r]=$t);return n??t}function Ne(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}var In=[],Mt=0;function Le(){let e=In[Mt];return e===void 0&&(e=Gt(),In.push(e)),Mt++,e}function Gt(){return{t:0,px:0,py:0,rx:0,ry:0,ok:!1}}var st={x:0,y:0};function Vt(e,t,n,r,{seeds:o=256,minStep:i=0}={}){if(!(n>t)||!Number.isFinite(t)||!Number.isFinite(n))return[];let s=new Ht(r),a=0,u=(p,M)=>{let h=e(M,st);a++;let g=h&&Number.isFinite(st.x)&&Number.isFinite(st.y);return p.t=M,p.rx=g?st.x:0,p.ry=g?st.y:0,p.px=Tn(p.rx),p.py=Tn(p.ry),p.ok=g,p},c=p=>u(Le(),p),f=(p,M)=>{let h=p,g=M.t;for(let w=0;w<60&&!(a>=4e4||ve(h,r));w++){let S=(h.t+g)/2;if(S===h.t||S===g)break;let k=c(S);if(!k.ok){g=S;continue}let N=Math.abs(k.px-h.px)<.25&&Math.abs(k.py-h.py)<.25;if(h=k,N)break}return h},l=(p,M,h,g)=>{if(p.ok&&h.ok){g&&Fe(p,M,h,r)?s.break():s.draw(p,h);return}if(p.ok){let w=f(p,h);w.t!==p.t&&s.draw(p,w),s.break();return}if(s.break(),h.ok){let w=f(h,p);w.t!==h.t?s.draw(w,h):s.start(h)}},x=(p,M,h)=>{if(a>=4e4||s.points>=24e3){l(p,null,M,!1);return}let g=c((p.t+M.t)/2),w=h>=12||M.t-p.t<=i;if(w||Ce(p,g,M)){l(p,g,M,w);return}x(p,g,h+1),x(g,M,h+1)},y=Math.max(1,Math.round(o)),d=(n-t)/y,m=[Gt(),Gt()],_=u(m[0],t);for(let p=1;p<=y;p++){let M=u(m[p&1],p===y?n:t+p*d);Mt=0,x(_,M,0),_=M}return Mt=0,s.finish()}function Ce(e,t,n){if(e.ok!==t.ok||t.ok!==n.ok)return!1;if(!e.ok)return!0;let r=n.px-e.px,o=n.py-e.py,i=Math.hypot(r,o)||1;if(Math.abs((t.px-e.px)*o-(t.py-e.py)*r)/i>.25)return!1;let s=Math.abs(Math.atan2(t.py-e.py,t.px-e.px)-Math.atan2(n.py-t.py,n.px-t.px));return s>Math.PI&&(s=2*Math.PI-s),s<.05}function Fe(e,t,n,r){return!(e.py>r.maxY&&n.py<r.minY||e.py<r.minY&&n.py>r.maxY||e.px>r.maxX&&n.px<r.minX||e.px<r.minX&&n.px>r.maxX)||t===null?!1:t.ok?t.ry<Math.min(e.ry,n.ry)||t.ry>Math.max(e.ry,n.ry)||t.rx<Math.min(e.rx,n.rx)||t.rx>Math.max(e.rx,n.rx):!0}function ve(e,t){return e.py>t.maxY||e.py<t.minY||e.px>t.maxX||e.px<t.minX}function Tn(e){return e>16e3?16e3:e<-16e3?-16e3:e}var Ht=class{clip;points=0;runs=[];open=[];cursor=null;constructor(t){this.clip=t}draw(t,n){let r=Ye(t.px,t.py,n.px,n.py,this.clip);if(!r){this.break();return}let[o,i]=r;this.cursor&&Re(this.cursor,o)?this.push(i):(this.break(),this.push(o),this.push(i)),this.cursor=i}start(t){this.break(),Xe(t.px,t.py,this.clip)&&(this.cursor={x:t.px,y:t.py},this.push(this.cursor))}break(){this.open.length>=2&&this.runs.push(this.open),this.open=[],this.cursor=null}finish(){return this.break(),this.runs}push(t){this.open.push(t),this.points++}};function Re(e,t){return Math.abs(e.x-t.x)<.1&&Math.abs(e.y-t.y)<.1}function Xe(e,t,n){return e>=n.minX&&e<=n.maxX&&t>=n.minY&&t<=n.maxY}function Ye(e,t,n,r,o){let i=n-e,s=r-t,a=0,u=1,c=[[-i,e-o.minX],[i,o.maxX-e],[-s,t-o.minY],[s,o.maxY-t]];for(let[f,l]of c){if(f===0){if(l<0)return null;continue}let x=l/f;if(f<0){if(x>u)return null;x>a&&(a=x)}else{if(x<a)return null;x<u&&(u=x)}}return[{x:e+a*i,y:t+a*s},{x:e+u*i,y:t+u*s}]}import{findNode2D as De}from"@motionscript/sdk";function bn(e,t){if(t==="")return null;let n=De(e,t);return n&&typeof n.valueAt=="function"?n:null}function qe(e,t){if(t!=="")return bn(e,t);for(let n=e.parent;n;n=n.parent)if(typeof n.valueAt=="function")return n;return null}import{command as je,findNode2D as Ue,frameIn as ze,Graphics2D as Be,PaintNode as $e,pathOps as Ge,property as wt,withdraw as He}from"@motionscript/sdk";var G=function(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i};function Ln(e){return typeof e.partBounds=="function"}function Cn(e,t){if(t!==""){let n=Ue(e,t);return n&&n!==e?n:null}for(let n=e.parent;n;n=n.parent)if(Ln(n))return n;return null}function _t(e,t){let n=Cn(e,t.on);if(!n)return null;let r=t.part&&Ln(n)?n.partBounds(t.part,t.occurrence||1):{x:0,y:0,width:n.layoutBounds.width,height:n.layoutBounds.height};if(!r)return null;let o=ze(e,n),i=o.rotation*Math.PI/180,s=Math.cos(i),a=Math.sin(i),u=(l,x)=>({x:o.x+(s*l+a*x)*o.scale,y:o.y+(-a*l+s*x)*o.scale}),c=r.width/2,f=r.height/2;return[u(r.x-c,r.y+f),u(r.x+c,r.y+f),u(r.x+c,r.y-f),u(r.x-c,r.y-f)]}function Ve(e,t,n){return e.map((r,o)=>({x:r.x+(t[o].x-r.x)*n,y:r.y+(t[o].y-r.y)*n}))}var Nn=({on:e,part:t,occurrence:n})=>({on:e,part:t,occurrence:n});function We(e,t,n){return n<=0||!t?n<1?e:t:{...Nn(t),from:e?Nn(e):null,t:n}}var Qe=[-1,-1,1,1],F=class extends $e{retargetTo(t){let n=t.data??{},r=this.retarget??this,o={on:n.on??r.on,part:n.part??(n.on?"":r.part),occurrence:n.occurrence??1,t:1};return this.to({data:{retarget:o},duration:t.duration,easing:t.easing})}quad(){let t=this.retarget;if(!t)return _t(this,this);let n=_t(this,t),r=_t(this,t.from??this);return!r||!n||t.t>=1?n??r:Ve(r,n,t.t)}measure(){return{width:0,height:0}}shapeGraphics(){let t=this._outline();return t.length===0?null:new Be().path({data:t,centerBounds:Qe,start:this.start,end:this.end})}_localBounds(){let t=Ge.bounds(this._outline());return t?{x:(t.minX+t.maxX)/2,y:(t.minY+t.maxY)/2,width:t.maxX-t.minX,height:t.maxY-t.minY}:{x:0,y:0,width:0,height:0}}_outline(){let t=this.quad();return t?this.outline(t):[]}};G([wt({default:"",kind:"nodeRef",animatable:!1})],F.prototype,"on",void 0);G([wt({default:"",animatable:!1})],F.prototype,"part",void 0);G([wt({default:1,min:1,step:1,animatable:!1})],F.prototype,"occurrence",void 0);G([wt({default:null,tween:We})],F.prototype,"retarget",void 0);G([je({args:[{key:"on",kind:"nodeRef"},{key:"part",kind:"text",default:""},{key:"occurrence",kind:"number",min:1,step:1,default:1}]})],F.prototype,"retargetTo",null);F=G([He(...X)],F);var I=(e,t,n=1)=>({x:e.x+t.x*n,y:e.y+t.y*n}),Wt=(e,t,n=.5)=>({x:e.x+(t.x-e.x)*n,y:e.y+(t.y-e.y)*n});function at(e,t){let n=t.x-e.x,r=t.y-e.y,o=Math.hypot(n,r);return{unit:o===0?{x:1,y:0}:{x:n/o,y:r/o},length:o}}function Je(e,t){let[n,r,o,i]=e,s=at(n,r).unit,a=at(i,n).unit;return[I(I(n,s,-t),a,t),I(I(r,s,t),a,t),I(I(o,s,t),a,-t),I(I(i,s,-t),a,-t)]}var ct=["x","y"],Ke=new Set(ct),Fn=P(128);function H(e){return $(e).filter(t=>!Ke.has(t))}function Et(e,t=[]){let n=`${t.join(",")}|${e}`,r=Fn.get(n);if(r!==void 0)return r;let o;try{let i=e.trim();if(i==="")throw new Error("Empty equation");let s=j(i);if(s?.length!==2)throw new Error("A field has two parts: (x, y)");let[a,u]=s.map(c=>{let f=q(c.trim(),ct,t);if(f instanceof Error)throw f;return f});o={x:a,y:u}}catch(i){o=i instanceof Error?i:new Error(String(i))}return Fn.set(n,o),o}function Qt(e){if(e.trim()==="")return null;let t=Et(e,H(e));return t instanceof Error?t.message:null}var z={height:["x","y"],surface:["u","v"],spaceCurve:["t"]},Ze=new Set(["x","y","z","u","v"]),tr=new Set(["t"]),nr=P(128),er=P(128);function Jt(e){return $(e).filter(t=>!Ze.has(t))}function Kt(e){return $(e).filter(t=>!tr.has(t))}function vn(e,t=[]){return qn(nr,e,t,n=>{let r=Dn(t),o=j(n);if(o){if(o.length!==3)throw new Error("A parametric surface has three parts: (x, y, z)");let[s,a,u]=o.map(c=>r(c,z.surface));return{kind:"parametric",x:s,y:a,z:u}}let i=et(n,"=");if(i.length>2)throw new Error("An equation has one '='");if(i.length===2&&i[0].trim()!=="z")throw new Error("A surface is written z = \u2026, or as three parts (x, y, z)");return{kind:"height",f:r(i[i.length-1],z.height)}})}function Rn(e,t=[]){return qn(er,e,t,n=>{let r=Dn(t),o=j(n);if(o?.length!==3)throw new Error("A space curve has three parts: (x, y, z)");let[i,s,a]=o.map(u=>r(u,z.spaceCurve));return{x:i,y:s,z:a}})}function Xn(e){if(e.trim()==="")return null;let t=vn(e,Jt(e));return t instanceof Error?t.message:null}function Yn(e){if(e.trim()==="")return null;let t=Rn(e,Kt(e));return t instanceof Error?t.message:null}function Dn(e){return(t,n)=>{let r=q(t.trim(),n,e);if(r instanceof Error)throw r;return r}}function qn(e,t,n,r){let o=`${n.join(",")}|${t}`,i=e.get(o);if(i!==void 0)return i;let s;try{let a=t.trim();if(a==="")throw new Error("Empty equation");s=r(a)}catch(a){s=a instanceof Error?a:new Error(String(a))}return e.set(o,s),s}var rr={equation:{error:zt,params:L,variables:[...new Set(Object.values(yt).flat())]},surfaceEquation:{error:Xn,params:Jt,variables:[...z.height,...z.surface]},spaceCurveEquation:{error:Yn,params:Kt,variables:z.spaceCurve},fieldEquation:{error:Qt,params:H,variables:ct}};import{Node3D as or}from"@motionscript/sdk";function ir(e,t,n,r){let o=Zt(e,r.x),i=Zt(t,r.y),s=Zt(n,r.z),a=(e[0]+e[1])/2,u=(t[0]+t[1])/2,c=(n[0]+n[1])/2;return{xRange:e,yRange:t,zRange:n,revision:[e,t,n,r.x,r.y,r.z].join("|"),toLocal:(f,l,x)=>({x:(l-u)*i,y:(x-c)*s,z:(f-a)*o}),offset:(f,l,x)=>({x:l*i,y:x*s,z:f*o})}}function Zt([e,t],n){let r=t-e;return r>0?n/r:0}function sr(e){for(let t=e.parent;t;t=t instanceof or?t.parent:null){let n=t;if(typeof n._graphSpace=="function")return n._graphSpace()}return null}function ar(e){let t=Math.hypot(e.x,e.y,e.z);if(!(t>0))return{x:0,y:0,z:0,w:1};let n=e.x/t,r=e.y/t,o=e.z/t;if(r<-1+1e-9)return{x:1,y:0,z:0,w:0};let i=1+r,s=Math.hypot(o,n,i);return{x:o/s,y:0,z:-n/s,w:i/s}}import{Fills as cr,Graphics2D as ur,Mat as fr,Tex as lr}from"@motionscript/sdk";var St=64,tn=96,jn=P(256);function pr(e,t){let n=`${t.fontFamily}|${JSON.stringify(t.color)}|${e}`,r=jn.get(n);if(r)return r;let o=Math.min(1024,Math.max(128,Math.ceil((e.length*St*.62+St)/32)*32)),i=new ur().text({text:e,fontSize:St,...t.fontFamily===""?{}:{fontFamily:t.fontFamily},wrap:!1,width:o,textAlign:"center"}).fill(cr.color(t.color)),s={texture:lr.surface(i,{width:o,height:tn}),width:o};return jn.set(n,s),s}function hr(e,t,n,r){if(t===""||!(r.size>0))return;let{texture:o,width:i}=pr(t,r),s=r.size*tn/St;e.sprite({material:fr.sprite({map:o,transparent:!0,depthWrite:!1}),position:n,scale:[s*i/tn,s,1]})}import{command as en,node as dr,property as rn,strokeProperty as mr,withdraw as yr}from"@motionscript/sdk";function nn(e,[t,n],[r,o],i,s){if(!(n>t)||!(o>r)||i<1||s<1)return[];let a=(n-t)/i,u=(o-r)/s,c=i+1,f=new Float64Array(c*(s+1));for(let h=0;h<=s;h++)for(let g=0;g<=i;g++)f[h*c+g]=e(t+g*a,r+h*u);let l=new Map,x=c*(s+1),y=(h,g,w)=>{let S=f[g*c+h],k=w?f[(g+1)*c+h]:f[g*c+h+1];if(!Number.isFinite(S)||!Number.isFinite(k)||S<0==k<0)return null;let N=(w?x:0)+g*c+h;if(!l.has(N)){let R=S/(S-k);l.set(N,w?{x:t+h*a,y:r+(g+R)*u}:{x:t+(h+R)*a,y:r+g*u})}return N},d=new Map,m=(h,g)=>{h===null||g===null||((d.get(h)??d.set(h,[]).get(h)).push(g),(d.get(g)??d.set(g,[]).get(g)).push(h))};for(let h=0;h<s;h++)for(let g=0;g<i;g++){let w=y(g,h,!1),S=y(g,h+1,!1),k=y(g,h,!0),N=y(g+1,h,!0),R=[w,N,S,k].filter(Pt=>Pt!==null);if(R.length===2)m(R[0],R[1]);else if(R.length===4){let Pt=e(t+(g+.5)*a,r+(h+.5)*u),$n=f[h*c+g];Pt<0==$n<0?(m(w,N),m(S,k)):(m(w,k),m(S,N))}}let _=[],p=new Set,M=h=>{let g=[l.get(h)];p.add(h);let w=h;for(;;){let S=(d.get(w)??[]).find(k=>!p.has(k));if(S===void 0)break;p.add(S),g.push(l.get(S)),w=S}return g};for(let[h,g]of d)g.length===1&&!p.has(h)&&_.push(M(h));for(let h of d.keys()){if(p.has(h))continue;let g=M(h);g.push(g[0]),_.push(g)}return _.filter(h=>h.length>1)}var At=["axes2d","numberLine","polarPlane"],xr=[...At,"functionPlot"];var v=function(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i},gr=Math.PI*2,b=class extends D{constructor(t){super(t??{})}morphTo(t){return this.to({data:T(t.data),duration:t.duration,easing:t.easing})}paramsTo(t){return this.to({data:T(t.data),duration:t.duration,easing:t.easing})}domainTo(t){return this.to({data:T(t.data),duration:t.duration,easing:t.easing})}valueAt(t){let{source:n,blend:r}=this.expression,o=this.shift(),i=this._heightOf(n,t-o.x)+o.y;if(!r)return i;let s=this._heightOf(r.from,t-o.x)+o.y;return s+(i-s)*r.t}span(){return this.domain}trace(t){let{area:n}=t;if(!Number.isFinite(n.maxX-n.minX))return[];let{source:r,blend:o}=this.expression,i=this.shift(),s=[r,o?.from,o?.t,t.revision,this.span(),JSON.stringify(this.params),i.x,i.y].join("|");if(s===this._key)return this._runs;this._key=s;let a=o&&o.t<.5?o.from:r;if(this._equation(r)?.kind==="implicit"||o&&this._equation(o.from)?.kind==="implicit")return this._runs=this._contour(a,t,i),this._runs;let u=this._curve(r,t,i);if(u&&o){let f=this._curve(o.from,t,i);f&&(u=wr(f,u,o.t))}let c=n.maxX-n.minX;return this._runs=u?Vt(u,0,1,n,{seeds:Math.min(512,Math.max(64,Math.round(c/8))),minStep:.5/Math.max(1,c)}):[],this._runs}_key="";_runs=[];_equation(t){let n=gt(t,L(t));return n instanceof Error?null:n}_heightOf(t,n){let r=this._equation(t);return r?.kind!=="function"||r.of!=="x"?NaN:r.f(n,0,U(L(t),this.params))}_contour(t,n,r){let o=this._equation(t);if(o?.kind!=="implicit")return[];let i=U(L(t),this.params),{area:s}=n,a=f=>Math.min(_r,Math.max(8,Math.round(f/Mr))),{f:u}=o;return nn((f,l)=>u(f-r.x,l-r.y,i),n.xRange,n.yRange,a(s.maxX-s.minX),a(s.maxY-s.minY)).map(f=>f.map(l=>n.toPoint(l.x,l.y)))}_curve(t,n,r){let o=this._equation(t);if(!o||o.kind==="implicit")return null;let i=U(L(t),this.params),s=this.span();switch(o.kind){case"function":{let a=o.of==="x",[u,c]=a?n.xRange:n.yRange,f=a?r.x:r.y,l=Math.max(u-f,s?.[0]??-1/0),x=Math.min(c-f,s?.[1]??1/0);if(!(x>l))return null;let{f:y}=o;return(d,m)=>{let _=l+(x-l)*d,p=y(_,0,i);return Number.isFinite(p)?(a?n.toPoint(_+r.x,p+r.y,m):n.toPoint(p+r.x,_+r.y,m),!0):!1}}case"polar":{let[a,u]=s??[0,gr],{f:c}=o;return(f,l)=>{let x=a+(u-a)*f,y=c(x,0,i);return Number.isFinite(y)?(n.toPoint(y*Math.cos(x)+r.x,y*Math.sin(x)+r.y,l),!0):!1}}case"parametric":{let[a,u]=s??[0,1],{x:c,y:f}=o;return(l,x)=>{let y=a+(u-a)*l,d=c(y,0,i),m=f(y,0,i);return!Number.isFinite(d)||!Number.isFinite(m)?!1:(n.toPoint(d+r.x,m+r.y,x),!0)}}}}};v([rn({default:"",mapper:rt,tween:ot,kind:"equation"})],b.prototype,"expression",void 0);v([rn({default:null,tween:Bt,kind:"range",defaultMin:-5,defaultMax:5})],b.prototype,"domain",void 0);v([rn({default:{},tween:it})],b.prototype,"params",void 0);v([mr({default:{weight:3,fill:Rt,align:"center",cap:"round",join:"round"}})],b.prototype,"stroke",void 0);v([en({args:["expression"]})],b.prototype,"morphTo",null);v([en({args:["params"]})],b.prototype,"paramsTo",null);v([en({args:["domain"]})],b.prototype,"domainTo",null);b=v([dr({key:"functionPlot",within:At,closed:!0,parentKey:"shape",forkable:!0,layout:{children:"freeform",defaultWidthMode:"hug",defaultHeightMode:"hug",acceptsChildren:!0},seed:{expression:"sin(x)"}}),yr(...X)],b);var Mr=5,_r=220;function wr(e,t,n){let r={x:0,y:0};return(o,i)=>!e(o,r)||!t(o,i)?!1:(i.x=r.x+(i.x-r.x)*n,i.y=r.y+(i.y-r.y)*n,!0)}import{command as Un,Graphics2D as kr,property as Ot,withdraw as Or}from"@motionscript/sdk";import{colorOps as on,fillOps as sn}from"@motionscript/sdk";function Er(e){return(e??[]).map(t=>on.resolve(t))}function Sr(e,t,n){return e.length!==t.length?n<1?e:t:t.map((r,o)=>on.lerp(e[o],r,n))}function Ar(e,t){if(e.length===1)return e[0];let n=Y(t,0,1)*(e.length-1),r=Math.min(e.length-2,Math.floor(n));return on.lerp(e[r],e[r+1],n-r)}function an(e){return(Array.isArray(e)?e:[]).map(t=>sn.resolve(t??[]))}function cn(e,t,n){return e.length!==t.length?n<1?e:t:t.map((r,o)=>sn.lerp(e[o],r,n))}function un(e,t){if(e.length===1)return e[0];let n=Y(t,0,1)*(e.length-1),r=Math.min(e.length-2,Math.floor(n));return sn.lerp(e[r],e[r+1],n-r)}var B=function(e,t,n,r){var o=arguments.length,i=o<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(i=(o<3?s(i):o>3?s(t,n,i):s(t,n))||i);return o>3&&i&&Object.defineProperty(t,n,i),i},kt=12,C=class extends D{morphTo(t){return this.to({data:T(t.data),duration:t.duration,easing:t.easing})}paramsTo(t){return this.to({data:T(t.data),duration:t.duration,easing:t.easing})}trace(t){let{area:n}=t;if(!Number.isFinite(n.maxX-n.minX))return[];let{source:r,blend:o}=this.expression,i=this.shift(),s=[r,o?.from,o?.t,t.revision,JSON.stringify(this.params),i.x,i.y,this.own()].join("|");if(s!==this._key){this._key=s;let a=this._sampler(i);this._drawn=a?this.strokes(t,a):[],this._runs=this._drawn.flatMap(u=>u.runs)}return this._runs}renderInk(t){let n=this.strengthFills,r=this.stroke,o=n.length>0&&r.length>0?K(this._runs):null;if(!o){super.renderInk(t);return}let i=this.maxMagnitude>0?this.maxMagnitude:this._drawn.reduce((a,u)=>Math.max(a,u.magnitude),0),s=Array.from({length:kt},()=>[]);for(let a of this._drawn){let u=i>0?Math.min(1,a.magnitude/i):0;s[Math.min(kt-1,Math.floor(u*kt))].push(...a.runs)}s.forEach((a,u)=>{if(a.length===0)return;let c=un(n,(u+.5)/kt);t.draw(new kr().path({data:J(a),centerBounds:[o.minX,o.minY,o.maxX,o.maxY],start:this.start,end:this.end}).shadow(this.shadow).stroke(r.map(f=>({...f,fill:c}))))})}_key="";_drawn=[];_runs=[];_sampler(t){let{source:n,blend:r}=this.expression,o=this._field(n,t);if(!o||!r)return o;let i=this._field(r.from,t);if(!i)return o;let s={x:0,y:0};return(a,u,c)=>!i(a,u,s)||!o(a,u,c)?!1:(c.x=s.x+(c.x-s.x)*r.t,c.y=s.y+(c.y-s.y)*r.t,!0)}_field(t,n){let r=H(t),o=Et(t,r);if(o instanceof Error)return null;let i=U(r,this.params),{x:s,y:a}=o;return(u,c,f)=>{let l=s(u-n.x,c-n.y,i),x=a(u-n.x,c-n.y,i);return f.x=l,f.y=x,Number.isFinite(l)&&Number.isFinite(x)}}};B([Ot({default:"",mapper:rt,tween:ot,kind:"fieldEquation"})],C.prototype,"expression",void 0);B([Ot({default:{},tween:it})],C.prototype,"params",void 0);B([Ot({default:[],mapper:an,tween:cn,kind:"vector"})],C.prototype,"strengthFills",void 0);B([Ot({default:0,min:0,step:.1})],C.prototype,"maxMagnitude",void 0);B([Un({args:["expression"]})],C.prototype,"morphTo",null);B([Un({args:["params"]})],C.prototype,"paramsTo",null);C=B([Or(...X,...Lt)],C);var Pr=.5523;function Ir(e,t,n,r){let{unit:o,length:i}=at(e,t);if(i===0)return[];let s=Math.min(r/2,i/4),a=Wt(e,t),u=(p,M)=>I(p,n,M*s),c=(p,M)=>I(p,o,M*s),f=Pr,l=(p,M,h)=>({type:"C",x1:p.x,y1:p.y,x2:M.x,y2:M.y,x:h.x,y:h.y}),x=u(c(e,1),1),y=u(c(a,-1),1),d=u(a,2),m=u(c(a,1),1),_=u(c(t,-1),1);return[{type:"M",x:e.x,y:e.y},l(u(e,f),u(c(e,1-f),1),x),{type:"L",x:y.x,y:y.y},l(u(c(a,-1+f),1),u(a,2-f),d),l(u(a,2-f),u(c(a,1-f),1),m),{type:"L",x:_.x,y:_.y},l(u(c(t,-1+f),1),u(t,f),t)]}var Tr=["circular","spring","tree","grid"];function br(e,t,n,r){let o=t.length;if(o===0)return new Map;if(o===1)return new Map([[t[0],{x:0,y:0}]]);switch(e){case"grid":return Nr(t);case"tree":return zn(Cr(t,n,r));case"spring":return zn(Fr(t,n));default:return Bn(t)}}function Bn(e){let t=e.length;return new Map(e.map((n,r)=>{let o=Math.PI/2-2*Math.PI*r/t;return[n,{x:Math.cos(o),y:Math.sin(o)}]}))}function Nr(e){let t=Math.ceil(Math.sqrt(e.length)),n=Math.ceil(e.length/t),r=(o,i)=>i===1?0:-1+2*o/(i-1);return new Map(e.map((o,i)=>[o,{x:r(i%t,t),y:-r(Math.floor(i/t),n)}]))}function Lr(e,t){let n=new Map(e.map(r=>[r,[]]));for(let{from:r,to:o}of t)r===o||!n.has(r)||!n.has(o)||(n.get(r).push(o),n.get(o).push(r));return n}function Cr(e,t,n){let r=Lr(e,t),o=new Map,i=0,s=(c,f,l)=>{l.add(c);let x=r.get(c).filter(m=>!l.has(m));for(let m of x)l.add(m);if(x.length===0)return o.set(c,{x:i++,y:-f}),o.get(c).x;let y=x.map(m=>s(m,f+1,l)),d=(y[0]+y[y.length-1])/2;return o.set(c,{x:d,y:-f}),d},a=new Set,u=r.has(n)?n:e[0];for(let c of[u,...e])a.has(c)||s(c,0,a);return o}function Fr(e,t){let n=e.length,r=new Map(e.map((f,l)=>[f,l])),o=Bn(e),i=e.map(f=>o.get(f).x),s=e.map(f=>o.get(f).y),a=t.flatMap(({from:f,to:l})=>{let x=r.get(f),y=r.get(l);return x===void 0||y===void 0||x===y?[]:[[x,y]]}),u=Math.sqrt(4/n),c=160;for(let f=0;f<c;f++){let l=new Float64Array(n),x=new Float64Array(n);for(let d=0;d<n;d++)for(let m=d+1;m<n;m++){let _=i[d]-i[m],p=s[d]-s[m],M=Math.hypot(_,p);M<1e-6&&([_,p,M]=[.001*(d-m),.001,.001]);let h=u*u/M;l[d]+=_/M*h,x[d]+=p/M*h,l[m]-=_/M*h,x[m]-=p/M*h}for(let[d,m]of a){let _=i[d]-i[m],p=s[d]-s[m],M=Math.max(Math.hypot(_,p),1e-6),h=M*M/u;l[d]-=_/M*h,x[d]-=p/M*h,l[m]+=_/M*h,x[m]+=p/M*h}let y=.12*(1-f/c);for(let d=0;d<n;d++){let m=Math.hypot(l[d],x[d]);m>0&&(i[d]+=l[d]/m*Math.min(m,y),s[d]+=x[d]/m*Math.min(m,y))}}return new Map(e.map((f,l)=>[f,{x:i[l],y:s[l]}]))}function zn(e){let t=1/0,n=1/0,r=-1/0,o=-1/0;for(let s of e.values())t=Math.min(t,s.x),r=Math.max(r,s.x),n=Math.min(n,s.y),o=Math.max(o,s.y);let i=(s,a,u)=>u-a<1e-9?0:-1+2*(s-a)/(u-a);return new Map([...e].map(([s,a])=>[s,{x:i(a.x,t,r),y:i(a.y,n,o)}]))}export{ut as a,Ct as b,Ft as c,ft as d,dn as e,re as f,oe as g,ie as h,ae as i,ce as j,lt as k,J as l,K as m,fe as n,Y as o,T as p,V as q,W as r,Q as s,pt as t,ht as u,xt as v,Rt as w,Xt as x,_n as y,Yt as z,Dt as A,qt as B,dt as C,mt as D,E,tt as F,Pe as G,kn as H,q as I,yt as J,gt as K,zt as L,L as M,ct as N,H as O,Et as P,Qt as Q,rt as R,ot as S,Bt as T,$t as U,it as V,U as W,Ne as X,nn as Y,D as Z,Vt as _,At as $,xr as aa,b as ba,bn as ca,qe as da,Cn as ea,_t as fa,F as ga,I as ha,Wt as ia,at as ja,Je as ka,Ir as la,hr as ma,ir as na,sr as oa,ar as pa,z as qa,Jt as ra,Kt as sa,vn as ta,Rn as ua,Xn as va,Yn as wa,rr as xa,Er as ya,Sr as za,Ar as Aa,an as Ba,cn as Ca,un as Da,C as Ea,Tr as Fa,br as Ga};
2
- //# sourceMappingURL=chunk-3GJB6AVO.js.map