framefields 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE.md +4 -0
- package/dist/audio/index.d.mts +4 -4
- package/dist/audio/index.mjs +10 -10
- package/dist/{audio-BuCVk1IQ.mjs → audio-DHLoNcxD.mjs} +3 -3
- package/dist/{audio-BuCVk1IQ.mjs.map → audio-DHLoNcxD.mjs.map} +1 -1
- package/dist/{audio-CYZkDwae.d.mts → audio-afTBdB3U.d.mts} +3 -3
- package/dist/{audio-CYZkDwae.d.mts.map → audio-afTBdB3U.d.mts.map} +1 -1
- package/dist/cli/check-worker.mjs +45 -45
- package/dist/cli.mjs +174 -83
- package/dist/cli.mjs.map +1 -1
- package/dist/cloud/index.d.mts +14 -3
- package/dist/cloud/index.d.mts.map +1 -1
- package/dist/cloud/index.mjs +2 -2
- package/dist/{cloud-xcfV4J03.mjs → cloud-COid1Ipa.mjs} +169 -16
- package/dist/cloud-COid1Ipa.mjs.map +1 -0
- package/dist/components/index.d.mts +10 -10
- package/dist/components/index.mjs +44 -44
- package/dist/{dist-Dg9LMWoX.mjs → dist-2_lT3Dwc.mjs} +2 -2
- package/dist/{dist-Dg9LMWoX.mjs.map → dist-2_lT3Dwc.mjs.map} +1 -1
- package/dist/{dist-CWLLnigL.mjs → dist-B-OPY7Cs.mjs} +273 -76
- package/dist/dist-B-OPY7Cs.mjs.map +1 -0
- package/dist/{dist-EQX3TUUl.mjs → dist-BSqeChht.mjs} +3 -3
- package/dist/{dist-EQX3TUUl.mjs.map → dist-BSqeChht.mjs.map} +1 -1
- package/dist/{dist-CNGv-JTX.mjs → dist-BwtxciN4.mjs} +1 -1
- package/dist/dist-CySGkG54.mjs.map +1 -1
- package/dist/effects/index.d.mts +5 -5
- package/dist/effects/index.mjs +35 -35
- package/dist/{effects-DKLbLXF7.mjs → effects-C8CL9cOq.mjs} +2 -2
- package/dist/{effects-DKLbLXF7.mjs.map → effects-C8CL9cOq.mjs.map} +1 -1
- package/dist/fonts/index.mjs +2 -2
- package/dist/{fonts-gPbGbShD.mjs → fonts-BQrDjnpV.mjs} +2 -2
- package/dist/{fonts-gPbGbShD.mjs.map → fonts-BQrDjnpV.mjs.map} +1 -1
- package/dist/{gpu-CpkJJLQP.mjs → gpu-DHa-3Dou.mjs} +11 -3
- package/dist/gpu-DHa-3Dou.mjs.map +1 -0
- package/dist/{index-Cro-818i.d.mts → index-BNClElng.d.mts} +592 -516
- package/dist/index-BNClElng.d.mts.map +1 -0
- package/dist/{index-jSDEM-uE.d.mts → index-CAuNuvIg.d.mts} +5 -5
- package/dist/{index-jSDEM-uE.d.mts.map → index-CAuNuvIg.d.mts.map} +1 -1
- package/dist/index-COYNQ_mf.d.mts.map +1 -1
- package/dist/{index-D2i9J9Zq.d.mts → index-CTv9ZieD.d.mts} +2 -2
- package/dist/{index-D2i9J9Zq.d.mts.map → index-CTv9ZieD.d.mts.map} +1 -1
- package/dist/{index-C8YwZ6k1.d.mts → index-DQa7mhzq.d.mts} +2 -2
- package/dist/{index-C8YwZ6k1.d.mts.map → index-DQa7mhzq.d.mts.map} +1 -1
- package/dist/{index-Bly-7YM1.d.mts → index-Drk6HC2k.d.mts} +2 -2
- package/dist/{index-Bly-7YM1.d.mts.map → index-Drk6HC2k.d.mts.map} +1 -1
- package/dist/{index-BuiZzc6i.d.mts → index-Fliv2Z-w.d.mts} +32 -1
- package/dist/index-Fliv2Z-w.d.mts.map +1 -0
- package/dist/{index-CEU_Zsb9.d.mts → index-WwuuX8ZJ.d.mts} +24 -22
- package/dist/index-WwuuX8ZJ.d.mts.map +1 -0
- package/dist/index.d.mts +10 -10
- package/dist/index.mjs +52 -52
- package/dist/preview/index.d.mts +1 -1
- package/dist/preview/index.mjs +10 -10
- package/dist/{preview-BToKUTtZ.mjs → preview-BUtt481A.mjs} +2 -2
- package/dist/{preview-BToKUTtZ.mjs.map → preview-BUtt481A.mjs.map} +1 -1
- package/dist/preview-engine/audio.mjs +1 -1
- package/dist/preview-engine/{chunk-QF4JWVO3.mjs → chunk-35XSD4QM.mjs} +15 -15
- package/dist/preview-engine/{chunk-ZF2MEFKO.mjs → chunk-3DOIE4DV.mjs} +1 -1
- package/dist/preview-engine/{chunk-JDB7PMRI.mjs → chunk-3IT7LHWR.mjs} +1 -1
- package/dist/preview-engine/{chunk-DNNGWS2C.mjs → chunk-3MLGWUSK.mjs} +1 -1
- package/dist/preview-engine/{chunk-KVOFO273.mjs → chunk-3QJ5GRBH.mjs} +1 -1
- package/dist/preview-engine/{chunk-54Q5CKSV.mjs → chunk-3QTHW2CD.mjs} +1 -1
- package/dist/preview-engine/chunk-44V4V5LD.mjs +1 -0
- package/dist/preview-engine/{chunk-BRV7TQDV.mjs → chunk-4JNIEQS2.mjs} +1 -1
- package/dist/preview-engine/chunk-4YT5YJIF.mjs +1 -0
- package/dist/preview-engine/{chunk-C4M3B2Q2.mjs → chunk-5SLBE2FX.mjs} +1 -1
- package/dist/preview-engine/{chunk-BJXNKMSY.mjs → chunk-64L4GUOF.mjs} +20 -6
- package/dist/preview-engine/{chunk-UMJ3VGKN.mjs → chunk-6B3NOY5W.mjs} +1 -1
- package/dist/preview-engine/{chunk-VQA4DYZU.mjs → chunk-6O7UDVNL.mjs} +1 -1
- package/dist/preview-engine/chunk-74J4DJQA.mjs +1 -0
- package/dist/preview-engine/chunk-77MT33VR.mjs +1 -0
- package/dist/preview-engine/chunk-A6OAPDIA.mjs +1 -0
- package/dist/preview-engine/chunk-ADLIF544.mjs +39 -0
- package/dist/preview-engine/{chunk-OLB4TQLQ.mjs → chunk-AKVRG7UU.mjs} +1 -1
- package/dist/preview-engine/{chunk-CIVEZJYF.mjs → chunk-CRBOK3JT.mjs} +1 -1
- package/dist/preview-engine/chunk-CSLSWUUT.mjs +1 -0
- package/dist/preview-engine/{chunk-JSYG6OWZ.mjs → chunk-D7OMXGIZ.mjs} +1 -1
- package/dist/preview-engine/{chunk-EPRINA4V.mjs → chunk-E7BKWHOT.mjs} +10 -10
- package/dist/preview-engine/{chunk-NOKPBMIP.mjs → chunk-EWDJMJO5.mjs} +1 -1
- package/dist/preview-engine/{chunk-5KSBS3AL.mjs → chunk-EYE3GNL5.mjs} +1 -1
- package/dist/preview-engine/{chunk-GHTG5XV6.mjs → chunk-EYKN2VET.mjs} +84 -25
- package/dist/preview-engine/{chunk-OELPPLML.mjs → chunk-FJTURGJV.mjs} +1 -1
- package/dist/preview-engine/{chunk-IKVJ4MW5.mjs → chunk-G4ZTSLZU.mjs} +1 -1
- package/dist/preview-engine/{chunk-VZLIRYAL.mjs → chunk-GAMAKN5L.mjs} +1 -1
- package/dist/preview-engine/{chunk-65NANVQL.mjs → chunk-HTAHYSCW.mjs} +1 -1
- package/dist/preview-engine/{chunk-ZIXPWP2B.mjs → chunk-ICWD36H6.mjs} +1 -1
- package/dist/preview-engine/chunk-JAAFSVAG.mjs +1 -0
- package/dist/preview-engine/{chunk-RDWLLITE.mjs → chunk-JAUMCOOJ.mjs} +1 -1
- package/dist/preview-engine/{chunk-ACBBBOUM.mjs → chunk-KBCZKIIQ.mjs} +1 -1
- package/dist/preview-engine/{chunk-YVZTRH4Y.mjs → chunk-KDCM7S3S.mjs} +1 -1
- package/dist/preview-engine/chunk-KIPXBOYG.mjs +1974 -0
- package/dist/preview-engine/{chunk-6LTINEA4.mjs → chunk-M4QVCQ3O.mjs} +1 -1
- package/dist/preview-engine/{chunk-GN3NDRLI.mjs → chunk-NCQHOGZK.mjs} +1 -1
- package/dist/preview-engine/{chunk-YKM7JDQY.mjs → chunk-NJO2BIJX.mjs} +1 -1
- package/dist/preview-engine/{chunk-7GMHSTRP.mjs → chunk-NTSALWFF.mjs} +1 -1
- package/dist/preview-engine/{chunk-PKNUTHPI.mjs → chunk-O75BFM4S.mjs} +1 -1
- package/dist/preview-engine/{chunk-VFQH5KVS.mjs → chunk-ONHY4KNY.mjs} +1 -1
- package/dist/preview-engine/chunk-PH3UUX6A.mjs +138 -0
- package/dist/preview-engine/chunk-PIHG6HJO.mjs +1 -0
- package/dist/preview-engine/{chunk-YHMBGJP6.mjs → chunk-QPT2Y2GZ.mjs} +1 -1
- package/dist/preview-engine/{chunk-4AGQN53P.mjs → chunk-QXLFTCLC.mjs} +1 -1
- package/dist/preview-engine/{chunk-O63FLYWC.mjs → chunk-RGKS6YIA.mjs} +1 -1
- package/dist/preview-engine/{chunk-FQL4IJZN.mjs → chunk-RN7J5TRU.mjs} +1 -1
- package/dist/preview-engine/{chunk-26XWIHW3.mjs → chunk-RVCLMO5Q.mjs} +1 -1
- package/dist/preview-engine/{chunk-TEWRQKX3.mjs → chunk-SFHWP65D.mjs} +1 -1
- package/dist/preview-engine/{chunk-EXEO245X.mjs → chunk-TKXOSEIJ.mjs} +1 -1
- package/dist/preview-engine/chunk-UKZVUYB6.mjs +483 -0
- package/dist/preview-engine/{chunk-EAWJXW4J.mjs → chunk-UVEDFIPN.mjs} +1 -1
- package/dist/preview-engine/{chunk-Z24UEN4P.mjs → chunk-VUO4K52B.mjs} +1 -1
- package/dist/preview-engine/{chunk-IBPYV6HF.mjs → chunk-W4XR6F5G.mjs} +1 -1
- package/dist/preview-engine/{chunk-UI3VH33L.mjs → chunk-WPYWCWWL.mjs} +1 -1
- package/dist/preview-engine/{chunk-WFMUDL55.mjs → chunk-YAPGJZPI.mjs} +1 -1
- package/dist/preview-engine/{chunk-LMXMBX4J.mjs → chunk-YJ4DSRDY.mjs} +1 -1
- package/dist/preview-engine/{chunk-CCORQLMR.mjs → chunk-YOJKIMU5.mjs} +1 -1
- package/dist/preview-engine/{chunk-UGB6JKVS.mjs → chunk-ZHNEZZ6A.mjs} +1 -1
- package/dist/preview-engine/{chunk-LFNCWMKS.mjs → chunk-ZZMI3WOT.mjs} +1 -1
- package/dist/preview-engine/components.mjs +1 -1
- package/dist/preview-engine/effects.mjs +1 -1
- package/dist/preview-engine/fonts.mjs +1 -1
- package/dist/preview-engine/framefields.mjs +1 -1
- package/dist/preview-engine/player.mjs +1 -1
- package/dist/preview-engine/{renderers-53EI26GL.mjs → renderers-3FZVDYRQ.mjs} +1 -1
- package/dist/preview-engine/renderers-3KEBYOOF.mjs +1 -0
- package/dist/preview-engine/{renderers-6YVZUQOH.mjs → renderers-4RPQSUUZ.mjs} +1 -1
- package/dist/preview-engine/renderers-5EGFXFPF.mjs +1 -0
- package/dist/preview-engine/renderers-5SJHYUTM.mjs +1 -0
- package/dist/preview-engine/renderers-66MWDUN6.mjs +1 -0
- package/dist/preview-engine/{renderers-CCRZNGVK.mjs → renderers-6FENMFSC.mjs} +1 -1
- package/dist/preview-engine/renderers-77OXJ2GY.mjs +1 -0
- package/dist/preview-engine/renderers-7LI4QKHO.mjs +1 -0
- package/dist/preview-engine/{renderers-CYJAVWHT.mjs → renderers-AIZRIW2R.mjs} +1 -1
- package/dist/preview-engine/{renderers-OGOW3NA4.mjs → renderers-BDI2BDBA.mjs} +1 -1
- package/dist/preview-engine/renderers-BDXCO6NR.mjs +1 -0
- package/dist/preview-engine/{renderers-EN7LXJLG.mjs → renderers-BUZ67FNZ.mjs} +1 -1
- package/dist/preview-engine/renderers-DMTGKURQ.mjs +1 -0
- package/dist/preview-engine/renderers-DU7KPFVV.mjs +1 -0
- package/dist/preview-engine/{renderers-WSABL3QO.mjs → renderers-ECXMT5BD.mjs} +1 -1
- package/dist/preview-engine/{renderers-MOEC2XZZ.mjs → renderers-EILFSWSJ.mjs} +1 -1
- package/dist/preview-engine/{renderers-X6CORAES.mjs → renderers-EVEWFJ7U.mjs} +1 -1
- package/dist/preview-engine/renderers-F6PT2LON.mjs +1 -0
- package/dist/preview-engine/renderers-F7WPJXKT.mjs +1 -0
- package/dist/preview-engine/renderers-FIFF267S.mjs +1 -0
- package/dist/preview-engine/{renderers-GQM3KMV3.mjs → renderers-FQISHQEN.mjs} +1 -1
- package/dist/preview-engine/{renderers-HKLCB4U6.mjs → renderers-FXAVFNUN.mjs} +1 -1
- package/dist/preview-engine/{renderers-P2HORBZ6.mjs → renderers-GITAVRYZ.mjs} +1 -1
- package/dist/preview-engine/renderers-GTKRV225.mjs +1 -0
- package/dist/preview-engine/{renderers-KCGK33Y2.mjs → renderers-HG6JZIZO.mjs} +1 -1
- package/dist/preview-engine/{renderers-I6QKZ7CH.mjs → renderers-HHWMIDN3.mjs} +1 -1
- package/dist/preview-engine/renderers-HI3SRJVD.mjs +1 -0
- package/dist/preview-engine/{renderers-7CAHX35U.mjs → renderers-HXEDI4BD.mjs} +1 -1
- package/dist/preview-engine/{renderers-77PDUMYI.mjs → renderers-HXNSDJBY.mjs} +1 -1
- package/dist/preview-engine/{renderers-ACUJMDEK.mjs → renderers-I2ZOUFRU.mjs} +1 -1
- package/dist/preview-engine/renderers-JHFD4LHZ.mjs +1 -0
- package/dist/preview-engine/{renderers-IHGAWLUF.mjs → renderers-JMSAW7VY.mjs} +1 -1
- package/dist/preview-engine/renderers-KGVZUFHD.mjs +1 -0
- package/dist/preview-engine/{renderers-RN2MHIFK.mjs → renderers-KICDB5Y6.mjs} +1 -1
- package/dist/preview-engine/{renderers-C7SI3NIE.mjs → renderers-KKULMOV4.mjs} +1 -1
- package/dist/preview-engine/{renderers-HSFQIILN.mjs → renderers-KMVMPYY7.mjs} +1 -1
- package/dist/preview-engine/renderers-L6GFGHS6.mjs +1 -0
- package/dist/preview-engine/renderers-LN7WPG6I.mjs +1 -0
- package/dist/preview-engine/{renderers-BOBVXYAA.mjs → renderers-LWW4RF6D.mjs} +1 -1
- package/dist/preview-engine/renderers-LY57CZZB.mjs +1 -0
- package/dist/preview-engine/renderers-MBMJWZEW.mjs +1 -0
- package/dist/preview-engine/{renderers-VVP5WQOY.mjs → renderers-MPFU74I3.mjs} +1 -1
- package/dist/preview-engine/{renderers-H6PBHEYU.mjs → renderers-MW53LTMB.mjs} +1 -1
- package/dist/preview-engine/{renderers-PPZK6VEW.mjs → renderers-NQC4DPX4.mjs} +1 -1
- package/dist/preview-engine/{renderers-4IBFDW2S.mjs → renderers-PC2GOZDT.mjs} +1 -1
- package/dist/preview-engine/renderers-PREFONJG.mjs +1 -0
- package/dist/preview-engine/renderers-PSBTV2DO.mjs +228 -0
- package/dist/preview-engine/{renderers-UG2C3C7T.mjs → renderers-Q77UPEYE.mjs} +1 -1
- package/dist/preview-engine/renderers-QHXCFDHI.mjs +1 -0
- package/dist/preview-engine/renderers-R22CDFO4.mjs +1 -0
- package/dist/preview-engine/renderers-RDYJRNAR.mjs +1 -0
- package/dist/preview-engine/renderers-RENLKAA7.mjs +1 -0
- package/dist/preview-engine/{renderers-5XLGCEOA.mjs → renderers-RIPXT4AL.mjs} +1 -1
- package/dist/preview-engine/{renderers-FY2HOQCS.mjs → renderers-SFVFAS3C.mjs} +1 -1
- package/dist/preview-engine/{renderers-VIGZYJYX.mjs → renderers-SWQVCJHB.mjs} +1 -1
- package/dist/preview-engine/renderers-SZVDZDY7.mjs +1 -0
- package/dist/preview-engine/renderers-TEKHQHCL.mjs +1 -0
- package/dist/preview-engine/renderers-TS32FDV7.mjs +1 -0
- package/dist/preview-engine/renderers-TYSLUZ53.mjs +1 -0
- package/dist/preview-engine/renderers-U3RLYFCN.mjs +1 -0
- package/dist/preview-engine/{renderers-6LNDAO4B.mjs → renderers-U4IXWMD6.mjs} +1 -1
- package/dist/preview-engine/renderers-V5HM6PZ2.mjs +1 -0
- package/dist/preview-engine/{renderers-33FCFHDR.mjs → renderers-VUQAZ56P.mjs} +1 -1
- package/dist/preview-engine/renderers-W5YFMLSB.mjs +1 -0
- package/dist/preview-engine/renderers-XKDWUK56.mjs +1 -0
- package/dist/preview-engine/renderers-XKSBNCLZ.mjs +1 -0
- package/dist/preview-engine/renderers-XLQXVD37.mjs +1 -0
- package/dist/preview-engine/renderers-ZGX3A3QZ.mjs +1 -0
- package/dist/preview-engine/signals.mjs +1 -1
- package/dist/preview-engine/{src-4IUYUKIZ.mjs → src-GPF7RIBU.mjs} +1 -1
- package/dist/{program-Bc860ko5.mjs → program-Cvv_nb9T.mjs} +42 -15
- package/dist/program-Cvv_nb9T.mjs.map +1 -0
- package/dist/renderer/index.d.mts +1 -1
- package/dist/renderer/index.mjs +2 -2
- package/dist/renderer--RJepuOy.mjs +5 -0
- package/dist/{renderer-Bf4-N7k7.mjs → renderer-4uZGSmUD.mjs} +4 -4
- package/dist/{renderer-Bf4-N7k7.mjs.map → renderer-4uZGSmUD.mjs.map} +1 -1
- package/dist/{renderer-V4dhrf_h.mjs → renderer-5fGj_tqN.mjs} +4 -4
- package/dist/{renderer-V4dhrf_h.mjs.map → renderer-5fGj_tqN.mjs.map} +1 -1
- package/dist/{renderer-ByjaseAo.mjs → renderer-6g1ri445.mjs} +4 -4
- package/dist/{renderer-ByjaseAo.mjs.map → renderer-6g1ri445.mjs.map} +1 -1
- package/dist/{renderer-CR0mDPYY.mjs → renderer-B09I95bo.mjs} +2 -2
- package/dist/{renderer-BVKOQarx.d.mts → renderer-B1U6YRRV.d.mts} +22 -4
- package/dist/renderer-B1U6YRRV.d.mts.map +1 -0
- package/dist/renderer-B4NFnaty.mjs +5 -0
- package/dist/renderer-B6g4ts0e.mjs +5 -0
- package/dist/{renderer-g_1t2je9.mjs → renderer-BBjkX0Vt.mjs} +2 -2
- package/dist/{renderer-DAn9xiQT.mjs → renderer-BC_Nse6h.mjs} +4 -4
- package/dist/{renderer-DAn9xiQT.mjs.map → renderer-BC_Nse6h.mjs.map} +1 -1
- package/dist/renderer-BGoAr-tl.mjs +5 -0
- package/dist/{renderer-_9gbYS-3.mjs → renderer-BJEexai1.mjs} +4 -4
- package/dist/{renderer-_9gbYS-3.mjs.map → renderer-BJEexai1.mjs.map} +1 -1
- package/dist/{renderer-DcvjSolU.mjs → renderer-BOg8i8eF.mjs} +11 -2
- package/dist/{renderer-DcvjSolU.mjs.map → renderer-BOg8i8eF.mjs.map} +1 -1
- package/dist/renderer-BSOdBgdE.mjs +5 -0
- package/dist/{renderer-4ZUv3X1I.mjs → renderer-BSsKlcHk.mjs} +4 -4
- package/dist/{renderer-4ZUv3X1I.mjs.map → renderer-BSsKlcHk.mjs.map} +1 -1
- package/dist/{renderer-Cz-n883J.mjs → renderer-BTd6tFcS.mjs} +4 -4
- package/dist/{renderer-Cz-n883J.mjs.map → renderer-BTd6tFcS.mjs.map} +1 -1
- package/dist/renderer-BU6O0fpM.mjs +5 -0
- package/dist/{renderer-D-QVGphn.mjs → renderer-BXGuCnCJ.mjs} +4 -4
- package/dist/{renderer-D-QVGphn.mjs.map → renderer-BXGuCnCJ.mjs.map} +1 -1
- package/dist/renderer-BZ97iidG.mjs +5 -0
- package/dist/renderer-B_Klh1VT.mjs +5 -0
- package/dist/renderer-BaWQM1y-.mjs +5 -0
- package/dist/renderer-Bc0jvAj0.mjs +5 -0
- package/dist/renderer-Bd-NuU3M.mjs +3 -0
- package/dist/{renderer-B-CMRUag.mjs → renderer-Bf7Z7WT5.mjs} +3 -3
- package/dist/{renderer-B-CMRUag.mjs.map → renderer-Bf7Z7WT5.mjs.map} +1 -1
- package/dist/renderer-Bm077kZ6.mjs +5 -0
- package/dist/renderer-BtzE_e_Y.mjs +5 -0
- package/dist/{renderer-DFJWPqOJ.mjs → renderer-BvRM3OZ6.mjs} +3 -3
- package/dist/{renderer-DFJWPqOJ.mjs.map → renderer-BvRM3OZ6.mjs.map} +1 -1
- package/dist/{renderer-fwKnV9zs.mjs → renderer-BwJ0nXXu.mjs} +4 -4
- package/dist/{renderer-fwKnV9zs.mjs.map → renderer-BwJ0nXXu.mjs.map} +1 -1
- package/dist/{renderer-CLAvn9c6.mjs → renderer-BwV-o_1b.mjs} +3 -3
- package/dist/{renderer-CLAvn9c6.mjs.map → renderer-BwV-o_1b.mjs.map} +1 -1
- package/dist/{renderer-BDZC3o3N.mjs → renderer-Bxiiar50.mjs} +4 -4
- package/dist/{renderer-BDZC3o3N.mjs.map → renderer-Bxiiar50.mjs.map} +1 -1
- package/dist/{renderer-o68mVeyk.mjs → renderer-ByFPmHBC.mjs} +3 -3
- package/dist/{renderer-o68mVeyk.mjs.map → renderer-ByFPmHBC.mjs.map} +1 -1
- package/dist/{renderer-D4f8f66C.mjs → renderer-BzTj_CeK.mjs} +4 -4
- package/dist/{renderer-D4f8f66C.mjs.map → renderer-BzTj_CeK.mjs.map} +1 -1
- package/dist/renderer-C225eCAo.mjs +5 -0
- package/dist/{renderer-BNJ6Jk7-.mjs → renderer-C2kFIZ4r.mjs} +3 -3
- package/dist/{renderer-BNJ6Jk7-.mjs.map → renderer-C2kFIZ4r.mjs.map} +1 -1
- package/dist/{renderer-riIFosX6.mjs → renderer-C3CGYjrC.mjs} +4 -4
- package/dist/{renderer-riIFosX6.mjs.map → renderer-C3CGYjrC.mjs.map} +1 -1
- package/dist/renderer-CC4fhNup.mjs +3 -0
- package/dist/{renderer-B1esRxGy.mjs → renderer-CGpi8CDT.mjs} +4 -4
- package/dist/{renderer-B1esRxGy.mjs.map → renderer-CGpi8CDT.mjs.map} +1 -1
- package/dist/{renderer-Rw87u1Cr.mjs → renderer-CInMMs5x.mjs} +4 -4
- package/dist/{renderer-Rw87u1Cr.mjs.map → renderer-CInMMs5x.mjs.map} +1 -1
- package/dist/{renderer-COcKhouz.mjs → renderer-CLTRTtQ8.mjs} +4 -4
- package/dist/{renderer-COcKhouz.mjs.map → renderer-CLTRTtQ8.mjs.map} +1 -1
- package/dist/renderer-CLXdR4vz.mjs +5 -0
- package/dist/{renderer-BhsrlGKp.mjs → renderer-CMCmljb0.mjs} +74 -21
- package/dist/renderer-CMCmljb0.mjs.map +1 -0
- package/dist/{renderer-HDj9Zb-O.mjs → renderer-CN-mCIoI.mjs} +19 -6
- package/dist/renderer-CN-mCIoI.mjs.map +1 -0
- package/dist/{renderer-Ros7XQg2.mjs → renderer-CNpq7rL-.mjs} +3 -3
- package/dist/{renderer-Ros7XQg2.mjs.map → renderer-CNpq7rL-.mjs.map} +1 -1
- package/dist/{renderer-B3Dme2es.mjs → renderer-CZClDMgF.mjs} +4 -4
- package/dist/{renderer-B3Dme2es.mjs.map → renderer-CZClDMgF.mjs.map} +1 -1
- package/dist/{renderer-1uoKiILq.mjs → renderer-C_gR2H3R.mjs} +3 -3
- package/dist/{renderer-1uoKiILq.mjs.map → renderer-C_gR2H3R.mjs.map} +1 -1
- package/dist/{renderer-88C3QpKL.d.mts → renderer-CcmxR6Fy.d.mts} +2 -2
- package/dist/{renderer-88C3QpKL.d.mts.map → renderer-CcmxR6Fy.d.mts.map} +1 -1
- package/dist/{renderer-50JEMaVo.mjs → renderer-CiHVnhUk.mjs} +4 -4
- package/dist/{renderer-50JEMaVo.mjs.map → renderer-CiHVnhUk.mjs.map} +1 -1
- package/dist/renderer-CszM8B3C.mjs +5 -0
- package/dist/renderer-Ctp8ZYfk.mjs +5 -0
- package/dist/{renderer-JHByuUNb.mjs → renderer-CtpEzVBn.mjs} +3 -3
- package/dist/{renderer-JHByuUNb.mjs.map → renderer-CtpEzVBn.mjs.map} +1 -1
- package/dist/renderer-CxQdSp8I.mjs +5 -0
- package/dist/{renderer-BaIJIfJ6.mjs → renderer-D3QPNBEj.mjs} +4 -4
- package/dist/{renderer-BaIJIfJ6.mjs.map → renderer-D3QPNBEj.mjs.map} +1 -1
- package/dist/{renderer-Bbxh4N8Y.mjs → renderer-D3YbHjRG.mjs} +73 -73
- package/dist/{renderer-Bbxh4N8Y.mjs.map → renderer-D3YbHjRG.mjs.map} +1 -1
- package/dist/renderer-D4GMRtDd.mjs +6 -0
- package/dist/{renderer-Bx14Wnxl.mjs → renderer-DCMoBppL.mjs} +58 -4
- package/dist/renderer-DCMoBppL.mjs.map +1 -0
- package/dist/{renderer-sfqZK6L5.mjs → renderer-DEoerd-j.mjs} +4 -4
- package/dist/{renderer-sfqZK6L5.mjs.map → renderer-DEoerd-j.mjs.map} +1 -1
- package/dist/renderer-DEsGIvTZ.mjs +5 -0
- package/dist/{renderer-ynFRJh7G.mjs → renderer-DGXqspB9.mjs} +2 -2
- package/dist/renderer-DIaUQ0EP.mjs +5 -0
- package/dist/{renderer-DgPn_SOC.mjs → renderer-DKFaVaRJ.mjs} +3 -3
- package/dist/{renderer-DgPn_SOC.mjs.map → renderer-DKFaVaRJ.mjs.map} +1 -1
- package/dist/{renderer-CrR8Mpxq.mjs → renderer-DL3o_lG1.mjs} +4 -4
- package/dist/{renderer-CrR8Mpxq.mjs.map → renderer-DL3o_lG1.mjs.map} +1 -1
- package/dist/{renderer-Bxjb0HYU.mjs → renderer-DLaUT6JZ.mjs} +3 -3
- package/dist/{renderer-Bxjb0HYU.mjs.map → renderer-DLaUT6JZ.mjs.map} +1 -1
- package/dist/renderer-DLjqcNzQ.mjs +5 -0
- package/dist/renderer-DMuQZa51.mjs +5 -0
- package/dist/{renderer-Co6UFbZB.mjs → renderer-DO1SZ5xY.mjs} +4 -4
- package/dist/{renderer-Co6UFbZB.mjs.map → renderer-DO1SZ5xY.mjs.map} +1 -1
- package/dist/{renderer-B6Oeahe_.mjs → renderer-DO_zXwMJ.mjs} +3 -3
- package/dist/{renderer-B6Oeahe_.mjs.map → renderer-DO_zXwMJ.mjs.map} +1 -1
- package/dist/renderer-DOgi2aF2.mjs +5 -0
- package/dist/{renderer-BSELd5vU.mjs → renderer-DP9ScNM6.mjs} +3 -3
- package/dist/{renderer-BSELd5vU.mjs.map → renderer-DP9ScNM6.mjs.map} +1 -1
- package/dist/{renderer-DOkbn1ot.mjs → renderer-DQJHjU0L.mjs} +4 -4
- package/dist/{renderer-DOkbn1ot.mjs.map → renderer-DQJHjU0L.mjs.map} +1 -1
- package/dist/renderer-DSh7cvi4.mjs +5 -0
- package/dist/renderer-DV1LVBBP.mjs +5 -0
- package/dist/{renderer-BJ-7WRgO.mjs → renderer-DX60Kr20.mjs} +3 -3
- package/dist/{renderer-BJ-7WRgO.mjs.map → renderer-DX60Kr20.mjs.map} +1 -1
- package/dist/{renderer-DLPhfwbR.mjs → renderer-DZIxduEt.mjs} +3 -3
- package/dist/{renderer-DLPhfwbR.mjs.map → renderer-DZIxduEt.mjs.map} +1 -1
- package/dist/{renderer-TKZCA0B9.mjs → renderer-DaLy1dFA.mjs} +208 -69
- package/dist/renderer-DaLy1dFA.mjs.map +1 -0
- package/dist/{renderer-DaXQgGg3.mjs → renderer-DaY04IyU.mjs} +4 -4
- package/dist/{renderer-DaXQgGg3.mjs.map → renderer-DaY04IyU.mjs.map} +1 -1
- package/dist/{renderer-Dpl6poqD.mjs → renderer-Dak_wVh9.mjs} +2 -2
- package/dist/{renderer-Dpl6poqD.mjs.map → renderer-Dak_wVh9.mjs.map} +1 -1
- package/dist/renderer-Dhrj2bJz.mjs +5 -0
- package/dist/{renderer-celhuAL7.mjs → renderer-Dj54y3h3.mjs} +3 -3
- package/dist/{renderer-celhuAL7.mjs.map → renderer-Dj54y3h3.mjs.map} +1 -1
- package/dist/renderer-DoFUu1R4.mjs +5 -0
- package/dist/{renderer-RvI3qRUI.mjs → renderer-Dp9FQKVP.mjs} +4 -4
- package/dist/{renderer-RvI3qRUI.mjs.map → renderer-Dp9FQKVP.mjs.map} +1 -1
- package/dist/{renderer-KKk7myX1.mjs → renderer-DrK6pyfz.mjs} +4 -4
- package/dist/{renderer-KKk7myX1.mjs.map → renderer-DrK6pyfz.mjs.map} +1 -1
- package/dist/{renderer-BURhYcpA.mjs → renderer-DrL3J9ci.mjs} +3 -3
- package/dist/{renderer-BURhYcpA.mjs.map → renderer-DrL3J9ci.mjs.map} +1 -1
- package/dist/{renderer-BOrMBwQS.mjs → renderer-DsPLMzy1.mjs} +2 -2
- package/dist/{renderer-BOrMBwQS.mjs.map → renderer-DsPLMzy1.mjs.map} +1 -1
- package/dist/renderer-DsydX3cx.mjs +5 -0
- package/dist/{renderer-D06HxSXO.mjs → renderer-DwH5e3hx.mjs} +2 -2
- package/dist/renderer-DxVSoeYi.mjs +5 -0
- package/dist/{renderer-BQetXCcZ.mjs → renderer-Dy1xQOTu.mjs} +3 -3
- package/dist/{renderer-BQetXCcZ.mjs.map → renderer-Dy1xQOTu.mjs.map} +1 -1
- package/dist/{renderer-CxGx1Lhi.mjs → renderer-FvvywNvv.mjs} +3 -3
- package/dist/{renderer-CxGx1Lhi.mjs.map → renderer-FvvywNvv.mjs.map} +1 -1
- package/dist/{renderer-DE9Jik9K.mjs → renderer-HXw4cJZx.mjs} +3 -3
- package/dist/{renderer-DE9Jik9K.mjs.map → renderer-HXw4cJZx.mjs.map} +1 -1
- package/dist/{renderer-CU8v-LxD.mjs → renderer-HhJPFidU.mjs} +4 -4
- package/dist/{renderer-CU8v-LxD.mjs.map → renderer-HhJPFidU.mjs.map} +1 -1
- package/dist/{renderer-BwrfKKqw.mjs → renderer-IAffbHXx.mjs} +3 -3
- package/dist/{renderer-BwrfKKqw.mjs.map → renderer-IAffbHXx.mjs.map} +1 -1
- package/dist/{renderer-fs8f1QeE.mjs → renderer-LrAldCWN.mjs} +4 -4
- package/dist/{renderer-fs8f1QeE.mjs.map → renderer-LrAldCWN.mjs.map} +1 -1
- package/dist/renderer-Nc9bHb0n.mjs +5 -0
- package/dist/{renderer-h62QaJYz.mjs → renderer-O4y02xkD.mjs} +3 -3
- package/dist/{renderer-h62QaJYz.mjs.map → renderer-O4y02xkD.mjs.map} +1 -1
- package/dist/{renderer-eMCTAa9e.mjs → renderer-PnnkUWm-.mjs} +3 -3
- package/dist/{renderer-eMCTAa9e.mjs.map → renderer-PnnkUWm-.mjs.map} +1 -1
- package/dist/renderer-TFaSD2Db.mjs +5 -0
- package/dist/{renderer-jnAIhWn_.mjs → renderer-TiaHrU5z.mjs} +4 -4
- package/dist/{renderer-jnAIhWn_.mjs.map → renderer-TiaHrU5z.mjs.map} +1 -1
- package/dist/renderer-Z61ctppe.mjs +5 -0
- package/dist/{renderer-DkqZmfm8.mjs → renderer-_KIBvES8.mjs} +4 -4
- package/dist/{renderer-DkqZmfm8.mjs.map → renderer-_KIBvES8.mjs.map} +1 -1
- package/dist/renderer-awXf3sNS.mjs +5 -0
- package/dist/{renderer-7ow5Acsg.mjs → renderer-b0H3oDae.mjs} +3 -3
- package/dist/{renderer-7ow5Acsg.mjs.map → renderer-b0H3oDae.mjs.map} +1 -1
- package/dist/renderer-cHT28oYI.mjs +5 -0
- package/dist/renderer-g7Y3bFot.mjs +5 -0
- package/dist/{renderer-q7q6k_cD.mjs → renderer-oBgCEqaM.mjs} +3 -3
- package/dist/{renderer-q7q6k_cD.mjs.map → renderer-oBgCEqaM.mjs.map} +1 -1
- package/dist/{renderer-Bo7shNdU.mjs → renderer-qVJdxbXB.mjs} +4 -4
- package/dist/{renderer-Bo7shNdU.mjs.map → renderer-qVJdxbXB.mjs.map} +1 -1
- package/dist/renderer-qVv0OzVc.mjs +5 -0
- package/dist/{renderer-D0aAZHC7.mjs → renderer-rKw5_EjG.mjs} +3 -3
- package/dist/{renderer-D0aAZHC7.mjs.map → renderer-rKw5_EjG.mjs.map} +1 -1
- package/dist/{renderer-B1LD29TV.mjs → renderer-sMFJtt_H.mjs} +3 -3
- package/dist/{renderer-B1LD29TV.mjs.map → renderer-sMFJtt_H.mjs.map} +1 -1
- package/dist/{renderer-C9BSXyrq.mjs → renderer-smP1F57W.mjs} +3 -3
- package/dist/{renderer-C9BSXyrq.mjs.map → renderer-smP1F57W.mjs.map} +1 -1
- package/dist/{renderer-DwK9jsER.mjs → renderer-snjhPaP-.mjs} +4 -4
- package/dist/{renderer-DwK9jsER.mjs.map → renderer-snjhPaP-.mjs.map} +1 -1
- package/dist/{renderer-lHNTgiOM.mjs → renderer-t1sXDiqm.mjs} +3 -3
- package/dist/{renderer-lHNTgiOM.mjs.map → renderer-t1sXDiqm.mjs.map} +1 -1
- package/dist/{renderer-CAWnCsQc.mjs → renderer-tRi3KNoG.mjs} +4 -4
- package/dist/{renderer-CAWnCsQc.mjs.map → renderer-tRi3KNoG.mjs.map} +1 -1
- package/dist/{renderer-BNHcwxw9.mjs → renderer-uA0UCxjA.mjs} +3 -3
- package/dist/{renderer-BNHcwxw9.mjs.map → renderer-uA0UCxjA.mjs.map} +1 -1
- package/dist/{renderer-pNmI-A9o.mjs → renderer-xNOKSN3V.mjs} +4 -4
- package/dist/{renderer-pNmI-A9o.mjs.map → renderer-xNOKSN3V.mjs.map} +1 -1
- package/dist/{renderers-CP8CFWDs-DRoslK4F.mjs → renderers-CP8CFWDs-DWRjjeUg.mjs} +3 -3
- package/dist/{renderers-CP8CFWDs-DRoslK4F.mjs.map → renderers-CP8CFWDs-DWRjjeUg.mjs.map} +1 -1
- package/dist/sam/index.d.mts +2 -2
- package/dist/sam/index.mjs +1 -1
- package/dist/signals/index.d.mts +5 -5
- package/dist/signals/index.mjs +5 -5
- package/dist/{src-Bnr8DUC--BRDqRF6I.mjs → src-BU6vm9sP-DFJ3phW0.mjs} +74 -9
- package/dist/src-BU6vm9sP-DFJ3phW0.mjs.map +1 -0
- package/dist/{src-BYp6r-cS.mjs → src-D7M8VTzv.mjs} +248 -28
- package/dist/src-D7M8VTzv.mjs.map +1 -0
- package/package.json +59 -59
- package/dist/cloud-xcfV4J03.mjs.map +0 -1
- package/dist/dist-CWLLnigL.mjs.map +0 -1
- package/dist/gpu-CpkJJLQP.mjs.map +0 -1
- package/dist/index-BuiZzc6i.d.mts.map +0 -1
- package/dist/index-CEU_Zsb9.d.mts.map +0 -1
- package/dist/index-Cro-818i.d.mts.map +0 -1
- package/dist/preview-engine/chunk-4FY4TNST.mjs +0 -1
- package/dist/preview-engine/chunk-7LDSMOO3.mjs +0 -1
- package/dist/preview-engine/chunk-AGAZJZWI.mjs +0 -1
- package/dist/preview-engine/chunk-BXPM5SJ3.mjs +0 -1
- package/dist/preview-engine/chunk-CIVJXFWH.mjs +0 -4
- package/dist/preview-engine/chunk-D73ZKPFN.mjs +0 -138
- package/dist/preview-engine/chunk-KOVN277Z.mjs +0 -1
- package/dist/preview-engine/chunk-M4QANUJI.mjs +0 -480
- package/dist/preview-engine/chunk-XF6DYP6B.mjs +0 -1974
- package/dist/preview-engine/chunk-XYGDTPO7.mjs +0 -39
- package/dist/preview-engine/chunk-YGKO4NIU.mjs +0 -1
- package/dist/preview-engine/renderers-2NGIILMI.mjs +0 -1
- package/dist/preview-engine/renderers-466Z77BH.mjs +0 -1
- package/dist/preview-engine/renderers-4KRENGZA.mjs +0 -1
- package/dist/preview-engine/renderers-4W52BQEU.mjs +0 -1
- package/dist/preview-engine/renderers-55PRAS7G.mjs +0 -1
- package/dist/preview-engine/renderers-5LLYINHW.mjs +0 -1
- package/dist/preview-engine/renderers-63N3Y2XO.mjs +0 -1
- package/dist/preview-engine/renderers-6ROVFDIN.mjs +0 -1
- package/dist/preview-engine/renderers-A4RVLPMG.mjs +0 -1
- package/dist/preview-engine/renderers-A53P4J6O.mjs +0 -1
- package/dist/preview-engine/renderers-AFJ3373L.mjs +0 -1
- package/dist/preview-engine/renderers-ATFWTA3U.mjs +0 -1
- package/dist/preview-engine/renderers-BPYJXHBU.mjs +0 -1
- package/dist/preview-engine/renderers-D3ZF7FXT.mjs +0 -1
- package/dist/preview-engine/renderers-D7YN6B4B.mjs +0 -1
- package/dist/preview-engine/renderers-DBLASKF5.mjs +0 -1
- package/dist/preview-engine/renderers-DC5ZYYHM.mjs +0 -1
- package/dist/preview-engine/renderers-J6ZEXW5L.mjs +0 -1
- package/dist/preview-engine/renderers-JV4MF46Q.mjs +0 -1
- package/dist/preview-engine/renderers-KQKH4ZIX.mjs +0 -1
- package/dist/preview-engine/renderers-MDHPQY6D.mjs +0 -1
- package/dist/preview-engine/renderers-MEITHN4N.mjs +0 -1
- package/dist/preview-engine/renderers-MN3HSBTJ.mjs +0 -1
- package/dist/preview-engine/renderers-NTG3QGNH.mjs +0 -1
- package/dist/preview-engine/renderers-OU4SFMB2.mjs +0 -1
- package/dist/preview-engine/renderers-P6TIBJIG.mjs +0 -1
- package/dist/preview-engine/renderers-POJWQ7L3.mjs +0 -1
- package/dist/preview-engine/renderers-RJ7S6VHD.mjs +0 -1
- package/dist/preview-engine/renderers-RJJAJZYN.mjs +0 -1
- package/dist/preview-engine/renderers-UEQ733VK.mjs +0 -1
- package/dist/preview-engine/renderers-ULO2AW2U.mjs +0 -1
- package/dist/preview-engine/renderers-UPVHGHCK.mjs +0 -1
- package/dist/preview-engine/renderers-UZHSNNIM.mjs +0 -1
- package/dist/preview-engine/renderers-V5KWZL2C.mjs +0 -1
- package/dist/preview-engine/renderers-WL372W36.mjs +0 -228
- package/dist/preview-engine/renderers-YMXKYOHQ.mjs +0 -1
- package/dist/preview-engine/renderers-YWDAZ2NZ.mjs +0 -1
- package/dist/program-Bc860ko5.mjs.map +0 -1
- package/dist/renderer--Ymc_4XJ.mjs +0 -5
- package/dist/renderer-B-OdV-eq.mjs +0 -5
- package/dist/renderer-B65fwoA2.mjs +0 -5
- package/dist/renderer-B92Ahkcv.mjs +0 -5
- package/dist/renderer-B9z2AK31.mjs +0 -5
- package/dist/renderer-BIF3Dg3Z.mjs +0 -5
- package/dist/renderer-BJUVaIAT.mjs +0 -5
- package/dist/renderer-BKRDMbI-.mjs +0 -5
- package/dist/renderer-BSwhyVWa.mjs +0 -5
- package/dist/renderer-BUqSZn2X.mjs +0 -5
- package/dist/renderer-BVKOQarx.d.mts.map +0 -1
- package/dist/renderer-BbmvjqK9.mjs +0 -3
- package/dist/renderer-BhsrlGKp.mjs.map +0 -1
- package/dist/renderer-Bpe4k_x6.mjs +0 -5
- package/dist/renderer-Bx14Wnxl.mjs.map +0 -1
- package/dist/renderer-C1NjG0CJ.mjs +0 -5
- package/dist/renderer-C7Puyst9.mjs +0 -5
- package/dist/renderer-CGA_7320.mjs +0 -5
- package/dist/renderer-CLnFkXO7.mjs +0 -5
- package/dist/renderer-CMQIT1Kh.mjs +0 -5
- package/dist/renderer-CQ1rwjIh.mjs +0 -5
- package/dist/renderer-CT8h0boY.mjs +0 -5
- package/dist/renderer-Cb0lszt3.mjs +0 -5
- package/dist/renderer-Ci7oLye9.mjs +0 -5
- package/dist/renderer-CjqXB3CZ.mjs +0 -5
- package/dist/renderer-CqTV04zQ.mjs +0 -5
- package/dist/renderer-CtWeRtHK.mjs +0 -5
- package/dist/renderer-CzolnwCo.mjs +0 -5
- package/dist/renderer-D6qhcx_C.mjs +0 -5
- package/dist/renderer-DDfEf0jt.mjs +0 -5
- package/dist/renderer-DDpa8ztp.mjs +0 -5
- package/dist/renderer-DbQBqzmx.mjs +0 -5
- package/dist/renderer-DfUcwMKa.mjs +0 -5
- package/dist/renderer-DgIjNANM.mjs +0 -6
- package/dist/renderer-Dsh6Tgu0.mjs +0 -3
- package/dist/renderer-DuIwR9GT.mjs +0 -5
- package/dist/renderer-Dv4u2c14.mjs +0 -5
- package/dist/renderer-HDj9Zb-O.mjs.map +0 -1
- package/dist/renderer-IE1yu3lZ.mjs +0 -5
- package/dist/renderer-PY_wnEN0.mjs +0 -5
- package/dist/renderer-TKZCA0B9.mjs.map +0 -1
- package/dist/renderer-gv24VyzO.mjs +0 -5
- package/dist/renderer-nN6lPZf9.mjs +0 -5
- package/dist/src-BYp6r-cS.mjs.map +0 -1
- package/dist/src-Bnr8DUC--BRDqRF6I.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"src-BYp6r-cS.mjs","names":["path","resolve","last","line","stack","num","withAlpha","color","d3Format","round","d3Pie","d3Arc","x","d3Stack","range","lo","hi","d","d3Area","d3Line","run","range","result","area","size","object","fs","path","read","target","stack","target","anim","Effect","parseColor","read","spec","list","size","z","color","line","shape","ease","merge","z","target","spec","R","spec","shape","z","target","spec","scaleShape","result","num","shape","z","dist","read","target","num","spec","h","size","shape","z$1","size","color","num$2","host","relative","line","range","stack","result","area","size","resolvedSource","result","target","node","analyzeVisionFrames","last","color","CoreEffect"],"sources":["../../ai/dist/index.mjs","../src/ids.ts","../src/rich-text.ts","../src/chart.ts","../src/clip-vision.ts","../src/media-signals.ts","../src/physics/core.ts","../src/particles.ts","../src/swarm3d.ts","../src/shapes3d.ts","../src/transitions.ts","../src/lighting.ts","../src/physics/backend.ts","../src/physics/world2d.ts","../src/physics/world3d.ts","../src/physics/index.ts","../src/styles.ts","../../components/dist/meta-1w21OBWA.mjs","../src/components/host.ts","../src/components/audio.ts","../src/components/index.ts","../src/index.ts"],"sourcesContent":["//#region src/errors.ts\n/**\n* A non-2xx answer from the gateway or the model. `type` is the gateway's error code\n* (`insufficient_credits`, `rate_limited`, `key_limit_reached`, …) when the gateway refused\n* the call; it is unset when the model itself failed.\n*/\nvar ApiError = class extends Error {\n\tstatus;\n\tbody;\n\trequestId;\n\ttype;\n\tconstructor({ message, status: status$1, body, requestId, type }) {\n\t\tsuper(message);\n\t\tthis.name = \"ApiError\";\n\t\tthis.status = status$1;\n\t\tthis.body = body;\n\t\tthis.requestId = requestId ?? \"\";\n\t\tthis.type = type;\n\t}\n};\n/** A `422`: the input did not match the model's schema. `fieldErrors` says which fields. */\nvar ValidationError = class extends ApiError {\n\tconstructor(args) {\n\t\tsuper(args);\n\t\tthis.name = \"ValidationError\";\n\t}\n\tget fieldErrors() {\n\t\treturn Array.isArray(this.body?.detail) ? this.body.detail : [];\n\t}\n\tgetFieldErrors(field) {\n\t\treturn this.fieldErrors.filter((e) => e.loc[e.loc.length - 1] === field);\n\t}\n};\nfunction messageOf(body, fallback) {\n\tif (body?.error?.message) return body.error.message;\n\tif (typeof body?.detail === \"string\") return body.detail;\n\tif (Array.isArray(body?.detail)) {\n\t\tconst first = body.detail[0];\n\t\tif (first?.msg) return `${first.msg} (${(first.loc ?? []).join(\".\")})`;\n\t}\n\tif (typeof body?.message === \"string\") return body.message;\n\treturn fallback;\n}\n/** Builds the error for a failed response; the body is read here, once. */\nasync function errorFromResponse(response) {\n\tconst text = await response.text().catch(() => \"\");\n\tlet body = text || void 0;\n\ttry {\n\t\tbody = text ? JSON.parse(text) : void 0;\n\t} catch {}\n\tconst parsed = typeof body === \"object\" && body !== null ? body : void 0;\n\tconst args = {\n\t\tmessage: messageOf(parsed, `${response.status} ${response.statusText}`.trim()),\n\t\tstatus: response.status,\n\t\tbody,\n\t\trequestId: response.headers.get(\"x-framefields-request-id\") ?? void 0,\n\t\ttype: parsed?.error?.type\n\t};\n\treturn response.status === 422 && Array.isArray(parsed?.detail) ? new ValidationError(args) : new ApiError(args);\n}\n\n//#endregion\n//#region src/transport.ts\n/** The framefields AI gateway. Every request goes here, authenticated with a framefields key. */\nconst FRAMEFIELDS_AI_PROXY_URL = \"https://api.framefields.dev/v1/ai/proxy\";\nlet configuredKey;\nconst env = (name) => typeof process !== \"undefined\" ? process.env?.[name] : void 0;\nfunction setApiKey(key) {\n\tconfiguredKey = key;\n}\nfunction apiKey() {\n\tconst key = configuredKey ?? env(\"FRAMEFIELDS_API_KEY\");\n\tif (!key) throw new Error(\"framefields ai: no API key. Set FRAMEFIELDS_API_KEY or call ai.config({ apiKey }). Create a key at https://framefields.dev/dashboard/keys\");\n\treturn key;\n}\nfunction targetOf({ service, path, query }) {\n\tconst params = new URLSearchParams();\n\tfor (const [name, value] of Object.entries(query ?? {})) if (value !== void 0) params.set(name, value);\n\tconst search = params.size ? `?${params}` : \"\";\n\treturn `${service}/${path.replace(/^\\/+/, \"\")}${search}`;\n}\n/**\n* Sends one call through the gateway and returns the response, or throws `ApiError` /\n* `ValidationError` for a non-2xx answer. The key is checked before anything is sent.\n*/\nasync function gatewayFetch(request) {\n\tconst headers = {\n\t\tAuthorization: `Key ${apiKey()}`,\n\t\tAccept: request.accept ?? \"application/json\",\n\t\t\"x-framefields-target\": targetOf(request)\n\t};\n\tconst hasBody = request.body !== void 0;\n\tif (hasBody) headers[\"Content-Type\"] = \"application/json\";\n\tconst response = await fetch(env(\"FRAMEFIELDS_AI_PROXY_URL\") ?? FRAMEFIELDS_AI_PROXY_URL, {\n\t\tmethod: request.method ?? (hasBody ? \"POST\" : \"GET\"),\n\t\theaders,\n\t\tbody: hasBody ? JSON.stringify(request.body) : void 0,\n\t\tsignal: request.signal\n\t});\n\tif (!response.ok) throw await errorFromResponse(response);\n\treturn response;\n}\n/** `gatewayFetch` for JSON answers, with the gateway's request id alongside. */\nasync function gatewayJson(request) {\n\tconst response = await gatewayFetch(request);\n\treturn {\n\t\tdata: await response.json(),\n\t\trequestId: response.headers.get(\"x-framefields-request-id\") ?? \"\"\n\t};\n}\n\n//#endregion\n//#region src/storage.ts\n/** Files above this size upload in parts. */\nconst MULTIPART_THRESHOLD = 90 * 1024 * 1024;\nconst PART_SIZE = 10 * 1024 * 1024;\nconst PART_TRIES = 3;\nconst EXTENSIONS = {\n\t\"image/jpeg\": \"jpg\",\n\t\"image/png\": \"png\",\n\t\"image/webp\": \"webp\",\n\t\"video/mp4\": \"mp4\",\n\t\"audio/mpeg\": \"mp3\",\n\t\"audio/wav\": \"wav\"\n};\nfunction fileName(file, contentType) {\n\tif (\"name\" in file && typeof file.name === \"string\" && file.name) return file.name;\n\treturn `${Date.now()}.${EXTENSIONS[contentType] ?? \"bin\"}`;\n}\nfunction initiate(file, multipart) {\n\tconst contentType = file.type || \"application/octet-stream\";\n\treturn gatewayJson({\n\t\tservice: \"storage\",\n\t\tpath: multipart ? \"upload/initiate-multipart\" : \"upload/initiate\",\n\t\tbody: {\n\t\t\tcontent_type: contentType,\n\t\t\tfile_name: fileName(file, contentType)\n\t\t}\n\t}).then((r) => r.data);\n}\nasync function put(url, init) {\n\tconst response = await fetch(url, init);\n\tif (!response.ok) throw await errorFromResponse(response);\n\treturn response;\n}\nasync function uploadPart(url, chunk) {\n\tfor (let attempt = 1;; attempt++) try {\n\t\treturn await (await put(url, {\n\t\t\tmethod: \"PUT\",\n\t\t\tbody: chunk\n\t\t})).json();\n\t} catch (err) {\n\t\tif (attempt >= PART_TRIES) throw err;\n\t}\n}\nasync function uploadMultipart(file) {\n\tconst ticket = await initiate(file, true);\n\tconst base = new URL(ticket.upload_url);\n\tconst partUrl = (suffix) => `${base.origin}${base.pathname}/${suffix}${base.search}`;\n\tconst parts = [];\n\tfor (let start = 0; start < file.size; start += PART_SIZE) {\n\t\tconst chunk = file.slice(start, Math.min(start + PART_SIZE, file.size));\n\t\tparts.push(await uploadPart(partUrl(parts.length + 1), chunk));\n\t}\n\tawait put(partUrl(\"complete\"), {\n\t\tmethod: \"POST\",\n\t\theaders: { \"Content-Type\": \"application/json\" },\n\t\tbody: JSON.stringify({ parts: parts.map(({ partNumber, etag }) => ({\n\t\t\tpartNumber,\n\t\t\tetag\n\t\t})) })\n\t});\n\treturn ticket.file_url;\n}\nasync function upload(file) {\n\tif (file.size > MULTIPART_THRESHOLD) return uploadMultipart(file);\n\tconst ticket = await initiate(file, false);\n\tawait put(ticket.upload_url, {\n\t\tmethod: \"PUT\",\n\t\tbody: file,\n\t\theaders: { \"Content-Type\": file.type || \"application/octet-stream\" }\n\t});\n\treturn ticket.file_url;\n}\nconst isPlainObject = (value) => typeof value === \"object\" && value !== null && Object.getPrototypeOf(value) === Object.prototype;\nasync function transformInput(input) {\n\tif (input instanceof Blob) return await upload(input);\n\tif (Array.isArray(input)) return await Promise.all(input.map((item) => transformInput(item)));\n\tif (isPlainObject(input)) {\n\t\tconst entries = await Promise.all(Object.entries(input).map(async ([key, value]) => [key, await transformInput(value)]));\n\t\treturn Object.fromEntries(entries);\n\t}\n\treturn input;\n}\nconst storage = {\n\tupload,\n\ttransformInput\n};\n\n//#endregion\n//#region src/queue.ts\n/** Statuses worth asking again for: rate limits and a gateway or model service hiccup. */\nconst TRANSIENT = new Set([\n\t429,\n\t502,\n\t503,\n\t504\n]);\nconst READ_TRIES = 4;\nconst sleep = (ms, signal) => new Promise((resolve, reject) => {\n\tsignal?.throwIfAborted();\n\tconst timer = setTimeout(resolve, ms);\n\tsignal?.addEventListener(\"abort\", () => {\n\t\tclearTimeout(timer);\n\t\treject(signal.reason);\n\t}, { once: true });\n});\n/** Reads (status, result) are free and idempotent, so transient failures are retried. */\nasync function read(run$1, signal) {\n\tfor (let attempt = 1;; attempt++) try {\n\t\treturn await run$1();\n\t} catch (err) {\n\t\tif (!(err instanceof ApiError && TRANSIENT.has(err.status)) || attempt >= READ_TRIES) throw err;\n\t\tawait sleep(500 * 2 ** attempt, signal);\n\t}\n}\nconst requestPath = (model, requestId, suffix = \"\") => `${model}/requests/${encodeURIComponent(requestId)}${suffix}`;\nasync function submit(model, { input, abortSignal }) {\n\tconst { data } = await gatewayJson({\n\t\tservice: \"queue\",\n\t\tpath: model,\n\t\tbody: await storage.transformInput(input) ?? {},\n\t\tsignal: abortSignal\n\t});\n\treturn data;\n}\nfunction status(model, { requestId, logs, abortSignal }) {\n\treturn read(async () => {\n\t\tconst { data } = await gatewayJson({\n\t\t\tservice: \"queue\",\n\t\t\tpath: requestPath(model, requestId, \"/status\"),\n\t\t\tquery: { logs: logs ? \"1\" : void 0 },\n\t\t\tsignal: abortSignal\n\t\t});\n\t\treturn data;\n\t}, abortSignal);\n}\nfunction result(model, { requestId, abortSignal }) {\n\treturn read(async () => {\n\t\tconst { data } = await gatewayJson({\n\t\t\tservice: \"queue\",\n\t\t\tpath: requestPath(model, requestId),\n\t\t\tsignal: abortSignal\n\t\t});\n\t\treturn {\n\t\t\tdata,\n\t\t\trequestId\n\t\t};\n\t}, abortSignal);\n}\nasync function cancel(model, { requestId, abortSignal }) {\n\tawait gatewayJson({\n\t\tservice: \"queue\",\n\t\tpath: requestPath(model, requestId, \"/cancel\"),\n\t\tmethod: \"PUT\",\n\t\tsignal: abortSignal\n\t});\n}\nasync function subscribeToStatus(model, options) {\n\tconst interval = options.pollInterval ?? 500;\n\tfor (;;) {\n\t\tconst current = await status(model, options);\n\t\toptions.onQueueUpdate?.(current);\n\t\tif (current.status === \"COMPLETED\") return current;\n\t\tawait sleep(interval, options.abortSignal);\n\t}\n}\nconst queue = {\n\tsubmit,\n\tstatus,\n\tresult,\n\tcancel,\n\tsubscribeToStatus\n};\n/** Queues the job, waits for it, and returns its output. */\nasync function subscribe(model, options) {\n\tconst { request_id: requestId } = await submit(model, options);\n\toptions.onEnqueue?.(requestId);\n\tawait subscribeToStatus(model, {\n\t\t...options,\n\t\trequestId\n\t});\n\treturn result(model, {\n\t\trequestId,\n\t\tabortSignal: options.abortSignal\n\t});\n}\n\n//#endregion\n//#region src/stream.ts\n/** Yields each `data:` payload of a server-sent event stream, joined across lines. */\nasync function* serverSentEvents(body) {\n\tconst decoder = new TextDecoder();\n\tlet buffer = \"\";\n\tfor await (const chunk of body) {\n\t\tbuffer += decoder.decode(chunk, { stream: true }).replace(/\\r\\n?/g, \"\\n\");\n\t\tlet end = buffer.indexOf(\"\\n\\n\");\n\t\twhile (end !== -1) {\n\t\t\tconst block = buffer.slice(0, end);\n\t\t\tbuffer = buffer.slice(end + 2);\n\t\t\tconst parsed = parseBlock(block);\n\t\t\tif (parsed) yield parsed;\n\t\t\tend = buffer.indexOf(\"\\n\\n\");\n\t\t}\n\t}\n\tconst last = parseBlock(buffer);\n\tif (last) yield last;\n}\nfunction parseBlock(block) {\n\tlet event = \"message\";\n\tconst data = [];\n\tfor (const line of block.split(\"\\n\")) if (line.startsWith(\"data:\")) data.push(line.slice(5).replace(/^ /, \"\"));\n\telse if (line.startsWith(\"event:\")) event = line.slice(6).trim();\n\treturn data.length ? {\n\t\tevent,\n\t\tdata: data.join(\"\\n\")\n\t} : null;\n}\nasync function* outputs(body, requestId) {\n\tfor await (const { event, data } of serverSentEvents(body)) {\n\t\tconst payload = JSON.parse(data);\n\t\tif (event === \"error\") throw new ApiError({\n\t\t\tmessage: \"The model stream ended with an error\",\n\t\t\tstatus: 500,\n\t\t\tbody: payload,\n\t\t\trequestId\n\t\t});\n\t\tyield payload;\n\t}\n}\n/** Runs a streaming model; resolves once the stream is open. */\nasync function stream(model, { input, abortSignal }) {\n\tconst controller = new AbortController();\n\tconst signal = abortSignal ? AbortSignal.any([abortSignal, controller.signal]) : controller.signal;\n\tconst response = await gatewayFetch({\n\t\tservice: \"run\",\n\t\tpath: `${model}/stream`,\n\t\tbody: await storage.transformInput(input) ?? {},\n\t\taccept: \"text/event-stream\",\n\t\tsignal\n\t});\n\tconst requestId = response.headers.get(\"x-framefields-request-id\") ?? \"\";\n\tif (!response.body) throw new ApiError({\n\t\tmessage: \"Empty stream\",\n\t\tstatus: 502,\n\t\trequestId\n\t});\n\tconst source = outputs(response.body, requestId);\n\tlet last;\n\tlet finished;\n\tasync function* tracked() {\n\t\tfor await (const value of source) {\n\t\t\tlast = value;\n\t\t\tyield value;\n\t\t}\n\t}\n\tconst iterator = tracked();\n\tconst drain = async () => {\n\t\tlet step = await iterator.next();\n\t\twhile (!step.done) step = await iterator.next();\n\t\tif (last === void 0) throw new ApiError({\n\t\t\tmessage: \"Stream had no output\",\n\t\t\tstatus: 502,\n\t\t\trequestId\n\t\t});\n\t\treturn last;\n\t};\n\treturn {\n\t\trequestId,\n\t\t[Symbol.asyncIterator]: () => iterator,\n\t\tdone: () => {\n\t\t\tfinished ??= drain();\n\t\t\treturn finished;\n\t\t},\n\t\tabort: () => controller.abort()\n\t};\n}\n\n//#endregion\n//#region src/index.ts\nasync function run(model, { input, abortSignal }) {\n\treturn gatewayJson({\n\t\tservice: \"run\",\n\t\tpath: model,\n\t\tbody: await storage.transformInput(input) ?? {},\n\t\tsignal: abortSignal\n\t});\n}\nconst ai = {\n\tconfig(options) {\n\t\tsetApiKey(options.apiKey);\n\t},\n\trun,\n\tsubscribe,\n\tstream,\n\tqueue,\n\tstorage\n};\n\n//#endregion\nexport { ApiError, FRAMEFIELDS_AI_PROXY_URL, ValidationError, ai };\n//# sourceMappingURL=index.mjs.map","/**\n * Default ids for nodes created without one. A counter per prefix rather than\n * a random suffix: the same composition script builds the same ids on every\n * run and in every render worker, so specs, caches and diffs stay stable.\n */\nconst counters = new Map<string, number>();\n\nexport function autoId(prefix: string): string {\n\tconst n = (counters.get(prefix) ?? 0) + 1;\n\tcounters.set(prefix, n);\n\treturn `${prefix}-auto-${n}`;\n}\n","import type { Signal, TextSpan, TextSpanMark } from \"@framefields/core\";\n\nexport type { TextSpan, TextSpanMark };\n\nexport type TextSpanItem =\n\t| string\n\t| number\n\t| boolean\n\t| Signal<unknown>\n\t| TextSpan\n\t| (string | TextSpan)[]\n\t| null\n\t| undefined;\n\n/**\n * Tagged template literal for authoring rich, multi-style text runs.\n *\n * Interpolates strings, numbers, reactive signals, and typed span modifiers\n * directly into a structured TextSpan[] array with zero runtime parsing.\n *\n * @example\n * rich`Scale ${bold(\"10x\", { fill: \"#6366f1\" })} faster with ${mark(\"120 FPS\", { bg: \"#10b98133\" })}`\n */\nexport function rich(\n\tstrings: TemplateStringsArray,\n\t...values: TextSpanItem[]\n): TextSpan[] {\n\tconst spans: TextSpan[] = [];\n\n\tfor (let i = 0; i < strings.length; i++) {\n\t\tconst str = strings[i];\n\t\tif (str) {\n\t\t\tspans.push({ text: str });\n\t\t}\n\n\t\tif (i < values.length) {\n\t\t\tconst val = values[i];\n\t\t\tif (val === null || val === undefined) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (Array.isArray(val)) {\n\t\t\t\tfor (const item of val) {\n\t\t\t\t\tif (typeof item === \"string\") {\n\t\t\t\t\t\tif (item) spans.push({ text: item });\n\t\t\t\t\t} else if (item && typeof item === \"object\" && \"text\" in item) {\n\t\t\t\t\t\tspans.push(item as TextSpan);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else if (typeof val === \"object\" && \"text\" in val) {\n\t\t\t\tspans.push(val as TextSpan);\n\t\t\t} else if (\n\t\t\t\ttypeof val === \"object\" &&\n\t\t\t\t\"get\" in val &&\n\t\t\t\ttypeof (val as { get: unknown }).get === \"function\"\n\t\t\t) {\n\t\t\t\tspans.push({ text: val as Signal<string> });\n\t\t\t} else {\n\t\t\t\tspans.push({ text: String(val) });\n\t\t\t}\n\t\t}\n\t}\n\n\treturn spans;\n}\n\nexport function span(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn { text, ...options };\n}\n\nexport function bold(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn { text, fontWeight: options.fontWeight ?? 700, ...options };\n}\n\nexport function italic(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn { text, fontStyle: \"italic\", ...options };\n}\n\nexport function accent(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn { text, fill: options.fill ?? \"#6366f1\", ...options };\n}\n\nexport function color(\n\ttext: string | Signal<string>,\n\tfill: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\" | \"fill\"> = {},\n): TextSpan {\n\treturn { text, fill, ...options };\n}\n\nexport function size(\n\ttext: string | Signal<string>,\n\tfontSize: number | Signal<number>,\n\toptions: Omit<TextSpan, \"text\" | \"fontSize\"> = {},\n): TextSpan {\n\treturn { text, fontSize, ...options };\n}\n\nexport interface MarkOptions extends Omit<TextSpan, \"text\" | \"mark\" | \"fill\"> {\n\tbg?: string | Signal<string>;\n\tfill?: string | Signal<string>;\n\tradius?: number;\n\tpaddingX?: number;\n\tpaddingY?: number;\n}\n\nexport function mark(\n\ttext: string | Signal<string>,\n\toptions: MarkOptions = {},\n): TextSpan {\n\tconst { bg, fill, radius, paddingX, paddingY, ...rest } = options;\n\treturn {\n\t\ttext,\n\t\tfill,\n\t\tmark: {\n\t\t\tbackground: bg ?? \"#6366f133\",\n\t\t\tborderRadius: radius ?? 4,\n\t\t\tpaddingX: paddingX ?? 6,\n\t\t\tpaddingY: paddingY ?? 2,\n\t\t},\n\t\t...rest,\n\t};\n}\n\nexport function sup(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn {\n\t\ttext,\n\t\tbaselineShift: options.baselineShift ?? -8,\n\t\t...options,\n\t};\n}\n\nexport function sub(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn {\n\t\ttext,\n\t\tbaselineShift: options.baselineShift ?? 6,\n\t\t...options,\n\t};\n}\n\nexport function code(\n\ttext: string | Signal<string>,\n\toptions: Omit<TextSpan, \"text\"> = {},\n): TextSpan {\n\treturn {\n\t\ttext,\n\t\tfontFamily: options.fontFamily ?? \"JetBrains Mono\",\n\t\tmark: options.mark ?? {\n\t\t\tbackground: \"#ffffff18\",\n\t\t\tborderRadius: 4,\n\t\t\tpaddingX: 6,\n\t\t\tpaddingY: 2,\n\t\t},\n\t\t...options,\n\t};\n}\n\n/**\n * Normalizes string, TextSpan[], or array of mixed strings/spans into plain text and spans.\n */\nexport function normalizeTextSpans(\n\tinput: string | TextSpan[] | (string | TextSpan)[],\n): { text: string; spans?: TextSpan[] } {\n\tif (typeof input === \"string\") {\n\t\treturn { text: input };\n\t}\n\n\tif (!Array.isArray(input)) {\n\t\treturn { text: String(input) };\n\t}\n\n\tconst spans: TextSpan[] = [];\n\tlet plainText = \"\";\n\n\tfor (const item of input) {\n\t\tif (typeof item === \"string\") {\n\t\t\tif (item) {\n\t\t\t\tspans.push({ text: item });\n\t\t\t\tplainText += item;\n\t\t\t}\n\t\t} else if (item && typeof item === \"object\" && \"text\" in item) {\n\t\t\tconst s = item as TextSpan;\n\t\t\tspans.push(s);\n\t\t\tconst piece =\n\t\t\t\ttypeof s.text === \"string\"\n\t\t\t\t\t? s.text\n\t\t\t\t\t: s.text &&\n\t\t\t\t\t\t\ttypeof s.text === \"object\" &&\n\t\t\t\t\t\t\t\"get\" in s.text &&\n\t\t\t\t\t\t\ttypeof (s.text as { get: () => unknown }).get === \"function\"\n\t\t\t\t\t\t? String((s.text as { get: () => unknown }).get())\n\t\t\t\t\t\t: String(s.text ?? \"\");\n\t\t\tplainText += piece;\n\t\t}\n\t}\n\n\treturn {\n\t\ttext: plainText,\n\t\tspans: spans.length > 0 ? spans : undefined,\n\t};\n}\n\n/**\n * Upfront parser for external CMS or subtitle strings containing basic tags\n * (<b>, <i>, <span>, <color>, <mark>, <accent>, <code>, <sup>, <sub>).\n *\n * Compiles string markup into clean TextSpan[] before entering the composition pipeline.\n */\nexport function parseMarkup(markup: string): TextSpan[] {\n\tif (!markup || !markup.includes(\"<\")) {\n\t\treturn [{ text: markup }];\n\t}\n\n\tconst spans: TextSpan[] = [];\n\tconst tagRegex = /<(\\/?[a-zA-Z0-9_-]+)([^>]*)>/g;\n\tlet lastIndex = 0;\n\n\tinterface StyleState {\n\t\ttag: string;\n\t\tstyle: Partial<TextSpan>;\n\t}\n\tconst stack: StyleState[] = [];\n\n\tconst getCurrentStyle = (): Partial<TextSpan> => {\n\t\tconst merged: Partial<TextSpan> = {};\n\t\tfor (const state of stack) {\n\t\t\tObject.assign(merged, state.style);\n\t\t}\n\t\treturn merged;\n\t};\n\n\tfor (;;) {\n\t\tconst match = tagRegex.exec(markup);\n\t\tif (!match) {\n\t\t\tbreak;\n\t\t}\n\t\tconst textBefore = markup.slice(lastIndex, match.index);\n\t\tif (textBefore) {\n\t\t\tspans.push({ text: textBefore, ...getCurrentStyle() });\n\t\t}\n\t\tlastIndex = match.index + match[0].length;\n\n\t\tconst tagName = match[1].toLowerCase();\n\t\tconst rawAttrs = match[2];\n\n\t\tif (tagName.startsWith(\"/\")) {\n\t\t\tconst closingTag = tagName.slice(1);\n\t\t\tfor (let i = stack.length - 1; i >= 0; i--) {\n\t\t\t\tif (stack[i].tag === closingTag) {\n\t\t\t\t\tstack.splice(i, 1);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tconst attrs: Record<string, string> = {};\n\t\t\tconst attrRegex = /([a-zA-Z0-9_-]+)=[\"']([^\"']*)[\"']/g;\n\t\t\tfor (;;) {\n\t\t\t\tconst attrMatch = attrRegex.exec(rawAttrs);\n\t\t\t\tif (!attrMatch) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tattrs[attrMatch[1].toLowerCase()] = attrMatch[2];\n\t\t\t}\n\n\t\t\tconst style: Partial<TextSpan> = {};\n\n\t\t\tif (tagName === \"b\" || tagName === \"strong\") {\n\t\t\t\tstyle.fontWeight = 700;\n\t\t\t\tif (attrs.color || attrs.fill) style.fill = attrs.color ?? attrs.fill;\n\t\t\t} else if (tagName === \"i\" || tagName === \"em\") {\n\t\t\t\tstyle.fontStyle = \"italic\";\n\t\t\t\tif (attrs.color || attrs.fill) style.fill = attrs.color ?? attrs.fill;\n\t\t\t} else if (tagName === \"accent\") {\n\t\t\t\tstyle.fill = \"#6366f1\";\n\t\t\t} else if (tagName === \"color\") {\n\t\t\t\tstyle.fill = attrs.value ?? attrs.hex ?? attrs.fill;\n\t\t\t} else if (tagName === \"size\") {\n\t\t\t\tconst num = parseFloat(attrs.value ?? attrs.px ?? attrs.pt ?? \"0\");\n\t\t\t\tif (num > 0) style.fontSize = num;\n\t\t\t} else if (tagName === \"mark\") {\n\t\t\t\tstyle.mark = {\n\t\t\t\t\tbackground: attrs.bg ?? attrs.background ?? \"#6366f133\",\n\t\t\t\t\tborderRadius: attrs.radius ? parseFloat(attrs.radius) : 4,\n\t\t\t\t\tpaddingX: attrs.paddingx ? parseFloat(attrs.paddingx) : 6,\n\t\t\t\t\tpaddingY: attrs.paddingy ? parseFloat(attrs.paddingy) : 2,\n\t\t\t\t};\n\t\t\t\tif (attrs.color || attrs.fill) style.fill = attrs.color ?? attrs.fill;\n\t\t\t} else if (tagName === \"sup\") {\n\t\t\t\tstyle.baselineShift = -8;\n\t\t\t} else if (tagName === \"sub\") {\n\t\t\t\tstyle.baselineShift = 6;\n\t\t\t} else if (tagName === \"code\") {\n\t\t\t\tstyle.fontFamily = \"JetBrains Mono\";\n\t\t\t\tstyle.mark = {\n\t\t\t\t\tbackground: attrs.bg ?? \"#ffffff18\",\n\t\t\t\t\tborderRadius: 4,\n\t\t\t\t\tpaddingX: 6,\n\t\t\t\t\tpaddingY: 2,\n\t\t\t\t};\n\t\t\t} else if (tagName === \"span\") {\n\t\t\t\tif (attrs.color || attrs.fill) style.fill = attrs.color ?? attrs.fill;\n\t\t\t\tif (attrs.fontfamily) style.fontFamily = attrs.fontfamily;\n\t\t\t\tif (attrs.fontsize) style.fontSize = parseFloat(attrs.fontsize);\n\t\t\t\tif (attrs.fontweight) {\n\t\t\t\t\tconst nw = parseInt(attrs.fontweight, 10);\n\t\t\t\t\tstyle.fontWeight = Number.isNaN(nw) ? attrs.fontweight : nw;\n\t\t\t\t}\n\t\t\t\tif (attrs.fontstyle === \"italic\" || attrs.fontstyle === \"normal\") {\n\t\t\t\t\tstyle.fontStyle = attrs.fontstyle;\n\t\t\t\t}\n\t\t\t\tif (attrs.letterspacing)\n\t\t\t\t\tstyle.letterSpacing = parseFloat(attrs.letterspacing);\n\t\t\t\tif (attrs.baselineshift)\n\t\t\t\t\tstyle.baselineShift = parseFloat(attrs.baselineshift);\n\t\t\t\tif (attrs.opacity) style.opacity = parseFloat(attrs.opacity);\n\t\t\t}\n\n\t\t\tstack.push({ tag: tagName, style });\n\t\t}\n\t}\n\n\tconst remainingText = markup.slice(lastIndex);\n\tif (remainingText) {\n\t\tspans.push({ text: remainingText, ...getCurrentStyle() });\n\t}\n\n\treturn spans;\n}\n","/**\n * Charts built from ordinary layout nodes. d3 does the math (scales, ticks,\n * line/area/arc geometry, stacking); every bar, line, slice and label is a\n * regular box, shape or text node, so charts use the composition's fonts and\n * can be animated, graded and composited like any other layer.\n */\nimport {\n\ttype BoxNode,\n\tLayerAnimation,\n\ttype LayoutNode,\n} from \"@framefields/compositions/program\";\nimport { format as d3Format } from \"d3-format\";\nimport {\n\ttype ScaleBand,\n\ttype ScaleLinear,\n\ttype ScaleTime,\n\tscaleBand,\n\tscaleLinear,\n\tscaleUtc,\n} from \"d3-scale\";\nimport {\n\ttype CurveFactory,\n\tcurveLinear,\n\tcurveMonotoneX,\n\tcurveStepAfter,\n\tarc as d3Arc,\n\tarea as d3Area,\n\tline as d3Line,\n\tpie as d3Pie,\n\tstack as d3Stack,\n\tstackOffsetDiverging,\n} from \"d3-shape\";\nimport { autoId } from \"./ids.js\";\nimport { type AnimatableNode, Layer } from \"./index.js\";\n\nexport type ChartType =\n\t| \"line\"\n\t| \"area\"\n\t| \"bar\"\n\t| \"scatter\"\n\t| \"pie\"\n\t| \"donut\"\n\t| \"candlestick\";\n\nexport type ChartX = number | string | Date;\n\n/** A plain value (x is its index or `categories[i]`), an `[x, y]` pair, or `{ x, y }`. */\nexport type ChartDatum =\n\t| number\n\t| readonly [ChartX, number]\n\t| { x: ChartX; y: number };\n\nexport interface ChartCandle {\n\tx: ChartX;\n\topen: number;\n\thigh: number;\n\tlow: number;\n\tclose: number;\n}\n\n/** A pie or donut slice. */\nexport interface ChartSlice {\n\tlabel: string;\n\tvalue: number;\n\tcolor?: string;\n}\n\nexport interface ChartSeries {\n\tname?: string;\n\t/** Series type in a combined chart; defaults to the chart's `type`. */\n\ttype?: Exclude<ChartType, \"pie\" | \"donut\">;\n\tdata: readonly ChartDatum[] | readonly ChartCandle[];\n\tcolor?: string;\n\t/** Line width for line and area series. Default 3. */\n\tstrokeWidth?: number;\n\t/** Line and area interpolation. Default \"smooth\". */\n\tcurve?: \"linear\" | \"smooth\" | \"step\";\n\t/** Dot radius drawn on line points; scatter point radius. 0 hides line dots. */\n\tpointRadius?: number;\n}\n\nexport interface ChartAxisOptions {\n\t/** Show tick labels. Default true. */\n\tshow?: boolean;\n\t/** Draw grid lines across the plot. Default true for y, false for x. */\n\tgrid?: boolean;\n\tmin?: number;\n\tmax?: number;\n\t/** Approximate number of ticks. Default 5. */\n\tticks?: number;\n\t/** A d3-format specifier such as \",.0f\", \"$.2s\" or \".0%\", or a function. */\n\tformat?: string | ((value: ChartX) => string);\n}\n\nexport interface ChartAnimationOptions {\n\t/** Frame the reveal starts, relative to the chart's own start. Default 0. */\n\tstart?: number;\n\t/** Frames each element takes to animate in. Default 30. */\n\tduration?: number;\n\t/** Frames between consecutive bars, points or slices. Default spreads them over `duration`. */\n\tstagger?: number;\n\t/** Easing for bars, points and slices. Default \"power3.out\". */\n\tease?: string;\n}\n\nexport interface ChartPadding {\n\ttop?: number;\n\tright?: number;\n\tbottom?: number;\n\tleft?: number;\n}\n\nexport interface ChartOptions {\n\t/** Chart type, and the default for series without their own. Default \"line\". */\n\ttype?: ChartType;\n\twidth?: number;\n\theight?: number;\n\tseries?: readonly ChartSeries[];\n\t/** Shorthand for a single series, or the slices of a pie or donut. */\n\tdata?: readonly ChartDatum[] | readonly ChartCandle[] | readonly ChartSlice[];\n\t/** Labels for x positions when data are plain values; slice labels for pie charts. */\n\tcategories?: readonly string[];\n\t/** Stack bar and area series instead of grouping or overlapping them. */\n\tstacked?: boolean;\n\tcolors?: readonly string[];\n\txAxis?: ChartAxisOptions;\n\tyAxis?: ChartAxisOptions;\n\t/** Space around the plot for axis labels and legend. Computed when omitted. */\n\tpadding?: number | ChartPadding;\n\tfontFamily?: string;\n\t/** Axis, legend and value label size. Default 18. */\n\tfontSize?: number;\n\t/** Axis labels; when set, also the legend and value labels. */\n\ttextColor?: string;\n\tgridColor?: string;\n\tbackground?: string;\n\t/** Show the series or slice legend. Default: on for several series and for pies. */\n\tlegend?: boolean;\n\t/** Print values on bars and slices (pie values print as percentages). */\n\tvalueLabels?: boolean;\n\t/** Donut hole as a fraction of the radius. Default 0.6 for \"donut\". */\n\tinnerRadius?: number;\n\t/** Corner radius of bars and slices. Default 4. */\n\tcornerRadius?: number;\n\tupColor?: string;\n\tdownColor?: string;\n\t/** Reveal animation, or `false` for a static chart. */\n\tanimate?: false | ChartAnimationOptions;\n}\n\nexport const DEFAULT_CHART_COLORS = [\n\t\"#6366f1\",\n\t\"#22d3ee\",\n\t\"#f59e0b\",\n\t\"#ec4899\",\n\t\"#10b981\",\n\t\"#8b5cf6\",\n\t\"#f97316\",\n\t\"#3b82f6\",\n] as const;\n\ntype XScale =\n\t| ScaleBand<string>\n\t| ScaleLinear<number, number>\n\t| ScaleTime<number, number>;\n\ninterface Timing {\n\tenabled: boolean;\n\tstart: number;\n\tduration: number;\n\tstagger: number;\n\tease: string;\n}\n\ninterface Point {\n\tx: ChartX;\n\ty: number;\n}\n\ninterface Rect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n}\n\nconst isCandle = (d: unknown): d is ChartCandle =>\n\ttypeof d === \"object\" && d !== null && \"open\" in d && \"close\" in d;\n\nconst isSlice = (d: unknown): d is ChartSlice =>\n\ttypeof d === \"object\" && d !== null && \"label\" in d && \"value\" in d;\n\nfunction curveOf(curve: ChartSeries[\"curve\"]): CurveFactory {\n\tif (curve === \"linear\") return curveLinear;\n\tif (curve === \"step\") return curveStepAfter;\n\treturn curveMonotoneX;\n}\n\nfunction withAlpha(color: string, alpha: number): string {\n\tconst hex = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim());\n\tif (!hex) return color;\n\tlet h = hex[1];\n\tif (h.length === 3) h = [...h].map((c) => c + c).join(\"\");\n\tconst n = parseInt(h, 16);\n\treturn `rgba(${(n >> 16) & 255}, ${(n >> 8) & 255}, ${n & 255}, ${alpha})`;\n}\n\nfunction fmt(\n\taxis: ChartAxisOptions | undefined,\n): ((v: ChartX) => string) | null {\n\tif (!axis?.format) return null;\n\tif (typeof axis.format === \"function\") return axis.format;\n\tconst f = d3Format(axis.format);\n\treturn (v) => (typeof v === \"number\" ? f(v) : String(v));\n}\n\nfunction round(v: number): number {\n\treturn Math.round(v * 100) / 100;\n}\n\nfunction fadeIn(t: Timing, delay = 0, duration = t.duration): LayerAnimation {\n\treturn LayerAnimation.create().fromTo(\"opacity\", 0, 1, {\n\t\tstart: t.start + delay,\n\t\tend: t.start + delay + Math.max(1, duration),\n\t\tease: \"power2.out\",\n\t});\n}\n\n/** Builds the chart as a box of absolutely positioned child nodes. */\nexport function buildChart(\n\toptions: ChartOptions,\n\tprops: Partial<BoxNode>,\n\tdefaultFontFamily: string,\n): AnimatableNode<BoxNode> {\n\tconst id = props.id ?? autoId(\"chart\");\n\tconst width =\n\t\toptions.width ?? (typeof props.width === \"number\" ? props.width : 960);\n\tconst height =\n\t\toptions.height ?? (typeof props.height === \"number\" ? props.height : 540);\n\tconst type = options.type ?? \"line\";\n\tconst fontSize = options.fontSize ?? 18;\n\tconst fontFamily = options.fontFamily ?? defaultFontFamily;\n\tconst textColor = options.textColor ?? \"#94a3b8\";\n\t// Legend and value labels read a little stronger than axis labels; with a custom\n\t// textColor (e.g. dark text on a light background) they use it as is.\n\tconst strongText = options.textColor ?? \"#e2e8f0\";\n\tconst gridColor = options.gridColor ?? \"rgba(148, 163, 184, 0.18)\";\n\tconst colors = options.colors?.length ? options.colors : DEFAULT_CHART_COLORS;\n\tconst radius = options.cornerRadius ?? 4;\n\n\tconst anim = options.animate === false ? undefined : (options.animate ?? {});\n\tconst timing: Timing = {\n\t\tenabled: anim !== undefined,\n\t\tstart: anim?.start ?? 0,\n\t\tduration: anim?.duration ?? 30,\n\t\tstagger: anim?.stagger ?? -1,\n\t\tease: anim?.ease ?? \"power3.out\",\n\t};\n\n\tconst children: LayoutNode[] = [];\n\tconst label = (\n\t\ttext: string,\n\t\trect: Rect,\n\t\talign: \"start\" | \"center\" | \"end\",\n\t\textra: { delay?: number; color?: string; weight?: number } = {},\n\t\tkey = \"\",\n\t) => {\n\t\tconst node = Layer.text(text, {\n\t\t\tid: `${id}-label-${key || children.length}`,\n\t\t\tposition: \"absolute\",\n\t\t\tx: round(rect.x),\n\t\t\ty: round(rect.y),\n\t\t\twidth: round(rect.width),\n\t\t\theight: round(rect.height),\n\t\t\tfontFamily,\n\t\t\tfontSize,\n\t\t\tfontWeight: extra.weight ?? 500,\n\t\t\tfill: extra.color ?? textColor,\n\t\t\talign,\n\t\t\tverticalAlign: \"middle\",\n\t\t});\n\t\tif (timing.enabled) node.animate(fadeIn(timing, extra.delay ?? 0));\n\t\tchildren.push(node);\n\t};\n\n\tconst lineHeight = Math.ceil(fontSize * 1.4);\n\n\tif (type === \"pie\" || type === \"donut\") {\n\t\tbuildPie();\n\t} else {\n\t\tbuildCartesian();\n\t}\n\n\t// Staggers and fractional durations land between frames; the program schema\n\t// wants whole-frame keyframes.\n\tfor (const child of children) snapKeyframes(child);\n\n\treturn Layer.box({\n\t\tbackground: options.background ?? \"transparent\",\n\t\t...props,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tchildren,\n\t});\n\n\t// ── pie & donut ─────────────────────────────────────────────────────\n\n\tfunction buildPie(): void {\n\t\tconst slices = collectSlices();\n\t\tconst total = slices.reduce((s, d) => s + Math.max(0, d.value), 0);\n\t\tconst showLegend = options.legend ?? true;\n\t\tconst pad = resolvePadding({\n\t\t\ttop: 16,\n\t\t\tright: showLegend ? legendColumnWidth(slices.map((s) => s.label)) : 16,\n\t\t\tbottom: 16,\n\t\t\tleft: 16,\n\t\t});\n\t\tconst plot = plotRect(pad);\n\t\tconst r = Math.max(1, Math.min(plot.width, plot.height) / 2);\n\t\tconst inner = r * (options.innerRadius ?? (type === \"donut\" ? 0.6 : 0));\n\t\tconst cx = plot.x + plot.width / 2;\n\t\tconst cy = plot.y + plot.height / 2;\n\t\tconst m = 4;\n\t\tconst arcs = d3Pie<ChartSlice>()\n\t\t\t.sort(null)\n\t\t\t.value((d) => Math.max(0, d.value))\n\t\t\t.padAngle(slices.length > 1 ? 0.012 : 0)(slices);\n\t\tconst arcGen = d3Arc<(typeof arcs)[number]>()\n\t\t\t.innerRadius(inner)\n\t\t\t.outerRadius(r)\n\t\t\t.cornerRadius(Math.min(radius, (r - inner) / 2));\n\t\tconst step = staggerStep(arcs.length);\n\n\t\tarcs.forEach((a, i) => {\n\t\t\tconst d = arcGen(a);\n\t\t\tif (!d) return;\n\t\t\tconst color = slices[i].color ?? colors[i % colors.length];\n\t\t\tconst node = Layer.shape(\"path\", {\n\t\t\t\tid: `${id}-slice-${i}`,\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tx: round(cx - r - m),\n\t\t\t\ty: round(cy - r - m),\n\t\t\t\twidth: round(2 * (r + m)),\n\t\t\t\theight: round(2 * (r + m)),\n\t\t\t\td: translatePath(d, r + m, r + m),\n\t\t\t\tfillColor: color,\n\t\t\t\tanchorX: 0.5,\n\t\t\t\tanchorY: 0.5,\n\t\t\t});\n\t\t\tif (timing.enabled) {\n\t\t\t\tconst s = timing.start + i * step;\n\t\t\t\tnode.animate(\n\t\t\t\t\tLayerAnimation.create()\n\t\t\t\t\t\t.fromTo(\"opacity\", 0, 1, {\n\t\t\t\t\t\t\tstart: s,\n\t\t\t\t\t\t\tend: s + timing.duration * 0.5,\n\t\t\t\t\t\t})\n\t\t\t\t\t\t.fromTo(\"scale\", 0.85, 1, {\n\t\t\t\t\t\t\tstart: s,\n\t\t\t\t\t\t\tend: s + timing.duration,\n\t\t\t\t\t\t\tease: timing.ease,\n\t\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\t\t\tchildren.push(node);\n\n\t\t\tif (options.valueLabels && total > 0 && a.value > 0) {\n\t\t\t\tconst [lx, ly] = d3Arc<(typeof arcs)[number]>()\n\t\t\t\t\t.innerRadius(inner || r * 0.55)\n\t\t\t\t\t.outerRadius(r)\n\t\t\t\t\t.centroid(a);\n\t\t\t\tconst pct = `${Math.round((a.value / total) * 100)}%`;\n\t\t\t\tlabel(\n\t\t\t\t\tpct,\n\t\t\t\t\t{\n\t\t\t\t\t\tx: cx + lx - 60,\n\t\t\t\t\t\ty: cy + ly - lineHeight / 2,\n\t\t\t\t\t\twidth: 120,\n\t\t\t\t\t\theight: lineHeight,\n\t\t\t\t\t},\n\t\t\t\t\t\"center\",\n\t\t\t\t\t{\n\t\t\t\t\t\tdelay: i * step + timing.duration * 0.5,\n\t\t\t\t\t\tcolor: \"#ffffff\",\n\t\t\t\t\t\tweight: 700,\n\t\t\t\t\t},\n\t\t\t\t\t`value-${i}`,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (showLegend) {\n\t\t\tlegendColumn(\n\t\t\t\tslices.map((s, i) => ({\n\t\t\t\t\tname: s.label,\n\t\t\t\t\tcolor: s.color ?? colors[i % colors.length],\n\t\t\t\t})),\n\t\t\t\t{ x: plot.x + plot.width + 24, y: plot.y, height: plot.height },\n\t\t\t);\n\t\t}\n\t}\n\n\tfunction collectSlices(): ChartSlice[] {\n\t\tconst raw = (options.data ??\n\t\t\toptions.series?.[0]?.data ??\n\t\t\t[]) as readonly unknown[];\n\t\treturn raw.map((d, i) => {\n\t\t\tif (isSlice(d)) return d;\n\t\t\tconst value =\n\t\t\t\ttypeof d === \"number\"\n\t\t\t\t\t? d\n\t\t\t\t\t: Array.isArray(d)\n\t\t\t\t\t\t? Number(d[1])\n\t\t\t\t\t\t: Number((d as Point).y);\n\t\t\tconst name =\n\t\t\t\toptions.categories?.[i] ??\n\t\t\t\t(Array.isArray(d)\n\t\t\t\t\t? String(d[0])\n\t\t\t\t\t: typeof d === \"object\" && d\n\t\t\t\t\t\t? String((d as Point).x)\n\t\t\t\t\t\t: `${i + 1}`);\n\t\t\treturn { label: name, value };\n\t\t});\n\t}\n\n\t// ── cartesian: line, area, bar, scatter, candlestick ───────────────\n\n\tfunction buildCartesian(): void {\n\t\tconst series: ChartSeries[] = options.series?.length\n\t\t\t? [...options.series]\n\t\t\t: options.data\n\t\t\t\t? [{ data: options.data as ChartSeries[\"data\"] }]\n\t\t\t\t: [];\n\t\tif (series.length === 0) return;\n\n\t\tconst typeOf = (s: ChartSeries) =>\n\t\t\ts.type ?? (type as ChartSeries[\"type\"]) ?? \"line\";\n\t\tconst colorOf = (s: ChartSeries, i: number) =>\n\t\t\ts.color ?? colors[i % colors.length];\n\n\t\t// Normalise every series to points (candles keep their OHLC values).\n\t\tconst points: Point[][] = series.map((s) =>\n\t\t\t(s.data as readonly unknown[]).map((d, i) => {\n\t\t\t\tif (isCandle(d)) return { x: d.x, y: d.close };\n\t\t\t\tif (typeof d === \"number\")\n\t\t\t\t\treturn { x: options.categories?.[i] ?? i, y: d };\n\t\t\t\tif (Array.isArray(d)) return { x: d[0] as ChartX, y: Number(d[1]) };\n\t\t\t\treturn { x: (d as Point).x, y: Number((d as Point).y) };\n\t\t\t}),\n\t\t);\n\n\t\tconst anyBand = series.some(\n\t\t\t(s) => typeOf(s) === \"bar\" || typeOf(s) === \"candlestick\",\n\t\t);\n\t\tconst allX = points.flat().map((p) => p.x);\n\t\tconst xKind: \"band\" | \"time\" | \"linear\" =\n\t\t\tanyBand || allX.some((x) => typeof x === \"string\")\n\t\t\t\t? \"band\"\n\t\t\t\t: allX.some((x) => x instanceof Date)\n\t\t\t\t\t? \"time\"\n\t\t\t\t\t: \"linear\";\n\n\t\t// Stacking for bars and areas.\n\t\tconst stackable = (s: ChartSeries) =>\n\t\t\ttypeOf(s) === \"bar\" || typeOf(s) === \"area\";\n\t\tconst stacked = !!options.stacked;\n\t\tconst categories = xKind === \"band\" ? [...new Set(allX.map(String))] : [];\n\t\tconst stackRanges = new Map<number, [number, number][]>();\n\t\tif (stacked) {\n\t\t\tconst keys = series.map((_, i) => i).filter((i) => stackable(series[i]));\n\t\t\tconst rows = categories.length\n\t\t\t\t? categories\n\t\t\t\t: [...new Set(allX.map((x) => +x))].sort((a, b) => a - b).map(String);\n\t\t\tconst table = rows.map((key) => {\n\t\t\t\tconst row: Record<string, number> = {};\n\t\t\t\tfor (const i of keys) {\n\t\t\t\t\tconst p = points[i].find(\n\t\t\t\t\t\t(pt) => String(xKind === \"band\" ? pt.x : +pt.x) === key,\n\t\t\t\t\t);\n\t\t\t\t\trow[i] = p?.y ?? 0;\n\t\t\t\t}\n\t\t\t\treturn row;\n\t\t\t});\n\t\t\tconst layers = d3Stack<Record<string, number>>()\n\t\t\t\t.keys(keys.map(String))\n\t\t\t\t.offset(stackOffsetDiverging)(table);\n\t\t\tlayers.forEach((layer) => {\n\t\t\t\tconst i = Number(layer.key);\n\t\t\t\tstackRanges.set(\n\t\t\t\t\ti,\n\t\t\t\t\tpoints[i].map((p) => {\n\t\t\t\t\t\tconst idx = rows.indexOf(String(xKind === \"band\" ? p.x : +p.x));\n\t\t\t\t\t\treturn [layer[idx][0], layer[idx][1]];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t// y domain\n\t\tconst yValues: number[] = [0];\n\t\tseries.forEach((s, i) => {\n\t\t\tconst range = stackRanges.get(i);\n\t\t\tif (typeOf(s) === \"candlestick\") {\n\t\t\t\tfor (const c of s.data as readonly ChartCandle[])\n\t\t\t\t\tyValues.push(c.high, c.low);\n\t\t\t} else if (range) {\n\t\t\t\tfor (const [a, b] of range) yValues.push(a, b);\n\t\t\t} else {\n\t\t\t\tfor (const p of points[i]) yValues.push(p.y);\n\t\t\t}\n\t\t});\n\t\tif (\n\t\t\tseries.every(\n\t\t\t\t(s) =>\n\t\t\t\t\ttypeOf(s) === \"candlestick\" ||\n\t\t\t\t\ttypeOf(s) === \"scatter\" ||\n\t\t\t\t\ttypeOf(s) === \"line\",\n\t\t\t)\n\t\t) {\n\t\t\t// Line, scatter and price charts don't have to include zero.\n\t\t\tyValues.shift();\n\t\t}\n\n\t\tconst yAxis = options.yAxis ?? {};\n\t\tconst xAxis = options.xAxis ?? {};\n\t\tconst yTickCount = yAxis.ticks ?? 5;\n\t\tlet lo = yAxis.min ?? Math.min(...yValues);\n\t\tlet hi = yAxis.max ?? Math.max(...yValues);\n\t\tif (!Number.isFinite(lo) || !Number.isFinite(hi)) [lo, hi] = [0, 1];\n\t\tif (lo === hi) [lo, hi] = [lo - 1, hi + 1];\n\t\tconst y = scaleLinear().domain([lo, hi]);\n\t\tif (yAxis.min === undefined || yAxis.max === undefined) y.nice(yTickCount);\n\t\tconst yFormat =\n\t\t\tfmt(yAxis) ?? ((v: ChartX) => y.tickFormat(yTickCount)(v as number));\n\t\tconst yTicks = y.ticks(yTickCount);\n\n\t\tconst legendItems = series.map((s, i) => ({\n\t\t\tname: s.name ?? `Series ${i + 1}`,\n\t\t\tcolor: colorOf(s, i),\n\t\t}));\n\t\tconst showLegend = options.legend ?? series.length > 1;\n\t\tconst showY = yAxis.show !== false;\n\t\tconst showX = xAxis.show !== false;\n\t\tconst yLabelWidth = showY\n\t\t\t? Math.max(...yTicks.map((t) => yFormat(t).length)) * fontSize * 0.7 + 20\n\t\t\t: 0;\n\t\tconst pad = resolvePadding({\n\t\t\ttop: (showLegend ? lineHeight + 20 : 0) + Math.ceil(lineHeight / 2),\n\t\t\tright: 20,\n\t\t\tbottom: showX ? lineHeight + 14 : 12,\n\t\t\tleft: Math.max(16, Math.ceil(yLabelWidth)),\n\t\t});\n\t\tconst plot = plotRect(pad);\n\t\t// Room for value labels above positive bars and below negative ones.\n\t\tconst labelRoom = lineHeight + 6;\n\t\tconst barValues = options.valueLabels\n\t\t\t? series.flatMap((s, i) =>\n\t\t\t\t\ttypeOf(s) === \"bar\" ? points[i].map((p) => p.y) : [],\n\t\t\t\t)\n\t\t\t: [];\n\t\tconst topInset = barValues.some((v) => v > 0) ? labelRoom : 0;\n\t\tconst bottomInset = barValues.some((v) => v < 0) ? labelRoom : 0;\n\t\ty.range([plot.height - bottomInset, topInset]);\n\n\t\tlet x: XScale;\n\t\tif (xKind === \"band\") {\n\t\t\tx = scaleBand<string>()\n\t\t\t\t.domain(categories)\n\t\t\t\t.range([0, plot.width])\n\t\t\t\t.paddingInner(anyBand ? 0.28 : 0)\n\t\t\t\t.paddingOuter(anyBand ? 0.14 : 0.5);\n\t\t} else if (xKind === \"time\") {\n\t\t\tconst xs = allX.map((v) => +new Date(v as Date));\n\t\t\tx = scaleUtc()\n\t\t\t\t.domain([Math.min(...xs), Math.max(...xs)])\n\t\t\t\t.range([0, plot.width]);\n\t\t} else {\n\t\t\tconst xs = allX.map(Number);\n\t\t\tx = scaleLinear()\n\t\t\t\t.domain([xAxis.min ?? Math.min(...xs), xAxis.max ?? Math.max(...xs)])\n\t\t\t\t.range([0, plot.width]);\n\t\t}\n\t\tconst xPos = (v: ChartX): number => {\n\t\t\tif (xKind === \"band\") {\n\t\t\t\tconst b = x as ScaleBand<string>;\n\t\t\t\treturn (b(String(v)) ?? 0) + b.bandwidth() / 2;\n\t\t\t}\n\t\t\tif (xKind === \"time\")\n\t\t\t\treturn (x as ScaleTime<number, number>)(new Date(v as Date));\n\t\t\treturn (x as ScaleLinear<number, number>)(Number(v));\n\t\t};\n\n\t\t// Grid and y labels.\n\t\tconst gridDelay = 0;\n\t\tif (yAxis.grid !== false) {\n\t\t\tyTicks.forEach((t, i) => {\n\t\t\t\tconst node = Layer.box({\n\t\t\t\t\tid: `${id}-ygrid-${i}`,\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tx: plot.x,\n\t\t\t\t\ty: round(plot.y + y(t) - 0.5),\n\t\t\t\t\twidth: plot.width,\n\t\t\t\t\theight: 1,\n\t\t\t\t\tbackground: gridColor,\n\t\t\t\t});\n\t\t\t\tif (timing.enabled)\n\t\t\t\t\tnode.animate(fadeIn(timing, gridDelay, timing.duration / 2));\n\t\t\t\tchildren.push(node);\n\t\t\t});\n\t\t}\n\t\tif (showY) {\n\t\t\tyTicks.forEach((t, i) => {\n\t\t\t\tlabel(\n\t\t\t\t\tyFormat(t),\n\t\t\t\t\t{\n\t\t\t\t\t\tx: 0,\n\t\t\t\t\t\ty: plot.y + y(t) - lineHeight / 2,\n\t\t\t\t\t\twidth: plot.x - 12,\n\t\t\t\t\t\theight: lineHeight,\n\t\t\t\t\t},\n\t\t\t\t\t\"end\",\n\t\t\t\t\t{},\n\t\t\t\t\t`y-${i}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t// x labels (and optional vertical grid).\n\t\tconst xTicks: { pos: number; text: string }[] = [];\n\t\tconst xFormat = fmt(xAxis);\n\t\tif (xKind === \"band\") {\n\t\t\tconst b = x as ScaleBand<string>;\n\t\t\tconst every = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.ceil(\n\t\t\t\t\tcategories.length /\n\t\t\t\t\t\tMath.max(1, Math.floor(plot.width / (fontSize * 4))),\n\t\t\t\t),\n\t\t\t);\n\t\t\tcategories.forEach((c, i) => {\n\t\t\t\tif (i % every === 0)\n\t\t\t\t\txTicks.push({\n\t\t\t\t\t\tpos: (b(c) ?? 0) + b.bandwidth() / 2,\n\t\t\t\t\t\ttext: xFormat ? xFormat(c) : c,\n\t\t\t\t\t});\n\t\t\t});\n\t\t} else {\n\t\t\tconst s = x as ScaleLinear<number, number>;\n\t\t\tconst count =\n\t\t\t\txAxis.ticks ?? Math.max(2, Math.floor(plot.width / (fontSize * 6)));\n\t\t\tconst tf = s.tickFormat(count);\n\t\t\tfor (const t of s.ticks(count)) {\n\t\t\t\txTicks.push({\n\t\t\t\t\tpos: s(t),\n\t\t\t\t\ttext: xFormat ? xFormat(xKind === \"time\" ? new Date(t) : t) : tf(t),\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t\tif (xAxis.grid) {\n\t\t\txTicks.forEach((t, i) => {\n\t\t\t\tconst node = Layer.box({\n\t\t\t\t\tid: `${id}-xgrid-${i}`,\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tx: round(plot.x + t.pos - 0.5),\n\t\t\t\t\ty: plot.y,\n\t\t\t\t\twidth: 1,\n\t\t\t\t\theight: plot.height,\n\t\t\t\t\tbackground: gridColor,\n\t\t\t\t});\n\t\t\t\tif (timing.enabled)\n\t\t\t\t\tnode.animate(fadeIn(timing, gridDelay, timing.duration / 2));\n\t\t\t\tchildren.push(node);\n\t\t\t});\n\t\t}\n\t\tif (showX) {\n\t\t\tconst slot = Math.max(\n\t\t\t\tfontSize * 3,\n\t\t\t\tplot.width / Math.max(1, xTicks.length),\n\t\t\t);\n\t\t\txTicks.forEach((t, i) => {\n\t\t\t\tlabel(\n\t\t\t\t\tt.text,\n\t\t\t\t\t{\n\t\t\t\t\t\tx: plot.x + t.pos - slot / 2,\n\t\t\t\t\t\ty: plot.y + plot.height + 10,\n\t\t\t\t\t\twidth: slot,\n\t\t\t\t\t\theight: lineHeight,\n\t\t\t\t\t},\n\t\t\t\t\t\"center\",\n\t\t\t\t\t{},\n\t\t\t\t\t`x-${i}`,\n\t\t\t\t);\n\t\t\t});\n\t\t}\n\n\t\t// Baseline at zero when it is inside the domain.\n\t\tconst [y0, y1] = y.domain();\n\t\tif (y0 <= 0 && y1 >= 0 && anyBand) {\n\t\t\tconst node = Layer.box({\n\t\t\t\tid: `${id}-zero`,\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tx: plot.x,\n\t\t\t\ty: round(plot.y + y(0) - 1),\n\t\t\t\twidth: plot.width,\n\t\t\t\theight: 2,\n\t\t\t\tbackground: withAlpha(\"#94a3b8\", 0.45),\n\t\t\t});\n\t\t\tif (timing.enabled) node.animate(fadeIn(timing, 0, timing.duration / 2));\n\t\t\tchildren.push(node);\n\t\t}\n\n\t\t// Series. Bars first so lines draw on top.\n\t\tconst barSeries = series\n\t\t\t.map((_, i) => i)\n\t\t\t.filter((i) => typeOf(series[i]) === \"bar\");\n\t\tconst order = [\n\t\t\t...barSeries,\n\t\t\t...series\n\t\t\t\t.map((_, i) => i)\n\t\t\t\t.filter((i) => typeOf(series[i]) === \"candlestick\"),\n\t\t\t...series.map((_, i) => i).filter((i) => typeOf(series[i]) === \"area\"),\n\t\t\t...series.map((_, i) => i).filter((i) => typeOf(series[i]) === \"line\"),\n\t\t\t...series.map((_, i) => i).filter((i) => typeOf(series[i]) === \"scatter\"),\n\t\t];\n\n\t\tconst band = xKind === \"band\" ? (x as ScaleBand<string>) : null;\n\t\tconst bandStep = band ? staggerStep(categories.length) : 0;\n\t\tconst categoryIndex = (v: ChartX) =>\n\t\t\tband ? categories.indexOf(String(v)) : 0;\n\n\t\torder.forEach((si, rank) => {\n\t\t\tconst s = series[si];\n\t\t\tconst color = colorOf(s, si);\n\t\t\tconst kind = typeOf(s);\n\t\t\tconst pts = points[si];\n\t\t\tconst range = stackRanges.get(si);\n\n\t\t\tif (kind === \"bar\" && band) {\n\t\t\t\tconst groupSize = stacked ? 1 : barSeries.length;\n\t\t\t\tconst groupIdx = stacked ? 0 : barSeries.indexOf(si);\n\t\t\t\tconst bw = band.bandwidth() / groupSize;\n\t\t\t\tconst gap = groupSize > 1 ? Math.min(4, bw * 0.12) : 0;\n\t\t\t\tpts.forEach((p, i) => {\n\t\t\t\t\tconst [lo, hi] = range ? range[i] : [0, p.y];\n\t\t\t\t\tconst top = plot.y + y(Math.max(lo, hi));\n\t\t\t\t\tconst bottom = plot.y + y(Math.min(lo, hi));\n\t\t\t\t\tconst h = Math.max(0, bottom - top);\n\t\t\t\t\tconst bx =\n\t\t\t\t\t\tplot.x + (band(String(p.x)) ?? 0) + groupIdx * bw + gap / 2;\n\t\t\t\t\tconst grows = p.y >= 0 ? \"up\" : \"down\";\n\t\t\t\t\tconst node = Layer.box({\n\t\t\t\t\t\tid: `${id}-bar-${si}-${i}`,\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\tx: round(bx),\n\t\t\t\t\t\ty: round(top),\n\t\t\t\t\t\twidth: round(Math.max(1, bw - gap)),\n\t\t\t\t\t\theight: round(h),\n\t\t\t\t\t\tbackground: color,\n\t\t\t\t\t\tborderRadius: Math.min(radius, (bw - gap) / 2, h / 2),\n\t\t\t\t\t});\n\t\t\t\t\tconst delay =\n\t\t\t\t\t\tcategoryIndex(p.x) * bandStep +\n\t\t\t\t\t\t(stacked ? barSeries.indexOf(si) * timing.duration * 0.6 : 0);\n\t\t\t\t\tif (timing.enabled) {\n\t\t\t\t\t\tconst st = timing.start + delay;\n\t\t\t\t\t\tconst end = st + timing.duration;\n\t\t\t\t\t\tconst a = LayerAnimation.create().fromTo(\"height\", 0, round(h), {\n\t\t\t\t\t\t\tstart: st,\n\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\tease: timing.ease,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (grows === \"up\") {\n\t\t\t\t\t\t\ta.fromTo(\"y\", round(top + h), round(top), {\n\t\t\t\t\t\t\t\tstart: st,\n\t\t\t\t\t\t\t\tend,\n\t\t\t\t\t\t\t\tease: timing.ease,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t\tnode.animate(a);\n\t\t\t\t\t}\n\t\t\t\t\tchildren.push(node);\n\t\t\t\t\tif (options.valueLabels) {\n\t\t\t\t\t\tconst text = yFormat(p.y);\n\t\t\t\t\t\tconst ly = grows === \"up\" ? top - lineHeight - 4 : top + h + 4;\n\t\t\t\t\t\tlabel(\n\t\t\t\t\t\t\ttext,\n\t\t\t\t\t\t\t{ x: bx - 30, y: ly, width: bw - gap + 60, height: lineHeight },\n\t\t\t\t\t\t\t\"center\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tdelay: delay + timing.duration * 0.6,\n\t\t\t\t\t\t\t\tcolor: strongText,\n\t\t\t\t\t\t\t\tweight: 600,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t`value-${si}-${i}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (kind === \"candlestick\" && band) {\n\t\t\t\tconst up = options.upColor ?? \"#22c55e\";\n\t\t\t\tconst down = options.downColor ?? \"#ef4444\";\n\t\t\t\tconst bw = band.bandwidth();\n\t\t\t\t(s.data as readonly ChartCandle[]).forEach((c, i) => {\n\t\t\t\t\tconst col = c.close >= c.open ? up : down;\n\t\t\t\t\tconst cxp = plot.x + (band(String(c.x)) ?? 0) + bw / 2;\n\t\t\t\t\tconst delay = categoryIndex(c.x) * bandStep;\n\t\t\t\t\tconst parts: [string, Rect][] = [\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"wick\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: cxp - Math.max(1, bw * 0.06),\n\t\t\t\t\t\t\t\ty: plot.y + y(c.high),\n\t\t\t\t\t\t\t\twidth: Math.max(2, bw * 0.12),\n\t\t\t\t\t\t\t\theight: Math.max(1, y(c.low) - y(c.high)),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\"body\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tx: cxp - bw / 2,\n\t\t\t\t\t\t\t\ty: plot.y + y(Math.max(c.open, c.close)),\n\t\t\t\t\t\t\t\twidth: bw,\n\t\t\t\t\t\t\t\theight: Math.max(2, Math.abs(y(c.open) - y(c.close))),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t];\n\t\t\t\t\tfor (const [part, r] of parts) {\n\t\t\t\t\t\tconst node = Layer.box({\n\t\t\t\t\t\t\tid: `${id}-candle-${si}-${i}-${part}`,\n\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\tx: round(r.x),\n\t\t\t\t\t\t\ty: round(r.y),\n\t\t\t\t\t\t\twidth: round(r.width),\n\t\t\t\t\t\t\theight: round(r.height),\n\t\t\t\t\t\t\tbackground: col,\n\t\t\t\t\t\t\tborderRadius:\n\t\t\t\t\t\t\t\tpart === \"body\" ? Math.min(radius / 2, r.width / 2) : 0,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (timing.enabled) {\n\t\t\t\t\t\t\tconst st = timing.start + delay;\n\t\t\t\t\t\t\tconst mid = r.y + r.height / 2;\n\t\t\t\t\t\t\tnode.animate(\n\t\t\t\t\t\t\t\tLayerAnimation.create()\n\t\t\t\t\t\t\t\t\t.fromTo(\"height\", 0, round(r.height), {\n\t\t\t\t\t\t\t\t\t\tstart: st,\n\t\t\t\t\t\t\t\t\t\tend: st + timing.duration,\n\t\t\t\t\t\t\t\t\t\tease: timing.ease,\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t\t.fromTo(\"y\", round(mid), round(r.y), {\n\t\t\t\t\t\t\t\t\t\tstart: st,\n\t\t\t\t\t\t\t\t\t\tend: st + timing.duration,\n\t\t\t\t\t\t\t\t\t\tease: timing.ease,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchildren.push(node);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (kind === \"line\" || kind === \"area\") {\n\t\t\t\tconst sw = s.strokeWidth ?? 3;\n\t\t\t\tconst m = Math.ceil(sw * 2 + (s.pointRadius ?? 0) + 2);\n\t\t\t\tconst xy = pts.map((p, i) => ({\n\t\t\t\t\tx: xPos(p.x) + m,\n\t\t\t\t\ttop: (range ? y(range[i][1]) : y(p.y)) + m,\n\t\t\t\t\tbase:\n\t\t\t\t\t\t(range\n\t\t\t\t\t\t\t? y(range[i][0])\n\t\t\t\t\t\t\t: y(Math.max(y.domain()[0], Math.min(0, y.domain()[1])))) + m,\n\t\t\t\t}));\n\t\t\t\tconst curve = curveOf(s.curve);\n\t\t\t\tconst frame: Rect = {\n\t\t\t\t\tx: plot.x - m,\n\t\t\t\t\ty: plot.y - m,\n\t\t\t\t\twidth: plot.width + 2 * m,\n\t\t\t\t\theight: plot.height + 2 * m,\n\t\t\t\t};\n\t\t\t\tconst delay = rank * (timing.duration / 3);\n\n\t\t\t\tif (kind === \"area\") {\n\t\t\t\t\tconst d = d3Area<(typeof xy)[number]>()\n\t\t\t\t\t\t.x((p) => p.x)\n\t\t\t\t\t\t.y0((p) => p.base)\n\t\t\t\t\t\t.y1((p) => p.top)\n\t\t\t\t\t\t.curve(curve)(xy);\n\t\t\t\t\tif (d) {\n\t\t\t\t\t\tconst node = Layer.shape(\"path\", {\n\t\t\t\t\t\t\tid: `${id}-area-${si}`,\n\t\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t\t...roundRect(frame),\n\t\t\t\t\t\t\td: roundPath(d),\n\t\t\t\t\t\t\tfillType: \"linear\",\n\t\t\t\t\t\t\tfillColor: withAlpha(color, 0.45),\n\t\t\t\t\t\t\tgradientEndColor: withAlpha(color, 0.02),\n\t\t\t\t\t\t\tgradientAngle: 90,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (timing.enabled)\n\t\t\t\t\t\t\tnode.animate(\n\t\t\t\t\t\t\t\tfadeIn(timing, delay + timing.duration * 0.4, timing.duration),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tchildren.push(node);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst d = d3Line<(typeof xy)[number]>()\n\t\t\t\t\t.x((p) => p.x)\n\t\t\t\t\t.y((p) => p.top)\n\t\t\t\t\t.curve(curve)(xy);\n\t\t\t\tif (d && sw > 0) {\n\t\t\t\t\tconst node = Layer.shape(\"path\", {\n\t\t\t\t\t\tid: `${id}-line-${si}`,\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\t...roundRect(frame),\n\t\t\t\t\t\td: roundPath(d),\n\t\t\t\t\t\tfillType: \"none\",\n\t\t\t\t\t\tstrokeColor: color,\n\t\t\t\t\t\tstrokeWidth: sw,\n\t\t\t\t\t\tstrokeLineCap: \"round\",\n\t\t\t\t\t\tstrokeLineJoin: \"round\",\n\t\t\t\t\t});\n\t\t\t\t\tif (timing.enabled) {\n\t\t\t\t\t\tnode.animate(\n\t\t\t\t\t\t\tLayerAnimation.create().fromTo(\"trimEnd\", 0, 1, {\n\t\t\t\t\t\t\t\tstart: timing.start + delay,\n\t\t\t\t\t\t\t\tend: timing.start + delay + timing.duration * 1.5,\n\t\t\t\t\t\t\t\tease: \"power2.inOut\",\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tchildren.push(node);\n\t\t\t\t}\n\n\t\t\t\tif ((s.pointRadius ?? 0) > 0) {\n\t\t\t\t\tdots(\n\t\t\t\t\t\tsi,\n\t\t\t\t\t\tpts,\n\t\t\t\t\t\tcolor,\n\t\t\t\t\t\ts.pointRadius ?? 0,\n\t\t\t\t\t\tdelay + timing.duration * 0.5,\n\t\t\t\t\t\trange,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (kind === \"scatter\") {\n\t\t\t\tdots(\n\t\t\t\t\tsi,\n\t\t\t\t\tpts,\n\t\t\t\t\tcolor,\n\t\t\t\t\ts.pointRadius ?? 6,\n\t\t\t\t\trank * (timing.duration / 3),\n\t\t\t\t\trange,\n\t\t\t\t);\n\t\t\t}\n\t\t});\n\n\t\tif (showLegend) legendRow(legendItems);\n\n\t\tfunction dots(\n\t\t\tsi: number,\n\t\t\tpts: Point[],\n\t\t\tcolor: string,\n\t\t\tr: number,\n\t\t\tbaseDelay: number,\n\t\t\trange: [number, number][] | undefined,\n\t\t): void {\n\t\t\tconst step = staggerStep(pts.length);\n\t\t\tpts.forEach((p, i) => {\n\t\t\t\tconst py = range ? y(range[i][1]) : y(p.y);\n\t\t\t\tconst node = Layer.shape(\"circle\", {\n\t\t\t\t\tid: `${id}-point-${si}-${i}`,\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tx: round(plot.x + xPos(p.x) - r),\n\t\t\t\t\ty: round(plot.y + py - r),\n\t\t\t\t\twidth: round(r * 2),\n\t\t\t\t\theight: round(r * 2),\n\t\t\t\t\tfillColor: color,\n\t\t\t\t\tanchorX: 0.5,\n\t\t\t\t\tanchorY: 0.5,\n\t\t\t\t});\n\t\t\t\tif (timing.enabled) {\n\t\t\t\t\tconst st = timing.start + baseDelay + i * step;\n\t\t\t\t\tnode.animate(\n\t\t\t\t\t\tLayerAnimation.create()\n\t\t\t\t\t\t\t.fromTo(\"scale\", 0, 1, {\n\t\t\t\t\t\t\t\tstart: st,\n\t\t\t\t\t\t\t\tend: st + timing.duration * 0.6,\n\t\t\t\t\t\t\t\tease: \"back.out(2)\",\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.fromTo(\"opacity\", 0, 1, { start: st, end: st + 6 }),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tchildren.push(node);\n\t\t\t});\n\t\t}\n\t}\n\n\t// ── shared helpers ──────────────────────────────────────────────────\n\n\tfunction staggerStep(count: number): number {\n\t\tif (!timing.enabled || count <= 1) return 0;\n\t\tif (timing.stagger >= 0) return timing.stagger;\n\t\treturn Math.min(4, timing.duration / count);\n\t}\n\n\tfunction resolvePadding(\n\t\tauto: Required<ChartPadding>,\n\t): Required<ChartPadding> {\n\t\tconst p = options.padding;\n\t\tif (typeof p === \"number\") return { top: p, right: p, bottom: p, left: p };\n\t\treturn {\n\t\t\ttop: p?.top ?? auto.top,\n\t\t\tright: p?.right ?? auto.right,\n\t\t\tbottom: p?.bottom ?? auto.bottom,\n\t\t\tleft: p?.left ?? auto.left,\n\t\t};\n\t}\n\n\tfunction plotRect(p: Required<ChartPadding>): Rect {\n\t\treturn {\n\t\t\tx: p.left,\n\t\t\ty: p.top,\n\t\t\twidth: Math.max(1, width - p.left - p.right),\n\t\t\theight: Math.max(1, height - p.top - p.bottom),\n\t\t};\n\t}\n\n\tfunction legendColumnWidth(names: string[]): number {\n\t\tconst longest = Math.max(0, ...names.map((n) => n.length));\n\t\treturn Math.min(width * 0.4, longest * fontSize * 0.6 + fontSize + 48);\n\t}\n\n\tfunction legendColumn(\n\t\titems: { name: string; color: string }[],\n\t\tat: { x: number; y: number; height: number },\n\t): void {\n\t\tconst rowH = lineHeight + 8;\n\t\tconst top = at.y + Math.max(0, (at.height - items.length * rowH) / 2);\n\t\titems.forEach((item, i) => {\n\t\t\tlegendItem(item, at.x, top + i * rowH, i);\n\t\t});\n\t}\n\n\tfunction legendRow(items: { name: string; color: string }[]): void {\n\t\tconst widths = items.map(\n\t\t\t(it) => it.name.length * fontSize * 0.6 + fontSize + 28,\n\t\t);\n\t\tconst total = widths.reduce((a, b) => a + b, 0);\n\t\tlet cursor = Math.max(0, width - total - 20);\n\t\titems.forEach((item, i) => {\n\t\t\tlegendItem(item, cursor, 4, i);\n\t\t\tcursor += widths[i];\n\t\t});\n\t}\n\n\tfunction legendItem(\n\t\titem: { name: string; color: string },\n\t\tlx: number,\n\t\tly: number,\n\t\ti: number,\n\t): void {\n\t\tconst sw = Math.round(fontSize * 0.7);\n\t\tconst swatch = Layer.box({\n\t\t\tid: `${id}-legend-swatch-${i}`,\n\t\t\tposition: \"absolute\",\n\t\t\tx: round(lx),\n\t\t\ty: round(ly + (lineHeight - sw) / 2),\n\t\t\twidth: sw,\n\t\t\theight: sw,\n\t\t\tborderRadius: Math.round(sw / 4),\n\t\t\tbackground: item.color,\n\t\t});\n\t\tif (timing.enabled) swatch.animate(fadeIn(timing, 0, timing.duration / 2));\n\t\tchildren.push(swatch);\n\t\tlabel(\n\t\t\titem.name,\n\t\t\t{\n\t\t\t\tx: lx + sw + 8,\n\t\t\t\ty: ly,\n\t\t\t\twidth: item.name.length * fontSize * 0.6 + 12,\n\t\t\t\theight: lineHeight,\n\t\t\t},\n\t\t\t\"start\",\n\t\t\t{ color: options.textColor ?? \"#cbd5e1\" },\n\t\t\t`legend-${i}`,\n\t\t);\n\t}\n}\n\nfunction snapKeyframes(node: LayoutNode): void {\n\tfor (const track of node.animation?.tracks ?? []) {\n\t\tfor (const kf of track.keyframes ?? []) kf.frame = Math.round(kf.frame);\n\t}\n\tfor (const child of (node as { children?: LayoutNode[] }).children ?? []) {\n\t\tsnapKeyframes(child);\n\t}\n}\n\nfunction roundRect(r: Rect): Rect {\n\treturn {\n\t\tx: round(r.x),\n\t\ty: round(r.y),\n\t\twidth: round(r.width),\n\t\theight: round(r.height),\n\t};\n}\n\n/** Shortens the long float literals d3 emits. */\nfunction roundPath(d: string): string {\n\treturn d.replace(/-?\\d*\\.\\d{3,}(?:e-?\\d+)?/gi, (n) =>\n\t\tString(round(Number(n))),\n\t);\n}\n\n/** Offsets an absolute SVG path (as produced by d3-arc) by dx, dy. */\nfunction translatePath(d: string, dx: number, dy: number): string {\n\t// d3-arc emits M/L/A/Z with absolute coordinates; A has 7 params, of which\n\t// the last two are the endpoint.\n\tconst out: string[] = [];\n\tconst re = /([MLAZ])([^MLAZ]*)/gi;\n\tfor (const [, cmd, args] of d.matchAll(re)) {\n\t\tconst nums = (args.match(/-?\\d*\\.?\\d+(?:e-?\\d+)?/gi) ?? []).map(Number);\n\t\tif (cmd.toUpperCase() === \"A\") {\n\t\t\tfor (let i = 0; i + 6 < nums.length; i += 7) {\n\t\t\t\tnums[i + 5] += dx;\n\t\t\t\tnums[i + 6] += dy;\n\t\t\t}\n\t\t} else if (cmd.toUpperCase() !== \"Z\") {\n\t\t\tfor (let i = 0; i + 1 < nums.length; i += 2) {\n\t\t\t\tnums[i] += dx;\n\t\t\t\tnums[i + 1] += dy;\n\t\t\t}\n\t\t}\n\t\tout.push(cmd + nums.map(round).join(\",\"));\n\t}\n\treturn out.join(\"\");\n}\n","import {\n\ttype FrameSignal,\n\tmediaSourceRange,\n\tmediaSourceTime,\n\ttype ResolvedMediaTimeRemap,\n\tSignal,\n} from \"@framefields/core\";\nimport {\n\ttype ClipPose,\n\ttype ClipSubjectSource,\n\tCOCO17_KEYPOINT_NAMES,\n\ttype InstanceMask,\n\tmaskObject,\n\tmergeSubjectMask,\n\tVisionBundle,\n\tVisionRunner,\n} from \"@framefields/vision\";\nimport type {\n\tSam2Options,\n\tSam2Tracker,\n\tSam3ObjectResult,\n\tSam3Options,\n\tSam3Tracker,\n} from \"@framefields/vision-sam\";\nimport { mediaDecoderCache } from \"@framefields/webgpu-renderers\";\nimport type { VisionProps } from \"./effects/index.js\";\n\nexport type PoseKeypointName = (typeof COCO17_KEYPOINT_NAMES)[number];\n\nexport interface ClipVisionOptions {\n\t/** Prompted SAM 2.1 (Tiny or Small) video segmentation. Pose is opt-in in this mode, as with sam3. */\n\tsam2?: Sam2Options;\n\t/** SAM 3 point/box or text selection with temporal tracking. Mutually exclusive with sam2. */\n\tsam3?: Sam3Options;\n\t/** Explicitly agree to Meta's SAM License terms, required to download and run SAM 3. */\n\tacceptSamLicense?: boolean;\n\t/** Composition frame the clip's first frame plays on (default 0). */\n\tstartFrame?: number;\n\t/** Seconds trimmed off the clip's start, as on its media layer (default 0). */\n\ttrimStartSec?: number;\n\t/** The media layer's source-time mapping. */\n\ttimeRemap?: ResolvedMediaTimeRemap;\n\t/** Media layer duration in composition frames, when known. */\n\tdurationFrames?: number;\n\t/** Analysis frame rate (default: the composition's). */\n\tfps?: number;\n\t/**\n\t * Track 17 COCO keypoints (default true; opt-in with sam2/sam3, where each frame's pose\n\t * is the detected person whose keypoints fall most inside the selection).\n\t */\n\tpose?: boolean;\n\t/** Track the person's silhouette, dress and held things included (default true). */\n\tmask?: boolean;\n\t/** Silhouette cell size in source pixels (default 8: a 1920×1080 clip gives a 240×135 grid). */\n\tmaskCell?: number;\n\t/** Keypoints are averaged over ±`smoothing` frames, weighted by confidence (default 2; 0 = raw). */\n\tsmoothing?: number;\n\tvariant?: VisionProps[\"variant\"];\n\tconfidence?: number;\n\tmodelsDir?: string;\n\tbaseUrl?: string;\n\t/**\n\t * Node: where results persist between runs. Default\n\t * `$FRAMEFIELDS_VISION_CACHE_DIR` or `~/.cache/framefields/vision`;\n\t * `false` keeps them in memory only. Browsers always keep them in memory.\n\t */\n\tcacheDir?: string | false;\n}\n\n/** Where the clip sits in the composition, like a media layer's box and `fit`. */\nexport interface PersonPlacement {\n\tx?: number;\n\ty?: number;\n\twidth: number;\n\theight: number;\n\tfit?: \"cover\" | \"contain\" | \"fill\";\n}\n\ninterface FrameResult {\n\tscore?: number;\n\t/** 17 × [x, y, visibility], source px; null when no person was found. */\n\tkp: Float32Array | null;\n\t/** cellW × cellH, 0–255; null when no person was found. */\n\tmask: Uint8Array | null;\n}\n\n/** A frame's merged subject at source resolution, run-length encoded. */\ninterface SubjectResult {\n\tcategory: string;\n\tarea: number;\n\t/** (value, run length) pairs over the source-sized 0–255 mask. */\n\tvalues: Uint8Array;\n\tlengths: Uint32Array;\n\t/**\n\t * Prompted (SAM) frames only: presence probability per track ID. The runs then hold a\n\t * label map (track ID per pixel, 0 for none) instead of alpha.\n\t */\n\tscores?: number[];\n}\n\n/** A subject as written to the subjects cache file. */\ninterface StoredSubject {\n\tcategory: string;\n\tarea: number;\n\tscores?: number[];\n\tvalues: string;\n\tlengths: string;\n}\n\ninterface Transform {\n\tsx: number;\n\tsy: number;\n\tox: number;\n\toy: number;\n}\n\n/** Frames looked back over to bridge a gap where the person is lost. */\nconst HOLD = 24;\n\nconst CACHE_VERSION = 1;\n\ntype VisionSam = typeof import(\"@framefields/vision-sam\");\n\nlet visionSam: Promise<VisionSam> | undefined;\nlet clipVisionIds = 0;\n\n/** SAM ships in its own chunk, loaded only when a clip asks for `sam2` or `sam3`. */\nfunction loadVisionSam(): Promise<VisionSam> {\n\tvisionSam ??= import(\"@framefields/vision-sam\");\n\treturn visionSam;\n}\n\n/**\n * Vision results for one clip, computed per frame on demand and shared by\n * everything that reads the clip: physics, layout, signals. Unlike the\n * render-time `withVision`, which analyses a layer's previous rendered frame,\n * this analyses the clip's own frames, so a result exists before its frame\n * renders. The composition analyses what each frame needs just before\n * drawing it (and a live physics world before stepping), so preview and\n * export fill the cache as they play; nothing has to be analysed up front.\n *\n * Results depend only on the clip and settings, so they persist on disk in\n * Node: a second run, or a render after a preview, reuses them. A matte-mode\n * `withVision` layer of the same clip reuses them too (`keepSubjects`).\n */\nexport class ClipVision implements ClipSubjectSource {\n\treadonly source: string;\n\treadonly fps: number;\n\treadonly compositionFps: number;\n\treadonly startFrame: number;\n\treadonly trimStartSec: number;\n\treadonly smoothing: number;\n\t/** @internal */\n\treadonly options: ClipVisionOptions;\n\tprivate readonly results = new Map<number, FrameResult>();\n\tprivate sourceWidth = 0;\n\tprivate sourceHeight = 0;\n\tprivate cellW = 0;\n\tprivate cellH = 0;\n\tprivate readonly cell: number;\n\tprivate queue: Promise<void> = Promise.resolve();\n\tprivate runner?: VisionRunner;\n\tprivate sam2Tracker?: Sam2Tracker;\n\tprivate sam2Frame = -1;\n\tprivate sam3Tracker?: Sam3Tracker;\n\tprivate sam3Frame = -1;\n\tprivate sam?: Promise<VisionSam>;\n\t/** Clips walk their source independently, so each owns a decoder (requests to one supersede). */\n\tprivate readonly decoderId = `clip-vision#${++clipVisionIds}#`;\n\tprivate signalBundle?: VisionBundle;\n\tprivate publishedSignals = new Set<number>();\n\tprivate signalMaskFrame = -1;\n\t/** Masks of `signalMaskFrame` by track ID (0: all tracks merged). */\n\tprivate readonly signalMasks = new Map<number, InstanceMask>();\n\t/** Prompted track count per source frame, including frames where every track is absent. */\n\tprivate readonly trackCounts = new Map<number, number>();\n\tprivate cacheLoaded?: Promise<void>;\n\tprivate unsaved = 0;\n\tprivate unsavedSubjects = 0;\n\tprivate readonly blurred = new Map<number, Float32Array | null>();\n\tprivate readonly smoothed = new Map<string, [number, number, number]>();\n\tprivate personView?: PersonTrack;\n\t/** Full-resolution subject masks for render-time mattes (see `keepSubjects`). */\n\tprivate readonly subjects = new Map<number, SubjectResult | null>();\n\tprivate wantSubjects = false;\n\tprivate subjectsLoaded?: Promise<void>;\n\n\t/** @internal Use `comp.vision(source, options)`. */\n\tconstructor(source: string, fps: number, options: ClipVisionOptions = {}) {\n\t\tthis.source = source;\n\t\tif (options.sam2 && options.sam3)\n\t\t\tthrow new Error(\"Choose one prompted backend: sam2 or sam3.\");\n\t\tthis.options = options.sam2\n\t\t\t? {\n\t\t\t\t\t...options,\n\t\t\t\t\tsam2: {\n\t\t\t\t\t\t...options.sam2,\n\t\t\t\t\t\tprompts: options.sam2.prompts.map((prompt) => ({\n\t\t\t\t\t\t\t...prompt,\n\t\t\t\t\t\t\tpoints: prompt.points.map((point) => ({ ...point })),\n\t\t\t\t\t\t})),\n\t\t\t\t\t},\n\t\t\t\t}\n\t\t\t: options.sam3\n\t\t\t\t? {\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tsam3: {\n\t\t\t\t\t\t\t...options.sam3,\n\t\t\t\t\t\t\tprompts: (\n\t\t\t\t\t\t\t\toptions.sam3.prompts ??\n\t\t\t\t\t\t\t\t(options.sam3.text\n\t\t\t\t\t\t\t\t\t? [{ frame: 0, text: options.sam3.text }]\n\t\t\t\t\t\t\t\t\t: [])\n\t\t\t\t\t\t\t).map((prompt) => ({\n\t\t\t\t\t\t\t\t...prompt,\n\t\t\t\t\t\t\t\t...(prompt.points\n\t\t\t\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\t\t\t\tpoints: prompt.points.map((point) => ({\n\t\t\t\t\t\t\t\t\t\t\t\t...point,\n\t\t\t\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t: {}),\n\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: options;\n\t\tthis.compositionFps = fps;\n\t\tthis.fps = options.fps ?? fps;\n\t\tthis.startFrame = Math.round(options.startFrame ?? 0);\n\t\tthis.trimStartSec = options.trimStartSec ?? 0;\n\t\tthis.smoothing = Math.max(\n\t\t\t0,\n\t\t\tMath.round(options.smoothing ?? (options.sam2 || options.sam3 ? 0 : 2)),\n\t\t);\n\t\tthis.cell = Math.max(1, Math.round(options.maskCell ?? 8));\n\t\tif (options.sam2 || options.sam3) this.wantSubjects = true;\n\t}\n\n\t/** @internal Explicit selections must never fall back to another detected subject. */\n\tget exact(): boolean {\n\t\treturn this.options.sam2 !== undefined || this.options.sam3 !== undefined;\n\t}\n\n\t/** Object, mask and optional pose signals on the composition clock, in source geometry. */\n\tget signals(): VisionBundle {\n\t\tthis.keepSubjects();\n\t\tthis.signalBundle ??= new VisionBundle({\n\t\t\tfps: this.compositionFps,\n\t\t\ttotalFrames: Number.MAX_SAFE_INTEGER,\n\t\t\tmaskSource: (frame) =>\n\t\t\t\tthis.trackIds(frame).flatMap((id) => {\n\t\t\t\t\tconst mask = this.maskAt(frame, id);\n\t\t\t\t\treturn mask && mask.area > 0 ? [mask] : [];\n\t\t\t\t}),\n\t\t\tmatteSource: (frame) => {\n\t\t\t\tconst mask = this.maskAt(frame);\n\t\t\t\treturn mask\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tmask: mask.mask,\n\t\t\t\t\t\t\twidth: mask.width,\n\t\t\t\t\t\t\theight: mask.height,\n\t\t\t\t\t\t\tcoverage: mask.coverage,\n\t\t\t\t\t\t}\n\t\t\t\t\t: undefined;\n\t\t\t},\n\t\t});\n\t\treturn this.signalBundle;\n\t}\n\n\tprivate decoder(): ReturnType<typeof mediaDecoderCache.getVideo> {\n\t\treturn mediaDecoderCache.getVideo(this.source, true, this.decoderId);\n\t}\n\n\t/** Free inference sessions and the decoder. Analysed frames remain readable; later frames replay memory. */\n\trelease(): void {\n\t\tmediaDecoderCache.clearNode(this.decoderId);\n\t\tthis.sam2Tracker?.release();\n\t\tthis.sam2Tracker = undefined;\n\t\tthis.sam2Frame = -1;\n\t\tthis.sam3Tracker?.release();\n\t\tthis.sam3Tracker = undefined;\n\t\tthis.sam3Frame = -1;\n\t\tthis.runner?.close();\n\t\tthis.runner = undefined;\n\t\tthis.signalMaskFrame = -1;\n\t\tthis.signalMasks.clear();\n\t\tthis.publishedSignals.clear();\n\t}\n\n\t/** The tracked person in source pixels; `.place()` maps it into the composition. */\n\tget person(): PersonTrack {\n\t\tthis.personView ??= new PersonTrack(this);\n\t\treturn this.personView;\n\t}\n\n\t/**\n\t * Analyses what reading composition frame `frame` needs (it and a few\n\t * neighbours for smoothing). Pass a second frame to analyse a whole range.\n\t * Calls queue, so the clip is decoded once, in order.\n\t */\n\tready(frame: number, toFrame: number = frame): Promise<void> {\n\t\tconst [from, to] = this.window(frame, toFrame);\n\t\tconst run = this.queue.then(async () => {\n\t\t\ttry {\n\t\t\t\tawait this.compute(from, to);\n\t\t\t} catch (error) {\n\t\t\t\tthis.release();\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tif (this.signalBundle)\n\t\t\t\tthis.publishSignals(Math.min(frame, toFrame), Math.max(frame, toFrame));\n\t\t});\n\t\tthis.queue = run.catch(() => undefined);\n\t\treturn run;\n\t}\n\n\t/** True when composition frame `frame` can be read synchronously. */\n\tisReady(frame: number): boolean {\n\t\tconst [from, to] = this.window(frame, frame);\n\t\tfor (let c = from; c <= to; c++) if (!this.analysed(c)) return false;\n\t\treturn true;\n\t}\n\n\t/**\n\t * @internal Also keep each frame's full-resolution subject mask, merged\n\t * like the Vision effect's matte, so a matte layer of this clip reuses it\n\t * instead of segmenting the frame again (framefields links them).\n\t */\n\tkeepSubjects(): void {\n\t\tthis.wantSubjects = true;\n\t}\n\n\t/**\n\t * @internal The subject at a source frame of the clip (`frame` at `fps`),\n\t * for a render-time matte: undefined until that frame is analysed with\n\t * subjects kept, null when it holds no subject.\n\t */\n\tsubject(frame: number, fps: number): InstanceMask | null | undefined {\n\t\tconst sourceFrame = this.sourceFrame(frame, fps);\n\t\tif (sourceFrame === undefined) return undefined;\n\t\tconst s = this.subjects.get(sourceFrame);\n\t\tif (s === undefined) return s;\n\t\tif (s === null || !this.sourceWidth) return null;\n\t\tconst width = this.sourceWidth;\n\t\tconst height = this.sourceHeight;\n\t\treturn {\n\t\t\tcategory: s.category,\n\t\t\tmask: subjectAlpha(s, width * height),\n\t\t\twidth,\n\t\t\theight,\n\t\t\tarea: s.area,\n\t\t\tcoverage: s.area / (width * height),\n\t\t\tdetectionIndex: -1,\n\t\t};\n\t}\n\n\t/**\n\t * @internal The pose matched to the subject at a source frame of the clip\n\t * (`frame` at `fps`), normalized to the source size, for a render-time\n\t * skeleton: undefined until that frame and its smoothing window are\n\t * analysed, null when no pose matched there.\n\t */\n\tpose(frame: number, fps: number): ClipPose | null | undefined {\n\t\tconst c = this.sourceFrame(frame, fps);\n\t\tif (c === undefined || !this.tracksPose || !this.sourceWidth) return;\n\t\tfor (let g = c - this.smoothing; g <= c + this.smoothing; g++)\n\t\t\tif (!this.results.has(Math.max(0, g))) return undefined;\n\t\tif (!this.results.get(c)?.kp) return null;\n\t\tconst width = this.sourceWidth;\n\t\tconst height = this.sourceHeight;\n\t\treturn {\n\t\t\twidth,\n\t\t\theight,\n\t\t\tkeypoints: Array.from({ length: 17 }, (_, k) => {\n\t\t\t\tconst [x, y, visibility] = this.keypoint(k, c);\n\t\t\t\treturn { x: x / width, y: y / height, visibility };\n\t\t\t}),\n\t\t};\n\t}\n\n\t/** Whether frames carry keypoints: on by default, opt-in for prompted (SAM) clips. */\n\tget tracksPose(): boolean {\n\t\treturn this.exact\n\t\t\t? this.options.pose === true\n\t\t\t: (this.options.pose ?? true);\n\t}\n\n\t/**\n\t * The analysed source frame a render-time read at `frame` (at `fps`) maps to;\n\t * undefined for an unprompted clip read between its analysed frames.\n\t */\n\tprivate sourceFrame(frame: number, fps: number): number | undefined {\n\t\tconst c = (frame * this.fps) / fps;\n\t\tif (\n\t\t\t!this.exact &&\n\t\t\t!this.options.timeRemap &&\n\t\t\tMath.abs(c - Math.round(c)) > 1e-6\n\t\t)\n\t\t\treturn undefined;\n\t\treturn this.options.timeRemap || this.exact\n\t\t\t? Math.floor(c + 1e-6)\n\t\t\t: Math.round(c);\n\t}\n\n\t/** Composition frame → clip frame (fractional). */\n\tclipFrame(frame: number): number {\n\t\tif (this.options.timeRemap)\n\t\t\treturn (\n\t\t\t\tmediaSourceTime(\n\t\t\t\t\tthis.options.timeRemap,\n\t\t\t\t\tthis.localFrame(frame),\n\t\t\t\t\tthis.compositionFps,\n\t\t\t\t) * this.fps\n\t\t\t);\n\t\treturn (\n\t\t\t((frame - this.startFrame) / this.compositionFps + this.trimStartSec) *\n\t\t\tthis.fps\n\t\t);\n\t}\n\n\tprivate localFrame(frame: number): number {\n\t\tconst local = Math.max(0, frame - this.startFrame);\n\t\treturn this.options.durationFrames === undefined\n\t\t\t? local\n\t\t\t: Math.min(local, Math.max(0, this.options.durationFrames - 1));\n\t}\n\n\tprivate window(frame: number, toFrame: number): [number, number] {\n\t\tconst range = this.options.timeRemap\n\t\t\t? mediaSourceRange(\n\t\t\t\t\tthis.options.timeRemap,\n\t\t\t\t\tthis.localFrame(Math.min(frame, toFrame)),\n\t\t\t\t\tthis.localFrame(Math.max(frame, toFrame)),\n\t\t\t\t\tthis.compositionFps,\n\t\t\t\t)\n\t\t\t: undefined;\n\t\tconst a = Math.floor(\n\t\t\trange ? range.min * this.fps : this.clipFrame(Math.min(frame, toFrame)),\n\t\t);\n\t\tconst b = Math.ceil(\n\t\t\trange ? range.max * this.fps : this.clipFrame(Math.max(frame, toFrame)),\n\t\t);\n\t\treturn [\n\t\t\tMath.max(0, a - HOLD - this.smoothing),\n\t\t\tMath.max(0, b + this.smoothing),\n\t\t];\n\t}\n\n\tprivate analysed(c: number): boolean {\n\t\treturn this.results.has(c) && (!this.wantSubjects || this.subjects.has(c));\n\t}\n\n\t/** Loads `@framefields/vision-sam` and validates the prompts once, on first use. */\n\tprivate prompted(): Promise<VisionSam> {\n\t\tthis.sam ??= loadVisionSam().then((sam) => {\n\t\t\tif (this.options.sam2) sam.validateSam2Prompts(this.options.sam2.prompts);\n\t\t\tif (this.options.sam3) sam.validateSam3Prompts(this.options.sam3);\n\t\t\treturn sam;\n\t\t});\n\t\treturn this.sam;\n\t}\n\n\tprivate async compute(from: number, to: number): Promise<void> {\n\t\tif (this.exact) await this.prompted();\n\t\tthis.cacheLoaded ??= this.loadCache();\n\t\tawait this.cacheLoaded;\n\t\tif (this.wantSubjects) {\n\t\t\tthis.subjectsLoaded ??= this.loadSubjects();\n\t\t\tawait this.subjectsLoaded;\n\t\t}\n\t\tlet missing = false;\n\t\tfor (let c = from; c <= to; c++) if (!this.analysed(c)) missing = true;\n\t\tif (!missing) return;\n\n\t\tif (this.options.sam2) {\n\t\t\tawait this.computeSam2(to);\n\t\t\treturn;\n\t\t}\n\t\tif (this.options.sam3) {\n\t\t\tawait this.computeSam3(to);\n\t\t\treturn;\n\t\t}\n\t\tconst wantPose = this.tracksPose;\n\t\tconst wantMask = this.options.mask ?? true;\n\t\tthis.runner ??= VisionRunner.create({\n\t\t\tmodelsDir: this.options.modelsDir,\n\t\t\tbaseUrl: this.options.baseUrl,\n\t\t\t...(this.options.confidence !== undefined && {\n\t\t\t\tconfidence: this.options.confidence,\n\t\t\t}),\n\t\t\t...(this.options.variant !== undefined && {\n\t\t\t\tvariant: this.options.variant,\n\t\t\t}),\n\t\t});\n\t\tconst decoder = this.decoder();\n\t\tfor (let c = from; c <= to; c++) {\n\t\t\tif (this.analysed(c)) continue;\n\t\t\tconst image = await decodedPixels(await decoder.getFrame(c / this.fps));\n\t\t\tif (!image) {\n\t\t\t\tthis.results.set(c, { kp: null, mask: null });\n\t\t\t\tif (this.wantSubjects) this.subjects.set(c, null);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (!this.sourceWidth) this.setSize(image.width, image.height);\n\t\t\t// Analysed before without subjects: only segment it again.\n\t\t\tconst known = this.results.get(c);\n\t\t\tlet kp: Float32Array | null = known?.kp ?? null;\n\t\t\tlet mask: Uint8Array | null = known?.mask ?? null;\n\t\t\tif (wantPose && !known) {\n\t\t\t\tconst person = (await this.runner.pose(image)).people[0];\n\t\t\t\tif (person) {\n\t\t\t\t\tkp = new Float32Array(51);\n\t\t\t\t\tfor (const [k, p] of person.keypoints.entries()) {\n\t\t\t\t\t\tkp.set([p.x, p.y, p.visibility], k * 3);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst seg =\n\t\t\t\t(wantMask && !known) || this.wantSubjects\n\t\t\t\t\t? await this.runner.segment(image)\n\t\t\t\t\t: undefined;\n\t\t\tif (seg && this.wantSubjects) {\n\t\t\t\tconst subject = mergeSubjectMask(seg.masks);\n\t\t\t\tthis.subjects.set(\n\t\t\t\t\tc,\n\t\t\t\t\tsubject\n\t\t\t\t\t\t? {\n\t\t\t\t\t\t\t\tcategory: subject.category,\n\t\t\t\t\t\t\t\tarea: subject.area,\n\t\t\t\t\t\t\t\t...encodeRuns(subject.mask),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t: null,\n\t\t\t\t);\n\t\t\t\tthis.unsavedSubjects++;\n\t\t\t}\n\t\t\tif (seg && wantMask && !known) {\n\t\t\t\tconst silhouette = personSilhouette(seg);\n\t\t\t\tif (silhouette) {\n\t\t\t\t\tmask = new Uint8Array(this.cellW * this.cellH);\n\t\t\t\t\tdownsampleMean(\n\t\t\t\t\t\tsilhouette,\n\t\t\t\t\t\timage.width,\n\t\t\t\t\t\timage.height,\n\t\t\t\t\t\tthis.cell,\n\t\t\t\t\t\tmask,\n\t\t\t\t\t\tthis.cellW,\n\t\t\t\t\t\tthis.cellH,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis.results.set(c, { kp, mask });\n\t\t\tif (!known) this.unsaved++;\n\t\t\tif (this.unsaved >= 24) await this.saveCache();\n\t\t\tif (this.unsavedSubjects >= 24) await this.saveSubjects();\n\t\t}\n\t\tif (this.unsaved > 0) await this.saveCache();\n\t\tif (this.unsavedSubjects > 0) await this.saveSubjects();\n\t}\n\n\tprivate async computeSam2(to: number): Promise<void> {\n\t\tconst settings = this.options.sam2;\n\t\tif (!settings) return;\n\t\tconst first = settings.prompts[0]?.frame ?? 0;\n\t\tfor (let frame = 0; frame < Math.min(first, to + 1); frame++) {\n\t\t\tthis.results.set(frame, { kp: null, mask: null, score: 0 });\n\t\t\tthis.subjects.set(frame, null);\n\t\t}\n\t\tif (to < first) return;\n\t\tconst decoder = this.decoder();\n\t\tif (!this.sam2Tracker) {\n\t\t\tconst frameCount = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.ceil((await decoder.durationSec()) * this.fps - 1e-6),\n\t\t\t);\n\t\t\tif (settings.prompts.some((prompt) => prompt.frame >= frameCount)) {\n\t\t\t\tthrow new Error(\"SAM 2 prompt frames must be inside the source video.\");\n\t\t\t}\n\t\t\tconst { Sam2Tracker } = await this.prompted();\n\t\t\tthis.sam2Tracker = await Sam2Tracker.create({\n\t\t\t\tmodelsDir: this.options.modelsDir,\n\t\t\t\tbaseUrl: this.options.baseUrl,\n\t\t\t\tframeCount,\n\t\t\t\tmodel: settings.model,\n\t\t\t});\n\t\t\tthis.sam2Frame = first - 1;\n\t\t}\n\t\tfor (let frame = this.sam2Frame + 1; frame <= to; frame++) {\n\t\t\tconst image = await decodedPixels(\n\t\t\t\tawait decoder.getFrame(frame / this.fps),\n\t\t\t);\n\t\t\tif (!image) throw new Error(`Cannot decode SAM 2 source frame ${frame}.`);\n\t\t\tif (!this.sourceWidth) this.setSize(image.width, image.height);\n\t\t\tconst prompt = settings.prompts.find((item) => item.frame === frame);\n\t\t\tconst result = await this.sam2Tracker.process(\n\t\t\t\timage,\n\t\t\t\tframe,\n\t\t\t\tprompt?.points,\n\t\t\t);\n\t\t\tconst kp = this.tracksPose\n\t\t\t\t? await this.matchedPose(image, result.mask)\n\t\t\t\t: null;\n\t\t\tthis.storeSamFrame(frame, result.width, result.height, [result], kp);\n\t\t\tif (this.unsaved >= 24) {\n\t\t\t\tawait this.saveCache();\n\t\t\t\tawait this.saveSubjects();\n\t\t\t}\n\t\t}\n\t\tawait this.saveCache();\n\t\tawait this.saveSubjects();\n\t}\n\n\tprivate async computeSam3(to: number): Promise<void> {\n\t\tconst settings = this.options.sam3;\n\t\tif (!settings) return;\n\t\tconst first = settings.prompts[0]?.frame ?? 0;\n\t\tfor (let frame = 0; frame < Math.min(first, to + 1); frame++) {\n\t\t\tthis.results.set(frame, { kp: null, mask: null, score: 0 });\n\t\t\tthis.subjects.set(frame, null);\n\t\t}\n\t\tif (to < first) return;\n\t\tconst decoder = this.decoder();\n\t\tif (!this.sam3Tracker) {\n\t\t\tconst frameCount = Math.max(\n\t\t\t\t1,\n\t\t\t\tMath.ceil((await decoder.durationSec()) * this.fps - 1e-6),\n\t\t\t);\n\t\t\tif (settings.prompts.some((prompt) => prompt.frame >= frameCount)) {\n\t\t\t\tthrow new Error(\"SAM 3 prompt frames must be inside the source video.\");\n\t\t\t}\n\t\t\tconst { Sam3Tracker } = await this.prompted();\n\t\t\tthis.sam3Tracker = await Sam3Tracker.create({\n\t\t\t\tmodelsDir: this.options.modelsDir,\n\t\t\t\tbaseUrl: this.options.baseUrl,\n\t\t\t\tframeCount,\n\t\t\t\ttextThreshold: settings.textThreshold,\n\t\t\t\tmaxObjects: settings.maxObjects,\n\t\t\t\tmerge: settings.merge,\n\t\t\t\tredetect: settings.redetect,\n\t\t\t\tprecision: settings.precision,\n\t\t\t\tacceptLicense:\n\t\t\t\t\tthis.options.acceptSamLicense ?? this.options.sam3?.acceptLicense,\n\t\t\t});\n\t\t\tthis.sam3Frame = first - 1;\n\t\t}\n\t\tfor (let frame = this.sam3Frame + 1; frame <= to; frame++) {\n\t\t\tconst image = await decodedPixels(\n\t\t\t\tawait decoder.getFrame(frame / this.fps),\n\t\t\t);\n\t\t\tif (!image) throw new Error(`Cannot decode SAM 3 source frame ${frame}.`);\n\t\t\tif (!this.sourceWidth) this.setSize(image.width, image.height);\n\t\t\tconst prompt = settings.prompts.find((item) => item.frame === frame);\n\t\t\tconst result = await this.sam3Tracker.process(image, frame, prompt);\n\t\t\tconst kp = this.tracksPose\n\t\t\t\t? await this.matchedPose(image, unionMask(result.objects, image))\n\t\t\t\t: null;\n\t\t\tthis.storeSamFrame(\n\t\t\t\tframe,\n\t\t\t\tresult.width,\n\t\t\t\tresult.height,\n\t\t\t\tresult.objects,\n\t\t\t\tkp,\n\t\t\t);\n\t\t\tif (this.unsaved >= 24) {\n\t\t\t\tawait this.saveCache();\n\t\t\t\tawait this.saveSubjects();\n\t\t\t}\n\t\t}\n\t\tawait this.saveCache();\n\t\tawait this.saveSubjects();\n\t}\n\n\t/** Stores a prompted frame: every track's mask as one label map, the union as the subject. */\n\tprivate storeSamFrame(\n\t\tframe: number,\n\t\twidth: number,\n\t\theight: number,\n\t\tobjects: readonly Pick<Sam3ObjectResult, \"mask\" | \"score\">[],\n\t\tkp: Float32Array | null,\n\t): void {\n\t\tconst labels = new Uint8Array(width * height);\n\t\t// Ascending presence, so where tracks overlap the most confident one keeps the pixel.\n\t\tconst order = [...objects.keys()].sort(\n\t\t\t(a, b) => (objects[a]?.score ?? 0) - (objects[b]?.score ?? 0),\n\t\t);\n\t\tfor (const index of order) {\n\t\t\tconst mask = objects[index]?.mask;\n\t\t\tif (!mask) continue;\n\t\t\tfor (let i = 0; i < mask.length; i++)\n\t\t\t\tif ((mask[i] ?? 0) >= 128) labels[i] = index + 1;\n\t\t}\n\t\tconst union = Uint8Array.from(labels, (id) => (id ? 255 : 0));\n\t\tconst grid = new Uint8Array(this.cellW * this.cellH);\n\t\tdownsampleMean(\n\t\t\tunion,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tthis.cell,\n\t\t\tgrid,\n\t\t\tthis.cellW,\n\t\t\tthis.cellH,\n\t\t);\n\t\tlet area = 0;\n\t\tfor (const id of labels) if (id) area++;\n\t\tconst scores = objects.map((o) => 1 / (1 + Math.exp(-o.score)));\n\t\tthis.results.set(frame, {\n\t\t\tkp,\n\t\t\tmask: grid,\n\t\t\tscore: Math.max(0, ...scores),\n\t\t});\n\t\tthis.subjects.set(\n\t\t\tframe,\n\t\t\tarea > 0\n\t\t\t\t? { category: this.samCategory(), area, scores, ...encodeRuns(labels) }\n\t\t\t\t: null,\n\t\t);\n\t\tthis.trackCounts.set(frame, objects.length);\n\t\tthis.blurred.delete(frame);\n\t\tif (this.options.sam3) this.sam3Frame = frame;\n\t\telse this.sam2Frame = frame;\n\t\tthis.unsaved++;\n\t\tthis.unsavedSubjects++;\n\t}\n\n\tprivate samCategory(): string {\n\t\treturn (\n\t\t\tthis.options.sam2?.category ?? this.options.sam3?.category ?? \"object\"\n\t\t);\n\t}\n\n\tprivate async matchedPose(\n\t\timage: {\n\t\t\tdata: Uint8Array | Uint8ClampedArray;\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t},\n\t\tmask: Uint8Array,\n\t): Promise<Float32Array | null> {\n\t\tthis.runner ??= VisionRunner.create({\n\t\t\tmodelsDir: this.options.modelsDir,\n\t\t\tbaseUrl: this.options.baseUrl,\n\t\t\tvariant: this.options.variant,\n\t\t});\n\t\tconst { people } = await this.runner.pose(image);\n\t\tconst ranked = people\n\t\t\t.map((person) => ({\n\t\t\t\tperson,\n\t\t\t\toverlap: person.keypoints.reduce((sum, point) => {\n\t\t\t\t\tconst x = Math.max(0, Math.min(image.width - 1, Math.round(point.x)));\n\t\t\t\t\tconst y = Math.max(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tMath.min(image.height - 1, Math.round(point.y)),\n\t\t\t\t\t);\n\t\t\t\t\treturn (\n\t\t\t\t\t\tsum + ((mask[y * image.width + x] ?? 0) / 255) * point.visibility\n\t\t\t\t\t);\n\t\t\t\t}, 0),\n\t\t\t}))\n\t\t\t.sort((a, b) => b.overlap - a.overlap);\n\t\tconst match = ranked[0];\n\t\tif (!match || match.overlap < 2) return null;\n\t\treturn Float32Array.from(\n\t\t\tmatch.person.keypoints.flatMap((point) => [\n\t\t\t\tpoint.x,\n\t\t\t\tpoint.y,\n\t\t\t\tpoint.visibility,\n\t\t\t]),\n\t\t);\n\t}\n\n\t/** Track IDs at a composition frame: every prompted track, else the one subject. */\n\tprivate trackIds(frame: number): number[] {\n\t\tconst c = Math.max(0, Math.floor(this.clipFrame(frame)));\n\t\tconst count =\n\t\t\tthis.subjects.get(c)?.scores?.length ?? this.trackCounts.get(c) ?? 1;\n\t\treturn Array.from({ length: count }, (_, i) => i + 1);\n\t}\n\n\t/** The subject (all tracks merged) or, with `id`, one track's mask, in source pixels. */\n\tprivate maskAt(frame: number, id?: number): InstanceMask | undefined {\n\t\tconst c = Math.max(0, Math.floor(this.clipFrame(frame)));\n\t\tif (this.signalMaskFrame !== c) {\n\t\t\tthis.signalMaskFrame = c;\n\t\t\tthis.signalMasks.clear();\n\t\t}\n\t\tconst hit = this.signalMasks.get(id ?? 0);\n\t\tif (hit) return hit;\n\t\tif (!this.results.has(c) || !this.sourceWidth) return undefined;\n\t\tconst stored = this.subjects.get(c);\n\t\tconst size = this.sourceWidth * this.sourceHeight;\n\t\tconst data = stored ? subjectAlpha(stored, size, id) : new Uint8Array(size);\n\t\tlet area = stored?.area ?? 0;\n\t\tif (id !== undefined && stored?.scores) {\n\t\t\tarea = 0;\n\t\t\tfor (const alpha of data) if (alpha) area++;\n\t\t}\n\t\tconst mask: InstanceMask = {\n\t\t\tcategory: stored?.category ?? this.samCategory(),\n\t\t\tmask: data,\n\t\t\twidth: this.sourceWidth,\n\t\t\theight: this.sourceHeight,\n\t\t\tarea,\n\t\t\tcoverage: area / size,\n\t\t\tdetectionIndex: (id ?? 1) - 1,\n\t\t\ttrackId: id ?? 1,\n\t\t};\n\t\tthis.signalMasks.set(id ?? 0, mask);\n\t\treturn mask;\n\t}\n\n\tprivate publishSignals(from: number, to: number): void {\n\t\tconst bundle = this.signalBundle;\n\t\tif (!bundle || !this.sourceWidth) return;\n\t\tbundle.setFrameSize(this.sourceWidth, this.sourceHeight);\n\t\tfor (let frame = from; frame <= to; frame++) {\n\t\t\tif (this.publishedSignals.has(frame)) continue;\n\t\t\tthis.publishedSignals.add(frame);\n\t\t\tconst c = Math.max(0, Math.floor(this.clipFrame(frame)));\n\t\t\tconst mask = this.maskAt(frame);\n\t\t\tif (!mask) continue;\n\t\t\tconst before = bundle.getObjectResult(frame - 1).objects;\n\t\t\tconst scores = this.subjects.get(c)?.scores;\n\t\t\tconst objects = this.trackIds(frame).flatMap((id) => {\n\t\t\t\tconst track = this.maskAt(frame, id);\n\t\t\t\tif (!track) return [];\n\t\t\t\treturn [\n\t\t\t\t\tmaskObject(\n\t\t\t\t\t\ttrack,\n\t\t\t\t\t\tframe,\n\t\t\t\t\t\tthis.compositionFps,\n\t\t\t\t\t\tscores?.[id - 1] ?? this.results.get(c)?.score ?? 1,\n\t\t\t\t\t\tbefore.find((object) => object.trackId === id),\n\t\t\t\t\t),\n\t\t\t\t];\n\t\t\t});\n\t\t\tbundle.setObjectResult(frame, objects);\n\t\t\tconst object =\n\t\t\t\tobjects[0] ?? maskObject(mask, frame, this.compositionFps, 0);\n\t\t\tconst kp = this.results.get(c)?.kp;\n\t\t\tbundle.setPoseResult(frame, {\n\t\t\t\tpeople: kp\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tscore: object.score,\n\t\t\t\t\t\t\t\tboundingBox: object.boundingBox,\n\t\t\t\t\t\t\t\ttrackId: 1,\n\t\t\t\t\t\t\t\tkeypoints: Array.from({ length: 17 }, (_, i) => ({\n\t\t\t\t\t\t\t\t\tx: (kp[i * 3] ?? 0) / mask.width,\n\t\t\t\t\t\t\t\t\ty: (kp[i * 3 + 1] ?? 0) / mask.height,\n\t\t\t\t\t\t\t\t\tvisibility: kp[i * 3 + 2] ?? 0,\n\t\t\t\t\t\t\t\t})),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t]\n\t\t\t\t\t: [],\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate setSize(width: number, height: number): void {\n\t\tthis.sourceWidth = width;\n\t\tthis.sourceHeight = height;\n\t\tthis.cellW = Math.ceil(width / this.cell);\n\t\tthis.cellH = Math.ceil(height / this.cell);\n\t}\n\n\t/** @internal */\n\tsize(): { width: number; height: number } {\n\t\treturn { width: this.sourceWidth, height: this.sourceHeight };\n\t}\n\n\t/** @internal Raw result for a clip frame, or throws when it was never analysed. */\n\tresult(c: number): FrameResult | undefined {\n\t\treturn this.results.get(Math.max(0, c));\n\t}\n\n\t/** @internal Confidence-weighted keypoint over the smoothing window, in source px. */\n\tkeypoint(k: number, c: number): [number, number, number] {\n\t\tc = Math.max(0, c);\n\t\tconst key = `${k}:${c}`;\n\t\tconst hit = this.smoothed.get(key);\n\t\tif (hit) return hit;\n\t\tconst avg = (center: number): [number, number, number] | null => {\n\t\t\tlet sx = 0;\n\t\t\tlet sy = 0;\n\t\t\tlet sv = 0;\n\t\t\tlet sw = 0;\n\t\t\tfor (let g = center - this.smoothing; g <= center + this.smoothing; g++) {\n\t\t\t\tconst r = this.mustHave(g < 0 ? 0 : g);\n\t\t\t\tif (!r.kp) continue;\n\t\t\t\tconst v = r.kp[k * 3 + 2];\n\t\t\t\tconst w = (this.smoothing + 1 - Math.abs(g - center)) * v * v;\n\t\t\t\tsx += r.kp[k * 3] * w;\n\t\t\t\tsy += r.kp[k * 3 + 1] * w;\n\t\t\t\tsv += v * w;\n\t\t\t\tsw += w;\n\t\t\t}\n\t\t\treturn sw > 1e-6 ? [sx / sw, sy / sw, sv / sw] : null;\n\t\t};\n\t\tlet out: [number, number, number] | null = null;\n\t\t// Lost? Hold the last place the person was seen (within HOLD frames).\n\t\tfor (let d = 0; d <= HOLD && !out; d++) if (c - d >= 0) out = avg(c - d);\n\t\tout ??= [this.sourceWidth / 2, this.sourceHeight / 2, 0];\n\t\tthis.smoothed.set(key, out);\n\t\treturn out;\n\t}\n\n\t/** @internal Softened silhouette grid for a clip frame (null: no person). */\n\tblurredMask(c: number): Float32Array | null {\n\t\tc = Math.max(0, c);\n\t\tif (this.blurred.has(c)) return this.blurred.get(c) ?? null;\n\t\tthis.mustHave(c);\n\t\tconst mask = this.exact\n\t\t\t? (this.results.get(c)?.mask ?? null)\n\t\t\t: bridgedMask(this.results, c, this.smoothing);\n\t\tconst grid = mask ? boxBlur(mask, this.cellW, this.cellH, 2) : null;\n\t\tthis.blurred.set(c, grid);\n\t\treturn grid;\n\t}\n\n\t/** @internal */\n\tgrid(): { cell: number; width: number; height: number } {\n\t\treturn { cell: this.cell, width: this.cellW, height: this.cellH };\n\t}\n\n\tprivate mustHave(c: number): FrameResult {\n\t\tconst r = this.results.get(c);\n\t\tif (r) return r;\n\t\tthrow new Error(\n\t\t\t`ClipVision \"${this.source}\": frame ${c} is not analysed yet. ` +\n\t\t\t\t\"Read it while rendering (the composition prepares each frame), in a live physics world, \" +\n\t\t\t\t`or after \\`await clip.ready(frame)\\`.`,\n\t\t);\n\t}\n\n\t// ── Persistence (Node) ────────────────────────────────────────────────\n\n\tprivate cacheFile?: string | null;\n\n\tprivate async cachePath(): Promise<string | null> {\n\t\tif (this.cacheFile !== undefined) return this.cacheFile;\n\t\tthis.cacheFile = null;\n\t\tif (\n\t\t\tthis.options.cacheDir === false ||\n\t\t\ttypeof process === \"undefined\" ||\n\t\t\t!process.versions?.node\n\t\t) {\n\t\t\treturn null;\n\t\t}\n\t\ttry {\n\t\t\tconst [fs, path, os, crypto] = await Promise.all([\n\t\t\t\timport(\"node:fs\"),\n\t\t\t\timport(\"node:path\"),\n\t\t\t\timport(\"node:os\"),\n\t\t\t\timport(\"node:crypto\"),\n\t\t\t]);\n\t\t\tconst stat = fs.statSync(this.source);\n\t\t\tconst dir =\n\t\t\t\tthis.options.cacheDir ??\n\t\t\t\tprocess.env.FRAMEFIELDS_VISION_CACHE_DIR ??\n\t\t\t\tpath.join(os.homedir(), \".cache\", \"framefields\", \"vision\");\n\t\t\tconst o = this.options;\n\t\t\tconst sam = this.exact ? await this.prompted() : undefined;\n\t\t\tconst key = JSON.stringify([\n\t\t\t\tCACHE_VERSION,\n\t\t\t\tpath.resolve(this.source),\n\t\t\t\tstat.size,\n\t\t\t\tstat.mtimeMs,\n\t\t\t\tthis.fps,\n\t\t\t\tthis.tracksPose,\n\t\t\t\to.mask ?? true,\n\t\t\t\tthis.cell,\n\t\t\t\to.variant ?? \"s\",\n\t\t\t\to.confidence ?? null,\n\t\t\t\t// Prompted subjects are track-ID label maps (format 2); format 3 drops\n\t\t\t\t// entries keyed as tracking pose when SAM clips left it off by default.\n\t\t\t\t...(o.sam2 ? [[sam?.sam2Revision(o.sam2.model), o.sam2, 3]] : []),\n\t\t\t\t...(o.sam3 && sam\n\t\t\t\t\t? [\n\t\t\t\t\t\t\t[\n\t\t\t\t\t\t\t\tsam.sam3Revision(\n\t\t\t\t\t\t\t\t\tawait sam.sam3Precision(undefined, o.sam3.precision),\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\to.sam3,\n\t\t\t\t\t\t\t\t3,\n\t\t\t\t\t\t\t],\n\t\t\t\t\t\t]\n\t\t\t\t\t: []),\n\t\t\t]);\n\t\t\tconst hash = crypto\n\t\t\t\t.createHash(\"sha256\")\n\t\t\t\t.update(key)\n\t\t\t\t.digest(\"hex\")\n\t\t\t\t.slice(0, 24);\n\t\t\tfs.mkdirSync(dir, { recursive: true });\n\t\t\tthis.cacheFile = path.join(\n\t\t\t\tdir,\n\t\t\t\t`${path.basename(this.source)}.${hash}.json`,\n\t\t\t);\n\t\t} catch {\n\t\t\tthis.cacheFile = null; // remote URL or unreadable: memory only\n\t\t}\n\t\treturn this.cacheFile;\n\t}\n\n\tprivate async loadCache(): Promise<void> {\n\t\tconst file = await this.cachePath();\n\t\tif (!file) return;\n\t\ttry {\n\t\t\tconst fs = await import(\"node:fs\");\n\t\t\tif (!fs.existsSync(file)) return;\n\t\t\tconst json = JSON.parse(fs.readFileSync(file, \"utf8\")) as {\n\t\t\t\twidth: number;\n\t\t\t\theight: number;\n\t\t\t\tcell: number;\n\t\t\t\tframes: Record<\n\t\t\t\t\tstring,\n\t\t\t\t\t{ kp: number[] | null; mask: string | null; score?: number }\n\t\t\t\t>;\n\t\t\t};\n\t\t\tif (json.cell !== this.cell) return;\n\t\t\tthis.setSize(json.width, json.height);\n\t\t\tfor (const [c, r] of Object.entries(json.frames)) {\n\t\t\t\tthis.results.set(Number(c), {\n\t\t\t\t\tkp: r.kp ? Float32Array.from(r.kp) : null,\n\t\t\t\t\tscore: r.score,\n\t\t\t\t\tmask: r.mask ? new Uint8Array(Buffer.from(r.mask, \"base64\")) : null,\n\t\t\t\t});\n\t\t\t}\n\t\t} catch {\n\t\t\t// A damaged cache is recomputed.\n\t\t}\n\t}\n\n\tprivate async saveCache(): Promise<void> {\n\t\tthis.unsaved = 0;\n\t\tconst file = await this.cachePath();\n\t\tif (!file || !this.sourceWidth) return;\n\t\tconst frames: Record<\n\t\t\tstring,\n\t\t\t{ kp: number[] | null; mask: string | null; score?: number }\n\t\t> = {};\n\t\tfor (const [c, r] of this.results) {\n\t\t\tframes[c] = {\n\t\t\t\tkp: r.kp ? Array.from(r.kp, (v) => Math.round(v * 100) / 100) : null,\n\t\t\t\tmask: r.mask ? Buffer.from(r.mask).toString(\"base64\") : null,\n\t\t\t\tscore: r.score,\n\t\t\t};\n\t\t}\n\t\tconst fs = await import(\"node:fs\");\n\t\tconst tmp = `${file}.${process.pid}.tmp`;\n\t\tfs.writeFileSync(\n\t\t\ttmp,\n\t\t\tJSON.stringify({\n\t\t\t\twidth: this.sourceWidth,\n\t\t\t\theight: this.sourceHeight,\n\t\t\t\tcell: this.cell,\n\t\t\t\tframes,\n\t\t\t}),\n\t\t);\n\t\tfs.renameSync(tmp, file);\n\t}\n\n\t/** Subjects live beside the results: large, and only matte layers read them. */\n\tprivate async subjectsPath(): Promise<string | null> {\n\t\tconst file = await this.cachePath();\n\t\treturn file ? file.replace(/\\.json$/, \".subjects.json\") : null;\n\t}\n\n\tprivate async loadSubjects(): Promise<void> {\n\t\tconst file = await this.subjectsPath();\n\t\tif (!file) return;\n\t\ttry {\n\t\t\tconst fs = await import(\"node:fs\");\n\t\t\tif (!fs.existsSync(file)) return;\n\t\t\tconst json = JSON.parse(fs.readFileSync(file, \"utf8\")) as {\n\t\t\t\twidth: number;\n\t\t\t\theight: number;\n\t\t\t\tframes: Record<string, StoredSubject | null>;\n\t\t\t};\n\t\t\tif (this.sourceWidth && json.width !== this.sourceWidth) return;\n\t\t\tif (!this.sourceWidth) this.setSize(json.width, json.height);\n\t\t\tfor (const [c, s] of Object.entries(json.frames)) {\n\t\t\t\tconst lengths = Buffer.from(s?.lengths ?? \"\", \"base64\");\n\t\t\t\tthis.subjects.set(\n\t\t\t\t\tNumber(c),\n\t\t\t\t\ts && {\n\t\t\t\t\t\tcategory: s.category,\n\t\t\t\t\t\tarea: s.area,\n\t\t\t\t\t\t...(s.scores && { scores: s.scores }),\n\t\t\t\t\t\tvalues: new Uint8Array(Buffer.from(s.values, \"base64\")),\n\t\t\t\t\t\tlengths: new Uint32Array(\n\t\t\t\t\t\t\tlengths.buffer.slice(\n\t\t\t\t\t\t\t\tlengths.byteOffset,\n\t\t\t\t\t\t\t\tlengths.byteOffset + lengths.byteLength,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t),\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t} catch {\n\t\t\t// A damaged cache is recomputed.\n\t\t}\n\t}\n\n\tprivate async saveSubjects(): Promise<void> {\n\t\tthis.unsavedSubjects = 0;\n\t\tconst file = await this.subjectsPath();\n\t\tif (!file || !this.sourceWidth) return;\n\t\tconst frames: Record<string, StoredSubject | null> = {};\n\t\tfor (const [c, s] of this.subjects) {\n\t\t\tframes[c] = s && {\n\t\t\t\tcategory: s.category,\n\t\t\t\tarea: s.area,\n\t\t\t\t...(s.scores && { scores: s.scores }),\n\t\t\t\tvalues: Buffer.from(s.values).toString(\"base64\"),\n\t\t\t\tlengths: Buffer.from(\n\t\t\t\t\ts.lengths.buffer,\n\t\t\t\t\ts.lengths.byteOffset,\n\t\t\t\t\ts.lengths.byteLength,\n\t\t\t\t).toString(\"base64\"),\n\t\t\t};\n\t\t}\n\t\tconst fs = await import(\"node:fs\");\n\t\tconst tmp = `${file}.${process.pid}.tmp`;\n\t\tfs.writeFileSync(\n\t\t\ttmp,\n\t\t\tJSON.stringify({\n\t\t\t\twidth: this.sourceWidth,\n\t\t\t\theight: this.sourceHeight,\n\t\t\t\tframes,\n\t\t\t}),\n\t\t);\n\t\tfs.renameSync(tmp, file);\n\t}\n}\n\n/**\n * The person in a {@link ClipVision}: pose keypoints and silhouette at any\n * composition frame, in source pixels or, after `place()`, composition\n * pixels. Reads are synchronous; the frame must be analysed (it is while\n * rendering, inside a live physics world, or after `await clip.ready(frame)`).\n */\nexport class PersonTrack {\n\t/** @internal */\n\tconstructor(\n\t\treadonly clip: ClipVision,\n\t\tprivate readonly t?: Transform,\n\t\tprivate readonly placement?: PersonPlacement,\n\t) {}\n\n\t/** The same person in composition pixels for a clip laid out at `placement`. */\n\tplace(placement: PersonPlacement): PersonTrack {\n\t\treturn new PersonTrack(this.clip, undefined, placement);\n\t}\n\n\tprivate transform(): Transform {\n\t\tif (this.t) return this.t;\n\t\tconst p = this.placement;\n\t\tconst { width: sw, height: sh } = this.clip.size();\n\t\tif (!p || !sw) return { sx: 1, sy: 1, ox: 0, oy: 0 };\n\t\tlet sx = p.width / sw;\n\t\tlet sy = p.height / sh;\n\t\tif (p.fit !== \"fill\") {\n\t\t\tconst s = p.fit === \"contain\" ? Math.min(sx, sy) : Math.max(sx, sy);\n\t\t\tsx = s;\n\t\t\tsy = s;\n\t\t}\n\t\treturn {\n\t\t\tsx,\n\t\t\tsy,\n\t\t\tox: (p.x ?? 0) + (p.width - sw * sx) / 2,\n\t\t\toy: (p.y ?? 0) + (p.height - sh * sy) / 2,\n\t\t};\n\t}\n\n\t/** A keypoint at a composition frame (fractional frames interpolate). */\n\tpoint(\n\t\tname: PoseKeypointName,\n\t\tframe: number,\n\t): { x: number; y: number; visibility: number } {\n\t\tconst k = keypointIndex(name);\n\t\tconst c = this.clip.clipFrame(frame);\n\t\tconst c0 = Math.floor(c);\n\t\tconst u = c - c0;\n\t\tconst a = this.clip.keypoint(k, c0);\n\t\tconst b = u > 0 ? this.clip.keypoint(k, c0 + 1) : a;\n\t\tconst t = this.transform();\n\t\treturn {\n\t\t\tx: (a[0] + (b[0] - a[0]) * u) * t.sx + t.ox,\n\t\t\ty: (a[1] + (b[1] - a[1]) * u) * t.sy + t.oy,\n\t\t\tvisibility: a[2] + (b[2] - a[2]) * u,\n\t\t};\n\t}\n\n\t/** Signals for a keypoint, for `.signal(\"x\", …)`; read while rendering. */\n\tsignals(name: PoseKeypointName): {\n\t\tx: FrameSignal<number>;\n\t\ty: FrameSignal<number>;\n\t\tvisibility: FrameSignal<number>;\n\t} {\n\t\tconst read = (axis: \"x\" | \"y\" | \"visibility\") =>\n\t\t\tSignal.builder({\n\t\t\t\ttype: \"custom\",\n\t\t\t\tfn: (ctx) => this.point(name, ctx.frame)[axis],\n\t\t\t}) as FrameSignal<number>;\n\t\treturn { x: read(\"x\"), y: read(\"y\"), visibility: read(\"visibility\") };\n\t}\n\n\t/**\n\t * @internal The softened silhouette grid at a composition frame and how\n\t * placed px map onto it (`cell = (px − origin) / scale − 0.5`), for GPU\n\t * consumers such as particles. Null when no person was found.\n\t */\n\tsilhouetteGrid(frame: number): {\n\t\tdata: Float32Array;\n\t\twidth: number;\n\t\theight: number;\n\t\toriginX: number;\n\t\toriginY: number;\n\t\tscaleX: number;\n\t\tscaleY: number;\n\t} | null {\n\t\tconst grid = this.clip.blurredMask(Math.round(this.clip.clipFrame(frame)));\n\t\tif (!grid) return null;\n\t\tconst { cell, width, height } = this.clip.grid();\n\t\tconst t = this.transform();\n\t\treturn {\n\t\t\tdata: grid,\n\t\t\twidth,\n\t\t\theight,\n\t\t\toriginX: t.ox,\n\t\t\toriginY: t.oy,\n\t\t\tscaleX: cell * t.sx,\n\t\t\tscaleY: cell * t.sy,\n\t\t};\n\t}\n\n\t/**\n\t * The silhouette near a point at a composition frame: `alpha` 0–1 (softened\n\t * over a few cells; inside > 0.5) and its gradient `gx`, `gy` per px,\n\t * pointing into the body. Push things out with `-gradient`.\n\t */\n\tsample(\n\t\tframe: number,\n\t\tx: number,\n\t\ty: number,\n\t): { alpha: number; gx: number; gy: number } {\n\t\tconst grid = this.clip.blurredMask(Math.round(this.clip.clipFrame(frame)));\n\t\tif (!grid) return { alpha: 0, gx: 0, gy: 0 };\n\t\tconst { cell, width: w, height: h } = this.clip.grid();\n\t\tconst t = this.transform();\n\t\tconst cx = (x - t.ox) / t.sx / cell - 0.5;\n\t\tconst cy = (y - t.oy) / t.sy / cell - 0.5;\n\t\tconst read = (gx: number, gy: number) =>\n\t\t\tgx < 0 || gy < 0 || gx >= w || gy >= h ? 0 : grid[gy * w + gx];\n\t\tconst bil = (px: number, py: number) => {\n\t\t\tconst x0 = Math.floor(px);\n\t\t\tconst y0 = Math.floor(py);\n\t\t\tconst ux = px - x0;\n\t\t\tconst uy = py - y0;\n\t\t\tconst a = read(x0, y0) + (read(x0 + 1, y0) - read(x0, y0)) * ux;\n\t\t\tconst b =\n\t\t\t\tread(x0, y0 + 1) + (read(x0 + 1, y0 + 1) - read(x0, y0 + 1)) * ux;\n\t\t\treturn a + (b - a) * uy;\n\t\t};\n\t\treturn {\n\t\t\talpha: bil(cx, cy),\n\t\t\tgx: (bil(cx + 1, cy) - bil(cx - 1, cy)) / (2 * cell * t.sx),\n\t\t\tgy: (bil(cx, cy + 1) - bil(cx, cy - 1)) / (2 * cell * t.sy),\n\t\t};\n\t}\n}\n\nfunction keypointIndex(name: PoseKeypointName): number {\n\tconst i = COCO17_KEYPOINT_NAMES.indexOf(name);\n\tif (i < 0) {\n\t\tthrow new Error(\n\t\t\t`Unknown keypoint \"${name}\". Use one of ${COCO17_KEYPOINT_NAMES.join(\", \")}.`,\n\t\t);\n\t}\n\treturn i;\n}\n\n/** RGBA pixels of a decoded frame (headless buffer, or a canvas in the browser). */\nasync function decodedPixels(\n\tframe: {\n\t\twidth: number;\n\t\theight: number;\n\t\tbuffer?: Uint8Array;\n\t\tcanvas?: unknown;\n\t} | null,\n): Promise<{\n\tdata: Uint8Array | Uint8ClampedArray;\n\twidth: number;\n\theight: number;\n} | null> {\n\tif (!frame || frame.width <= 0) return null;\n\tif (frame.buffer)\n\t\treturn { data: frame.buffer, width: frame.width, height: frame.height };\n\tconst canvas = frame.canvas as\n\t\t| {\n\t\t\t\tgetContext(type: \"2d\"): {\n\t\t\t\t\tgetImageData(\n\t\t\t\t\t\tx: number,\n\t\t\t\t\t\ty: number,\n\t\t\t\t\t\tw: number,\n\t\t\t\t\t\th: number,\n\t\t\t\t\t): { data: Uint8ClampedArray };\n\t\t\t\t} | null;\n\t\t }\n\t\t| undefined;\n\tconst ctx = canvas?.getContext(\"2d\");\n\tif (!ctx) return null;\n\treturn {\n\t\tdata: ctx.getImageData(0, 0, frame.width, frame.height).data,\n\t\twidth: frame.width,\n\t\theight: frame.height,\n\t};\n}\n\ntype Segmentation = Awaited<ReturnType<VisionRunner[\"segment\"]>>;\n\n/**\n * The largest person's mask, plus instances that overlap it and are no more\n * than twice its size (a flowing dress often comes back as \"kite\").\n */\nfunction personSilhouette(seg: Segmentation): Uint8Array | undefined {\n\treturn mergeSubjectMask(seg.masks, {\n\t\tclasses: [\"person\"],\n\t\toverlap: 0.2,\n\t\tmaxGrowth: 3.5,\n\t})?.mask;\n}\n\nfunction maskSum(m: Uint8Array | null | undefined): number {\n\tif (!m) return 0;\n\tlet s = 0;\n\tfor (let i = 0; i < m.length; i++) s += m[i];\n\treturn s;\n}\n\n/**\n * Bridges 1–2 frame segmentation part dropouts (e.g. a fast-spinning skirt\n * missed on a single frame) across the smoothing window.\n */\nfunction bridgedMask(\n\tresults: Map<number, FrameResult>,\n\tc: number,\n\tsmoothing: number,\n): Uint8Array | null {\n\tconst base = results.get(c)?.mask ?? null;\n\tif (smoothing <= 0) return base;\n\tconst baseSum = maskSum(base);\n\tlet prevFrame = -1;\n\tlet prevMask: Uint8Array | null = null;\n\tlet nextFrame = -1;\n\tlet nextMask: Uint8Array | null = null;\n\tconst threshold = Math.max(1000, baseSum * 1.35);\n\n\tfor (let d = 1; d <= smoothing + 1; d++) {\n\t\tif (prevFrame < 0 && c - d >= 0) {\n\t\t\tconst m = results.get(c - d)?.mask ?? null;\n\t\t\tif (maskSum(m) > threshold) {\n\t\t\t\tprevFrame = c - d;\n\t\t\t\tprevMask = m;\n\t\t\t}\n\t\t}\n\t\tif (nextFrame < 0) {\n\t\t\tconst m = results.get(c + d)?.mask ?? null;\n\t\t\tif (maskSum(m) > threshold) {\n\t\t\t\tnextFrame = c + d;\n\t\t\t\tnextMask = m;\n\t\t\t}\n\t\t}\n\t}\n\tif (!prevMask && !nextMask) return base;\n\tconst ref = prevMask ?? nextMask;\n\tif (!ref) return base;\n\tconst out = base ? new Uint8Array(base) : new Uint8Array(ref.length);\n\tif (prevMask && nextMask && nextFrame > prevFrame) {\n\t\tconst u = (c - prevFrame) / (nextFrame - prevFrame);\n\t\tfor (let i = 0; i < out.length; i++) {\n\t\t\tconst v = Math.round(prevMask[i] + (nextMask[i] - prevMask[i]) * u);\n\t\t\tif (v > out[i]) out[i] = v;\n\t\t}\n\t} else {\n\t\tfor (let i = 0; i < out.length; i++) {\n\t\t\tif (ref[i] > out[i]) out[i] = ref[i];\n\t\t}\n\t}\n\treturn out;\n}\n\nfunction downsampleMean(\n\tsrc: Uint8Array,\n\tw: number,\n\th: number,\n\tcell: number,\n\tdst: Uint8Array,\n\tmw: number,\n\tmh: number,\n): void {\n\tfor (let my = 0; my < mh; my++) {\n\t\tfor (let mx = 0; mx < mw; mx++) {\n\t\t\tlet sum = 0;\n\t\t\tlet n = 0;\n\t\t\tfor (let y = my * cell; y < Math.min(h, (my + 1) * cell); y++) {\n\t\t\t\tfor (let x = mx * cell; x < Math.min(w, (mx + 1) * cell); x++) {\n\t\t\t\t\tsum += src[y * w + x];\n\t\t\t\t\tn++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdst[my * mw + mx] = n ? Math.round(sum / n) : 0;\n\t\t}\n\t}\n}\n\n/** A mask as (value, run length) pairs: long flat runs with soft edges. */\nfunction encodeRuns(mask: Uint8Array): {\n\tvalues: Uint8Array;\n\tlengths: Uint32Array;\n} {\n\tlet runs = 0;\n\tfor (let i = 1; i <= mask.length; i++)\n\t\tif (i === mask.length || mask[i] !== mask[i - 1]) runs++;\n\tconst values = new Uint8Array(runs);\n\tconst lengths = new Uint32Array(runs);\n\tlet r = 0;\n\tlet start = 0;\n\tfor (let i = 1; i <= mask.length; i++) {\n\t\tif (i === mask.length || mask[i] !== mask[start]) {\n\t\t\tvalues[r] = mask[start];\n\t\t\tlengths[r++] = i - start;\n\t\t\tstart = i;\n\t\t}\n\t}\n\treturn { values, lengths };\n}\n\nfunction decodeRuns(\n\truns: { values: Uint8Array; lengths: Uint32Array },\n\tsize: number,\n): Uint8Array {\n\tconst out = new Uint8Array(size);\n\tlet at = 0;\n\tfor (let r = 0; r < runs.values.length; r++) {\n\t\tconst end = Math.min(size, at + runs.lengths[r]);\n\t\tif (runs.values[r] !== 0) out.fill(runs.values[r], at, end);\n\t\tat = end;\n\t}\n\treturn out;\n}\n\n/** Separable box blur to 0–1, so gradients reach a little past the edge. */\nfunction boxBlur(\n\tsrc: Uint8Array,\n\tw: number,\n\th: number,\n\tr: number,\n): Float32Array {\n\tconst tmp = new Float32Array(w * h);\n\tconst dst = new Float32Array(w * h);\n\tfor (let y = 0; y < h; y++) {\n\t\tfor (let x = 0; x < w; x++) {\n\t\t\tlet s = 0;\n\t\t\tlet n = 0;\n\t\t\tfor (let k = -r; k <= r; k++) {\n\t\t\t\tconst xx = x + k;\n\t\t\t\tif (xx >= 0 && xx < w) {\n\t\t\t\t\ts += src[y * w + xx];\n\t\t\t\t\tn++;\n\t\t\t\t}\n\t\t\t}\n\t\t\ttmp[y * w + x] = s / n / 255;\n\t\t}\n\t}\n\tfor (let y = 0; y < h; y++) {\n\t\tfor (let x = 0; x < w; x++) {\n\t\t\tlet s = 0;\n\t\t\tlet n = 0;\n\t\t\tfor (let k = -r; k <= r; k++) {\n\t\t\t\tconst yy = y + k;\n\t\t\t\tif (yy >= 0 && yy < h) {\n\t\t\t\t\ts += tmp[yy * w + x];\n\t\t\t\t\tn++;\n\t\t\t\t}\n\t\t\t}\n\t\t\tdst[y * w + x] = s / n;\n\t\t}\n\t}\n\treturn dst;\n}\n\ntype SeedFrame = {\n\tkp: number[] | null;\n\tmask: Uint8Array | null;\n\t/** Source-sized subject mask for render-time mattes; null = no subject. */\n\tsubject?: Uint8Array | null;\n};\n\n/** @internal Test hook: a clip whose results are given instead of computed. */\nexport function clipVisionFromResults(\n\tfps: number,\n\tsize: { width: number; height: number; cell: number },\n\tframes: SeedFrame[],\n\toptions: ClipVisionOptions = {},\n): ClipVision {\n\tconst clip = new ClipVision(\"memory\", fps, {\n\t\t...options,\n\t\tmaskCell: size.cell,\n\t\tcacheDir: false,\n\t});\n\treturn seedClipVision(clip, size, frames);\n}\n\n/** @internal Test hook: gives a clip's per-frame results instead of computing them. */\nexport function seedClipVision(\n\tclip: ClipVision,\n\tsize: { width: number; height: number },\n\tframes: SeedFrame[],\n): ClipVision {\n\tconst c = clip as unknown as {\n\t\tsetSize(w: number, h: number): void;\n\t\tresults: Map<number, FrameResult>;\n\t\tsubjects: Map<number, SubjectResult | null>;\n\t};\n\tc.setSize(size.width, size.height);\n\tframes.forEach((f, i) => {\n\t\tc.results.set(i, {\n\t\t\tkp: f.kp ? Float32Array.from(f.kp) : null,\n\t\t\tmask: f.mask,\n\t\t});\n\t\tif (f.subject === undefined) return;\n\t\tlet area = 0;\n\t\tfor (const v of f.subject ?? []) area += v;\n\t\tc.subjects.set(\n\t\t\ti,\n\t\t\tf.subject && {\n\t\t\t\tcategory: \"person\",\n\t\t\t\tarea: Math.round(area / 255),\n\t\t\t\t...encodeRuns(f.subject),\n\t\t\t},\n\t\t);\n\t});\n\treturn clip;\n}\n\n/** A stored subject as 0/255 alpha: label maps merge every track, or keep track `id` only. */\nfunction subjectAlpha(\n\tstored: SubjectResult,\n\tsize: number,\n\tid?: number,\n): Uint8Array {\n\tconst values = decodeRuns(stored, size);\n\tif (!stored.scores) return values;\n\treturn values.map((label) =>\n\t\t(id === undefined ? label > 0 : label === id) ? 255 : 0,\n\t);\n}\n\n/** Every track's mask merged, for matching one pose to the whole selection. */\nfunction unionMask(\n\tobjects: readonly Pick<Sam3ObjectResult, \"mask\">[],\n\timage: { width: number; height: number },\n): Uint8Array {\n\tconst union = new Uint8Array(image.width * image.height);\n\tfor (const { mask } of objects)\n\t\tfor (let i = 0; i < union.length; i++)\n\t\t\tunion[i] = Math.max(union[i] ?? 0, mask[i] ?? 0);\n\treturn union;\n}\n","import {\n\ttype MediaSignalResolver,\n\tmediaSignalSampler,\n\tsampleMediaTimeSignal,\n} from \"@framefields/compositions/program\";\nimport {\n\ttype FrameContext,\n\tMediaSignalRecorder,\n\ttype MediaTimeSignalRemap,\n\ttype ResolvedMediaTimeRemap,\n} from \"@framefields/core\";\n\ninterface Entry {\n\tbinding: MediaTimeSignalRemap;\n\tlive: boolean;\n\tcompositionFrames: number;\n\tresolved: ResolvedMediaTimeRemap;\n}\n\n/**\n * The timing histories behind a composition's signal `timeRemap`s. Each layer\n * resolves to one history shared by every compile, so video, audio, vision and\n * preview read the same source clock. Without frame hooks nothing can change\n * a signal mid-render, so it is sampled up front. With hooks the signal is\n * live: each boundary is recorded once, after its frame's hooks, in frame\n * order, and replayed for seeks and audio.\n */\nexport class MediaSignalTimeline {\n\tprivate readonly entries = new Map<string, Entry>();\n\tprivate reached = -1;\n\n\tconstructor(private readonly fps: number) {}\n\n\tresolver(options: {\n\t\tlive: boolean;\n\t\tcompositionDurationFrames: number;\n\t\tsignals: Record<string, unknown>;\n\t}): MediaSignalResolver {\n\t\tconst { live, compositionDurationFrames } = options;\n\t\tconst clock = {\n\t\t\tfps: this.fps,\n\t\t\tcompositionDurationFrames,\n\t\t\tsignals: options.signals,\n\t\t};\n\t\treturn (binding, layer) => {\n\t\t\tconst key = `${layer.id}\\u0000${layer.startFrame}\\u0000${layer.durationFrames}`;\n\t\t\tconst cached = this.entries.get(key);\n\t\t\tif (\n\t\t\t\tcached &&\n\t\t\t\tcached.live === live &&\n\t\t\t\tcached.compositionFrames === compositionDurationFrames &&\n\t\t\t\tsameBinding(cached.binding, binding)\n\t\t\t)\n\t\t\t\treturn cached.resolved;\n\t\t\tconst resolved: ResolvedMediaTimeRemap = live\n\t\t\t\t? {\n\t\t\t\t\t\tkind: \"recorded\",\n\t\t\t\t\t\trecorder: new MediaSignalRecorder({\n\t\t\t\t\t\t\tmode: binding.mode,\n\t\t\t\t\t\t\tfps: this.fps,\n\t\t\t\t\t\t\tstartFrame: layer.startFrame,\n\t\t\t\t\t\t\tdurationFrames: layer.durationFrames,\n\t\t\t\t\t\t\tsourceStartSec: binding.sourceStartSec,\n\t\t\t\t\t\t\tsample: mediaSignalSampler(binding, clock),\n\t\t\t\t\t\t}),\n\t\t\t\t\t}\n\t\t\t\t: sampleMediaTimeSignal(binding, layer, clock);\n\t\t\tthis.entries.set(key, {\n\t\t\t\tbinding,\n\t\t\t\tlive,\n\t\t\t\tcompositionFrames: compositionDurationFrames,\n\t\t\t\tresolved,\n\t\t\t});\n\t\t\treturn resolved;\n\t\t};\n\t}\n\n\t/**\n\t * Frames to run, in order, before `frame` so live histories have no gaps:\n\t * a seek forward replays the frames it skipped. A seek back replays\n\t * nothing; recorded history is reused.\n\t */\n\tframesBefore(frame: number): number[] {\n\t\tconst needs = this.recorders().some(\n\t\t\t(r) => !r.complete && r.nextFrame < frame,\n\t\t);\n\t\tif (!needs) return [];\n\t\tconst frames: number[] = [];\n\t\tfor (let f = this.reached + 1; f < frame; f++) frames.push(f);\n\t\treturn frames;\n\t}\n\n\t/** Let live signals be read through `frame` (no look-ahead past the clock). */\n\tadvance(frame: number): void {\n\t\tfor (const r of this.recorders()) r.advance(frame);\n\t}\n\n\t/**\n\t * Record each live boundary at `frame` once its hooks have run. At the\n\t * composition's last frame, layers that outlive it hold their last value.\n\t */\n\treach(frame: number): void {\n\t\tif (frame > this.reached) this.reached = frame;\n\t\tfor (const [, entry] of this.entries) {\n\t\t\tif (entry.resolved.kind !== \"recorded\") continue;\n\t\t\tconst recorder = entry.resolved.recorder;\n\t\t\trecorder.ensure(frame);\n\t\t\tif (\n\t\t\t\tframe >= entry.compositionFrames - 1 &&\n\t\t\t\t!recorder.complete &&\n\t\t\t\trecorder.nextFrame > recorder.startFrame\n\t\t\t)\n\t\t\t\trecorder.close();\n\t\t}\n\t}\n\n\t/** True while a live history still has boundaries to record. */\n\tget pending(): boolean {\n\t\treturn this.recorders().some((r) => !r.complete);\n\t}\n\n\tprivate recorders(): MediaSignalRecorder[] {\n\t\tconst out: MediaSignalRecorder[] = [];\n\t\tfor (const { resolved } of this.entries.values())\n\t\t\tif (resolved.kind === \"recorded\") out.push(resolved.recorder);\n\t\treturn out;\n\t}\n}\n\nfunction sameBinding(\n\ta: MediaTimeSignalRemap,\n\tb: MediaTimeSignalRemap,\n): boolean {\n\treturn (\n\t\ta.signal === b.signal &&\n\t\ta.mode === b.mode &&\n\t\ta.sourceStartSec === b.sourceStartSec\n\t);\n}\n\n/** The frame context of another frame on the same clock. */\nexport function contextAtFrame(ctx: FrameContext, frame: number): FrameContext {\n\tconst time = ctx.fps > 0 ? frame / ctx.fps : 0;\n\treturn {\n\t\t...ctx,\n\t\tframe,\n\t\ttime,\n\t\tprogress:\n\t\t\tctx.duration > 0 ? Math.max(0, Math.min(1, time / ctx.duration)) : 0,\n\t};\n}\n\nconst remapIds = new WeakMap<object, number>();\nlet nextRemapId = 0;\n\n/**\n * A key equal for the same source clock: by value for a fixed map, by\n * identity for a resolved signal history.\n */\nexport function remapKey(map: ResolvedMediaTimeRemap | undefined): string {\n\tif (!map) return \"\";\n\tif (map.kind === \"rate\" || map.kind === \"keyframes\")\n\t\treturn JSON.stringify(map);\n\tconst target = map.kind === \"sampled\" ? map.history : map.recorder;\n\tlet id = remapIds.get(target);\n\tif (id === undefined) {\n\t\tid = ++nextRemapId;\n\t\tremapIds.set(target, id);\n\t}\n\treturn `${map.kind}:${id}`;\n}\n","import {\n\ttype AnimatableProp,\n\ttype KeyframeTuple,\n\tLayerAnimation,\n} from \"@framefields/compositions/program\";\nimport { type FrameContext, type FrameSignal, Signal } from \"@framefields/core\";\nimport type { SimBody, SimWorld } from \"./backend.js\";\n\n/**\n * A value read every simulated frame: a number, a signal (sampled at the\n * composition frame, like `.signal()` tracks), or `(frame) => value` where\n * `frame` is the composition frame.\n */\nexport type PhysicsDriver =\n\t| number\n\t| ((frame: number) => number)\n\t| { get(ctx?: FrameContext): number };\n\nexport interface PhysicsWorldOptions {\n\t/** Composition frame rate. */\n\tfps: number;\n\t/** How many frames to simulate. Signals hold the last frame afterwards. */\n\tframes: number;\n\t/**\n\t * Composition frame the simulation's frame 0 lands on (default 0). Set it\n\t * to a scene's start so a world inside that scene starts with it.\n\t */\n\tstartFrame?: number;\n\t/** Pixels per physics meter (default 100). Only changes how stiff and heavy things feel. */\n\tpixelsPerMeter?: number;\n\t/** Solver steps per frame (default 4). Raise for fast, thin or stacked bodies. */\n\tsubsteps?: number;\n\t/** Frames an impact envelope takes to fall to ~37% (default 8). */\n\timpactDecay?: number;\n\t/** Velocity change, px/s, that reads as impact 1 (default 1500). */\n\timpactReference?: number;\n}\n\nexport interface BodyCommonOptions {\n\t/** `\"dynamic\"` (default) falls and collides; `\"fixed\"` never moves; `\"kinematic\"` follows `follow` and pushes others. */\n\ttype?: \"dynamic\" | \"fixed\" | \"kinematic\";\n\t/** Bounciness, 0–1 (default 0.3). */\n\trestitution?: number;\n\t/** Default 0.6. */\n\tfriction?: number;\n\t/** Mass per area/volume (default 1). Heavier bodies push lighter ones. */\n\tdensity?: number;\n\t/** Velocity damping per second (default 0). */\n\tlinearDamping?: number;\n\t/** Spin damping per second (default 0). */\n\tangularDamping?: number;\n\t/** Multiplies world gravity for this body (default 1; 0 floats). */\n\tgravityScale?: number;\n\t/** Never rotates. */\n\tlockRotation?: boolean;\n\t/** Continuous collision detection for very fast bodies (default false). */\n\tccd?: boolean;\n\t/** Collides with nothing; still moves, still reports contacts (triggers). */\n\tsensor?: boolean;\n\t/** Simulation frame the body wakes up; it holds its place before (default 0). */\n\tstartFrame?: number;\n\t/**\n\t * How the result reaches the layer: `\"signals\"` (default) binds the\n\t * body's signals, `\"keyframes\"` writes plain keyframes, `\"none\"` leaves\n\t * the layer alone (read the signals yourself).\n\t */\n\toutput?: \"signals\" | \"keyframes\" | \"none\";\n}\n\n/** What `world.live()` needs from a composition. */\nexport interface LiveHost {\n\tonPrepareFrame(\n\t\tcallback: (ctx: { frame: number }) => Promise<void> | void,\n\t): unknown;\n\tprepareVision?(frame: number): Promise<void>;\n}\n\ninterface Stepper<B, V, R> {\n\t/** Last simulated frame, relative to the world's start. */\n\tcurrent: number;\n\tfreed: boolean;\n\tbySim: Map<SimBody<V, R>, B>;\n\tkinematicFrom: Map<B, { position: V; rotation: R }>;\n\t/** Impact envelope level per body after `current`. */\n\tlevel: Map<B, number>;\n}\n\nexport interface PhysicsCollision<B> {\n\t/** Composition frame of first contact. */\n\tframe: number;\n\t/** The other body. */\n\twith: B;\n\t/** Velocity change of the harder-hit body, px/s. */\n\tspeed: number;\n}\n\nexport interface PhysicsBakeOptions {\n\t/** Largest error a dropped keyframe may leave, px (default 0.25). Degrees use a fifth of it. */\n\ttolerance?: number;\n}\n\nconst CHANNEL_TOLERANCE_SCALE: Record<string, number> = {\n\trotation: 0.2,\n\trotateX: 0.2,\n\trotateY: 0.2,\n\trotateZ: 0.2,\n};\n\nexport function sampleDriver(\n\tdriver: PhysicsDriver,\n\tframe: number,\n\tfps: number,\n): number {\n\tif (typeof driver === \"number\") return driver;\n\tif (typeof driver === \"function\") return driver(frame);\n\tconst time = frame / fps;\n\treturn driver.get({\n\t\tframe,\n\t\tfps,\n\t\ttime,\n\t\tduration: 0,\n\t\tdurationMs: 0,\n\t\tprogress: 0,\n\t\tdeltaTime: 1 / fps,\n\t});\n}\n\n/** Shortest-path angle continuation so rotation never jumps by 360. */\nexport function unwrapDegrees(previous: number, next: number): number {\n\tlet d = next - previous;\n\td -= Math.round(d / 360) * 360;\n\treturn previous + d;\n}\n\n/**\n * Ramer–Douglas–Peucker over one channel: the fewest linear keyframes that\n * stay within `tolerance` of every simulated frame.\n */\nexport function simplifyKeys(\n\tvalues: ArrayLike<number>,\n\ttolerance: number,\n): KeyframeTuple[] {\n\tconst n = values.length;\n\tif (n === 0) return [];\n\tconst keep = new Uint8Array(n);\n\tkeep[0] = 1;\n\tkeep[n - 1] = 1;\n\tconst stack: Array<[number, number]> = [[0, n - 1]];\n\twhile (stack.length > 0) {\n\t\tconst [a, b] = stack.pop() as [number, number];\n\t\tlet worst = -1;\n\t\tlet worstErr = tolerance;\n\t\tfor (let i = a + 1; i < b; i++) {\n\t\t\tconst t = (i - a) / (b - a);\n\t\t\tconst lerp = values[a] + (values[b] - values[a]) * t;\n\t\t\tconst err = Math.abs(values[i] - lerp);\n\t\t\tif (err > worstErr) {\n\t\t\t\tworstErr = err;\n\t\t\t\tworst = i;\n\t\t\t}\n\t\t}\n\t\tif (worst >= 0) {\n\t\t\tkeep[worst] = 1;\n\t\t\tstack.push([a, worst], [worst, b]);\n\t\t}\n\t}\n\tconst keys: KeyframeTuple[] = [];\n\tfor (let i = 0; i < n; i++) {\n\t\tif (keep[i]) keys.push([i, round4(values[i]), \"none\"]);\n\t}\n\t// A constant channel needs a single key.\n\tif (keys.length === 2 && keys[0][1] === keys[1][1]) keys.pop();\n\treturn keys;\n}\n\nfunction round4(v: number): number {\n\treturn Math.round(v * 1e4) / 1e4;\n}\n\n/**\n * Per-frame recordings of one body, indexed by composition frame. Arrays are\n * filled when the world simulates; reading a signal before that simulates.\n */\nexport class Recording {\n\treadonly channels = new Map<string, Float32Array>();\n\tprivate readonly signals = new Map<string, FrameSignal<number>>();\n\n\tconstructor(\n\t\treadonly length: number,\n\t\tprivate readonly fps: number,\n\t\tprivate readonly ensure: () => void,\n\t) {}\n\n\tchannel(name: string): Float32Array {\n\t\tlet arr = this.channels.get(name);\n\t\tif (!arr) {\n\t\t\tarr = new Float32Array(this.length);\n\t\t\tthis.channels.set(name, arr);\n\t\t}\n\t\treturn arr;\n\t}\n\n\t/**\n\t * A per-frame signal over a channel. Creating it does nothing; the first\n\t * value read runs the simulation (offline worlds), so signals can be bound\n\t * while bodies are still being added.\n\t */\n\tsignal(name: string): FrameSignal<number> {\n\t\tlet sig = this.signals.get(name);\n\t\tif (!sig) {\n\t\t\tconst arr = this.channel(name);\n\t\t\tconst fps = this.fps;\n\t\t\tsig = Signal.builder({\n\t\t\t\ttype: \"custom\",\n\t\t\t\tfn: (ctx: { frame: number; fps?: number }) => {\n\t\t\t\t\tthis.ensure();\n\t\t\t\t\tconst f =\n\t\t\t\t\t\tctx.fps && ctx.fps !== fps\n\t\t\t\t\t\t\t? (ctx.frame / ctx.fps) * fps\n\t\t\t\t\t\t\t: ctx.frame;\n\t\t\t\t\tconst i = Math.max(0, Math.min(arr.length - 1, Math.round(f)));\n\t\t\t\t\treturn arr[i];\n\t\t\t\t},\n\t\t\t}) as unknown as FrameSignal<number>;\n\t\t\tthis.signals.set(name, sig);\n\t\t}\n\t\treturn sig;\n\t}\n}\n\n/** What the shared stepping loop needs from a 2D or 3D body. */\nexport interface CoreBody<V extends number[], R> {\n\treadonly sim: SimBody<V, R>;\n\treadonly type: \"dynamic\" | \"fixed\" | \"kinematic\";\n\treadonly startFrame: number;\n\treadonly gravityScale: number;\n\t/** Unset: signals, or keyframes under `bakeKeyframes()`. */\n\treadonly output?: \"signals\" | \"keyframes\" | \"none\";\n\treadonly recording: Recording;\n\treadonly collisions: PhysicsCollision<unknown>[];\n\treadonly layer?: Record<string, unknown>;\n\t/** Kinematic pose (backend units) at a composition frame, if it follows drivers. */\n\tkinematicTarget?(frame: number): { position: V; rotation: R } | undefined;\n\t/** Writes the body's state for one composition frame into its recording. */\n\trecord(index: number, previousIndex: number): void;\n\t/** Props bound to the layer, with the recording channel each one reads. */\n\tboundChannels(): Array<[AnimatableProp, string]>;\n}\n\ninterface ForceEntry<V> {\n\tbody: CoreBody<number[], unknown>;\n\taccel: (frame: number) => V;\n}\n\ninterface ImpulseEntry<V> {\n\tbody: CoreBody<number[], unknown>;\n\tframe: number;\n\tdv: V;\n}\n\n/**\n * Stepping, recording, impacts and output shared by `PhysicsWorld2D` and\n * `PhysicsWorld3D`. V is a vector in backend units (meters).\n */\nexport abstract class WorldCore<\n\tV extends number[],\n\tR,\n\tB extends CoreBody<V, R>,\n> {\n\treadonly fps: number;\n\treadonly frames: number;\n\treadonly startFrame: number;\n\treadonly pixelsPerMeter: number;\n\tprotected readonly substeps: number;\n\tprotected readonly impactDecay: number;\n\tprotected readonly impactReference: number;\n\tprotected readonly bodies: B[] = [];\n\tprotected readonly forces: ForceEntry<V>[] = [];\n\tprotected readonly impulses: ImpulseEntry<V>[] = [];\n\tprotected readonly fields: Array<{\n\t\ttargets?: Set<B>;\n\t\taccel: (body: B, frame: number) => V | null | undefined;\n\t}> = [];\n\tprivate readonly worldRecording: Recording;\n\tprivate readonly allCollisions: Array<PhysicsCollision<B> & { body: B }> = [];\n\t/** No more bodies, joints or forces: the world has started (or finished). */\n\tprivate locked = false;\n\tprivate liveMode = false;\n\tprivate stepper?: Stepper<B, V, R>;\n\tprivate chain: Promise<void> = Promise.resolve();\n\n\tprotected constructor(\n\t\tprotected readonly sim: SimWorld<V, SimBody<V, R>, unknown>,\n\t\tprotected readonly gravity: V,\n\t\toptions: PhysicsWorldOptions,\n\t) {\n\t\tif (!(options.fps > 0)) throw new Error(\"Physics: `fps` must be > 0.\");\n\t\tif (!(options.frames >= 1) || !Number.isInteger(options.frames)) {\n\t\t\tthrow new Error(\"Physics: `frames` must be a positive integer.\");\n\t\t}\n\t\tthis.fps = options.fps;\n\t\tthis.frames = options.frames;\n\t\tthis.startFrame = Math.max(0, Math.round(options.startFrame ?? 0));\n\t\tthis.pixelsPerMeter = options.pixelsPerMeter ?? 100;\n\t\tthis.substeps = Math.max(1, Math.round(options.substeps ?? 4));\n\t\tthis.impactDecay = Math.max(0.5, options.impactDecay ?? 8);\n\t\tthis.impactReference = options.impactReference ?? 1500;\n\t\tthis.worldRecording = this.newRecording();\n\t}\n\n\t/** First contacts so far (all of them once simulated), in frame order. */\n\tget collisions(): ReadonlyArray<PhysicsCollision<B> & { body: B }> {\n\t\tthis.ensureSimulated();\n\t\treturn this.allCollisions;\n\t}\n\n\t/** Loudest impact envelope of any body each frame: camera shake, flashes, hit sounds. */\n\tget impact(): FrameSignal<number> {\n\t\treturn this.worldRecording.signal(\"impact\");\n\t}\n\n\t/** Runs the whole simulation now (once) and binds every body's layer per its `output`. */\n\tsimulate(): this {\n\t\tif (this.liveMode)\n\t\t\tthrow new Error(\n\t\t\t\t\"Physics: this world is live; it steps as frames render.\",\n\t\t\t);\n\t\tthis.ensureSimulated();\n\t\treturn this;\n\t}\n\n\t/** Like {@link simulate}, but writes keyframes for every body whose `output` was left at its default. */\n\tbakeKeyframes(options: PhysicsBakeOptions = {}): this {\n\t\tif (this.locked) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Physics: bakeKeyframes() must come before simulate(), live() or reading any body signal.\",\n\t\t\t);\n\t\t}\n\t\tthis.bakeDefault = options;\n\t\tthis.ensureSimulated();\n\t\treturn this;\n\t}\n\n\t/**\n\t * Steps the world as the composition renders instead of all at once: before\n\t * each frame draws, the world advances to it, after the composition's\n\t * vision clips (`comp.vision`) and any `inputs` have that frame ready. Use\n\t * it when bodies follow a performer, so nothing is analysed up front and a\n\t * preview starts at once. Frames already simulated are kept, so scrubbing\n\t * back costs nothing; jumping ahead simulates the frames in between.\n\t * Signals only; `bakeKeyframes()` needs the whole run up front.\n\t */\n\tlive(\n\t\tcomp: LiveHost,\n\t\toptions: {\n\t\t\tinputs?: ReadonlyArray<{ ready(frame: number): Promise<void> }>;\n\t\t} = {},\n\t): this {\n\t\tif (this.locked) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Physics: live() must come before simulate() or reading any body signal.\",\n\t\t\t);\n\t\t}\n\t\tthis.locked = true;\n\t\tthis.liveMode = true;\n\t\tconst prepare = async (frame: number) => {\n\t\t\tawait comp.prepareVision?.(frame);\n\t\t\tfor (const input of options.inputs ?? []) await input.ready(frame);\n\t\t};\n\t\tthis.prepareInputs = prepare;\n\t\tfor (const body of this.bodies) this.bind(body);\n\t\tcomp.onPrepareFrame((ctx) => this.advanceTo(ctx.frame));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Live worlds: simulates up to composition frame `frame` (no-op when it\n\t * already has). Calls queue, so frames are stepped once, in order.\n\t */\n\tadvanceTo(frame: number): Promise<void> {\n\t\tthis.chain = this.chain.then(async () => {\n\t\t\tconst target = Math.min(\n\t\t\t\tthis.frames - 1,\n\t\t\t\tMath.round(frame) - this.startFrame,\n\t\t\t);\n\t\t\tif (!this.stepper) {\n\t\t\t\tawait this.prepareInputs?.(this.startFrame);\n\t\t\t\tthis.stepper = this.begin();\n\t\t\t}\n\t\t\tconst st = this.stepper;\n\t\t\twhile (st.current < target) {\n\t\t\t\tconst next = st.current + 1;\n\t\t\t\tawait this.prepareInputs?.(this.startFrame + next);\n\t\t\t\tthis.stepFrame(st, next);\n\t\t\t}\n\t\t\tif (st.current === this.frames - 1 && !st.freed) {\n\t\t\t\tst.freed = true;\n\t\t\t\tthis.sim.free();\n\t\t\t}\n\t\t});\n\t\treturn this.chain;\n\t}\n\n\tprivate prepareInputs?: (frame: number) => Promise<void>;\n\tprivate bakeDefault?: PhysicsBakeOptions;\n\n\tprotected newRecording(): Recording {\n\t\treturn new Recording(this.startFrame + this.frames, this.fps, () =>\n\t\t\tthis.ensureSimulated(),\n\t\t);\n\t}\n\n\tprotected assertOpen(): void {\n\t\tif (this.locked) {\n\t\t\tthrow new Error(\n\t\t\t\t\"Physics: the world has already started; add every body, joint and force before simulate(), live() or reading signals.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tprotected addBody(body: B): B {\n\t\tthis.assertOpen();\n\t\tthis.bodies.push(body);\n\t\treturn body;\n\t}\n\n\tprotected addForce(body: B, accel: (frame: number) => V): void {\n\t\tthis.assertOpen();\n\t\tthis.forces.push({\n\t\t\tbody: body as unknown as CoreBody<number[], unknown>,\n\t\t\taccel,\n\t\t});\n\t}\n\n\tprotected addField(\n\t\taccel: (body: B, frame: number) => V | null | undefined,\n\t\ttargets?: readonly B[],\n\t): void {\n\t\tthis.assertOpen();\n\t\tthis.fields.push({ accel, ...(targets && { targets: new Set(targets) }) });\n\t}\n\n\tprotected addImpulse(body: B, frame: number, dv: V): void {\n\t\tthis.assertOpen();\n\t\tthis.impulses.push({\n\t\t\tbody: body as unknown as CoreBody<number[], unknown>,\n\t\t\tframe: Math.round(frame),\n\t\t\tdv,\n\t\t});\n\t}\n\n\tprotected ensureSimulated(): void {\n\t\tif (this.locked) return;\n\t\tthis.locked = true;\n\t\tconst st = this.begin();\n\t\tfor (let f = 1; f < this.frames; f++) this.stepFrame(st, f);\n\t\tst.freed = true;\n\t\tthis.sim.free();\n\t\tfor (const body of this.bodies) this.bind(body);\n\t}\n\n\t/** Records frame 0 and sets every channel to it, so frames not simulated yet hold the start pose. */\n\tprivate begin(): Stepper<B, V, R> {\n\t\tconst { startFrame } = this;\n\t\tconst bodies = this.bodies;\n\t\tconst bySim = new Map<SimBody<V, R>, B>();\n\t\tfor (const b of bodies) bySim.set(b.sim, b);\n\t\tfor (const b of bodies) if (b.startFrame > 0) b.sim.setEnabled(false);\n\t\tconst kinematicFrom = new Map<B, { position: V; rotation: R }>();\n\t\tfor (const b of bodies) {\n\t\t\tb.record(startFrame, -1);\n\t\t\tb.recording.channel(\"impact\");\n\t\t\tconst t = b.kinematicTarget?.(startFrame);\n\t\t\tif (t) kinematicFrom.set(b, t);\n\t\t}\n\t\tthis.worldRecording.channel(\"impact\");\n\t\tfor (const rec of [\n\t\t\t...bodies.map((b) => b.recording),\n\t\t\tthis.worldRecording,\n\t\t]) {\n\t\t\tfor (const arr of rec.channels.values()) arr.fill(arr[startFrame]);\n\t\t}\n\t\treturn {\n\t\t\tcurrent: 0,\n\t\t\tfreed: false,\n\t\t\tbySim,\n\t\t\tkinematicFrom,\n\t\t\tlevel: new Map(bodies.map((b) => [b, 0])),\n\t\t};\n\t}\n\n\tprivate stepFrame(st: Stepper<B, V, R>, f: number): void {\n\t\tconst { fps, startFrame, substeps } = this;\n\t\tconst dt = 1 / (fps * substeps);\n\t\tconst bodies = this.bodies;\n\t\tconst frame = startFrame + f;\n\t\tconst dims = this.gravity.length;\n\t\tconst prevVel = new Map<B, number[]>();\n\t\tfor (const b of bodies) {\n\t\t\t// A body sits at its start pose on its start frame and moves after.\n\t\t\tif (b.startFrame > 0 && f === b.startFrame + 1) b.sim.setEnabled(true);\n\t\t\tprevVel.set(b, b.sim.velocity() as number[]);\n\t\t}\n\t\tconst isActive = (b: B) => b.type === \"dynamic\" && f > b.startFrame;\n\t\t// Velocity each body is expected to gain this frame from gravity,\n\t\t// forces, fields and impulses: anything beyond it came from a contact.\n\t\tconst expected = new Map<B, number[]>();\n\t\tfor (const b of bodies) {\n\t\t\texpected.set(\n\t\t\t\tb,\n\t\t\t\tthis.gravity.map((g) => (isActive(b) ? (g * b.gravityScale) / fps : 0)),\n\t\t\t);\n\t\t}\n\t\tfor (const imp of this.impulses) {\n\t\t\tif (imp.frame !== f) continue;\n\t\t\tconst body = imp.body as unknown as B;\n\t\t\tif (!isActive(body)) continue;\n\t\t\tconst m = body.sim.mass();\n\t\t\tbody.sim.applyImpulse(imp.dv.map((v) => v * m) as V);\n\t\t\tconst e = expected.get(body) as number[];\n\t\t\tfor (let i = 0; i < dims; i++) e[i] += imp.dv[i];\n\t\t}\n\t\tconst frameForces = this.forces\n\t\t\t.filter((fe) => isActive(fe.body as unknown as B))\n\t\t\t.map((fe) => {\n\t\t\t\tconst body = fe.body as unknown as B;\n\t\t\t\tconst a = fe.accel(frame);\n\t\t\t\tconst e = expected.get(body) as number[];\n\t\t\t\tfor (let i = 0; i < dims; i++) e[i] += a[i] / fps;\n\t\t\t\treturn { body, a };\n\t\t\t});\n\t\tconst kinematicTo = new Map<B, { position: V; rotation: R }>();\n\t\tfor (const b of bodies) {\n\t\t\tconst t = b.kinematicTarget?.(frame);\n\t\t\tif (t) kinematicTo.set(b, t);\n\t\t}\n\n\t\tconst started = new Set<string>();\n\t\tconst pairs: Array<[B, B]> = [];\n\t\tfor (let s = 1; s <= substeps; s++) {\n\t\t\tfor (const { body, a } of frameForces) {\n\t\t\t\tconst m = body.sim.mass();\n\t\t\t\tbody.sim.applyImpulse(a.map((v) => v * m * dt) as V);\n\t\t\t}\n\t\t\tfor (const field of this.fields) {\n\t\t\t\tfor (const b of bodies) {\n\t\t\t\t\tif (!isActive(b) || (field.targets && !field.targets.has(b)))\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\tconst a = field.accel(b, frame);\n\t\t\t\t\tif (!a) continue;\n\t\t\t\t\tconst m = b.sim.mass();\n\t\t\t\t\tb.sim.applyImpulse(a.map((v) => v * m * dt) as V);\n\t\t\t\t\tconst e = expected.get(b) as number[];\n\t\t\t\t\tfor (let i = 0; i < dims; i++) e[i] += a[i] * dt;\n\t\t\t\t}\n\t\t\t}\n\t\t\tfor (const [b, to] of kinematicTo) {\n\t\t\t\tconst from = st.kinematicFrom.get(b) ?? to;\n\t\t\t\tconst k = s / substeps;\n\t\t\t\tb.sim.setKinematicTarget(\n\t\t\t\t\tlerpVec(from.position, to.position, k),\n\t\t\t\t\tthis.lerpRotation(from.rotation, to.rotation, k),\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.sim.step(dt);\n\t\t\tfor (const [sa, sb] of this.sim.drainCollisionStarts()) {\n\t\t\t\tconst a = st.bySim.get(sa);\n\t\t\t\tconst b = st.bySim.get(sb);\n\t\t\t\tif (!a || !b) continue;\n\t\t\t\tconst key = `${bodies.indexOf(a)}:${bodies.indexOf(b)}`;\n\t\t\t\tif (started.has(key)) continue;\n\t\t\t\tstarted.add(key);\n\t\t\t\tpairs.push([a, b]);\n\t\t\t}\n\t\t}\n\t\tst.kinematicFrom = kinematicTo;\n\n\t\tfor (const b of bodies) b.record(frame, frame - 1);\n\n\t\tconst raw = new Map<B, number>();\n\t\tif (pairs.length > 0) {\n\t\t\tconst ppm = this.pixelsPerMeter;\n\t\t\tconst hit = (b: B): number => {\n\t\t\t\tif (b.type !== \"dynamic\") return 0;\n\t\t\t\tconst v = b.sim.velocity() as number[];\n\t\t\t\tconst v0 = prevVel.get(b) as number[];\n\t\t\t\tconst e = expected.get(b) as number[];\n\t\t\t\tlet sq = 0;\n\t\t\t\tfor (let i = 0; i < dims; i++) {\n\t\t\t\t\tconst d = v[i] - (v0[i] + e[i]);\n\t\t\t\t\tsq += d * d;\n\t\t\t\t}\n\t\t\t\treturn Math.sqrt(sq) * ppm;\n\t\t\t};\n\t\t\tfor (const [a, b] of pairs) {\n\t\t\t\tconst speed = Math.max(hit(a), hit(b));\n\t\t\t\tfor (const [self, other] of [\n\t\t\t\t\t[a, b],\n\t\t\t\t\t[b, a],\n\t\t\t\t] as const) {\n\t\t\t\t\traw.set(self, Math.max(raw.get(self) ?? 0, speed));\n\t\t\t\t\tconst c = { frame, with: other, speed };\n\t\t\t\t\tself.collisions.push(c as never);\n\t\t\t\t\tif (self === a) this.allCollisions.push({ ...c, body: a });\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Impact envelopes: instant attack, exponential release.\n\t\tconst decay = Math.exp(-1 / this.impactDecay);\n\t\tlet loudest = 0;\n\t\tfor (const b of bodies) {\n\t\t\tconst level = Math.max(\n\t\t\t\t(raw.get(b) ?? 0) / this.impactReference,\n\t\t\t\t(st.level.get(b) ?? 0) * decay,\n\t\t\t);\n\t\t\tst.level.set(b, level);\n\t\t\tb.recording.channel(\"impact\")[frame] = level;\n\t\t\tif (level > loudest) loudest = level;\n\t\t}\n\t\tthis.worldRecording.channel(\"impact\")[frame] = loudest;\n\t\tst.current = f;\n\t}\n\n\tprotected abstract lerpRotation(a: R, b: R, t: number): R;\n\n\tprivate bind(body: B): void {\n\t\tconst layer = body.layer as\n\t\t\t| { animate?: (...a: LayerAnimation[]) => unknown }\n\t\t\t| undefined;\n\t\tconst output = body.output ?? (this.bakeDefault ? \"keyframes\" : \"signals\");\n\t\tif (typeof layer?.animate !== \"function\" || output === \"none\") return;\n\t\tif (body.type === \"fixed\") return;\n\t\tconst channels = body.boundChannels();\n\t\tif (output === \"keyframes\" && this.liveMode) {\n\t\t\tthrow new Error(\n\t\t\t\t'Physics: live worlds bind signals; drop `output: \"keyframes\"` or use simulate().',\n\t\t\t);\n\t\t}\n\t\tif (output === \"signals\") {\n\t\t\tconst anim = LayerAnimation.create();\n\t\t\tfor (const [prop, channel] of channels) {\n\t\t\t\tanim.signal(prop, body.recording.signal(channel));\n\t\t\t}\n\t\t\tlayer.animate(anim);\n\t\t\treturn;\n\t\t}\n\t\tconst tolerance = this.bakeDefault?.tolerance ?? 0.25;\n\t\tconst anim = LayerAnimation.create();\n\t\tfor (const [prop, channel] of channels) {\n\t\t\tconst arr = body.recording.channel(channel);\n\t\t\tconst local = arr.subarray(this.startFrame);\n\t\t\tconst scale = CHANNEL_TOLERANCE_SCALE[prop] ?? 1;\n\t\t\tanim.keys(prop, simplifyKeys(local, tolerance * scale));\n\t\t}\n\t\tlayer.animate(anim);\n\t}\n}\n\nfunction lerpVec<V extends number[]>(a: V, b: V, t: number): V {\n\treturn a.map((v, i) => v + (b[i] - v) * t) as V;\n}\n","import { Effect } from \"@framefields/core\";\nimport type {\n\tEmitterShape,\n\tParticleBlend,\n\tParticleBounds,\n\tParticleFrame,\n\tParticleProgram,\n\tParticleShape,\n\tParticleStatic,\n} from \"@framefields/node-particles\";\nimport { parseColor } from \"@framefields/webgpu-renderers\";\nimport type { PersonTrack } from \"./clip-vision.js\";\nimport { type PhysicsDriver, sampleDriver } from \"./physics/core.js\";\n\nexport type { EmitterShape, ParticleBlend, ParticleBounds, ParticleShape };\n\ntype Range = number | [number, number];\n\nexport interface ParticlesOptions {\n\t/** Particle layer box in composition px (the particles' own space; default the whole canvas). */\n\tx?: number;\n\ty?: number;\n\twidth: number;\n\theight: number;\n\tid?: string;\n\tstartFrame?: number;\n\tdurationFrames?: number;\n\tzIndex?: number;\n\t/** Most particles alive at once (default 20000). Costs GPU memory, not time when idle. */\n\tmax?: number;\n\tseed?: number;\n\temitter?: {\n\t\t/** `\"rect\"` (default, the whole layer), `\"point\"`, `\"line\"`, `\"circle\"` (area) or `\"ring\"` (edge). Layer px. */\n\t\tshape?: EmitterShape;\n\t\t/** Emitter position (layer px). A driver moves it: `(f) => person.point(\"rightWrist\", f).x` paints with light. */\n\t\tx?: PhysicsDriver;\n\t\ty?: PhysicsDriver;\n\t\twidth?: number;\n\t\theight?: number;\n\t\tradius?: number;\n\t\t/** Aim away from the emitter's center instead of along `direction`. */\n\t\tradial?: boolean;\n\t\t/** Particles per second (default 1000); a driver for bursts of activity. */\n\t\trate?: PhysicsDriver;\n\t\t/** Extra particles at given layer frames. */\n\t\tbursts?: Array<{ frame: number; count: number }>;\n\t};\n\t/** Seconds each particle lives (default [2, 4]). */\n\tlifetime?: Range;\n\t/** Launch speed, px/s (default [40, 160]). */\n\tspeed?: Range;\n\t/** Launch direction, degrees (0 = right, -90 = up; default -90). */\n\tdirection?: number;\n\t/** Spread around `direction`, degrees (default 360). */\n\tspread?: number;\n\t/** px/s². A single driver pulls down. */\n\tgravity?: PhysicsDriver | [PhysicsDriver, PhysicsDriver];\n\t/** Velocity damping per second (default 0.4). Higher reads as thicker air or liquid. */\n\tdrag?: PhysicsDriver;\n\t/** Swirling, divergence-free flow (curl noise): smoke, ink, flow fields. */\n\tnoise?: { strength?: PhysicsDriver; scale?: number; speed?: number };\n\t/** Points that pull (positive) or push (negative), px/s² at the center, falling off over `radius`. Layer px. Up to 8. */\n\tattractors?: Array<{\n\t\tx: PhysicsDriver;\n\t\ty: PhysicsDriver;\n\t\tstrength: PhysicsDriver;\n\t\tradius?: number;\n\t}>;\n\t/**\n\t * A performer pushes particles out of their silhouette, harder where it\n\t * is sweeping in: `person` from `comp.vision(clip).person.place(…)`.\n\t */\n\tpush?: {\n\t\tperson: PersonTrack;\n\t\tstrength?: PhysicsDriver;\n\t\tsweep?: PhysicsDriver;\n\t};\n\t/** What happens at the layer's edges: `\"none\"` (default), `\"kill\"`, `\"bounce\"`, `\"wrap\"`. */\n\tbounds?: ParticleBounds;\n\t/** A floor line in layer px that particles bounce on. */\n\tfloor?: number;\n\t/** Bounciness at the floor and bounced edges (default 0.3). */\n\tbounce?: number;\n\t/** px at birth → death (default [6, 0]). */\n\tsize?: Range;\n\t/** Random size variation, 0–1 (default 0.5). */\n\tsizeJitter?: number;\n\t/** Fractions of life to fade in and out (default [0.1, 0.3]). */\n\tfade?: [number, number];\n\t/** `\"circle\"` (default), `\"soft\"` (glow), `\"square\"`, `\"spark\"` (streaks along motion). */\n\tshape?: ParticleShape;\n\t/** Spark length per px/s (default 0.04). */\n\tstretch?: number;\n\t/** `\"normal\"` (default), `\"add\"` (glows build up), `\"screen\"`. */\n\tblend?: ParticleBlend;\n\t/** One color, or up to 8 spread over each particle's life (default white). */\n\tcolor?: string | string[];\n\t/** Color by speed instead of age: the px/s that reaches the last color. */\n\tcolorBySpeed?: number;\n\topacity?: number;\n\t/** Solver steps per frame (default 2). */\n\tsubsteps?: number;\n\t/** Seconds simulated before the first frame, so it starts already full. */\n\tprewarm?: number;\n}\n\nconst range = (\n\tr: Range | undefined,\n\tfallback: [number, number],\n): [number, number] =>\n\tr === undefined ? fallback : typeof r === \"number\" ? [r, r] : r;\n\n/**\n * A GPU particle system: tens of thousands of particles simulated in a\n * compute shader and drawn in one call. Used through `Layer.particles()`.\n * It steps as the composition renders (snapshots make scrubbing back\n * cheap), and its drivers are read every frame.\n */\nexport class Particles\n\textends Effect<Record<string, never>>\n\timplements ParticleProgram\n{\n\tpublic readonly op = \"Particles\";\n\treadonly particleStatic: ParticleStatic;\n\tparticleState?: unknown;\n\tprivate readonly options: ParticlesOptions;\n\n\tconstructor(options: ParticlesOptions) {\n\t\tsuper({});\n\t\tthis.options = options;\n\t\tconst e = options.emitter ?? {};\n\t\tconst staticPos = (d: PhysicsDriver | undefined) =>\n\t\t\ttypeof d === \"number\" ? d : undefined;\n\t\tconst width = options.width;\n\t\tconst height = options.height;\n\t\tconst colors = (\n\t\t\tArray.isArray(options.color)\n\t\t\t\t? options.color\n\t\t\t\t: [options.color ?? \"#ffffff\"]\n\t\t).map((c): [number, number, number, number] => {\n\t\t\tconst p = parseColor(c);\n\t\t\treturn [p.r, p.g, p.b, p.a];\n\t\t});\n\t\tthis.particleStatic = {\n\t\t\tmax: Math.max(1, Math.round(options.max ?? 20000)),\n\t\t\tseed: Math.round(options.seed ?? 1) >>> 0,\n\t\t\tlayer: { x: options.x ?? 0, y: options.y ?? 0, width, height },\n\t\t\temitter: {\n\t\t\t\tshape: e.shape ?? \"rect\",\n\t\t\t\tx:\n\t\t\t\t\tstaticPos(e.x) ??\n\t\t\t\t\t(e.shape === \"circle\" || e.shape === \"ring\" || e.shape === \"point\"\n\t\t\t\t\t\t? width / 2\n\t\t\t\t\t\t: 0),\n\t\t\t\ty:\n\t\t\t\t\tstaticPos(e.y) ??\n\t\t\t\t\t(e.shape === \"circle\" || e.shape === \"ring\" || e.shape === \"point\"\n\t\t\t\t\t\t? height / 2\n\t\t\t\t\t\t: 0),\n\t\t\t\twidth: e.width ?? width,\n\t\t\t\theight: e.height ?? (e.shape === \"line\" ? 0 : height),\n\t\t\t\tradius: e.radius ?? Math.min(width, height) / 4,\n\t\t\t\tradial: e.radial ?? false,\n\t\t\t},\n\t\t\tlifetime: range(options.lifetime, [2, 4]),\n\t\t\tspeed: range(options.speed, [40, 160]),\n\t\t\tdirection: options.direction ?? -90,\n\t\t\tspread: options.spread ?? 360,\n\t\t\tbounds: options.bounds ?? \"none\",\n\t\t\tfloor: options.floor ?? null,\n\t\t\tbounce: options.bounce ?? 0.3,\n\t\t\tsize: range(options.size, [6, 0]),\n\t\t\tsizeJitter: options.sizeJitter ?? 0.5,\n\t\t\tfade: options.fade ?? [0.1, 0.3],\n\t\t\tshape: options.shape ?? \"circle\",\n\t\t\tstretch: options.stretch ?? 0.04,\n\t\t\tblend: options.blend ?? \"normal\",\n\t\t\tcolors: colors.slice(0, 8),\n\t\t\tcolorBySpeed: options.colorBySpeed ?? null,\n\t\t\topacity: options.opacity ?? 1,\n\t\t\tsubsteps: options.substeps ?? 2,\n\t\t\tprewarm: options.prewarm ?? 0,\n\t\t};\n\t}\n\n\tparticleFrame(frame: number, fps: number): ParticleFrame {\n\t\tconst o = this.options;\n\t\tconst read = (d: PhysicsDriver | undefined, fallback: number) =>\n\t\t\td === undefined ? fallback : sampleDriver(d, frame, fps);\n\t\tconst layerFrame = frame - (o.startFrame ?? 0);\n\t\tconst burst = (o.emitter?.bursts ?? [])\n\t\t\t.filter((b) => Math.round(b.frame) === layerFrame)\n\t\t\t.reduce((n, b) => n + b.count, 0);\n\t\tconst g = o.gravity;\n\t\tconst gravity: [number, number] = Array.isArray(g)\n\t\t\t? [read(g[0], 0), read(g[1], 0)]\n\t\t\t: [0, read(g, 0)];\n\t\tlet push: ParticleFrame[\"push\"] = null;\n\t\tif (o.push) {\n\t\t\tpush = {\n\t\t\t\tstrength: read(o.push.strength, 6000),\n\t\t\t\tsweep: read(o.push.sweep, 60000),\n\t\t\t\tmask: o.push.person.silhouetteGrid(frame),\n\t\t\t\tprevious: o.push.person.silhouetteGrid(Math.max(0, frame - 1)),\n\t\t\t};\n\t\t}\n\t\tconst ex = o.emitter?.x;\n\t\tconst ey = o.emitter?.y;\n\t\tconst moving =\n\t\t\t(ex !== undefined && typeof ex !== \"number\") ||\n\t\t\t(ey !== undefined && typeof ey !== \"number\");\n\t\tconst at = (f: number) => ({\n\t\t\tx:\n\t\t\t\tex === undefined\n\t\t\t\t\t? this.particleStatic.emitter.x\n\t\t\t\t\t: sampleDriver(ex, f, fps),\n\t\t\ty:\n\t\t\t\tey === undefined\n\t\t\t\t\t? this.particleStatic.emitter.y\n\t\t\t\t\t: sampleDriver(ey, f, fps),\n\t\t});\n\t\tlet emitter: ParticleFrame[\"emitter\"];\n\t\tif (moving) {\n\t\t\tconst now = at(frame);\n\t\t\tconst before = at(Math.max(0, frame - 1));\n\t\t\temitter = {\n\t\t\t\tx: now.x,\n\t\t\t\ty: now.y,\n\t\t\t\tpreviousX: before.x,\n\t\t\t\tpreviousY: before.y,\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\t...(emitter && { emitter }),\n\t\t\trate: read(o.emitter?.rate, 1000),\n\t\t\tburst,\n\t\t\tgravity,\n\t\t\tdrag: read(o.drag, 0.4),\n\t\t\tnoise: {\n\t\t\t\tstrength: read(o.noise?.strength, 0),\n\t\t\t\tscale: o.noise?.scale ?? 300,\n\t\t\t\tspeed: o.noise?.speed ?? 0.3,\n\t\t\t},\n\t\t\tattractors: (o.attractors ?? []).map((a) => ({\n\t\t\t\tx: read(a.x, 0),\n\t\t\t\ty: read(a.y, 0),\n\t\t\t\tstrength: read(a.strength, 0),\n\t\t\t\tradius: a.radius ?? 200,\n\t\t\t})),\n\t\t\tpush,\n\t\t};\n\t}\n}\n","/**\n * @file packages/framefields/src/swarm3d.ts\n * GPU-Simulated 3D Particle Swarm & Faceted Shards (`Layer3D.swarm`).\n */\n\nimport type {\n\tMaterialType,\n\tModel3DNode,\n} from \"@framefields/compositions/program\";\nimport { autoId } from \"./ids.js\";\nimport { type AnimatableNode, Layer } from \"./index.js\";\nimport type { PhysicsDriver } from \"./physics/core.js\";\nimport { Layer3D, type Surface3DOptions } from \"./shapes3d.js\";\n\nexport interface Swarm3DOptions extends Surface3DOptions {\n\tid?: string;\n\tstartFrame?: number;\n\tdurationFrames?: number;\n\t/** Maximum 3D mesh particles alive at once (default 2000, up to 100000). */\n\tmax?: number;\n\tseed?: number;\n\t/**\n\t * Geometry drawn per particle:\n\t * - `\"shard\"` (default: 8 procedural shard variants)\n\t * - `{ type: \"shard\", variants?: number, facets?: number, irregularity?: number, bevel?: number }`\n\t * - `\"sphere\" | \"roundedBox\" | \"cylinder\"`\n\t * - `AnimatableNode<Model3DNode> | Array<AnimatableNode<Model3DNode>>`\n\t */\n\tmesh?:\n\t\t| \"shard\"\n\t\t| \"sphere\"\n\t\t| \"roundedBox\"\n\t\t| \"cylinder\"\n\t\t| {\n\t\t\t\ttype: \"shard\";\n\t\t\t\tvariants?: number;\n\t\t\t\tfacets?: number;\n\t\t\t\tirregularity?: number;\n\t\t\t\tbevel?: number;\n\t\t }\n\t\t| AnimatableNode<Model3DNode>\n\t\t| Array<AnimatableNode<Model3DNode>>;\n\t/** Particle radius/scale in px at birth -> death (default [18, 12]). */\n\tsize?: number | [number, number];\n\tsizeJitter?: number;\n\tfade?: [number, number];\n\temitter?: {\n\t\tshape?: \"point\" | \"box\" | \"sphere\" | \"shell\" | \"ring\" | \"disc\";\n\t\tx?: PhysicsDriver;\n\t\ty?: PhysicsDriver;\n\t\tz?: PhysicsDriver;\n\t\twidth?: number;\n\t\theight?: number;\n\t\tdepth?: number;\n\t\tradius?: number;\n\t\trate?: PhysicsDriver;\n\t\tbursts?: Array<{ frame: number; count: number }>;\n\t};\n\tlifetime?: number | [number, number];\n\tspeed?: number | [number, number];\n\tdirection?: [number, number, number];\n\tspread?: number;\n\tangularSpeed?: number | [number, number];\n\tangularDrag?: PhysicsDriver;\n\tgravity?: PhysicsDriver | [PhysicsDriver, PhysicsDriver, PhysicsDriver];\n\tdrag?: PhysicsDriver;\n\tnoise?: {\n\t\tstrength?: PhysicsDriver;\n\t\tscale?: number;\n\t\tspeed?: number;\n\t};\n\tattractors?: Array<{\n\t\tx: PhysicsDriver;\n\t\ty: PhysicsDriver;\n\t\tz: PhysicsDriver;\n\t\tstrength: PhysicsDriver;\n\t\tradius?: number;\n\t}>;\n\tvortex?: {\n\t\tx?: PhysicsDriver;\n\t\ty?: PhysicsDriver;\n\t\tz?: PhysicsDriver;\n\t\taxis?: [number, number, number];\n\t\t/** Tangential swirl acceleration (px/s²). */\n\t\tswirl?: PhysicsDriver;\n\t\t/** Radial pull toward the vortex center/axis (px/s²). */\n\t\tpull?: PhysicsDriver;\n\t\t/** Axial acceleration along `axis` (px/s²). */\n\t\taxial?: PhysicsDriver;\n\t\tradius?: number;\n\t};\n\tfloor?: {\n\t\ty: number;\n\t\tbounce?: number;\n\t\t/** Sliding friction damping (0 = ice, 3 = rough stone). Default 1.5. */\n\t\tfriction?: PhysicsDriver;\n\t\t/** How strongly floor scraping & sharp acceleration build up `heat`. Default 1.0. */\n\t\theatGain?: number;\n\t\t/** Seconds for friction/acceleration heat to cool down. Default 0.45. */\n\t\theatDecay?: number;\n\t};\n\t/** Base surface color (default \"#232026\"). */\n\tcolor?: string | string[];\n\troughness?: number;\n\tmetallic?: number;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\tspecularIntensity?: number;\n\tambientIntensity?: number;\n\t/** Dynamic HDR emission driven by particle speed and/or friction heat. */\n\theat?: {\n\t\t/** Source driver: `\"friction\"` | `\"speed\"` | `\"both\"` (default `\"both\"`). */\n\t\tsource?: \"friction\" | \"speed\" | \"both\";\n\t\t/** Speed (px/s) that reaches full heat=1 when source includes speed (default 900). */\n\t\tmaxSpeed?: number;\n\t\t/** Emissive color ramp from cool (0) to hot (1). */\n\t\tcolor: string | string[];\n\t\t/** Peak HDR emissiveIntensity at heat = 1 (feeds bloom when > 2.5). Default 5.0. */\n\t\tintensity?: PhysicsDriver;\n\t\t/** Power curve shaping the heat ramp (default 1.6). */\n\t\tcurve?: number;\n\t};\n\t/** Optional secondary fine sparks spawned from hot/scraping shards in 3D. */\n\tsparks?: {\n\t\tmax?: number;\n\t\trate?: number;\n\t\tthreshold?: number;\n\t\tsize?: number | [number, number];\n\t\tlifetime?: number | [number, number];\n\t\tspeed?: number | [number, number];\n\t\tstretch?: number;\n\t\tcolor?: string | string[];\n\t\tintensity?: number;\n\t};\n\tsubsteps?: number;\n\tprewarm?: number;\n}\n\nexport function createSwarm3D(\n\toptions: Swarm3DOptions,\n): AnimatableNode<Model3DNode> {\n\tlet meshVariants: Array<AnimatableNode<Model3DNode>>;\n\n\tif (Array.isArray(options.mesh)) {\n\t\tmeshVariants = options.mesh;\n\t} else if (\n\t\toptions.mesh &&\n\t\ttypeof options.mesh === \"object\" &&\n\t\t\"kind\" in options.mesh\n\t) {\n\t\tmeshVariants = [options.mesh as AnimatableNode<Model3DNode>];\n\t} else if (\n\t\toptions.mesh &&\n\t\ttypeof options.mesh === \"object\" &&\n\t\toptions.mesh.type === \"shard\"\n\t) {\n\t\tconst numVariants = Math.max(1, options.mesh.variants ?? 8);\n\t\tmeshVariants = [];\n\t\tfor (let i = 0; i < numVariants; i++) {\n\t\t\tmeshVariants.push(\n\t\t\t\tLayer3D.shard({\n\t\t\t\t\tradius: 20,\n\t\t\t\t\tfacets: options.mesh.facets ?? 12 + (i % 6),\n\t\t\t\t\tseed: (options.seed ?? 1) * 31 + i * 17,\n\t\t\t\t\tirregularity: options.mesh.irregularity ?? 0.35,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t} else if (options.mesh === \"sphere\") {\n\t\tmeshVariants = [Layer3D.sphere({ radius: 20 })];\n\t} else if (options.mesh === \"roundedBox\") {\n\t\tmeshVariants = [Layer3D.roundedBox({ size: [30, 30, 30] })];\n\t} else if (options.mesh === \"cylinder\") {\n\t\tmeshVariants = [Layer3D.cylinder({ radius: 15, height: 35 })];\n\t} else {\n\t\t// Default: 8 procedural shard variants\n\t\tconst numVariants = 8;\n\t\tmeshVariants = [];\n\t\tfor (let i = 0; i < numVariants; i++) {\n\t\t\tmeshVariants.push(\n\t\t\t\tLayer3D.shard({\n\t\t\t\t\tradius: 20,\n\t\t\t\t\tfacets: 10 + (i % 8) * 2,\n\t\t\t\t\tseed: (options.seed ?? 42) + i * 13,\n\t\t\t\t\tirregularity: 0.35 + (i % 3) * 0.1,\n\t\t\t\t}),\n\t\t\t);\n\t\t}\n\t}\n\n\tconst node: Model3DNode = {\n\t\tid: options.id ?? autoId(\"swarm3d\"),\n\t\tkind: \"model3d\",\n\t\tx: 0,\n\t\ty: 0,\n\t\tz: 0,\n\t\topacity: 1,\n\t\ttwoSided: true,\n\t\tmaterial: options.material ?? \"lit\",\n\t\troughness: options.roughness ?? 0.35,\n\t\tmetallic: options.metallic ?? 0.7,\n\t\tspecularIntensity: options.specularIntensity ?? 0.5,\n\t\tambientIntensity: options.ambientIntensity ?? 1.0,\n\t\tstartFrame: options.startFrame,\n\t\tdurationFrames: options.durationFrames,\n\t\tswarm3d: {\n\t\t\t...options,\n\t\t\tmeshVariants,\n\t\t},\n\t};\n\n\tconst primary = meshVariants[0] as unknown as Record<string, unknown>;\n\tif (primary) {\n\t\tif (primary.modelData) node.modelData = primary.modelData;\n\t\tif (primary.primitive3d) node.primitive3d = primary.primitive3d;\n\t}\n\n\treturn Layer.model(\n\t\tnode as unknown as Partial<Model3DNode>,\n\t) as unknown as AnimatableNode<Model3DNode>;\n}\n","import type {\n\tBoxNode,\n\tLayoutNode,\n\tMaterialType,\n\tModel3DNode,\n} from \"@framefields/compositions/program\";\nimport {\n\ttype CapsuleGeometryOptions,\n\ttype CylinderGeometryOptions,\n\ttype ExtrudeShapeGeometryOptions,\n\tgenerateExtrudedTextGeometry,\n\tgetPrimitiveGeometry,\n\ttype LatheGeometryOptions,\n\ttype Line3DGeometryOptions,\n\ttype Model3DData,\n\tPath3D,\n\ttype Points3DGeometryOptions,\n\ttype PolyhedronGeometryOptions,\n\ttype PrimitiveGeometryOptions,\n\ttype RingGeometryOptions,\n\ttype RoundedBoxGeometryOptions,\n\ttype ShardGeometryOptions,\n\tSlugFontCache,\n\ttype SphereGeometryOptions,\n\ttype TorusGeometryOptions,\n\ttype TubeGeometryOptions,\n\ttype TubePathSpec,\n} from \"@framefields/webgpu-renderers\";\nimport { autoId } from \"./ids.js\";\nimport { type AnimatableNode, Layer } from \"./index.js\";\nimport type { PhysicsBody3D } from \"./physics/world3d.js\";\nimport { createSwarm3D, type Swarm3DOptions } from \"./swarm3d.js\";\n\n/** Physically based surface options every 3D builder accepts. */\nexport interface Surface3DOptions {\n\t/** Light the surface gives off: a CSS color added on top of lighting. */\n\temissive?: string;\n\t/** Emissive multiplier; above 1 glows past white and blooms. Default 1. */\n\temissiveIntensity?: number;\n\t/** Falls into a `castShadow` light's shadow map (meshes default on, flat layers off). */\n\tcastShadow?: boolean;\n}\n\nconst MATERIAL_KEYS = [\n\t\"material\",\n\t\"shininess\",\n\t\"roughness\",\n\t\"specularIntensity\",\n\t\"metallic\",\n\t\"ambientIntensity\",\n\t\"ior\",\n\t\"transmission\",\n\t\"dispersion\",\n\t\"fresnelPower\",\n\t\"envIntensity\",\n\t\"emissive\",\n\t\"emissiveIntensity\",\n\t\"castShadow\",\n] as const;\n\n/** The material and surface options that were actually given. */\nfunction materialProps(o: object): Record<string, unknown> {\n\tconst src = o as Record<string, unknown>;\n\tconst out: Record<string, unknown> = {};\n\tfor (const k of MATERIAL_KEYS) {\n\t\tif (src[k] !== undefined) out[k] = src[k];\n\t}\n\treturn out;\n}\n\nexport interface CubeFaceConfig extends Surface3DOptions {\n\tbackground?: string;\n\tborderRadius?: number;\n\tborderWidth?: number;\n\tborderColor?: string;\n\topacity?: number;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tmetallic?: number;\n\tambientIntensity?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\tchildren?: LayoutNode[];\n}\n\nexport type CubeFaceInput = CubeFaceConfig | LayoutNode | string;\n\nexport interface Cube3DOptions extends Surface3DOptions {\n\tid?: string;\n\tsize: number | [number, number, number];\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tfaces?: {\n\t\tfront?: CubeFaceInput;\n\t\tback?: CubeFaceInput;\n\t\tleft?: CubeFaceInput;\n\t\tright?: CubeFaceInput;\n\t\ttop?: CubeFaceInput;\n\t\tbottom?: CubeFaceInput;\n\t};\n\ttwoSided?: boolean;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tmetallic?: number;\n\tambientIntensity?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\topacity?: number;\n}\n\nexport interface Carousel3DOptions {\n\tid?: string;\n\tradius: number;\n\titems: LayoutNode[];\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tfaceInward?: boolean;\n\titemWidth?: number;\n\titemHeight?: number;\n\ttwoSided?: boolean;\n\topacity?: number;\n}\n\nexport interface Prism3DOptions extends Surface3DOptions {\n\tid?: string;\n\t/** Number of polygon sides (default 6). */\n\tsides?: number;\n\t/** Circumradius of the polygon (default 60). */\n\tradius?: number;\n\t/** Optional top (-y) radius; defaults to `radius`. */\n\tradiusTop?: number;\n\t/** Optional bottom (+y) radius; defaults to `radius`. */\n\tradiusBottom?: number;\n\t/** Height along Y (default 100). */\n\theight?: number;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tscale?: number;\n\tscaleX?: number;\n\tscaleY?: number;\n\tscaleZ?: number;\n\t/** Leave the top and bottom polygon caps off (default false = solid capped prism). */\n\topenEnded?: boolean;\n\t/** Flat-shade each polygonal side facet (default true for crisp prism edges). */\n\tflatShaded?: boolean;\n\t/** Draw triangle edges instead of filled surfaces. */\n\twireframe?: boolean;\n\t/** Surface color baked into the mesh (default `#3b82f6`). */\n\tcolor?: string;\n\t/** Animated color multiplier (`node.color`). */\n\ttint?: string;\n\t/** Optional per-side panel configs; when provided, builds a multi-panel preserve-3d container. */\n\tsideConfigs?: Array<CubeFaceInput>;\n\ttwoSided?: boolean;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tmetallic?: number;\n\tambientIntensity?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\topacity?: number;\n\tstartFrame?: number;\n\tdurationFrames?: number;\n}\n\nexport interface Pyramid3DOptions extends Surface3DOptions {\n\tid?: string;\n\t/** Number of base polygon sides (default 4 = square pyramid; 3 = triangular pyramid). */\n\tsides?: number;\n\t/** Circumradius of the base polygon (default 60). */\n\tradius?: number;\n\t/** Optional top (-y) truncation radius for a frustum pyramid (default 0 = sharp apex). */\n\tradiusTop?: number;\n\t/** Height from base (+y) to apex (-y) (default 100). */\n\theight?: number;\n\t/** Leave the base cap off (default false = solid capped pyramid). */\n\topenEnded?: boolean;\n\t/** Flat-shade each triangular side face (default true). */\n\tflatShaded?: boolean;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tscale?: number;\n\tscaleX?: number;\n\tscaleY?: number;\n\tscaleZ?: number;\n\twireframe?: boolean;\n\tcolor?: string;\n\ttint?: string;\n\ttwoSided?: boolean;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tmetallic?: number;\n\tambientIntensity?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\topacity?: number;\n\tstartFrame?: number;\n\tdurationFrames?: number;\n}\n\nexport interface Plane3DOptions extends Surface3DOptions {\n\tid?: string;\n\twidth: number;\n\theight: number;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tbackground?: string;\n\tborderRadius?: number;\n\ttwoSided?: boolean;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tmetallic?: number;\n\tambientIntensity?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\topacity?: number;\n\tchildren?: LayoutNode[];\n}\n\nexport interface Grid3DOptions {\n\tid?: string;\n\twidth: number;\n\theight: number;\n\tdivisions?: number;\n\tcolor?: string;\n\t/** Line thickness in world pixels (default 2). */\n\tlineWidth?: number;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\topacity?: number;\n}\n\nexport interface Text3DOptions extends Surface3DOptions {\n\tid?: string;\n\ttext: string;\n\tfontSize?: number;\n\tfontFamily?: string;\n\tfontWeight?: number | string;\n\tfontStyle?: string;\n\tfill?: string;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tscale?: number;\n\tscaleX?: number;\n\tscaleY?: number;\n\tscaleZ?: number;\n\talign?: \"start\" | \"center\" | \"end\" | \"left\" | \"right\";\n\t/**\n\t * Base direction: \"auto\" (default) takes it from the first strong\n\t * character, so Arabic and Hebrew read right to left. \"start\"/\"end\"\n\t * alignment follows it.\n\t */\n\tdirection?: \"ltr\" | \"rtl\" | \"auto\";\n\tverticalAlign?: \"top\" | \"middle\" | \"bottom\";\n\tletterSpacing?: number;\n\tlineHeight?: number;\n\tis3D?: boolean;\n\ttwoSided?: boolean;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tambientIntensity?: number;\n\tmetallic?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\topacity?: number;\n\tbackground?: string;\n\tborderRadius?: number;\n\tpadding?: number;\n\tstroke?: string;\n\tstrokeWidth?: number;\n\textrusionDepth?: number;\n\t/** @deprecated No effect: extruded text is one solid mesh, not a stack of slices. */\n\textrusionSteps?: number;\n\t/**\n\t * Extruded text only: color of the side walls. `fill` colors the letter\n\t * faces (front and back). Defaults to `fill`.\n\t */\n\tbevelColor?: string;\n}\n\nexport interface ExtrudedText3DOptions extends Text3DOptions {\n\tdepth: number;\n\t/** @deprecated No effect: extruded text is one solid mesh, not a stack of slices. */\n\tslices?: number;\n\t/** Fixed straight segments per curve; by default curves split as finely as their on-screen size needs. */\n\tcurveSegments?: number;\n\t/** Most a flattened curve strays from the outline, in on-screen px at scale 1 (default 0.1). */\n\tcurveTolerance?: number;\n}\n\n/** Node props shared by the mesh primitives (roundedBox, sphere, cylinder, torus, capsule, …). */\nexport interface Primitive3DNodeOptions extends Surface3DOptions {\n\tid?: string;\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tscale?: number;\n\tscaleX?: number;\n\tscaleY?: number;\n\tscaleZ?: number;\n\t/** Render both front and back faces (default false for closed solids). */\n\ttwoSided?: boolean;\n\t/** Draw triangle edges instead of filled surfaces. */\n\twireframe?: boolean;\n\t/** Surface color baked into the mesh (default white). */\n\tcolor?: string;\n\t/**\n\t * Multiplies the surface color. It is the node's `color`, so animate it\n\t * with `.keys(\"color\", …)`; the baked surface `color` stays fixed.\n\t */\n\ttint?: string;\n\tmaterial?: MaterialType;\n\tshininess?: number;\n\troughness?: number;\n\tspecularIntensity?: number;\n\tambientIntensity?: number;\n\tmetallic?: number;\n\tior?: number;\n\ttransmission?: number;\n\tdispersion?: number;\n\tfresnelPower?: number;\n\tenvIntensity?: number;\n\topacity?: number;\n\tstartFrame?: number;\n\tdurationFrames?: number;\n}\n\nexport type RoundedBox3DOptions = Primitive3DNodeOptions &\n\tOmit<RoundedBoxGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Sphere3DOptions = Primitive3DNodeOptions &\n\tOmit<SphereGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Cylinder3DOptions = Primitive3DNodeOptions &\n\tOmit<CylinderGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Torus3DOptions = Primitive3DNodeOptions &\n\tOmit<TorusGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Capsule3DOptions = Primitive3DNodeOptions &\n\tOmit<CapsuleGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Ring3DOptions = Primitive3DNodeOptions &\n\tOmit<RingGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Polyhedron3DOptions = Primitive3DNodeOptions &\n\tOmit<PolyhedronGeometryOptions, \"type\" | \"color\" | \"material\"> & {\n\t\t/** Alias for `shape` (`\"tetrahedron\" | \"octahedron\" | \"dodecahedron\" | \"icosahedron\" | \"icosphere\"`). */\n\t\ttype?: PolyhedronGeometryOptions[\"shape\"];\n\t};\nexport type Icosphere3DOptions = Omit<Polyhedron3DOptions, \"shape\" | \"type\">;\nexport type ExtrudeShape3DOptions = Primitive3DNodeOptions &\n\tOmit<ExtrudeShapeGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Lathe3DOptions = Primitive3DNodeOptions &\n\tOmit<LatheGeometryOptions, \"type\" | \"color\" | \"material\">;\nexport type Tube3DOptions = Primitive3DNodeOptions &\n\tOmit<TubeGeometryOptions, \"type\" | \"color\" | \"material\" | \"path\"> & {\n\t\t/** A `Path3D` instance, `TubePathSpec`, or array of 3D waypoints `[x, y, z]`. */\n\t\tpath?: Path3D | TubePathSpec;\n\t\t/** Alias for `path` when passing an array of 3D waypoints `[x, y, z]` or a `Path3D`. */\n\t\tpoints?: Path3D | TubePathSpec;\n\t};\nexport type Line3DOptions = Primitive3DNodeOptions &\n\tOmit<Line3DGeometryOptions, \"type\" | \"color\" | \"material\" | \"points\"> & {\n\t\t/** A `Path3D` instance, `TubePathSpec`, or array of 3D points `[x, y, z]`. */\n\t\tpoints?: Path3D | TubePathSpec;\n\t\t/** Alias for `points` when passing a `Path3D` or `TubePathSpec`. */\n\t\tpath?: Path3D | TubePathSpec;\n\t};\nexport type Points3DOptions = Primitive3DNodeOptions &\n\tOmit<Points3DGeometryOptions, \"type\" | \"color\" | \"material\" | \"points\"> & {\n\t\t/** A `Path3D` instance, `TubePathSpec`, or array of 3D points `[x, y, z]`. */\n\t\tpoints: Path3D | TubePathSpec;\n\t};\nexport type Shard3DOptions = Primitive3DNodeOptions &\n\tOmit<ShardGeometryOptions, \"type\" | \"color\" | \"material\">;\n\nexport interface InstanceTransform3D {\n\tx: number;\n\ty: number;\n\tz: number;\n\t/** Euler degrees [rx, ry, rz] or unit quaternion [qx, qy, qz, qw]. */\n\trotation?: [number, number, number] | [number, number, number, number];\n\tscale?: number;\n\tcolor?: string | [number, number, number, number];\n\temissive?: string | [number, number, number];\n\temissiveIntensity?: number;\n}\n\nexport interface Instances3DOptions extends Surface3DOptions {\n\tid?: string;\n\t/** One mesh node/primitive, or an array of mesh variants distributed across instances. */\n\tmesh: AnimatableNode<Model3DNode> | Array<AnimatableNode<Model3DNode>>;\n\t/** Count of instances when driven by `instanceAt` or `bodies`. */\n\tcount?: number;\n\t/** Bind directly to Physics.world3d rigid bodies. */\n\tbodies?: readonly PhysicsBody3D[];\n\t/** Per-frame callback `(index, frame, fps) => InstanceTransform3D`. */\n\tinstanceAt?: (\n\t\tindex: number,\n\t\tframe: number,\n\t\tfps: number,\n\t) => InstanceTransform3D | undefined;\n\t/** Pre-computed array of instance transforms. */\n\ttransforms?: InstanceTransform3D[];\n\t/** Optional speed/impact-to-emissive mapping when bound to `bodies`. */\n\temissiveBySpeed?: {\n\t\tcolor: string | string[];\n\t\tmaxSpeed: number;\n\t\tintensity?: number;\n\t};\n\temissiveByImpact?: { color: string; intensity?: number };\n\tx?: number;\n\ty?: number;\n\tz?: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n\tscale?: number;\n\tcolor?: string;\n\tcolorTint?: string;\n\topacity?: number;\n\ttwoSided?: boolean;\n\twireframe?: boolean;\n\tmaterial?: MaterialType;\n\troughness?: number;\n\tmetallic?: number;\n\tspecularIntensity?: number;\n\tambientIntensity?: number;\n\tstartFrame?: number;\n\tdurationFrames?: number;\n}\n\n/** Mesh shading the geometry can bake in; layer materials (glass, …) apply on the node. */\nfunction meshShading(\n\tmaterial: MaterialType | undefined,\n): \"lit\" | \"unlit\" | \"toon\" | undefined {\n\treturn material === \"lit\" || material === \"unlit\" || material === \"toon\"\n\t\t? material\n\t\t: undefined;\n}\n\nfunction normalizePathSpec(input: Path3D | TubePathSpec): TubePathSpec {\n\tif (input instanceof Path3D) {\n\t\treturn input.getPoints(96);\n\t}\n\treturn input;\n}\n\nfunction primitiveNode(\n\tprefix: string,\n\tgeometry: PrimitiveGeometryOptions,\n\to: Primitive3DNodeOptions,\n): AnimatableNode<Model3DNode> {\n\t// Only defined keys, so equal shapes share one cached mesh.\n\tconst spec = Object.fromEntries(\n\t\tObject.entries({\n\t\t\t...geometry,\n\t\t\tcolor: o.color,\n\t\t\tmaterial: meshShading(o.material),\n\t\t\tshininess: o.shininess,\n\t\t\troughness: o.roughness,\n\t\t\tmetallic: o.metallic,\n\t\t}).filter(([, v]) => v !== undefined),\n\t) as unknown as PrimitiveGeometryOptions;\n\treturn Layer.model({\n\t\tid: o.id ?? autoId(prefix),\n\t\tmodelData: getPrimitiveGeometry(spec),\n\t\t// What the compositor rebuilds the mesh from when modelData did not\n\t\t// survive (a spec sent as JSON).\n\t\tprimitive3d: spec,\n\t\tis3D: true,\n\t\tx: o.x ?? 0,\n\t\ty: o.y ?? 0,\n\t\tz: o.z ?? 0,\n\t\trotateX: o.rotateX ?? 0,\n\t\trotateY: o.rotateY ?? 0,\n\t\trotateZ: o.rotateZ ?? 0,\n\t\tscale: o.scale ?? 1,\n\t\tscaleX: o.scaleX ?? 1,\n\t\tscaleY: o.scaleY ?? 1,\n\t\tscaleZ: o.scaleZ ?? 1,\n\t\topacity: o.opacity ?? 1,\n\t\tcolor: o.tint,\n\t\tmaterial: o.material,\n\t\tshininess: o.shininess ?? 32,\n\t\troughness: o.roughness,\n\t\tspecularIntensity: o.specularIntensity ?? 0.5,\n\t\tambientIntensity: o.ambientIntensity ?? 1.0,\n\t\tmetallic: o.metallic,\n\t\t...materialProps(o),\n\t\ttwoSided: o.twoSided ?? false,\n\t\twireframe: o.wireframe,\n\t\tstartFrame: o.startFrame,\n\t\tdurationFrames: o.durationFrames,\n\t});\n}\n\nexport type Shape3DContainer = AnimatableNode<BoxNode> & {\n\tfaces?: AnimatableNode<BoxNode>[];\n\titems?: LayoutNode[];\n\t[Symbol.iterator](): Iterator<LayoutNode>;\n};\n\nexport type SolidShape3DNode = AnimatableNode<Model3DNode> & {\n\tfaces?: LayoutNode[];\n\titems?: LayoutNode[];\n\t[Symbol.iterator](): Iterator<LayoutNode>;\n};\n\n/**\n * Attaches the faces/items handles as non-enumerable properties, like\n * `animate`, so they stay out of `toSpec()` and schema validation.\n */\nfunction withParts<T extends object>(\n\tnode: T,\n\tparts: { faces?: LayoutNode[]; items?: LayoutNode[] },\n): T & Shape3DContainer {\n\tconst list = (parts.faces ?? parts.items ?? []) as LayoutNode[];\n\tfor (const [key, value] of Object.entries(parts)) {\n\t\tObject.defineProperty(node, key, {\n\t\t\tvalue,\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\tObject.defineProperty(node, Symbol.iterator, {\n\t\tvalue: function* () {\n\t\t\tyield* list;\n\t\t},\n\t\tenumerable: false,\n\t\tconfigurable: true,\n\t});\n\treturn node as T & Shape3DContainer;\n}\n\n/** Largest initial scale of an extruded text node along its outline's axes. */\nfunction extrudedTextScale(options: ExtrudedText3DOptions): number {\n\tconst scale = options.scale ?? 1;\n\tconst s = Math.max(\n\t\tMath.abs(scale * (options.scaleX ?? 1)),\n\t\tMath.abs(scale * (options.scaleY ?? 1)),\n\t);\n\treturn s > 0 ? s : 1;\n}\n\nexport const Layer3D = {\n\t/**\n\t * Creates a true 3D volumetric cube with 6 textured or colored faces.\n\t * Returns a preserve-3d container that can be transformed in 3D camera space.\n\t */\n\tcube(options: Cube3DOptions): Shape3DContainer {\n\t\tconst size = options.size;\n\t\tconst [w, h, d] = typeof size === \"number\" ? [size, size, size] : size;\n\t\tconst twoSided = options.twoSided ?? true;\n\t\tconst defaultColors = {\n\t\t\tfront: \"#3b82f6\",\n\t\t\tback: \"#1d4ed8\",\n\t\t\tleft: \"#2563eb\",\n\t\t\tright: \"#1e40af\",\n\t\t\ttop: \"#60a5fa\",\n\t\t\tbottom: \"#172554\",\n\t\t};\n\n\t\tconst buildFace = (\n\t\t\tfaceId: string,\n\t\t\tinput: CubeFaceInput | undefined,\n\t\t\tdefaultColor: string,\n\t\t\tfaceW: number,\n\t\t\tfaceH: number,\n\t\t\tfaceProps: Partial<BoxNode>,\n\t\t): AnimatableNode<BoxNode> => {\n\t\t\tif (input && typeof input === \"object\" && \"kind\" in input) {\n\t\t\t\tconst node = input as AnimatableNode<BoxNode>;\n\t\t\t\tnode.position = \"absolute\";\n\t\t\t\tnode.is3D = true;\n\t\t\t\tnode.twoSided = twoSided;\n\t\t\t\tnode.material = node.material ?? options.material ?? \"lit\";\n\t\t\t\tnode.shininess = node.shininess ?? options.shininess ?? 32;\n\t\t\t\tnode.specularIntensity =\n\t\t\t\t\tnode.specularIntensity ?? options.specularIntensity ?? 0.5;\n\t\t\t\tif (options.roughness !== undefined && node.roughness === undefined) {\n\t\t\t\t\tnode.roughness = options.roughness;\n\t\t\t\t}\n\t\t\t\tif (options.metallic !== undefined && node.metallic === undefined) {\n\t\t\t\t\tnode.metallic = options.metallic;\n\t\t\t\t}\n\t\t\t\tif (\n\t\t\t\t\toptions.ambientIntensity !== undefined &&\n\t\t\t\t\tnode.ambientIntensity === undefined\n\t\t\t\t) {\n\t\t\t\t\tnode.ambientIntensity = options.ambientIntensity;\n\t\t\t\t}\n\t\t\t\tObject.assign(node, faceProps);\n\t\t\t\treturn node;\n\t\t\t}\n\t\t\tconst cfg: CubeFaceConfig =\n\t\t\t\ttypeof input === \"string\"\n\t\t\t\t\t? { background: input }\n\t\t\t\t\t: (input ?? { background: defaultColor });\n\n\t\t\treturn Layer.box({\n\t\t\t\tid: `${options.id ?? \"cube\"}-${faceId}`,\n\t\t\t\tposition: \"absolute\",\n\t\t\t\twidth: faceW,\n\t\t\t\theight: faceH,\n\t\t\t\tis3D: true,\n\t\t\t\ttwoSided,\n\t\t\t\tmaterial: cfg.material ?? options.material ?? \"lit\",\n\t\t\t\tshininess: cfg.shininess ?? options.shininess ?? 32,\n\t\t\t\tspecularIntensity:\n\t\t\t\t\tcfg.specularIntensity ?? options.specularIntensity ?? 0.5,\n\t\t\t\troughness: cfg.roughness ?? options.roughness,\n\t\t\t\tmetallic: cfg.metallic ?? options.metallic,\n\t\t\t\tambientIntensity:\n\t\t\t\t\tcfg.ambientIntensity ?? options.ambientIntensity ?? 1.0,\n\t\t\t\t...materialProps({\n\t\t\t\t\t...options,\n\t\t\t\t\t...cfg,\n\t\t\t\t}),\n\t\t\t\tbackground: cfg.background ?? defaultColor,\n\t\t\t\tborderRadius: cfg.borderRadius ?? 0,\n\t\t\t\tborderWidth: cfg.borderWidth,\n\t\t\t\tborderColor: cfg.borderColor,\n\t\t\t\topacity: cfg.opacity ?? 1,\n\t\t\t\tchildren: cfg.children ?? [],\n\t\t\t\t...faceProps,\n\t\t\t});\n\t\t};\n\n\t\tconst halfW = w / 2;\n\t\tconst halfH = h / 2;\n\t\tconst halfD = d / 2;\n\n\t\tconst faces: AnimatableNode<BoxNode>[] = [\n\t\t\tbuildFace(\"front\", options.faces?.front, defaultColors.front, w, h, {\n\t\t\t\tx: 0,\n\t\t\t\ty: 0,\n\t\t\t\tz: -halfD,\n\t\t\t\trotateX: 0,\n\t\t\t\trotateY: 0,\n\t\t\t\trotateZ: 0,\n\t\t\t}),\n\t\t\tbuildFace(\"back\", options.faces?.back, defaultColors.back, w, h, {\n\t\t\t\tx: 0,\n\t\t\t\ty: 0,\n\t\t\t\tz: halfD,\n\t\t\t\trotateX: 0,\n\t\t\t\trotateY: 180,\n\t\t\t\trotateZ: 0,\n\t\t\t}),\n\t\t\tbuildFace(\"left\", options.faces?.left, defaultColors.left, d, h, {\n\t\t\t\tx: -halfW,\n\t\t\t\ty: 0,\n\t\t\t\tz: 0,\n\t\t\t\trotateX: 0,\n\t\t\t\trotateY: 90,\n\t\t\t\trotateZ: 0,\n\t\t\t}),\n\t\t\tbuildFace(\"right\", options.faces?.right, defaultColors.right, d, h, {\n\t\t\t\tx: halfW,\n\t\t\t\ty: 0,\n\t\t\t\tz: 0,\n\t\t\t\trotateX: 0,\n\t\t\t\trotateY: -90,\n\t\t\t\trotateZ: 0,\n\t\t\t}),\n\t\t\tbuildFace(\"top\", options.faces?.top, defaultColors.top, w, d, {\n\t\t\t\tx: 0,\n\t\t\t\ty: -halfH,\n\t\t\t\tz: 0,\n\t\t\t\trotateX: -90,\n\t\t\t\trotateY: 0,\n\t\t\t\trotateZ: 0,\n\t\t\t}),\n\t\t\tbuildFace(\"bottom\", options.faces?.bottom, defaultColors.bottom, w, d, {\n\t\t\t\tx: 0,\n\t\t\t\ty: halfH,\n\t\t\t\tz: 0,\n\t\t\t\trotateX: 90,\n\t\t\t\trotateY: 0,\n\t\t\t\trotateZ: 0,\n\t\t\t}),\n\t\t];\n\n\t\tconst container = Layer.box({\n\t\t\tid: options.id ?? autoId(\"cube\"),\n\t\t\tposition: \"absolute\",\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\twidth: w,\n\t\t\theight: h,\n\t\t\tis3D: true,\n\t\t\ttransformStyle: \"preserve-3d\",\n\t\t\trotateX: options.rotateX ?? 0,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\topacity: options.opacity ?? 1,\n\t\t\tbackground: \"transparent\",\n\t\t\tchildren: faces,\n\t\t});\n\n\t\treturn withParts(container, { faces });\n\t},\n\n\t/**\n\t * Creates a 3D cylindrical carousel of items arranged radially around a center point.\n\t */\n\tcarousel(options: Carousel3DOptions): Shape3DContainer {\n\t\tconst { items, radius, faceInward = false, twoSided = true } = options;\n\t\tconst n = items.length;\n\t\tconst angleStep = n > 0 ? 360 / n : 0;\n\n\t\tconst transformedItems = items.map((item, idx) => {\n\t\t\t// Item 0 sits nearest the default camera (-z) and the ring runs clockwise\n\t\t\t// seen from above. A face's front normal is (-sin ry, 0, -cos ry) (the\n\t\t\t// cube's convention: rotateY 90 faces -x), so the outward normal\n\t\t\t// (sin a, 0, -cos a) needs ry = -a, and inward needs 180 - a.\n\t\t\tconst angleDeg = idx * angleStep;\n\t\t\tconst rad = (angleDeg * Math.PI) / 180;\n\t\t\tconst x = radius * Math.sin(rad);\n\t\t\tconst z = -radius * Math.cos(rad);\n\t\t\tconst ry = faceInward ? 180 - angleDeg : -angleDeg;\n\n\t\t\tconst node = item as AnimatableNode<BoxNode>;\n\t\t\tnode.position = \"absolute\";\n\t\t\tnode.is3D = true;\n\t\t\tnode.twoSided = twoSided;\n\t\t\tnode.x = x;\n\t\t\tnode.y = 0;\n\t\t\tnode.z = z;\n\t\t\tnode.rotateY = ry;\n\t\t\treturn node;\n\t\t});\n\n\t\tconst container = Layer.box({\n\t\t\tid: options.id ?? autoId(\"carousel\"),\n\t\t\tposition: \"absolute\",\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\twidth: options.itemWidth ?? 200,\n\t\t\theight: options.itemHeight ?? 200,\n\t\t\tis3D: true,\n\t\t\ttransformStyle: \"preserve-3d\",\n\t\t\trotateX: options.rotateX ?? 0,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\topacity: options.opacity ?? 1,\n\t\t\tbackground: \"transparent\",\n\t\t\tchildren: transformedItems,\n\t\t});\n\n\t\treturn withParts(container, { items: transformedItems });\n\t},\n\n\t/**\n\t * Creates an N-sided regular polygonal 3D prism with top and bottom caps,\n\t * outward flat-shaded facet normals, and full material options.\n\t * If `sideConfigs` are provided, builds a multi-panel preserve-3d container with all material props applied.\n\t */\n\tprism(options: Prism3DOptions): Shape3DContainer {\n\t\tconst n = Math.max(3, Math.round(options.sides));\n\t\tif (options.sideConfigs && options.sideConfigs.length > 0) {\n\t\t\tconst { radius, height, twoSided = true } = options;\n\t\t\tconst sideWidth = 2 * radius * Math.tan(Math.PI / n);\n\t\t\tconst angleStep = 360 / n;\n\t\t\tconst panels: AnimatableNode<BoxNode>[] = [];\n\n\t\t\tfor (let i = 0; i < n; i++) {\n\t\t\t\tconst angleDeg = i * angleStep;\n\t\t\t\tconst rad = (angleDeg * Math.PI) / 180;\n\t\t\t\tconst x = radius * Math.sin(rad);\n\t\t\t\tconst z = -radius * Math.cos(rad);\n\t\t\t\tconst input = options.sideConfigs[i];\n\t\t\t\tconst defaultColor = options.color ?? `hsl(${(i * 360) / n}, 70%, 50%)`;\n\n\t\t\t\tif (input && typeof input === \"object\" && \"kind\" in input) {\n\t\t\t\t\tconst node = input as AnimatableNode<BoxNode>;\n\t\t\t\t\tnode.position = \"absolute\";\n\t\t\t\t\tnode.is3D = true;\n\t\t\t\t\tnode.twoSided = twoSided;\n\t\t\t\t\tnode.x = x;\n\t\t\t\t\tnode.y = 0;\n\t\t\t\t\tnode.z = z;\n\t\t\t\t\tnode.rotateY = -angleDeg;\n\t\t\t\t\tObject.assign(node, materialProps(options));\n\t\t\t\t\tpanels.push(node);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tconst cfg: CubeFaceConfig =\n\t\t\t\t\ttypeof input === \"string\"\n\t\t\t\t\t\t? { background: input }\n\t\t\t\t\t\t: (input ?? { background: defaultColor });\n\n\t\t\t\tpanels.push(\n\t\t\t\t\tLayer.box({\n\t\t\t\t\t\tid: `${options.id ?? \"prism\"}-panel-${i}`,\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\twidth: sideWidth,\n\t\t\t\t\t\theight,\n\t\t\t\t\t\tis3D: true,\n\t\t\t\t\t\ttwoSided,\n\t\t\t\t\t\tx,\n\t\t\t\t\t\ty: 0,\n\t\t\t\t\t\tz,\n\t\t\t\t\t\trotateY: -angleDeg,\n\t\t\t\t\t\tbackground: cfg.background ?? defaultColor,\n\t\t\t\t\t\tborderRadius: cfg.borderRadius ?? 0,\n\t\t\t\t\t\tborderWidth: cfg.borderWidth,\n\t\t\t\t\t\tborderColor: cfg.borderColor,\n\t\t\t\t\t\topacity: cfg.opacity ?? options.opacity ?? 1,\n\t\t\t\t\t\tmaterial: cfg.material ?? options.material ?? \"lit\",\n\t\t\t\t\t\tshininess: cfg.shininess ?? options.shininess ?? 32,\n\t\t\t\t\t\tspecularIntensity:\n\t\t\t\t\t\t\tcfg.specularIntensity ?? options.specularIntensity ?? 0.5,\n\t\t\t\t\t\tambientIntensity:\n\t\t\t\t\t\t\tcfg.ambientIntensity ?? options.ambientIntensity ?? 1.0,\n\t\t\t\t\t\t...materialProps({ ...options, ...cfg }),\n\t\t\t\t\t\tchildren: cfg.children ?? [],\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst container = Layer.box({\n\t\t\t\tid: options.id ?? autoId(\"prism\"),\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tx: options.x ?? 0,\n\t\t\t\ty: options.y ?? 0,\n\t\t\t\tz: options.z ?? 0,\n\t\t\t\twidth: sideWidth,\n\t\t\t\theight,\n\t\t\t\tis3D: true,\n\t\t\t\ttransformStyle: \"preserve-3d\",\n\t\t\t\trotateX: options.rotateX ?? 0,\n\t\t\t\trotateY: options.rotateY ?? 0,\n\t\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\t\topacity: options.opacity ?? 1,\n\t\t\t\tbackground: \"transparent\",\n\t\t\t\tchildren: panels,\n\t\t\t});\n\n\t\t\treturn withParts(container, { faces: panels });\n\t\t}\n\n\t\tconst modelNode = primitiveNode(\n\t\t\t\"prism\",\n\t\t\t{\n\t\t\t\ttype: \"cylinder\",\n\t\t\t\tradius: options.radius,\n\t\t\t\tradiusTop: options.radiusTop ?? options.radius,\n\t\t\t\tradiusBottom: options.radiusBottom ?? options.radius,\n\t\t\t\theight: options.height,\n\t\t\t\tsegments: n,\n\t\t\t\topenEnded: options.openEnded ?? false,\n\t\t\t\tflatShaded: options.flatShaded ?? true,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tcolor: options.color ?? \"#3b82f6\",\n\t\t\t\ttwoSided: options.twoSided ?? Boolean(options.openEnded),\n\t\t\t},\n\t\t);\n\n\t\treturn withParts(modelNode, {\n\t\t\tfaces: [modelNode],\n\t\t\titems: [modelNode],\n\t\t}) as unknown as Shape3DContainer;\n\t},\n\n\t/**\n\t * Creates a solid N-sided regular polygonal pyramid (or truncated pyramid when `radiusTop > 0`)\n\t * with a bottom cap and crisp flat-shaded side facets.\n\t */\n\tpyramid(options: Pyramid3DOptions): AnimatableNode<Model3DNode> {\n\t\tconst n = Math.max(3, Math.round(options.sides ?? 4));\n\t\treturn primitiveNode(\n\t\t\t\"pyramid\",\n\t\t\t{\n\t\t\t\ttype: \"cylinder\",\n\t\t\t\tradius: options.radius ?? 60,\n\t\t\t\tradiusTop: options.radiusTop ?? 0,\n\t\t\t\tradiusBottom: options.radius ?? 60,\n\t\t\t\theight: options.height,\n\t\t\t\tsegments: n,\n\t\t\t\topenEnded: options.openEnded ?? false,\n\t\t\t\tflatShaded: options.flatShaded ?? true,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tcolor: options.color ?? \"#f59e0b\",\n\t\t\t\ttwoSided: options.twoSided ?? Boolean(options.openEnded),\n\t\t\t},\n\t\t);\n\t},\n\n\t/**\n\t * Creates a standalone planar 3D card/quad.\n\t */\n\tplane(options: Plane3DOptions): AnimatableNode<BoxNode> {\n\t\treturn Layer.box({\n\t\t\tid: options.id ?? autoId(\"plane\"),\n\t\t\tposition: \"absolute\",\n\t\t\twidth: options.width,\n\t\t\theight: options.height,\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\tis3D: true,\n\t\t\ttwoSided: options.twoSided ?? true,\n\t\t\trotateX: options.rotateX ?? 0,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\tbackground: options.background ?? \"#3b82f6\",\n\t\t\tborderRadius: options.borderRadius ?? 0,\n\t\t\topacity: options.opacity ?? 1,\n\t\t\t...materialProps(options),\n\t\t\tchildren: options.children ?? [],\n\t\t});\n\t},\n\n\t/**\n\t * Creates a 3D perspective ground grid: `divisions` cells per side, each\n\t * line its own unlit quad so it stays crisp at any camera distance.\n\t */\n\tgrid(options: Grid3DOptions): AnimatableNode<BoxNode> {\n\t\tconst { width, height } = options;\n\t\tconst id = options.id ?? autoId(\"grid\");\n\t\tconst divisions = Math.max(1, Math.round(options.divisions ?? 10));\n\t\tconst lineWidth = options.lineWidth ?? 2;\n\t\tconst color = options.color ?? \"rgba(59, 130, 246, 0.5)\";\n\t\tconst line = (\n\t\t\tlineId: string,\n\t\t\tx: number,\n\t\t\ty: number,\n\t\t\tw: number,\n\t\t\th: number,\n\t\t): AnimatableNode<BoxNode> =>\n\t\t\tLayer.box({\n\t\t\t\tid: `${id}-${lineId}`,\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tx,\n\t\t\t\ty,\n\t\t\t\tz: 0,\n\t\t\t\twidth: w,\n\t\t\t\theight: h,\n\t\t\t\tis3D: true,\n\t\t\t\ttwoSided: true,\n\t\t\t\tmaterial: \"unlit\",\n\t\t\t\tbackground: color,\n\t\t\t});\n\t\t// Every quad is backed by a texture of its own size, so long lines are\n\t\t// split into segments that stay well inside the GPU's texture limit.\n\t\tconst MAX_SEGMENT = 4096;\n\t\tconst lines: AnimatableNode<BoxNode>[] = [];\n\t\tconst vSegments = Math.ceil(height / MAX_SEGMENT);\n\t\tconst hSegments = Math.ceil(width / MAX_SEGMENT);\n\t\tfor (let i = 0; i <= divisions; i++) {\n\t\t\tconst u = i / divisions - 0.5;\n\t\t\tfor (let k = 0; k < vSegments; k++) {\n\t\t\t\tconst len = height / vSegments;\n\t\t\t\tconst y = -height / 2 + len * (k + 0.5);\n\t\t\t\tlines.push(line(`v${i}-${k}`, u * width, y, lineWidth, len));\n\t\t\t}\n\t\t\tfor (let k = 0; k < hSegments; k++) {\n\t\t\t\tconst len = width / hSegments;\n\t\t\t\tconst x = -width / 2 + len * (k + 0.5);\n\t\t\t\tlines.push(line(`h${i}-${k}`, x, u * height, len, lineWidth));\n\t\t\t}\n\t\t}\n\t\treturn Layer.box({\n\t\t\tid,\n\t\t\tposition: \"absolute\",\n\t\t\twidth,\n\t\t\theight,\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\tis3D: true,\n\t\t\ttransformStyle: \"preserve-3d\",\n\t\t\trotateX: options.rotateX ?? 90,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\tbackground: \"transparent\",\n\t\t\topacity: options.opacity ?? 1,\n\t\t\tchildren: lines,\n\t\t});\n\t},\n\n\t/**\n\t * Creates a standalone planar 3D text node, or solid extruded 3D text when `extrusionDepth` is set.\n\t */\n\ttext(options: Text3DOptions): AnimatableNode<LayoutNode> {\n\t\tif (options.extrusionDepth && options.extrusionDepth > 0) {\n\t\t\treturn Layer3D.extrudedText({\n\t\t\t\t...options,\n\t\t\t\tdepth: options.extrusionDepth,\n\t\t\t});\n\t\t}\n\n\t\treturn Layer.text(options.text, {\n\t\t\tid: options.id ?? autoId(\"text3d\"),\n\t\t\tposition: \"absolute\",\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\tis3D: true,\n\t\t\ttwoSided: options.twoSided ?? true,\n\t\t\trotateX: options.rotateX ?? 0,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\tfontSize: options.fontSize ?? 48,\n\t\t\tfontFamily: options.fontFamily,\n\t\t\tfontWeight: options.fontWeight ?? \"bold\",\n\t\t\tfontStyle: options.fontStyle,\n\t\t\tfill: options.fill ?? \"#ffffff\",\n\t\t\talign: (options.align ?? \"center\") as\n\t\t\t\t| \"left\"\n\t\t\t\t| \"center\"\n\t\t\t\t| \"right\"\n\t\t\t\t| \"start\"\n\t\t\t\t| \"end\",\n\t\t\tdirection: options.direction,\n\t\t\tverticalAlign: options.verticalAlign ?? \"middle\",\n\t\t\tletterSpacing: options.letterSpacing,\n\t\t\tlineHeight: options.lineHeight,\n\t\t\tmaterial: options.material ?? \"lit\",\n\t\t\tshininess: options.shininess ?? 64,\n\t\t\troughness: options.roughness,\n\t\t\tspecularIntensity: options.specularIntensity ?? 0.8,\n\t\t\tambientIntensity: options.ambientIntensity ?? 1.0,\n\t\t\tmetallic: options.metallic,\n\t\t\t...materialProps(options),\n\t\t\topacity: options.opacity ?? 1,\n\t\t\tbackground: options.background,\n\t\t\tborderRadius: options.borderRadius,\n\t\t\tpadding: options.padding,\n\t\t\tstroke: options.stroke,\n\t\t\tstrokeWidth: options.strokeWidth,\n\t\t});\n\t},\n\n\t/**\n\t * Creates solid extruded 3D typography: `fill` colors the letter faces,\n\t * `bevelColor` the side walls; curves are tessellated to `curveTolerance`.\n\t */\n\textrudedText(options: ExtrudedText3DOptions): Shape3DContainer {\n\t\tconst { depth, text, fill = \"#ffffff\", bevelColor } = options;\n\n\t\tlet modelData: Model3DData | undefined;\n\t\t// Tolerance is in on-screen px: a node scaled up 3x needs 3x finer geometry.\n\t\tconst curveTolerance =\n\t\t\t(options.curveTolerance ?? 0.1) / extrudedTextScale(options);\n\t\tconst parsedFont =\n\t\t\t(options.fontFamily\n\t\t\t\t? SlugFontCache.getParsed(options.fontFamily)\n\t\t\t\t: null) ??\n\t\t\tSlugFontCache.getParsed(\"Inter\") ??\n\t\t\tSlugFontCache.getParsed(\"Unbounded\") ??\n\t\t\tSlugFontCache.getFirstParsed();\n\n\t\tif (parsedFont) {\n\t\t\tconst res = generateExtrudedTextGeometry({\n\t\t\t\ttext,\n\t\t\t\t// SlugFontCache holds fontkit fonts under a narrower type.\n\t\t\t\tfont: parsedFont as unknown as Parameters<\n\t\t\t\t\ttypeof generateExtrudedTextGeometry\n\t\t\t\t>[0][\"font\"],\n\t\t\t\tfontSize: options.fontSize ?? 48,\n\t\t\t\tdepth,\n\t\t\t\tfill,\n\t\t\t\tbevelColor,\n\t\t\t\tcurveSegments: options.curveSegments,\n\t\t\t\tcurveTolerance,\n\t\t\t\talign: options.align,\n\t\t\t\tdirection: options.direction,\n\t\t\t\tverticalAlign: options.verticalAlign,\n\t\t\t\tletterSpacing: options.letterSpacing,\n\t\t\t\t// The mesh's own shading only knows these; glass and the like are\n\t\t\t\t// layer materials, applied by the model node below.\n\t\t\t\tmaterial:\n\t\t\t\t\toptions.material === \"lit\" ||\n\t\t\t\t\toptions.material === \"unlit\" ||\n\t\t\t\t\toptions.material === \"toon\"\n\t\t\t\t\t\t? options.material\n\t\t\t\t\t\t: undefined,\n\t\t\t\tshininess: options.shininess,\n\t\t\t\troughness: options.roughness,\n\t\t\t\tmetallic: options.metallic,\n\t\t\t});\n\t\t\tmodelData = res.modelData;\n\t\t}\n\n\t\tconst modelNode = Layer.model({\n\t\t\tid: options.id ?? autoId(\"extruded-text\"),\n\t\t\tmodelData,\n\t\t\tis3D: true,\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\trotateX: options.rotateX ?? 0,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\tscale: options.scale ?? 1,\n\t\t\tscaleX: options.scaleX ?? 1,\n\t\t\tscaleY: options.scaleY ?? 1,\n\t\t\tscaleZ: options.scaleZ ?? 1,\n\t\t\topacity: options.opacity ?? 1,\n\t\t\tmaterial: options.material,\n\t\t\tshininess: options.shininess ?? 32,\n\t\t\troughness: options.roughness,\n\t\t\tspecularIntensity: options.specularIntensity ?? 0.8,\n\t\t\tambientIntensity: options.ambientIntensity ?? 1.0,\n\t\t\tmetallic: options.metallic,\n\t\t\t...materialProps(options),\n\t\t\ttwoSided: options.twoSided ?? true,\n\t\t\t// What the compositor rebuilds the mesh from when modelData did not\n\t\t\t// survive (a spec sent as JSON): the same tolerance as here.\n\t\t\ttext3dOptions: { ...options, curveTolerance },\n\t\t});\n\n\t\treturn withParts(modelNode, {\n\t\t\tfaces: [modelNode],\n\t\t\titems: [modelNode],\n\t\t}) as unknown as Shape3DContainer;\n\t},\n\n\t/**\n\t * A solid box with rounded edges and corners, as one smooth-shaded mesh:\n\t * cards, buttons, device bodies. `taper` below 1 narrows the top (-y)\n\t * face, the shape of a keycap. Equal shapes share one GPU buffer.\n\t */\n\troundedBox(options: RoundedBox3DOptions): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"rounded-box\",\n\t\t\t{\n\t\t\t\ttype: \"roundedBox\",\n\t\t\t\twidth: options.width,\n\t\t\t\theight: options.height,\n\t\t\t\tdepth: options.depth,\n\t\t\t\tradius: options.radius,\n\t\t\t\tsegments: options.segments,\n\t\t\t\ttaper: options.taper,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/** A UV sphere mesh. */\n\tsphere(options: Sphere3DOptions): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"sphere\",\n\t\t\t{ type: \"sphere\", radius: options.radius, segments: options.segments },\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/** A capped cylinder, or a cone/frustum with different top and bottom radii. */\n\tcylinder(options: Cylinder3DOptions): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"cylinder\",\n\t\t\t{\n\t\t\t\ttype: \"cylinder\",\n\t\t\t\tradius: options.radius,\n\t\t\t\tradiusTop: options.radiusTop,\n\t\t\t\tradiusBottom: options.radiusBottom,\n\t\t\t\theight: options.height,\n\t\t\t\tsegments: options.segments,\n\t\t\t\topenEnded: options.openEnded,\n\t\t\t\tflatShaded: options.flatShaded,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\ttwoSided: options.twoSided ?? Boolean(options.openEnded),\n\t\t\t},\n\t\t);\n\t},\n\n\t/**\n\t * A 3D torus (donut / ring) mesh with major `radius`, tube radius `tube`,\n\t * and optional partial `arc` sweep in degrees.\n\t */\n\ttorus(options: Torus3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"torus\",\n\t\t\t{\n\t\t\t\ttype: \"torus\",\n\t\t\t\tradius: options.radius,\n\t\t\t\ttube: options.tube,\n\t\t\t\tradialSegments: options.radialSegments,\n\t\t\t\ttubularSegments: options.tubularSegments,\n\t\t\t\tarc: options.arc,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/**\n\t * A smooth 3D capsule (pill) mesh aligned along the Y axis: a cylinder of\n\t * length `length` and radius `radius` capped by two hemispheres.\n\t */\n\tcapsule(options: Capsule3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"capsule\",\n\t\t\t{\n\t\t\t\ttype: \"capsule\",\n\t\t\t\tradius: options.radius,\n\t\t\t\tlength: options.length,\n\t\t\t\tcapSegments: options.capSegments,\n\t\t\t\tradialSegments: options.radialSegments,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/**\n\t * A 3D ring / annulus with `innerRadius`, `outerRadius`, and optional `depth`\n\t * for a thick-walled washer/annular solid.\n\t */\n\tring(options: Ring3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"ring\",\n\t\t\t{\n\t\t\t\ttype: \"ring\",\n\t\t\t\tinnerRadius: options.innerRadius,\n\t\t\t\touterRadius: options.outerRadius,\n\t\t\t\tdepth: options.depth,\n\t\t\t\tthetaSegments: options.thetaSegments,\n\t\t\t\tphiSegments: options.phiSegments,\n\t\t\t\tthetaStart: options.thetaStart,\n\t\t\t\tthetaLength: options.thetaLength,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/**\n\t * A Platonic polyhedron (`tetrahedron`, `octahedron`, `dodecahedron`, `icosahedron`)\n\t * or geodesic `icosphere` with configurable subdivision `detail` and `flatShaded` facets.\n\t */\n\tpolyhedron(options: Polyhedron3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\tconst shape = options.shape ?? options.type ?? \"icosahedron\";\n\t\treturn primitiveNode(\n\t\t\tshape,\n\t\t\t{\n\t\t\t\ttype: \"polyhedron\",\n\t\t\t\tshape,\n\t\t\t\tradius: options.radius,\n\t\t\t\tdetail: options.detail,\n\t\t\t\tflatShaded: options.flatShaded,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/**\n\t * An icosahedron (20-sided regular polyhedron), optionally subdivided with `detail`.\n\t */\n\ticosahedron(options: Icosphere3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn Layer3D.polyhedron({ ...options, shape: \"icosahedron\" });\n\t},\n\n\t/**\n\t * An evenly distributed geodesic icosphere mesh (`detail` defaults to 2, smooth-shaded by default).\n\t */\n\ticosphere(options: Icosphere3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn Layer3D.polyhedron({\n\t\t\t...options,\n\t\t\tshape: \"icosphere\",\n\t\t\tdetail: options.detail ?? 2,\n\t\t\tflatShaded: options.flatShaded ?? false,\n\t\t});\n\t},\n\n\t/**\n\t * Extrudes a 2D outline (an SVG path string with curves/holes or a 2D point contour array)\n\t * into a 3D solid mesh with optional front/back bevels (`bevelThickness`, `bevelSize`, `bevelSegments`)\n\t * and separate side wall color (`bevelColor`).\n\t */\n\textrude(options: ExtrudeShape3DOptions): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"extrude\",\n\t\t\t{\n\t\t\t\ttype: \"extrude\",\n\t\t\t\tshape: options.shape,\n\t\t\t\td: options.d,\n\t\t\t\tcontour: options.contour,\n\t\t\t\tholes: options.holes,\n\t\t\t\tdepth: options.depth,\n\t\t\t\tbevelThickness: options.bevelThickness,\n\t\t\t\tbevelSize: options.bevelSize,\n\t\t\t\tbevelSegments: options.bevelSegments,\n\t\t\t\tbevelColor: options.bevelColor,\n\t\t\t\tcurveSegments: options.curveSegments,\n\t\t\t\tcurveTolerance: options.curveTolerance,\n\t\t\t\tcenter: options.center,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/**\n\t * Revolves a 2D profile (`[[r, y], ...]` or an SVG path string) around the Y axis\n\t * to create bowls, bottles, goblets, vases, and turned solids.\n\t */\n\tlathe(options: Lathe3DOptions): AnimatableNode<Model3DNode> {\n\t\tconst capped = options.capped ?? options.closed;\n\t\treturn primitiveNode(\n\t\t\t\"lathe\",\n\t\t\t{\n\t\t\t\ttype: \"lathe\",\n\t\t\t\tpoints: options.points,\n\t\t\t\tsegments: options.segments,\n\t\t\t\tphiStart: options.phiStart,\n\t\t\t\tphiLength: options.phiLength,\n\t\t\t\tcapped,\n\t\t\t\tclosed: options.closed,\n\t\t\t\tflatShaded: options.flatShaded,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\ttwoSided: options.twoSided ?? !(capped ?? false),\n\t\t\t},\n\t\t);\n\t},\n\n\t/**\n\t * Sweeps a circular or thick-walled hollow pipe cross-section (`innerRadius > 0`)\n\t * along a 3D curve (`Path3D`, `TubePathSpec`, or 3D waypoints `[x, y, z]`) using\n\t * Rotation-Minimizing Frames.\n\t */\n\ttube(options: Tube3DOptions): AnimatableNode<Model3DNode> {\n\t\tconst pathInput = options.path ?? options.points;\n\t\tif (!pathInput) {\n\t\t\tthrow new Error(\"Layer3D.tube requires `path` or `points`\");\n\t\t}\n\t\treturn primitiveNode(\n\t\t\t\"tube\",\n\t\t\t{\n\t\t\t\ttype: \"tube\",\n\t\t\t\tpath: normalizePathSpec(pathInput),\n\t\t\t\tradius: options.radius,\n\t\t\t\tinnerRadius: options.innerRadius,\n\t\t\t\tradiusTaper: options.radiusTaper,\n\t\t\t\ttubularSegments: options.tubularSegments,\n\t\t\t\tradialSegments: options.radialSegments,\n\t\t\t\tclosed: options.closed,\n\t\t\t\tcapped: options.capped,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\ttwoSided: options.twoSided ?? options.capped === false,\n\t\t\t},\n\t\t);\n\t},\n\n\t/**\n\t * 3D line / curve geometry (`line-list` topology) along 3D points or a `Path3D` curve,\n\t * supporting dashed segments (`dashSize`, `gapSize`) and per-vertex colors for 3D diagrams.\n\t */\n\tline(options: Line3DOptions): AnimatableNode<Model3DNode> {\n\t\tconst pointsInput = options.points ?? options.path;\n\t\tif (!pointsInput) {\n\t\t\tthrow new Error(\"Layer3D.line requires `points` or `path`\");\n\t\t}\n\t\treturn primitiveNode(\n\t\t\t\"line3d\",\n\t\t\t{\n\t\t\t\ttype: \"line3d\",\n\t\t\t\tpoints: normalizePathSpec(pointsInput),\n\t\t\t\tcolors: options.colors,\n\t\t\t\tmode: options.mode,\n\t\t\t\tclosed: options.closed,\n\t\t\t\tdashSize: options.dashSize,\n\t\t\t\tgapSize: options.gapSize,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tmaterial: options.material ?? \"unlit\",\n\t\t\t\tcastShadow: options.castShadow ?? false,\n\t\t\t},\n\t\t);\n\t},\n\n\t/**\n\t * 3D point cloud / diagram vertex geometry along 3D points or a `Path3D` curve.\n\t * Pass `pointSize > 0` for 3D spherical diagram dots that scale in perspective,\n\t * or omit `pointSize` for native GPU `point-list` pixels.\n\t */\n\tpoints(options: Points3DOptions): AnimatableNode<Model3DNode> {\n\t\tconst isPixelPoints = (options.pointSize ?? 0) <= 0;\n\t\treturn primitiveNode(\n\t\t\t\"points3d\",\n\t\t\t{\n\t\t\t\ttype: \"points3d\",\n\t\t\t\tpoints: normalizePathSpec(options.points),\n\t\t\t\tcolors: options.colors,\n\t\t\t\tpointSize: options.pointSize,\n\t\t\t},\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tmaterial: options.material ?? (isPixelPoints ? \"unlit\" : \"lit\"),\n\t\t\t\tcastShadow: options.castShadow ?? !isPixelPoints,\n\t\t\t},\n\t\t);\n\t},\n\n\t/**\n\t * A procedural faceted convex polyhedron / rock shard: carved from half-space planes.\n\t * Convex hull collider in Physics.world3d is derived automatically.\n\t */\n\tshard(options: Shard3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn primitiveNode(\n\t\t\t\"shard\",\n\t\t\t{\n\t\t\t\ttype: \"shard\",\n\t\t\t\tradius: options.radius,\n\t\t\t\tsize: options.size,\n\t\t\t\tfacets: options.facets,\n\t\t\t\tseed: options.seed,\n\t\t\t\tirregularity: options.irregularity,\n\t\t\t},\n\t\t\toptions,\n\t\t);\n\t},\n\n\t/**\n\t * Single-draw-call hardware-instanced 3D mesh batch node.\n\t * Renders hundreds or thousands of 3D meshes in 1 draw call per mesh variant,\n\t * driven by Physics.world3d rigid bodies, procedural callbacks, or transform arrays.\n\t */\n\tinstances(options: Instances3DOptions): AnimatableNode<Model3DNode> {\n\t\tconst primaryMesh = Array.isArray(options.mesh)\n\t\t\t? options.mesh[0]\n\t\t\t: options.mesh;\n\t\tconst node: Model3DNode = {\n\t\t\tid: options.id ?? autoId(\"instances3d\"),\n\t\t\tkind: \"model3d\",\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? 0,\n\t\t\trotateX: options.rotateX ?? 0,\n\t\t\trotateY: options.rotateY ?? 0,\n\t\t\trotateZ: options.rotateZ ?? 0,\n\t\t\tscale: options.scale ?? 1,\n\t\t\tcolor: options.color,\n\t\t\tcolorTint: options.colorTint,\n\t\t\topacity: options.opacity ?? 1,\n\t\t\ttwoSided: options.twoSided ?? true,\n\t\t\twireframe: options.wireframe ?? false,\n\t\t\tmaterial: options.material ?? \"lit\",\n\t\t\troughness: options.roughness,\n\t\t\tmetallic: options.metallic,\n\t\t\tspecularIntensity: options.specularIntensity,\n\t\t\tambientIntensity: options.ambientIntensity,\n\t\t\tstartFrame: options.startFrame,\n\t\t\tdurationFrames: options.durationFrames,\n\t\t\tinstances3d: { ...options },\n\t\t\t...materialProps(options),\n\t\t};\n\t\tif (primaryMesh) {\n\t\t\tconst m = primaryMesh as unknown as Record<string, unknown>;\n\t\t\tif (m.modelData) node.modelData = m.modelData;\n\t\t\tif (m.primitive3d) node.primitive3d = m.primitive3d;\n\t\t\tif (m.src) node.src = m.src as string;\n\t\t}\n\t\treturn Layer.model(\n\t\t\tnode as unknown as Partial<Model3DNode>,\n\t\t) as unknown as AnimatableNode<Model3DNode>;\n\t},\n\n\t/**\n\t * GPU-simulated 3D particle swarm and shard system.\n\t * Simulates thousands of 3D mesh particles natively inside WebGPU with 3D curl noise,\n\t * attractors, vortex fields, floor collisions, and speed/friction-driven HDR bloom emission.\n\t */\n\tswarm(options: Swarm3DOptions = {}): AnimatableNode<Model3DNode> {\n\t\treturn createSwarm3D(options);\n\t},\n\n\t/**\n\t * Creates a 3D model node rendered natively with WebGPU mesh shaders.\n\t */\n\tmodel(options: Partial<Model3DNode> = {}): AnimatableNode<Model3DNode> {\n\t\treturn Layer.model(options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D Wavefront OBJ model node.\n\t */\n\tobj(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.obj(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D Autodesk FBX model node with skeletal animation support.\n\t */\n\tfbx(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.fbx(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D glTF 2.0 model node.\n\t */\n\tgltf(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.gltf(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D GLB binary container model node.\n\t */\n\tglb(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.glb(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D STL CAD / 3D printing model node.\n\t */\n\tstl(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.stl(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D Stanford PLY scan model node.\n\t */\n\tply(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.ply(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D MagicaVoxel VOX model node.\n\t */\n\tvox(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.vox(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D Studio (3DS) binary model node.\n\t */\n\tthreeDS(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.threeDS(src, options);\n\t},\n\n\t/**\n\t * Convenience helper to create a 3D Object File Format (OFF) model node.\n\t */\n\toff(\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> {\n\t\treturn Layer.off(src, options);\n\t},\n};\n","/**\n * Scene sequencing with transitions. `Layer.sequence` lays scenes end to end\n * and overlaps neighbours by each transition's length; the transition itself\n * is plain keyframes (and, for wipes and irises, a track matte) merged into\n * the scenes, so it renders like anything else and stays editable.\n */\nimport {\n\ttype AnimationTrack,\n\ttype BoxNode,\n\tLayerAnimation,\n\ttype LayoutNode,\n} from \"@framefields/compositions/program\";\nimport { autoId } from \"./ids.js\";\nimport { type AnimatableNode, Layer } from \"./index.js\";\n\nexport type TransitionDirection = \"left\" | \"right\" | \"up\" | \"down\";\n\n/** What a transition needs to know to animate two scenes. */\ninterface TransitionContext {\n\t/** Scene size (px). */\n\twidth: number;\n\theight: number;\n\t/** Overlap length in frames. */\n\tframes: number;\n\t/** Outgoing scene: local frame where the overlap starts, and its rest position. */\n\toutStart: number;\n\toutRest: { x: number; y: number };\n\t/** Incoming scene rest position (the overlap starts at its local frame 0). */\n\tinRest: { x: number; y: number };\n}\n\ninterface TransitionParts {\n\toutgoing?: LayerAnimation;\n\tincoming?: LayerAnimation;\n\t/** A matte revealing the incoming scene (laid out like the scene, keyed from its start). */\n\tincomingMatte?: LayoutNode;\n\t/** Static props set on both scenes (e.g. motion blur for a whip). */\n\tsceneProps?: Record<string, unknown>;\n}\n\nexport interface TransitionSpec {\n\treadonly kind: string;\n\t/** Overlap between the two scenes, in frames (0 = hard cut). */\n\treadonly frames: number;\n\t/** @internal */\n\tbuild(ctx: TransitionContext): TransitionParts;\n}\n\nconst offsetFor = (dir: TransitionDirection, w: number, h: number) => {\n\tswitch (dir) {\n\t\tcase \"left\":\n\t\t\treturn { dx: -w, dy: 0 };\n\t\tcase \"right\":\n\t\t\treturn { dx: w, dy: 0 };\n\t\tcase \"up\":\n\t\t\treturn { dx: 0, dy: -h };\n\t\tdefault:\n\t\t\treturn { dx: 0, dy: h };\n\t}\n};\n\nfunction spec(\n\tkind: string,\n\tframes: number,\n\tbuild: (ctx: TransitionContext) => TransitionParts,\n): TransitionSpec {\n\treturn { kind, frames: Math.max(0, Math.round(frames)), build };\n}\n\n/**\n * Scene-to-scene transitions for `Layer.sequence`. `frames` is how long the\n * two scenes overlap; `ease` shapes the move (default \"power3.inOut\").\n */\nexport const Transition = {\n\t/** Instant cut. */\n\tcut: (): TransitionSpec => spec(\"cut\", 0, () => ({})),\n\n\t/** The incoming scene fades in over the outgoing one. */\n\tcrossfade: (frames = 15, ease = \"sine.inOut\"): TransitionSpec =>\n\t\tspec(\"crossfade\", frames, (c) => ({\n\t\t\tincoming: LayerAnimation.keys(\"opacity\", [\n\t\t\t\t[0, 0],\n\t\t\t\t[c.frames, 1, ease],\n\t\t\t]),\n\t\t})),\n\n\t/** Out to the background, then in: a dip to the composition's background color. */\n\tfadeThrough: (frames = 20, ease = \"sine.inOut\"): TransitionSpec =>\n\t\tspec(\"fadeThrough\", frames, (c) => {\n\t\t\tconst half = Math.max(1, Math.floor(c.frames / 2));\n\t\t\treturn {\n\t\t\t\toutgoing: LayerAnimation.keys(\"opacity\", [\n\t\t\t\t\t[c.outStart, 1],\n\t\t\t\t\t[c.outStart + half, 0, ease],\n\t\t\t\t]),\n\t\t\t\tincoming: LayerAnimation.keys(\"opacity\", [\n\t\t\t\t\t[0, 0],\n\t\t\t\t\t[half, 0],\n\t\t\t\t\t[c.frames, 1, ease],\n\t\t\t\t]),\n\t\t\t};\n\t\t}),\n\n\t/** Both scenes move together: the new one pushes the old one out toward `direction`. */\n\tpush: (\n\t\tdirection: TransitionDirection = \"left\",\n\t\tframes = 18,\n\t\tease = \"power3.inOut\",\n\t): TransitionSpec =>\n\t\tspec(\"push\", frames, (c) => {\n\t\t\tconst { dx, dy } = offsetFor(direction, c.width, c.height);\n\t\t\tconst out = LayerAnimation.create();\n\t\t\tconst inc = LayerAnimation.create();\n\t\t\tif (dx !== 0) {\n\t\t\t\tout.keys(\"x\", [\n\t\t\t\t\t[c.outStart, c.outRest.x],\n\t\t\t\t\t[c.outStart + c.frames, c.outRest.x + dx, ease],\n\t\t\t\t]);\n\t\t\t\tinc.keys(\"x\", [\n\t\t\t\t\t[0, c.inRest.x - dx],\n\t\t\t\t\t[c.frames, c.inRest.x, ease],\n\t\t\t\t]);\n\t\t\t} else {\n\t\t\t\tout.keys(\"y\", [\n\t\t\t\t\t[c.outStart, c.outRest.y],\n\t\t\t\t\t[c.outStart + c.frames, c.outRest.y + dy, ease],\n\t\t\t\t]);\n\t\t\t\tinc.keys(\"y\", [\n\t\t\t\t\t[0, c.inRest.y - dy],\n\t\t\t\t\t[c.frames, c.inRest.y, ease],\n\t\t\t\t]);\n\t\t\t}\n\t\t\treturn { outgoing: out, incoming: inc };\n\t\t}),\n\n\t/** The new scene slides in over the old one, which stays put and dims slightly. */\n\tslide: (\n\t\tdirection: TransitionDirection = \"left\",\n\t\tframes = 18,\n\t\tease = \"power3.out\",\n\t): TransitionSpec =>\n\t\tspec(\"slide\", frames, (c) => {\n\t\t\tconst { dx, dy } = offsetFor(direction, c.width, c.height);\n\t\t\tconst prop = dx !== 0 ? \"x\" : \"y\";\n\t\t\tconst rest = dx !== 0 ? c.inRest.x : c.inRest.y;\n\t\t\treturn {\n\t\t\t\toutgoing: LayerAnimation.keys(\"opacity\", [\n\t\t\t\t\t[c.outStart, 1],\n\t\t\t\t\t[c.outStart + c.frames, 0.6, ease],\n\t\t\t\t]),\n\t\t\t\tincoming: LayerAnimation.keys(prop, [\n\t\t\t\t\t[0, rest - (dx || dy)],\n\t\t\t\t\t[c.frames, rest, ease],\n\t\t\t\t]),\n\t\t\t};\n\t\t}),\n\n\t/** Old scene grows and fades, new one settles in from slightly small. */\n\tzoom: (frames = 18, ease = \"power2.inOut\"): TransitionSpec =>\n\t\tspec(\"zoom\", frames, (c) => ({\n\t\t\toutgoing: LayerAnimation.create()\n\t\t\t\t.keys(\"scale\", [\n\t\t\t\t\t[c.outStart, 1],\n\t\t\t\t\t[c.outStart + c.frames, 1.25, ease],\n\t\t\t\t])\n\t\t\t\t.keys(\"opacity\", [\n\t\t\t\t\t[c.outStart, 1],\n\t\t\t\t\t[c.outStart + c.frames, 0, ease],\n\t\t\t\t]),\n\t\t\tincoming: LayerAnimation.create()\n\t\t\t\t.keys(\"scale\", [\n\t\t\t\t\t[0, 0.85],\n\t\t\t\t\t[c.frames, 1, ease],\n\t\t\t\t])\n\t\t\t\t.keys(\"opacity\", [\n\t\t\t\t\t[0, 0],\n\t\t\t\t\t[c.frames, 1, ease],\n\t\t\t\t]),\n\t\t})),\n\n\t/** A fast, motion-blurred push: the camera whips to the next scene. */\n\twhip: (\n\t\tdirection: TransitionDirection = \"left\",\n\t\tframes = 10,\n\t): TransitionSpec => {\n\t\tconst push = Transition.push(direction, frames, \"expo.inOut\");\n\t\treturn spec(\"whip\", frames, (c) => ({\n\t\t\t...push.build(c),\n\t\t\tsceneProps: { motionBlurShutter: 360 },\n\t\t}));\n\t},\n\n\t/** A hard edge sweeps across, revealing the new scene. */\n\twipe: (\n\t\tdirection: TransitionDirection = \"left\",\n\t\tframes = 18,\n\t\tease = \"power2.inOut\",\n\t): TransitionSpec =>\n\t\tspec(\"wipe\", frames, (c) => {\n\t\t\t// `direction` is where the edge travels: \"left\" reveals from the right.\n\t\t\tconst { dx, dy } = offsetFor(direction, c.width, c.height);\n\t\t\tconst prop = dx !== 0 ? \"x\" : \"y\";\n\t\t\tconst rest = dx !== 0 ? c.inRest.x : c.inRest.y;\n\t\t\treturn {\n\t\t\t\tincomingMatte: Layer.box({\n\t\t\t\t\tid: autoId(\"wipe-matte\"),\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tx: c.inRest.x,\n\t\t\t\t\ty: c.inRest.y,\n\t\t\t\t\twidth: c.width,\n\t\t\t\t\theight: c.height,\n\t\t\t\t\tbackground: \"#ffffff\",\n\t\t\t\t}).animate(\n\t\t\t\t\tLayerAnimation.keys(prop, [\n\t\t\t\t\t\t[0, rest - (dx || dy)],\n\t\t\t\t\t\t[c.frames, rest, ease],\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t};\n\t\t}),\n\n\t/** A circle opens from the center (or `at`, as fractions of the frame) to reveal the new scene. */\n\tiris: (\n\t\tframes = 20,\n\t\toptions: { at?: [number, number]; ease?: string } = {},\n\t): TransitionSpec =>\n\t\tspec(\"iris\", frames, (c) => {\n\t\t\tconst [fx, fy] = options.at ?? [0.5, 0.5];\n\t\t\tconst cx = c.inRest.x + fx * c.width;\n\t\t\tconst cy = c.inRest.y + fy * c.height;\n\t\t\t// Big enough to cover the farthest corner.\n\t\t\tconst r = Math.hypot(\n\t\t\t\tMath.max(fx, 1 - fx) * c.width,\n\t\t\t\tMath.max(fy, 1 - fy) * c.height,\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tincomingMatte: Layer.shape(\"circle\", {\n\t\t\t\t\tid: autoId(\"iris-matte\"),\n\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\tx: cx - r,\n\t\t\t\t\ty: cy - r,\n\t\t\t\t\twidth: r * 2,\n\t\t\t\t\theight: r * 2,\n\t\t\t\t\tfillColor: \"#ffffff\",\n\t\t\t\t}).animate(\n\t\t\t\t\tLayerAnimation.keys(\"scale\", [\n\t\t\t\t\t\t[0, 0],\n\t\t\t\t\t\t[c.frames, 1, options.ease ?? \"power2.inOut\"],\n\t\t\t\t\t]),\n\t\t\t\t),\n\t\t\t};\n\t\t}),\n};\n\nexport interface SequenceEntry {\n\t/** A full-frame layer (usually a box holding the scene). */\n\tscene: AnimatableNode<LayoutNode> | LayoutNode;\n\t/** Frames this scene is on screen, transitions included. */\n\tduration: number;\n\t/** How this scene arrives from the previous one (default: cut). */\n\ttransition?: TransitionSpec;\n}\n\nexport interface SceneSequenceOptions {\n\tid?: string;\n\t/** Scene size used by moving transitions (default: each scene's own width/height, else 1920×1080). */\n\twidth?: number;\n\theight?: number;\n\t/** First frame of the whole sequence. Default 0. */\n\tstartFrame?: number;\n}\n\nexport type SequenceNode = AnimatableNode<BoxNode> & {\n\t/** Total length in frames: put it in the composition's duration. */\n\treadonly totalFrames: number;\n\t/** Where each scene starts (composition frames, relative to the sequence). */\n\treadonly sceneStarts: readonly number[];\n};\n\nfunction sizeOf(node: LayoutNode, axis: \"width\" | \"height\", fallback: number) {\n\tconst v = (node as unknown as Record<string, unknown>)[axis];\n\treturn typeof v === \"number\" ? v : fallback;\n}\n\n/**\n * Scenes back to back, each overlapping the previous one by its transition.\n * Scene timing is set for you (`startFrame` / `durationFrames`), so every\n * scene keys its own animation from its local frame 0.\n */\nexport function sequence(\n\tentries: SequenceEntry[],\n\toptions: SceneSequenceOptions = {},\n): SequenceNode {\n\tconst scenes: LayoutNode[] = [];\n\tconst starts: number[] = [];\n\tlet cursor = 0;\n\tentries.forEach((entry, i) => {\n\t\tconst t = i === 0 ? undefined : entry.transition;\n\t\tconst overlap = Math.min(t?.frames ?? 0, entries[i - 1]?.duration ?? 0);\n\t\tconst start = Math.max(0, cursor - overlap);\n\t\tconst duration = Math.max(1, Math.round(entry.duration));\n\t\tstarts.push(start);\n\t\tconst node = entry.scene as LayoutNode & Record<string, unknown>;\n\t\t// Scenes stack in one frame rather than flowing one under the other.\n\t\tif (node.position === undefined || node.position === \"relative\") {\n\t\t\tnode.position = \"absolute\";\n\t\t\tnode.x ??= 0;\n\t\t\tnode.y ??= 0;\n\t\t}\n\t\tnode.startFrame = start;\n\t\tnode.durationFrames = duration;\n\t\tscenes.push(node);\n\t\tcursor = start + duration;\n\t});\n\n\tentries.forEach((entry, i) => {\n\t\tif (i === 0 || !entry.transition || entry.transition.frames === 0) return;\n\t\tconst prev = scenes[i - 1] as LayoutNode & Record<string, unknown>;\n\t\tconst cur = scenes[i] as LayoutNode & Record<string, unknown>;\n\t\tconst frames = Math.min(entry.transition.frames, entries[i - 1].duration);\n\t\tconst width = options.width ?? sizeOf(cur, \"width\", 1920);\n\t\tconst height = options.height ?? sizeOf(cur, \"height\", 1080);\n\t\tconst parts = entry.transition.build({\n\t\t\twidth,\n\t\t\theight,\n\t\t\tframes,\n\t\t\toutStart: entries[i - 1].duration - frames,\n\t\t\toutRest: {\n\t\t\t\tx: typeof prev.x === \"number\" ? prev.x : 0,\n\t\t\t\ty: typeof prev.y === \"number\" ? prev.y : 0,\n\t\t\t},\n\t\t\tinRest: {\n\t\t\t\tx: typeof cur.x === \"number\" ? cur.x : 0,\n\t\t\t\ty: typeof cur.y === \"number\" ? cur.y : 0,\n\t\t\t},\n\t\t});\n\t\tconst merge = (\n\t\t\tnode: LayoutNode & Record<string, unknown>,\n\t\t\tanim?: LayerAnimation,\n\t\t) => {\n\t\t\tif (!anim) return;\n\t\t\tconst existing =\n\t\t\t\t(node.animation as { tracks?: AnimationTrack[] } | undefined)?.tracks ??\n\t\t\t\t[];\n\t\t\tnode.animation = LayerAnimation.merge(\n\t\t\t\t{ tracks: existing },\n\t\t\t\tanim,\n\t\t\t).toSpec();\n\t\t};\n\t\tmerge(prev, parts.outgoing);\n\t\tmerge(cur, parts.incoming);\n\t\tif (parts.sceneProps) {\n\t\t\tObject.assign(prev, parts.sceneProps);\n\t\t\tObject.assign(cur, parts.sceneProps);\n\t\t}\n\t\tif (parts.incomingMatte) {\n\t\t\tcur.matte = { node: parts.incomingMatte, mode: \"alpha\" };\n\t\t}\n\t});\n\n\tconst root = Layer.box({\n\t\tid: options.id ?? autoId(\"sequence\"),\n\t\tposition: \"absolute\",\n\t\tx: 0,\n\t\ty: 0,\n\t\twidth:\n\t\t\toptions.width ?? sizeOf(scenes[0] ?? ({} as LayoutNode), \"width\", 1920),\n\t\theight:\n\t\t\toptions.height ?? sizeOf(scenes[0] ?? ({} as LayoutNode), \"height\", 1080),\n\t\tstartFrame: options.startFrame ?? 0,\n\t\tdurationFrames: Math.max(1, cursor),\n\t\tchildren: scenes,\n\t});\n\tObject.defineProperty(root, \"totalFrames\", {\n\t\tvalue: cursor,\n\t\tenumerable: false,\n\t});\n\tObject.defineProperty(root, \"sceneStarts\", {\n\t\tvalue: starts,\n\t\tenumerable: false,\n\t});\n\treturn root as SequenceNode;\n}\n","import type {\n\tEnvironmentPreset,\n\tLightNode,\n\tToneMapping,\n} from \"@framefields/compositions/program\";\nimport { autoId } from \"./ids.js\";\nimport {\n\ttype AnimatableNode,\n\ttype EnvironmentOptions,\n\tLight,\n} from \"./index.js\";\n\nexport interface LightingRigOptions {\n\t/** What the lights aim at (world px). Default: the canvas center at z 0. */\n\ttarget?: [number, number, number];\n\t/** How far the lights sit from the target. Default 1600. */\n\tdistance?: number;\n\t/** Turns the whole rig (lights and environment) around the vertical axis, degrees. */\n\trotation?: number;\n\t/** Scales every light. Default 1. */\n\tintensity?: number;\n\t/** Exposure in stops. Default 0. */\n\texposure?: number;\n\ttoneMapping?: ToneMapping;\n\t/** Key light casts a soft shadow. Default true. */\n\tshadows?: boolean;\n\t/** Shadow edge blur in texels. Default 3. */\n\tshadowSoftness?: number;\n\t/** Fog fading into the background, e.g. `{ color: BG, start: 2500, end: 6000 }`. */\n\tfog?: EnvironmentOptions[\"fog\"];\n\t/** Glow around emissive surfaces and highlights: `true` or settings. */\n\tbloom?: EnvironmentOptions[\"bloom\"];\n\t/** Prefix for the rig's node ids. */\n\tid?: string;\n}\n\ninterface RigSpec {\n\tenvironment: EnvironmentPreset;\n\tenvIntensity: number;\n\t/** Light directions relative to the target, before `rotation`; y is down. */\n\tkey: { dir: [number, number, number]; color: string; intensity: number };\n\trim?: { dir: [number, number, number]; color: string; intensity: number };\n\tfill?: { dir: [number, number, number]; color: string; intensity: number };\n}\n\nconst RIGS = {\n\t/** Product photography: soft overhead key with a shadow, cool rim, studio reflections. */\n\tstudio: {\n\t\tenvironment: \"studio\",\n\t\tenvIntensity: 1,\n\t\tkey: { dir: [-0.55, -1, -0.7], color: \"#fff6ec\", intensity: 1.1 },\n\t\trim: { dir: [0.9, -0.5, 0.9], color: \"#dbe8ff\", intensity: 0.9 },\n\t},\n\t/** Bright, airy, low contrast: lifestyle and UI-on-device shots. */\n\tsoft: {\n\t\tenvironment: \"soft\",\n\t\tenvIntensity: 1,\n\t\tkey: { dir: [-0.4, -1, -0.8], color: \"#ffffff\", intensity: 1.0 },\n\t},\n\t/** Low warm sun, long shadows, cool sky fill. */\n\tsunset: {\n\t\tenvironment: \"sunset\",\n\t\tenvIntensity: 0.9,\n\t\tkey: { dir: [-1, -0.35, -0.3], color: \"#ffb27a\", intensity: 2.2 },\n\t\tfill: { dir: [0.8, -0.6, -0.4], color: \"#7f9cff\", intensity: 0.35 },\n\t},\n\t/** Moody: dark world, hard key, strong rim. Pair with emissive accents. */\n\tdramatic: {\n\t\tenvironment: \"night\",\n\t\tenvIntensity: 0.8,\n\t\tkey: { dir: [-0.8, -1, -0.35], color: \"#ffffff\", intensity: 2.4 },\n\t\trim: { dir: [0.7, -0.4, 1], color: \"#8fb4ff\", intensity: 1.8 },\n\t},\n} satisfies Record<string, RigSpec>;\n\nexport type LightingRig = keyof typeof RIGS;\n\nfunction rotateY(\n\t[x, y, z]: [number, number, number],\n\tdegrees: number,\n): [number, number, number] {\n\tconst r = (degrees * Math.PI) / 180;\n\tconst c = Math.cos(r);\n\tconst s = Math.sin(r);\n\treturn [c * x + s * z, y, -s * x + c * z];\n}\n\nfunction aim(\n\tdir: [number, number, number],\n\ttarget: [number, number, number],\n\tdistance: number,\n\trotation: number,\n): Pick<LightNode, \"x\" | \"y\" | \"z\" | \"targetX\" | \"targetY\" | \"targetZ\"> {\n\tconst [dx, dy, dz] = rotateY(dir, rotation);\n\tconst len = Math.hypot(dx, dy, dz) || 1;\n\treturn {\n\t\tx: target[0] + (dx / len) * distance,\n\t\ty: target[1] + (dy / len) * distance,\n\t\tz: target[2] + (dz / len) * distance,\n\t\ttargetX: target[0],\n\t\ttargetY: target[1],\n\t\ttargetZ: target[2],\n\t};\n}\n\nfunction rig(\n\tname: LightingRig,\n\toptions: LightingRigOptions,\n): AnimatableNode<LightNode>[] {\n\tconst spec: RigSpec = RIGS[name];\n\tconst target = options.target ?? [960, 540, 0];\n\tconst distance = options.distance ?? 1600;\n\tconst rotation = options.rotation ?? 0;\n\tconst k = options.intensity ?? 1;\n\tconst id = options.id ?? autoId(`lighting-${name}`);\n\tconst nodes: AnimatableNode<LightNode>[] = [\n\t\tLight.environment(spec.environment, {\n\t\t\tid: `${id}-environment`,\n\t\t\tintensity: spec.envIntensity * k,\n\t\t\trotation,\n\t\t\texposure: options.exposure,\n\t\t\ttoneMapping: options.toneMapping,\n\t\t\tfog: options.fog,\n\t\t\tbloom: options.bloom,\n\t\t}),\n\t\tLight.directional({\n\t\t\tid: `${id}-key`,\n\t\t\tcolor: spec.key.color,\n\t\t\tintensity: spec.key.intensity * k,\n\t\t\t...aim(spec.key.dir, target, distance, rotation),\n\t\t\tcastShadow: options.shadows ?? true,\n\t\t\tshadowSoftness: options.shadowSoftness ?? 3,\n\t\t}),\n\t];\n\tfor (const [part, light] of [\n\t\t[\"rim\", spec.rim],\n\t\t[\"fill\", spec.fill],\n\t] as const) {\n\t\tif (!light) continue;\n\t\tnodes.push(\n\t\t\tLight.directional({\n\t\t\t\tid: `${id}-${part}`,\n\t\t\t\tcolor: light.color,\n\t\t\t\tintensity: light.intensity * k,\n\t\t\t\t...aim(light.dir, target, distance, rotation),\n\t\t\t}),\n\t\t);\n\t}\n\treturn nodes;\n}\n\n/**\n * Ready-made lighting: an environment (physical shading, tone mapping) plus\n * placed key / rim / fill lights, the key casting a soft shadow. Add the\n * returned nodes to the composition: `comp.add(Lighting.studio({ target }))`.\n *\n * Tweak from there rather than starting from zero: `intensity`, `exposure`,\n * `rotation` (turns the rig), `shadowSoftness`, `fog`.\n */\nexport const Lighting = {\n\tstudio: (options: LightingRigOptions = {}) => rig(\"studio\", options),\n\tsoft: (options: LightingRigOptions = {}) => rig(\"soft\", options),\n\tsunset: (options: LightingRigOptions = {}) => rig(\"sunset\", options),\n\tdramatic: (options: LightingRigOptions = {}) => rig(\"dramatic\", options),\n};\n","/**\n * The simulation backend the physics worlds drive. Worlds talk to this\n * engine-neutral surface only, so another solver can be dropped in later;\n * Rapier (deterministic builds, identical results on every platform) is the\n * one shipped. Units here are SI: meters, radians, seconds, y down.\n */\nimport type RAPIER2D from \"@dimforge/rapier2d-deterministic-compat\";\nimport type RAPIER3D from \"@dimforge/rapier3d-deterministic-compat\";\n\nexport type Vec2 = [number, number];\nexport type Vec3 = [number, number, number];\n/** Quaternion as [x, y, z, w]. */\nexport type Quat = [number, number, number, number];\n\nexport type BodyType = \"dynamic\" | \"fixed\" | \"kinematic\";\n\ninterface MaterialSpec {\n\tdensity: number;\n\tfriction: number;\n\trestitution: number;\n}\n\nexport type Shape2D =\n\t| { kind: \"box\"; hx: number; hy: number; radius?: number }\n\t| { kind: \"ball\"; radius: number }\n\t/** Flat [x0, y0, x1, y1, …] around the body origin. */\n\t| { kind: \"hull\"; points: number[] };\n\nexport type Shape3D =\n\t| { kind: \"box\"; hx: number; hy: number; hz: number; radius?: number }\n\t| { kind: \"ball\"; radius: number }\n\t/** Axis along y. */\n\t| { kind: \"cylinder\"; halfHeight: number; radius: number }\n\t/** Flat [x0, y0, z0, …] around the body origin. */\n\t| { kind: \"hull\"; points: number[] };\n\ninterface BodySpecBase extends MaterialSpec {\n\ttype: BodyType;\n\tlinearDamping: number;\n\tangularDamping: number;\n\tgravityScale: number;\n\tlockRotation: boolean;\n\tccd: boolean;\n\tenabled: boolean;\n\t/** Touches nothing (joint anchors). */\n\tsensor?: boolean;\n}\n\nexport interface BodySpec2D extends BodySpecBase {\n\tposition: Vec2;\n\tangle: number;\n\tvelocity: Vec2;\n\tangularVelocity: number;\n\tshape: Shape2D;\n}\n\nexport interface BodySpec3D extends BodySpecBase {\n\t/** Per-axis rotation, when only some axes are locked: [x, y, z] allowed. */\n\tenabledRotations?: [boolean, boolean, boolean];\n\tposition: Vec3;\n\trotation: Quat;\n\tvelocity: Vec3;\n\tangularVelocity: Vec3;\n\tshape: Shape3D;\n}\n\nexport type JointSpec<V> =\n\t| { type: \"revolute\"; anchorA: V; anchorB: V; axis?: Vec3 }\n\t| { type: \"spherical\"; anchorA: V; anchorB: V }\n\t| { type: \"fixed\"; anchorA: V; anchorB: V }\n\t| { type: \"rope\"; anchorA: V; anchorB: V; length: number }\n\t| {\n\t\t\ttype: \"spring\";\n\t\t\tanchorA: V;\n\t\t\tanchorB: V;\n\t\t\trestLength: number;\n\t\t\tstiffness: number;\n\t\t\tdamping: number;\n\t };\n\nexport interface SimBody<V, R> {\n\tposition(): V;\n\trotation(): R;\n\tvelocity(): V;\n\t/** 2D: rad/s; 3D: rad/s per axis. */\n\tangularVelocity(): R extends number ? number : Vec3;\n\tsleeping(): boolean;\n\tmass(): number;\n\tsetEnabled(enabled: boolean): void;\n\tapplyImpulse(impulse: V): void;\n\tsetKinematicTarget(position: V, rotation: R): void;\n}\n\nexport type SimBody2D = SimBody<Vec2, number>;\nexport type SimBody3D = SimBody<Vec3, Quat>;\n\nexport interface SimWorld<V, B, S> {\n\taddBody(spec: S): B;\n\taddJoint(a: B, b: B, spec: JointSpec<V>): void;\n\tstep(dt: number): void;\n\t/** Pairs that started touching during the last step. */\n\tdrainCollisionStarts(): Array<[B, B]>;\n\tfree(): void;\n}\n\nexport type SimWorld2D = SimWorld<Vec2, SimBody2D, BodySpec2D>;\nexport type SimWorld3D = SimWorld<Vec3, SimBody3D, BodySpec3D>;\n\nexport interface PhysicsBackend {\n\tcreateWorld2D(gravity: Vec2): SimWorld2D;\n\tcreateWorld3D(gravity: Vec3): SimWorld3D;\n}\n\n// ---------------------------------------------------------------------------\n// Rapier\n// ---------------------------------------------------------------------------\n\ntype Rapier2D = typeof RAPIER2D;\ntype Rapier3D = typeof RAPIER3D;\n\n// Literal specifiers: the preview's browser bundle splits each engine into a\n// chunk loaded on first use; Node keeps them as external optional packages.\nconst RAPIER_2D = \"@dimforge/rapier2d-deterministic-compat\";\nconst RAPIER_3D = \"@dimforge/rapier3d-deterministic-compat\";\n\nasync function loadRapier<T>(\n\tspecifier: string,\n\tload: () => Promise<unknown>,\n): Promise<T> {\n\tlet mod: { default?: T } & T;\n\ttry {\n\t\tmod = (await load()) as { default?: T } & T;\n\t} catch (error) {\n\t\tthrow new Error(\n\t\t\t`Physics needs the optional dependency \"${specifier}\". Install it with \\`npm i ${specifier}\\`.`,\n\t\t\t{ cause: error },\n\t\t);\n\t}\n\tconst rapier = (mod.default ?? mod) as T & { init(): Promise<void> };\n\tawait rapier.init();\n\treturn rapier;\n}\n\nlet rapier2d: Promise<Rapier2D> | undefined;\nlet rapier3d: Promise<Rapier3D> | undefined;\n\n/** Loads and initializes Rapier once per process; 2D and 3D are separate modules. */\nexport async function rapierBackend(dims: 2 | 3): Promise<PhysicsBackend> {\n\tif (dims === 2) {\n\t\trapier2d ??= loadRapier<Rapier2D>(\n\t\t\tRAPIER_2D,\n\t\t\t() => import(\"@dimforge/rapier2d-deterministic-compat\"),\n\t\t);\n\t\tconst R = await rapier2d;\n\t\treturn {\n\t\t\tcreateWorld2D: (gravity) => new RapierWorld2D(R, gravity),\n\t\t\tcreateWorld3D: () => {\n\t\t\t\tthrow new Error(\"This backend was loaded for 2D.\");\n\t\t\t},\n\t\t};\n\t}\n\trapier3d ??= loadRapier<Rapier3D>(\n\t\tRAPIER_3D,\n\t\t() => import(\"@dimforge/rapier3d-deterministic-compat\"),\n\t);\n\tconst R = await rapier3d;\n\treturn {\n\t\tcreateWorld2D: () => {\n\t\t\tthrow new Error(\"This backend was loaded for 3D.\");\n\t\t},\n\t\tcreateWorld3D: (gravity) => new RapierWorld3D(R, gravity),\n\t};\n}\n\nclass RapierWorld2D implements SimWorld2D {\n\tprivate readonly world: RAPIER2D.World;\n\tprivate readonly events: RAPIER2D.EventQueue;\n\tprivate readonly byCollider = new Map<number, SimBody2D>();\n\tprivate readonly started: Array<[SimBody2D, SimBody2D]> = [];\n\n\tconstructor(\n\t\tprivate readonly R: Rapier2D,\n\t\tgravity: Vec2,\n\t) {\n\t\tthis.world = new R.World({ x: gravity[0], y: gravity[1] });\n\t\tthis.events = new R.EventQueue(true);\n\t}\n\n\taddBody(spec: BodySpec2D): SimBody2D {\n\t\tconst R = this.R;\n\t\tconst desc = bodyDesc(R, spec.type)\n\t\t\t.setTranslation(spec.position[0], spec.position[1])\n\t\t\t.setRotation(spec.angle)\n\t\t\t.setLinvel(spec.velocity[0], spec.velocity[1])\n\t\t\t.setAngvel(spec.angularVelocity)\n\t\t\t.setLinearDamping(spec.linearDamping)\n\t\t\t.setAngularDamping(spec.angularDamping)\n\t\t\t.setGravityScale(spec.gravityScale)\n\t\t\t.setCcdEnabled(spec.ccd)\n\t\t\t.setEnabled(spec.enabled);\n\t\tif (spec.lockRotation) desc.lockRotations();\n\t\tconst body = this.world.createRigidBody(desc);\n\t\tconst collider = this.world.createCollider(\n\t\t\tshapeDesc2D(R, spec.shape)\n\t\t\t\t.setDensity(spec.density)\n\t\t\t\t.setFriction(spec.friction)\n\t\t\t\t.setRestitution(spec.restitution)\n\t\t\t\t.setActiveEvents(R.ActiveEvents.COLLISION_EVENTS)\n\t\t\t\t.setSensor(spec.sensor ?? false),\n\t\t\tbody,\n\t\t);\n\t\tconst sim: SimBody2D & { raw: RAPIER2D.RigidBody } = {\n\t\t\traw: body,\n\t\t\tposition: () => {\n\t\t\t\tconst t = body.translation();\n\t\t\t\treturn [t.x, t.y];\n\t\t\t},\n\t\t\trotation: () => body.rotation(),\n\t\t\tvelocity: () => {\n\t\t\t\tconst v = body.linvel();\n\t\t\t\treturn [v.x, v.y];\n\t\t\t},\n\t\t\tangularVelocity: () => body.angvel(),\n\t\t\tsleeping: () => body.isSleeping(),\n\t\t\tmass: () => body.mass(),\n\t\t\tsetEnabled: (on) => body.setEnabled(on),\n\t\t\tapplyImpulse: ([x, y]) => body.applyImpulse({ x, y }, true),\n\t\t\tsetKinematicTarget: ([x, y], angle) => {\n\t\t\t\tbody.setNextKinematicTranslation({ x, y });\n\t\t\t\tbody.setNextKinematicRotation(angle);\n\t\t\t},\n\t\t};\n\t\tthis.byCollider.set(collider.handle, sim);\n\t\treturn sim;\n\t}\n\n\taddJoint(a: SimBody2D, b: SimBody2D, spec: JointSpec<Vec2>): void {\n\t\tconst R = this.R;\n\t\tconst a1 = { x: spec.anchorA[0], y: spec.anchorA[1] };\n\t\tconst a2 = { x: spec.anchorB[0], y: spec.anchorB[1] };\n\t\tlet data: RAPIER2D.JointData;\n\t\tswitch (spec.type) {\n\t\t\tcase \"revolute\":\n\t\t\tcase \"spherical\":\n\t\t\t\tdata = R.JointData.revolute(a1, a2);\n\t\t\t\tbreak;\n\t\t\tcase \"fixed\":\n\t\t\t\tdata = R.JointData.fixed(a1, 0, a2, 0);\n\t\t\t\tbreak;\n\t\t\tcase \"rope\":\n\t\t\t\tdata = R.JointData.rope(spec.length, a1, a2);\n\t\t\t\tbreak;\n\t\t\tcase \"spring\":\n\t\t\t\tdata = R.JointData.spring(\n\t\t\t\t\tspec.restLength,\n\t\t\t\t\tspec.stiffness,\n\t\t\t\t\tspec.damping,\n\t\t\t\t\ta1,\n\t\t\t\t\ta2,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\t\t// Jointed bodies pass through each other where they meet.\n\t\tthis.world\n\t\t\t.createImpulseJoint(data, rawBody(a), rawBody(b), true)\n\t\t\t.setContactsEnabled(false);\n\t}\n\n\tstep(dt: number): void {\n\t\tthis.world.timestep = dt;\n\t\tthis.world.step(this.events);\n\t\tthis.events.drainCollisionEvents((h1, h2, started) => {\n\t\t\tif (!started) return;\n\t\t\tconst a = this.byCollider.get(h1);\n\t\t\tconst b = this.byCollider.get(h2);\n\t\t\tif (a && b) this.started.push([a, b]);\n\t\t});\n\t}\n\n\tdrainCollisionStarts(): Array<[SimBody2D, SimBody2D]> {\n\t\treturn this.started.splice(0);\n\t}\n\n\tfree(): void {\n\t\tthis.events.free();\n\t\tthis.world.free();\n\t}\n}\n\nclass RapierWorld3D implements SimWorld3D {\n\tprivate readonly world: RAPIER3D.World;\n\tprivate readonly events: RAPIER3D.EventQueue;\n\tprivate readonly byCollider = new Map<number, SimBody3D>();\n\tprivate readonly started: Array<[SimBody3D, SimBody3D]> = [];\n\n\tconstructor(\n\t\tprivate readonly R: Rapier3D,\n\t\tgravity: Vec3,\n\t) {\n\t\tthis.world = new R.World({ x: gravity[0], y: gravity[1], z: gravity[2] });\n\t\tthis.events = new R.EventQueue(true);\n\t}\n\n\taddBody(spec: BodySpec3D): SimBody3D {\n\t\tconst R = this.R;\n\t\tconst [qx, qy, qz, qw] = spec.rotation;\n\t\tconst desc = bodyDesc(R, spec.type)\n\t\t\t.setTranslation(spec.position[0], spec.position[1], spec.position[2])\n\t\t\t.setRotation({ x: qx, y: qy, z: qz, w: qw })\n\t\t\t.setLinvel(spec.velocity[0], spec.velocity[1], spec.velocity[2])\n\t\t\t// Locked axes start still too (Rapier keeps an initial spin otherwise).\n\t\t\t.setAngvel(\n\t\t\t\tvec3(\n\t\t\t\t\tspec.lockRotation\n\t\t\t\t\t\t? [0, 0, 0]\n\t\t\t\t\t\t: (spec.angularVelocity.map((w, i) =>\n\t\t\t\t\t\t\t\tspec.enabledRotations && !spec.enabledRotations[i] ? 0 : w,\n\t\t\t\t\t\t\t) as Vec3),\n\t\t\t\t),\n\t\t\t)\n\t\t\t.setLinearDamping(spec.linearDamping)\n\t\t\t.setAngularDamping(spec.angularDamping)\n\t\t\t.setGravityScale(spec.gravityScale)\n\t\t\t.setCcdEnabled(spec.ccd)\n\t\t\t.setEnabled(spec.enabled);\n\t\tif (spec.lockRotation) desc.lockRotations();\n\t\telse if (spec.enabledRotations)\n\t\t\tdesc.enabledRotations(...spec.enabledRotations);\n\t\tconst body = this.world.createRigidBody(desc);\n\t\tconst shape = shapeDesc3D(R, spec.shape);\n\t\tconst collider = this.world.createCollider(\n\t\t\tshape\n\t\t\t\t.setDensity(spec.density)\n\t\t\t\t.setFriction(spec.friction)\n\t\t\t\t.setRestitution(spec.restitution)\n\t\t\t\t.setActiveEvents(R.ActiveEvents.COLLISION_EVENTS)\n\t\t\t\t.setSensor(spec.sensor ?? false),\n\t\t\tbody,\n\t\t);\n\t\tconst sim: SimBody3D & { raw: RAPIER3D.RigidBody } = {\n\t\t\traw: body,\n\t\t\tposition: () => {\n\t\t\t\tconst t = body.translation();\n\t\t\t\treturn [t.x, t.y, t.z];\n\t\t\t},\n\t\t\trotation: () => {\n\t\t\t\tconst q = body.rotation();\n\t\t\t\treturn [q.x, q.y, q.z, q.w];\n\t\t\t},\n\t\t\tvelocity: () => {\n\t\t\t\tconst v = body.linvel();\n\t\t\t\treturn [v.x, v.y, v.z];\n\t\t\t},\n\t\t\tangularVelocity: () => {\n\t\t\t\tconst w = body.angvel();\n\t\t\t\treturn [w.x, w.y, w.z];\n\t\t\t},\n\t\t\tsleeping: () => body.isSleeping(),\n\t\t\tmass: () => body.mass(),\n\t\t\tsetEnabled: (on) => body.setEnabled(on),\n\t\t\tapplyImpulse: (v) => body.applyImpulse(vec3(v), true),\n\t\t\tsetKinematicTarget: (p, [x, y, z, w]) => {\n\t\t\t\tbody.setNextKinematicTranslation(vec3(p));\n\t\t\t\tbody.setNextKinematicRotation({ x, y, z, w });\n\t\t\t},\n\t\t};\n\t\tthis.byCollider.set(collider.handle, sim);\n\t\treturn sim;\n\t}\n\n\taddJoint(a: SimBody3D, b: SimBody3D, spec: JointSpec<Vec3>): void {\n\t\tconst R = this.R;\n\t\tconst a1 = vec3(spec.anchorA);\n\t\tconst a2 = vec3(spec.anchorB);\n\t\tlet data: RAPIER3D.JointData;\n\t\tswitch (spec.type) {\n\t\t\tcase \"revolute\":\n\t\t\t\tdata = R.JointData.revolute(a1, a2, vec3(spec.axis ?? [0, 0, 1]));\n\t\t\t\tbreak;\n\t\t\tcase \"spherical\":\n\t\t\t\tdata = R.JointData.spherical(a1, a2);\n\t\t\t\tbreak;\n\t\t\tcase \"fixed\": {\n\t\t\t\tconst identity = { x: 0, y: 0, z: 0, w: 1 };\n\t\t\t\tdata = R.JointData.fixed(a1, identity, a2, identity);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"rope\":\n\t\t\t\tdata = R.JointData.rope(spec.length, a1, a2);\n\t\t\t\tbreak;\n\t\t\tcase \"spring\":\n\t\t\t\tdata = R.JointData.spring(\n\t\t\t\t\tspec.restLength,\n\t\t\t\t\tspec.stiffness,\n\t\t\t\t\tspec.damping,\n\t\t\t\t\ta1,\n\t\t\t\t\ta2,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t}\n\t\t// Jointed bodies pass through each other where they meet.\n\t\tthis.world\n\t\t\t.createImpulseJoint(data, rawBody(a), rawBody(b), true)\n\t\t\t.setContactsEnabled(false);\n\t}\n\n\tstep(dt: number): void {\n\t\tthis.world.timestep = dt;\n\t\tthis.world.step(this.events);\n\t\tthis.events.drainCollisionEvents((h1, h2, started) => {\n\t\t\tif (!started) return;\n\t\t\tconst a = this.byCollider.get(h1);\n\t\t\tconst b = this.byCollider.get(h2);\n\t\t\tif (a && b) this.started.push([a, b]);\n\t\t});\n\t}\n\n\tdrainCollisionStarts(): Array<[SimBody3D, SimBody3D]> {\n\t\treturn this.started.splice(0);\n\t}\n\n\tfree(): void {\n\t\tthis.events.free();\n\t\tthis.world.free();\n\t}\n}\n\nfunction vec3([x, y, z]: Vec3): { x: number; y: number; z: number } {\n\treturn { x, y, z };\n}\n\nfunction rawBody<T>(body: unknown): T {\n\treturn (body as { raw: T }).raw;\n}\n\nfunction bodyDesc<R extends Rapier2D | Rapier3D>(\n\tR: R,\n\ttype: BodyType,\n): ReturnType<R[\"RigidBodyDesc\"][\"dynamic\"]> {\n\tconst D = R.RigidBodyDesc;\n\tconst desc =\n\t\ttype === \"fixed\"\n\t\t\t? D.fixed()\n\t\t\t: type === \"kinematic\"\n\t\t\t\t? D.kinematicPositionBased()\n\t\t\t\t: D.dynamic();\n\treturn desc as ReturnType<R[\"RigidBodyDesc\"][\"dynamic\"]>;\n}\n\nfunction shapeDesc2D(R: Rapier2D, shape: Shape2D): RAPIER2D.ColliderDesc {\n\tswitch (shape.kind) {\n\t\tcase \"ball\":\n\t\t\treturn R.ColliderDesc.ball(shape.radius);\n\t\tcase \"box\": {\n\t\t\t// The rounded border wraps a core box; keep the core solid (a flat core has no mass).\n\t\t\tconst r = Math.min(shape.radius ?? 0, shape.hx / 2, shape.hy / 2);\n\t\t\treturn r > 0\n\t\t\t\t? R.ColliderDesc.roundCuboid(shape.hx - r, shape.hy - r, r)\n\t\t\t\t: R.ColliderDesc.cuboid(shape.hx, shape.hy);\n\t\t}\n\t\tcase \"hull\": {\n\t\t\tconst desc = R.ColliderDesc.convexHull(new Float32Array(shape.points));\n\t\t\tif (!desc)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Physics: could not build a convex hull for this shape.\",\n\t\t\t\t);\n\t\t\treturn desc;\n\t\t}\n\t}\n}\n\nfunction shapeDesc3D(R: Rapier3D, shape: Shape3D): RAPIER3D.ColliderDesc {\n\tswitch (shape.kind) {\n\t\tcase \"ball\":\n\t\t\treturn R.ColliderDesc.ball(shape.radius);\n\t\tcase \"box\": {\n\t\t\t// The rounded border wraps a core box; keep the core solid (a flat core has no mass).\n\t\t\tconst r = Math.min(\n\t\t\t\tshape.radius ?? 0,\n\t\t\t\tshape.hx / 2,\n\t\t\t\tshape.hy / 2,\n\t\t\t\tshape.hz / 2,\n\t\t\t);\n\t\t\treturn r > 0\n\t\t\t\t? R.ColliderDesc.roundCuboid(\n\t\t\t\t\t\tshape.hx - r,\n\t\t\t\t\t\tshape.hy - r,\n\t\t\t\t\t\tshape.hz - r,\n\t\t\t\t\t\tr,\n\t\t\t\t\t)\n\t\t\t\t: R.ColliderDesc.cuboid(shape.hx, shape.hy, shape.hz);\n\t\t}\n\t\tcase \"cylinder\":\n\t\t\treturn R.ColliderDesc.cylinder(shape.halfHeight, shape.radius);\n\t\tcase \"hull\": {\n\t\t\tconst desc = R.ColliderDesc.convexHull(new Float32Array(shape.points));\n\t\t\tif (!desc)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Physics: could not build a convex hull for this shape.\",\n\t\t\t\t);\n\t\t\treturn desc;\n\t\t}\n\t}\n}\n","import type {\n\tAnimatableProp,\n\tLayoutNode,\n} from \"@framefields/compositions/program\";\nimport type { FrameSignal } from \"@framefields/core\";\nimport {\n\tbuildShapeSvgPath,\n\tparseSvgPathToSegments,\n\ttype ShapeGeometryConfig,\n} from \"@framefields/webgpu-renderers\";\nimport { FontManager } from \"../fonts/manager.js\";\nimport type {\n\tBodySpec2D,\n\tPhysicsBackend,\n\tShape2D,\n\tSimBody2D,\n\tSimWorld2D,\n\tVec2,\n} from \"./backend.js\";\nimport {\n\ttype BodyCommonOptions,\n\ttype CoreBody,\n\ttype PhysicsCollision,\n\ttype PhysicsDriver,\n\ttype PhysicsWorldOptions,\n\ttype Recording,\n\tsampleDriver,\n\tunwrapDegrees,\n\tWorldCore,\n} from \"./core.js\";\n\nexport interface World2DOptions extends PhysicsWorldOptions {\n\t/** px/s², y down. A number pulls straight down. Default 2400. */\n\tgravity?: number | [number, number];\n}\n\n/** A plain rectangle for bodies with no layer (invisible obstacles, funnels). */\nexport interface PhysicsRect {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\trotation?: number;\n\tborderRadius?: number;\n}\n\nexport interface Body2DOptions extends BodyCommonOptions {\n\t/**\n\t * Collider: `\"auto\"` (default) reads the layer — circles stay circles,\n\t * rounded boxes keep their radius, polygons/stars/paths use their convex\n\t * hull. Force `\"box\"`, `\"circle\"` or `\"hull\"` (the shape's outline).\n\t */\n\tshape?: \"auto\" | \"box\" | \"circle\" | \"hull\";\n\t/** Collider size override `[width, height]`, px. Text layers are measured when they have no size. */\n\tsize?: [number, number];\n\t/** px/s. */\n\tvelocity?: [number, number];\n\t/** Degrees per second, clockwise. */\n\tangularVelocity?: number;\n\t/**\n\t * Kinematic bodies: where the layer is each frame, as its own `x` / `y`\n\t * (top-left) and `rotation` (degrees). Missing ones keep the start pose.\n\t */\n\tfollow?: { x?: PhysicsDriver; y?: PhysicsDriver; rotation?: PhysicsDriver };\n}\n\ntype LayerLike = Record<string, unknown> & {\n\tkind?: string;\n\tanimate?: (...a: unknown[]) => unknown;\n};\n\n/**\n * A simulated body. Its signals hold one value per composition frame; bind\n * them to any prop or effect uniform (`.signal(\"opacity\", body.impact)`).\n * Reading a signal runs the simulation if it has not run yet.\n */\nexport class PhysicsBody2D implements CoreBody<Vec2, number> {\n\treadonly collisions: PhysicsCollision<PhysicsBody2D>[] = [];\n\t/** @internal */ readonly recording: Recording;\n\t/** @internal */ readonly sim: SimBody2D;\n\n\t/** @internal */\n\tconstructor(\n\t\t/** @internal */ readonly world: PhysicsWorld2D,\n\t\tsim: SimBody2D,\n\t\treadonly type: \"dynamic\" | \"fixed\" | \"kinematic\",\n\t\treadonly layer: LayerLike | undefined,\n\t\t/** Layer box size (unscaled), scale and pivot, to turn the center back into x/y. */\n\t\tprivate readonly frame: {\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\tscale: number;\n\t\t\tanchorX: number;\n\t\t\tanchorY: number;\n\t\t\trotation: number;\n\t\t},\n\t\tprivate readonly options: Body2DOptions,\n\t\trecording: Recording,\n\t) {\n\t\tthis.sim = sim;\n\t\tthis.recording = recording;\n\t}\n\n\tget startFrame(): number {\n\t\treturn Math.max(0, Math.round(this.options.startFrame ?? 0));\n\t}\n\tget gravityScale(): number {\n\t\treturn this.options.gravityScale ?? 1;\n\t}\n\tget output(): Body2DOptions[\"output\"] {\n\t\treturn this.options.output;\n\t}\n\n\t/** The layer's `x` (top-left) every frame. */\n\tget x(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"x\");\n\t}\n\t/** The layer's `y` (top-left) every frame. */\n\tget y(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"y\");\n\t}\n\t/** Degrees, clockwise, continuous (no jump at 360). */\n\tget rotation(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"rotation\");\n\t}\n\t/** Body center, px. */\n\tget centerX(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"centerX\");\n\t}\n\tget centerY(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"centerY\");\n\t}\n\t/** px/s. */\n\tget vx(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"vx\");\n\t}\n\tget vy(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"vy\");\n\t}\n\t/** px/s. */\n\tget speed(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"speed\");\n\t}\n\t/** Degrees per second. */\n\tget angularVelocity(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"angularVelocity\");\n\t}\n\t/**\n\t * Hit envelope: jumps on each new contact (1 ≈ a 1500 px/s velocity\n\t * change, see `impactReference`) and decays over `impactDecay` frames.\n\t */\n\tget impact(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"impact\");\n\t}\n\t/** 1 while the body is at rest, else 0. */\n\tget sleeping(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"sleeping\");\n\t}\n\n\t/** @internal */\n\tkinematicTarget(\n\t\tframe: number,\n\t): { position: Vec2; rotation: number } | undefined {\n\t\tconst follow = this.options.follow;\n\t\tif (this.type !== \"kinematic\" || !follow) return undefined;\n\t\tconst f = this.frame;\n\t\tconst fps = this.world.fps;\n\t\tconst x =\n\t\t\tfollow.x === undefined ? undefined : sampleDriver(follow.x, frame, fps);\n\t\tconst y =\n\t\t\tfollow.y === undefined ? undefined : sampleDriver(follow.y, frame, fps);\n\t\tconst rotation =\n\t\t\tfollow.rotation === undefined\n\t\t\t\t? f.rotation\n\t\t\t\t: sampleDriver(follow.rotation, frame, fps);\n\t\tconst start = this.initialLayerXY();\n\t\tconst center = layerToCenter(x ?? start[0], y ?? start[1], rotation, f);\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\treturn {\n\t\t\tposition: [center[0] / ppm, center[1] / ppm],\n\t\t\trotation: (rotation * Math.PI) / 180,\n\t\t};\n\t}\n\n\tprivate initialLayerXY(): Vec2 {\n\t\tconst l = this.layer;\n\t\treturn [Number(l?.x ?? 0), Number(l?.y ?? 0)];\n\t}\n\n\t/** @internal */\n\trecord(index: number, previous: number): void {\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\tconst [mx, my] = this.sim.position();\n\t\tconst cx = mx * ppm;\n\t\tconst cy = my * ppm;\n\t\tconst rec = this.recording;\n\t\tconst rotation = rec.channel(\"rotation\");\n\t\tconst deg = (this.sim.rotation() * 180) / Math.PI;\n\t\trotation[index] =\n\t\t\tprevious < 0\n\t\t\t\t? unwrapDegrees(this.frame.rotation, deg)\n\t\t\t\t: unwrapDegrees(rotation[previous], deg);\n\t\tconst [x, y] = centerToLayer(cx, cy, rotation[index], this.frame);\n\t\trec.channel(\"x\")[index] = x;\n\t\trec.channel(\"y\")[index] = y;\n\t\trec.channel(\"centerX\")[index] = cx;\n\t\trec.channel(\"centerY\")[index] = cy;\n\t\tconst [vx, vy] = this.sim.velocity();\n\t\trec.channel(\"vx\")[index] = vx * ppm;\n\t\trec.channel(\"vy\")[index] = vy * ppm;\n\t\trec.channel(\"speed\")[index] = Math.hypot(vx, vy) * ppm;\n\t\trec.channel(\"angularVelocity\")[index] =\n\t\t\t(this.sim.angularVelocity() * 180) / Math.PI;\n\t\trec.channel(\"sleeping\")[index] = this.sim.sleeping() ? 1 : 0;\n\t}\n\n\t/** @internal */\n\tboundChannels(): Array<[AnimatableProp, string]> {\n\t\tconst out: Array<[AnimatableProp, string]> = [\n\t\t\t[\"x\", \"x\"],\n\t\t\t[\"y\", \"y\"],\n\t\t];\n\t\tif (!this.options.lockRotation) out.push([\"rotation\", \"rotation\"]);\n\t\treturn out;\n\t}\n\n\t/** @internal World-space point (px) → this body's local frame (meters), at the start pose. */\n\tlocalAnchor(point: Vec2 | undefined): Vec2 {\n\t\tif (!point) return [0, 0];\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\tconst [px, py] = this.sim.position();\n\t\tconst a = -this.sim.rotation();\n\t\tconst dx = point[0] / ppm - px;\n\t\tconst dy = point[1] / ppm - py;\n\t\treturn [\n\t\t\tdx * Math.cos(a) - dy * Math.sin(a),\n\t\t\tdx * Math.sin(a) + dy * Math.cos(a),\n\t\t];\n\t}\n\n\t/** @internal Start-pose center in px. */\n\tcenter(): Vec2 {\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\tconst [x, y] = this.sim.position();\n\t\treturn [x * ppm, y * ppm];\n\t}\n}\n\n/** What a {@link PhysicsWorld2D.field} sees for one body. */\nexport interface FieldSample2D {\n\t/** Body center, px. */\n\tx: number;\n\ty: number;\n\t/** px/s. */\n\tvx: number;\n\tvy: number;\n\t/** Composition frame. */\n\tframe: number;\n\tbody: PhysicsBody2D;\n}\n\nexport interface PhysicsSpringOptions {\n\t/** Rest length, px (default: the distance at the start). */\n\tlength?: number;\n\t/** Oscillations per second (default 2). Higher is stiffer. */\n\tfrequency?: number;\n\t/** 0 bounces forever, 1 settles without overshoot (default 0.2). */\n\tdampingRatio?: number;\n\t/** Attachment point on body A, world px at the start (default its center). */\n\tanchorA?: [number, number];\n\t/** Attachment point on body B (or the world point), world px. */\n\tanchorB?: [number, number];\n}\n\nexport interface PhysicsRopeOptions {\n\t/** Maximum length, px (default: the distance at the start). */\n\tlength?: number;\n\tanchorA?: [number, number];\n\tanchorB?: [number, number];\n}\n\nexport interface PhysicsGroundOptions {\n\t/** Top edge of the ground, px. */\n\ty: number;\n\tfriction?: number;\n\trestitution?: number;\n}\n\nexport interface PhysicsWallsOptions {\n\tx?: number;\n\ty?: number;\n\twidth: number;\n\theight: number;\n\t/** Close the top too (default false: things can fall in). */\n\tceiling?: boolean;\n\t/** Wall thickness outside the box, px (default 400). */\n\tthickness?: number;\n\tfriction?: number;\n\trestitution?: number;\n}\n\n/**\n * A deterministic 2D rigid-body world (Rapier) in layer pixels. Build it,\n * add bodies from layers, then `simulate()`: each body's layer is bound to\n * its simulated `x` / `y` / `rotation`, and every body exposes signals\n * (`impact`, `speed`, …) for driving anything else. The simulation runs\n * once while the composition is built, so frames render in any order and\n * identically on every machine.\n */\nexport class PhysicsWorld2D extends WorldCore<Vec2, number, PhysicsBody2D> {\n\t/** @internal */\n\tconstructor(backend: PhysicsBackend, options: World2DOptions) {\n\t\tconst ppm = options.pixelsPerMeter ?? 100;\n\t\tconst g = options.gravity ?? 2400;\n\t\tconst gravity: Vec2 =\n\t\t\ttypeof g === \"number\" ? [0, g / ppm] : [g[0] / ppm, g[1] / ppm];\n\t\tconst sim = backend.createWorld2D(gravity);\n\t\tsuper(sim as never, gravity, options);\n\t}\n\n\t/**\n\t * Adds a body for a layer (absolutely positioned: `x`, `y`, and a size)\n\t * or for a plain rectangle. The layer's current pose is the start pose.\n\t */\n\tbody(\n\t\ttarget: LayoutNode | PhysicsRect,\n\t\toptions: Body2DOptions = {},\n\t): PhysicsBody2D {\n\t\tthis.assertOpen();\n\t\tconst isLayer = typeof (target as unknown as LayerLike).kind === \"string\";\n\t\tconst layer = isLayer ? (target as unknown as LayerLike) : undefined;\n\t\tconst geom = layerGeometry(target as unknown as LayerLike, options);\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tconst type = options.type ?? \"dynamic\";\n\t\tconst [cx, cy] = layerToCenter(geom.x, geom.y, geom.rotation, geom);\n\t\tconst v = options.velocity ?? [0, 0];\n\t\tconst spec: BodySpec2D = {\n\t\t\ttype,\n\t\t\tposition: [cx / ppm, cy / ppm],\n\t\t\tangle: (geom.rotation * Math.PI) / 180,\n\t\t\tvelocity: [v[0] / ppm, v[1] / ppm],\n\t\t\tangularVelocity: ((options.angularVelocity ?? 0) * Math.PI) / 180,\n\t\t\tlinearDamping: options.linearDamping ?? 0,\n\t\t\tangularDamping: options.angularDamping ?? 0,\n\t\t\tgravityScale: options.gravityScale ?? 1,\n\t\t\tlockRotation: options.lockRotation ?? false,\n\t\t\tccd: options.ccd ?? false,\n\t\t\tenabled: true,\n\t\t\tsensor: options.sensor ?? false,\n\t\t\tdensity: options.density ?? 1,\n\t\t\tfriction: options.friction ?? 0.6,\n\t\t\trestitution: options.restitution ?? 0.3,\n\t\t\tshape: scaleShape(geom.shape, 1 / ppm),\n\t\t};\n\t\tconst simBody = (this.sim as unknown as SimWorld2D).addBody(spec);\n\t\tconst body = new PhysicsBody2D(\n\t\t\tthis,\n\t\t\tsimBody,\n\t\t\ttype,\n\t\t\tlayer,\n\t\t\tgeom,\n\t\t\toptions,\n\t\t\tthis.newRecording(),\n\t\t);\n\t\treturn this.addBody(body);\n\t}\n\n\t/** A fixed, very wide floor whose top edge sits at `y`. */\n\tground(options: PhysicsGroundOptions): PhysicsBody2D {\n\t\tconst t = 2000;\n\t\tconst w = 1e6;\n\t\treturn this.body(\n\t\t\t{ x: -w / 2, y: options.y, width: w, height: t },\n\t\t\t{\n\t\t\t\ttype: \"fixed\",\n\t\t\t\tfriction: options.friction,\n\t\t\t\trestitution: options.restitution ?? 0.2,\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Fixed floor, left and right walls (and optionally a ceiling) around a box, e.g. the canvas. */\n\twalls(options: PhysicsWallsOptions): {\n\t\tfloor: PhysicsBody2D;\n\t\tleft: PhysicsBody2D;\n\t\tright: PhysicsBody2D;\n\t\tceiling?: PhysicsBody2D;\n\t} {\n\t\tconst { width: W, height: H } = options;\n\t\tconst x = options.x ?? 0;\n\t\tconst y = options.y ?? 0;\n\t\tconst t = options.thickness ?? 400;\n\t\tconst mat = {\n\t\t\ttype: \"fixed\" as const,\n\t\t\tfriction: options.friction,\n\t\t\trestitution: options.restitution ?? 0.2,\n\t\t};\n\t\tconst tall = H * 4 + t;\n\t\tconst result = {\n\t\t\tfloor: this.body(\n\t\t\t\t{ x: x - t, y: y + H, width: W + 2 * t, height: t },\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tleft: this.body(\n\t\t\t\t{ x: x - t, y: y + H - tall, width: t, height: tall },\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tright: this.body(\n\t\t\t\t{ x: x + W, y: y + H - tall, width: t, height: tall },\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tceiling: undefined as PhysicsBody2D | undefined,\n\t\t};\n\t\tif (options.ceiling) {\n\t\t\tresult.ceiling = this.body(\n\t\t\t\t{ x: x - t, y: y - t, width: W + 2 * t, height: t },\n\t\t\t\tmat,\n\t\t\t);\n\t\t}\n\t\treturn result;\n\t}\n\n\t/** Pins a body to the world at a point (default its center); it can still swing around it. */\n\tpin(body: PhysicsBody2D, at?: [number, number]): this {\n\t\tconst point = at ?? body.center();\n\t\tconst anchor = this.anchorBody(point);\n\t\tthis.joint(body, anchor, {\n\t\t\ttype: \"revolute\",\n\t\t\tanchorA: body.localAnchor(point),\n\t\t\tanchorB: [0, 0],\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** Joins two bodies at a world point so they swing around it (a hinge). */\n\thinge(a: PhysicsBody2D, b: PhysicsBody2D, at: [number, number]): this {\n\t\tthis.joint(a, b, {\n\t\t\ttype: \"revolute\",\n\t\t\tanchorA: a.localAnchor(at),\n\t\t\tanchorB: b.localAnchor(at),\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** Glues two bodies together rigidly. */\n\tweld(a: PhysicsBody2D, b: PhysicsBody2D): this {\n\t\tconst at = a.center();\n\t\tthis.joint(a, b, {\n\t\t\ttype: \"fixed\",\n\t\t\tanchorA: [0, 0],\n\t\t\tanchorB: b.localAnchor(at),\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** A damped spring between two bodies, or from a body to a world point. */\n\tspring(\n\t\ta: PhysicsBody2D,\n\t\tb: PhysicsBody2D | [number, number],\n\t\toptions: PhysicsSpringOptions = {},\n\t): this {\n\t\tconst { other, pa, pb } = this.endpoints(\n\t\t\ta,\n\t\t\tb,\n\t\t\toptions.anchorA,\n\t\t\toptions.anchorB,\n\t\t);\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tconst length =\n\t\t\t(options.length ?? Math.hypot(pb[0] - pa[0], pb[1] - pa[1])) / ppm;\n\t\tconst mass = effectiveMass(a, other);\n\t\tconst w = 2 * Math.PI * (options.frequency ?? 2);\n\t\tthis.joint(a, other, {\n\t\t\ttype: \"spring\",\n\t\t\tanchorA: a.localAnchor(pa),\n\t\t\tanchorB: other.localAnchor(pb),\n\t\t\trestLength: length,\n\t\t\tstiffness: mass * w * w,\n\t\t\tdamping: 2 * (options.dampingRatio ?? 0.2) * mass * w,\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** A rope: never longer than `length`, slack when closer. */\n\trope(\n\t\ta: PhysicsBody2D,\n\t\tb: PhysicsBody2D | [number, number],\n\t\toptions: PhysicsRopeOptions = {},\n\t): this {\n\t\tconst { other, pa, pb } = this.endpoints(\n\t\t\ta,\n\t\t\tb,\n\t\t\toptions.anchorA,\n\t\t\toptions.anchorB,\n\t\t);\n\t\tconst length = options.length ?? Math.hypot(pb[0] - pa[0], pb[1] - pa[1]);\n\t\tthis.joint(a, other, {\n\t\t\ttype: \"rope\",\n\t\t\tanchorA: a.localAnchor(pa),\n\t\t\tanchorB: other.localAnchor(pb),\n\t\t\tlength: length / this.pixelsPerMeter,\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** A steady push, px/s² (mass-independent): wind, magnets, audio. Drivers are read every frame. */\n\tforce(\n\t\tbody: PhysicsBody2D,\n\t\taccel: { x?: PhysicsDriver; y?: PhysicsDriver },\n\t): this {\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tthis.addForce(body, (frame) => [\n\t\t\taccel.x === undefined ? 0 : sampleDriver(accel.x, frame, this.fps) / ppm,\n\t\t\taccel.y === undefined ? 0 : sampleDriver(accel.y, frame, this.fps) / ppm,\n\t\t]);\n\t\treturn this;\n\t}\n\n\t/**\n\t * A force field: called for every awake dynamic body (or just `bodies`)\n\t * each solver step with its center and velocity in px, px/s; returns an\n\t * acceleration `[ax, ay]` px/s² (or nothing). Wind, vortices, magnets,\n\t * flow fields, a dancer's silhouette pushing particles.\n\t */\n\tfield(\n\t\taccel: (sample: FieldSample2D) => [number, number] | null | undefined,\n\t\toptions: { bodies?: readonly PhysicsBody2D[] } = {},\n\t): this {\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tthis.addField((body, frame) => {\n\t\t\tconst [x, y] = body.sim.position();\n\t\t\tconst [vx, vy] = body.sim.velocity();\n\t\t\tconst a = accel({\n\t\t\t\tx: x * ppm,\n\t\t\t\ty: y * ppm,\n\t\t\t\tvx: vx * ppm,\n\t\t\t\tvy: vy * ppm,\n\t\t\t\tframe,\n\t\t\t\tbody,\n\t\t\t});\n\t\t\treturn a ? [a[0] / ppm, a[1] / ppm] : null;\n\t\t}, options.bodies);\n\t\treturn this;\n\t}\n\n\t/** An instant kick at a simulation frame: adds `[vx, vy]` px/s to the body's velocity. */\n\timpulse(\n\t\tbody: PhysicsBody2D,\n\t\tframe: number,\n\t\tvelocity: [number, number],\n\t): this {\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tthis.addImpulse(body, frame, [velocity[0] / ppm, velocity[1] / ppm]);\n\t\treturn this;\n\t}\n\n\tprotected lerpRotation(a: number, b: number, t: number): number {\n\t\treturn a + (b - a) * t;\n\t}\n\n\tprivate joint(\n\t\ta: PhysicsBody2D,\n\t\tb: PhysicsBody2D,\n\t\tspec: Parameters<SimWorld2D[\"addJoint\"]>[2],\n\t): void {\n\t\tthis.assertOpen();\n\t\t(this.sim as unknown as SimWorld2D).addJoint(a.sim, b.sim, spec);\n\t}\n\n\tprivate anchorBody(point: [number, number]): PhysicsBody2D {\n\t\treturn this.body(\n\t\t\t{ x: point[0] - 0.5, y: point[1] - 0.5, width: 1, height: 1 },\n\t\t\t{ type: \"fixed\", output: \"none\", sensor: true },\n\t\t);\n\t}\n\n\tprivate endpoints(\n\t\ta: PhysicsBody2D,\n\t\tb: PhysicsBody2D | [number, number],\n\t\tanchorA?: [number, number],\n\t\tanchorB?: [number, number],\n\t): { other: PhysicsBody2D; pa: Vec2; pb: Vec2 } {\n\t\tconst pa = anchorA ?? a.center();\n\t\tif (Array.isArray(b)) {\n\t\t\tconst pb = anchorB ?? b;\n\t\t\treturn { other: this.anchorBody(pb), pa, pb };\n\t\t}\n\t\treturn { other: b, pa, pb: anchorB ?? b.center() };\n\t}\n}\n\nfunction effectiveMass(a: PhysicsBody2D, b: PhysicsBody2D): number {\n\tconst ma = a.type === \"dynamic\" ? a.sim.mass() : 0;\n\tconst mb = b.type === \"dynamic\" ? b.sim.mass() : 0;\n\tif (ma > 0 && mb > 0) return (ma * mb) / (ma + mb);\n\treturn Math.max(ma, mb, 1e-3);\n}\n\ninterface LayerGeometry {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n\tscale: number;\n\tanchorX: number;\n\tanchorY: number;\n\trotation: number;\n\t/** Collider in px, around the box center, already scaled. */\n\tshape: Shape2D;\n}\n\nfunction num(v: unknown, fallback: number): number {\n\treturn typeof v === \"number\" && Number.isFinite(v) ? v : fallback;\n}\n\nfunction layerGeometry(\n\tlayer: LayerLike,\n\toptions: Body2DOptions,\n): LayerGeometry {\n\tconst id = typeof layer.id === \"string\" ? ` \"${layer.id}\"` : \"\";\n\tif (typeof layer.x !== \"number\" || typeof layer.y !== \"number\") {\n\t\tthrow new Error(\n\t\t\t`Physics: layer${id} needs numeric \\`x\\` and \\`y\\` (absolute position) to become a body.`,\n\t\t);\n\t}\n\tlet width =\n\t\toptions.size?.[0] ??\n\t\t(typeof layer.width === \"number\" ? layer.width : undefined);\n\tlet height =\n\t\toptions.size?.[1] ??\n\t\t(typeof layer.height === \"number\" ? layer.height : undefined);\n\tif ((width === undefined || height === undefined) && layer.kind === \"text\") {\n\t\tconst m = FontManager.measure(String(layer.text ?? \"\"), {\n\t\t\tfontFamily: String(layer.fontFamily ?? \"Inter\"),\n\t\t\tfontSize: num(layer.fontSize, 48),\n\t\t\tfontWeight: layer.fontWeight as never,\n\t\t\tletterSpacing: num(layer.letterSpacing, 0),\n\t\t\tlineHeight:\n\t\t\t\ttypeof layer.lineHeight === \"number\" ? layer.lineHeight : undefined,\n\t\t});\n\t\twidth ??= m.width;\n\t\theight ??= m.height;\n\t}\n\tif (\n\t\twidth === undefined ||\n\t\theight === undefined ||\n\t\twidth <= 0 ||\n\t\theight <= 0\n\t) {\n\t\tthrow new Error(\n\t\t\t`Physics: layer${id} needs a numeric \\`width\\` and \\`height\\` (or the \\`size\\` option) to become a body.`,\n\t\t);\n\t}\n\tconst scale = num(layer.scale, 1);\n\tconst geom = {\n\t\tx: layer.x,\n\t\ty: layer.y,\n\t\twidth,\n\t\theight,\n\t\tscale,\n\t\tanchorX: num(layer.anchorX, 0.5),\n\t\tanchorY: num(layer.anchorY, 0.5),\n\t\trotation: num(layer.rotation, 0),\n\t};\n\treturn {\n\t\t...geom,\n\t\tshape: scaleShape(\n\t\t\tcolliderShape(layer, width, height, options.shape ?? \"auto\"),\n\t\t\tscale,\n\t\t),\n\t};\n}\n\nfunction colliderShape(\n\tlayer: LayerLike,\n\tw: number,\n\th: number,\n\tmode: NonNullable<Body2DOptions[\"shape\"]>,\n): Shape2D {\n\tconst isShape = layer.kind === \"shape\";\n\tconst shapeType = isShape ? String(layer.shapeType ?? \"rect\") : \"rect\";\n\tconst radius = num(layer.borderRadius, num(layer.cornerRadius, 0));\n\tconst box: Shape2D = { kind: \"box\", hx: w / 2, hy: h / 2, radius };\n\tif (mode === \"box\") return box;\n\tif (mode === \"circle\" || (mode === \"auto\" && shapeType === \"circle\")) {\n\t\treturn { kind: \"ball\", radius: Math.min(w, h) / 2 };\n\t}\n\tif (mode === \"auto\" && shapeType === \"rect\") return box;\n\tif (mode === \"hull\" || mode === \"auto\") {\n\t\tconst points = outlinePoints(layer, shapeType, w, h);\n\t\treturn points.length >= 6 ? { kind: \"hull\", points } : box;\n\t}\n\treturn box;\n}\n\n/** The shape's outline as flat points around the box center, px. */\nfunction outlinePoints(\n\tlayer: LayerLike,\n\tshapeType: string,\n\tw: number,\n\th: number,\n): number[] {\n\tconst d =\n\t\tshapeType === \"path\"\n\t\t\t? String(layer.d ?? \"\")\n\t\t\t: buildShapeSvgPath({\n\t\t\t\t\tshapeType: shapeType as ShapeGeometryConfig[\"shapeType\"],\n\t\t\t\t\twidth: w,\n\t\t\t\t\theight: h,\n\t\t\t\t\tcornerRadius: num(layer.cornerRadius, num(layer.borderRadius, 0)),\n\t\t\t\t\tpolygonSides: layer.polygonSides as number | undefined,\n\t\t\t\t\tstarPoints: layer.starPoints as number | undefined,\n\t\t\t\t\tstarInnerRadiusRatio: layer.starInnerRadiusRatio as\n\t\t\t\t\t\t| number\n\t\t\t\t\t\t| undefined,\n\t\t\t\t\tarrowHeadWidth: layer.arrowHeadWidth as number | undefined,\n\t\t\t\t\tarrowHeadLength: layer.arrowHeadLength as number | undefined,\n\t\t\t\t\tarrowShaftWidth: layer.arrowShaftWidth as number | undefined,\n\t\t\t\t});\n\tconst out: number[] = [];\n\tfor (const seg of parseSvgPathToSegments(d)) {\n\t\tout.push(\n\t\t\tseg.p0.x - w / 2,\n\t\t\tseg.p0.y - h / 2,\n\t\t\tseg.p1.x - w / 2,\n\t\t\tseg.p1.y - h / 2,\n\t\t);\n\t}\n\treturn out;\n}\n\nfunction scaleShape(shape: Shape2D, s: number): Shape2D {\n\tswitch (shape.kind) {\n\t\tcase \"ball\":\n\t\t\treturn { kind: \"ball\", radius: shape.radius * s };\n\t\tcase \"box\":\n\t\t\treturn {\n\t\t\t\tkind: \"box\",\n\t\t\t\thx: shape.hx * s,\n\t\t\t\thy: shape.hy * s,\n\t\t\t\tradius: (shape.radius ?? 0) * s,\n\t\t\t};\n\t\tcase \"hull\":\n\t\t\treturn { kind: \"hull\", points: shape.points.map((v) => v * s) };\n\t}\n}\n\ninterface PivotFrame {\n\twidth: number;\n\theight: number;\n\tscale: number;\n\tanchorX: number;\n\tanchorY: number;\n}\n\n/**\n * Layers rotate and scale around their pivot (`anchorX/Y` of the unscaled\n * box); bodies rotate around their center. These convert between the two.\n */\nfunction pivotOffset(rotationDeg: number, f: PivotFrame): Vec2 {\n\tconst a = (rotationDeg * Math.PI) / 180;\n\tconst dx = (0.5 - f.anchorX) * f.width * f.scale;\n\tconst dy = (0.5 - f.anchorY) * f.height * f.scale;\n\treturn [\n\t\tdx * Math.cos(a) - dy * Math.sin(a),\n\t\tdx * Math.sin(a) + dy * Math.cos(a),\n\t];\n}\n\nfunction layerToCenter(\n\tx: number,\n\ty: number,\n\trotationDeg: number,\n\tf: PivotFrame,\n): Vec2 {\n\tconst [ox, oy] = pivotOffset(rotationDeg, f);\n\treturn [x + f.anchorX * f.width + ox, y + f.anchorY * f.height + oy];\n}\n\nfunction centerToLayer(\n\tcx: number,\n\tcy: number,\n\trotationDeg: number,\n\tf: PivotFrame,\n): Vec2 {\n\tconst [ox, oy] = pivotOffset(rotationDeg, f);\n\treturn [cx - ox - f.anchorX * f.width, cy - oy - f.anchorY * f.height];\n}\n","import type {\n\tAnimatableProp,\n\tLayoutNode,\n} from \"@framefields/compositions/program\";\nimport type { FrameSignal } from \"@framefields/core\";\nimport type {\n\tBodySpec3D,\n\tPhysicsBackend,\n\tQuat,\n\tShape3D,\n\tSimBody3D,\n\tSimWorld3D,\n\tVec3,\n} from \"./backend.js\";\nimport {\n\ttype BodyCommonOptions,\n\ttype CoreBody,\n\ttype PhysicsCollision,\n\ttype PhysicsDriver,\n\ttype PhysicsWorldOptions,\n\ttype Recording,\n\tsampleDriver,\n\tunwrapDegrees,\n\tWorldCore,\n} from \"./core.js\";\n\nexport interface World3DOptions extends PhysicsWorldOptions {\n\t/** px/s², y down. A number pulls straight down. Default 2400. */\n\tgravity?: number | [number, number, number];\n}\n\n/** A plain box for bodies with no layer (invisible obstacles). Centered on x/y/z like Layer3D. */\nexport interface PhysicsBox3D {\n\tx: number;\n\ty: number;\n\tz: number;\n\twidth: number;\n\theight: number;\n\tdepth: number;\n\trotateX?: number;\n\trotateY?: number;\n\trotateZ?: number;\n}\n\nexport interface Body3DOptions extends Omit<BodyCommonOptions, \"lockRotation\"> {\n\t/** Initial X position override in px. */\n\tx?: number;\n\t/** Initial Y position override in px. */\n\ty?: number;\n\t/** Initial Z position override in px. */\n\tz?: number;\n\t/** Initial Euler X rotation override in degrees. */\n\trotateX?: number;\n\t/** Initial Euler Y rotation override in degrees. */\n\trotateY?: number;\n\t/** Initial Euler Z rotation override in degrees. */\n\trotateZ?: number;\n\t/**\n\t * Never rotates (`true`), or only around some axes: `{ x: true, y: true }`\n\t * keeps a card facing the camera while it still spins in the picture plane.\n\t */\n\tlockRotation?: boolean | { x?: boolean; y?: boolean; z?: boolean };\n\t/**\n\t * Collider: `\"auto\"` (default) reads the Layer3D primitive (box, sphere,\n\t * cylinder) and falls back to the mesh's convex hull for models and\n\t * tapered or uneven shapes. Force `\"box\"`, `\"sphere\"`, `\"cylinder\"` or `\"hull\"`.\n\t */\n\tshape?: \"auto\" | \"box\" | \"sphere\" | \"cylinder\" | \"hull\";\n\t/** Collider size override `[width, height, depth]`, px (before the layer's scale). */\n\tsize?: [number, number, number];\n\t/** px/s. */\n\tvelocity?: [number, number, number];\n\t/** Degrees per second around x, y, z. */\n\tangularVelocity?: [number, number, number];\n\t/** Kinematic bodies: the layer's `x` / `y` / `z` and `rotateX/Y/Z` each frame. */\n\tfollow?: {\n\t\tx?: PhysicsDriver;\n\t\ty?: PhysicsDriver;\n\t\tz?: PhysicsDriver;\n\t\trotateX?: PhysicsDriver;\n\t\trotateY?: PhysicsDriver;\n\t\trotateZ?: PhysicsDriver;\n\t};\n}\n\ntype LayerLike = Record<string, unknown> & { kind?: string };\n\nconst DEG = Math.PI / 180;\n\n/** Quaternion of the renderer's Euler order: R = Rz · Ry · Rx (degrees). */\nexport function quatFromEuler(rx: number, ry: number, rz: number): Quat {\n\tconst half = (d: number) => (d * DEG) / 2;\n\tconst qx: Quat = [Math.sin(half(rx)), 0, 0, Math.cos(half(rx))];\n\tconst qy: Quat = [0, Math.sin(half(ry)), 0, Math.cos(half(ry))];\n\tconst qz: Quat = [0, 0, Math.sin(half(rz)), Math.cos(half(rz))];\n\treturn quatMul(quatMul(qz, qy), qx);\n}\n\nfunction quatMul(a: Quat, b: Quat): Quat {\n\tconst [ax, ay, az, aw] = a;\n\tconst [bx, by, bz, bw] = b;\n\treturn [\n\t\taw * bx + ax * bw + ay * bz - az * by,\n\t\taw * by - ax * bz + ay * bw + az * bx,\n\t\taw * bz + ax * by - ay * bx + az * bw,\n\t\taw * bw - ax * bx - ay * by - az * bz,\n\t];\n}\n\n/**\n * Euler angles (degrees, R = Rz · Ry · Rx) for a quaternion, choosing of the\n * two equivalent solutions the one closest to `previous` and unwrapping each\n * angle, so rotations stay continuous frame to frame.\n */\nexport function eulerFromQuat(q: Quat, previous?: Vec3): Vec3 {\n\tconst [x, y, z, w] = q;\n\tconst r00 = 1 - 2 * (y * y + z * z);\n\tconst r10 = 2 * (x * y + w * z);\n\tconst r20 = 2 * (x * z - w * y);\n\tconst r21 = 2 * (y * z + w * x);\n\tconst r22 = 1 - 2 * (x * x + y * y);\n\tconst r01 = 2 * (x * y - w * z);\n\tconst r11 = 1 - 2 * (x * x + z * z);\n\tconst sy = Math.max(-1, Math.min(1, -r20));\n\tlet a: Vec3;\n\tif (Math.abs(sy) > 0.999999) {\n\t\t// Gimbal lock: only x - z (or x + z) is defined; keep x where it was.\n\t\tconst ay = Math.asin(sy);\n\t\tconst keepX = previous ? previous[0] * DEG : 0;\n\t\tconst az = Math.atan2(-r01, r11) + (sy > 0 ? keepX : -keepX);\n\t\ta = [keepX, ay, az];\n\t} else {\n\t\ta = [Math.atan2(r21, r22), Math.asin(sy), Math.atan2(r10, r00)];\n\t}\n\tconst first: Vec3 = [a[0] / DEG, a[1] / DEG, a[2] / DEG];\n\tif (!previous) return first;\n\tconst second: Vec3 = [first[0] + 180, 180 - first[1], first[2] + 180];\n\tconst unwrap = (c: Vec3): Vec3 => [\n\t\tunwrapDegrees(previous[0], c[0]),\n\t\tunwrapDegrees(previous[1], c[1]),\n\t\tunwrapDegrees(previous[2], c[2]),\n\t];\n\tconst p = unwrap(first);\n\tconst s = unwrap(second);\n\tconst dist = (c: Vec3) =>\n\t\tMath.abs(c[0] - previous[0]) +\n\t\tMath.abs(c[1] - previous[1]) +\n\t\tMath.abs(c[2] - previous[2]);\n\treturn dist(p) <= dist(s) ? p : s;\n}\n\n/**\n * A simulated 3D body. Like {@link PhysicsBody2D}, its signals hold one\n * value per composition frame and reading one runs the simulation.\n */\nexport class PhysicsBody3D implements CoreBody<Vec3, Quat> {\n\treadonly collisions: PhysicsCollision<PhysicsBody3D>[] = [];\n\t/** @internal */ readonly recording: Recording;\n\t/** @internal */ readonly sim: SimBody3D;\n\n\t/** @internal */\n\tconstructor(\n\t\t/** @internal */ readonly world: PhysicsWorld3D,\n\t\tsim: SimBody3D,\n\t\treadonly type: \"dynamic\" | \"fixed\" | \"kinematic\",\n\t\treadonly layer: LayerLike | undefined,\n\t\tprivate readonly start: { position: Vec3; rotation: Vec3 },\n\t\tprivate readonly options: Body3DOptions,\n\t\trecording: Recording,\n\t) {\n\t\tthis.sim = sim;\n\t\tthis.recording = recording;\n\t}\n\n\tget startFrame(): number {\n\t\treturn Math.max(0, Math.round(this.options.startFrame ?? 0));\n\t}\n\tget gravityScale(): number {\n\t\treturn this.options.gravityScale ?? 1;\n\t}\n\tget output(): Body3DOptions[\"output\"] {\n\t\treturn this.options.output;\n\t}\n\n\t/** Center, px (what Layer3D's `x` / `y` / `z` mean). */\n\tget x(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"x\");\n\t}\n\tget y(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"y\");\n\t}\n\tget z(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"z\");\n\t}\n\t/** Degrees, continuous. */\n\tget rotateX(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"rotateX\");\n\t}\n\tget rotateY(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"rotateY\");\n\t}\n\tget rotateZ(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"rotateZ\");\n\t}\n\t/** px/s. */\n\tget vx(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"vx\");\n\t}\n\tget vy(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"vy\");\n\t}\n\tget vz(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"vz\");\n\t}\n\tget speed(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"speed\");\n\t}\n\t/** Hit envelope, as on 2D bodies. */\n\tget impact(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"impact\");\n\t}\n\t/** 1 while the body is at rest, else 0. */\n\tget sleeping(): FrameSignal<number> {\n\t\treturn this.recording.signal(\"sleeping\");\n\t}\n\n\t/** @internal */\n\tkinematicTarget(\n\t\tframe: number,\n\t): { position: Vec3; rotation: Quat } | undefined {\n\t\tconst follow = this.options.follow;\n\t\tif (this.type !== \"kinematic\" || !follow) return undefined;\n\t\tconst fps = this.world.fps;\n\t\tconst read = (d: PhysicsDriver | undefined, fallback: number) =>\n\t\t\td === undefined ? fallback : sampleDriver(d, frame, fps);\n\t\tconst p = this.start.position;\n\t\tconst r = this.start.rotation;\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\treturn {\n\t\t\tposition: [\n\t\t\t\tread(follow.x, p[0]) / ppm,\n\t\t\t\tread(follow.y, p[1]) / ppm,\n\t\t\t\tread(follow.z, p[2]) / ppm,\n\t\t\t],\n\t\t\trotation: quatFromEuler(\n\t\t\t\tread(follow.rotateX, r[0]),\n\t\t\t\tread(follow.rotateY, r[1]),\n\t\t\t\tread(follow.rotateZ, r[2]),\n\t\t\t),\n\t\t};\n\t}\n\n\t/** @internal */\n\trecord(index: number, previous: number): void {\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\tconst rec = this.recording;\n\t\tconst [x, y, z] = this.sim.position();\n\t\trec.channel(\"x\")[index] = x * ppm;\n\t\trec.channel(\"y\")[index] = y * ppm;\n\t\trec.channel(\"z\")[index] = z * ppm;\n\t\tconst rx = rec.channel(\"rotateX\");\n\t\tconst ry = rec.channel(\"rotateY\");\n\t\tconst rz = rec.channel(\"rotateZ\");\n\t\tconst prev: Vec3 =\n\t\t\tprevious < 0\n\t\t\t\t? this.start.rotation\n\t\t\t\t: [rx[previous], ry[previous], rz[previous]];\n\t\tconst e = eulerFromQuat(this.sim.rotation(), prev);\n\t\trx[index] = e[0];\n\t\try[index] = e[1];\n\t\trz[index] = e[2];\n\t\tconst [vx, vy, vz] = this.sim.velocity();\n\t\trec.channel(\"vx\")[index] = vx * ppm;\n\t\trec.channel(\"vy\")[index] = vy * ppm;\n\t\trec.channel(\"vz\")[index] = vz * ppm;\n\t\trec.channel(\"speed\")[index] = Math.hypot(vx, vy, vz) * ppm;\n\t\trec.channel(\"sleeping\")[index] = this.sim.sleeping() ? 1 : 0;\n\t}\n\n\t/** @internal */\n\tboundChannels(): Array<[AnimatableProp, string]> {\n\t\tconst out: Array<[AnimatableProp, string]> = [\n\t\t\t[\"x\", \"x\"],\n\t\t\t[\"y\", \"y\"],\n\t\t\t[\"z\", \"z\"],\n\t\t];\n\t\tif (this.options.lockRotation !== true) {\n\t\t\tout.push(\n\t\t\t\t[\"rotateX\", \"rotateX\"],\n\t\t\t\t[\"rotateY\", \"rotateY\"],\n\t\t\t\t[\"rotateZ\", \"rotateZ\"],\n\t\t\t);\n\t\t}\n\t\treturn out;\n\t}\n\n\t/** @internal World point (px) → local frame (meters) at the start pose. */\n\tlocalAnchor(point: Vec3 | undefined): Vec3 {\n\t\tif (!point) return [0, 0, 0];\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\tconst p = this.sim.position();\n\t\tconst [qx, qy, qz, qw] = this.sim.rotation();\n\t\tconst v: Vec3 = [\n\t\t\tpoint[0] / ppm - p[0],\n\t\t\tpoint[1] / ppm - p[1],\n\t\t\tpoint[2] / ppm - p[2],\n\t\t];\n\t\treturn rotateByQuat(v, [-qx, -qy, -qz, qw]);\n\t}\n\n\t/** @internal Start-pose center, px. */\n\tcenter(): Vec3 {\n\t\tconst ppm = this.world.pixelsPerMeter;\n\t\tconst [x, y, z] = this.sim.position();\n\t\treturn [x * ppm, y * ppm, z * ppm];\n\t}\n}\n\nfunction rotateByQuat(v: Vec3, q: Quat): Vec3 {\n\tconst r = quatMul(quatMul(q, [v[0], v[1], v[2], 0]), [\n\t\t-q[0],\n\t\t-q[1],\n\t\t-q[2],\n\t\tq[3],\n\t]);\n\treturn [r[0], r[1], r[2]];\n}\n\n/** What a {@link PhysicsWorld3D.field} sees for one body. */\nexport interface FieldSample3D {\n\tx: number;\n\ty: number;\n\tz: number;\n\tvx: number;\n\tvy: number;\n\tvz: number;\n\tframe: number;\n\tbody: PhysicsBody3D;\n}\n\nexport interface PhysicsSpring3DOptions {\n\tlength?: number;\n\tfrequency?: number;\n\tdampingRatio?: number;\n\tanchorA?: Vec3;\n\tanchorB?: Vec3;\n}\n\nexport interface PhysicsRope3DOptions {\n\tlength?: number;\n\tanchorA?: Vec3;\n\tanchorB?: Vec3;\n}\n\n/**\n * A deterministic 3D rigid-body world (Rapier) for Layer3D primitives and\n * models, in the 3D scene's pixels (y down). Same flow as 2D: add bodies,\n * `simulate()`, and each layer's `x/y/z` and `rotateX/Y/Z` follow the\n * simulation; bodies expose signals for everything else.\n */\nexport class PhysicsWorld3D extends WorldCore<Vec3, Quat, PhysicsBody3D> {\n\t/** @internal */\n\tconstructor(backend: PhysicsBackend, options: World3DOptions) {\n\t\tconst ppm = options.pixelsPerMeter ?? 100;\n\t\tconst g = options.gravity ?? 2400;\n\t\tconst gravity: Vec3 =\n\t\t\ttypeof g === \"number\"\n\t\t\t\t? [0, g / ppm, 0]\n\t\t\t\t: [g[0] / ppm, g[1] / ppm, g[2] / ppm];\n\t\tsuper(backend.createWorld3D(gravity) as never, gravity, options);\n\t}\n\n\t/** Adds a body for a Layer3D primitive or model (centered on its `x/y/z`), or a plain box. */\n\tbody(\n\t\ttarget: LayoutNode | PhysicsBox3D,\n\t\toptions: Body3DOptions = {},\n\t): PhysicsBody3D {\n\t\tthis.assertOpen();\n\t\tconst isLayer = typeof (target as unknown as LayerLike).kind === \"string\";\n\t\tconst layer = isLayer ? (target as unknown as LayerLike) : undefined;\n\t\tconst t = target as unknown as LayerLike;\n\t\tconst position: Vec3 = [\n\t\t\tnum(options.x ?? t.x, 0),\n\t\t\tnum(options.y ?? t.y, 0),\n\t\t\tnum(options.z ?? t.z, 0),\n\t\t];\n\t\tconst rotation: Vec3 = [\n\t\t\tnum(options.rotateX ?? t.rotateX, 0),\n\t\t\tnum(options.rotateY ?? t.rotateY, 0),\n\t\t\tnum(options.rotateZ ?? t.rotateZ, 0),\n\t\t];\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tconst type = options.type ?? \"dynamic\";\n\t\tconst v = options.velocity ?? [0, 0, 0];\n\t\tconst w = options.angularVelocity ?? [0, 0, 0];\n\t\tconst spec: BodySpec3D = {\n\t\t\ttype,\n\t\t\tposition: [position[0] / ppm, position[1] / ppm, position[2] / ppm],\n\t\t\trotation: quatFromEuler(rotation[0], rotation[1], rotation[2]),\n\t\t\tvelocity: [v[0] / ppm, v[1] / ppm, v[2] / ppm],\n\t\t\tangularVelocity: [w[0] * DEG, w[1] * DEG, w[2] * DEG],\n\t\t\tlinearDamping: options.linearDamping ?? 0,\n\t\t\tangularDamping: options.angularDamping ?? 0,\n\t\t\tgravityScale: options.gravityScale ?? 1,\n\t\t\tlockRotation: options.lockRotation === true,\n\t\t\t...(typeof options.lockRotation === \"object\" && {\n\t\t\t\tenabledRotations: [\n\t\t\t\t\t!options.lockRotation.x,\n\t\t\t\t\t!options.lockRotation.y,\n\t\t\t\t\t!options.lockRotation.z,\n\t\t\t\t] as [boolean, boolean, boolean],\n\t\t\t}),\n\t\t\tccd: options.ccd ?? false,\n\t\t\tenabled: true,\n\t\t\tsensor: options.sensor ?? false,\n\t\t\tdensity: options.density ?? 1,\n\t\t\tfriction: options.friction ?? 0.6,\n\t\t\trestitution: options.restitution ?? 0.3,\n\t\t\tshape: scaleShape(colliderShape3D(t, options), 1 / ppm),\n\t\t};\n\t\tconst simBody = (this.sim as unknown as SimWorld3D).addBody(spec);\n\t\tconst body = new PhysicsBody3D(\n\t\t\tthis,\n\t\t\tsimBody,\n\t\t\ttype,\n\t\t\tlayer,\n\t\t\t{ position, rotation },\n\t\t\toptions,\n\t\t\tthis.newRecording(),\n\t\t);\n\t\treturn this.addBody(body);\n\t}\n\n\t/** A fixed, very large floor whose top face sits at `y`. */\n\tground(options: {\n\t\ty: number;\n\t\tfriction?: number;\n\t\trestitution?: number;\n\t}): PhysicsBody3D {\n\t\tconst t = 2000;\n\t\treturn this.body(\n\t\t\t{ x: 0, y: options.y + t / 2, z: 0, width: 1e6, height: t, depth: 1e6 },\n\t\t\t{\n\t\t\t\ttype: \"fixed\",\n\t\t\t\tfriction: options.friction,\n\t\t\t\trestitution: options.restitution ?? 0.2,\n\t\t\t},\n\t\t);\n\t}\n\n\t/** Fixed floor and four walls around a box centered on `x`/`z`, floor at `y + height/2`. */\n\twalls(options: {\n\t\tx?: number;\n\t\ty?: number;\n\t\tz?: number;\n\t\twidth: number;\n\t\theight: number;\n\t\tdepth: number;\n\t\tthickness?: number;\n\t\tfriction?: number;\n\t\trestitution?: number;\n\t}): PhysicsBody3D[] {\n\t\tconst { width: W, height: H, depth: D } = options;\n\t\tconst [x, y, z] = [options.x ?? 0, options.y ?? 0, options.z ?? 0];\n\t\tconst t = options.thickness ?? 400;\n\t\tconst mat = {\n\t\t\ttype: \"fixed\" as const,\n\t\t\tfriction: options.friction,\n\t\t\trestitution: options.restitution ?? 0.2,\n\t\t};\n\t\tconst tall = H * 4;\n\t\tconst wy = y + H / 2 - tall / 2;\n\t\treturn [\n\t\t\tthis.body(\n\t\t\t\t{\n\t\t\t\t\tx,\n\t\t\t\t\ty: y + H / 2 + t / 2,\n\t\t\t\t\tz,\n\t\t\t\t\twidth: W + 2 * t,\n\t\t\t\t\theight: t,\n\t\t\t\t\tdepth: D + 2 * t,\n\t\t\t\t},\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tthis.body(\n\t\t\t\t{\n\t\t\t\t\tx: x - W / 2 - t / 2,\n\t\t\t\t\ty: wy,\n\t\t\t\t\tz,\n\t\t\t\t\twidth: t,\n\t\t\t\t\theight: tall,\n\t\t\t\t\tdepth: D + 2 * t,\n\t\t\t\t},\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tthis.body(\n\t\t\t\t{\n\t\t\t\t\tx: x + W / 2 + t / 2,\n\t\t\t\t\ty: wy,\n\t\t\t\t\tz,\n\t\t\t\t\twidth: t,\n\t\t\t\t\theight: tall,\n\t\t\t\t\tdepth: D + 2 * t,\n\t\t\t\t},\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tthis.body(\n\t\t\t\t{ x, y: wy, z: z - D / 2 - t / 2, width: W, height: tall, depth: t },\n\t\t\t\tmat,\n\t\t\t),\n\t\t\tthis.body(\n\t\t\t\t{ x, y: wy, z: z + D / 2 + t / 2, width: W, height: tall, depth: t },\n\t\t\t\tmat,\n\t\t\t),\n\t\t];\n\t}\n\n\t/** Pins a body to the world at a point (default its center); it can still turn around it. */\n\tpin(body: PhysicsBody3D, at?: Vec3): this {\n\t\tconst point = at ?? body.center();\n\t\tconst anchor = this.anchorBody(point);\n\t\tthis.joint(body, anchor, {\n\t\t\ttype: \"spherical\",\n\t\t\tanchorA: body.localAnchor(point),\n\t\t\tanchorB: [0, 0, 0],\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** Joins two bodies at a world point, turning only around `axis` (default z, facing the camera). */\n\thinge(\n\t\ta: PhysicsBody3D,\n\t\tb: PhysicsBody3D,\n\t\tat: Vec3,\n\t\taxis: Vec3 = [0, 0, 1],\n\t): this {\n\t\tthis.joint(a, b, {\n\t\t\ttype: \"revolute\",\n\t\t\tanchorA: a.localAnchor(at),\n\t\t\tanchorB: b.localAnchor(at),\n\t\t\taxis,\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** Glues two bodies together rigidly. */\n\tweld(a: PhysicsBody3D, b: PhysicsBody3D): this {\n\t\tthis.joint(a, b, {\n\t\t\ttype: \"fixed\",\n\t\t\tanchorA: [0, 0, 0],\n\t\t\tanchorB: b.localAnchor(a.center()),\n\t\t});\n\t\treturn this;\n\t}\n\n\tspring(\n\t\ta: PhysicsBody3D,\n\t\tb: PhysicsBody3D | Vec3,\n\t\toptions: PhysicsSpring3DOptions = {},\n\t): this {\n\t\tconst { other, pa, pb } = this.endpoints(\n\t\t\ta,\n\t\t\tb,\n\t\t\toptions.anchorA,\n\t\t\toptions.anchorB,\n\t\t);\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tconst length = (options.length ?? dist(pa, pb)) / ppm;\n\t\tconst ma = a.type === \"dynamic\" ? a.sim.mass() : 0;\n\t\tconst mb = other.type === \"dynamic\" ? other.sim.mass() : 0;\n\t\tconst mass =\n\t\t\tma > 0 && mb > 0 ? (ma * mb) / (ma + mb) : Math.max(ma, mb, 1e-3);\n\t\tconst w = 2 * Math.PI * (options.frequency ?? 2);\n\t\tthis.joint(a, other, {\n\t\t\ttype: \"spring\",\n\t\t\tanchorA: a.localAnchor(pa),\n\t\t\tanchorB: other.localAnchor(pb),\n\t\t\trestLength: length,\n\t\t\tstiffness: mass * w * w,\n\t\t\tdamping: 2 * (options.dampingRatio ?? 0.2) * mass * w,\n\t\t});\n\t\treturn this;\n\t}\n\n\trope(\n\t\ta: PhysicsBody3D,\n\t\tb: PhysicsBody3D | Vec3,\n\t\toptions: PhysicsRope3DOptions = {},\n\t): this {\n\t\tconst { other, pa, pb } = this.endpoints(\n\t\t\ta,\n\t\t\tb,\n\t\t\toptions.anchorA,\n\t\t\toptions.anchorB,\n\t\t);\n\t\tthis.joint(a, other, {\n\t\t\ttype: \"rope\",\n\t\t\tanchorA: a.localAnchor(pa),\n\t\t\tanchorB: other.localAnchor(pb),\n\t\t\tlength: (options.length ?? dist(pa, pb)) / this.pixelsPerMeter,\n\t\t});\n\t\treturn this;\n\t}\n\n\t/** A steady push, px/s² (mass-independent). Drivers are read every frame. */\n\tforce(\n\t\tbody: PhysicsBody3D,\n\t\taccel: { x?: PhysicsDriver; y?: PhysicsDriver; z?: PhysicsDriver },\n\t): this {\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tconst read = (d: PhysicsDriver | undefined, frame: number) =>\n\t\t\td === undefined ? 0 : sampleDriver(d, frame, this.fps) / ppm;\n\t\tthis.addForce(body, (frame) => [\n\t\t\tread(accel.x, frame),\n\t\t\tread(accel.y, frame),\n\t\t\tread(accel.z, frame),\n\t\t]);\n\t\treturn this;\n\t}\n\n\t/** A force field, as in 2D: returns `[ax, ay, az]` px/s² for a body at `x/y/z` px. */\n\tfield(\n\t\taccel: (sample: FieldSample3D) => Vec3 | null | undefined,\n\t\toptions: { bodies?: readonly PhysicsBody3D[] } = {},\n\t): this {\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tthis.addField((body, frame) => {\n\t\t\tconst [x, y, z] = body.sim.position();\n\t\t\tconst [vx, vy, vz] = body.sim.velocity();\n\t\t\tconst a = accel({\n\t\t\t\tx: x * ppm,\n\t\t\t\ty: y * ppm,\n\t\t\t\tz: z * ppm,\n\t\t\t\tvx: vx * ppm,\n\t\t\t\tvy: vy * ppm,\n\t\t\t\tvz: vz * ppm,\n\t\t\t\tframe,\n\t\t\t\tbody,\n\t\t\t});\n\t\t\treturn a ? [a[0] / ppm, a[1] / ppm, a[2] / ppm] : null;\n\t\t}, options.bodies);\n\t\treturn this;\n\t}\n\n\t/** An instant kick at a simulation frame: adds `[vx, vy, vz]` px/s. */\n\timpulse(body: PhysicsBody3D, frame: number, velocity: Vec3): this {\n\t\tconst ppm = this.pixelsPerMeter;\n\t\tthis.addImpulse(body, frame, [\n\t\t\tvelocity[0] / ppm,\n\t\t\tvelocity[1] / ppm,\n\t\t\tvelocity[2] / ppm,\n\t\t]);\n\t\treturn this;\n\t}\n\n\tprotected lerpRotation(a: Quat, b: Quat, t: number): Quat {\n\t\t// Normalized lerp along the short arc; fine for per-substep steps.\n\t\tconst sign =\n\t\t\ta[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3] < 0 ? -1 : 1;\n\t\tconst q = a.map((v, i) => v + (b[i] * sign - v) * t) as Quat;\n\t\tconst len = Math.hypot(...q) || 1;\n\t\treturn q.map((v) => v / len) as Quat;\n\t}\n\n\tprivate joint(\n\t\ta: PhysicsBody3D,\n\t\tb: PhysicsBody3D,\n\t\tspec: Parameters<SimWorld3D[\"addJoint\"]>[2],\n\t): void {\n\t\tthis.assertOpen();\n\t\t(this.sim as unknown as SimWorld3D).addJoint(a.sim, b.sim, spec);\n\t}\n\n\tprivate anchorBody(point: Vec3): PhysicsBody3D {\n\t\treturn this.body(\n\t\t\t{ x: point[0], y: point[1], z: point[2], width: 1, height: 1, depth: 1 },\n\t\t\t{ type: \"fixed\", output: \"none\", sensor: true },\n\t\t);\n\t}\n\n\tprivate endpoints(\n\t\ta: PhysicsBody3D,\n\t\tb: PhysicsBody3D | Vec3,\n\t\tanchorA?: Vec3,\n\t\tanchorB?: Vec3,\n\t): { other: PhysicsBody3D; pa: Vec3; pb: Vec3 } {\n\t\tconst pa = anchorA ?? a.center();\n\t\tif (Array.isArray(b)) {\n\t\t\tconst pb = anchorB ?? b;\n\t\t\treturn { other: this.anchorBody(pb), pa, pb };\n\t\t}\n\t\treturn { other: b, pa, pb: anchorB ?? b.center() };\n\t}\n}\n\nfunction dist(a: Vec3, b: Vec3): number {\n\treturn Math.hypot(b[0] - a[0], b[1] - a[1], b[2] - a[2]);\n}\n\nfunction num(v: unknown, fallback: number): number {\n\treturn typeof v === \"number\" && Number.isFinite(v) ? v : fallback;\n}\n\ninterface PrimitiveSpec {\n\ttype?: string;\n\tshape?: string;\n\twidth?: number;\n\theight?: number;\n\tdepth?: number;\n\tlength?: number;\n\tradius?: number;\n\ttube?: number;\n\touterRadius?: number;\n\tradiusTop?: number;\n\tradiusBottom?: number;\n\ttaper?: number;\n}\n\n/** Collider in px around the layer's center, with the layer's scale applied. */\nfunction colliderShape3D(t: LayerLike, options: Body3DOptions): Shape3D {\n\tconst id = typeof t.id === \"string\" ? ` \"${t.id}\"` : \"\";\n\tconst s = num(t.scale, 1);\n\tconst scale: Vec3 = [\n\t\ts * num(t.scaleX, 1),\n\t\ts * num(t.scaleY, 1),\n\t\ts * num(t.scaleZ, 1),\n\t];\n\tconst uniform = scale[0] === scale[1] && scale[1] === scale[2];\n\tconst prim = (t.primitive3d ?? {}) as PrimitiveSpec;\n\tconst mode = options.shape ?? \"auto\";\n\tconst hull = (): Shape3D | undefined => {\n\t\tconst pts = meshPoints(t.modelData);\n\t\tif (!pts) return undefined;\n\t\treturn { kind: \"hull\", points: pts.map((v, i) => v * scale[i % 3]) };\n\t};\n\n\tif (options.size || mode === \"box\") {\n\t\tconst [w, h, d] = options.size ?? boxSize(t, prim) ?? [0, 0, 0];\n\t\tif (w > 0 && h > 0 && d > 0) {\n\t\t\treturn {\n\t\t\t\tkind: \"box\",\n\t\t\t\thx: (w * scale[0]) / 2,\n\t\t\t\thy: (h * scale[1]) / 2,\n\t\t\t\thz: (d * scale[2]) / 2,\n\t\t\t\tradius:\n\t\t\t\t\tprim.type === \"roundedBox\"\n\t\t\t\t\t\t? num(prim.radius, 0) * Math.min(...scale)\n\t\t\t\t\t\t: 0,\n\t\t\t};\n\t\t}\n\t}\n\tif (mode === \"hull\") {\n\t\tconst h = hull();\n\t\tif (h) return h;\n\t}\n\tconst sphere =\n\t\tmode === \"sphere\" ||\n\t\t(mode === \"auto\" &&\n\t\t\t(prim.type === \"sphere\" ||\n\t\t\t\t(prim.type === \"polyhedron\" && prim.shape === \"icosphere\")));\n\tif (sphere && (uniform || mode === \"sphere\")) {\n\t\tconst r = num(prim.radius, 0) || Math.max(...(boxSize(t, prim) ?? [0])) / 2;\n\t\tif (r > 0) return { kind: \"ball\", radius: r * Math.max(...scale) };\n\t}\n\tconst rTop = num(prim.radiusTop, num(prim.radius, 0));\n\tconst rBottom = num(prim.radiusBottom, num(prim.radius, 0));\n\tconst cylinder =\n\t\tmode === \"cylinder\" || (mode === \"auto\" && prim.type === \"cylinder\");\n\tif (cylinder && rTop === rBottom && rTop > 0 && scale[0] === scale[2]) {\n\t\treturn {\n\t\t\tkind: \"cylinder\",\n\t\t\thalfHeight: (num(prim.height, 0) * scale[1]) / 2,\n\t\t\tradius: rTop * scale[0],\n\t\t};\n\t}\n\tif (\n\t\tmode === \"auto\" &&\n\t\tprim.type === \"roundedBox\" &&\n\t\t(prim.taper ?? 1) === 1\n\t) {\n\t\tconst [w, h, d] = [\n\t\t\tnum(prim.width, 0),\n\t\t\tnum(prim.height, 0),\n\t\t\tnum(prim.depth, 0),\n\t\t];\n\t\treturn {\n\t\t\tkind: \"box\",\n\t\t\thx: (w * scale[0]) / 2,\n\t\t\thy: (h * scale[1]) / 2,\n\t\t\thz: (d * scale[2]) / 2,\n\t\t\tradius: num(prim.radius, 0) * Math.min(...scale),\n\t\t};\n\t}\n\tconst h = hull();\n\tif (h) return h;\n\tconst size = boxSize(t, prim);\n\tif (size) {\n\t\treturn {\n\t\t\tkind: \"box\",\n\t\t\thx: (size[0] * scale[0]) / 2,\n\t\t\thy: (size[1] * scale[1]) / 2,\n\t\t\thz: (size[2] * scale[2]) / 2,\n\t\t};\n\t}\n\tthrow new Error(\n\t\t`Physics: layer${id} has no mesh or size to build a 3D collider from; pass \\`size: [w, h, d]\\`.`,\n\t);\n}\n\nfunction boxSize(t: LayerLike, prim: PrimitiveSpec): Vec3 | undefined {\n\tif (prim.type === \"roundedBox\")\n\t\treturn [num(prim.width, 0), num(prim.height, 0), num(prim.depth, 0)];\n\tif (prim.type === \"sphere\" || prim.type === \"polyhedron\") {\n\t\tconst d = num(prim.radius, 50) * 2;\n\t\treturn [d, d, d];\n\t}\n\tif (prim.type === \"capsule\") {\n\t\tconst r = num(prim.radius, 30);\n\t\tconst len = num(prim.length, 60);\n\t\treturn [r * 2, len + r * 2, r * 2];\n\t}\n\tif (prim.type === \"torus\") {\n\t\tconst R = num(prim.radius, 60);\n\t\tconst r = num(prim.tube, 20);\n\t\treturn [(R + r) * 2, (R + r) * 2, r * 2];\n\t}\n\tif (prim.type === \"ring\") {\n\t\tconst rOut = num(prim.outerRadius, 60);\n\t\tconst depth = Math.max(2, num(prim.depth, 0));\n\t\treturn [rOut * 2, rOut * 2, depth];\n\t}\n\tif (prim.type === \"cylinder\") {\n\t\tconst d =\n\t\t\tMath.max(\n\t\t\t\tnum(prim.radiusTop, num(prim.radius, 0)),\n\t\t\t\tnum(prim.radiusBottom, num(prim.radius, 0)),\n\t\t\t) * 2;\n\t\treturn [d, num(prim.height, 0), d];\n\t}\n\tif (\n\t\ttypeof t.width === \"number\" &&\n\t\ttypeof t.height === \"number\" &&\n\t\ttypeof t.depth === \"number\"\n\t) {\n\t\treturn [t.width, t.height, t.depth];\n\t}\n\treturn undefined;\n}\n\n/** Every vertex of a model, flat xyz, at most ~4k points (the hull needs no more). */\nfunction meshPoints(modelData: unknown): number[] | undefined {\n\tconst meshes = (\n\t\tmodelData as\n\t\t\t| { meshes?: Array<{ positions?: ArrayLike<number> }> }\n\t\t\t| undefined\n\t)?.meshes;\n\tif (!meshes?.length) return undefined;\n\tlet total = 0;\n\tfor (const m of meshes) total += (m.positions?.length ?? 0) / 3;\n\tif (total < 4) return undefined;\n\tconst stride = Math.max(1, Math.floor(total / 4096));\n\tconst out: number[] = [];\n\tlet i = 0;\n\tfor (const m of meshes) {\n\t\tconst p = m.positions;\n\t\tif (!p) continue;\n\t\tfor (let v = 0; v < p.length; v += 3, i++) {\n\t\t\tif (i % stride === 0) out.push(p[v], p[v + 1], p[v + 2]);\n\t\t}\n\t}\n\treturn out;\n}\n\nfunction scaleShape(shape: Shape3D, s: number): Shape3D {\n\tswitch (shape.kind) {\n\t\tcase \"ball\":\n\t\t\treturn { kind: \"ball\", radius: shape.radius * s };\n\t\tcase \"box\":\n\t\t\treturn {\n\t\t\t\tkind: \"box\",\n\t\t\t\thx: shape.hx * s,\n\t\t\t\thy: shape.hy * s,\n\t\t\t\thz: shape.hz * s,\n\t\t\t\tradius: (shape.radius ?? 0) * s,\n\t\t\t};\n\t\tcase \"cylinder\":\n\t\t\treturn {\n\t\t\t\tkind: \"cylinder\",\n\t\t\t\thalfHeight: shape.halfHeight * s,\n\t\t\t\tradius: shape.radius * s,\n\t\t\t};\n\t\tcase \"hull\":\n\t\t\treturn { kind: \"hull\", points: shape.points.map((v) => v * s) };\n\t}\n}\n","import { rapierBackend } from \"./backend.js\";\nimport { PhysicsWorld2D, type World2DOptions } from \"./world2d.js\";\nimport { PhysicsWorld3D, type World3DOptions } from \"./world3d.js\";\n\n/**\n * Rigid-body physics baked into signals. A world simulates once, while the\n * composition is built (Rapier's deterministic build, so every machine gets\n * the same motion), and replays as per-frame signals: layers follow their\n * bodies, and `impact`, `speed`, … drive any other prop or effect.\n *\n * ```ts\n * const world = await Physics.world2d({ fps: 30, frames: 150 });\n * world.walls({ width: W, height: H });\n * const card = world.body(cardLayer, { restitution: 0.4 });\n * world.simulate();\n * flash.animate(LayerAnimation.create().signal(\"opacity\", card.impact));\n * ```\n */\nexport const Physics = {\n\t/** A 2D world in layer pixels (y down). Loads the physics engine on first use. */\n\tasync world2d(options: World2DOptions): Promise<PhysicsWorld2D> {\n\t\treturn new PhysicsWorld2D(await rapierBackend(2), options);\n\t},\n\t/** A 3D world for Layer3D primitives and models, in scene pixels (y down). */\n\tasync world3d(options: World3DOptions): Promise<PhysicsWorld3D> {\n\t\treturn new PhysicsWorld3D(await rapierBackend(3), options);\n\t},\n};\n\nexport type {\n\tBodyCommonOptions,\n\tPhysicsBakeOptions,\n\tPhysicsCollision,\n\tPhysicsDriver,\n\tPhysicsWorldOptions,\n} from \"./core.js\";\nexport {\n\ttype Body2DOptions,\n\ttype FieldSample2D,\n\tPhysicsBody2D,\n\ttype PhysicsGroundOptions,\n\ttype PhysicsRect,\n\ttype PhysicsRopeOptions,\n\ttype PhysicsSpringOptions,\n\ttype PhysicsWallsOptions,\n\tPhysicsWorld2D,\n\ttype World2DOptions,\n} from \"./world2d.js\";\nexport {\n\ttype Body3DOptions,\n\ttype FieldSample3D,\n\tPhysicsBody3D,\n\ttype PhysicsBox3D,\n\ttype PhysicsRope3DOptions,\n\ttype PhysicsSpring3DOptions,\n\tPhysicsWorld3D,\n\ttype World3DOptions,\n} from \"./world3d.js\";\n","/**\n * Ready-made looks: each preset is a short stack of effects, applied with\n * `layer.withEffects(Styles.vhs())`. Presets take a few options for the\n * knobs that matter most; for anything finer, build the stack from the\n * effect classes directly.\n */\nimport type { Effect } from \"@framefields/core\";\nimport {\n\tAscii,\n\tContour,\n\tCRT,\n\tDither,\n\tFilmGrain,\n\tGradientMap,\n\tHalftoneScreen,\n\tIridescence,\n\tKaleidoscope,\n\tOpArt,\n\tPainterly,\n\tPixelate,\n\tPosterize,\n\tRGBSplit,\n\tToon,\n\tVignette,\n} from \"./effects/index.js\";\n\ntype Look = Effect<object>[];\nconst look = (...effects: unknown[]): Look => effects as Look;\n\nexport const Styles = {\n\t/** 8-bit game: PICO-8 palette, chunky pixels, light dithering. */\n\tpixelArt: (\n\t\to: { pixelSize?: number; palette?: \"pico8\" | \"c64\" | \"cga\" } = {},\n\t) =>\n\t\tlook(\n\t\t\tnew Posterize({\n\t\t\t\tpalette: o.palette ?? \"pico8\",\n\t\t\t\tpixelSize: o.pixelSize ?? 6,\n\t\t\t\tdither: 0.4,\n\t\t\t}),\n\t\t),\n\n\t/** Original Game Boy: four greens, dithered, big pixels. */\n\tgameBoy: (o: { pixelSize?: number } = {}) =>\n\t\tlook(\n\t\t\tnew Posterize({\n\t\t\t\tpalette: \"gameboy\",\n\t\t\t\tpixelSize: o.pixelSize ?? 4,\n\t\t\t\tdither: 0.6,\n\t\t\t}),\n\t\t),\n\n\t/** Teletext / Ceefax: eight flat colors in big blocks. */\n\tteletext: (o: { pixelSize?: number } = {}) =>\n\t\tlook(new Posterize({ palette: \"teletext\", pixelSize: o.pixelSize ?? 10 })),\n\n\t/** LED wall: round lit pixels with gaps. */\n\tledWall: (o: { size?: number } = {}) =>\n\t\tlook(new Pixelate({ size: o.size ?? 14, shape: \"circle\", gap: 0.18 })),\n\n\t/** Text-mode art: the clip drawn in characters. `matrix` makes it green phosphor. */\n\tascii: (o: { cellSize?: number; matrix?: boolean } = {}) =>\n\t\tlook(\n\t\t\tnew Ascii({\n\t\t\t\tcellSize: o.cellSize ?? 10,\n\t\t\t\tcolorMode: o.matrix ? \"green\" : \"source\",\n\t\t\t\tbg: o.matrix ? \"#020a04\" : \"#0b0b0b\",\n\t\t\t}),\n\t\t),\n\n\t/** 1-bit print: ordered dither in two inks. */\n\toneBit: (o: { dark?: string; light?: string; scale?: number } = {}) =>\n\t\tlook(\n\t\t\tnew Dither({\n\t\t\t\tmode: \"bayer\",\n\t\t\t\tscale: o.scale ?? 2,\n\t\t\t\tdark: o.dark ?? \"#111111\",\n\t\t\t\tlight: o.light ?? \"#f2efe6\",\n\t\t\t}),\n\t\t),\n\n\t/** Riso print: two inks on paper, ordered dither, grain. */\n\trisograph: (o: { inkA?: string; inkB?: string; paper?: string } = {}) => {\n\t\tconst a = o.inkA ?? \"#1d3fbb\";\n\t\tconst b = o.inkB ?? \"#ff5fa2\";\n\t\tconst paper = o.paper ?? \"#f4efe4\";\n\t\treturn look(\n\t\t\tnew GradientMap({\n\t\t\t\tstops: [\n\t\t\t\t\t{ position: 0, color: a },\n\t\t\t\t\t{ position: 0.55, color: b },\n\t\t\t\t\t{ position: 1, color: paper },\n\t\t\t\t],\n\t\t\t}),\n\t\t\tnew Posterize({\n\t\t\t\tpalette: \"custom\",\n\t\t\t\tcolors: [a, b, paper],\n\t\t\t\tdither: 0.8,\n\t\t\t\tpixelSize: 2,\n\t\t\t}),\n\t\t\tnew FilmGrain({ strength: 0.2 }),\n\t\t);\n\t},\n\n\t/** Cartoon / cel shading with ink outlines. */\n\tcartoon: (o: { levels?: number; ink?: string } = {}) =>\n\t\tlook(\n\t\t\tnew Toon({\n\t\t\t\tlevels: o.levels ?? 4,\n\t\t\t\tedgeColor: o.ink ?? \"#111111\",\n\t\t\t\tsaturation: 1.3,\n\t\t\t}),\n\t\t),\n\n\t/** Comic book: cel shading, ink lines and a halftone dot screen. */\n\tcomic: (o: { dotFrequency?: number } = {}) =>\n\t\tlook(\n\t\t\tnew Toon({ levels: 4, edgeWidth: 1.5, saturation: 1.4 }),\n\t\t\tnew HalftoneScreen({ frequency: o.dotFrequency ?? 70, opacity: 0.35 }),\n\t\t),\n\n\t/** Thermal camera: brightness mapped to the ironbow palette. */\n\tthermal: () =>\n\t\tlook(\n\t\t\tnew GradientMap({\n\t\t\t\tstops: [\n\t\t\t\t\t{ position: 0, color: \"#000010\" },\n\t\t\t\t\t{ position: 0.25, color: \"#3b0a7a\" },\n\t\t\t\t\t{ position: 0.5, color: \"#c4205f\" },\n\t\t\t\t\t{ position: 0.75, color: \"#ff9a1f\" },\n\t\t\t\t\t{ position: 1, color: \"#fffbe0\" },\n\t\t\t\t],\n\t\t\t}),\n\t\t),\n\n\t/** VHS tape: wobble, colour bleed, soft scanlines, grain. */\n\tvhs: (o: { tracking?: number } = {}) =>\n\t\tlook(\n\t\t\tnew CRT({\n\t\t\t\ttracking: o.tracking ?? 0.5,\n\t\t\t\tchroma: 4,\n\t\t\t\tcurvature: 0.04,\n\t\t\t\tscanlines: 0.25,\n\t\t\t\tmask: 0.05,\n\t\t\t\tnoise: 0.15,\n\t\t\t}),\n\t\t\tnew RGBSplit({ amount: 3 }),\n\t\t),\n\n\t/** An old CRT monitor: curved glass, scanlines, RGB mask. */\n\tcrt: (o: { curvature?: number } = {}) =>\n\t\tlook(\n\t\t\tnew CRT({ curvature: o.curvature ?? 0.15, scanlines: 0.5, mask: 0.35 }),\n\t\t),\n\n\t/** Glitch: hard RGB split plus tracking errors. Animate `amount` for hits. */\n\tglitch: (o: { amount?: number } = {}) =>\n\t\tlook(\n\t\t\tnew RGBSplit({ amount: o.amount ?? 18 }),\n\t\t\tnew CRT({\n\t\t\t\ttracking: 1,\n\t\t\t\tchroma: 6,\n\t\t\t\tcurvature: 0,\n\t\t\t\tscanlines: 0.1,\n\t\t\t\tmask: 0,\n\t\t\t\tvignette: 0,\n\t\t\t}),\n\t\t),\n\n\t/** Oil painting. */\n\toilPainting: (o: { brush?: number } = {}) =>\n\t\tlook(new Painterly({ style: \"oil\", radius: o.brush ?? 5 })),\n\n\t/** Watercolour: soft patches, pigment edges, paper. */\n\twatercolor: (o: { brush?: number } = {}) =>\n\t\tlook(\n\t\t\tnew Painterly({ style: \"watercolor\", radius: o.brush ?? 6, paper: 0.5 }),\n\t\t),\n\n\t/** Topographic map lines on paper. */\n\ttopographic: (o: { levels?: number; ink?: string; paper?: string } = {}) =>\n\t\tlook(\n\t\t\tnew Contour({\n\t\t\t\tlevels: o.levels ?? 16,\n\t\t\t\tfill: \"flat\",\n\t\t\t\tlineColor: o.ink ?? \"#5a3a1a\",\n\t\t\t\tfillColor: o.paper ?? \"#f3ead8\",\n\t\t\t}),\n\t\t),\n\n\t/** Kaleidoscope. Animate `rotation` on the returned effect, or pass a fixed angle. */\n\tkaleidoscope: (o: { segments?: number; rotation?: number } = {}) =>\n\t\tlook(\n\t\t\tnew Kaleidoscope({\n\t\t\t\tsegments: o.segments ?? 8,\n\t\t\t\trotation: o.rotation ?? 0,\n\t\t\t}),\n\t\t),\n\n\t/** Op art / line portrait: stripes bent by the image. */\n\topArt: (\n\t\to: {\n\t\t\tpattern?: \"stripes\" | \"rings\" | \"checker\" | \"waves\";\n\t\t\tfrequency?: number;\n\t\t} = {},\n\t) =>\n\t\tlook(\n\t\t\tnew OpArt({\n\t\t\t\tpattern: o.pattern ?? \"stripes\",\n\t\t\t\tfrequency: o.frequency ?? 60,\n\t\t\t}),\n\t\t),\n\n\t/** Holographic foil sheen. Animate `shift` to make it move. */\n\tholographic: (o: { strength?: number; shift?: number } = {}) =>\n\t\tlook(new Iridescence({ strength: o.strength ?? 0.7, shift: o.shift ?? 0 })),\n\n\t/** Black-and-white film noir: crushed tones, grain, vignette. */\n\tnoir: () =>\n\t\tlook(\n\t\t\tnew GradientMap({\n\t\t\t\tstops: [\n\t\t\t\t\t{ position: 0, color: \"#000000\" },\n\t\t\t\t\t{ position: 0.55, color: \"#8a8a8a\" },\n\t\t\t\t\t{ position: 1, color: \"#ffffff\" },\n\t\t\t\t],\n\t\t\t}),\n\t\t\tnew FilmGrain({ strength: 0.35 }),\n\t\t\tnew Vignette({ strength: 0.6 }),\n\t\t),\n\n\t/** Analog film: grain and a soft vignette. */\n\tfilm: () =>\n\t\tlook(new FilmGrain({ strength: 0.25 }), new Vignette({ strength: 0.35 })),\n};\n\nexport type StyleName = keyof typeof Styles;\n","import { LayerAnimation } from \"@framefields/compositions/program\";\nimport { z } from \"zod\";\n\n//#region src/core/rng.ts\n/** splitmix32: tiny, fast, and well distributed for animation jitter. */\nfunction rng(seed) {\n\tlet state = seed >>> 0;\n\tconst next = () => {\n\t\tstate = state + 2654435769 >>> 0;\n\t\tlet z$1 = state;\n\t\tz$1 = Math.imul(z$1 ^ z$1 >>> 16, 2246822507) >>> 0;\n\t\tz$1 = Math.imul(z$1 ^ z$1 >>> 13, 3266489909) >>> 0;\n\t\tz$1 = (z$1 ^ z$1 >>> 16) >>> 0;\n\t\treturn z$1 / 4294967296;\n\t};\n\treturn {\n\t\tnext,\n\t\trange: (min, max) => min + (max - min) * next(),\n\t\tint: (min, max) => min + Math.floor(next() * (max - min + 1)),\n\t\tpick: (items) => {\n\t\t\tif (items.length === 0) throw new Error(\"rng.pick: empty list\");\n\t\t\treturn items[Math.floor(next() * items.length)];\n\t\t},\n\t\tspread: (amount) => (next() * 2 - 1) * amount\n\t};\n}\n/** FNV-1a 32-bit hash of a string. */\nfunction hashString(value) {\n\tlet h = 2166136261;\n\tfor (let i = 0; i < value.length; i++) {\n\t\th ^= value.charCodeAt(i);\n\t\th = Math.imul(h, 16777619) >>> 0;\n\t}\n\treturn h >>> 0;\n}\n/**\n* A stream keyed by `key` under `seed`: the n-th word of a caption gets the\n* same jitter whether or not earlier words change.\n*/\nfunction hashRng(seed, key) {\n\treturn rng((Math.imul(seed >>> 0, 2654435761) ^ hashString(String(key))) >>> 0);\n}\n\n//#endregion\n//#region src/core/timing.ts\n/**\n* Frame math. Component times are integer frames (the SDK convention);\n* real-world inputs (seconds, beats, chars/sec) are rounded once, here.\n*/\n/** Seconds → whole frames. */\nfunction toFrames(seconds, fps) {\n\tassertFps(fps);\n\treturn Math.round(seconds * fps);\n}\n/** Whole frames → seconds. */\nfunction toSeconds(frames, fps) {\n\tassertFps(fps);\n\treturn frames / fps;\n}\n/** `n` beats of `beatFrames` each, as whole frames. */\nfunction beats(n, beatFrames) {\n\treturn Math.round(n * beatFrames);\n}\n/** Snap a frame to the nearest multiple of `grid` (no-op when grid ≤ 0). */\nfunction quantize(frame, grid) {\n\tif (!grid || grid <= 0) return Math.round(frame);\n\treturn Math.round(Math.round(frame / grid) * grid);\n}\n/**\n* Speeds in themes are authored at 30 fps; this rescales them so motion\n* lasts the same time at any frame rate.\n*/\nfunction scaleFrames(framesAt30, fps) {\n\tassertFps(fps);\n\treturn Math.max(1, Math.round(framesAt30 * fps / 30));\n}\n/**\n* Start offset (frames) for each of `count` units, `stagger` frames apart,\n* in the given order. `random` is a seeded shuffle of the forward offsets.\n*/\nfunction staggerOffsets(count, stagger, order = \"forward\", seed = 1) {\n\tif (count <= 0) return [];\n\treturn staggerRanks(count, order, seed).map((r) => Math.round(r * stagger));\n}\n/** The position (0 = first) at which each unit starts, by order. */\nfunction staggerRanks(count, order, seed = 1) {\n\tconst idx = Array.from({ length: count }, (_, i) => i);\n\tconst center = (count - 1) / 2;\n\tswitch (order) {\n\t\tcase \"forward\": return idx;\n\t\tcase \"reverse\": return idx.map((i) => count - 1 - i);\n\t\tcase \"center\": return idx.map((i) => Math.abs(i - center));\n\t\tcase \"edges\": return idx.map((i) => center - Math.abs(i - center));\n\t\tcase \"random\": {\n\t\t\tconst r = rng(seed);\n\t\t\tconst shuffled = [...idx];\n\t\t\tfor (let i = shuffled.length - 1; i > 0; i--) {\n\t\t\t\tconst j = Math.floor(r.next() * (i + 1));\n\t\t\t\t[shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];\n\t\t\t}\n\t\t\tconst ranks = new Array(count);\n\t\t\tshuffled.forEach((unit, position) => {\n\t\t\t\tranks[unit] = position;\n\t\t\t});\n\t\t\treturn ranks;\n\t\t}\n\t}\n}\nconst frameSpan = (start, duration) => ({\n\tstart,\n\tend: start + Math.max(0, duration)\n});\nconst within = (frame, w) => frame >= w.start && frame <= w.end;\n/** The smallest window that covers all of `windows`. */\nfunction cover(windows) {\n\tif (windows.length === 0) return {\n\t\tstart: 0,\n\t\tend: 0\n\t};\n\tlet start = Number.POSITIVE_INFINITY;\n\tlet end = Number.NEGATIVE_INFINITY;\n\tfor (const w of windows) {\n\t\tstart = Math.min(start, w.start);\n\t\tend = Math.max(end, w.end);\n\t}\n\treturn {\n\t\tstart,\n\t\tend\n\t};\n}\n/** Lay out durations back to back from `start`, with `gap` frames between. */\nfunction chain(durations, start = 0, gap = 0) {\n\tconst out = [];\n\tlet cursor = start;\n\tfor (const d of durations) {\n\t\tout.push(frameSpan(cursor, d));\n\t\tcursor += d + gap;\n\t}\n\treturn out;\n}\nfunction assertFps(fps) {\n\tif (!(fps > 0) || !Number.isFinite(fps)) throw new Error(`fps must be a positive number, got ${fps}`);\n}\n\n//#endregion\n//#region src/core/motion.ts\n/**\n* Named entrances and exits shared by every component's `enter` / `exit`.\n* A preset becomes plain keyframes on the component's `stage` part, which is\n* pinned at (0, 0) inside the root, so offsets never fight the root's layout.\n* Mask presets slide the stage a full width or height through the root,\n* which clips it.\n*/\nconst MOTION_PRESETS = [\n\t\"none\",\n\t\"fade\",\n\t\"rise\",\n\t\"drop\",\n\t\"scale\",\n\t\"pop\",\n\t\"slide-left\",\n\t\"slide-right\",\n\t\"slide-up\",\n\t\"slide-down\",\n\t\"tilt\",\n\t\"mask-up\",\n\t\"mask-down\",\n\t\"mask-left\",\n\t\"mask-right\"\n];\n/** Normalise a preset (or `false`) against a theme and fps. */\nfunction resolveMotion(input, kind, theme, fps = 30) {\n\tif (input === false || input === void 0) return null;\n\tconst o = typeof input === \"string\" ? { preset: input } : input;\n\tif (o.preset === \"none\") return null;\n\tif (!MOTION_PRESETS.includes(o.preset)) throw new Error(`Unknown motion preset \"${o.preset}\". Use one of: ${MOTION_PRESETS.join(\", \")}.`);\n\treturn {\n\t\tpreset: o.preset,\n\t\tduration: Math.max(1, Math.round(o.duration ?? scaleFrames(theme.motion.speed.base, fps))),\n\t\tease: o.ease ?? (o.preset === \"pop\" ? theme.motion.ease.snap : kind === \"enter\" ? theme.motion.ease.enter : theme.motion.ease.exit),\n\t\tdistance: o.distance ?? (o.preset.startsWith(\"slide-\") ? 120 : 40) * theme.scale,\n\t\tdelay: Math.max(0, Math.round(o.delay ?? 0)),\n\t\tblur: shutter(o.blur ?? o.preset.startsWith(\"slide-\"))\n\t};\n}\nconst shutter = (blur) => blur === true ? 90 : blur === false ? 0 : Math.max(0, Math.min(360, blur));\nconst isMask = (m) => m.preset.startsWith(\"mask-\");\n/** Offset (dx, dy) a translating preset starts from (enter) or ends at (exit). */\nfunction offsetOf(m, size) {\n\tswitch (m.preset) {\n\t\tcase \"mask-up\": return [0, size?.height ?? m.distance];\n\t\tcase \"mask-down\": return [0, -(size?.height ?? m.distance)];\n\t\tcase \"mask-left\": return [size?.width ?? m.distance, 0];\n\t\tcase \"mask-right\": return [-(size?.width ?? m.distance), 0];\n\t\tcase \"rise\":\n\t\tcase \"slide-up\": return [0, m.distance];\n\t\tcase \"drop\":\n\t\tcase \"slide-down\": return [0, -m.distance];\n\t\tcase \"slide-left\": return [m.distance, 0];\n\t\tcase \"slide-right\": return [-m.distance, 0];\n\t\tdefault: return [0, 0];\n\t}\n}\n/**\n* Keyframes for an entrance that ends settled at frame `at + delay + duration`\n* (local frames of the animated node).\n*/\nfunction enterAnimation(m, at = 0, size) {\n\tconst s = at + m.delay;\n\tconst e = s + m.duration;\n\tconst anim = LayerAnimation.create();\n\tif (!isMask(m)) anim.keys(\"opacity\", [[s, 0], [\n\t\te,\n\t\t1,\n\t\tm.ease\n\t]]);\n\tconst [dx, dy] = offsetOf(m, size);\n\tif (dx !== 0) anim.keys(\"x\", [[s, dx], [\n\t\te,\n\t\t0,\n\t\tm.ease\n\t]]);\n\tif (dy !== 0) anim.keys(\"y\", [[s, dy], [\n\t\te,\n\t\t0,\n\t\tm.ease\n\t]]);\n\tif (m.preset === \"scale\") anim.keys(\"scale\", [[s, .92], [\n\t\te,\n\t\t1,\n\t\tm.ease\n\t]]);\n\tif (m.preset === \"pop\") anim.keys(\"scale\", [[s, .6], [\n\t\te,\n\t\t1,\n\t\tm.ease\n\t]]);\n\tif (m.preset === \"tilt\") {\n\t\tanim.keys(\"perspective\", [[s, 1200]]);\n\t\tanim.keys(\"rotateX\", [[s, 28], [\n\t\t\te,\n\t\t\t0,\n\t\t\tm.ease\n\t\t]]);\n\t\tanim.keys(\"translateZ\", [[s, -160], [\n\t\t\te,\n\t\t\t0,\n\t\t\tm.ease\n\t\t]]);\n\t}\n\treturn anim;\n}\n/**\n* Keyframes for an exit that finishes at local frame `end - delay`.\n*/\nfunction exitAnimation(m, end, size) {\n\tconst e = end - m.delay;\n\tconst s = Math.max(0, e - m.duration);\n\tconst anim = LayerAnimation.create();\n\tif (!isMask(m)) anim.keys(\"opacity\", [[s, 1], [\n\t\te,\n\t\t0,\n\t\tm.ease\n\t]]);\n\tconst [dx, dy] = offsetOf(m, size);\n\tif (dx !== 0) anim.keys(\"x\", [[s, 0], [\n\t\te,\n\t\t-dx,\n\t\tm.ease\n\t]]);\n\tif (dy !== 0) anim.keys(\"y\", [[s, 0], [\n\t\te,\n\t\t-dy,\n\t\tm.ease\n\t]]);\n\tif (m.preset === \"scale\") anim.keys(\"scale\", [[s, 1], [\n\t\te,\n\t\t.92,\n\t\tm.ease\n\t]]);\n\tif (m.preset === \"pop\") anim.keys(\"scale\", [[s, 1], [\n\t\te,\n\t\t.6,\n\t\tm.ease\n\t]]);\n\tif (m.preset === \"tilt\") {\n\t\tanim.keys(\"perspective\", [[s, 1200]]);\n\t\tanim.keys(\"rotateX\", [[s, 0], [\n\t\t\te,\n\t\t\t-28,\n\t\t\tm.ease\n\t\t]]);\n\t\tanim.keys(\"translateZ\", [[s, 0], [\n\t\t\te,\n\t\t\t-160,\n\t\t\tm.ease\n\t\t]]);\n\t}\n\treturn anim;\n}\n\n//#endregion\n//#region src/core/color.ts\nconst NAMED = {\n\twhite: [\n\t\t255,\n\t\t255,\n\t\t255,\n\t\t1\n\t],\n\tblack: [\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t1\n\t],\n\ttransparent: [\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0\n\t]\n};\n/** The color's channels, or null when the format isn't one listed above. */\nfunction parseColor(color) {\n\tconst c = color.trim().toLowerCase();\n\tconst named = NAMED[c];\n\tif (named) return [...named];\n\tconst hex = c.match(/^#([\\da-f]{3,4}|[\\da-f]{6}|[\\da-f]{8})$/);\n\tif (hex?.[1]) {\n\t\tconst h = hex[1].length <= 4 ? [...hex[1]].map((x) => x + x).join(\"\") : hex[1];\n\t\tconst byte = (i) => Number.parseInt(h.slice(i, i + 2), 16);\n\t\treturn [\n\t\t\tbyte(0),\n\t\t\tbyte(2),\n\t\t\tbyte(4),\n\t\t\th.length === 8 ? byte(6) / 255 : 1\n\t\t];\n\t}\n\tconst fn$1 = c.match(/^rgba?\\(([^)]*)\\)$/);\n\tif (fn$1?.[1]) {\n\t\tconst parts = fn$1[1].split(/[\\s,/]+/).filter(Boolean);\n\t\tif (parts.length !== 3 && parts.length !== 4) return null;\n\t\tconst num$2 = (p, max) => p.endsWith(\"%\") ? Number.parseFloat(p) / 100 * max : Number(p);\n\t\tconst [r, g, b] = parts.slice(0, 3).map((p) => num$2(p, 255));\n\t\tconst a = parts[3] === void 0 ? 1 : num$2(parts[3], 1);\n\t\tif ([\n\t\t\tr,\n\t\t\tg,\n\t\t\tb,\n\t\t\ta\n\t\t].some((v) => v === void 0 || Number.isNaN(v))) return null;\n\t\treturn [\n\t\t\tr,\n\t\t\tg,\n\t\t\tb,\n\t\t\ta\n\t\t];\n\t}\n\treturn null;\n}\nconst css = ([r, g, b, a]) => `rgba(${Math.round(r)},${Math.round(g)},${Math.round(b)},${+a.toFixed(3)})`;\n/** `color` at `alpha` (replacing its own); unknown formats pass through. */\nfunction withAlpha(color, alpha) {\n\tconst c = parseColor(color);\n\treturn c ? css([\n\t\tc[0],\n\t\tc[1],\n\t\tc[2],\n\t\talpha\n\t]) : color;\n}\n/**\n* `color` fully transparent, keeping its hue, so a gradient fading to it has\n* no dark fringe. Unknown formats give plain `rgba(0,0,0,0)`.\n*/\nfunction transparent(color) {\n\tconst c = parseColor(color);\n\treturn css(c ? [\n\t\tc[0],\n\t\tc[1],\n\t\tc[2],\n\t\t0\n\t] : [\n\t\t0,\n\t\t0,\n\t\t0,\n\t\t0\n\t]);\n}\n/** Mix `a` toward `b` by `t` (0 → a, 1 → b): `#rrggbb` when both are opaque. */\nfunction mix(a, b, t) {\n\tconst x = parseColor(a);\n\tconst y = parseColor(b);\n\tif (!x || !y) return a;\n\tconst m = x.map((v, k) => v + (y[k] - v) * t);\n\tif (m[3] < 1) return css(m);\n\treturn `#${m.slice(0, 3).map((v) => Math.round(v).toString(16).padStart(2, \"0\")).join(\"\")}`;\n}\n/** WCAG relative luminance (0 black … 1 white), or null for unknown formats. */\nfunction luminance(color) {\n\tconst c = parseColor(color);\n\tif (!c) return null;\n\tconst channel = (v) => {\n\t\tconst s = v / 255;\n\t\treturn s <= .03928 ? s / 12.92 : ((s + .055) / 1.055) ** 2.4;\n\t};\n\treturn .2126 * channel(c[0]) + .7152 * channel(c[1]) + .0722 * channel(c[2]);\n}\n/** WCAG contrast ratio of two colors, or null when either is unknown. */\nfunction contrastRatio(a, b) {\n\tconst la = luminance(a);\n\tconst lb = luminance(b);\n\tif (la === null || lb === null) return null;\n\tconst [hi, lo] = la > lb ? [la, lb] : [lb, la];\n\treturn (hi + .05) / (lo + .05);\n}\n/**\n* True when black text reads better than white on `color` (luminance above\n* ~0.18). Unknown formats count as dark.\n*/\nfunction isLight(color) {\n\treturn (luminance(color) ?? 0) > .179;\n}\n/** Whichever of `light` / `dark` ink reads better on `background`. */\nfunction inkOn(background, light = \"#ffffff\", dark = \"#0b0c0e\") {\n\treturn (contrastRatio(light, background) ?? 0) >= (contrastRatio(dark, background) ?? 0) ? light : dark;\n}\n\n//#endregion\n//#region src/core/theme.ts\n/**\n* Design tokens every component reads instead of hard-coded colors, fonts and\n* timings. `defineTheme` deep-merges a partial theme over `themes.graphite`.\n*/\nconst motion = {\n\tease: {\n\t\tenter: \"expo.out\",\n\t\texit: \"power2.in\",\n\t\tmove: \"power3.inOut\",\n\t\tsnap: \"back.out(1.6)\"\n\t},\n\tspeed: {\n\t\tfast: 8,\n\t\tbase: 16,\n\t\tslow: 30\n\t},\n\tspring: {\n\t\tsettle: {\n\t\t\tstiffness: 230,\n\t\t\tdamping: 24\n\t\t},\n\t\tbase: {\n\t\t\tstiffness: 260,\n\t\t\tdamping: 20\n\t\t},\n\t\tpop: {\n\t\t\tstiffness: 320,\n\t\t\tdamping: 14\n\t\t}\n\t}\n};\nconst weight = {\n\tregular: 400,\n\tmedium: 500,\n\tsemibold: 600,\n\tbold: 700,\n\theavy: 800\n};\n/** Dark grounds need deeper shadows, and a lit top edge to separate surfaces. */\nconst darkElevation = {\n\tlow: {\n\t\topacity: .32,\n\t\tdistance: 3,\n\t\tsize: 10,\n\t\tedge: .07\n\t},\n\tmid: {\n\t\topacity: .4,\n\t\tdistance: 10,\n\t\tsize: 30,\n\t\tedge: .08\n\t},\n\thigh: {\n\t\topacity: .5,\n\t\tdistance: 22,\n\t\tsize: 60,\n\t\tedge: .1\n\t}\n};\nconst lightElevation = {\n\tlow: {\n\t\topacity: .1,\n\t\tdistance: 2,\n\t\tsize: 8,\n\t\tedge: 0\n\t},\n\tmid: {\n\t\topacity: .14,\n\t\tdistance: 8,\n\t\tsize: 26,\n\t\tedge: 0\n\t},\n\thigh: {\n\t\topacity: .2,\n\t\tdistance: 18,\n\t\tsize: 54,\n\t\tedge: 0\n\t}\n};\nconst shape = {\n\tradius: {\n\t\tsm: 6,\n\t\tmd: 12,\n\t\tlg: 24,\n\t\tpill: 999\n\t},\n\tstroke: {\n\t\thair: 1,\n\t\tbase: 2,\n\t\tbold: 4\n\t}\n};\nconst fonts = {\n\tdisplay: \"Inter\",\n\tbody: \"Inter\",\n\tmono: \"JetBrains Mono\"\n};\n/** Built-in themes. Fonts are never bundled: register the families you use. */\nconst themes = {\n\tgraphite: {\n\t\tmode: \"dark\",\n\t\tcolor: {\n\t\t\tbg: \"#0d0e11\",\n\t\t\tsurface: \"#16181d\",\n\t\t\traised: \"#1f2229\",\n\t\t\tline: \"#2b2f38\",\n\t\t\tink: \"#f3f4f6\",\n\t\t\tmuted: \"#8b909c\",\n\t\t\taccent: \"#5b8cff\",\n\t\t\taccent2: \"#b07cff\",\n\t\t\tpositive: \"#3ecf8e\",\n\t\t\tnegative: \"#ff5c5c\",\n\t\t\thighlight: \"#ffd23f\",\n\t\t\tshadow: \"#000000\"\n\t\t},\n\t\tfont: fonts,\n\t\tweight,\n\t\t...shape,\n\t\televation: darkElevation,\n\t\tmotion,\n\t\tscale: 1\n\t},\n\tpaper: {\n\t\tmode: \"light\",\n\t\tcolor: {\n\t\t\tbg: \"#f4f1ea\",\n\t\t\tsurface: \"#fffdf8\",\n\t\t\traised: \"#ffffff\",\n\t\t\tline: \"#dcd6c8\",\n\t\t\tink: \"#1a1814\",\n\t\t\tmuted: \"#6b665c\",\n\t\t\taccent: \"#e0451f\",\n\t\t\taccent2: \"#1f5fe0\",\n\t\t\tpositive: \"#1f8a4c\",\n\t\t\tnegative: \"#c8282d\",\n\t\t\thighlight: \"#ffe066\",\n\t\t\tshadow: \"#3b2f1e\"\n\t\t},\n\t\tfont: fonts,\n\t\tweight,\n\t\t...shape,\n\t\televation: lightElevation,\n\t\tmotion,\n\t\tscale: 1\n\t},\n\tsignal: {\n\t\tmode: \"dark\",\n\t\tcolor: {\n\t\t\tbg: \"#000000\",\n\t\t\tsurface: \"#111111\",\n\t\t\traised: \"#1c1c1c\",\n\t\t\tline: \"#333333\",\n\t\t\tink: \"#ffffff\",\n\t\t\tmuted: \"#a3a3a3\",\n\t\t\taccent: \"#c6ff00\",\n\t\t\taccent2: \"#ff2e88\",\n\t\t\tpositive: \"#00e676\",\n\t\t\tnegative: \"#ff1744\",\n\t\t\thighlight: \"#c6ff00\",\n\t\t\tshadow: \"#000000\"\n\t\t},\n\t\tfont: fonts,\n\t\tweight,\n\t\t...shape,\n\t\televation: darkElevation,\n\t\tmotion: {\n\t\t\t...motion,\n\t\t\tease: {\n\t\t\t\t...motion.ease,\n\t\t\t\tenter: \"back.out(1.8)\"\n\t\t\t},\n\t\t\tspeed: {\n\t\t\t\tfast: 6,\n\t\t\t\tbase: 12,\n\t\t\t\tslow: 24\n\t\t\t},\n\t\t\tspring: {\n\t\t\t\tsettle: {\n\t\t\t\t\tstiffness: 300,\n\t\t\t\t\tdamping: 26\n\t\t\t\t},\n\t\t\t\tbase: {\n\t\t\t\t\tstiffness: 340,\n\t\t\t\t\tdamping: 22\n\t\t\t\t},\n\t\t\t\tpop: {\n\t\t\t\t\tstiffness: 400,\n\t\t\t\t\tdamping: 14\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\tscale: 1\n\t}\n};\n/**\n* Merge a partial theme over a base (default `themes.graphite`). Throws when\n* `ink` on `surface` falls below WCAG 4.5:1 and both are hex colors.\n*/\nfunction defineTheme(input = {}, base = themes.graphite) {\n\tconst theme = merge(base, input);\n\tif (input.mode === void 0 && input.color?.bg !== void 0) {\n\t\ttheme.mode = isLight(theme.color.bg) ? \"light\" : \"dark\";\n\t\tif (input.elevation === void 0) theme.elevation = theme.mode === \"light\" ? lightElevation : darkElevation;\n\t}\n\tconst ratio = contrastRatio(theme.color.ink, theme.color.surface);\n\tif (ratio !== null && ratio < 4.5) throw new Error(`Theme contrast too low: ink ${theme.color.ink} on surface ${theme.color.surface} is ${ratio.toFixed(2)}:1 (needs 4.5:1).`);\n\treturn theme;\n}\n/** A theme's duration token in frames at `fps`. */\nfunction themeFrames(theme, speed, fps = 30) {\n\treturn scaleFrames(theme.motion.speed[speed], fps);\n}\nfunction merge(base, over) {\n\tif (over === void 0) return base;\n\tif (base === null || over === null || typeof base !== \"object\" || typeof over !== \"object\" || Array.isArray(base) || Array.isArray(over)) return over;\n\tconst out = { ...base };\n\tfor (const [key, value] of Object.entries(over)) out[key] = merge(out[key], value);\n\treturn out;\n}\n\n//#endregion\n//#region src/core/contract.ts\n/** Shift every cue's `frame` (and `end`, when present) by `offset`. */\nfunction offsetCues(cues, offset) {\n\tconst out = {};\n\tfor (const [name, list$1] of Object.entries(cues)) out[name] = list$1.map((c) => {\n\t\tconst shifted = {\n\t\t\t...c,\n\t\t\tframe: c.frame + offset\n\t\t};\n\t\tif (typeof c.end === \"number\") shifted.end = c.end + offset;\n\t\treturn shifted;\n\t});\n\treturn out;\n}\n/**\n* Keyframes that pulse at each cue: rest → peak on the cue → rest. Use them\n* on any prop: `LayerAnimation.keys(\"scale\", pulseKeys(pointer.cues.clicks, { rest: 1, peak: 1.1 }))`.\n* Frames are as given, so cues from a sibling component line up when both\n* share a parent.\n*/\nfunction pulseKeys(cues, { rest = 0, peak = 1, attack = 0, release = 8, ease: ease$1 = \"power2.out\" } = {}) {\n\tconst frames = cues.map((c) => typeof c === \"number\" ? c : c.frame).sort((a, b) => a - b);\n\tconst keys = /* @__PURE__ */ new Map();\n\tfor (const f of frames) {\n\t\tconst from = Math.max(0, f - attack);\n\t\tif (!keys.has(from)) keys.set(from, [from, rest]);\n\t\tkeys.set(f, [f, peak]);\n\t\tkeys.set(f + release, [\n\t\t\tf + release,\n\t\t\trest,\n\t\t\tease$1\n\t\t]);\n\t}\n\treturn [...keys.values()].sort((a, b) => a[0] - b[0]);\n}\nconst fn = () => z.custom((v) => typeof v === \"function\", { message: \"Expected a function\" });\nfunction motionPresetSchema() {\n\treturn z.union([z.enum(MOTION_PRESETS), z.object({\n\t\tpreset: z.enum(MOTION_PRESETS),\n\t\tduration: z.number().int().positive().optional(),\n\t\tease: z.string().optional(),\n\t\tdistance: z.number().optional(),\n\t\tdelay: z.number().int().min(0).optional(),\n\t\tblur: z.union([z.boolean(), z.number().min(0).max(360)]).optional()\n\t})]);\n}\nlet baseProps;\n/** Props every component accepts (built on first use). */\nfunction basePropsSchema() {\n\tbaseProps ??= buildBaseProps();\n\treturn baseProps;\n}\nfunction buildBaseProps() {\n\treturn z.object({\n\t\tid: z.string().min(1).optional(),\n\t\tat: z.number().int().min(0).optional(),\n\t\tduration: z.number().int().positive().optional(),\n\t\thold: z.number().int().min(0).optional(),\n\t\tenter: z.union([motionPresetSchema(), z.literal(false)]).optional(),\n\t\texit: z.union([motionPresetSchema(), z.literal(false)]).optional(),\n\t\tx: z.number().optional(),\n\t\ty: z.number().optional(),\n\t\twidth: z.number().positive().optional(),\n\t\theight: z.number().positive().optional(),\n\t\tposition: z.enum([\"absolute\", \"relative\"]).optional(),\n\t\ttheme: z.custom((v) => typeof v === \"object\" && v !== null).optional(),\n\t\tseed: z.number().int().optional(),\n\t\tfps: z.number().positive().optional(),\n\t\tcanvas: z.object({\n\t\t\twidth: z.number().positive(),\n\t\t\theight: z.number().positive()\n\t\t}).strict().optional(),\n\t\tcustomize: fn().optional()\n\t});\n}\nfunction defineComponent(definition) {\n\treturn definition;\n}\n/**\n* Wrap component factories so every call starts from the project's frame\n* rate, canvas, theme and seed. Props given at the call win; a call's\n* partial `theme` merges over the default theme, not over `graphite`.\n*\n* ```ts\n* const ui = withDefaults({ fps: 60, canvas: { width: 1080, height: 1920 }, theme: themes.paper });\n* const Captions = ui(CaptionsBase);\n* ```\n*/\nfunction withDefaults(defaults) {\n\tconst base = defaults.theme ? defineTheme(defaults.theme) : void 0;\n\treturn (factory) => (props) => factory({\n\t\t...defaults,\n\t\t...props,\n\t\ttheme: props.theme && base ? defineTheme(props.theme, base) : props.theme ?? base\n\t});\n}\n/**\n* The frame `gap` frames after `node` ends: `at: after(title, 6)`. Throws\n* for open-ended components, which have no end until given a `duration`.\n*/\nfunction after(node, gap = 0) {\n\tif (!Number.isFinite(node.span.end)) throw new Error(\"after(): this component is open-ended (it stays until its parent ends). Give it a `duration`, or use its cues.\");\n\treturn node.span.end + gap;\n}\nconst kebab = (name) => name.replace(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n/**\n* Bind a definition to a host, producing the user-facing factory. framefields\n* calls this once per component behind a PURE annotation, so bundlers drop\n* the ones nobody imports.\n*/\nfunction bind(host, definition) {\n\tlet schema;\n\treturn (input) => {\n\t\tschema ??= basePropsSchema().extend(definition.props()).strict();\n\t\tconst parsed = schema.safeParse(input ?? {});\n\t\tif (!parsed.success) {\n\t\t\tconst known = Object.keys(schema.shape);\n\t\t\tconst issues = parsed.error.issues.map((i) => {\n\t\t\t\tconst where = i.path.join(\".\") || \"(props)\";\n\t\t\t\tconst hint = i.code === \"unrecognized_keys\" && i.path.length === 0 ? suggest(i.keys, known) : \"\";\n\t\t\t\treturn ` - ${where}: ${i.message}${hint}`;\n\t\t\t}).join(\"\\n\");\n\t\t\tconst who = typeof input?.id === \"string\" ? `${definition.name}#${input.id}` : definition.name;\n\t\t\tthrow new Error(`${who}: invalid props\\n${issues}`);\n\t\t}\n\t\treturn assemble(host, definition, parsed.data);\n\t};\n}\n/** ` (did you mean \"label\"?)` for keys one or two edits from a known prop. */\nfunction suggest(keys, known) {\n\tconst hints = keys.flatMap((key) => {\n\t\tlet best;\n\t\tlet bestD = 3;\n\t\tfor (const k of known) {\n\t\t\tconst d = editDistance(key.toLowerCase(), k.toLowerCase());\n\t\t\tif (d < bestD) [best, bestD] = [k, d];\n\t\t}\n\t\treturn best ? [`\"${key}\" → \"${best}\"`] : [];\n\t});\n\treturn hints.length > 0 ? ` (did you mean ${hints.join(\", \")}?)` : \"\";\n}\nfunction editDistance(a, b) {\n\tlet prev = Array.from({ length: b.length + 1 }, (_, j) => j);\n\tfor (let i = 1; i <= a.length; i++) {\n\t\tconst row = [i];\n\t\tfor (let j = 1; j <= b.length; j++) row[j] = Math.min(prev[j] + 1, row[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));\n\t\tprev = row;\n\t}\n\treturn prev[b.length];\n}\nfunction assemble(host, definition, props) {\n\tconst theme = defineTheme(props.theme ?? {});\n\tconst fps = props.fps ?? 30;\n\tconst seed = props.seed ?? 1;\n\tconst id = props.id ?? host.autoId(kebab(definition.name));\n\tconst defaults = definition.defaults ?? {};\n\tconst hold = props.hold ?? defaults.hold ?? 0;\n\tconst ctx = {\n\t\thost,\n\t\ttheme,\n\t\tfps,\n\t\tseed,\n\t\tid,\n\t\tpartId: (part) => `${id}-${part}`,\n\t\trng: (key) => hashRng(seed, key),\n\t\trequested: {\n\t\t\twidth: props.width,\n\t\t\theight: props.height,\n\t\t\tduration: props.duration,\n\t\t\tat: props.at ?? 0\n\t\t},\n\t\thold,\n\t\tcanvas: props.canvas ?? {\n\t\t\twidth: 1920 * theme.scale,\n\t\t\theight: 1080 * theme.scale\n\t\t}\n\t};\n\tconst built = definition.build(ctx, props);\n\tconst enter = resolveMotion(props.enter === void 0 ? defaults.enter : props.enter, \"enter\", theme, fps);\n\tconst exit = resolveMotion(props.exit === void 0 ? defaults.exit : props.exit, \"exit\", theme, fps);\n\tconst openEnded = built.duration === null || built.openEnded === true && !exit && !built.afterHold;\n\tconst duration = props.duration ?? (openEnded || built.duration === null ? null : Math.max(1, built.duration + hold + (built.afterHold ?? 0) + (exit ? exit.duration + exit.delay : 0)));\n\tif (duration === null && exit) throw new Error(`${definition.name}: an exit needs a known end. Give \\`duration\\`, or drop \\`exit\\`.`);\n\tconst width = props.width ?? built.width;\n\tconst height = props.height ?? built.height;\n\tconst blur = Math.max(enter?.blur ?? 0, exit?.blur ?? 0);\n\tconst masked = enter?.preset.startsWith(\"mask-\") || exit?.preset.startsWith(\"mask-\");\n\tconst stage = host.box({\n\t\tid: ctx.partId(\"stage\"),\n\t\tposition: \"absolute\",\n\t\tx: 0,\n\t\ty: 0,\n\t\twidth,\n\t\theight,\n\t\toverflow: \"visible\",\n\t\t...blur > 0 && { motionBlurShutter: blur },\n\t\tchildren: built.children\n\t});\n\tconst size = {\n\t\twidth,\n\t\theight\n\t};\n\tif (enter) stage.animate(enterAnimation(enter, 0, size));\n\tif (exit && duration !== null) stage.animate(exitAnimation(exit, duration, size));\n\tconst origin = props.x === void 0 && props.y === void 0 && !props.position ? built.origin : void 0;\n\tconst absolute = props.x !== void 0 || props.y !== void 0 || origin !== void 0;\n\tconst rootX = props.x ?? origin?.[0] ?? 0;\n\tconst rootY = props.y ?? origin?.[1] ?? 0;\n\tconst root = host.box({\n\t\tid,\n\t\t...absolute ? {\n\t\t\tposition: \"absolute\",\n\t\t\tx: rootX,\n\t\t\ty: rootY\n\t\t} : props.position ? { position: props.position } : {},\n\t\twidth,\n\t\theight,\n\t\toverflow: masked ? \"hidden\" : \"visible\",\n\t\tstartFrame: props.at ?? 0,\n\t\t...duration !== null && { durationFrames: duration },\n\t\tchildren: [stage]\n\t});\n\tconst parts = {\n\t\t...built.parts,\n\t\troot,\n\t\tstage\n\t};\n\tprops.customize?.(parts);\n\tholdFirstKeys(root);\n\tconst start = props.at ?? 0;\n\tconst cues = offsetCues(built.cues, start);\n\tObject.defineProperties(root, {\n\t\tcues: {\n\t\t\tvalue: cues,\n\t\t\tenumerable: false\n\t\t},\n\t\tspan: {\n\t\t\tvalue: {\n\t\t\t\tstart,\n\t\t\t\tend: duration === null ? Number.POSITIVE_INFINITY : start + duration,\n\t\t\t\tduration: duration ?? Number.POSITIVE_INFINITY\n\t\t\t},\n\t\t\tenumerable: false\n\t\t},\n\t\tpart: {\n\t\t\tvalue: (name) => parts[name],\n\t\t\tenumerable: false\n\t\t},\n\t\tpartNames: {\n\t\t\tvalue: Object.keys(parts),\n\t\t\tenumerable: false\n\t\t}\n\t});\n\tif (built.api) {\n\t\tconst api = built.api({\n\t\t\tx: absolute ? rootX : 0,\n\t\t\ty: absolute ? rootY : 0,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tabsolute,\n\t\t\tstart\n\t\t});\n\t\tfor (const [key, value] of Object.entries(api)) Object.defineProperty(root, key, {\n\t\t\tvalue,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\treturn root;\n}\n/**\n* Before a track's first keyframe the renderer shows the node's base value,\n* not the first key's. Components always mean \"hold the first key\" (a\n* bubble invisible until it lands, a stroke undrawn until it starts), so\n* every track in the tree gets its first value pinned at frame 0.\n*/\nfunction holdFirstKeys(node) {\n\tconst n = node;\n\tfor (const track of n.animation?.tracks ?? []) {\n\t\tconst first = track.keyframes?.[0];\n\t\tif (!first || first.frame <= 0 || track.repeat) continue;\n\t\ttrack.keyframes?.unshift({\n\t\t\tid: `${first.id}-hold`,\n\t\t\tframe: 0,\n\t\t\tvalue: first.value\n\t\t});\n\t}\n\tfor (const child of n.children ?? []) holdFirstKeys(child);\n\tif (n.matte?.node) holdFirstKeys(n.matte.node);\n}\n\n//#endregion\n//#region src/core/path.ts\nconst dist = (a, b) => Math.hypot(b[0] - a[0], b[1] - a[1]);\nconst lerp2 = (a, b, t) => [a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t];\n/**\n* Centripetal Catmull-Rom through `points`, flattened to a polyline with\n* `steps` samples per segment. Centripetal (alpha 0.5) never loops or cusps\n* between close points, which matters for pointer paths.\n*/\nfunction catmullRom(points, steps = 16) {\n\tif (points.length < 2) return points.map((p) => [p[0], p[1]]);\n\tconst out = [[points[0][0], points[0][1]]];\n\tfor (let i = 0; i < points.length - 1; i++) {\n\t\tconst p0 = points[Math.max(0, i - 1)];\n\t\tconst p1 = points[i];\n\t\tconst p2 = points[i + 1];\n\t\tconst p3 = points[Math.min(points.length - 1, i + 2)];\n\t\tfor (let s = 1; s <= steps; s++) out.push(catmullRomPoint(p0, p1, p2, p3, s / steps));\n\t}\n\treturn out;\n}\nfunction catmullRomPoint(p0, p1, p2, p3, t) {\n\tconst knot = (a, b) => Math.max(1e-6, Math.sqrt(dist(a, b)));\n\tconst t0 = 0;\n\tconst t1 = t0 + knot(p0, p1);\n\tconst t2 = t1 + knot(p1, p2);\n\tconst t3 = t2 + knot(p2, p3);\n\tconst u = t1 + (t2 - t1) * t;\n\tconst mix$1 = (a, b, ta, tb) => tb === ta ? a : lerp2(a, b, (u - ta) / (tb - ta));\n\tconst a1 = mix$1(p0, p1, t0, t1);\n\tconst a2 = mix$1(p1, p2, t1, t2);\n\tconst a3 = mix$1(p2, p3, t2, t3);\n\treturn mix$1(mix$1(a1, a2, t0, t2), mix$1(a2, a3, t1, t3), t1, t2);\n}\nfunction arcPath(points) {\n\tif (points.length === 0) throw new Error(\"arcPath: no points\");\n\tconst cumulative = [0];\n\tfor (let i = 1; i < points.length; i++) cumulative.push(cumulative[i - 1] + dist(points[i - 1], points[i]));\n\tconst length = cumulative[cumulative.length - 1];\n\tconst segmentAt = (u) => {\n\t\tif (points.length === 1 || length === 0) return [0, 0];\n\t\tconst d = Math.min(1, Math.max(0, u)) * length;\n\t\tlet lo = 0;\n\t\tlet hi = cumulative.length - 1;\n\t\twhile (hi - lo > 1) {\n\t\t\tconst mid = lo + hi >> 1;\n\t\t\tif (cumulative[mid] <= d) lo = mid;\n\t\t\telse hi = mid;\n\t\t}\n\t\tconst seg = cumulative[hi] - cumulative[lo];\n\t\treturn [lo, seg > 0 ? (d - cumulative[lo]) / seg : 0];\n\t};\n\treturn {\n\t\tpoints,\n\t\tlength,\n\t\tat(u) {\n\t\t\tconst [i, t] = segmentAt(u);\n\t\t\tif (points.length === 1) return [points[0][0], points[0][1]];\n\t\t\treturn lerp2(points[i], points[Math.min(i + 1, points.length - 1)], t);\n\t\t},\n\t\tangleAt(u) {\n\t\t\tconst [i] = segmentAt(u);\n\t\t\tconst a = points[Math.min(i, points.length - 2)] ?? points[0];\n\t\t\tconst b = points[Math.min(i + 1, points.length - 1)];\n\t\t\treturn Math.atan2(b[1] - a[1], b[0] - a[0]);\n\t\t}\n\t};\n}\n/** SVG path data for a polyline (optionally closed). Rounded to 0.01 px. */\nfunction toPathData(points, closed = false) {\n\tif (points.length === 0) return \"\";\n\tconst r = (n) => Math.round(n * 100) / 100;\n\tconst [first, ...rest] = points;\n\tconst parts = [`M${r(first[0])} ${r(first[1])}`];\n\tfor (const p of rest) parts.push(`L${r(p[0])} ${r(p[1])}`);\n\tif (closed) parts.push(\"Z\");\n\treturn parts.join(\" \");\n}\n/**\n* Scale and offset SVG path data: `x' = x × scale + dx`. Absolute commands\n* move by the offset; relative ones (and arc radii) only scale. Used to\n* size glyphs designed on a small grid, and logo marks in their viewBox.\n*/\nfunction transformPathData(d, scale, dx = 0, dy = 0) {\n\tconst r = (n) => Math.round(n * 1e3) / 1e3;\n\tconst tokens = d.match(/[a-zA-Z]|[-+]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[-+]?\\d+)?/gi) ?? [];\n\tconst out = [];\n\tlet command = \"\";\n\tlet axis = 0;\n\tfor (const token of tokens) {\n\t\tif (/^[a-zA-Z]$/.test(token)) {\n\t\t\tcommand = token;\n\t\t\taxis = 0;\n\t\t\tout.push(command);\n\t\t\tcontinue;\n\t\t}\n\t\tconst n = Number(token);\n\t\tconst upper = command.toUpperCase();\n\t\tconst relative = command !== upper;\n\t\tif (upper === \"A\") {\n\t\t\tconst k = axis % 7;\n\t\t\taxis++;\n\t\t\tif (k === 2 || k === 3 || k === 4) out.push(String(n));\n\t\t\telse if (k < 2 || relative) out.push(String(r(n * scale)));\n\t\t\telse out.push(String(r(n * scale + (k === 5 ? dx : dy))));\n\t\t\tcontinue;\n\t\t}\n\t\tif (relative) out.push(String(r(n * scale)));\n\t\telse if (upper === \"H\") out.push(String(r(n * scale + dx)));\n\t\telse if (upper === \"V\") out.push(String(r(n * scale + dy)));\n\t\telse {\n\t\t\tout.push(String(r(n * scale + (axis % 2 === 0 ? dx : dy))));\n\t\t\taxis++;\n\t\t}\n\t}\n\treturn out.join(\" \").replace(/ ?([a-zA-Z]) ?/g, \"$1\");\n}\n\n//#endregion\n//#region src/core/draw.ts\n/** Keys for `trimEnd` 0 → 1 between `start` and `start + duration`. */\nfunction drawOnKeys(start, duration, ease$1 = \"power2.inOut\") {\n\treturn [[start, 0], [\n\t\tstart + Math.max(1, duration),\n\t\t1,\n\t\tease$1\n\t]];\n}\n/**\n* Perturb points with seeded, low-frequency noise: neighbouring points move\n* together, so lines bend instead of jittering.\n*/\nfunction wobblePoints(points, { wobble = 0, seed = 1 } = {}, variant = 0) {\n\tif (wobble <= 0 || points.length === 0) return points.map((p) => [p[0], p[1]]);\n\tconst r = hashRng(seed, `wobble:${variant}`);\n\tconst controls = Math.max(2, Math.min(8, Math.ceil(points.length / 6)));\n\tconst ox = Array.from({ length: controls }, () => r.spread(wobble));\n\tconst oy = Array.from({ length: controls }, () => r.spread(wobble));\n\tconst sample = (arr, t) => {\n\t\tconst f = t * (arr.length - 1);\n\t\tconst i = Math.min(arr.length - 2, Math.floor(f));\n\t\tconst k = f - i;\n\t\tconst s = k * k * (3 - 2 * k);\n\t\treturn arr[i] * (1 - s) + arr[i + 1] * s;\n\t};\n\treturn points.map((p, i) => {\n\t\tconst t = points.length === 1 ? 0 : i / (points.length - 1);\n\t\treturn [p[0] + sample(ox, t), p[1] + sample(oy, t)];\n\t});\n}\n/** An ellipse around `rect` (+ padding); hand-drawn ellipses overshoot their start. */\nfunction ellipsePath(rect, { padding = 0, wobble = 0, seed = 1 } = {}, variant = 0) {\n\tconst cx = rect.x + rect.width / 2;\n\tconst cy = rect.y + rect.height / 2;\n\tconst rx = rect.width / 2 + padding;\n\tconst ry = rect.height / 2 + padding;\n\tconst r = hashRng(seed, `ellipse:${variant}`);\n\tconst start = wobble > 0 ? -Math.PI * .6 + r.spread(.3) : 0;\n\tconst sweep = wobble > 0 ? Math.PI * 2 * 1.08 : Math.PI * 2;\n\tconst steps = 64;\n\tconst points = [];\n\tfor (let i = 0; i <= steps; i++) {\n\t\tconst a = start + sweep * i / steps;\n\t\tconst grow = wobble > 0 ? 1 + (i / steps - .5) * .06 : 1;\n\t\tpoints.push([cx + Math.cos(a) * rx * grow, cy + Math.sin(a) * ry * grow]);\n\t}\n\treturn toPathData(wobblePoints(points, {\n\t\twobble,\n\t\tseed\n\t}, variant), wobble <= 0);\n}\n/** A rectangle around `rect` (+ padding). */\nfunction boxPath(rect, { padding = 0, wobble = 0, seed = 1 } = {}, variant = 0) {\n\tconst x0 = rect.x - padding;\n\tconst y0 = rect.y - padding;\n\tconst x1 = rect.x + rect.width + padding;\n\tconst y1 = rect.y + rect.height + padding;\n\tconst corners = [\n\t\t[x0, y0],\n\t\t[x1, y0],\n\t\t[x1, y1],\n\t\t[x0, y1],\n\t\t[x0, y0]\n\t];\n\tif (wobble <= 0) return toPathData(corners.slice(0, 4), true);\n\tconst w = x1 - x0;\n\tconst points = [[x0 + w * .06, y0]];\n\tfor (let i = 0; i < 4; i++) {\n\t\tconst a = corners[i];\n\t\tconst b = corners[i + 1];\n\t\tfor (let s = 1; s <= 8; s++) {\n\t\t\tconst t = s / 8;\n\t\t\tif (i === 0 && a[0] + (b[0] - a[0]) * t < x0 + w * .06) continue;\n\t\t\tpoints.push([a[0] + (b[0] - a[0]) * t, a[1] + (b[1] - a[1]) * t]);\n\t\t}\n\t}\n\tpoints.push([x0 + w * .14, y0 + (y1 - y0) * .01]);\n\treturn toPathData(wobblePoints(points, {\n\t\twobble,\n\t\tseed\n\t}, variant));\n}\n/** A horizontal stroke from `from` to `to`. */\nfunction linePath(from, to, { wobble = 0, seed = 1 } = {}, variant = 0) {\n\tconst steps = wobble > 0 ? 16 : 1;\n\tconst points = [];\n\tfor (let i = 0; i <= steps; i++) {\n\t\tconst t = i / steps;\n\t\tpoints.push([from[0] + (to[0] - from[0]) * t, from[1] + (to[1] - from[1]) * t]);\n\t}\n\treturn toPathData(wobblePoints(points, {\n\t\twobble,\n\t\tseed\n\t}, variant));\n}\n/** A wavy line from `from` to `to`, `waves` crests of `amplitude` px. */\nfunction squigglePath(from, to, { amplitude = 6, waves, wobble = 0, seed = 1 } = {}, variant = 0) {\n\tconst length = Math.hypot(to[0] - from[0], to[1] - from[1]);\n\tconst n = waves ?? Math.max(2, Math.round(length / 28));\n\tconst angle = Math.atan2(to[1] - from[1], to[0] - from[0]);\n\tconst nx = -Math.sin(angle);\n\tconst ny = Math.cos(angle);\n\tconst steps = n * 8;\n\tconst points = [];\n\tfor (let i = 0; i <= steps; i++) {\n\t\tconst t = i / steps;\n\t\tconst off = Math.sin(t * n * Math.PI * 2) * amplitude;\n\t\tpoints.push([from[0] + (to[0] - from[0]) * t + nx * off, from[1] + (to[1] - from[1]) * t + ny * off]);\n\t}\n\treturn toPathData(wobblePoints(points, {\n\t\twobble,\n\t\tseed\n\t}, variant));\n}\n/** An arrow from `from` to `to` with a separate head path. */\nfunction arrowPaths(from, to, { curve = \"arc\", headSize = 18, wobble = 0, seed = 1 } = {}, variant = 0) {\n\tconst dx = to[0] - from[0];\n\tconst dy = to[1] - from[1];\n\tconst length = Math.hypot(dx, dy) || 1;\n\tconst nx = -dy / length;\n\tconst ny = dx / length;\n\tconst bend = curve === \"straight\" ? 0 : curve === \"arc\" ? .18 : .35;\n\tconst controls = curve === \"swoop\" ? [\n\t\tfrom,\n\t\t[from[0] + dx * .3 + nx * length * bend, from[1] + dy * .3 + ny * length * bend],\n\t\t[from[0] + dx * .75 - nx * length * bend * .4, from[1] + dy * .75 - ny * length * bend * .4],\n\t\tto\n\t] : [\n\t\tfrom,\n\t\t[from[0] + dx * .5 + nx * length * bend, from[1] + dy * .5 + ny * length * bend],\n\t\tto\n\t];\n\tconst wobbled = wobblePoints(bend === 0 ? [from, to] : catmullRom(controls, 12), {\n\t\twobble,\n\t\tseed\n\t}, variant);\n\tconst tail = wobbled[wobbled.length - 2] ?? from;\n\tconst angle = Math.atan2(to[1] - tail[1], to[0] - tail[0]);\n\tconst wing = (side) => [to[0] - Math.cos(angle + side * .5) * headSize, to[1] - Math.sin(angle + side * .5) * headSize];\n\tconst left = wing(1);\n\tconst right = wing(-1);\n\treturn {\n\t\tshaft: toPathData(wobbled),\n\t\thead: `${toPathData([left, to])} ${toPathData([to, right]).replace(/^M/, \"L\")}`\n\t};\n}\n/**\n* Hand-drawn \"boil\": `d` keys that switch between `variants` poses every\n* `every` frames with hold interpolation, from `start` to `end`.\n* `makePath(variant)` must be deterministic for a variant index.\n*/\nfunction boilKeys(makePath, { start, end, every, variants = 3 }) {\n\tconst poses = Array.from({ length: Math.max(1, variants) }, (_, i$1) => makePath(i$1));\n\tif (every <= 0 || poses.length === 1) return [[start, poses[0]]];\n\tconst keys = [];\n\tlet i = 0;\n\tfor (let f = start; f <= end; f += every) {\n\t\tkeys.push([\n\t\t\tf,\n\t\t\tposes[i % poses.length],\n\t\t\t\"hold\"\n\t\t]);\n\t\ti++;\n\t}\n\treturn keys;\n}\n\n//#endregion\n//#region src/core/schemas.ts\n/**\n* Shared prop schemas. Built on first use, never at import: a schema built at\n* module load is a side effect bundlers must keep, which would ship every\n* component to anyone importing one.\n*/\nlet target;\n/** Any `Target`: [x, y], a rect, { node }, { text }, { track }, or (frame) => point. */\nfunction targetSchema() {\n\ttarget ??= z.custom((v) => v !== null && v !== void 0 && (Array.isArray(v) || typeof v === \"object\" || typeof v === \"function\"), { message: \"Expected a target: [x, y], a rect, { node }, { text }, { track } or (frame) => point\" });\n\treturn target;\n}\n\n//#endregion\n//#region src/core/text.ts\n/** Whitespace-separated words with their character ranges. */\nfunction wordRanges(text) {\n\tconst out = [];\n\tfor (const m of text.matchAll(/\\S+/g)) {\n\t\tconst start = m.index ?? 0;\n\t\tout.push({\n\t\t\ttext: m[0],\n\t\t\tstart,\n\t\t\tend: start + m[0].length,\n\t\t\tindex: out.length\n\t\t});\n\t}\n\treturn out;\n}\n/** Character range of the `nth` match of `match` in `text`, or null. */\nfunction findRange(text, match, nth = 0) {\n\tif (typeof match === \"string\") {\n\t\tlet from = 0;\n\t\tfor (let i$1 = 0;; i$1++) {\n\t\t\tconst at = text.indexOf(match, from);\n\t\t\tif (at < 0) return null;\n\t\t\tif (i$1 === nth) return [at, at + match.length];\n\t\t\tfrom = at + Math.max(1, match.length);\n\t\t}\n\t}\n\tconst flags = match.flags.includes(\"g\") ? match.flags : `${match.flags}g`;\n\tlet i = 0;\n\tfor (const m of text.matchAll(new RegExp(match.source, flags))) {\n\t\tif (i === nth) return [m.index ?? 0, (m.index ?? 0) + m[0].length];\n\t\ti++;\n\t}\n\treturn null;\n}\n/**\n* Per-line x offset that `align` adds inside a box of `options.width`\n* (measurement itself lays every line out from the left edge).\n*/\nfunction lineShift(metrics, line, options) {\n\tif (!options.width || !options.align || options.align === \"left\") return 0;\n\tlet min = Number.POSITIVE_INFINITY;\n\tlet max = Number.NEGATIVE_INFINITY;\n\tfor (const g of metrics.glyphs) {\n\t\tif (g.line !== line || g.char.trim() === \"\") continue;\n\t\tmin = Math.min(min, g.x);\n\t\tmax = Math.max(max, g.x + g.width);\n\t}\n\tif (!Number.isFinite(min)) return 0;\n\tconst free = options.width - (max - min);\n\treturn (options.align === \"center\" ? free / 2 : free) - min;\n}\n/**\n* The boxes characters [start, end) cover: one rect per line, spanning the\n* glyphs' advances, `lineHeight` tall. Whitespace at a line's ends is\n* excluded.\n*/\nfunction rangeRects(metrics, start, end, options) {\n\tconst byLine = /* @__PURE__ */ new Map();\n\tfor (const g of metrics.glyphs) {\n\t\tif (g.index < start || g.index >= end || g.char.trim() === \"\") continue;\n\t\tconst box = byLine.get(g.line) ?? {\n\t\t\tmin: Number.POSITIVE_INFINITY,\n\t\t\tmax: Number.NEGATIVE_INFINITY\n\t\t};\n\t\tbox.min = Math.min(box.min, g.x);\n\t\tbox.max = Math.max(box.max, g.x + g.width - (options.letterSpacing ?? 0));\n\t\tbyLine.set(g.line, box);\n\t}\n\treturn [...byLine.entries()].sort(([a], [b]) => a - b).map(([line, box]) => {\n\t\tconst shift = lineShift(metrics, line, options);\n\t\treturn {\n\t\t\tx: box.min + shift,\n\t\t\ty: line * metrics.lineHeight,\n\t\t\twidth: box.max - box.min,\n\t\t\theight: metrics.lineHeight\n\t\t};\n\t});\n}\n\n//#endregion\n//#region src/core/targets.ts\nconst isVec2 = (t) => Array.isArray(t) && t.length === 2 && t.every((n) => typeof n === \"number\");\nconst isRect = (t) => typeof t === \"object\" && t !== null && [\n\t\"x\",\n\t\"y\",\n\t\"width\",\n\t\"height\"\n].every((k) => typeof t[k] === \"number\");\nconst num$1 = (v) => typeof v === \"number\" && Number.isFinite(v) ? v : void 0;\nfunction frameValue(v, frame, fps) {\n\tif (typeof v === \"function\") return v(frame);\n\tif (v && typeof v.get === \"function\") {\n\t\tconst time = frame / fps;\n\t\treturn v.get({\n\t\t\tframe,\n\t\t\tfps,\n\t\t\ttime,\n\t\t\tduration: 0,\n\t\t\tdurationMs: 0,\n\t\t\tprogress: 0,\n\t\t\tdeltaTime: 1 / fps\n\t\t});\n\t}\n\tthrow new Error(\"Tracked target values must be signals or (frame) => number.\");\n}\n/** Resolve a target to rects (static) or a per-frame rect (dynamic). */\nfunction resolveTarget(target$1, ctx = {}) {\n\tif (typeof target$1 === \"function\") return {\n\t\tkind: \"dynamic\",\n\t\tanchor: \"center\",\n\t\tat: (frame) => {\n\t\t\tconst v = target$1(frame);\n\t\t\treturn isVec2(v) ? {\n\t\t\t\tx: v[0],\n\t\t\t\ty: v[1],\n\t\t\t\twidth: 0,\n\t\t\t\theight: 0\n\t\t\t} : v;\n\t\t}\n\t};\n\tif (isVec2(target$1)) return {\n\t\tkind: \"static\",\n\t\tanchor: \"center\",\n\t\trects: [{\n\t\t\tx: target$1[0],\n\t\t\ty: target$1[1],\n\t\t\twidth: 0,\n\t\t\theight: 0\n\t\t}]\n\t};\n\tif (isRect(target$1)) return {\n\t\tkind: \"static\",\n\t\tanchor: \"center\",\n\t\trects: [target$1]\n\t};\n\tif (\"track\" in target$1) {\n\t\tconst t = target$1.track;\n\t\tconst fps = ctx.fps ?? 30;\n\t\treturn {\n\t\t\tkind: \"dynamic\",\n\t\t\tanchor: target$1.anchor ?? \"center\",\n\t\t\tat: (frame) => ({\n\t\t\t\tx: frameValue(t.x, frame, fps),\n\t\t\t\ty: frameValue(t.y, frame, fps),\n\t\t\t\twidth: frameValue(t.width, frame, fps),\n\t\t\t\theight: frameValue(t.height, frame, fps)\n\t\t\t})\n\t\t};\n\t}\n\tif (\"text\" in target$1) return {\n\t\tkind: \"static\",\n\t\tanchor: target$1.anchor ?? \"tip\",\n\t\trects: textRects(target$1, ctx)\n\t};\n\tconst node = target$1.node;\n\tconst rect = nodeRect(node);\n\tif (!rect) throw new Error(`Target node \"${node.id ?? \"?\"}\" has no absolute geometry. Give it numeric x, y, width and height, or target a rect.`);\n\treturn {\n\t\tkind: \"static\",\n\t\tanchor: target$1.anchor ?? \"center\",\n\t\trects: [rect]\n\t};\n}\nfunction nodeRect(node) {\n\tconst x = num$1(node.x);\n\tconst y = num$1(node.y);\n\tconst width = num$1(node.width);\n\tconst height = num$1(node.height);\n\tif (x === void 0 || y === void 0 || width === void 0 || height === void 0) return null;\n\treturn {\n\t\tx,\n\t\ty,\n\t\twidth,\n\t\theight\n\t};\n}\n/** Measure a text target the way the renderer lays it out. */\nfunction textLayout(target$1, ctx) {\n\tconst node = target$1.text;\n\tconst content = typeof node.text === \"string\" ? node.text : typeof node.content === \"string\" ? node.content : null;\n\tif (content === null) throw new Error(\"Text target node has no string content.\");\n\tconst x = num$1(node.x);\n\tconst y = num$1(node.y);\n\tif (x === void 0 || y === void 0) throw new Error(`Text target \"${node.id ?? \"?\"}\" needs numeric x and y so its glyphs can be placed.`);\n\tif (!ctx.measure) throw new Error(\"Text targets need a measure function.\");\n\tconst fontFamily = node.fontFamily ?? ctx.textDefaults?.fontFamily;\n\tif (!fontFamily) throw new Error(\"Text target has no fontFamily.\");\n\tconst options = {\n\t\t...ctx.textDefaults,\n\t\tfontFamily,\n\t\tfontSize: num$1(node.fontSize) ?? ctx.textDefaults?.fontSize,\n\t\tfontWeight: node.fontWeight ?? ctx.textDefaults?.fontWeight,\n\t\tletterSpacing: num$1(node.letterSpacing) ?? ctx.textDefaults?.letterSpacing,\n\t\tlineHeight: num$1(node.lineHeight) ?? ctx.textDefaults?.lineHeight,\n\t\twidth: num$1(node.width),\n\t\talign: alignOf(node.align),\n\t\tdirection: node.direction\n\t};\n\tconst range = target$1.range ?? (target$1.match !== void 0 ? findRange(content, target$1.match, target$1.nth ?? 0) : [0, content.length]);\n\tif (!range) throw new Error(`Text target: \"${String(target$1.match)}\" not found in \"${content}\".`);\n\treturn {\n\t\tcontent,\n\t\tmetrics: ctx.measure(content, options),\n\t\toptions,\n\t\trange: [range[0], range[1]],\n\t\tx,\n\t\ty\n\t};\n}\nfunction textRects(target$1, ctx) {\n\tconst t = textLayout(target$1, ctx);\n\tconst rects = rangeRects(t.metrics, t.range[0], t.range[1], t.options);\n\tif (rects.length === 0) throw new Error(\"Text target range covers no glyphs.\");\n\treturn rects.map((r) => ({\n\t\t...r,\n\t\tx: r.x + t.x,\n\t\ty: r.y + t.y\n\t}));\n}\n/** Text node alignment (start / center / end, or left / right) as measure reads it. */\nfunction alignOf(align) {\n\tif (align === \"center\") return \"center\";\n\tif (align === \"end\" || align === \"right\") return \"right\";\n\treturn \"left\";\n}\n/** The union rect of `rects`. */\nfunction boundsOf(rects) {\n\tif (rects.length === 0) return {\n\t\tx: 0,\n\t\ty: 0,\n\t\twidth: 0,\n\t\theight: 0\n\t};\n\tlet x0 = Number.POSITIVE_INFINITY;\n\tlet y0 = Number.POSITIVE_INFINITY;\n\tlet x1 = Number.NEGATIVE_INFINITY;\n\tlet y1 = Number.NEGATIVE_INFINITY;\n\tfor (const r of rects) {\n\t\tx0 = Math.min(x0, r.x);\n\t\ty0 = Math.min(y0, r.y);\n\t\tx1 = Math.max(x1, r.x + r.width);\n\t\ty1 = Math.max(y1, r.y + r.height);\n\t}\n\treturn {\n\t\tx: x0,\n\t\ty: y0,\n\t\twidth: x1 - x0,\n\t\theight: y1 - y0\n\t};\n}\n/** The point of `rect` named by `anchor`. `tip` on text = start of the first line, mid-height. */\nfunction anchorPoint(rect, anchor = \"center\", isText = false) {\n\tconst { x, y, width: w, height: h } = rect;\n\tswitch (anchor) {\n\t\tcase \"tip\": return isText ? [x, y + h / 2] : [x + w / 2, y + h / 2];\n\t\tcase \"center\": return [x + w / 2, y + h / 2];\n\t\tcase \"top\": return [x + w / 2, y];\n\t\tcase \"bottom\": return [x + w / 2, y + h];\n\t\tcase \"left\": return [x, y + h / 2];\n\t\tcase \"right\": return [x + w, y + h / 2];\n\t\tcase \"top-left\": return [x, y];\n\t\tcase \"top-right\": return [x + w, y];\n\t\tcase \"bottom-left\": return [x, y + h];\n\t\tcase \"bottom-right\": return [x + w, y + h];\n\t}\n}\n/** The point a resolved target names at `frame` (static targets ignore frame). */\nfunction targetPoint(resolved, frame = 0, isText = false) {\n\tif (resolved.kind === \"dynamic\") return anchorPoint(resolved.at(frame), resolved.anchor, isText);\n\tconst first = resolved.rects[0];\n\treturn anchorPoint(resolved.anchor === \"tip\" ? first : boundsOf(resolved.rects), resolved.anchor, isText);\n}\n\n//#endregion\n//#region src/core/ease.ts\nconst clamp01$1 = (t) => t < 0 ? 0 : t > 1 ? 1 : t;\n/** The \"in\" form of each base curve; `out` and `inOut` derive from it. */\nconst BASES = {\n\tnone: () => (x) => x,\n\tlinear: () => (x) => x,\n\tpower1: () => (x) => x * x,\n\tpower2: () => (x) => x * x * x,\n\tcubic: () => (x) => x * x * x,\n\tpower3: () => (x) => x ** 4,\n\tsine: () => (x) => 1 - Math.cos(x * Math.PI / 2),\n\tcirc: () => (x) => 1 - Math.sqrt(Math.max(0, 1 - x * x)),\n\texpo: () => (x) => x === 0 ? 0 : 2 ** (10 * (x - 1)),\n\tback: ([overshoot = 1.70158]) => (x) => (overshoot + 1) * x * x * x - overshoot * x * x,\n\telastic: ([amplitude = 1, period = .3]) => {\n\t\tconst a = Math.max(1, amplitude);\n\t\tconst s = period / (2 * Math.PI) * Math.asin(1 / a);\n\t\treturn (x) => x === 0 || x === 1 ? x : -(a * 2 ** (10 * (x - 1)) * Math.sin((x - 1 - s) * (2 * Math.PI) / period));\n\t},\n\tbounce: () => (x) => 1 - bounceOut(1 - x)\n};\nfunction bounceOut(x) {\n\tconst n1 = 7.5625;\n\tconst d1 = 2.75;\n\tif (x < 1 / d1) return n1 * x * x;\n\tif (x < 2 / d1) return n1 * (x - 1.5 / d1) ** 2 + .75;\n\tif (x < 2.5 / d1) return n1 * (x - 2.25 / d1) ** 2 + .9375;\n\treturn n1 * (x - 2.625 / d1) ** 2 + .984375;\n}\nconst cache = /* @__PURE__ */ new Map();\n/** Parse an ease name into a function on [0, 1]. Unknown names throw. */\nfunction ease(name) {\n\tif (!name) return (t) => clamp01$1(t);\n\tconst cached = cache.get(name);\n\tif (cached) return cached;\n\tconst match = name.trim().match(/^([a-zA-Z0-9]+)(?:\\.([a-zA-Z]+))?(?:\\(([^)]*)\\))?$/);\n\tif (!match) throw new Error(`Unknown ease \"${name}\"`);\n\tconst base = (match[1] ?? \"\").toLowerCase();\n\tconst dir = (match[2] ?? \"out\").toLowerCase();\n\tconst params = (match[3] ?? \"\").split(\",\").map((s) => Number.parseFloat(s)).filter((n) => !Number.isNaN(n));\n\tlet fn$1;\n\tif (base === \"hold\") fn$1 = (t) => t >= 1 ? 1 : 0;\n\telse {\n\t\tconst make = BASES[base];\n\t\tif (!make) throw new Error(`Unknown ease \"${name}\"`);\n\t\tconst easeIn = make(params);\n\t\tif (dir === \"in\") fn$1 = (t) => easeIn(clamp01$1(t));\n\t\telse if (dir === \"inout\") fn$1 = (t) => {\n\t\t\tconst s = clamp01$1(t);\n\t\t\treturn s < .5 ? easeIn(s * 2) / 2 : 1 - easeIn((1 - s) * 2) / 2;\n\t\t};\n\t\telse if (dir === \"out\") fn$1 = (t) => 1 - easeIn(1 - clamp01$1(t));\n\t\telse throw new Error(`Unknown ease direction in \"${name}\"`);\n\t}\n\tcache.set(name, fn$1);\n\treturn fn$1;\n}\n/** `ease(name)(t)` in one call. */\nfunction evaluateEase(name, t) {\n\treturn ease(name)(t);\n}\n\n//#endregion\n//#region src/core/keys.ts\n/**\n* Keyframe bookkeeping shared by every component: ordering, sampling, and\n* builders that collect keys per node and prop before animating once.\n*/\n/** Round to `places` decimals (default 3): keeps baked keys short and stable. */\nconst round = (v, places = 3) => {\n\tconst k = 10 ** places;\n\treturn Math.round(v * k) / k;\n};\n/** The last element, or `undefined`. */\nconst last = (list$1) => list$1[list$1.length - 1];\n/**\n* Keys in ascending frame order; of several keys on one frame, the one given\n* last wins. Input order is otherwise free.\n*/\nfunction ascending(keys) {\n\tconst byFrame = /* @__PURE__ */ new Map();\n\tfor (const k of keys) byFrame.set(k[0], k);\n\treturn [...byFrame.values()].sort((a, b) => a[0] - b[0]);\n}\n/**\n* Keys written as a timeline where each key supersedes what came before at\n* or after its frame: a key earlier than the previous one drops the later\n* ones (a retarget cancels the planned rest of a move).\n*/\nfunction supersede(keys) {\n\tconst out = [];\n\tfor (const k of keys) {\n\t\twhile (out.length > 0 && last(out)[0] >= k[0]) out.pop();\n\t\tout.push(k);\n\t}\n\treturn out;\n}\n/**\n* A numeric track's value at `frame`, the way the renderer evaluates it:\n* each segment eased by its end key's ease, `hold` stepping on the key.\n*/\nfunction valueAt(keys, frame) {\n\tconst first = keys[0];\n\tif (!first) return 0;\n\tif (frame <= first[0]) return first[1];\n\tfor (let i = 1; i < keys.length; i++) {\n\t\tconst [f0, v0] = keys[i - 1];\n\t\tconst [f1, v1, ease$1] = keys[i];\n\t\tif (frame > f1) continue;\n\t\tif (ease$1 === \"hold\") return frame === f1 ? v1 : v0;\n\t\tconst t = evaluateEase(typeof ease$1 === \"string\" ? ease$1 : void 0, (frame - f0) / Math.max(1, f1 - f0));\n\t\treturn v0 + (v1 - v0) * t;\n\t}\n\treturn last(keys)[1];\n}\n/** A value track built from transitions: each eases from wherever the value is to `to`. */\nvar Track = class {\n\tchanges = [];\n\tconstructor(initial) {\n\t\tthis.initial = initial;\n\t}\n\tto(start, end, value, ease$1 = \"power2.out\") {\n\t\tthis.changes.push({\n\t\t\tstart,\n\t\t\tend: Math.max(start, end),\n\t\t\tto: value,\n\t\t\tease: ease$1\n\t\t});\n\t\treturn this;\n\t}\n\t/** Jump to `value` on `frame` (a hold key). */\n\tset(frame, value) {\n\t\treturn this.to(frame, frame, value);\n\t}\n\t/** Ascending keyframes; a change that starts mid-transition starts from its target. */\n\tkeys() {\n\t\tconst keys = [[0, this.initial]];\n\t\tlet value = this.initial;\n\t\tfor (const c of [...this.changes].sort((x, y) => x.start - y.start)) {\n\t\t\tconst prev = last(keys);\n\t\t\tconst start = Math.max(c.start, prev[0] + (c.end === c.start ? 1 : 0));\n\t\t\tif (start > prev[0]) keys.push([start, value]);\n\t\t\tconst end = Math.max(c.end, start);\n\t\t\tif (end === start) keys[keys.length - 1] = [\n\t\t\t\tstart,\n\t\t\t\tc.to,\n\t\t\t\t\"hold\"\n\t\t\t];\n\t\t\telse keys.push([\n\t\t\t\tend,\n\t\t\t\tc.to,\n\t\t\t\tc.ease\n\t\t\t]);\n\t\t\tvalue = c.to;\n\t\t}\n\t\treturn supersede(keys);\n\t}\n};\n/**\n* Keys collected per node and prop from anywhere in a build, merged into one\n* ascending track each and applied with one `animate()` per node.\n*/\nvar KeyBook = class {\n\tbook = /* @__PURE__ */ new Map();\n\t/** Append keys for `node`'s `prop` (merged with any already given). */\n\tkey(node, prop, keys) {\n\t\tconst byProp = this.book.get(node) ?? /* @__PURE__ */ new Map();\n\t\tthis.book.set(node, byProp);\n\t\tbyProp.set(prop, [...byProp.get(prop) ?? [], ...keys]);\n\t\treturn this;\n\t}\n\t/** Animate every node once with its merged tracks. */\n\tapply() {\n\t\tfor (const [node, byProp] of this.book) {\n\t\t\tconst anim = LayerAnimation.create();\n\t\t\tfor (const [prop, keys] of byProp) anim.keys(prop, ascending(keys));\n\t\t\tnode.animate(anim);\n\t\t}\n\t}\n};\n\n//#endregion\n//#region src/core/bake.ts\n/**\n* Simplify `values` (one per frame, starting at `startFrame`) to linear keys\n* whose interpolation stays within `tolerance` of every sample\n* (Ramer–Douglas–Peucker on the frame/value polyline). First and last\n* samples are always kept.\n*/\nfunction bakeSamples(values, startFrame = 0, options = {}) {\n\tconst tolerance = options.tolerance ?? .25;\n\tif (values.length === 0) return [];\n\tif (values.length === 1) return [[startFrame, values[0]]];\n\tconst keep = new Uint8Array(values.length);\n\tkeep[0] = 1;\n\tkeep[values.length - 1] = 1;\n\tconst stack = [[0, values.length - 1]];\n\twhile (stack.length > 0) {\n\t\tconst [a, b] = stack.pop();\n\t\tconst va = values[a];\n\t\tconst vb = values[b];\n\t\tlet worst = -1;\n\t\tlet worstErr = tolerance;\n\t\tfor (let i = a + 1; i < b; i++) {\n\t\t\tconst t = (i - a) / (b - a);\n\t\t\tconst err = Math.abs(values[i] - (va + (vb - va) * t));\n\t\t\tif (err > worstErr) {\n\t\t\t\tworstErr = err;\n\t\t\t\tworst = i;\n\t\t\t}\n\t\t}\n\t\tif (worst !== -1) {\n\t\t\tkeep[worst] = 1;\n\t\t\tstack.push([a, worst], [worst, b]);\n\t\t}\n\t}\n\tconst out = [];\n\tfor (let i = 0; i < values.length; i++) if (keep[i]) out.push([startFrame + i, values[i]]);\n\treturn out;\n}\n/** Sample `fn` on every frame in [start, end] and bake it. */\nfunction bakeFunction(fn$1, start, end, options) {\n\tconst values = [];\n\tfor (let f = start; f <= end; f++) values.push(fn$1(f));\n\treturn bakeSamples(values, start, options);\n}\n/**\n* Damped spring from 0 to 1 in closed form: `stiffness` (k), `damping` (c),\n* `mass` (m), sampled in seconds. Under-damped springs overshoot.\n*/\nfunction springAt(seconds, { stiffness = 170, damping = 26, mass = 1 } = {}) {\n\tif (seconds <= 0) return 0;\n\tconst w0 = Math.sqrt(stiffness / mass);\n\tconst zeta = damping / (2 * Math.sqrt(stiffness * mass));\n\tif (zeta < 1) {\n\t\tconst wd = w0 * Math.sqrt(1 - zeta * zeta);\n\t\treturn 1 - Math.exp(-zeta * w0 * seconds) * (Math.cos(wd * seconds) + zeta * w0 / wd * Math.sin(wd * seconds));\n\t}\n\tif (zeta === 1) return 1 - Math.exp(-w0 * seconds) * (1 + w0 * seconds);\n\tconst r1 = -w0 * (zeta - Math.sqrt(zeta * zeta - 1));\n\tconst r2 = -w0 * (zeta + Math.sqrt(zeta * zeta - 1));\n\tconst c2 = r1 / (r1 - r2);\n\treturn 1 - ((1 - c2) * Math.exp(r1 * seconds) + c2 * Math.exp(r2 * seconds));\n}\n/**\n* Frames until a spring stays within `epsilon` of rest, at `fps`; capped at\n* `max` frames.\n*/\nfunction springSettleFrames(fps, options, epsilon = .001, max = 600) {\n\tlet last$1 = 0;\n\tfor (let f = 0; f <= max; f++) if (Math.abs(1 - springAt(f / fps, options)) > epsilon) last$1 = f;\n\treturn Math.min(max, last$1 + 1);\n}\n/**\n* A spring from `from` to `to` starting at frame `start`, baked to linear\n* keys (within `tolerance`, default 0.2 % of the distance).\n*/\nfunction springKeys(start, from, to, fps, options, tolerance = Math.max(1e-4, Math.abs(to - from) * .002)) {\n\tconst frames = springSettleFrames(fps, options);\n\treturn bakeSamples(Array.from({ length: frames + 1 }, (_, f) => f === frames ? to : from + (to - from) * springAt(f / fps, options)), start, { tolerance });\n}\n/**\n* Per-frame values (frames 0…`length`) that spring to each new target from\n* wherever they are: a retarget mid-flight starts from the current value\n* (velocity isn't carried over). Bake with `bakeSamples` or bind as a signal.\n*/\nfunction springTrack(changes, initial, length, fps, options = {\n\tstiffness: 230,\n\tdamping: 24\n}) {\n\tconst sorted = [...changes].sort((a, b) => a[0] - b[0]);\n\tconst out = new Array(length + 1);\n\tlet from = initial;\n\tlet to = initial;\n\tlet since = 0;\n\tlet k = 0;\n\tfor (let f = 0; f <= length; f++) {\n\t\twhile (k < sorted.length && sorted[k][0] <= f) {\n\t\t\tfrom = from + (to - from) * springAt((f - since) / fps, options);\n\t\t\tto = sorted[k][1];\n\t\t\tsince = sorted[k][0];\n\t\t\tk++;\n\t\t}\n\t\tout[f] = from + (to - from) * springAt((f - since) / fps, options);\n\t}\n\treturn out;\n}\n\n//#endregion\n//#region src/core/surface.ts\n/** Layer styles for `level`: a drop shadow and, when the theme asks, a top-edge highlight. */\nfunction elevationStyle(theme, level) {\n\tconst e = theme.elevation[level];\n\tconst s = theme.scale;\n\treturn {\n\t\t...e.opacity > 0 && { dropShadow: {\n\t\t\tcolor: theme.color.shadow,\n\t\t\topacity: e.opacity,\n\t\t\tangle: 90,\n\t\t\tdistance: e.distance * s,\n\t\t\tsize: e.size * s\n\t\t} },\n\t\t...e.edge > 0 && { innerShadow: {\n\t\t\tcolor: \"#ffffff\",\n\t\t\topacity: e.edge,\n\t\t\tangle: 270,\n\t\t\tdistance: Math.max(1, s),\n\t\t\tsize: 0,\n\t\t\tblendMode: \"normal\"\n\t\t} }\n\t};\n}\n/** Put `node` at `level` (or leave it flat for `false`); returns it. */\nfunction elevate(host, node, theme, level) {\n\tif (level === false) return node;\n\tconst style = elevationStyle(theme, level);\n\treturn Object.keys(style).length > 0 ? host.style(node, style) : node;\n}\n/**\n* A background for a surface of `color`: a vertical sheen a few percent\n* lighter at the top on dark themes (light themes stay flat, where a\n* lighter top reads as a glare). Non-hex / non-rgb colors pass through.\n*/\nfunction surfaceFill(color, theme, sheen = .05) {\n\tif (theme.mode === \"light\" || sheen <= 0) return color;\n\tconst top = mix(color, \"#ffffff\", sheen);\n\treturn top === color ? color : `linear-gradient(180deg, ${top} 0%, ${color} 100%)`;\n}\n\n//#endregion\n//#region src/core/audio.ts\n/**\n* Audio analysis, offline and deterministic: decoded samples in, plain\n* per-frame data out (`AudioLevels`). Components bind it to props as\n* signals or bake it into glyph tables, so the result seeks exactly and\n* serialises as JSON.\n*/\nconst FFT_SIZE = 2048;\n/** dB below a band's reference that reads as 0. */\nconst BAND_RANGE = 42;\n/** A band's reference never sits more than this under the loudest band's. */\nconst BAND_FLOOR = 30;\nconst LEVEL_RANGE = 48;\n/** References never sit below this (dBFS): silence stays 0, not normalised up. */\nconst SILENCE = -60;\n/** In-place radix-2 FFT over `re` / `im` (length a power of two). */\nfunction fft(re, im) {\n\tconst n = re.length;\n\tfor (let i = 1, j = 0; i < n; i++) {\n\t\tlet bit = n >> 1;\n\t\tfor (; j & bit; bit >>= 1) j ^= bit;\n\t\tj ^= bit;\n\t\tif (i < j) {\n\t\t\t[re[i], re[j]] = [re[j], re[i]];\n\t\t\t[im[i], im[j]] = [im[j], im[i]];\n\t\t}\n\t}\n\tfor (let len = 2; len <= n; len <<= 1) {\n\t\tconst ang = -2 * Math.PI / len;\n\t\tconst wr = Math.cos(ang);\n\t\tconst wi = Math.sin(ang);\n\t\tfor (let i = 0; i < n; i += len) {\n\t\t\tlet cr = 1;\n\t\t\tlet ci = 0;\n\t\t\tfor (let k = 0; k < len / 2; k++) {\n\t\t\t\tconst a = i + k;\n\t\t\t\tconst b = a + len / 2;\n\t\t\t\tconst xr = re[b] * cr - im[b] * ci;\n\t\t\t\tconst xi = re[b] * ci + im[b] * cr;\n\t\t\t\tre[b] = re[a] - xr;\n\t\t\t\tim[b] = im[a] - xi;\n\t\t\t\tre[a] = re[a] + xr;\n\t\t\t\tim[a] = im[a] + xi;\n\t\t\t\tconst t = cr * wr - ci * wi;\n\t\t\t\tci = cr * wi + ci * wr;\n\t\t\t\tcr = t;\n\t\t\t}\n\t\t}\n\t}\n}\nfunction percentile(values, p) {\n\tif (values.length === 0) return 0;\n\tconst sorted = [...values].sort((a, b) => a - b);\n\treturn sorted[Math.min(sorted.length - 1, Math.floor(p * sorted.length))];\n}\nconst db = (v) => 20 * Math.log10(v + 1e-9);\nconst clamp01 = (v) => v < 0 ? 0 : v > 1 ? 1 : v;\n/** Band edges in Hz, log-spaced. */\nfunction bandEdges(count, minHz, maxHz) {\n\treturn Array.from({ length: count + 1 }, (_, i) => minHz * (maxHz / minHz) ** (i / count));\n}\n/**\n* Analyse decoded audio: a Hann-windowed FFT per frame into log-spaced\n* bands, each normalised to its own 98th percentile (floored 30 dB under the\n* loudest band's, so a quiet band is not stretched into noise), an RMS level\n* envelope, and onsets from low-band spectral flux.\n*/\nfunction analyzeChannels(channels, sampleRate, options = {}) {\n\tconst fps = options.fps ?? 30;\n\tconst count = options.bands ?? 32;\n\tconst minHz = options.minHz ?? 50;\n\tconst maxHz = Math.min(options.maxHz ?? 12e3, sampleRate / 2);\n\tconst length = Math.max(0, ...channels.map((c) => c.length));\n\tconst mono = new Float32Array(length);\n\tfor (const c of channels) for (let i = 0; i < c.length; i++) mono[i] = mono[i] + c[i] / channels.length;\n\tconst frames = Math.ceil(length / sampleRate * fps);\n\tconst hop = sampleRate / fps;\n\tconst hann = Float64Array.from({ length: FFT_SIZE }, (_, i) => .5 - .5 * Math.cos(2 * Math.PI * i / (FFT_SIZE - 1)));\n\tconst edges = bandEdges(count, minHz, maxHz);\n\tconst binHz = sampleRate / FFT_SIZE;\n\tconst ranges = edges.slice(0, -1).map((lo, b) => {\n\t\tconst from = Math.max(1, Math.floor(lo / binHz));\n\t\tconst to = Math.max(from + 1, Math.ceil(edges[b + 1] / binHz));\n\t\treturn [from, Math.min(FFT_SIZE / 2, to)];\n\t});\n\tconst lowBands = edges.filter((e) => e < 150).length;\n\tconst raw = Array.from({ length: count }, () => new Array(frames));\n\tconst rms = new Array(frames);\n\tconst flux = new Array(frames).fill(0);\n\tlet previousLow = null;\n\tconst re = new Float64Array(FFT_SIZE);\n\tconst im = new Float64Array(FFT_SIZE);\n\tfor (let f = 0; f < frames; f++) {\n\t\tconst from = Math.round((f + .5) * hop) - FFT_SIZE / 2;\n\t\tfor (let i = 0; i < FFT_SIZE; i++) {\n\t\t\tre[i] = (mono[from + i] ?? 0) * hann[i];\n\t\t\tim[i] = 0;\n\t\t}\n\t\tfft(re, im);\n\t\tconst low = [];\n\t\tranges.forEach(([a, b], band) => {\n\t\t\tlet sum = 0;\n\t\t\tfor (let k = a; k < b; k++) sum += Math.hypot(re[k], im[k]);\n\t\t\tconst mag = sum / (b - a) * (4 / FFT_SIZE);\n\t\t\traw[band][f] = mag;\n\t\t\tif (band < Math.max(1, lowBands)) low.push(mag);\n\t\t});\n\t\tif (previousLow) flux[f] = low.reduce((acc, v, i) => acc + Math.max(0, v - (previousLow[i] ?? 0)), 0);\n\t\tpreviousLow = low;\n\t\tconst s0 = Math.round(f * hop);\n\t\tconst s1 = Math.min(length, Math.round((f + 1) * hop));\n\t\tlet e = 0;\n\t\tfor (let i = s0; i < s1; i++) e += mono[i] ** 2;\n\t\trms[f] = Math.sqrt(e / Math.max(1, s1 - s0));\n\t}\n\tconst refs = raw.map((band) => percentile(band.map(db), .98));\n\tconst loudest = Math.max(...refs);\n\tconst bands = raw.map((band, b) => {\n\t\tconst ref = Math.max(refs[b], loudest - BAND_FLOOR, SILENCE - 20);\n\t\treturn band.map((v) => round(clamp01(1 - (ref - db(v)) / BAND_RANGE)));\n\t});\n\tconst levelRef = Math.max(SILENCE, percentile(rms.map(db), .98));\n\treturn {\n\t\tfps,\n\t\tframes,\n\t\tbands,\n\t\tlevel: rms.map((v) => round(clamp01(1 - (levelRef - db(v)) / LEVEL_RANGE))),\n\t\tbeats: pickOnsets(flux, fps)\n\t};\n}\n/** Local maxima of `flux` well above its neighbourhood, at least 0.15 s apart. */\nfunction pickOnsets(flux, fps) {\n\tconst reach = Math.max(2, Math.round(fps * .5));\n\tconst gap = Math.max(1, Math.round(fps * .15));\n\tconst peak = Math.max(0, ...flux);\n\tconst beats$1 = [];\n\tfor (let f = 1; f < flux.length; f++) {\n\t\tconst v = flux[f];\n\t\tif (v <= peak * .08) continue;\n\t\tif (v < flux[f - 1] || v < (flux[f + 1] ?? 0)) continue;\n\t\tconst near = flux.slice(Math.max(0, f - reach), f + reach + 1);\n\t\tconst mean = near.reduce((a, b) => a + b, 0) / near.length;\n\t\tif (v < mean + 1.5 * Math.sqrt(near.reduce((a, b) => a + (b - mean) ** 2, 0) / near.length)) continue;\n\t\tconst last$1 = beats$1[beats$1.length - 1];\n\t\tif (last$1 !== void 0 && f - last$1 < gap) continue;\n\t\tbeats$1.push(f);\n\t}\n\treturn beats$1;\n}\n/** Average adjacent bands down (or repeat them up) to `count` bands. */\nfunction resampleBands(bands, count) {\n\tconst n = bands.length;\n\tif (n === 0) return [];\n\tconst frames = bands[0]?.length ?? 0;\n\treturn Array.from({ length: count }, (_, i) => {\n\t\tconst a = Math.floor(i * n / count);\n\t\tconst b = Math.max(a + 1, Math.floor((i + 1) * n / count));\n\t\treturn Array.from({ length: frames }, (_$1, f) => {\n\t\t\tlet sum = 0;\n\t\t\tfor (let k = a; k < b; k++) sum += bands[k][f] ?? 0;\n\t\t\treturn round(sum / (b - a));\n\t\t});\n\t});\n}\n/** Each value falls no faster than `release` frames from its peak (attack is instant). */\nfunction smoothRelease(values, release) {\n\tif (release <= 0) return [...values];\n\tconst k = 1 / (release + 1);\n\tlet prev = 0;\n\treturn values.map((v) => {\n\t\tprev = v >= prev ? v : prev + (v - prev) * k;\n\t\treturn round(prev);\n\t});\n}\n/** The schema for `AudioLevels` props (Waveform, Captions `pulse`). */\nfunction audioLevelsSchema() {\n\treturn z.object({\n\t\tfps: z.number().positive(),\n\t\tframes: z.number().int().min(0),\n\t\tbands: z.array(z.array(z.number())),\n\t\tlevel: z.array(z.number()),\n\t\tbeats: z.array(z.number().int())\n\t});\n}\n\n//#endregion\n//#region src/core/glyphs.ts\n/**\n* Per-unit glyph animation on the GPU, with no node per unit: each unit\n* (character, word or line) gets its own start frame, and the renderer's\n* expression selector reads the schedule from a baked table. Timing is\n* exact (cue frames are where the motion happens) and any ease works,\n* because the curve is sampled offline with `core/ease.ts`.\n*\n* Expression `frame` is the text node's local frame; `textIndex` counts\n* every character of the string, spaces included.\n*/\n/** The expression variable that indexes each unit. */\nconst UNIT_INDEX = {\n\tchar: \"textIndex\",\n\tword: \"wordIndex\",\n\tline: \"lineIndex\"\n};\nconst num = (v) => String(Math.round(v * 1e4) / 1e4);\nconst list = (values) => `[${values.map(num).join(\",\")}]`;\n/**\n* The weight expression for a schedule. `enter`: 1 (fully pushed) until the\n* unit starts, easing to 0 (at rest) by `start + duration`. `exit`: the\n* reverse, 0 → 1. Optional `factors` scale each unit's weight (seeded\n* scatter directions, for instance).\n*/\nfunction scheduleExpression(unit, schedule, mode, factors) {\n\tconst n = Math.max(1, Math.round(schedule.duration));\n\tconst table = Array.from({ length: n + 1 }, (_, k) => evaluateEase(schedule.ease, k / n));\n\tconst idx = UNIT_INDEX[unit];\n\tconst pick = (arr) => `(${arr}[${idx}]??${arr}[${arr}.length-1])`;\n\tconst weight$1 = mode === \"enter\" ? \"1-v\" : \"v\";\n\tconst scaled = factors ? `(${weight$1})*${pick(\"F\")}` : weight$1;\n\treturn [\n\t\t`((S,L,F)=>{`,\n\t\t`const t=frame-${pick(\"S\")};`,\n\t\t`const k=floor(t);`,\n\t\t`const v=t<=0?L[0]:t>=${n}?L[${n}]:L[k]+(L[k+1]-L[k])*(t-k);`,\n\t\t`return ${scaled};`,\n\t\t`})(${list(schedule.starts)},${list(table)},${factors ? list(factors) : \"0\"})`\n\t].join(\"\");\n}\n/**\n* 1 while each unit is inside its window [start, end) (a word being spoken),\n* else 0: a hard edge on exact frames. Indexed per unit; `factors` scale it.\n*/\nfunction windowExpression(unit, starts, ends, factors) {\n\tconst idx = UNIT_INDEX[unit];\n\treturn `((S,E)=>{const s=S[${idx}];return s!==undefined&&frame>=s&&frame<E[${idx}]?1${factors ? `*(${list(factors)}[${idx}]??0)` : \"\"}:0;})(${list(starts)},${list(ends)})`;\n}\n/** 1 until each unit's start frame, then 0 (an exact step, no ease). */\nfunction stepExpression(unit, starts) {\n\treturn `((S)=>frame<(S[${UNIT_INDEX[unit]}]??S[S.length-1])?1:0)(${list(starts)})`;\n}\n/**\n* A per-character array (one entry per string index) in the renderer's\n* order: its `textIndex` skips line breaks, so every character after a\n* `\\n` sits one index earlier than in the string.\n*/\nfunction rendererChars(text, values) {\n\treturn values.filter((_, i) => text[i] !== \"\\n\");\n}\n/** A fixed weight per unit (e.g. 1 for emphasised characters). */\nfunction constantExpression(unit, weights) {\n\treturn `(${list(weights)}[${UNIT_INDEX[unit]}]??0)`;\n}\nfunction glyphAnimator(name, expression, props) {\n\treturn {\n\t\tname,\n\t\tselectors: [{\n\t\t\ttype: \"expression\",\n\t\t\texpression,\n\t\t\tmode: \"add\",\n\t\t\tamount: 1\n\t\t}],\n\t\tprops\n\t};\n}\n/**\n* Evaluate an expression the way the renderer does (same scope names, same\n* [-1, 1] clamp). For tests and offline checks.\n*/\nfunction evaluateGlyphExpression(expression, scope) {\n\tconst vars = {\n\t\ttextIndex: scope.textIndex ?? 0,\n\t\twordIndex: scope.wordIndex ?? 0,\n\t\tlineIndex: scope.lineIndex ?? 0,\n\t\tframe: scope.frame,\n\t\tfloor: Math.floor,\n\t\tclamp: (v, lo, hi) => Math.max(lo, Math.min(hi, v)),\n\t\tabs: Math.abs,\n\t\tmin: Math.min,\n\t\tmax: Math.max\n\t};\n\tconst fn$1 = new Function(...Object.keys(vars), `return (${expression});`);\n\tconst result = Number(fn$1(...Object.values(vars)));\n\treturn Number.isFinite(result) ? Math.max(-1, Math.min(1, result)) : 0;\n}\n\n//#endregion\n//#region src/core/layout.ts\n/**\n* Safe-area margins by use. Portrait leaves room for the captions, buttons\n* and handles that short-form platforms draw over the bottom and right.\n*/\nconst SAFE_INSETS = {\n\ttitles: {\n\t\tlandscape: {\n\t\t\tx: .06,\n\t\t\ttop: .08,\n\t\t\tbottom: .1\n\t\t},\n\t\tportrait: {\n\t\t\tx: .08,\n\t\t\ttop: .1,\n\t\t\tbottom: .24\n\t\t}\n\t},\n\tcaptions: {\n\t\tlandscape: {\n\t\t\tx: .1,\n\t\t\ttop: .08,\n\t\t\tbottom: .1\n\t\t},\n\t\tportrait: {\n\t\t\tx: .08,\n\t\t\ttop: .12,\n\t\t\tbottom: .22\n\t\t}\n\t}\n};\n/**\n* The rect inside `canvas` that content keeps to. `area` forces an\n* orientation or gives the rect itself; by default a frame taller than it is\n* wide counts as portrait.\n*/\nfunction safeArea(canvas, area, insets = SAFE_INSETS.titles) {\n\tif (area && typeof area === \"object\") return area;\n\tconst { width: W, height: H } = canvas;\n\tconst i = (area ? area === \"portrait\" : H > W) ? insets.portrait : insets.landscape;\n\treturn {\n\t\tx: W * i.x,\n\t\ty: H * i.top,\n\t\twidth: W * (1 - 2 * i.x),\n\t\theight: H * (1 - i.top - i.bottom)\n\t};\n}\n\n//#endregion\n//#region src/core/typing.ts\n/**\n* Keystroke frames for typing at `cps` characters a second: seeded ±30 %\n* jitter, a beat after spaces, a longer one after punctuation. Frame `k[i]`\n* is when character `i` appears.\n*/\nfunction typingFrames(text, cps, fps, r, start = 0) {\n\tconst per = fps / cps;\n\tconst out = [];\n\tlet t = start;\n\tfor (let i = 0; i < text.length; i++) {\n\t\tconst prev = text[i - 1] ?? \"\";\n\t\tlet gap = i === 0 ? 0 : per * (1 + r.spread(.3));\n\t\tif (prev === \" \") gap += per * .6;\n\t\tif (/[.,!?;:]/.test(prev)) gap += per * 3;\n\t\tt += gap;\n\t\tout.push(Math.max(start, Math.round(t)));\n\t}\n\tfor (let i = 1; i < out.length; i++) out[i] = Math.max(out[i], out[i - 1] + 1);\n\treturn out;\n}\n\n//#endregion\n//#region src/core/meta.ts\nfunction defineMeta(meta) {\n\tif (!/^[A-Z][A-Za-z0-9]+$/.test(meta.name)) throw new Error(`Component name must be PascalCase: \"${meta.name}\"`);\n\tif (meta.summary.length > 200) throw new Error(`${meta.name}: summary must be one sentence (≤ 200 chars).`);\n\treturn meta;\n}\n\n//#endregion\nexport { wobblePoints as $, last as A, chain as At, textLayout as B, hashRng as Bt, springAt as C, transparent as Ct, KeyBook as D, exitAnimation as Dt, springTrack as E, enterAnimation as Et, evaluateEase as F, staggerOffsets as Ft, targetSchema as G, lineShift as H, rng as Ht, anchorPoint as I, staggerRanks as It, boxPath as J, arrowPaths as K, boundsOf as L, toFrames as Lt, supersede as M, frameSpan as Mt, valueAt as N, quantize as Nt, Track as O, resolveMotion as Ot, ease as P, scaleFrames as Pt, squigglePath as Q, resolveTarget as R, toSeconds as Rt, bakeSamples as S, parseColor as St, springSettleFrames as T, MOTION_PRESETS as Tt, rangeRects as U, findRange as V, hashString as Vt, wordRanges as W, ellipsePath as X, drawOnKeys as Y, linePath as Z, smoothRelease as _, contrastRatio as _t, UNIT_INDEX as a, transformPathData as at, surfaceFill as b, luminance as bt, glyphAnimator as c, bind as ct, stepExpression as d, offsetCues as dt, arcPath as et, windowExpression as f, pulseKeys as ft, resampleBands as g, themes as gt, bandEdges as h, themeFrames as ht, safeArea as i, toPathData as it, round as j, cover as jt, ascending as k, beats as kt, rendererChars as l, defineComponent as lt, audioLevelsSchema as m, defineTheme as mt, typingFrames as n, dist as nt, constantExpression as o, after as ot, analyzeChannels as p, withDefaults as pt, boilKeys as q, SAFE_INSETS as r, lerp2 as rt, evaluateGlyphExpression as s, basePropsSchema as st, defineMeta as t, catmullRom as tt, scheduleExpression as u, holdFirstKeys as ut, elevate as v, inkOn as vt, springKeys as w, withAlpha as wt, bakeFunction as x, mix as xt, elevationStyle as y, isLight as yt, targetPoint as z, within as zt };\n//# sourceMappingURL=meta-1w21OBWA.mjs.map","/**\n * The host framefields injects into component builds: the `Layer`\n * factories, real font measurement and stable ids. `Layer` is read inside\n * each call, never at module load, so importing this file has no effects.\n */\nimport type { Host, LayerStyleConfig } from \"@framefields/components/toolkit\";\nimport { frameArraySignal } from \"@framefields/core\";\nimport { FilmGrain, LayerStyle } from \"../effects/index.js\";\nimport { FontManager } from \"../fonts/index.js\";\nimport { autoId } from \"../ids.js\";\nimport { type AnimatableNode, Layer } from \"../index.js\";\nimport { Layer3D } from \"../shapes3d.js\";\n\nconst IMAGE = /\\.(png|jpe?g|webp|gif|avif|tiff?|bmp)(\\?.*)?$/i;\nconst SVG = /\\.svg(\\?.*)?$/i;\n\n/** Every style the config names is switched on. */\nfunction layerStyle(config: LayerStyleConfig): LayerStyle {\n\tconst on = <T extends object>(s: T | undefined) =>\n\t\ts ? { ...s, enabled: true } : undefined;\n\treturn new LayerStyle({\n\t\t...(config.dropShadow && { dropShadow: on(config.dropShadow) }),\n\t\t...(config.outerGlow && { outerGlow: on(config.outerGlow) }),\n\t\t...(config.innerShadow && { innerShadow: on(config.innerShadow) }),\n\t\t...(config.stroke && { stroke: on(config.stroke) }),\n\t} as ConstructorParameters<typeof LayerStyle>[0]);\n}\n\n/** A mid-grey SVG as a data URL: neutral under soft-light, so only its grain shows. */\nfunction greySvg(width: number, height: number): string {\n\tconst w = Math.max(16, Math.round(width));\n\tconst h = Math.max(16, Math.round(height));\n\treturn `data:image/svg+xml;utf8,${encodeURIComponent(\n\t\t`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${w}\" height=\"${h}\"><rect width=\"${w}\" height=\"${h}\" fill=\"#808080\"/></svg>`,\n\t)}`;\n}\n\nexport const host: Host = {\n\tbox: (options) => Layer.box(options),\n\tflex: (options) => Layer.flex(options),\n\ttext: (content, options) => Layer.text(content, options),\n\tshape: (type, options) => Layer.shape(type, options),\n\tmeasure: (text, options) => FontManager.measure(text, options),\n\tfonts: () => FontManager.getAll().map((f) => f.family),\n\tautoId,\n\tmedia: (source, options) =>\n\t\tSVG.test(source)\n\t\t\t? Layer.svg(source, options)\n\t\t\t: IMAGE.test(source)\n\t\t\t\t? Layer.image(source, options)\n\t\t\t\t: Layer.video(source, { muted: true, ...options }),\n\tstyle: (node, config) => {\n\t\t(node as unknown as AnimatableNode).withEffect(layerStyle(config));\n\t\treturn node;\n\t},\n\tcutout: (source, { mode = \"person\", ...options }) =>\n\t\tLayer.video(source, {\n\t\t\tmuted: true,\n\t\t\tvolume: 0,\n\t\t\tfit: \"cover\",\n\t\t\t...options,\n\t\t}).withVision({\n\t\t\tmode: \"matte\",\n\t\t\tenableSegmentation: true,\n\t\t\t// The larger model separates a subject (not just people) more cleanly.\n\t\t\tvariant: mode === \"subject\" ? \"m\" : \"s\",\n\t\t\tconfidence: 0.25,\n\t\t\tfeatherRadius: 0.04,\n\t\t\tkeyBackground: true,\n\t\t}),\n\tparticles: (options) => Layer.particles(options),\n\t// `Signal.fromArray` itself; the `Signal` namespace would pull every builder.\n\tsignal: (values, fps) => frameArraySignal([...values], fps),\n\tgrain: ({ id, x, y, width, height, strength, size }) =>\n\t\tLayer.svg(greySvg(width, height), {\n\t\t\tid,\n\t\t\tposition: \"absolute\",\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tfit: \"fill\",\n\t\t\tblendMode: \"soft-light\",\n\t\t}).withEffect(\n\t\t\tnew FilmGrain({\n\t\t\t\tstrength,\n\t\t\t\t...(size !== undefined && { size }),\n\t\t\t\tshadows: 1,\n\t\t\t\tmidtones: 1,\n\t\t\t\thighlights: 1,\n\t\t\t}),\n\t\t),\n\textrudedText: ({ fontWeight, ...options }) =>\n\t\tLayer3D.extrudedText({\n\t\t\t...options,\n\t\t\t...(fontWeight !== undefined && { fontWeight: String(fontWeight) }),\n\t\t\talign: \"center\",\n\t\t\tverticalAlign: \"middle\",\n\t\t} as Parameters<typeof Layer3D.extrudedText>[0]),\n\tmatte: (node, matte, mode = \"alpha\") => {\n\t\t(node as unknown as AnimatableNode).withMatte(matte, mode);\n\t\treturn node;\n\t},\n};\n","/**\n * `analyzeAudio`: decode a track and analyse it into `AudioLevels`, plain\n * per-frame data for `Waveform` and `Captions` `pulse`. Offline and\n * deterministic: the same file always gives the same levels.\n */\nimport {\n\ttype AnalyzeOptions,\n\ttype AudioLevels,\n\tanalyzeChannels,\n} from \"@framefields/components/toolkit\";\nimport { decodeAudioSource } from \"@framefields/compositions\";\n\nexport async function analyzeAudio(\n\tsource: string,\n\toptions: AnalyzeOptions = {},\n): Promise<AudioLevels> {\n\tconst decoded = await decodeAudioSource(source);\n\tif (!decoded || decoded.channels.length === 0)\n\t\tthrow new Error(`analyzeAudio: could not decode audio from ${source}`);\n\treturn analyzeChannels(decoded.channels, decoded.sampleRate, options);\n}\n","/**\n * `framefields/components`: the toolkit components are built from. The\n * components themselves are not in the package: `npx framefields add <name>`\n * copies their source into your project, where it imports this toolkit\n * (timing, paths, strokes, targets, baking, themes) and `bindComponent`.\n *\n * Named exports with no top-level calls, so bundlers keep only what a\n * project's components use.\n */\n\nimport type {\n\tBaseProps,\n\tComponentDefinition,\n\tComponentExtras,\n\tCues,\n} from \"@framefields/components/toolkit\";\nimport { bind } from \"@framefields/components/toolkit\";\nimport type { BoxNode } from \"@framefields/compositions/program\";\nimport type { z } from \"zod\";\nimport type { AnimatableNode } from \"../index.js\";\nimport { host } from \"./host.js\";\n\n/** A component's root: a normal framefields box layer plus cues, span and parts. */\nexport type ComponentNode<C extends Cues = Cues> = AnimatableNode<BoxNode> &\n\tComponentExtras<C>;\n\n/**\n * Bind a component definition to framefields, producing its factory. Every\n * installed component ends with one of these; use it for your own\n * components built with `defineComponent` too.\n */\nexport function bindComponent<\n\tS extends z.ZodRawShape,\n\tC extends Cues,\n\tE extends object = object,\n>(\n\tdefinition: ComponentDefinition<S, C, E>,\n): (props: z.input<z.ZodObject<S>> & BaseProps) => ComponentNode<C> & E {\n\treturn bind(host, definition) as never;\n}\n\nexport * from \"@framefields/components/toolkit\";\n/** framefields' own zod, so component schemas share its instance. */\nexport { z } from \"zod\";\nexport { analyzeAudio } from \"./audio.js\";\n","import { resolveFrameRequest } from \"@framefields/core\";\n\nexport {\n\ttype Ai,\n\ttype AiConfig,\n\tApiError,\n\tai,\n\tFRAMEFIELDS_AI_PROXY_URL,\n\ttype QueueStatus,\n\ttype Result,\n\ttype RunOptions,\n\tValidationError,\n} from \"@framefields/ai\";\nexport {\n\ttype AudioPitchOptions,\n\ttype AudioPitchSignals,\n\tAudioSignal,\n\ttype AudioSignalOptions,\n\tcomputed,\n\tcosineSignal,\n\ttype ExtractedAudioSignalsBundle,\n\ttype FrameSignal,\n\tSignal,\n\ttype SignalContext,\n\ttype SignalValue,\n\ttype SineSignalOptions,\n\tsignal,\n\tsignalBuilder,\n\tsignalRegistry,\n\tsineSignal,\n} from \"./signals/index.js\";\n\nimport {\n\tFontManager,\n\ttype MeasuredGlyph,\n\ttype MeasureTextOptions,\n\ttype RegisteredFont,\n\ttype RegisterFontOptions,\n\ttype TextMetrics,\n} from \"./fonts/index.js\";\nimport { autoId } from \"./ids.js\";\nimport { normalizeTextSpans, type TextSpan } from \"./rich-text.js\";\n\nexport {\n\tencodeStereoWav,\n\tmixAudioTracks,\n\tmixSfxInto,\n\ttype RenderedSfx,\n\trenderSfx,\n\ttype SfxRenderContext,\n\ttype SfxTrigger,\n\tsoftLimit,\n} from \"./audio/index.js\";\nexport {\n\taccent,\n\tbold,\n\tcode,\n\tcolor,\n\titalic,\n\ttype MarkOptions,\n\tmark,\n\tnormalizeTextSpans,\n\tparseMarkup,\n\trich,\n\tsize,\n\tspan,\n\tsub,\n\tsup,\n\ttype TextSpan,\n\ttype TextSpanItem,\n\ttype TextSpanMark,\n} from \"./rich-text.js\";\nexport {\n\tFontManager,\n\ttype MeasuredGlyph,\n\ttype MeasureTextOptions,\n\ttype RegisteredFont,\n\ttype RegisterFontOptions,\n\ttype TextMetrics,\n};\n\nexport {\n\tCannyComputePipeline,\n\ttype CannyOptions,\n\ttype ControlNetConditioningOutputs,\n\tControlNetMultiplexer,\n\ttype DeflickerOptions,\n\tDepthNormalsComputePipeline,\n\ttype DepthNormalsOptions,\n\ttype NormalRelightingOptions,\n\tOpticalFlowComputePipeline,\n\ttype OpticalFlowOptions,\n\tTemporalDeflickerPipeline,\n\ttype TensorDimensions,\n\ttype TensorFormat,\n\ttype TensorNode,\n\tTensorPipeline,\n\ttype TensorPipelineConfig,\n\ttype TensorSource,\n\ttype TensorViewExport,\n} from \"@framefields/tensor-webgpu\";\nexport {\n\tCOCO_CLASSES,\n\tCOCO17_BONES,\n\tCOCO17_KEYPOINT_NAMES,\n\tCOCO17_KEYPOINTS,\n\ttype DetectedObject,\n\ttype InstanceMask,\n\ttype Landmark3D,\n\ttype LandmarkCoordinateSignals,\n\ttype MaskTrackSignals,\n\ttype NormalizedLandmarkList,\n\ttype ObjectAnchorName,\n\ttype ObjectAnchorsSignals,\n\ttype ObjectBoundingBox,\n\ttype ObjectBoundingBoxSignals,\n\ttype ObjectCollectionSignals,\n\ttype ObjectKinematicsSignals,\n\ttype ObjectTrackSignals,\n\ttype PersonMatte,\n\ttype PinToLandmarkOptions,\n\ttype PinToObjectOptions,\n\ttype PoseLandmarkSignals,\n\ttype PoseResult,\n\tPoseSkeletonRenderer,\n\tpinNodeToLandmark,\n\tpinNodeToObject,\n\ttype SegmentationResult,\n\tSegmentationTexturePool,\n\tSpatialLandmarkTransformer,\n\tTemporalObjectTracker,\n\ttype TrackedObject,\n\tVisionBundle,\n\ttype VisionConfig,\n\tVisionNode,\n\tVisionRunner,\n\ttype VisionTask,\n\ttype VisionVariant,\n} from \"@framefields/vision\";\n\n// Types only, so SAM stays in its own lazily loaded chunk; the trackers are in `framefields/sam`.\nexport type {\n\tSam2FrameResult,\n\tSam2Model,\n\tSam2Options,\n\tSam2Point,\n\tSam2Prompt,\n\tSam3Options,\n\tSam3Precision,\n\tSam3Prompt,\n} from \"@framefields/vision-sam\";\n\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { preflightMediaTime } from \"@framefields/compositions\";\nimport {\n\ttype AnimatableProp,\n\ttype AnimatablePropsFor,\n\ttype AnimationTrack,\n\ttype BoxNode,\n\ttype CameraNode,\n\ttype CompositorProgramConfig,\n\ttype CompositorToProgramOptions,\n\tcollectNodeOps,\n\tcompositorToProgram,\n\ttype EnvironmentPreset,\n\ttype FlexNode,\n\tLayerAnimation,\n\ttype LayoutNode,\n\ttype LightNode,\n\tlintComposition,\n\ttype MatteMode,\n\ttype MediaAnimatableProp,\n\ttype MediaNode,\n\ttype MediaSignalResolver,\n\ttype Model3DAnimatableProp,\n\ttype Model3DNode,\n\tmergeAnimationTracks,\n\ttype ShapeAnimatableProp,\n\ttype ShapeNode,\n\ttype SizeSpec,\n\ttype TextAnimatableProp,\n\ttype TextNode,\n} from \"@framefields/compositions/program\";\nimport {\n\tappendOperation,\n\tEffect as CoreEffect,\n\tcreateVirtualMedia,\n\ttype DataType,\n\ttype FrameContext,\n\ttype MediaMetadata,\n\ttype MediaOperation,\n\ttype MediaSourceInput,\n\ttype MeshAudioDeformConfig,\n\tProgrammaticSignal,\n\ttype RenderDiagnostic,\n\ttype ResolvedMediaTimeRemap,\n\ttype Signal,\n\ttype VirtualMediaData,\n} from \"@framefields/core\";\n\nexport type {\n\tMediaTimeRemap,\n\tMediaTimeRemapInput,\n\tMediaTimeSignalRemap,\n} from \"@framefields/core\";\n\nimport {\n\tanalyzeSequence as analyzeVisionFrames,\n\tCLIP_SUBJECT,\n\ttype LandmarkCoordinateSignals,\n\ttype MaskTrackSignals,\n\ttype ObjectTrackSignals,\n\ttype PinToLandmarkOptions,\n\ttype PinToObjectOptions,\n\tpinNodeToLandmark,\n\tpinNodeToObject,\n\ttype VisionAnalysisReport,\n\tVisionBundle,\n\tVisionNode,\n\tVisionRunner,\n\ttype VisionTask,\n} from \"@framefields/vision\";\n\nexport {\n\tanalyzeSequence,\n\ttype VisionAnalysisReport,\n} from \"@framefields/vision\";\n\nimport {\n\ttype DeflickerOptions,\n\ttype NormalRelightingOptions,\n\tTensorPipeline,\n} from \"@framefields/tensor-webgpu\";\nimport { inputStore, mediaDecoderCache } from \"@framefields/webgpu-renderers\";\nimport { buildChart, type ChartOptions } from \"./chart.js\";\nimport { ClipVision, type ClipVisionOptions } from \"./clip-vision.js\";\nimport {\n\ttype AnyAudioEffect,\n\ttype AnyEffect,\n\ttype AnyVisualEffect,\n\tApplyLUT,\n\ttype ApplyLUTProps,\n\tBlur,\n\ttype BlurProps,\n\tColorBalance,\n\ttype ColorBalanceProps,\n\tColorKey,\n\ttype ColorKeyProps,\n\tCrop,\n\ttype CropProps,\n\tCurves,\n\ttype CurvesProps,\n\tCustomEffect,\n\ttype DeflickerProps,\n\tDepthOfField,\n\ttype DepthOfFieldProps,\n\ttype EffectProp,\n\teffectFactories,\n\tFilmGrain,\n\ttype FilmGrainProps,\n\tGradientMap,\n\ttype GradientMapProps,\n\tHalftoneScreen,\n\ttype HalftoneScreenProps,\n\tHighPass,\n\ttype HighPassProps,\n\tLevels,\n\ttype LevelsProps,\n\tModulate,\n\ttype ModulateProps,\n\tMotionBlur,\n\ttype MotionBlurProps,\n\tPBRGlass,\n\ttype PBRGlassProps,\n\tProceduralVFX,\n\ttype ProceduralVFXProps,\n\tRelight3D,\n\ttype Relight3DProps,\n\tSelectiveColor,\n\ttype SelectiveColorProps,\n\tShadowsHighlights,\n\ttype ShadowsHighlightsProps,\n\tSSAO,\n\ttype SSAOProps,\n\tTemporalDeflicker,\n\tTileOffset,\n\ttype TileOffsetProps,\n\tUnsharpMask,\n\ttype UnsharpMaskProps,\n\tVignette,\n\ttype VignetteProps,\n\tVision,\n\ttype VisionProps,\n} from \"./effects/index.js\";\nimport {\n\tcontextAtFrame,\n\tMediaSignalTimeline,\n\tremapKey,\n} from \"./media-signals.js\";\nimport { Particles, type ParticlesOptions } from \"./particles.js\";\nimport {\n\ttype FrameGridOptions,\n\tHeadlessMediaRenderer,\n\ttype RenderProgress,\n\trenderFrameGrid,\n\ttype VideoQaOptions,\n\ttype VideoQaReport,\n} from \"./renderer/index.js\";\nimport {\n\ttype Carousel3DOptions,\n\ttype Cube3DOptions,\n\tLayer3D,\n\ttype Plane3DOptions,\n\ttype Prism3DOptions,\n\ttype SolidShape3DNode,\n} from \"./shapes3d.js\";\nimport {\n\ttype SceneSequenceOptions,\n\ttype SequenceEntry,\n\ttype SequenceNode,\n\tsequence,\n} from \"./transitions.js\";\n\nexport interface SectionOptions {\n\treadonly id?: string;\n\treadonly position?: \"absolute\" | \"relative\";\n\treadonly source?: string | MediaNode;\n\treadonly effects?: AnyVisualEffect[];\n\treadonly padding?: number;\n\treadonly borderRadius?: number;\n\treadonly borderColor?: string;\n\treadonly borderWidth?: number;\n\treadonly opacity?: EffectProp<number>;\n\treadonly blendMode?: string;\n\treadonly fit?: \"cover\" | \"contain\";\n\treadonly width?: EffectProp<SizeSpec>;\n\treadonly height?: EffectProp<SizeSpec>;\n\treadonly compositionWidth?: number;\n\treadonly compositionHeight?: number;\n\treadonly compWidth?: number;\n\treadonly compHeight?: number;\n\treadonly x?: EffectProp<number>;\n\treadonly y?: EffectProp<number>;\n\treadonly hideWhenLost?: boolean;\n\treadonly smoothFrames?: number;\n\treadonly children?: LayoutNode[];\n}\n\nexport type SectionNode = AnimatableNode<BoxNode, \"visual\"> & {\n\treadonly innerMedia: AnimatableNode<MediaNode, \"hybrid\">;\n\t// Any visual effect, whatever its config shape (Blur, FilmGrain, …).\n\treadonly effects: AnyVisualEffect[];\n\taddEffect(effect: AnyVisualEffect): SectionNode;\n\twithEffect(effect: AnyVisualEffect): SectionNode;\n\twithEffects(effects: AnyVisualEffect[]): SectionNode;\n};\n\nexport type TrackedRegionOptions = SectionOptions;\n\n/** Editing helpers attached to every tracked object (see decorateTrackSignals). */\nexport interface TrackEditing {\n\t/** A section of the source that follows this track */\n\tsection(\n\t\tsourceOrOptions?: string | MediaNode | SectionOptions,\n\t\toptions?: SectionOptions,\n\t): SectionNode;\n\t/** A blur confined to this track's region */\n\tblurEffect(options?: Partial<BlurProps>): Blur;\n\t/** The tracked region of `source`, cut out as a section */\n\tisolate(\n\t\tsource: string | MediaNode,\n\t\toptions?: TrackedRegionOptions,\n\t): SectionNode;\n}\n\n/** A tracked object with its editing helpers, as vision hands it out. */\nexport type EditableObjectTrack = ObjectTrackSignals & TrackEditing;\n\nfunction decorateTrackSignals<T extends ObjectTrackSignals>(\n\ttrack: T,\n\tsource?: string | MediaNode,\n): T {\n\tif (!track) return track;\n\tif (source && !track.source) {\n\t\tObject.defineProperty(track, \"source\", {\n\t\t\tvalue: source,\n\t\t\tenumerable: true,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\tif (typeof track.section !== \"function\") {\n\t\tObject.defineProperty(track, \"section\", {\n\t\t\tvalue: (\n\t\t\t\tsourceOrOptions?: string | MediaNode | SectionOptions,\n\t\t\t\toptions?: SectionOptions,\n\t\t\t) => {\n\t\t\t\tif (\n\t\t\t\t\ttypeof sourceOrOptions === \"object\" &&\n\t\t\t\t\tsourceOrOptions !== null &&\n\t\t\t\t\t!(\"kind\" in sourceOrOptions) &&\n\t\t\t\t\t!(\"inputHandleId\" in sourceOrOptions) &&\n\t\t\t\t\t!(\"src\" in sourceOrOptions)\n\t\t\t\t) {\n\t\t\t\t\tconst resolvedSource =\n\t\t\t\t\t\t(sourceOrOptions as SectionOptions).source ??\n\t\t\t\t\t\t(track.source as string | MediaNode | undefined) ??\n\t\t\t\t\t\tsource;\n\t\t\t\t\treturn Layer.section(\n\t\t\t\t\t\tresolvedSource as string | MediaNode,\n\t\t\t\t\t\ttrack,\n\t\t\t\t\t\tsourceOrOptions as SectionOptions,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst resolvedSource =\n\t\t\t\t\tsourceOrOptions ??\n\t\t\t\t\t(track.source as string | MediaNode | undefined) ??\n\t\t\t\t\tsource;\n\t\t\t\treturn Layer.section(\n\t\t\t\t\tresolvedSource as string | MediaNode,\n\t\t\t\t\ttrack,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t},\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\tif (typeof track.blurEffect !== \"function\") {\n\t\tObject.defineProperty(track, \"blurEffect\", {\n\t\t\tvalue: (options?: Partial<BlurProps>) => new Blur({ track, ...options }),\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\tif (typeof track.isolate !== \"function\") {\n\t\tObject.defineProperty(track, \"isolate\", {\n\t\t\tvalue: (sourceArg: string | MediaNode, options?: TrackedRegionOptions) =>\n\t\t\t\tLayer.section(sourceArg, track, options),\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\treturn track;\n}\n\nconst origVisionAttach = VisionNode.attach;\nVisionNode.attach = function (\n\tsource: Parameters<typeof origVisionAttach>[0],\n\tconfig?: Parameters<typeof origVisionAttach>[1],\n\tbundleOptions?: Parameters<typeof origVisionAttach>[2],\n): ReturnType<typeof origVisionAttach> {\n\tconst bundle = origVisionAttach.call(this, source, config, bundleOptions);\n\tif (bundle?.objects) {\n\t\tconst src = source as string | MediaNode;\n\t\tconst origGet = bundle.objects.get.bind(bundle.objects);\n\t\tbundle.objects.get = (id: number) => decorateTrackSignals(origGet(id), src);\n\n\t\tconst origByCategory = bundle.objects.byCategory.bind(bundle.objects);\n\t\tbundle.objects.byCategory = (cat: string, rank?: number) =>\n\t\t\tdecorateTrackSignals(origByCategory(cat, rank), src);\n\n\t\tif (bundle.objects.primary) {\n\t\t\tdecorateTrackSignals(bundle.objects.primary, src);\n\t\t}\n\t}\n\treturn bundle;\n};\n\nexport {\n\ttype AdvancedTextAnimator,\n\tAdvancedTextAnimatorBuilder,\n\tAdvancedTextAnimatorSchema,\n\t// Text Animations & After Effects Parity\n\ttype AETextAnimator,\n\tAETextAnimatorSchema,\n\ttype AnchorGrouping,\n\tAnchorGroupingSchema,\n\ttype AnchorPreset,\n\tAnchorPresetSchema,\n\ttype AnimatableGlyphProps,\n\tAnimatableGlyphPropsSchema,\n\ttype AnimatableProp,\n\ttype AnimationTrack,\n\ttype ArcLengthLUTEntry,\n\ttype AudioSpectrumTypography,\n\tAudioSpectrumTypographySchema,\n\tapplyStaggerToChildren,\n\ttype BlockNode,\n\ttype BloomConfig,\n\tBloomConfigSchema,\n\ttype BoxNode,\n\tBoxNodeSchema,\n\tbuildPathLUT,\n\tCameraAnimation,\n\ttype CameraDoF,\n\ttype CameraLens,\n\ttype CameraNode,\n\tCameraNodeSchema,\n\ttype CameraShake,\n\ttype CarrierHandoffConfig,\n\tCarrierHandoffConfigSchema,\n\ttype CarrierState,\n\ttype ChromaticGlitchConfig,\n\tChromaticGlitchConfigSchema,\n\ttype ColorSignalOptions,\n\ttype ColorStop,\n\tColorStopSchema,\n\ttype CompositorProgramConfig,\n\tCompositorProgramSchema,\n\ttype CompositorToProgramOptions,\n\ttype CubicBezierSegment,\n\tCubicBezierSegmentSchema,\n\tcalculateSequenceTimeline,\n\tcollectNodeOps,\n\tcompositorToProgram,\n\tcomputeAnchorPivotOffset,\n\tcomputeCarrierContinuity,\n\tcomputeLayout,\n\tcomputeLayoutSync,\n\tcomputeLineLeadingDisplacement,\n\tcomputeRangeSelectorWeight,\n\tcomputeStaggerDelay,\n\ttype DynamicStrokeProperties,\n\tDynamicStrokePropertiesSchema,\n\tdeterministicWigglyNoise,\n\tdistanceToCurveParameter,\n\ttype EaseRef,\n\ttype EnhancedTextNode,\n\tEnhancedTextNodeSchema,\n\ttype EnvironmentFloor,\n\tEnvironmentFloorSchema,\n\ttype EnvironmentFog,\n\tEnvironmentFogSchema,\n\ttype EnvironmentPreset,\n\tEnvironmentPresetSchema,\n\ttype ExpressionEvaluationContext,\n\ttype ExpressionSelector,\n\tExpressionSelectorSchema,\n\ttype ExtendedGlyphProperties,\n\tExtendedGlyphPropertiesSchema,\n\tellipseToCubicBeziers,\n\tevaluateAnimationAtFrame,\n\tevaluateCubicBezier,\n\tevaluateCubicBezierDerivative,\n\tevaluateExpressionSelector,\n\tevaluateMarqueeOffset,\n\tevaluateSelectorCombination,\n\tevaluateSkewMatrix,\n\tevaluateSpringProgress,\n\tevaluateTrackAtFrame,\n\tevaluateTypewriterState,\n\tevaluateVolumetricFormation,\n\ttype FlexNode,\n\tFlexNodeSchema,\n\ttype FromToOptions,\n\ttype GlyphAnchorGrouping,\n\tGlyphAnchorGroupingSchema,\n\ttype GlyphAnchorPoint,\n\tGlyphAnchorPointSchema,\n\tgenerateArcLengthLUT,\n\tgeneratePathSegments,\n\tgetScramblePool,\n\tgetShuffledOrder,\n\thoistMattes,\n\ttype Keyframe,\n\ttype KeyframeTuple,\n\ttype KineticMarqueeConfig,\n\tKineticMarqueeConfigSchema,\n\tLayerAnimation,\n\ttype LayoutNode,\n\tLayoutNodeSchema,\n\ttype LightNode,\n\tLightNodeSchema,\n\ttype LightType,\n\tLightTypeSchema,\n\ttype LineSpacingDynamics,\n\tLineSpacingDynamicsSchema,\n\ttype LongShadowConfig,\n\tLongShadowConfigSchema,\n\tlintComposition,\n\ttype MaterialType,\n\tMaterialTypeSchema,\n\ttype MatteMode,\n\tMatteModeSchema,\n\ttype MediaNode,\n\tMediaNodeSchema,\n\ttype Model3DNode,\n\tModel3DNodeSchema,\n\tmergeAnimationTracks,\n\ttype ParticleDissolveConfig,\n\tParticleDissolveConfigSchema,\n\ttype PathChainLUT,\n\ttype PathChainLUTEntry,\n\tparseSvgPathToCubicBeziers,\n\tScene,\n\ttype SceneDefinition,\n\tSceneDefinitionSchema,\n\ttype SceneOptions,\n\ttype SceneTransitionType,\n\tSceneTransitionTypeSchema,\n\ttype SelectorBasedOn,\n\tSelectorBasedOnSchema,\n\ttype SelectorMode,\n\tSelectorModeSchema,\n\ttype SelectorShape,\n\tSelectorShapeSchema,\n\ttype SelectorUnits,\n\tSelectorUnitsSchema,\n\tSequence,\n\ttype SequenceOptions,\n\ttype SequenceTimelineResult,\n\ttype ShapeNode,\n\tShapeNodeSchema,\n\ttype SignalTrackOptions,\n\ttype SkewProperties,\n\tSkewPropertiesSchema,\n\ttype Spatial3DProperties,\n\tSpatial3DPropertiesSchema,\n\ttype SpringOptions,\n\ttype SpringPhysics,\n\tSpringPhysicsSchema,\n\tsampleAudioSpectrumScale,\n\tsampleCurveGeometry,\n\tsamplePathChainGeometry,\n\ttype TextAnchorConfig,\n\tTextAnchorConfigSchema,\n\tTextAnimator,\n\tTextAnimatorBuilder,\n\tTextAnimatorSchema,\n\ttype TextCursorConfig,\n\tTextCursorConfigSchema,\n\ttype TextCursorStyle,\n\tTextCursorStyleSchema,\n\ttype TextNode,\n\tTextNodeSchema,\n\tTextPathBuilder,\n\ttype TextPathOptions,\n\tTextPathOptionsSchema,\n\ttype TextPathSource,\n\tTextPathSourceSchema,\n\ttype TextRangeSelector,\n\tTextRangeSelectorSchema,\n\ttype TextScrambleConfig,\n\tTextScrambleConfigSchema,\n\ttype TextSelector,\n\tTextSelectorSchema,\n\ttype TextSignalSelector,\n\tTextSignalSelectorSchema,\n\tTextSpanMarkSchema,\n\tTextSpanSchema,\n\ttype TextWigglySelector,\n\tTextWigglySelectorSchema,\n\ttype ToneMapping,\n\tToneMappingSchema,\n\ttype TrackSource,\n\ttype TypewriterAnimator,\n\tTypewriterAnimatorSchema,\n\ttype TypingCadence,\n\tTypingCadenceSchema,\n\ttype VariableFontAxes,\n\tVariableFontAxesSchema,\n\ttype Vec2,\n\tVec2Schema,\n\ttype VolumetricFormationConfig,\n\tVolumetricFormationConfigSchema,\n\ttype VolumetricFormationMode,\n\tVolumetricFormationModeSchema,\n\ttype WiggleOptions,\n\twaveToCubicBeziers,\n} from \"@framefields/compositions/program\";\nexport * from \"@framefields/core\";\nexport * from \"@framefields/renderers\";\nexport type {\n\tAnimatablePropsFor,\n\tTextAnimatableProp,\n\tShapeAnimatableProp,\n\tMediaAnimatableProp,\n\tModel3DAnimatableProp,\n\tSizeSpec,\n};\nexport {\n\ttype AnimationClip3D,\n\ttype AudioLatentData,\n\tAudioLatentEngine,\n\tAudioLatentTrackCache,\n\tAudioMeshDeformPipeline,\n\ttype BlendMode,\n\ttype Bone3D,\n\tCamera3D,\n\tEffectPipeline,\n\tensureDevice,\n\tGlassPipeline,\n\ttype GPULightData,\n\tinputStore,\n\tLight3D,\n\ttype Light3DOptions,\n\ttype LoadModelOptions,\n\tloadFBX,\n\tloadModel3D,\n\tloadOBJ,\n\tlutStore,\n\ttype Material3D,\n\ttype Mesh3DData,\n\ttype Model3DData,\n\tMotionBlurPipeline,\n\ttype NodeAnimationTrack3D,\n\tPath3D,\n\tparseFBX,\n\tparseMTL,\n\tparseOBJ,\n\ttype RenderContextValue,\n\tRenderer2D,\n\tRenderer3D,\n\tShadowPipeline,\n\ttype Skeleton3D,\n\tSlugFontCache,\n\tSlugPipeline,\n\tSSAOPipeline,\n\tshaderStore,\n\ttextureCache,\n} from \"@framefields/webgpu-renderers\";\nexport {\n\ttype ChartAnimationOptions,\n\ttype ChartAxisOptions,\n\ttype ChartCandle,\n\ttype ChartDatum,\n\ttype ChartOptions,\n\ttype ChartPadding,\n\ttype ChartSeries,\n\ttype ChartSlice,\n\ttype ChartType,\n\ttype ChartX,\n\tDEFAULT_CHART_COLORS,\n} from \"./chart.js\";\nexport {\n\tClipVision,\n\ttype ClipVisionOptions,\n\ttype PersonPlacement,\n\tPersonTrack,\n\ttype PoseKeypointName,\n} from \"./clip-vision.js\";\nexport type {\n\tAnyAudioEffect,\n\tAnyEffect,\n\tAnyVisualEffect,\n\tEffectConfigMap,\n\tEffectOp,\n\tEffectPropsFor,\n} from \"./effects/index.js\";\nexport {\n\tApplyLUT,\n\ttype ApplyLUTProps,\n\tAscii,\n\ttype AsciiProps,\n\tAudioCompressor,\n\ttype AudioCompressorProps,\n\tAudioDelay,\n\ttype AudioDelayProps,\n\tAudioFade,\n\ttype AudioFadeProps,\n\tAudioNoiseGate,\n\ttype AudioNoiseGateProps,\n\tAudioParametricEq,\n\ttype AudioParametricEqProps,\n\tAudioReverb,\n\ttype AudioReverbProps,\n\tAudioSignalExtractor,\n\ttype AudioSignalExtractorProps,\n\tBlur,\n\ttype BlurProps,\n\tCameraParallax3D,\n\ttype CameraParallax3DProps,\n\tChannelMerger,\n\ttype ChannelMergerProps,\n\tChannelSplitter,\n\ttype ChannelSplitterProps,\n\tColorBalance,\n\ttype ColorBalanceProps,\n\tColorKey,\n\ttype ColorKeyProps,\n\tContour,\n\ttype ContourProps,\n\tCornerPin,\n\ttype CornerPinProps,\n\tCRT,\n\ttype CRTProps,\n\tCrop,\n\ttype CropProps,\n\tCurves,\n\ttype CurvesChannelPoint,\n\ttype CurvesProps,\n\tCustomEffect,\n\tDatamosh,\n\ttype DatamoshProps,\n\ttype DeflickerProps,\n\tDepthOfField,\n\ttype DepthOfFieldProps,\n\tDisplacementMap,\n\ttype DisplacementMapProps,\n\tDither,\n\ttype DitherProps,\n\tExtractLUT,\n\ttype ExtractLUTProps,\n\teffectFactories,\n\teffectMeta,\n\tFilmGrain,\n\ttype FilmGrainProps,\n\tFlip,\n\ttype FlipProps,\n\tGooey,\n\ttype GooeyProps,\n\tGradientMap,\n\ttype GradientMapProps,\n\ttype GradientMapStop,\n\ttype HalftoneDotShape,\n\ttype HalftoneMode,\n\tHalftoneScreen,\n\ttype HalftoneScreenProps,\n\tHighPass,\n\ttype HighPassProps,\n\tIridescence,\n\ttype IridescenceProps,\n\tKaleidoscope,\n\ttype KaleidoscopeProps,\n\tKenBurns,\n\ttype KenBurnsProps,\n\tLayerStyle,\n\ttype LayerStyleProps,\n\ttype LevelChannel,\n\tLevels,\n\ttype LevelsProps,\n\tLiquify,\n\ttype LiquifyProps,\n\tMaskMath,\n\ttype MaskMathProps,\n\tMeshWarp,\n\ttype MeshWarpProps,\n\tModulate,\n\ttype ModulateProps,\n\tMotionBlur,\n\ttype MotionBlurProps,\n\tNoiseGenerator,\n\ttype NoiseGeneratorProps,\n\tOpArt,\n\ttype OpArtProps,\n\tPaint,\n\tPainterly,\n\ttype PainterlyProps,\n\ttype PaintProps,\n\tPatchHeal,\n\ttype PatchHealProps,\n\tPBRGlass,\n\ttype PBRGlassProps,\n\tPixelate,\n\ttype PixelateProps,\n\tPosterize,\n\ttype PosterizeProps,\n\tProceduralVFX,\n\ttype ProceduralVFXProps,\n\tRefineEdge,\n\ttype RefineEdgeProps,\n\tRefractionCaustics3D,\n\ttype RefractionCaustics3DProps,\n\tRelight3D,\n\ttype Relight3DProps,\n\tResizerScaler,\n\ttype ResizerScalerProps,\n\tRGBSplit,\n\ttype RGBSplitProps,\n\tRotate,\n\ttype RotateProps,\n\tSelectiveColor,\n\ttype SelectiveColorAdjustment,\n\ttype SelectiveColorProps,\n\tShadowsHighlights,\n\ttype ShadowsHighlightsProps,\n\tSSAO,\n\ttype SSAOProps,\n\tStereoPanning,\n\ttype StereoPanningProps,\n\tTemporalDeflicker,\n\tTileOffset,\n\ttype TileOffsetEdgeMode,\n\ttype TileOffsetProps,\n\tToon,\n\ttype ToonProps,\n\tTrails,\n\ttype TrailsProps,\n\tUnsharpMask,\n\ttype UnsharpMaskProps,\n\tVignette,\n\ttype VignetteProps,\n\tVision,\n\ttype VisionProps,\n} from \"./effects/index.js\";\nexport {\n\tLighting,\n\ttype LightingRig,\n\ttype LightingRigOptions,\n} from \"./lighting.js\";\nexport {\n\ttype EmitterShape,\n\ttype ParticleBlend,\n\ttype ParticleBounds,\n\ttype ParticleShape,\n\tParticles,\n\ttype ParticlesOptions,\n} from \"./particles.js\";\nexport {\n\ttype Body2DOptions,\n\ttype Body3DOptions,\n\ttype BodyCommonOptions,\n\ttype FieldSample2D,\n\ttype FieldSample3D,\n\tPhysics,\n\ttype PhysicsBakeOptions,\n\tPhysicsBody2D,\n\tPhysicsBody3D,\n\ttype PhysicsBox3D,\n\ttype PhysicsCollision,\n\ttype PhysicsDriver,\n\ttype PhysicsGroundOptions,\n\ttype PhysicsRect,\n\ttype PhysicsRope3DOptions,\n\ttype PhysicsRopeOptions,\n\ttype PhysicsSpring3DOptions,\n\ttype PhysicsSpringOptions,\n\ttype PhysicsWallsOptions,\n\tPhysicsWorld2D,\n\tPhysicsWorld3D,\n\ttype PhysicsWorldOptions,\n\ttype World2DOptions,\n\ttype World3DOptions,\n} from \"./physics/index.js\";\nexport {\n\ttype Capsule3DOptions,\n\ttype Carousel3DOptions,\n\ttype Cube3DOptions,\n\ttype CubeFaceConfig,\n\ttype CubeFaceInput,\n\ttype Cylinder3DOptions,\n\ttype ExtrudedText3DOptions,\n\ttype ExtrudeShape3DOptions,\n\ttype Grid3DOptions,\n\ttype Icosphere3DOptions,\n\ttype Instances3DOptions,\n\ttype InstanceTransform3D,\n\ttype Lathe3DOptions,\n\tLayer3D,\n\ttype Line3DOptions,\n\ttype Plane3DOptions,\n\ttype Points3DOptions,\n\ttype Polyhedron3DOptions,\n\ttype Primitive3DNodeOptions,\n\ttype Prism3DOptions,\n\ttype Pyramid3DOptions,\n\ttype Ring3DOptions,\n\ttype RoundedBox3DOptions,\n\ttype Shape3DContainer,\n\ttype Shard3DOptions,\n\ttype SolidShape3DNode,\n\ttype Sphere3DOptions,\n\ttype Surface3DOptions,\n\ttype Text3DOptions,\n\ttype Torus3DOptions,\n\ttype Tube3DOptions,\n} from \"./shapes3d.js\";\nexport { type StyleName, Styles } from \"./styles.js\";\nexport type { Swarm3DOptions } from \"./swarm3d.js\";\nexport {\n\ttype SceneSequenceOptions,\n\ttype SequenceEntry,\n\ttype SequenceNode,\n\tTransition,\n\ttype TransitionDirection,\n\ttype TransitionSpec,\n} from \"./transitions.js\";\n\nexport interface CompositionOptions {\n\twidth: number;\n\theight: number;\n\tfps?: number;\n\tdurationMs?: number;\n\tdurationFrames?: number;\n\tbackgroundColor?: string;\n\tfonts?: string[];\n\tsignals?: Record<string, unknown>;\n\t/**\n\t * Smooth the edges of 3D meshes (extruded text, models) with 4x MSAA.\n\t * Default true; set false to save ~60-125 MB of GPU memory at 1080p.\n\t */\n\tantialias3d?: boolean;\n}\n\n/**\n * Fluent builder for single clips and chained visual/audio effect pipelines.\n */\nexport class Media {\n\tpublic readonly virtualMedia: VirtualMediaData;\n\n\tconstructor(source: MediaSourceInput, type: DataType = \"Video\") {\n\t\tthis.virtualMedia = createVirtualMedia(source, type);\n\t}\n\n\tstatic video(source: MediaSourceInput, meta?: Partial<MediaMetadata>): Media {\n\t\tconst m = new Media(source, \"Video\");\n\t\tif (meta) Object.assign(m.virtualMedia.metadata, meta);\n\t\treturn m;\n\t}\n\n\tstatic image(source: MediaSourceInput, meta?: Partial<MediaMetadata>): Media {\n\t\tconst m = new Media(source, \"Image\");\n\t\tif (meta) Object.assign(m.virtualMedia.metadata, meta);\n\t\treturn m;\n\t}\n\n\tstatic lottie(\n\t\tsource: MediaSourceInput,\n\t\tmeta?: Partial<MediaMetadata>,\n\t): Media {\n\t\tconst m = new Media(source, \"Lottie\");\n\t\tif (meta) Object.assign(m.virtualMedia.metadata, meta);\n\t\treturn m;\n\t}\n\n\tstatic audio(source: MediaSourceInput, meta?: Partial<MediaMetadata>): Media {\n\t\tconst m = new Media(source, \"Audio\");\n\t\tif (meta) Object.assign(m.virtualMedia.metadata, meta);\n\t\treturn m;\n\t}\n\n\t/**\n\t * Appends any Effect instance or shader operation onto the current media AST.\n\t */\n\tpublic apply<TProps extends object>(effect: Effect<TProps>): Media;\n\tpublic apply<\n\t\tTConfig extends Record<string, unknown> = Record<string, unknown>,\n\t>(op: string, config?: TConfig): Media;\n\tpublic apply(\n\t\teffectOrOp: Effect<object> | string,\n\t\tconfig: Record<string, unknown> = {},\n\t): Media {\n\t\tlet opPayload: Record<string, unknown>;\n\t\tif (\n\t\t\teffectOrOp instanceof Effect ||\n\t\t\t(typeof effectOrOp === \"object\" &&\n\t\t\t\teffectOrOp !== null &&\n\t\t\t\t\"op\" in effectOrOp)\n\t\t) {\n\t\t\topPayload = (effectOrOp as Effect<object>).toOperation();\n\t\t} else {\n\t\t\topPayload = {\n\t\t\t\top: effectOrOp,\n\t\t\t\t...config,\n\t\t\t};\n\t\t}\n\n\t\tconst nextVM = appendOperation(this.virtualMedia, {\n\t\t\t...opPayload,\n\t\t\tdataType: this.virtualMedia.operation.dataType,\n\t\t} as MediaOperation);\n\t\treturn new Media(nextVM);\n\t}\n\n\t/**\n\t * Returns the underlying VirtualMediaData AST node ready for rendering.\n\t */\n\tpublic toVirtualMedia(): VirtualMediaData {\n\t\treturn this.virtualMedia;\n\t}\n\n\t/**\n\t * Renders a single frame from this media pipeline to a PNG Buffer.\n\t * Can render either by timestamp in milliseconds (`atMs`) or by frame index (`frame`).\n\t */\n\tpublic async renderFrame(\n\t\toptions: {\n\t\t\tatMs?: number;\n\t\t\tframe?: number;\n\t\t\tfps?: number;\n\t\t\trenderer?: HeadlessMediaRenderer;\n\t\t} = {},\n\t): Promise<Buffer> {\n\t\tconst renderer = options.renderer ?? new HeadlessMediaRenderer();\n\t\treturn renderer.renderFrame(this.virtualMedia, options);\n\t}\n\n\tget fps(): number | undefined {\n\t\treturn this.virtualMedia.metadata?.fps ?? undefined;\n\t}\n\n\tget durationMs(): number | undefined {\n\t\treturn this.virtualMedia.metadata?.durationMs ?? undefined;\n\t}\n\n\tget width(): number | undefined {\n\t\treturn this.virtualMedia.metadata?.width ?? undefined;\n\t}\n\n\tget height(): number | undefined {\n\t\treturn this.virtualMedia.metadata?.height ?? undefined;\n\t}\n\n\t/**\n\t * Renders an image grid of sequential frames across a given frame or millisecond range.\n\t * Ideal for automated visual inspection of animation motion, easing curves, and layout stability.\n\t */\n\tpublic async renderFrameGrid(\n\t\toptions: FrameGridOptions = {},\n\t): Promise<Buffer> {\n\t\treturn renderFrameGrid(this, options);\n\t}\n\n\t/**\n\t * Renders this media pipeline into an MP4/WebM video file with audio.\n\t */\n\tpublic async renderVideo(\n\t\toutputPathOrOptions: string | RenderVideoOptions = {},\n\t\toptions: RenderVideoOptions = {},\n\t): Promise<RenderVideoResult> {\n\t\tconst opts =\n\t\t\ttypeof outputPathOrOptions === \"string\"\n\t\t\t\t? { ...options, outputPath: outputPathOrOptions }\n\t\t\t\t: outputPathOrOptions;\n\t\tconst renderer = opts.renderer ?? new HeadlessMediaRenderer();\n\t\tconst result = await renderer.renderVideo(this.virtualMedia, opts);\n\t\treturn deliverToOutputPath(result, opts.outputPath);\n\t}\n}\n\n/**\n * Copies a rendered temp file to `outputPath` and drops the temp, so the\n * returned `filePath` is where the video actually lives.\n */\nasync function deliverToOutputPath(\n\tresult: RenderVideoResult,\n\toutputPath: string | undefined,\n): Promise<RenderVideoResult> {\n\tif (!outputPath) return result;\n\tconst target = path.resolve(outputPath);\n\tawait fs.mkdir(path.dirname(target), { recursive: true });\n\tawait fs.copyFile(result.filePath, target);\n\tawait result.cleanup();\n\treturn { ...result, filePath: target, cleanup: async () => {} };\n}\n\nexport interface RenderVideoOptions {\n\tcodec?: string;\n\taudioCodec?: string;\n\tquality?: string;\n\tconcurrency?: number;\n\t/**\n\t * Depth of the DMA staging ring used to overlap GPU rendering with hardware\n\t * encoding (default 2, clamped 2–8). A deeper ring hides more encoder\n\t * latency at the cost of VRAM (~8.3MB/slot at 1080p RGBA). Also settable\n\t * via `FRAMEFIELDS_RING_CAPACITY`.\n\t */\n\tringCapacity?: number;\n\toutputPath?: string;\n\trenderer?: HeadlessMediaRenderer;\n\t/**\n\t * Check the output while it renders and return the findings as `qa`:\n\t * dropped, black or frozen frames, loudness (LUFS), clipping, silence and\n\t * document warnings such as truncated animations. `true` uses defaults;\n\t * pass thresholds (e.g. `{ targetLufs: -14 }`) to tighten them.\n\t */\n\tqa?: boolean | VideoQaOptions;\n\t/**\n\t * Stops the render between frames. The promise rejects with\n\t * `signal.reason` and no file is left behind.\n\t */\n\tsignal?: AbortSignal;\n\t/**\n\t * Called as the render moves through its phases: \"prepare\", each frame\n\t * (\"render\"), \"audio\" (per clip mixed), \"audio-encode\", \"mux\", \"convert\"\n\t * (GIF only) and \"done\". The engine logs the same phases on its own.\n\t */\n\tonProgress?: (progress: RenderProgress) => void;\n\t/**\n\t * Renders only frames `start` (inclusive) to `end` (exclusive): one chunk\n\t * of a render split across workers. Chunks start on a keyframe with\n\t * timestamps from 0; join them with `stitchChunks` from\n\t * `framefields/renderer`. Effects that carry state between frames\n\t * (trails, particles, datamosh) rebuild it before `start`.\n\t */\n\tframes?: { start: number; end: number };\n\t/**\n\t * `false` writes no audio track, as for chunks: render the timeline's\n\t * audio once with `codec: \"aac\"` and pass it to `stitchChunks`.\n\t */\n\taudio?: boolean;\n}\n\nexport interface RenderVideoResult {\n\tfilePath: string;\n\tcleanup: () => Promise<void>;\n\t/** Present when rendered with `qa`; print it with `formatQaReport` */\n\tqa?: VideoQaReport;\n}\n\nexport interface SubjectSandwichOptions {\n\treadonly source: string | MediaNode;\n\treadonly subject?: MaskTrackSignals | ObjectTrackSignals;\n\treadonly behind: readonly LayoutNode[];\n\treadonly feather?: number;\n\treadonly fit?: \"cover\" | \"contain\" | \"fill\";\n\treadonly variant?: VisionProps[\"variant\"];\n\treadonly confidence?: number;\n\treadonly keyBackground?: boolean;\n\treadonly backgroundKeyThreshold?: number;\n\treadonly muted?: boolean;\n\treadonly volume?: number;\n}\n\nexport interface SmartFramingOptions {\n\treadonly source: string | MediaNode;\n\treadonly targetAspect?: number;\n\treadonly sourceAspect?: number;\n\treadonly target: ObjectTrackSignals | MaskTrackSignals;\n\treadonly damping?: number;\n\treadonly leadHeadroom?: number;\n\treadonly fit?: \"cover\" | \"contain\" | \"fill\";\n\treadonly variant?: VisionProps[\"variant\"];\n\treadonly muted?: boolean;\n\treadonly volume?: number;\n}\n\nexport interface SubjectOutlineOptions {\n\treadonly source?: string | MediaNode;\n\treadonly color?: string;\n\treadonly width?: number;\n\treadonly blur?: number;\n\treadonly pulseSignal?: ProgrammaticSignal | Signal<number>;\n\treadonly muted?: boolean;\n\treadonly volume?: number;\n}\n\n/**\n * High-level programmatic builder for multi-layer Framefields compositions.\n */\nexport class Composition {\n\tpublic width: number;\n\tpublic height: number;\n\tpublic fps: number;\n\tpublic durationMs?: number;\n\tpublic backgroundColor: string;\n\tpublic antialias3d?: boolean;\n\tpublic fonts: string[];\n\tpublic children: LayoutNode[] = [];\n\tpublic audioTracks: MediaNode[] = [];\n\tpublic signals: Record<string, unknown> = {};\n\tprivate _frameHooks: Array<(ctx: FrameContext) => void> = [];\n\tprivate _prepareHooks: Array<(ctx: FrameContext) => Promise<void> | void> =\n\t\t[];\n\tprivate readonly _clipVision = new Map<string, ClipVision>();\n\tprivate _mediaSignals?: MediaSignalTimeline;\n\tprivate _visionConfig?: VisionProps;\n\tprivate _visionBundle?: VisionBundle;\n\tprivate _effects: AnyEffect[] = [];\n\n\t/**\n\t * Applies a whole-composition post-processing effect or vision pipeline.\n\t */\n\tpublic apply(effect: AnyEffect): this {\n\t\tif (effect instanceof Vision) {\n\t\t\tthis.withVision(effect);\n\t\t\treturn this;\n\t\t}\n\t\tthis._effects.push(effect);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Runs vision on the whole composition — the rendered frame (composition, blur, crop,\n\t * anything upstream) is the inference input. Models are LAZY: nothing downloads until\n\t * the first frame actually runs a task.\n\t * Returns the reactive VisionBundle (objects / masks / pose / classes signals).\n\t */\n\tpublic withVision(config: VisionProps | Vision = {}): VisionBundle {\n\t\tthis._visionBundle ??= new VisionBundle({\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tfps: this.fps,\n\t\t});\n\t\tconst rawConfig =\n\t\t\tconfig instanceof Vision ? (config.config as VisionProps) : config;\n\t\tthis._visionConfig = {\n\t\t\t...rawConfig,\n\t\t\tvisionBundle: this._visionBundle,\n\t\t};\n\t\treturn this._visionBundle;\n\t}\n\n\t/**\n\t * Vision for a clip, analysed per frame on demand and shared by everything\n\t * that reads it (see {@link ClipVision}): `comp.vision(\"dancer.mp4\").person`\n\t * gives pose keypoints and a silhouette at any frame. Each frame is\n\t * analysed just before it renders, so nothing runs up front. Results\n\t * persist on disk in Node. The same clip and options return one instance.\n\t */\n\tpublic vision(\n\t\tsourceOrLayer: string | MediaNode,\n\t\toptions: ClipVisionOptions = {},\n\t): ClipVision {\n\t\tconst source =\n\t\t\ttypeof sourceOrLayer === \"string\"\n\t\t\t\t? sourceOrLayer\n\t\t\t\t: (sourceOrLayer.src ?? sourceOrLayer.inputHandleId);\n\t\tif (typeof sourceOrLayer !== \"string\") {\n\t\t\t// A clip is analysed frame by frame, so its signal time is live.\n\t\t\tconst vm = this.toVirtualMedia({\n\t\t\t\tresolveMediaSignal: this.mediaSignalResolver(true),\n\t\t\t});\n\t\t\tconst layer = collectNodeOps(vm.children).find(\n\t\t\t\t(node) =>\n\t\t\t\t\t(node.operation as unknown as { id?: string }).id ===\n\t\t\t\t\tsourceOrLayer.id,\n\t\t\t);\n\t\t\tif (!layer)\n\t\t\t\tthrow new Error(\n\t\t\t\t\t\"Add the media layer to the composition before calling comp.vision(layer)\",\n\t\t\t\t);\n\t\t\toptions = {\n\t\t\t\tstartFrame: layer.operation.startFrame ?? sourceOrLayer.startFrame,\n\t\t\t\ttrimStartSec: sourceOrLayer.trimStartSec,\n\t\t\t\ttimeRemap: (\n\t\t\t\t\tlayer.operation as unknown as { timeRemap?: ResolvedMediaTimeRemap }\n\t\t\t\t).timeRemap,\n\t\t\t\tdurationFrames: sourceOrLayer.durationFrames,\n\t\t\t\t...options,\n\t\t\t};\n\t\t}\n\t\tconst key = `${source}\\u0000${JSON.stringify({ ...options, timeRemap: remapKey(options.timeRemap) })}`;\n\t\tlet clip = this._clipVision.get(key);\n\t\tif (!clip) {\n\t\t\tclip = new ClipVision(source, this.fps, options);\n\t\t\tthis._clipVision.set(key, clip);\n\t\t}\n\t\treturn clip;\n\t}\n\n\t/**\n\t * @internal Analyses every `comp.vision` clip up to a composition frame\n\t * (frames already analysed are skipped), so consumers that step frame by\n\t * frame — physics, particles — always find every frame before it.\n\t */\n\tpublic async prepareVision(frame: number): Promise<void> {\n\t\tthis.linkClipLayers();\n\t\tawait Promise.all(\n\t\t\t[...this._clipVision.values()].map((clip) => clip.ready(0, frame)),\n\t\t);\n\t}\n\n\t/**\n\t * Points matte-family and skeleton `withVision` layers at the `comp.vision`\n\t * clip they show, so the cutout reuses that clip's per-frame subject and the\n\t * skeleton draws its matched pose, instead of analysing the frame again\n\t * during render. Only layers whose settings would give the same subject are\n\t * linked; the rest keep their own pass.\n\t */\n\tprivate linkClipLayers(): void {\n\t\tif (this._clipVision.size === 0) return;\n\t\tlet layers:\n\t\t\t| Map<\n\t\t\t\t\tstring | undefined,\n\t\t\t\t\t{ startFrame?: number; timeRemap?: ResolvedMediaTimeRemap }\n\t\t\t >\n\t\t\t| undefined;\n\t\tconst walk = (node: unknown): void => {\n\t\t\tif (!node || typeof node !== \"object\") return;\n\t\t\tconst n = node as {\n\t\t\t\tid?: string;\n\t\t\t\tkind?: string;\n\t\t\t\tdataType?: string;\n\t\t\t\tinputHandleId?: unknown;\n\t\t\t\tsrc?: string;\n\t\t\t\tstartFrame?: number;\n\t\t\t\ttrimStartSec?: number;\n\t\t\t\tvision?: unknown;\n\t\t\t\tchildren?: unknown;\n\t\t\t};\n\t\t\tif (\n\t\t\t\tn.kind === \"media\" &&\n\t\t\t\tn.dataType === \"Video\" &&\n\t\t\t\ttypeof n.inputHandleId === \"string\" &&\n\t\t\t\tn.vision instanceof Vision &&\n\t\t\t\t!(CLIP_SUBJECT in n.vision)\n\t\t\t) {\n\t\t\t\tlayers ??= new Map(\n\t\t\t\t\tcollectNodeOps(this.toVirtualMedia().children).map((node) => {\n\t\t\t\t\t\tconst op = node.operation as unknown as {\n\t\t\t\t\t\t\tid?: string;\n\t\t\t\t\t\t\tstartFrame?: number;\n\t\t\t\t\t\t\ttimeRemap?: ResolvedMediaTimeRemap;\n\t\t\t\t\t\t};\n\t\t\t\t\t\treturn [op.id, op];\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tconst layer = layers.get(n.id);\n\t\t\t\tconst clip = this.clipForLayer(n.src ?? n.inputHandleId, n.vision, {\n\t\t\t\t\ttrimStartSec: n.trimStartSec,\n\t\t\t\t\tstartFrame: layer?.startFrame ?? n.startFrame,\n\t\t\t\t\ttimeRemap: layer?.timeRemap,\n\t\t\t\t});\n\t\t\t\tif (clip) {\n\t\t\t\t\tif (n.vision.mode !== \"skeleton\") clip.keepSubjects();\n\t\t\t\t\tObject.defineProperty(n.vision, CLIP_SUBJECT, {\n\t\t\t\t\t\tvalue: clip,\n\t\t\t\t\t\tenumerable: false,\n\t\t\t\t\t\tconfigurable: true,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (Array.isArray(n.children)) for (const c of n.children) walk(c);\n\t\t};\n\t\tfor (const child of this.children) walk(child);\n\t}\n\n\t/** The `comp.vision` clip a matte or skeleton layer of the same source reads instead of analysing. */\n\tprivate clipForLayer(\n\t\tsource: string,\n\t\tv: Vision,\n\t\tlayer: {\n\t\t\tstartFrame?: number;\n\t\t\ttrimStartSec?: number;\n\t\t\ttimeRemap?: ResolvedMediaTimeRemap;\n\t\t},\n\t): ClipVision | undefined {\n\t\tconst mode = v.mode ?? \"passthrough\";\n\t\tconst skeleton = mode === \"skeleton\";\n\t\tif (mode !== \"matte\" && mode !== \"mask\" && mode !== \"crop\" && !skeleton)\n\t\t\treturn;\n\t\t// Anything that changes the subject, or needs results the clip lacks.\n\t\tif (\n\t\t\tv.classes !== undefined ||\n\t\t\tv.enableMatte === true ||\n\t\t\tv.visionBundle !== undefined ||\n\t\t\t(!skeleton &&\n\t\t\t\t(v.matteSource === \"selfie\" ||\n\t\t\t\t\tv.keyBackground === true ||\n\t\t\t\t\tv.enablePose === true ||\n\t\t\t\t\t(v.maskThreshold ?? 0.5) !== 0.5 ||\n\t\t\t\t\tv.featherRadius !== undefined))\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tfor (const clip of this._clipVision.values()) {\n\t\t\tconst o = clip.options;\n\t\t\tif (\n\t\t\t\tclip.source === source &&\n\t\t\t\tclip.startFrame === (layer.startFrame ?? 0) &&\n\t\t\t\tclip.trimStartSec === (layer.trimStartSec ?? 0) &&\n\t\t\t\tremapKey(o.timeRemap) === remapKey(layer.timeRemap) &&\n\t\t\t\t(o.variant ?? \"s\") === (v.variant ?? \"s\") &&\n\t\t\t\t(o.confidence ?? 0.3) === (v.confidence ?? 0.3)\n\t\t\t) {\n\t\t\t\t// A skeleton of a selected person must draw that person, never whoever is detected first.\n\t\t\t\tif (skeleton && !clip.tracksPose) {\n\t\t\t\t\tif (clip.exact)\n\t\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\t\"A skeleton layer of a prompted comp.vision clip needs `pose: true` on that clip.\",\n\t\t\t\t\t\t);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn clip;\n\t\t\t}\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * One-shot, ffmpeg-free vision analysis of a media source.\n\t *\n\t * Decodes frames through the same mediabunny pipeline the renderer uses, runs the requested\n\t * tasks lazily (only those models download), temporally tracks detections, and returns a\n\t * zod-serializable report. The decoder is released and the runner closed on completion.\n\t */\n\tpublic async analyzeVisionSequence(\n\t\tsource: string,\n\t\toptions: {\n\t\t\ttasks?: readonly VisionTask[];\n\t\t\tcategories?: readonly string[];\n\t\t\tfps?: number;\n\t\t\ttotalFrames?: number;\n\t\t\tpathStride?: number;\n\t\t\tincludeMasks?: boolean;\n\t\t\tmodelsDir?: string;\n\t\t\tbaseUrl?: string;\n\t\t\tconfidence?: number;\n\t\t\tvariant?: VisionProps[\"variant\"];\n\t\t\t/** Tracker box-association IoU. Default 0.25. */\n\t\t\tiouThreshold?: number;\n\t\t} = {},\n\t): Promise<VisionAnalysisReport> {\n\t\tconst fps = options.fps ?? this.fps;\n\t\tconst durationMs = this.durationMs ?? (await this.computeDuration());\n\t\tconst totalFrames =\n\t\t\toptions.totalFrames ?? Math.max(1, Math.round((durationMs / 1000) * fps));\n\n\t\tconst runner = VisionRunner.create({\n\t\t\tmodelsDir: options.modelsDir,\n\t\t\tbaseUrl: options.baseUrl,\n\t\t\t...(options.confidence !== undefined\n\t\t\t\t? { confidence: options.confidence }\n\t\t\t\t: {}),\n\t\t\t...(options.variant !== undefined ? { variant: options.variant } : {}),\n\t\t});\n\n\t\tconst decoder = mediaDecoderCache.getVideo(source, true);\n\t\tasync function* frameSource(): AsyncGenerator<{\n\t\t\tdata: Uint8Array;\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t}> {\n\t\t\tfor (let i = 0; i < totalFrames; i++) {\n\t\t\t\tconst frame = await decoder.getFrame(i / fps);\n\t\t\t\tif (frame?.buffer && frame.width > 0 && frame.height > 0) {\n\t\t\t\t\tyield {\n\t\t\t\t\t\tdata: frame.buffer,\n\t\t\t\t\t\twidth: frame.width,\n\t\t\t\t\t\theight: frame.height,\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\treturn await analyzeVisionFrames(frameSource(), {\n\t\t\t\trunner,\n\t\t\t\tsource,\n\t\t\t\tfps,\n\t\t\t\t...(options.tasks !== undefined ? { tasks: options.tasks } : {}),\n\t\t\t\t...(options.categories !== undefined\n\t\t\t\t\t? { categories: options.categories }\n\t\t\t\t\t: {}),\n\t\t\t\t...(options.pathStride !== undefined\n\t\t\t\t\t? { pathStride: options.pathStride }\n\t\t\t\t\t: {}),\n\t\t\t\t...(options.includeMasks !== undefined\n\t\t\t\t\t? { includeMasks: options.includeMasks }\n\t\t\t\t\t: {}),\n\t\t\t\t...(options.iouThreshold !== undefined\n\t\t\t\t\t? { iouThreshold: options.iouThreshold }\n\t\t\t\t\t: {}),\n\t\t\t});\n\t\t} finally {\n\t\t\trunner.close();\n\t\t\tdecoder.destroy();\n\t\t}\n\t}\n\n\t/**\n\t * Game-engine per-frame lifecycle hook for the composition.\n\t * Invoked before rendering each frame so scripts or agents can mutate properties and signals.\n\t */\n\tpublic onRequestFrame(callback: (ctx: FrameContext) => void): this {\n\t\tthis._frameHooks.push(callback);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Async work a frame needs before it is evaluated (vision, a live physics\n\t * world). Every render path awaits these, in order, before drawing the\n\t * frame; they may run more than once per frame, so keep them idempotent.\n\t */\n\tpublic onPrepareFrame(\n\t\tcallback: (ctx: FrameContext) => Promise<void> | void,\n\t): this {\n\t\tthis._prepareHooks.push(callback);\n\t\treturn this;\n\t}\n\n\tpublic notifyFrame(ctx: FrameContext): Promise<void> | undefined {\n\t\tconst skipped = this._mediaSignals?.framesBefore(ctx.frame) ?? [];\n\t\tif (skipped.length === 0) return this.runFrame(ctx);\n\t\t// Live signal time has no gaps: a seek forward runs the frames it skips.\n\t\treturn (async () => {\n\t\t\tfor (const frame of skipped)\n\t\t\t\tawait this.runFrame(contextAtFrame(ctx, frame));\n\t\t\tawait this.runFrame(ctx);\n\t\t})();\n\t}\n\n\tprivate runFrame(ctx: FrameContext): Promise<void> | undefined {\n\t\tfor (const hook of this._frameHooks) {\n\t\t\thook(ctx);\n\t\t}\n\t\tconst signals = this._mediaSignals;\n\t\tsignals?.advance(ctx.frame);\n\t\tif (this._clipVision.size === 0 && this._prepareHooks.length === 0) {\n\t\t\tsignals?.reach(ctx.frame);\n\t\t\treturn undefined;\n\t\t}\n\t\treturn (async () => {\n\t\t\tawait this.prepareVision(ctx.frame);\n\t\t\tfor (const hook of this._prepareHooks) await hook(ctx);\n\t\t\tsignals?.reach(ctx.frame);\n\t\t})();\n\t}\n\n\t/**\n\t * @internal Runs the frame clock through the last frame while a live\n\t * signal `timeRemap` history is incomplete, so audio can be mixed before\n\t * any frame renders (the preview does). Compile the composition first.\n\t */\n\tpublic async prepareMediaTime(): Promise<void> {\n\t\tconst durationMs = this.durationMs ?? (await this.computeDuration());\n\t\tconst last = Math.round((durationMs / 1000) * this.fps) - 1;\n\t\tif (!this._mediaSignals?.pending || last < 0) return;\n\t\tawait this.notifyFrame(\n\t\t\tcontextAtFrame(\n\t\t\t\t{\n\t\t\t\t\tframe: 0,\n\t\t\t\t\tfps: this.fps,\n\t\t\t\t\ttime: 0,\n\t\t\t\t\tduration: durationMs / 1000,\n\t\t\t\t\tdurationMs,\n\t\t\t\t\tprogress: 0,\n\t\t\t\t\tdeltaTime: 1 / this.fps,\n\t\t\t\t},\n\t\t\t\tlast,\n\t\t\t),\n\t\t);\n\t}\n\n\t/**\n\t * Resolves signal `timeRemap`s to one shared history per layer: sampled\n\t * when nothing can change a signal mid-render, recorded live otherwise.\n\t */\n\tprivate mediaSignalResolver(\n\t\tlive = this.hasFrameHooks(),\n\t\tdurationMs = this.durationMs,\n\t\tsignals = this.signals,\n\t): MediaSignalResolver {\n\t\tthis._mediaSignals ??= new MediaSignalTimeline(this.fps);\n\t\treturn this._mediaSignals.resolver({\n\t\t\tlive,\n\t\t\tcompositionDurationFrames: Math.round(\n\t\t\t\t((durationMs ?? 0) / 1000) * this.fps,\n\t\t\t),\n\t\t\tsignals,\n\t\t});\n\t}\n\n\tprivate hasFrameHooks(): boolean {\n\t\treturn (\n\t\t\tthis._frameHooks.length > 0 ||\n\t\t\tthis._prepareHooks.length > 0 ||\n\t\t\tthis._clipVision.size > 0\n\t\t);\n\t}\n\n\tconstructor(options: CompositionOptions) {\n\t\tthis.width = options.width;\n\t\tthis.height = options.height;\n\t\tthis.fps = options.fps ?? 60;\n\t\tthis.durationMs =\n\t\t\toptions.durationMs ??\n\t\t\t(options.durationFrames !== undefined\n\t\t\t\t? (options.durationFrames / this.fps) * 1000\n\t\t\t\t: undefined);\n\t\tthis.backgroundColor = options.backgroundColor ?? \"#000000\";\n\t\tthis.antialias3d = options.antialias3d;\n\t\tthis.fonts = options.fonts ?? [];\n\t\tthis.signals = options.signals ?? {};\n\t}\n\n\tpublic static create(options: CompositionOptions): Composition {\n\t\treturn new Composition(options);\n\t}\n\n\tpublic addSignal(name: string, signal: unknown): this {\n\t\tthis.signals[name] = signal;\n\t\treturn this;\n\t}\n\n\tpublic add(\n\t\tlayerOrFirst:\n\t\t\t| LayoutNode\n\t\t\t| LayoutNode[]\n\t\t\t| TensorPipeline\n\t\t\t| VisionNode\n\t\t\t| { node: unknown },\n\t\t...rest: Array<\n\t\t\t| LayoutNode\n\t\t\t| LayoutNode[]\n\t\t\t| TensorPipeline\n\t\t\t| VisionNode\n\t\t\t| { node: unknown }\n\t\t\t| LayerAnimation\n\t\t\t| { tracks: AnimationTrack[] }\n\t\t>\n\t): this {\n\t\tif (layerOrFirst instanceof TensorPipeline) {\n\t\t\tthis.children.push(layerOrFirst.toNode() as unknown as LayoutNode);\n\t\t} else if (layerOrFirst instanceof VisionNode) {\n\t\t\tthis.children.push(layerOrFirst.toNode() as unknown as LayoutNode);\n\t\t} else if (\n\t\t\tlayerOrFirst &&\n\t\t\ttypeof layerOrFirst === \"object\" &&\n\t\t\t\"node\" in layerOrFirst\n\t\t) {\n\t\t\tthis.add(\n\t\t\t\t(\n\t\t\t\t\tlayerOrFirst as {\n\t\t\t\t\t\tnode: LayoutNode | TensorPipeline | { node: unknown };\n\t\t\t\t\t}\n\t\t\t\t).node as LayoutNode,\n\t\t\t\t...rest,\n\t\t\t);\n\t\t\treturn this;\n\t\t} else if (Array.isArray(layerOrFirst)) {\n\t\t\tfor (const l of layerOrFirst) {\n\t\t\t\tthis.add(l);\n\t\t\t}\n\t\t} else {\n\t\t\tconst targetNode = layerOrFirst as LayoutNode;\n\t\t\tconst animCandidate = rest[0];\n\t\t\tif (\n\t\t\t\tanimCandidate &&\n\t\t\t\t!(animCandidate instanceof TensorPipeline) &&\n\t\t\t\t!Array.isArray(animCandidate) &&\n\t\t\t\t(animCandidate instanceof LayerAnimation || \"tracks\" in animCandidate)\n\t\t\t) {\n\t\t\t\ttargetNode.animation =\n\t\t\t\t\tanimCandidate instanceof LayerAnimation\n\t\t\t\t\t\t? animCandidate.toSpec()\n\t\t\t\t\t\t: animCandidate;\n\t\t\t\tthis.children.push(targetNode);\n\t\t\t\treturn this;\n\t\t\t}\n\t\t\tthis.children.push(targetNode);\n\t\t}\n\n\t\tfor (const item of rest) {\n\t\t\tif (item && !(item instanceof LayerAnimation) && !(\"tracks\" in item)) {\n\t\t\t\tthis.add(\n\t\t\t\t\titem as\n\t\t\t\t\t\t| LayoutNode\n\t\t\t\t\t\t| LayoutNode[]\n\t\t\t\t\t\t| TensorPipeline\n\t\t\t\t\t\t| { node: unknown },\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn this;\n\t}\n\n\tpublic addAudio(track: MediaNode): this {\n\t\tthis.audioTracks.push(track);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Turnkey \"Text Behind Subject\" (\"Sandwich\") Primitive.\n\t * Lowers into:\n\t * 1. Bottom Layer: Full background video plate\n\t * 2. Middle Layer: User-supplied `behind` nodes\n\t * 3. Top Layer: Subject cutout video with continuous matte alpha registered at identical coordinates\n\t */\n\tpublic addSubjectSandwich(options: SubjectSandwichOptions): this {\n\t\tconst src =\n\t\t\ttypeof options.source === \"string\"\n\t\t\t\t? options.source\n\t\t\t\t: (options.source.inputHandleId ?? \"\");\n\t\tconst fit = options.fit ?? \"cover\";\n\t\tconst feather = options.feather ?? 4;\n\t\tconst featherVal = feather > 1 ? feather / 100 : feather;\n\t\tconst variant = options.variant ?? \"s\";\n\n\t\t// 1. Bottom Layer: Full background video plate\n\t\tconst bottomPlate = Layer.video(src, {\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tposition: \"absolute\",\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tfit,\n\t\t\tmuted: options.muted ?? false,\n\t\t\tvolume: options.muted ? 0 : (options.volume ?? 1),\n\t\t});\n\t\tthis.add(bottomPlate);\n\n\t\t// 2. Middle Layer: User-supplied `behind` nodes\n\t\tfor (const node of options.behind) {\n\t\t\tthis.add(node);\n\t\t}\n\n\t\t// 3. Top Layer: Subject cutout video with continuous matte alpha registered at identical coordinates\n\t\tconst topPlate = Layer.video(src, {\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tposition: \"absolute\",\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\tfit,\n\t\t\tmuted: true,\n\t\t\tvolume: 0,\n\t\t}).withVision({\n\t\t\tmode: \"matte\",\n\t\t\tenableSegmentation: true,\n\t\t\tvariant,\n\t\t\tconfidence: options.confidence ?? 0.25,\n\t\t\tfeatherRadius: featherVal,\n\t\t\tkeyBackground: options.keyBackground ?? true,\n\t\t\tbackgroundKeyThreshold: options.backgroundKeyThreshold,\n\t\t});\n\t\tthis.add(topPlate);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Dynamic Smart Re-Framing (16:9 → 9:16 Auto-Crop).\n\t * Automatically transforms landscape footage into vertical shorts/reels by framing the\n\t * tracked subject with smooth camera physics and lead headroom.\n\t */\n\tpublic addSmartFraming(options: SmartFramingOptions): this {\n\t\tconst src =\n\t\t\ttypeof options.source === \"string\"\n\t\t\t\t? options.source\n\t\t\t\t: (options.source.inputHandleId ?? \"\");\n\t\tconst damping = Math.max(0, Math.min(0.99, options.damping ?? 0.8));\n\t\tconst headroom = options.leadHeadroom ?? 0.18;\n\t\tconst compW = this.width;\n\t\tconst compH = this.height;\n\n\t\tconst sourceAspect = options.sourceAspect ?? 16 / 9;\n\t\tconst compAspect = compW / compH;\n\n\t\t// Calculate canvas coverage dimensions to avoid black bars during pan\n\t\tconst plateWidth =\n\t\t\tcompAspect < sourceAspect ? Math.round(compH * sourceAspect) : compW;\n\t\tconst plateHeight =\n\t\t\tcompAspect < sourceAspect ? compH : Math.round(compW / sourceAspect);\n\n\t\tconst minOffsetX = compW - plateWidth; // <= 0\n\t\tconst minOffsetY = compH - plateHeight; // <= 0\n\n\t\tconst targetObj = options.target as unknown as {\n\t\t\tcenter?: {\n\t\t\t\tx?: ProgrammaticSignal;\n\t\t\t\ty?: ProgrammaticSignal;\n\t\t\t\tscreenX?: ProgrammaticSignal;\n\t\t\t\tscreenY?: ProgrammaticSignal;\n\t\t\t};\n\t\t\tbounds?: {\n\t\t\t\tx?: ProgrammaticSignal;\n\t\t\t\ty?: ProgrammaticSignal;\n\t\t\t\twidth?: ProgrammaticSignal;\n\t\t\t\theight?: ProgrammaticSignal;\n\t\t\t\tcenterX?: ProgrammaticSignal;\n\t\t\t\tcenterY?: ProgrammaticSignal;\n\t\t\t};\n\t\t};\n\n\t\tconst rawOffsetX = new ProgrammaticSignal(\n\t\t\t(ctx) => {\n\t\t\t\tif (minOffsetX >= 0) return 0;\n\t\t\t\tconst normX = targetObj.center?.x\n\t\t\t\t\t? targetObj.center.x.get(ctx)\n\t\t\t\t\t: targetObj.bounds?.centerX\n\t\t\t\t\t\t? targetObj.bounds.centerX.get(ctx) / compW\n\t\t\t\t\t\t: targetObj.center?.screenX\n\t\t\t\t\t\t\t? targetObj.center.screenX.get(ctx) / compW\n\t\t\t\t\t\t\t: 0.5;\n\t\t\t\tconst clampedNormX = Math.max(0, Math.min(1, normX));\n\t\t\t\tconst targetPx = clampedNormX * plateWidth;\n\t\t\t\tconst desired = compW / 2 - targetPx;\n\t\t\t\treturn Math.max(minOffsetX, Math.min(0, desired));\n\t\t\t},\n\t\t\t{ fps: this.fps, label: \"smart_framing_pan_x\" },\n\t\t);\n\n\t\tconst rawOffsetY = new ProgrammaticSignal(\n\t\t\t(ctx) => {\n\t\t\t\tif (minOffsetY >= 0) return 0;\n\t\t\t\tconst normY = targetObj.center?.y\n\t\t\t\t\t? targetObj.center.y.get(ctx)\n\t\t\t\t\t: targetObj.bounds?.centerY\n\t\t\t\t\t\t? targetObj.bounds.centerY.get(ctx) / compH\n\t\t\t\t\t\t: targetObj.center?.screenY\n\t\t\t\t\t\t\t? targetObj.center.screenY.get(ctx) / compH\n\t\t\t\t\t\t\t: 0.5;\n\t\t\t\tconst clampedNormY = Math.max(0, Math.min(1, normY));\n\t\t\t\tconst targetPy = clampedNormY * plateHeight;\n\t\t\t\tconst desired = compH * headroom - targetPy;\n\t\t\t\treturn Math.max(minOffsetY, Math.min(0, desired));\n\t\t\t},\n\t\t\t{ fps: this.fps, label: \"smart_framing_pan_y\" },\n\t\t);\n\n\t\t// Damped camera smoothing\n\t\tconst smoothOffsetX = new ProgrammaticSignal(\n\t\t\t(ctx) => {\n\t\t\t\tconst targetFrame = ctx.frame;\n\t\t\t\tif (targetFrame <= 0) return rawOffsetX.get(ctx);\n\t\t\t\tlet filtered = rawOffsetX.get({ ...ctx, frame: 0, time: 0 });\n\t\t\t\tconst alpha = 1.0 - damping;\n\t\t\t\tfor (let f = 1; f <= targetFrame; f++) {\n\t\t\t\t\tconst val = rawOffsetX.get({ ...ctx, frame: f, time: f / ctx.fps });\n\t\t\t\t\tfiltered = filtered + alpha * (val - filtered);\n\t\t\t\t}\n\t\t\t\treturn filtered;\n\t\t\t},\n\t\t\t{ fps: this.fps, label: \"smart_framing_smooth_x\" },\n\t\t);\n\n\t\tconst smoothOffsetY = new ProgrammaticSignal(\n\t\t\t(ctx) => {\n\t\t\t\tconst targetFrame = ctx.frame;\n\t\t\t\tif (targetFrame <= 0) return rawOffsetY.get(ctx);\n\t\t\t\tlet filtered = rawOffsetY.get({ ...ctx, frame: 0, time: 0 });\n\t\t\t\tconst alpha = 1.0 - damping;\n\t\t\t\tfor (let f = 1; f <= targetFrame; f++) {\n\t\t\t\t\tconst val = rawOffsetY.get({ ...ctx, frame: f, time: f / ctx.fps });\n\t\t\t\t\tfiltered = filtered + alpha * (val - filtered);\n\t\t\t\t}\n\t\t\t\treturn filtered;\n\t\t\t},\n\t\t\t{ fps: this.fps, label: \"smart_framing_smooth_y\" },\n\t\t);\n\n\t\tconst container = Layer.box({\n\t\t\twidth: compW,\n\t\t\theight: compH,\n\t\t\toverflow: \"hidden\",\n\t\t\tposition: \"relative\",\n\t\t});\n\n\t\tconst videoPlate = Layer.video(src, {\n\t\t\twidth: plateWidth,\n\t\t\theight: plateHeight,\n\t\t\tposition: \"absolute\",\n\t\t\tx: smoothOffsetX as unknown as number,\n\t\t\ty: smoothOffsetY as unknown as number,\n\t\t\tfit: options.fit ?? \"cover\",\n\t\t\tmuted: options.muted ?? false,\n\t\t\tvolume: options.muted ? 0 : (options.volume ?? 1),\n\t\t});\n\n\t\tif (!container.children) {\n\t\t\tcontainer.children = [];\n\t\t}\n\t\tcontainer.children.push(videoPlate);\n\t\tthis.add(container);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Subject Contour Glow & Neon Outline.\n\t * Strokes the silhouette boundary with a stylized bloom/glow and optional audio-reactive pulse.\n\t */\n\tpublic addSubjectOutline(\n\t\t_subject: MaskTrackSignals | ObjectTrackSignals,\n\t\toptions: SubjectOutlineOptions = {},\n\t): this {\n\t\tconst blur = options.blur ?? 12;\n\t\tconst compW = this.width;\n\t\tconst compH = this.height;\n\n\t\tconst pulse = options.pulseSignal;\n\t\tconst baseOpacity = pulse\n\t\t\t? new ProgrammaticSignal(\n\t\t\t\t\t(ctx) => Math.max(0, Math.min(1, Number(pulse.get(ctx)) || 0)),\n\t\t\t\t\t{ fps: this.fps, label: \"outline_pulse\" },\n\t\t\t\t)\n\t\t\t: 1.0;\n\n\t\tconst src =\n\t\t\ttypeof options.source === \"string\"\n\t\t\t\t? options.source\n\t\t\t\t: (options.source?.inputHandleId ?? \"\");\n\n\t\tconst outlineLayer = Layer.box({\n\t\t\twidth: compW,\n\t\t\theight: compH,\n\t\t\tposition: \"absolute\",\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\topacity: baseOpacity as unknown as number,\n\t\t});\n\n\t\tif (src) {\n\t\t\tconst maskVideo = Layer.video(src, {\n\t\t\t\twidth: compW,\n\t\t\t\theight: compH,\n\t\t\t\tposition: \"absolute\",\n\t\t\t\tx: 0,\n\t\t\t\ty: 0,\n\t\t\t\tfit: \"cover\",\n\t\t\t\tmuted: true,\n\t\t\t\tvolume: 0,\n\t\t\t}).withVision({\n\t\t\t\tmode: \"mask\",\n\t\t\t\tenableSegmentation: true,\n\t\t\t});\n\t\t\tif (!outlineLayer.children) {\n\t\t\t\toutlineLayer.children = [];\n\t\t\t}\n\t\t\toutlineLayer.children.push(maskVideo);\n\t\t}\n\n\t\toutlineLayer.apply(\n\t\t\tnew Blur({\n\t\t\t\tstrength: blur,\n\t\t\t\tblurType: \"Gaussian\",\n\t\t\t}),\n\t\t);\n\n\t\tthis.add(outlineLayer);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Creates an isolated, styled section of the composition or underlying source plate.\n\t * Any WebGPU effects (Blur, FilmGrain, Curves, Vignette, etc.) can be applied to this section.\n\t */\n\tpublic section(\n\t\tsourceOrTargetOrOptions?:\n\t\t\t| string\n\t\t\t| MediaNode\n\t\t\t| ObjectTrackSignals\n\t\t\t| SectionOptions,\n\t\ttargetOrOptions?: ObjectTrackSignals | SectionOptions,\n\t\toptions?: SectionOptions,\n\t): SectionNode {\n\t\tlet source: string | MediaNode | undefined;\n\t\tlet target: ObjectTrackSignals | undefined;\n\t\tlet opts: SectionOptions = {};\n\n\t\tconst isFirstTrack =\n\t\t\tsourceOrTargetOrOptions !== null &&\n\t\t\ttypeof sourceOrTargetOrOptions === \"object\" &&\n\t\t\t\"bounds\" in sourceOrTargetOrOptions;\n\n\t\tconst isFirstMedia =\n\t\t\ttypeof sourceOrTargetOrOptions === \"string\" ||\n\t\t\t(sourceOrTargetOrOptions !== null &&\n\t\t\t\ttypeof sourceOrTargetOrOptions === \"object\" &&\n\t\t\t\t(\"kind\" in sourceOrTargetOrOptions ||\n\t\t\t\t\t\"src\" in sourceOrTargetOrOptions ||\n\t\t\t\t\t\"inputHandleId\" in sourceOrTargetOrOptions));\n\n\t\tif (\n\t\t\tisFirstMedia &&\n\t\t\ttargetOrOptions &&\n\t\t\ttypeof targetOrOptions === \"object\" &&\n\t\t\t\"bounds\" in targetOrOptions\n\t\t) {\n\t\t\tsource = sourceOrTargetOrOptions as string | MediaNode;\n\t\t\ttarget = targetOrOptions as ObjectTrackSignals;\n\t\t\topts = options ?? {};\n\t\t} else if (isFirstMedia && targetOrOptions) {\n\t\t\tsource = sourceOrTargetOrOptions as string | MediaNode;\n\t\t\topts = targetOrOptions as SectionOptions;\n\t\t} else if (isFirstTrack) {\n\t\t\ttarget = sourceOrTargetOrOptions as ObjectTrackSignals;\n\t\t\topts = (targetOrOptions as SectionOptions) ?? {};\n\t\t\tsource = opts.source ?? (target.source as string | MediaNode | undefined);\n\t\t} else if (\n\t\t\tsourceOrTargetOrOptions &&\n\t\t\ttypeof sourceOrTargetOrOptions === \"object\"\n\t\t) {\n\t\t\topts = sourceOrTargetOrOptions as SectionOptions;\n\t\t\tsource = opts.source;\n\t\t}\n\n\t\tif (!source) {\n\t\t\tconst mediaChild = this.children.find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.kind === \"media\" &&\n\t\t\t\t\t(c.dataType === \"Video\" || c.dataType === \"Image\"),\n\t\t\t) as MediaNode | undefined;\n\t\t\tif (mediaChild) {\n\t\t\t\tsource = mediaChild;\n\t\t\t}\n\t\t}\n\n\t\treturn Layer.section(source ?? \"\", target ?? opts, {\n\t\t\tcompositionWidth: this.width,\n\t\t\tcompositionHeight: this.height,\n\t\t\t...opts,\n\t\t});\n\t}\n\n\t/**\n\t * Creates a section and immediately adds it to the composition layout tree.\n\t */\n\tpublic addSection(\n\t\tsourceOrTargetOrOptions?:\n\t\t\t| string\n\t\t\t| MediaNode\n\t\t\t| ObjectTrackSignals\n\t\t\t| SectionOptions,\n\t\ttargetOrOptions?: ObjectTrackSignals | SectionOptions,\n\t\toptions?: SectionOptions,\n\t): SectionNode {\n\t\tconst node = this.section(\n\t\t\tsourceOrTargetOrOptions,\n\t\t\ttargetOrOptions,\n\t\t\toptions,\n\t\t);\n\t\tthis.add(node);\n\t\treturn node;\n\t}\n\n\t/**\n\t * Dynamically calculates composition duration from the longest media or animation layer.\n\t */\n\tpublic async computeDuration(): Promise<number> {\n\t\tif (this.durationMs !== undefined) return this.durationMs;\n\t\tlet maxDurationMs = 0;\n\t\tconst mediaSources: string[] = [];\n\n\t\tfor (const node of [...this.children, ...this.audioTracks]) {\n\t\t\tif (node.kind === \"media\") {\n\t\t\t\tconst src = node.inputHandleId;\n\t\t\t\tif (\n\t\t\t\t\ttypeof src === \"string\" &&\n\t\t\t\t\t(node.dataType === \"Video\" || node.dataType === \"Audio\")\n\t\t\t\t) {\n\t\t\t\t\tmediaSources.push(src);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (typeof node.durationFrames === \"number\") {\n\t\t\t\tconst start = typeof node.startFrame === \"number\" ? node.startFrame : 0;\n\t\t\t\tconst durMs = ((start + node.durationFrames) / this.fps) * 1000;\n\t\t\t\tif (durMs > maxDurationMs) maxDurationMs = durMs;\n\t\t\t}\n\t\t}\n\n\t\tfor (const src of mediaSources) {\n\t\t\ttry {\n\t\t\t\tconst input = await inputStore.acquire(src);\n\t\t\t\tconst sec = await input.computeDuration();\n\t\t\t\tif (Number.isFinite(sec) && sec > 0) {\n\t\t\t\t\tconst ms = Math.round(sec * 1000);\n\t\t\t\t\tif (ms > maxDurationMs) maxDurationMs = ms;\n\t\t\t\t}\n\t\t\t} catch (_) {}\n\t\t}\n\n\t\treturn maxDurationMs > 0 ? maxDurationMs : 5000;\n\t}\n\n\tpublic async registerFont(\n\t\toptionsOrFamilyOrSource: RegisterFontOptions | string,\n\t\tsource?: string | Uint8Array,\n\t): Promise<this> {\n\t\tconst reg = await FontManager.register(optionsOrFamilyOrSource, source);\n\t\tif (reg.filePath && !this.fonts.includes(reg.filePath)) {\n\t\t\tthis.fonts.push(reg.filePath);\n\t\t}\n\t\treturn this;\n\t}\n\n\t/** Sets the color emoji font; see {@link FontManager.registerEmojiFont}. */\n\tpublic async registerEmojiFont(source: string | Uint8Array): Promise<this> {\n\t\tawait FontManager.registerEmojiFont(source);\n\t\treturn this;\n\t}\n\n\tpublic toSpec(): CompositorProgramConfig {\n\t\tconst layoutItems: LayoutNode[] = [...this.children, ...this.audioTracks];\n\t\tconst registeredPaths = FontManager.getRegisteredFontPaths();\n\t\tconst mergedFonts = Array.from(\n\t\t\tnew Set([...this.fonts, ...registeredPaths]),\n\t\t);\n\t\treturn {\n\t\t\twidth: this.width,\n\t\t\theight: this.height,\n\t\t\tfps: this.fps,\n\t\t\tmode: \"Video\",\n\t\t\tbackgroundColor: this.backgroundColor,\n\t\t\t...(this.antialias3d !== undefined && { antialias3d: this.antialias3d }),\n\t\t\tlayout: layoutItems,\n\t\t\tfonts: mergedFonts,\n\t\t\tsignals: this.signals,\n\t\t\t...(this._effects.length > 0 && { effects: this._effects }),\n\t\t\t...(this._visionConfig && { vision: this._visionConfig }),\n\t\t\t...(this.hasFrameHooks() && {\n\t\t\t\tonRequestFrame: (ctx: FrameContext) => this.notifyFrame(ctx),\n\t\t\t}),\n\t\t} as unknown as CompositorProgramConfig;\n\t}\n\n\t/**\n\t * Compiles the composition into a VirtualMediaData AST ready for WebGPU rendering.\n\t */\n\tpublic toVirtualMedia(\n\t\toptions: Partial<CompositorToProgramOptions> = {},\n\t): VirtualMediaData {\n\t\tconst durationMs = options.durationMs ?? this.durationMs;\n\t\tconst signals = options.signals ?? this.signals;\n\t\treturn compositorToProgram(this.toSpec(), {\n\t\t\tisVideoMode: true,\n\t\t\tfps: this.fps,\n\t\t\tdurationMs,\n\t\t\tsignals,\n\t\t\tresolveMediaSignal: this.mediaSignalResolver(\n\t\t\t\tundefined,\n\t\t\t\tdurationMs,\n\t\t\t\tsignals,\n\t\t\t),\n\t\t\t...(this._effects.length > 0 && { effects: this._effects }),\n\t\t\t...(this._visionConfig && { vision: this._visionConfig }),\n\t\t\t...options,\n\t\t});\n\t}\n\n\t/**\n\t * Compiles the composition into a VirtualMediaData AST with dynamically resolved duration.\n\t */\n\tpublic async toVirtualMediaAsync(\n\t\toptions: Partial<CompositorToProgramOptions> = {},\n\t): Promise<VirtualMediaData> {\n\t\tconst durationMs =\n\t\t\toptions.durationMs ?? this.durationMs ?? (await this.computeDuration());\n\t\tthis.durationMs = durationMs;\n\t\tconst signals = options.signals ?? this.signals;\n\t\tconst vm = compositorToProgram(this.toSpec(), {\n\t\t\tisVideoMode: true,\n\t\t\tfps: this.fps,\n\t\t\tdurationMs,\n\t\t\tsignals,\n\t\t\tresolveMediaSignal: this.mediaSignalResolver(\n\t\t\t\tundefined,\n\t\t\t\tdurationMs,\n\t\t\t\tsignals,\n\t\t\t),\n\t\t\t...(this._effects.length > 0 && { effects: this._effects }),\n\t\t\t...(this._visionConfig && { vision: this._visionConfig }),\n\t\t\t...options,\n\t\t});\n\t\tawait preflightMediaTime(vm, this.fps);\n\t\treturn vm;\n\t}\n\n\t/**\n\t * Renders a single frame from the composition to a PNG Buffer.\n\t * Can render either by timestamp in milliseconds (`atMs`) or by frame index (`frame`).\n\t */\n\tpublic async renderFrame(\n\t\toptions: {\n\t\t\tatMs?: number;\n\t\t\tfps?: number;\n\t\t\tframe?: number;\n\t\t\trenderer?: HeadlessMediaRenderer;\n\t\t} = {},\n\t): Promise<Buffer> {\n\t\tconst { frame } = resolveFrameRequest(options, this.fps);\n\t\tif (options.fps !== undefined && options.fps !== this.fps)\n\t\t\tthrow new Error(\n\t\t\t\t`Composition fps is ${this.fps}; cannot render at fps ${options.fps}.`,\n\t\t\t);\n\n\t\t// Compile first: the frame's hooks then record its live signal time.\n\t\tconst vm = this.toVirtualMedia();\n\t\tif (this.hasFrameHooks()) {\n\t\t\tconst targetFrame = frame;\n\t\t\tawait this.notifyFrame({\n\t\t\t\tframe: targetFrame,\n\t\t\t\tfps: this.fps,\n\t\t\t\ttime: this.fps > 0 ? targetFrame / this.fps : 0,\n\t\t\t\tduration: (this.durationMs ?? 0) / 1000,\n\t\t\t\tdurationMs: this.durationMs ?? 0,\n\t\t\t\tprogress:\n\t\t\t\t\tthis.durationMs && this.durationMs > 0\n\t\t\t\t\t\t? Math.max(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tMath.min(\n\t\t\t\t\t\t\t\t\t1,\n\t\t\t\t\t\t\t\t\t((targetFrame / this.fps) * 1000) / this.durationMs,\n\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t: 0,\n\t\t\t\tdeltaTime: this.fps > 0 ? 1 / this.fps : 0,\n\t\t\t});\n\t\t}\n\t\tconst renderer = options.renderer ?? new HeadlessMediaRenderer();\n\t\treturn renderer.renderFrame(vm, {\n\t\t\tfps: this.fps,\n\t\t\tframe,\n\t\t});\n\t}\n\n\t/**\n\t * Renders an image grid of sequential frames across a given frame or millisecond range.\n\t * Ideal for automated visual inspection of animation motion, easing curves, and layout stability.\n\t */\n\tpublic async renderFrameGrid(\n\t\toptions: FrameGridOptions = {},\n\t): Promise<Buffer> {\n\t\treturn renderFrameGrid(this, options);\n\t}\n\n\t/**\n\t * Renders this composition into an MP4/WebM video file with audio.\n\t */\n\tpublic async renderVideo(\n\t\toutputPathOrOptions: string | RenderVideoOptions = {},\n\t\toptions: RenderVideoOptions = {},\n\t): Promise<RenderVideoResult> {\n\t\tconst opts =\n\t\t\ttypeof outputPathOrOptions === \"string\"\n\t\t\t\t? { ...options, outputPath: outputPathOrOptions }\n\t\t\t\t: outputPathOrOptions;\n\t\tconst renderer = opts.renderer ?? new HeadlessMediaRenderer();\n\t\tconst result = await renderer.renderVideo(this.toVirtualMedia(), opts);\n\t\tif (result.qa) {\n\t\t\t// Fold the document checks into the output checks.\n\t\t\tconst lint = this.lint();\n\t\t\tconst issues = [\n\t\t\t\t...result.qa.issues,\n\t\t\t\t...lint.map((d) => ({\n\t\t\t\t\tseverity: d.severity,\n\t\t\t\t\tcode: d.code,\n\t\t\t\t\tmessage: d.message,\n\t\t\t\t\t...(d.layerId !== undefined && { layerId: d.layerId }),\n\t\t\t\t})),\n\t\t\t];\n\t\t\tresult.qa = {\n\t\t\t\t...result.qa,\n\t\t\t\tissues,\n\t\t\t\t// Lint warnings advise; only a lint error fails the render.\n\t\t\t\tpassed: result.qa.passed && !lint.some((d) => d.severity === \"error\"),\n\t\t\t};\n\t\t}\n\t\treturn deliverToOutputPath(result, opts.outputPath);\n\t}\n\n\t/**\n\t * Checks the document for things that render without error but not as\n\t * intended: unreadable colors or gradients (drawn transparent),\n\t * low-contrast text, layers parked off-canvas, shadows on lights that\n\t * cannot cast them, physical materials without an environment, tracks that\n\t * never change. `renderVideo({ qa })` includes these automatically.\n\t */\n\tpublic lint(): RenderDiagnostic[] {\n\t\treturn lintComposition(this.toSpec(), {\n\t\t\temojiFont: FontManager.hasEmojiFont(),\n\t\t});\n\t}\n}\n\n/**\n * Layer helpers for constructing composition nodes with clean URL/path strings.\n */\n\nexport type NodeCapability = \"visual\" | \"audio\" | \"hybrid\";\n\nexport type CompatibleEffect<TCap extends NodeCapability> =\n\tTCap extends \"hybrid\"\n\t\t? AnyEffect\n\t\t: TCap extends \"visual\"\n\t\t\t? AnyVisualEffect\n\t\t\t: TCap extends \"audio\"\n\t\t\t\t? AnyAudioEffect\n\t\t\t\t: Effect<object>;\n\nexport type AnimatableNode<\n\tT extends LayoutNode = LayoutNode,\n\tTCap extends NodeCapability = \"visual\",\n> = T & {\n\tglass?: Record<string, unknown>;\n\taudioDeform?: MeshAudioDeformConfig | Record<string, unknown>;\n\tcrop?: CropProps | Crop;\n\tvision?: Vision;\n\trelighting?: NormalRelightingOptions;\n\tmatte?: { node: LayoutNode; mode?: MatteMode };\n\tdeflicker?: DeflickerOptions;\n\teffects?: CompatibleEffect<TCap>[];\n\tblurRegions?: unknown[];\n\tanimate<P extends AnimatableProp = AnimatableProp>(\n\t\t...anim: (\n\t\t\t| ([AnimatableProp] extends [P]\n\t\t\t\t\t? LayerAnimation\n\t\t\t\t\t: LayerAnimation<P & AnimatablePropsFor<T>>)\n\t\t\t| {\n\t\t\t\t\ttracks: AnimationTrack<\n\t\t\t\t\t\t[AnimatableProp] extends [P]\n\t\t\t\t\t\t\t? AnimatableProp\n\t\t\t\t\t\t\t: P & AnimatablePropsFor<T>\n\t\t\t\t\t>[];\n\t\t\t }\n\t\t\t| (\n\t\t\t\t\t| ([AnimatableProp] extends [P]\n\t\t\t\t\t\t\t? LayerAnimation\n\t\t\t\t\t\t\t: LayerAnimation<P & AnimatablePropsFor<T>>)\n\t\t\t\t\t| {\n\t\t\t\t\t\t\ttracks: AnimationTrack<\n\t\t\t\t\t\t\t\t[AnimatableProp] extends [P]\n\t\t\t\t\t\t\t\t\t? AnimatableProp\n\t\t\t\t\t\t\t\t\t: P & AnimatablePropsFor<T>\n\t\t\t\t\t\t\t>[];\n\t\t\t\t\t }\n\t\t\t )[]\n\t\t)[]\n\t): AnimatableNode<T, TCap>;\n\tpinToLandmark(\n\t\ttarget:\n\t\t\t| LandmarkCoordinateSignals\n\t\t\t| {\n\t\t\t\t\tx: number;\n\t\t\t\t\ty: number;\n\t\t\t\t\tz?: number;\n\t\t\t\t\tscreenX?: number;\n\t\t\t\t\tscreenY?: number;\n\t\t\t },\n\t\toptions?: PinToLandmarkOptions,\n\t): AnimatableNode<T, TCap>;\n\tpinToObject(\n\t\ttarget:\n\t\t\t| ObjectTrackSignals\n\t\t\t| LandmarkCoordinateSignals\n\t\t\t| {\n\t\t\t\t\tx: number;\n\t\t\t\t\ty: number;\n\t\t\t\t\tz?: number;\n\t\t\t\t\tscreenX?: number;\n\t\t\t\t\tscreenY?: number;\n\t\t\t },\n\t\toptions?: PinToObjectOptions,\n\t): AnimatableNode<T, TCap>;\n\t/**\n\t * Track matte: `matte` (any layer) masks this one by its alpha or\n\t * brightness. It is laid out like a sibling (same parent) and timed with\n\t * this node; with no x/y/width/height it covers this node's box. Animate\n\t * the matte for wipes and reveals: text through a sliding box, video\n\t * inside type, an iris circle.\n\t */\n\twithMatte(matte: LayoutNode, mode?: MatteMode): AnimatableNode<T, TCap>;\n\t/** Alias of {@link withMatte}. */\n\twithMask(mask: LayoutNode, mode?: MatteMode): AnimatableNode<T, TCap>;\n\twithPbrGlass(options?: Record<string, unknown>): AnimatableNode<T, TCap>;\n\tdeformWithAudio(\n\t\tconfig?: MeshAudioDeformConfig | Record<string, unknown>,\n\t): AnimatableNode<T, TCap>;\n\twithCrop(cropConfig: CropProps | Crop): AnimatableNode<T, TCap>;\n\t/** Runs vision on this node's rendered output (see `Vision` for options and modes). */\n\twithVision(config?: VisionProps | Vision): AnimatableNode<T, TCap>;\n\twithRelighting(options?: NormalRelightingOptions): AnimatableNode<T, TCap>;\n\trelight(options?: NormalRelightingOptions): AnimatableNode<T, TCap>;\n\twithDeflicker(options?: DeflickerOptions): AnimatableNode<T, TCap>;\n\tapply(effect: CompatibleEffect<TCap>): AnimatableNode<T, TCap>;\n\twithEffect(effect: CompatibleEffect<TCap>): AnimatableNode<T, TCap>;\n\twithEffects(effects: CompatibleEffect<TCap>[]): AnimatableNode<T, TCap>;\n\tsection(\n\t\ttargetOrOptions?: ObjectTrackSignals | SectionOptions,\n\t\toptions?: SectionOptions,\n\t): SectionNode;\n\tblurRegion(\n\t\ttrackTarget: ObjectTrackSignals,\n\t\toptions?: Partial<BlurProps>,\n\t): AnimatableNode<T, TCap>;\n\twithBlurRegion(\n\t\ttrackTarget: ObjectTrackSignals,\n\t\toptions?: Partial<BlurProps>,\n\t): AnimatableNode<T, TCap>;\n};\n\nfunction withAnimation<\n\tT extends LayoutNode,\n\tTCap extends NodeCapability = \"visual\",\n>(node: T): AnimatableNode<T, TCap> {\n\tconst target = node as AnimatableNode<T, TCap>;\n\t// Animation builders are structurally valid inputs, but carry enumerable\n\t// authoring defaults that are not fields of the strict program schema.\n\tif (target.animation instanceof LayerAnimation)\n\t\ttarget.animation = target.animation.toSpec();\n\tObject.defineProperty(target, \"animate\", {\n\t\tvalue: (\n\t\t\t...anims: (\n\t\t\t\t| LayerAnimation\n\t\t\t\t| { tracks: AnimationTrack[] }\n\t\t\t\t| LayerAnimation[]\n\t\t\t)[]\n\t\t) => {\n\t\t\t// Every call layers onto what is already there: keyframe tracks on\n\t\t\t// the same prop merge (a later key wins on a shared frame).\n\t\t\tconst incoming = anims\n\t\t\t\t.flat()\n\t\t\t\t.flatMap((a) =>\n\t\t\t\t\ta instanceof LayerAnimation\n\t\t\t\t\t\t? a.tracks\n\t\t\t\t\t\t: ((a as { tracks?: AnimationTrack[] }).tracks ?? []),\n\t\t\t\t);\n\t\t\tconst current = target.animation as\n\t\t\t\t| { tracks?: AnimationTrack[]; frameStep?: number }\n\t\t\t\t| undefined;\n\t\t\tconst existing = current?.tracks ?? [];\n\t\t\t// The last `.stepped()` wins; stepping applies to the whole layer.\n\t\t\tconst frameStep =\n\t\t\t\tanims\n\t\t\t\t\t.flat()\n\t\t\t\t\t.map((a) => (a as { frameStep?: number }).frameStep)\n\t\t\t\t\t.filter((n): n is number => n !== undefined)\n\t\t\t\t\t.at(-1) ?? current?.frameStep;\n\t\t\ttarget.animation = {\n\t\t\t\ttracks: mergeAnimationTracks([...existing, ...incoming]),\n\t\t\t\t...(frameStep !== undefined && frameStep > 1 && { frameStep }),\n\t\t\t};\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"pinToLandmark\", {\n\t\tvalue: (\n\t\t\tlandmarkTarget:\n\t\t\t\t| LandmarkCoordinateSignals\n\t\t\t\t| {\n\t\t\t\t\t\tx: number;\n\t\t\t\t\t\ty: number;\n\t\t\t\t\t\tz?: number;\n\t\t\t\t\t\tscreenX?: number;\n\t\t\t\t\t\tscreenY?: number;\n\t\t\t\t },\n\t\t\toptions?: PinToLandmarkOptions,\n\t\t) => {\n\t\t\tpinNodeToLandmark(\n\t\t\t\ttarget as unknown as { x?: unknown; y?: unknown; z?: unknown },\n\t\t\t\tlandmarkTarget,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"pinToObject\", {\n\t\tvalue: (\n\t\t\tobjectTarget:\n\t\t\t\t| ObjectTrackSignals\n\t\t\t\t| LandmarkCoordinateSignals\n\t\t\t\t| {\n\t\t\t\t\t\tx: number;\n\t\t\t\t\t\ty: number;\n\t\t\t\t\t\tz?: number;\n\t\t\t\t\t\tscreenX?: number;\n\t\t\t\t\t\tscreenY?: number;\n\t\t\t\t },\n\t\t\toptions?: PinToObjectOptions,\n\t\t) => {\n\t\t\tpinNodeToObject(\n\t\t\t\ttarget as unknown as {\n\t\t\t\t\tx?: unknown;\n\t\t\t\t\ty?: unknown;\n\t\t\t\t\tz?: unknown;\n\t\t\t\t\twidth?: unknown;\n\t\t\t\t\theight?: unknown;\n\t\t\t\t\topacity?: unknown;\n\t\t\t\t},\n\t\t\t\tobjectTarget,\n\t\t\t\toptions,\n\t\t\t);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tconst withMatte = (matte: LayoutNode, mode?: MatteMode) => {\n\t\ttarget.matte = { node: matte, ...(mode && { mode }) };\n\t\treturn target;\n\t};\n\tfor (const name of [\"withMatte\", \"withMask\"]) {\n\t\tObject.defineProperty(target, name, {\n\t\t\tvalue: withMatte,\n\t\t\tenumerable: false,\n\t\t\twritable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\n\tObject.defineProperty(target, \"withPbrGlass\", {\n\t\tvalue: (options?: Record<string, unknown>) => {\n\t\t\ttarget.glass = options ?? {};\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"deformWithAudio\", {\n\t\tvalue: (config?: MeshAudioDeformConfig | Record<string, unknown>) => {\n\t\t\ttarget.audioDeform = config ?? {};\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withCrop\", {\n\t\tvalue: (cropConfig: CropProps | Crop) => {\n\t\t\ttarget.crop =\n\t\t\t\tcropConfig instanceof Crop ? cropConfig : new Crop(cropConfig);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withVision\", {\n\t\tvalue: (config?: VisionProps | Vision) => {\n\t\t\ttarget.vision = config instanceof Vision ? config : new Vision(config);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withRelighting\", {\n\t\tvalue: (options?: NormalRelightingOptions) => {\n\t\t\ttarget.relighting = options ?? {};\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"relight\", {\n\t\tvalue: (options?: NormalRelightingOptions) => {\n\t\t\ttarget.relighting = options ?? {};\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withDeflicker\", {\n\t\tvalue: (options?: DeflickerOptions) => {\n\t\t\ttarget.deflicker = options ?? {};\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"apply\", {\n\t\tvalue: (effect: CompatibleEffect<TCap>) => {\n\t\t\tif (!target.effects) {\n\t\t\t\ttarget.effects = [];\n\t\t\t}\n\t\t\ttarget.effects.push(effect);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withEffect\", {\n\t\tvalue: (effect: CompatibleEffect<TCap>) => {\n\t\t\tif (!target.effects) {\n\t\t\t\ttarget.effects = [];\n\t\t\t}\n\t\t\ttarget.effects.push(effect);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withEffects\", {\n\t\tvalue: (effects: CompatibleEffect<TCap>[]) => {\n\t\t\tif (!target.effects) {\n\t\t\t\ttarget.effects = [];\n\t\t\t}\n\t\t\ttarget.effects.push(...effects);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"section\", {\n\t\tvalue: (\n\t\t\ttargetOrOptions: ObjectTrackSignals | SectionOptions = {},\n\t\t\toptions?: SectionOptions,\n\t\t) => {\n\t\t\tif (\n\t\t\t\ttargetOrOptions !== null &&\n\t\t\t\ttypeof targetOrOptions === \"object\" &&\n\t\t\t\t\"bounds\" in targetOrOptions\n\t\t\t) {\n\t\t\t\treturn Layer.section(\n\t\t\t\t\ttarget as MediaNode,\n\t\t\t\t\ttargetOrOptions as ObjectTrackSignals,\n\t\t\t\t\toptions,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn Layer.section(\n\t\t\t\ttarget as MediaNode,\n\t\t\t\ttargetOrOptions as SectionOptions,\n\t\t\t);\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"blurRegion\", {\n\t\tvalue: (trackTarget: ObjectTrackSignals, options?: Partial<BlurProps>) => {\n\t\t\tconst blur = new Blur({\n\t\t\t\ttrack: trackTarget,\n\t\t\t\tstrength: options?.strength ?? 25,\n\t\t\t\tshape: options?.shape ?? \"ellipse\",\n\t\t\t\t...options,\n\t\t\t});\n\t\t\tif (!target.effects) {\n\t\t\t\ttarget.effects = [];\n\t\t\t}\n\t\t\ttarget.effects.push(blur as CompatibleEffect<TCap>);\n\t\t\treturn target;\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\tObject.defineProperty(target, \"withBlurRegion\", {\n\t\tvalue: (trackTarget: ObjectTrackSignals, options?: Partial<BlurProps>) => {\n\t\t\treturn (\n\t\t\t\ttarget as {\n\t\t\t\t\tblurRegion: (\n\t\t\t\t\t\tt: ObjectTrackSignals,\n\t\t\t\t\t\to?: Partial<BlurProps>,\n\t\t\t\t\t) => unknown;\n\t\t\t\t}\n\t\t\t).blurRegion(trackTarget, options);\n\t\t},\n\t\tenumerable: false,\n\t\twritable: true,\n\t\tconfigurable: true,\n\t});\n\n\treturn target;\n}\n\nexport const Layer = {\n\tvideo: (\n\t\tsrc: string,\n\t\toptions: Partial<MediaNode> = {},\n\t): AnimatableNode<MediaNode, \"hybrid\"> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"video\"),\n\t\t\tkind: \"media\",\n\t\t\tinputHandleId: src,\n\t\t\tdataType: \"Video\",\n\t\t\tfit: options.fit ?? \"cover\",\n\t\t\t...options,\n\t\t}),\n\timage: (\n\t\tsrc: string,\n\t\toptions: Partial<MediaNode> = {},\n\t): AnimatableNode<MediaNode, \"visual\"> => {\n\t\tif (typeof src === \"string\") {\n\t\t\tif (\n\t\t\t\t/\\.(json|lottie)(\\?.*)?$/i.test(src) ||\n\t\t\t\tsrc.startsWith(\"data:application/json\")\n\t\t\t) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Layer.image] '${src}' is a Lottie vector animation, not a static image. Use Layer.lottie('${src}', options) instead.`,\n\t\t\t\t);\n\t\t\t} else if (/\\.(mp4|mov|webm|mkv)(\\?.*)?$/i.test(src)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Layer.image] '${src}' is a video file, not a static image. Use Layer.video('${src}', options) instead.`,\n\t\t\t\t);\n\t\t\t} else if (/\\.(mp3|wav|ogg|m4a|aac)(\\?.*)?$/i.test(src)) {\n\t\t\t\tconsole.warn(\n\t\t\t\t\t`[Layer.image] '${src}' is an audio file, not a static image. Use Layer.audio('${src}', options) instead.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn withAnimation({\n\t\t\tid: options.id ?? autoId(\"img\"),\n\t\t\tkind: \"media\",\n\t\t\tinputHandleId: src,\n\t\t\tdataType: \"Image\",\n\t\t\tfit: options.fit ?? \"cover\",\n\t\t\t...options,\n\t\t});\n\t},\n\tsvg: (\n\t\tsrc: string,\n\t\toptions: Partial<MediaNode> = {},\n\t): AnimatableNode<MediaNode, \"visual\"> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"svg\"),\n\t\t\tkind: \"media\",\n\t\t\tinputHandleId: src,\n\t\t\tdataType: \"SVG\",\n\t\t\tfit: options.fit ?? \"contain\",\n\t\t\t...options,\n\t\t}),\n\tlottie: (\n\t\tsrc: string,\n\t\toptions: Partial<MediaNode> = {},\n\t): AnimatableNode<MediaNode, \"visual\"> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"lottie\"),\n\t\t\tkind: \"media\",\n\t\t\tinputHandleId: src,\n\t\t\tdataType: \"Lottie\",\n\t\t\tfit: options.fit ?? \"contain\",\n\t\t\t...options,\n\t\t}),\n\taudio: (\n\t\tsrc: string,\n\t\toptions: Partial<MediaNode> = {},\n\t): AnimatableNode<MediaNode, \"audio\"> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"audio\"),\n\t\t\tkind: \"media\",\n\t\t\tinputHandleId: src,\n\t\t\tdataType: \"Audio\",\n\t\t\tvolume: options.volume ?? 1,\n\t\t\t...options,\n\t\t}),\n\ttext: (\n\t\tcontentOrOptions:\n\t\t\t| string\n\t\t\t| TextSpan[]\n\t\t\t| (string | TextSpan)[]\n\t\t\t| Partial<TextNode>,\n\t\tmaybeOptions: Partial<TextNode> = {},\n\t): AnimatableNode<TextNode, \"visual\"> => {\n\t\tconst isArray = Array.isArray(contentOrOptions);\n\t\tconst isObj =\n\t\t\t!isArray &&\n\t\t\ttypeof contentOrOptions === \"object\" &&\n\t\t\tcontentOrOptions !== null;\n\t\tconst options = isObj\n\t\t\t? (contentOrOptions as Partial<TextNode>)\n\t\t\t: maybeOptions;\n\n\t\tlet textContent = \"\";\n\t\tlet spans: TextSpan[] | undefined = options.spans;\n\n\t\tif (isArray) {\n\t\t\tconst normalized = normalizeTextSpans(\n\t\t\t\tcontentOrOptions as (string | TextSpan)[],\n\t\t\t);\n\t\t\ttextContent = normalized.text;\n\t\t\tspans = normalized.spans;\n\t\t} else if (isObj) {\n\t\t\tif (options.spans && !options.text) {\n\t\t\t\tconst normalized = normalizeTextSpans(options.spans);\n\t\t\t\ttextContent = normalized.text;\n\t\t\t} else {\n\t\t\t\ttextContent = (options.text as string) ?? \"\";\n\t\t\t}\n\t\t} else {\n\t\t\ttextContent =\n\t\t\t\ttypeof contentOrOptions === \"string\"\n\t\t\t\t\t? contentOrOptions\n\t\t\t\t\t: String(contentOrOptions ?? \"\");\n\t\t}\n\n\t\treturn withAnimation({\n\t\t\tid: options.id ?? autoId(\"text\"),\n\t\t\tkind: \"text\",\n\t\t\tfontFamily:\n\t\t\t\toptions.fontFamily ?? FontManager.getAll()[0]?.family ?? \"Inter\",\n\t\t\tfontSize: options.fontSize ?? 48,\n\t\t\tfill: options.fill ?? \"#ffffff\",\n\t\t\t...options,\n\t\t\ttext: options.text ?? textContent,\n\t\t\tspans: options.spans ?? spans,\n\t\t});\n\t},\n\tcaption: (\n\t\tsrc: string,\n\t\toptions: Partial<MediaNode> = {},\n\t): AnimatableNode<MediaNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"caption\"),\n\t\t\tkind: \"media\",\n\t\t\tinputHandleId: src,\n\t\t\tdataType: options.dataType ?? \"Caption\",\n\t\t\tfontFamily:\n\t\t\t\toptions.fontFamily ?? FontManager.getAll()[0]?.family ?? \"Inter\",\n\t\t\tfontSize: options.fontSize ?? 48,\n\t\t\tfill: options.fill ?? \"#ffffff\",\n\t\t\t...options,\n\t\t}),\n\tshape: (\n\t\tshapeType:\n\t\t\t| \"rect\"\n\t\t\t| \"circle\"\n\t\t\t| \"ellipse\"\n\t\t\t| \"polygon\"\n\t\t\t| \"star\"\n\t\t\t| \"arrow\"\n\t\t\t| \"path\" = \"rect\",\n\t\toptions: Partial<ShapeNode> & {\n\t\t\t/** Alias of `fillColor`: a color or a CSS gradient string. */\n\t\t\tfill?: string;\n\t\t} = {},\n\t): AnimatableNode<ShapeNode> => {\n\t\t// `fill` and `fillColor` are the same thing; either may hold a\n\t\t// color or a CSS gradient. Only `fillColor` reaches the node.\n\t\tconst { fill, ...rest } = options;\n\t\treturn withAnimation({\n\t\t\tid: rest.id ?? autoId(\"shape\"),\n\t\t\tkind: \"shape\",\n\t\t\tshapeType: rest.shapeType ?? shapeType,\n\t\t\t...rest,\n\t\t\tfillColor: rest.fillColor ?? fill ?? \"#3b82f6\",\n\t\t});\n\t},\n\tflex: (options: Partial<FlexNode> = {}): AnimatableNode<FlexNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"flex\"),\n\t\t\tkind: \"flex\",\n\t\t\tdir: options.dir ?? \"column\",\n\t\t\tchildren: options.children ?? [],\n\t\t\t...options,\n\t\t}),\n\tbox: (options: Partial<BoxNode> = {}): AnimatableNode<BoxNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"box\"),\n\t\t\tkind: \"box\",\n\t\t\tbackground: options.background ?? \"transparent\",\n\t\t\tchildren: options.children ?? [],\n\t\t\t...options,\n\t\t}),\n\t/**\n\t * A GPU particle system as a layer: tens of thousands of particles\n\t * simulated in a compute shader and drawn in one call (see\n\t * {@link ParticlesOptions}). Positions are in the layer's own px; drivers\n\t * (rate, gravity, noise, attractors) are read every frame, and a\n\t * performer can push particles with `push: { person }`.\n\t */\n\tparticles: (options: ParticlesOptions): AnimatableNode<MediaNode> => {\n\t\tconst system = new Particles(options);\n\t\t// A media layer whose source is the particle op itself: it draws into\n\t\t// the layer's own texture, composited like any clip.\n\t\tconst source = {\n\t\t\tmetadata: { width: options.width, height: options.height },\n\t\t\toperation: { ...system.toOperation(), effect: system, dataType: \"Video\" },\n\t\t\tchildren: [],\n\t\t};\n\t\treturn withAnimation({\n\t\t\tid: options.id ?? autoId(\"particles\"),\n\t\t\tkind: \"media\",\n\t\t\tdataType: \"Video\",\n\t\t\tsrc: source,\n\t\t\tposition: \"absolute\",\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\twidth: options.width,\n\t\t\theight: options.height,\n\t\t\t...(options.startFrame !== undefined && {\n\t\t\t\tstartFrame: options.startFrame,\n\t\t\t}),\n\t\t\t...(options.durationFrames !== undefined && {\n\t\t\t\tdurationFrames: options.durationFrames,\n\t\t\t}),\n\t\t\t...(options.zIndex !== undefined && { zIndex: options.zIndex }),\n\t\t} as unknown as MediaNode);\n\t},\n\t/**\n\t * A procedural VFX layer (smoke, fire, rain, snow, aurora, …) drawn by\n\t * the GPU, transparent where there is no effect. Put it above or below\n\t * other layers like any clip.\n\t */\n\tvfx: (\n\t\toptions: Partial<ProceduralVFXProps> & {\n\t\t\tx?: number;\n\t\t\ty?: number;\n\t\t\twidth: number;\n\t\t\theight: number;\n\t\t\tid?: string;\n\t\t\tstartFrame?: number;\n\t\t\tdurationFrames?: number;\n\t\t\tzIndex?: number;\n\t\t},\n\t): AnimatableNode<MediaNode> => {\n\t\tconst { x, y, id, startFrame, durationFrames, zIndex, ...props } = options;\n\t\tconst vfx = new ProceduralVFX({\n\t\t\toutputType: \"Video\",\n\t\t\t...props,\n\t\t} as ProceduralVFXProps);\n\t\tconst source = {\n\t\t\tmetadata: { width: options.width, height: options.height },\n\t\t\toperation: { ...vfx.toOperation(), effect: vfx, dataType: \"Video\" },\n\t\t\tchildren: [],\n\t\t};\n\t\treturn withAnimation({\n\t\t\tid: id ?? autoId(\"vfx\"),\n\t\t\tkind: \"media\",\n\t\t\tdataType: \"Video\",\n\t\t\tsrc: source,\n\t\t\tposition: \"absolute\",\n\t\t\tx: x ?? 0,\n\t\t\ty: y ?? 0,\n\t\t\twidth: options.width,\n\t\t\theight: options.height,\n\t\t\t...(startFrame !== undefined && { startFrame }),\n\t\t\t...(durationFrames !== undefined && { durationFrames }),\n\t\t\t...(zIndex !== undefined && { zIndex }),\n\t\t} as unknown as MediaNode);\n\t},\n\tsection: (\n\t\tsource: string | MediaNode | Composition,\n\t\ttargetOrOptions: ObjectTrackSignals | SectionOptions = {},\n\t\toptions: SectionOptions = {},\n\t): SectionNode => {\n\t\tlet realSource: string | MediaNode = source as string | MediaNode;\n\t\tif (\n\t\t\tsource &&\n\t\t\ttypeof source === \"object\" &&\n\t\t\t\"toSpec\" in source &&\n\t\t\t\"children\" in source\n\t\t) {\n\t\t\tconst compMedia = (\n\t\t\t\t((source as Composition).children || []) as LayoutNode[]\n\t\t\t).find(\n\t\t\t\t(c) =>\n\t\t\t\t\tc.kind === \"media\" &&\n\t\t\t\t\t(c.dataType === \"Video\" || c.dataType === \"Image\"),\n\t\t\t) as MediaNode | undefined;\n\t\t\tif (compMedia) {\n\t\t\t\trealSource = compMedia;\n\t\t\t}\n\t\t}\n\n\t\tconst isTracked =\n\t\t\ttargetOrOptions !== null &&\n\t\t\ttypeof targetOrOptions === \"object\" &&\n\t\t\t\"bounds\" in targetOrOptions;\n\t\tconst opts: SectionOptions = isTracked\n\t\t\t? options\n\t\t\t: (targetOrOptions as SectionOptions);\n\t\tconst target = isTracked\n\t\t\t? (targetOrOptions as ObjectTrackSignals)\n\t\t\t: undefined;\n\n\t\tconst padding = opts.padding ?? 0;\n\t\tconst src =\n\t\t\ttypeof realSource === \"string\"\n\t\t\t\t? realSource\n\t\t\t\t: (realSource?.inputHandleId ??\n\t\t\t\t\t(realSource as { src?: string })?.src ??\n\t\t\t\t\t\"\");\n\t\tconst dataType =\n\t\t\ttypeof realSource === \"object\" && realSource?.dataType\n\t\t\t\t? realSource.dataType\n\t\t\t\t: \"Video\";\n\t\tconst compW =\n\t\t\t(opts.compositionWidth as number) ??\n\t\t\t(opts.compWidth as number) ??\n\t\t\t(isTracked ? (opts.width as number) : undefined) ??\n\t\t\t1920;\n\t\tconst compH =\n\t\t\t(opts.compositionHeight as number) ??\n\t\t\t(opts.compHeight as number) ??\n\t\t\t(isTracked ? (opts.height as number) : undefined) ??\n\t\t\t1080;\n\n\t\tconst effList: Effect[] = Array.isArray(opts.effects)\n\t\t\t? ([...opts.effects] as Effect[])\n\t\t\t: opts.effects\n\t\t\t\t? [opts.effects as Effect]\n\t\t\t\t: [];\n\n\t\tconst innerX = target\n\t\t\t? target.bounds.screenX.multiply(-1).add(padding)\n\t\t\t: typeof opts.x === \"number\"\n\t\t\t\t? -opts.x\n\t\t\t\t: opts.x &&\n\t\t\t\t\t\ttypeof (opts.x as { multiply?: unknown }).multiply === \"function\"\n\t\t\t\t\t? (\n\t\t\t\t\t\t\topts.x as unknown as { multiply: (n: number) => unknown }\n\t\t\t\t\t\t).multiply(-1)\n\t\t\t\t\t: 0;\n\n\t\tconst innerY = target\n\t\t\t? target.bounds.screenY.multiply(-1).add(padding)\n\t\t\t: typeof opts.y === \"number\"\n\t\t\t\t? -opts.y\n\t\t\t\t: opts.y &&\n\t\t\t\t\t\ttypeof (opts.y as { multiply?: unknown }).multiply === \"function\"\n\t\t\t\t\t? (\n\t\t\t\t\t\t\topts.y as unknown as { multiply: (n: number) => unknown }\n\t\t\t\t\t\t).multiply(-1)\n\t\t\t\t\t: 0;\n\n\t\tconst innerMedia = (\n\t\t\tdataType === \"Image\"\n\t\t\t\t? Layer.image(src, {\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\twidth: compW,\n\t\t\t\t\t\theight: compH,\n\t\t\t\t\t\tfit: opts.fit ?? \"cover\",\n\t\t\t\t\t\tx: innerX as number,\n\t\t\t\t\t\ty: innerY as number,\n\t\t\t\t\t})\n\t\t\t\t: Layer.video(src, {\n\t\t\t\t\t\tposition: \"absolute\",\n\t\t\t\t\t\twidth: compW,\n\t\t\t\t\t\theight: compH,\n\t\t\t\t\t\tfit: opts.fit ?? \"cover\",\n\t\t\t\t\t\tx: innerX as number,\n\t\t\t\t\t\ty: innerY as number,\n\t\t\t\t\t})\n\t\t).withEffects(effList);\n\n\t\tconst boxWidth = target\n\t\t\t? target.bounds.screenWidth.add(padding * 2)\n\t\t\t: opts.width !== undefined\n\t\t\t\t? opts.width\n\t\t\t\t: compW;\n\n\t\tconst boxHeight = target\n\t\t\t? target.bounds.screenHeight.add(padding * 2)\n\t\t\t: opts.height !== undefined\n\t\t\t\t? opts.height\n\t\t\t\t: compH;\n\n\t\tconst boxChildren = [innerMedia, ...(opts.children ?? [])];\n\n\t\tconst boxId =\n\t\t\topts.id ??\n\t\t\t(target ? autoId(`section-track-${target.trackId}`) : autoId(\"section\"));\n\n\t\tlet box = Layer.box({\n\t\t\tid: boxId,\n\t\t\tposition: (opts.position as \"absolute\" | \"relative\") ?? \"absolute\",\n\t\t\twidth: boxWidth as number,\n\t\t\theight: boxHeight as number,\n\t\t\tx: target ? undefined : (opts.x as number),\n\t\t\ty: target ? undefined : (opts.y as number),\n\t\t\tborderRadius: opts.borderRadius ?? 0,\n\t\t\tborderColor: opts.borderColor,\n\t\t\tborderWidth: opts.borderWidth,\n\t\t\topacity: (opts.opacity as number) ?? 1,\n\t\t\toverflow: \"hidden\",\n\t\t\tchildren: boxChildren,\n\t\t});\n\n\t\tif (target) {\n\t\t\tbox = box.pinToObject(target, {\n\t\t\t\tanchor: \"topLeft\",\n\t\t\t\toffsetX: -padding,\n\t\t\t\toffsetY: -padding,\n\t\t\t\thideWhenLost: opts.hideWhenLost ?? true,\n\t\t\t\tsmoothFrames: opts.smoothFrames,\n\t\t\t});\n\t\t}\n\n\t\tconst sectionNode = box as SectionNode;\n\t\tObject.defineProperty(sectionNode, \"innerMedia\", {\n\t\t\tvalue: innerMedia,\n\t\t\tenumerable: true,\n\t\t\twritable: false,\n\t\t});\n\t\tObject.defineProperty(sectionNode, \"effects\", {\n\t\t\tget: () => effList,\n\t\t\tenumerable: true,\n\t\t});\n\t\tObject.defineProperty(sectionNode, \"addEffect\", {\n\t\t\tvalue: (effect: Effect) => {\n\t\t\t\teffList.push(effect);\n\t\t\t\tinnerMedia.effects = effList;\n\t\t\t\treturn sectionNode;\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\twritable: false,\n\t\t});\n\t\tObject.defineProperty(sectionNode, \"withEffect\", {\n\t\t\tvalue: (effect: Effect) => sectionNode.addEffect(effect),\n\t\t\tenumerable: true,\n\t\t\twritable: false,\n\t\t});\n\t\tObject.defineProperty(sectionNode, \"withEffects\", {\n\t\t\tvalue: (effects: Effect[]) => {\n\t\t\t\tfor (const eff of effects) {\n\t\t\t\t\tsectionNode.addEffect(eff);\n\t\t\t\t}\n\t\t\t\treturn sectionNode;\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\twritable: false,\n\t\t});\n\n\t\treturn sectionNode;\n\t},\n\ttrackedRegion: (\n\t\tsource: string | MediaNode,\n\t\ttarget: ObjectTrackSignals,\n\t\toptions: TrackedRegionOptions = {},\n\t): SectionNode => {\n\t\treturn Layer.section(source, target, options);\n\t},\n\tblurTrackedRegion: (\n\t\tsource: string | MediaNode,\n\t\ttarget: ObjectTrackSignals,\n\t\toptions: Partial<BlurProps> & {\n\t\t\tborderRadius?: number;\n\t\t\tpadding?: number;\n\t\t\tborderColor?: string;\n\t\t\tborderWidth?: number;\n\t\t} = {},\n\t): SectionNode => {\n\t\t// Section styling is not a Blur prop; keep it out of the effect config.\n\t\tconst { padding, borderRadius, borderColor, borderWidth, ...blurOptions } =\n\t\t\toptions;\n\t\treturn Layer.section(source, target, {\n\t\t\tpadding: padding ?? 8,\n\t\t\tborderRadius: borderRadius ?? 12,\n\t\t\tborderColor,\n\t\t\tborderWidth,\n\t\t\teffects: [\n\t\t\t\tnew Blur({\n\t\t\t\t\tstrength: blurOptions.strength ?? 25,\n\t\t\t\t\tblurType: blurOptions.blurType ?? \"Gaussian\",\n\t\t\t\t\t...blurOptions,\n\t\t\t\t}),\n\t\t\t],\n\t\t});\n\t},\n\t/**\n\t * A line, area, bar, scatter, candlestick, pie or donut chart. Returns a box\n\t * of ordinary nodes (bars are boxes, lines and slices are path shapes,\n\t * labels are text), so it positions, animates and composites like any layer.\n\t * `props` applies to that box: position, id, timing, effects.\n\t */\n\tchart: (\n\t\toptions: ChartOptions,\n\t\tprops: Partial<BoxNode> = {},\n\t): AnimatableNode<BoxNode> =>\n\t\tbuildChart(options, props, FontManager.getAll()[0]?.family ?? \"Inter\"),\n\tcamera: (options: Partial<CameraNode> = {}): AnimatableNode<CameraNode> =>\n\t\twithAnimation<CameraNode>({\n\t\t\tid: options.id ?? autoId(\"camera\"),\n\t\t\tkind: \"camera\",\n\t\t\tmode: options.mode ?? \"lookAt\",\n\t\t\tpitch: options.pitch ?? 0,\n\t\t\tyaw: options.yaw ?? 0,\n\t\t\troll: options.roll ?? 0,\n\t\t\t...options,\n\t\t}),\n\tlight: (options: Partial<LightNode> = {}): AnimatableNode<LightNode> =>\n\t\twithAnimation<LightNode>({\n\t\t\tid: options.id ?? autoId(\"light\"),\n\t\t\tkind: \"light\",\n\t\t\tlightType: options.lightType ?? \"point\",\n\t\t\tcolor: options.color ?? \"#ffffff\",\n\t\t\tintensity: options.intensity ?? 1.0,\n\t\t\t...options,\n\t\t}),\n\tambientLight: (\n\t\tcolor: string | Partial<LightNode> = \"#ffffff\",\n\t\tintensity: number = 0.5,\n\t\toptions: Partial<LightNode> = {},\n\t): AnimatableNode<LightNode> => Light.ambient(color, intensity, options),\n\t/**\n\t * Scenes back to back with transitions between them; see `Transition`.\n\t * `comp.add(Layer.sequence([{ scene: hero(), duration: 90 },\n\t * { scene: next(), duration: 120, transition: Transition.push(\"left\") }]))`.\n\t * The result's `totalFrames` is the sequence length.\n\t */\n\tsequence: (\n\t\tentries: SequenceEntry[],\n\t\toptions?: SceneSequenceOptions,\n\t): SequenceNode => sequence(entries, options),\n\t/** See {@link Light.environment}: `Layer.environment(\"studio\", { exposure: 0.3 })`. */\n\tenvironment: (\n\t\tpresetOrOptions: EnvironmentPreset | EnvironmentOptions = \"studio\",\n\t\toptions: EnvironmentOptions = {},\n\t): AnimatableNode<LightNode> => Light.environment(presetOrOptions, options),\n\tdirectionalLight: (\n\t\toptions: Partial<LightNode> = {},\n\t): AnimatableNode<LightNode> => Light.directional(options),\n\tpointLight: (options: Partial<LightNode> = {}): AnimatableNode<LightNode> =>\n\t\tLight.point(options),\n\tspotLight: (options: Partial<LightNode> = {}): AnimatableNode<LightNode> =>\n\t\tLight.spot(options),\n\tcube: (options: Cube3DOptions): AnimatableNode<BoxNode> =>\n\t\tLayer3D.cube(options),\n\tcarousel3d: (options: Carousel3DOptions): AnimatableNode<BoxNode> =>\n\t\tLayer3D.carousel(options),\n\tplane3d: (options: Plane3DOptions): AnimatableNode<BoxNode> =>\n\t\tLayer3D.plane(options),\n\tprism3d: (options: Prism3DOptions = {}): SolidShape3DNode =>\n\t\tLayer3D.prism(options),\n\tmodel: (options: Partial<Model3DNode> = {}): AnimatableNode<Model3DNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"model3d\"),\n\t\t\tkind: \"model3d\",\n\t\t\tis3D: options.is3D ?? true,\n\t\t\tmodelFormat: options.modelFormat ?? \"auto\",\n\t\t\tloop: options.loop ?? true,\n\t\t\tscale: options.scale ?? 1.0,\n\t\t\tscaleX: options.scaleX ?? 1.0,\n\t\t\tscaleY: options.scaleY ?? 1.0,\n\t\t\tscaleZ: options.scaleZ ?? 1.0,\n\t\t\topacity: options.opacity ?? 1.0,\n\t\t\t// material and twoSided stay unset unless given: the model's own\n\t\t\t// materials (toon, single-sided, …) decide, falling back to lit.\n\t\t\t...options,\n\t\t}),\n\tobj: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"obj\",\n\t\t\t...options,\n\t\t}),\n\tfbx: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"fbx\",\n\t\t\t...options,\n\t\t}),\n\tgltf: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"gltf\",\n\t\t\t...options,\n\t\t}),\n\tglb: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"glb\",\n\t\t\t...options,\n\t\t}),\n\tstl: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"stl\",\n\t\t\t...options,\n\t\t}),\n\tply: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"ply\",\n\t\t\t...options,\n\t\t}),\n\tvox: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"vox\",\n\t\t\t...options,\n\t\t}),\n\tthreeDS: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"3ds\",\n\t\t\t...options,\n\t\t}),\n\toff: (\n\t\tsrc: string,\n\t\toptions: Partial<Model3DNode> = {},\n\t): AnimatableNode<Model3DNode> =>\n\t\tLayer.model({\n\t\t\tsrc,\n\t\t\tmodelFormat: \"off\",\n\t\t\t...options,\n\t\t}),\n};\n\n/** World settings for `Layer.environment` (see `LightNode` for every field). */\nexport type EnvironmentOptions = Partial<\n\tPick<\n\t\tLightNode,\n\t\t| \"id\"\n\t\t| \"preset\"\n\t\t| \"top\"\n\t\t| \"horizon\"\n\t\t| \"bottom\"\n\t\t| \"intensity\"\n\t\t| \"softboxes\"\n\t\t| \"rotation\"\n\t\t| \"exposure\"\n\t\t| \"toneMapping\"\n\t\t| \"fog\"\n\t\t| \"floor\"\n\t\t| \"bloom\"\n\t\t| \"startFrame\"\n\t\t| \"durationFrames\"\n\t>\n>;\n\nexport const Light = {\n\t/**\n\t * The scene's world: a procedural studio environment that lights and\n\t * reflects off every surface, plus exposure, tone mapping and fog. Adding\n\t * one switches the scene to physically based shading (GGX, real\n\t * `roughness` / `metallic`, `emissive` that blooms past white).\n\t */\n\tenvironment: (\n\t\tpresetOrOptions: EnvironmentPreset | EnvironmentOptions = \"studio\",\n\t\toptions: EnvironmentOptions = {},\n\t): AnimatableNode<LightNode> => {\n\t\tconst opts =\n\t\t\ttypeof presetOrOptions === \"string\"\n\t\t\t\t? { preset: presetOrOptions, ...options }\n\t\t\t\t: { ...presetOrOptions, ...options };\n\t\treturn withAnimation({\n\t\t\tkind: \"light\",\n\t\t\tlightType: \"environment\",\n\t\t\tpreset: \"studio\",\n\t\t\tintensity: 1,\n\t\t\t...opts,\n\t\t\tid: opts.id ?? autoId(\"environment\"),\n\t\t});\n\t},\n\tambient: (\n\t\tcolor: string | Partial<LightNode> = \"#ffffff\",\n\t\tintensity: number = 0.5,\n\t\toptions: Partial<LightNode> = {},\n\t): AnimatableNode<LightNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"light-ambient\"),\n\t\t\tkind: \"light\",\n\t\t\tlightType: \"ambient\",\n\t\t\tcolor: typeof color === \"string\" ? color : (color.color ?? \"#ffffff\"),\n\t\t\tintensity,\n\t\t\t...(typeof color === \"object\" && color),\n\t\t\t...options,\n\t\t}),\n\tdirectional: (options: Partial<LightNode> = {}): AnimatableNode<LightNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"light-directional\"),\n\t\t\tkind: \"light\",\n\t\t\tlightType: \"directional\",\n\t\t\tcolor: options.color ?? \"#ffffff\",\n\t\t\tintensity: options.intensity ?? 1.0,\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? -1000,\n\t\t\tz: options.z ?? -1000,\n\t\t\ttargetX: options.targetX ?? 0,\n\t\t\ttargetY: options.targetY ?? 0,\n\t\t\ttargetZ: options.targetZ ?? 0,\n\t\t\t...options,\n\t\t}),\n\tpoint: (options: Partial<LightNode> = {}): AnimatableNode<LightNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"light-point\"),\n\t\t\tkind: \"light\",\n\t\t\tlightType: \"point\",\n\t\t\tcolor: options.color ?? \"#ffffff\",\n\t\t\tintensity: options.intensity ?? 1.0,\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? 0,\n\t\t\tz: options.z ?? -500,\n\t\t\tradius: options.radius ?? 1000,\n\t\t\tdecay: options.decay ?? 1.0,\n\t\t\t...options,\n\t\t}),\n\tspot: (options: Partial<LightNode> = {}): AnimatableNode<LightNode> =>\n\t\twithAnimation({\n\t\t\tid: options.id ?? autoId(\"light-spot\"),\n\t\t\tkind: \"light\",\n\t\t\tlightType: \"spot\",\n\t\t\tcolor: options.color ?? \"#ffffff\",\n\t\t\tintensity: options.intensity ?? 1.0,\n\t\t\tx: options.x ?? 0,\n\t\t\ty: options.y ?? -500,\n\t\t\tz: options.z ?? -1000,\n\t\t\ttargetX: options.targetX ?? 0,\n\t\t\ttargetY: options.targetY ?? 0,\n\t\t\ttargetZ: options.targetZ ?? 0,\n\t\t\tangle: options.angle ?? 45,\n\t\t\tpenumbra: options.penumbra ?? 0.2,\n\t\t\tradius: options.radius ?? 2000,\n\t\t\tdecay: options.decay ?? 1.0,\n\t\t\t...options,\n\t\t}),\n};\n\nexport {\n\ttype PreviewCloseReason,\n\ttype PreviewOptions,\n\ttype PreviewSession,\n\ttype PreviewSource,\n\tstartPreview,\n} from \"./preview/index.js\";\nexport {\n\ttype AudioQaStats,\n\ttype ChunkPlan,\n\ttype ChunkPlanOptions,\n\tcomputeGridLayout,\n\tdescribeGpu,\n\ttype FrameCostSample,\n\ttype FrameGridOptions,\n\ttype FrameGridRenderable,\n\ttype FrameSamplePoint,\n\tformatQaReport,\n\ttype GpuAdapterDescription,\n\tHeadlessMediaRenderer,\n\tHeadlessWebGPURenderer,\n\ttype PlannedChunk,\n\tplanChunks,\n\ttype QaIssue,\n\ttype QaSegment,\n\ttype RenderProgress,\n\trenderFrameGrid,\n\trenderSemaphore,\n\tresetRenderCaches,\n\tresolveSamplePoints,\n\ttype StitchOptions,\n\ttype StitchResult,\n\tstitchChunks,\n\ttype VideoQaOptions,\n\ttype VideoQaReport,\n\ttype VideoQaStats,\n} from \"./renderer/index.js\";\n\nexport function section(\n\tsource: string | MediaNode | Composition,\n\ttargetOrOptions: ObjectTrackSignals | SectionOptions = {},\n\toptions: SectionOptions = {},\n): SectionNode {\n\treturn Layer.section(source, targetOrOptions, options);\n}\n\nexport function blurRegion(\n\tsourceOrLayer: string | AnimatableNode<MediaNode>,\n\ttarget: ObjectTrackSignals,\n\toptions: Partial<BlurProps> & {\n\t\tborderRadius?: number;\n\t\tpadding?: number;\n\t\tborderColor?: string;\n\t\tborderWidth?: number;\n\t} = {},\n): AnimatableNode<MediaNode> | AnimatableNode<BoxNode> {\n\tif (typeof sourceOrLayer === \"object\" && \"blurRegion\" in sourceOrLayer) {\n\t\treturn (sourceOrLayer as AnimatableNode<MediaNode>).blurRegion(\n\t\t\ttarget,\n\t\t\toptions,\n\t\t);\n\t}\n\treturn Layer.blurTrackedRegion(sourceOrLayer as string, target, options);\n}\n\nexport function editTrackedRegion(\n\tsource: string | MediaNode,\n\ttarget: ObjectTrackSignals,\n\toptions: TrackedRegionOptions = {},\n): SectionNode {\n\treturn Layer.section(source, target, options);\n}\n\nexport const Effect = Object.assign(CoreEffect, effectFactories, {\n\tblur: (config?: BlurProps) => new Blur(config),\n\tvignette: (config?: VignetteProps) => new Vignette(config),\n\tcolorBalance: (config?: ColorBalanceProps) => new ColorBalance(config),\n\tcolorKey: (config?: ColorKeyProps) => new ColorKey(config),\n\tlevels: (config?: LevelsProps) => new Levels(config),\n\tfilmGrain: (config?: FilmGrainProps) => new FilmGrain(config),\n\tcurves: (config?: CurvesProps) => new Curves(config),\n\tselectiveColor: (config?: SelectiveColorProps) => new SelectiveColor(config),\n\tgradientMap: (config?: GradientMapProps) => new GradientMap(config),\n\tshadowsHighlights: (config?: ShadowsHighlightsProps) =>\n\t\tnew ShadowsHighlights(config),\n\tapplyLut: (config?: ApplyLUTProps) => new ApplyLUT(config),\n\tunsharpMask: (config?: UnsharpMaskProps) => new UnsharpMask(config),\n\thighPass: (config?: HighPassProps) => new HighPass(config),\n\thalftoneScreen: (config?: HalftoneScreenProps) => new HalftoneScreen(config),\n\ttileOffset: (config?: TileOffsetProps) => new TileOffset(config),\n\tmotionBlur: (config?: MotionBlurProps) => new MotionBlur(config),\n\tssao: (config?: SSAOProps) => new SSAO(config),\n\tpbrGlass: (config?: PBRGlassProps) => new PBRGlass(config),\n\tdepthOfField: (config?: DepthOfFieldProps) => new DepthOfField(config),\n\tcrop: (config?: CropProps) => new Crop(config),\n\tvision: (config?: VisionProps) => new Vision(config),\n\trelight3d: (config?: Relight3DProps) => new Relight3D(config),\n\tmodulate: (config?: ModulateProps) => new Modulate(config),\n\tdeflicker: (config?: DeflickerProps) => new TemporalDeflicker(config),\n\tcustom: (op: string, config: Record<string, unknown> = {}) =>\n\t\tnew CustomEffect(op, config),\n});\n\nexport type Effect<TConfig extends object = Record<string, unknown>> =\n\tCoreEffect<TConfig>;\n\n// Components: `npx framefields add <name>` copies a component's source into\n// the project. The root carries what users touch around them; the authoring\n// toolkit (timing, paths, strokes, baking) lives at `framefields/components`.\nexport {\n\ttype Anchor,\n\ttype AudioLevels,\n\tafter,\n\ttype BaseProps,\n\ttype Cue,\n\ttype Cues,\n\tdefineTheme,\n\ttype MotionPreset,\n\tpulseKeys,\n\ttype Target,\n\ttype Theme,\n\ttype ThemeInput,\n\tthemes,\n\twithDefaults,\n} from \"@framefields/components/toolkit\";\nexport {\n\tanalyzeAudio,\n\tbindComponent,\n\ttype ComponentNode,\n} from \"./components/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAMA,IAAI,WAAW,cAAc,MAAM;CAClC;CACA;CACA;CACA;CACA,YAAY,EAAE,SAAS,QAAQ,UAAU,MAAM,WAAW,QAAQ;AACjE,QAAM,QAAQ;AACd,OAAK,OAAO;AACZ,OAAK,SAAS;AACd,OAAK,OAAO;AACZ,OAAK,YAAY,aAAa;AAC9B,OAAK,OAAO;;;;AAId,IAAI,kBAAkB,cAAc,SAAS;CAC5C,YAAY,MAAM;AACjB,QAAM,KAAK;AACX,OAAK,OAAO;;CAEb,IAAI,cAAc;AACjB,SAAO,MAAM,QAAQ,KAAK,MAAM,OAAO,GAAG,KAAK,KAAK,SAAS,EAAE;;CAEhE,eAAe,OAAO;AACrB,SAAO,KAAK,YAAY,QAAQ,MAAM,EAAE,IAAI,EAAE,IAAI,SAAS,OAAO,MAAM;;;AAG1E,SAAS,UAAU,MAAM,UAAU;AAClC,KAAI,MAAM,OAAO,QAAS,QAAO,KAAK,MAAM;AAC5C,KAAI,OAAO,MAAM,WAAW,SAAU,QAAO,KAAK;AAClD,KAAI,MAAM,QAAQ,MAAM,OAAO,EAAE;EAChC,MAAM,QAAQ,KAAK,OAAO;AAC1B,MAAI,OAAO,IAAK,QAAO,GAAG,MAAM,IAAI,KAAK,MAAM,OAAO,EAAE,EAAE,KAAK,IAAI,CAAC;;AAErE,KAAI,OAAO,MAAM,YAAY,SAAU,QAAO,KAAK;AACnD,QAAO;;;AAGR,eAAe,kBAAkB,UAAU;CAC1C,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,YA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