@higgsfield/video-editor-mcp 1.0.7 → 1.1.1-dev.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/THIRD_PARTY_NOTICES.md +24 -24
- package/dist/cli.mjs +134 -125
- package/dist/index.html +136 -133
- package/dist/launcher.mjs +90 -90
- package/dist/server.mjs +1553 -1389
- package/node_modules/@higgsfield/higgsedit/README.md +181 -1
- package/node_modules/@higgsfield/higgsedit/dist/capture-page.js +902 -314
- package/node_modules/@higgsfield/higgsedit/dist/chunk-2JYLVSVV.mjs +1594 -0
- package/node_modules/@higgsfield/higgsedit/dist/chunk-2WKNH7OL.mjs +16 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-OMKZ5BXM.mjs → chunk-5LTTL3Q3.mjs} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/chunk-7PYXSJS7.mjs +717 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-MLJAIZGP.mjs → chunk-BH2QF635.mjs} +33 -326
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-WZR5PZM7.mjs → chunk-BV5COOQZ.mjs} +250 -161
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-HTCYVKFX.mjs → chunk-C3GSB3XZ.mjs} +8 -7
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-CYH2EUQV.mjs → chunk-DVN4LUXV.mjs} +13 -4
- package/node_modules/@higgsfield/higgsedit/dist/chunk-F4CMIG5G.mjs +36 -0
- package/node_modules/@higgsfield/higgsedit/dist/chunk-IEPPEDEU.mjs +33 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-UVAZ6I6U.mjs → chunk-KIWGVAPJ.mjs} +16 -12
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-L6QDNSL3.mjs → chunk-L5LWBA6A.mjs} +5 -5
- package/node_modules/@higgsfield/higgsedit/dist/chunk-LMQR3DHT.mjs +37 -0
- package/node_modules/@higgsfield/higgsedit/dist/chunk-LTKMGZ6T.mjs +58 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-VI6IV6JP.mjs → chunk-MV2JTTBQ.mjs} +65 -47
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-4D6AXU4B.mjs → chunk-NARTAWRN.mjs} +50 -30
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-27NBQ5FA.mjs → chunk-NUXTKQNM.mjs} +33 -21
- package/node_modules/@higgsfield/higgsedit/dist/chunk-OCIZ36XD.mjs +40 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-MK6PL7N4.mjs → chunk-OF6RMSM2.mjs} +19 -17
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-6BETMESC.mjs → chunk-P2BGHTRR.mjs} +2 -2
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-EKFC4S4M.mjs → chunk-PAHMD6SU.mjs} +5 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-QVLAEV3U.mjs → chunk-PFQYUJQL.mjs} +3 -4
- package/node_modules/@higgsfield/higgsedit/dist/chunk-QJTILFBS.mjs +335 -0
- package/node_modules/@higgsfield/higgsedit/dist/chunk-QQ3GGKDN.mjs +21 -0
- package/node_modules/@higgsfield/higgsedit/dist/chunk-TH7TK67K.mjs +23 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-SIMO6I3D.mjs → chunk-UDL5AHKO.mjs} +163 -158
- package/node_modules/@higgsfield/higgsedit/dist/chunk-UMWOUQN3.mjs +60 -0
- package/node_modules/@higgsfield/higgsedit/dist/{chunk-3AIM3THH.mjs → chunk-VLM5EOWJ.mjs} +4 -4
- package/node_modules/@higgsfield/higgsedit/dist/chunk-WENFTPXQ.mjs +403 -0
- package/node_modules/@higgsfield/higgsedit/dist/chunk-YLVXQIPX.mjs +464 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/.vite/manifest.json +559 -506
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/agent-corner-bottom-q4hZltI-.svg +431 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/agent-corner-top-BJYI-I24.svg +431 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/confirmation-BTnwl3LS.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/drag-Bt_t4HZO.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/local-B3OTAV_A.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/menubar-2Y1Y2XJt.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/model-DdE4hCgf.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/{IconText1-CzbCrP7v.css → notifications-B08L1jSe.css} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/{panel-g852pZf_.css → panel-BRN_AbBM.css} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-CYELNqrv.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-DYLpT6oA.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-v84HaGTZ.css +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconChainLink1-Bxb1Or0F.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconCheckmark2Medium-daaES9uF.js → IconCheckmark2Medium-hegaz9mQ.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconChevronDownSmall-BhTBJk26.js → IconChevronDownSmall-DaruzJwU.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconClosedCaptioning-BPqcqKsD.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconCrossMedium-acfnCXOM.js → IconCrossMedium-BsPFJzc6.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconOpenaiFilled-D1fzthmi.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconPause-pTeVSvUe.js → IconPause-ClNg8pao.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconPlayFilled-CwdgIuDG.js → IconPlayFilled-CHb-7GSx.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconSparklesSoftFilled-o7o33KRn.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/ai-composer-B9h-eaki.js +567 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/auto-layout-BO20Tg4B.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{button-CjG6GcgF.js → button-Cg0U0zpV.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/canvas-Bw4CVzfw.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/capabilities-BCd4-zPF.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/commands-QeSqAbCt.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/components-tXMtIZNL.js +51 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/confirmation-CO2PHR_z.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/dom-6aoQn29n.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/drag-Dw8b_vO2.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{editing-CjWbiCxv.js → editing-Cy-SaOyB.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/edits-CqLBqir0.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/export-dialog-BjBskOe3.js +2 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/factories-Bw_iQrUL.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/id3-CSR0NCRI.js +2 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/import-DP49i4ke.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/import-error-CMz9sLPe.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/ingest-DsmIc415.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/jsx-runtime-B5yqYJvp.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{media-Bwjxu-0U.js → media-DQw6vU_T.js} +1 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/menubar-D31srALX.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/meters-D0nZVEJs.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/mode-DEG6doKF.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/model-Duf9fszJ.js +2 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/model-DyAkLA69.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/notifications-DqWZNIrK.js +9 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/palette-HT83gWgL.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-B5Mvm6dg.js +7 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-BC90wyvd.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-Bw_ZJ2JI.js +3 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DNS060Nt.js +3 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DSgxIrEq.js +2 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DgBttE5O.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-assets-_T2bHsHW.js +771 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-inspector-DfHvAt5X.js +2 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-nBZvHlkA.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-timeline-DsCpJVSt.js +327 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-viewport-CEhZwZ67.js +280 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/projects-2_tW9Do7.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/react-dom-1uB7Vbbb.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/schemas-CddYAOcj.js +64 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/session-BpFeKAI2.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/src-BLG3tYBa.js +2 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/styles-e2n2A_JN.js +284 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/supercomputer-CuV0zYKd.js +24 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/tabs-XeAgs9cs.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/toggle-DbNEaSIl.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-C8Ll3qFl.js +69 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-bar-Dv1LPFbu.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useOpenInteractionType-HWSfSsp2.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useRenderElement-D4SOg3N_.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/value-EB7YmAdS.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/writeback-support-fj5rA9k3.js +1 -0
- package/node_modules/@higgsfield/higgsedit/dist/editor/editor-B-WAkLt7.js +372 -0
- package/node_modules/@higgsfield/higgsedit/dist/higgsedit.mjs +39 -24
- package/node_modules/@higgsfield/higgsedit/dist/jsx/hooks.d.ts +26 -0
- package/node_modules/@higgsfield/higgsedit/dist/jsx/index.d.ts +17 -0
- package/node_modules/@higgsfield/higgsedit/dist/jsx/inspect.d.ts +42 -0
- package/node_modules/@higgsfield/higgsedit/dist/jsx/jsx-runtime.d.ts +28 -0
- package/node_modules/@higgsfield/higgsedit/dist/jsx/svg.d.ts +9 -0
- package/node_modules/@higgsfield/higgsedit/dist/jsx/time.d.ts +6 -0
- package/node_modules/@higgsfield/higgsedit/dist/jsx/types.d.ts +420 -0
- package/node_modules/@higgsfield/higgsedit/package.json +28 -20
- package/package.json +4 -3
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/plugin.json +1 -1
- package/plugin/skills/video-editing/references/caption-titling.md +1 -1
- package/plugin/skills/video-editing/references/local-setup.md +3 -3
- package/node_modules/@higgsfield/higgsedit/dist/chunk-C6SASQHE.mjs +0 -424
- package/node_modules/@higgsfield/higgsedit/dist/chunk-FZ5U36SQ.mjs +0 -83
- package/node_modules/@higgsfield/higgsedit/dist/chunk-QLPCYN6K.mjs +0 -292
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/edit-drag-D2EV5ddd.css +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/editor-CuRHT75g.css +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-DnuQD7ja.css +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/FieldControl-B0fenhBJ.js +0 -2
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconChainLink1-Cwv1X7hi.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconEyeOpen-BqTT9_VV.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconEyeSlash-Whv58c1m.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconPencil-Dr17k_7e.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconPlay-BroH3ziH.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconPlusSmall-43T9aE3d.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconText1-BaP_p9DW.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconTrashCan-DX2w2AIC.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/ai-composer-C-l0eIdP.js +0 -560
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/captions-Cd-bDG3G.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/clip-highlight-DpAvcA4x.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/components-e3ZbUVns.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/disposables-CwUPjcuA.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/drag-HLBkto5o.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/dropdown-BJ04G_X3.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/edit-drag-Bg6LggKC.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/edits-a2IixhrN.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/export-dialog-4I4gqI5V.js +0 -2
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/face-tracker-DzVfjVOO.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/fit-imported-media-CaCB0x0b.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/generation-queue-DuL2F4-_.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/import-error-CMARA0Hy.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/jsx-runtime-B-hcVAMW.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/menubar-Bs26OdwP.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/meters-YEr9OQjq.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/paints-DS2Msf91.js +0 -67
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/palette-CcS9IcAC.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-7M3uQokX.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-BBK1NyG-.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-CHZTs7By.js +0 -4
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DaSOa3MP.js +0 -2
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DlK3RYVo.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-Dst5OKWu.js +0 -2
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-H_ZoDiKK.js +0 -2
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-Rn9Z7Eek.js +0 -3
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-assets-FAghGFG3.js +0 -678
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-inspector-DEqULBNF.js +0 -260
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-timeline-0GYNz1uc.js +0 -333
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-viewport-DOWjJi5-.js +0 -317
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/projects-BBJc7h5_.js +0 -2
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/session-B9sZaFKC.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/supercomputer-CX-LCL6Y.js +0 -24
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/tabs-CvKQ-eas.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/toggle-CrzrwiDZ.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-BgRfk-Qq.js +0 -69
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-bar-C9nqAfE2.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/typography-C5-w9LOu-kD3uLKkf.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useOpenInteractionType-DbrQ6Ehu.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useRenderElement-bbxXdYq0.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/writeback-support-BZfNpkmB.js +0 -1
- package/node_modules/@higgsfield/higgsedit/dist/editor/editor-Csn2_T_e.js +0 -293
- package/node_modules/@higgsfield/higgsedit/dist/export-settings.mjs +0 -75
- package/node_modules/@higgsfield/higgsedit/dist/history.mjs +0 -295
- package/node_modules/@higgsfield/higgsedit/dist/media-upload.mjs +0 -381
- package/node_modules/@higgsfield/higgsedit/dist/proxy.mjs +0 -170
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{et as r,tt as i,wt as a}from"./paints-DS2Msf91.js";import{i as o,n as s,t as c}from"./IconEyeSlash-Whv58c1m.js";import{d as l}from"./session-B9sZaFKC.js";import{r as u}from"./captions-Cd-bDG3G.js";import{f as d}from"./dropdown-BJ04G_X3.js";import{T as f,_ as p,a as m,c as h,d as g,o as _,p as v,s as y,u as b,w as ee}from"../editor-Csn2_T_e.js";import{t as x}from"./button-CjG6GcgF.js";import{t as S}from"./IconChevronDownSmall-BhTBJk26.js";import{t as te}from"./IconCrossMedium-acfnCXOM.js";import{t as ne}from"./IconPencil-Dr17k_7e.js";import{_ as re,a as C,c as w,d as T,f as ie,h as E,i as D,l as O,m as ae,n as k,p as oe,s as A,u as j,v as se}from"./components-e3ZbUVns.js";import{A as ce,B as le,D as ue,E as de,F as fe,I as pe,L as me,M as he,N as ge,O as _e,P as ve,R as ye,S as be,T as xe,_ as Se,a as Ce,b as we,c as M,d as Te,f as Ee,g as De,i as Oe,j as ke,k as N,l as Ae,m as je,n as Me,o as Ne,p as Pe,r as Fe,s as Ie,t as Le,u as Re,v as ze,w as Be,x as Ve,y as He,z as Ue}from"./edits-a2IixhrN.js";import{C as We,S as Ge,_ as Ke,a as qe,c as Je,d as Ye,f as Xe,g as Ze,h as Qe,i as $e,l as et,n as tt,o as nt,p as rt,r as it,t as at}from"./face-tracker-DzVfjVOO.js";import{t as ot}from"./IconPlusSmall-43T9aE3d.js";import{n as st,t as P}from"./writeback-support-BZfNpkmB.js";import{i as ct,n as lt,o as ut,r as dt,s as ft,t as pt}from"./IconEyeOpen-BqTT9_VV.js";import{F as mt,I as ht,L as gt,N as _t,P as vt,R as yt,f as bt,m as xt,n as St,t as Ct,y as wt}from"./IconChainLink1-Cwv1X7hi.js";import{n as Tt,t as Et}from"./palette-CcS9IcAC.js";var F=e(t(),1),Dt=(0,F.createContext)(null);function I(){let e=(0,F.use)(Dt);if(!e)throw Error(`useEdit() outside the inspector panel`);return e}var L=n();function R(e){return{available:!1,reason:e}}function Ot(e,t){if(!e||t.length===0)return{availability:R(`Select a visual layer to align.`),context:null};let n=e.scenes.find(e=>t.every(t=>wt(e,t)!==null));if(!n)return{availability:R(`Selected layers must be in the same scene.`),context:null};let r=t.map(e=>wt(n,e)).filter(e=>e!==null);if(r.some(e=>e.clip.kind===`audio`))return{availability:R(`Audio layers cannot be aligned on the canvas.`),context:null};let i=t.map(t=>ft(e,t));if(i.some(e=>e===null))return{availability:R(`One or more selected layers could not be found.`),context:null};if(i.some(e=>e.locked))return{availability:R(`Alignment is unavailable because a selected layer or ancestor is locked.`),context:null};if(i.some(e=>e.sealed))return{availability:R(`Component internals are sealed. Align the component instance instead.`),context:null};if(i.some(e=>e.parent?.autoLayout!=null))return{availability:R(`Alignment is managed by the Auto Layout parent.`),context:null};if(!xt(r))return{availability:R(`Selected layers must share the same parent.`),context:null};let a;if(r.length>1){let e=bt(r);if(!e)return{availability:R(`Selected layers do not have alignable bounds.`),context:null};a=e}else{let e=i[0].parent;a=e?{minX:0,minY:0,maxX:e.size.width,maxY:e.size.height}:{minX:0,minY:0,maxX:n.width,maxY:n.height}}return{availability:{available:!0,reason:null},context:{scene:n,locations:r,containerBounds:a}}}function kt(e,t){return Ot(e,t).availability}function At(e,t,n){let r=t===`x`?e.minX:e.minY,i=t===`x`?e.maxX:e.maxY;return n===`start`?r:n===`end`?i:(r+i)/2}function jt(e,t){return e===`x`?t===`start`?`Align left`:t===`end`?`Align right`:`Align horizontal centers`:t===`start`?`Align top`:t===`end`?`Align bottom`:`Align vertical centers`}function Mt(e,t,n,r){let{context:i}=Ot(e,t);if(!i)return null;let a=At(i.containerBounds,n,r),o=[];for(let t of i.locations){let i=bt([t]),s=M(e,t.clip.id);if(!i||!s)return null;let c=a-At(i,n,r);if(Math.abs(c)<1e-9)continue;let l={...t.clip,transform:{...t.clip.transform,[n]:t.clip.transform[n]+c}};o.push({op:`set`,path:s.path,value:De(l)})}return o.length===0?null:{id:ge(),name:jt(n,r),coalesceKey:null,ops:o}}var Nt=[{label:`Align left`,axis:`x`,edge:`start`,icon:(0,L.jsx)(gt,{mode:`raw`,size:15})},{label:`Align horizontal center`,axis:`x`,edge:`center`,icon:(0,L.jsx)(yt,{mode:`raw`,size:15})},{label:`Align right`,axis:`x`,edge:`end`,icon:(0,L.jsx)(ht,{mode:`raw`,size:15})},{label:`Align top`,axis:`y`,edge:`start`,icon:(0,L.jsx)(_t,{mode:`raw`,size:15})},{label:`Align vertical center`,axis:`y`,edge:`center`,icon:(0,L.jsx)(mt,{mode:`raw`,size:15})},{label:`Align bottom`,axis:`y`,edge:`end`,icon:(0,L.jsx)(vt,{mode:`raw`,size:15})}];function Pt({disabled:e,reason:t,onAlign:n,inline:r=!1}){let i=(0,L.jsx)(`div`,{className:`alignment-buttons`,role:`group`,"aria-label":`Align selected layers`,children:Nt.map(t=>(0,L.jsx)(C,{title:t.label,disabled:e,onClick:()=>n(t.axis,t.edge),children:t.icon},t.label))});return r?(0,L.jsx)(O,{label:`Align`,children:i}):(0,L.jsxs)(j,{title:`Alignment`,children:[(0,L.jsx)(`div`,{className:`alignment-buttons`,role:`group`,"aria-label":`Align selected layers`,children:Nt.map(t=>(0,L.jsx)(C,{title:t.label,disabled:e,onClick:()=>n(t.axis,t.edge),children:t.icon},t.label))}),t&&(0,L.jsx)(A,{children:t})]})}function Ft(e,t){return e.available===t.available&&e.reason===t.reason}function It({clipIds:e,inline:t=!1}){let n=m(l),{applyEnvelope:r}=I(),i=y(t=>kt(t,e),Ft);return(0,L.jsx)(Pt,{inline:t,disabled:!i.available,reason:i.reason,onAlign:(t,i)=>{let a=n?.snapshot();a&&r(Mt(a,e,t,i))}})}var Lt=e=>{let t=F.useId();return F.createElement(Vt,{...e,instanceId:t})},Rt=0,zt=typeof F.useId==`function`?void 0:class extends F.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++Rt}`})}render(){return F.createElement(Vt,{...this.props.iconProps,instanceId:this.state.instanceId})}},Bt=F.forwardRef((e,t)=>zt?F.createElement(zt,{iconProps:{...e,svgRef:t}}):F.createElement(Lt,{...e,svgRef:t}));Bt.displayName=`CentralIconBase`;var Vt=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return F.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&F.createElement(`title`,null,y),g?F.createElement(F.Fragment,null,F.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},F.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),F.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),F.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ht=F.memo(F.forwardRef((e,t)=>F.createElement(Bt,{...e,ref:t,ariaLabel:`chevron-left-small`,maskId:`round-outlined-radius-2-stroke-1.5-IconChevronLeftSmall`},F.createElement(`path`,{d:`M13.5858 16L10.2929 12.7071C9.90237 12.3166 9.90237 11.6834 10.2929 11.2929L13.5858 8`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),Ut=e=>{let t=F.useId();return F.createElement(qt,{...e,instanceId:t})},Wt=0,Gt=typeof F.useId==`function`?void 0:class extends F.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++Wt}`})}render(){return F.createElement(qt,{...this.props.iconProps,instanceId:this.state.instanceId})}},Kt=F.forwardRef((e,t)=>Gt?F.createElement(Gt,{iconProps:{...e,svgRef:t}}):F.createElement(Ut,{...e,svgRef:t}));Kt.displayName=`CentralIconBase`;var qt=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return F.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&F.createElement(`title`,null,y),g?F.createElement(F.Fragment,null,F.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},F.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),F.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),F.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Jt=F.memo(F.forwardRef((e,t)=>F.createElement(Kt,{...e,ref:t,ariaLabel:`keyframe, rhombus`,maskId:`round-outlined-radius-2-stroke-1.5-IconKeyframe`},F.createElement(`path`,{d:`M13.4142 3.4142C12.6332 2.63316 11.3668 2.63316 10.5858 3.4142L3.41422 10.5857C2.63317 11.3668 2.63316 12.6331 3.41421 13.4142L10.5858 20.5858C11.3668 21.3668 12.6332 21.3668 13.4142 20.5858L20.5858 13.4142C21.3668 12.6331 21.3668 11.3668 20.5858 10.5857L13.4142 3.4142Z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`})))),Yt=0,z=()=>`gesture-${++Yt}`;function B({checked:e,onChange:t,title:n}){return(0,L.jsx)(d,{size:`sm`,checked:e,title:n,onCheckedChange:t})}function V({value:e,min:t,max:n,step:r,format:i,onInput:a}){let[o,s]=(0,F.useState)(null),c=(0,F.useRef)(null),l=o??e;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ie,{value:l,min:t,max:n,step:r,onGestureStart:()=>{c.current=z()},onGestureEnd:()=>{c.current=null,s(null)},onInput:e=>{s(c.current===null?null:e),a(e,c.current)}}),i!==void 0&&(0,L.jsx)(`span`,{className:`muted num-readout text-q-mono-xs-regular`,children:i(l)})]})}function H({clip:e,property:t,value:n,effectId:r=null,effectParam:i=null,disabled:a}){return(0,L.jsx)(U,{clip:e,targets:[{property:t,value:n,effectId:r,effectParam:i}],disabled:a})}function Xt(e,t,n){return t.every(t=>Re(e,t.property,n,t.effectId??null,t.effectParam??null))}function U({clip:e,targets:t,disabled:n}){let{updateClip:r}=I(),i=h(),a=b(),o=(0,F.useRef)(null),c=t.some(t=>Ae(e,t.property,t.effectId??null,t.effectParam??null)!==null);(0,F.useEffect)(()=>{if(!a)return;let n=()=>{let n=Math.max(0,a.get()-e.timeRange.start);o.current?.classList.toggle(`active`,Xt(e,t,n))};n();let r=a.subscribe(n);return()=>r.dispose()},[a,e,t]);let l=n=>{let r=i?.currentTime.get()??0,a=null;for(let i of t){let t=Me(e,i.property,r,n,i.effectId??null,i.effectParam??null);t!==null&&(a===null||(n>0?t<a:t>a))&&(a=t)}a!==null&&i?.seek(a)};return(0,L.jsxs)(`span`,{className:`kf-controls`,children:[c&&(0,L.jsx)(x,{variant:`ghost`,size:`xxs`,iconOnly:!0,className:`kf-nav`,"aria-label":`Previous keyframe`,title:`Previous keyframe`,disabled:n,onClick:()=>l(-1),children:(0,L.jsx)(Ht,{mode:`raw`,size:12})}),(0,L.jsx)(x,{ref:o,variant:`ghost`,size:`xxs`,iconOnly:!0,className:`kf-diamond`,"aria-label":`Toggle keyframe at playhead`,title:`Toggle keyframe at playhead`,disabled:n,onClick:()=>{let n=i?.currentTime.get()??0,a=Math.max(0,n-e.timeRange.start),o=Xt(e,t,a);r(e.id,`Toggle keyframe`,e=>{let n=e;for(let e of t){let t=e.effectId??null,r=e.effectParam??null;(o||!Re(n,e.property,a,t,r))&&(n=Se(n,e.property,e.value,a,t,r))}return n})},children:(0,L.jsx)(Jt,{mode:`raw`,size:12})}),c&&(0,L.jsx)(x,{variant:`ghost`,size:`xxs`,iconOnly:!0,className:`kf-nav`,"aria-label":`Next keyframe`,title:`Next keyframe`,disabled:n,onClick:()=>l(1),children:(0,L.jsx)(s,{mode:`raw`,size:12})})]})}function W({axis:e,value:t,onCommit:n,step:r,min:i,max:a,disabled:o}){let s=(0,F.useRef)(null);return(0,L.jsxs)(`span`,{className:`axis-field`,children:[(0,L.jsx)(`span`,{className:`axis-label muted text-q-caption-xs-regular`,children:e}),(0,L.jsx)(w,{label:`${e} axis value`,value:t,disabled:o,onCommit:e=>n(e,s.current),step:r,min:i,max:a,onGestureStart:()=>{s.current=z()},onGestureEnd:()=>{s.current=null}})]})}function G({onClick:e,disabled:t,title:n=`Reset to default`}){return(0,L.jsx)(x,{variant:`ghost`,size:`xxs`,iconOnly:!0,className:`reset-btn`,"aria-label":n,title:n,disabled:t,onClick:e,children:(0,L.jsx)(St,{mode:`raw`,size:12})})}function Zt({linked:e,onToggle:t}){return(0,L.jsx)(x,{variant:e?`brandSoft`:`ghost`,size:`xxs`,iconOnly:!0,className:`link-btn${e?` active`:``}`,"aria-label":e?`Unlink X and Y`:`Link X and Y`,title:e?`Unlink X and Y`:`Link X and Y`,onClick:t,children:(0,L.jsx)(Ct,{mode:`raw`,size:12})})}function K(){return(0,L.jsx)(`span`,{className:`ctl-spacer`})}function q({label:e,title:t,active:n,disabled:r,onClick:i}){return(0,L.jsx)(x,{variant:n?`brandSoft`:`tertiary`,size:`xxs`,title:t,disabled:r,onClick:i,children:e})}var Qt=200,$t=168,en=16,tn=-.5,nn=1.5,J=e=>(Math.round(e*100)/100).toString();function rn({value:e,onChange:t,onClose:n}){let[r,i]=(0,F.useState)(null),a=r??{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},o=(0,F.useRef)(null),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),u=e=>en+e*168,d=e=>152-(e-tn)/2*136,f=e=>Math.min(1,Math.max(0,(e-en)/168)),p=e=>Math.min(nn,Math.max(tn,tn+(152-e)/136*2)),m=(e,{dpr:t})=>{let n=l.current??=Et(e.canvas);e.setTransform(t,0,0,t,0,0),e.clearRect(0,0,Qt,$t),e.strokeStyle=n.borderDefault,e.lineWidth=1,e.strokeRect(u(0),d(1),u(1)-u(0),d(0)-d(1)),e.strokeStyle=n.accent,e.lineWidth=2,e.beginPath();let r={kind:`cubic-bezier`,x1:a.x1,y1:a.y1,x2:a.x2,y2:a.y2};for(let t=0;t<=64;t++){let n=t/64,i=ke(r,n);t===0?e.moveTo(u(n),d(i)):e.lineTo(u(n),d(i))}e.stroke(),e.strokeStyle=n.textTertiary,e.lineWidth=1,e.beginPath(),e.moveTo(u(0),d(0)),e.lineTo(u(a.x1),d(a.y1)),e.moveTo(u(1),d(1)),e.lineTo(u(a.x2),d(a.y2)),e.stroke();for(let[t,r]of[[a.x1,a.y1],[a.x2,a.y2]])e.fillStyle=n.textPrimary,e.beginPath(),e.arc(u(t),d(r),5,0,Math.PI*2),e.fill()},h=(e,t)=>{let n=Math.hypot(e-u(a.x1),t-d(a.y1)),r=Math.hypot(e-u(a.x2),t-d(a.y2));return Math.min(n,r)>14?null:n<=r?1:2},g=()=>{o.current&&(o.current=null,s.current=null,i(null))};return re(c,n),(0,L.jsxs)(`div`,{ref:c,className:`fui-menu q-dropdown-content q-dropdown-popup bezier-pop`,children:[(0,L.jsx)(`div`,{className:`bezier-canvas`,onPointerCancel:g,children:(0,L.jsx)(Tt,{draw:m,onPointerDown:e=>{let t=e.currentTarget.getBoundingClientRect(),n=h(e.clientX-t.left,e.clientY-t.top);n&&(o.current=n,s.current=z(),e.currentTarget.setPointerCapture(e.pointerId))},onPointerMove:e=>{if(!o.current)return;let n=e.currentTarget.getBoundingClientRect(),r=f(e.clientX-n.left),c=p(e.clientY-n.top),l=o.current===1?{...a,x1:r,y1:c}:{...a,x2:r,y2:c};i(l),t(l,s.current)},onPointerUp:g})}),(0,L.jsxs)(`div`,{className:`bezier-footer`,children:[(0,L.jsxs)(`span`,{className:`muted bezier-readout text-q-mono-xs-regular`,children:[J(a.x1),`,`,J(a.y1),`,`,J(a.x2),`,`,J(a.y2)]}),(0,L.jsx)(x,{size:`xxs`,onClick:n,children:`Done`})]})]})}function an({value:e,onChange:t}){let[n,r]=(0,F.useState)(!1),i=fe(e);return(0,L.jsxs)(`span`,{className:`easing-picker`,children:[(0,L.jsx)(T,{value:i,options:xe.map(e=>({value:e.id,label:e.label})),onChange:n=>{if(n===`custom`){e.kind!==`cubic-bezier`&&t({...Be}),r(!0);return}r(!1);let i=xe.find(e=>e.id===n);i?.easing&&t({...i.easing})}}),e.kind===`steps`&&(0,L.jsx)(w,{value:e.count,min:1,max:64,onCommit:e=>t({kind:`steps`,count:Math.max(1,Math.round(e))})}),i===`custom`&&e.kind===`cubic-bezier`&&(0,L.jsx)(C,{title:`Edit curve`,active:n,onClick:()=>r(e=>!e),children:(0,L.jsx)(ne,{mode:`raw`,size:12})}),n&&e.kind===`cubic-bezier`&&(0,L.jsx)(rn,{value:e,onChange:(e,n)=>t({kind:`cubic-bezier`,x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},n),onClose:()=>r(!1)})]})}var on=new Map;function Y({id:e,title:t,unavailable:n,actions:r,children:i}){let a=(0,F.useId)(),[o,c]=(0,F.useState)(()=>!(on.get(e)??!!n));return(0,L.jsxs)(`section`,{className:`fui-section ds-section${o?``:` is-collapsed`}`,"data-section":e,"data-unavailable":n??void 0,children:[(0,L.jsxs)(`div`,{className:`fui-section-head ds-section-head`,children:[(0,L.jsxs)(`button`,{type:`button`,className:`ds-section-toggle`,"data-section-toggle":``,"aria-expanded":o,"aria-controls":a,onClick:()=>{on.set(e,o),c(!o)},children:[o?(0,L.jsx)(S,{size:12}):(0,L.jsx)(s,{size:12}),(0,L.jsx)(`span`,{className:`fui-section-title`,children:t})]}),n?(0,L.jsx)(`span`,{className:`ds-section-unavailable`,title:n,children:`Unavailable`}):(0,L.jsx)(`span`,{className:`ds-section-actions`,children:r})]}),o&&(0,L.jsx)(`div`,{id:a,className:`ds-section-body`,children:n?(0,L.jsx)(A,{children:n}):i})]})}function sn({label:e,onClick:t,disabled:n,title:r}){return(0,L.jsx)(`button`,{type:`button`,className:`icon-btn ds-add`,"aria-label":e,title:r??e,disabled:n,onClick:t,children:(0,L.jsx)(ot,{size:12})})}function X({label:e,entries:t}){return(0,L.jsx)(D,{label:(0,L.jsx)(ot,{size:12}),ariaLabel:e,title:e,align:`right`,buttonClassName:`icon-btn ds-add`,entries:t})}function cn(e,t){return t.kind===`audio`||t.kind===`media`&&e?.assets.find(e=>e.id===t.assetId)?.kind===`video`}function ln({clip:e,fps:t,hasAudio:n}){let{updateClip:r}=I(),i=new Set(ce(e.kind,n));return(0,L.jsx)(Y,{id:`animation`,title:`Animation`,actions:(0,L.jsx)(X,{label:`Add animation`,entries:()=>{let t=[];for(let n of[`in`,`out`]){t.push({kind:`header`,label:n===`in`?`Animate in`:`Animate out`});for(let a of ze)t.push({kind:`item`,label:N(a),disabled:!i.has(a),onSelect:()=>r(e.id,`Add animation`,e=>({...e,presetAnimations:[...e.presetAnimations,Ce(a,n)]}))})}return t}}),children:e.presetAnimations.map(n=>{let i=(t,i,a=null)=>r(e.id,t,e=>({...e,presetAnimations:e.presetAnimations.map(e=>e.id===n.id?{...e,...i}:e)}),a);return(0,L.jsxs)(`div`,{className:`anim-entry`,children:[(0,L.jsxs)(`div`,{className:`effect-row`,children:[(0,L.jsx)(T,{className:`anim-dir`,value:n.direction,options:[{value:`in`,label:`In`},{value:`out`,label:`Out`}],onChange:e=>i(`Edit animation`,{direction:e})}),(0,L.jsx)(`span`,{className:`fx-label`,children:N(n.preset)}),(0,L.jsx)(C,{title:`Remove animation`,onClick:()=>r(e.id,`Remove animation`,e=>({...e,presetAnimations:e.presetAnimations.filter(e=>e.id!==n.id)})),children:`×`})]}),(0,L.jsxs)(O,{label:`Duration`,children:[(0,L.jsx)(E,{value:n.duration,fps:t,min:.05,step:.1,onCommit:e=>i(`Edit animation`,{duration:e})}),(0,L.jsx)(`span`,{className:`muted`,children:`s`})]}),(0,L.jsx)(O,{label:`Easing`,children:(0,L.jsx)(an,{value:n.easing,onChange:(e,t)=>i(`Edit animation`,{easing:e},t??null)})})]},n.id)})})}function un(e,t){return e===t?!0:!e||!t?!1:e.leftId===t.leftId&&e.rightId===t.rightId&&Te(e.presets,t.presets)}function dn({clipIds:e}){let{applyEnvelope:t}=I(),n=m(l),r=y(t=>{if(!t)return null;let n=Fe(t,e);return!n||n.left.kind===`audio`||n.right.kind===`audio`?null:{leftId:n.left.id,rightId:n.right.id,presets:Ke}},un);return r?(0,L.jsxs)(j,{title:`Transition`,children:[(0,L.jsx)(D,{label:`Add transition`,buttonClassName:`w-full`,entries:()=>r.presets.map(e=>({kind:`item`,label:N(e),onSelect:()=>{let i=n?.snapshot();i&&t(Le(i,r.leftId,r.rightId,e))}}))}),(0,L.jsx)(`div`,{className:`muted anim-hint text-q-caption-xs-regular`,children:`Plays across the cut, centred on it.`})]}):null}function fn(e,t){return e===t||!!e&&!!t&&e.target.rightId===t.target.rightId&&e.transition?.preset===t.transition?.preset&&e.transition?.duration===t.transition?.duration}function pn({clip:e,fps:t}){let{applyEnvelope:n}=I(),r=m(l),i=y(t=>{let n=t?M(t,e.id):null;if(!t||!n)return null;let r=Ge(t,n.scene).find(t=>t.left.id===e.id);return r?{target:r.target,transition:r.transition?{preset:r.transition.preset,duration:r.transition.duration}:null}:null},fn),a=(e,t)=>{let a=r?.snapshot();a&&i&&n(We(a,i.target,e,t))};return i?(0,L.jsx)(Y,{id:`transition`,title:`Transition`,actions:i.transition?null:(0,L.jsx)(X,{label:`Add transition`,entries:()=>Ke.map(e=>({kind:`item`,label:N(e),onSelect:()=>a(e)}))}),children:i.transition?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{label:`Type`,children:[(0,L.jsx)(T,{value:i.transition.preset,options:Ke.map(e=>({value:e,label:N(e)})),onChange:e=>a(e)}),(0,L.jsx)(C,{title:`Remove transition`,onClick:()=>a(null),children:`×`})]}),(0,L.jsxs)(O,{label:`Duration`,children:[(0,L.jsx)(E,{value:i.transition.duration,fps:t,min:.05,step:.1,onCommit:e=>a(i.transition.preset,e)}),(0,L.jsx)(`span`,{className:`muted`,children:`s`})]})]}):null}):(0,L.jsx)(Y,{id:`transition`,title:`Transition`,unavailable:`Only a clip followed by another in a <sequence> hands over with a transition.`})}var mn=new Set([`crash-zoom`,`whip-in`,`whip-out`,`shake`]);function hn({clip:e,fps:t}){let{updateClip:n}=I(),r=h(),i=y(e=>e),[a,o]=(0,F.useState)(null);if(!Qe(e))return null;let s=Xe(e),c=tt()&&!!i&&at(i,e)!==null,l=async(t,r,a=null)=>{o(null);let s={};if($e.has(t)){let t=i?await it(i,e).catch(()=>null):null;if(!t?.faces.some(e=>e.face)){o(`No face found in this clip.`);return}s={faces:t.faces,source:t.source}}n(e.id,`Camera: ${Je[t]}`,e=>et(e,t,{...r,...s}),a)},u=t=>{let n=r?.currentTime.get()??0,i=qe.has(t)?rt(e,n):null;l(t,i===null||i<.05?{}:{at:i})};return(0,L.jsxs)(j,{title:`Camera`,actions:(0,L.jsx)(D,{label:`+`,align:`right`,title:`Add camera move`,buttonClassName:`icon-btn`,entries:()=>nt.map(e=>({kind:`item`,label:Je[e],checked:s.includes(e),disabled:$e.has(e)&&!c,onSelect:()=>u(e)}))}),children:[a&&(0,L.jsx)(A,{children:a}),s.length===0&&(0,L.jsx)(A,{children:`No camera moves`}),s.map(r=>{let i=Ye(e,r)??{intensity:1,at:null,duration:null},a=e=>({intensity:i.intensity,...i.at===null?{}:{at:i.at},...i.duration===null?{}:{duration:i.duration},...e});return(0,L.jsxs)(`div`,{className:`anim-entry`,children:[(0,L.jsxs)(`div`,{className:`effect-row`,children:[(0,L.jsx)(`span`,{className:`fx-label`,children:Je[r]}),(0,L.jsx)(C,{title:`Remove camera move`,onClick:()=>n(e.id,`Remove camera move`,e=>Ze(e,r)),children:`×`})]}),(0,L.jsx)(O,{label:`Strength`,children:(0,L.jsx)(V,{value:i.intensity,min:.25,max:3,step:.05,format:e=>`${Math.round(e*100)}%`,onInput:(e,t)=>void l(r,a({intensity:e}),t)})}),mn.has(r)&&(0,L.jsxs)(O,{label:`Duration`,children:[(0,L.jsx)(E,{value:i.duration??(r===`shake`?.6:.3),fps:t,min:.05,step:.05,onCommit:e=>void l(r,a({duration:e}))}),(0,L.jsx)(`span`,{className:`muted`,children:`s`})]})]},r)})]})}function gn({clipId:e}){return y(t=>dt(t,e)?.clip.id??null)?(0,L.jsx)(j,{title:`Component props`,children:(0,L.jsx)(lt,{clipId:e})}):null}var Z=[{family:`Inter`,label:`Inter`,weights:[300,400,500,600,700,800],fallback:`sans-serif`,googleParam:`Inter`},{family:`Geologica`,label:`Geologica`,weights:[300,400,500,600,700,800],fallback:`sans-serif`,googleParam:`Geologica`},{family:`Nunito`,label:`Nunito`,weights:[300,400,500,600,700,800],fallback:`sans-serif`,googleParam:`Nunito`},{family:`Figtree`,label:`Figtree`,weights:[300,400,500,600,700,800],fallback:`sans-serif`,googleParam:`Figtree`},{family:`Urbanist`,label:`Urbanist`,weights:[300,400,500,600,700,800],fallback:`sans-serif`,googleParam:`Urbanist`},{family:`Montserrat`,label:`Montserrat`,weights:[300,400,500,600,700,800],fallback:`sans-serif`,googleParam:`Montserrat`},{family:`Bangers`,label:`Bangers`,weights:[400],fallback:`cursive`,googleParam:`Bangers`},{family:`Chewy`,label:`Chewy`,weights:[400],fallback:`cursive`,googleParam:`Chewy`},{family:`Source Code Pro`,label:`Source Code Pro`,weights:[300,400,500,600,700],fallback:`monospace`,googleParam:`Source+Code+Pro`},{family:`monospace`,label:`Monospace`,weights:[400,700],fallback:`monospace`,googleParam:null}];function Q(e){return e.family===e.fallback?e.fallback:`"${e.family}", ${e.fallback}`}function _n(){return`https://fonts.googleapis.com/css2?${Z.filter(e=>e.googleParam!==null).map(e=>`family=${e.googleParam}:wght@${e.weights.join(`;`)}`).join(`&`)}&display=swap`}function vn(){let e=[];for(let t of Z)if(t.googleParam!==null)for(let n of t.weights)e.push(`${n} 16px "${t.family}"`);return e}var yn=!1;function bn(e,t){if(!yn){if(yn=!0,!e.fonts?.load){t();return}if(!e.querySelector(`link[href*="fonts.googleapis.com/css2"]`)){let t=e.createElement(`link`);t.rel=`stylesheet`,t.href=_n(),e.head.appendChild(t)}Promise.allSettled(vn().map(t=>e.fonts.load(t))).then(()=>e.fonts.ready).then(t).catch(()=>t())}}function xn(){let e=m(ee),[t,n]=(0,F.useState)(()=>e?.entries()??[]);return(0,F.useEffect)(()=>{if(!e)return;n(e.entries());let t=e.onChange(()=>n(e.entries()));return()=>t.dispose()},[e]),{api:e,entries:t}}var Sn=e=>e.group.join(` / `);function Cn(e){let t=[...new Set(e.map(Sn))];return(t.includes(``)?[``,...t.filter(e=>e!==``)]:t).map(t=>({group:t,entries:e.filter(e=>Sn(e)===t)}))}var wn=(e,t)=>t-e>=10?1:.01;function Tn({api:e,entry:t}){let n=n=>e.set(t.file,t.name,n),{value:r,label:i}=t;switch(t.type){case`number`:{let a=Number(r),o={onGestureStart:()=>e.beginGesture(),onGestureEnd:()=>e.endGesture()};return t.min!==void 0&&t.max!==void 0?(0,L.jsxs)(O,{label:i,children:[(0,L.jsx)(ie,{value:a,min:t.min,max:t.max,step:t.step??wn(t.min,t.max),onInput:n,...o}),(0,L.jsx)(w,{value:a,min:t.min,max:t.max,step:t.step??1,label:i,onCommit:n,...o})]}):(0,L.jsx)(O,{label:i,children:(0,L.jsx)(w,{value:a,step:t.step??1,label:i,onCommit:n,...o,...t.min===void 0?{}:{min:t.min},...t.max===void 0?{}:{max:t.max}})})}case`color`:return(0,L.jsx)(O,{label:i,children:(0,L.jsx)(k,{value:String(r),label:i,onCommit:n})});case`text`:return(0,L.jsx)(O,{label:i,children:(0,L.jsx)(oe,{value:String(r),rows:2,onCommit:n})});case`boolean`:return(0,L.jsx)(O,{label:i,children:(0,L.jsx)(`input`,{type:`checkbox`,"aria-label":i,checked:r===!0,onChange:e=>n(e.target.checked)})});case`select`:return(0,L.jsx)(O,{label:i,children:(0,L.jsx)(T,{value:String(r),label:i,options:(t.options??[]).map(e=>({value:e,label:e})),onChange:n})});case`font`:{let e=String(r),t=Z.find(t=>t.family===e);return(0,L.jsx)(O,{label:i,children:(0,L.jsx)(`div`,{className:`picker`,children:(0,L.jsx)(D,{buttonClassName:`w-full justify-between`,label:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{style:{fontFamily:t?Q(t):e},children:t?.label??e}),(0,L.jsx)(`span`,{className:`muted`,children:(0,L.jsx)(S,{mode:`raw`,size:12})})]}),entries:()=>[...t?[]:[{kind:`item`,label:e,checked:!0,onSelect:()=>{}}],...Z.map(t=>({kind:`item`,label:t.label,checked:t.family===e,labelStyle:{fontFamily:Q(t)},onSelect:()=>n(t.family)}))]})})})}}}function En(){let{api:e,entries:t}=xn();return!e||!t.length?null:(0,L.jsx)(L.Fragment,{children:Cn(t).map(({group:t,entries:n})=>(0,L.jsx)(`div`,{"data-inspect-group":t,children:(0,L.jsx)(j,{title:t||`Variables`,children:n.map(t=>(0,L.jsx)(`div`,{"data-inspect":`${t.file}#${t.name}`,children:(0,L.jsx)(Tn,{api:e,entry:t})},`${t.file}#${t.name}`))})},t))})}function Dn(e){return e.background.type===`solid`?e.background.color:`#000000`}function On({doc:e,scene:t}){let{updateScene:n,applyEnvelope:r}=I(),i=(0,F.useRef)(null),a=(e,r)=>n(t.id,e,r),o=Ve.find(e=>e.width===t.width&&e.height===t.height)??null,s=()=>{let e=[];for(let t of He){e.push({kind:`header`,label:we[t]});for(let n of Ve.filter(e=>e.category===t))e.push({kind:`item`,label:n.ratioLabel?`${n.name} ${n.ratioLabel}`:n.name,detail:`${n.width}×${n.height}`,checked:o?.id===n.id,onSelect:()=>a(`Change scene size`,e=>({...e,width:n.width,height:n.height}))})}return e},c=t.tracks.reduce((e,t)=>e+t.clips.length,0);return(0,L.jsxs)(`div`,{ref:i,children:[(0,L.jsxs)(j,{title:`Scene`,children:[(0,L.jsx)(O,{label:`Name`,children:(0,L.jsx)(ae,{value:t.name,onCommit:e=>{let n=e.trim();n.length>0&&n!==t.name&&a(`Rename scene`,e=>({...e,name:n}))}})}),(0,L.jsx)(O,{label:`Aspect`,children:(0,L.jsx)(`div`,{className:`picker`,children:(0,L.jsx)(D,{buttonClassName:`w-full justify-between`,entries:s,label:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{children:o?`${o.name}${o.ratioLabel?` ${o.ratioLabel}`:``}`:`Custom`}),(0,L.jsx)(`span`,{className:`muted`,children:(0,L.jsx)(S,{mode:`raw`,size:12})})]})})})}),(0,L.jsxs)(O,{label:`Size`,children:[(0,L.jsx)(w,{value:t.width,min:2,onCommit:e=>a(`Resize scene`,t=>({...t,width:Math.round(e)}))}),(0,L.jsx)(`span`,{className:`muted`,children:`×`}),(0,L.jsx)(w,{value:t.height,min:2,onCommit:e=>a(`Resize scene`,t=>({...t,height:Math.round(e)}))})]}),(0,L.jsx)(O,{label:`Duration`,children:(0,L.jsxs)(`span`,{className:`muted`,children:[se(t.duration),` s`]})}),(0,L.jsx)(O,{label:`FPS`,children:(0,L.jsx)(w,{value:t.fps,min:1,max:120,onCommit:e=>a(`Change fps`,t=>({...t,fps:e}))})})]}),(0,L.jsx)(j,{title:`Background`,children:(0,L.jsx)(O,{label:`Color`,children:(0,L.jsx)(k,{value:Dn(t),onCommit:e=>a(`Change background`,t=>({...t,background:{type:`solid`,color:e}}))})})}),(0,L.jsx)(En,{}),P(`scene-list`)&&(0,L.jsx)(j,{children:(0,L.jsx)(x,{variant:`secondary`,size:`xs`,className:`w-full`,disabled:e.scenes.length<=1,onClick:()=>{c>0&&!p(i.current).confirm(`Delete "${t.name}" and its ${c} clip${c===1?``:`s`}?`)||r(Ie(e,t.id))},children:`Delete scene`})})]})}function kn(){return(0,L.jsx)(j,{children:(0,L.jsx)(A,{children:`No document open`})})}var An={literal:`static`,absent:`not set`,expression:`code-driven`,"loop-bound":`loop-bound`,"call-site":`from call site`,shared:`shared component`,spread:`spread`};function jn(e){let t=m(f),[n,r]=(0,F.useState)(null),[i,a]=(0,F.useState)(0);return(0,F.useEffect)(()=>{if(!t)return;let e=t.onChange(()=>a(e=>e+1));return()=>e.dispose()},[t]),(0,F.useEffect)(()=>{if(!t||!e){r(null);return}let n=!0;return t.describe(e).then(e=>{n&&r(e)}),()=>{n=!1}},[t,e,i]),n}var Mn=(e,t)=>{if(!e||`refused`in e)return!0;let n=e.props.find(e=>e.name===t);return!n||n.editable},Nn=(e,t)=>{if(`refused`in e)return!1;let n=e.props.find(e=>e.name===`animate`)?.value;return!!n&&typeof n==`object`&&!Array.isArray(n)&&t in n};function Pn({info:e}){if(!e)return null;if(`refused`in e)return(0,L.jsx)(j,{title:`Source`,children:(0,L.jsx)(A,{children:e.refused.reason})});let t=e.props.filter(e=>e.kind!==`absent`&&e.name!==`animate`);return(0,L.jsx)(j,{title:`Source`,children:(0,L.jsxs)(`div`,{className:`project-source`,"data-project-source":!0,children:[(0,L.jsxs)(`div`,{className:`project-source-file`,children:[e.file,`:`,e.line,e.component?` · inside <${e.component}>`:``]}),t.map(t=>(0,L.jsxs)(`div`,{className:`project-source-row`,"data-prop":t.name,"data-kind":t.kind,title:t.reason??t.source??``,children:[(0,L.jsx)(`span`,{className:`project-source-name`,children:t.name}),(0,L.jsxs)(`span`,{className:`project-source-kind`,"data-editable":t.editable,children:[Nn(e,t.name)?`keyframed`:An[t.kind],t.editable?``:` · read-only`]}),!t.editable&&t.source&&(0,L.jsx)(`code`,{className:`project-source-code`,children:t.source})]},t.name)),e.text&&(0,L.jsxs)(`div`,{className:`project-source-row`,"data-prop":`text`,"data-kind":e.text.kind,children:[(0,L.jsx)(`span`,{className:`project-source-name`,children:`text`}),(0,L.jsxs)(`span`,{className:`project-source-kind`,"data-editable":e.text.editable,children:[An[e.text.kind],e.text.editable?``:` · read-only`]}),!e.text.editable&&e.text.source&&(0,L.jsx)(`code`,{className:`project-source-code`,children:e.text.source})]})]})})}var Fn=[{type:`solid`,label:`Solid`},{type:`gradient`,label:`Gradient`},{type:`media`,label:`Media`}],In=[`cover`,`contain`,`fill`];function Ln({clip:e,assets:t}){let{updateClip:n}=I(),r=e.fill,i=t.filter(e=>e.kind===`image`||e.kind===`video`),[a,o]=(0,F.useState)(0),[s,c]=(0,F.useState)(null),l=(0,F.useRef)(``),u=(0,F.useRef)(null),d=(t,r=`Fill`,i=null)=>n(e.id,r,e=>({...e,fill:t}),i),f=e=>{if(r.type!==e){if(e===`solid`)d({type:`solid`,color:r.type===`gradient`?r.stops[0]?.color??`#ffffff`:`#808080`},`Solid fill`);else if(e===`gradient`){let e=r.type===`solid`?r.color:`#d1fe17`;o(0),d({type:`gradient`,gradientKind:`linear`,angle:90,stops:[{offset:0,color:e,opacity:1},{offset:1,color:e,opacity:0}]},`Gradient fill`)}else{let e=i[0];e&&d({type:`media`,assetId:e.id,fit:`cover`},`Media fill`)}}},p=(0,L.jsx)(O,{label:`Fill`,children:(0,L.jsx)(`div`,{className:`flex flex-1 gap-0.5 rounded-lg bg-q-background-tertiary p-0.5 [&>*]:flex-1`,children:Fn.map(e=>(0,L.jsx)(q,{label:e.label,active:r.type===e.type,disabled:e.type===`media`&&r.type!==`media`&&i.length===0,title:e.type===`media`&&i.length===0?`Import an image or video first`:void 0,onClick:()=>f(e.type)},e.type))})});if(r.type===`solid`)return(0,L.jsxs)(L.Fragment,{children:[p,(0,L.jsxs)(O,{label:`Color`,children:[(0,L.jsx)(k,{value:r.color,onCommit:e=>d({type:`solid`,color:e})}),(0,L.jsx)(H,{clip:e,property:`color`,value:r.color})]})]});if(r.type===`media`)return(0,L.jsxs)(L.Fragment,{children:[p,i.length===0?(0,L.jsx)(A,{children:`Import an image or video first`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(O,{label:`Asset`,children:(0,L.jsx)(T,{value:r.assetId,options:i.map(e=>({value:e.id,label:e.name})),onChange:e=>d({...r,assetId:e},`Media fill asset`)})}),(0,L.jsx)(O,{label:`Fit`,children:(0,L.jsx)(T,{value:r.fit,options:In.map(e=>({value:e,label:e})),onChange:e=>d({...r,fit:e},`Media fill fit`)})})]})]});let m=(e,t=`Fill`,n=null)=>d({...r,...e},t,n),h=(e,t,n=`Edit gradient stop`,i=null)=>m({stops:r.stops.map((n,r)=>r===e?{...n,...t}:n)},n,i),g=r.stops[a]?a:0,_=r.stops[g]??null,v=s?r.stops.map((e,t)=>t===s.index?{...e,offset:s.offset}:e):r.stops,y=e=>{let t=[...r.stops].sort((e,t)=>e.offset-t.offset),n=t[0],i=t[t.length-1];for(let r of t)if(r.offset<=e&&(n=r),r.offset>=e){i=r;break}let a=i.offset-n.offset,s=a>1e-6?(e-n.offset)/a:0,c={offset:e,color:Ue(n.color,i.color,s),opacity:n.opacity+(i.opacity-n.opacity)*s};o(r.stops.length),m({stops:[...r.stops,c]},`Add gradient stop`)},b=r.stops.length<=2;return(0,L.jsxs)(L.Fragment,{children:[p,(0,L.jsx)(`div`,{className:`grad-strip`,title:`Click to add a stop`,style:{background:ye(v)},onPointerDown:e=>{if(e.target!==e.currentTarget)return;let t=e.currentTarget.getBoundingClientRect();y(Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)))},children:r.stops.map((e,t)=>(0,L.jsx)(`button`,{type:`button`,className:`grad-handle${t===g?` active`:``}`,style:{left:`${(s?.index===t?s.offset:e.offset)*100}%`,background:le(e.color,1)},onPointerDown:n=>{n.stopPropagation(),n.preventDefault(),o(t),l.current=z(),u.current=n.currentTarget.parentElement.getBoundingClientRect(),n.currentTarget.setPointerCapture(n.pointerId),c({index:t,offset:e.offset})},onPointerMove:e=>{let n=u.current;if(!n||s?.index!==t)return;let r=Math.round(Math.min(1,Math.max(0,(e.clientX-n.left)/n.width))*1e3)/1e3;c({index:t,offset:r}),h(t,{offset:r},`Move gradient stop`,l.current)},onPointerUp:()=>c(null),onPointerCancel:()=>c(null)},t))}),_&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{label:`Stop`,children:[(0,L.jsx)(k,{value:_.color,onCommit:e=>h(g,{color:e})}),(0,L.jsx)(C,{title:`Remove stop`,disabled:b,onClick:()=>{b||(o(Math.max(0,Math.min(g,r.stops.length-2))),m({stops:r.stops.filter((e,t)=>t!==g)},`Remove gradient stop`))},children:`×`})]}),(0,L.jsx)(O,{label:`Opacity`,children:(0,L.jsx)(V,{value:_.opacity,min:0,max:1,step:.01,format:e=>`${Math.round(e*100)}%`,onInput:(e,t)=>h(g,{opacity:e},`Edit gradient stop`,t)})}),(0,L.jsx)(O,{label:`Offset`,children:(0,L.jsx)(w,{value:_.offset,min:0,max:1,step:.01,onCommit:e=>h(g,{offset:e})})})]}),(0,L.jsx)(O,{label:`Type`,children:(0,L.jsx)(T,{value:r.gradientKind,options:[{value:`linear`,label:`Linear`},{value:`radial`,label:`Radial`}],onChange:e=>m({gradientKind:e})})}),r.gradientKind===`linear`&&(0,L.jsxs)(O,{label:`Angle`,children:[(0,L.jsx)(w,{value:r.angle,step:1,onCommit:e=>m({angle:e})}),(0,L.jsx)(`span`,{className:`muted`,children:`°`})]})]})}function Rn(e){let t=e.origin;if(typeof t!=`object`||!t)return null;let n=t;return typeof n.file==`string`&&n.file!==``&&typeof n.line==`number`?{file:n.file,line:n.line}:null}function zn({clip:e}){let t=e.kind===`group`?`group · ${e.children.length} children`:e.kind,n=Rn(e);return(0,L.jsxs)(j,{children:[(0,L.jsxs)(`div`,{className:`section-head`,children:[(0,L.jsx)(`span`,{className:`section-title clip-name text-q-caption-sm-medium`,title:e.name,children:e.name}),(0,L.jsx)(`span`,{className:`muted`,children:t})]}),n&&(0,L.jsx)(`div`,{className:`muted`,title:`The line of the agent's edit script that declared this clip. Edits made here stay in this copy — the script is the source of truth.`,children:`declared at ${n.file}:${n.line}`})]})}var Bn={width:!1,height:!1},Vn=[{value:`left`,label:`Left`},{value:`right`,label:`Right`},{value:`center`,label:`Center`},{value:`stretch`,label:`Left & right`},{value:`scale`,label:`Scale`}],Hn=[{value:`top`,label:`Top`},{value:`bottom`,label:`Bottom`},{value:`center`,label:`Center`},{value:`stretch`,label:`Top & bottom`},{value:`scale`,label:`Scale`}];function Un({clip:e,sceneWidth:t,sceneHeight:n,disabled:r=!1,positioningDisabled:i=!1}){let{updateClip:a}=I(),o=(t,n,r=null)=>a(e.id,t,n,r),s=e.transform,c=(e,t,n=null)=>o(e,e=>({...e,transform:{...e.transform,...t}}),n),[l,u]=(0,F.useState)(s.scaleX===s.scaleY),[d,f]=(0,F.useState)(()=>new Set($)),p=d.has(`scale`)||s.scaleX!==1||s.scaleY!==1,m=d.has(`anchor`)||s.anchorX!==.5||s.anchorY!==.5,h=e=>{$.add(e),f(new Set($))},g=(e,t,n=null)=>c(`Scale`,l?{scaleX:t,scaleY:t}:{[e]:t},n),_=t/2,v=n/2;return(0,L.jsx)(Y,{id:`transform`,title:`Transform`,actions:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(X,{label:`Add transform property`,entries:()=>[{kind:`item`,label:`Scale`,disabled:p,onSelect:()=>h(`scale`)},{kind:`item`,label:`Anchor`,disabled:m,onSelect:()=>h(`anchor`)}]}),(0,L.jsx)(G,{title:`Reset all transform values`,disabled:r||i,onClick:()=>c(`Reset transform`,{x:_,y:v,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,anchorX:.5,anchorY:.5,flipX:!1,flipY:!1})})]}),children:(0,L.jsxs)(`fieldset`,{className:`contents`,disabled:r,children:[(0,L.jsxs)(O,{label:`Position`,children:[(0,L.jsx)(W,{axis:`X`,value:s.x-_,disabled:i,onCommit:(e,t)=>c(`Move`,{x:e+_},t)}),(0,L.jsx)(W,{axis:`Y`,value:s.y-v,disabled:i,onCommit:(e,t)=>c(`Move`,{y:e+v},t)}),(0,L.jsx)(U,{clip:e,disabled:i,targets:[{property:`positionX`,value:s.x},{property:`positionY`,value:s.y}]}),(0,L.jsx)(G,{title:`Reset position (scene center)`,disabled:i||s.x===_&&s.y===v,onClick:()=>c(`Reset position`,{x:_,y:v})})]}),(0,L.jsx)(It,{clipIds:[e.id],inline:!0}),(0,L.jsxs)(O,{label:`Constraints`,children:[(0,L.jsx)(T,{label:`Horizontal constraint`,title:`How it follows its parent's width`,value:e.constrainX??`left`,options:Vn,onChange:e=>o(`Constrain horizontally`,t=>({...t,constrainX:e===`left`?null:e}))}),(0,L.jsx)(T,{label:`Vertical constraint`,title:`How it follows its parent's height`,value:e.constrainY??`top`,options:Hn,onChange:e=>o(`Constrain vertically`,t=>({...t,constrainY:e===`top`?null:e}))})]}),p&&(0,L.jsxs)(O,{label:`Scale`,children:[(0,L.jsx)(W,{axis:`X`,value:s.scaleX,step:.05,onCommit:(e,t)=>g(`scaleX`,e,t)}),(0,L.jsx)(Zt,{linked:l,onToggle:()=>u(e=>!e)}),(0,L.jsx)(W,{axis:`Y`,value:s.scaleY,step:.05,onCommit:(e,t)=>g(`scaleY`,e,t)}),(0,L.jsx)(U,{clip:e,targets:l?[{property:`scale`,value:s.scaleX}]:[{property:`scaleX`,value:s.scaleX},{property:`scaleY`,value:s.scaleY}]}),(0,L.jsx)(G,{disabled:s.scaleX===1&&s.scaleY===1,onClick:()=>c(`Reset zoom`,{scaleX:1,scaleY:1})})]}),(0,L.jsxs)(O,{label:`Rotation`,children:[(0,L.jsx)(V,{value:s.rotation,min:-180,max:180,step:1,onInput:(t,n)=>a(e.id,`Rotate`,e=>({...e,transform:{...e.transform,rotation:t}}),n)}),(0,L.jsx)(w,{className:`angle-field`,value:s.rotation,step:1,onCommit:e=>c(`Rotate`,{rotation:e})}),(0,L.jsx)(H,{clip:e,property:`rotation`,value:s.rotation}),(0,L.jsx)(G,{disabled:s.rotation===0,onClick:()=>c(`Reset rotation`,{rotation:0})})]}),m&&(0,L.jsxs)(O,{label:`Anchor`,children:[(0,L.jsx)(W,{axis:`X`,value:s.anchorX,step:.05,onCommit:(e,t)=>c(`Anchor`,{anchorX:e},t)}),(0,L.jsx)(W,{axis:`Y`,value:s.anchorY,step:.05,onCommit:(e,t)=>c(`Anchor`,{anchorY:e},t)}),(0,L.jsx)(K,{}),(0,L.jsx)(G,{title:`Reset anchor (center)`,disabled:s.anchorX===.5&&s.anchorY===.5,onClick:()=>c(`Reset anchor`,{anchorX:.5,anchorY:.5})})]}),P(`skew-flip`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{label:`Skew`,children:[(0,L.jsx)(W,{axis:`X`,value:s.skewX,step:1,onCommit:(e,t)=>c(`Skew`,{skewX:e},t)}),(0,L.jsx)(W,{axis:`Y`,value:s.skewY,step:1,onCommit:(e,t)=>c(`Skew`,{skewY:e},t)}),(0,L.jsx)(U,{clip:e,targets:[{property:`skewX`,value:s.skewX},{property:`skewY`,value:s.skewY}]}),(0,L.jsx)(G,{disabled:s.skewX===0&&s.skewY===0,onClick:()=>c(`Reset skew`,{skewX:0,skewY:0})})]}),(0,L.jsxs)(O,{label:`Flip`,children:[(0,L.jsxs)(`div`,{className:`flex flex-1 gap-0.5 rounded-lg bg-q-background-tertiary p-0.5 [&>*]:flex-1`,children:[(0,L.jsx)(q,{label:`⇋ H`,title:`Flip horizontal`,active:s.flipX,onClick:()=>o(`Flip horizontal`,e=>({...e,transform:{...e.transform,flipX:!e.transform.flipX}}))}),(0,L.jsx)(q,{label:`⇵ V`,title:`Flip vertical`,active:s.flipY,onClick:()=>o(`Flip vertical`,e=>({...e,transform:{...e.transform,flipY:!e.transform.flipY}}))})]}),(0,L.jsx)(K,{}),(0,L.jsx)(G,{disabled:!s.flipX&&!s.flipY,onClick:()=>c(`Reset flip`,{flipX:!1,flipY:!1})})]})]})]})})}var $=new Set;function Wn({clip:e,disabled:t=!1,sizeDisabled:n=Bn}){let{updateClip:r}=I(),i=(t,n,i=null)=>r(e.id,t,n,i);return(0,L.jsx)(Y,{id:`layout`,title:`Layout`,children:(0,L.jsx)(`fieldset`,{className:`contents`,disabled:t,children:(0,L.jsxs)(O,{label:`Size`,children:[(0,L.jsx)(W,{axis:`W`,value:e.size.width,min:0,disabled:n.width,onCommit:(e,t)=>i(`Resize`,t=>({...t,size:{...t.size,width:e}}),t)}),(0,L.jsx)(W,{axis:`H`,value:e.size.height,min:0,disabled:n.height,onCommit:(e,t)=>i(`Resize`,t=>({...t,size:{...t.size,height:e}}),t)}),(0,L.jsx)(U,{clip:e,disabled:n.width||n.height,targets:[{property:`width`,value:e.size.width},{property:`height`,value:e.size.height}]}),(0,L.jsx)(K,{})]})})})}function Gn({clip:e,disabled:t=!1}){let{updateClip:n}=I(),r=(t,r)=>n(e.id,t,r),i=e.kind===`adjustment`?`An adjustment layer has no pixels of its own to fade, blend or round.`:null;return(0,L.jsx)(Y,{id:`appearance`,title:`Appearance`,unavailable:i,actions:(0,L.jsx)(`button`,{type:`button`,className:`icon-btn`,"aria-label":e.hidden?`Show element`:`Hide element`,title:e.hidden?`Show`:`Hide`,disabled:t,onClick:()=>r(e.hidden?`Show`:`Hide`,e=>({...e,hidden:!e.hidden})),children:e.hidden?(0,L.jsx)(c,{size:12}):(0,L.jsx)(pt,{size:12})}),children:(0,L.jsxs)(`fieldset`,{className:`contents`,disabled:t,children:[e.kind!==`adjustment`&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{label:`Opacity`,children:[(0,L.jsx)(V,{value:e.opacity,min:0,max:1,step:.01,format:e=>`${Math.round(e*100)}%`,onInput:(t,r)=>n(e.id,`Opacity`,e=>({...e,opacity:t}),r)}),(0,L.jsx)(H,{clip:e,property:`opacity`,value:e.opacity}),(0,L.jsx)(G,{disabled:e.opacity===1,onClick:()=>r(`Reset opacity`,e=>({...e,opacity:1}))})]}),(0,L.jsxs)(O,{label:`Blending`,children:[(0,L.jsx)(T,{value:e.blendMode,options:o.map(e=>({value:e,label:be[e]})),onChange:e=>r(`Blend mode`,t=>({...t,blendMode:e}))}),(0,L.jsx)(K,{}),(0,L.jsx)(G,{disabled:e.blendMode===`normal`,onClick:()=>r(`Reset blending`,e=>({...e,blendMode:`normal`}))})]})]}),(e.kind===`rect`||e.kind===`media`)&&(0,L.jsx)(Kn,{clip:e})]})})}function Kn({clip:e}){let{updateClip:t}=I(),n=e.cornerRadius,r=n=>t(e.id,`Corner radius`,e=>({...e,cornerRadius:n(e.cornerRadius)})),i={tl:`radiusTL`,tr:`radiusTR`,br:`radiusBR`,bl:`radiusBL`},a=t=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(w,{value:n[t],min:0,onCommit:e=>r(n=>({...n,mixed:!0,[t]:e}))}),(0,L.jsx)(H,{clip:e,property:i[t],value:n[t]})]}),o=P(`per-corner-radius`)&&(0,L.jsx)(C,{title:n.mixed?`Link corners`:`Separate corners`,active:n.mixed,onClick:()=>r(e=>e.mixed?{mixed:!1,uniform:e.tl,tl:e.tl,tr:e.tl,br:e.tl,bl:e.tl}:{...e,mixed:!0,tl:e.uniform,tr:e.uniform,br:e.uniform,bl:e.uniform}),children:`⛶`});return n.mixed?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{label:`Radius`,children:[(0,L.jsx)(`span`,{className:`muted`,style:{flex:1},children:`Per corner`}),o]}),(0,L.jsxs)(O,{label:`TL · TR`,children:[a(`tl`),a(`tr`)]}),(0,L.jsxs)(O,{label:`BL · BR`,children:[a(`bl`),a(`br`)]})]}):(0,L.jsxs)(O,{label:`Radius`,children:[(0,L.jsx)(w,{value:n.uniform,min:0,onCommit:e=>r(()=>({mixed:!1,uniform:e,tl:e,tr:e,br:e,bl:e}))}),(0,L.jsx)(H,{clip:e,property:`radius`,value:n.uniform}),o]})}function qn(e){return e.kind===`rect`&&e.drawnBy===`html`?`An <html> box's picture is its HTML children, drawn by code: edit them in the source.`:e.kind===`rect`&&e.drawnBy===`surface`?`A <surface>'s picture is drawn by code into its canvas: edit that code in the source.`:null}function Jn({clip:e,assets:t}){let n=qn(e),r=e.kind===`media`?t.find(t=>t.id===e.assetId):void 0;return(0,L.jsx)(Y,{id:`fill`,title:`Fill`,unavailable:n,actions:(0,L.jsx)(sn,{label:`Add fill`,title:`Higgsedit elements take one fill: edit it below`,disabled:!0,onClick:()=>{}}),children:e.kind===`media`?(0,L.jsx)(O,{label:r?.kind===`image`?`Image`:`Video`,children:(0,L.jsx)(`span`,{className:`fill-source`,title:e.assetId,children:r?.name??e.assetId})}):(0,L.jsx)(Ln,{clip:e,assets:t})})}function Yn({clip:e}){let{updateClip:t}=I();return P(`stroke`)?(0,L.jsx)(Y,{id:`border`,title:`Border`,children:(0,L.jsxs)(O,{label:`Stroke`,children:[(0,L.jsx)(k,{value:e.stroke.color,onCommit:n=>t(e.id,`Stroke`,e=>({...e,stroke:{...e.stroke,color:n}}))}),(0,L.jsx)(w,{value:e.stroke.width,min:0,onCommit:n=>t(e.id,`Stroke width`,e=>({...e,stroke:{...e.stroke,width:n}}))}),(0,L.jsx)(H,{clip:e,property:`strokeWidth`,value:e.stroke.width})]})}):(0,L.jsx)(Y,{id:`border`,title:`Border`,unavailable:`Strokes aren't in Higgsedit's element vocabulary yet: the write-back refuses them.`})}function Xn(){return(0,L.jsx)(Y,{id:`shadow`,title:`Shadow`,unavailable:`Higgsedit has no shadow on elements yet: no shadow prop, and drop-shadow isn't one of its effects.`})}function Zn({clip:e}){let{updateClip:t}=I(),n=Z.find(t=>t.family===e.fontFamily)??null;return(0,L.jsx)(`div`,{className:`picker`,children:(0,L.jsx)(D,{buttonClassName:`w-full justify-between`,label:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{style:{fontFamily:n?Q(n):e.fontFamily},children:n?.label??e.fontFamily}),(0,L.jsx)(`span`,{className:`muted`,children:(0,L.jsx)(S,{mode:`raw`,size:12})})]}),entries:()=>Z.map(n=>({kind:`item`,label:n.label,checked:n.family===e.fontFamily,labelStyle:{fontFamily:Q(n)},onSelect:()=>t(e.id,`Font`,e=>{let t=e,r=n.weights.reduce((e,n)=>Math.abs(n-t.fontWeight)<Math.abs(e-t.fontWeight)?n:e,n.weights[0]);return{...t,fontFamily:n.family,fontWeight:r}})}))})})}function Qn({clip:e}){let{updateClip:t}=I(),n=(n,r)=>t(e.id,n,e=>r(e)),r=[...Z.find(t=>t.family===e.fontFamily)?.weights??[300,400,500,600,700,800]];return r.includes(e.fontWeight)||r.push(e.fontWeight),r.sort((e,t)=>e-t),(0,L.jsxs)(Y,{id:`typography`,title:`Typography`,children:[(0,L.jsx)(oe,{className:`text-area`,value:e.text,onCommit:e=>n(`Edit text`,t=>({...t,text:e}))}),(0,L.jsx)(O,{label:`Font`,children:(0,L.jsx)(Zn,{clip:e})}),(0,L.jsx)(O,{label:`Size`,children:(0,L.jsx)(w,{value:e.fontSize,min:1,onCommit:e=>n(`Font size`,t=>({...t,fontSize:e}))})}),(0,L.jsxs)(O,{label:`Weight`,children:[(0,L.jsx)(T,{value:String(e.fontWeight),options:r.map(e=>({value:String(e),label:_e[e]??String(e)})),onChange:e=>n(`Font weight`,t=>({...t,fontWeight:Number(e)}))}),P(`italic`)&&(0,L.jsx)(C,{className:`style-btn italic-btn`,title:`Italic`,active:e.italic,onClick:()=>n(`Italic`,e=>({...e,italic:!e.italic})),children:`I`}),(0,L.jsx)(C,{className:`style-btn bold-btn`,title:`Bold`,active:e.fontWeight>=700,onClick:()=>n(`Bold`,e=>({...e,fontWeight:e.fontWeight>=700?400:700})),children:`B`})]}),(0,L.jsx)(O,{label:`Align`,children:(0,L.jsx)(`div`,{className:`flex flex-1 gap-0.5 rounded-lg bg-q-background-tertiary p-0.5 [&>*]:flex-1`,children:[`left`,`center`,`right`].map(t=>(0,L.jsx)(q,{label:t===`left`?`⟸`:t===`center`?`≡`:`⟹`,active:e.align===t,onClick:()=>n(`Align`,e=>({...e,align:t}))},t))})}),P(`letter-spacing`)&&(0,L.jsxs)(O,{label:`Spacing`,children:[(0,L.jsx)(w,{value:e.letterSpacing,step:.5,onCommit:e=>n(`Letter spacing`,t=>({...t,letterSpacing:e}))}),(0,L.jsx)(`span`,{className:`muted`,children:`px`})]}),(0,L.jsxs)(O,{label:`Line height`,children:[(0,L.jsx)(w,{value:e.lineHeight,min:.5,max:4,step:.1,onCommit:e=>n(`Line height`,t=>({...t,lineHeight:e}))}),(0,L.jsx)(`span`,{className:`muted`,children:`×`})]})]})}function $n({clip:e}){let{updateClip:t}=I();return(0,L.jsxs)(Y,{id:`audio`,title:`Audio`,children:[(0,L.jsxs)(O,{label:`Volume`,children:[(0,L.jsx)(V,{value:e.volume,min:0,max:1,step:.01,format:e=>`${Math.round(e*100)}%`,onInput:(n,r)=>t(e.id,`Volume`,e=>({...e,volume:n}),r)}),(0,L.jsx)(H,{clip:e,property:`volume`,value:e.volume})]}),(0,L.jsx)(O,{label:`Muted`,children:(0,L.jsx)(B,{checked:e.muted,onChange:n=>t(e.id,`Mute`,e=>({...e,muted:n}))})})]})}function er({clip:e,fps:t,playback:n,hasAudio:r}){let{updateClip:i}=I(),a=(t,n)=>i(e.id,t,e=>({...e,timeRange:{...e.timeRange,...n}})),o=e=>{n&&i(n.id,`Speed`,t=>Pe(t,e))};return(0,L.jsxs)(Y,{id:`time`,title:`Time`,children:[(0,L.jsxs)(O,{label:`Start`,children:[(0,L.jsx)(E,{value:e.timeRange.start,fps:t,min:0,onCommit:e=>a(`Move in time`,{start:e})}),(0,L.jsx)(`span`,{className:`muted`,children:`s`})]}),(0,L.jsxs)(O,{label:`Length`,children:[(0,L.jsx)(E,{value:e.timeRange.duration,fps:t,min:1/Math.max(1,t),onCommit:e=>a(`Change length`,{duration:e})}),(0,L.jsx)(`span`,{className:`muted`,children:`s`})]}),n&&(0,L.jsxs)(O,{label:`Speed`,children:[(0,L.jsx)(w,{value:n.speed,min:.1,max:10,step:.05,onCommit:o}),(0,L.jsx)(`span`,{className:`muted`,children:`×`}),(0,L.jsx)(G,{disabled:n.speed===1,onClick:()=>o(1)})]}),n&&r&&(0,L.jsx)(O,{label:`Preserve pitch`,children:(0,L.jsx)(B,{checked:n.preservePitch,onChange:e=>i(n.id,`Preserve pitch`,t=>({...t,preservePitch:e}))})})]})}function tr({clip:e}){let{updateClip:t}=I(),n=e.mask,r=(n,r,i=null)=>t(e.id,n,e=>e.mask?{...e,mask:{...e.mask,...r}}:e,i),i=n?(0,L.jsx)(C,{title:`Remove mask`,onClick:()=>t(e.id,`Remove mask`,e=>({...e,mask:null})),children:(0,L.jsx)(te,{mode:`raw`,size:12})}):(0,L.jsx)(sn,{label:`Add mask`,onClick:()=>t(e.id,`Add mask`,e=>({...e,mask:he(e.size)}))});return n?(0,L.jsxs)(Y,{id:`mask`,title:`Mask`,actions:i,children:[(0,L.jsxs)(O,{label:`Shape`,children:[(0,L.jsx)(T,{value:n.shape,options:[{value:`rectangle`,label:`Rectangle`},{value:`ellipse`,label:`Ellipse`}],onChange:e=>r(`Mask shape`,{shape:e})}),(0,L.jsx)(B,{checked:n.enabled,title:`Enabled`,onChange:e=>r(`Toggle mask`,{enabled:e})})]}),(0,L.jsxs)(O,{label:`Position`,children:[(0,L.jsx)(W,{axis:`X`,value:n.x,onCommit:(e,t)=>r(`Mask position`,{x:e},t)}),(0,L.jsx)(W,{axis:`Y`,value:n.y,onCommit:(e,t)=>r(`Mask position`,{y:e},t)})]}),(0,L.jsxs)(O,{label:`Size`,children:[(0,L.jsx)(W,{axis:`W`,value:n.width,min:0,onCommit:(e,t)=>r(`Mask size`,{width:e},t)}),(0,L.jsx)(W,{axis:`H`,value:n.height,min:0,onCommit:(e,t)=>r(`Mask size`,{height:e},t)})]}),(0,L.jsxs)(O,{label:`Rotation`,children:[(0,L.jsx)(V,{value:n.rotation,min:-180,max:180,step:1,onInput:(e,t)=>r(`Mask rotation`,{rotation:e},t)}),(0,L.jsx)(w,{className:`angle-field`,value:n.rotation,step:1,onCommit:e=>r(`Mask rotation`,{rotation:e})})]}),n.shape===`rectangle`&&(0,L.jsx)(O,{label:`Corner`,children:(0,L.jsx)(w,{value:n.cornerRadius,min:0,onCommit:e=>r(`Mask corner`,{cornerRadius:e})})}),(0,L.jsx)(O,{label:`Feather`,children:(0,L.jsx)(V,{value:n.feather,min:0,max:100,step:1,format:e=>`${Math.round(e)}px`,onInput:(e,t)=>r(`Mask feather`,{feather:e},t)})}),(0,L.jsx)(O,{label:`Invert`,children:(0,L.jsx)(B,{checked:n.invert,onChange:e=>r(`Invert mask`,{invert:e})})})]}):(0,L.jsx)(Y,{id:`mask`,title:`Mask`,actions:i})}function nr({clip:e,fx:t}){let{updateClip:n}=I(),r=(r,i=null)=>n(e.id,`Edit effect`,e=>({...e,effects:e.effects.map(e=>e.id===t.id?{...e,params:{...e.params,...r}}:e)}),i),i=e=>{let n=t.params[e];return typeof n==`number`&&Number.isFinite(n)?n:0};return(0,L.jsxs)(`div`,{className:`effect`,children:[(0,L.jsxs)(`div`,{className:`effect-row`,children:[(0,L.jsx)(B,{checked:t.enabled,title:`Enabled`,onChange:r=>n(e.id,`Edit effect`,e=>({...e,effects:e.effects.map(e=>e.id===t.id?{...e,enabled:r}:e)}))}),(0,L.jsx)(`span`,{className:`fx-label`,children:pe(t.kind)}),(0,L.jsx)(C,{title:`Remove effect`,onClick:()=>n(e.id,`Remove effect`,e=>({...e,effects:e.effects.filter(e=>e.id!==t.id),animations:e.animations.filter(e=>e.effectId!==t.id)})),children:(0,L.jsx)(te,{mode:`raw`,size:12})})]}),t.kind===`drop-shadow`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(O,{label:`Offset`,children:[(0,L.jsx)(W,{axis:`X`,value:i(`offsetX`),onCommit:(e,t)=>r({offsetX:e},t)}),(0,L.jsx)(W,{axis:`Y`,value:i(`offsetY`),onCommit:(e,t)=>r({offsetY:e},t)})]}),(0,L.jsx)(O,{label:`Blur`,children:(0,L.jsx)(w,{value:i(`blur`),min:0,onCommit:e=>r({blur:e})})}),(0,L.jsx)(O,{label:`Color`,children:(0,L.jsx)(k,{value:typeof t.params.color==`string`?t.params.color:`#000000`,onCommit:e=>r({color:e})})})]}):(0,L.jsxs)(`div`,{className:`effect-row`,children:[(0,L.jsx)(V,{value:i(`value`),min:me(t.kind).min,max:me(t.kind).max,step:me(t.kind).step,format:e=>String(Math.round(e*100)/100),onInput:(e,t)=>r({value:e},t)}),(0,L.jsx)(H,{clip:e,property:`effectParam`,value:i(`value`),effectId:t.id,effectParam:`value`})]})]})}function rr({clip:e}){let t=v(),[n,r]=(0,F.useState)([]),i=e.kind,a=e.locked;return(0,F.useEffect)(()=>{let n=!1;return t.menus.items(`inspector/clip`,{clipId:e.id,clipKind:i,clipLocked:a}).then(e=>{n||r(e)}).catch(()=>{n||r([])}),()=>{n=!0}},[t,e.id,i,a]),n.length===0?null:(0,L.jsx)(Y,{id:`ai-edit`,title:`AI Edit`,children:(0,L.jsx)(`div`,{className:`ai-edit-grid`,children:n.map(e=>(0,L.jsx)(x,{variant:`secondary`,size:`xxs`,onClick:()=>{t.commands.execute(e.command).catch(n=>t.log.error(`menu "${e.id}" failed`,String(n)))},children:e.title},e.id))})})}function ir({clip:e}){let{updateClip:t}=I(),n=n=>t(e.id,`Add effect`,e=>({...e,effects:[...e.effects,{id:ge(),kind:n,enabled:!0,params:ve(n)}]}));return(0,L.jsx)(Y,{id:`effects`,title:`Effects`,actions:(0,L.jsx)(X,{label:`Add effect`,entries:()=>[...st(`drop-shadow`)?[{kind:`item`,label:de[`drop-shadow`],onSelect:()=>n(`drop-shadow`)},{kind:`separator`}]:[],...ue.filter(st).map(e=>({kind:`item`,label:de[e],onSelect:()=>n(e)}))]}),children:e.effects.map(t=>(0,L.jsx)(nr,{clip:e,fx:t},t.id))})}var ar=e=>e.charAt(0).toUpperCase()+e.slice(1);function or({clip:e}){let{updateClip:t}=I(),n=e.captions,o=(n,r)=>t(e.id,n,e=>{let t=e;return{...t,captions:{...t.captions,...r}}}),s=a(n.preset).slots;return(0,L.jsxs)(Y,{id:`caption`,title:`Caption`,children:[(0,L.jsx)(O,{label:`Preset`,children:(0,L.jsx)(T,{value:n.preset,options:i.map(e=>({value:e,label:ar(e)})),onChange:e=>o(`Caption preset`,{preset:e,colors:[]})})}),(0,L.jsx)(O,{label:`Position`,children:(0,L.jsx)(T,{value:n.verticalAlign,options:r.map(e=>({value:e,label:ar(e)})),onChange:e=>o(`Caption position`,{verticalAlign:e})})}),s.map((e,t)=>(0,L.jsx)(O,{label:`Color ${t+1}`,children:(0,L.jsx)(k,{value:n.colors[t]??e,onCommit:e=>{let r=s.map((e,t)=>n.colors[t]??e);r[t]=e,o(`Caption colour`,{colors:r})}})},t))]})}var sr={clipIds:[],sceneId:null,enteredGroupId:null},cr={zoom:1,panX:0,panY:0};function lr(){let e=v(),t=h(),n=m(l),r=g(t?.selection,sr),i=g(t?.camera,cr,e=>e.zoom),a=(0,F.useRef)(null),o=(0,F.useMemo)(()=>{let t=t=>{e.commands.execute(`document.apply`,t).catch(t=>{e.log.error(`inspector: document.apply failed — ${t instanceof Error?t.message:String(t)}`)})};return{updateClip(e,r,i,a=null){let o=n?.snapshot();if(!o)return;let s=Oe(o,e,r,i,a);s&&t(s)},updateScene(e,r,i,a=null){let o=n?.snapshot();if(!o)return;let s=je(o,e,r,i,a);s&&t(s)},applyEnvelope(e){e&&t(e)}}},[e,n]);return(0,F.useEffect)(()=>{if(!t)return;let e=a.current?.ownerDocument;e&&bn(e,()=>t.requestRender())},[t]),(0,L.jsxs)(`div`,{ref:a,className:`fable-inspector text-q-caption-sm-regular text-q-text-primary`,"data-theme":`default-dark`,children:[(0,L.jsxs)(`div`,{className:`panel-header`,children:[(0,L.jsx)(`span`,{className:`text-q-caption-sm-medium`,children:`Inspector`}),(0,L.jsx)(gr,{zoom:i})]}),(0,L.jsx)(`div`,{className:`inspector-body`,children:(0,L.jsx)(Dt,{value:o,children:(0,L.jsx)(ur,{selection:r})})})]})}function ur({selection:e}){let t=y(t=>t?e.clipIds.filter(e=>M(t,e)!==null):[],Te);return t.length===1?(0,L.jsx)(fr,{clipId:t[0]},t[0]):t.length>1?(0,L.jsx)(pr,{clipIds:t}):(0,L.jsx)(hr,{sceneId:e.sceneId})}function dr(e,t){return e?.clip===t?.clip&&e?.fps===t?.fps&&e?.sceneWidth===t?.sceneWidth&&e?.sceneHeight===t?.sceneHeight&&e?.assets===t?.assets&&e?.hasAudio===t?.hasAudio&&e?.directControlsDisabled===t?.directControlsDisabled&&e?.positioningDisabled===t?.positioningDisabled&&e?.widthManaged===t?.widthManaged&&e?.heightManaged===t?.heightManaged}function fr({clipId:e}){let t=y(t=>{if(!t)return null;let n=M(t,e);if(!n)return null;let r=ft(t,e),i=r?.locked===!0||r?.sealed===!0,a=i||r?.parent?.autoLayout!=null;return{clip:n.clip,fps:n.scene.fps,sceneWidth:n.scene.width,sceneHeight:n.scene.height,assets:t.assets,hasAudio:cn(t,n.clip),directControlsDisabled:i,positioningDisabled:a,widthManaged:i||(r?.layout!=null||r?.parent?.autoLayout!=null)&&r.sizing.width!==`fixed`,heightManaged:i||(r?.layout!=null||r?.parent?.autoLayout!=null)&&r.sizing.height!==`fixed`}},dr),n=jn(t?e:null);if(!t)return null;let{clip:r,fps:i,sceneWidth:a,sceneHeight:o,assets:s,hasAudio:c,directControlsDisabled:l,positioningDisabled:d,widthManaged:f,heightManaged:p}=t,m=r.kind===`audio`||r.kind===`media`&&c,h=Ee(s,r),g=r.kind!==`audio`,_=(r.kind===`media`||r.kind===`audio`)&&!h?r:null,v=!Mn(n,`x`)||!Mn(n,`y`);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(zn,{clip:r}),(0,L.jsx)(Pn,{info:n}),(0,L.jsx)(`fieldset`,{className:`contents`,disabled:l,children:(0,L.jsx)(er,{clip:r,fps:i,playback:_,hasAudio:c})}),g&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Un,{clip:r,sceneWidth:a,sceneHeight:o,disabled:l,positioningDisabled:d||v}),(0,L.jsx)(Wn,{clip:r,disabled:l,sizeDisabled:{width:f,height:p}}),(0,L.jsx)(Gn,{clip:r,disabled:l})]}),P(`auto-layout`)&&(0,L.jsx)(ct,{clipId:r.id}),(0,L.jsxs)(`fieldset`,{className:`contents`,disabled:l,children:[u(r)&&(0,L.jsx)(or,{clip:r}),r.kind===`text`&&(0,L.jsx)(Qn,{clip:r}),(r.kind===`rect`||r.kind===`text`||r.kind===`media`)&&(0,L.jsx)(Jn,{clip:r,assets:s}),(r.kind===`rect`||r.kind===`text`)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Yn,{clip:r}),(0,L.jsx)(Xn,{})]}),g&&r.kind!==`adjustment`&&P(`effects`)&&(0,L.jsx)(ir,{clip:r})]}),(0,L.jsx)(gn,{clipId:r.id}),(0,L.jsxs)(`fieldset`,{className:`contents`,disabled:l,children:[P(`camera`)&&(0,L.jsx)(hn,{clip:r,fps:i}),(0,L.jsx)(ln,{clip:r,fps:i,hasAudio:c}),g&&(0,L.jsx)(pn,{clip:r,fps:i}),g&&r.kind!==`adjustment`&&(0,L.jsx)(tr,{clip:r}),m&&(r.kind===`media`||r.kind===`audio`)&&(0,L.jsx)($n,{clip:r}),(0,L.jsx)(rr,{clip:r})]})]})}function pr({clipIds:e}){let{applyEnvelope:t}=I(),n=h(),r=m(l);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(It,{clipIds:e}),P(`auto-layout`)&&(0,L.jsx)(ut,{clipIds:e}),(0,L.jsx)(j,{title:`${e.length} clips selected`,children:(0,L.jsx)(x,{variant:`secondary`,size:`xs`,className:`w-full`,onClick:()=>{let i=r?.snapshot();i&&(t(Ne(i,e)),n?.clearSelection())},children:`Delete clips`})}),(0,L.jsx)(dn,{clipIds:e})]})}function mr(e,t){return e.doc===t.doc&&e.scene===t.scene}function hr({sceneId:e}){let t=y(t=>{if(!t)return{doc:null,scene:null};let n=e??t.activeSceneId;return{doc:t,scene:t.scenes.find(e=>e.id===n)??t.scenes[0]??null}},mr);return t.doc?t.scene?(0,L.jsx)(On,{doc:t.doc,scene:t.scene}):(0,L.jsx)(j,{children:(0,L.jsx)(A,{children:`No scene`})}):(0,L.jsx)(kn,{})}function gr({zoom:e}){let t=_(`fable.panel-viewport.zoomToFit`),n=_(`fable.panel-viewport.zoomToActual`),r=_(`fable.panel-viewport.zoomIn`),i=_(`fable.panel-viewport.zoomOut`),a=_(`fable.panel-viewport.zoomToSelection`),o=h(),s=g(o?.selection,null)?.clipIds.length??0,c=y(e=>e?`${e.id}\n${e.activeSceneId}`:null);return(0,L.jsx)(D,{label:(0,L.jsxs)(`span`,{className:`zoom-readout text-q-mono-sm-regular text-q-text-tertiary`,children:[`${Math.round(e*100)}%`,` ▾`]}),ariaLabel:`Zoom`,title:`Zoom`,align:`right`,buttonClassName:`zoom-menu`,entries:()=>[{kind:`item`,label:`Zoom in`,shortcut:`⌘=`,onSelect:()=>void r()},{kind:`item`,label:`Zoom out`,shortcut:`⌘-`,onSelect:()=>void i()},{kind:`item`,label:`Zoom to selection`,shortcut:`⌘2`,disabled:s===0,onSelect:()=>void a()},{kind:`item`,label:`Zoom to fit`,disabled:!c,onSelect:()=>{let[e,n]=c.split(`
|
|
2
|
-
`);t({documentId:e,sceneId:n,scope:`scene`})}},{kind:`item`,label:`Fit content`,shortcut:`⌘1`,onSelect:()=>void t()},{kind:`item`,label:`100%`,shortcut:`⌘0`,onSelect:()=>void n()}]})}export{lr as default};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{a as e,n as t,t as n}from"./jsx-runtime-B-hcVAMW.js";import{d as r,n as i,p as a,u as o}from"./session-B9sZaFKC.js";import{t as s}from"./typography-C5-w9LOu-kD3uLKkf.js";import{t as c}from"./tabs-CvKQ-eas.js";import{C as l,a as u,c as d,d as f,g as p,o as m,p as h,s as g,u as _,y as v}from"../editor-Csn2_T_e.js";import{t as y}from"./fit-imported-media-CaCB0x0b.js";import{t as b}from"./button-CjG6GcgF.js";import{n as x,t as S}from"./toggle-CrzrwiDZ.js";import{t as C}from"./IconChevronDownSmall-BhTBJk26.js";import{t as w}from"./IconPencil-Dr17k_7e.js";import{_ as T,c as E,f as D,i as O,n as k,o as A,r as j}from"./components-e3ZbUVns.js";import{m as M}from"./edits-a2IixhrN.js";import{n as ee,r as N,t as te}from"./IconText1-BaP_p9DW.js";import{n as ne}from"./import-error-CMARA0Hy.js";import{t as P}from"./asset-op-C6YhYJcd.js";import{a as F,r as re,s as ie,t as ae}from"./IconEyeOpen-BqTT9_VV.js";import{A as I,C as oe,D as se,E as L,F as ce,I as le,L as ue,M as de,N as R,O as fe,P as z,R as B,S as pe,T as V,_ as me,a as he,b as ge,c as _e,d as ve,f as ye,g as be,h as xe,i as Se,j as H,k as Ce,l as we,m as Te,n as Ee,o as De,p as Oe,r as ke,s as Ae,t as je,u as Me,v as Ne,w as Pe,x as Fe,y as Ie}from"./IconChainLink1-Cwv1X7hi.js";import{n as Le,t as Re}from"./palette-CcS9IcAC.js";import{a as ze,i as Be,n as Ve,r as He,t as Ue}from"./drag-HLBkto5o.js";import{t as We}from"./IconPlay-BroH3ziH.js";import{n as Ge,t as Ke}from"./IconTrashCan-DX2w2AIC.js";import{t as qe}from"./IconPlayFilled-CwdgIuDG.js";var U=e(t(),1);function W(){let e=globalThis.crypto;return e&&`randomUUID`in e?e.randomUUID():`id-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}var G=e=>e;function K(e,t,n=null){return{id:W(),name:e,ops:t,coalesceKey:n}}function q(e,t,n,r,i=null){let a=ge(e,t);if(!a)return null;let o=null;for(let n of e.scenes)if(o=Ie(n,t)?.clip??null,o)break;if(!o)return null;let s=r(o);return s===o?null:K(n,[{op:`set`,path:a,value:G(s)}],i)}function Je(e,t,n,r){let i=[];for(let n of t){let t=ge(e,n.clipId);t&&(i.push({op:`set`,path:[...t,`transform`],value:G(n.transform)}),n.size&&i.push({op:`set`,path:[...t,`size`],value:G(n.size)}))}return i.length>0?K(n,i,r):null}function Ye(e,t,n,r,i){let a=e.scenes.findIndex(e=>e.id===t);if(a===-1)return null;let o=e.scenes[a].tracks,s=o[o.length-1]??null,c=i.planClipPlacement(e,t,n,{preferredTrackId:s?.id??null});if(!c)return null;if(s===null||c.createdTrack||c.trackId===s.id)return K(r,c.ops);let l={...ft(),name:J(o),clips:[n]};return K(r,[{op:`insert`,path:[`scenes`,a,`tracks`],index:o.length,value:G(l)}])}function J(e){let t=new Set(e.map(e=>e.name)),n=e.length+1;for(;t.has(`Track ${n}`);)n++;return`Track ${n}`}var Xe=5;function Ze(e,t,n,r){let i=e.kind===`image`?Xe:e.duration??Xe,a={id:W(),name:e.name,opacity:1,blendMode:`normal`,effects:[],timeRange:{start:n,duration:i},animations:[],presetAnimations:[],mask:null,locked:!1,hidden:!1};if(e.kind===`audio`)return{...a,kind:`audio`,assetId:e.id,size:{width:0,height:0},transform:{...Y},trim:{start:0,end:e.duration??i},volume:1,muted:!1,speed:1,preservePitch:!0};let o=e.width!=null&&e.width>0?e.width:t.width,s=e.height!=null&&e.height>0?e.height:t.height,c=Math.min(t.width/o,t.height/s),l=r??{x:t.width/2,y:t.height/2},u=o*c/2,d=s*c/2;return{...a,kind:`media`,assetId:e.id,size:{width:o,height:s},transform:{...Y,x:Math.min(Math.max(l.x,u),t.width-u),y:Math.min(Math.max(l.y,d),t.height-d),scaleX:c,scaleY:c},trim:{start:0,end:e.duration??i},volume:1,muted:!1,speed:1,preservePitch:!0,cornerRadius:{mixed:!1,uniform:0,tl:0,tr:0,br:0,bl:0}}}function Qe(e,t,n,r,i){let a=i.planClipPlacement(e,t.id,n);if(!a)return null;let o=[...a.ops];return e.activeSceneId!==t.id&&o.push({op:`set`,path:[`activeSceneId`],value:t.id}),{envelope:K(r,o),clipId:n.id}}function $e(e,t,n,r,i,a){let o=e.scenes.find(e=>e.id===n),s=e.assets.find(e=>e.id===t);return!o||!s?null:Qe(e,o,Ze(s,o,Math.max(r,0),i),`Add clip`,a)}function et(e,t,n,r,i,a){let o=$e({...e,assets:[...e.assets.filter(e=>e.id!==t.id),t]},t.id,n,r,i,a);return o?{envelope:K(`Import and add clip`,[P(e,t,G(t)),...o.envelope.ops]),clipId:o.clipId}:null}var tt=5;function nt(e,t,n){let r=new Set,i=n=>{if(n===t)return!0;if(r.has(n))return!1;r.add(n);let a=e.scenes.find(e=>e.id===n);if(!a)return!1;for(let e of a.tracks)for(let t of e.clips)if(t.kind===`scene`&&i(t.sceneId))return!0;return!1};return i(n)}function rt(e,t,n,r){let i=Math.min(1,t.width/e.width,t.height/e.height),a=r??{x:t.width/2,y:t.height/2},o=e.duration>0?e.duration:tt;return{id:W(),kind:`scene`,sceneId:e.id,name:e.name,opacity:1,blendMode:`normal`,effects:[],timeRange:{start:n,duration:o},trim:{start:0,end:o},speed:1,animations:[],presetAnimations:[],mask:null,locked:!1,hidden:!1,size:{width:e.width,height:e.height},transform:{...Y,x:a.x,y:a.y,scaleX:i,scaleY:i}}}function it(e,t,n,r,i,a){let o=e.scenes.find(e=>e.id===n),s=e.scenes.find(e=>e.id===t);return!o||!s||nt(e,o.id,s.id)?null:Qe(e,o,rt(s,o,Math.max(r,0),i),`Add scene clip`,a)}function at(e,t,n){let r=ge(e,t);return r?K(`Edit text`,[{op:`set`,path:[...r,`text`],value:n}]):null}function ot(e,t,n){let r=Fe(e,t);return r?K(`Rename scene`,[{op:`set`,path:[...r,`name`],value:n}]):null}function st(e,t){return e.activeSceneId===t||!e.scenes.some(e=>e.id===t)?null:K(`Switch scene`,[{op:`set`,path:[`activeSceneId`],value:t}])}function ct(e,t){return K(`Add scene`,[{op:`insert`,path:[`scenes`],index:e.scenes.length,value:G(t)},{op:`set`,path:[`activeSceneId`],value:t.id}])}function lt(e,t){if(e.scenes.length<=1)return null;let n=e.scenes.findIndex(e=>e.id===t);if(n===-1)return null;let r=[];if(e.activeSceneId===t){let t=e.scenes[n+1]??e.scenes[n-1];r.push({op:`set`,path:[`activeSceneId`],value:t.id})}return r.push({op:`remove`,path:[`scenes`],index:n}),K(`Delete scene`,r)}var Y={x:0,y:0,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,anchorX:.5,anchorY:.5,flipX:!1,flipY:!1};function X(e,t){return{start:Math.max(t,0),duration:5}}function ut(e,t,n,r){return{id:W(),name:`Rectangle`,kind:`rect`,transform:{...Y,x:n.x,y:n.y},size:{width:Math.max(r.width,1),height:Math.max(r.height,1)},opacity:1,blendMode:`normal`,effects:[],timeRange:X(e,t),animations:[],presetAnimations:[],mask:null,locked:!1,hidden:!1,fill:{type:`solid`,color:`#d9d9d9`},stroke:{color:`#000000`,width:0},cornerRadius:{mixed:!1,uniform:0,tl:0,tr:0,br:0,bl:0}}}function dt(e,t,n,r){let i=1.2;return{id:W(),name:`Text`,kind:`text`,text:`Text`,fontFamily:`Inter`,fontSize:64,fontWeight:400,italic:!1,letterSpacing:0,lineHeight:i,align:`left`,fill:{type:`solid`,color:`#ffffff`},stroke:{color:`#000000`,width:0},motion:null,transform:{...Y,x:n.x,y:n.y},size:{width:Math.max(r,10),height:64*i},opacity:1,blendMode:`normal`,effects:[],timeRange:X(e,t),animations:[],presetAnimations:[],mask:null,locked:!1,hidden:!1}}function ft(){return{id:W(),name:`Track 1`,clips:[],locked:!1,hidden:!1,muted:!1,solo:!1,mode:`default`,volume:1}}function pt(e,t){let n=e.scenes.length+1;for(;e.scenes.some(e=>e.name===`Scene ${n}`);)n++;return{id:W(),name:`Scene ${n}`,x:Math.round(t.x),y:Math.round(t.y),width:t.width,height:t.height,background:{type:`solid`,color:`#000000`},fps:30,duration:0,tracks:[ft()],markers:[]}}var Z=n();function mt(e,t){return e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.name===t[n].name)}function ht(e){let t=new Map,n=(e,r)=>{for(let i of e)i.kind===`scene`&&!t.has(i.sceneId)&&t.set(i.sceneId,r),i.kind===`group`&&n(i.children,r)};for(let t of e.scenes)for(let e of t.tracks)n(e.clips,t.id);return t}function gt(e,t){if(!t)return[];let n=ht(e),r=new Map(e.scenes.map(e=>[e.id,e])),i=[],a=new Set,o=t;for(;o&&!a.has(o);){a.add(o);let e=r.get(o);if(!e)break;i.unshift({id:e.id,name:e.name}),o=n.get(o)}return i}function _t(){let e=h(),t=d(),n=u(r),i=m(`fable.panel-viewport.zoomToFit`),a=g(e=>e?gt(e,e.activeSceneId):[],mt),o=r=>{let a=n?.snapshot();if(!a||!t)return;let o=st(a,r);if(!o){i();return}e.commands.execute(`document.apply`,o).then(()=>i()).catch(t=>e.log.error(`Switch scene failed`,{error:String(t)}));let s=a.scenes.find(e=>e.id===r);t.setSelection({enteredGroupId:null}),s&&t.seek(Math.min(t.currentTime.get(),s.duration))};return a.length<=1?null:(0,Z.jsx)(`nav`,{className:`fv-design-title`,"aria-label":`Scene path`,children:a.map((e,t)=>{let n=t===a.length-1;return(0,Z.jsxs)(`span`,{className:`fv-crumb-item`,children:[t>0&&(0,Z.jsx)(`span`,{className:`fv-crumb-sep`,"aria-hidden":`true`,children:`/`}),n?(0,Z.jsx)(s,{as:`span`,variant:`label-sm-medium`,color:`primary`,className:`fv-crumb fv-crumb-current`,"aria-current":`page`,children:e.name}):(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,className:`fv-crumb`,onClick:()=>o(e.id),children:e.name})]},e.id)})})}var vt=e=>{let t=U.useId();return U.createElement(St,{...e,instanceId:t})},yt=0,bt=typeof U.useId==`function`?void 0:class extends U.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++yt}`})}render(){return U.createElement(St,{...this.props.iconProps,instanceId:this.state.instanceId})}},xt=U.forwardRef((e,t)=>bt?U.createElement(bt,{iconProps:{...e,svgRef:t}}):U.createElement(vt,{...e,svgRef:t}));xt.displayName=`CentralIconBase`;var St=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return U.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&U.createElement(`title`,null,y),g?U.createElement(U.Fragment,null,U.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},U.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),U.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),U.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ct=U.memo(U.forwardRef((e,t)=>U.createElement(xt,{...e,ref:t,ariaLabel:`color-palette, colours`,maskId:`round-outlined-radius-2-stroke-1.5-IconColorPalette`},U.createElement(`path`,{d:`M21.25 12C21.25 19.1094 13.6572 12.7979 12 16.1176C10.9722 18.1765 14.9058 20.75 12 20.75C6.89137 20.75 2.75 16.8325 2.75 12C2.75 7.16751 6.89137 3.25 12 3.25C17.1086 3.25 21.25 7.16751 21.25 12Z`,stroke:`currentColor`,strokeWidth:`1.5`}),U.createElement(`path`,{d:`M11.5 7.75C11.5 8.44036 10.9404 9 10.25 9C9.55964 9 9 8.44036 9 7.75C9 7.05964 9.55964 6.5 10.25 6.5C10.9404 6.5 11.5 7.05964 11.5 7.75Z`,stroke:`currentColor`,strokeWidth:`1.5`}),U.createElement(`path`,{d:`M8.5 12C8.5 12.6904 7.94036 13.25 7.25 13.25C6.55964 13.25 6 12.6904 6 12C6 11.3096 6.55964 10.75 7.25 10.75C7.94036 10.75 8.5 11.3096 8.5 12Z`,stroke:`currentColor`,strokeWidth:`1.5`}),U.createElement(`path`,{d:`M16.5 9.25C16.5 9.94036 15.9404 10.5 15.25 10.5C14.5596 10.5 14 9.94036 14 9.25C14 8.55964 14.5596 8 15.25 8C15.9404 8 16.5 8.55964 16.5 9.25Z`,stroke:`currentColor`,strokeWidth:`1.5`})))),wt=e=>{let t=U.useId();return U.createElement(Ot,{...e,instanceId:t})},Tt=0,Et=typeof U.useId==`function`?void 0:class extends U.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++Tt}`})}render(){return U.createElement(Ot,{...this.props.iconProps,instanceId:this.state.instanceId})}},Dt=U.forwardRef((e,t)=>Et?U.createElement(Et,{iconProps:{...e,svgRef:t}}):U.createElement(wt,{...e,svgRef:t}));Dt.displayName=`CentralIconBase`;var Ot=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return U.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&U.createElement(`title`,null,y),g?U.createElement(U.Fragment,null,U.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},U.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),U.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),U.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},kt=U.memo(U.forwardRef((e,t)=>U.createElement(Dt,{...e,ref:t,ariaLabel:`eye-closed, see, hidden`,maskId:`round-outlined-radius-2-stroke-1.5-IconEyeClosed`},U.createElement(`path`,{d:`M3.75 13.0199C8.54029 18.1132 15.4597 18.1132 20.25 13.0199`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M3.75 7.62257C6.14516 5.07587 9.0726 3.80251 12 3.80249C14.9274 3.80247 17.8549 5.07576 20.25 7.62238`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M12 17V20.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M8.25 16.5L6.75 18.9821`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M15.5 16.5L17.25 18.9821`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),At=e=>{let t=U.useId();return U.createElement(Q,{...e,instanceId:t})},jt=0,Mt=typeof U.useId==`function`?void 0:class extends U.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++jt}`})}render(){return U.createElement(Q,{...this.props.iconProps,instanceId:this.state.instanceId})}},Nt=U.forwardRef((e,t)=>Mt?U.createElement(Mt,{iconProps:{...e,svgRef:t}}):U.createElement(At,{...e,svgRef:t}));Nt.displayName=`CentralIconBase`;var Q=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return U.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&U.createElement(`title`,null,y),g?U.createElement(U.Fragment,null,U.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},U.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),U.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),U.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Pt=U.memo(U.forwardRef((e,t)=>U.createElement(Nt,{...e,ref:t,ariaLabel:`text-edit, prompts, comment, draft`,maskId:`round-outlined-radius-2-stroke-1.5-IconTextEdit`},U.createElement(`path`,{d:`M1.75 5.75H9.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M1.75 9.75H6.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M21.3358 6.97366L20.0263 5.66416C19.2452 4.88311 17.9789 4.88311 17.1979 5.66416L8.33579 14.5262C7.96071 14.9013 7.75 15.41 7.75 15.9404V19.2499H11.0595C11.5899 19.2499 12.0986 19.0392 12.4737 18.6642L21.3358 9.80209C22.1168 9.02104 22.1168 7.75471 21.3358 6.97366Z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),Ft={clipIds:[],sceneId:null,enteredGroupId:null};function It(e,t){return e?.clip===t?.clip&&e?.scene===t?.scene}function Lt({toolbarRef:e,apply:t,execute:n,editSelectedText:i}){let a=d(),o=u(r),s=f(a?.selection,Ft),c=g(e=>{if(!e||s.clipIds.length!==1)return null;let t=e.scenes.find(t=>t.id===e.activeSceneId)??null;if(!t)return null;let n=Ie(t,s.clipIds[0])?.clip??null;return n?{clip:n,scene:t}:null},It),[l,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(!0),_=(0,U.useRef)(null);T(e,()=>p(!1),l);let v=(e,t,n=null)=>{let r=c;r&&y(r.clip.id,e,t,n)},y=(e,n,r,i=null)=>{let a=o?.snapshot();if(!a)return;let s=q(a,e,n,r,i);s&&t(s)},C=c?.clip??null,O=c?.scene??null,A=C&&(C.kind===`rect`||C.kind===`text`)&&C.fill.type===`solid`?C.fill.color:null,j=(e,t)=>{C&&O&&v(`Align clip`,n=>{let r=n.transform,i=Math.abs(e===`x`?n.size.width*r.scaleX:n.size.height*r.scaleY),a=e===`x`?r.anchorX:r.anchorY,o=e===`x`?O.width:O.height,s=t===`start`?i*a:t===`center`?o/2+i*(a-.5):o-i*(1-a);return{...n,transform:{...r,[e]:s}}})},M=(e,t)=>{if(!C)return;let n=Math.max(t,1);v(`Resize clip`,t=>{let r=t.size.width/Math.max(t.size.height,1),i=m?e===`width`?{width:n,height:n/r}:{width:n*r,height:n}:{...t.size,[e]:n};return{...t,size:i}})};return(0,Z.jsxs)(`div`,{ref:e,className:`fv-context-toolbar`,role:`toolbar`,"aria-label":`Selected object controls`,hidden:!0,onPointerDown:e=>e.stopPropagation(),children:[(0,Z.jsx)(S,{"aria-label":`Edit selected object`,pressed:l,size:`sm`,title:`Edit properties`,onPressedChange:p,children:(0,Z.jsx)(w,{mode:`raw`,size:15})}),C?.kind===`text`&&(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Edit text`,title:`Edit text`,onClick:i,children:(0,Z.jsx)(Pt,{mode:`raw`,size:15})}),A!==null&&(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Edit color`,title:`Edit color`,onClick:()=>p(!0),children:(0,Z.jsx)(Ct,{mode:`raw`,size:15})}),(0,Z.jsx)(`span`,{className:`fv-context-divider`,"aria-hidden":`true`}),(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Duplicate selected object`,title:`Duplicate (⌘D)`,onClick:()=>n(`fable.transport.duplicate`),children:(0,Z.jsx)(Ge,{mode:`raw`,size:15})}),(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Hide or show selected object`,title:`Hide / show (⇧⌘H)`,onClick:()=>n(`fable.transport.toggleHidden`),children:C?.hidden?(0,Z.jsx)(kt,{mode:`raw`,size:15}):(0,Z.jsx)(ae,{mode:`raw`,size:15})}),(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Delete selected object`,title:`Delete (⌫)`,onClick:()=>n(`fable.transport.delete`),children:(0,Z.jsx)(Ke,{mode:`raw`,size:15})}),l&&C&&O&&(0,Z.jsxs)(`div`,{className:`fv-context-editor`,role:`dialog`,"aria-label":`Edit selected object properties`,children:[(0,Z.jsxs)(`div`,{className:`fv-context-editor-title`,children:[(0,Z.jsx)(`span`,{className:`fv-context-editor-name`,title:C.name,children:C.name}),(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Reset transform`,title:`Reset transform`,onClick:()=>v(`Reset transform`,e=>({...e,transform:{...e.transform,x:O.width/2,y:O.height/2,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,anchorX:.5,anchorY:.5,flipX:!1,flipY:!1}})),children:(0,Z.jsx)(Ee,{mode:`raw`,size:14})})]}),(0,Z.jsxs)(`label`,{className:`fv-context-editor-row fv-context-opacity`,children:[(0,Z.jsx)(`span`,{children:`Opacity`}),(0,Z.jsx)(D,{value:C.opacity*100,min:0,max:100,step:1,onGestureStart:()=>{_.current=`fv-context:opacity:${W()}`},onGestureEnd:()=>{_.current=null},onInput:e=>v(`Change opacity`,t=>({...t,opacity:e/100}),_.current)}),(0,Z.jsxs)(`output`,{className:`fv-context-value`,children:[Math.round(C.opacity*100),`%`]})]}),(0,Z.jsxs)(`div`,{className:`fv-context-editor-row`,children:[(0,Z.jsx)(`span`,{children:`Alignment`}),(0,Z.jsxs)(x,{size:`xxs`,variant:`ghost`,className:`fv-context-align`,"aria-label":`Horizontal alignment`,children:[(0,Z.jsx)(b,{iconOnly:!0,"aria-label":`Align left`,title:`Align left`,onClick:()=>j(`x`,`start`),children:(0,Z.jsx)(ue,{mode:`raw`,size:15})}),(0,Z.jsx)(b,{iconOnly:!0,"aria-label":`Align horizontal center`,title:`Align horizontal center`,onClick:()=>j(`x`,`center`),children:(0,Z.jsx)(B,{mode:`raw`,size:15})}),(0,Z.jsx)(b,{iconOnly:!0,"aria-label":`Align right`,title:`Align right`,onClick:()=>j(`x`,`end`),children:(0,Z.jsx)(le,{mode:`raw`,size:15})})]}),(0,Z.jsxs)(x,{size:`xxs`,variant:`ghost`,className:`fv-context-align`,"aria-label":`Vertical alignment`,children:[(0,Z.jsx)(b,{iconOnly:!0,"aria-label":`Align top`,title:`Align top`,onClick:()=>j(`y`,`start`),children:(0,Z.jsx)(R,{mode:`raw`,size:15})}),(0,Z.jsx)(b,{iconOnly:!0,"aria-label":`Align vertical center`,title:`Align vertical center`,onClick:()=>j(`y`,`center`),children:(0,Z.jsx)(ce,{mode:`raw`,size:15})}),(0,Z.jsx)(b,{iconOnly:!0,"aria-label":`Align bottom`,title:`Align bottom`,onClick:()=>j(`y`,`end`),children:(0,Z.jsx)(z,{mode:`raw`,size:15})})]})]}),(0,Z.jsxs)(`div`,{className:`fv-context-editor-row`,children:[(0,Z.jsx)(`span`,{children:`Dimensions`}),(0,Z.jsxs)(`label`,{className:`fv-context-number`,children:[(0,Z.jsx)(`span`,{children:`W`}),(0,Z.jsx)(E,{value:C.size.width,min:1,onCommit:e=>M(`width`,e)})]}),(0,Z.jsx)(S,{size:`sm`,className:m?`active`:void 0,"aria-label":`Lock aspect ratio`,pressed:m,title:`Lock aspect ratio`,onPressedChange:h,children:(0,Z.jsx)(je,{mode:`raw`,size:14})}),(0,Z.jsxs)(`label`,{className:`fv-context-number`,children:[(0,Z.jsx)(`span`,{children:`H`}),(0,Z.jsx)(E,{value:C.size.height,min:1,onCommit:e=>M(`height`,e)})]})]}),(0,Z.jsxs)(`div`,{className:`fv-context-editor-row`,children:[(0,Z.jsx)(`span`,{children:`Rotation`}),(0,Z.jsx)(E,{className:`fv-context-rotation`,value:C.transform.rotation,step:1,onCommit:e=>v(`Rotate clip`,t=>({...t,transform:{...t.transform,rotation:e}}))}),(0,Z.jsx)(b,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Reset rotation`,title:`Reset rotation`,onClick:()=>v(`Reset rotation`,e=>({...e,transform:{...e.transform,rotation:0}})),children:(0,Z.jsx)(Ee,{mode:`raw`,size:14})})]}),A!==null&&(0,Z.jsxs)(`label`,{className:`fv-context-editor-row`,children:[(0,Z.jsx)(`span`,{children:`Color`}),(0,Z.jsx)(k,{value:A,onCommit:e=>v(`Change color`,t=>t.kind!==`rect`&&t.kind!==`text`||t.fill.type!==`solid`?t:{...t,fill:{...t.fill,color:e}})})]})]})]})}var Rt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M8.25 3.75h-3.5a1 1 0 0 0-1 1v3.5m12-4.5h3.5a1 1 0 0 1 1 1v3.5m0 7.5v3.5a1 1 0 0 1-1 1h-3.5m-7.5 0h-3.5a1 1 0 0 1-1-1v-3.5`})})}),zt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M3.75 10.25v-5.5a1 1 0 0 1 1-1h15.5a1 1 0 0 1 1 1v9.5a1 1 0 0 1-1 1h-5.5m2-4h-3v-3m0 3L17 8m-6.75 13.25h-6.5a1 1 0 0 1-1-1v-5.5a1 1 0 0 1 1-1h6.5a1 1 0 0 1 1 1v5.5a1 1 0 0 1-1 1`})})}),Bt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M5.75 3A1.75 1.75 0 0 0 4 4.75v14.5c0 .966.784 1.75 1.75 1.75h2.5A1.75 1.75 0 0 0 10 19.25V4.75A1.75 1.75 0 0 0 8.25 3zM15.75 3A1.75 1.75 0 0 0 14 4.75v14.5c0 .966.784 1.75 1.75 1.75h2.5A1.75 1.75 0 0 0 20 19.25V4.75A1.75 1.75 0 0 0 18.25 3z`})})}),Vt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M19.248 4.752A10.22 10.22 0 0 1 22.25 12c0 2.83-1.147 5.393-3.002 7.248M15.889 8.11a5.48 5.48 0 0 1 1.611 3.89 5.48 5.48 0 0 1-1.61 3.889M2.75 7.75h2.957a1 1 0 0 0 .54-.158L12.25 3.75v16.5l-6.004-3.842a1 1 0 0 0-.539-.158H2.75a1 1 0 0 1-1-1v-6.5a1 1 0 0 1 1-1`})})}),Ht=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M12.25 3.75H13a.75.75 0 0 0-1.154-.632zm0 16.5-.404.632A.75.75 0 0 0 13 20.25zm9.78-9.72a.75.75 0 1 0-1.06-1.06zm-5.303 3.182a.75.75 0 0 0 1.06 1.061zm1.06-4.242a.75.75 0 0 0-1.06 1.06zm3.183 5.303a.75.75 0 1 0 1.06-1.06zM2.75 8.5h2.957V7H2.75zm3.9-.276 6.004-3.842-.808-1.264-6.004 3.843zM11.5 3.75v16.5H13V3.75zm1.154 15.868-6.003-3.842-.809 1.263 6.004 3.843zM5.707 15.5H2.75V17h2.957zM2.5 15.25v-6.5H1v6.5zm4.15.526a1.75 1.75 0 0 0-.943-.276V17a.25.25 0 0 1 .135.04zM5.708 8.5c.335 0 .662-.096.944-.276l-.809-1.263A.25.25 0 0 1 5.707 7zm-2.957 7a.25.25 0 0 1-.25-.25H1c0 .966.784 1.75 1.75 1.75zm0-8.5A1.75 1.75 0 0 0 1 8.75h1.5a.25.25 0 0 1 .25-.25zm18.22 2.47-2.122 2.121 1.061 1.06 2.121-2.12zm-2.122 2.121-2.121 2.121 1.06 1.061 2.122-2.121zm-2.121-1.06 2.121 2.12 1.061-1.06-2.121-2.121zm2.121 2.12 2.122 2.122 1.06-1.06-2.121-2.122z`})})});function Ut(e,t){let n=xe(e);if(!n||t.length!==1)return null;let r=Ie(n,t[0])?.clip;return r?.kind===`media`?e?.assets.find(e=>e.id===r.assetId&&(e.kind===`video`||e.kind===`image`))??null:null}function Wt(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e)):0;return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`}function Gt(e,t){let n=u(`capability:storage/local`),r=(0,U.useRef)(null),[i]=(0,U.useState)(()=>new l(0)),[a,o]=(0,U.useState)(null),[s,c]=(0,U.useState)({asset:null,playing:!1,duration:0}),d=t&&a?.asset===e?a:null,f=s.asset===e?s:null;return(0,U.useEffect)(()=>{if(i.set(0),!t||!e||!n)return;let r=!0,a;return o(null),c({asset:e,playing:!1,duration:0}),n.readAssetBlob(e).then(async t=>{if(!r)return;if(!t)throw Error(`The original file is unavailable.`);let n=t instanceof Blob?t:new Blob([await t.arrayBuffer()],{type:t.type});r&&(a=URL.createObjectURL(n),o({asset:e,src:a}))}).catch(t=>{r&&o({asset:e,error:t instanceof Error?t.message:`Could not load the original file.`})}),()=>{r=!1,a&&URL.revokeObjectURL(a)}},[e,t,n,i]),(0,U.useEffect)(()=>{let e=r.current;return()=>e?.pause()},[d?.src]),{videoRef:r,currentTime:i,src:d?.src,error:d?.error,playing:f?.playing??!1,duration:f?.duration??0,syncVideo:()=>{let t=r.current;t&&e&&(i.set(t.currentTime),c({asset:e,playing:!t.paused,duration:Number.isFinite(t.duration)?t.duration:0}))},togglePlayback:()=>{let t=r.current;t&&(t.paused?t.play().catch(()=>{e&&r.current===t&&o({asset:e,error:`Could not play this source. Try reopening it.`})}):t.pause())},onError:()=>{e&&o({asset:e,error:`Could not load the original file.`})}}}var Kt=[{value:1,label:`Full`,short:`Full`},{value:.5,label:`Half`,short:`½`},{value:.25,label:`Quarter`,short:`¼`}];function qt({rootRef:e,mode:t,onModeChange:n,sourceAvailable:r,source:i,previewId:a,palette:o}){let s=d(),{previewMuted:l}=v(),u=f(l,!1),p=f(s?.playing,!1),h=f(s?.previewQuality,1),y=g(e=>xe(e)?.duration??0),x=_(),S=m(`fable.session.togglePlayback`),C=m(`fable.panel-viewport.zoomToFit`),[w,T]=(0,U.useState)(!1),[E,D]=(0,U.useState)(!1),k=t===`source`,j=k?i.playing:p,M=k?i.duration:y;(0,U.useEffect)(()=>{let t=e.current?.ownerDocument;if(!t)return;let n=()=>{T(t.fullscreenElement===e.current),C()};return t.addEventListener(`fullscreenchange`,n),()=>t.removeEventListener(`fullscreenchange`,n)},[e,C]);let ee=(0,U.useCallback)(async()=>{let t=e.current;if(t){D(!1);try{t.ownerDocument.fullscreenElement===t?await t.ownerDocument.exitFullscreen():await t.requestFullscreen()}catch{D(!0)}}},[e]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`fv-scene-controls`,children:[(0,Z.jsx)(c.Root,{className:`fv-preview-mode`,variant:`segmented`,shape:`pill`,surface:`flat`,value:t,onValueChange:e=>n(e===`source`?`source`:`result`),children:(0,Z.jsxs)(c.List,{"aria-label":`Preview mode`,indicator:!1,children:[(0,Z.jsx)(c.Tab,{value:`source`,disabled:!r,"aria-controls":a,title:r?`Preview the selected clip’s original file`:`Select a video or image clip to preview its source`,children:`Source`}),(0,Z.jsx)(c.Tab,{value:`result`,"aria-controls":a,children:`Result`})]})}),(0,Z.jsx)(`div`,{className:`fv-scene-center`,children:o}),(0,Z.jsxs)(`div`,{className:`fv-scene-right`,children:[(0,Z.jsxs)(`div`,{className:`fv-player-transport`,role:`group`,"aria-label":`Playback controls`,children:[(0,Z.jsx)(b,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button`,"aria-label":j?`Pause preview`:`Play preview`,disabled:M<=0||k&&!i.src,onClick:()=>{k?i.togglePlayback():S()},children:j?(0,Z.jsx)(Bt,{size:20}):(0,Z.jsx)(qe,{size:20})}),(0,Z.jsxs)(`div`,{className:`fv-player-timecode`,"aria-label":`Playback time`,children:[(0,Z.jsx)(A,{source:k?i.currentTime:x,format:Wt,initial:Wt(k?i.currentTime.get():x?.get()??0)},t),(0,Z.jsxs)(`span`,{className:`fv-player-total`,children:[` / `,Wt(M)]})]}),(0,Z.jsx)(b,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button`,"aria-label":u?`Unmute preview`:`Mute preview`,"aria-pressed":u,disabled:!l,onClick:()=>{l?.set(!u),!k&&s?.playing.get()&&s.seek(s.currentTime.get())},children:u?(0,Z.jsx)(Ht,{size:20}):(0,Z.jsx)(Vt,{size:20})})]}),(0,Z.jsx)(O,{label:(0,Z.jsx)(`span`,{className:`fv-quality-label`,children:Kt.find(e=>e.value===h)?.short??`Full`}),ariaLabel:`Preview quality`,title:`Preview quality`,align:`right`,buttonClassName:`fv-player-button fv-quality`,entries:()=>Kt.map(e=>({kind:`item`,label:e.label,checked:e.value===h,onSelect:()=>s?.setPreviewQuality(e.value)}))}),(0,Z.jsx)(b,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button fv-player-fullscreen`,"aria-label":w?`Exit full screen`:`Full screen`,onClick:()=>void ee(),children:w?(0,Z.jsx)(zt,{size:20}):(0,Z.jsx)(Rt,{size:20})})]})]}),E&&(0,Z.jsx)(`p`,{className:`fv-player-error`,role:`status`,children:`Fullscreen is unavailable in this host.`})]})}var Jt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M18.5 15a.75.75 0 0 1 .75.75v2h2a.75.75 0 0 1 0 1.5h-2v2a.75.75 0 0 1-1.5 0v-2h-2a.75.75 0 0 1 0-1.5h2v-2a.75.75 0 0 1 .75-.75`}),(0,Z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M19.25 3c.966 0 1.75.784 1.75 1.75v9.42a5 5 0 0 0-7.415 3.415l-4.701-4.701a1.25 1.25 0 0 0-1.768 0L4.5 15.5v3.75c0 .138.112.25.25.25h8.85c.11.536.305 1.04.57 1.5H4.75A1.75 1.75 0 0 1 3 19.25V4.75C3 3.784 3.784 3 4.75 3zM15 6.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5`,clipRule:`evenodd`})]})}),Yt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M12.75 3.75h-9a1 1 0 0 0-1 1v12.5a1 1 0 0 0 1 1h4.902a1 1 0 0 1 .642.234l2.065 1.73a1 1 0 0 0 1.28.004l2.099-1.738a1 1 0 0 1 .638-.23h4.874a1 1 0 0 0 1-1v-5`}),(0,Z.jsx)(`path`,{fill:`currentColor`,d:`m20.24 4.185-.696-1.812a.582.582 0 0 0-1.088 0l-.697 1.812a1 1 0 0 1-.574.575l-1.812.696a.582.582 0 0 0 0 1.088l1.812.696a1 1 0 0 1 .575.575l.696 1.812a.582.582 0 0 0 1.088 0l.697-1.812a1 1 0 0 1 .574-.575l1.812-.696a.582.582 0 0 0 0-1.088l-1.812-.696a1 1 0 0 1-.575-.575`})]})}),Xt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M2.746 13.5c8.172-8.078 11.542-11.22 13.521-9.114 2.814 2.993-11.639 12.076-7.64 14.382 3.331 1.92 8.708-8.556 10.916-5.869 1.302 1.583-3.276 5.092-2.057 6.838.836 1.198 2.627.057 3.76-.966`})})}),Zt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsx)(Z.Fragment,{children:(0,Z.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M12 5.75a.75.75 0 0 1 .75-.75h4.5c.966 0 1.75.784 1.75 1.75v4.5a.75.75 0 0 1-1.5 0v-4.5a.25.25 0 0 0-.25-.25h-4.5a.75.75 0 0 1-.75-.75M5.75 12a.75.75 0 0 1 .75.75v4.5c0 .138.112.25.25.25h4.5a.75.75 0 0 1 0 1.5h-4.5A1.75 1.75 0 0 1 5 17.25v-4.5a.75.75 0 0 1 .75-.75`,clipRule:`evenodd`})})}),Qt=({size:e=24,...t})=>(0,Z.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M12 2c5.523 0 10 4.477 10 10a9.98 9.98 0 0 1-3.785 7.835.75.75 0 0 1-.934-1.175 8.5 8.5 0 1 0-10.562 0 .75.75 0 0 1-.934 1.175A9.98 9.98 0 0 1 2 12C2 6.477 6.477 2 12 2`}),(0,Z.jsx)(`path`,{fill:`currentColor`,d:`M10.714 11.467a2 2 0 0 1 2.817.247c1.141 1.36 1.834 3.753 2.14 5.027a.45.45 0 0 1-.624.524c-1.202-.523-3.44-1.621-4.58-2.98a2 2 0 0 1 .247-2.818`})]})}),$t=e=>{let t=U.useId();return U.createElement(rn,{...e,instanceId:t})},en=0,tn=typeof U.useId==`function`?void 0:class extends U.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++en}`})}render(){return U.createElement(rn,{...this.props.iconProps,instanceId:this.state.instanceId})}},nn=U.forwardRef((e,t)=>tn?U.createElement(tn,{iconProps:{...e,svgRef:t}}):U.createElement($t,{...e,svgRef:t}));nn.displayName=`CentralIconBase`;var rn=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return U.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&U.createElement(`title`,null,y),g?U.createElement(U.Fragment,null,U.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},U.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),U.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),U.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},an=U.memo(U.forwardRef((e,t)=>U.createElement(nn,{...e,ref:t,ariaLabel:`cursor-1, arrow`,maskId:`round-outlined-radius-2-stroke-1.5-IconCursor1`},U.createElement(`path`,{d:`M3.45158 4.72779L9.06387 20.5551C9.36964 21.4174 10.577 21.4503 10.9293 20.6059L13.6196 14.157C13.721 13.9138 13.9143 13.7205 14.1575 13.6191L20.6064 10.9288C21.4508 10.5765 21.4179 9.36915 20.5556 9.06338L4.72828 3.45109C3.93501 3.1698 3.17029 3.93452 3.45158 4.72779Z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`})))),on=e=>{let t=U.useId();return U.createElement(un,{...e,instanceId:t})},sn=0,cn=typeof U.useId==`function`?void 0:class extends U.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++sn}`})}render(){return U.createElement(un,{...this.props.iconProps,instanceId:this.state.instanceId})}},ln=U.forwardRef((e,t)=>cn?U.createElement(cn,{iconProps:{...e,svgRef:t}}):U.createElement(on,{...e,svgRef:t}));ln.displayName=`CentralIconBase`;var un=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return U.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&U.createElement(`title`,null,y),g?U.createElement(U.Fragment,null,U.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},U.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),U.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),U.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},dn=U.memo(U.forwardRef((e,t)=>U.createElement(ln,{...e,ref:t,ariaLabel:`hand-5-finger, select`,maskId:`round-outlined-radius-2-stroke-1.5-IconHand5Finger`},U.createElement(`path`,{d:`M16.25 7.75V7.25C16.25 6.42157 16.9216 5.75 17.75 5.75C18.5784 5.75 19.25 6.42157 19.25 7.25V14.2354C19.25 18.1094 16.1094 21.25 12.2354 21.25C9.32487 21.25 6.71671 19.4527 5.68043 16.7329L3.25 10.3542C3.73657 9.15947 5.3114 8.89654 6.15969 9.86836L7.25 11.1175V5.25C7.25 4.42157 7.92157 3.75 8.75 3.75C9.57843 3.75 10.25 4.42157 10.25 5.25V11M10.25 9.75V4.25C10.25 3.42157 10.9216 2.75 11.75 2.75C12.5784 2.75 13.25 3.42157 13.25 4.25V11.5M13.25 7.75V5.25C13.25 4.42157 13.9216 3.75 14.75 3.75C15.5784 3.75 16.25 4.42157 16.25 5.25V12`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),fn=e=>{let t=U.useId();return U.createElement(gn,{...e,instanceId:t})},pn=0,mn=typeof U.useId==`function`?void 0:class extends U.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++pn}`})}render(){return U.createElement(gn,{...this.props.iconProps,instanceId:this.state.instanceId})}},hn=U.forwardRef((e,t)=>mn?U.createElement(mn,{iconProps:{...e,svgRef:t}}):U.createElement(fn,{...e,svgRef:t}));hn.displayName=`CentralIconBase`;var gn=({children:e,size:t=24,ariaLabel:n,color:r,ariaHidden:i,"aria-hidden":a,"aria-label":o,role:s,svgRef:c,renderShapes:l,style:u,mode:d=`masked`,maskId:f,instanceId:p,...m})=>{let h=p?`${f}-${p}`:f,g=d!==`raw`&&!!f,_=a??i??!0,v=_===!0||_===`true`,y=o??n,b=l?l(h??p??`icon`):e;return U.createElement(`svg`,{...m,ref:c,"aria-hidden":_,"aria-label":o,role:s??(v?void 0:`img`),width:typeof t==`number`?`${t}px`:t,height:typeof t==`number`?`${t}px`:t,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,style:{color:r,...u}},y&&!v&&U.createElement(`title`,null,y),g?U.createElement(U.Fragment,null,U.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},U.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),U.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),U.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},_n=U.memo(U.forwardRef((e,t)=>U.createElement(hn,{...e,ref:t,ariaLabel:`sparkles-soft`,maskId:`round-outlined-radius-2-stroke-1.5-IconSparklesSoft`},U.createElement(`path`,{d:`M19.25 13C14.1955 13.4375 11.4375 16.1955 11 21.25C10.544 16.1169 7.80041 13.5721 2.75 13C7.88024 12.4083 10.4083 9.88024 11 4.75C11.5721 9.80041 14.1169 12.544 19.25 13Z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),U.createElement(`path`,{d:`M19.7898 1.25884C19.7731 1.11151 19.6486 1.00015 19.5003 1C19.352 0.999849 19.2272 1.11096 19.2103 1.25825C19.0998 2.21602 18.8134 2.8895 18.3515 3.35146C17.8895 3.81343 17.216 4.09979 16.2582 4.21025C16.111 4.22724 15.9998 4.35203 16 4.5003C16.0002 4.64857 16.1115 4.77313 16.2588 4.78981C17.2008 4.89651 17.8886 5.18275 18.3615 5.64713C18.8327 6.10977 19.125 6.7831 19.2095 7.73414C19.2229 7.88476 19.3491 8.00017 19.5003 8C19.6515 7.99983 19.7775 7.88413 19.7906 7.73349C19.8716 6.79809 20.1636 6.11059 20.6371 5.6371C21.1106 5.16361 21.7981 4.87155 22.7335 4.79058C22.8841 4.77754 22.9998 4.65154 23 4.50033C23.0002 4.34912 22.8848 4.22286 22.7341 4.20948C21.7831 4.125 21.1098 3.83266 20.6471 3.36151C20.1827 2.88857 19.8965 2.20078 19.7898 1.25884Z`,fill:`currentColor`})))),$=16,vn={clipIds:[],sceneId:null,enteredGroupId:null},yn=[{tool:`move`,label:`Move`,shortcut:`V`,icon:(0,Z.jsx)(an,{size:$})},{tool:`hand`,label:`Hand`,shortcut:`H`,icon:(0,Z.jsx)(dn,{size:$})}],bn=[{tool:`rect`,label:`Rectangle`,shortcut:`R`,icon:(0,Z.jsx)(ze,{size:$})},{tool:`text`,label:`Text`,shortcut:`T`,icon:(0,Z.jsx)(te,{size:$})}],xn=[{label:`Edit`,icon:(0,Z.jsx)(ee,{size:$})},{label:`Upscale`,icon:(0,Z.jsx)(Zt,{size:$})},{label:`Extend`,icon:(0,Z.jsx)(Jt,{size:$})},{label:`FPS Boost`,icon:(0,Z.jsx)(Qt,{size:$})}];function Sn({disabled:e}){let[t,n]=(0,U.useState)(null);return xn.map(r=>(0,Z.jsxs)(`button`,{type:`button`,className:`fv-palette-button fv-palette-action`,"aria-pressed":t===r.label,disabled:e,title:e?`Select a video clip first`:r.label,onClick:()=>n(e=>e===r.label?null:r.label),children:[r.icon,r.label]},r.label))}var Cn=e=>yn.some(t=>t.tool===e);function wn(){let e=h(),t=d(),n=f(t?.activeTool,`move`),r=f(t?.selection,vn),i=(0,U.useRef)(`move`);Cn(n)&&(i.current=n);let a=yn.find(e=>e.tool===i.current),o=g(e=>{if(!e||r.clipIds.length!==1)return null;let t=e.scenes.flatMap(e=>e.tracks.flatMap(e=>e.clips)).find(e=>e.id===r.clipIds[0]);return t?.kind===`media`&&e.assets.find(e=>e.id===t.assetId)?.kind===`video`?t.id:null}),s=o!==null,c=t=>{e.commands.execute(t).catch(n=>{e.log.error(`command "${t}" failed`,String(n)),N({message:n instanceof Error?n.message:`Could not complete this action`,variant:`error`})})},l=(e,r,i,a)=>(0,Z.jsx)(`button`,{type:`button`,className:`fv-palette-button${n===e?` active`:``}`,"aria-label":`${r} (${i})`,"aria-pressed":n===e,title:`${r} (${i})`,onClick:()=>t?.setActiveTool(e),children:a},e);return(0,Z.jsxs)(`div`,{className:`fv-palette`,role:`toolbar`,"aria-label":`Canvas tools`,"data-canvas-toolbar":``,children:[(0,Z.jsxs)(`div`,{className:`fv-palette-group`,children:[l(a.tool,a.label,a.shortcut,a.icon),(0,Z.jsx)(O,{label:(0,Z.jsx)(C,{size:12}),ariaLabel:`Select tool`,title:`Select tool`,buttonClassName:`fv-palette-chevron`,entries:()=>yn.map(e=>({kind:`item`,label:e.label,shortcut:e.shortcut,checked:n===e.tool,onSelect:()=>t?.setActiveTool(e.tool)}))})]}),(0,Z.jsx)(`span`,{className:`fv-palette-sep`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`fv-palette-group`,children:bn.map(e=>l(e.tool,e.label,e.shortcut,e.icon))}),(0,Z.jsx)(`span`,{className:`fv-palette-sep`,"aria-hidden":`true`}),(0,Z.jsxs)(`div`,{className:`fv-palette-group`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`fv-palette-button`,"aria-label":`Notes`,title:`Notes: leave notes on video (coming soon)`,disabled:!0,children:(0,Z.jsx)(Yt,{size:$})}),(0,Z.jsx)(`button`,{type:`button`,className:`fv-palette-button`,"aria-label":`Draw to edit`,title:s?`Draw to edit: show changes visually to your agent`:`Select a video clip first`,disabled:!s,onClick:()=>c(`fable.ai-composer.edit-draw`),children:(0,Z.jsx)(Xt,{size:$})})]}),(0,Z.jsx)(`span`,{className:`fv-palette-sep`,"aria-hidden":`true`}),(0,Z.jsx)(`div`,{className:`fv-palette-group`,children:r.clipIds.length===0?(0,Z.jsx)(`button`,{type:`button`,className:`fv-palette-button`,"aria-label":`Create video`,title:`Create video with AI`,onClick:()=>c(`fable.ai-composer.create-video`),children:(0,Z.jsx)(_n,{size:$})}):(0,Z.jsx)(Sn,{disabled:!s},o??`none`)})]})}var Tn={zoom:1,panX:0,panY:0},En={clipIds:[],sceneId:null,enteredGroupId:null},Dn=e=>{let t=Math.max(0,Math.round(e));return`${String(Math.floor(t/60)).padStart(2,`0`)}:${String(t%60).padStart(2,`0`)}`},On=(e,t)=>e===t||!!e&&!!t&&e.id===t.id&&e.name===t.name&&e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height&&e.duration===t.duration;function kn(){let e=h(),t=d(),n=u(r),i=f(t?.camera,Tn),a=f(t?.playing,!1),o=g(e=>{let t=e?.scenes.find(t=>t.id===e.activeSceneId)??null;return t?{id:t.id,name:t.name,x:t.x,y:t.y,width:t.width,height:t.height,duration:t.duration}:null},On),s=f(t?.selection,En,e=>e.clipIds.length===0&&e.sceneId!==null),[c,l]=(0,U.useState)(!1);if(!o)return null;let p=t=>{l(!1);let r=n?.snapshot(),i=t.trim();if(!r||!i||i===o.name)return;let a=M(r,o.id,`Rename scene`,e=>({...e,name:i}));a&&e.commands.execute(`document.apply`,a).catch(t=>e.log.error(`Rename scene failed`,{error:String(t)}))},m=o.x*i.zoom+i.panX,_=o.y*i.zoom+i.panY-24;return(0,Z.jsxs)(`div`,{className:`fv-scene-header${s?` selected`:``}`,"data-scene-header":``,style:{left:m,top:_,width:o.width*i.zoom,height:24},children:[(0,Z.jsx)(`button`,{type:`button`,className:`fv-scene-header-play`,"aria-label":a?`Pause scene`:`Play scene`,disabled:o.duration<=0,onClick:()=>a?t?.pause():t?.play(),children:a?(0,Z.jsx)(Be,{size:12}):(0,Z.jsx)(We,{size:12})}),c?(0,Z.jsx)(`input`,{className:`fv-scene-header-input`,"aria-label":`Scene name`,defaultValue:o.name,autoFocus:!0,onFocus:e=>e.currentTarget.select(),onBlur:e=>p(e.currentTarget.value),onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?p(e.currentTarget.value):e.key===`Escape`&&l(!1)}}):(0,Z.jsx)(`span`,{className:`fv-scene-header-name`,"data-scene-name":``,title:`Double-click to rename`,onClick:()=>t?.setSelection({clipIds:[],sceneId:o.id,enteredGroupId:null}),onDoubleClick:()=>l(!0),children:o.name}),(0,Z.jsx)(`span`,{className:`fv-scene-header-size`,children:`${o.width}×${o.height}`}),(0,Z.jsx)(`span`,{className:`fv-scene-header-badge`,children:`Active`}),(0,Z.jsx)(`span`,{className:`fv-scene-header-duration`,"data-scene-duration":``,children:Dn(o.duration)})]})}var An=.02,jn=1.5;function Mn(e,t){let n=t.deltaMode===1?16:1;if(t.ctrlKey||t.metaKey){let r=Math.exp(-t.deltaY*n*(t.ctrlKey?.01:.0015)),i=Math.min(Math.max(r,1/jn),jn),a=Math.min(Math.max(e.zoom*i,An),64),o=a/e.zoom;return{zoom:a,panX:t.sx-(t.sx-e.panX)*o,panY:t.sy-(t.sy-e.panY)*o}}let r=t.deltaX*n,i=t.deltaY*n;return t.shiftKey&&r===0&&(r=i,i=0),{zoom:e.zoom,panX:e.panX-r,panY:e.panY-i}}function Nn(e,t,n){let r=e.scenes.find(t=>t.id===e.activeSceneId);if(!r)return null;let i=0,a=0,o=r.width,s=r.height,c=!1,l=new Float64Array(18);function u(e,n){let r={clip:e,chain:n},d=me(r,t);if(!(e.hidden||e.kind===`audio`||d<0||d>e.timeRange.duration)){c=!0,De(r,t,{zoom:1,panX:0,panY:0},l);for(let e=0;e<16;e+=2)i=Math.min(i,l[e]),a=Math.min(a,l[e+1]),o=Math.max(o,l[e]),s=Math.max(s,l[e+1]);if(e.kind===`group`&&!e.frame?.clip&&!e.mask?.enabled)for(let t of e.children)u(t,[...n,e])}}for(let e of r.tracks)if(!e.hidden)for(let t of e.clips)u(t,[]);if(!c||![i,a,o,s].every(Number.isFinite)||((i<-.01||a<-.01||o>r.width+.01||s>r.height+.01)&&(i=Math.floor(i/256)*256-256,a=Math.floor(a/256)*256-256,o=Math.ceil(o/256)*256+256,s=Math.ceil(s/256)*256+256),!Number.isFinite(o-i)||!Number.isFinite(s-a)))return null;let d={x:r.x+i,y:r.y+a,width:o-i,height:s-a};if(n?.scene===r&&n.bounds.x===d.x&&n.bounds.y===d.y&&n.bounds.width===d.width&&n.bounds.height===d.height)return n;let f=`viewport-overflow:${r.id}`,p={id:f,name:`Viewport preview`,size:{width:r.width,height:r.height},transform:{x:-i,y:-a,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,anchorX:0,anchorY:0,flipX:!1,flipY:!1},timeRange:{start:0,duration:Math.max(r.duration,t+1/r.fps)},opacity:1,blendMode:`normal`,effects:[],animations:[],presetAnimations:[],mask:null,locked:!1,hidden:!1,id:`${f}:content`,kind:`group`,children:r.tracks.filter(e=>!e.hidden).flatMap(e=>e.clips)},m={...r,width:o-i,height:s-a,background:{type:`solid`,color:`transparent`},tracks:[{id:`${f}:content-track`,name:`Viewport content`,mode:`default`,clips:[p],locked:!0,hidden:!1,muted:!0,solo:!1,volume:0}]};return{document:{...e,scenes:e.scenes.map(e=>e===r?m:e)},scene:r,bounds:d}}var Pn=2,Fn=8294400;function In(e,t){let{width:n,height:r}=e.bounds;return Math.min(Pn,Number.isFinite(t)&&t>0?t:1,4096/n,4096/r,Math.sqrt(Fn/n/r))}var Ln=.5,Rn=(e,t)=>t.x>=e.x&&t.y>=e.y&&t.x+t.width<=e.x+e.width&&t.y+t.height<=e.y+e.height,zn=250;function Bn(e,t,n){let r=null,i=null,a=null,o=0,s=null,c=!1,l=null,u=0,d=!1,f=null,p=null;function m(e,t){p!==null&&clearTimeout(p),p=null,f=null,l=t,u=performance.now(),d=!0,e.seek(t)}function h(e,t){if(!(d&&l!==t&&performance.now()-u<zn)){m(e,t);return}f=t,p??=setTimeout(()=>{p=null,f!==null&&i?.player===e&&m(e,f)},zn)}function g(){let e=i;i=null,e?.player?.dispose(),a&&t.release(a.frame),a=null,o=0,s=null,l=null,d=!1,f=null,p!==null&&clearTimeout(p),p=null}return{presentation:()=>a,update(u,p,_,v,y,b){if(c)return;if(!y){g(),r=null;return}if(r?.document!==u||r.time!==p||r.playing!==v){(r?.document.id!==u.id||r.document.activeSceneId!==u.activeSceneId)&&g();let o=r?.playing??!1;r={document:u,time:p,playing:v};let s=Nn(u,p,i?.preview);if(!s){g();return}if(i)i.preview!==s&&i.player?.setDocument(s.document);else{let o={preview:s,player:null};i=o,o.player=e.create((e,s)=>{if(i!==o||!r?.playing&&s!==l)return;t.retain(e),a&&t.release(a.frame),a={frame:e,scene:o.preview.scene,bounds:o.preview.bounds,time:s},n(),s===l&&(d=!1);let c=o.player;!r?.playing&&f!==null&&c&&m(c,f)},{sceneId:u.activeSceneId,loop:!1,followAudioClock:!0}),o.player.setDocument(s.document)}i.preview=s;let c=i.player;c&&(!v&&c.isPlaying()&&c.pause(),v?(!o||!c.isPlaying()||Math.abs(c.time()-p)>.15)&&m(c,p):h(c,p),v&&!c.isPlaying()&&c.play())}if(!i)return;let x=In(i.preview,_);if(o!==x&&(o=x,i.player?.setScale(o)),b){let e=i.preview.bounds,t={x:b.x-e.x,y:b.y-e.y,width:b.width,height:b.height};if(Rn(t,{x:0,y:0,width:e.width,height:e.height}))s&&(s=null,i.player?.setVisible?.(null));else if(!s||!Rn(s,t)){let e=t.width*Ln,n=t.height*Ln;s={x:t.x-e,y:t.y-n,width:t.width+2*e,height:t.height+2*n},i.player?.setVisible?.(s)}}},reset(){g(),r=null},dispose(){c=!0,g(),r=null}}}var Vn=.25;function Hn(e,t,n,r,i){i||(e.save(),e.globalAlpha=Vn,e.drawImage(t,n.x,n.y,n.width,n.height),e.restore()),e.save(),e.beginPath(),e.rect(r.x,r.y,r.width,r.height),e.clip(),e.drawImage(t,n.x,n.y,n.width,n.height),e.restore()}var Un=`application/x-fable-asset`,Wn=`application/x-fable-scene`;function Gn(e){return!!e?.some(e=>[Un,Wn,Ue,`Files`].includes(e))}function Kn(e){let t=e.getData(Un).split(`
|
|
2
|
-
`)[0];if(t)return{kind:`asset`,id:t};let n=e.getData(Wn).split(`
|
|
3
|
-
`)[0];if(n)return{kind:`scene`,id:n};let r=Ve(e.getData(Ue));if(r)return{kind:`generation`,payload:r};let i=Array.from(e.files);return i.length>0?{kind:`files`,files:i}:null}var qn=L(),Jn=L();function Yn(e,t,n,r){for(let i=e.tracks.length-1;i>=0;i--){let a=e.tracks[i];if(a.hidden||a.locked)continue;let o=Xn(a.clips,t,n,r,[]);if(o)return o}return null}function Xn(e,t,n,r,i){for(let a=e.length-1;a>=0;a--){let o=e[a];if(o.hidden||o.locked||o.kind===`audio`)continue;let s=r-o.timeRange.start;if(s<0||s>o.timeRange.duration)continue;let c=de(o,s);if(o.kind===`group`){if(V(o.transform,c,qn),!Ce(qn,Jn))continue;let e=I(Jn,t,n),r=H(Jn,t,n);i.push(o);let a=Xn(o.children,e,r,s,i);if(i.pop(),a)return a;continue}if(c.width<=0||c.height<=0||(V(o.transform,c,qn),!Ce(qn,Jn)))continue;let l=I(Jn,t,n),u=H(Jn,t,n);if(l>=0&&l<=c.width&&u>=0&&u<=c.height)return{clip:o,chain:[...i]}}return null}function Zn(e,t){let n=e.chain;if(n.length===0)return e.clip;if(t){let r=n.findIndex(e=>e.id===t);if(r!==-1)return n[r+1]??e.clip}return n[0]}function Qn(e,t,n){for(let r=e.scenes.length-1;r>=0;r--){let i=e.scenes[r];if(t>=i.x&&t<=i.x+i.width&&n>=i.y&&n<=i.y+i.height)return i}return null}function $n(e){e.wrap=`soft`,e.style.whiteSpace=`pre-line`,e.style.overflowWrap=`normal`}var er=5,tr=9;function nr(e,t){let n=t===`x`?e.minX:e.minY,r=t===`x`?e.maxX:e.maxY;return[n,(n+r)/2,r]}function rr(e,t){let n=t===`x`?e.minY:e.minX,r=t===`x`?e.maxY:e.maxX;return nr(e,t).map(e=>({value:e,from:n,to:r}))}function ir(e,t){let n=e=>t.flatMap(t=>rr(t,e)).sort((e,t)=>e.value-t.value);return{bounds:e,x:n(`x`),y:n(`y`),heldX:null,heldY:null}}function ar(e,t){let n=0,r=e.length;for(;n<r;){let i=n+r>>>1;e[i].value<t?n=i+1:r=i}return n}function or(e,t,n,r,i){if(r&&Math.abs(r.anchor.value-e[r.sourceIndex])*i<=tr)return r;let a=null,o=er/i,s=(t,n)=>{if(!t)return;let r=Math.abs(t.value-e[n]);r<=o&&(!a||r<o)&&(a={anchor:t,sourceIndex:n},o=r)};for(let r=0;r<e.length;r++){let i=ar(t,e[r]);s(t[i],r),s(t[i-1],r);for(let e of n)s(e,r)}return a}function sr(e,t,n,r,i,a=!1){if(a||!Number.isFinite(i)||i<=0)return e.heldX=e.heldY=null,{dx:t,dy:n,guides:[]};let o=nr(e.bounds,`x`).map(e=>e+t),s=nr(e.bounds,`y`).map(e=>e+n);e.heldX=or(o,e.x,rr(r,`x`),e.heldX,i),e.heldY=or(s,e.y,rr(r,`y`),e.heldY,i),e.heldX&&(t+=e.heldX.anchor.value-o[e.heldX.sourceIndex]),e.heldY&&(n+=e.heldY.anchor.value-s[e.heldY.sourceIndex]);let c=[];return e.heldX&&c.push({axis:`x`,value:e.heldX.anchor.value,from:Math.min(e.bounds.minY+n,e.heldX.anchor.from),to:Math.max(e.bounds.maxY+n,e.heldX.anchor.to)}),e.heldY&&c.push({axis:`y`,value:e.heldY.anchor.value,from:Math.min(e.bounds.minX+t,e.heldY.anchor.from),to:Math.max(e.bounds.maxX+t,e.heldY.anchor.to)}),{dx:t,dy:n,guides:c}}function cr(e,t,n){if(e.clip.kind===`audio`)return null;let r=Math.max(0,Math.min(me(e,t),e.clip.timeRange.duration)),i=de(e.clip,r);if(i.width<=0||i.height<=0)return null;let a=Ne(e,t,L()),o=[],s=[];for(let[e,t]of[[0,0],[i.width,0],[i.width,i.height],[0,i.height]])o.push(I(a,e,t)+n.x),s.push(H(a,e,t)+n.y);return[...o,...s].every(Number.isFinite)?{minX:Math.min(...o),maxX:Math.max(...o),minY:Math.min(...s),maxY:Math.max(...s)}:null}function lr(e,t,n,r){let i=t.map(t=>cr(t,n,e)).filter(e=>e!==null);if(!i.length)return null;let a={minX:Math.min(...i.map(e=>e.minX)),minY:Math.min(...i.map(e=>e.minY)),maxX:Math.max(...i.map(e=>e.maxX)),maxY:Math.max(...i.map(e=>e.maxY))},o=new Set(t.map(e=>e.clip.id)),s=new Set(t.flatMap(e=>e.chain.map(e=>e.id))),c=[],l=(t,i,a)=>{for(let u of t){let t=a-u.timeRange.start;if(u.hidden||u.kind===`audio`||u.opacity<=0||t<0||t>=u.timeRange.duration||o.has(u.id))continue;if(u.kind===`group`&&s.has(u.id)){l(u.children,[...i,u],t);continue}let d=cr({clip:u,chain:i},n,e);d&&d.maxX>=r.minX&&d.minX<=r.maxX&&d.maxY>=r.minY&&d.minY<=r.maxY&&c.push(d)}};for(let t of e.tracks)t.hidden||l(t.clips,[],n);return ir(a,c)}var ur=7,dr={previewLetterbox:`#000000`,frameMarquee:`#9ca3af`},fr=`capability:storage/local`;function pr(e,t,n){return e!==.5&&t!==.5?!n:n}function mr(e,t){let n=(t[0]+t[8])/2,r=(t[1]+t[9])/2,i=t[e*2]-n,a=t[e*2+1]-r,o=(Math.atan2(a,i)*180/Math.PI+180)%180;return o<22.5||o>=157.5?`ew-resize`:o<67.5?`nwse-resize`:o<112.5?`ns-resize`:`nesw-resize`}function hr(e,t,n){let{host:r,session:i,docs:a,frames:o,players:s,placement:c,apply:l,invalidate:u,updateSelectionToolbar:d}=n,f=window,m=t.getContext(`2d`),h=Re(t),g=!0,_=null,v=!1,b=!1,x=null,S=null,C=[],w=null,T=null,E=null,D=null,O=null,k=null,A=null,j=null,M=!1,ee=[],N=new Float64Array(18),te=L(),P=()=>a.snapshot(),F=()=>xe(P()),ae=P()?.id??null,ce=P()?.activeSceneId??null;function le(){let t=R();return{minX:-t.panX/t.zoom,minY:-t.panY/t.zoom,maxX:(e.clientWidth-t.panX)/t.zoom,maxY:(e.clientHeight-t.panY)/t.zoom}}function ue(){S=null,C=[],w=null}let R=()=>i.camera.get(),z=()=>i.selection.get().clipIds,B=new Map,V=new Map,he=Bn(s,o,u);function ge(e){e&&o.release(e.frame)}function Ee(){for(let e of B.values())ge(e);B.clear()}function je(){ge(j),j=null}function Fe(e,t,n,r){if(M)return;let i=r?.scenes.find(t=>t.id===e);if(!i)return;o.retain(t);let a=B.get(e);B.set(e,{frame:t,scene:i,time:n}),ge(a),u()}function Le(e,t,n){if(M||e.disposed||A!==e)return;let r=e.document?.scenes.find(t=>t.id===e.sceneId);if(!r)return;o.retain(t);let i=j;j={frame:t,scene:r,time:n},ge(i),O?.(),D&&(D.style.opacity=``),u()}function ze(e){e.disposed=!0,e.player?.dispose()}function Be(){for(let e of V.values())ze(e);V.clear()}function Ve(e,t){e.document=t,e.player?.setDocument(t)}function He(e=P()){let t=new Set;if(e)for(let n of e.scenes)n.id!==e.activeSceneId&&t.add(n.id);for(let[e,n]of V)t.has(e)||(ze(n),V.delete(e));for(let t of Array.from(B.keys()))(!e||!e.scenes.some(e=>e.id===t))&&(ge(B.get(t)),B.delete(t));for(let n of t){if(V.has(n))continue;let t={sceneId:n,document:e,player:null,disposed:!1};V.set(n,t),t.player=s.create((e,r)=>{!t.disposed&&V.get(n)===t&&Fe(n,e,r,t.document)},{sceneId:n,loop:!1}),t.player.setDocument(e),t.player.seek(i.currentTime.get())}}function Ue(e){if(k&&A?.sceneId===e&&j)return j;let t=he.presentation();return e===P()?.activeSceneId?t?.scene.id===e?t:null:B.get(e)??null}function We(e,t){if(!g)return;let n=F();if(!n||e<2||t<2)return;let r=_?.sceneId===n.id?_.bounds:{minX:n.x,minY:n.y,maxX:n.x+n.width,maxY:n.y+n.height},a={x:16,top:36,bottom:64},o=Math.max(1,e-a.x*2),s=Math.max(1,t-a.top-a.bottom),c=Math.min(o/(r.maxX-r.minX),s/(r.maxY-r.minY),64);if(!(c>0))return;let l=a.x+o/2-(r.minX+r.maxX)/2*c,u=a.top+s/2-(r.minY+r.maxY)/2*c,d=R();if(d.zoom!==c||d.panX!==l||d.panY!==u){v=!0;try{i.setCamera({zoom:c,panX:l,panY:u})}finally{v=!1}}}function Ge(e){let t=F();if(e&&(P()?.id!==e.documentId||t?.id!==e.sceneId))return;let n=!e&&t&&Me(t,i.currentTime.get());_=t&&n?{sceneId:t.id,bounds:n}:null,g=!0,u()}function Ke(t){let n=R(),r=e.clientWidth/2,a=e.clientHeight/2;i.setCamera({zoom:Math.min(n.zoom*t,64),panX:r-(r-n.panX)*t,panY:a-(a-n.panY)*t}),u()}function qe(){let e=F();if(!e)return;let t=i.currentTime.get(),n=new Float64Array(18),r=null;for(let i of z()){let a=Ie(e,i);if(!a||a.clip.kind===`audio`)continue;De(a,t,{zoom:1,panX:0,panY:0},n,e.x,e.y);let o=[n[0],n[4],n[8],n[12]],s=[n[1],n[5],n[9],n[13]];if(![...o,...s].every(Number.isFinite))continue;let c={minX:Math.min(...o),minY:Math.min(...s),maxX:Math.max(...o),maxY:Math.max(...s)};r=r?{minX:Math.min(r.minX,c.minX),minY:Math.min(r.minY,c.minY),maxX:Math.max(r.maxX,c.maxX),maxY:Math.max(r.maxY,c.maxY)}:c}!r||r.maxX<=r.minX||r.maxY<=r.minY||(_={sceneId:e.id,bounds:r},g=!0,u())}function U(){let t=F(),n=e.clientWidth,r=e.clientHeight;!t||n<2||r<2||(i.setCamera({zoom:1,panX:(n-t.width)/2-t.x,panY:(r-t.height)/2-t.y}),u())}let G=!1;function K(e,n){if(!m)return;Y();let r=P(),a=n.dpr;if(m.setTransform(1,0,0,1,0,0),m.clearRect(0,0,t.width,t.height),!r){d(null);return}We(n.width,n.height);let s=R();he.update(r,i.currentTime.get(),s.zoom*a*i.previewQuality.get(),i.playing.get(),!k&&!G&&n.width>1&&n.height>1,{x:-s.panX/s.zoom,y:-s.panY/s.zoom,width:n.width/s.zoom,height:n.height/s.zoom});let c=Math.min(1,Math.round(s.zoom*a*i.previewQuality.get()*64)/64);for(let e of V.values())e.player&&e.scale!==c&&(e.scale=c,e.player.setScale(c));let l=R(),u=r.scenes.map(e=>Ue(e.id)?.scene??e),f=u.some((e,t)=>e!==r.scenes[t])?{...r,scenes:u}:r;m.setTransform(l.zoom*a,0,0,l.zoom*a,l.panX*a,l.panY*a);for(let e of f.scenes){let t=Ue(e.id),n=t?o.toNative(t.frame):null;if(n){let r=t?.bounds;r?Hn(m,n,r,e,i.playing.get()):m.drawImage(n,e.x,e.y,e.width,e.height)}else e.id!==r.activeSceneId&&(m.fillStyle=e.background.type===`solid`?e.background.color:h.scenePlaceholder,m.fillRect(e.x,e.y,e.width,e.height))}G&&tt(f),m.setTransform(a,0,0,a,0,0),(f.scenes.length>1||i.selection.get().sceneId)&&Ae(m,f,l,i.selection.get().sceneId,h);let p=z(),g=Ue(r.activeSceneId),_=g?.scene??xe(f),v=g?.time??i.currentTime.get();if(C.length){m.save(),m.strokeStyle=h.accent,m.globalAlpha=.6,m.lineWidth=1,m.setLineDash([3,3]),m.beginPath();for(let e of C)if(e.axis===`x`){let t=e.value*l.zoom+l.panX;m.moveTo(t,e.from*l.zoom+l.panY),m.lineTo(t,e.to*l.zoom+l.panY)}else{let t=e.value*l.zoom+l.panY;m.moveTo(e.from*l.zoom+l.panX,t),m.lineTo(e.to*l.zoom+l.panX,t)}m.stroke(),m.restore()}_&&p.length>0?(_e(m,_,v,l,a,p,h),d(Oe(_,v,l,p))):d(null);let y=_&&p.length>0?we(m,_,v,l,a,p,h):null;y?t.dataset.sizeReadout=y:delete t.dataset.sizeReadout,(x?.kind===`draw-rect`||x?.kind===`draw-frame`)&&rt(x,a),E&&nt(r,l,a),m.setTransform(1,0,0,1,0,0)}let q=null,J=null,Xe=null;function Ze(){let e=q;!e||e.readyState<2||!e.videoWidth||(J??=f.document.createElement(`canvas`),(J.width!==e.videoWidth||J.height!==e.videoHeight)&&(J.width=e.videoWidth,J.height=e.videoHeight),J.getContext(`2d`)?.drawImage(e,0,0))}function Qe(e){if(!e){if(!G)return;G=!1,Xe=null,u();return}if(!q){q=f.document.createElement(`video`),q.muted=!0,q.playsInline=!0,q.preload=`auto`;let e=()=>{Ze(),u(),Xe!==null&&q&&(q.currentTime=Xe,Xe=null)};q.addEventListener(`seeked`,e),q.addEventListener(`loadeddata`,e)}let t=q;t.src!==e.src&&(t.src=e.src,J=null),t.readyState>=1?t.seeking?Xe=e.time:t.currentTime=e.time:t.addEventListener(`loadedmetadata`,()=>void(t.currentTime=e.time),{once:!0}),G=!0,u()}function tt(e){let t=J,n=e.scenes.find(t=>t.id===e.activeSceneId);if(!m||!t||!n)return;let r=t.width,i=t.height,a=Math.min(n.width/r,n.height/i),o=r*a,s=i*a;m.save(),m.beginPath(),m.rect(n.x,n.y,n.width,n.height),m.clip(),m.fillStyle=dr.previewLetterbox,m.fillRect(n.x,n.y,n.width,n.height),m.drawImage(t,n.x+(n.width-o)/2,n.y+(n.height-s)/2,o,s),m.restore()}function nt(e,t,n){if(!m)return;let r=e.scenes.find(e=>e.id===E);r&&(m.setTransform(n,0,0,n,0,0),m.strokeStyle=h.accent,m.lineWidth=2,m.strokeRect(r.x*t.zoom+t.panX,r.y*t.zoom+t.panY,r.width*t.zoom,r.height*t.zoom))}function rt(e,t){if(!m)return;let n=R();m.setTransform(t,0,0,t,0,0);let r=e.x0*n.zoom+n.panX,i=e.y0*n.zoom+n.panY,a=e.x1*n.zoom+n.panX,o=e.y1*n.zoom+n.panY;m.strokeStyle=e.kind===`draw-frame`?dr.frameMarquee:h.accent,m.lineWidth=1,m.setLineDash([4,4]),m.strokeRect(Math.min(r,a),Math.min(i,o),Math.abs(a-r),Math.abs(o-i)),m.setLineDash([]),m.setTransform(1,0,0,1,0,0)}function Y(){let e=i.activeTool.get();t.style.cursor=b||x?.kind===`pan`||e===`hand`?`grab`:x?.kind===`resize`||x?.kind===`group-resize`?x.cursor:x?.kind===`rotate`||x?.kind===`group-rotate`?`grabbing`:e===`rect`||e===`text`||e===`frame`?`crosshair`:T??`default`}function X(e){let n=t.getBoundingClientRect();return{sx:e.clientX-n.left,sy:e.clientY-n.top}}function ft(e,t){return(e-t.panX)/t.zoom}function Z(e,t){return(e-t.panY)/t.zoom}function mt(){let e=F();return e?{ox:e.x,oy:e.y}:{ox:0,oy:0}}function ht(e,t,n){let r=P();if(!r)return;let i=Je(r,e,t,n);i&&l(i)}function gt(e){let t=[];for(let n of z()){let r=Ie(e,n);r&&t.push(r)}return t}function _t(e,t){let n=N[16],r=N[17];if(Math.hypot(e-n,t-r)<=9)return 8;for(let n=0;n<ke.length;n++){let r=N[n*2],i=N[n*2+1];if(Math.abs(e-r)<=ur&&Math.abs(t-i)<=ur)return n}return null}function vt(e,t){let n=F();if(!n)return null;let r=R(),a=i.currentTime.get(),o=z();if(o.length>1){let i=gt(n).filter(e=>e.clip.kind!==`audio`),a=Te(i);if(!a)return null;let o=ye(i);if(!o)return null;Se(o,a,r,n.x,n.y,N);let s=_t(e,t);return s===null?null:{kind:`multi`,index:s,bounds:o,locs:i,chain:a}}for(let i of o){let o=Ie(n,i);if(!o||o.clip.kind===`audio`||pe(o))continue;De(o,a,r,N,n.x,n.y);let s=_t(e,t);if(s!==null)return{kind:`single`,loc:o,index:s}}return null}function yt(e){return e===8?`grab`:mr(e,N)}function bt(e,t){let n=P();if(!n||!m)return null;let r=R();for(let i=n.scenes.length-1;i>=0;i--){let a=n.scenes[i],o=ve(m,a,r,h);if(e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return a}return null}function xt(e){let t=P(),n=oe(t,e);if(!t||!n)return;let r=st(t,e);r&&(l(r),i.setSelection({enteredGroupId:null}),i.seek(Math.min(i.currentTime.get(),n.duration)))}function St(){let e=F();return e?gt(e).filter(e=>!pe(e)):[]}function Ct(){return`fable.panel-viewport:gesture:${W()}`}function wt(e){let t=L();return be(e,te),Ce(te,t)?t:null}function Tt(t,n,r,a){let o=n-t.wx,s=r-t.wy,c=F(),l=le(),d=`${e.clientWidth}:${e.clientHeight}`;if(w!==d&&ue(),!S&&c&&(S=lr(c,t.origs,i.currentTime.get(),l),w=d),S){let e=sr(S,o,s,l,R().zoom,a);o=e.dx,s=e.dy,C=e.guides,u()}let f=L(),p=[];for(let e of t.origs){let t=o,n=s;if(e.chain.length>0){if(be(e.chain,te),!Ce(te,f))continue;t=se(f,o,s),n=fe(f,o,s)}let r=e.clip.transform;p.push({clipId:e.clip.id,transform:{...r,x:r.x+t,y:r.y+n}})}ht(p,t.origs.length>1?`Move clips`:`Move clip`,t.key)}function Et(e,t,n,r){let i=e.b,a=1,o=(i.minX+i.maxX)/2;if(e.hx!==.5){o=e.hx===0?i.maxX:i.minX;let n=(e.hx===0?i.minX:i.maxX)-o;Math.abs(n)>1e-6&&(a=(t-o)/n),a>.01||(a=.01)}let s=1,c=(i.minY+i.maxY)/2;if(e.hy!==.5){c=e.hy===0?i.maxY:i.minY;let t=(e.hy===0?i.minY:i.maxY)-c;Math.abs(t)>1e-6&&(s=(n-c)/t),s>.01||(s=.01)}if(r){let t=e.hx!==.5&&e.hy!==.5?Math.max(a,s):e.hx===.5?s:a;a=t,s=t}ht(e.origs.map(e=>{let t=e.clip.transform;return{clipId:e.clip.id,transform:{...t,x:o+(t.x-o)*a,y:c+(t.y-c)*s,scaleX:t.scaleX*a,scaleY:t.scaleY*s}}}),`Resize clips`,e.key)}function Dt(e,t,n,r){let i=(Math.atan2(n-e.cy,t-e.cx)-e.startAngle)*180/Math.PI;r&&(i=Math.round(i/15)*15);let a=i*Math.PI/180,o=Math.cos(a),s=Math.sin(a);ht(e.origs.map(t=>{let n=t.clip.transform,r=n.x-e.cx,a=n.y-e.cy;return{clipId:t.clip.id,transform:{...n,x:e.cx+r*o-a*s,y:e.cy+r*s+a*o,rotation:n.rotation+i}}}),`Rotate clips`,e.key)}function Ot(e,t,n,r){let i=e.orig.clip,a=i.transform,o=I(e.inv,t,n),s=H(e.inv,t,n),c=i.size.width,l=i.size.height,u=e.hx===0?c:0,d=e.hy===0?l:0,f=0,p=c;e.hx!==.5&&(p=Math.max(Math.abs(o-u),1),f=Math.min(o,u));let m=0,h=l;if(e.hy!==.5&&(h=Math.max(Math.abs(s-d),1),m=Math.min(s,d)),r&&c>0&&l>0){let t=e.hx!==.5&&e.hy!==.5?Math.max(p/c,h/l):e.hx===.5?h/l:p/c;p=Math.max(c*t,1),h=Math.max(l*t,1),f=e.hx===.5?(c-p)/2:o<u?u-p:u,m=e.hy===.5?(l-h)/2:s<d?d-h:d}let g=I(e.base,f,m),_=H(e.base,f,m),v=-a.anchorX*p,y=-a.anchorY*h;ht([{clipId:i.id,size:{width:p,height:h},transform:{...a,x:g-(e.base.a*v+e.base.c*y),y:_-(e.base.b*v+e.base.d*y)}}],`Resize clip`,e.key)}function kt(e,t,n,r){let i=e.orig.clip.transform,a=Math.atan2(n-i.y,t-i.x),o=i.rotation+(a-e.startAngle)*180/Math.PI;r&&(o=Math.round(o/15)*15),ht([{clipId:e.orig.clip.id,transform:{...i,rotation:o}}],`Rotate clip`,e.key)}function At(e,t,n,r){let a=P(),o=F();if(!a||!o)return;let s=e-o.x,u=t-o.y,d=n-o.x,f=r-o.y,p=R().zoom,m=Math.abs(d-s),h=Math.abs(f-u),g=(s+d)/2,_=(u+f)/2;m*p<3&&h*p<3&&(m=200,h=200,g=s,_=u);let v=ut(o,i.currentTime.get(),{x:g,y:_},{width:m,height:h}),y=Ye(a,o.id,v,`Add rectangle`,c);y&&(l(y),i.setSelection({clipIds:[v.id]}),i.setActiveTool(`move`))}function jt(e,t){let n=P(),r=F();if(!n||!r)return;let a=160;m&&(m.save(),m.font=`400 64px ${h.fontUi}`,a=Math.max(m.measureText(`Text`).width,10),m.restore());let o=dt(r,i.currentTime.get(),{x:e-r.x,y:t-r.y},a),s=Ye(n,r.id,o,`Add text`,c);s&&(l(s),i.setSelection({clipIds:[o.id]}),i.setActiveTool(`move`),Rt(o))}function Mt(e,t,n,r){let a=P();if(!a)return;let o=R().zoom,s=Math.abs(n-e),c=Math.abs(r-t),u=Math.min(e,n),d=Math.min(t,r);s*o<4&&c*o<4&&(s=1920,c=1080,u=e,d=t);let f=e=>Math.round(e/10)*10;s=Math.max(f(s),160),c=Math.max(f(c),90);let p=pt(a,{x:u,y:d,width:s,height:c});l(ct(a,p)),i.setSelection({clipIds:[],sceneId:p.id,enteredGroupId:null}),i.seek(Math.min(i.currentTime.get(),p.duration)),i.setActiveTool(`move`)}function Nt(e){let t=P();if(!t||t.scenes.length<=1)return;let n=t.scenes.find(t=>t.id===e);if(!n)return;let r=n.tracks.reduce((e,t)=>e+t.clips.length,0);if(r>0&&!f.confirm(`Delete "${n.name}" and its ${r} clip${r===1?``:`s`}?`))return;let a=lt(t,e);a&&(l(a),i.setSelection({clipIds:[],sceneId:null,enteredGroupId:null}))}function Q(){D&&=(D.remove(),null),O=null,k&&(k=null,A&&ze(A),A=null,je(),i.requestRender(),u())}function Pt(e,t){return e.map(e=>e.id===t?{...e,hidden:!0}:e.kind===`group`?{...e,children:Pt(e.children,t)}:e)}function Ft(e,t){return{...e,scenes:e.scenes.map(n=>n.id===e.activeSceneId?{...n,background:{type:`solid`,color:`transparent`},tracks:n.tracks.map(e=>({...e,clips:Pt(e.clips,t)}))}:n)}}function It(e){let t=P();if(!t)return;k=e,je();let n={sceneId:t.activeSceneId,document:t,player:null,disposed:!1};A=n;let r=Math.min(3,Math.max(1,R().zoom*(f.devicePixelRatio||1)));n.player=s.create((e,t)=>Le(n,e,t),{sceneId:n.sceneId,loop:!1,scale:r}),n.player.setDocument(Ft(t,e)),n.player.seek(i.currentTime.get())}function Lt(t,n,r){e.appendChild(t),D=t,t.focus(),t.select();let i=!1,a=()=>{if(i)return;i=!0;let e=t.value;Q(),r(e)},o=t;o.addEventListener(`blur`,a),o.addEventListener(`keydown`,e=>{e.stopPropagation(),!e.isComposing&&(e.key===`Enter`&&!(n&&e.shiftKey)?(e.preventDefault(),a()):e.key===`Escape`&&(i=!0,Q()))})}function Rt(e){if(Q(),!F())return;i.pause();let t=f.document.createElement(`textarea`);t.value=e.text,$n(t),t.spellcheck=!1,t.setAttribute(`autocorrect`,`off`),t.setAttribute(`autocapitalize`,`off`);let n=t.style;n.position=`absolute`,n.left=`0`,n.top=`0`,n.transformOrigin=`0 0`,n.background=`transparent`,n.caretColor=h.accent,n.border=`0`,n.outline=`none`,n.resize=`none`,n.overflow=`hidden`,n.padding=`0`,n.margin=`0`,n.opacity=`0`,n.zIndex=`20`;let r=()=>{let t=P(),r=j?.scene??F(),a=r?Ie(r,e.id):null;if(!t||!r||!a||a.clip.kind!==`text`){Q();return}let o=a.clip,s=R(),{x:c,y:l}=r,u=j?.time??i.currentTime.get(),d=L();Ne(a,u,d);let f=Math.min(Math.max(me(a,u),0),o.timeRange.duration),p=de(o,f),m=s.zoom*d.a,g=s.zoom*d.b,_=s.zoom*d.c,v=s.zoom*d.d,y=s.zoom*(d.e+c)+s.panX,b=s.zoom*(d.f+l)+s.panY;n.transform=`matrix(${m}, ${g}, ${_}, ${v}, ${y}, ${b})`,n.width=`${p.width}px`,n.height=`${p.height}px`,n.font=_r(o),n.lineHeight=String(o.lineHeight),n.letterSpacing=`${o.letterSpacing}px`,n.textAlign=o.align,n.color=o.fill.type===`solid`?o.fill.color:h.white,n.webkitTextStroke=o.stroke.width>0?`${o.stroke.width}px ${o.stroke.color}`:``};r(),O=r,t.addEventListener(`input`,()=>{t.scrollLeft=0,t.scrollTop=0}),It(e.id),j&&(n.opacity=``),Lt(t,!0,t=>{let n=P();if(n&&t!==e.text){let r=at(n,e.id,t);r&&l(r)}})}function zt(){let e=F(),t=z();if(!e||t.length!==1)return!1;let n=Ie(e,t[0])?.clip;return!n||n.kind!==`text`?!1:(Rt(n),!0)}function Bt(e){if(!m)return;Q();let t=ve(m,e,R(),h),n=f.document.createElement(`input`);n.type=`text`,n.value=e.name;let r=n.style;r.position=`absolute`,r.left=`${t.x}px`,r.top=`${t.y-3}px`,r.width=`${Math.max(t.w+60,140)}px`,r.font=`12px ${h.fontUi}`,r.padding=`2px 4px`,r.background=h.inlineEditorBackground,r.color=h.text,r.border=`1px solid ${h.accent}`,r.borderRadius=`3px`,r.outline=`none`,r.zIndex=`20`,Lt(n,!1,t=>{let n=t.trim(),r=P();if(r&&n.length>0&&n!==e.name){let t=ot(r,e.id,n);t&&l(t)}})}function Vt(e){e.preventDefault();let t=F();if(!t)return;let{sx:r,sy:a}=X(e),o=R(),{ox:s,oy:c}=mt(),l=Yn(t,ft(r,o)-s,Z(a,o)-c,i.currentTime.get());if(!l)return;let u=Zn(l,i.selection.get().enteredGroupId),d=z();d.includes(u.id)||(d=[u.id],i.setSelection({clipIds:d}));let f=e.clientX,p=e.clientY,m=[],h=re({scenes:[t]},l.clip.id),g=ie(P(),u.id);d.length>1&&m.push({label:`Add Auto Layout`,onSelect:()=>n.showAutoLayoutEditor(f,p,{selectionIds:d})}),g?.canOwnLayout?m.push({label:g.layout?`Edit Auto Layout…`:`Add Auto Layout`,disabled:g.locked,onSelect:()=>n.showAutoLayoutEditor(f,p,{clipId:u.id,enableOnOpen:g.layout===null})}):g?.canEditSizing&&m.push({label:`Edit layout sizing…`,disabled:g.locked,onSelect:()=>n.showAutoLayoutEditor(f,p,{clipId:u.id})}),h&&m.push({label:`Edit component props…`,disabled:h.locked,onSelect:()=>{i.setSelection({clipIds:[h.clip.id]}),n.showComponentEditor(f,p,h.clip.id)}}),u.kind===`text`&&m.push({label:`Edit text`,onSelect:()=>{i.setSelection({clipIds:[u.id]}),Rt(u)}}),u.kind===`group`&&!u.component&&m.push({label:`Enter group`,onSelect:()=>i.setSelection({enteredGroupId:u.id,clipIds:[]})}),m.length!==0&&n.showMenu(f,p,m)}function Ht(e){try{t.setPointerCapture(e.pointerId)}catch{}}function Ut(e){ue();let{sx:t,sy:n}=X(e),r=R();if(e.button===1||e.button===0&&(b||i.activeTool.get()===`hand`)){e.preventDefault(),Ht(e),x={kind:`pan`,sx:t,sy:n,cam:r},Y();return}if(e.button!==0)return;Ht(e);let a=ft(t,r),o=Z(n,r),s=i.activeTool.get();if(s===`rect`){x={kind:`draw-rect`,x0:a,y0:o,x1:a,y1:o},u();return}if(s===`frame`){x={kind:`draw-frame`,x0:a,y0:o,x1:a,y1:o},u();return}if(s===`text`){jt(a,o);return}let c=F(),{ox:l,oy:d}=mt(),f=a-l,p=o-d,m=vt(t,n);if(m){if(m.kind===`multi`){let e=m.locs.filter(e=>!pe(e));if(e.length===0)return;let t=wt(m.chain);if(!t)return;let n=I(t,f,p),r=H(t,f,p);if(m.index===8){let i=(m.bounds.minX+m.bounds.maxX)/2,a=(m.bounds.minY+m.bounds.maxY)/2;x={kind:`group-rotate`,origs:e,cx:i,cy:a,startAngle:Math.atan2(r-a,n-i),parentInv:t,key:Ct()}}else{let n=ke[m.index];x={kind:`group-resize`,origs:e,b:m.bounds,hx:n[0],hy:n[1],parentInv:t,cursor:mr(m.index,N),key:Ct()}}Y();return}let e=m.loc,t=wt(e.chain);if(!t)return;let n=I(t,f,p),r=H(t,f,p);if(m.index===8){let i=e.clip.transform;x={kind:`rotate`,orig:e,parentInv:t,startAngle:Math.atan2(r-i.y,n-i.x),key:Ct()}}else{let n=ke[m.index],r=L(),i=L();if(Pe(e.clip.transform,e.clip.size.width,e.clip.size.height,r),!Ce(r,i))return;x={kind:`resize`,orig:e,hx:n[0],hy:n[1],base:r,inv:i,parentInv:t,cursor:mr(m.index,N),key:Ct()}}Y();return}let h=c?Yn(c,f,p,i.currentTime.get()):null;if(h&&c){let t=Zn(h,i.selection.get().enteredGroupId);if(e.shiftKey){let e=z();i.setSelection({clipIds:e.includes(t.id)?e.filter(e=>e!==t.id):[...e,t.id]});return}!z().includes(t.id)&&!z().includes(h.clip.id)&&i.setSelection({clipIds:[t.id]});let n=St();n.length>0&&(x={kind:`move`,origs:n,wx:a,wy:o,key:Ct()});return}let g=bt(t,n);if(g){xt(g.id),i.setSelection({clipIds:[],sceneId:g.id,enteredGroupId:null});return}let _=P(),v=_?Qn(_,a,o):null;if(v&&c&&v.id!==c.id){xt(v.id),i.setSelection({clipIds:[],sceneId:null,enteredGroupId:null});return}e.shiftKey||i.clearSelection()}function Wt(e){let{sx:t,sy:n}=X(e);if(!x){let e=i.activeTool.get()===`move`?vt(t,n):null;T=e?yt(e.index):null,Y();return}if(x.kind===`pan`){i.setCamera({zoom:x.cam.zoom,panX:x.cam.panX+t-x.sx,panY:x.cam.panY+n-x.sy});return}let r=R(),a=ft(t,r),o=Z(n,r),{ox:s,oy:c}=mt(),l=a-s,d=o-c;switch(x.kind){case`draw-rect`:case`draw-frame`:x.x1=a,x.y1=o,u();break;case`move`:Tt(x,a,o,e.altKey);break;case`resize`:Ot(x,I(x.parentInv,l,d),H(x.parentInv,l,d),pr(x.hx,x.hy,e.shiftKey));break;case`rotate`:kt(x,I(x.parentInv,l,d),H(x.parentInv,l,d),e.shiftKey);break;case`group-resize`:Et(x,I(x.parentInv,l,d),H(x.parentInv,l,d),pr(x.hx,x.hy,e.shiftKey));break;case`group-rotate`:Dt(x,I(x.parentInv,l,d),H(x.parentInv,l,d),e.shiftKey)}}function Gt(e){if(!x)return;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId);let n=x;x=null,ue(),T=null,n.kind===`draw-rect`?At(n.x0,n.y0,n.x1,n.y1):n.kind===`draw-frame`&&Mt(n.x0,n.y0,n.x1,n.y1),Y(),u()}function Kt(){x||(T=null,Y())}function qt(e,t){let n=R(),{sx:r,sy:i}=X(e);return Qn(t,ft(r,n),Z(i,n))??xe(t)}function Jt(e){let t=e.dataTransfer;if(!t||!Gn(t.types))return;let n=P();if(!n)return;e.preventDefault(),t.dropEffect=`copy`;let r=qt(e,n)?.id??null;r!==E&&(E=r,u())}function Yt(){E&&(E=null,u())}async function Xt(e,t){try{let n=await r.require(fr);for(let a of e){let e;try{e=await n.importFile(a)}catch(e){ne(r,a.name,e);continue}if(M)return;let o=P();if(!o)return;let s=et(o,e,t.sceneId,t.at,t.center,c);if(!s)continue;await r.commands.execute(`document.apply`,s.envelope);let l=P();!M&&l?.id===o.id&&l.activeSceneId===o.activeSceneId&&(i.setSelection({clipIds:[s.clipId],sceneId:null,enteredGroupId:null}),await y(r,o,[e],t.sceneId))}}catch(e){r.log.warn(`viewport: file drop failed`,String(e))}}async function Zt(e,t,i){try{let{gateway:r}=n,a=await r.getJob(e);if(a.kind!==t)throw Error(`result is not ${t} media`);await Xt([await r.fetchResultFile(a)],i)}catch(t){r.log.warn(`viewport: generation import failed for "${e}"`,String(t))}}function Qt(e){if(E=null,u(),!e.dataTransfer)return;let t=Kn(e.dataTransfer);if(!t)return;let n=P();if(!n)return;e.preventDefault();let a=qt(e,n);if(!a)return;let o=R(),{sx:s,sy:l}=X(e),d=ft(s,o),f=Z(l,o),p=Qn(n,d,f)===null?null:{x:d-a.x,y:f-a.y},m=i.currentTime.get();if(t.kind===`files`){Xt(t.files,{sceneId:a.id,at:m,center:p});return}if(t.kind===`generation`){Zt(t.payload.jobId,t.payload.kind,{sceneId:a.id,at:m,center:p});return}let h=t.kind===`asset`?$e(n,t.id,a.id,m,p,c):it(n,t.id,a.id,m,p,c);h&&r.commands.execute(`document.apply`,h.envelope).then(()=>{let e=P();if(M||e?.id!==n.id||e.activeSceneId!==n.activeSceneId)return;i.setSelection({clipIds:[h.clipId],sceneId:null,enteredGroupId:null});let o=t.kind===`asset`&&n.assets.find(e=>e.id===t.id);if(o)return y(r,n,[o],a.id)}).catch(e=>r.log.warn(`viewport: media drop failed`,String(e)))}function $t(e){let{sx:t,sy:n}=X(e),r=R(),a=bt(t,n);if(a){Bt(a);return}let o=F(),{ox:s,oy:c}=mt(),l=o?Yn(o,ft(t,r)-s,Z(n,r)-c,i.currentTime.get()):null;if(!l||!o)return;let u=i.selection.get().enteredGroupId,d=Zn(l,u);if(d.kind===`group`){let e=Zn(l,d.id);i.setSelection({enteredGroupId:d.id,clipIds:[e.id]});return}l.clip.kind===`text`&&d.id===l.clip.id&&(i.setSelection({clipIds:[l.clip.id]}),Rt(l.clip))}function en(e){e.preventDefault();let{sx:t,sy:n}=X(e);i.setCamera(Mn(R(),{sx:t,sy:n,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function tn(e){if(!p(e.target)){if(e.code===`Space`){b=!0,e.target===f.document.body&&e.preventDefault(),Y();return}if(!(e.metaKey||e.ctrlKey||e.altKey)){switch(e.key){case`v`:case`V`:i.setActiveTool(`move`);break;case`f`:case`F`:i.setActiveTool(`frame`);break;case`h`:case`H`:i.setActiveTool(`hand`);break;case`r`:case`R`:i.setActiveTool(`rect`);break;case`t`:case`T`:i.setActiveTool(`text`);break;case`Delete`:case`Backspace`:{let t=i.selection.get();t.sceneId&&t.clipIds.length===0&&(e.preventDefault(),Nt(t.sceneId));return}case`Escape`:if(i.selection.get().enteredGroupId){i.setSelection({enteredGroupId:null});break}i.clearSelection();break;default:return}Y(),u()}}}function nn(e){e.code===`Space`&&(b=!1,Y())}function rn(e){let t=F();if(!t)return!1;let n=i.activeTool.get();if(n!==`rect`&&n!==`frame`&&n!==`text`)return!1;let r=e.x+t.x,a=e.y+t.y;switch(e.type){case`down`:return n===`text`?(jt(r,a),!0):(x={kind:n===`rect`?`draw-rect`:`draw-frame`,x0:r,y0:a,x1:r,y1:a},u(),!0);case`move`:return x?.kind===`draw-rect`||x?.kind===`draw-frame`?(x.x1=r,x.y1=a,u(),!0):!1;case`up`:case`cancel`:if(x?.kind===`draw-rect`||x?.kind===`draw-frame`){let t=x;return x=null,e.type===`up`&&(t.kind===`draw-rect`?At(t.x0,t.y0,t.x1,t.y1):Mt(t.x0,t.y0,t.x1,t.y1)),u(),!0}return!1}}return ee.push(i.previewQuality.subscribe(()=>u()),i.camera.subscribe(()=>{ue(),T=null,O?.(),!v&&(g=!1,u())}),i.selection.subscribe(()=>{T=null,u()}),i.activeTool.subscribe(()=>{Y(),u()}),i.playing.subscribe(u),i.currentTime.subscribe(()=>{ue(),k&&(A?.player?.seek(i.currentTime.get()),O?.()),u()}),i.activeSceneId.subscribe(()=>{let e=P();e&&e.activeSceneId!==ce&&(ce=e.activeSceneId,_=null,x=null,ue(),k&&Q(),He(),u())}),a.onEvent(e=>{if(e.type===`closed`){queueMicrotask(()=>{M||P()||(ae=null,ce=null,_=null,x=null,ue(),he.reset(),Q(),Be(),Ee(),u())});return}if(e.type!==`changed`&&e.type!==`opened`)return;e.type===`opened`&&(x=null,ue(),Q(),e.document.id!==ae&&(_=null,he.reset(),g=!0,Be(),Ee()),ae=e.document.id);let t=e.type===`opened`?e.document:P();He(t);for(let e of V.values())Ve(e,t);k&&t&&A&&(A.document=t,A.player?.setDocument(Ft(t,k)),O?.()),u()})),t.addEventListener(`pointerdown`,Ut),t.addEventListener(`pointermove`,Wt),t.addEventListener(`pointerleave`,Kt),t.addEventListener(`pointerup`,Gt),t.addEventListener(`pointercancel`,Gt),t.addEventListener(`dblclick`,$t),t.addEventListener(`wheel`,en,{passive:!1}),t.addEventListener(`contextmenu`,Vt),t.addEventListener(`dragover`,Jt),t.addEventListener(`dragleave`,Yt),t.addEventListener(`drop`,Qt),f.addEventListener(`keydown`,tn),f.addEventListener(`keyup`,nn),f.document.fonts?.addEventListener(`loadingdone`,u),He(),i.requestRender(),u(),{draw:K,toolPointer:rn,zoomToFit:Ge,zoomToActual:U,zoomBy:Ke,zoomToSelection:qe,scrubPreview:Qe,editSelectedText:zt,dispose(){M=!0,Q(),je(),q?.removeAttribute(`src`),q=null,J=null;for(let e of ee)e.dispose();Be(),he.dispose(),Ee(),t.removeEventListener(`pointerdown`,Ut),t.removeEventListener(`pointermove`,Wt),t.removeEventListener(`pointerleave`,Kt),t.removeEventListener(`pointerup`,Gt),t.removeEventListener(`pointercancel`,Gt),t.removeEventListener(`dblclick`,$t),t.removeEventListener(`wheel`,en),t.removeEventListener(`contextmenu`,Vt),t.removeEventListener(`dragover`,Jt),t.removeEventListener(`dragleave`,Yt),t.removeEventListener(`drop`,Qt),f.removeEventListener(`keydown`,tn),f.removeEventListener(`keyup`,nn),f.document.fonts?.removeEventListener(`loadingdone`,u)}}}var gr=new Map([[`Inter`,`sans-serif`],[`Geologica`,`sans-serif`],[`Nunito`,`sans-serif`],[`Figtree`,`sans-serif`],[`Urbanist`,`sans-serif`],[`Montserrat`,`sans-serif`],[`Bangers`,`cursive`],[`Chewy`,`cursive`],[`Source Code Pro`,`monospace`],[`monospace`,`monospace`]]);function _r(e){let t=e.fontFamily,n=t.includes(` `)&&!t.includes(`,`)&&!t.includes(`"`)?`"${t}"`:t,r=gr.get(t),i=r&&r!==t?`${n}, ${r}`:n;return`${e.italic?`italic `:``}${e.fontWeight} ${e.fontSize}px ${i}`}var vr={clipIds:[],sceneId:null,enteredGroupId:null};function yr({bindStage:e}){let t=h(),{gateway:n,previewMuted:s}=v(),c=d(),l=f(c?.selection,vr,e=>e.clipIds),p=g(e=>Ut(e,l)),[m,_]=(0,U.useState)(`result`),y=m===`source`&&p?`source`:`result`,b=Gt(p,y===`source`),x=f(s,!1),S=(0,U.useId)();(0,U.useEffect)(()=>{if(y!==`source`||!c)return;c.pause();let e=c.playing.subscribe(e=>{e&&c.pause()});return()=>e.dispose()},[y,c]);let C=u(r),w=u(a),T=u(i),E=u(o),D=(0,U.useRef)(null),O=(0,U.useRef)(null),k=(0,U.useRef)(null),A=(0,U.useRef)(null),M=(0,U.useRef)(null),ee=(0,U.useRef)(null),[N,te]=(0,U.useState)(null),[ne,P]=(0,U.useState)(null),[re,ie]=(0,U.useState)(null),ae=(0,U.useCallback)((e,t)=>{M.current?.draw(e,t)},[]),I=(0,U.useCallback)(e=>{let t=A.current,n=O.current;if(!t||!n||!e){t&&(t.hidden=!0);return}t.hidden=!1;let{x:r,y:i}=he(e,{width:n.clientWidth,height:n.clientHeight},{width:t.offsetWidth,height:t.offsetHeight}),a=`translate3d(${r}px, ${i}px, 0)`;t.style.transform!==a&&(t.style.transform=a)},[]),oe=(0,U.useCallback)(e=>{t.commands.execute(e).catch(n=>{t.log.warn(`contextual control "${e}" failed`,{error:String(n)})})},[t]),se=(0,U.useCallback)(()=>{M.current?.editSelectedText()},[]),L=(0,U.useCallback)(e=>{t.commands.execute(`document.apply`,e).catch(e=>{t.log.error(`document.apply failed`,{error:String(e)})})},[t]);return(0,U.useEffect)(()=>{if(!c||!C||!w||!T||!E)return;let r=O.current,i=k.current;if(!r||!i)return;let a=hr(r,i,{host:t,gateway:n,session:c,docs:C,frames:w,players:T,placement:E,apply:L,invalidate:()=>ee.current?.(),updateSelectionToolbar:I,showMenu:(e,t,n)=>te({x:e,y:t,items:n}),showComponentEditor:(e,t,n)=>P({x:e,y:t,clipId:n}),showAutoLayoutEditor:(e,t,n)=>ie({x:e,y:t,...n})});M.current=a;let o=e(a,c);return()=>{o.dispose(),a.dispose(),M.current=null}},[n,t,c,C,w,T,E,L,e,I]),(0,Z.jsxs)(`div`,{ref:D,className:`fv-root bg-q-background-primary text-q-text-primary text-q-body-sm-regular`,"data-preview-mode":y,children:[(0,Z.jsx)(_t,{}),(0,Z.jsxs)(`div`,{ref:O,id:S,className:`fv-stage`,role:`region`,"aria-label":y===`source`?`Original clip preview`:`Edited project preview`,children:[(0,Z.jsx)(Le,{draw:ae,invalidate:ee,canvasRef:k,className:`fv-canvas`}),y===`result`&&(0,Z.jsx)(kn,{}),(0,Z.jsx)(Lt,{toolbarRef:A,apply:L,execute:oe,editSelectedText:se}),y===`source`&&(0,Z.jsxs)(`div`,{className:`fv-source-preview`,children:[b.src&&p?.kind===`video`&&(0,Z.jsx)(`video`,{ref:b.videoRef,src:b.src,muted:x,playsInline:!0,preload:`metadata`,onLoadedMetadata:b.syncVideo,onPlay:b.syncVideo,onPause:b.syncVideo,onEnded:b.syncVideo,onTimeUpdate:e=>b.currentTime.set(e.currentTarget.currentTime),onError:b.onError},p.id),b.src&&p?.kind===`image`&&(0,Z.jsx)(`img`,{src:b.src,alt:`Selected clip source`,onError:b.onError}),!b.src&&(0,Z.jsx)(`p`,{role:`status`,children:b.error??`Loading original…`})]})]}),(0,Z.jsx)(qt,{rootRef:D,mode:y,onModeChange:_,sourceAvailable:p!==null,source:b,previewId:S,palette:y===`result`?(0,Z.jsx)(wn,{}):null}),N&&(0,Z.jsx)(j,{x:N.x,y:N.y,items:N.items,onClose:()=>te(null)}),ne&&(0,Z.jsx)(He,{x:ne.x,y:ne.y,clipId:ne.clipId,onClose:()=>P(null)}),re&&(0,Z.jsx)(F,{...re,onClose:()=>ie(null)})]})}export{yr as default};
|