@motionscript/core 0.1.0-alpha.6 → 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 (445) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +2 -4
  3. package/dist/assets/errors.js +4 -5
  4. package/dist/assets/errors.js.map +1 -1
  5. package/dist/assets/scope.d.ts +1 -1
  6. package/dist/assets/scope.d.ts.map +1 -1
  7. package/dist/assets/scope.js +1 -1
  8. package/dist/assets/scope.js.map +1 -1
  9. package/dist/attributes/audio/schedule.d.ts +3 -18
  10. package/dist/attributes/audio/schedule.d.ts.map +1 -1
  11. package/dist/attributes/audio/schedule.js.map +1 -1
  12. package/dist/attributes/index.d.ts +3 -5
  13. package/dist/attributes/index.d.ts.map +1 -1
  14. package/dist/attributes/index.js +2 -2
  15. package/dist/attributes/index.js.map +1 -1
  16. package/dist/attributes/layout/insets.d.ts +1 -1
  17. package/dist/attributes/layout/insets.js.map +1 -1
  18. package/dist/attributes/layout/size.d.ts +1 -1
  19. package/dist/attributes/layout/size.js +1 -1
  20. package/dist/attributes/layout/size.js.map +1 -1
  21. package/dist/attributes/properties/decorator.d.ts +44 -11
  22. package/dist/attributes/properties/decorator.d.ts.map +1 -1
  23. package/dist/attributes/properties/decorator.js +37 -9
  24. package/dist/attributes/properties/decorator.js.map +1 -1
  25. package/dist/attributes/properties/inputs.d.ts +1 -1
  26. package/dist/attributes/properties/inputs.js +1 -1
  27. package/dist/attributes/properties/inputs.js.map +1 -1
  28. package/dist/attributes/properties/typed.d.ts +19 -140
  29. package/dist/attributes/properties/typed.d.ts.map +1 -1
  30. package/dist/attributes/properties/typed.js +12 -108
  31. package/dist/attributes/properties/typed.js.map +1 -1
  32. package/dist/attributes/shape/corners/corner-radius.d.ts +1 -1
  33. package/dist/attributes/shape/corners/corner-radius.js +1 -1
  34. package/dist/attributes/shape/corners/corner-radius.js.map +1 -1
  35. package/dist/attributes/shape/effects/implementations/drop-shadow.d.ts +1 -1
  36. package/dist/attributes/shape/effects/implementations/drop-shadow.js.map +1 -1
  37. package/dist/attributes/shape/fill/color/parser.d.ts +1 -1
  38. package/dist/attributes/shape/fill/color/parser.js +1 -1
  39. package/dist/attributes/shape/fill/color/parser.js.map +1 -1
  40. package/dist/attributes/shape/fill/implementations/canvas3d.d.ts +2 -2
  41. package/dist/attributes/shape/fill/implementations/canvas3d.js.map +1 -1
  42. package/dist/attributes/shape/fill/implementations/shader.d.ts +2 -2
  43. package/dist/attributes/shape/fill/implementations/shader.js.map +1 -1
  44. package/dist/attributes/shape/fill/implementations/video.d.ts +1 -1
  45. package/dist/attributes/shape/fill/implementations/video.js +1 -1
  46. package/dist/attributes/shape/fill/implementations/video.js.map +1 -1
  47. package/dist/attributes/shape/fill/lerp.d.ts +1 -1
  48. package/dist/attributes/shape/fill/lerp.js.map +1 -1
  49. package/dist/attributes/shape/filters/chain.d.ts +1 -1
  50. package/dist/attributes/shape/filters/chain.js +1 -1
  51. package/dist/attributes/shape/filters/chain.js.map +1 -1
  52. package/dist/attributes/shape/filters/union.d.ts +4 -3
  53. package/dist/attributes/shape/filters/union.d.ts.map +1 -1
  54. package/dist/attributes/shape/filters/union.js.map +1 -1
  55. package/dist/attributes/shape/path/ops.d.ts +1 -2
  56. package/dist/attributes/shape/path/ops.d.ts.map +1 -1
  57. package/dist/attributes/shape/path/ops.js.map +1 -1
  58. package/dist/attributes/shared/operators.d.ts +2 -2
  59. package/dist/attributes/shared/operators.js.map +1 -1
  60. package/dist/attributes/text/types.d.ts +2 -3
  61. package/dist/attributes/text/types.d.ts.map +1 -1
  62. package/dist/attributes/text/types.js.map +1 -1
  63. package/dist/browser/chunks/chunk-D4FSTPML.js +14 -0
  64. package/dist/browser/chunks/chunk-D4FSTPML.js.map +7 -0
  65. package/dist/browser/chunks/chunk-LKUYVFU3.js +2 -0
  66. package/dist/browser/chunks/{chunk-DHB4COFY.js.map → chunk-LKUYVFU3.js.map} +4 -4
  67. package/dist/browser/chunks/chunk-RTNATFWX.js +5 -0
  68. package/dist/browser/chunks/chunk-RTNATFWX.js.map +7 -0
  69. package/dist/browser/chunks/chunk-ZRPZPWZU.js +3 -0
  70. package/dist/browser/chunks/chunk-ZRPZPWZU.js.map +7 -0
  71. package/dist/browser/component.js +1 -1
  72. package/dist/browser/component.js.map +4 -4
  73. package/dist/browser/experimental.js +1 -1
  74. package/dist/browser/index.js +1 -1
  75. package/dist/browser/index.js.map +4 -4
  76. package/dist/browser/manifest.json +2 -4
  77. package/dist/browser/sdk.js +1 -1
  78. package/dist/component.d.ts +10 -18
  79. package/dist/component.d.ts.map +1 -1
  80. package/dist/component.js +10 -17
  81. package/dist/component.js.map +1 -1
  82. package/dist/components/builtins/audio/audio.d.ts +53 -0
  83. package/dist/components/builtins/audio/audio.d.ts.map +1 -0
  84. package/dist/components/builtins/audio/audio.js +41 -0
  85. package/dist/components/builtins/audio/audio.js.map +1 -0
  86. package/dist/components/builtins/geometry/composite.d.ts +93 -0
  87. package/dist/components/builtins/geometry/composite.d.ts.map +1 -0
  88. package/dist/components/builtins/geometry/composite.js +25 -0
  89. package/dist/components/builtins/geometry/composite.js.map +1 -0
  90. package/dist/components/builtins/geometry/geometry.d.ts +921 -0
  91. package/dist/components/builtins/geometry/geometry.d.ts.map +1 -0
  92. package/dist/components/builtins/geometry/geometry.js +107 -0
  93. package/dist/components/builtins/geometry/geometry.js.map +1 -0
  94. package/dist/components/builtins/geometry/shape-outline.d.ts +93 -0
  95. package/dist/components/builtins/geometry/shape-outline.d.ts.map +1 -0
  96. package/dist/components/builtins/geometry/shape-outline.js +470 -0
  97. package/dist/components/builtins/geometry/shape-outline.js.map +1 -0
  98. package/dist/components/builtins/layout/layout.d.ts +186 -0
  99. package/dist/components/builtins/layout/layout.d.ts.map +1 -0
  100. package/dist/components/builtins/layout/layout.js +84 -0
  101. package/dist/components/builtins/layout/layout.js.map +1 -0
  102. package/dist/components/builtins/media/media.d.ts +240 -0
  103. package/dist/components/builtins/media/media.d.ts.map +1 -0
  104. package/dist/components/builtins/media/media.js +149 -0
  105. package/dist/components/builtins/media/media.js.map +1 -0
  106. package/dist/components/builtins/providers/providers.d.ts +47 -0
  107. package/dist/components/builtins/providers/providers.d.ts.map +1 -0
  108. package/dist/components/builtins/providers/providers.js +30 -0
  109. package/dist/components/builtins/providers/providers.js.map +1 -0
  110. package/dist/components/builtins/text/number-format.d.ts +66 -0
  111. package/dist/components/builtins/text/number-format.d.ts.map +1 -0
  112. package/dist/components/builtins/text/number-format.js +227 -0
  113. package/dist/components/builtins/text/number-format.js.map +1 -0
  114. package/dist/components/builtins/text/number-pattern.d.ts +51 -0
  115. package/dist/components/builtins/text/number-pattern.d.ts.map +1 -0
  116. package/dist/components/builtins/text/number-pattern.js +77 -0
  117. package/dist/components/builtins/text/number-pattern.js.map +1 -0
  118. package/dist/components/builtins/text/text-defaults.d.ts +32 -0
  119. package/dist/components/builtins/text/text-defaults.d.ts.map +1 -0
  120. package/dist/components/builtins/text/text-defaults.js +37 -0
  121. package/dist/components/builtins/text/text-defaults.js.map +1 -0
  122. package/dist/components/builtins/text/text-layout.d.ts +82 -0
  123. package/dist/components/builtins/text/text-layout.d.ts.map +1 -0
  124. package/dist/components/builtins/text/text-layout.js +331 -0
  125. package/dist/components/builtins/text/text-layout.js.map +1 -0
  126. package/dist/components/builtins/text/text.d.ts +409 -0
  127. package/dist/components/builtins/text/text.d.ts.map +1 -0
  128. package/dist/components/builtins/text/text.js +113 -0
  129. package/dist/components/builtins/text/text.js.map +1 -0
  130. package/dist/components/builtins/three/canvas3d.d.ts +245 -0
  131. package/dist/components/builtins/three/canvas3d.d.ts.map +1 -0
  132. package/dist/components/builtins/three/canvas3d.js +21 -0
  133. package/dist/components/builtins/three/canvas3d.js.map +1 -0
  134. package/dist/components/builtins/three/grid-geometry3d.d.ts +62 -0
  135. package/dist/components/builtins/three/grid-geometry3d.d.ts.map +1 -0
  136. package/dist/components/builtins/three/grid-geometry3d.js +114 -0
  137. package/dist/components/builtins/three/grid-geometry3d.js.map +1 -0
  138. package/dist/components/builtins/three/three.d.ts +1889 -0
  139. package/dist/components/builtins/three/three.d.ts.map +1 -0
  140. package/dist/components/builtins/three/three.js +305 -0
  141. package/dist/components/builtins/three/three.js.map +1 -0
  142. package/dist/components/factory/api.d.ts +516 -0
  143. package/dist/components/factory/api.d.ts.map +1 -0
  144. package/dist/components/factory/api.js +4 -0
  145. package/dist/components/factory/api.js.map +1 -0
  146. package/dist/components/factory/clip-of.d.ts +5 -0
  147. package/dist/components/factory/clip-of.d.ts.map +1 -0
  148. package/dist/components/factory/clip-of.js +33 -0
  149. package/dist/components/factory/clip-of.js.map +1 -0
  150. package/dist/components/factory/commands-for.d.ts +19 -0
  151. package/dist/components/factory/commands-for.d.ts.map +1 -0
  152. package/dist/components/factory/commands-for.js +5 -0
  153. package/dist/components/factory/commands-for.js.map +1 -0
  154. package/dist/components/factory/component-audio.d.ts +9 -0
  155. package/dist/components/factory/component-audio.d.ts.map +1 -0
  156. package/dist/components/factory/component-audio.js +18 -0
  157. package/dist/components/factory/component-audio.js.map +1 -0
  158. package/dist/components/factory/component2d.d.ts +8 -0
  159. package/dist/components/factory/component2d.d.ts.map +1 -0
  160. package/dist/components/factory/component2d.js +240 -0
  161. package/dist/components/factory/component2d.js.map +1 -0
  162. package/dist/components/factory/component3d.d.ts +9 -0
  163. package/dist/components/factory/component3d.d.ts.map +1 -0
  164. package/dist/components/factory/component3d.js +99 -0
  165. package/dist/components/factory/component3d.js.map +1 -0
  166. package/dist/components/factory/factory.d.ts +63 -0
  167. package/dist/components/factory/factory.d.ts.map +1 -0
  168. package/dist/components/factory/factory.js +313 -0
  169. package/dist/components/factory/factory.js.map +1 -0
  170. package/dist/components/factory/timeline.d.ts +22 -0
  171. package/dist/components/factory/timeline.d.ts.map +1 -0
  172. package/dist/components/factory/timeline.js +128 -0
  173. package/dist/components/factory/timeline.js.map +1 -0
  174. package/dist/components/factory/type-def.d.ts +26 -0
  175. package/dist/components/factory/type-def.d.ts.map +1 -0
  176. package/dist/components/factory/type-def.js +16 -0
  177. package/dist/components/factory/type-def.js.map +1 -0
  178. package/dist/components/factory/types.d.ts +91 -0
  179. package/dist/components/factory/types.d.ts.map +1 -0
  180. package/dist/components/factory/types.js +88 -0
  181. package/dist/components/factory/types.js.map +1 -0
  182. package/dist/components/factory/views.d.ts +121 -0
  183. package/dist/components/factory/views.d.ts.map +1 -0
  184. package/dist/components/factory/views.js +413 -0
  185. package/dist/components/factory/views.js.map +1 -0
  186. package/dist/components/modules/aim.d.ts +30 -0
  187. package/dist/components/modules/aim.d.ts.map +1 -0
  188. package/dist/components/modules/aim.js +39 -0
  189. package/dist/components/modules/aim.js.map +1 -0
  190. package/dist/components/modules/corners.d.ts +13 -0
  191. package/dist/components/modules/corners.d.ts.map +1 -0
  192. package/dist/components/modules/corners.js +12 -0
  193. package/dist/components/modules/corners.js.map +1 -0
  194. package/dist/components/modules/flow.d.ts +26 -0
  195. package/dist/components/modules/flow.d.ts.map +1 -0
  196. package/dist/components/modules/flow.js +57 -0
  197. package/dist/components/modules/flow.js.map +1 -0
  198. package/dist/components/modules/material.d.ts +40 -0
  199. package/dist/components/modules/material.d.ts.map +1 -0
  200. package/dist/components/modules/material.js +75 -0
  201. package/dist/components/modules/material.js.map +1 -0
  202. package/dist/components/modules/paint.d.ts +71 -0
  203. package/dist/components/modules/paint.d.ts.map +1 -0
  204. package/dist/components/modules/paint.js +106 -0
  205. package/dist/components/modules/paint.js.map +1 -0
  206. package/dist/components/modules/shapes.d.ts +31 -0
  207. package/dist/components/modules/shapes.d.ts.map +1 -0
  208. package/dist/components/modules/shapes.js +43 -0
  209. package/dist/components/modules/shapes.js.map +1 -0
  210. package/dist/components/modules/text-layout.d.ts +26 -0
  211. package/dist/components/modules/text-layout.d.ts.map +1 -0
  212. package/dist/components/modules/text-layout.js +57 -0
  213. package/dist/components/modules/text-layout.js.map +1 -0
  214. package/dist/components/modules/text-style.d.ts +48 -0
  215. package/dist/components/modules/text-style.d.ts.map +1 -0
  216. package/dist/components/modules/text-style.js +63 -0
  217. package/dist/components/modules/text-style.js.map +1 -0
  218. package/dist/components/modules/three-entries.d.ts +23 -0
  219. package/dist/components/modules/three-entries.d.ts.map +1 -0
  220. package/dist/components/modules/three-entries.js +41 -0
  221. package/dist/components/modules/three-entries.js.map +1 -0
  222. package/dist/components/modules/view3d.d.ts +59 -0
  223. package/dist/components/modules/view3d.d.ts.map +1 -0
  224. package/dist/components/modules/view3d.js +171 -0
  225. package/dist/components/modules/view3d.js.map +1 -0
  226. package/dist/components/trees/2d/group-bounds.d.ts +56 -0
  227. package/dist/components/trees/2d/group-bounds.d.ts.map +1 -0
  228. package/dist/components/trees/2d/group-bounds.js +87 -0
  229. package/dist/components/trees/2d/group-bounds.js.map +1 -0
  230. package/dist/components/trees/2d/node-lifecycle.d.ts +46 -0
  231. package/dist/components/trees/2d/node-lifecycle.d.ts.map +1 -0
  232. package/dist/components/trees/2d/node-lifecycle.js +264 -0
  233. package/dist/components/trees/2d/node-lifecycle.js.map +1 -0
  234. package/dist/components/trees/2d/node-motion.d.ts +56 -0
  235. package/dist/components/trees/2d/node-motion.d.ts.map +1 -0
  236. package/dist/components/trees/2d/node-motion.js +86 -0
  237. package/dist/components/trees/2d/node-motion.js.map +1 -0
  238. package/dist/components/trees/2d/node-render.d.ts +36 -0
  239. package/dist/components/trees/2d/node-render.d.ts.map +1 -0
  240. package/dist/components/trees/2d/node-render.js +67 -0
  241. package/dist/components/trees/2d/node-render.js.map +1 -0
  242. package/dist/components/trees/2d/node-space.d.ts +63 -0
  243. package/dist/components/trees/2d/node-space.d.ts.map +1 -0
  244. package/dist/components/trees/2d/node-space.js +131 -0
  245. package/dist/components/trees/2d/node-space.js.map +1 -0
  246. package/dist/components/trees/2d/node-transform.d.ts +55 -0
  247. package/dist/components/trees/2d/node-transform.d.ts.map +1 -0
  248. package/dist/components/trees/2d/node-transform.js +73 -0
  249. package/dist/components/trees/2d/node-transform.js.map +1 -0
  250. package/dist/components/trees/2d/node2d.d.ts +1020 -0
  251. package/dist/components/trees/2d/node2d.d.ts.map +1 -0
  252. package/dist/components/trees/2d/node2d.js +1481 -0
  253. package/dist/components/trees/2d/node2d.js.map +1 -0
  254. package/dist/components/trees/audio/index.d.ts +2 -0
  255. package/dist/components/trees/audio/index.d.ts.map +1 -0
  256. package/dist/components/trees/audio/index.js +2 -0
  257. package/dist/components/trees/audio/index.js.map +1 -0
  258. package/dist/components/trees/audio/node-audio.d.ts +109 -0
  259. package/dist/components/trees/audio/node-audio.d.ts.map +1 -0
  260. package/dist/components/trees/audio/node-audio.js +167 -0
  261. package/dist/components/trees/audio/node-audio.js.map +1 -0
  262. package/dist/components/trees/index.d.ts +10 -0
  263. package/dist/components/trees/index.d.ts.map +1 -0
  264. package/dist/components/trees/index.js +14 -0
  265. package/dist/components/trees/index.js.map +1 -0
  266. package/dist/components/trees/node/node-editor-state.d.ts +53 -0
  267. package/dist/components/trees/node/node-editor-state.d.ts.map +1 -0
  268. package/dist/components/trees/node/node-editor-state.js +23 -0
  269. package/dist/components/trees/node/node-editor-state.js.map +1 -0
  270. package/dist/components/trees/node/node-reactive.d.ts +89 -0
  271. package/dist/components/trees/node/node-reactive.d.ts.map +1 -0
  272. package/dist/components/trees/node/node-reactive.js +135 -0
  273. package/dist/components/trees/node/node-reactive.js.map +1 -0
  274. package/dist/components/trees/node/node-time.d.ts +39 -0
  275. package/dist/components/trees/node/node-time.d.ts.map +1 -0
  276. package/dist/components/trees/node/node-time.js +14 -0
  277. package/dist/components/trees/node/node-time.js.map +1 -0
  278. package/dist/components/trees/node/node-walk.d.ts +46 -0
  279. package/dist/components/trees/node/node-walk.d.ts.map +1 -0
  280. package/dist/components/trees/node/node-walk.js +74 -0
  281. package/dist/components/trees/node/node-walk.js.map +1 -0
  282. package/dist/components/trees/node/node.d.ts +401 -0
  283. package/dist/components/trees/node/node.d.ts.map +1 -0
  284. package/dist/components/trees/node/node.js +680 -0
  285. package/dist/components/trees/node/node.js.map +1 -0
  286. package/dist/components/trees/root/canvas2d-node.d.ts +163 -0
  287. package/dist/components/trees/root/canvas2d-node.d.ts.map +1 -0
  288. package/dist/components/trees/root/canvas2d-node.js +216 -0
  289. package/dist/components/trees/root/canvas2d-node.js.map +1 -0
  290. package/dist/components/trees/three/node3d.d.ts +222 -0
  291. package/dist/components/trees/three/node3d.d.ts.map +1 -0
  292. package/dist/components/trees/three/node3d.js +289 -0
  293. package/dist/components/trees/three/node3d.js.map +1 -0
  294. package/dist/document/builtins.js +13 -13
  295. package/dist/document/builtins.js.map +1 -1
  296. package/dist/document/command-traits.d.ts +2 -2
  297. package/dist/document/command-traits.js +1 -1
  298. package/dist/document/command-traits.js.map +1 -1
  299. package/dist/document/deny-globals.d.ts +2 -2
  300. package/dist/document/deny-globals.js +2 -2
  301. package/dist/document/deny-globals.js.map +1 -1
  302. package/dist/document/expression/index.d.ts +1 -1
  303. package/dist/document/expression/index.js +1 -1
  304. package/dist/document/expression/index.js.map +1 -1
  305. package/dist/document/expression/ops.js +1 -1
  306. package/dist/document/expression/ops.js.map +1 -1
  307. package/dist/document/index.d.ts +1 -2
  308. package/dist/document/index.d.ts.map +1 -1
  309. package/dist/document/index.js +1 -2
  310. package/dist/document/index.js.map +1 -1
  311. package/dist/document/node-decorator.d.ts +14 -10
  312. package/dist/document/node-decorator.d.ts.map +1 -1
  313. package/dist/document/node-decorator.js +14 -10
  314. package/dist/document/node-decorator.js.map +1 -1
  315. package/dist/document/node-descriptor.d.ts +3 -3
  316. package/dist/document/node-descriptor.d.ts.map +1 -1
  317. package/dist/document/node-descriptor.js.map +1 -1
  318. package/dist/document/registry.d.ts +23 -25
  319. package/dist/document/registry.d.ts.map +1 -1
  320. package/dist/document/registry.js +12 -18
  321. package/dist/document/registry.js.map +1 -1
  322. package/dist/document/timeline.d.ts +3 -3
  323. package/dist/document/timeline.d.ts.map +1 -1
  324. package/dist/document/timeline.js +2 -2
  325. package/dist/document/timeline.js.map +1 -1
  326. package/dist/document/types.d.ts +4 -4
  327. package/dist/document/types.js.map +1 -1
  328. package/dist/document/validate.d.ts +1 -1
  329. package/dist/document/validate.js.map +1 -1
  330. package/dist/experimental.d.ts +19 -19
  331. package/dist/experimental.d.ts.map +1 -1
  332. package/dist/experimental.js +17 -17
  333. package/dist/experimental.js.map +1 -1
  334. package/dist/index.d.ts +10 -11
  335. package/dist/index.d.ts.map +1 -1
  336. package/dist/index.js +10 -11
  337. package/dist/index.js.map +1 -1
  338. package/dist/layout/types.d.ts +1 -1
  339. package/dist/layout/types.js.map +1 -1
  340. package/dist/props/host.d.ts +1 -1
  341. package/dist/props/host.js.map +1 -1
  342. package/dist/props/slot.d.ts +1 -1
  343. package/dist/props/slot.js +1 -1
  344. package/dist/props/slot.js.map +1 -1
  345. package/dist/render/clip.d.ts +1 -1
  346. package/dist/render/clip.js +1 -1
  347. package/dist/render/clip.js.map +1 -1
  348. package/dist/render/descriptors/rect.js.map +1 -1
  349. package/dist/render/descriptors/text.d.ts +11 -5
  350. package/dist/render/descriptors/text.d.ts.map +1 -1
  351. package/dist/render/descriptors/text.js +7 -1
  352. package/dist/render/descriptors/text.js.map +1 -1
  353. package/dist/render/render-context2d.d.ts +2 -2
  354. package/dist/render/render-context2d.js.map +1 -1
  355. package/dist/render3d/builders.d.ts +1 -1
  356. package/dist/render3d/builders.js +1 -1
  357. package/dist/render3d/builders.js.map +1 -1
  358. package/dist/render3d/graphics3d.d.ts +13 -19
  359. package/dist/render3d/graphics3d.d.ts.map +1 -1
  360. package/dist/render3d/graphics3d.js +13 -19
  361. package/dist/render3d/graphics3d.js.map +1 -1
  362. package/dist/render3d/scene3d.d.ts +1 -1
  363. package/dist/render3d/scene3d.js +1 -1
  364. package/dist/render3d/scene3d.js.map +1 -1
  365. package/dist/render3d/texture.d.ts +2 -2
  366. package/dist/render3d/texture.d.ts.map +1 -1
  367. package/dist/render3d/texture.js.map +1 -1
  368. package/dist/render3d/vector3.d.ts +2 -2
  369. package/dist/render3d/vector3.js +2 -2
  370. package/dist/render3d/vector3.js.map +1 -1
  371. package/dist/runtime/asset-refine.d.ts +1 -1
  372. package/dist/runtime/asset-refine.d.ts.map +1 -1
  373. package/dist/runtime/asset-refine.js +1 -1
  374. package/dist/runtime/asset-refine.js.map +1 -1
  375. package/dist/runtime/asset-update.js +1 -1
  376. package/dist/runtime/asset-update.js.map +1 -1
  377. package/dist/runtime/audio-index.d.ts +0 -11
  378. package/dist/runtime/audio-index.d.ts.map +1 -1
  379. package/dist/runtime/audio-index.js +0 -25
  380. package/dist/runtime/audio-index.js.map +1 -1
  381. package/dist/runtime/clip-instance.d.ts +3 -3
  382. package/dist/runtime/clip-instance.d.ts.map +1 -1
  383. package/dist/runtime/clip-instance.js +4 -4
  384. package/dist/runtime/clip-instance.js.map +1 -1
  385. package/dist/runtime/clip-store.d.ts +2 -3
  386. package/dist/runtime/clip-store.d.ts.map +1 -1
  387. package/dist/runtime/clip-store.js +17 -35
  388. package/dist/runtime/clip-store.js.map +1 -1
  389. package/dist/runtime/engine.d.ts +3 -3
  390. package/dist/runtime/engine.js +2 -2
  391. package/dist/runtime/engine.js.map +1 -1
  392. package/dist/runtime/node-picking.d.ts +2 -2
  393. package/dist/runtime/node-picking.d.ts.map +1 -1
  394. package/dist/runtime/node-picking.js +3 -3
  395. package/dist/runtime/node-picking.js.map +1 -1
  396. package/dist/runtime/node-picking3d.d.ts +2 -2
  397. package/dist/runtime/node-picking3d.d.ts.map +1 -1
  398. package/dist/runtime/node-picking3d.js +1 -1
  399. package/dist/runtime/node-picking3d.js.map +1 -1
  400. package/dist/runtime/playback-controller.d.ts +2 -2
  401. package/dist/runtime/playback-controller.d.ts.map +1 -1
  402. package/dist/runtime/playback-controller.js +1 -1
  403. package/dist/runtime/playback-controller.js.map +1 -1
  404. package/dist/runtime/state-evaluator.d.ts +2 -2
  405. package/dist/runtime/state-evaluator.d.ts.map +1 -1
  406. package/dist/runtime/state-evaluator.js.map +1 -1
  407. package/dist/runtime/text-geometry.d.ts +1 -1
  408. package/dist/runtime/text-geometry.d.ts.map +1 -1
  409. package/dist/runtime/text-geometry.js +4 -5
  410. package/dist/runtime/text-geometry.js.map +1 -1
  411. package/dist/sdk/index.d.ts +43 -39
  412. package/dist/sdk/index.d.ts.map +1 -1
  413. package/dist/sdk/index.js +24 -25
  414. package/dist/sdk/index.js.map +1 -1
  415. package/dist/tween/command-decorator.d.ts +7 -9
  416. package/dist/tween/command-decorator.d.ts.map +1 -1
  417. package/dist/tween/command-decorator.js +2 -2
  418. package/dist/tween/command-decorator.js.map +1 -1
  419. package/dist/tween/command.d.ts +1 -1
  420. package/dist/tween/command.js.map +1 -1
  421. package/dist/tween/index.d.ts +2 -1
  422. package/dist/tween/index.d.ts.map +1 -1
  423. package/dist/tween/index.js +1 -1
  424. package/dist/tween/index.js.map +1 -1
  425. package/dist/tween/loop.d.ts +1 -1
  426. package/dist/tween/loop.js +1 -1
  427. package/dist/tween/loop.js.map +1 -1
  428. package/dist/util/reference.d.ts +6 -6
  429. package/dist/util/reference.js.map +1 -1
  430. package/package.json +2 -10
  431. package/dist/browser/chunks/chunk-2RIYH36X.js +0 -3
  432. package/dist/browser/chunks/chunk-2RIYH36X.js.map +0 -7
  433. package/dist/browser/chunks/chunk-DDJN3QII.js +0 -15
  434. package/dist/browser/chunks/chunk-DDJN3QII.js.map +0 -7
  435. package/dist/browser/chunks/chunk-DHB4COFY.js +0 -2
  436. package/dist/browser/chunks/chunk-EJDPYDQI.js +0 -5
  437. package/dist/browser/chunks/chunk-EJDPYDQI.js.map +0 -7
  438. package/dist/browser/chunks/chunk-SFNJRPBV.js +0 -2
  439. package/dist/browser/chunks/chunk-SFNJRPBV.js.map +0 -7
  440. package/dist/browser/chunks/chunk-XAWE4EAK.js +0 -2
  441. package/dist/browser/chunks/chunk-XAWE4EAK.js.map +0 -7
  442. package/dist/browser/jsx-jsx-dev-runtime.js +0 -2
  443. package/dist/browser/jsx-jsx-dev-runtime.js.map +0 -7
  444. package/dist/browser/jsx-jsx-runtime.js +0 -2
  445. package/dist/browser/jsx-jsx-runtime.js.map +0 -7
@@ -0,0 +1,14 @@
1
+ import{$b as no,Ad as Ue,Ae as ge,B as Ks,Be as Vo,Cd as j,Ce as Wt,Da as $t,Db as at,Dd as K,De as Ko,Ea as qs,Eb as hr,Ed as z,Ee as Uo,Fb as Js,Fc as _r,Gd as vo,Ge as Go,Ha as rr,Hc as wr,Hd as $,He as Yo,Ia as be,Ic as ao,Id as N,Ie as qo,Jc as co,Jd as J,Je as Xo,Kc as uo,Kd as E,Lc as xr,Mc as jt,Md as bo,Nb as pr,Nc as lo,Nd as ko,Ob as Qs,Oc as Vt,Od as So,Pb as re,Pc as vr,Pd as Gt,Qb as eo,Qc as fo,Qd as Ao,Rb as ct,Rc as R,Rd as Mo,Sa as or,Sb as Ke,Sd as Ar,T as tr,Tb as Rt,Ua as it,Ub as Se,Uc as ut,Ud as To,Va as ir,Vb as De,Vc as br,Vd as Oo,Wb as pe,Wc as kr,Wd as Eo,Xa as Xs,Xb as zt,Xc as Sr,Ya as Ws,Yb as dt,Za as Hs,Zc as ho,_ as nr,_a as Zs,_b as to,_c as po,ad as Kt,ae as Mr,bd as Ut,be as Tr,ca as Us,ce as Or,da as Gs,dc as ro,de as Do,ea as ot,eb as Nt,ed as yo,ee as Io,f as Zn,fb as ar,fd as _o,fe as Fo,gb as ne,gc as Ie,ge as $o,hc as so,je as Er,kb as cr,ke as Cr,le as No,ma as Ys,me as lt,n as er,nb as Ve,nc as oo,ne as Ro,ob as ke,oe as Yt,pa as fe,pc as mr,pe as zo,qc as Lt,qe as Lo,rb as dr,re as Bo,sc as gr,tb as ur,tc as Ae,td as wo,te as Pr,ub as he,uc as Bt,ue as I,vb as B,vc as io,ve as x,wb as ce,wd as xo,we as qt,xb as lr,xc as Z,xd as O,xe as me,yc as yr,yd as k,ye as Xt,zb as fr,zd as Me,ze as jo}from"./chunk-RTNATFWX.js";import{b as Co,f as Po}from"./chunk-LKUYVFU3.js";import{b as Vs,d as Jn,f as Qn,h as je,m as sr,n as mo,o as go}from"./chunk-ZRPZPWZU.js";var Dr=["multiply","screen","overlay","darken","lighten","color-dodge","color-burn","hard-light","soft-light","difference","exclusion","hue","saturation","color","luminosity","normal"],td=[...Dr,"pass-through"],nd=Object.fromEntries(Dr.map((n,e)=>[n,e]));function rd(n){return nd[n]}function Ir(n){let e=1;for(let t of n)t.type==="speed"&&!Nt(t.value)&&t.value>0&&(e*=t.value);return e}function Ht(n,e){let t=Ir(n);for(let r of n)if(r.type==="speed"&&Nt(r.value))return cr(r.value,e)/t;return e/t}function Wo(n,e,t,r){let s=n.at??0,o=n.until??1/0,i=n.trimStart??0,a=n.trimEnd??1/0,c=n.loop??!1,d=ke(n.filters),u=e.getMediaDuration(n.src),l={id:`${t}|${n.src}|${s}|${r}`,src:n.src,startAt:s,endAt:1/0,trimStart:i,volume:n.volume??1,loop:c,ownerId:t};if(d.length>0&&(l.filters=d),n.bus&&(l.bus=n.bus),n.optional&&(l.optional=!0),c&&a>i&&Number.isFinite(a)&&(l.trimEnd=a),c&&Number.isFinite(o))l.endAt=o;else if(c)l.open=!0;else if(Number.isFinite(a))l.endAt=Math.min(o,s+Ht(d,Math.max(0,a-i)));else{let h=Ht(d,Math.max(0,u-i));Number.isFinite(o)?l.endAt=Math.min(o,s+h):(l.open=!0,l.mediaDuration=h)}return l}var Fr=class{src;volume;loop;trimStart;trimEnd;filters;constructor(e){this.src=e.src,this.volume=e.volume??1,this.loop=e.loop??!1,this.trimStart=e.trimStart??0,this.trimEnd=e.trimEnd??e.duration??1/0,this.filters=ke(e.filters)}effectiveSpeed(){return Ir(this.filters)}clipDurationFor(e){return Ht(this.filters,e)}sceneDurationFor(e){return this.clipDurationFor(e)}get clipDuration(){return this.trimEnd!==1/0?this.clipDurationFor(this.trimEnd-this.trimStart):void 0}};function ft(n){return!n||n.length===0?"":n.map(e=>{switch(e.type){case"gain":case"speed":return`${e.type}:${ne(e.value)}`;case"highpass":case"lowpass":return`${e.type}:${ne(e.frequency)}:${ne(e.q)}`;case"tremolo":return`tremolo:${ne(e.rate)}:${ne(e.depth)}`;case"echo":return`echo:${ne(e.delay)}:${ne(e.feedback)}:${ne(e.mix)}`}}).join("|")}function $r(n){return`${n.id}:${ne(n.volume)}:${ne(n.pan)}:${n.mute?1:0}:${ft(n.filters)}:${n.startAt}:${n.endAt}`}var od=new Set(["number","slider","angle","hue","boolean","color","vector","point"]);function Gp(n){return od.has(n.kind)}var Ho=64,Zo=64e3;function Jo(n){if(typeof n!="object"||n===null)throw new Error("A shader pack must be an object.");let e=n,t=e.scope;if(t!=="fill"&&t!=="effect")throw new Error(`A shader pack needs scope "fill" or "effect", got ${JSON.stringify(t)}. The two are written against different contracts \u2014 a fill has no backdrop to sample and an effect has no shape box to map coordinates onto.`);let r=typeof e.source=="string"?e.source.trim():"";if(r==="")throw new Error(`Shader pack "${String(e.name??"?")}" has no source.`);if(r.length>Zo)throw new Error(`Shader pack "${String(e.name??"?")}" source is ${r.length} characters, over the ${Zo} ceiling.`);let s={...typeof e.$kind=="string"?{$kind:e.$kind}:{},...typeof e.id=="string"?{id:e.id}:{},name:typeof e.name=="string"&&e.name!==""?e.name:"Shader",...typeof e.description=="string"?{description:e.description}:{},source:r,...Jt(e.uniforms)?{uniforms:e.uniforms}:{},properties:id(e.properties,String(e.name??"?"))};if(t==="fill"){let o=e.coords;return{...s,scope:"fill",...o==="normalized"||o==="centered"||o==="local"?{coords:o}:{}}}return{...s,scope:"effect",...e.backdrop===!0?{backdrop:!0}:{}}}function id(n,e){if(!Jt(n))return{};let t={},r=new Map;for(let[s,o]of Object.entries(n)){if(Object.keys(t).length>=Ho){ht(`shader "${e}" declares more than ${Ho} properties; the rest are ignored.`);break}if(!Jt(o)||typeof o.kind!="string"){ht(`shader "${e}" property "${s}" has no kind; ignored.`);continue}let i=o.inputs;if(!Jt(i)||Object.keys(i).length===0){ht(`shader "${e}" property "${s}" names no uniform in "inputs"; ignored.`);continue}let a=!1;for(let c of Object.values(i)){if(typeof c!="string"){ht(`shader "${e}" property "${s}" has a non-string uniform name; ignored.`),a=!0;break}let d=r.get(c);if(d!==void 0){ht(`shader "${e}" properties "${d}" and "${s}" both write uniform "${c}"; "${s}" ignored.`),a=!0;break}r.set(c,s)}a||(t[s]=o)}return t}function Jt(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}var Zt=new Set;function ht(n){Zt.has(n)||(Zt.size>256&&Zt.clear(),Zt.add(n),console.warn(`[shader] ${n}`))}function ye(n,e){return n===""?String(e):`${n}.${e}`}function Nr(n,e){n.declareAssets(e)}function Rr(n,e){if(!n.mounted)return;Nr(n,e);let t=n._allChildren;for(let r=0;r<t.length;r++)Rr(t[r],e)}function Qo(n,e){n.attachDetached(e)}function Qt(n){n._sample();for(let e of n.children)Qt(e)}function en(n,e){n._primeMotion(e);for(let t of n.children)en(t,e)}function zr(n,e){let t=r=>{let s=r.key!==void 0?e?.[r.key]:void 0;r._setEditorState(s?.hidden===!0,s?.locked===!0);for(let o of r._allChildren)t(o)};t(n)}var Fe=class extends R{constructor(e){super(e)}zoomTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}panTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}orbitTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}dollyTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}headingTo(e){return this.to({data:e.data,duration:e.duration,easing:e.easing})}fillTo(e){let t=this.fill,r=be.resolve(e.data),s=e.lerp??be.lerp;return this.command(o=>({fill:s(t,r,o)}),e.duration,e.easing)}overlayTo(e){let t=this.overlay,r=be.resolve(e.data),s=e.lerp??be.lerp;return this.command(o=>({overlay:s(t,r,o)}),e.duration,e.easing)}flowArrangement(){return this}shapeGraphics(){return new ot().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}renderSelf(e){let t=this.fill;t.length!==0&&e.draw(this.shapeGraphics().fill(t))}renderOverlay(e){let t=this.overlay;t.length!==0&&e.draw(this.shapeGraphics().fill(t))}acceptsChild(e){return e.dimension==="2d"||e.dimension==="audio"}get _childTrees(){return["2d","audio"]}get childrenAudio(){return this._allChildren.filter(e=>e instanceof ut)}declareAssets(e){super.declareAssets(e),e.fill(this.fill),e.fill(this.overlay)}clipSelf(){return new xr().rect({width:this.layoutBounds.width,height:this.layoutBounds.height})}_cameraScope(){return this.space3D||this.zoom===1&&this.heading===0&&this.lookAt.x===0&&this.lookAt.y===0?null:{lookAt:this.lookAt,zoom:this.zoom,heading:this.heading}}_spaceCamera(){if(!this.space3D)return null;let e=this.layoutBounds;return{perspective:this.perspective,orbit:this.orbit,elevation:this.elevation,dolly:this.dolly,lookAt:this.lookAt,zoom:this.zoom,heading:this.heading,viewportX:e?.x??0,viewportY:-(e?.y??0)}}_projection(){return this.space3D?fr:super._projection()}renderChildren(e){let t=this._spaceCamera();if(t){this._renderInSpace(e,jt(this,t));return}if(this.zoom===1&&this.heading===0&&this.lookAt.x===0&&this.lookAt.y===0){super.renderChildren(e);return}let r=this.layoutBounds,s=r?.width??0,o=r?.height??0,i=r?.x??0,a=r?.y??0;e.beginCamera({x:i,y:-a,width:s,height:o},this.lookAt,this.zoom,this.heading);for(let c of this._children)c instanceof R&&c.render(e);e.endCamera()}};Qs(Fe,{fill:wr(),overlay:wr(),flow:co(),gap:re({default:0}),wrap:re({default:!1}),crossGap:re({default:void 0}),columns:re({default:1}),align:ao(),zoom:re({default:1}),lookAt:re({default:{x:0,y:0},tween:at}),heading:re({default:0}),space3D:re({default:!1}),orbit:re({default:0}),elevation:re({default:0}),dolly:re({default:0}),zoomTo:Ae({args:[{key:"zoom",kind:"number",min:.01,step:.1,unit:"\xD7"}]}),panTo:Ae({args:[{key:"lookAt",kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}]}),orbitTo:Ae({args:[{key:"orbit",kind:"number",step:1,unit:"\xB0"},{key:"elevation",kind:"number",step:1,unit:"\xB0"}]}),dollyTo:Ae({args:[{key:"dolly",kind:"number",step:10}]}),headingTo:Ae({args:[{key:"heading",kind:"number",step:1,unit:"\xB0"}]}),fillTo:Ae(),overlayTo:Ae()});var nn={cornerRadius:k.number(0),cornerStyle:k.custom("rounded",{lerp:Zn})},ei=O({key:"rect",state:{...$,...j,...Me},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,Ue(n.size,e))}),ti=O({key:"ellipse",state:{...$,...j,startAngle:k.number(0),sweep:k.number(360),ratio:k.number(0)},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,bo(n.size,e))}),ni=O({key:"polygon",state:{...$,...j,sides:k.number(5),...nn},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,ko(n.size,e))}),ri=O({key:"polygram",state:{...$,...j,sides:k.number(5),ratio:k.number(.5),...nn},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,So(n.size,e))}),si=O({key:"path",state:{...$,...j,data:k.path},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,Ao(n.size,e.data),{clipShape:Gt(n.size)})}),Qm=O({key:"facePath",state:{...$,...j,data:k.path},defaults:{width:"hug",height:"hug"},commands:{...N},measure:(n,e)=>{let t=sr.size(e.data),r=e.padding;return{width:t.width+r.left+r.right,height:t.height+r.top+r.bottom}},layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,Mo(e.data),{clipShape:null})});function mt(n,e){return O({key:n,state:{...$,...j,...nn},commands:{...N},measure:(t,r,s)=>K(t,r,s,E(r)),layout:(t,r,s)=>z(t,r,s,E(r)),render:(t,r)=>J(t,r,Ar(e,t.size,r),{clipShape:Gt(t.size)})})}var eg=mt("triangle","triangle"),tg=mt("rightTriangle","rightTriangle"),ng=mt("pentagon","pentagon"),rg=mt("hexagon","hexagon"),sg=mt("octagon","octagon"),og=O({key:"star",state:{...$,...j,...nn,points:k.number(go),ratio:k.number(mo)},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,Ar("star",n.size,{cornerRadius:e.cornerRadius,cornerStyle:e.cornerStyle,sides:Math.max(3,Math.round(e.points)),ratio:e.ratio}),{clipShape:Gt(n.size)})});var oi=O({key:"boolean",state:{...$,...j,op:k.oneOf(["union","subtract","intersect","exclude"])},commands:{...N},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>n.merge(e.op,e)}),ii=O({key:"mask",state:{mode:k.oneOf(["alpha","vector","luminance"]),inverted:!1},render:(n,e)=>n.mask(e)});var di=O({key:"camera",state:{...$,...j,...To,...Me},commands:{...N,...Oo},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>J(n,e,Ue(n.size,e),{children:()=>Eo(n,e)})}),ai={lookAt:k.custom({x:0,y:0},{lerp:at,kind:"vector2",properties:{x:{kind:"number"},y:{kind:"number"},z:{kind:"number"}}}),zoom:k.number(1,{min:.01,step:.1,unit:"\xD7"}),heading:k.number(0,{step:1,unit:"\xB0"}),orbit:k.number(0,{step:1,unit:"\xB0"}),elevation:k.number(0,{step:1,unit:"\xB0"}),dolly:k.number(0,{step:10}),orbitSpeed:k.number(0)},ui=O({key:"orbitCamera",state:ai,defaults:{width:"hug",height:"hug",perspective:1e3},commands:vo(ai,{orbitTo:{args:["orbit","elevation"]},dollyTo:{args:["dolly"]},zoomTo:{args:["zoom"]},panTo:{args:["lookAt"]},headingTo:{args:["heading"]}}),render:(n,e)=>n.space({perspective:e.perspective,orbit:e.orbit+e.orbitSpeed*n.time.total,elevation:e.elevation,dolly:e.dolly,lookAt:e.lookAt,zoom:e.zoom,heading:e.heading,viewportX:0,viewportY:0})}),li=O({key:"rotated-box",state:{angle:k.number(-90)},defaults:{rotation:n=>n.angle},measure:(n,e,t)=>{let{cos:r,sin:s}=ci(e.angle),{width:o,height:i}=n.max,a=Math.abs(e.angle%180)===90,c=o!==void 0&&i!==void 0?{width:o*r+i*s,height:o*s+i*r}:{width:a?i:o,height:a?o:i},d=0,u=0;for(let l of t){let h=l.measure(c);d=Math.max(d,h.width),u=Math.max(u,h.height)}return{width:d*r+u*s,height:d*s+u*r}},layout:(n,e,t)=>{let{cos:r,sin:s}=ci(e.angle),o={x:0,y:0,width:n.width*r+n.height*s,height:n.width*s+n.height*r};return z(o,e,t)}});function ci(n){let e=n*(Math.PI/180);return{cos:Math.abs(Math.cos(e)),sin:Math.abs(Math.sin(e))}}var{overlay:Ag,...Kr}=$,{overlayTo:Mg,...Ur}=N,Vr=n=>n.fontSize==="autofit"?"fill":"hug",ad=[];function cd(n){return n==null?null:n instanceof Gs?n.toCommands():n}function dd(n){return Array.isArray(n)?n.map(({fill:e,stroke:t,...r})=>({...r,...e===void 0?{}:{fill:be.resolve(e)},...t===void 0?{}:{stroke:or.resolve(t)}})):[]}var ud={...Kr,...Yt,text:k.text("",{typing:!0}),wrap:!1,path:k.custom(null,{resolve:cd}),runs:k.custom([],{resolve:dd,animatable:!1})},Br=n=>({text:n.text,wraps:n.wrap,glyphPath:n.path,runs:n.runs}),rn=O({key:"text",state:ud,defaults:{width:n=>n.fontSize==="autofit"||n.wrap?"fill":"hug",height:Vr},commands:{...Ur,append:{args:{text:k.text("",{multiline:!0})},run:(n,e)=>n.tween({text:e.text+n.args.text})},prepend:{args:{text:k.text("",{multiline:!0})},run:(n,e)=>n.tween({text:n.args.text+e.text})}},load:(n,e)=>Or(n,e,Br(e)),measure:(n,e)=>Mr(n,e,Br(e)),render:(n,e)=>Tr(n,e,Br(e))}),ld={...Kr,...Yt,value:0,format:k.custom("number"),customPattern:"",fractionDigits:0,grouped:!0,currencySymbol:"$"},jr=n=>({text:Co(n.value,Po(n)),wraps:!1,glyphPath:null,runs:ad}),fi=O({key:"number",state:ld,defaults:{width:Vr,height:Vr},commands:{...Ur,countTo:{args:["value"]}},load:(n,e)=>Or(n,e,jr(e)),measure:(n,e)=>Mr(n,e,jr(e)),render:(n,e)=>Tr(n,e,jr(e))}),{verticalAlign:Tg,textDecoration:Og,textCase:Eg,minFontSize:Cg,...fd}=Yt,hi=O({key:"richtext",state:{...Kr,...fd,fontSize:k.number(48,{inherit:Ro("fontSize",{autofit:!1})}),spans:k.custom([],{resolve:n=>n==null?[]:Array.isArray(n)?n:[n]})},defaults:{width:"hug",height:"hug"},commands:{...Ur},load:(n,e)=>$o(n,e),measure:(n,e)=>Io(n,e),render:(n,e)=>Fo(n,e)}),pi=O({key:"default-text-style",state:zo,provide:(n,e)=>Lo(n,e),render:(n,e)=>n.textStyle(Bo(e),()=>n.children())});var mi=O({key:"provider",state:{context:k.custom(void 0),value:k.custom(void 0)},provide:n=>n.context?[lt(n.context,n.value!==void 0?n.value:n.context.defaultValue)]:[]}),gi=O({key:"theme-provider",state:{theme:k.custom(void 0),data:k.custom(void 0),seed:k.custom(void 0)},provide:(n,e)=>{let t=[];return n.theme&&t.push(lt(Er,{...e(Er),...n.theme})),n.data&&t.push(lt(Cr,{...e(Cr),...n.data})),n.seed!==void 0&&t.push(lt(No,n.seed)),t}});function hd(n){let e=[...n.filters];return(ar(n.volume,1)!==1||typeof n.volume!="number")&&e.push(...Ve.gain(n.volume)),n.speed!==1&&e.push(...Ve.speed(n.speed)),e}var yi=Pr({key:"sound",state:{src:k.custom(void 0),trimStart:0,trimEnd:k.custom(void 0),loop:!1,speed:1},allowedChildren:[],commands:{play:(n,e)=>n.sound(e.src,{trimStart:e.trimStart,trimEnd:e.trimEnd,loop:e.loop,filters:hd(e)})}}),_i=Pr({key:"audioBus",state:{solo:!1}});var pd={src:k.custom(void 0),fit:k.custom(void 0),crop:k.insets,zoom:1,anchor:k.alignment,matrix:k.custom(void 0),filters:k.custom([],{resolve:n=>nr(n),lerp:tr}),playing:!0,timestamp:k.custom(void 0),trimStart:k.custom(void 0),trimEnd:k.custom(void 0),speed:k.custom(void 0),loop:k.custom(void 0),duration:k.custom(void 0),volume:1,muted:!1,audioFilters:k.custom([],{resolve:n=>ke(n)}),bus:k.custom(void 0),segments:k.custom([])};function md(n,e){if(n.segments.length===0)return null;let t=0;for(let r of n.segments){if(e<=r.at)break;t+=Math.min(e-r.at,r.duration)*(r.speed??n.speed??1)}return t}function gd(n,e){let t=md(n,e);if(t===null)return;let r=n.trimStart??0,s=n.segments[0];return Us(t+(s?s.from-r:0),r,n.trimEnd??1/0,n.loop,n.duration)}var Gr=new WeakMap;function yd(n,e,t){if(!e.src)return Gr.delete(n),null;let r=gd(e,t),s=e.crop,o=e.anchor,i=[e.src,e.fit??"",e.zoom,e.playing?1:0,s.left,s.right,s.top,s.bottom,o.x,o.y,e.timestamp??"",e.trimStart??"",e.trimEnd??"",e.speed??"",e.loop??"",e.duration??"",r??""].join("|"),a=Gr.get(n);if(a&&a.key===i)return a.fill;let c={type:"video",src:e.src,fit:e.fit,crop:e.crop,zoom:e.zoom,anchor:e.anchor,matrix:e.matrix,filters:e.filters,playing:e.playing,timestamp:e.timestamp??r,trimStart:e.trimStart,trimEnd:e.trimEnd,speed:e.speed,loop:e.loop,duration:e.duration},d=$t(c);return Gr.set(n,{key:i,fill:d}),d}function _d(n,e){let t=[];return e!==1&&t.push(...ke(Ve.speed(e))),t.push(...n.audioFilters),t}var wi=O({key:"video",state:{...$,...j,...Me,...pd},commands:{...N,play:{args:{from:k.custom(void 0),volume:k.custom(void 0),speed:k.custom(void 0)},run:(n,e)=>{let t=e,r=n.args.from!==void 0;if(!t.src||t.muted||!r&&!t.playing)return n.together([]);let s=n.args.speed??t.speed??1,o=!r&&(t.loop??"none")!=="none";return n.sound(t.src,{volume:n.args.volume??t.volume,loop:o,trimStart:r?n.args.from:t.trimStart,trimEnd:t.trimEnd,filters:_d(t,s),bus:t.bus,optional:!0,closed:!o})}}},load:(n,e)=>{e.src&&n.fill($t({type:"video",src:e.src,filters:e.filters,trimStart:e.trimStart,trimEnd:e.trimEnd}))},measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>{let t=e,r=yd(xo(n).host,t,n.time.elapsed),s={width:n.size.width,height:n.size.height,cornerRadius:t.cornerRadius,cornerStyle:t.cornerStyle,start:t.start,end:t.end};J(n,e,Ue(n.size,e),{fill:[r??qs,...e.fill],overlay:()=>r?new ot().mask().rect(s).fill([r]).applyMask().rect(s).fill(e.overlay).endMask():null})}});var $e={orbit:0,elevation:0,distance:10};function xi(n){return n.orbit!==void 0||n.elevation!==void 0||n.distance!==void 0}function Yr(n){let e=Z(n.target??0);if(!xi(n)){let i=n.lookAt??n.target;return{position:Z(n.position??0),lookAt:i===void 0?void 0:Z(i)}}let t=n.distance??$e.distance,r=(n.orbit??$e.orbit)*Math.PI/180,s=wd(n.elevation??$e.elevation,-89.9,89.9)*Math.PI/180,o=Math.cos(s)*t;return{position:{x:e.x+Math.sin(r)*o,y:e.y+Math.sin(s)*t,z:e.z+Math.cos(r)*o},lookAt:e}}function wd(n,e,t){return n<e?e:n>t?t:n}var vi=I({key:"group3d"}),gt={geometry:x(),...Vo},bi=I({key:"mesh3d",state:gt,render:(n,e)=>n.draw(Wt(e,e.geometry))}),Ne={startAngle:x(),sweep:x()},Re=["startAngle","sweep"];function Q(n,e,t,r){return I({key:n,state:{...gt,...t},render:(s,o)=>s.draw(Wt(o,ge(e,o,r)))})}var ki=Q("box3d","box",{width:x(),height:x(),depth:x(),cornerRadius:x(),segments:x()},["width","height","depth","cornerRadius","segments"]),Si=Q("sphere3d","sphere",{radius:x(),segments:x(),...Ne,startLatitude:x(),latitudeSweep:x()},["radius","segments","startLatitude","latitudeSweep",...Re]),Ai=Q("plane3d","plane",{width:x(),height:x(),segments:x()},["width","height","segments"]),Mi=Q("cylinder3d","cylinder",{radius:x(),height:x(),segments:x(),capped:x(),...Ne},["radius","height","segments","capped",...Re]),Ti=Q("cone3d","cone",{radius:x(),height:x(),segments:x(),capped:x(),...Ne},["radius","height","segments","capped",...Re]),Oi=Q("torus3d","torus",{radius:x(),thickness:x(),segments:x(),...Ne},["radius","thickness","segments",...Re]),Ei=Q("torus-knot3d","torusKnot",{radius:x(),thickness:x(),segments:x(),windings:x()},["radius","thickness","segments","windings"]),Ci=Q("circle3d","circle",{radius:x(),segments:x(),...Ne},["radius","segments",...Re]),Pi=Q("ring3d","ring",{radius:x(),innerRadius:x(),segments:x(),...Ne},["radius","innerRadius","segments",...Re]),Di=Q("capsule3d","capsule",{radius:x(),height:x(),segments:x()},["radius","height","segments"]),Ii=I({key:"polyhedron3d",state:{...gt,shape:k.custom("icosahedron"),radius:x(),segments:x()},render:(n,e)=>n.draw(Wt(e,ge("polyhedron",e,["shape","radius","segments"])))}),Fi=Q("extrude3d","extrude",{path:x(),depth:x(),segments:x(),bevel:x()},["path","depth","segments","bevel"]),$i=Q("lathe3d","lathe",{points:x(),segments:x(),...Ne},["points","segments",...Re]),Ni=Q("tube3d","tube",{points:x(),radius:x(),segments:x(),closed:x()},["points","radius","segments","closed"]),Ri=I({key:"instances3d",state:{...gt,instances:x(),colors:x()},render:(n,e)=>{!e.geometry||!e.instances?.length||n.draw(new fe().instances(e.geometry,Ko(e),e.instances,{colors:e.colors}))}}),zi=I({key:"points3d",state:gt,render:(n,e)=>{e.geometry&&n.draw(new fe().points(e.geometry,Uo(e)))}}),Li=I({key:"line3d",state:{points:x(),geometry:x(),closed:k.custom(!1),segments:k.custom(!1),stroke:x(),opacity:x(),material:x()},render:(n,e)=>{!e.geometry&&!e.points?.length||n.draw(new fe().line({points:e.geometry?void 0:e.points,geometry:e.geometry,closed:e.closed,segments:e.segments,stroke:e.stroke,opacity:e.opacity,material:e.material}))}}),Bi=I({key:"sprite3d",state:{fill:k.custom(void 0,{lerp:Ys}),opacity:x(),material:x()},render:(n,e)=>n.draw(new fe().sprite({fill:e.fill,opacity:e.opacity,material:e.material}))}),ji=I({key:"model3d",state:{src:x(),animation:x(),override:x()},render:(n,e)=>{e.src&&n.draw(new fe().model({src:e.src,animation:e.animation,override:e.override}))}}),ay=I({key:"modelView3d",state:{src:x(),animation:x(),override:x(),clip:"",clipTime:0},render:(n,e)=>{if(!e.src){n.draw(new fe().box({width:1,height:1,depth:1,material:{type:"basic",color:"#6b7280",wireframe:!0,transparent:!0,opacity:.7}}));return}n.draw(new fe().model({src:e.src,animation:{clip:xd(e.clip),time:e.clipTime},override:e.override}))}});function xd(n){let e=n.trim();if(e==="")return;let t=Number(e);return Number.isInteger(t)&&t>=0?t:e}var qr={shadow:!1},Vi=I({key:"ambient-light3d",state:{color:me(),intensity:x()},render:(n,e)=>n.light(ge("ambient",e,["color","intensity"]))}),Ki=I({key:"hemisphere-light3d",state:{sky:me(),ground:me(),intensity:x()},render:(n,e)=>n.light(ge("hemisphere",e,["sky","ground","intensity"]))}),Ui=I({key:"directional-light3d",state:{color:me(),intensity:x(),target:Xt("origin")},defaults:qr,render:(n,e)=>n.light(ge("directional",e,["color","intensity","target","shadow"]))}),Gi=I({key:"point-light3d",state:{color:me(),intensity:x(),distance:x(),decay:x()},defaults:qr,render:(n,e)=>n.light(ge("point",e,["color","intensity","distance","decay","shadow"]))}),Yi=I({key:"spot-light3d",state:{color:me(),intensity:x(),distance:x(),angle:x(),penumbra:x(),decay:x(),target:Xt("origin")},defaults:qr,render:(n,e)=>n.light(ge("spot",e,["color","intensity","distance","angle","penumbra","decay","target","shadow"]))}),qi=I({key:"area-light3d",state:{color:me(),intensity:x(),width:x(),height:x()},render:(n,e)=>n.light(ge("area",e,["color","intensity","width","height"]))}),vd=["target","orbit","elevation","distance","fov","frustumHeight","near","far","zoom"],bd=["orbit","elevation","distance"],Xi=I({key:"camera3d",state:{type:k.custom("perspective"),target:Xt("origin"),orbit:x(),elevation:x(),distance:x(),fov:x(),frustumHeight:x(),near:x(),far:x(),zoom:x()},commands:{orbitTo:{args:{orbit:qt({step:1,unit:"\xB0"}),elevation:qt({min:-89,max:89,step:1,unit:"\xB0"}),distance:qt({min:.01,step:.1})},run:(n,e)=>{let t={orbit:e.orbit??$e.orbit,elevation:e.elevation??$e.elevation,distance:e.distance??$e.distance};return n.animate(r=>{let s={};for(let o of bd){let i=n.args[o];i!==void 0&&(s[o]=t[o]+(i-t[o])*r)}return s})}},lookTo:{args:["target"]}},render:(n,e)=>{let t={type:e.type};for(let r of vd)e[r]!==void 0&&(t[r]=e[r]);n.camera(t)}}),Wi=I({key:"fog3d",state:{color:me(),near:x(),far:x(),density:x()},render:(n,e)=>{let t={};e.color!==void 0&&(t.color=e.color),e.density!==void 0?t.density=e.density:(e.near!==void 0&&(t.near=e.near),e.far!==void 0&&(t.far=e.far)),n.fog(t)}}),Hi=I({key:"environment3d",state:{src:x(),faces:x(),preset:x(),intensity:x(),background:x(),blur:x()},render:(n,e)=>{if(e.src===void 0&&e.faces===void 0&&e.preset===void 0)return n.environment(null);let t=jo(e,["src","faces","preset","intensity","background","blur"]);(e.rotationX||e.rotationY||e.rotationZ)&&(t.rotation=[e.rotationX,e.rotationY,e.rotationZ]),n.environment(t)}});var Zi=O({key:"canvas3d",state:{...$,...j,...Me,...Go},defaults:{width:"fill",height:"fill"},commands:{...N,...Yo},allowedChildren:["2d","3d"],load:n=>qo(n),measure:(n,e,t)=>K(n,e,t,E(e)),layout:(n,e,t)=>z(n,e,t,E(e)),render:(n,e)=>Xo(n,e)});function Ge(n){return n.kind==="still"}function hy(n){return n.kind==="composition"}function sn(n){return n.kind==="audio"}function kd(n){return n.kind!=="still"}var b="";function U(n){let e=n;return{start:e.startAt??0,end:e.endAt??1/0}}function py(n,e){return on(new Map(n.map(t=>[t.id,t])),e)}function Ji(n){let e=new Map(n.map(o=>[o.id,o])),t=new Map,r=[],s=new Set;for(let o of e.values()){if(t.has(o.id))continue;r.length=0,s.clear();let i,a=o;for(;a;){let c=t.get(a.id);if(c){i=c;break}if(s.has(a.id)){for(let d of r)t.set(d.id,on(e,d.id));r.length=0;break}r.push(a),s.add(a.id),a=a.parentId===null?void 0:e.get(a.parentId)}for(let c=r.length-1;c>=0;c--){let d=U(r[c]);i&&(d.start=Math.max(d.start,i.start),d.end=Math.min(d.end,i.end)),t.set(r[c].id,d),i=d}}return t}function on(n,e){let t=n.get(e);if(!t)return;let r=U(t),s=new Set;for(;t.parentId!==null&&!s.has(t.id);){s.add(t.id);let o=n.get(t.parentId);if(!o)break;let i=U(o);r.start=Math.max(r.start,i.start),r.end=Math.min(r.end,i.end),t=o}return r}function my(n){let{startAt:e,endAt:t,...r}=n;return r}function Sd(n){let e=n.duration??0;return e<=0||!n.loop||n.loop.count===null?e:e*to(n.loop)}function de(n){if(!kd(n))return 0;if(n.duration!==void 0)return n.duration;let e=0;for(let t of n.commands)e=Math.max(e,t.at+Sd(t));for(let t of n.nodes)t.startAt!==void 0&&(e=Math.max(e,t.startAt)),t.endAt!==void 0&&Number.isFinite(t.endAt)&&(e=Math.max(e,t.endAt));return e}function Ad(n){return typeof n=="object"&&n!==null&&n.kind==="project"}function Qi(n,e={}){return Ad(n)?n:{kind:"project",name:e.name??"Untitled",fps:e.fps,viewport:e.viewport,theme:n.theme,tracks:[{id:"clip",clip:n,duration:de(n)}]}}var F=class extends Error{source;position;path;constructor(e,t,r=-1,s){let o=r>=0?` (at character ${r+1} of "${t}")`:` (in "${t}")`;super(`${e}${o}${s?` at ${s}`:""}`),this.name="ExpressionError",this.source=t,this.position=r,this.path=s}};var ze=Math.PI/180,Xr={abs:{arity:[1,1],apply:n=>Math.abs(n[0])},sign:{arity:[1,1],apply:n=>Math.sign(n[0])},sqrt:{arity:[1,1],apply:n=>Math.sqrt(n[0])},floor:{arity:[1,1],apply:n=>Math.floor(n[0])},ceil:{arity:[1,1],apply:n=>Math.ceil(n[0])},round:{arity:[1,2],apply:n=>n.length>1&&n[1]!==0?Math.round(n[0]/n[1])*n[1]:Math.round(n[0])},min:{arity:[1,1/0],apply:n=>Math.min(...n)},max:{arity:[1,1/0],apply:n=>Math.max(...n)},clamp:{arity:[3,3],apply:n=>Math.min(Math.max(n[0],n[1]),n[2])},mod:{arity:[2,2],apply:n=>(n[0]%n[1]+n[1])%n[1]},pow:{arity:[2,2],apply:n=>n[0]**n[1]},log:{arity:[1,2],apply:n=>n.length>1?Math.log(n[0])/Math.log(n[1]):Math.log(n[0])},exp:{arity:[1,1],apply:n=>Math.exp(n[0])},mix:{arity:[3,3],apply:n=>n[0]+(n[1]-n[0])*n[2]},smoothstep:{arity:[3,3],apply:n=>{if(Number.isNaN(n[0])||Number.isNaN(n[1])||Number.isNaN(n[2]))return NaN;if(n[0]===n[1])return n[2]<n[0]?0:1;let e=Math.min(Math.max((n[2]-n[0])/(n[1]-n[0]),0),1);return e*e*(3-2*e)}},step:{arity:[2,2],apply:n=>Number.isNaN(n[0])||Number.isNaN(n[1])?NaN:n[1]<n[0]?0:1},sin:{arity:[1,1],apply:n=>Math.sin(n[0]*ze)},cos:{arity:[1,1],apply:n=>Math.cos(n[0]*ze)},tan:{arity:[1,1],apply:n=>Math.tan(n[0]*ze)},asin:{arity:[1,1],apply:n=>Math.asin(n[0])/ze},acos:{arity:[1,1],apply:n=>Math.acos(n[0])/ze},atan:{arity:[1,1],apply:n=>Math.atan(n[0])/ze},atan2:{arity:[2,2],apply:n=>Math.atan2(n[0],n[1])/ze},hypot:{arity:[2,1/0],apply:n=>Math.hypot(...n)}},ea={pi:Math.PI,tau:Math.PI*2,e:Math.E},qe={functions:Xr,constants:ea,refs:"bracket",unknownName:n=>`unknown name "${n}" \u2014 a variable is referenced as "[${n}]"; bare names are the constants ${yt(ea).join(", ")}`};function yt(n){return Object.keys(n).sort()}var Md=new Set(["+","-","*","/","%","^"]);function Ye(n){return n!==void 0&&n>="0"&&n<="9"}function Td(n,e){let t=[],r=0;for(;r<n.length;){let s=n[r];if(s===" "||s===" "||s===`
2
+ `||s==="\r"){r++;continue}if(Ye(s)||s==="."&&Ye(n[r+1])){let o=r;for(;Ye(n[r]);)r++;if(n[r]===".")for(r++;Ye(n[r]);)r++;if(n[r]==="e"||n[r]==="E"){let i=r;if(r++,(n[r]==="+"||n[r]==="-")&&r++,Ye(n[r]))for(;Ye(n[r]);)r++;else r=i}if(n[r]===".")throw new F('unexpected character "."',n,r);t.push({kind:"number",text:"",value:Number(n.slice(o,r)),pos:o});continue}if(s==="["&&e.refs==="bracket"){let o=r,i=n.indexOf("]",r+1);if(i===-1)throw new F("unclosed `[` \u2014 a variable reference is written `[id]`",n,o);let a=n.slice(r+1,i).trim();if(a.length===0)throw new F("empty variable reference `[]`",n,o);if(a.includes("["))throw new F("variable references cannot nest",n,o);t.push({kind:"ref",text:a,value:0,pos:o}),r=i+1;continue}if(/[A-Za-z_]/.test(s)){let o=r;for(;r<n.length&&/[A-Za-z0-9_]/.test(n[r]);)r++;t.push({kind:"ident",text:n.slice(o,r),value:0,pos:o});continue}if(Md.has(s)){t.push({kind:"op",text:s,value:0,pos:r++});continue}if(s==="("||s===")"||s===","){t.push({kind:s,text:s,value:0,pos:r++});continue}throw new F(`unexpected character "${s}"`,n,r)}return t.push({kind:"end",text:"",value:0,pos:n.length}),t}function an(n,e=qe){if(n.trim().length===0)throw new F("empty expression",n);let t=Td(n,e),r=[],s=0,o=()=>t[s],i=()=>t[s++],a=y=>(r.includes(y)||r.push(y),{kind:"ref",name:y}),c=y=>y.kind==="number"||y.kind==="ref"||y.kind==="ident"||y.kind==="(";function d(){let y=u();for(;;){let _=o();if(_.kind==="op"&&(_.text==="+"||_.text==="-")){i(),y={kind:"binary",op:_.text,left:y,right:u()};continue}return y}}function u(){let y=l();for(;;){let _=o();if(_.kind==="op"&&(_.text==="*"||_.text==="/"||_.text==="%")){i(),y={kind:"binary",op:_.text,left:y,right:l()};continue}if(c(_)){y={kind:"binary",op:"*",left:y,right:l()};continue}return y}}function l(){let y=o();if(y.kind==="op"&&(y.text==="-"||y.text==="+")){i();let _=l();return y.text==="-"?{kind:"unary",op:"-",operand:_}:_}return h()}function h(){let y=p(),_=o();return _.kind==="op"&&_.text==="^"?(i(),{kind:"binary",op:"^",left:y,right:l()}):y}function f(y,_){let v=Object.hasOwn(e.functions,y)?e.functions[y]:void 0;if(!v)throw new F(`unknown function "${y}" \u2014 available: ${yt(e.functions).join(", ")}`,n,_);let A=[];if(o().kind!==")")for(;A.push(d()),o().kind===",";)i();let M=i();if(M.kind!==")")throw new F(`expected \`)\` closing ${y}(`,n,M.pos);let[T,D]=v.arity;if(A.length<T||A.length>D){let V=D===1/0?`at least ${T}`:T===D?`${T}`:`${T}\u2013${D}`,P=(D===1/0||T===D)&&T===1?"":"s";throw new F(`${y}() takes ${V} argument${P}, got ${A.length}`,n,_)}return{kind:"call",name:y,args:A}}function p(){let y=i();switch(y.kind){case"number":return{kind:"const",value:y.value};case"ref":return a(y.text);case"(":{let _=d(),v=i();if(v.kind!==")")throw new F("expected `)`",n,v.pos);return _}case"ident":{if(o().kind==="(")return i(),f(y.text,y.pos);let _=Object.hasOwn(e.constants,y.text)?e.constants[y.text]:void 0;if(_!==void 0)return{kind:"const",value:_};if(e.refs==="bare")return a(y.text);throw new F(e.unknownName(y.text),n,y.pos)}default:throw new F(y.kind==="end"?"expression ends early":`unexpected "${y.text}"`,n,y.pos)}}let w=d(),m=o();if(m.kind!=="end")throw new F(`unexpected "${m.text}"`,n,m.pos);return{source:n,root:w,refs:r,passthrough:w.kind==="ref"}}function Od(n){return typeof n=="number"?n:typeof n=="boolean"?n?1:0:typeof n=="string"?n.trim()===""?NaN:Number(n):NaN}function cn(n,e,t){let r=o=>{let i=e(o);if(!i)throw new F(`"${o}" resolves to nothing in this document \u2014 a reference names a variable (declared with a "variable" command), a constant (a \`constants\` row), or another node's prop as "[key.prop]" (\`key\` on that node's row)`,n.source,-1,t);return i};if(n.passthrough)return r(n.root.name);let s=o=>{switch(o.kind){case"const":{let{value:i}=o;return()=>i}case"ref":{let i=r(o.name);return()=>Od(i())}case"unary":{let i=s(o.operand);return()=>-i()}case"binary":{let i=s(o.left),a=s(o.right);switch(o.op){case"+":return()=>i()+a();case"-":return()=>i()-a();case"*":return()=>i()*a();case"/":return()=>i()/a();case"%":return()=>i()%a();case"^":return()=>i()**a()}break}case"call":{let{apply:i}=Xr[o.name],a=o.args.map(s);return()=>i(a.map(c=>c()))}}throw new F("unsupported expression node",n.source,-1,t)};return s(n.root)}function Xe(n){return typeof n=="string"&&n.length>1&&n[0]==="="&&n[1]!=="="}function Wr(n){return n.startsWith("==")?n.slice(1):n}var Te=n=>({dynamic:!1,value:n});function _t(n,e,t){if(typeof n=="string")return t(n,e);if(Array.isArray(n)){let r=n.map((o,i)=>_t(o,`${e}[${i}]`,t));if(r.some(o=>o.dynamic))return{dynamic:!0,read:()=>r.map(o=>o.dynamic?o.read():o.value)};let s=r.map(o=>o.value);return Te(s.every((o,i)=>o===n[i])?n:s)}if(Cd(n)){let r=Object.keys(n),s=r.map(i=>_t(n[i],`${e}.${i}`,t));if(s.some(i=>i.dynamic))return{dynamic:!0,read:()=>{let i={};return r.forEach((a,c)=>{let d=s[c];i[a]=d.dynamic?d.read():d.value}),i}};if(!s.some((i,a)=>i.value!==n[r[a]]))return Te(n);let o={};return r.forEach((i,a)=>{o[i]=s[a].value}),Te(o)}return Te(n)}function Hr(n,e,t="props"){return _t(n,t,(r,s)=>Xe(r)?{dynamic:!0,read:cn(an(r.slice(1)),e,s)}:Te(Wr(r)))}function ta(n,e,t="props"){let r={},s={},o=!1;for(let i of Object.keys(n??{})){let a=Hr(n[i],e,`${t}.${i}`);a.dynamic?(s[i]=a.read,o=!0):r[i]=a.value}return{literal:r,bindings:s,hasBindings:o}}function na(n,e){let t=[];return _t(n,e,(r,s)=>(Xe(r)&&t.push({path:s,source:r}),Te(r))),t}var Ed=/\[([^[\]]+)\]/g;function ra(n,e){return _t(n,"",r=>Xe(r)?Te(r.replace(Ed,(s,o)=>{let i=e(o.trim());return i===void 0?s:`[${i}]`})):Te(r)).value}function Cd(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function sa(n,e=qe){return an(Xe(n)?n.slice(1):n,e)}var L={isSource:Xe,unescape:Wr,parse:sa,tryParse:(n,e)=>{try{return{expression:sa(n,e)}}catch(t){return{error:t instanceof Error?t.message:String(t)}}},compile:cn,bind:Hr,bindProps:ta,collect:na,renameRefs:ra,functions:()=>yt(qe.functions),constants:()=>yt(qe.constants),dialect:qe};var oa=(n,e,t)=>Math.min(t,Math.max(e,n));function Pd(n){let e=[];for(let t=0;t<n.length-1;t++){let r=n[t],s=n[t+1],o=n[t-1]??r,i=n[t+2]??s,a=r.out?{x:r.x+r.out.x,y:r.y+r.out.y}:{x:r.x+(s.x-o.x)/6,y:r.y+(s.y-o.y)/6},c=s.in?{x:s.x+s.in.x,y:s.y+s.in.y}:{x:s.x-(i.x-r.x)/6,y:s.y-(i.y-r.y)/6};e.push({p0:{x:r.x,y:r.y},c1:{x:oa(a.x,r.x,s.x),y:a.y},c2:{x:oa(c.x,r.x,s.x),y:c.y},p3:{x:s.x,y:s.y}})}return e}function ia(n,e,t,r,s){let o=1-s;return o*o*o*n+3*o*o*s*e+3*o*s*s*t+s*s*s*r}function Dd(n,e){let t=0,r=1;for(let s=0;s<30;s++){let o=(t+r)/2;ia(n.p0.x,n.c1.x,n.c2.x,n.p3.x,o)<e?t=o:r=o}return(t+r)/2}function dn(n){return Array.isArray(n)&&n.length>=2&&n.every(Id)}function Id(n){if(typeof n!="object"||n===null)return!1;let{x:e,y:t}=n;return typeof e=="number"&&Number.isFinite(e)&&typeof t=="number"&&Number.isFinite(t)}function aa(n){let e=Pd(n);return e.length===0?ir(t=>t,"lin"):ir(t=>{if(t<=0)return e[0].p0.y;let r=e[e.length-1];if(t>=1)return r.p3.y;let s=r;for(let i of e)if(t<=i.p3.x){s=i;break}let o=Dd(s,t);return ia(s.p0.y,s.c1.y,s.c2.y,s.p3.y,o)},`curve:${JSON.stringify(n)}`)}var ca=new Set(["linear","in","out","inOut","custom"]),da=new Set(["normal","reverse","alternate"]);function se(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function _e(n){return typeof n=="number"&&Number.isFinite(n)&&n>=0}function Fd(n,e,t){if(n===void 0)return;if(!se(n)){t.push({path:e,message:"easing must be an object with a `kind`."});return}let{kind:r,args:s}=n;if(typeof r!="string"||!ca.has(r)){t.push({path:`${e}.kind`,message:`easing kind must be one of ${[...ca].join(", ")} (got ${JSON.stringify(r)}).`});return}r==="custom"&&s!==void 0&&typeof s!="string"&&!dn(s)&&t.push({path:`${e}.args`,message:"a custom easing's args must be its curve \u2014 two or more `{ x, y }` points \u2014 or a registered ease's key."})}function $d(n,e,t){if(n===void 0)return;if(!se(n)){t.push({path:e,message:"loop must be an object with a `count`."});return}let{direction:r,count:s}=n;s!==null&&(typeof s!="number"||!Number.isInteger(s)||s<0)&&t.push({path:`${e}.count`,message:"loop count must be a whole number of repeats >= 0, or null to repeat for the rest of the clip."}),r!==void 0&&!da.has(r)&&t.push({path:`${e}.direction`,message:`loop direction must be one of ${[...da].join(", ")} (got ${JSON.stringify(r)}).`})}function Nd(n,e,t){if(!se(n))return t.push({path:e,message:"node must be an object."}),!1;let r=!0,{id:s,type:o,parentId:i,layerOrder:a,props:c,key:d}=n;return typeof s!="string"&&(t.push({path:`${e}.id`,message:"id must be a string."}),r=!1),(typeof o!="string"||o.length===0)&&(t.push({path:`${e}.type`,message:"type must be a non-empty string."}),r=!1),i!==null&&typeof i!="string"&&(t.push({path:`${e}.parentId`,message:"parentId must be a node id or null."}),r=!1),(typeof a!="number"||!Number.isFinite(a))&&(t.push({path:`${e}.layerOrder`,message:"layerOrder must be a finite number."}),r=!1),se(c)||(t.push({path:`${e}.props`,message:"props must be an object (`{}` when nothing is set)."}),r=!1),d!==void 0&&(typeof d!="string"||d.length===0?(t.push({path:`${e}.key`,message:"key must be a non-empty string when present."}),r=!1):(d.includes("]")||d.includes("."))&&(t.push({path:`${e}.key`,message:`node key "${d}" cannot contain "]" or "." \u2014 it is referenced as "[${d}.prop]".`}),r=!1)),r}function la(n,e){let t=new Map;for(let r of n){let s=r.spec.key;if(typeof s!="string"||s.length===0)continue;let o=t.get(s);if(o){e.push({path:`${r.path}.key`,message:`duplicate node key "${s}" (also declared at ${o.path}).`});continue}t.set(s,r)}return t}function Rd(n,e,t,r){n.id===""&&(n.type!==t||n.parentId!==null)&&r.push({path:e,message:`the node with id "" is this document's root and must be \`{ type: "${t}", parentId: null }\`.`})}function zd(n,e,t){if(!se(n))return t.push({path:e,message:"command must be an object."}),!1;let r=!0,{id:s,type:o,targetId:i,at:a,duration:c,args:d}=n;return(typeof s!="string"||s.length===0)&&(t.push({path:`${e}.id`,message:"id must be a non-empty string."}),r=!1),(typeof o!="string"||o.length===0)&&(t.push({path:`${e}.type`,message:"type must be a non-empty string."}),r=!1),i!==null&&typeof i!="string"&&(t.push({path:`${e}.targetId`,message:"targetId must be a node id, or null for the scene root."}),r=!1),_e(a)||(t.push({path:`${e}.at`,message:"at must be a finite number of seconds >= 0."}),r=!1),c!==void 0&&!_e(c)&&(t.push({path:`${e}.duration`,message:"duration must be a finite number of seconds >= 0."}),r=!1),se(d)||(t.push({path:`${e}.args`,message:"args must be an object (`{}` when there are none)."}),r=!1),Fd(n.easing,`${e}.easing`,t),$d(n.loop,`${e}.loop`,t),r}function Ld(n,e,t){if(!se(n))return t.push({path:e,message:"variable must be an object."}),!1;let r=!0,{id:s,name:o,value:i,lerp:a}=n;return typeof s!="string"||s.length===0?(t.push({path:`${e}.id`,message:"id must be a non-empty string."}),r=!1):s.includes("]")&&(t.push({path:`${e}.id`,message:`variable id "${s}" cannot contain "]" \u2014 it is referenced as "[${s}]".`}),r=!1),o!==void 0&&typeof o!="string"&&(t.push({path:`${e}.name`,message:"name must be a string when present."}),r=!1),"value"in n?L.isSource(i)&&(t.push({path:`${e}.value`,message:"a variable holds a value, not an expression \u2014 only a node prop can be bound."}),r=!1):(t.push({path:`${e}.value`,message:"value is required \u2014 a variable is what it holds before anything changes it."}),r=!1),a!==void 0&&typeof a!="string"&&(t.push({path:`${e}.lerp`,message:"lerp must be a registered lerp key when present."}),r=!1),r}function fa(n,e){if(n===void 0)return[];if(!Array.isArray(n))return e.push({path:"variables",message:"variables must be an array."}),[];let t=[];return n.forEach((r,s)=>{let o=`variables[${s}]`;Ld(r,o,e)&&t.push({spec:r,path:o})}),t}function ha(n,e){let t=new Map;for(let r of n){let s=t.get(r.spec.id);if(s){e.push({path:`${r.path}.id`,message:`duplicate variable id "${r.spec.id}" (also declared at ${s.path}).`});continue}t.set(r.spec.id,r)}return t}function pa(n){let e=n.indexOf(".");return e<0?void 0:{key:n.slice(0,e),prop:n.slice(e+1)}}function Zr(n,e,t,r,s){for(let o of L.collect(n,e)){let i=L.tryParse(o.source);if("error"in i){s.push({path:o.path,message:i.error});continue}for(let a of i.expression.refs){let c=pa(a);if(!c){if(t.has(a))continue;s.push({path:o.path,message:r.has(a)?`expression references "[${a}]", which is a node key \u2014 a node is not a value, so name the prop too: "[${a}.x]".`:`expression references "[${a}]", which this document does not declare. Declared: ${[...t].map(d=>`[${d}]`).join(", ")||"none"}.`});continue}if(c.key.length===0||c.prop.length===0||c.prop.includes(".")){s.push({path:o.path,message:`expression references "[${a}]", which is not a node reference \u2014 one is "[key.prop]".`});continue}r.has(c.key)||s.push({path:o.path,message:`expression references "[${a}]", but no node in this document is keyed "${c.key}". Keyed: ${[...r].join(", ")||"none"}.`})}}}function Jr(n,e,t,r){if(se(e))for(let s of Object.keys(e)){let o=[];for(let i of L.collect(e[s],`${t}.${s}`)){let a=L.tryParse(i.source);if(!("error"in a))for(let c of a.expression.refs)pa(c)&&o.push(c)}o.length>0&&r.push({id:`${n}.${s}`,path:`${t}.${s}`,reads:o})}}function ma(n,e){let t=new Map(n.map(a=>[a.id,a])),r=new Set,s=[],o=new Set,i=a=>{let c=t.get(a);if(!c||r.has(a))return;let d=s.indexOf(a);if(d>=0){if(!o.has(a)){let u=[...s.slice(d),a];for(let l of u)o.add(l);e.push({path:c.path,message:`expression cycle ${u.join(" \u2192 ")} \u2014 a prop cannot read a prop that reads it back.`})}return}s.push(a);for(let u of c.reads)i(u);s.pop(),r.add(a)};for(let a of n)i(a.id)}function Bd(n,e){let t=new Map;for(let s of n){if(t.has(s.spec.id)){e.push({path:`${s.path}.id`,message:`duplicate node id "${s.spec.id}".`});continue}t.set(s.spec.id,s)}for(let s of n){let o=s.spec.parentId;o!==null&&!t.has(o)&&e.push({path:`${s.path}.parentId`,message:`parentId "${o}" is not a node in this document.`})}let r=new Set;for(let{spec:s}of n){if(r.has(s.id))continue;let o=new Set,i=s;for(;i;){if(o.has(i.id)){e.push({path:`${t.get(i.id)?.path}.parentId`,message:`node "${i.id}" is its own ancestor \u2014 parent chain forms a cycle.`});break}if(o.add(i.id),r.has(i.id))break;let a=i.parentId;i=a===null?void 0:t.get(a)?.spec}for(let a of o)r.add(a)}}function ga(n,e,t){for(let r of n){let s=e.get(r.id);s&&t.push({path:`${s.path}.id`,message:`"${r.id}" is already a node id \u2014 nodes and variables share one id space.`})}}function ya(n,e){n.constants!==void 0&&e.push({path:"constants",message:"constants were merged into `variables` \u2014 move each row there and drop its `kind`."})}function _a(n,e,t){if(!Array.isArray(n))return t.push({path:"nodes",message:"nodes must be an array."}),[];let r=[];return n.forEach((s,o)=>{let i=`nodes[${o}]`;Nd(s,i,t)&&(r.push({spec:s,path:i}),Rd(s,i,e,t))}),Bd(r,t),r}function jd(n,e,t){let{startAt:r,endAt:s}=n;r!==void 0&&!_e(r)&&t.push({path:`${e}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),s!==void 0&&!_e(s)&&t.push({path:`${e}.endAt`,message:"endAt must be a finite number of seconds >= 0."}),_e(s)&&s<=(_e(r)?r:0)&&t.push({path:`${e}.endAt`,message:`endAt (${s}s) must be after startAt (${r??0}s).`}),n.id===""&&(r!==void 0||s!==void 0)&&t.push({path:e,message:"the root is present for the whole clip \u2014 it cannot carry startAt or endAt."})}function Vd(n,e){ya(n,e),n.commands!==void 0&&e.push({path:"commands",message:"a still has no timeline, so no commands \u2014 make it a composition to animate it."});let t=ha(fa(n.variables,e),e),r=_a(n.nodes,"canvas2d",e);for(let d of r){let{startAt:u,endAt:l}=d.spec;(u!==void 0||l!==void 0)&&e.push({path:d.path,message:"a still has no timeline \u2014 drop startAt/endAt, or make it a composition."})}let s=r.map(d=>d.spec);ga(s,t,e);let o=la(r,e),i=new Set(t.keys()),a=new Set(o.keys()),c=[];for(let d of r)Zr(d.spec.props,`${d.path}.props`,i,a,e),d.spec.key&&Jr(d.spec.key,d.spec.props,`${d.path}.props`,c);ma(c,e)}function Kd(n,e){wa(n,"canvas2d",e)}function Ud(n,e){wa(n,"audioBus",e)}var Gd={add:"a node is a row in `nodes` \u2014 its `startAt` is when it enters.",variable:"a variable is declared in `variables`."};function wa(n,e,t){if(ya(n,t),!Array.isArray(n.commands)){t.push({path:"commands",message:"commands must be an array."});return}n.duration!==void 0&&!_e(n.duration)&&t.push({path:"duration",message:"duration must be a finite number of seconds >= 0."});let r=ha(fa(n.variables,t),t),s=_a(n.nodes,e,t);for(let f of s)jd(f.spec,f.path,t);let o=s.map(f=>f.spec);ga(o,r,t);let i=la(s,t),a=[],c=new Set;n.commands.forEach((f,p)=>{if(!zd(f,`commands[${p}]`,t))return;if(c.has(f.id)){t.push({path:`commands[${p}].id`,message:`duplicate command id "${f.id}".`});return}let w=Gd[f.type];if(w){t.push({path:`commands[${p}].type`,message:`there is no "${f.type}" command \u2014 ${w}`});return}c.add(f.id),a.push({spec:f,path:`commands[${p}]`})});let d=new Map(o.map(f=>[f.id,f]));for(let{spec:f,path:p}of a){if(f.targetId===null||r.has(f.targetId))continue;let w=on(d,f.targetId);w===void 0?t.push({path:`${p}.targetId`,message:`targetId "${f.targetId}" is not a node or variable in this document.`}):f.at<w.start&&t.push({path:`${p}.at`,message:`command runs at ${f.at}s but its target "${f.targetId}" is not present until ${w.start}s.`})}let u=new Set(r.keys()),l=new Set(i.keys());for(let f of s)Zr(f.spec.props,`${f.path}.props`,u,l,t);for(let{spec:f,path:p}of a)Zr(f.args,`${p}.args`,u,l,t);let h=[];for(let f of s)f.spec.key&&Jr(f.spec.key,f.spec.props,`${f.path}.props`,h);for(let{spec:f,path:p}of a){if(f.type!=="set"||f.targetId===null)continue;let w=d.get(f.targetId)?.key;w&&Jr(w,f.args,`${p}.args`,h)}ma(h,t)}function Qr(n){let e=[];if(!se(n))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};let t=n.kind;return t==="still"?Vd(n,e):t==="composition"?Kd(n,e):t==="audio"?Ud(n,e):e.push({path:"kind",message:`kind must be "still", "composition" or "audio" (got ${JSON.stringify(t)}).`}),{valid:e.length===0,issues:e}}function Yd(n){let e=[];if(!se(n))return{valid:!1,issues:[{path:"",message:"document must be an object."}]};let t=n;if(t.kind!=="project"&&e.push({path:"kind",message:`kind must be "project" (got ${JSON.stringify(t.kind)}).`}),(typeof t.name!="string"||t.name.length===0)&&e.push({path:"name",message:"name must be a non-empty string."}),t.fps!==void 0&&(typeof t.fps!="number"||!(t.fps>0))&&e.push({path:"fps",message:"fps must be a positive number when present."}),!Array.isArray(t.tracks))return e.push({path:"tracks",message:"tracks must be an array."}),{valid:!1,issues:e};let r=new Set;return t.tracks.forEach((s,o)=>{let i=`tracks[${o}]`;if(!se(s)){e.push({path:i,message:"track must be an object."});return}let a=s;if(typeof a.id!="string"||a.id.length===0?e.push({path:`${i}.id`,message:"id must be a non-empty string."}):r.has(a.id)?e.push({path:`${i}.id`,message:`duplicate track id "${a.id}".`}):r.add(a.id),a.name!==void 0&&typeof a.name!="string"&&e.push({path:`${i}.name`,message:"name must be a string when present."}),a.startAt!==void 0&&!_e(a.startAt)&&e.push({path:`${i}.startAt`,message:"startAt must be a finite number of seconds >= 0."}),_e(a.duration)||e.push({path:`${i}.duration`,message:"duration is required, and must be a finite number of seconds >= 0."}),a.clip===void 0){e.push({path:`${i}.clip`,message:"clip is required \u2014 a track places a clip document inline."});return}for(let c of qd(a.clip))e.push({path:`${i}.clip${c.path?`.${c.path}`:""}`,message:c.message})}),{valid:e.length===0,issues:e}}var ua=new WeakMap;function qd(n){if(!se(n))return Qr(n).issues;let e=ua.get(n);return e||(e=Qr(n).issues,ua.set(n,e)),e}function xa(n){let{valid:e,issues:t}=Yd(n);if(!e){let r=t.map(s=>` ${s.path||"<root>"}: ${s.message}`).join(`
3
+ `);throw new Error(`Invalid project document:
4
+ ${r}`)}}function By(n){let{valid:e,issues:t}=Qr(n);if(!e){let r=t.map(s=>` ${s.path||"<root>"}: ${s.message}`).join(`
5
+ `);throw new Error(`Invalid clip document:
6
+ ${r}`)}return n}var Xd={canvas2d:Fe,provider:mi,"theme-provider":gi,"default-text-style":pi,rect:ei,ellipse:ti,path:si,polygon:ni,polygram:ri,boolean:oi,mask:ii,camera:di,orbitCamera:ui,"rotated-box":li,text:rn,richtext:hi,number:fi,video:wi,audioBus:_i,sound:yi,canvas3d:Zi,group3d:vi,mesh3d:bi,box3d:ki,sphere3d:Si,plane3d:Ai,circle3d:Ci,cylinder3d:Mi,cone3d:Ti,capsule3d:Di,torus3d:Oi,"torus-knot3d":Ei,tube3d:Ni,lathe3d:$i,extrude3d:Fi,ring3d:Pi,polyhedron3d:Ii,points3d:zi,line3d:Li,sprite3d:Bi,instances3d:Ri,model3d:ji,camera3d:Xi,"ambient-light3d":Vi,"directional-light3d":Ui,"point-light3d":Gi,"spot-light3d":Yi,"hemisphere-light3d":Ki,"area-light3d":qi,fog3d:Wi,environment3d:Hi};function un(n,e){return(t,r,s,o)=>{let i=t[n];if(typeof i!="function")throw new Error(`Command "${n}" is not available on ${t.constructor.name}.`);return i.call(t,{data:r[e],duration:s,easing:o})}}var Wd={number:Vs,vector2:Jn,vector3:yr,color:((n,e,t)=>{let[r,s,o,i]=er(je(String(n)),je(String(e)),t),a=c=>Math.round(Math.min(Math.max(c,0),1)*255);return`rgba(${a(r)}, ${a(s)}, ${a(o)}, ${Number(i.toFixed(4))})`}),step:((n,e,t)=>t>=1?e:n)};function va(n){for(let[e,t]of Object.entries(Xd))n.addNode(e,t);for(let[e,t]of Object.entries(Wd))n.addLerp(e,t);n.addCommand("to",(e,t,r,s)=>e.to({data:{...t},duration:r,easing:s})),n.addCommand("set",(e,t)=>{let r=t;return Ie(0,()=>{e.set(r)})},{binds:!0}),n.addCommand("fillTo",un("fillTo","fill"),{args:[{key:"fill",kind:"fills"}],method:"fillTo"}),n.addCommand("overlayTo",un("overlayTo","overlay"),{args:[{key:"overlay",kind:"fills"}],method:"overlayTo"}),n.addCommand("strokeTo",un("strokeTo","stroke"),{args:[{key:"stroke",kind:"strokes"}],method:"strokeTo"}),n.addCommand("shadowTo",un("shadowTo","shadow"),{args:[{key:"shadow",kind:"shadows"}],method:"shadowTo"}),n.addVariableCommand("variableTo",(e,t,r,s)=>{let o=t.value,i=t.lerp,a=typeof i=="string"?n.lerp(i):void 0;if(i!==void 0&&!a)throw new Error(`A "lerp" param must name a registered lerp (variable "${e.id}"), got ${JSON.stringify(i)}. Registered: ${n.lerpKeys().join(", ")}.`);let c=a??e.lerp,d,u=!1;return Ie(r,l=>{u||(d=e.get(),u=!0),e.set(c(d,o,l))},s)}),n.addVariableCommand("variableSet",(e,t)=>Ie(0,()=>{e.set(t.value)})),n.addCommand("save",e=>Ie(0,()=>{e.save()}))}var es=["globalThis","window","self","top","parent","frames","Function","importScripts","document","navigator","location","history","screen","customElements","fetch","XMLHttpRequest","WebSocket","EventSource","Request","Response","Headers","localStorage","sessionStorage","indexedDB","caches","cookieStore","crypto","Worker","SharedWorker","ServiceWorker","MessageChannel","BroadcastChannel","postMessage","alert","confirm","prompt","open","print","Notification"],Hd=new Set(["eval","arguments"]),ba=es.filter(n=>Hd.has(n));if(ba.length>0)throw new Error(`DENIED_GLOBALS cannot contain ${ba.join(", ")}: strict mode forbids binding those names, so no dynamic node would link at all. See the note in this file.`);var Zd=["@motionscript/sdk","motionscript","motion-script"],ln=class n{static MAX_SHADERS=512;constructor(e={}){if(this._dynamicNodes=e.dynamicNodes,e.builtins!==!1&&va(this),Array.isArray(e.nodes))for(let t of e.nodes)this.addNode(t);else for(let[t,r]of Object.entries(e.nodes??{}))this.addNode(t,r);for(let[t,r]of Object.entries(e.lerps??{}))this.addLerp(t,r);for(let[t,r]of Object.entries(e.eases??{}))this.addEase(t,r);for(let[t,r]of Object.entries(e.shaders??{}))this.addShader(t,r)}addNode(e,t,r){let s=typeof t=="function",o=s?t:e,i=typeof o.node=="function"?o.node:o,a=s?r:t,c=s?e:Kt(i);if(c===void 0)throw new Error(`${i.name||"The class"} is no component, so it has no document key. Make it with component2d({ key }), or register it explicitly: addNode("myKey", TheClass).`);let d=typeof c=="string"?{key:c}:c,u=d.key,l=this._nodes.get(u);if(l){if(l.ctor===i)return this;if(!a?.replace)throw new Error(`Node type "${u}" is already registered to a different class (${l.ctor.name} vs ${i.name}). Keys must be unique \u2014 a document naming this type would otherwise resolve differently depending on registration order.`)}let h=new Map;for(let f of gr(Object.create(i.prototype)))h.set(f.key,{method:f.method,args:this._describeArgs(f.args)});return this._nodes.set(u,{key:u,ctor:i,commands:h,descriptor:{...d,dimension:this._describeDimension(i),holds:this._describeHolds(i),properties:this._describeProperties(i)}}),this}async addNodeFromSource(e,t){if(!this._dynamicNodes)throw new Error("addNodeFromSource needs `dynamicNodes: { sdk, compile }` on the Registry constructor.");let r=await this._dynamicNodes.compile(e),s=this._evalNodeModule(r);return this.addNode(s,t),s}node(e){return this._nodes.get(e)}hasNode(e){return this._nodes.has(e)}nodeKeys(){return[...this._nodes.keys()].sort()}describe(e){return this._nodes.get(e)?.descriptor}instantiate(e,t){let r=this._nodes.get(e.type);if(!r)throw new Error(`Unknown node type "${e.type}" (node ${e.id}). This registry knows: ${this.nodeKeys().join(", ")||"nothing"}.`);return new r.ctor({...t??e.props,id:e.id,...e.key!==void 0&&{key:e.key}})}addCommand(e,t,r){return this._claimed(e,t)?this:(this._commands.set(e,{key:e,scope:"node",factory:t,...r?.args?{args:this._describeArgs(r.args)}:{},binds:r?.binds,...r?.method?{method:r.method}:{}}),this)}addVariableCommand(e,t){return this._claimed(e,t)?this:(this._commands.set(e,{key:e,scope:"variable",factory:t}),this)}command(e){return this._commands.get(e)}nodeCommand(e,t){let s=this._nodes.get(e)?.commands.get(t);if(s)return(o,i,a,c)=>{let d=o[s.method];if(typeof d!="function")throw new Error(`Command "${t}" needs a "${s.method}" method on ${o.constructor.name}, which has none.`);let u={};for(let l of s.args)u[l.key]=i[l.key];return d.call(o,{data:u,duration:a,easing:c})}}takesCommand(e,t){let r=this._nodes.get(e);if(!r)return!1;if(r.commands.has(t))return!0;let s=this._commands.get(t);return s?.scope!=="node"?!1:s.method===void 0?!0:typeof r.ctor.prototype[s.method]=="function"}commandKeys(e){return[...e===void 0?this._commands.keys():this._nodes.get(e)?.commands.keys()??[]].sort()}addLerp(e,t){let r=this._lerps.get(e);if(r&&r!==t)throw new Error(`Variable lerp "${e}" is already registered to a different function. Keys must be unique.`);return this._lerps.set(e,t),this}lerp(e){return this._lerps.get(e)}lerpKeys(){return[...this._lerps.keys()].sort()}requireLerp(e,t,r){let s=e??(typeof t=="number"?"number":"step"),o=this._lerps.get(s);if(!o)throw new Error(`Unknown variable lerp "${s}" (${r}). Registered: ${this.lerpKeys().join(", ")||"none"}.`);return o}addEase(e,t){let r=this._eases.get(e);if(r&&r!==t)throw new Error(`Ease "${e}" is already registered to a different function. Keys must be unique.`);return this._eases.set(e,t),this}ease(e){return this._eases.get(e)}easeKeys(){return[...this._eases.keys()].sort()}addShader(e,t,r){let s=Jo(t),o=this._shaders.get(e);if(o){if(o.scope===s.scope&&o.source===s.source&&o.name===s.name)return o;if(!r?.replace)throw new Error(`Shader "${e}" is already registered to a different pack ("${o.name}" vs "${s.name}"). Keys must be unique \u2014 a document naming this shader would otherwise resolve differently depending on registration order.`)}else if(this._shaders.size>=n.MAX_SHADERS)throw new Error(`Cannot register shader "${e}": the ${n.MAX_SHADERS}-shader ceiling is reached.`);return this._shaders.set(e,s),s}shader(e){return this._shaders.get(e)}fillShader(e){let t=this._shaders.get(e);return t?.scope==="fill"?t:void 0}effectShader(e){let t=this._shaders.get(e);return t?.scope==="effect"?t:void 0}shaderKeys(){return[...this._shaders.keys()].sort()}_nodes=new Map;_commands=new Map;_lerps=new Map;_eases=new Map;_shaders=new Map;_dynamicNodes;_evalNodeModule(e){let{sdk:t,modules:r}=this._dynamicNodes,s=c=>{if(Zd.includes(c))return t;if(r&&Object.hasOwn(r,c))return r[c];let d=["@motionscript/sdk",...Object.keys(r??{})];throw new Error(`"${c}" isn't available to a custom node. It can require ${d.map(u=>`"${u}"`).join(", ")}; a host supplies more through \`dynamicNodes.modules\`.`)},o={exports:{}};new Function("exports","require","module",...es,`"use strict";
7
+ return function () {
8
+ ${e}
9
+ };`)(o.exports,s,o)();let a=o.exports.default;if(typeof a!="function"||Kt(typeof a.node=="function"?a.node:a)===void 0)throw new Error('This script must `export default` a component: `component2d({ key: "\u2026", \u2026 })`.');return a}_claimed(e,t){let r=this._commands.get(e);if(!r)return!1;if(r.factory===t)return!0;throw new Error(`Command type "${e}" is already registered to a different factory. Keys must be unique.`)}_describeProperties(e){let t={};for(let r of pr(Object.create(e.prototype))){let s=r.editor??{};t[r.key]={...s,kind:s.kind??this._inferKind(r.default),...r.default!==void 0?{default:r.default}:{}}}return t}_describeDimension(e){let t=Object.create(e.prototype).dimension;return typeof t=="string"?t:void 0}_describeHolds(e){let t=Object.create(e.prototype)._childTrees;return Array.isArray(t)?[...t]:void 0}_inferKind(e){switch(typeof e){case"number":return"number";case"string":return"text";case"boolean":return"boolean";case"object":return e===null?"unknown":Array.isArray(e)&&e.every(t=>typeof t=="number")?"vector":"object";default:return"unknown"}}_describeArgs(e){return(e??[]).map(t=>typeof t=="string"?{key:t,kind:"unknown"}:{kind:"unknown",...t})}};var Jd="canvas3d";function Qd(n,e,t){let r=new Set;for(let s=e;s!==void 0&&!r.has(s);s=n.describe(s)?.parentKey){if(s===t)return!0;r.add(s)}return!1}function fn(n,e,t,r){return t.some(s=>Qd(n,e,s)||r.isA?.(e,s)===!0)}function eu(n,e,t,r={}){let s=n.describe(e),o=t===null?void 0:n.describe(t);if(t!==null&&(o?.layout?.acceptsChildren===!1||o?.holds?.length===0))return{kind:"leaf",parent:t};let i=s?.within??[];if(i.length>0&&(t===null||!fn(n,t,i,r)))return{kind:"within",within:i};if(t!==null&&o?.closed===!0&&!fn(n,t,i,r))return{kind:"closed",parent:t};let a=t!==null&&(o?.dimension==="3d"||o?.holds?.includes("3d")===!0||fn(n,t,[Jd],r));return s?.dimension==="3d"!==a?{kind:"dimension",parent:t}:null}function tu(n,e,t,r={}){let s=n.describe(e)?.beside??[];return s.length===0||t.some(o=>fn(n,o,s,r))?null:{kind:"beside",beside:s}}function p_(n,e,t={}){let r=a=>a.parentId===b?null:a.parentId,s=new Map(e.map(a=>[a.id,a])),o=new Map;for(let a of e){if(a.id===b)continue;let c=o.get(r(a));c?c.push(a.type):o.set(r(a),[a.type])}let i=new Map;for(let a of e){if(a.id===b||!n.hasNode(a.type))continue;let c=r(a),d=c===null?null:s.get(c)?.type??null,u=eu(n,a.type,d,t)??tu(n,a.type,nu(o.get(c)??[],a.type),t);u&&i.set(a.id,u)}return i}function nu(n,e){let t=n.indexOf(e);return t===-1?[...n]:[...n.slice(0,t),...n.slice(t+1)]}var hn="@bus";function ru(){return{id:hn,type:"audioBus",parentId:null,layerOrder:0,props:{}}}function su(){return{id:"",type:"canvas2d",parentId:null,layerOrder:0,props:{}}}function ou(n){let e=[su()];n.nodes.some(ka)||e.push(ru());for(let t of n.nodes)e.push(iu(t));return{kind:"composition",duration:n.duration,variables:n.variables,nodes:e,commands:n.commands.map(au)}}function ka(n){return n.id===""&&n.type==="audioBus"}function iu(n){return ka(n)?{...n,id:hn,parentId:null}:n.parentId===null||n.parentId===""?{...n,parentId:hn}:n}function au(n){return n.targetId===null||n.targetId===""?{...n,targetId:hn}:n}function cu(n){let e=new Set(n.commands.filter(r=>r.type==="play").map(r=>r.targetId)),t=[];for(let r of n.nodes){if(r.type!=="sound"&&r.type!=="video"||e.has(r.id))continue;let{start:s,end:o}=U(r),i=r.type==="video"?r.props.segments:void 0;if(Array.isArray(i)&&i.length>0){i.forEach((a,c)=>{t.push({id:`@play:${r.id}:${c}`,type:"play",targetId:r.id,at:s+a.at,duration:Number.isFinite(a.duration)?a.duration:0,args:{from:a.from,...a.speed!==void 0&&{speed:a.speed},...a.volume!==void 0&&{volume:a.volume}}})});continue}t.push({id:`@play:${r.id}`,type:"play",targetId:r.id,at:s,duration:Number.isFinite(o)?o-s:0,args:{}})}return t.length===0?n:{...n,commands:[...n.commands,...t]}}function We(n){let e=sn(n)?ou(n):n;return Ge(e)?e:cu(e)}var Ta=["center","topLeft","topRight","bottomLeft","bottomRight","topCenter","bottomCenter","centerLeft","centerRight"];function ns(n,e,t){let r=du.has(e.type),s=n.command(e.type);if(s?.scope==="variable"){let h=uu.has(e.type);return{scope:"variable",known:h,lifecycle:r,readsLayout:!h,writesLayout:!1}}let o=t??(e.targetId===null?Ea:void 0),i=o?n.node(o.type):void 0;if(!o||!i)return null;let a;if(s){if(a=Ca[e.type],a&&typeof pn(i.ctor,a[0])!="function")return null}else{let h=i.commands.get(e.type);if(!h)return null;a=h.method===e.type?Pa[e.type]:void 0}let c=!r&&a!==void 0&&yu(i.ctor,a);if(!c)return{scope:"node",known:c,lifecycle:r,readsLayout:!0,writesLayout:!0};let d=e.args??{},u=o.props??{},l=mu(e.type,d);return{scope:"node",known:c,lifecycle:r,readsLayout:pu(e.type,d,u,l),writesLayout:l===void 0||l.some(h=>!ss(n,o.type,h))}}function Oa(n,e,t){let r=n.command(e.type),s=t??(e.targetId===null?Ea:void 0),o=r?r.scope==="node"?r.args:void 0:s?n.node(s.type)?.commands.get(e.type)?.args:void 0,i=[];for(let a of o??[]){let c=e.args?.[a.key];a.kind==="nodeRef"&&typeof c=="string"&&c!==""&&i.push(c)}return i}function mn(n,e){let t=n.node(e)?.ctor;return t!==void 0&&pn(t,"provideContext")!==pn(Bt,"provideContext")}function rs(n){for(let e of L.collect(n,"")){let t=L.tryParse(e.source);if("error"in t||t.expression.refs.some(r=>r.includes(".")))return!0}return!1}function ss(n,e,t){let r=n.node(e);return!r||!Da().ctors.has(r.ctor)?!1:r.descriptor.dimension==="audio"?!0:lu.has(t)}var du=new Set(["removeChildAt","addChildAt","reparent"]),uu=new Set(["variableTo","variableSet"]),lu=new Set(["x","y","rotation","scale","opacity","fill","stroke","shadow","overlay","effects","blend","transformOrigin","zoom","lookAt","heading"]),Ea={id:b,type:"canvas2d",parentId:null,layerOrder:0,props:{}},X=["to","_prepareStep","_writeProp"],Le=["command","set","_writeProp"],Ca={to:X,set:["set","_writeProp"],save:["save"],fillTo:["fillTo",...Le],overlayTo:["overlayTo",...Le],strokeTo:["strokeTo",...Le],shadowTo:["shadowTo",...Le]},Pa={...Ca,restore:["restore","_prepareStep","_writeProp"],fadeTo:["fadeTo",...X],rotateTo:["rotateTo",...X],scaleTo:["scaleTo",...X],layoutTo:["layoutTo",...X],effectTo:["effectTo",...X],progressTo:["progressTo",...X],pulse:["pulse",...Le],wiggle:["wiggle",...Le],flash:["flash",...Le],moveTo:["moveTo",...X,"command","set"],zoomTo:["zoomTo",...X],panTo:["panTo",...X],headingTo:["headingTo",...X],countTo:["countTo",...X],append:["append",...X],prepend:["prepend",...X],play:["play"]},fu={fadeTo:["opacity"],rotateTo:["rotation"],scaleTo:["scale"],layoutTo:["width","height","padding"],effectTo:["effects"],progressTo:["start","end"],pulse:["scale"],wiggle:["rotation"],flash:["start","end"],moveTo:["x","y"],zoomTo:["zoom"],panTo:["lookAt"],headingTo:["heading"],fillTo:["fill"],overlayTo:["overlay"],strokeTo:["stroke"],shadowTo:["shadow"],play:[]},hu=new Set(Object.keys(Pa).filter(n=>n!=="set"&&n!=="save"));function pu(n,e,t,r){if(Sa(e)||n==="moveTo"&&typeof e.target=="string"&&e.target!=="")return!0;let s=Sa(t),o=gu(t);return n==="save"||n==="restore"?s||o.size>0:hu.has(n)?(n==="append"||n==="prepend"?["text"]:n==="countTo"?["value"]:r??[]).some(a=>o.has(a)||s&&(a==="x"||a==="y")):!1}function mu(n,e){let t=fu[n];if(t)return t;if(n!=="to"&&n!=="set")return;let r=[];for(let s of Object.keys(e))s==="size"?r.push("width","height"):n==="to"&&s==="pivot"?r.push("transformOrigin"):n==="to"&&Ta.includes(s)?r.push("x","y","transformOrigin"):r.push(s);return r}function Sa(n){return Ta.some(e=>n[e]!==void 0)}var Aa=new WeakMap;function gu(n){let e=Aa.get(n);if(!e){let t=new Set;for(let r of Object.keys(n))rs(n[r])&&t.add(r);Aa.set(n,e=t)}return e}function pn(n,e){return n.prototype[e]}var Ma=new WeakMap;function yu(n,e){let t=Ma.get(n);t||Ma.set(n,t=new Map);let r=t.get(e);return r===void 0&&(r=e.every(s=>{let o=pn(n,s);return o===void 0||_u(s).has(o)}),t.set(e,r)),r}var ts=null;function Da(){if(!ts){let n=new ln;ts={ctors:new Set(n.nodeKeys().map(e=>n.node(e).ctor)),methods:new Map}}return ts}function _u(n){let e=Da(),t=e.methods.get(n);if(!t){let r=new Set;for(let s of e.ctors)for(let o=s.prototype;o&&o!==Object.prototype;o=Object.getPrototypeOf(o)){let i=Object.getOwnPropertyDescriptor(o,n);i&&typeof i.value=="function"&&r.add(i.value)}e.methods.set(n,t=r)}return t}function Y(n,e){if(n===e)return!0;if(typeof n!="object"||typeof e!="object"||n===null||e===null)return n!==n&&e!==e;if(Array.isArray(n)){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let o=0;o<n.length;o++)if(!Y(n[o],e[o]))return!1;return!0}if(Array.isArray(e))return!1;let t=n,r=e,s=0;for(let o of Object.keys(t)){let i=t[o];if(i!==void 0&&(s++,!Y(i,r[o])))return!1}for(let o of Object.keys(r))r[o]!==void 0&&s--;return s===0}function wu(){return{identical:!0,kindChanged:!1,themeChanged:!1,rootChanged:!1,duration:!1,nodes:{added:new Set,removed:new Set,changed:new Set,respec:new Set,moved:new Set,span:new Set,reorderedParents:new Set},commands:{added:new Set,removed:new Set,changed:new Set,reorderedAts:new Set},variables:{added:new Set,removed:new Set,changed:new Set},remappedKeys:new Set}}function gn(n,e){let t=wu();if(n===e)return t;if(n.kind!==e.kind)return t.kindChanged=!0,t.identical=!1,t;let r=Ia(n),s=Ia(e);t.themeChanged=!Y(n.theme,e.theme),t.duration=de(r)!==de(s),n.nodes!==e.nodes&&xu(r.nodes,s.nodes,t),n.variables!==e.variables&&ku(r.variables??[],s.variables??[],t);let o=r.kind==="composition"?r.commands:[],i=s.kind==="composition"?s.commands:[];return n.commands!==e.commands&&bu(o,i,t),t.identical=!t.themeChanged&&!t.rootChanged&&!t.duration&&t.remappedKeys.size===0&&os(t.nodes)&&t.nodes.reorderedParents.size===0&&os(t.commands)&&t.commands.reorderedAts.size===0&&os(t.variables),t}function Ia(n){return We(n)}function os(n){return n.added.size===0&&n.removed.size===0&&n.changed.size===0}var Fa={id:b,type:"canvas2d",parentId:null,layerOrder:0,props:{}};function xu(n,e,t){let r=He(n),s=He(e),o=t.nodes,i=r.get(b)??Fa,a=s.get(b)??Fa;t.rootChanged=i!==a&&!vu(i,a);for(let[l,h]of r){if(l===b)continue;let f=s.get(l);if(!f){o.removed.add(l);continue}if(h===f)continue;let p=!1;(h.type!==f.type||h.key!==f.key||!Y(h.props,f.props))&&(o.respec.add(l),p=!0),h.parentId!==f.parentId&&(o.moved.add(l),p=!0),za(h,f)||(o.span.add(l),p=!0),(p||h.layerOrder!==f.layerOrder)&&o.changed.add(l)}for(let l of s.keys())l!==b&&!r.has(l)&&o.added.add(l);let c=$a(n);for(let[l,h]of $a(e)){let f=c.get(l);f!==void 0&&f!==h&&t.remappedKeys.add(l)}let d=Na(n),u=Na(e);for(let[l,h]of d){let f=u.get(l);f&&!La(h,f)&&o.reorderedParents.add(l)}}function vu(n,e){return n.type===e.type&&n.key===e.key&&n.parentId===e.parentId&&n.layerOrder===e.layerOrder&&Y(n.props,e.props)&&za(n,e)}function za(n,e){let t=U(n),r=U(e);return t.start===r.start&&t.end===r.end}function bu(n,e,t){let r=He(n),s=He(e),o=t.commands;for(let[c,d]of r){let u=s.get(c);if(!u){o.removed.add(c);continue}d!==u&&(d.type!==u.type||d.targetId!==u.targetId||d.at!==u.at||(d.duration??0)!==(u.duration??0)||!Y(d.easing,u.easing)||!Y(d.loop,u.loop)||!Y(d.args,u.args))&&o.changed.add(c)}for(let c of s.keys())r.has(c)||o.added.add(c);let i=Ra(n),a=Ra(e);for(let[c,d]of i){let u=a.get(c);u&&!La(d,u)&&o.reorderedAts.add(c)}}function ku(n,e,t){let r=He(n),s=He(e),o=t.variables;for(let[i,a]of r){let c=s.get(i);if(!c){o.removed.add(i);continue}a!==c&&(a.lerp!==c.lerp||!Y(a.value,c.value))&&o.changed.add(i)}for(let i of s.keys())r.has(i)||o.added.add(i)}function He(n){let e=new Map;for(let t of n)e.set(t.id,t);return e}function $a(n){let e=new Map;for(let t of n)t.key&&e.set(t.key,t.id);return e}function Na(n){let e=new Map;n.forEach((r,s)=>{if(r.id===b)return;let o=r.parentId??b,i=e.get(o);i||e.set(o,i=[]),i.push({id:r.id,order:r.layerOrder,index:s})});let t=new Map;for(let[r,s]of e)s.sort((o,i)=>o.order-i.order||o.index-i.index),t.set(r,s.map(o=>o.id));return t}function Ra(n){let e=new Map;for(let t of n){let r=e.get(t.at);r||e.set(t.at,r=[]),r.push(t.id)}return e}function La(n,e){let t=new Set(e),r=new Set(n),s=n.filter(i=>t.has(i)),o=e.filter(i=>r.has(i));if(s.length!==o.length)return!1;for(let i=0;i<s.length;i++)if(s[i]!==o[i])return!1;return!0}function Su(n){let e=n.indexOf(".");return e<0?void 0:{key:n.slice(0,e),prop:n.slice(e+1)}}function is(n,e=""){let t=[],r=[],s=0,o=new Set;for(let i of L.collect(n,e)){let a=L.tryParse(i.source);if("error"in a){s++;continue}for(let c of a.expression.refs){if(o.has(c))continue;o.add(c);let d=Su(c);d?r.push([d.key,d.prop]):t.push(c)}}return{vars:t,keys:r,unparsable:s}}function cs(n){return new as(We(n))}var Au=Object.freeze({vars:[],keys:[],unparsable:0}),Mu=new Map,Ba=[];function yn(n,e){return n!==void 0&&e>=n.start&&e<n.end}var as=class{doc;nodes=new Map;nodeCount;variables=new Map;commands=new Map;ordered;byTarget=new Map;keyed=new Map;dependents={byVar:new Map,byKey:new Map};duration;issues={duplicateIds:!1,duplicateKeys:!1,unresolvedParent:!1,cycle:!1,invalidRoot:!1,unparsable:!1,unresolvedRefs:!1};constructor(e){this.doc=e,this.duration=de(e);let t=e.kind==="composition"?e.commands:[];this._indexNodes(e.nodes),this.nodeCount=this.nodes.size-1;for(let r of e.variables??[])(this.variables.has(r.id)||this.nodes.has(r.id))&&(this.issues.duplicateIds=!0),this.variables.set(r.id,r);this.ordered=t.map((r,s)=>({spec:r,index:s})).sort((r,s)=>r.spec.at-s.spec.at||r.index-s.index).map(r=>r.spec);for(let r of this.ordered){this.commands.has(r.id)&&(this.issues.duplicateIds=!0),this.commands.set(r.id,r);let s=this.targetOf(r),o=this.byTarget.get(s);o||this.byTarget.set(s,o=[]),o.push(r.id);let i=this._byAt.get(r.at);i||this._byAt.set(r.at,i=[]),i.push(r)}this._ats=[...this._byAt.keys()],this._indexRefs(t)}children(e){return this._children.get(e)??Ba}descendants(e){let t=[],r=new Set([e]),s=[...this.children(e)].reverse();for(;s.length>0;){let o=s.pop();if(r.has(o))continue;r.add(o),t.push(o);let i=this.children(o);for(let a=i.length-1;a>=0;a--)s.push(i[a])}return t}ownSpan(e){let t=this.nodes.get(e);return t?U(t):void 0}effSpan(e){let t=this._eff.get(e);if(t)return t;if(!this.nodes.has(e))return;let r=[],s=new Set,o={start:0,end:1/0},i=this.nodes.get(e);for(;i;){let a=this._eff.get(i.id);if(a){o=a;break}if(s.has(i.id)||(s.add(i.id),r.push(i),i.id===b||i.parentId===null))break;i=this.nodes.get(i.parentId)}for(let a=r.length-1;a>=0;a--){let c=U(r[a]);o={start:Math.max(o.start,c.start),end:Math.min(o.end,c.end)},this._eff.set(r[a].id,o)}return this._eff.get(e)}targetOf(e){return e.targetId??b}commandsAt(e){return this._byAt.get(e)??Ba}bindings(e){return this._bindings.get(e)??Mu}refs(e){return this._refs.get(e)??Au}initialKey(e){return yn(this.ownSpan(e),0)?yn(this.effSpan(e),0)?"mounted":"unmounted":"absent"}captureKey(e){let t=this.captureTime(e);return t===void 0?"none":yn(this.effSpan(e),t)?"arrival-mounted":"arrival-unmounted"}captureTime(e){let t=this.ownSpan(e);if(!t||yn(t,0))return;let r=0,s=this._ats.length;for(;r<s;){let i=r+s>>1;this._ats[i]<t.start?r=i+1:s=i}let o=this._ats[r];return o!==void 0&&o<t.end?o:void 0}_children=new Map;_eff=new Map;_byAt=new Map;_ats=[];_bindings=new Map;_refs=new Map;_indexNodes(e){let t=new Map;e.forEach((s,o)=>{if(this.nodes.has(s.id)&&(this.issues.duplicateIds=!0),this.nodes.set(s.id,s),s.key&&(this.keyed.has(s.key)&&(this.issues.duplicateKeys=!0),this.keyed.set(s.key,s.id)),s.id===b){(s.type!=="canvas2d"||s.parentId!==null)&&(this.issues.invalidRoot=!0);return}let i=s.parentId??b,a=t.get(i);a||t.set(i,a=[]),a.push({id:s.id,order:s.layerOrder,index:o})}),this.nodes.has(b)||this.nodes.set(b,{id:b,type:"canvas2d",parentId:null,layerOrder:0,props:{}});for(let[s,o]of t)o.sort((i,a)=>i.order-a.order||i.index-a.index),this._children.set(s,o.map(i=>i.id));let r=new Set([b]);for(let s of this.nodes.values()){s.parentId!==null&&!this.nodes.has(s.parentId)&&(this.issues.unresolvedParent=!0);let o=new Set,i=s;for(;i&&!r.has(i.id);){if(o.has(i.id)){this.issues.cycle=!0;break}o.add(i.id),i=i.parentId===null?void 0:this.nodes.get(i.parentId)}for(let a of o)r.add(a)}}_indexRefs(e){for(let t of this.nodes.values())this._bind(t.id,t.props);for(let t of e){if(t.type==="set"){let r=this.targetOf(t);if(this.nodes.has(r)){this._bind(r,t.args);continue}}is(t.args).unparsable>0&&(this.issues.unparsable=!0)}for(let[t,r]of this._bindings){let s=new Set,o=new Map,i=0;for(let a of r.values()){for(let c of a.vars)s.add(c);for(let c of a.keys)o.set(`${c[0]}.${c[1]}`,c);i+=a.unparsable}this._refs.set(t,{vars:[...s],keys:[...o.values()],unparsable:i});for(let a of s){this.variables.has(a)||(this.issues.unresolvedRefs=!0);let c=this.dependents.byVar.get(a);c||this.dependents.byVar.set(a,c=new Set),c.add(t)}for(let[a]of o.values()){this.keyed.has(a)||(this.issues.unresolvedRefs=!0);let c=this.dependents.byKey.get(a);c||this.dependents.byKey.set(a,c=new Set),c.add(t)}}}_bind(e,t){if(t)for(let r of Object.keys(t)){let s=is(t[r]);if(s.unparsable>0&&(this.issues.unparsable=!0),s.vars.length===0&&s.keys.length===0)continue;let o=this._bindings.get(e);o||this._bindings.set(e,o=new Map);let i=o.get(r);if(!i){o.set(r,s);continue}let a=new Set([...i.vars,...s.vars]),c=new Map([...i.keys,...s.keys].map(d=>[`${d[0]}.${d[1]}`,d]));o.set(r,{vars:[...a],keys:[...c.values()],unparsable:i.unparsable+s.unparsable})}}};var wn=class n{_finish;_tracks;_replayed;static build(e){let t=new Float64Array(e.length).fill(NaN),r=new Map,s=[],o=[];for(let i=0;i<e.length;i++){let a=e[i],c=ro(a.command)?Eu(a.start,a.duration):NaN;if(Number.isNaN(c)){s.push(i);continue}t[i]=c,c>a.start&&o.push(i);let d=new Set;pe({read:()=>{},write:u=>d.add(u)},()=>a.command.at(1));for(let u of d){let l=r.get(u),h={order:i,finish:c,end:u.snapshot()};l?l.push(h):r.set(u,[h])}}return s.length===e.length?null:new n(e,t,[...r].map(([i,a])=>new ds(i,a)),s,o)}holds(e){return!Number.isNaN(this._finish[e])}evaluate(e,t){let r=this._tracks,s=this._held;for(let h=0;h<r.length;h++){let f=s[h]=r[h].at(t);f>=0&&r[h].slot.restoreFrom(r[h].ends[f])}let o=this._replayed,i=this._long,a=this._binOf(t),c=this._binStart[a+1],d=0,u=this._binStart[a],l=0;for(;;){let h=d<o.length?o[d]:_n,f=u<c?this._binItems[u]:_n,p=l<i.length?i[l]:_n,w;if(h<f&&h<p)w=h,d++;else if(f<p)w=f,u++;else if(p!==_n)w=p,l++;else break;let m=e[w];if(!(t<m.start||this._finish[w]<=t)){m.command.at(it(m.duration>0?(t-m.start)/m.duration:1));for(let y=this._fixStart[w];y<this._fixStart[w+1];y++){let _=this._fixTracks[y],v=s[_];v>=0&&r[_].order[v]>w&&r[_].slot.restoreFrom(r[_].ends[v])}}}}constructor(e,t,r,s,o){this._finish=t,this._tracks=r,this._replayed=s,this._held=new Int32Array(r.length);let i=1/0,a=-1/0;for(let f of o)i=Math.min(i,e[f].start),a=Math.max(a,t[f]);let c=Math.max(1,Math.min(Tu,o.length));this._from=Number.isFinite(i)?i:0,this._width=a>i?(a-i)/c:1,this._bins=c;let d=Array.from({length:c},()=>[]),u=[];for(let f of o){let p=this._binOf(e[f].start),w=this._binOf(t[f]);if(w-p>Ou)u.push(f);else for(let m=p;m<=w;m++)d[m].push(f)}this._long=u,this._binStart=new Int32Array(c+1);for(let f=0;f<c;f++)this._binStart[f+1]=this._binStart[f]+d[f].length;this._binItems=Int32Array.from(d.flat());let l=new Map(r.map((f,p)=>[f.slot,p])),h=[];this._fixStart=new Int32Array(e.length+1);for(let f=0;f<e.length;f++){for(let p of e[f].writes){let w=l.get(p);w!==void 0&&h.push(w)}this._fixStart[f+1]=h.length}this._fixTracks=Int32Array.from(h)}_held;_from;_width;_bins;_binStart;_binItems;_long;_fixStart;_fixTracks;_binOf(e){let t=Math.floor((e-this._from)/this._width);return t<0?0:t>=this._bins?this._bins-1:t}},_n=2147483647,Tu=1024,Ou=32,ds=class{slot;finish;order;ends;_best;constructor(e,t){this.slot=e,t.sort((s,o)=>s.finish-o.finish||s.order-o.order),this.finish=Float64Array.from(t,s=>s.finish),this.order=Int32Array.from(t,s=>s.order),this.ends=t.map(s=>s.end),this._best=new Int32Array(t.length);let r=0;for(let s=0;s<t.length;s++)this.order[s]>this.order[r]&&(r=s),this._best[s]=r}at(e){let t=0,r=this.finish.length;for(;t<r;){let s=t+r>>>1;this.finish[s]<=e?t=s+1:r=s}return t===0?-1:this._best[t-1]}};function Eu(n,e){if(!(e>0))return n;let t=s=>(s-n)/e>=1,r=n+e;if(!Number.isFinite(r))return NaN;for(let s=0;!t(r);s++){if(s===8)return NaN;r=ja(r,!0)}for(let s=0;s<8;s++){let o=ja(r,!1);if(!t(o))return r;r=o}return NaN}var us=new Float64Array(1),Cu=new BigInt64Array(us.buffer);function ja(n,e){return n===0?e?Number.MIN_VALUE:-Number.MIN_VALUE:(us[0]=n,Cu[0]+=n>0===e?1n:-1n,us[0])}var Pu=16;function Xa(n,e,t,r,s={}){if(t.kindChanged||t.themeChanged||Va(n)||Va(e))return null;let o=n.nodes.get(b),i=e.nodes.get(b);if(t.rootChanged&&!Du(o,i)||e.issues.unparsable||e.issues.unresolvedRefs||t.remappedKeys.size>0)return null;let a=Ka(n,r),c=a&&Ka(e,r);if(!a||!c)return null;let{added:d,removed:u,respec:l,moved:h,span:f,reorderedParents:p}=t.nodes,w=g=>(e.byTarget.get(g)?.length??0)>0,m=(g,S,C,q)=>g.byTarget.get(C)?.some(G=>q(S.get(G)))??!1,y=g=>m(n,a,g,S=>!S.known)||m(e,c,g,S=>!S.known),_=(g,S)=>{let C=g.nodes.get(S)?.type;return C===void 0||r.dimensionOf?.(C)!=="audio"},v=g=>_(n,g)||_(e,g),A=[];for(let g of e.nodes.keys())g!==b&&n.nodes.has(g)&&A.push(g);let M=new Set,T=g=>{let S=n.nodes.get(g)?.type,C=e.nodes.get(g)?.type;return S!==void 0&&r.isContextProvider(S)||C!==void 0&&r.isContextProvider(C)},D=g=>{if(!M.has(g)&&(M.add(g),T(g)))for(let S of e.descendants(g))M.add(S)};for(let g of l)D(g);for(let g of h)if(D(g),Ya(n,g,r)||Ya(e,g,r))for(let S of e.descendants(g))M.add(S);for(let g of[...d,...u])if(T(g))for(let S of e.descendants(g))M.add(S);let V=!1;for(let g of A){let S=r.ctorOf(g);S!==void 0&&r.registeredCtor(e.nodes.get(g).type)!==S&&(D(g),v(g)&&(V=!0)),w(g)&&n.initialKey(g)!==e.initialKey(g)&&D(g)}let P=new Set,ee=new Set,ae=g=>{e.variables.has(g)?ee.add(g):e.nodes.has(g)&&P.add(g)};for(let g of t.commands.added)ae(e.targetOf(e.commands.get(g)));for(let g of t.commands.removed)ae(n.targetOf(n.commands.get(g)));for(let g of t.commands.changed)ae(n.targetOf(n.commands.get(g))),ae(e.targetOf(e.commands.get(g)));for(let g of new Set([...n.byTarget.keys(),...e.byTarget.keys()]))$u(n.byTarget.get(g),e.byTarget.get(g))||ae(g);for(let g of t.commands.reorderedAts){for(let S of n.commandsAt(g))ae(n.targetOf(S));for(let S of e.commandsAt(g))ae(e.targetOf(S))}if(t.duration)for(let g of e.commands.values())g.loop?.count===null&&ae(e.targetOf(g));for(let g of t.variables.added)ee.add(g);for(let g of t.variables.changed)ee.add(g);let rt=new Set;for(let g of A)Fu(n.effSpan(g),e.effSpan(g))?w(g)&&(n.captureKey(g)!==e.captureKey(g)||n.captureTime(g)!==e.captureTime(g))&&P.add(g):(rt.add(g),w(g)&&P.add(g));let H=p.size>0||V||[...d].some(g=>_(e,g))||[...u].some(g=>_(n,g))||[...h].some(v)||[...f].some(v)||[...l].some(g=>v(g)&&qa(n.nodes.get(g),e.nodes.get(g),r))||t.rootChanged&&qa(o,i,r),te=new Set([...d,...u,...rt]);t.rootChanged&&te.add(b);let Qc=[...Ua(n,r),...Ua(e,r)],Bs=(g,S)=>{let C=e.nodes.get(g)?.type;if(C===void 0||r.dimensionOf?.(C)==="audio")return!1;for(let[q,G]of e.bindings(g))if(S(G)&&!r.isLayoutNeutralProp(C,q))return!0;return!1},js=-1;for(;js!==P.size+ee.size+M.size+te.size+(H?1:0);){js=P.size+ee.size+M.size+te.size+(H?1:0);for(let g of M)w(g)&&P.add(g);for(let g of M)te.add(g);for(let g of P)te.add(g);for(let g of ee)for(let S of e.dependents.byVar.get(g)??[])te.add(S),!H&&Bs(S,C=>C.vars.includes(g))&&(H=!0);for(let g of te)for(let S of Iu(n,e,g))for(let C of e.dependents.byKey.get(S)??[])te.add(C),!H&&Bs(C,q=>q.keys.some(([G])=>G===S))&&(H=!0);for(let{reader:g,ref:S}of Qc)(Ga(n,S,te)||Ga(e,S,te))&&te.add(g);for(let g of te)e.nodes.has(g)&&w(g)&&P.add(g);for(let g of P)g!==b&&y(g)&&D(g);if(!H){for(let g of[...P,...ee])if(m(n,a,g,S=>S.writesLayout)||m(e,c,g,S=>S.writesLayout)){H=!0;break}}if(H)for(let g of e.byTarget.keys())e.nodes.has(g)&&m(e,c,g,S=>S.readsLayout)&&P.add(g)}if(P.has(b)&&y(b))return null;let ed=Math.max((s.rebuildFraction??.5)*e.nodeCount,s.minRebuildNodes??Pu);if(M.size>ed)return null;let st;if([...P,...ee].some(g=>m(e,c,g,S=>S.readsLayout||!S.known)))st="all";else{st=new Set;let g=[],S=new Set;for(let C of P){let q=e.refs(C);q.vars.length===0&&q.keys.length===0||(e.byTarget.get(C)??[]).some(G=>e.commands.get(G).type!=="set")&&(S.add(C),g.push(C))}for(;g.length>0;){let C=e.refs(g.pop());for(let q of C.vars)!ee.has(q)&&w(q)&&st.add(q);for(let[q]of C.keys){let G=e.keyed.get(q);G!==void 0&&(!P.has(G)&&w(G)&&st.add(G),S.has(G)||(S.add(G),g.push(G)))}}}let Wn=new Set([...u,...M]);for(let g of p)for(let S of e.children(g))n.nodes.has(S)&&Wn.add(S);for(let g of M)for(let S of e.children(g))Wn.add(S);let Hn=[];for(let g of new Set([...P,...M,...d])){if(!w(g))continue;let S=e.captureTime(g);S!==void 0&&Hn.push({at:S,id:g})}return Hn.sort((g,S)=>g.at-S.at),{prev:n,next:e,diff:t,added:d,removed:u,reinstantiate:M,detach:Wn,dirtyNodes:P,dirtyVariables:ee,replay:st,captures:Hn,layoutChanged:H}}function Va(n){let{duplicateIds:e,duplicateKeys:t,unresolvedParent:r,cycle:s,invalidRoot:o}=n.issues;return e||t||r||s||o}function Ka(n,e){let t=new Map;for(let r of n.ordered){let s=n.targetOf(r),o=n.nodes.get(s),i=e.traits(r,o);if(!i||i.lifecycle||(i.scope==="variable"?!n.variables.has(s):!o))return null;t.set(r.id,i)}return t}function Ua(n,e){if(!e.nodeRefs)return[];let t=[];for(let r of n.ordered){let s=n.targetOf(r);for(let o of e.nodeRefs(r,n.nodes.get(s)))t.push({reader:s,ref:o})}return t}function Ga(n,e,t){let r=new Set,s=e;for(;s!==void 0&&!r.has(s);){if(t.has(s))return!0;r.add(s);let o=n.nodes.get(s);if(!o||s===b)return!1;s=o.parentId??b}return!1}function Ya(n,e,t){let r=new Set([e]),s=n.nodes.get(e);for(;s&&s.id!==b;){let o=s.parentId??b;if(r.has(o))return!1;if(r.add(o),s=n.nodes.get(o),s&&t.isContextProvider(s.type))return!0}return!1}function Du(n,e){let t=U(n),r=U(e);return n.type===e.type&&n.key===e.key&&n.parentId===e.parentId&&n.layerOrder===e.layerOrder&&t.start===r.start&&t.end===r.end}function qa(n,e,t){if(n.type!==e.type||n.key!==e.key)return!0;for(let r of new Set([...Object.keys(n.props),...Object.keys(e.props)]))if(!Y(n.props[r],e.props[r])&&!t.isLayoutNeutralProp(e.type,r))return!0;return!1}function Iu(n,e,t){let r=[],s=n.nodes.get(t)?.key,o=e.nodes.get(t)?.key;return s&&r.push(s),o&&o!==s&&r.push(o),r}function Fu(n,e){return n?.start===e?.start&&n?.end===e?.end}function $u(n,e){if(n===e)return!0;if(!n||!e||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function Nu(n,e){if(n)switch(n.kind){case"linear":return Xs();case"in":return Ws(n.args);case"out":return Hs(n.args);case"inOut":return Zs(n.args);case"custom":{let t=n.args;if(dn(t))return aa(t);if(typeof t!="string")throw new Error(`A "custom" ease needs a curve or its Registry.addEase key in \`args\` (got ${JSON.stringify(n.args)}).`);let r=e.ease(t);if(!r)throw new Error(`No ease registered under "${t}". Registered: ${e.easeKeys().join(", ")||"none"}.`);return r}}}function Ru(n){return n.map((e,t)=>({spec:e,index:t})).sort((e,t)=>e.spec.at-t.spec.at||e.index-t.index).map(e=>e.spec)}function zu(){return{id:b,type:"canvas2d",parentId:null,layerOrder:0,props:{}}}function Wa(n){let e=[],t;for(let r of n){if(r.id===b&&r.type==="canvas2d"){t=r;continue}e.push(r)}return{root:t??zu(),rest:e}}function Ha(n){let e=new Map;for(let t of n.nodes)e.set(t.id,U(t));return e.delete(b),e}var vn=class{canvas;constructor(e,t,r){this.canvas=r,this._doc=e,this._registry=t;let{root:s,rest:o}=Wa(e.nodes);this._rootSpec=s,this._specs=o,this._varSpecs=e.variables??[],this._keyed=new Map([s,...o].filter(i=>!!i.key).map(i=>[i.key,i.id])),this._spans=Ha(e),this._duration=de(e)}get duration(){return this._duration}build(){this._buildVariables(),this._pristineRoot=mr(this.canvas),this._applyRootProps();for(let e of this._specs)this._live.set(e.id,{spec:e,node:this._instantiate(e),initial:Oe,initialStackDepth:0,baseline:Oe,baseStackDepth:0,presence:new ct(!1,null,Se+e.id)});this._baseChildCount.set(b,this.canvas._allChildren.length);for(let[e,t]of this._live)this._baseChildCount.set(e,t.node._allChildren.length);this.syncPresence(0),this._root={spec:this._rootSpec,node:this.canvas,initial:Oe,initialStackDepth:0,baseline:Oe,baseStackDepth:0,presence:new ct(!0,null,Se+b)};for(let e of this._live.values())xn(e);xn(this._root),this._baselined=new Set(this._present);for(let e of this._present)this._live.get(e)?.node.mounted===!1&&(this._baselined.delete(e),this._unmounted.add(e))}compile(e=()=>{}){this._settled=null,this._compileCommands(e),this._restoreBaselines();let t=this.syncPresence(0);(this._restoreDisplaced(this._collectDisplaced())||t)&&e(),this._indexSettled()}variableValue(e){return this._vars.get(e)?.cell.get()}variables(){return this._varSpecs}get presenceTime(){return this._presenceIndex().time}commandSounds(){let e=[];for(let t of this._placed){let r=wo(t.command);if(r)for(let s of r.sounds)e.push({node:r.host,at:t.start+s.at,until:s.until===void 0?void 0:t.start+s.until,src:s.src,options:s.options})}return e}placedCommands(){return this._placed}evaluateAt(e,t){if(t){zt(()=>this._restoreBaselines()),this._evaluateObserved(e,t);return}if(this._settled){this._restoreBaselines(this._wholeRestore);for(let{slot:r,baseline:s}of this._slotRestore)r.restoreFrom(s);this._settled.evaluate(this._placed,e);return}this._restoreBaselines();for(let r of this._placed){if(e<r.start)continue;let s=r.duration>0?(e-r.start)/r.duration:1;r.command.at(it(s))}}syncPresence(e){let t=this._presenceIndex().crossed(e);if(t.length===0)return!1;let r=[],s=[];for(let i of t){let a=bn(i,e);a!==this._present.has(i.id)&&(a?r:s).push(i)}if(this._arrived=r,r.length===0&&s.length===0)return!1;s.sort(Qa);for(let i of s){this._present.delete(i.id),i.siblings.add(i.slot,-1);let a=this._live.get(i.id);a&&(a.presence.set(!1),this._parentNodeOf(a.spec)?.remove(a.node))}r.sort(Qa);let o=new Map;for(let i of r){let a=o.get(i.siblings);a?a.push(i):o.set(i.siblings,[i])}for(let[i,a]of o){a.sort((u,l)=>u.slot-l.slot);let c=i.parentId===b?this.canvas:this._live.get(i.parentId)?.node,d=this._baseChildCount.get(i.parentId)??0;for(let u of a){this._present.add(u.id);let l=d+i.before(u.slot);i.add(u.slot,1);let h=this._live.get(u.id);h&&(h.presence.set(!0),c?.addChildAt({data:{child:h.node,index:l}}))}}return!0}liveNode(e){return e===b?this.canvas:this._live.get(e)?.node}baselineProps(e){let t=e===b?this._root:this._live.get(e);if(!t)return;let r=t.baseline===Oe?t.initial:t.baseline,s={};for(let[o,i]of r)s[o]=i.fn?i.fn():i.value;return s}presenceSlot(e){return e===b?this._root?.presence:this._live.get(e)?.presence}variableSlot(e){return this._vars.get(e)?.cell}planUpdate(e){let t=this._docIndex??=cs(this._doc);return Xa(t,cs(e),gn(this._doc,e),this._patchEnvironment())}applyUpdate(e,t,r){if(!this._root)throw new Error("ClipTimeline.applyUpdate needs a built timeline.");if(e.prev!==this._docIndex)throw new Error("This patch was planned against a different version of the document.");this._settled=null,this._restoreBaselines(),this.syncPresence(0),this._updateVariables(e),this._keyed.clear();for(let[l,h]of e.next.keyed)this._keyed.set(l,h);let s=this._updateStructure(e);for(let l of s){xn(l);let h=l.spec.id;this._present.has(h)&&(l.node.mounted?this._baselined.add(h):this._unmounted.add(h))}if(e.diff.rootChanged){let l=this.canvas;Lt(l,this._pristineRoot),l._stateStack.length=0,this._applyRootProps(),xn(this._root)}for(let l of e.dirtyNodes){let h=l===b?this._root:this._live.get(l);h&&!s.has(h)&&Bu(h)}r();let o=new Map;for(let l of this._placed)o.set(l.spec.id,l);let i=this._walkPatch(e,o,t),a=l=>e.dirtyNodes.has(l)||e.dirtyVariables.has(l),c=[],d=new Set;if(this._animated=[],this._animatedVars=[],this._animatedParts=[],!Ge(this._doc))for(let l of e.next.ordered){let h=i.get(l.id);if(!h&&!a(e.next.targetOf(l))){let f=o.get(l.id);f&&(h=f.spec===l?f:{...f,spec:l})}h&&(c.push(h),this._touch(h,d))}this._placed=c,this._restoreBaselines();let u=this.syncPresence(0);(this._restoreDisplaced(this._collectDisplaced())||u)&&t(),this._indexSettled()}_doc;_registry;_rootSpec;_specs;_varSpecs;_spans;_duration;_docIndex=null;_pristineRoot=Oe;_live=new Map;_vars=new Map;_keyed;_placed=[];_settled=null;_wholeRestore=[];_slotRestore=[];_root=null;_animated=[];_animatedVars=[];_animatedParts=[];_partBaselines=new WeakMap;_baseChildCount=new Map;_present=new Set;_baselined=new Set;_displaced=[];_unmounted=new Set;_presence=null;_arrived=[];_resolveVariable=e=>{let t=e.indexOf(".");if(t>0){let r=this._keyed.get(e.slice(0,t));if(r===void 0)return;let s=e.slice(t+1);return()=>this._nodeById(r)?.[s]}return this._vars.get(e)?.read};_nodeById(e){if(e===b)return this.canvas;let t=this._live.get(e);if(t)return eo!==null&&this._readPresence(t),t.node.mounted?t.node:void 0}_readPresence(e){let t=e;for(let r=0;t&&r<=this._live.size;r++)t.presence.get(),t=t.spec.parentId===null?void 0:this._live.get(t.spec.parentId)}_applyRootProps(){let{literal:e,bindings:t}=L.bindProps(this._rootSpec.props,this._resolveVariable);this.canvas.set({...e,...t})}_instantiate(e){let{literal:t,bindings:r,hasBindings:s}=L.bindProps(e.props,this._resolveVariable),o=this._registry.instantiate(e,t);return s&&o.set(r),o}_buildVariables(){for(let e of this._varSpecs){if(this._vars.has(e.id))throw new Error(`Duplicate variable id "${e.id}". Ids must be unique \u2014 an expression writing "[${e.id}]" would otherwise name whichever declaration was read last.`);this._vars.set(e.id,this._liveVariable(e))}}_liveVariable(e){let t=new ct(e.value,null,Rt+e.id);return{spec:e,cell:t,read:()=>t.get(),target:this._variableTarget(e,t),baseline:e.value}}_variableTarget(e,t){let r=this._registry.requireLerp(e.lerp,e.value,`variable "${e.id}"`);return{id:e.id,get:()=>t.get(),set:s=>t.set(s),lerp:r}}_restoreBaselines(e=this._animated){this._restoreDisplaced(this._displaced);for(let t of this._animatedVars)t.cell.set(t.baseline);for(let t of e){let r=t.node;Lt(r,t.baseline),r._stateStack.length>t.baseStackDepth&&(r._stateStack.length=t.baseStackDepth)}for(let t of this._animatedParts)t.restoreFrom(this._partBaselines.get(t))}_compileCommands(e){if(Ge(this._doc))return;let t=new Set,r=Ru(this._doc.commands),s=this._refBound(r),o=this._settleWindows(r,i=>this._readsLayout(r[i],s));for(let i=0;i<r.length;i++){let a=r[i];if(this.syncPresence(a.at)){for(let d of this._arrived)this._baselined.has(d.id)||this._baselineArrival(d.id);this._baselineMounted(),o[i]&&e()}let c=this._buildPlaced(a);this._placed.push(c),this._touch(c,t)}}_indexSettled(){let e=this._settled=wn.build(this._placed);if(!e)return;this._restoreBaselines();let t=new Set,r=new Map;this._placed.forEach((s,o)=>{let i=e.holds(o);i||t.add(s.owner);for(let a of s.writes){let c=a._host,d=c===null?void 0:c.id===b?this._root:this._live.get(c.id);d&&(i?r.has(d)?r.get(d).add(a):r.set(d,new Set([a])):t.add(d))}}),this._wholeRestore=[],this._slotRestore=[];for(let s of this._animated){let o=t.has(s)?null:Lu(s,r.get(s));o?this._slotRestore.push(...o):this._wholeRestore.push(s)}}_collectDisplaced(){let e=[];for(let t of this._present){let r=this._live.get(t),s=r&&this._declaredParent(t);r&&s&&r.node.parent!==s&&e.push(r)}return e.sort((t,r)=>this._presenceIndex().row(t.spec.id).slot-this._presenceIndex().row(r.spec.id).slot),this._displaced=e}_restoreDisplaced(e){let t=!1;for(let r of e){let s=r.spec.id,o=this._presenceIndex().row(s),i=this._declaredParent(s);if(!o||!i||!this._present.has(s)||r.node.parent===i)continue;r.node.parent?.remove(r.node);let a=this._baseChildCount.get(o.siblings.parentId)??0;i.addChildAt({data:{child:r.node,index:a+o.siblings.before(o.slot)}}),t=!0}return t}_declaredParent(e){let t=this._presenceIndex().row(e)?.siblings.parentId;if(t!==void 0)return t===b?this.canvas:this._live.get(t)?.node}_baselineArrival(e){let t=this._live.get(e);if(t&&!t.node.mounted){this._unmounted.add(e);return}t&&fs(t),this._baselined.add(e),this._unmounted.delete(e)}_baselineMounted(){for(let e of this._unmounted){let t=this._live.get(e);t?t.node.mounted&&(fs(t),this._baselined.add(e),this._unmounted.delete(e)):this._unmounted.delete(e)}}_buildPlaced(e){let t=this._registry.command(e.type);if(!t){let h=this._targetOrThrow(e).entry.spec.type,f=this._registry.nodeCommand(h,e.type);if(!f)throw new Error(`Node type "${h}" has no command "${e.type}" (command ${e.id}). It publishes: ${this._registry.commandKeys(h).join(", ")||"none"}.`+(Za[e.type]?` ${Za[e.type]}`:""));t={key:e.type,scope:"node",factory:f}}let r=e.duration??0,s=Nu(e.easing,this._registry),o=new ls(this._notePartWrite),i=no(e.loop)?e.loop:void 0,a=h=>h&&i?so(h,i,this._unlimitedFill(e.at)):h;if(t.scope==="variable"){let h=e.targetId===null?void 0:this._vars.get(e.targetId);if(!h)throw new Error(`Command ${e.id} ("${e.type}") targets variable "${e.targetId}", which this document does not declare.`);this._assertNoExpressions(e);let{factory:f}=t,p=pe(o,()=>Ja(()=>a(f(h.target,e.args,r,s))));return{spec:e,start:e.at,duration:i?p.duration:r,command:p,writes:o.writes,readsLayout:o.readsLayout,owner:h}}let c=this._targetOrThrow(e),d=t.binds?this._bindArgs(e.args):(this._assertNoExpressions(e),e.args),{factory:u}=t,l=pe(o,()=>Ja(()=>a(u(c.node,d,r,s))));return{spec:e,start:e.at,duration:i?l.duration:r,command:l,writes:o.writes,readsLayout:o.readsLayout,owner:c.entry}}_unlimitedFill(e){return Math.max(0,this._duration-e)}_touch(e,t){this._touchOwner(e.owner,t);for(let r of e.writes){let s=r._host;if(s===null)continue;let o=s.id===b?this._root:this._live.get(s.id);o?this._touchOwner(o,t):this._partBaselines.has(r)&&!t.has(r)&&(t.add(r),this._animatedParts.push(r))}}_touchOwner(e,t){t.has(e)||(t.add(e),"cell"in e?this._animatedVars.push(e):this._animated.push(e))}_notePartWrite=e=>{let t=e._host;t===null||this._partBaselines.has(e)||t.id===b||this._live.has(t.id)||this._partBaselines.set(e,e.snapshot())};_bindArgs(e){let{literal:t,bindings:r}=L.bindProps(e,this._resolveVariable,"args");return{...t,...r}}_assertNoExpressions(e){let t=L.collect(e.args,"args");if(t.length===0)return;let{path:r,source:s}=t[0];throw new Error(`Command ${e.id} ("${e.type}") carries an expression at ${r}: ${JSON.stringify(s)}. Expressions bind a prop to a variable; they are not tween destinations. Bind the prop where the node is authored (or with a "set" command) and animate the variable with "variableTo" instead.`)}_targetOrThrow(e){let t=this._targetOf(e);if(!t)throw new Error(`Command ${e.id} ("${e.type}") targets node "${e.targetId}", which this document does not declare.`);return t}_targetOf(e){if(e.targetId===null)return this._root?{id:b,node:this._root.node,entry:this._root}:null;let t=this._live.get(e.targetId);return t?{id:e.targetId,node:t.node,entry:t}:null}_evaluateObserved(e,t){let r=0;pe({read:()=>{},write:o=>t(r,o)},()=>{for(;r<this._placed.length;r++){let o=this._placed[r];if(e<o.start)continue;let i=o.duration>0?(e-o.start)/o.duration:1;o.command.at(it(i))}})}_settleWindows(e,t){let r=this._presenceIndex(),s=new Uint8Array(e.length),o=-1,i=r.time;for(let a=0;a<e.length;a++){let{at:c}=e[a];r.differs(i,c)&&(o=a),i=c,!(o<0||s[o])&&t(a)&&(s[o]=1)}return s}_readsLayout(e,t){let r=e.targetId??b,s=e.targetId===null?this._rootSpec:this._live.get(e.targetId)?.spec,o=ns(this._registry,e,s);return o===null||o.readsLayout||t.has(r)}_refBound(e){let t=new Set;for(let r of e){let s=this._registry.command(r.type);s?.scope==="node"&&s.binds&&rs(r.args)&&t.add(r.targetId??b)}return t}_presenceIndex(){return this._presence??=new kn(this._specs,this._spans)}_parentNodeOf(e){return e.parentId===null?this.canvas:this._live.get(e.parentId)?.node}_patchEnvironment(){let e=this._registry;return{traits:(t,r)=>ns(e,t,r),nodeRefs:(t,r)=>Oa(e,t,r),isContextProvider:t=>mn(e,t),isLayoutNeutralProp:(t,r)=>ss(e,t,r),ctorOf:t=>this._live.get(t)?.node.constructor,registeredCtor:t=>e.node(t)?.ctor,dimensionOf:t=>e.node(t)?.descriptor.dimension}}_updateVariables(e){let{added:t,removed:r,changed:s}=e.diff.variables;for(let o of r)this._vars.delete(o);for(let o of t)this._vars.set(o,this._liveVariable(e.next.variables.get(o)));for(let o of s){let i=e.next.variables.get(o),a=this._vars.get(o);if(!a){this._vars.set(o,this._liveVariable(i));continue}a.baseline=i.value,a.target=this._variableTarget(i,a.cell)}for(let o of e.next.variables.values()){let i=this._vars.get(o.id);i&&(i.spec=o)}for(let o of e.dirtyVariables){let i=this._vars.get(o);i&&i.cell.set(i.baseline)}}_updateStructure(e){let{next:t}=e;for(let c of e.detach){let d=this._live.get(c);d&&(d.node.parent?.remove(d.node),d.presence.set(!1),this._present.delete(c))}let r=c=>this._live.get(c.id)?.node===c;for(let c of e.removed){let d=this._live.get(c);d&&(hs(d.node,r),this._live.delete(c),this._baseChildCount.delete(c),this._baselined.delete(c),this._unmounted.delete(c))}for(let c of e.reinstantiate){let d=this._live.get(c);d&&hs(d.node,r)}let{root:s,rest:o}=Wa(t.doc.nodes),i=new Set;for(let c of o){let d=this._live.get(c.id);if(d&&!e.reinstantiate.has(c.id)){d.spec=c;continue}let u=this._instantiate(c);d?(d.spec=c,d.node=u,this._baselined.delete(c.id),this._unmounted.delete(c.id)):(d={spec:c,node:u,initial:Oe,initialStackDepth:0,baseline:Oe,baseStackDepth:0,presence:new ct(!1,null,Se+c.id)},this._live.set(c.id,d)),this._baseChildCount.set(c.id,u._allChildren.length),i.add(d)}this._doc=t.doc,this._docIndex=t,this._rootSpec=s,this._root.spec=s,this._specs=o,this._varSpecs=t.doc.variables??[],this._spans=Ha(t.doc),this._duration=de(t.doc);let a=this._presence=new kn(this._specs,this._spans);for(let c of[...this._present]){let d=a.row(c);if(d&&bn(d,0)){d.siblings.add(d.slot,1);continue}this._present.delete(c);let u=this._live.get(c);u&&(u.presence.set(!1),u.node.parent?.remove(u.node))}return this.syncPresence(0),i}_walkPatch(e,t,r){let s=new Map;if(Ge(this._doc))return s;let{next:o}=e,i=p=>e.dirtyNodes.has(p)||e.dirtyVariables.has(p),a=this._refBound(o.ordered),c=e.replay;c!=="all"&&[...a].some(i)&&(c="all");let d=[],{captures:u}=e,l=0;for(let p of o.ordered){for(;l<u.length&&u[l].at<=p.at;)d.push({at:u[l].at,capture:u[l++].id});let w=o.targetOf(p);(c==="all"||i(w)||c.has(w))&&d.push({at:p.at,spec:p})}for(;l<u.length;l++)d.push({at:u[l].at,capture:u[l].id});let h=this._settleWindows(d,p=>{let w=d[p].spec;return w!==void 0&&i(o.targetOf(w))&&this._readsLayout(w,a)}),f=!1;for(let p=0;p<d.length;p++){let w=d[p];if(h[p]&&(f=!0),this.syncPresence(w.at)&&this._baselineMounted(),w.capture!==void 0){this._baselined.delete(w.capture),this._baselineArrival(w.capture);continue}f&&(r(),f=!1);let m=w.spec,y=t.get(m.id);if(y&&!i(o.targetOf(m))){y.command.at(1);continue}s.set(m.id,this._buildPlaced(m))}return s}},Za={add:"A node is a row in `nodes`, entering at its `startAt`.",remove:"A node leaves at its `endAt`.",variable:"A variable is declared in `variables`."},Oe=new Map,ls=class{firstWrite;writes=new Set;readsLayout=!1;constructor(e){this.firstWrite=e}read(e){e._name===Ke&&(this.readsLayout=!0)}write(e){this.writes.has(e)||(this.firstWrite(e),this.writes.add(e))}};function Ja(n){let e=n();return e?(e.at(1),e):Ie(0,()=>{n()})}function fs(n){let e=n.node;n.baseline=mr(e),n.baseStackDepth=e._stateStack.length}function Lu(n,e){if(!e)return[];let t=n.node.__cells?.slots;if(!t)return null;let r=[];for(let[s,o]of t){let i=e.has(o)?n.baseline.get(s):void 0;i&&r.push({slot:o,baseline:i})}return r.length===e.size?r:null}function xn(n){fs(n),n.initial=n.baseline,n.initialStackDepth=n.baseStackDepth}function Bu(n){let e=n.node;Lt(e,n.initial),e._stateStack.length>n.initialStackDepth&&(e._stateStack.length=n.initialStackDepth),n.baseline=n.initial,n.baseStackDepth=n.initialStackDepth}function hs(n,e){for(let t of n._allChildren)e(t)||hs(t,e);n.dispose()}function bn(n,e){return e>=n.start&&e<n.end}function Qa(n,e){return n.order-e.order}var ps=class{parentId;constructor(e,t){this.parentId=e,this._tree=new Int32Array(t+1)}add(e,t){for(let r=e+1;r<this._tree.length;r+=r&-r)this._tree[r]+=t}before(e){let t=0;for(let r=e;r>0;r-=r&-r)t+=this._tree[r];return t}_tree},kn=class{time=-1/0;constructor(e,t){let r=new Map;e.forEach((s,o)=>{if(!t.has(s.id))return;let i=s.parentId??b,a=r.get(i);a?a.push({spec:s,order:o}):r.set(i,[{spec:s,order:o}])});for(let[s,o]of r){o.sort((a,c)=>a.spec.layerOrder-c.spec.layerOrder);let i=new ps(s,o.length);o.forEach(({spec:a,order:c},d)=>{let{start:u,end:l}=t.get(a.id),h={id:a.id,start:u,end:l,order:c,slot:d,siblings:i,pass:0};this._rows.set(a.id,h),this._events.push({time:u,row:h}),Number.isFinite(l)&&this._events.push({time:l,row:h})})}this._events.sort((s,o)=>s.time-o.time)}crossed(e){this.time=e;let t=this._upperBound(e);if(t===this._cursor)return ju;let r=Math.min(t,this._cursor),s=Math.max(t,this._cursor);this._cursor=t;let o=++this._pass,i=[];for(let a=r;a<s;a++){let{row:c}=this._events[a];c.pass!==o&&(c.pass=o,i.push(c))}return i}differs(e,t){let r=this._upperBound(Math.min(e,t)),s=this._upperBound(Math.max(e,t));for(let o=r;o<s;o++){let{row:i}=this._events[o];if(bn(i,e)!==bn(i,t))return!0}return!1}row(e){return this._rows.get(e)}_events=[];_rows=new Map;_cursor=0;_pass=0;_upperBound(e){let t=0,r=this._events.length;for(;t<r;){let s=t+r>>>1;this._events[s].time<=e?t=s+1:r=s}return t}},ju=[];function mw(n){let e=n.width??0,t=n.height??0,{x:r,y:s,pivot:o}=_o(n,e,t);return{...yo(n),opacity:n.opacity??1,rotation:n.rotation??0,scale:n.scale??1,x:r,y:s,start:n.start??0,end:n.end??1,pivot:Ut(o),spans:n.spans??[],lineHeight:n.lineHeight??1.2,textAlign:n.textAlign??"center",width:e,height:t}}function yw(n){return{x:n.x??0,y:n.y??0,width:n.width??0,height:n.height??0,opacity:n.opacity??1,blend:n.blend??"pass-through",rotation:n.rotation??0,scale:n.scale??1,effects:n.effects??[],pivot:n.pivot??{x:0,y:0},matrix:n.matrix}}function xw(n){return typeof n=="string"?n:n.map(e=>{switch(e.type){case"M":case"m":return`${e.type} ${e.x} ${e.y}`;case"L":case"l":return`${e.type} ${e.x} ${e.y}`;case"T":case"t":return`${e.type} ${e.x} ${e.y}`;case"H":case"h":return`${e.type} ${e.x}`;case"V":case"v":return`${e.type} ${e.y}`;case"C":case"c":return`${e.type} ${e.x1} ${e.y1} ${e.x2} ${e.y2} ${e.x} ${e.y}`;case"S":case"s":return`${e.type} ${e.x2} ${e.y2} ${e.x} ${e.y}`;case"Q":case"q":return`${e.type} ${e.x1} ${e.y1} ${e.x} ${e.y}`;case"A":case"a":return`${e.type} ${e.rx} ${e.ry} ${e.rotation} ${e.largeArc} ${e.sweep} ${e.x} ${e.y}`;case"Z":case"z":return e.type}}).join(" ")}function vw(n){return{opacity:n.opacity??1,rotation:n.rotation??0,scale:n.scale??1,x:n.x??0,y:n.y??0,start:n.start??0,end:n.end??1,width:n.width??0,height:n.height??0,pivot:Ut(n.pivot),data:n.data??"",centerBounds:n.centerBounds}}function ms(n){let e=n.lines[n.lines.length-1];return e?e.end+1:1}function ec(n){return typeof n?.layoutTextBlock=="function"?n:null}var Vu={box:n=>({type:"box",...n}),sphere:n=>({type:"sphere",...n}),plane:n=>({type:"plane",...n}),cylinder:n=>({type:"cylinder",...n}),cone:n=>({type:"cone",...n}),torus:n=>({type:"torus",...n}),torusKnot:n=>({type:"torusKnot",...n}),circle:n=>({type:"circle",...n}),ring:n=>({type:"ring",...n}),capsule:n=>({type:"capsule",...n}),tetrahedron:n=>({type:"polyhedron",shape:"tetrahedron",...n}),octahedron:n=>({type:"polyhedron",shape:"octahedron",...n}),icosahedron:n=>({type:"polyhedron",shape:"icosahedron",...n}),dodecahedron:n=>({type:"polyhedron",shape:"dodecahedron",...n}),extrude:n=>({type:"extrude",...n}),lathe:n=>({type:"lathe",...n}),tube:n=>({type:"tube",...n}),buffer:n=>({type:"buffer",...n}),parametric:n=>({type:"parametric",...n}),edges:(n,e)=>({type:"edges",source:n,...e}),wireframe:n=>({type:"wireframe",source:n}),model:(n,e)=>({type:"modelGeometry",src:n,...e})},Ku={basic:n=>({type:"basic",...n}),standard:n=>({type:"standard",...n}),physical:n=>({type:"physical",...n}),phong:n=>({type:"phong",...n}),lambert:n=>({type:"lambert",...n}),toon:n=>({type:"toon",...n}),normal:n=>({type:"normal",...n}),depth:n=>({type:"depth",...n}),matcap:n=>({type:"matcap",...n}),points:n=>({type:"points",...n}),lineBasic:n=>({type:"lineBasic",...n}),lineDashed:n=>({type:"lineDashed",...n}),sprite:n=>({type:"sprite",...n}),shadow:n=>({type:"shadow",...n}),shader:n=>({type:"shader",...n})},Uu={image:(n,e)=>({src:n,...e}),data:(n,e,t,r)=>({data:n,width:e,height:t,...r}),surface:(n,e)=>({width:512,height:512,...e,source:n})};function Gu(n,e){return n===void 0?e.map(gs):typeof n=="number"?e.map(()=>gs(n)):e.map((t,r)=>gs(n[r]??t))}function gs(n){return Math.max(1,Math.floor(n))}function Yu(n,e){return e<=0?3:Math.max(3,Math.min(16,Math.round(n/e*40)))}function qu(n){let e=[n.width/2,n.height/2,n.depth/2],t=Math.max(e[0],e[1],e[2]),r=Math.max(0,Math.min(n.radius,e[0],e[1],e[2])),s=[Math.max(0,e[0]-r),Math.max(0,e[1]-r),Math.max(0,e[2]-r)],o=Yu(r,t),i=[],a=[],c=[],d=[];for(let u of Xu(e,s,r,n.segments,o))Wu(u,e,i,a,c,d);return{type:"buffer",position:new Float32Array(i),normal:new Float32Array(a),uv:new Float32Array(c),index:new Uint32Array(d),staticData:!0}}function*Xu(n,e,t,r,s){let o=[0,1,2],i=[-1,1];for(let a of o){let c=(a+1)%3,d=(a+2)%3;for(let u of i){let l=Zu(a,u);yield{uSteps:r[c],vSteps:r[d],normal:()=>l,position:(h,f)=>{let p=[0,0,0];return p[a]=u*n[a],p[c]=ys(-e[c],e[c],h),p[d]=ys(-e[d],e[d],f),p}}}}if(!(t<=0)){for(let a of o){let c=(a+1)%3,d=(a+2)%3;for(let u of i)for(let l of i)yield{uSteps:s,vSteps:r[a],normal:h=>{let f=h*Math.PI/2,p=[0,0,0];return p[c]=u*Math.cos(f),p[d]=l*Math.sin(f),p},position:(h,f)=>{let p=h*Math.PI/2,w=[0,0,0];return w[c]=u*(e[c]+t*Math.cos(p)),w[d]=l*(e[d]+t*Math.sin(p)),w[a]=ys(-e[a],e[a],f),w}}}for(let a of i)for(let c of i)for(let d of i){let u=[a*e[0],c*e[1],d*e[2]],l=(h,f)=>{let p=h*Math.PI/2,w=f*Math.PI/2;return[a*Math.sin(p)*Math.cos(w),c*Math.cos(p),d*Math.sin(p)*Math.sin(w)]};yield{uSteps:s,vSteps:s,normal:l,position:(h,f)=>{let p=l(h,f);return[u[0]+t*p[0],u[1]+t*p[1],u[2]+t*p[2]]}}}}}function Wu(n,e,t,r,s,o){let i=t.length/3,a=n.uSteps+1,c=n.vSteps+1;for(let d=0;d<c;d++)for(let u=0;u<a;u++){let l=n.uSteps===0?0:u/n.uSteps,h=n.vSteps===0?0:d/n.vSteps,f=n.position(l,h),p=n.normal(l,h);t.push(f[0],f[1],f[2]),r.push(p[0],p[1],p[2]);let[w,m]=Hu(f,p,e);s.push(w,m)}for(let d=0;d<n.vSteps;d++)for(let u=0;u<n.uSteps;u++){let l=i+d*a+u,h=l+1,f=l+a,p=f+1;tc(t,r,o,l,f,h),tc(t,r,o,h,f,p)}}function tc(n,e,t,r,s,o){let i=n[r*3],a=n[r*3+1],c=n[r*3+2],d=n[s*3],u=n[s*3+1],l=n[s*3+2],h=n[o*3],f=n[o*3+1],p=n[o*3+2],w=d-i,m=u-a,y=l-c,_=h-i,v=f-a,A=p-c,M=m*A-y*v,T=y*_-w*A,D=w*v-m*_;if(M*M+T*T+D*D<1e-20)return;M*e[r*3]+T*e[r*3+1]+D*e[r*3+2]>=0?t.push(r,s,o):t.push(r,o,s)}function Hu(n,e,t){let r=Math.abs(e[0]),s=Math.abs(e[1]),o=Math.abs(e[2]),i=r>=s&&r>=o?0:s>=o?1:2,a=(i+1)%3,c=(i+2)%3;return[t[a]===0?.5:.5+n[a]/(2*t[a]),t[c]===0?.5:.5+n[c]/(2*t[c])]}function Zu(n,e){let t=[0,0,0];return t[n]=e,t}function ys(n,e,t){return n+(e-n)*t}function nc(n){return n===void 0||n===!0?!0:n===!1?!1:n==="cast"||typeof n=="object"}function Ju(n){return n===void 0||n===!0?!0:n===!1?!1:n==="receive"||typeof n=="object"}function Qu(n){return nc(n)?typeof n=="object"?n:{}:null}function ws(n){return n===void 0?[1,1]:typeof n=="number"?[n,n]:[n[0]??1,n[1]??n[0]??1]}function el(n){if(n===void 0)return null;let e=typeof n=="number"?{size:n}:n,t=e.size??.1;return{size:t,thickness:e.thickness??t*2,offset:e.offset??0,segments:e.segments??3}}function tl(n){let e=n.segments,[t,r]=typeof e=="number"?[e,e]:[e[0]??1,e[1]??e[0]??1],s=Math.max(1,Math.floor(t))+1,o=Math.max(1,Math.floor(r))+1,i=new Float32Array(s*o*3),a=new Float32Array(s*o*2),c=n.color?new Float32Array(s*o*3):void 0,d={x:0,y:0,z:0};for(let h=0;h<o;h++){let f=h/(o-1);for(let p=0;p<s;p++){let w=p/(s-1),m=h*s+p,y=n.vertex(w,f);if(Array.isArray(y))d.x=y[0],d.y=y[1],d.z=y[2];else{let _=y;d.x=_.x,d.y=_.y,d.z=_.z}if(i[m*3]=d.x,i[m*3+1]=d.y,i[m*3+2]=d.z,a[m*2]=w,a[m*2+1]=f,c&&n.color){let _=nl(n.color(w,f,d));c[m*3]=_[0],c[m*3+1]=_[1],c[m*3+2]=_[2]}}}let u=new Uint32Array((s-1)*(o-1)*6),l=0;for(let h=0;h<o-1;h++)for(let f=0;f<s-1;f++){let p=h*s+f,w=p+1,m=p+s,y=m+1;u[l++]=p,u[l++]=m,u[l++]=w,u[l++]=w,u[l++]=m,u[l++]=y}return{type:"buffer",position:i,uv:a,color:c,index:u,computeNormals:n.computeNormals,params:n.params}}function nl(n){let[e,t,r]=typeof n=="string"?je(n):n;return[_s(e),_s(t),_s(r)]}function _s(n){return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Sn(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function ue(n,e){let t=new Array(16);for(let r=0;r<4;r++){let s=e[r*4],o=e[r*4+1],i=e[r*4+2],a=e[r*4+3];t[r*4]=n[0]*s+n[4]*o+n[8]*i+n[12]*a,t[r*4+1]=n[1]*s+n[5]*o+n[9]*i+n[13]*a,t[r*4+2]=n[2]*s+n[6]*o+n[10]*i+n[14]*a,t[r*4+3]=n[3]*s+n[7]*o+n[11]*i+n[15]*a}return t}function An(n){let[e,t,r,s,o,i,a,c,d,u,l,h,f,p,w,m]=n,y=u*w*c-p*l*c+p*a*h-i*w*h-u*a*m+i*l*m,_=f*l*c-d*w*c-f*a*h+o*w*h+d*a*m-o*l*m,v=d*p*c-f*u*c+f*i*h-o*p*h-d*i*m+o*u*m,A=f*u*a-d*p*a-f*i*l+o*p*l+d*i*w-o*u*w,M=e*y+t*_+r*v+s*A;if(M===0)return null;let T=1/M;return[y*T,(p*l*s-u*w*s-p*r*h+t*w*h+u*r*m-t*l*m)*T,(i*w*s-p*a*s+p*r*c-t*w*c-i*r*m+t*a*m)*T,(u*a*s-i*l*s-u*r*c+t*l*c+i*r*h-t*a*h)*T,_*T,(d*w*s-f*l*s+f*r*h-e*w*h-d*r*m+e*l*m)*T,(f*a*s-o*w*s-f*r*c+e*w*c+o*r*m-e*a*m)*T,(o*l*s-d*a*s+d*r*c-e*l*c-o*r*h+e*a*h)*T,v*T,(f*u*s-d*p*s-f*t*h+e*p*h+d*t*m-e*u*m)*T,(o*p*s-f*i*s+f*t*c-e*p*c-o*t*m+e*i*m)*T,(d*i*s-o*u*s-d*t*c+e*u*c+o*t*h-e*i*h)*T,A*T,(d*p*r-f*u*r+f*t*l-e*p*l-d*t*w+e*u*w)*T,(f*i*r-o*p*r-f*t*a+e*p*a+o*t*w-e*i*w)*T,(o*u*r-d*i*r+d*t*a-e*u*a-o*t*l+e*i*l)*T]}function le(n,e){let{x:t,y:r,z:s}=e;return{x:n[0]*t+n[4]*r+n[8]*s+n[12],y:n[1]*t+n[5]*r+n[9]*s+n[13],z:n[2]*t+n[6]*r+n[10]*s+n[14],w:n[3]*t+n[7]*r+n[11]*s+n[15]}}function rc(n,e,t){let{x:r,y:s,z:o,w:i}=e,a=r+r,c=s+s,d=o+o,u=r*a,l=r*c,h=r*d,f=s*c,p=s*d,w=o*d,m=i*a,y=i*c,_=i*d;return[(1-(f+w))*t.x,(l+_)*t.x,(h-y)*t.x,0,(l-_)*t.y,(1-(u+w))*t.y,(p+m)*t.y,0,(h+y)*t.z,(p-m)*t.z,(1-(u+f))*t.z,0,n.x,n.y,n.z,1]}function wt(n,e,t=rl){let r=n.x-e.x,s=n.y-e.y,o=n.z-e.z,i=Math.hypot(r,s,o);i===0&&(o=1,i=1),r/=i,s/=i,o/=i;let a=t.y*o-t.z*s,c=t.z*r-t.x*o,d=t.x*s-t.y*r,u=Math.hypot(a,c,d);u===0&&(Math.abs(t.z)===1?r+=1e-4:o+=1e-4,i=Math.hypot(r,s,o),r/=i,s/=i,o/=i,a=t.y*o-t.z*s,c=t.z*r-t.x*o,d=t.x*s-t.y*r,u=Math.hypot(a,c,d)),a/=u,c/=u,d/=u;let l=s*d-o*c,h=o*a-r*d,f=r*c-s*a;return[a,c,d,0,l,h,f,0,r,s,o,0,0,0,0,1]}var rl={x:0,y:1,z:0};function xt(n,e){if(!n)return Sn();let t=Z(n.position),r=Z(n.scale===void 0?1:n.scale);if(n.lookAt!==void 0){let o=Z(n.lookAt),i=e?le(e,t):{...t,w:1},a={x:i.x,y:i.y,z:i.z},c=wt(o,a);if(e){let d=An(sc(e));d&&(c=ue(d,c))}return ue(ue(vt(t),c),ol(r))}let s=n.quaternion??_r(sl(n.rotation));return rc(t,s,r)}function sl(n){return{...Z(n),order:n?.order}}function vt(n){return[1,0,0,0,0,1,0,0,0,0,1,0,n.x,n.y,n.z,1]}function ol(n){return[n.x,0,0,0,0,n.y,0,0,0,0,n.z,0,0,0,0,1]}function sc(n){let e=Math.hypot(n[0],n[1],n[2])||1,t=Math.hypot(n[4],n[5],n[6])||1,r=Math.hypot(n[8],n[9],n[10])||1;return[n[0]/e,n[1]/e,n[2]/e,0,n[4]/t,n[5]/t,n[6]/t,0,n[8]/r,n[9]/r,n[10]/r,0,0,0,0,1]}function Mn(n,e,t,r,s){let o=t*Math.tan(n*Math.PI/360)/s,i=2*o,a=e*i,c=-.5*a;return il(c,c+a,o,o-i,t,r)}function il(n,e,t,r,s,o){let i=2*s/(e-n),a=2*s/(t-r),c=(e+n)/(e-n),d=(t+r)/(t-r),u=-(o+s)/(o-s),l=-2*o*s/(o-s);return[i,0,0,0,0,a,0,0,c,d,u,-1,0,0,l,0]}function xs(n,e,t,r,s,o,i){let a=(e-n)/(2*i),c=(t-r)/(2*i),d=(e+n)/2,u=(t+r)/2,l=d-a,h=d+a,f=u+c,p=u-c,w=1/(h-l),m=1/(f-p),y=1/(o-s);return[2*w,0,0,0,0,2*m,0,0,0,0,-2*y,0,-(h+l)*w,-(f+p)*m,-(o+s)*y,1]}function W(n,e,t){return{min:{x:-n,y:-e,z:-t},max:{x:n,y:e,z:t}}}function bt(n,e){return n?e?{min:{x:Math.min(n.min.x,e.min.x),y:Math.min(n.min.y,e.min.y),z:Math.min(n.min.z,e.min.z)},max:{x:Math.max(n.max.x,e.max.x),y:Math.max(n.max.y,e.max.y),z:Math.max(n.max.z,e.max.z)}}:n:e}function Tn(n){let{min:e,max:t}=n;return[{x:e.x,y:e.y,z:e.z},{x:t.x,y:e.y,z:e.z},{x:e.x,y:t.y,z:e.z},{x:t.x,y:t.y,z:e.z},{x:e.x,y:e.y,z:t.z},{x:t.x,y:e.y,z:t.z},{x:e.x,y:t.y,z:t.z},{x:t.x,y:t.y,z:t.z}]}function Ze(n,e){let t=1/0,r=1/0,s=1/0,o=-1/0,i=-1/0,a=-1/0;for(let c of Tn(n)){let d=le(e,c);d.x<t&&(t=d.x),d.y<r&&(r=d.y),d.z<s&&(s=d.z),d.x>o&&(o=d.x),d.y>i&&(i=d.y),d.z>a&&(a=d.z)}return{min:{x:t,y:r,z:s},max:{x:o,y:i,z:a}}}function On(n){if(!n)return null;switch(n.type){case"box":return W((n.width??1)/2,(n.height??1)/2,(n.depth??1)/2);case"sphere":return W(n.radius??1,n.radius??1,n.radius??1);case"plane":return W((n.width??1)/2,(n.height??1)/2,0);case"cylinder":{let[e,t]=ws(n.radius),r=Math.max(e,t);return W(r,(n.height??1)/2,r)}case"cone":{let e=n.radius??1;return W(e,(n.height??1)/2,e)}case"torus":{let e=n.radius??1,t=n.thickness??.4;return W(e+t,e+t,t)}case"torusKnot":{let e=n.radius??1,t=n.thickness??.4;return W(e*1.5+t,e*1.5+t,e*.5+t)}case"circle":return W(n.radius??1,n.radius??1,0);case"ring":{let e=n.radius??1;return W(e,e,0)}case"capsule":{let e=n.radius??.5;return W(e,(n.height??1)/2+e,e)}case"polyhedron":{let e=n.radius??1;return W(e,e,e)}case"lathe":{let e=0,t=1/0,r=-1/0;for(let s of n.points){let o=Z(s);e=Math.max(e,Math.abs(o.x)),t=Math.min(t,o.y),r=Math.max(r,o.y)}return Number.isFinite(t)?{min:{x:-e,y:t,z:-e},max:{x:e,y:r,z:e}}:null}case"tube":{let e=n.points.map(r=>Z(r)),t=al(e);return t?dl(t,n.radius??1):null}case"buffer":return cl(n.position);case"edges":case"wireframe":return On(n.source);default:return null}}function al(n){if(n.length===0)return null;let e=1/0,t=1/0,r=1/0,s=-1/0,o=-1/0,i=-1/0;for(let a of n)a.x<e&&(e=a.x),a.y<t&&(t=a.y),a.z<r&&(r=a.z),a.x>s&&(s=a.x),a.y>o&&(o=a.y),a.z>i&&(i=a.z);return{min:{x:e,y:t,z:r},max:{x:s,y:o,z:i}}}function cl(n){if(n.length<3)return null;let e=1/0,t=1/0,r=1/0,s=-1/0,o=-1/0,i=-1/0;for(let a=0;a+2<n.length;a+=3){let c=n[a],d=n[a+1],u=n[a+2];c<e&&(e=c),d<t&&(t=d),u<r&&(r=u),c>s&&(s=c),d>o&&(o=d),u>i&&(i=u)}return{min:{x:e,y:t,z:r},max:{x:s,y:o,z:i}}}function dl(n,e){return{min:{x:n.min.x-e,y:n.min.y-e,z:n.min.z-e},max:{x:n.max.x+e,y:n.max.y+e,z:n.max.z+e}}}var ul=["color","opacity","visible","emission","emissionStrength","roughness","metalness","shininess","specular","reflectivity","clearcoat","clearcoatRoughness","transmission","thickness","ior","sheen","sheenColor","sheenRoughness","iridescence","iridescenceIOR","specularIntensity","specularColor","anisotropy","anisotropyRotation","attenuationColor","attenuationDistance","aoMapIntensity","lightMapIntensity","envMapIntensity","normalScale","displacementScale","displacementBias","size","width","dashSize","gapSize","scale","rotation","depthWrite","depthTest","polygonOffsetFactor","polygonOffsetUnits"],ll=["transparent","alphaTest","faces","wireframe","blend","vertexColors","toneMapped","shading","dithering","polygonOffset","raw","extends","defines"];var En=class{onError;precomp;storageAdapter;audioDevice;lastAudioRequestKey="";lastAudioSrcs=new Set;audioFetching=new Map;audioFailed=new Map;audioReported=new Set;audioRequired=new Set;layoutGateKeys;disposed=!1;loaderDisposers=new Map;loaderInFlight=new Map;constructor(e,t,r,s=o=>console.error(`[AssetManager] ${o.message}`)){this.onError=s,this.precomp=e,this.layoutGateKeys=oc(e),this.storageAdapter=t,this.audioDevice=r}setPrecomp(e){this.precomp=e,this.layoutGateKeys=oc(e);for(let t of this.audioReported)this.audioFailed.delete(t);this.audioReported.clear(),this.lastAudioRequestKey=null,this.lastAudioSrcs=null}async loadAt(e){let t=[];for(let[r,s]of this.precomp.assets){if(s.record.type==="loader"){let o=this.syncLoader(r,s,e);o&&t.push(o);continue}s.cacheAt<=e&&s.record.endFrame>=e&&t.push(this.storageAdapter.loadAsset(r,s.record))}await Promise.all(t),this.audioDevice.schedulesAudio&&this.syncAudio(e)}isReady(e){return this.loaderDisposers.has(e)||this.storageAdapter.isLoaded(e)}async loadRecords(e){await Promise.all(e.map(t=>t.type==="loader"?this.runLoader(t.src,t.load):this.storageAdapter.loadAsset(t.src,t)))}prefetch(e){for(let[t,r]of this.precomp.assets){if(r.record.type==="loader"){this.syncLoader(t,r,e)?.catch(s=>{console.error(`[AssetManager] loader failed for ${t}:`,s)});continue}r.cacheAt<=e&&r.record.endFrame>=e&&this.storageAdapter.loadAsset(t,r.record).catch(s=>{console.error(`[AssetManager] prefetch failed for ${t}:`,s)})}}syncLoader(e,t,r){if(t.record.type!=="loader")return;let s=t.discardAt??1/0;if(!(t.cacheAt<=r&&r<=s)){if(this.layoutGateKeys.has(e))return;let i=this.loaderDisposers.get(e);i&&(this.loaderDisposers.delete(e),i());return}return this.runLoader(e,t.record.load)}runLoader(e,t){if(this.loaderDisposers.has(e))return;let r=this.loaderInFlight.get(e);if(r)return r;let s=t().then(o=>{this.loaderDisposers.set(e,o??fl)}).finally(()=>{this.loaderInFlight.delete(e)});return this.loaderInFlight.set(e,s),s}dispose(){for(let e of this.loaderDisposers.values())e();this.loaderDisposers.clear(),this.loaderInFlight.clear(),this.disposed=!0}syncAudio(e){let t=e/this.precomp.fps,r=[],s=new Set,o=new Set,i=new Set,a=(d,u)=>{let l=u+d.startAt,h=u+d.endAt;if(h<t||l>t+10)return;d.optional||o.add(d.src);let f=hl(d,u);i.has(f)||(i.add(f),r.push({...d,id:f,startAt:l,endAt:h,...d.bus&&{bus:d.bus.map(p=>({...p,startAt:u+p.startAt,endAt:u+p.endAt}))}}),s.add(d.src))};for(let d of this.precomp.tracks){let u=d.startFrame/this.precomp.fps;for(let l of d.audioRequests)a(l,u)}this.audioRequired=o;for(let d of s)if(!this.audioDevice.has(d)&&!this.audioFetching.has(d)&&!this.audioFailed.has(d)){let u=this.storageAdapter.fetchAudioData(d).then(l=>this.audioDevice.append(d,l)).catch(l=>this.failAudio(d,l)).finally(()=>this.audioFetching.delete(d));this.audioFetching.set(d,u)}for(let[d,u]of this.audioFailed)s.has(d)?o.has(d)&&this.reportAudio(d,u):(this.audioFailed.delete(d),this.audioReported.delete(d));let c=ml(r);c!==this.lastAudioRequestKey&&(this.audioDevice.schedule(r),this.lastAudioRequestKey=c),(this.lastAudioSrcs===null||!gl(this.lastAudioSrcs,s))&&(this.audioDevice.retain(s),this.lastAudioSrcs=s)}failAudio(e,t){this.disposed||(this.audioFailed.set(e,t),this.audioRequired.has(e)&&this.reportAudio(e,t))}reportAudio(e,t){if(this.audioReported.has(e))return;this.audioReported.add(e);let r=t instanceof Error?t.message:String(t);this.onError(new Error(`audio "${e}" could not be loaded: ${r}`,{cause:t}))}};function oc(n){let e=new Set;for(let t of n.tracks)for(let r of t.layoutGates??[])e.add(r);return e}var fl=()=>{};function hl(n,e){return`${n.src}|${e+n.startAt}|${e+n.endAt}|${n.trimStart}|${n.trimEnd??"_"}|${n.loop?1:0}|${n.volume}|${ft(n.filters)}|${pl(n.bus)}`}function pl(n){return!n||n.length===0?"":n.map($r).join(">")}function ml(n){return n.length===0?"":n.map(e=>e.id).sort().join(`
10
+ `)}function gl(n,e){if(n.size!==e.size)return!1;for(let t of n)if(!e.has(t))return!1;return!0}function ic(n){switch(n.type){case"image":case"video":return n.src;case"font":return n.family;case"loader":return n.key}}function yl(n){return typeof n=="number"?Number.isFinite(n)?n:400:typeof n=="string"&&parseInt(n,10)||400}var Cn=class{catalog;constructor(e,t={}){this.catalog=e,this._options=t}get declarations(){return this._decls}image(e){!e||this._decls.has(e)||(this.catalog.getImageMeta(e),this._decls.set(e,{type:"image",src:e}))}video(e,t){!e||this._decls.has(e)||(this.catalog.getVideoMeta(e),this._decls.set(e,{type:"video",src:e,trimStart:t?.start??0,trimEnd:t?.end??this.catalog.getVideoDuration(e)}))}font(e,t){!e||this._decls.has(e)||this._decls.set(e,{type:"font",family:e,weight:yl(t)})}loader(e,t,r){let s=r?.gate??"render",o=this._decls.get(e);if(o===void 0){this._decls.set(e,{type:"loader",key:e,load:t,gate:s});return}o.type==="loader"&&(o.load,s==="layout"&&o.gate!=="layout"&&this._decls.set(e,{...o,gate:s}))}fill(e){if(e){if(!Array.isArray(e)){rr(e,this);return}for(let t of e)rr(t,this)}}effects(e){if(e)for(let t of e)Ks(t,this)}subtree(e){this._subtrees??=new Set,!this._subtrees.has(e)&&(this._subtrees.add(e),this._options.bindSubtree?.(e),this._options.onSubtree?this._options.onSubtree(e,this):Rr(e,this))}_options;_decls=new Map;_subtrees};function xe(){return typeof performance<"u"&&typeof performance.now=="function"?performance.now():Date.now()}function _l(){let n=globalThis.scheduler;return typeof n?.yield=="function"?n.yield.bind(n):void 0}var we=null,vs=[];function wl(){return typeof MessageChannel!="function"?null:(we||(we=new MessageChannel,we.port1.onmessage=()=>vs.shift()?.(),we.port1.unref?.(),we.port2.unref?.()),new Promise(n=>{vs.push(n),we.port2.postMessage(null)}))}function Pn(){let n=_l();return n?n():wl()??new Promise(e=>setTimeout(e,0))}function mv(){we?.port1.close(),we?.port2.close(),we=null,vs.length=0}function Be(n,e){return n*(1/e)}function ve(n,e){let t=n*e,r=Math.round(t);return Math.abs(t-r)<=1e-9*Math.max(1,Math.abs(t))?r:t}function yv(n,e){return{kind:"frame",frame:Math.round(ve(n,e))}}function Je(n,e){return typeof n!="number"||!Number.isFinite(n)?1:Math.max(1,Math.ceil(ve(n,e)))}function kt(n,e){return n.map((t,r)=>{let s=Math.max(0,Math.round(ve(t.startAt??0,e)));return{id:t.id,index:r,startFrame:s,endFrame:s+Je(t.duration,e)-1}})}function ac(n){let e=0;for(let t of n)e=Math.max(e,t.endFrame+1);return e}function Ee(n,e){return n.filter(t=>e>=t.startFrame&&e<=t.endFrame)}function oe(n,e,t){return Math.min(Be(n,e),t)}function Qe(n,e,t){let r=t-1,s=a=>oe(a,e,1/0),o=Math.min(r+1,Math.max(0,Math.ceil(n.start*e)));for(;o>0&&s(o-1)>=n.start;)o--;for(;o<=r&&s(o)<n.start;)o++;let i=r;if(n.end!==1/0){for(i=Math.max(-1,Math.min(r,Math.ceil(n.end*e)));i>=0&&s(i)>=n.end;)i--;for(;i<r&&s(i+1)<n.end;)i++}return o<=i?{startFrame:o,endFrame:i}:null}var Dn=class{_scope;canvas;constructor(e,t,r){this._scope=r,this._clip=e,this._duration=t,this._doc=cc(e);let{width:s,height:o}=r.viewport;this.canvas=new Fe({id:b,width:s,height:o,flow:"freeform"}),this._timeline=new vn(this._doc,r.registry,this.canvas),this._indexRows()}get duration(){return this._duration}get clip(){return this._clip}build(e=this._scope.measurer){this.attach(0),this._timeline.build(),this.sample(),this.layout(e),this._timeline.compile(()=>{this.sample(),this.layout(e)}),this.layout(e)}update(e,t){if(e===this._clip)return this._duration=t,!0;let r=this.planUpdate(e);return r?(this.applyUpdate(r,e,t),!0):!1}planUpdate(e){return this._timeline.planUpdate(cc(e))}applyUpdate(e,t,r,s=this._scope.measurer){this.attach(0);let o=()=>{this.sample(),this.layout(s)};this._timeline.applyUpdate(e,o,o),this.layout(s),this._clip=t,this._doc=e.next.doc,this._duration=r,this._indexRows()}placedCommands(){return this._timeline.placedCommands()}commandSounds(){return this._timeline.commandSounds()}atPresence(e,t){let r=this._timeline.presenceTime;this._timeline.syncPresence(e);try{return t()}finally{this._timeline.syncPresence(r)}}evaluateAt(e,t){this._timeline.syncPresence(e),this._timeline.evaluateAt(e,t)}attach(e,t){this.canvas.attach({assets:this._scope.assets,context:oo.EMPTY,time:e}),zr(this.canvas,t)}layout(e=this._scope.measurer){let{width:t,height:r}=this._scope.viewport;this.canvas.layout({x:0,y:0,width:t,height:r},e)}render(e){this.canvas.render(e)}sample(){Qt(this.canvas)}primeMotion(e){en(this.canvas,e)}node(e){return this._timeline.liveNode(e)}baselineProps(e){return this._timeline.baselineProps(e)}rowSpans(){return[...this._rows.values()].map(e=>e.span)}rowSpan(e){return this._rows.get(e)?.span}ownerKeyOf(e){let t="";for(let r=e;;){if(r===this.canvas||this._timeline.liveNode(r.id)===r){let i=r===this.canvas?b:r.id;return t===""?i:`${i}/${t}`}let s=r.parent;if(!s)return;let o=s._allChildren.indexOf(r);t=t===""?String(o):`${o}.${t}`,r=s}}spanOf(e){for(let t=e;t;t=t.parent){if(t===this.canvas)return{start:0,end:this.duration};let r=this._rowSpan(t);if(r)return{...r}}}forEachOwner(e){let t=(r,s,o,i,a)=>{if(!r.mounted)return;let c=r===this.canvas?void 0:this._rowSpan(r);c&&(s=r.id,o="",i=c),e(r,o===""?s:`${s}/${o}`,i,a);let d=r._allChildren;for(let u=0;u<d.length;u++)t(d[u],s,o===""?String(u):`${o}.${u}`,i,ye(a,u))};t(this.canvas,b,"",{start:0,end:this.duration},"")}dispose(){for(let e of this.canvas.children)e.dispose();this.canvas.dispose()}_clip;_doc;_duration;_timeline;_rows=new Map;_indexRows(){this._rows.clear();let e=Ji(this._doc.nodes);for(let t of this._doc.nodes)t.id!==b&&this._rows.set(t.id,{parentId:t.parentId,span:e.get(t.id)})}_rowSpan(e){let t=this._rows.get(e.id);if(!t)return;let r=e.parent;return(t.parentId===null||t.parentId===b?r===this.canvas:r!==null&&r.id===t.parentId)?t.span:void 0}};function cc(n){return We(n)}var xl=new Set,St=class{constructor(e){this._frameCount=Math.max(0,e)}setOwner(e,t){let r=new Set,s=this._owners.get(e);s&&this._unlink(e,s,r);let o={declared:new Map,learned:new Map};for(let i of t)i.endFrame>=i.startFrame&&vl(o.declared,{...i});return o.declared.size>0?(this._owners.set(e,o),this._link(e,o,r)):this._owners.delete(e),this._refresh(r)}removeOwner(e){let t=this._owners.get(e);if(!t)return{keys:new Set};let r=new Set;return this._unlink(e,t,r),this._owners.delete(e),this._refresh(r)}learn(e,t,r){let s=ic(t),o=this._owners.get(e);o||(o={declared:new Map,learned:new Map},this._owners.set(e,o));let i=o.learned.get(s)??[],a=i.findIndex(d=>r>=d.startFrame-1&&r<=d.endFrame+1);if(a<0)i.push({key:s,decl:t,startFrame:r,endFrame:r});else{let d=i[a];i[a]={...d,startFrame:Math.min(d.startFrame,r),endFrame:Math.max(d.endFrame,r)}}o.learned.set(s,i);let c=this._byKey.get(s);return c||this._byKey.set(s,c=new Set),c.add(e),this._refresh(new Set([s]))}setFrameCount(e){let t=Math.max(0,e);return t===this._frameCount?{keys:new Set}:(this._frameCount=t,this._refresh(new Set(this._byKey.keys())))}owners(e){return this._byKey.get(e)??xl}segmentsOf(e){let t=this._owners.get(e);if(!t)return[];let r=[];for(let s of t.declared.values())r.push(...s);for(let s of t.learned.values())r.push(...s);return r}declaredSegmentsOf(e){let t=this._owners.get(e);if(!t)return[];let r=[];for(let s of t.declared.values())r.push(...s);return r}ownerKeys(){return this._owners.keys()}records(){return this._records}layoutGates(){if(this._layoutGates===null){let e=[];for(let t of this._entries.values())t.layout&&e.push(t.record);this._layoutGates=e}return this._layoutGates}_frameCount;_owners=new Map;_byKey=new Map;_entries=new Map;_records=new Map;_layoutGates=null;_link(e,t,r){for(let s of t.declared.keys()){let o=this._byKey.get(s);o||this._byKey.set(s,o=new Set),o.add(e),r.add(s)}}_unlink(e,t,r){for(let s of[t.declared,t.learned])for(let o of s.keys()){let i=this._byKey.get(o);i&&(i.delete(e),i.size===0&&this._byKey.delete(o)),r.add(o)}}_refresh(e){let t=new Set;for(let r of e){let s=this._entries.get(r),o=this._compute(r);if(o===void 0){if(s===void 0)continue;this._entries.delete(r),this._records.delete(r)}else{if(s!==void 0&&s.layout===o.layout&&kl(s.record,o.record))continue;this._entries.set(r,o),this._records.set(r,o.record)}t.add(r)}return t.size>0&&(this._layoutGates=null),{keys:t}}_compute(e){let t=this._byKey.get(e);if(!t)return;let r=this._frameCount-1,s,o=1/0,i=-1/0,a=!1,c=d=>{if(d)for(let u of d){let l=Math.max(0,u.startFrame),h=Math.min(r,u.endFrame);h<l||(l<o&&(o=l,s=u),h>i&&(i=h),u.decl.type==="loader"&&u.decl.gate==="layout"&&(a=!0))}};for(let d of t){let u=this._owners.get(d);u&&(c(u.declared.get(e)),c(u.learned.get(e)))}if(s!==void 0)return{record:bl(s.decl,o,i),layout:s.decl.type==="font"||a}}};function vl(n,e){let t=n.get(e.key);t?t.push(e):n.set(e.key,[e])}function bl(n,e,t){switch(n.type){case"image":return{type:"image",startFrame:e,endFrame:t,src:n.src};case"video":return{type:"video",startFrame:e,endFrame:t,src:n.src,trimStart:n.trimStart,trimEnd:n.trimEnd};case"font":return{type:"font",startFrame:e,endFrame:t,fontWeight:n.weight,fontFamily:n.family,src:n.family};case"loader":return{type:"loader",src:n.key,startFrame:e,endFrame:t,load:n.load}}}function kl(n,e){if(n.type!==e.type||n.src!==e.src||n.startFrame!==e.startFrame||n.endFrame!==e.endFrame)return!1;switch(n.type){case"video":{let t=e;return n.trimStart===t.trimStart&&n.trimEnd===t.trimEnd}case"font":return n.fontWeight===e.fontWeight;case"loader":return n.load===e.load;default:return!0}}function*ks(n,e){let t=new bs(n,e);for(;t.step();)yield;return t.result()}var dc=3,bs=class{_instance;_options;constructor(e,t){this._instance=e,this._options=t,this._last=t.frameCount-1;let{owners:r,below:s}=t,o=r!==void 0||s!==void 0;if(!(this._last<0||o&&(r?.size??0)+(s?.size??0)===0)){if(o){this._start=1/0;for(let i of[...r?.values()??[],...s?.values()??[]])this._start=Math.min(this._start,Math.max(0,i))}if(!(this._start>this._last)){this._walked=this._start-1,this._placed=e.placedCommands().map(i=>({id:i.spec.id,...this._activeFrames(i.start,i.duration),writes:new Set(i.writes)}));for(let i=0;i<this._placed.length;i++)for(let a of this._placed[i].writes)this._addWriter(a,i);this._enqueue(this._start);for(let i of this._structureSpans()){let a=Qe(i,t.fps,t.frameCount);a&&(this._structureFrame(a.startFrame),this._structureFrame(a.endFrame+1))}for(let i of this._placed)[...i.writes].some(In)&&this._forEachDueFrame(i,this._start,a=>this._structureFrame(a))}}}step(){let e=Cl(this._heap);return e===void 0?!1:(this._queued.delete(e),this._frame=e,this._dueTaken=!1,this._evaluate(e),this._declareDue(e),this._heap.length>0)}result(){let e=new Map,t=new Map;for(let r of this._owners.values()){let s=r.present?[...r.intervals,[r.arrivedAt,1/0]]:r.intervals;e.set(r.key,{ownerKey:r.key,nodeId:r.node.id,segments:r.error?[]:Tl(r.history,s),deps:r.allDeps,...r.error&&{error:r.error}});for(let o of r.allDeps){let i=t.get(o);i||t.set(o,i=new Set),i.add(r.key)}}for(let r of this._options.owners?.keys()??[])e.has(r)||e.set(r,{ownerKey:r,nodeId:void 0,segments:[],deps:new Set});return{owners:e,readers:t}}_last;_start=0;_walked=-1;_placed=[];_writers=new Map;_heap=[];_queued=new Set;_due=new Map;_structureFrames=new Set;_owners=new Map;_readers=new Map;_pseudo=new Set;_rewound=new Set;_frame=-1;_dueTaken=!1;_dev=Ol();_presenceObserver={read:()=>{},write:e=>{In(e)&&this._pseudo.add(e)}};_structureSpans(){let{owners:e,below:t}=this._options;if(e===void 0&&t===void 0)return this._instance.rowSpans();let r=new Set(t?.keys());for(let o of e?.keys()??[]){let i=o.indexOf("/");r.add(i<0?o:o.slice(0,i))}let s=[];for(let o of r){let i=this._instance.rowSpan(o);i&&s.push(i)}return s}_activeFrames(e,t){let{fps:r}=this._options,s=e+Math.max(0,t),o=Math.max(0,Math.ceil(e*r));for(;o>0&&oe(o-1,r,1/0)>=e;)o--;for(;oe(o,r,1/0)<e;)o++;let i=Math.max(-1,Math.floor(s*r));for(;oe(i+1,r,1/0)<=s;)i++;for(;i>=0&&oe(i,r,1/0)>s;)i--;return{from:o,to:i}}_evaluate(e){this._options.onPhase?.("evaluate");let t=oe(e,this._options.fps,this._instance.duration);if(e>this._walked&&(e===this._start||this._structureFrames.has(e))&&this._instance.attach(t),this._pseudo.clear(),pe(this._presenceObserver,()=>this._instance.evaluateAt(t,(r,s)=>{In(s)&&this._pseudo.add(s),this._commandWrote(r,s)})),!(e<=this._walked)){(e===this._start||this._pseudo.size>0)&&this._reconcile(e);for(let r of this._pseudo)for(let s of this._readers.get(r)??[])s.stale=!0,this._queueOwner(s,e);this._walked=e}}_reconcile(e){let t=new Set;this._instance.forEachOwner((r,s,o)=>{let i=this._limitOf(s);if(i===void 0)return;let a=this._owners.get(s);a||(a={key:s,node:r,span:o,from:i,present:!1,arrivedAt:-1,arrived:!1,intervals:[],history:[],deps:null,values:[],stale:!0,allDeps:new Set,scheduled:new Set,rounds:0},this._owners.set(s,a)),t.add(a),a.node!==r&&(a.node=r,a.stale=!0,a.present&&this._queueOwner(a,Math.max(e,a.from))),!a.present&&(a.present=!0,a.arrivedAt=Math.max(e,a.from),a.stale=!0,this._queueOwner(a,a.arrivedAt),a.arrived||(a.arrived=!0,this._options.onArrive?.(r,s,o,e)))});for(let r of this._owners.values())!r.present||t.has(r)||(e-1>=r.arrivedAt&&r.intervals.push([r.arrivedAt,e-1]),r.present=!1)}_limitOf(e){let{owners:t,below:r}=this._options;if(t===void 0&&r===void 0)return this._start;let s=t?.get(e);if(r)for(let o=e.indexOf("/");o>=0;o=e.indexOf("/",o+1)){let i=r.get(e.slice(0,o));i!==void 0&&(s===void 0||i<s)&&(s=i)}return s}_declareDue(e){this._dueTaken=!0;let t=this._due.get(e);if(this._due.delete(e),this._options.declare!==!1){for(let r of t??[])r.error||this._rewound.has(r)||!Sl(r,e)||!r.stale&&Al(r)||this._declare(r,e);for(let r of this._rewound)this._queueOwner(r,e);this._rewound.clear()}}_declare(e,t){this._options.onPhase?.("declare");let r=e.node,s=new Set,o=[],i,a=!1,c=!1,d=this._options.bindSubtree??(f=>Qo(r,f)),u=new Cn(this._options.catalog,{bindSubtree:f=>zt(()=>d(f))});try{pe({read:f=>{s.add(f),i=f,f._name===Ke&&(a=!0)},write:f=>{o.push(f)},clock:()=>{c=!0}},()=>Nr(r,u))}catch(f){let p=f instanceof Error?f:new Error(String(f));e.error={message:p.message,stack:p.stack,...i&&{prop:dt(i)}};return}if(this._dev){let f=r.constructor.name;if(o.length>0){let p=[...new Set(o.map(dt))].join(", ");At(`${f}:write:${p}`,`[assets] ${f} wrote ${p} while declaring its assets. A declaration is re-run only when something it read changes, so a write there is a frame-order dependency.`)}a&&At(`${f}:layout`,`[assets] ${f}.declareAssets read layoutBounds. Declarations run without layout; decode size follows the draw, so declare the asset without a size.`),c&&At(`${f}:clock`,`[assets] ${f}.declareAssets read time. Declarations are re-run only when a prop they read changes, so anything following the clock is missed between those frames.`)}e.stale=!1,e.deps=[...s],e.values=e.deps.map(f=>f.get());for(let f of s){if(e.allDeps.has(f))continue;e.allDeps.add(f);let p=this._readers.get(f);p||this._readers.set(f,p=new Set),p.add(e)}let l=u.declarations,h=e.history[e.history.length-1];(!h||h.frame<e.arrivedAt||!Ml(h.decls,l))&&e.history.push({frame:t,decls:l}),this._scheduleWriters(e,t+1)}_scheduleWriters(e,t){for(let r of e.deps??[]){let s=this._writers.get(r);if(s)for(let o of s)e.scheduled.has(o)||(e.scheduled.add(o),this._forEachDueFrame(this._placed[o],t,i=>this._queueOwner(e,i)))}}_forEachDueFrame(e,t,r){let s=Math.max(t,e.from),o=Math.min(this._last,e.to);for(let a=s;a<=o;a++)r(a);let i=Math.max(e.to+1,e.from);i>=t&&i<=this._last&&r(i)}_commandWrote(e,t){let r=this._placed[e];if(!(!r||r.writes.has(t))){r.writes.add(t),this._addWriter(t,e),this._dev&&At(`command:${r.id}:${dt(t)}`,`[assets] Command ${r.id} wrote ${dt(t)} at frame ${this._frame}, which compile did not record it writing. Owners reading it are re-declared over the command's span.`);for(let s of this._readers.get(t)??[])this._requeue(s,Math.max(r.from,s.from),r.id)}}_requeue(e,t,r){if(!e.error){if(t>this._frame){this._scheduleWriters(e,t);return}if(t===this._frame){this._queueOwner(e,t);return}if(e.rounds>=dc){this._dev&&At(`requeue:${e.key}`,`[assets] ${e.key} was re-queued ${dc} times (last by command ${r}); its asset windows may be incomplete.`);return}e.rounds++,e.history=e.history.filter(s=>s.frame<t),e.stale=!0,e.scheduled.clear(),this._queueOwner(e,t);for(let[s]of e.intervals)s>t&&this._queueOwner(e,s);if(e.present&&e.arrivedAt>t&&this._queueOwner(e,e.arrivedAt),e.deps?.some(In))for(let s of this._structureFrames)s>=t&&s<=this._walked&&this._queueOwner(e,s);this._rewound.add(e)}}_addWriter(e,t){let r=this._writers.get(e);r?r.push(t):this._writers.set(e,[t])}_structureFrame(e){e<=this._start||e>this._last||(this._structureFrames.add(e),this._enqueue(e))}_queueOwner(e,t){if(t>this._last)return;let r=this._due.get(t);r||this._due.set(t,r=new Set),r.add(e),this._enqueue(t)}_enqueue(e){this._queued.has(e)||e===this._frame&&!this._dueTaken||(this._queued.add(e),El(this._heap,e))}};function In(n){return n._name===De||n._name.startsWith(Se)}function Sl(n,e){if(n.present&&e>=n.arrivedAt)return!0;for(let[t,r]of n.intervals)if(e>=t&&e<=r)return!0;return!1}function Al(n){let e=n.deps;if(e===null)return!1;for(let t=0;t<e.length;t++)if(!Object.is(e[t].get(),n.values[t]))return!1;return!0}function Ml(n,e){if(n.size!==e.size)return!1;for(let[t,r]of n){let s=e.get(t);if(!s||!lc(r,s))return!1}return!0}function lc(n,e){switch(n.type){case"image":return e.type==="image"&&n.src===e.src;case"video":return e.type==="video"&&n.src===e.src&&n.trimStart===e.trimStart&&n.trimEnd===e.trimEnd;case"font":return e.type==="font"&&n.family===e.family;case"loader":return e.type==="loader"&&n.key===e.key&&n.load===e.load&&n.gate===e.gate}}function Tl(n,e){let t=[];for(let[r,s]of e){let o=new Map;for(let i of n)if(!(i.frame<r||i.frame>s)){for(let[a,c]of o){let d=i.decls.get(a);d&&lc(c.decl,d)||(t.push({...c,endFrame:i.frame-1}),o.delete(a))}for(let[a,c]of i.decls)o.has(a)||o.set(a,{key:a,decl:c,startFrame:i.frame,endFrame:s})}for(let i of o.values())t.push({...i,endFrame:s})}return t}function Ol(){return!1}var uc=new Set;function At(n,e){uc.has(n)||(uc.add(n),console.warn(e))}function El(n,e){let t=n.length;for(n.push(e);t>0;){let r=t-1>>1;if(n[r]<=e)break;n[t]=n[r],t=r}n[t]=e}function Cl(n){if(n.length===0)return;let e=n[0],t=n.pop();if(n.length===0)return e;let r=0;for(;;){let s=2*r+1;if(s>=n.length)break;let o=s+1,i=o<n.length&&n[o]<n[s]?o:s;if(n[i]>=t)break;n[r]=n[i],r=i}return n[r]=t,e}var Ms="",Nn="",Rn="";function $n(n,e){return n+Ms+e}function fc(n){return Nn+n}function hc(n){if(!(n.startsWith(Nn)||n.startsWith(Rn)))return n.slice(0,n.lastIndexOf(Ms))}function As(n){return n.startsWith(Nn)||n.startsWith(Rn)?n.slice(1):n.slice(n.lastIndexOf(Ms)+1)}var tt=class{_instance;constructor(e){this._instance=e}idOf(e){let t=e._host;if(t===null)return Nn+e._name;let r=this._keys.get(t);return r===void 0&&(r=t instanceof Bt?this._instance.ownerKeyOf(t)??null:null,this._keys.set(t,r)),r===null?Rn+e._name:$n(r,e._name)}idsOf(e){let t=[];for(let r of e)t.push(this.idOf(r));return t}_keys=new Map};function Fn(n){let e=[];for(let t=n.indexOf("/");t>=0;t=n.indexOf("/",t+1))e.push(n.slice(0,t));return e}function Mt(n,e,t){let r=n.get(e);r||n.set(e,r=new Set),r.add(t)}function Tt(n,e,t){let r=n.get(e);return!r||(r.delete(t),r.size>0)?!1:(n.delete(e),!0)}var et=new Set,Ot=class{set(e,t){this.remove(e);let r=new Set(t);this._deps.set(e,r);for(let s of Fn(e))Mt(this._ownersBelow,s,e);for(let s of r)this._readers.has(s)||this._index(s),Mt(this._readers,s,e)}remove(e){let t=this._deps.get(e);if(t){this._deps.delete(e);for(let r of Fn(e))Tt(this._ownersBelow,r,e);for(let r of t)Tt(this._readers,r,e)&&this._unindex(r)}}has(e){return this._deps.has(e)}depsOf(e){return this._deps.get(e)??et}readersOf(e){return this._readers.get(e)??et}ownersBelow(e){return this._ownersBelow.get(e)??et}slotsHostedBy(e){return this._byHost.get(e)??et}*slotsHostedBelow(e){for(let t of this._hostsBelow.get(e)??et)yield*this.slotsHostedBy(t)}slotsNamed(e){return this._byName.get(e)??et}_deps=new Map;_readers=new Map;_ownersBelow=new Map;_byHost=new Map;_hostsBelow=new Map;_byName=new Map;_index(e){Mt(this._byName,As(e),e);let t=hc(e);if(t!==void 0){Mt(this._byHost,t,e);for(let r of Fn(t))Mt(this._hostsBelow,r,t)}}_unindex(e){Tt(this._byName,As(e),e);let t=hc(e);if(t!==void 0&&Tt(this._byHost,t,e))for(let r of Fn(t))Tt(this._hostsBelow,r,t)}};function pc(n){let{patch:e,deps:t,fps:r}=n,{prev:s,next:o,diff:i}=e,a={owners:new Map,below:new Map,removed:new Set,arrivalOwners:new Set,arrivalBelow:new Set},c=(m,y,_)=>{let v=m.get(y);(v===void 0||_<v)&&m.set(y,_)},d=(m,y,_)=>{c(a.owners,m,y),_&&a.arrivalOwners.add(m)},u=(m,y,_)=>{for(let v of t.readersOf(m))d(v,y,_)},l=(m,y)=>{!n.buildsChildren(m)&&t.ownersBelow(m).size===0||(c(a.below,m,y),a.arrivalBelow.add(m))},h=(m,y)=>{let _=m.effSpan(y);return _?Ss(_.start,r):1/0},f=(m,y)=>{u(fc(Se+m),y,!0),u($n(m,De),y,!0);for(let _ of[s,o]){let v=_.nodes.get(m);v&&u($n(v.parentId??b,De),y,!0)}},p=(m,y,_)=>{for(let v of t.slotsHostedBy(m)){let A=As(v);(_===null||_.has(A)||A===De)&&u(v,y,!0)}for(let v of t.slotsHostedBelow(m))u(v,y,!0)};for(let[m,y]of n.before){if(n.after.has(m))continue;let _=Ss(y.start,r);for(let v of y.writes)u(v,_,!1)}for(let[m,y]of n.after){if(n.before.has(m))continue;let _=Ss(y.start,r);for(let v of y.writes)u(v,_,!1)}for(let m of i.variables.changed)u(fc(Rt+m),0,!0);if(e.layoutChanged)for(let m of t.slotsNamed(Ke))u(m,0,!0);for(let m of i.nodes.reorderedParents)u($n(m,De),0,!0);for(let m of i.nodes.removed){let y=h(s,m);a.removed.add(m),f(m,y),p(m,y,null)}for(let m of i.nodes.added){let y=h(o,m);y!==1/0&&(d(m,y,!0),l(m,y),f(m,y))}for(let m of o.nodes.keys()){if(m===b||!s.nodes.has(m))continue;let y=s.effSpan(m),_=o.effSpan(m);if(y?.start===_?.start&&y?.end===_?.end)continue;let v=Math.min(h(s,m),h(o,m));v!==1/0&&(d(m,v,!0),l(m,v),f(m,v))}let w=new Set([...e.reinstantiate,...i.nodes.added,...i.nodes.removed]);for(let m of e.reinstantiate){let y=Pl(m,n,w);p(m,0,y),l(m,0);for(let _ of[m,...t.ownersBelow(m)])for(let v of t.depsOf(_))if(v.startsWith(Rn)){d(_,0,!0);break}i.nodes.moved.has(m)&&f(m,0)}if(i.rootChanged){let m=n.propsOf(b);p(b,0,m?mc(s.nodes.get(b),o.nodes.get(b),m):null)}return a}function Pl(n,e,t){let{prev:r,next:s,diff:o}=e.patch,i=r.nodes.get(n),a=s.nodes.get(n);if(!i||!a||!o.nodes.respec.has(n)||o.nodes.moved.has(n)||i.type!==a.type||i.key!==a.key)return null;for(let d of[r,s])if(Dl(d,n,t,e))return null;let c=e.propsOf(n);return c?mc(i,a,c):null}function mc(n,e,t){let r=new Set;for(let s of new Set([...Object.keys(n.props),...Object.keys(e.props)]))if(!Y(n.props[s],e.props[s])){if(!t.has(s))return null;r.add(s)}return r}function Dl(n,e,t,r){let s=new Set([e]),o=n.nodes.get(e)?.parentId??null;for(;o!==null&&o!==b&&!s.has(o);){s.add(o);let i=n.nodes.get(o);if(!i)return!1;if(t.has(o)&&r.isContextProvider(i.type))return!0;o=i.parentId}return!1}function Ss(n,e){if(!(n>0))return 0;if(!Number.isFinite(n))return 1/0;let t=Math.max(0,Math.ceil(n*e));for(;t>0&&oe(t-1,e,1/0)>=n;)t--;for(;oe(t,e,1/0)<n;)t++;return t}var Et=class{setOwner(e,t){if(t.length===0)return this.removeOwner(e);let r=this._owners.get(e);return r&&gc(r,t)?!1:(this._owners.set(e,t),!0)}removeOwner(e){return this._owners.delete(e)}requests(){let e=[];for(let t of this._owners.values())e.push(...t);return e}_owners=new Map};function gc(n,e){if(Object.is(n,e))return!0;if(typeof n!="object"||typeof e!="object"||n===null||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e))return!1;let t=Object.keys(n);if(t.length!==Object.keys(e).length)return!1;for(let r of t)if(!gc(n[r],e[r]))return!1;return!0}var Il="@commands",Pt=8,Ce=class{_scope;constructor(e,t,r={}){this._scope=t,this._options=r,this._refine=r.assets!==!1?"assets":r.audio!==!1?"audio":"none",this._project=e;for(let s of e.tracks)this._entries.set(s.id,this._fresh(s));this._spans=kt(e.tracks,t.fps)}get project(){return this._project}get tracks(){return this._project.tracks}get spans(){return this._spans}get version(){return this._version}get profile(){return this._options.profile}setProject(e){let t={deltas:new Map,rebuilt:[]};if(this._disposed||e===this._project)return t;let r=!Y(this._project.theme,e.theme);this._project=e;let s=this._entries;this._entries=new Map;for(let a of e.tracks){let c=s.get(a.id),d=c&&!r?this._reconcile(c,a,t):this._fresh(a);c&&d!==c&&t.rebuilt.push(a.id),this._entries.set(a.id,d)}let o=t.rebuilt.length>0||s.size!==this._entries.size;for(let[a,c]of s)this._entries.get(a)!==c&&(this._discard(c),o=!0);let i=kt(e.tracks,this._scope.fps);return(o||!zl(i,this._spans))&&this._version++,this._spans=i,t}reset(){if(this._disposed)return;let e=this._entries;this._entries=new Map;for(let t of this._project.tracks)this._entries.set(t.id,this._fresh(t));for(let t of e.values())this._discard(t);this._version++}ensureBuilt(e){let t=this._entries.get(e);return!t||t.running||this._disposed?null:(t.steps&&this._drain(t),!t.instance&&!t.failure&&(this._start(t,!0,this._refine!=="none"&&!t.discovered),this._drain(t)),t.instance)}discover(e){let t=this._entries.get(e);if(!(!t||t.running||this._disposed)){if(this._refine==="none"){this.ensureBuilt(e);return}t.discovered||(t.steps||this._start(t,!t.instance,!0),this._drain(t))}}async runAsync(e={}){let{budgetMs:t=Pt,isCancelled:r,onProgress:s}=e;if(this._refine!=="none")for(;;){if(this._disposed||r?.())return;let o=this._nextUndiscovered();if(!o)return;o.steps||this._start(o,!o.instance,!0);let i=xe()+t,a=this._step(o);for(;!a;){if(xe()>=i){if(o.profile?.suspend(),await Pn(),this._disposed||r?.())return;if(o.discarded||!o.steps)break;o.profile?.resume(),i=xe()+t}a=this._step(o)}!o.discarded&&o.discovered&&s?.()}}instanceOf(e){let t=this._entries.get(e);return t&&!t.steps?t.instance:null}generationOf(e){return this._entries.get(e)?.generation??-1}failed(e){return!!this._entries.get(e)?.failure}isDiscovered(e){return!!this._entries.get(e)?.discovered}trackAssets(e){return this._entries.get(e)?.discovered??void 0}errorsOf(e){let t=this._entries.get(e);return t?.discovered?t.errors:[]}ownersOf(e,t){return this._entries.get(e)?.index.owners(t)??new Set}layoutGates(e){let t=this._entries.get(e);return t?.discovered?t.index.layoutGates():[]}learn(e,t,r,s){let o=this._entries.get(e);return!o?.discovered||o.index.learn(t,r,s).keys.size===0?!1:this._refresh(o)}settleGates(e){let t=this._options.isReady;if(!t)return!1;let r=!1;for(let s of e){let o=this._entries.get(s);if(!o||o.unready.size===0||!o.instance||o.steps||o.running)continue;let i=o.discovered?new Set(o.index.layoutGates().map(c=>c.src)):null,a=!1;for(let c of[...o.unready])i&&!i.has(c)?o.unready.delete(c):t(c)&&(a=!0);a&&(this._rebuildInstance(o),r=!0)}return r}rebuild(e){let t=this._entries.get(e);!t||t.running||t.steps||(t.instance?.dispose(),t.instance=null,t.unready.clear(),t.generation++,t.failure&&(t.failure=null,t.discovered=null,this._version++))}release(e){let t=this._entries.get(e);!t||!t.instance||t.running||t.steps||!t.discovered||(t.instance.dispose(),t.instance=null,t.generation++)}trim(e,t){for(let r=0;r<this._spans.length;r++){let s=this._spans[r];s.endFrame>=e-t&&s.startFrame<=e+t||this.release(s.id)}}dispose(){this._disposed=!0;for(let e of this._entries.values())this._discard(e)}_options;_refine;_project;_entries=new Map;_spans;_version=0;_disposed=!1;_fresh(e){let t=Je(e.duration,this._scope.fps);return{track:e,frameCount:t,instance:null,steps:null,running:!1,discarded:!1,profile:void 0,discovered:null,errors:[],index:new St(t),audio:new Et,commandAudio:new Set,commandSounds:null,deps:new Ot,assetDeps:new Map,audioDeps:new Map,ownerErrors:new Map,audioErrors:new Map,failure:null,refineError:null,generation:0,writes:new WeakMap,unready:new Set}}_reconcile(e,t,r){let s=Je(t.duration,this._scope.fps);if(e.track.clip===t.clip)return this._resize(e,t,s);if(e.steps||e.failure)return this._fresh(t);if(!e.instance)return e.discovered&&gn(e.track.clip,t.clip).identical?this._resize(e,t,s):this._fresh(t);let o=e.instance,i;try{i=o.planUpdate(t.clip)}catch{i=null}if(!i)return this._fresh(t);if(i.diff.identical)return this._resize(e,t,s);let a=e.discovered!==null&&this._refine!=="none",c=a?this._placedWrites(e):void 0;try{this._compile(e,l=>o.applyUpdate(i,t.clip,t.duration,l))}catch{return this._fresh(t)}if(e.generation++,e.track=t,!a)return e.frameCount=s,e;if(s>e.frameCount)return this._undiscover(e,s),e;let d=pc({patch:i,deps:e.deps,before:c,after:this._placedWrites(e),fps:this._scope.fps,propsOf:l=>{let h=o.node(l);return h?new Set(h.__cells?.slots.keys()??[]):void 0},buildsChildren:l=>{let h=o.node(l);return!!h&&h._allChildren.some(f=>o.node(f.id)!==f)},isContextProvider:l=>mn(this._scope.registry,l)}),u=this._applyDirty(e,d,s);if(s!==e.frameCount){e.frameCount=s;for(let l of e.index.setFrameCount(s).keys)u.add(l)}return this._refresh(e)&&r.deltas.set(t.id,u),e}_resize(e,t,r){let s=e.track.duration;return e.track=t,t.duration===s?e:e.steps?this._fresh(t):(e.instance?.update(e.instance.clip,t.duration),this._refine==="none"||!e.discovered?e.frameCount=r:r>e.frameCount?this._undiscover(e,r):r!==e.frameCount&&(e.frameCount=r,e.index.setFrameCount(r),this._refresh(e)),e)}_undiscover(e,t){e.frameCount=t,e.discovered=null,this._version++}_discard(e){e.discarded=!0,!e.running&&(e.steps?.return(void 0),e.steps=null,e.instance?.dispose(),e.instance=null)}_nextUndiscovered(){let e,t=1/0;for(let r of this._spans){let s=this._entries.get(r.id);!s||s.discovered||s.running||(!e||r.startFrame<t)&&(e=s,t=r.startFrame)}return e}_start(e,t,r){let s=this._project.tracks.findIndex(o=>o.id===e.track.id);e.profile=r?this._options.profile?.track(s,e.track.id):void 0,e.steps=this._steps(e,t,r)}_drain(e){for(;e.steps&&!this._step(e););}_step(e){let t=e.steps;if(!t)return!0;e.running=!0;let r;try{r=t.next()}finally{e.running=!1}return e.generation++,e.discarded||this._disposed?(r.done||t.return(void 0),e.steps=null,e.instance?.dispose(),e.instance=null,!0):r.done?(e.steps=null,!0):!1}*_steps(e,t,r){let s=e.profile,{fps:o,assets:i}=this._scope;if(t){s?.enter("build"),e.unready.clear();try{let l=new Dn(e.track.clip,e.track.duration,this._scope);e.instance=l,this._compile(e,h=>l.build(h))}catch(l){e.instance?.dispose(),e.instance=null,e.failure=Ts(e.track.id,l),r&&(this._resetAssets(e),this._refresh(e,!0),s?.done(e.frameCount));return}if(!r)return;yield}let a=e.instance,c=e.frameCount;this._resetAssets(e);let d=new Map;try{let l=yield*ks(a,{fps:o,frameCount:c,catalog:i,declare:this._refine==="assets",onPhase:h=>s?.enter(h),onArrive:(h,f)=>{s?.enter("audio"),this._declareAudio(e,f,d)}});this._commit(e,l,d)}catch(l){e.refineError=Ts(e.track.id,l)}let u=this._options.isReady;if(u)for(let l of e.index.layoutGates())l.type==="loader"&&!u(l.src)&&e.unready.add(l.src);this._refresh(e,!0),s?.done(c),this._options.keepInstances===!1&&(a.dispose(),e.instance=null)}_resetAssets(e){e.index=new St(e.frameCount),e.audio=new Et,e.commandAudio=new Set,e.commandSounds=null,e.deps=new Ot,e.assetDeps.clear(),e.audioDeps.clear(),e.ownerErrors.clear(),e.audioErrors.clear(),e.refineError=null}_commit(e,t,r){let s=new tt(e.instance);for(let o of t.owners.values()){let i=o.ownerKey;o.error?e.ownerErrors.set(i,this._ownerError(e,o)):e.index.setOwner(i,o.segments),e.assetDeps.set(i,s.idsOf(o.deps))}for(let[o,i]of r)e.audioDeps.set(o,s.idsOf(i));for(let o of new Set([...e.assetDeps.keys(),...e.audioDeps.keys()]))this._link(e,o)}_applyDirty(e,t,r){let s=new Set,o=_=>{for(let v of _.keys)s.add(v)};for(let _ of t.removed)for(let v of[_,...e.deps.ownersBelow(_)])this._drop(e,v,o);if(t.owners.size===0&&t.below.size===0)return s;let i=e.instance,{fps:a,assets:c}=this._scope,d=new Set,u=new Map,l=ks(i,{fps:a,frameCount:r,catalog:c,owners:t.owners,below:t.below,declare:this._refine==="assets",onArrive:(_,v,A,M)=>{d.add(v),M===Qe(A,a,r)?.startFrame&&this._declareAudio(e,v,u)}}),h=l.next();for(;!h.done;)h=l.next();e.generation++;let f=h.value,p=_=>{let v=t.owners.get(_);for(let A=_.indexOf("/");A>=0;A=_.indexOf("/",A+1)){let M=t.below.get(_.slice(0,A));M!==void 0&&(v===void 0||M<v)&&(v=M)}return v??0},w=_=>{if(t.arrivalOwners.has(_))return!0;for(let v=_.indexOf("/");v>=0;v=_.indexOf("/",v+1))if(t.arrivalBelow.has(_.slice(0,v)))return!0;return!1},m=new Set(f.owners.keys());for(let _ of t.below.keys())for(let v of e.deps.ownersBelow(_))m.add(v);let y=new tt(i);for(let _ of m){let v=p(_),A=f.owners.get(_);if(!A&&v===0){this._drop(e,_,o);continue}let M=v>0?Fl(e.index.declaredSegmentsOf(_),v):[];if(A?.error?e.ownerErrors.set(_,this._ownerError(e,A)):e.ownerErrors.delete(_),o(e.index.setOwner(_,A&&!A.error?[...M,...A.segments]:M)),A){let T=y.idsOf(A.deps);e.assetDeps.set(_,v>0?[...new Set([...e.assetDeps.get(_)??[],...T])]:T)}w(_)&&!d.has(_)&&(e.audio.removeOwner(_),e.audioDeps.delete(_),e.audioErrors.delete(_)),this._link(e,_)}for(let[_,v]of u)e.audioDeps.set(_,y.idsOf(v)),this._link(e,_);return s}_drop(e,t,r){r(e.index.removeOwner(t)),e.audio.removeOwner(t),e.assetDeps.delete(t),e.audioDeps.delete(t),e.ownerErrors.delete(t),e.audioErrors.delete(t),e.deps.remove(t)}_link(e,t){let r=e.assetDeps.get(t),s=e.audioDeps.get(t);r===void 0&&s===void 0?e.deps.remove(t):e.deps.set(t,[...r??[],...s??[]])}_declareAudio(e,t,r){r.set(t,[]);let s=e.instance?this._commandSoundsOf(e,e.instance).get(t):void 0;if(s)return this._setCommandAudio(e,e.instance,t,s);e.audio.removeOwner(t),e.audioErrors.delete(t)}_declareCommandAudio(e){let t=e.instance;if(e.commandSounds=null,!t||this._refine==="none")return;let r=this._commandSoundsOf(e,t);for(let s of e.commandAudio)r.has(s)||(e.audio.removeOwner(s),e.audioErrors.delete(s));e.commandAudio=new Set(r.keys());for(let[s,o]of r)this._setCommandAudio(e,t,s,o);e.commandSounds=null}_commandSoundsOf(e,t){if(e.commandSounds)return e.commandSounds;let r=new Map;for(let s of t.commandSounds()){let o=t.ownerKeyOf(s.node)??Il,i=r.get(o);i?i.push(s):r.set(o,[s])}return e.commandSounds=r}_setCommandAudio(e,t,r,s){let o=this._scope.assets,i=a=>{let c=t.spanOf(a);if(!c)throw new Error(`${a.className} is not in the tree, so it has no span.`);return c};try{let a=s.map((c,d)=>{let{bus:u,closed:l,...h}=c.options,f=t.atPresence(c.at,()=>{let w=u?Sr(c.node,u):null;return w?kr(w,i):c.node instanceof ut?br(c.node,i):void 0}),p=h.trimEnd??(l?o.getMediaDuration(c.src):void 0);return Wo({...h,trimEnd:p,src:c.src,at:c.at,until:c.until,bus:f},o,r,d)});e.audio.setOwner(r,a),e.audioErrors.delete(r),e.commandAudio.add(r)}catch(a){e.audio.removeOwner(r),e.audioErrors.set(r,{...Ts(e.track.id,a),nodeId:s[0].node.id})}}_ownerError(e,t){let r=t.error;return{trackId:e.track.id,message:r.message,...r.stack!==void 0&&{stack:r.stack},...t.nodeId!==void 0&&{nodeId:t.nodeId},...r.prop!==void 0&&{prop:r.prop}}}_refresh(e,t=!1){this._declareCommandAudio(e);let r=e.discovered,{fps:s}=this._scope,o=r&&Rl(r.assetRecords,e.index.records())?r.assetRecords:new Map(e.index.records()),i=$l(e.audio.requests(),e.frameCount/s),a=e.index.layoutGates().map(d=>d.src),c=[...e.audioErrors.values(),...e.ownerErrors.values(),...e.failure?[e.failure]:[],...e.refineError?[e.refineError]:[]];return!t&&r&&o===r.assetRecords&&r.frameCount===e.frameCount&&Ct(r.audioRequests,i)&&Ct(r.layoutGates,a)&&Ct(e.errors,c)?!1:(e.discovered={id:e.track.id,discovered:!0,frameCount:e.frameCount,startFrame:0,audioRequests:i,assetRecords:o,layoutGates:a},e.errors=c,this._version++,!0)}_placedWrites(e){let t=e.instance,r=new Map,s;for(let o of t.placedCommands()){let i=e.writes.get(o.writes);i||(s??=new tt(t),i={start:o.start,writes:s.idsOf(o.writes)},e.writes.set(o.writes,i)),r.set(o.writes,i)}return r}_compile(e,t){let r=this._options.isReady,s=this._scope.measurer;if(!r){t(s);return}let o=new Set;t({measureText(i,a,c,d,u,l){return o.add(c),s.measureText(i,a,c,d,u,l)}});for(let i of o)r(i)||e.unready.add(i)}_rebuildInstance(e){e.instance?.dispose(),e.instance=null,e.generation++,this._start(e,!0,!1),this._drain(e),e.failure&&e.discovered&&this._refresh(e)}};function Ts(n,e){let t=e instanceof Error?e:new Error(String(e));return{trackId:n,message:t.message,stack:t.stack}}function Fl(n,e){let t=[];for(let r of n)r.startFrame>=e||t.push(r.endFrame>=e?{...r,endFrame:e-1}:r);return t}function $l(n,e){let t=[];for(let r of n){let s=r.bus&&Nl(r.bus,e),o=s===r.bus?{...r}:{...r,bus:s};if(r.open){t.push(o);continue}if(r.startAt>=e)continue;let i=Math.min(r.endAt,e);i<=r.startAt||t.push(i===r.endAt?o:{...o,endAt:i})}return t}function Nl(n,e){return n.every(t=>t.endAt<=e)?n:n.map(t=>t.endAt<=e?t:{...t,endAt:e})}function Rl(n,e){if(n.size!==e.size)return!1;for(let[t,r]of n){let s=e.get(t);if(!s||!Ct(r,s))return!1}return!0}function zl(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t].id!==e[t].id||n[t].startFrame!==e[t].startFrame||n[t].endFrame!==e[t].endFrame)return!1;return!0}function Ct(n,e){if(Object.is(n,e))return!0;if(typeof n!="object"||typeof e!="object"||n===null||e===null||Array.isArray(n)!==Array.isArray(e))return!1;let t=Object.keys(n);if(t.length!==Object.keys(e).length)return!1;for(let r of t)if(!Ct(n[r],e[r]))return!1;return!0}var zn=class{_scope;constructor(e,t,r){this._scope=t,this._owned=r===void 0,this._store=r??new Ce(e,t,{assets:!1,audio:!1}),this._slots=this._slotsFor(e.tracks,new Map),this._currentTrackId=Os(this._slots)?.track.id??null}get currentFrame(){return this._currentFrame}get currentTrackId(){return this._currentTrackId}get currentCanvas(){return this.currentInstance?.canvas??null}get currentInstance(){let e=this._slotOf(this._currentTrackId);return e?.instance&&e.instance===this._store.instanceOf(e.track.id)?e.instance:null}get activeTrackIds(){return this._active.map(e=>e.track.id)}stateAt(e){if(this._disposed)return;let t=Math.max(0,Math.floor(e)),r=this._slotsToDraw(t);if(!this._stale&&t===this._currentFrame&&Ll(r,this._active)&&r.every(o=>this._settled(o)))return;this._active=r;let s=Os([...r].reverse());s&&(this._currentTrackId=s.track.id);for(let o of r)o.instance=this._store.ensureBuilt(o.track.id);for(let o of r)o.instance&&(this._evaluate(o,t-o.span.startFrame),o.generation=this._store.generationOf(o.track.id));this._currentFrame=t,this._stale=!1}layout(e=this._scope.measurer){for(let t of this._active)this._live(t)?.layout(e)}render(e){for(let t of this._active)this._live(t)?.render(e)}invalidate(){this._stale=!0}rebuild(e=this._currentTrackId){e!==null&&(this._store.rebuild(e),this._stale=!0)}setProject(e){if(this._disposed)return;this._store.setProject(e);let t=new Map(this._slots.map(s=>[s.track.id,s]));this._slots=this._slotsFor(e.tracks,t);let r=new Set(this._slots);for(let s of this._editorStates.keys())this._slotOf(s)||this._editorStates.delete(s);this._active=this._active.filter(s=>r.has(s)),this._slotOf(this._currentTrackId)||(this._currentTrackId=Os(this._slots)?.track.id??null),this._stale=!0}setEditorStates(e,t){t?this._editorStates.set(e,t):this._editorStates.delete(e),this._stale=!0}dispose(){this._disposed=!0,this._active=[];for(let e of this._slots)e.instance=null;this._owned&&this._store.dispose()}_store;_owned;_slots;_active=[];_currentFrame=0;_currentTrackId;_stale=!1;_disposed=!1;_editorStates=new Map;_slotsFor(e,t){let r=kt(e,this._scope.fps);return e.map((s,o)=>{let i=t.get(s.id);return i?(i.track=s,i.span=r[o],i):{track:s,span:r[o],instance:null,generation:-1}})}_slotOf(e){return e===null?void 0:this._slots.find(t=>t.track.id===e)}_settled(e){let t=e.track.id;return e.instance?e.instance===this._store.instanceOf(t)&&e.generation===this._store.generationOf(t):this._store.failed(t)}_live(e){return e.instance&&e.instance===this._store.instanceOf(e.track.id)?e.instance:null}_slotsToDraw(e){let t=this._slots.map(s=>s.span),r=Ee(t,e);if(r.length===0){let s=Math.max(-1,...t.map(o=>o.endFrame));e>s&&s>=0&&(r=Ee(t,s))}return r.map(s=>this._slots[s.index])}_evaluate(e,t){let r=e.instance,s=Be(1,this._scope.fps),o=oe(t,this._scope.fps,e.track.duration);r.attach(o,this._editorStates.get(e.track.id));let i=Math.max(0,o-s);r.evaluateAt(i),r.layout(),r.primeMotion(i),r.evaluateAt(o),r.layout(),r.sample()}};function Os(n){return n.find(e=>!sn(e.track.clip))}function Ll(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}var Es=4;async function yc(n,e,t){for(let r=0;r<4;r++){if(!t())return"superseded";if(n(),!await e.warmPendingDecodes())return"settled";if(!t())return"superseded"}return"exhausted"}var Ln=class{_fps;_catalog;constructor(e,t){this._fps=e,this._catalog=t}update(e){let t=new Set,r=new Set;for(let o of e){r.add(o.id);let i=this._tracks.get(o.id);if(i&&i.records===o.records&&i.startFrame===o.startFrame)continue;let a=!i||i.startFrame!==o.startFrame;for(let[c,d]of o.records){let u=i?.records.get(c);(a||!u||!xc(u,d))&&t.add(c),this._holders(c).add(o.id)}if(i)for(let c of i.records.keys())o.records.has(c)||(t.add(c),this._release(c,o.id));this._tracks.set(o.id,{id:o.id,startFrame:o.startFrame,records:o.records})}for(let[o,i]of this._tracks)if(!r.has(o)){this._tracks.delete(o);for(let a of i.records.keys())t.add(a),this._release(a,o)}let s;for(let o of t){let i=this._entryOf(o),a=this._map.get(o);if(i===void 0){if(a===void 0)continue;s??=new Map(this._map),s.delete(o)}else(a===void 0||!Yl(a,i))&&(s??=new Map(this._map),s.set(o,i))}return s&&(this._map=s),this._map}_tracks=new Map;_byKey=new Map;_map=new Map;_holders(e){let t=this._byKey.get(e);return t||this._byKey.set(e,t=new Set),t}_release(e,t){let r=this._byKey.get(e);r&&(r.delete(t),r.size===0&&this._byKey.delete(e))}_entryOf(e){let t=this._byKey.get(e);if(!t)return;let r;for(let s of t){let o=this._tracks.get(s),i=o.records.get(e);i&&(r=jl(r,Bl(i,o.startFrame)))}return r&&Gl(r,this._fps,this._catalog)}};function Bl(n,e){return e===0?n:{...n,startFrame:n.startFrame+e,endFrame:n.endFrame+e}}function jl(n,e){return n?{...n,startFrame:Math.min(n.startFrame,e.startFrame),endFrame:Math.max(n.endFrame,e.endFrame)}:e}function _c(n,e){let t;try{t=n.type==="image"?e.getImageMeta(n.src):e.getVideoMeta(n.src)}catch{return 0}return!(t.width>0)&&!(t.height>0)?0:Ul(t.width,t.height)}var Vl=2,Kl=2,Ps=120,Cs=30;function Ul(n,e){return n*e*4/(1024*1024)}function wc(n){return Math.min(Ps,Math.max(Kl,Math.round(n*Vl)))}function Gl(n,e,t){switch(n.type){case"image":{let r=wc(_c(n,t));return{record:n,cacheAt:Math.max(0,n.startFrame-r),discardAt:n.endFrame+Cs}}case"video":{let r=Math.min(Ps,wc(_c(n,t))*2+Math.round(e));return{record:n,cacheAt:Math.max(0,n.startFrame-r),discardAt:n.endFrame+Cs}}case"font":return{record:n,cacheAt:0,discardAt:null};case"loader":return{record:n,cacheAt:Math.max(0,n.startFrame-Ps),discardAt:n.endFrame+Cs};default:return}}function Yl(n,e){return n.cacheAt===e.cacheAt&&n.discardAt===e.discardAt&&xc(n.record,e.record)}function xc(n,e){if(n===e)return!0;if(n.type!==e.type||n.src!==e.src||n.startFrame!==e.startFrame||n.endFrame!==e.endFrame)return!1;switch(n.type){case"video":{let t=e;return n.trimStart===t.trimStart&&n.trimEnd===t.trimEnd}case"font":{let t=e;return n.fontWeight===t.fontWeight&&n.fontFamily===t.fontFamily}case"loader":return n.load===e.load;default:return!0}}var ql=["build","declare","evaluate","audio"];function hb(){let n=[];return{timings:n,track(e,t){let r=Object.fromEntries(ql.map(c=>[c,0])),s=null,o=xe(),i=0,a=()=>{let c=xe()-o;s&&(r[s]+=c),i+=c};return{enter(c){a(),s=c,o=xe()},suspend(){a(),s=null},resume(){o=xe()},done(c){a(),s=null,n[e]={trackId:t,trackIndex:e,frameCount:c,totalMs:i,phases:r}}}}}}var Bn=class{_scope;constructor(e,t,r={}){this._scope=t,this._owned=r.store===void 0,this._store=r.store??new Ce(e,t,{profile:r.profile,assets:r.assets,keepInstances:!1}),this._assets=new Ln(t.fps,t.assets)}get store(){return this._store}get discoveredCount(){let e=0;for(let t of this._store.tracks)this._store.isDiscovered(t.id)&&e++;return e}result(){return this._assemble()}ensureCovering(e){for(let t of Ee(this._store.spans,e))this._store.discover(t.id);return this._assemble()}run(){for(let e of this._store.tracks)this._store.discover(e.id);return this._assemble()}async runAsync(e={}){let{budgetMs:t=Pt,isCancelled:r,onProgress:s}=e;return await this._store.runAsync({budgetMs:t,isCancelled:r,onProgress:s&&(()=>s(this._assemble()))}),this._assemble()}setProject(e){return this._store.setProject(e),this._assemble()}learn(e,t,r,s){return this._store.learn(e,t,r,s),this._assemble()}dispose(){this._owned&&this._store.dispose()}_store;_owned;_assets;_result=null;_version=-1;_assemble(){let e=this._store;if(this._result&&this._version===e.version)return this._result;let{fps:t}=this._scope,r=e.spans,s=ac(r),o=s/t,i=[],a=[],c=!0,d=r.map(h=>{let f=e.trackAssets(h.id);return f||(c=!1),a.push(...e.errorsOf(h.id)),f??Xl(h.id,h.endFrame-h.startFrame+1)}),u=this._assets.update(d.map((h,f)=>({id:h.id,startFrame:r[f].startFrame,records:h.assetRecords})));for(let h=0;h<d.length;h++)i.push(Wl({...d[h],startFrame:r[h].startFrame},t,o));let l=e.profile;return this._version=e.version,this._result={fps:t,tracks:i,totalFrames:s,totalDuration:o,assets:u,buildErrors:a,complete:c,timings:l?.timings?.slice()}}};function Xl(n,e){return{id:n,discovered:!1,frameCount:e,startFrame:0,audioRequests:[],assetRecords:new Map,layoutGates:[]}}function Wl(n,e,t){if(!n.audioRequests.some(o=>o.open))return n;let r=n.startFrame/e,s=n.audioRequests.map(o=>{if(!o.open)return o;let i=r+o.startAt,a=o.loop?t:Math.min(i+(o.mediaDuration??0),t);return{...o,endAt:Math.max(o.startAt,a-r)}});return{...n,audioRequests:s}}function nt(n){return typeof n?._isViewport3D=="function"&&n._isViewport3D()}function Fs(n,e,t){let r=Ns(n);if(!r)return[];let s=[];for(let o of $s(n,t)){let i=r.boxes.get(o.node.id);if(!i)continue;let a=Oc(i,r);a&&s.push({box:Ec(o.node,o.path,a.rect,e),depth:a.depth})}return s.sort((o,i)=>i.depth-o.depth),s.map(o=>o.box)}var Hl={x:0,y:0,z:0};function Sc(n,e,t,r,s,o){let i=Ns(n);if(!i)return null;let a=$s(n,t).find(f=>f.path===r);if(!a)return null;let c=i.matrices.get(a.node.id),d=i.parentMatrices.get(a.node.id);if(!c||!d)return null;let u=(f,p)=>p.map(w=>vc(f,w,i,e)),l=ho(a.node),h=l?s.map(f=>l.toLocal(f.x,f.y,f.z)):s;return{origin:vc(c,Hl,i,e),parentPoints:u(d,h),localPoints:u(c,o)}}function vc(n,e,t,r){let s=le(n,e),o=le(t.clip,{x:s.x,y:s.y,z:s.z});if(o.w<=Dt)return null;let i=o.x/o.w,a=o.y/o.w,c=t.centerX+i*(t.width/2),d=t.centerY+a*(t.height/2),u=B(r.matrix,{x:c,y:-d});return{x:u.x,y:-u.y}}function Ac(n,e,t,r,s){let o=Ns(n);if(!o)return null;let i=ce(e.matrix);if(!i)return null;let a=B(i,{x:t.x,y:-t.y}),c={x:a.x,y:-a.y},d=null,u=-1/0;for(let l of $s(n,s)){let h=o.boxes.get(l.node.id);if(!h)continue;let f=Oc(h,o);f&&rf(f.rect,c,r)&&(f.depth<=u||(u=f.depth,d={node:l.node,path:l.path,rect:f.rect}))}return d?Ec(d.node,d.path,d.rect,e):null}function $s(n,e){let t=[];return Mc(n._allChildren,e,t),t}function Mc(n,e,t){for(let r=0;r<n.length;r++){let s=n[r];if(!(s instanceof po))continue;let o=ye(e,r);t.push({node:s,path:o}),Mc(s._allChildren,o,t)}}function Ns(n){let e=n._localBounds();if(!(e.width>0)||!(e.height>0))return null;let t=n._scene3D();if(!t)return null;let r=Zl(t);if(r.boxes.size===0)return null;let s=An(r.camera);if(!s)return null;let o=e.width/e.height;return{boxes:r.boxes,matrices:r.matrices,parentMatrices:r.parentMatrices,clip:ue(tf(r.descriptor,o),s),view:s,width:e.width,height:e.height,centerX:e.x,centerY:e.y}}function Zl(n){let e=new Map,t=new Map,r=new Map,o=[{key:void 0,matrix:Sn(),visible:!0,box:null}],i=null,a=null,c=()=>o[o.length-1];for(let d of n.ops()){let u=c();switch(d.kind){case"push":{let l=Tc(u.matrix,d.transform);d.transform?.key!==void 0&&(t.set(d.transform.key,l),r.set(d.transform.key,u.matrix)),o.push({key:d.transform?.key,matrix:l,visible:u.visible&&d.transform?.visible!==!1,box:null});break}case"pop":{if(o.length===1)break;let l=o.pop();if(!l.visible||!l.box)break;l.key!==void 0&&e.set(l.key,l.box);let h=c();h.box=bt(h.box,l.box);break}case"camera":{a=d.camera,i=Ql(d.camera,u.matrix);break}case"light":break;default:{if(!u.visible)break;let l=Jl(d,u.matrix);l&&(u.box=bt(u.box,l));break}}}return{boxes:e,matrices:t,parentMatrices:r,camera:i??ef,descriptor:a}}function Tc(n,e){return ue(n,xt(e,n))}function Jl(n,e){if(n.kind==="model"||!("transform"in n))return null;let t=Tc(e,n.transform);if(n.kind==="sprite")return Ze(W(.5,.5,0),t);if(!("geometry"in n))return null;let r=On(n.geometry);if(!r)return null;if(n.kind==="instances"){let s=null;for(let o of n.instances)s=bt(s,Ze(r,xt(o,null)));return s?Ze(s,t):null}return Ze(r,t)}function Ql(n,e){let t=Yr(n);if(t.lookAt===void 0)return ue(e,xt({...n,position:t.position},e));let r=le(e,t.position),s={x:r.x,y:r.y,z:r.z};return ue(vt(s),wt(s,t.lookAt))}var ef=ue(vt({x:0,y:0,z:5}),wt({x:0,y:0,z:5},{x:0,y:0,z:0})),bc=50,Ds=.1,Is=1e3;function tf(n,e){if(n===null)return Mn(bc,e,Ds,Is,1);if(n.type==="perspective")return Mn(n.fov??bc,e,n.near??Ds,n.far??Is,n.zoom??1);let t=(n.frustumHeight??10)/2;return xs(-t*e,t*e,t,-t,n.near??Ds,n.far??Is,n.zoom??1)}var nf=[[0,1],[2,3],[4,5],[6,7],[0,2],[1,3],[4,6],[5,7],[0,4],[1,5],[2,6],[3,7]],Dt=1e-4,kc=8;function Oc(n,e){let r=Tn(n).map(y=>le(e.clip,y)),s=1/0,o=1/0,i=-1/0,a=-1/0,c=!1,d=(y,_,v)=>{let A=y/v,M=_/v;A<s&&(s=A),M<o&&(o=M),A>i&&(i=A),M>a&&(a=M),c=!0};for(let[y,_]of nf){let v=r[y],A=r[_],M=v.w>Dt,T=A.w>Dt;if(!M&&!T||(M&&d(v.x,v.y,v.w),T&&d(A.x,A.y,A.w),M===T))continue;let D=(Dt-v.w)/(A.w-v.w);d(v.x+(A.x-v.x)*D,v.y+(A.y-v.y)*D,Dt)}if(!c)return null;let u=e.width/2,l=e.height/2,h=u*kc,f=l*kc,p={minX:jn(e.centerX+s*u,e.centerX-h,e.centerX+h),maxX:jn(e.centerX+i*u,e.centerX-h,e.centerX+h),minY:jn(e.centerY+o*l,e.centerY-f,e.centerY+f),maxY:jn(e.centerY+a*l,e.centerY-f,e.centerY+f)},w={x:(n.min.x+n.max.x)/2,y:(n.min.y+n.max.y)/2,z:(n.min.z+n.max.z)/2},m=le(e.view,w);return{rect:p,depth:m.z}}function jn(n,e,t){return n<e?e:n>t?t:n}function rf(n,e,t){return e.x>=n.minX-t&&e.x<=n.maxX+t&&e.y>=n.minY-t&&e.y<=n.maxY+t}function Ec(n,e,t,r){let s=(o,i)=>{let a=B(r.matrix,{x:o,y:-i});return{x:a.x,y:-a.y}};return{id:n.id,path:e,type:n.className,topLeft:s(t.minX,t.maxY),topRight:s(t.maxX,t.maxY),bottomRight:s(t.maxX,t.minY),bottomLeft:s(t.minX,t.minY),center:s((t.minX+t.maxX)/2,(t.minY+t.maxY)/2),width:t.maxX-t.minX,height:t.maxY-t.minY,rotation:r.box.rotation,scale:r.box.scale,opacity:r.box.opacity,locked:n.locked}}function ie(n){let e=Vt(n);if(e)return he(ie(e.root),e.screen);let t=n.parent;return t?he(It(t),n._localMatrix()):n._localMatrix()}function It(n){let e=ie(n),t=n._spaceCamera();if(t)return he(e,jt(n,t).screen);let r=n._cameraScope();if(!r)return e;let s=n.layoutBounds;return he(e,lr(s.x,-s.y,r.lookAt,r.zoom,r.heading))}function Pc(n,e,t){if(e==="")return null;let r=Pe(n,e),s=r instanceof R?r.parent:null;if(!(r instanceof R)||!s)return null;let o=Nc(r,s),i=ce(o);if(!i)return null;let a=B(i,{x:t.x,y:-t.y});if(Rs(o,a))return null;let c=s._planeOf(r);if(!c)return{x:a.x,y:-a.y};let d=r._placement()?null:r.layoutBounds;return c.toCoords(a.x-(d?.x??0),(d?.y??0)-a.y)}function Dc(n,e,t){let r=Pe(n,e);if(!(r instanceof R))return null;let s=r._planeOf(null);if(!s)return null;let o=ce(It(r));if(!o)return null;let i=B(o,{x:t.x,y:-t.y});return s.toCoords(i.x,-i.y)}function Ic(n,e,t,r){let s=Pe(n,e),o=Pe(n,t),i=s instanceof R?s.parent:null;if(!(s instanceof R)||!(i instanceof R)||!(o instanceof R))return null;for(let V=o;V;V=V.parent)if(V===s)return null;let a=s.layoutBounds,c=o._planeOf(null),d=c?null:o._slotFor({width:a?.width??0,height:a?.height??0});if(!c&&!d)return null;let u=Nc(s,i),l=ce(u),h=ce(It(o));if(!l||!h)return null;let f=s._placement(),p=Cc(i),w=Cc(o),m=p.rotation+(f?.rotation??0)-w.rotation,y=w.scale===0?1:p.scale*(f?.scale??1)/w.scale,_=s._centreShift(s.rotation+m,s.scale*y),v=B(l,B(ie(s),{x:0,y:0})),A=i._planeOf(s),M=V=>A?{...A.toOffset(V.x,V.y)}:V,T=M({x:s.x,y:s.y});return{offsets:r.map(V=>{let P=M(V),ee=B(u,{x:v.x+P.x-T.x,y:v.y-(P.y-T.y)}),ae=B(h,ee),rt=ae.x-_.x,H=ae.y-_.y;return c?c.toCoords(rt,-H):{x:rt-d.x,y:d.y-H}}),turn:m,scale:y}}function Cc(n){let e=Rc(n),t=n._cameraScope();return t?{rotation:e.rotation-t.heading,scale:e.scale*t.zoom}:e}function Fc(n,e){let t=Pe(n,e);if(!(t instanceof R))return null;let r=ie(t);return t._handles().map(({prop:s,at:o})=>{let i=B(r,{x:o.x,y:-o.y});return{prop:s,at:{x:i.x,y:-i.y}}})}function $c(n,e,t,r){let s=Pe(n,e);if(!(s instanceof R))return null;let o=ie(s),i=ce(o);if(!i)return null;let a=B(i,{x:r.x,y:-r.y});return Rs(o,a)?null:s._handleValue(t,{x:a.x,y:-a.y})}function Nc(n,e){let t=Vt(n)?vr(e):null;if(!t){let i=n._slotMatrix();return i?he(It(e),i):It(e)}let r=n._slotAffine(),s=r?hr(t.view,r):t.view,o=hr(s,[1,0,0,0,0,1,0,0,0,0,1,n.depth]);return he(ie(t.root),Js(t.camera,o))}function Rs(n,e){return dr(n)&&(n.g??0)*e.x+(n.h??0)*e.y+(n.i??1)<=0}function Rc(n){let e=0,t=1,r=1;for(let s=n;s;s=s.parent){let o=s._placement();e+=s.rotation+(o?.rotation??0),t*=s.scale*(o?.scale??1),r*=s.opacity*(o?.opacity??1);let i=s!==n?s._cameraScope():null;i&&(e-=i.heading,t*=i.zoom)}return{rotation:e,scale:t,opacity:r}}function Ft(n,e){let t=n._localBounds(),r=t.x===0&&t.y===0?ie(n):he(ie(n),ur(t.x,-t.y)),s=uo(r,t.width/2,t.height/2),o=Rc(n);return{id:n.id,path:e,type:n.className,topLeft:s.topLeft,topRight:s.topRight,bottomRight:s.bottomRight,bottomLeft:s.bottomLeft,center:s.center,width:t.width,height:t.height,rotation:o.rotation,scale:o.scale,opacity:o.opacity,locked:n.locked}}function zc(n,e){if(e==="")return Ft(n,e);let t=n,r=null,s=e.split(".");for(let i=0;i<s.length;i++){nt(t)&&(r={node:t,path:Lc(s,i)});let a=t._allChildren[Number(s[i])];if(!a)return null;t=a}if(t instanceof R)return Ft(t,e);if(!r)return null;let o=Vn(r.node,r.path);return Fs(r.node,o,r.path).find(i=>i.path===e)??null}function Pe(n,e){if(e==="")return n;let t=n;for(let r of e.split(".")){let s=t._allChildren[Number(r)];if(!s)return null;t=s}return t}function Lc(n,e){return n.slice(0,e).join(".")}function Bc(n,e,t,r){if(e==="")return null;let s=n,o=null,i=e.split(".");for(let c=0;c<i.length;c++){nt(s)&&(o={node:s,path:Lc(i,c)});let d=s._allChildren[Number(i[c])];if(!d)return null;s=d}if(s instanceof R||!o)return null;let a=Vn(o.node,o.path);return Sc(o.node,a,o.path,e,t,r)}function jc(n,e,t=0){return Vc(n,"",e,t,!0)}function Vc(n,e,t,r,s){if(n.opacity===0||n.hidden)return null;let o=Kc(n,s);if(o==="none")return null;let i=o==="all"&&sf(n,t,r);if(!i&&o==="all"&&n._confinesChildren())return null;let a=Gc(n),c=Uc(n,a);for(let d=c.length-1;d>=0;d--){let u=c[d],l=a[u];if(l===null)continue;let h=Vc(l,ye(e,u),t,r,!1);if(h)return h}if(nt(n)&&i){let d=Ac(n,Vn(n,e),t,r,e);if(d)return d}return s||n.locked?null:i?Ft(n,e):null}function zs(n,e,t,r){if(n.opacity===0||n.hidden)return;let s=Kc(n,r);if(s==="none")return;if(!r&&s==="all"&&t.push(Ft(n,e)),nt(n))for(let i of Fs(n,Vn(n,e),e))t.push(i);let o=Gc(n);for(let i of Uc(n,o)){let a=o[i];a!==null&&zs(a,ye(e,i),t,!1)}}function Kc(n,e){if(e)return"all";let t=Vt(n);return t?!n.backfaceVisible&&t.facesAway?"none":t.paints?"all":n._rendersChildrenInSpace()?"children":"none":"all"}function Uc(n,e){let t=e.map((i,a)=>a),r=vr(n);if(!r)return t;let s=t.filter(i=>e[i]!==null),o=s.map(i=>lo(r,e[i]));return fo(o).map(i=>s[i])}function Gc(n){return nt(n)?n._allChildren.map(e=>e instanceof R?e:null):n.children}function Vn(n,e){return{box:Ft(n,e),matrix:ie(n)}}function sf(n,e,t){let r=ie(n),s=ce(r);if(!s)return!1;let o=B(s,{x:e.x,y:-e.y});return Rs(r,o)?!1:n._hitTestSelf({x:o.x,y:-o.y},t)}function Yc(n,e,t){let r=n instanceof rn?Do(n):null;if(!r)return null;let s=t.layoutTextBlock(r);if(!s)return null;let o=ie(n),i=(d,u)=>{let l=B(o,{x:d,y:u});return{x:l.x,y:-l.y}},a=new Array(ms(s)),c=[];for(let d of s.lines){c.push({start:d.start,end:d.end});for(let u=0;u<d.carets.length;u++){let l=d.carets[u];a[d.start+u]={offset:d.start+u,top:i(l,d.top),bottom:i(l,d.bottom)}}}return{path:e,text:n.text,carets:a,lines:c}}function $b(n,e){let t=0,r=1/0;for(let s of n.carets){let o=of(e,s.top,s.bottom);o<r&&(r=o,t=s.offset)}return t}function Nb(n,e,t){let r=Math.max(0,Math.min(e,t)),s=Math.min(n.carets.length-1,Math.max(e,t)),o=[];for(let i of n.lines){let a=Math.max(r,i.start),c=Math.min(s,i.end);if(a>=c)continue;let d=n.carets[a],u=n.carets[c];o.push({topLeft:d.top,topRight:u.top,bottomRight:u.bottom,bottomLeft:d.bottom})}return o}function of(n,e,t){let r=t.x-e.x,s=t.y-e.y,o=r*r+s*s,i=o===0?0:Math.max(0,Math.min(1,((n.x-e.x)*r+(n.y-e.y)*s)/o));return Math.hypot(n.x-(e.x+i*r),n.y-(e.y+i*s))}var Kn=class{renderContext;measurer;storageAdapter;masterClock;stateEvaluator;assetManager;audioDevice;assetCatalog;onFramePainted;disposed=!1;precompRunning=!1;hasPainted=!1;seekGeneration=0;precompBudgetMs;onPrecompProgress;fps;viewport;precomper;store;overrides=new Map;precomp;get spans(){return this.precomp.tracks.map((e,t)=>({id:e.id,index:t,startFrame:e.startFrame,endFrame:e.startFrame+e.frameCount-1}))}get totalFrames(){return this.precomp.totalFrames}get totalDuration(){return this.precomp.totalDuration}get currentTrackId(){return this.stateEvaluator.currentTrackId}get buildErrors(){return this.renderErrors.length===0?this.precomp.buildErrors:[...this.precomp.buildErrors,...this.renderErrors]}renderErrors=[];onRenderError;captureRenderError(e,t){let r=e instanceof Error?e:new Error(String(e));t!==void 0&&this.recoverMissingAsset(r,t)||this.renderErrors.some(s=>s.message===r.message)||(this.renderErrors.push({trackId:this.stateEvaluator.currentTrackId??"",message:r.message,stack:r.stack}),this.onRenderError?.(this.buildErrors))}learnMissingAsset(e,t){let r=df(e,this.assetCatalog);if(r)for(let s of[...this.stateEvaluator.activeTrackIds].reverse()){let o=this.store.instanceOf(s),i=this.precomp.tracks.find(d=>d.id===s);if(!o||!i)continue;let a;if(e.nodeId!==void 0&&o.forEachOwner((d,u)=>{a===void 0&&d.id===e.nodeId&&(a=u)}),a??=this.store.ownersOf(s,e.src).values().next().value,a===void 0)continue;let c=this.precomper.learn(s,a,r,Math.floor(t)-i.startFrame);c!==this.precomp&&this.adoptPrecomp(c);return}}rescuedAssets=new Set;recoverMissingAsset(e,t){if(!(e instanceof io)||e.assetType==="audio")return!1;let r=`${e.assetType}:${e.src}`;if(this.rescuedAssets.has(r))return!1;this.rescuedAssets.add(r),this.learnMissingAsset(e,t);let s=this.recordFor(e.assetType,e.src,t);return s?(this.storageAdapter.loadAsset(e.src,s).then(()=>{this.disposed||(this.renderAt(this.stateEvaluator.currentFrame),this.settleTrailing())}).catch(o=>{this.disposed||this.captureRenderError(new Error(`${e.message}
11
+
12
+ Loading it directly also failed: ${String(o)}`))}),!0):!1}recordFor(e,t,r){try{return e==="font"?{type:"font",src:t,startFrame:r,endFrame:r,fontFamily:t,fontWeight:400}:e==="image"?(this.assetCatalog.getImageMeta(t),{type:"image",src:t,startFrame:r,endFrame:r}):(this.assetCatalog.getVideoMeta(t),{type:"video",src:t,startFrame:r,endFrame:r,trimStart:0,trimEnd:this.assetCatalog.getVideoDuration(t)})}catch{return null}}clearRenderErrors(){this.rescuedAssets.clear(),this.renderErrors.length!==0&&(this.renderErrors.length=0,this.onRenderError?.(this.buildErrors))}constructor(e){let{project:t}=e;if(t.fps===void 0||t.viewport===void 0)throw new Error("PlaybackController takes a project whose fps and viewport are resolved \u2014 see Session.");this.renderContext=e.renderContext,this.measurer=e.measurer,this.masterClock=e.masterClock,this.storageAdapter=e.storageAdapter,this.audioDevice=e.audioDevice,this.fps=t.fps,this.viewport=t.viewport,this.precompBudgetMs=e.precompBudgetMs??Pt,this.onPrecompProgress=e.onPrecompProgress,this.assetCatalog=e.assets;let r={registry:e.registry,viewport:this.viewport,fps:this.fps,assets:e.assets,measurer:this.measurer};this.store=new Ce(t,r,{profile:e.precompProfile,isReady:s=>this.assetManager?.isReady(s)??!1}),this.precomper=new Bn(t,r,{store:this.store}),this.precomp=this.precomper.ensureCovering(0),this.stateEvaluator=new zn(t,r,this.store),this.assetManager=new En(this.precomp,this.storageAdapter,this.audioDevice,s=>this.captureRenderError(s)),this.masterClock.setDuration(this.totalDuration),this.masterClock.onPlay((s,o,i)=>{this.audioDevice.play(s,o,i),this.storageAdapter.setPlaying(!0)}),this.masterClock.onPause(()=>{this.audioDevice.stop(),this.storageAdapter.setPlaying(!1)}),this.masterClock.onTick(async s=>{let o=++this.seekGeneration,i=ve(s,this.fps);i>=this.totalFrames&&this.masterClock.pause(),this.discoverThrough(i),await this.loadFrame(i),this.isCurrent(o)&&(this.audioDevice.syncTo(s),this.renderAt(i),this.assetManager.prefetch(i),this.trimAround(i))}),this.startBackgroundPrecomp()}startBackgroundPrecomp(){this.precompRunning||this.disposed||this.precomp.complete||(this.precompRunning=!0,(async()=>{try{for(await Pn();!this.disposed&&!this.precomp.complete;){let e=await this.precomper.runAsync({budgetMs:this.precompBudgetMs,isCancelled:()=>this.disposed,onProgress:t=>this.adoptPrecomp(t)});if(this.disposed)return;this.precomp.complete||this.adoptPrecomp(e)}}finally{this.precompRunning=!1}})())}adoptPrecomp(e){this.disposed||(this.precomp=e,this.assetManager.setPrecomp(e),this.masterClock.setDuration(this.totalDuration),this.onPrecompProgress?.(e))}discoverThrough(e){let t=this.precomper.ensureCovering(Math.floor(e));t!==this.precomp&&this.adoptPrecomp(t)}async loadFrame(e){let t=[];for(let r of Ee(this.store.spans,Math.floor(e)))for(let s of this.store.layoutGates(r.id))this.assetManager.isReady(s.src)||t.push(s);if(t.length===0){await this.assetManager.loadAt(e);return}await Promise.all([this.assetManager.loadAt(e),this.assetManager.loadRecords(t)])}trimAround(e){Math.abs(e-this.lastTrimFrame)<this.fps||(this.lastTrimFrame=e,this.store.trim(Math.floor(e),Math.ceil(af*this.fps)))}lastTrimFrame=0;get isPlaying(){return this.masterClock.isPlaying}get currentTime(){return this.masterClock.currentTime}get currentFrame(){return ve(this.masterClock.currentTime,this.fps)}onTime(e){this.masterClock.onTime(e)}onPlay(e){this.masterClock.onPlay(()=>e())}onPause(e){this.masterClock.onPause(e)}isCurrent(e){return!this.disposed&&e===this.seekGeneration}renderAt(e){if(!this.disposed){this.hasPainted=!0,this.renders++;try{this.store.settleGates(Ee(this.store.spans,Math.floor(e)).map(t=>t.id)),this.stateEvaluator.stateAt(e),this.applyOverrides(),this.stateEvaluator.layout(this.measurer),this.renderContext.execute(()=>{this.stateEvaluator.render(this.renderContext)})}catch(t){this.captureRenderError(t,e)}this.announcePaint(e)}}announcePaint(e){if(this.onFramePainted)try{this.onFramePainted(Math.floor(e))}catch(t){console.error("[PlaybackController] onFramePainted listener threw:",t)}}async seek(e){if(this.disposed)return;let t=++this.seekGeneration;this.paintInFlight=t;try{let r=Math.max(0,Math.min(e,this.totalFrames));if(this.masterClock.pause(),this.discoverThrough(r),this.masterClock.seek(Be(r,this.fps)),await this.loadFrame(r),!this.isCurrent(t)||await this.settle(()=>this.renderAt(r),t)==="superseded")return;this.assetManager.prefetch(r),this.trimAround(r)}finally{this.paintLanded(t)}}setProject(e){if(this.disposed)return;let t=++this.seekGeneration;this.precomper.setProject(e),this.stateEvaluator.setProject(e),this.discoverThrough(this.currentFrame),this.clearRenderErrors(),this.masterClock.setDuration(this.totalDuration);let r=Math.min(this.currentFrame,Math.max(0,this.totalFrames-1));this.pendingSwap=t,this.paintInFlight=t,this.lastReplacePaint=this.loadAndRepaint(r,t),this.startBackgroundPrecomp()}reconcileCatalog(){this.disposed||(this.store.reset(),this.setProject(this.store.project))}whenReplaced(){return this.lastReplacePaint}lastReplacePaint=Promise.resolve();pendingSwap=0;async loadAndRepaint(e,t){try{try{await this.loadFrame(e)}catch(r){console.error("[PlaybackController] swap asset load failed:",r);return}await this.settle(()=>this.renderAt(e),t)}finally{this.pendingSwap===t&&(this.pendingSwap=0),this.paintLanded(t)}}seekWhilePlaying(e){++this.seekGeneration;let t=Math.max(0,Math.min(e,this.totalFrames));this.masterClock.seek(Be(t,this.fps))}async screenshot(){let e=this.stateEvaluator.currentFrame,t=++this.seekGeneration;this.paintInFlight=t;try{return await this.loadFrame(e),!this.isCurrent(t)||await this.settle(()=>this.renderAt(e),t,!0)==="superseded"?void 0:this.renderContext.screenshot()}finally{this.paintLanded(t)}}async settle(e,t,r=!1){let s=r?cf(this.storageAdapter):this.storageAdapter,o=await yc(e,s,()=>this.isCurrent(t));return o==="exhausted"&&console.warn(`[PlaybackController] frame ${this.stateEvaluator.currentFrame} still had decodes pending after ${4} passes`),o}paintInFlight=0;renders=0;repaintOwedSince=null;paintLanded(e){if(!(this.paintInFlight!==e||this.disposed)){if(this.paintInFlight=0,this.repaintOwedSince!==null){let t=this.renders===this.repaintOwedSince;this.repaintOwedSince=null,t&&!this.isPlaying&&this.renderAt(this.stateEvaluator.currentFrame)}this.settleTrailing()}}getTreeState(){let e=this.stateEvaluator.currentInstance;if(!e)return null;let t=this.precomp.tracks.find(c=>c.id===this.stateEvaluator.currentTrackId),r=t?.startFrame??0,s=t?.frameCount??Je(e.duration,this.fps),o=new Map,i=new Map;e.forEachOwner((c,d,u,l)=>{i.set(d,l);let h=Qe(u,this.fps,s);h&&o.set(l,{startFrame:r+h.startFrame,endFrame:r+h.endFrame})});let a=uf(t?.audioRequests??[],i);return Xc(e.canvas,"",o,a)}getNodeState(e){let t=this.stateEvaluator.currentCanvas;if(!t)return null;let r=Wc(t,e);return r?{id:r.id,type:r.className,properties:r.properties}:null}getNodeInitialProps(e){return this.stateEvaluator.currentInstance?.baselineProps(e)??null}getNodeBox(e){let t=this.stateEvaluator.currentCanvas;return t?zc(t,e):null}getNodePropsAt(e){let t=this.stateEvaluator.currentCanvas;if(!t)return null;let r=Pe(t,e);return r?r.properties:null}getNodeBoxes(){let e=this.stateEvaluator.currentCanvas;if(!e)return[];let t=[];return zs(e,"",t,!0),t}projectNode3D(e,t,r){let s=this.stateEvaluator.currentCanvas;return s?Bc(s,e,t,r):null}parentPlanePoint(e,t){let r=this.stateEvaluator.currentCanvas;return r?Pc(r,e,t):null}childPlanePoint(e,t){let r=this.stateEvaluator.currentCanvas;return r?Dc(r,e,t):null}reparentPlacement(e,t,r){let s=this.stateEvaluator.currentCanvas;return s?Ic(s,e,t,r):null}nodeHandles(e){let t=this.stateEvaluator.currentCanvas;return t?Fc(t,e):null}handleValue(e,t,r){let s=this.stateEvaluator.currentCanvas;return s?$c(s,e,t,r):null}getTextLayout(e){let t=this.stateEvaluator.currentCanvas;if(!t)return null;let r=qc(t,e);return r instanceof R?this.textLayoutOf(r,e):null}textLayoutOf(e,t){let r=ec(this.measurer);return r?Yc(e,t,r):null}pickNode(e,t=0){let r=this.stateEvaluator.currentCanvas;return r?jc(r,e,t):null}setNodeOverride(e,t){let r=this.overrides.get(e);this.overrides.set(e,r?{...r,...t}:{...t}),this.applyOverrides()}clearNodeOverrides(e){(e===void 0?this.overrides.size>0&&(this.overrides.clear(),!0):this.overrides.delete(e))&&(this.stateEvaluator.rebuild(),this.repaint())}setEditorStates(e,t){this.stateEvaluator.setEditorStates(e,t),this.repaint()}repaint(){this.hasPainted&&(this.pendingSwap!==0&&this.isCurrent(this.pendingSwap)||(this.renderAt(this.stateEvaluator.currentFrame),this.settleTrailing()))}settleTrailing(){this.trailingSettle||this.disposed||this.isPlaying||!this.hasBackgroundDecodes()||this.repaintBehindDecodes().catch(e=>{console.error("[PlaybackController] background decode failed:",e)})}trailingSettle=!1;hasBackgroundDecodes(){return this.storageAdapter.hasPendingDecodes()||this.storageAdapter.hasPendingUpgrades()}async repaintBehindDecodes(){this.trailingSettle=!0;try{for(let e=0;e<4&&this.hasBackgroundDecodes();e++){let[t,r]=await Promise.all([this.storageAdapter.warmPendingDecodes(),this.storageAdapter.warmPendingUpgrades()]);if(!(t||r)||this.disposed||this.isPlaying)return;if(this.paintInFlight!==0){this.repaintOwedSince=this.renders;return}this.renderAt(this.stateEvaluator.currentFrame)}}finally{this.trailingSettle=!1}}applyOverrides(){if(this.overrides.size===0)return;let e=this.stateEvaluator.currentCanvas;if(e)for(let[t,r]of this.overrides)qc(e,t)?.set(r)}play(e=1,t=!1){if(this.currentFrame>=this.totalFrames){this.seek(0).then(()=>this.masterClock.play(e,t)).catch(()=>{});return}this.masterClock.play(e,t)}pause(){this.masterClock.pause()}setMuted(e){this.audioDevice.setMuted(e)}dispose(){this.disposed=!0,this.masterClock.dispose(),this.audioDevice.dispose(),this.stateEvaluator.dispose(),this.store.dispose(),this.assetManager.dispose()}},af=30;function cf(n){return{async warmPendingDecodes(){let[e,t]=await Promise.all([n.warmPendingDecodes(),n.warmPendingUpgrades()]);return e||t}}}function df(n,e){switch(n.assetType){case"image":return{type:"image",src:n.src};case"font":return{type:"font",family:n.src,weight:400};case"video":try{return{type:"video",src:n.src,trimStart:0,trimEnd:e.getVideoDuration(n.src)}}catch{return}default:return}}function Jb(n){return n.children.length>0}function Xc(n,e,t,r){let s={id:n.id,path:e,type:n.className,children:n._allChildren.map((a,c)=>Xc(a,ye(e,c),t,r))},o=r.get(e);o&&o.length>0&&(s.waveform=o);let i=t.get(e);return i&&(s.startFrame=i.startFrame,s.endFrame=i.endFrame),s}function uf(n,e){let t=new Map;for(let r of n){let s=r.ownerId!==void 0?e.get(r.ownerId):"";if(s===void 0)continue;let o={src:r.src,startTime:r.startAt,endTime:Number.isFinite(r.endAt)?r.endAt:null},i=t.get(s);i?i.push(o):t.set(s,[o])}return t}function qc(n,e){if(e==="")return n;let t=n;for(let r of e.split(".")){let s=t._allChildren[Number(r)];if(!s)return null;t=s}return t}function Wc(n,e){if(n.id===e)return n;for(let t of n._allChildren){let r=Wc(t,e);if(r)return r}return null}var Un=class{manifest;constructor(e){this.manifest=e}reconcile(e){this.manifest=e}normalizeKey(e){return e.replace(/\\/g,"/").replace(/^\.\//,"").replace(/^\/+/,"")}getImageMeta(e){let t=this.manifest.image[this.normalizeKey(e)];if(!t)throw new Error(`Image asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`);return t}getVideoMeta(e){let t=this.manifest.video[this.normalizeKey(e)];if(!t)throw new Error(`Video asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`);return t}getAudioMeta(e){let t=this.manifest.audio[this.normalizeKey(e)];if(!t)throw new Error(`No audio metadata for src: ${e}`);return t}getFontMeta(e){let t=this.manifest.font[e];if(!t)throw new Error(`No font metadata for key: ${e}`);return t}getFontFamilyMetas(e){return Object.values(this.manifest.font).filter(t=>t.fontFamily===e)}getVideoDuration(e){return this.getVideoMeta(e).duration}getAudioDuration(e){return this.getAudioMeta(e).duration}getMediaDuration(e){let t=this.normalizeKey(e),r=this.manifest.audio[t];if(r)return r.duration;let s=this.manifest.video[t];if(s)return s.duration;throw new Error(`Audio asset not found: "${e}". Check the file exists in your public folder and the src matches its filename.`)}getImageSize(e){let{width:t,height:r}=this.getImageMeta(e);return{width:t,height:r}}};var Gn=class{controller;constructor(e){this.controller=e}get isPlaying(){return this.controller.isPlaying}get frame(){return this.controller.currentFrame}play(e=1,t=!1){this.controller.play(e,t)}pause(){this.controller.pause()}seekFrame(e){this.controller.seekWhilePlaying(e)}setMuted(e){this.controller.setMuted(e)}onTime(e){this.controller.onTime(e)}onPlay(e){this.controller.onPlay(e)}onPause(e){this.controller.onPause(e)}};var Yn=class{_isPlaying=!1;_currentTime=0;_duration=0;get isPlaying(){return this._isPlaying}get currentTime(){return this._currentTime}get duration(){return this._duration}setDuration(e){this._duration=e}setCurrentTime(e,t=!0){if(this._currentTime!==e&&(this._currentTime=e,!!t))for(let r of this.timeCallbacks)r(e)}setPlaying(e){this._isPlaying=e}play(e,t){this._isPlaying=!0;for(let r of this.playCallbacks)r(this._currentTime,e,t)}async tick(){await Promise.all(this.tickCallbacks.map(e=>e(this._currentTime)))}pause(){this._isPlaying=!1;for(let e of this.pauseCallbacks)e()}tickCallbacks=[];playCallbacks=[];pauseCallbacks=[];timeCallbacks=[];dispose(){this.tickCallbacks.length=0,this.playCallbacks.length=0,this.pauseCallbacks.length=0,this.timeCallbacks.length=0}onTick(e){this.tickCallbacks.push(e)}onPlay(e){this.playCallbacks.push(e)}onPause(e){this.pauseCallbacks.push(e)}onTime(e){this.timeCallbacks.push(e)}};var qn=class extends Yn{seek(e){this.setCurrentTime(e)}};var Hc=class{engine;viewport;fps;constructor(e,t){this.engine=e,this._override={viewport:t.viewport,fps:t.fps},this._project=Zc(t.document,t,e),this.viewport=this._project.viewport,this.fps=this._project.fps,this._catalog=new Un(e.manifest),this._unsubscribe=e._onManifestChange(a=>{this._catalog.reconcile(a),this._storage.setCatalog(this._catalog),this._controller.reconcileCatalog()});let r={catalog:this._catalog,viewport:this.viewport,fps:this.fps};this._storage=e.platform.createStorageAdapter(r),this._renderContext=e.platform.createRenderContext(this._storage);let s=e.platform.createMeasureContext(this._storage),o=e.platform.createAudioSink(),i=e.platform.createTicker(this.fps,o);this.applyGlobals(),t.target!==void 0&&this._renderContext.mount(t.target),this._controller=new Kn({project:this._project,registry:e._registry,renderContext:this._renderContext,measurer:s,storageAdapter:this._storage,masterClock:i??new qn,audioDevice:o,assets:this._catalog,onPrecompProgress:t.onPrecompProgress}),this._playback=i===null?null:new Gn(this._controller)}get document(){return this._project}get playback(){return this._playback}get controller(){return this._controller}get surface(){return this._renderContext}get duration(){return this._controller.totalDuration}get totalFrames(){return this._controller.totalFrames}async seek(e){await this.seekFrame(Math.round(ve(e,this.fps)))}async seekFrame(e){this.applyGlobals(),await this._controller.seek(e)}replace(e){let t=Zc(e,this._override,this);if(t.fps!==this.fps||t.viewport.width!==this.viewport.width||t.viewport.height!==this.viewport.height)throw new Error(`Cannot replace a ${this.viewport.width}\xD7${this.viewport.height} @ ${this.fps}fps document with a ${t.viewport.width}\xD7${t.viewport.height} @ ${t.fps}fps one \u2014 open a new session.`);this._project=t,this.applyGlobals(),this._controller.setProject(t)}image(e={}){return this.applyGlobals(),this.engine.exporter.exportStill({...e,frame:e.frame??{kind:"last"},project:this._project,registry:this.engine._registry,manifest:e.manifest??this.engine.manifest})}export(e={}){return this.applyGlobals(),this.engine.exporter.exportVideo({...e,project:this._project,registry:this.engine._registry,manifest:e.manifest??this.engine.manifest})}dispose(){this._unsubscribe(),this._controller.dispose(),this._renderContext.dispose()}applyGlobals(){Qn(this._project.theme)}_override;_project;_catalog;_storage;_renderContext;_controller;_playback;_unsubscribe};function Zc(n,e,t){let r=Qi(n),s={...r,viewport:e.viewport??r.viewport??t.viewport,fps:e.fps??r.fps??t.fps};return xa(s),s}function pk(n,e={}){let t=e.delimiter??",",r=hf(n,t);if(r.length===0)return[];let s=r[0].map(d=>d.trim()),i=r.slice(1).map(d=>{let u={};return s.forEach((l,h)=>{u[l]=d[h]??""}),u}),a=lf(s,i,e.numeric),c=ff(s,i,a,e.boolean);return a.length===0&&c.length===0?i:i.map(d=>{let u={...d};for(let l of a){let h=d[l];h!==""&&(u[l]=Number(h))}for(let l of c){let h=d[l];h!==""&&(u[l]=h==="true")}return u})}function mk(n,e){throw new Error(`parseData("${n}") must be called with a static string literal so the @motionscript/vite-plugin macro can inline it at build time. If you're seeing this error at runtime, either the plugin isn't installed/registered, or this call's argument isn't a plain string literal.`)}function lf(n,e,t){return t===!1?[]:Array.isArray(t)?t:n.filter(r=>{let s=!1;for(let o of e){let i=o[r];if(i!==""){if(!Number.isFinite(Number(i)))return!1;s=!0}}return s})}function ff(n,e,t,r){if(r===!1)return[];if(Array.isArray(r))return r;let s=new Set(t);return n.filter(o=>{if(s.has(o))return!1;let i=!1;for(let a of e){let c=a[o];if(c!==""){if(c!=="true"&&c!=="false")return!1;i=!0}}return i})}function hf(n,e){let t=[],r=[],s="",o=!1,i=!1,a=()=>{r.push(s),s=""},c=()=>{a(),t.push(r),r=[],i=!1};for(let d=0;d<n.length;d++){let u=n[d];if(o){u==='"'?n[d+1]==='"'?(s+='"',d++):o=!1:s+=u;continue}if(u==='"'){o=!0,i=!0;continue}if(u===e){i=!0,a();continue}if(u!=="\r"){if(u===`
13
+ `){(i||s)&&c();continue}s+=u,i=!0}}return(i||s)&&c(),t}var yk=(n,e)=>{let t=new Array(n);for(let r=0;r<n;r++)t[r]=e(r);return t};function wk(){let n=null;function e(t){if(t!==void 0)n=t;else{if(n===null)throw new Error("Reference not assigned yet");return n}}return e}var Xn=class{state=0;constructor(e){this.setSeed(e)}setSeed(e){this.state=typeof e=="string"?e.split("").reduce((t,r)=>(t=(t<<5)-t+r.charCodeAt(0),t&t),0):e}next(){this.state|=0,this.state=this.state+1831565813|0;var e=Math.imul(this.state^this.state>>>15,1|this.state);return e=e+Math.imul(e^e>>>7,61|e)^e,((e^e>>>14)>>>0)/4294967296}},Jc=4294967296,Ls=class n{_seed;numericSeed;gen;spareGauss=null;constructor(e){this.gen=new Xn(e),this.adopt(e)}get seed(){return this._seed}set seed(e){this.adopt(e)}static toNumeric(e){return typeof e=="string"?e.split("").reduce((t,r)=>(t<<5)-t+r.charCodeAt(0),0):e}adopt(e){this._seed=e,this.numericSeed=n.toNumeric(e),this.gen.setSeed(e),this.spareGauss=null}nextFloat(e=0,t=1){return this.gen.next()*(t-e)+e}nextInt(e=0,t=Jc){return Math.floor(this.gen.next()*(t-e))+e}floatArray(e,t=0,r=1){let s=new Array(e);for(let o=0;o<e;o++)s[o]=this.nextFloat(t,r);return s}intArray(e,t=0,r=Jc){let s=new Array(e);for(let o=0;o<e;o++)s[o]=this.nextInt(t,r);return s}gauss(e=0,t=1){if(this.spareGauss!==null){let a=this.spareGauss;return this.spareGauss=null,e+t*a}let r,s,o;do r=this.gen.next()*2-1,s=this.gen.next()*2-1,o=r*r+s*s;while(o>=1||o===0);let i=Math.sqrt(-2*Math.log(o)/o);return this.spareGauss=s*i,e+t*(r*i)}noise(e,t=1){let r=e*t,s=Math.floor(r),o=r-s,i=o*o*(3-2*o),a=this.latticeValue(s),c=this.latticeValue(s+1);return a+(c-a)*i}reset(e=this._seed){this.adopt(e)}latticeValue(e){let t=Math.sin(e+this.numericSeed)*1e4;return t-Math.floor(t)}};function Pk(n){return typeof n?._stepper=="function"}export{Dr as a,td as b,rd as c,Fr as d,ft as e,$r as f,Gp as g,Ho as h,Zo as i,Jo as j,ye as k,Qt as l,en as m,zr as n,Fe as o,ei as p,ti as q,ni as r,ri as s,si as t,Qm as u,eg as v,tg as w,ng as x,rg as y,sg as z,og as A,oi as B,ii as C,di as D,ui as E,li as F,rn as G,fi as H,hi as I,pi as J,mi as K,gi as L,yi as M,_i as N,wi as O,xi as P,Yr as Q,vi as R,bi as S,ki as T,Si as U,Ai as V,Mi as W,Ti as X,Oi as Y,Ei as Z,Ci as _,Pi as $,Di as aa,Ii as ba,Fi as ca,$i as da,Ni as ea,Ri as fa,zi as ga,Li as ha,Bi as ia,ji as ja,ay as ka,Vi as la,Ki as ma,Ui as na,Gi as oa,Yi as pa,qi as qa,Xi as ra,Wi as sa,Hi as ta,Zi as ua,Ge as va,hy as wa,sn as xa,kd as ya,b as za,U as Aa,py as Ba,Ji as Ca,on as Da,my as Ea,Sd as Fa,de as Ga,Ad as Ha,Qi as Ia,F as Ja,L as Ka,Pd as La,Dd as Ma,dn as Na,aa as Oa,Qr as Pa,Yd as Qa,xa as Ra,By as Sa,ln as Ta,Qd as Ua,eu as Va,tu as Wa,p_ as Xa,hn as Ya,ou as Za,cu as _a,We as $a,vn as ab,mw as bb,yw as cb,xw as db,vw as eb,ms as fb,Vu as gb,Ku as hb,Uu as ib,Gu as jb,qu as kb,nc as lb,Ju as mb,Qu as nb,ws as ob,el as pb,tl as qb,Sn as rb,ue as sb,An as tb,le as ub,rc as vb,wt as wb,xt as xb,vt as yb,sc as zb,Mn as Ab,xs as Bb,W as Cb,bt as Db,Tn as Eb,Ze as Fb,On as Gb,ul as Hb,ll as Ib,En as Jb,Cn as Kb,xe as Lb,Pn as Mb,mv as Nb,Be as Ob,ve as Pb,yv as Qb,Je as Rb,kt as Sb,ac as Tb,Ee as Ub,oe as Vb,Qe as Wb,Dn as Xb,Pt as Yb,Ce as Zb,zn as _b,Es as $b,yc as ac,hb as bc,Bn as cc,nt as dc,Fs as ec,Sc as fc,Ac as gc,ie as hc,Pc as ic,Dc as jc,Ic as kc,Fc as lc,$c as mc,Ft as nc,zc as oc,Pe as pc,Bc as qc,jc as rc,zs as sc,Yc as tc,$b as uc,Nb as vc,Kn as wc,Jb as xc,Un as yc,Gn as zc,Yn as Ac,qn as Bc,Hc as Cc,Zc as Dc,pk as Ec,mk as Fc,yk as Gc,wk as Hc,Xn as Ic,Ls as Jc,Pk as Kc};
14
+ //# sourceMappingURL=chunk-D4FSTPML.js.map