@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.
Files changed (189) hide show
  1. package/THIRD_PARTY_NOTICES.md +24 -24
  2. package/dist/cli.mjs +134 -125
  3. package/dist/index.html +136 -133
  4. package/dist/launcher.mjs +90 -90
  5. package/dist/server.mjs +1553 -1389
  6. package/node_modules/@higgsfield/higgsedit/README.md +181 -1
  7. package/node_modules/@higgsfield/higgsedit/dist/capture-page.js +902 -314
  8. package/node_modules/@higgsfield/higgsedit/dist/chunk-2JYLVSVV.mjs +1594 -0
  9. package/node_modules/@higgsfield/higgsedit/dist/chunk-2WKNH7OL.mjs +16 -0
  10. package/node_modules/@higgsfield/higgsedit/dist/{chunk-OMKZ5BXM.mjs → chunk-5LTTL3Q3.mjs} +1 -1
  11. package/node_modules/@higgsfield/higgsedit/dist/chunk-7PYXSJS7.mjs +717 -0
  12. package/node_modules/@higgsfield/higgsedit/dist/{chunk-MLJAIZGP.mjs → chunk-BH2QF635.mjs} +33 -326
  13. package/node_modules/@higgsfield/higgsedit/dist/{chunk-WZR5PZM7.mjs → chunk-BV5COOQZ.mjs} +250 -161
  14. package/node_modules/@higgsfield/higgsedit/dist/{chunk-HTCYVKFX.mjs → chunk-C3GSB3XZ.mjs} +8 -7
  15. package/node_modules/@higgsfield/higgsedit/dist/{chunk-CYH2EUQV.mjs → chunk-DVN4LUXV.mjs} +13 -4
  16. package/node_modules/@higgsfield/higgsedit/dist/chunk-F4CMIG5G.mjs +36 -0
  17. package/node_modules/@higgsfield/higgsedit/dist/chunk-IEPPEDEU.mjs +33 -0
  18. package/node_modules/@higgsfield/higgsedit/dist/{chunk-UVAZ6I6U.mjs → chunk-KIWGVAPJ.mjs} +16 -12
  19. package/node_modules/@higgsfield/higgsedit/dist/{chunk-L6QDNSL3.mjs → chunk-L5LWBA6A.mjs} +5 -5
  20. package/node_modules/@higgsfield/higgsedit/dist/chunk-LMQR3DHT.mjs +37 -0
  21. package/node_modules/@higgsfield/higgsedit/dist/chunk-LTKMGZ6T.mjs +58 -0
  22. package/node_modules/@higgsfield/higgsedit/dist/{chunk-VI6IV6JP.mjs → chunk-MV2JTTBQ.mjs} +65 -47
  23. package/node_modules/@higgsfield/higgsedit/dist/{chunk-4D6AXU4B.mjs → chunk-NARTAWRN.mjs} +50 -30
  24. package/node_modules/@higgsfield/higgsedit/dist/{chunk-27NBQ5FA.mjs → chunk-NUXTKQNM.mjs} +33 -21
  25. package/node_modules/@higgsfield/higgsedit/dist/chunk-OCIZ36XD.mjs +40 -0
  26. package/node_modules/@higgsfield/higgsedit/dist/{chunk-MK6PL7N4.mjs → chunk-OF6RMSM2.mjs} +19 -17
  27. package/node_modules/@higgsfield/higgsedit/dist/{chunk-6BETMESC.mjs → chunk-P2BGHTRR.mjs} +2 -2
  28. package/node_modules/@higgsfield/higgsedit/dist/{chunk-EKFC4S4M.mjs → chunk-PAHMD6SU.mjs} +5 -0
  29. package/node_modules/@higgsfield/higgsedit/dist/{chunk-QVLAEV3U.mjs → chunk-PFQYUJQL.mjs} +3 -4
  30. package/node_modules/@higgsfield/higgsedit/dist/chunk-QJTILFBS.mjs +335 -0
  31. package/node_modules/@higgsfield/higgsedit/dist/chunk-QQ3GGKDN.mjs +21 -0
  32. package/node_modules/@higgsfield/higgsedit/dist/chunk-TH7TK67K.mjs +23 -0
  33. package/node_modules/@higgsfield/higgsedit/dist/{chunk-SIMO6I3D.mjs → chunk-UDL5AHKO.mjs} +163 -158
  34. package/node_modules/@higgsfield/higgsedit/dist/chunk-UMWOUQN3.mjs +60 -0
  35. package/node_modules/@higgsfield/higgsedit/dist/{chunk-3AIM3THH.mjs → chunk-VLM5EOWJ.mjs} +4 -4
  36. package/node_modules/@higgsfield/higgsedit/dist/chunk-WENFTPXQ.mjs +403 -0
  37. package/node_modules/@higgsfield/higgsedit/dist/chunk-YLVXQIPX.mjs +464 -0
  38. package/node_modules/@higgsfield/higgsedit/dist/editor/.vite/manifest.json +559 -506
  39. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/agent-corner-bottom-q4hZltI-.svg +431 -0
  40. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/agent-corner-top-BJYI-I24.svg +431 -0
  41. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/confirmation-BTnwl3LS.css +1 -0
  42. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/drag-Bt_t4HZO.css +1 -0
  43. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/local-B3OTAV_A.css +1 -0
  44. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/menubar-2Y1Y2XJt.css +1 -0
  45. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/model-DdE4hCgf.css +1 -0
  46. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/{IconText1-CzbCrP7v.css → notifications-B08L1jSe.css} +1 -1
  47. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/{panel-g852pZf_.css → panel-BRN_AbBM.css} +1 -1
  48. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-CYELNqrv.css +1 -0
  49. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-DYLpT6oA.css +1 -0
  50. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-v84HaGTZ.css +1 -0
  51. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconChainLink1-Bxb1Or0F.js +1 -0
  52. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconCheckmark2Medium-daaES9uF.js → IconCheckmark2Medium-hegaz9mQ.js} +1 -1
  53. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconChevronDownSmall-BhTBJk26.js → IconChevronDownSmall-DaruzJwU.js} +1 -1
  54. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconClosedCaptioning-BPqcqKsD.js +1 -0
  55. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconCrossMedium-acfnCXOM.js → IconCrossMedium-BsPFJzc6.js} +1 -1
  56. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconOpenaiFilled-D1fzthmi.js +1 -0
  57. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconPause-pTeVSvUe.js → IconPause-ClNg8pao.js} +1 -1
  58. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{IconPlayFilled-CwdgIuDG.js → IconPlayFilled-CHb-7GSx.js} +1 -1
  59. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconSparklesSoftFilled-o7o33KRn.js +1 -0
  60. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/ai-composer-B9h-eaki.js +567 -0
  61. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/auto-layout-BO20Tg4B.js +1 -0
  62. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{button-CjG6GcgF.js → button-Cg0U0zpV.js} +1 -1
  63. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/canvas-Bw4CVzfw.js +1 -0
  64. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/capabilities-BCd4-zPF.js +1 -0
  65. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/commands-QeSqAbCt.js +1 -0
  66. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/components-tXMtIZNL.js +51 -0
  67. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/confirmation-CO2PHR_z.js +1 -0
  68. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/dom-6aoQn29n.js +1 -0
  69. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/drag-Dw8b_vO2.js +1 -0
  70. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{editing-CjWbiCxv.js → editing-Cy-SaOyB.js} +1 -1
  71. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/edits-CqLBqir0.js +1 -0
  72. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/export-dialog-BjBskOe3.js +2 -0
  73. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/factories-Bw_iQrUL.js +1 -0
  74. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/id3-CSR0NCRI.js +2 -0
  75. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/import-DP49i4ke.js +1 -0
  76. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/import-error-CMz9sLPe.js +1 -0
  77. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/ingest-DsmIc415.js +1 -0
  78. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/jsx-runtime-B5yqYJvp.js +1 -0
  79. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/{media-Bwjxu-0U.js → media-DQw6vU_T.js} +1 -1
  80. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/menubar-D31srALX.js +1 -0
  81. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/meters-D0nZVEJs.js +1 -0
  82. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/mode-DEG6doKF.js +1 -0
  83. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/model-Duf9fszJ.js +2 -0
  84. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/model-DyAkLA69.js +1 -0
  85. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/notifications-DqWZNIrK.js +9 -0
  86. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/palette-HT83gWgL.js +1 -0
  87. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-B5Mvm6dg.js +7 -0
  88. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-BC90wyvd.js +1 -0
  89. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-Bw_ZJ2JI.js +3 -0
  90. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DNS060Nt.js +3 -0
  91. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DSgxIrEq.js +2 -0
  92. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DgBttE5O.js +1 -0
  93. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-assets-_T2bHsHW.js +771 -0
  94. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-inspector-DfHvAt5X.js +2 -0
  95. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-nBZvHlkA.js +1 -0
  96. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-timeline-DsCpJVSt.js +327 -0
  97. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-viewport-CEhZwZ67.js +280 -0
  98. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/projects-2_tW9Do7.js +1 -0
  99. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/react-dom-1uB7Vbbb.js +1 -0
  100. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/schemas-CddYAOcj.js +64 -0
  101. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/session-BpFeKAI2.js +1 -0
  102. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/src-BLG3tYBa.js +2 -0
  103. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/styles-e2n2A_JN.js +284 -0
  104. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/supercomputer-CuV0zYKd.js +24 -0
  105. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/tabs-XeAgs9cs.js +1 -0
  106. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/toggle-DbNEaSIl.js +1 -0
  107. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-C8Ll3qFl.js +69 -0
  108. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-bar-Dv1LPFbu.js +1 -0
  109. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useOpenInteractionType-HWSfSsp2.js +1 -0
  110. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useRenderElement-D4SOg3N_.js +1 -0
  111. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/value-EB7YmAdS.js +1 -0
  112. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/writeback-support-fj5rA9k3.js +1 -0
  113. package/node_modules/@higgsfield/higgsedit/dist/editor/editor-B-WAkLt7.js +372 -0
  114. package/node_modules/@higgsfield/higgsedit/dist/higgsedit.mjs +39 -24
  115. package/node_modules/@higgsfield/higgsedit/dist/jsx/hooks.d.ts +26 -0
  116. package/node_modules/@higgsfield/higgsedit/dist/jsx/index.d.ts +17 -0
  117. package/node_modules/@higgsfield/higgsedit/dist/jsx/inspect.d.ts +42 -0
  118. package/node_modules/@higgsfield/higgsedit/dist/jsx/jsx-runtime.d.ts +28 -0
  119. package/node_modules/@higgsfield/higgsedit/dist/jsx/svg.d.ts +9 -0
  120. package/node_modules/@higgsfield/higgsedit/dist/jsx/time.d.ts +6 -0
  121. package/node_modules/@higgsfield/higgsedit/dist/jsx/types.d.ts +420 -0
  122. package/node_modules/@higgsfield/higgsedit/package.json +28 -20
  123. package/package.json +4 -3
  124. package/plugin/.codex-plugin/plugin.json +1 -1
  125. package/plugin/plugin.json +1 -1
  126. package/plugin/skills/video-editing/references/caption-titling.md +1 -1
  127. package/plugin/skills/video-editing/references/local-setup.md +3 -3
  128. package/node_modules/@higgsfield/higgsedit/dist/chunk-C6SASQHE.mjs +0 -424
  129. package/node_modules/@higgsfield/higgsedit/dist/chunk-FZ5U36SQ.mjs +0 -83
  130. package/node_modules/@higgsfield/higgsedit/dist/chunk-QLPCYN6K.mjs +0 -292
  131. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/edit-drag-D2EV5ddd.css +0 -1
  132. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/editor-CuRHT75g.css +0 -1
  133. package/node_modules/@higgsfield/higgsedit/dist/editor/assets/panel-DnuQD7ja.css +0 -1
  134. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/FieldControl-B0fenhBJ.js +0 -2
  135. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconChainLink1-Cwv1X7hi.js +0 -1
  136. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconEyeOpen-BqTT9_VV.js +0 -1
  137. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconEyeSlash-Whv58c1m.js +0 -1
  138. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconPencil-Dr17k_7e.js +0 -1
  139. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconPlay-BroH3ziH.js +0 -1
  140. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconPlusSmall-43T9aE3d.js +0 -1
  141. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconText1-BaP_p9DW.js +0 -1
  142. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/IconTrashCan-DX2w2AIC.js +0 -1
  143. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/ai-composer-C-l0eIdP.js +0 -560
  144. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/captions-Cd-bDG3G.js +0 -1
  145. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/clip-highlight-DpAvcA4x.js +0 -1
  146. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/components-e3ZbUVns.js +0 -1
  147. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/disposables-CwUPjcuA.js +0 -1
  148. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/drag-HLBkto5o.js +0 -1
  149. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/dropdown-BJ04G_X3.js +0 -1
  150. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/edit-drag-Bg6LggKC.js +0 -1
  151. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/edits-a2IixhrN.js +0 -1
  152. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/export-dialog-4I4gqI5V.js +0 -2
  153. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/face-tracker-DzVfjVOO.js +0 -1
  154. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/fit-imported-media-CaCB0x0b.js +0 -1
  155. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/generation-queue-DuL2F4-_.js +0 -1
  156. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/import-error-CMARA0Hy.js +0 -1
  157. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/jsx-runtime-B-hcVAMW.js +0 -1
  158. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/menubar-Bs26OdwP.js +0 -1
  159. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/meters-YEr9OQjq.js +0 -1
  160. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/paints-DS2Msf91.js +0 -67
  161. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/palette-CcS9IcAC.js +0 -1
  162. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-7M3uQokX.js +0 -1
  163. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-BBK1NyG-.js +0 -1
  164. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-CHZTs7By.js +0 -4
  165. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DaSOa3MP.js +0 -2
  166. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-DlK3RYVo.js +0 -1
  167. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-Dst5OKWu.js +0 -2
  168. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-H_ZoDiKK.js +0 -2
  169. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-Rn9Z7Eek.js +0 -3
  170. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-assets-FAghGFG3.js +0 -678
  171. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-inspector-DEqULBNF.js +0 -260
  172. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-timeline-0GYNz1uc.js +0 -333
  173. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/panel-viewport-DOWjJi5-.js +0 -317
  174. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/projects-BBJc7h5_.js +0 -2
  175. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/session-B9sZaFKC.js +0 -1
  176. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/supercomputer-CX-LCL6Y.js +0 -24
  177. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/tabs-CvKQ-eas.js +0 -1
  178. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/toggle-CrzrwiDZ.js +0 -1
  179. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-BgRfk-Qq.js +0 -69
  180. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/transport-bar-C9nqAfE2.js +0 -1
  181. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/typography-C5-w9LOu-kD3uLKkf.js +0 -1
  182. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useOpenInteractionType-DbrQ6Ehu.js +0 -1
  183. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/useRenderElement-bbxXdYq0.js +0 -1
  184. package/node_modules/@higgsfield/higgsedit/dist/editor/chunks/writeback-support-BZfNpkmB.js +0 -1
  185. package/node_modules/@higgsfield/higgsedit/dist/editor/editor-Csn2_T_e.js +0 -293
  186. package/node_modules/@higgsfield/higgsedit/dist/export-settings.mjs +0 -75
  187. package/node_modules/@higgsfield/higgsedit/dist/history.mjs +0 -295
  188. package/node_modules/@higgsfield/higgsedit/dist/media-upload.mjs +0 -381
  189. package/node_modules/@higgsfield/higgsedit/dist/proxy.mjs +0 -170
@@ -0,0 +1,3 @@
1
+ import{n as e,s as t,t as n}from"./jsx-runtime-B5yqYJvp.js";import{r}from"./notifications-DqWZNIrK.js";import{t as i}from"./react-dom-1uB7Vbbb.js";import{i as a,n as o,t as s}from"./capabilities-BCd4-zPF.js";import{n as c}from"./session-BpFeKAI2.js";import{a as l}from"./ingest-DsmIc415.js";import{t as u}from"./value-EB7YmAdS.js";import{c as d,d as f,g as p,l as m,v as h}from"./schemas-CddYAOcj.js";import{t as g}from"./IconCheckmark2Medium-hegaz9mQ.js";import{i as _,n as v,o as y}from"./import-error-CMz9sLPe.js";import{n as b}from"./dom-6aoQn29n.js";import{r as x}from"./import-DP49i4ke.js";import{_ as S,a as C,b as w,c as T,d as E,f as D,g as O,h as k,i as ee,l as te,m as ne,n as re,p as ie,r as ae,t as oe,u as se,v as A,y as ce}from"./model-Duf9fszJ.js";import{d as le}from"./useRenderElement-D4SOg3N_.js";import{A as ue,B as de,C as j,F as fe,H as M,L as N,M as P,R as F,S as pe,T as me,b as I,c as L,f as R,g as z,h as he,j as ge,n as _e,o as B,r as V,w as H,z as ve}from"./components-tXMtIZNL.js";import{$ as ye,A as be,E as xe,M as Se,N as Ce,P as we,Q as Te,X as U,Z as Ee,_ as W,at as De,ct as Oe,d as ke,dt as Ae,et as je,f as Me,ft as Ne,g as Pe,it as Fe,k as G,lt as K,m as q,nt as Ie,ot as Le,p as J,pt as Re,rt as ze,st as Be,tt as Ve,ut as He,w as Ue,x as We,y as Ge}from"../editor-B-WAkLt7.js";import{t as Y}from"./mode-DEG6doKF.js";import{t as X}from"./button-Cg0U0zpV.js";import{n as Ke,t as qe}from"./toggle-DbNEaSIl.js";import{n as Je,t as Ye}from"./IconOpenaiFilled-D1fzthmi.js";import{a as Xe,i as Ze,r as Qe,t as $e}from"./id3-CSR0NCRI.js";import{r as et,t as tt}from"./auto-layout-BO20Tg4B.js";import{_ as nt,a as rt,c as it,d as at,f as ot,g as st,h as ct,i as lt,l as ut,m as dt,n as ft,o as pt,p as mt,r as ht,s as gt,t as _t,u as vt,v as yt}from"./IconChainLink1-Bxb1Or0F.js";import{t as bt}from"./canvas-Bw4CVzfw.js";import{n as xt,t as St}from"./palette-HT83gWgL.js";import{a as Ct,c as wt,i as Tt,l as Et,n as Z,o as Dt,r as Ot,s as kt,t as At,u as jt}from"./drag-Dw8b_vO2.js";import{t as Mt}from"./IconPlayFilled-CHb-7GSx.js";var Nt=t(i(),1),Q=n(),$=t(e(),1),Pt=e=>{let t=$.useId();return $.createElement(Rt,{...e,instanceId:t})},Ft=0,It=typeof $.useId==`function`?void 0:class extends $.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++Ft}`})}render(){return $.createElement(Rt,{...this.props.iconProps,instanceId:this.state.instanceId})}},Lt=$.forwardRef((e,t)=>It?$.createElement(It,{iconProps:{...e,svgRef:t}}):$.createElement(Pt,{...e,svgRef:t}));Lt.displayName=`CentralIconBase`;var Rt=({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 $.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&&$.createElement(`title`,null,y),g?$.createElement($.Fragment,null,$.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},$.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),$.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),$.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},zt=$.memo($.forwardRef((e,t)=>$.createElement(Lt,{...e,ref:t,ariaLabel:`arrow-rotate-counter-clockwise, rotate-left`,maskId:`round-outlined-radius-2-stroke-1.5-IconArrowRotateCounterClockwise`},$.createElement(`path`,{d:`M5.4998 7.00891C7.32073 4.95438 9.20364 3.75 12.0208 3.75C16.5771 3.75 20.2708 7.44365 20.2708 12C20.2708 16.5563 16.5771 20.25 12.0208 20.25C8.42869 20.25 5.37278 17.9543 4.24023 14.75`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),$.createElement(`path`,{d:`M4.75 4V7.25C4.75 7.66421 5.08579 8 5.5 8H8.75`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}))));function Bt(e,t,n){let r=n.x-t.x,i=n.y-t.y,a=r*r+i*i,o=a?Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/a)):0;return Math.hypot(e.x-t.x-r*o,e.y-t.y-i*o)}function Vt(e,t,n){if(e.length<3)return e;let r=e.map(e=>({x:e.x*t,y:e.y*n})),i=new Set([0,e.length-1]),a=[[0,e.length-1]];for(;a.length;){let[e,t]=a.pop(),n=.75,o=-1;for(let i=e+1;i<t;i++){let a=Bt(r[i],r[e],r[t]);a>n&&(n=a,o=i)}o<0||(i.add(o),a.push([e,o],[o,t]))}return e.filter((e,t)=>i.has(t))}function Ht(e,t,n,r){let i=(e,t,n)=>(t.x-e.x)*(n.y-e.y)-(t.y-e.y)*(n.x-e.x);return i(e,t,n)*i(e,t,r)<0&&i(n,r,e)*i(n,r,t)<0}function Ut(e,t,n,r,i){let a=e=>({x:e.x*r,y:e.y*i}),o=a(t),s=a(n);return e.filter(e=>{let t=8+e.width*Math.min(r,i)/2;return!e.points.some((n,r)=>{let i=a(n),c=a(e.points[Math.max(0,r-1)]);return Ht(o,s,i,c)||Math.min(Bt(i,o,s),Bt(c,o,s),Bt(o,i,c),Bt(s,i,c))<=t})})}function Wt(e,t,n,r){e.lineCap=`round`,e.lineJoin=`round`;for(let i of t){let t=i.points[0];if(t){if(e.strokeStyle=e.fillStyle=i.color,e.lineWidth=i.width*Math.min(n,r),e.beginPath(),i.points.length===1)e.arc(t.x*n,t.y*r,e.lineWidth/2,0,Math.PI*2),e.fill();else{e.moveTo(t.x*n,t.y*r);for(let t=1;t<i.points.length;t++)e.lineTo(i.points[t].x*n,i.points[t].y*r);e.stroke()}}}}var Gt={kind:`cubic-bezier`,x1:.22,y1:1,x2:.36,y2:1};function Kt(e){let t=1,n=1,r=0,i=0;for(let a of e.drawing?.strokes??[])for(let e of a.points)t=Math.min(t,e.x),n=Math.min(n,e.y),r=Math.max(r,e.x),i=Math.max(i,e.y);return{x:(t+r)/2,y:(n+i)/2}}var qt=class{layers=new Map;opacity(e,t){let n=e.to?250:150,r=Math.min(1,Math.max(0,(t-e.at)/n));return e.from+(e.to-e.from)*A(Gt,r)}update(e,t,n,r){let i=new Set;for(let a of e){if(!a.drawing?.strokes.length)continue;i.add(a.id);let e=this.layers.get(a.id);e?(e.note.drawing!==a.drawing&&(e.center=Kt(a)),e.note=a,e.to||(e.from=this.opacity(e,t),e.to=1,e.at=t)):(e={note:a,center:Kt(a),from:0,to:1,at:t},this.layers.set(a.id,e)),(n||a.id===r)&&(e.from=e.to=1)}for(let[e,r]of this.layers)i.has(e)||(n?this.layers.delete(e):r.to&&(r.from=this.opacity(r,t),r.to=0,r.at=t))}paint(e,t){let n=!1;for(let[r,i]of this.layers){let a=this.opacity(i,e);a===0&&i.to===0?this.layers.delete(r):t(i,a),n||=a!==i.to}return n}};function Jt(e){let t=(0,$.useRef)(null),n=(0,$.useRef)(e);n.current=e;let r=(0,$.useRef)(()=>{}),i=(0,$.useRef)(()=>{}),a=(0,$.useRef)(null);(0,$.useLayoutEffect)(()=>{let e=t.current,o=e?.parentElement,s=e?.ownerDocument.defaultView;if(!e||!o||!s)return;let c=0,l=new qt,u=s.matchMedia(`(prefers-reduced-motion: reduce)`),d=null,f,p,m=t=>{c=0;let{scene:i,session:m,visible:h}=n.current,g=m.camera.get(),_=Math.min(s.devicePixelRatio||1,2),v=Math.round(o.clientWidth*_),y=Math.round(o.clientHeight*_);(e.width!==v||e.height!==y)&&(e.width=v,e.height=y);let b=e.getContext(`2d`);if(!b)return;b.setTransform(1,0,0,1,0,0),b.clearRect(0,0,v,y),b.setTransform(_,0,0,_,(i.x*g.zoom+g.panX)*_,(i.y*g.zoom+g.panY)*_),b.save(),b.beginPath();let x=i.width*g.zoom,S=i.height*g.zoom;b.rect(0,0,x,S),b.clip();let C=a.current,w=n.current.notes.selected.get()?.id;(h!==d||w!==f||u.matches!==p)&&(l.update(h,t,u.matches,w),d=h,f=w,p=u.matches);let T=l.paint(t,({note:e,center:t},n)=>{if(e.id===C?.draft.id||!e.drawing)return;b.save(),b.globalAlpha=n;let r=.96+.04*n;b.translate(t.x*x*(1-r),t.y*S*(1-r)),b.scale(r,r),Wt(b,e.drawing.strokes,x,S),b.restore()});C&&Wt(b,C.stroke?[...C.strokes,C.stroke]:C.strokes,x,S),b.restore(),T&&r.current()};r.current=()=>{c||=s.requestAnimationFrame(m)};let h=new ResizeObserver(r.current);return h.observe(o),u.addEventListener(`change`,r.current),r.current(),()=>{h.disconnect(),u.removeEventListener(`change`,r.current),s.cancelAnimationFrame(c),r.current=()=>{},i.current(),a.current=null}},[]),(0,$.useLayoutEffect)(()=>{a.current&&(!e.interactive||e.notes.selected.get()?.id!==a.current.draft.id)&&s(!0),r.current()});let o=(e,r)=>{let i=t.current.getBoundingClientRect(),{scene:a,session:o}=n.current,s=o.camera.get(),c=((e.clientX-i.left-s.panX)/s.zoom-a.x)/a.width,l=((e.clientY-i.top-s.panY)/s.zoom-a.y)/a.height;return!r&&(c<0||c>1||l<0||l>1)?null:{x:+Math.max(0,Math.min(1,c)).toFixed(5),y:+Math.max(0,Math.min(1,l)).toFixed(5)}},s=e=>{let o=a.current;if(a.current=null,!o)return;i.current();let{notes:s,onDrawing:c}=n.current,l=t.current;if(l?.hasPointerCapture(o.id)&&l.releasePointerCapture(o.id),c(!1),e&&!o.draft.drawing?.strokes.length&&!o.draft.text&&s.selected.get()?.id===o.draft.id&&s.selected.set(null),!e&&s.selected.get()?.id===o.draft.id){let e=o.stroke?[...o.strokes,{...o.stroke,points:Vt(o.stroke.points,o.width,o.height)}]:o.strokes,t=o.stroke?.points.at(-1)??o.last;!e.length&&!o.draft.text.trim()?s.remove(o.draft.id).catch(_):s.selected.set({...o.draft,...t,drawing:{strokes:e}})}r.current()},c=e=>{let t=a.current;if(!t||t.id!==e.pointerId)return;let n=e.getCoalescedEvents?.();for(let r of(n?.length?n:[e]).slice(-64)){let e=o(r,!0);if(t.stroke){if(Math.hypot((e.x-t.last.x)*t.width,(e.y-t.last.y)*t.height)<1.5)continue;t.stroke.points.length>=t.remaining&&(t.stroke.points=t.stroke.points.filter((e,t)=>t%2==0)),t.stroke.points.push(e)}else t.strokes=Ut(t.strokes,t.last,e,t.width,t.height);t.last=e}r.current()};return(0,Q.jsx)(`canvas`,{ref:t,className:`ve-draw-surface`,"data-tool":e.notes.pen.get().tool,role:`img`,"aria-label":`Draw changes on the video`,style:{pointerEvents:e.interactive?`auto`:`none`},onPointerDown:t=>{if(!e.interactive||t.button!==0||a.current||e.notes.state.get()!==`ready`)return;let n=t.currentTarget.ownerDocument.defaultView;if(!n)return;let l=o(t,!1);if(!l){e.notes.select(null).catch(_);return}let u=e.notes.selected.get();if(u&&!u.drawing)return;let d=e.notes.pen.get();if(!u&&d.tool===`eraser`)return;let f=u??xe(e.scene,e.session.currentTime.get(),l,e.notes.data.get().notes,`draw`),p=f.drawing.strokes,m=e.notes.data.get().notes.reduce((e,t)=>e+(t.id===f.id?0:we(t.drawing?.strokes??[])),0),h=Math.min(1024,Se-we(p),Ce-m-we(p));if(d.tool===`pen`&&(h<2||p.length>=256)){_(Error(`This drawing is full. Remove unused strokes or start another drawing.`));return}t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),e.session.pause(),e.session.setSelection({clipIds:[]}),e.session.seek(f.start),e.notes.selected.set(f);let g=e.session.camera.get().zoom,v=e.scene.width*g,y=e.scene.height*g;a.current={id:t.pointerId,draft:f,strokes:d.tool===`eraser`?Ut(p,l,l,v,y):p,stroke:d.tool===`pen`?{color:d.color,width:Math.min(.1,4/Math.min(v,y)),points:[l]}:null,last:l,width:v,height:y,remaining:h};let b=e=>{a.current?.id===e.pointerId&&s(e.type===`pointercancel`)},x=()=>s(!0);n.addEventListener(`pointermove`,c,!0),n.addEventListener(`pointerup`,b,!0),n.addEventListener(`pointercancel`,b,!0),n.addEventListener(`blur`,x),i.current=()=>{n.removeEventListener(`pointermove`,c,!0),n.removeEventListener(`pointerup`,b,!0),n.removeEventListener(`pointercancel`,b,!0),n.removeEventListener(`blur`,x),i.current=()=>{}},e.onDrawing(!0),r.current()}})}function Yt(e){let[t,n]=(0,$.useState)(e);return(0,$.useLayoutEffect)(()=>{if(e!==null){n(e);return}if(t===null)return;if(matchMedia(`(prefers-reduced-motion: reduce)`).matches){n(null);return}let r=setTimeout(()=>n(null),150);return()=>clearTimeout(r)},[e,t]),e??t}var Xt={revision:0,notes:[]};function Zt(){let{notes:e,chat:t}=We(),n=q(),r=J(e=>e),i=r?.scenes.find(e=>e.id===r.activeSceneId),a=W(e?.data,Xt),o=W(e?.mode,null);W(e?.pen,null);let s=W(e?.selected,null),c=W(e?.state,`loading`),l=W(e?.error,null),u=W(n?.camera,{zoom:1,panX:0,panY:0}),d=W(n?.currentTime,0,t=>be(e?.data.get().notes??[],e?.selected.get(),i?.id??``).filter(e=>e.start<=t&&t<e.start+e.duration),(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n])),[f,p]=(0,$.useState)(!1),[m,h]=(0,$.useState)(null),[g,v]=(0,$.useState)(!1),[b,x]=(0,$.useState)(!1),S=(0,$.useRef)(null),C=(0,$.useRef)(null),w=(0,$.useRef)(null),T=s?.sceneId===i?.id?s:null,E=Yt(T),D=E?.sceneId===i?.id?E:null,O=T?.id,k=!!T?.drawing,ee=Yt(o===`draw`||k||d.some(e=>e.drawing)?!0:null),te=!!T&&b;(0,$.useEffect)(()=>{if(x(!1),!O||g)return;if(!k){x(!0);return}let e=setTimeout(()=>x(!0),450);return()=>clearTimeout(e)},[O,g,k]);let ne=D&&i?{x:(i.x+D.x*i.width)*u.zoom+u.panX,y:(i.y+D.y*i.height)*u.zoom+u.panY}:null,re=ne?.x,ie=ne?.y,ae=(0,$.useCallback)(()=>{!f&&e?.state.get()!==`saving`&&e?.select(null).catch(e=>h(String(e.message??e)))},[e,f]);if((0,$.useEffect)(()=>{let t=C.current,n=S.current?.ownerDocument.defaultView;if(!n||!O)return;let r=r=>{let i=r.target;!(i instanceof n.Element)||t?.contains(i)||i.closest(`.ve-note-pin, .ve-note-clip, .ve-notes-hitarea, .ve-draw-surface, .ve-draw-tools`)||e?.selected.get()?.id!==O||ae()};return n.addEventListener(`click`,r),()=>n.removeEventListener(`click`,r)},[O,e,ae]),(0,$.useEffect)(()=>{h(null),O&&b&&!k&&!w.current?.ownerDocument.activeElement?.closest(`.ve-note-clip`)&&w.current?.focus()},[O,k,b]),(0,$.useEffect)(()=>{s&&s.sceneId!==i?.id&&e?.select(null).catch(_)},[i?.id,s,e]),(0,$.useLayoutEffect)(()=>{let e=C.current,t=S.current;if(!e||!t||re===void 0||ie===void 0)return;let n=()=>{e.style.left=`${Math.max(8,Math.min(re+8,t.clientWidth-e.offsetWidth-8))}px`,e.style.top=`${Math.max(8,Math.min(ie+8,t.clientHeight-e.offsetHeight-8))}px`};n();let r=new ResizeObserver(n);return r.observe(t),r.observe(e),()=>r.disconnect()},[re,ie,O]),!e||!i||!n||!r)return null;let oe=()=>{T&&!f&&e.state.get()!==`saving`&&e.remove(T.id).catch(e=>h(String(e.message??e)))},se=async()=>{if(T?.text.trim()&&!f&&e.state.get()!==`saving`&&e.state.get()!==`loading`){p(!0),h(null);try{await e.save(T,()=>t.attachNote(r,{...T,text:T.text.trim()})),e.selected.get()?.id===T.id&&e.selected.set(null),y(`${Ue(T)} added to chat`)}catch(e){h(e instanceof Error?e.message:`Could not add the note. Try again.`)}finally{p(!1)}}};return(0,Q.jsxs)(`div`,{ref:S,className:`ve-notes-overlay`,children:[ee&&(0,Q.jsx)(Jt,{notes:e,scene:i,session:n,visible:T?.drawing?[...d.filter(e=>e.id!==T.id),T]:d,interactive:o===`draw`&&!f&&c===`ready`,onDrawing:v},i.id),o===`note`&&(0,Q.jsx)(`div`,{className:`ve-notes-hitarea`,role:`button`,tabIndex:0,"aria-label":`Place a note on the video`,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),!(f||T)&&(n.pause(),n.setSelection({clipIds:[]}),c===`ready`&&i.duration>0&&e.selected.set(xe(i,n.currentTime.get(),{x:.5,y:.5},a.notes))))},onClick:t=>{if(t.button!==0||f)return;if(T){ae();return}if(c!==`ready`||i.duration<=0)return;let r=t.currentTarget.getBoundingClientRect(),o=((t.clientX-r.left-u.panX)/u.zoom-i.x)/i.width,s=((t.clientY-r.top-u.panY)/u.zoom-i.y)/i.height;o<0||o>1||s<0||s>1||(n.pause(),n.setSelection({clipIds:[]}),e.selected.set(xe(i,n.currentTime.get(),{x:o,y:s},a.notes)))}}),d.filter(e=>!e.drawing).map(t=>(0,Q.jsx)(`button`,{type:`button`,className:`ve-note-pin`,"aria-label":`Open note ${t.number}`,disabled:f||c===`saving`,style:{left:(i.x+t.x*i.width)*u.zoom+u.panX,top:(i.y+t.y*i.height)*u.zoom+u.panY},onClick:()=>{n.pause(),n.setSelection({clipIds:[]}),e.select(t).then(()=>e.mode.set(`note`)).catch(e=>h(String(e.message??e)))},children:t.number},t.id)),D&&(0,Q.jsxs)(`div`,{ref:C,role:`dialog`,"aria-label":Ue(D),"aria-hidden":!te,inert:!te,"data-open":te,className:`ve-note-popover`,"data-theme":`default-dark`,onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&ae()},children:[(0,Q.jsxs)(`header`,{children:[(0,Q.jsxs)(`span`,{children:[Ue(D),` `,(0,Q.jsx)(`time`,{children:G(D.start)})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":D.drawing?`Delete drawing`:`Delete note`,title:D.drawing?`Delete drawing`:`Delete note`,disabled:f||c===`saving`,onClick:oe,children:(0,Q.jsx)(Je,{size:16})}),(0,Q.jsxs)(`button`,{type:`button`,className:`ve-note-add`,"aria-label":D.drawing?`Add drawing to chat`:`Add note to chat`,title:`Add to chat`,disabled:!T?.text.trim()||f||c===`loading`||c===`saving`,"aria-busy":f,onClick:()=>void se(),children:[(0,Q.jsx)(Ye,{size:20}),(0,Q.jsx)(`span`,{children:`Add`})]})]})]}),(0,Q.jsx)(`textarea`,{ref:w,"aria-label":D.drawing?`Drawing prompt`:`Note text`,placeholder:`What should be changed?`,maxLength:4e3,value:D.text,disabled:f||c===`saving`,onKeyDown:e=>{e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||e.nativeEvent.keyCode===229||(e.preventDefault(),e.repeat||se())},onChange:t=>{T&&e.selected.set({...T,text:t.target.value})}}),m&&(0,Q.jsx)(`p`,{role:`alert`,children:m})]}),(o||d.length>0||T)&&(0,Q.jsxs)(`span`,{className:`ve-notes-export-hint`,children:[`ⓘ `,o===`draw`||k?`Drawings`:`Notes`,` won’t export`]}),o&&c===`error`&&(0,Q.jsxs)(`div`,{className:`ve-notes-error`,role:`alert`,children:[l,(0,Q.jsx)(`button`,{type:`button`,onClick:()=>void e.load().catch(()=>{}),children:`Reload notes`})]}),o&&c===`loading`&&(0,Q.jsx)(`span`,{className:`ve-notes-error`,role:`status`,children:`Loading notes…`})]})}var Qt=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M3.75 6.25v-1.5a1 1 0 0 1 1-1h1.5m11.5 0h1.5a1 1 0 0 1 1 1v1.5m0 11.5v1.5a1 1 0 0 1-1 1h-1.5m-11.5 0h-1.5a1 1 0 0 1-1-1v-1.5m0-4v-3.5m6.5-6.5h3.5m6.5 6.5v3.5m-6.5 6.5h-3.5`})})}),$t=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M12 14v3M7.75 9.75V7a4.25 4.25 0 0 1 8.435-.746M4.75 10.75a1 1 0 0 1 1-1h12.5a1 1 0 0 1 1 1v9.5a1 1 0 0 1-1 1H5.75a1 1 0 0 1-1-1z`})})}),en=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.5,d:`M16.25 9.75v-2.5a4.25 4.25 0 0 0-8.5 0v2.5M12 14v3m-7.25-6.25a1 1 0 0 1 1-1h12.5a1 1 0 0 1 1 1v9.5a1 1 0 0 1-1 1H5.75a1 1 0 0 1-1-1z`})})}),tn=new WeakMap;function nn(e){let t=tn.get(e);return t||(t=new u(!1),tn.set(e,t)),t}var rn=[{label:`21:9`,icon:`ratio-wide`,Icon:j,width:2520,height:1080},{label:`16:9`,icon:`ratio-wide`,Icon:j,width:1920,height:1080},{label:`9:16`,icon:`ratio-vertical`,Icon:me,width:1080,height:1920},{label:`1:1`,icon:`ratio-square`,Icon:H,width:1080,height:1080},{label:`3:4`,icon:`ratio-vertical`,Icon:me,width:1080,height:1440}];function an(e){return rn.find(t=>Math.abs(e.width/e.height-t.width/t.height)<.001)}function on(){let e=J(e=>e?.id),t=J(e=>e?.scenes.find(t=>t.id===e.activeSceneId)),[n,r]=(0,$.useState)(null),[i,a]=(0,$.useState)(!1),o=(0,$.useCallback)(e=>{e&&r(he(e))},[]);(0,$.useEffect)(()=>a(!1),[e,t?.id]);let s=t?an(t):void 0,c=s?.Icon??j,l=s?.label??`Custom`;return(0,Q.jsxs)(M.Root,{open:i,onOpenChange:a,modal:!1,children:[(0,Q.jsxs)(M.Trigger,{ref:o,className:`fv-aspect-ratio`,disabled:!t,"aria-label":`Aspect ratio: ${l}`,title:`Change aspect ratio`,children:[(0,Q.jsx)(c,{size:20,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:l})]}),n&&e&&t&&i&&(0,Q.jsx)(cn,{documentId:e,sceneId:t.id,container:n,onClose:()=>a(!1)})]})}function sn({x:e,y:t,documentId:n,sceneId:r,onClose:i}){let[a,o]=(0,$.useState)(null),s=(0,$.useCallback)(e=>{e&&o(he(e))},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{ref:s}),a&&(0,Nt.createPortal)((0,Q.jsxs)(M.Root,{open:!0,modal:!1,onOpenChange:e=>{e||i()},children:[(0,Q.jsx)(M.Trigger,{"aria-label":`Change aspect ratio`,className:`fui-context-anchor`,tabIndex:-1,style:{left:e,top:t}}),(0,Q.jsx)(cn,{documentId:n,sceneId:r,container:a,onClose:i,contextMenu:!0})]}),a)]})}function cn({documentId:e,sceneId:t,container:n,onClose:i,contextMenu:a=!1}){let s=Ge(),c=ke(o),l=J(n=>n?.id===e&&n.activeSceneId===t?n.scenes.find(e=>e.id===t):void 0),u=(0,$.useRef)(!1),d=(0,$.useRef)(!1);(0,$.useEffect)(()=>(d.current=!0,()=>{d.current=!1}),[]);let[f,p]=(0,$.useState)(!1),m=c?nn(c):null,h=W(m,!1);(0,$.useEffect)(()=>{l||i()},[l,i]);let _=async(n,i)=>{let a=c?.snapshot();if(u.current||a?.id!==e||a.activeSceneId!==t||![n,i].every(e=>Number.isFinite(e)&&e>=1&&e<=16384))return;let o=K(a,t,Math.round(n),Math.round(i));if(o){u.current=!0,p(!0);try{await s.commands.execute(`document.apply`,o);let n=c?.snapshot();n?.id===e&&n.activeSceneId===t&&await s.commands.execute(`fable.panel-viewport.zoomToFit`,{documentId:e,sceneId:t,scope:`scene`})}catch{r({variant:`error`,appearance:`editor`,message:`Could not change the aspect ratio. Please try again.`})}finally{u.current=!1,p(!1)}}},v=async()=>{if(!u.current){u.current=!0,p(!0);try{await s.commands.execute(`fable.ai-composer.adapt-to-timeline`,{projectId:e,sceneId:t}),d.current&&i()}catch(e){r({variant:`error`,appearance:`editor`,message:e instanceof Error?e.message:`Could not send the adaptation request. Please try again.`})}finally{u.current=!1,p(!1)}}};if(!l)return null;let y=an(l),b=h?en:$t;return(0,Q.jsxs)(I,{container:n,finalFocus:!a&&void 0,align:a?`start`:`end`,sideOffset:a?0:6,style:{width:`15.5rem`},"aria-label":`Aspect ratio`,children:[(0,Q.jsx)(M.Item,{title:`Adapt to timeline`,start:(0,Q.jsx)(Qt,{size:16,"aria-hidden":`true`}),disabled:f,closeOnClick:!1,onSelect:()=>void v()}),(0,Q.jsx)(pe,{container:n,items:rn.map(e=>({label:e.label,icon:e.icon,checked:e===y,disabled:f,onSelect:()=>void _(e.width,e.height)}))}),(0,Q.jsx)(M.Separator,{}),(0,Q.jsx)(M.Item,{title:`Custom`,end:y?void 0:(0,Q.jsx)(g,{size:16,className:`fui-menu-check`,"aria-label":`Selected`}),closeOnClick:!1,onSelect:()=>n.querySelector(`[aria-label="Canvas width"]`)?.focus()}),(0,Q.jsxs)(`div`,{className:`fui-aspect-dimensions`,children:[(0,Q.jsxs)(`label`,{children:[`W`,(0,Q.jsx)(L,{label:`Canvas width`,value:l.width,min:1,max:h?Math.min(16384,16384*l.width/l.height):16384,disabled:f,onCommit:e=>void _(e,h?Math.max(1,e*l.height/l.width):l.height)})]}),(0,Q.jsx)(`button`,{type:`button`,className:`fui-aspect-lock`,"aria-label":h?`Unlock aspect ratio`:`Lock aspect ratio`,"aria-pressed":h,title:h?`Unlock proportions`:`Lock proportions`,disabled:f,onClick:()=>m?.set(!h),children:(0,Q.jsx)(b,{size:16,"aria-hidden":`true`})}),(0,Q.jsxs)(`label`,{children:[`H`,(0,Q.jsx)(L,{label:`Canvas height`,value:l.height,min:1,max:h?Math.min(16384,16384*l.height/l.width):16384,disabled:f,onCommit:e=>void _(h?Math.max(1,e*l.width/l.height):l.width,e)})]})]})]})}function ln(e,t){return e.length===t.length&&e.every((e,n)=>e.id===t[n].id&&e.name===t[n].name)}function un(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 dn(e,t){if(!t)return[];let n=un(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 fn(){let e=Ge(),t=q(),n=ke(o),r=Me(`fable.panel-viewport.zoomToFit`),i=J(e=>e?dn(e,e.activeSceneId):[],ln),a=i=>{let a=n?.snapshot();if(!a||!t)return;let o=He(a,i);if(!o){r();return}e.commands.execute(`document.apply`,o).then(()=>r()).catch(t=>e.log.error(`Switch scene failed`,{error:String(t)}));let s=a.scenes.find(e=>e.id===i);t.setSelection({enteredGroupId:null}),s&&t.seek(Math.min(t.currentTime.get(),s.duration))};return i.length<=1?null:(0,Q.jsx)(`nav`,{className:`fv-design-title`,"aria-label":`Scene path`,children:i.map((e,t)=>{let n=t===i.length-1;return(0,Q.jsxs)(`span`,{className:`fv-crumb-item`,children:[t>0&&(0,Q.jsx)(`span`,{className:`fv-crumb-sep`,"aria-hidden":`true`,children:`/`}),n?(0,Q.jsx)(le,{as:`span`,variant:`label-sm-medium`,color:`primary`,className:`fv-crumb fv-crumb-current`,"aria-current":`page`,children:e.name}):(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,className:`fv-crumb`,onClick:()=>a(e.id),children:e.name})]},e.id)})})}var pn=e=>{let t=$.useId();return $.createElement(_n,{...e,instanceId:t})},mn=0,hn=typeof $.useId==`function`?void 0:class extends $.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++mn}`})}render(){return $.createElement(_n,{...this.props.iconProps,instanceId:this.state.instanceId})}},gn=$.forwardRef((e,t)=>hn?$.createElement(hn,{iconProps:{...e,svgRef:t}}):$.createElement(pn,{...e,svgRef:t}));gn.displayName=`CentralIconBase`;var _n=({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 $.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&&$.createElement(`title`,null,y),g?$.createElement($.Fragment,null,$.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},$.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),$.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),$.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},vn=$.memo($.forwardRef((e,t)=>$.createElement(gn,{...e,ref:t,ariaLabel:`color-palette, colours`,maskId:`round-outlined-radius-2-stroke-1.5-IconColorPalette`},$.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`}),$.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`}),$.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`}),$.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`})))),yn=e=>{let t=$.useId();return $.createElement(Cn,{...e,instanceId:t})},bn=0,xn=typeof $.useId==`function`?void 0:class extends $.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++bn}`})}render(){return $.createElement(Cn,{...this.props.iconProps,instanceId:this.state.instanceId})}},Sn=$.forwardRef((e,t)=>xn?$.createElement(xn,{iconProps:{...e,svgRef:t}}):$.createElement(yn,{...e,svgRef:t}));Sn.displayName=`CentralIconBase`;var Cn=({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 $.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&&$.createElement(`title`,null,y),g?$.createElement($.Fragment,null,$.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},$.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),$.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),$.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},wn=$.memo($.forwardRef((e,t)=>$.createElement(Sn,{...e,ref:t,ariaLabel:`text-edit, prompts, comment, draft`,maskId:`round-outlined-radius-2-stroke-1.5-IconTextEdit`},$.createElement(`path`,{d:`M1.75 5.75H9.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),$.createElement(`path`,{d:`M1.75 9.75H6.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),$.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`})))),Tn={clipIds:[],sceneId:null,enteredGroupId:null};function En(e,t){return e?.clip===t?.clip&&e?.scene===t?.scene}function Dn({toolbarRef:e,apply:t,execute:n,editSelectedText:r}){let i=q(),a=ke(o),s=W(i?.selection,Tn),c=J(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=C(t,s.clipIds[0])?.clip??null;return n?{clip:n,scene:t}:null},En),[l,u]=(0,$.useState)(!1),[d,f]=(0,$.useState)(!0),p=(0,$.useRef)(null);z(e,()=>u(!1),l);let m=(e,t,n=null)=>{let r=c;r&&h(r.clip.id,e,t,n)},h=(e,n,r,i=null)=>{let o=a?.snapshot();if(!o)return;let s=Re(o,e,n,r,i);s&&t(s)},g=c?.clip??null,_=c?.scene??null,v=g&&(g.kind===`rect`||g.kind===`text`)&&g.fill.type===`solid`?g.fill.color:null,y=(e,t)=>{g&&_&&m(`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`?_.width:_.height,s=t===`start`?i*a:t===`center`?o/2+i*(a-.5):o-i*(1-a);return{...n,transform:{...r,[e]:s}}})},b=(e,t)=>{if(!g)return;let n=Math.max(t,1);m(`Resize clip`,t=>{let r=t.size.width/Math.max(t.size.height,1),i=d?e===`width`?{width:n,height:n/r}:{width:n*r,height:n}:{...t.size,[e]:n};return{...t,size:i}})};return(0,Q.jsxs)(`div`,{ref:e,className:`fv-context-toolbar`,role:`toolbar`,"aria-label":`Selected object controls`,hidden:!0,onPointerDown:e=>e.stopPropagation(),children:[U.properties&&(0,Q.jsx)(qe,{"aria-label":`Edit selected object`,pressed:l,size:`sm`,title:`Edit properties`,onPressedChange:u,children:(0,Q.jsx)(de,{mode:`raw`,size:15})}),g?.kind===`text`&&(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Edit text`,title:`Edit text`,onClick:r,children:(0,Q.jsx)(wn,{mode:`raw`,size:15})}),U.properties&&v!==null&&(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Edit color`,title:`Edit color`,onClick:()=>u(!0),children:(0,Q.jsx)(vn,{mode:`raw`,size:15})}),(U.properties||g?.kind===`text`)&&(0,Q.jsx)(`span`,{className:`fv-context-divider`,"aria-hidden":`true`}),(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Duplicate selected object`,title:`Duplicate (⌘D)`,onClick:()=>n(`fable.transport.duplicate`),children:(0,Q.jsx)(fe,{mode:`raw`,size:15})}),(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Hide or show selected object`,title:`Hide / show (⇧⌘H)`,onClick:()=>n(`fable.transport.toggleHidden`),children:g?.hidden?(0,Q.jsx)(ve,{mode:`raw`,size:15}):(0,Q.jsx)(F,{mode:`raw`,size:15})}),(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Delete selected object`,title:`Delete (⌫)`,onClick:()=>n(`fable.transport.delete`),children:(0,Q.jsx)(N,{mode:`raw`,size:15})}),U.properties&&l&&g&&_&&(0,Q.jsxs)(`div`,{className:`fv-context-editor`,"data-theme":`default-dark`,role:`dialog`,"aria-label":`Edit selected object properties`,children:[(0,Q.jsxs)(`div`,{className:`fv-context-editor-title`,children:[(0,Q.jsx)(`span`,{className:`fv-context-editor-name`,title:g.name,children:g.name}),(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Reset transform`,title:`Reset transform`,onClick:()=>m(`Reset transform`,e=>({...e,transform:{...e.transform,x:_.width/2,y:_.height/2,scaleX:1,scaleY:1,rotation:0,skewX:0,skewY:0,anchorX:.5,anchorY:.5,flipX:!1,flipY:!1}})),children:(0,Q.jsx)(zt,{mode:`raw`,size:14})})]}),(0,Q.jsxs)(`label`,{className:`fv-context-editor-row fv-context-opacity`,children:[(0,Q.jsx)(`span`,{children:`Opacity`}),(0,Q.jsx)(R,{value:g.opacity*100,min:0,max:100,step:1,onGestureStart:()=>{p.current=`fv-context:opacity:${Fe()}`},onGestureEnd:()=>{p.current=null},onInput:e=>m(`Change opacity`,t=>({...t,opacity:e/100}),p.current)}),(0,Q.jsxs)(`output`,{className:`fv-context-value`,children:[Math.round(g.opacity*100),`%`]})]}),(0,Q.jsxs)(`div`,{className:`fv-context-editor-row`,children:[(0,Q.jsx)(`span`,{children:`Alignment`}),(0,Q.jsxs)(Ke,{size:`xxs`,variant:`ghost`,className:`fv-context-align`,"aria-label":`Horizontal alignment`,children:[(0,Q.jsx)(X,{iconOnly:!0,"aria-label":`Align left`,title:`Align left`,onClick:()=>y(`x`,`start`),children:(0,Q.jsx)(nt,{mode:`raw`,size:15})}),(0,Q.jsx)(X,{iconOnly:!0,"aria-label":`Align horizontal center`,title:`Align horizontal center`,onClick:()=>y(`x`,`center`),children:(0,Q.jsx)(yt,{mode:`raw`,size:15})}),(0,Q.jsx)(X,{iconOnly:!0,"aria-label":`Align right`,title:`Align right`,onClick:()=>y(`x`,`end`),children:(0,Q.jsx)(st,{mode:`raw`,size:15})})]}),(0,Q.jsxs)(Ke,{size:`xxs`,variant:`ghost`,className:`fv-context-align`,"aria-label":`Vertical alignment`,children:[(0,Q.jsx)(X,{iconOnly:!0,"aria-label":`Align top`,title:`Align top`,onClick:()=>y(`y`,`start`),children:(0,Q.jsx)(mt,{mode:`raw`,size:15})}),(0,Q.jsx)(X,{iconOnly:!0,"aria-label":`Align vertical center`,title:`Align vertical center`,onClick:()=>y(`y`,`center`),children:(0,Q.jsx)(ct,{mode:`raw`,size:15})}),(0,Q.jsx)(X,{iconOnly:!0,"aria-label":`Align bottom`,title:`Align bottom`,onClick:()=>y(`y`,`end`),children:(0,Q.jsx)(dt,{mode:`raw`,size:15})})]})]}),(0,Q.jsxs)(`div`,{className:`fv-context-editor-row`,children:[(0,Q.jsx)(`span`,{children:`Dimensions`}),(0,Q.jsxs)(`label`,{className:`fv-context-number`,children:[(0,Q.jsx)(`span`,{children:`W`}),(0,Q.jsx)(L,{value:g.size.width,min:1,onCommit:e=>b(`width`,e)})]}),(0,Q.jsx)(qe,{size:`sm`,className:d?`active`:void 0,"aria-label":`Lock aspect ratio`,pressed:d,title:`Lock aspect ratio`,onPressedChange:f,children:(0,Q.jsx)(_t,{mode:`raw`,size:14})}),(0,Q.jsxs)(`label`,{className:`fv-context-number`,children:[(0,Q.jsx)(`span`,{children:`H`}),(0,Q.jsx)(L,{value:g.size.height,min:1,onCommit:e=>b(`height`,e)})]})]}),(0,Q.jsxs)(`div`,{className:`fv-context-editor-row`,children:[(0,Q.jsx)(`span`,{children:`Rotation`}),(0,Q.jsx)(L,{className:`fv-context-rotation`,value:g.transform.rotation,step:1,onCommit:e=>m(`Rotate clip`,t=>({...t,transform:{...t.transform,rotation:e}}))}),(0,Q.jsx)(X,{variant:`ghost`,size:`xxs`,iconOnly:!0,"aria-label":`Reset rotation`,title:`Reset rotation`,onClick:()=>m(`Reset rotation`,e=>({...e,transform:{...e.transform,rotation:0}})),children:(0,Q.jsx)(zt,{mode:`raw`,size:14})})]}),v!==null&&(0,Q.jsxs)(`label`,{className:`fv-context-editor-row`,children:[(0,Q.jsx)(`span`,{children:`Color`}),(0,Q.jsx)(_e,{value:v,onCommit:e=>m(`Change color`,t=>t.kind!==`rect`&&t.kind!==`text`||t.fill.type!==`solid`?t:{...t,fill:{...t.fill,color:e}})})]})]})]})}var On=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{fill:`currentColor`,d:`M11.125 1.246a1.75 1.75 0 0 1 1.75 0L17 3.628a.75.75 0 0 1-.75 1.299l-3.5-2.02v8.671l7.75 4.717v-4.007a.75.75 0 0 1 1.5 0v4.764a1.75 1.75 0 0 1-.875 1.515L17 20.949a.75.75 0 1 1-.75-1.299l3.528-2.038L12 12.877l-7.78 4.734L7.75 19.65a.75.75 0 0 1-.75 1.3l-4.125-2.382A1.75 1.75 0 0 1 2 17.053v-4.764a.75.75 0 0 1 1.5 0v4.006l7.75-4.716V2.906l-3.5 2.02A.75.75 0 1 1 7 3.629z`})})}),kn=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{fill:`currentColor`,d:`M17.72 8.97a.75.75 0 1 1 1.06 1.06l-6.25 6.25a.75.75 0 0 1-1.06 0l-6.25-6.25a.75.75 0 1 1 1.06-1.06L12 14.69z`})})}),An=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M12 1a.75.75 0 0 1 .75.75V3h6.5c.966 0 1.75.784 1.75 1.75v14.5A1.75 1.75 0 0 1 19.25 21h-6.5v1.25a.75.75 0 0 1-1.5 0V21h-6.5A1.75 1.75 0 0 1 3 19.25V4.75C3 3.784 3.784 3 4.75 3h6.5V1.75A.75.75 0 0 1 12 1M8 8H4.5v4H8v4H4.5v3.25c0 .138.112.25.25.25H8V16h3.25v-4H8zh3.25V4.5H8z`,clipRule:`evenodd`})})}),jn=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`path`,{fill:`currentColor`,d:`M11 20a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5A.75.75 0 0 1 11 20M4.282 17.657a.751.751 0 0 1 1.06 1.06l-1.06 1.061a.75.75 0 0 1-1.06-1.06zM10.153 8.624a.75.75 0 0 1 1.3.752A5.2 5.2 0 0 0 10.75 12c0 1.075.322 2.072.875 2.903a.75.75 0 0 1-1.25.83A6.72 6.72 0 0 1 9.25 12c0-1.228.328-2.382.903-3.376`}),(0,Q.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M16 5.25a6.75 6.75 0 1 1-2.5 13.02 6.75 6.75 0 1 1 0-12.54 6.7 6.7 0 0 1 2.5-.48m-5 1.5a5.25 5.25 0 1 0 0 10.5 5.25 5.25 0 0 0 0-10.5`,clipRule:`evenodd`}),(0,Q.jsx)(`path`,{fill:`currentColor`,d:`M2.25 11.25a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1 0-1.5zM3.222 4.222a.75.75 0 0 1 1.06 0l1.06 1.06a.75.75 0 1 1-1.06 1.06l-1.06-1.06a.75.75 0 0 1 0-1.06M11 1a.75.75 0 0 1 .75.75v1.5a.75.75 0 0 1-1.5 0v-1.5A.75.75 0 0 1 11 1`})]})}),Mn=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsx)(`path`,{fill:`currentColor`,d:`M9.5 3.75a.25.25 0 0 1 .25-.25H11A.75.75 0 0 0 11 2H9.75A1.75 1.75 0 0 0 8 3.75V5a.75.75 0 0 0 1.5 0zM14 2a.75.75 0 0 0 0 1.5h2A.75.75 0 0 0 16 2zM19 2a.75.75 0 0 0 0 1.5h1.25a.25.25 0 0 1 .25.25V5A.75.75 0 0 0 22 5V3.75A1.75 1.75 0 0 0 20.25 2zM9.5 8A.75.75 0 0 0 8 8H3.25C2.56 8 2 8.56 2 9.25v11.5c0 .69.56 1.25 1.25 1.25h11.5c.69 0 1.25-.56 1.25-1.25V16a.75.75 0 0 0 0-1.5V9.25C16 8.56 15.44 8 14.75 8zM22 8a.75.75 0 0 0-1.5 0v2a.75.75 0 0 0 1.5 0zM22 13a.75.75 0 0 0-1.5 0v1.25a.25.25 0 0 1-.25.25H19a.75.75 0 0 0 0 1.5h1.25A1.75 1.75 0 0 0 22 14.25z`})})}),Nn=[{id:`upscale`,label:`Upscale`,Icon:Ct},{id:`extend`,label:`Extend`,Icon:Tt},{id:`reframe`,label:`Reframe`,Icon:On}],Pn=[{id:`fps-boost`,label:`FPS Boost`,Icon:Ot},{id:`remove-background`,label:`Remove BG`,Icon:An},{id:`sdr-to-hdr`,label:`SDR to HDR`,Icon:jn},{id:`depth-map`,label:`Depth Map`,Icon:Mn}],Fn={clipIds:[],sceneId:null,enteredGroupId:null};function In({toolbarRef:e,backdropRef:t}){let n=Ge(),r=q(),i=W(r?.selection,Fn),a=J(e=>{let t=e?.scenes.find(t=>t.id===e.activeSceneId);return!!(t&&i.clipIds.length&&i.clipIds.every(n=>{let r=C(t,n)?.clip;return r?.kind===`media`&&e?.assets.some(e=>e.id===r.assetId&&e.kind===`video`)}))}),o=J(e=>!!(e&&i.clipIds.length&&l(e,i.clipIds).length===i.clipIds.length)),[s,c]=(0,$.useState)(null),[u,d]=(0,$.useState)(!1),f=(0,$.useRef)(!1),p=JSON.stringify(i.clipIds);(0,$.useEffect)(()=>c(null),[p]);let m=i.clipIds.length>0&&i.clipIds.length<=20;(0,$.useLayoutEffect)(()=>{e.current&&i.clipIds.length&&(e.current.dataset.video=String(a))},[i.clipIds.length,a,e]);let h=async()=>{if(!f.current&&m){f.current=!0,d(!0);try{await n.commands.execute(`fable.transport.attachSelection`)}catch(e){_(e)}finally{f.current=!1,d(!1)}}},g=e=>{m&&a&&o&&n.commands.execute(`fable.ai-composer.${e}`).catch(_)};return(0,Q.jsx)(`div`,{ref:e,className:`fv-selection-toolbar`,"data-theme":`default-dark`,"data-visible":`false`,role:`toolbar`,"aria-label":`Selected object controls`,"aria-hidden":`true`,inert:!0,onPointerDown:e=>e.stopPropagation(),children:(0,Q.jsxs)(`div`,{className:`fv-selection-toolbar-surface`,children:[(0,Q.jsx)(`span`,{className:`fv-selection-toolbar-backdrop`,"aria-hidden":`true`,children:(0,Q.jsx)(`canvas`,{ref:t})}),(0,Q.jsxs)(`button`,{type:`button`,className:`fv-selection-action`,"aria-label":`Add to chat`,"aria-keyshortcuts":`A`,disabled:!m||u,"aria-busy":u,onClick:()=>void h(),children:[(0,Q.jsx)(Ye,{size:16,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:`Add to chat`}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,children:`A`})]}),(0,Q.jsx)(`span`,{className:`fv-selection-divider`,"aria-hidden":`true`}),Nn.map(({id:e,label:t,Icon:n})=>(0,Q.jsxs)(`button`,{type:`button`,className:`fv-selection-action fv-selection-video`,"aria-label":t,title:t,disabled:!m||!o,onClick:()=>g(e),children:[(0,Q.jsx)(n,{size:16,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:t})]},e)),(0,Q.jsx)(`span`,{className:`fv-selection-divider`,"aria-hidden":`true`}),(0,Q.jsxs)(M.Root,{modal:!1,open:m&&a&&s===p,onOpenChange:e=>c(e?p:null),children:[(0,Q.jsxs)(M.Trigger,{className:`fv-selection-action fv-selection-video`,"aria-label":`More tools`,disabled:!m||!o,children:[(0,Q.jsx)(`span`,{children:`More`}),(0,Q.jsx)(kn,{size:16,"aria-hidden":`true`})]}),(0,Q.jsx)(I,{container:he(e.current),align:`center`,sideOffset:6,className:`fv-selection-menu`,onPointerDown:e=>e.stopPropagation(),children:Pn.map(({id:e,label:t,Icon:n})=>(0,Q.jsx)(M.Item,{title:t,start:(0,Q.jsx)(n,{size:16,"aria-hidden":`true`}),onSelect:()=>g(e)},e))})]})]})})}var Ln=90,Rn=.5;function zn(e,t,n,r,i){if(!e||!t||!e.clientWidth||!n.offsetWidth)return;let a=n.offsetWidth+180,o=n.offsetHeight+180,s=Math.ceil(a*Rn),c=Math.ceil(o*Rn);t.width!==s&&(t.width=s),t.height!==c&&(t.height=c);let l=t.getContext(`2d`);if(!l)return;let u=e.width/e.clientWidth;l.clearRect(0,0,s,c),l.drawImage(e,(r-Ln)*u,(i-Ln)*u,a*u,o*u,0,0,s,c),n.dataset.backdrop=`true`}var Bn=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.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`})})}),Vn=({size:e=24,...t})=>(0,Q.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,...t,children:(0,Q.jsx)(Q.Fragment,{children:(0,Q.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`})})});function Hn(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 Un({duration:e}){let{notes:t}=We(),n=q(),r=W(t?.mode,null),i=W(t?.state,`loading`),a=!t||!n||e<=0||i!==`ready`,o=e=>{a||Y(t,n,r===e?null:e).catch(_)};return(0,Q.jsxs)(`div`,{className:`fv-fullscreen-annotations`,role:`group`,"aria-label":`Video annotations`,children:[(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button`,"aria-label":`Notes`,title:`Leave notes on video`,"aria-pressed":r===`note`,disabled:a,onClick:()=>o(`note`),children:(0,Q.jsx)(jt,{size:20})}),(0,Q.jsx)(wt,{notes:t,active:r===`draw`,children:(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button`,"aria-label":`Draw to edit`,title:`Show changes visually to your agent`,"aria-pressed":r===`draw`,disabled:a,onClick:()=>o(`draw`),children:(0,Q.jsx)(Et,{size:20})})})]})}function Wn({duration:e}){let t=q(),n=(0,$.useRef)(null);return(0,$.useEffect)(()=>{let r=n.current;if(!r||!t)return;let i=()=>{let n=Math.max(0,Math.min(t.currentTime.get(),e));r.value=String(n),r.style.setProperty(`--fv-progress`,`${e>0?n/e*100:0}%`),r.setAttribute(`aria-valuetext`,`${Hn(n)} of ${Hn(e)}`)};i();let a=t.currentTime.subscribe(i);return()=>a.dispose()},[e,t]),(0,Q.jsx)(`input`,{ref:n,className:`fv-fullscreen-seek`,type:`range`,"aria-label":`Video position`,min:0,max:e,step:.01,defaultValue:0,disabled:!t||e<=0,onPointerDown:()=>t?.pause(),onChange:e=>{t?.pause(),t?.seek(Number(e.currentTarget.value))}})}function Gn({rootRef:e}){let t=q(),{previewMuted:n}=We(),r=W(n,!1),i=W(t?.playing,!1),a=J(e=>oe(e)?.duration??0),o=Pe(),s=Me(`fable.session.togglePlayback`),c=Me(`fable.panel-viewport.zoomToFit`),[l,u]=(0,$.useState)(!1),[d,f]=(0,$.useState)(!1);(0,$.useEffect)(()=>{let t=e.current?.ownerDocument;if(!t)return;let n=()=>{u(t.fullscreenElement===e.current),c()};return t.addEventListener(`fullscreenchange`,n),()=>t.removeEventListener(`fullscreenchange`,n)},[e,c]);let p=(0,$.useCallback)(async()=>{let t=e.current;if(t){f(!1);try{t.ownerDocument.fullscreenElement===t?await t.ownerDocument.exitFullscreen():await t.requestFullscreen()}catch{f(!0)}}},[e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`fv-scene-controls`,"data-theme":`default-dark`,"data-fullscreen":l,children:[l&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Wn,{duration:a}),(0,Q.jsx)(Un,{duration:a})]}),(0,Q.jsxs)(`div`,{className:`fv-player-transport`,role:`group`,"aria-label":`Playback controls`,children:[(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button`,"aria-label":i?`Pause preview`:`Play preview`,disabled:a<=0,onClick:()=>void s(),children:i?(0,Q.jsx)(Vn,{size:16}):(0,Q.jsx)(Mt,{size:16})}),(0,Q.jsxs)(`div`,{className:`fv-player-timecode`,"aria-label":`Playback time`,children:[(0,Q.jsx)(B,{source:o,format:Hn,initial:Hn(o?.get()??0)}),(0,Q.jsxs)(`span`,{className:`fv-player-total`,children:[` / `,Hn(a)]})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button`,"aria-label":r?`Unmute preview`:`Mute preview`,"aria-pressed":r,disabled:!n,onClick:()=>{n?.set(!r),t?.playing.get()&&t.seek(t.currentTime.get())},children:r?(0,Q.jsx)(ge,{size:16}):(0,Q.jsx)(P,{size:16})})]}),(0,Q.jsx)(X,{variant:`ghost`,size:`sm`,iconOnly:!0,className:`fv-player-button fv-player-fullscreen`,"aria-label":l?`Exit full screen`:`Full screen`,onClick:()=>void p(),children:l?(0,Q.jsx)(Bn,{size:16}):(0,Q.jsx)(ue,{size:16})})]}),d&&(0,Q.jsx)(`p`,{className:`fv-player-error`,role:`status`,children:`Fullscreen is unavailable in this host.`})]})}function Kn(){return(0,Q.jsx)(`div`,{className:`fv-player-settings`,children:(0,Q.jsx)(on,{})})}var qn=.02,Jn=1.5;function Yn(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,qn),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 Xn(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=ae(r,t);if(!(e.hidden||e.kind===`audio`||d<0||d>e.timeRange.duration)){c=!0,rt(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 Zn=2,Qn=8294400;function $n(e,t){let{width:n,height:r}=e.bounds;return Math.min(Zn,Number.isFinite(t)&&t>0?t:1,4096/n,4096/r,Math.sqrt(Qn/n/r))}var er=250;function tr(e,t,n){let r=null,i=null,a=null,o=0,s=!1,c=null,l=0,u=!1,d=null,f=null;function p(e,t){f!==null&&clearTimeout(f),f=null,d=null,c=t,l=performance.now(),u=!0,e.seek(t)}function m(e,t){if(!(u&&c!==t&&performance.now()-l<er)){p(e,t);return}d=t,f??=setTimeout(()=>{f=null,d!==null&&i?.player===e&&p(e,d)},er)}function h(){let e=i;i=null,e?.player?.dispose(),a&&t.release(a.frame),a=null,o=0,c=null,u=!1,d=null,f!==null&&clearTimeout(f),f=null}return{presentation:()=>a,update(l,f,g,_,v){if(s)return;if(!v){h(),r=null;return}if(r?.document!==l||r.time!==f||r.playing!==_){(r?.document.id!==l.id||r.document.activeSceneId!==l.activeSceneId)&&h();let o=r?.playing??!1;r={document:l,time:f,playing:_};let s=Xn(l,f,i?.preview);if(!s){h();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!==c)return;t.retain(e),a&&t.release(a.frame),a={frame:e,scene:o.preview.scene,bounds:o.preview.bounds,time:s},n(),s===c&&(u=!1);let l=o.player;!r?.playing&&d!==null&&l&&p(l,d)},{sceneId:l.activeSceneId,loop:!1,followAudioClock:!0}),o.player.setDocument(s.document)}i.preview=s;let g=i.player;g&&(!_&&g.isPlaying()&&g.pause(),_?(!o||!g.isPlaying()||Math.abs(g.time()-f)>.15)&&p(g,f):m(g,f),_&&!g.isPlaying()&&g.play())}if(!i)return;let y=$n(i.preview,g);o!==y&&(o=y,i.player?.setScale(o))},reset(){h(),r=null},dispose(){s=!0,h(),r=null}}}var nr={request:e=>requestAnimationFrame(e),cancel:e=>cancelAnimationFrame(e)};function rr(e,t,n,r=nr){let i=new Map,a=null,o=null,s=null,c=!1,l=0,u=e;function d(){let e=s;s=null,e?.player?.dispose(),e&&e.entry.player===e.player&&delete e.entry.player}function f(){c||s||o!==null||![...i.values()].some(e=>e.dirty)||(o=r.request(p))}function p(){if(o=null,c||s)return;let r=[...i.values()].find(e=>e.dirty);if(!r)return;r.dirty=!1;let a=r.input;r.player?.dispose(),delete r.player;let l={entry:r,input:a,player:null};s=l,l.player=e.create((e,o)=>{if(!(s!==l&&r.player!==l.player||o!==a.time)){if(r.input===a&&i.get(a.scene.id)===r){t.retain(e),r.presentation&&t.release(r.presentation.frame),r.presentation={frame:e,scene:a.scene,time:o};let i=t.info(e);r.pendingMedia=i?.pendingMedia??[],r.pendingHtml=i?.pendingHtml??!1,r.htmlKeys=i?.htmlKeys??[],n()}s===l&&(u.onInvalidate?d():s=null,f())}},{sceneId:a.scene.id,scale:a.scale,loop:!1}),u.onInvalidate||(r.player=l.player),l.player.seek(a.time),l.player.setDocument(a.document)}function m(){d(),o!==null&&r.cancel(o),o=null;for(let e of i.values())e.player?.dispose(),e.presentation&&t.release(e.presentation.frame);i.clear()}let h=u.onInvalidate?.((e,t,n)=>{let r=new Set(n);for(let n of i.values())(e===`content`||(e===`html`?n.pendingHtml||n.htmlKeys.some(e=>r.has(e)):t?n.pendingMedia.includes(t):n.pendingMedia.length>0))&&(n.dirty=!0);f()});return{presentation:e=>i.get(e)?.presentation??null,update(e,n,r,o,u){if(c)return;a!==e.id&&(m(),a=e.id,l=n),u||(l=n);let p=e.scenes.filter(t=>t.id!==e.activeSceneId&&t.width>0&&t.height>0&&r.width>1&&r.height>1&&t.x<r.x+r.width&&t.y<r.y+r.height&&t.x+t.width>r.x&&t.y+t.height>r.y),h=Number.isFinite(o)&&o>0?o:1,g=p.map(e=>Math.min(1,h,4096/e.width,4096/e.height)),_=p.reduce((e,t,n)=>e+t.width*t.height*g[n]**2,0),v=Math.min(8294400,2*r.width*r.height*h**2),y=Math.min(1,Math.sqrt(Math.max(1,v)/Math.max(1,_))),b=new Set(p.map(e=>e.id));for(let[e,n]of i)b.has(e)||(s?.entry===n&&d(),n.player?.dispose(),n.presentation&&t.release(n.presentation.frame),i.delete(e));for(let t=0;t<p.length;t++){let n=p[t],r=g[t]*y,a=i.get(n.id);if(a&&a.input.document===e&&a.input.scene===n&&a.input.time===l&&a.input.scale===r)continue;let o={document:e,scene:n,time:l,scale:r};a?(a.input=o,a.dirty=!0):i.set(n.id,{input:o,dirty:!0,pendingMedia:[],pendingHtml:!1,htmlKeys:[]})}f()},reset:m,dispose(){c=!0,h?.dispose(),m()}}}var ir=`application/x-fable-asset`,ar=`application/x-fable-scene`;function or(e){return!!e?.some(e=>[ir,ar,At,`Files`].includes(e))}function sr(e){let t=e.getData(ir).split(`
2
+ `)[0];if(t)return{kind:`asset`,id:t};let n=e.getData(ar).split(`
3
+ `)[0];if(n)return{kind:`scene`,id:n};let r=Z(e.getData(At));if(r)return{kind:`generation`,payload:r};let i=Array.from(e.files);return i.length>0?{kind:`files`,files:i}:null}var cr=D(),lr=D();function ur(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=dr(a.clips,t,n,r,[]);if(o)return o}return null}function dr(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=w(o,s);if(o.kind===`group`){if(E(o.transform,c,cr),!k(cr,lr))continue;let e=O(lr,t,n),r=S(lr,t,n);i.push(o);let a=dr(o.children,e,r,s,i);if(i.pop(),a)return a;continue}let l=ce(o,c);if(c.width<=0||l<=0||(E(o.transform,c,cr),!k(cr,lr)))continue;let u=O(lr,t,n),d=S(lr,t,n);if(u>=0&&u<=c.width&&d>=0&&d<=l)return{clip:o,chain:[...i]}}return null}function fr(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 pr(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 mr(e){e.wrap=`soft`,e.style.whiteSpace=`pre-line`,e.style.overflowWrap=`normal`}var hr=5,gr=9;function _r(e,t){let n=t===`x`?e.minX:e.minY,r=t===`x`?e.maxX:e.maxY;return[n,(n+r)/2,r]}function vr(e,t){let n=t===`x`?e.minY:e.minX,r=t===`x`?e.maxY:e.maxX;return _r(e,t).map(e=>({value:e,from:n,to:r}))}function yr(e,t){let n=e=>t.flatMap(t=>vr(t,e)).sort((e,t)=>e.value-t.value);return{bounds:e,x:n(`x`),y:n(`y`),heldX:null,heldY:null}}function br(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 xr(e,t,n,r,i){if(r&&Math.abs(r.anchor.value-e[r.sourceIndex])*i<=gr)return r;let a=null,o=hr/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=br(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=_r(e.bounds,`x`).map(e=>e+t),s=_r(e.bounds,`y`).map(e=>e+n);e.heldX=xr(o,e.x,vr(r,`x`),e.heldX,i),e.heldY=xr(s,e.y,vr(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(ae(e,t),e.clip.timeRange.duration)),i=w(e.clip,r);if(i.width<=0||i.height<=0)return null;let a=ee(e,t,D()),o=[],s=[];for(let[e,t]of[[0,0],[i.width,0],[i.width,i.height],[0,i.height]])o.push(O(a,e,t)+n.x),s.push(S(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 wr(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 yr(a,c)}var Tr=7,Er={previewLetterbox:`#000000`,frameMarquee:`#9ca3af`},Dr=`capability:storage/local`;function Or(e,t,n){return e!==.5&&t!==.5?!n:n}function kr(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 Ar(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,p=t.getContext(`2d`),m=xt(t),g=St(t,u),_=!0,y=null,x=!1,E=!1,A=null,ce=null,le=[],ue=null,de=null,j=null,fe=null,M=null,N=null,P=null,F=null,pe=!1,me=[],I=new Float64Array(18),L=D(),R=()=>a.snapshot(),z=()=>oe(R()),he=R()?.id??null,ge=R()?.activeSceneId??null;function _e(){let t=V();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 B(){ce=null,le=[],ue=null}let V=()=>i.camera.get(),H=()=>i.selection.get().clipIds,ve=rr(s,o,u),be=tr(s,o,u);function xe(e){e&&o.release(e.frame)}function Se(){xe(F),F=null}function Ce(e,t,n){if(pe||e.disposed||P!==e)return;let r=e.document?.scenes.find(t=>t.id===e.sceneId);if(!r)return;o.retain(t);let i=F;F={frame:t,scene:r,time:n},xe(i),M?.(),fe&&(fe.style.opacity=``),u()}function we(e){e.disposed=!0,e.player?.dispose()}function U(e){if(N&&P?.sceneId===e&&F)return F;let t=be.presentation();return e===R()?.activeSceneId?t?.scene.id===e?t:null:ve.presentation(e)}function Ee(e,t){if(!_)return;let n=z();if(!n||e<2||t<2)return;let r=y?.sceneId===n.id?y.bounds:{minX:n.x,minY:n.y,maxX:n.x+n.width,maxY:n.y+n.height},a=Math.min(e/(r.maxX-r.minX),t/(r.maxY-r.minY),64);if(!(a>0))return;let o=e/2-(r.minX+r.maxX)/2*a,s=t/2-(r.minY+r.maxY)/2*a,c=V();if(c.zoom!==a||c.panX!==o||c.panY!==s){x=!0;try{i.setCamera({zoom:a,panX:o,panY:s})}finally{x=!1}}}function W(e){let t=z();if(e&&(R()?.id!==e.documentId||t?.id!==e.sceneId))return;let n=!e&&t&&it(t,i.currentTime.get());y=t&&n?{sceneId:t.id,bounds:n}:null,_=!0,u()}function ke(){let t=z(),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 Me=!1;function Pe(e,n){if(!p)return;Y();let r=R(),a=n.dpr;if(p.setTransform(1,0,0,1,0,0),p.clearRect(0,0,t.width,t.height),!r){d(null);return}be.update(r,i.currentTime.get(),V().zoom*a,i.playing.get(),!N&&!Me&&n.width>1&&n.height>1),Ee(n.width,n.height);let s=V();ve.update(r,i.currentTime.get(),{x:-s.panX/s.zoom,y:-s.panY/s.zoom,width:n.width/s.zoom,height:n.height/s.zoom},s.zoom*a,i.playing.get());let c=r.scenes.map(e=>U(e.id)?.scene??e),l=c.some((e,t)=>e!==r.scenes[t])?{...r,scenes:c}:r;p.setTransform(s.zoom*a,0,0,s.zoom*a,s.panX*a,s.panY*a);for(let e of l.scenes){let t=U(e.id),n=t?o.toNative(t.frame):null;if(n){let r=t?.bounds;r?(p.save(),p.beginPath(),p.rect(e.x,e.y,e.width,e.height),p.clip(),p.drawImage(n,r.x,r.y,r.width,r.height),p.restore()):p.drawImage(n,e.x,e.y,e.width,e.height)}else e.id!==r.activeSceneId&&(p.fillStyle=e.background.type===`solid`?e.background.color:m.scenePlaceholder,p.fillRect(e.x,e.y,e.width,e.height))}Me&&Ue(l),p.setTransform(a,0,0,a,0,0),(l.scenes.length>1||i.selection.get().sceneId)&&pt(p,l,s,i.selection.get().sceneId,m);let u=H(),f=U(r.activeSceneId),h=f?.scene??oe(l),g=f?.time??i.currentTime.get();if(le.length){p.save(),p.strokeStyle=m.accent,p.globalAlpha=.6,p.lineWidth=1,p.setLineDash([3,3]),p.beginPath();for(let e of le)if(e.axis===`x`){let t=e.value*s.zoom+s.panX;p.moveTo(t,e.from*s.zoom+s.panY),p.lineTo(t,e.to*s.zoom+s.panY)}else{let t=e.value*s.zoom+s.panY;p.moveTo(e.from*s.zoom+s.panX,t),p.lineTo(e.to*s.zoom+s.panX,t)}p.stroke(),p.restore()}h&&u.length>0?(gt(p,h,g,s,a,u,m),d(at(h,g,s,u))):d(null),(A?.kind===`draw-rect`||A?.kind===`draw-frame`)&&Ge(A,a),j&&We(r,s,a),p.setTransform(1,0,0,1,0,0)}let G=null,K=null,q=null;function J(){let e=G;!e||e.readyState<2||!e.videoWidth||(K??=f.document.createElement(`canvas`),(K.width!==e.videoWidth||K.height!==e.videoHeight)&&(K.width=e.videoWidth,K.height=e.videoHeight),K.getContext(`2d`)?.drawImage(e,0,0))}function Re(e){if(!e){if(!Me)return;Me=!1,q=null,u();return}if(!G){G=f.document.createElement(`video`),G.muted=!0,G.playsInline=!0,G.preload=`auto`;let e=()=>{J(),u(),q!==null&&G&&(G.currentTime=q,q=null)};G.addEventListener(`seeked`,e),G.addEventListener(`loadeddata`,e)}let t=G;t.src!==e.src&&(t.src=e.src,K=null),t.readyState>=1?t.seeking?q=e.time:t.currentTime=e.time:t.addEventListener(`loadedmetadata`,()=>void(t.currentTime=e.time),{once:!0}),Me=!0,u()}function Ue(e){let t=K,n=e.scenes.find(t=>t.id===e.activeSceneId);if(!p||!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;p.save(),p.beginPath(),p.rect(n.x,n.y,n.width,n.height),p.clip(),p.fillStyle=Er.previewLetterbox,p.fillRect(n.x,n.y,n.width,n.height),p.drawImage(t,n.x+(n.width-o)/2,n.y+(n.height-s)/2,o,s),p.restore()}function We(e,t,n){if(!p)return;let r=e.scenes.find(e=>e.id===j);r&&(p.setTransform(n,0,0,n,0,0),p.strokeStyle=m.accent,p.lineWidth=2,p.strokeRect(r.x*t.zoom+t.panX,r.y*t.zoom+t.panY,r.width*t.zoom,r.height*t.zoom))}function Ge(e,t){if(!p)return;let n=V();p.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;p.strokeStyle=e.kind===`draw-frame`?Er.frameMarquee:m.accent,p.lineWidth=1,p.setLineDash([4,4]),p.strokeRect(Math.min(r,a),Math.min(i,o),Math.abs(a-r),Math.abs(o-i)),p.setLineDash([]),p.setTransform(1,0,0,1,0,0)}function Y(){let e=i.activeTool.get();t.style.cursor=E||A?.kind===`pan`?`grab`:A?.kind===`resize`||A?.kind===`group-resize`?A.cursor:A?.kind===`rotate`||A?.kind===`group-rotate`?`grabbing`:e===`rect`||e===`text`||e===`frame`?`crosshair`:de??`default`}function X(e){let n=t.getBoundingClientRect();return{sx:e.clientX-n.left,sy:e.clientY-n.top}}function Ke(e,t){return(e-t.panX)/t.zoom}function qe(e,t){return(e-t.panY)/t.zoom}function Je(){let e=z();return e?{ox:e.x,oy:e.y}:{ox:0,oy:0}}function Ye(e,t,n){let r=R();if(!r)return;let i=Ne(r,e,t,n);i&&l(i)}function Xe(e){let t=[];for(let n of H()){let r=C(e,n);r&&t.push(r)}return t}function Ze(e,t){let n=I[16],r=I[17];if(Math.hypot(e-n,t-r)<=9)return 8;for(let n=0;n<ft.length;n++){let r=I[n*2],i=I[n*2+1];if(Math.abs(e-r)<=Tr&&Math.abs(t-i)<=Tr)return n}return null}function Qe(e,t){let n=z();if(!n)return null;let r=V(),a=i.currentTime.get(),o=H();if(o.length>1){let i=Xe(n).filter(e=>e.clip.kind!==`audio`),a=ot(i);if(!a)return null;let o=vt(i);if(!o)return null;ht(o,a,r,n.x,n.y,I);let s=Ze(e,t);return s===null?null:{kind:`multi`,index:s,bounds:o,locs:i,chain:a}}for(let i of o){let o=C(n,i);if(!o||o.clip.kind===`audio`||T(o))continue;rt(o,a,r,I,n.x,n.y);let s=Ze(e,t);if(s!==null)return{kind:`single`,loc:o,index:s}}return null}function $e(e){return e===8?`grab`:kr(e,I)}function tt(e,t){let n=R();if(!n||!p)return null;let r=V();for(let i=n.scenes.length-1;i>=0;i--){let a=n.scenes[i],o=ut(p,a,r,m);if(e>=o.x&&e<=o.x+o.w&&t>=o.y&&t<=o.y+o.h)return a}return null}function nt(e){let t=R(),n=te(t,e);if(!t||!n)return;let r=He(t,e);r&&(l(r),i.setSelection({enteredGroupId:null}),i.seek(Math.min(i.currentTime.get(),n.duration)))}function st(){let e=z();return e?Xe(e).filter(e=>!T(e)):[]}function ct(){return`fable.panel-viewport:gesture:${Fe()}`}function lt(e){let t=D();return re(e,L),k(L,t)?t:null}function dt(t,n,r,a){let o=n-t.wx,s=r-t.wy,c=z(),l=_e(),d=`${e.clientWidth}:${e.clientHeight}`;if(ue!==d&&B(),!ce&&c&&(ce=wr(c,t.origs,i.currentTime.get(),l),ue=d),ce){let e=Sr(ce,o,s,l,V().zoom,a);o=e.dx,s=e.dy,le=e.guides,u()}let f=D(),p=[];for(let e of t.origs){let t=o,n=s;if(e.chain.length>0){if(re(e.chain,L),!k(L,f))continue;t=ie(f,o,s),n=ne(f,o,s)}let r=e.clip.transform;p.push({clipId:e.clip.id,transform:{...r,x:r.x+t,y:r.y+n}})}Ye(p,t.origs.length>1?`Move clips`:`Move clip`,t.key)}function mt(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}Ye(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 _t(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);Ye(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 yt(e,t,n,r){let i=e.orig.clip,a=i.transform,o=O(e.inv,t,n),s=S(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=O(e.base,f,m),_=S(e.base,f,m),v=-a.anchorX*p,y=-a.anchorY*h;Ye([{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 bt(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),Ye([{clipId:e.orig.clip.id,transform:{...i,rotation:o}}],`Rotate clip`,e.key)}function Ct(e,t,n,r){let a=R(),o=z();if(!a||!o)return;let s=e-o.x,u=t-o.y,d=n-o.x,f=r-o.y,p=V().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=De(o,i.currentTime.get(),{x:g,y:_},{width:m,height:h}),y=Ve(a,o.id,v,`Add rectangle`,c);y&&(l(y),i.setSelection({clipIds:[v.id]}),i.setActiveTool(`move`))}function wt(e,t){let n=R(),r=z();if(!n||!r)return;let a=160;p&&(p.save(),p.font=`400 64px ${m.fontUi}`,a=Math.max(p.measureText(`Text`).width,10),p.restore());let o=Be(r,i.currentTime.get(),{x:e-r.x,y:t-r.y},a),s=Ve(n,r.id,o,`Add text`,c);s&&(l(s),i.setSelection({clipIds:[o.id]}),i.setActiveTool(`move`),Mt(o))}function Tt(e,t,n,r){let a=R();if(!a)return;let o=V().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=Le(a,{x:u,y:d,width:s,height:c});l(je(a,p)),i.setSelection({clipIds:[],sceneId:p.id,enteredGroupId:null}),i.seek(Math.min(i.currentTime.get(),p.duration)),i.setActiveTool(`move`)}function Et(e){let t=R();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=Ie(t,e);a&&(l(a),i.setSelection({clipIds:[],sceneId:null,enteredGroupId:null}))}function Z(){fe&&=(fe.remove(),null),M=null,N&&(N=null,P&&we(P),P=null,Se(),i.requestRender(),u())}function Dt(e,t){return e.map(e=>e.id===t?{...e,hidden:!0}:e.kind===`group`?{...e,children:Dt(e.children,t)}:e)}function Ot(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:Dt(e.clips,t)}))}:n)}}function At(e){let t=R();if(!t)return;N=e,Se();let n={sceneId:t.activeSceneId,document:t,player:null,disposed:!1};P=n;let r=Math.min(3,Math.max(1,V().zoom*(f.devicePixelRatio||1)));n.player=s.create((e,t)=>Ce(n,e,t),{sceneId:n.sceneId,loop:!1,scale:r}),n.player.setDocument(Ot(t,e)),n.player.seek(i.currentTime.get())}function jt(t,n,r){e.appendChild(t),fe=t,t.focus({preventScroll:!0}),t.select();let i=!1,a=()=>{if(i)return;i=!0;let e=t.value;Z(),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,Z()))})}function Mt(e){if(Z(),!z())return;i.pause();let t=f.document.createElement(`textarea`);t.value=e.text,mr(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=m.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=R(),r=F?.scene??z(),a=r?C(r,e.id):null;if(!t||!r||!a||a.clip.kind!==`text`){Z();return}let o=a.clip,s=V(),{x:c,y:l}=r,u=F?.time??i.currentTime.get(),d=D();ee(a,u,d);let f=Math.min(Math.max(ae(a,u),0),o.timeRange.duration),p=w(o,f),h=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(${h}, ${g}, ${_}, ${v}, ${y}, ${b})`,n.width=`${p.width}px`,n.height=`${p.height}px`,n.font=Mr(o),n.lineHeight=String(o.lineHeight),n.letterSpacing=`${o.letterSpacing}px`,n.textAlign=o.align,n.color=o.fill.type===`solid`?o.fill.color:m.white,n.webkitTextStroke=o.stroke.width>0?`${o.stroke.width}px ${o.stroke.color}`:``};r(),M=r,t.addEventListener(`input`,()=>{t.scrollLeft=0,t.scrollTop=0}),At(e.id),F&&(n.opacity=``),jt(t,!0,t=>{let n=R();if(n&&t!==e.text){let r=Ae(n,e.id,t);r&&l(r)}})}function Nt(){let e=z(),t=H();if(!e||t.length!==1)return!1;let n=C(e,t[0])?.clip;return!n||n.kind!==`text`?!1:(Mt(n),!0)}function Q(e){if(!p)return;Z();let t=ut(p,e,V(),m),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 ${m.fontUi}`,r.padding=`2px 4px`,r.background=m.inlineEditorBackground,r.color=m.text,r.border=`1px solid ${m.accent}`,r.borderRadius=`3px`,r.outline=`none`,r.zIndex=`20`,jt(n,!1,t=>{let n=t.trim(),r=R();if(r&&n.length>0&&n!==e.name){let t=Oe(r,e.id,n);t&&l(t)}})}function $(e){e.preventDefault();let t=z();if(!t)return;let{sx:a,sy:o}=X(e),s=V(),{ox:c,oy:l}=Je(),u=ur(t,Ke(a,s)-c,qe(o,s)-l,i.currentTime.get());if(!u){let i=R();n.showMenu(e.clientX,e.clientY,[...i&&n.showAspectMenu?[{label:`Change aspect ratio`,icon:`reframe`,onSelect:()=>n.showAspectMenu?.(e.clientX,e.clientY,i.id,t.id)}]:[],{label:`Export frame as image`,icon:`export`,shortcut:`⇧⌘E`,onSelect:()=>{r.commands.execute(`fable.transport.exportFramePng`).catch(e=>r.log.error(`Preview export failed`,String(e)))}}]);return}let d=fr(u,i.selection.get().enteredGroupId),f=H();f.includes(d.id)||(f=[d.id],i.setSelection({clipIds:f}));let p=e.clientX,m=e.clientY,h=[],g=kt({scenes:[t]},u.clip.id),_=et(R(),d.id);f.length>1&&h.push({label:`Add Auto Layout`,onSelect:()=>n.showAutoLayoutEditor(p,m,{selectionIds:f})}),_?.canOwnLayout?h.push({label:_.layout?`Edit Auto Layout…`:`Add Auto Layout`,disabled:_.locked,onSelect:()=>n.showAutoLayoutEditor(p,m,{clipId:d.id,enableOnOpen:_.layout===null})}):_?.canEditSizing&&h.push({label:`Edit layout sizing…`,disabled:_.locked,onSelect:()=>n.showAutoLayoutEditor(p,m,{clipId:d.id})}),g&&h.push({label:`Edit component props…`,disabled:g.locked,onSelect:()=>{i.setSelection({clipIds:[g.clip.id]}),n.showComponentEditor(p,m,g.clip.id)}}),d.kind===`text`&&h.push({label:`Edit text`,onSelect:()=>{i.setSelection({clipIds:[d.id]}),Mt(d)}}),d.kind===`group`&&!d.component&&h.push({label:`Enter group`,onSelect:()=>i.setSelection({enteredGroupId:d.id,clipIds:[]})});let v=R(),y=d.kind===`media`&&v?.assets.some(e=>e.id===d.assetId&&e.kind===`video`),b=e=>{r.commands.execute(e).catch(e=>r.log.error(`Preview action failed`,String(e)))};n.showMenu(p,m,[...y?[{label:`Edit with prompt…`,icon:`edit`,shortcut:`⌘J`,disabled:d.locked||u.chain.some(e=>e.locked)||!!_?.locked,onSelect:()=>b(`fable.ai-composer.edit`)}]:[],{label:`Select object`,icon:`show`,onSelect:()=>{i.setActiveTool(`move`),i.setSelection({clipIds:[d.id]})}},...y?[{label:`Draw on video`,icon:`rename`,disabled:d.locked||u.chain.some(e=>e.locked)||!!_?.locked,onSelect:()=>b(`fable.ai-composer.edit-draw`)}]:[],...h.length?[{label:`More`,children:h}]:[],...v&&n.showAspectMenu?[{label:`Change aspect ratio`,icon:`reframe`,separatorBefore:!0,onSelect:()=>n.showAspectMenu?.(p,m,v.id,t.id)}]:[],{label:`Export frame as image`,icon:`export`,shortcut:`⇧⌘E`,onSelect:()=>b(`fable.transport.exportFramePng`)}])}function Pt(e){try{t.setPointerCapture(e.pointerId)}catch{}}function Ft(e){B();let{sx:t,sy:n}=X(e),r=V();if(e.button===1||e.button===0&&E){e.preventDefault(),Pt(e),A={kind:`pan`,sx:t,sy:n,cam:r},Y();return}if(e.button!==0)return;Pt(e);let a=Ke(t,r),o=qe(n,r),s=i.activeTool.get();if(s===`rect`){A={kind:`draw-rect`,x0:a,y0:o,x1:a,y1:o},u();return}if(s===`frame`){A={kind:`draw-frame`,x0:a,y0:o,x1:a,y1:o},u();return}if(s===`text`){wt(a,o);return}let c=z(),{ox:l,oy:d}=Je(),f=a-l,p=o-d,m=Qe(t,n);if(m){if(m.kind===`multi`){let e=m.locs.filter(e=>!T(e));if(e.length===0)return;let t=lt(m.chain);if(!t)return;let n=O(t,f,p),r=S(t,f,p);if(m.index===8){let i=(m.bounds.minX+m.bounds.maxX)/2,a=(m.bounds.minY+m.bounds.maxY)/2;A={kind:`group-rotate`,origs:e,cx:i,cy:a,startAngle:Math.atan2(r-a,n-i),parentInv:t,key:ct()}}else{let n=ft[m.index];A={kind:`group-resize`,origs:e,b:m.bounds,hx:n[0],hy:n[1],parentInv:t,cursor:kr(m.index,I),key:ct()}}Y();return}let e=m.loc,t=lt(e.chain);if(!t)return;let n=O(t,f,p),r=S(t,f,p);if(m.index===8){let i=e.clip.transform;A={kind:`rotate`,orig:e,parentInv:t,startAngle:Math.atan2(r-i.y,n-i.x),key:ct()}}else{let n=ft[m.index],r=D(),i=D();if(se(e.clip.transform,e.clip.size.width,e.clip.size.height,r),!k(r,i))return;A={kind:`resize`,orig:e,hx:n[0],hy:n[1],base:r,inv:i,parentInv:t,cursor:kr(m.index,I),key:ct()}}Y();return}let h=c?ur(c,f,p,i.currentTime.get()):null;if(h&&c){let t=fr(h,i.selection.get().enteredGroupId);if(e.shiftKey){let e=H();i.setSelection({clipIds:e.includes(t.id)?e.filter(e=>e!==t.id):[...e,t.id]});return}!H().includes(t.id)&&!H().includes(h.clip.id)&&i.setSelection({clipIds:[t.id]});let n=st();n.length>0&&(A={kind:`move`,origs:n,wx:a,wy:o,key:ct()});return}let g=tt(t,n);if(g){nt(g.id),i.setSelection({clipIds:[],sceneId:g.id,enteredGroupId:null});return}let _=R(),v=_?pr(_,a,o):null;if(v&&c&&v.id!==c.id){nt(v.id),i.setSelection({clipIds:[],sceneId:null,enteredGroupId:null});return}e.shiftKey||i.clearSelection()}function It(e){let{sx:t,sy:n}=X(e);if(!A){let e=i.activeTool.get()===`move`?Qe(t,n):null;de=e?$e(e.index):null,Y();return}if(A.kind===`pan`){i.setCamera({zoom:A.cam.zoom,panX:A.cam.panX+t-A.sx,panY:A.cam.panY+n-A.sy});return}let r=V(),a=Ke(t,r),o=qe(n,r),{ox:s,oy:c}=Je(),l=a-s,d=o-c;switch(A.kind){case`draw-rect`:case`draw-frame`:A.x1=a,A.y1=o,u();break;case`move`:dt(A,a,o,e.altKey);break;case`resize`:yt(A,O(A.parentInv,l,d),S(A.parentInv,l,d),Or(A.hx,A.hy,e.shiftKey));break;case`rotate`:bt(A,O(A.parentInv,l,d),S(A.parentInv,l,d),e.shiftKey);break;case`group-resize`:mt(A,O(A.parentInv,l,d),S(A.parentInv,l,d),Or(A.hx,A.hy,e.shiftKey));break;case`group-rotate`:_t(A,O(A.parentInv,l,d),S(A.parentInv,l,d),e.shiftKey)}}function Lt(e){if(!A)return;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId);let n=A;A=null,B(),de=null,n.kind===`draw-rect`?Ct(n.x0,n.y0,n.x1,n.y1):n.kind===`draw-frame`&&Tt(n.x0,n.y0,n.x1,n.y1),Y(),u()}function Rt(){A||(de=null,Y())}function zt(e,t){let n=V(),{sx:r,sy:i}=X(e);return pr(t,Ke(r,n),qe(i,n))??oe(t)}function Bt(e){let t=e.dataTransfer;if(!t||!or(t.types))return;let n=R();if(!n)return;e.preventDefault(),t.dropEffect=`copy`;let r=zt(e,n)?.id??null;r!==j&&(j=r,u())}function Vt(){j&&(j=null,u())}async function Ht(e,t){try{let n=await r.require(Dr);for(let a of e){let e;try{e=await n.importFile(a)}catch(e){v(r,a.name,e);continue}if(pe)return;let o=R();if(!o)return;let s=ze(o,e,t.sceneId,t.at,t.center,c);if(!s)continue;await r.commands.execute(`document.apply`,s.envelope);let l=R();!pe&&l?.id===o.id&&l.activeSceneId===o.activeSceneId&&(i.setSelection({clipIds:[s.clipId],sceneId:null,enteredGroupId:null}),await h(r,o,[e],t.sceneId))}}catch(e){r.log.warn(`viewport: file drop failed`,String(e))}}async function Ut(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 Ht([await r.fetchResultFile(a)],i)}catch(t){r.log.warn(`viewport: generation import failed for "${e}"`,String(t))}}function Wt(e){if(j=null,u(),!e.dataTransfer)return;let t=sr(e.dataTransfer);if(!t)return;let n=R();if(!n)return;e.preventDefault();let a=zt(e,n);if(!a)return;let o=V(),{sx:s,sy:l}=X(e),d=Ke(s,o),f=qe(l,o),p=pr(n,d,f)===null?null:{x:d-a.x,y:f-a.y},m=i.currentTime.get();if(t.kind===`files`){Ht(t.files,{sceneId:a.id,at:m,center:p});return}if(t.kind===`generation`){Ut(t.payload.jobId,t.payload.kind,{sceneId:a.id,at:m,center:p});return}let g=t.kind===`asset`?Te(n,t.id,a.id,m,p,c):ye(n,t.id,a.id,m,p,c);g&&r.commands.execute(`document.apply`,g.envelope).then(()=>{let e=R();if(pe||e?.id!==n.id||e.activeSceneId!==n.activeSceneId)return;i.setSelection({clipIds:[g.clipId],sceneId:null,enteredGroupId:null});let o=t.kind===`asset`&&n.assets.find(e=>e.id===t.id);if(o)return h(r,n,[o],a.id)}).catch(e=>r.log.warn(`viewport: media drop failed`,String(e)))}function Gt(e){let{sx:t,sy:n}=X(e),r=V(),a=tt(t,n);if(a){Q(a);return}let o=z(),{ox:s,oy:c}=Je(),l=o?ur(o,Ke(t,r)-s,qe(n,r)-c,i.currentTime.get()):null;if(!l||!o)return;let u=i.selection.get().enteredGroupId,d=fr(l,u);if(d.kind===`group`){let e=fr(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]}),Mt(l.clip))}function Kt(e){e.preventDefault();let{sx:t,sy:n}=X(e);i.setCamera(Yn(V(),{sx:t,sy:n,deltaX:e.deltaX,deltaY:e.deltaY,deltaMode:e.deltaMode,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey}))}function qt(e){if(!b(e.target)){if(e.code===`Space`){E=!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`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(),Et(t.sceneId));return}case`Escape`:if(i.selection.get().enteredGroupId){i.setSelection({enteredGroupId:null});break}i.clearSelection();break;default:return}Y(),u()}}}function Jt(e){e.code===`Space`&&(E=!1,Y())}function Yt(e){let t=z();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`?(wt(r,a),!0):(A={kind:n===`rect`?`draw-rect`:`draw-frame`,x0:r,y0:a,x1:r,y1:a},u(),!0);case`move`:return A?.kind===`draw-rect`||A?.kind===`draw-frame`?(A.x1=r,A.y1=a,u(),!0):!1;case`up`:case`cancel`:if(A?.kind===`draw-rect`||A?.kind===`draw-frame`){let t=A;return A=null,e.type===`up`&&(t.kind===`draw-rect`?Ct(t.x0,t.y0,t.x1,t.y1):Tt(t.x0,t.y0,t.x1,t.y1)),u(),!0}return!1}}return me.push(i.camera.subscribe(()=>{B(),de=null,M?.(),!x&&(_=!1,u())}),i.selection.subscribe(()=>{de=null,u()}),i.activeTool.subscribe(()=>{Y(),u()}),i.playing.subscribe(u),i.currentTime.subscribe(()=>{B(),N&&(P?.player?.seek(i.currentTime.get()),M?.()),u()}),i.activeSceneId.subscribe(()=>{let e=R();e&&e.activeSceneId!==ge&&(ge=e.activeSceneId,y=null,A=null,B(),N&&Z(),u())}),a.onEvent(e=>{if(e.type===`closed`){queueMicrotask(()=>{pe||R()||(he=null,ge=null,y=null,A=null,B(),be.reset(),Z(),ve.reset(),u())});return}if(e.type!==`changed`&&e.type!==`opened`)return;e.type===`opened`&&(A=null,B(),Z(),e.document.id!==he&&(y=null,be.reset(),_=!0,ve.reset()),he=e.document.id);let t=e.type===`opened`?e.document:R();N&&t&&P&&(P.document=t,P.player?.setDocument(Ot(t,N)),M?.()),u()})),t.addEventListener(`pointerdown`,Ft),t.addEventListener(`pointermove`,It),t.addEventListener(`pointerleave`,Rt),t.addEventListener(`pointerup`,Lt),t.addEventListener(`pointercancel`,Lt),t.addEventListener(`dblclick`,Gt),t.addEventListener(`wheel`,Kt,{passive:!1}),t.addEventListener(`contextmenu`,$),t.addEventListener(`dragover`,Bt),t.addEventListener(`dragleave`,Vt),t.addEventListener(`drop`,Wt),f.addEventListener(`keydown`,qt),f.addEventListener(`keyup`,Jt),f.document.fonts?.addEventListener(`loadingdone`,u),i.requestRender(),u(),{draw:Pe,toolPointer:Yt,zoomToFit:W,zoomToActual:ke,scrubPreview:Re,editSelectedText:Nt,dispose(){g(),pe=!0,Z(),Se(),G?.removeAttribute(`src`),G=null,K=null;for(let e of me)e.dispose();ve.dispose(),be.dispose(),t.removeEventListener(`pointerdown`,Ft),t.removeEventListener(`pointermove`,It),t.removeEventListener(`pointerleave`,Rt),t.removeEventListener(`pointerup`,Lt),t.removeEventListener(`pointercancel`,Lt),t.removeEventListener(`dblclick`,Gt),t.removeEventListener(`wheel`,Kt),t.removeEventListener(`contextmenu`,$),t.removeEventListener(`dragover`,Bt),t.removeEventListener(`dragleave`,Vt),t.removeEventListener(`drop`,Wt),f.removeEventListener(`keydown`,qt),f.removeEventListener(`keyup`,Jt),f.document.fonts?.removeEventListener(`loadingdone`,u)}}}var jr=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 Mr(e){let t=e.fontFamily,n=t.includes(` `)&&!t.includes(`,`)&&!t.includes(`"`)?`"${t}"`:t,r=jr.get(t),i=r&&r!==t?`${n}, ${r}`:n;return`${e.italic?`italic `:``}${e.fontWeight} ${e.fontSize}px ${i}`}var Nr=`api/media/stream`,Pr=`This project is still using an older editor backend. Finish its running work, stop that higgsedit dev process, and reopen the project with the updated plugin before importing media.`;async function Fr(e){if(typeof createImageBitmap==`function`){let t=await createImageBitmap(e);try{return{duration:null,height:t.height,width:t.width}}finally{t.close()}}if(typeof document>`u`)throw Error(`Image metadata probing is unavailable.`);let t=URL.createObjectURL(e);try{let e=new Image;return await new Promise((n,r)=>{e.onload=()=>n(),e.onerror=()=>r(Error(`Image metadata could not be read.`)),e.src=t}),{duration:null,height:e.naturalHeight,width:e.naturalWidth}}finally{URL.revokeObjectURL(t)}}async function Ir(e,t){let n=new $e({formats:Qe,source:e instanceof Blob?new Ze(e):new Xe(e)});try{let[e,r]=await Promise.all([n.getPrimaryVideoTrack(),n.getPrimaryAudioTrack()]);if(t===`video`&&!e)throw Error(`The imported file has no video track.`);if(t===`audio`&&!r)throw Error(`The imported file has no audio track.`);let i=await n.getDurationFromMetadata(void 0,{skipLiveWait:!0})??await n.computeDuration(void 0,{skipLiveWait:!0});if(t===`audio`)return{duration:i,height:null,width:null};let[a,o]=await Promise.all([e.getDisplayWidth(),e.getDisplayHeight()]);return{duration:i,height:o,width:a}}finally{n.dispose()}}function Lr(e){return e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Uint8Array.from(e)}async function Rr(e,t){let n=e instanceof Blob?e:new Blob([Lr(new Uint8Array(await e.arrayBuffer()))],{type:e.type});return t===`font`||t===`component`?{duration:null,height:null,width:null}:t===`image`?Fr(n):Ir(n,t)}var zr=m({src:f().regex(/^\.\/media\/(?:import-[a-zA-Z0-9]{6}\/)?[^./\\\0][^/\\\0]*$/),byteSize:d().int().nonnegative()}),Br=[[`image`,/^image\//,/\.(png|jpe?g|webp|gif|avif|svg|bmp)$/i],[`audio`,/^audio\//,/\.(mp3|wav|ogg|oga|m4a|aac|flac)$/i]];async function Vr(e,t,n){n.throwIfAborted();let r=`getFile`in t?await t.getFile():t,i=r instanceof Blob?r:new Blob([await r.arrayBuffer()]),a=Br.find(([,e,t])=>e.test(r.type)||t.test(r.name))?.[0]??`video`,o=new URL(Nr,`${e}/`);o.searchParams.set(`name`,r.name);let s=new AbortController;try{n.throwIfAborted();let[t,c]=await Promise.all([fetch(o,{method:`POST`,body:i,signal:AbortSignal.any([n,s.signal])}).then(async e=>{if(e.status===404)throw await e.body?.cancel(),Error(Pr);if(!e.ok)throw Error(`Could not import ${r.name}: ${e.status} ${await e.text()}`);return zr.parse(await e.json())}),Rr(i,a)]);n.throwIfAborted();let l=t.src.slice(2),u=l.split(`/`).at(-1);return{id:t.src,name:u,kind:a,mimeType:r.type||`application/octet-stream`,byteSize:t.byteSize,...c,uri:new URL(`project/${l.split(`/`).map(encodeURIComponent).join(`/`)}`,`${e}/`).href,hash:`${t.src}:${t.byteSize}`}}finally{s.abort()}}var Hr=`data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='23.1111'%20height='23.1111'%20viewBox='0%200%2023.1111%2023.1111'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Frame'%3e%3cg%20id='Vector'%3e%3cpath%20d='M8.18518%203.61111C8.18518%203.21224%207.86183%202.88889%207.46296%202.88889C7.06409%202.88889%206.74074%203.21224%206.74074%203.61111V19.5C6.74074%2019.8989%207.06409%2020.2222%207.46296%2020.2222C7.86183%2020.2222%208.18518%2019.8989%208.18518%2019.5V3.61111Z'%20fill='url(%23paint0_linear_0_3026)'/%3e%3cpath%20d='M16.3704%205.53704C16.3704%205.13817%2016.047%204.81481%2015.6481%204.81481C15.2493%204.81481%2014.9259%205.13817%2014.9259%205.53704V17.5741C14.9259%2017.9729%2015.2493%2018.2963%2015.6481%2018.2963C16.047%2018.2963%2016.3704%2017.9729%2016.3704%2017.5741V5.53704Z'%20fill='url(%23paint1_linear_0_3026)'/%3e%3cpath%20d='M12.2778%207.46296C12.2778%207.06409%2011.9544%206.74074%2011.5556%206.74074C11.1567%206.74074%2010.8333%207.06409%2010.8333%207.46296V15.6481C10.8333%2016.047%2011.1567%2016.3704%2011.5556%2016.3704C11.9544%2016.3704%2012.2778%2016.047%2012.2778%2015.6481V7.46296Z'%20fill='url(%23paint2_linear_0_3026)'/%3e%3cpath%20d='M4.33333%209.38889C4.33333%208.99002%204.00998%208.66667%203.61111%208.66667C3.21224%208.66667%202.88889%208.99002%202.88889%209.38889V13.7222C2.88889%2014.1211%203.21224%2014.4444%203.61111%2014.4444C4.00998%2014.4444%204.33333%2014.1211%204.33333%2013.7222V9.38889Z'%20fill='url(%23paint3_linear_0_3026)'/%3e%3cpath%20d='M20.2222%209.38889C20.2222%208.99002%2019.8989%208.66667%2019.5%208.66667C19.1011%208.66667%2018.7778%208.99002%2018.7778%209.38889V13.7222C18.7778%2014.1211%2019.1011%2014.4444%2019.5%2014.4444C19.8989%2014.4444%2020.2222%2014.1211%2020.2222%2013.7222V9.38889Z'%20fill='url(%23paint4_linear_0_3026)'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_0_3026'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_0_3026'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint2_linear_0_3026'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint3_linear_0_3026'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint4_linear_0_3026'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,Ur=`data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='23.1111'%20height='23.1111'%20viewBox='0%200%2023.1111%2023.1111'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Frame'%3e%3cg%20id='Vector'%3e%3cpath%20d='M13.963%206.74074C12.6334%206.74074%2011.5556%207.81857%2011.5556%209.14815C11.5556%2010.4777%2012.6334%2011.5556%2013.963%2011.5556C15.2925%2011.5556%2016.3704%2010.4777%2016.3704%209.14815C16.3704%207.81857%2015.2925%206.74074%2013.963%206.74074Z'%20fill='url(%23paint0_linear_0_3082)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M4.57407%202.88889C3.64337%202.88889%202.88889%203.64337%202.88889%204.57407V18.537C2.88889%2018.6534%202.90068%2018.767%202.92312%2018.8767C3.08026%2019.6445%203.75971%2020.2222%204.57407%2020.2222H18.537C19.4677%2020.2222%2020.2222%2019.4677%2020.2222%2018.537V4.57407C20.2222%203.64337%2019.4677%202.88889%2018.537%202.88889H4.57407ZM15.9473%2018.7778H18.537C18.67%2018.7778%2018.7778%2018.67%2018.7778%2018.537V4.57407C18.7778%204.44112%2018.67%204.33333%2018.537%204.33333H4.57407C4.44112%204.33333%204.33333%204.44112%204.33333%204.57407V13.9045L6.51209%2011.7258C7.1702%2011.0677%208.2372%2011.0677%208.89531%2011.7258L15.9473%2018.7778Z'%20fill='url(%23paint1_linear_0_3082)'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_0_3082'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_0_3082'%20x1='11.5556'%20y1='2.88889'%20x2='11.5556'%20y2='20.2222'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,Wr=`data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='23.1111'%20height='23.1111'%20viewBox='0%200%2023.1111%2023.1111'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Frame'%3e%3cg%20id='Vector'%3e%3cpath%20d='M15.1667%204.33333C16.0974%204.33333%2016.8519%205.08781%2016.8519%206.01852V17.0926C16.8519%2018.0233%2016.0974%2018.7778%2015.1667%2018.7778H3.61111C2.68041%2018.7778%201.92593%2018.0233%201.92593%2017.0926V6.01852C1.92593%205.08781%202.68041%204.33333%203.61111%204.33333H15.1667Z'%20fill='url(%23paint0_linear_0_3052)'/%3e%3cpath%20d='M19.6862%206.94762C20.6348%206.56854%2021.6665%207.26707%2021.6667%208.28862V14.8225C21.6665%2015.844%2020.6348%2016.5425%2019.6862%2016.1635L17.8148%2015.4149V7.69618L19.6862%206.94762Z'%20fill='url(%23paint1_linear_0_3052)'/%3e%3c/g%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='paint0_linear_0_3052'%20x1='11.7963'%20y1='4.33333'%20x2='11.7963'%20y2='18.7778'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3clinearGradient%20id='paint1_linear_0_3052'%20x1='11.7963'%20y1='4.33333'%20x2='11.7963'%20y2='18.7778'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='white'/%3e%3cstop%20offset='1'%20stop-color='%23EDEDED'%20stop-opacity='0.3'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e`,Gr=`data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Frame'%3e%3cpath%20id='Vector'%20d='M11.5%206.00001L13.5626%205.08331C14.0034%204.88738%2014.5%205.21008%2014.5%205.69252V10.3075C14.5%2010.7899%2014.0034%2011.1127%2013.5626%2010.9167L11.5%2010M1.83333%204.16667C1.83333%203.79848%202.13181%203.5%202.5%203.5H10.8333C11.2015%203.5%2011.5%203.79848%2011.5%204.16667V11.8333C11.5%2012.2015%2011.2015%2012.5%2010.8333%2012.5H2.5C2.13181%2012.5%201.83333%2012.2015%201.83333%2011.8333V4.16667Z'%20stroke='%23828282'%20stroke-width='1.05141'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3c/g%3e%3c/svg%3e`,Kr=`data:image/svg+xml,%3csvg%20preserveAspectRatio='none'%20overflow='visible'%20style='display:%20block;'%20width='16'%20height='16'%20viewBox='0%200%2016%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Frame'%3e%3cpath%20id='Vector'%20d='M2.5%2010.6668L5.09785%208.2218C5.22904%208.09833%205.43461%208.1014%205.562%208.2288L8%2010.6668L9.0976%209.5692C9.2278%209.439%209.43887%209.439%209.56907%209.5692L13%2013.0001'%20stroke='%23828282'%20stroke-width='1.05141'%20stroke-linecap='round'/%3e%3cpath%20id='Vector_2'%20d='M7.83333%202.5H3.16667C2.79848%202.5%202.5%202.79848%202.5%203.16667V12.8333C2.5%2013.2015%202.79848%2013.5%203.16667%2013.5H12.8333C13.2015%2013.5%2013.5%2013.2015%2013.5%2012.8333V8.16667'%20stroke='%23828282'%20stroke-width='1.05141'%20stroke-linecap='round'%20stroke-linejoin='round'/%3e%3cpath%20id='Vector_3'%20d='M12.827%202.79012L12.3624%201.58223C12.3047%201.43228%2012.1607%201.33333%2012%201.33333C11.8393%201.33333%2011.6953%201.43228%2011.6376%201.58223L11.173%202.79012C11.1053%202.96618%2010.9662%203.10531%2010.7901%203.17303L9.5822%203.63761C9.43227%203.69528%209.33333%203.83934%209.33333%204C9.33333%204.16066%209.43227%204.30472%209.5822%204.36239L10.7901%204.82697C10.9662%204.89469%2011.1053%205.03382%2011.173%205.20988L11.6376%206.41777C11.6953%206.56772%2011.8393%206.66667%2012%206.66667C12.1607%206.66667%2012.3047%206.56772%2012.3624%206.41777L12.827%205.20988C12.8947%205.03382%2013.0338%204.89469%2013.2099%204.82697L14.4178%204.36239C14.5677%204.30472%2014.6667%204.16066%2014.6667%204C14.6667%203.83934%2014.5677%203.69528%2014.4178%203.63761L13.2099%203.17303C13.0338%203.10531%2012.8947%202.96618%2012.827%202.79012Z'%20fill='%23828282'/%3e%3c/g%3e%3c/svg%3e`;function qr({projectId:e}){let t=Ge(),{chat:n,origin:i=``}=We(),a=(0,$.useRef)(null);(0,$.useEffect)(()=>{let e=new AbortController;return a.current=e,()=>e.abort()},[]);let o=(0,$.useRef)(!1),[s,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(!1);function d(e){let t=a.current?.signal;o.current||!t||t.aborted||(o.current=!0,c(!0),e(t).catch(e=>{t.aborted||r({appearance:`editor`,variant:`error`,message:e instanceof Error?e.message:`Could not complete this action. Please try again.`})}).finally(()=>{o.current=!1,t.aborted||c(!1)}))}let f=n=>d(r=>Ee(t,n,e,{signal:r,importFile:e=>Vr(i,e,r)}));function m(e){d(async()=>{let r=await t.require(p);if(e===`video`){await r.createMedia(`video`);return}await r.sendRequest(()=>n.requestImage(),`image`)})}return(0,Q.jsxs)(`div`,{className:`fe-empty`,"aria-busy":s,"data-drag-over":l||void 0,onPointerDownCapture:e=>e.stopPropagation(),onDragOverCapture:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),e.dataTransfer.dropEffect=s?`none`:`copy`,u(!s))},onDragLeave:e=>{(!(e.relatedTarget instanceof Node)||!e.currentTarget.contains(e.relatedTarget))&&u(!1)},onDropCapture:e=>{e.dataTransfer.types.includes(`Files`)&&(e.preventDefault(),e.stopPropagation(),u(!1),s||f(Array.from(e.dataTransfer.files)))},children:[(0,Q.jsxs)(`button`,{type:`button`,className:`fe-empty-upload`,disabled:s,onClick:()=>x(f,t.log),children:[(0,Q.jsx)(`span`,{className:`fe-empty-icons`,"aria-hidden":`true`,children:[Hr,Ur,Wr].map(e=>(0,Q.jsx)(`span`,{children:(0,Q.jsx)(`span`,{className:`fe-empty-glyph`,style:{maskImage:`url(${JSON.stringify(e)})`}})},e))}),(0,Q.jsxs)(`span`,{className:`fe-empty-copy`,children:[(0,Q.jsx)(`strong`,{children:`Click to upload files`}),(0,Q.jsx)(`span`,{children:`Or drag & drop here`})]})]}),(0,Q.jsxs)(`div`,{className:`fe-empty-actions`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:`fe-action-pill`,disabled:s,onClick:()=>m(`video`),children:[(0,Q.jsx)(`span`,{className:`fe-action-glyph`,"aria-hidden":`true`,style:{maskImage:`url(${JSON.stringify(Gr)})`}}),`Create video`]}),(0,Q.jsxs)(`button`,{type:`button`,className:`fe-action-pill`,disabled:s,onClick:()=>m(`image`),children:[(0,Q.jsx)(`span`,{className:`fe-action-glyph`,"aria-hidden":`true`,style:{maskImage:`url(${JSON.stringify(Kr)})`}}),`Create image`]})]})]})}function Jr({bindStage:e}){let t=Ge(),{gateway:n}=We(),r=q(),i=J(e=>e&&!e.scenes.find(t=>t.id===e.activeSceneId)?.tracks.some(e=>e.clips.length)?e.id:null),l=ke(o),u=ke(a),d=ke(c),f=ke(s),p=(0,$.useRef)(null),m=(0,$.useRef)(null),h=(0,$.useRef)(null),g=(0,$.useRef)(null),_=(0,$.useRef)(null),v=(0,$.useRef)(null),y=(0,$.useRef)(null),[b,x]=(0,$.useState)(null),[S,C]=(0,$.useState)(null),[w,T]=(0,$.useState)(null),[E,D]=(0,$.useState)(null),O=(0,$.useCallback)((e,t)=>{v.current?.draw(e,t)},[]),k=(0,$.useCallback)(e=>{let t=g.current,n=m.current;if(t){let r=!!(n&&e);t.hidden=U.properties&&!r,t.inert=!r;let i=String(r);t.dataset.visible!==i&&(t.dataset.visible=i,t.setAttribute(`aria-hidden`,String(!r)))}if(!t||!n||!e)return;let{x:r,y:i}=lt(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),zn(h.current,_.current,t,r,i)},[]);(0,$.useEffect)(()=>{let e=g.current;if(!e)return;let t=new ResizeObserver(()=>y.current?.());return t.observe(e),()=>t.disconnect()},[]);let ee=(0,$.useCallback)(e=>{t.commands.execute(e).catch(n=>{t.log.warn(`contextual control "${e}" failed`,{error:String(n)})})},[t]),te=(0,$.useCallback)(()=>{v.current?.editSelectedText()},[]),ne=(0,$.useCallback)(e=>{t.commands.execute(`document.apply`,e).catch(e=>{t.log.error(`document.apply failed`,{error:String(e)})})},[t]);return(0,$.useEffect)(()=>{if(!r||!l||!u||!d||!f)return;let i=m.current,a=h.current;if(!i||!a)return;let o=Ar(i,a,{host:t,gateway:n,session:r,docs:l,frames:u,players:d,placement:f,apply:ne,invalidate:()=>y.current?.(),updateSelectionToolbar:k,showAspectMenu:(e,t,n,r)=>x({x:e,y:t,documentId:n,sceneId:r}),showMenu:(e,t,n)=>C({x:e,y:t,items:n}),showComponentEditor:(e,t,n)=>T({x:e,y:t,clipId:n}),showAutoLayoutEditor:(e,t,n)=>D({x:e,y:t,...n})});v.current=o;let s=e(o,r);return()=>{s.dispose(),o.dispose(),v.current=null}},[n,t,r,l,u,d,f,ne,e,k]),(0,Q.jsxs)(`div`,{ref:p,className:`fv-root bg-q-background-primary text-q-text-primary text-q-body-sm-regular`,"data-empty":!!i||void 0,children:[!i&&(0,Q.jsx)(fn,{}),!i&&(0,Q.jsx)(Kn,{}),(0,Q.jsxs)(`div`,{ref:m,className:`fv-stage`,role:`region`,"aria-label":`Edited project preview`,children:[(0,Q.jsx)(bt,{draw:O,invalidate:y,canvasRef:h,className:`fv-canvas`}),U.properties?(0,Q.jsx)(Dn,{toolbarRef:g,apply:ne,execute:ee,editSelectedText:te}):(0,Q.jsx)(In,{toolbarRef:g,backdropRef:_}),!i&&(0,Q.jsx)(Zt,{}),i&&(0,Q.jsx)(qr,{projectId:i},i)]}),!i&&(0,Q.jsx)(Gn,{rootRef:p}),b&&(0,Q.jsx)(sn,{...b,onClose:()=>x(null)}),S&&(0,Q.jsx)(V,{x:S.x,y:S.y,width:`290px`,items:S.items,onClose:()=>C(null)}),w&&(0,Q.jsx)(Dt,{x:w.x,y:w.y,clipId:w.clipId,onClose:()=>T(null)}),E&&(0,Q.jsx)(tt,{...E,onClose:()=>D(null)})]})}export{Jr as default};
@@ -0,0 +1,2 @@
1
+ import{n as e,s as t,t as n}from"./jsx-runtime-B5yqYJvp.js";import{n as r}from"./notifications-DqWZNIrK.js";import{t as i}from"./react-dom-1uB7Vbbb.js";import{i as a}from"./ingest-DsmIc415.js";import{d as o,f as s}from"./useRenderElement-D4SOg3N_.js";import{B as c,C as l,H as u,T as d,b as f,h as p,nt as m,w as h}from"./components-tXMtIZNL.js";import{t as g}from"./tabs-XeAgs9cs.js";import{Dt as _,Ot as v,_ as y,a as b,c as x,i as S,o as C,p as w,s as ee,x as te,y as ne}from"../editor-B-WAkLt7.js";import{r as T,t as E}from"./button-Cg0U0zpV.js";import{n as re,t as ie}from"./toggle-DbNEaSIl.js";import{t as ae}from"./media-DQw6vU_T.js";import{t as oe}from"./IconChevronDownSmall-DaruzJwU.js";import{t as D}from"./IconCrossMedium-BsPFJzc6.js";var O=n(),se={glass:``,solid:`q-card-solid`},k={flat:``,raised:`q-card-raised`};function ce(e={},...t){let{surface:n=`glass`,elevation:r=`flat`}=e;return s(`q-card`,se[n],k[r],...t)}function le({surface:e,elevation:t,className:n,render:r,ref:i,...a}){return T({render:r,defaultTagName:`div`,ref:i,props:{className:ce({surface:e,elevation:t},n),...a}})}function ue({title:e,description:t,actions:n,children:r,className:i,...a}){return(0,O.jsx)(`div`,{className:s(`q-card-header`,i),...a,children:r??(0,O.jsxs)(O.Fragment,{children:[e!=null||t!=null?(0,O.jsxs)(`div`,{className:`q-card-heading`,children:[e==null?null:(0,O.jsx)(de,{children:e}),t==null?null:(0,O.jsx)(A,{children:t})]}):null,n==null?null:(0,O.jsx)(`div`,{className:`q-card-actions`,children:n})]})})}function de({className:e,color:t,...n}){return(0,O.jsx)(o,{as:`div`,variant:`body-md-semi-bold`,color:`primary`,className:s(`q-card-title`,e),...n})}function A({className:e,color:t,...n}){return(0,O.jsx)(o,{as:`div`,variant:`body-sm-regular`,color:`secondary`,className:s(`q-card-description`,e),...n})}function fe({className:e,...t}){return(0,O.jsx)(`div`,{className:s(`q-card-body`,e),...t})}function pe({actions:e,children:t,className:n,...r}){return(0,O.jsx)(`div`,{className:s(`q-card-footer`,n),...r,children:t??(e==null?null:(0,O.jsx)(`div`,{className:`q-card-actions`,children:e}))})}var j=Object.assign(le,{Header:ue,Title:de,Description:A,Body:fe,Footer:pe}),me={xxs:`q-loader-xxs`,xs:`q-loader-xs`,sm:`q-loader-sm`,md:`q-loader-md`,lg:`q-loader-lg`},M={dots:`q-loader-dots`,circle:`q-loader-circle`,stars:`q-loader-stars`,shine:`q-loader-shine`};function N({className:e}){return(0,O.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":!0,children:(0,O.jsx)(`path`,{d:`M12 0c.6 6.7 5.3 11.4 12 12-6.7.6-11.4 5.3-12 12-.6-6.7-5.3-11.4-12-12C6.7 11.4 11.4 6.7 12 0Z`})})}function he({variant:e=`circle`,size:t=`md`,color:n=`brand`,animated:r=!0,className:i,style:a,"aria-label":o=`Loading`,...c}){let l={role:`status`,"aria-label":o,"aria-live":`polite`,"data-static":r?void 0:``,style:{...m(n),...a},...c},u=s(`q-loader`,M[e],me[t],i);return e===`dots`?(0,O.jsx)(`div`,{...l,className:u,children:Array.from({length:4},(e,t)=>(0,O.jsx)(`span`,{className:`q-loader-dot`},t))}):e===`stars`?(0,O.jsxs)(`div`,{...l,className:u,children:[(0,O.jsx)(N,{className:`q-loader-star q-loader-star-main`}),(0,O.jsx)(N,{className:`q-loader-star q-loader-star-sub`})]}):e===`shine`?(0,O.jsx)(`div`,{...l,className:u}):(0,O.jsx)(`div`,{...l,className:u,children:(0,O.jsxs)(`svg`,{className:`q-loader-spinner`,viewBox:`0 0 24 24`,fill:`none`,"aria-hidden":!0,children:[(0,O.jsx)(`circle`,{className:`q-loader-spinner-track`,cx:`12`,cy:`12`,r:`9`,strokeWidth:`2.5`}),(0,O.jsx)(`path`,{className:`q-loader-spinner-arc`,d:`M12 3a9 9 0 0 1 9 9`,strokeWidth:`2.5`,strokeLinecap:`round`})]})})}function ge({label:e,description:t,error:n,invalid:r,required:i=!1,start:a,end:o,prefix:c,suffix:l,render:u,rows:d,className:f,controlClassName:p,inputClassName:m,fieldProps:h,...g}){let _=r??n!=null,v=a??c,y=o??l;return(0,O.jsxs)(x,{className:s(`q-field q-field-multiline`,f),...h,children:[e==null?null:(0,O.jsxs)(ee,{className:s(`q-field-label`,_&&`q-field-label-invalid`),children:[e,i?(0,O.jsx)(`span`,{"aria-hidden":!0,className:`q-field-required`,children:`*`}):null]}),(0,O.jsxs)(`label`,{className:s(`q-field-control q-field-control-multiline`,_&&`q-field-control-invalid`,p),children:[v==null?null:(0,O.jsx)(`span`,{className:`q-field-affix`,children:v}),(0,O.jsx)(S,{render:u??(0,O.jsx)(`textarea`,{rows:d}),className:s(`q-field-input q-field-input-multiline`,m),"aria-invalid":_||void 0,autoComplete:`off`,...g}),y==null?null:(0,O.jsx)(`span`,{className:`q-field-affix`,children:y})]}),_&&n!=null?(0,O.jsx)(C,{match:!0,className:`q-field-error`,children:n}):t==null?null:(0,O.jsx)(b,{className:`q-field-description`,children:t})]})}var P=t(e(),1),_e=e=>{let t=P.useId();return P.createElement(L,{...e,instanceId:t})},ve=0,F=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++ve}`})}render(){return P.createElement(L,{...this.props.iconProps,instanceId:this.state.instanceId})}},I=P.forwardRef((e,t)=>F?P.createElement(F,{iconProps:{...e,svgRef:t}}):P.createElement(_e,{...e,svgRef:t}));I.displayName=`CentralIconBase`;var L=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},ye=P.memo(P.forwardRef((e,t)=>P.createElement(I,{...e,ref:t,ariaLabel:`add-image, upload-image`,maskId:`round-outlined-radius-2-stroke-1.5-IconAddImage`},P.createElement(`path`,{d:`M11.25 20.25H5.75C4.64543 20.25 3.75 19.3546 3.75 18.25V5.75C3.75 4.64543 4.64543 3.75 5.75 3.75H18.25C19.3546 3.75 20.25 4.64543 20.25 5.75V11.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),P.createElement(`path`,{d:`M3.75 16.25L6.58579 13.4142C7.36683 12.6332 8.63317 12.6332 9.41421 13.4142L12 16`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),P.createElement(`path`,{d:`M14.5 11.5C15.6046 11.5 16.5 10.6046 16.5 9.5C16.5 8.39543 15.6046 7.5 14.5 7.5C13.3954 7.5 12.5 8.39543 12.5 9.5C12.5 10.6046 13.3954 11.5 14.5 11.5Z`,stroke:`currentColor`,strokeWidth:`1.5`}),P.createElement(`path`,{d:`M15.75 18.5H21.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),P.createElement(`path`,{d:`M18.5 15.75V21.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})))),R=e=>{let t=P.useId();return P.createElement(Se,{...e,instanceId:t})},be=0,z=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++be}`})}render(){return P.createElement(Se,{...this.props.iconProps,instanceId:this.state.instanceId})}},xe=P.forwardRef((e,t)=>z?P.createElement(z,{iconProps:{...e,svgRef:t}}):P.createElement(R,{...e,svgRef:t}));xe.displayName=`CentralIconBase`;var Se=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ce=P.memo(P.forwardRef((e,t)=>P.createElement(xe,{...e,ref:t,ariaLabel:`arrow-up,arrow-top`,maskId:`round-outlined-radius-2-stroke-1.5-IconArrowUp`},P.createElement(`path`,{d:`M12 20.25V4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),P.createElement(`path`,{d:`M5.75 10L12 3.75L18.25 10`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),we=e=>{let t=P.useId();return P.createElement(Ee,{...e,instanceId:t})},B=0,V=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++B}`})}render(){return P.createElement(Ee,{...this.props.iconProps,instanceId:this.state.instanceId})}},Te=P.forwardRef((e,t)=>V?P.createElement(V,{iconProps:{...e,svgRef:t}}):P.createElement(we,{...e,svgRef:t}));Te.displayName=`CentralIconBase`;var Ee=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},De=P.memo(P.forwardRef((e,t)=>P.createElement(Te,{...e,ref:t,ariaLabel:`checkmark-1-medium`,maskId:`round-outlined-radius-2-stroke-1.5-IconCheckmark1Medium`},P.createElement(`path`,{d:`M6 14.15L10.0321 18L18 7`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),Oe=e=>{let t=P.useId();return P.createElement(W,{...e,instanceId:t})},H=0,ke=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++H}`})}render(){return P.createElement(W,{...this.props.iconProps,instanceId:this.state.instanceId})}},U=P.forwardRef((e,t)=>ke?P.createElement(ke,{iconProps:{...e,svgRef:t}}):P.createElement(Oe,{...e,svgRef:t}));U.displayName=`CentralIconBase`;var W=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ae=P.memo(P.forwardRef((e,t)=>P.createElement(U,{...e,ref:t,ariaLabel:`images-sparkle, photos, pictures, shot, generate`,maskId:`round-outlined-radius-2-stroke-1.5-IconImagesSparkle`},P.createElement(`path`,{d:`M3.75 16L7.29353 12.6649C7.68712 12.2944 8.30382 12.3038 8.686 12.686L12 16L13.2929 14.7071C13.6834 14.3165 14.3166 14.3165 14.7071 14.7071L19.5 19.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),P.createElement(`path`,{d:`M11.75 3.75H5.75C4.64543 3.75 3.75 4.64543 3.75 5.75V18.25C3.75 19.3546 4.64543 20.25 5.75 20.25H18.25C19.3546 20.25 20.25 19.3546 20.25 18.25V12.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),P.createElement(`path`,{d:`M19.2405 4.18518L18.5436 2.37334C18.4571 2.14842 18.241 2 18 2C17.759 2 17.5429 2.14842 17.4564 2.37334L16.7595 4.18518C16.658 4.44927 16.4493 4.65797 16.1852 4.75955L14.3733 5.45641C14.1484 5.54292 14 5.75901 14 6C14 6.24099 14.1484 6.45708 14.3733 6.54359L16.1852 7.24045C16.4493 7.34203 16.658 7.55073 16.7595 7.81482L17.4564 9.62666C17.5429 9.85158 17.759 10 18 10C18.241 10 18.4571 9.85158 18.5436 9.62666L19.2405 7.81482C19.342 7.55073 19.5507 7.34203 19.8148 7.24045L21.6267 6.54359C21.8516 6.45708 22 6.24099 22 6C22 5.75901 21.8516 5.54292 21.6267 5.45641L19.8148 4.75955C19.5507 4.65797 19.342 4.44927 19.2405 4.18518Z`,fill:`currentColor`})))),G=e=>{let t=P.useId();return P.createElement(je,{...e,instanceId:t})},K=0,q=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++K}`})}render(){return P.createElement(je,{...this.props.iconProps,instanceId:this.state.instanceId})}},J=P.forwardRef((e,t)=>q?P.createElement(q,{iconProps:{...e,svgRef:t}}):P.createElement(G,{...e,svgRef:t}));J.displayName=`CentralIconBase`;var je=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Me=P.memo(P.forwardRef((e,t)=>P.createElement(J,{...e,ref:t,ariaLabel:`plus-medium, add medium`,maskId:`round-outlined-radius-2-stroke-1.5-IconPlusMedium`},P.createElement(`path`,{d:`M12 5.25V12M12 12V18.75M12 12H5.25M12 12H18.75`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})))),Y=e=>{let t=P.useId();return P.createElement(Fe,{...e,instanceId:t})},Ne=0,X=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++Ne}`})}render(){return P.createElement(Fe,{...this.props.iconProps,instanceId:this.state.instanceId})}},Pe=P.forwardRef((e,t)=>X?P.createElement(X,{iconProps:{...e,svgRef:t}}):P.createElement(Y,{...e,svgRef:t}));Pe.displayName=`CentralIconBase`;var Fe=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ie=P.memo(P.forwardRef((e,t)=>P.createElement(Pe,{...e,ref:t,ariaLabel:`sparkle, star, ai`,maskId:`round-outlined-radius-2-stroke-1.5-IconSparkle`},P.createElement(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M21.25 12C14.8264 12 12 14.8264 12 21.25C12 14.8264 9.17361 12 2.75 12C9.17361 12 12 9.17361 12 2.75C12 9.17361 14.8264 12 21.25 12Z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`})))),Le=e=>{let t=P.useId();return P.createElement(ze,{...e,instanceId:t})},Re=0,Z=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++Re}`})}render(){return P.createElement(ze,{...this.props.iconProps,instanceId:this.state.instanceId})}},Q=P.forwardRef((e,t)=>Z?P.createElement(Z,{iconProps:{...e,svgRef:t}}):P.createElement(Le,{...e,svgRef:t}));Q.displayName=`CentralIconBase`;var ze=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Be=P.memo(P.forwardRef((e,t)=>P.createElement(Q,{...e,ref:t,ariaLabel:`video-clip, film, movie`,maskId:`round-outlined-radius-2-stroke-1.5-IconVideoClip`},P.createElement(`path`,{d:`M3.75 12H7.75M3.75 12V7.875M3.75 12V16.125M7.75 12H16.25M7.75 12V16.125M7.75 12V7.875M16.25 12H20.25M16.25 12V16.5833M16.25 12V7.875M20.25 12V7.875M20.25 12V16.5833M16.25 20.25H18.25C19.3546 20.25 20.25 19.3546 20.25 18.25V16.5833M16.25 20.25V16.5833M16.25 20.25H7.75M16.25 3.75H18.25C19.3546 3.75 20.25 4.64543 20.25 5.75V7.875M16.25 3.75V7.875M16.25 3.75H7.75M16.25 7.875H20.25M16.25 16.5833H20.25M7.75 20.25H5.75C4.64543 20.25 3.75 19.3546 3.75 18.25V16.125M7.75 20.25V16.125M7.75 3.75H5.75C4.64543 3.75 3.75 4.64543 3.75 5.75V7.875M7.75 3.75V7.875M3.75 7.875H7.75M3.75 16.125H7.75`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`square`,strokeLinejoin:`round`})))),Ve=e=>{let t=P.useId();return P.createElement(Ge,{...e,instanceId:t})},He=0,Ue=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++He}`})}render(){return P.createElement(Ge,{...this.props.iconProps,instanceId:this.state.instanceId})}},We=P.forwardRef((e,t)=>Ue?P.createElement(Ue,{iconProps:{...e,svgRef:t}}):P.createElement(Ve,{...e,svgRef:t}));We.displayName=`CentralIconBase`;var Ge=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ke=P.memo(P.forwardRef((e,t)=>P.createElement(We,{...e,ref:t,ariaLabel:`history, back, timeline`,maskId:`round-outlined-radius-2-stroke-1.5-IconHistory`},P.createElement(`path`,{d:`M12 7.75V12L15.5 15.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),P.createElement(`path`,{d:`M2.75 4.75V8.75H6.75`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),P.createElement(`path`,{d:`M3.25 15.0833C4.52169 18.676 7.95303 21.25 11.9864 21.25C17.1026 21.25 21.25 17.1086 21.25 12C21.25 6.89137 17.1026 2.75 11.9864 2.75C8.14808 2.75 4.85497 5.08106 3.44947 8.40278`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})))),qe=e=>{let t=P.useId();return P.createElement(Xe,{...e,instanceId:t})},$=0,Je=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++$}`})}render(){return P.createElement(Xe,{...this.props.iconProps,instanceId:this.state.instanceId})}},Ye=P.forwardRef((e,t)=>Je?P.createElement(Je,{iconProps:{...e,svgRef:t}}):P.createElement(qe,{...e,svgRef:t}));Ye.displayName=`CentralIconBase`;var Xe=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},Ze=P.memo(P.forwardRef((e,t)=>P.createElement(Ye,{...e,ref:t,ariaLabel:`user, people, person, member`,maskId:`round-outlined-radius-2-stroke-1.5-IconUser`},P.createElement(`path`,{d:`M6.5 20.25C5.39543 20.25 4.47594 19.3452 4.69524 18.2626C5.37179 14.9227 7.80671 12.25 12 12.25C16.1924 12.25 18.4514 14.9215 19.0718 18.2605C19.2736 19.3464 18.3546 20.25 17.25 20.25H6.5Z`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),P.createElement(`circle`,{cx:`12`,cy:`7.75`,r:`4.5`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}))));function Qe(e){return e?e.authenticated?e.email??`Signed in`:`Sign in`:`Account`}function $e(e){return e.status===`in_progress`?`Generating`:e.status[0].toUpperCase()+e.status.slice(1)}function et({open:e}){let{gateway:t}=te(),[n,r]=(0,P.useState)(null),[i,a]=(0,P.useState)(null),[s,c]=(0,P.useState)(!1),[l,u]=(0,P.useState)(null),[d,f]=(0,P.useState)(null),p=(0,P.useCallback)(async()=>{try{let e=await t.getAuthStatus();return r(e),a(null),e}catch(e){return a(e instanceof Error?e.message:`Auth status unavailable`),null}},[t]);(0,P.useEffect)(()=>{e&&p()},[e,p]);async function m(){try{await t.logout(),await p()}catch(e){a(e instanceof Error?e.message:`Sign-out failed`)}}async function h(){let e=!s;if(c(e),e){f(null);try{u(await t.listHistory(50))}catch(e){f(e instanceof Error?e.message:`Generation history unavailable`)}}}return e?(0,O.jsxs)(`div`,{className:`ai-account-wrap`,children:[(0,O.jsxs)(`div`,{className:`ai-account-row`,children:[(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,start:(0,O.jsx)(Ke,{mode:`raw`,size:13}),onClick:()=>void h(),"aria-expanded":s,children:`History`}),(0,O.jsx)(`span`,{className:`ai-account-spacer`}),(0,O.jsxs)(o,{as:`span`,variant:`caption-sm-regular`,color:`tertiary`,className:`ai-account-label`,children:[(0,O.jsx)(Ze,{mode:`raw`,size:13}),Qe(n)]}),n?.authenticated?(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,onClick:()=>void m(),children:`Sign out`}):null]}),i&&(0,O.jsx)(o,{variant:`caption-sm-regular`,color:`danger`,className:`ai-inline-error`,children:i}),s&&(0,O.jsxs)(j,{surface:`solid`,className:`ai-generation-history`,"aria-label":`Generation history`,children:[d?(0,O.jsx)(o,{variant:`caption-sm-regular`,color:`danger`,className:`ai-inline-error`,children:d}):null,!l&&!d?(0,O.jsx)(`div`,{className:`ai-history-state`,children:(0,O.jsx)(he,{size:`sm`,"aria-label":`Loading generations`})}):null,l?.length===0?(0,O.jsx)(o,{variant:`caption-sm-regular`,color:`tertiary`,className:`ai-history-state`,children:`No generations yet. Create one from the prompt below.`}):null,l?.map(e=>(0,O.jsxs)(`div`,{className:`ai-history-job`,children:[(0,O.jsxs)(`div`,{className:`ai-history-job-copy`,children:[(0,O.jsx)(o,{as:`span`,variant:`caption-sm-regular`,className:`ai-history-job-prompt`,title:e.prompt,children:e.prompt||e.modelId}),(0,O.jsxs)(o,{as:`span`,variant:`caption-xs-regular`,color:`tertiary`,className:`ai-history-job-meta`,children:[$e(e),` ·`,new Date(e.createdAt).toLocaleString()]})]}),e.resultUrl?(0,O.jsx)(E,{as:`a`,variant:`ghost`,size:`xxs`,href:e.resultUrl,target:`_blank`,rel:`noreferrer`,children:`Open`}):null]},e.id))]})]}):null}var tt=e=>{let t=P.useId();return P.createElement(at,{...e,instanceId:t})},nt=0,rt=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++nt}`})}render(){return P.createElement(at,{...this.props.iconProps,instanceId:this.state.instanceId})}},it=P.forwardRef((e,t)=>rt?P.createElement(rt,{iconProps:{...e,svgRef:t}}):P.createElement(tt,{...e,svgRef:t}));it.displayName=`CentralIconBase`;var at=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},ot=P.memo(P.forwardRef((e,t)=>P.createElement(it,{...e,ref:t,ariaLabel:`checkmark-1`,maskId:`round-outlined-radius-2-stroke-1.5-IconCheckmark1`},P.createElement(`path`,{d:`M4.75 12.7768L10 19.25L19.25 4.75`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})))),st=e=>{let t=P.useId();return P.createElement(dt,{...e,instanceId:t})},ct=0,lt=typeof P.useId==`function`?void 0:class extends P.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++ct}`})}render(){return P.createElement(dt,{...this.props.iconProps,instanceId:this.state.instanceId})}},ut=P.forwardRef((e,t)=>lt?P.createElement(lt,{iconProps:{...e,svgRef:t}}):P.createElement(st,{...e,svgRef:t}));ut.displayName=`CentralIconBase`;var dt=({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 P.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&&P.createElement(`title`,null,y),g?P.createElement(P.Fragment,null,P.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},P.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),P.createElement(`g`,{fill:`none`,style:{color:`#fff`}},b)),P.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):b)},ft=P.memo(P.forwardRef((e,t)=>P.createElement(ut,{...e,ref:t,ariaLabel:`exclamation-circle, info, warning`,maskId:`round-outlined-radius-2-stroke-1.5-IconExclamationCircle`},P.createElement(`circle`,{cx:`12`,cy:`12`,r:`9.25`,stroke:`currentColor`,strokeWidth:`1.5`}),P.createElement(`path`,{d:`M12 7.75V12.25`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`}),P.createElement(`circle`,{cx:`12`,cy:`16`,r:`1`,fill:`currentColor`}))));function pt(e,t,n){if(t?.kind===`added`)return`Added to timeline`;if(t?.kind===`error`)return t.message;switch(e.status){case`queued`:return`Queued…`;case`in_progress`:return`Generating…`;case`completed`:return n?`Ready to import`:`Importing…`;case`canceled`:return e.error??`Canceled`;case`failed`:return e.error??`Generation failed`}}function mt({controller:e}){let t=y(e.jobs,[]).filter(e=>e.modelId!==`reframe`),n=y(e.ingest,{}),r=y(e.models,[]);return t.length===0?null:(0,O.jsx)(`div`,{className:`ai-jobs`,children:t.map(t=>{let i=n[t.id],a=e.awaitingImport(t.id),s=e.busy(t),c=t.status===`failed`||t.status===`canceled`||i?.kind===`error`,l=i?.kind===`added`||a,u=r.find(e=>e.id===t.modelId)?.name??t.modelId;return(0,O.jsxs)(j,{surface:`solid`,elevation:`raised`,className:`ai-job${s?` active`:``}${c?` failed`:``}${l?` done`:``}`,children:[s?(0,O.jsx)(he,{size:`xs`,"aria-label":pt(t,i,a)}):(0,O.jsx)(`span`,{className:`ai-job-icon${l?` ok`:``}`,children:l?(0,O.jsx)(ot,{mode:`raw`,size:13}):(0,O.jsx)(ft,{mode:`raw`,size:13})}),(0,O.jsxs)(`div`,{className:`ai-job-body`,children:[(0,O.jsx)(o,{as:`div`,variant:`caption-sm-regular`,className:`ai-job-prompt`,title:t.prompt,children:t.prompt}),(0,O.jsx)(o,{as:`div`,variant:`caption-sm-regular`,color:c?`danger`:l?`success`:`tertiary`,className:`ai-job-meta`,children:`${u} · ${pt(t,i,a)}`})]}),(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,iconOnly:!0,title:`Dismiss`,"aria-label":`Dismiss job`,start:(0,O.jsx)(D,{mode:`raw`,size:12}),onClick:()=>e.dismiss(t.id)})]},t.id)})})}var ht=t(i(),1),gt=[{aspect:`9:16`,label:`9:16 · Vertical`,Icon:d},{aspect:`1:1`,label:`1:1 · Square`,Icon:h},{aspect:`16:9`,label:`16:9 · Wide`,Icon:l}];function _t({controller:e,target:t}){let n=w(e=>e),r=ne(),[i,o]=(0,P.useState)(null),[s,c]=(0,P.useState)(null),l=(0,P.useCallback)(e=>{e&&o(p(e)?.querySelector(`.ftl-body`)??null)},[]);(0,P.useEffect)(()=>{if(!i)return;let n=!0,a=()=>{r.commands.execute(`fable.panel-timeline.clipMenuAnchor`,t.sources.map(({clipId:e})=>e)).then(e=>{if(n&&e&&typeof e==`object`&&`x`in e&&`y`in e&&typeof e.x==`number`&&typeof e.y==`number`){let t=i.getBoundingClientRect(),n=p(i).getBoundingClientRect(),r=i.ownerDocument.defaultView,a=Math.max(0,n.left)+8,o=Math.min(r.innerWidth,n.right)-8,s=Math.max(0,n.top)+8,l=Math.min(r.innerHeight,n.bottom)-8;c({x:Math.max(a,Math.min(t.left+e.x,o)),y:Math.max(s,Math.min(t.top+e.y,l))})}}).catch(e=>r.log.warn(`Could not locate Reframe menu`,String(e)))},o=()=>e.toolTarget.set(null),s=new ResizeObserver(a);return s.observe(i),s.observe(p(i)),i.addEventListener(`wheel`,o,{passive:!0}),a(),()=>{n=!1,s.disconnect(),i.removeEventListener(`wheel`,o)}},[i,r,t.sources,e,n]);let d=t.sources.every(e=>a(n,e));return(0,P.useEffect)(()=>{n&&!d&&e.toolTarget.set(null)},[n,d,e]),(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`span`,{ref:l,hidden:!0}),i&&s&&(0,ht.createPortal)((0,O.jsxs)(u.Root,{open:!0,onOpenChange:t=>{t||e.toolTarget.set(null)},children:[(0,O.jsx)(u.Trigger,{"aria-label":`Reframe to`,tabIndex:-1,className:`ai-reframe-anchor`,style:{left:s.x,top:s.y}}),(0,O.jsxs)(f,{container:p(i),surface:`solid`,align:`center`,sideOffset:4,collisionPadding:8,positionerClassName:`ftl-transition-menu-positioner`,className:`ftl-transition-menu ai-reframe-menu`,style:{width:180},"data-theme":`default-dark`,children:[(0,O.jsx)(u.Label,{className:`ftl-effect-menu-label`,children:`Reframe to`}),gt.map(({aspect:t,label:n,Icon:r})=>(0,O.jsx)(u.Item,{title:n,start:(0,O.jsx)(r,{size:16}),onSelect:()=>void e.submitReframe(t)},t))]})]}),p(i))]})}var vt={assets:[],elements:[],prompt:``,editorState:void 0,imageModel:`image_auto`,videoModel:`seedance_2_5`,mode:`image`,settingsValues:{}},yt=new Set;function bt(e){vt={...vt,...e},yt.forEach(e=>e())}function xt({queue:e,draft:t}){let{widgets:n}=te(),r=(0,P.useRef)(null),i=()=>{e.creationDraft.get()===t&&e.creationDraft.set(null)};return(0,P.useLayoutEffect)(()=>{let e=document.activeElement;return t.prompt!==void 0&&bt({prompt:t.prompt,editorState:void 0}),r.current?.focus(),()=>{e instanceof HTMLElement&&e.isConnected&&e.focus({preventScroll:!0})}},[t]),(0,O.jsxs)(`section`,{className:`editor-create-video`,"data-theme":`default-dark`,"aria-label":`Create ${t.kind}`,onKeyDown:e=>{e.stopPropagation(),e.key===`Escape`&&!e.defaultPrevented&&(e.preventDefault(),i())},children:[(0,O.jsxs)(`header`,{children:[(0,O.jsxs)(`h2`,{children:[`Create `,t.kind]}),(0,O.jsx)(`button`,{type:`button`,"aria-label":`Close ${t.kind} composer`,onClick:i,children:(0,O.jsx)(D,{size:16,"aria-hidden":`true`})})]}),(0,O.jsx)(n.Composer,{handle:r,variant:`video-editor`,mode:t.kind,stayOnPage:!0,onSubmitted:i,submitRequest:n=>e.submitVideos(t.projectId,async()=>{let e=await n();return e.submitted?e.jobs:[]})})]})}var St=`application/x-fable-asset`,Ct=`fable:ai-prompt-history`,wt=50;function Tt(){try{let e=JSON.parse(localStorage.getItem(Ct)??`[]`);return Array.isArray(e)?e.filter(e=>typeof e==`string`):[]}catch{return[]}}function Et(e,t){let n=e[0]??t;for(let r of e)Math.abs(r-t)<Math.abs(n-t)&&(n=r);return n}function Dt(e,t){return e.aspectRatios.length===0?null:e.aspectRatios.includes(t??``)?t:e.defaultAspect}function Ot({controller:e}){let{gateway:t}=te(),n=y(e.generationQueue.creationDraft,null),i=ne(),a=y(e.open,!1),s=y(e.settingsOpen,!1),l=y(e.models,[]),d=y(e.modelsError,null),f=y(e.editTarget,null),p=y(e.toolTarget,null),m=y(e.reframeError,null);(0,P.useEffect)(()=>{m&&r(m.message)},[m]);let h=y(e.sceneLightingPresets,[]),b=y(e.sceneLightingPresetsError,null),[x,S]=(0,P.useState)(``);(0,P.useEffect)(()=>{f?.prompt!==void 0&&S(f.prompt)},[f]);let C=y(e.mediaKind,`video`),[w,ee]=(0,P.useState)(null),[T,se]=(0,P.useState)(null),[k,le]=(0,P.useState)(5),[ue,de]=(0,P.useState)(!0),[A,fe]=(0,P.useState)({start:null,end:null}),[pe,me]=(0,P.useState)({start:!1,end:!1}),[M,N]=(0,P.useState)([]),[_e,ve]=(0,P.useState)(!1),[F,I]=(0,P.useState)(null),[L,R]=(0,P.useState)(!1),[be,z]=(0,P.useState)(null),[xe,Se]=(0,P.useState)(Tt),[we,B]=(0,P.useState)(!1),[V,Te]=(0,P.useState)(`relight`),[Ee,Oe]=(0,P.useState)(null),H=(0,P.useRef)(null),ke=(0,P.useRef)(null),U=(0,P.useRef)(null);(0,P.useEffect)(()=>{if(!s)return;let e=ke.current;e&&!e.open&&(typeof e.showModal==`function`?e.showModal():e.setAttribute(`open`,``))},[s]);let W=(0,P.useRef)(A),G=(0,P.useRef)(M);(0,P.useEffect)(()=>{W.current=A,G.current=M});let K=l.filter(e=>e.kind===C),q=K.find(e=>e.id===w)??K[0]??null,J=h.find(e=>e.id===Ee&&e.mode===V)??null,je=!L&&(p?.tool===`scene-lighting`&&J!==null||x.trim().length>0&&!x.startsWith(`/`)&&(f!==null||q!==null)),Y=x.startsWith(`/`)&&!we,Ne=e=>l.some(t=>t.kind===e),X=e=>{ee(e.id),se(Dt(e,T)),e.durations.length>0&&!e.durations.includes(k)&&le(Et(e.durations,k))},Pe=t=>{if(t===C)return;e.mediaKind.set(t);let n=l.find(e=>e.kind===t);n&&X(n)};(0,P.useEffect)(()=>{!K.some(e=>e.id===w)&&K[0]&&X(K[0])},[l,w,C]),(0,P.useEffect)(()=>{e.loadModels()},[e]),(0,P.useEffect)(()=>{a&&queueMicrotask(()=>U.current?.focus())},[a]);let Fe=a&&x.trim().length>0;(0,P.useEffect)(()=>{if(!Fe){e.draft.set(null);return}let t=f?{kind:`video`,duration:f.assetDuration??5,label:f.app.name}:q?{kind:C,duration:C===`image`?5:q.durations.length>0?k:5,label:q.name}:null;e.draft.set(t)},[Fe,f,q,C,k,e]),(0,P.useEffect)(()=>()=>e.draft.set(null),[e]),(0,P.useLayoutEffect)(()=>{let e=U.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,160)}px`)},[x,a]),(0,P.useEffect)(()=>()=>{let e=W.current;e.start&&URL.revokeObjectURL(e.start.thumbUrl),e.end&&URL.revokeObjectURL(e.end.thumbUrl);for(let e of G.current)URL.revokeObjectURL(e.thumbUrl)},[]);let Le=e=>{Se(t=>{let n=[e,...t.filter(t=>t!==e)].slice(0,wt);try{localStorage.setItem(Ct,JSON.stringify(n))}catch{}return n})},Re=e=>{let t=(H.current?.ownerDocument??document).createElement(`input`);t.type=`file`,t.accept=`image/*`,t.onchange=()=>{let n=t.files?.[0];n&&e(n)},t.click()},Z=e=>{let t=W.current[e];t&&URL.revokeObjectURL(t.thumbUrl),fe(t=>({...t,[e]:null}))};async function Q(e,n){me(t=>({...t,[e]:!0})),z(null);try{let r=await t.upload(n,`image`),i=W.current[e];i&&URL.revokeObjectURL(i.thumbUrl),fe(t=>({...t,[e]:{mediaId:r,thumbUrl:URL.createObjectURL(n)}}))}catch(e){z(e instanceof Error?e.message:`Frame upload failed`)}finally{me(t=>({...t,[e]:!1}))}}async function ze(e,t){let n=await i.assets.get(t).catch(()=>null);if(!n||n.kind!==`image`){z(`Only image assets can be used as frames`);return}let r=await i.assets.readBlob(t).catch(()=>null);r&&await Q(e,new File([r],n.name,{type:n.mimeType}))}async function Ve(e){let n=q?.referenceImageLimit??0;if(!(n===0||G.current.length>=n)){ve(!0),z(null);try{let r=await t.upload(e,`image`);N(t=>[...t,{mediaId:r,thumbUrl:URL.createObjectURL(e)}].slice(0,n))}catch(e){z(e instanceof Error?e.message:`Reference upload failed`)}finally{ve(!1)}}}let He=e=>{let t=G.current.find(t=>t.mediaId===e);t&&URL.revokeObjectURL(t.thumbUrl),N(t=>t.filter(t=>t.mediaId!==e))},Ue=()=>{for(let e of G.current)URL.revokeObjectURL(e.thumbUrl);N([])};async function We(){if(!je)return;if(p?.tool===`scene-lighting`&&J){R(!0),z(null);try{await e.submitSceneLighting(J,p.sourceAspectRatio)}catch(e){z(e instanceof Error?e.message:`Scene lighting failed to start`)}finally{R(!1)}return}let t=x.trim();if(f){Le(t),S(``),e.submitEdit(t);return}if(q){R(!0),z(null);try{await e.submit({modelId:q.id,prompt:t,aspectRatio:q.aspectRatios.length>0?T:null,duration:q.durations.length>0?k:0,generateAudio:q.audioParam!==null&&ue,startFrameId:q.supportsStartFrame?A.start?.mediaId??null:null,endFrameId:q.supportsEndFrame?A.end?.mediaId??null:null,referenceImageIds:q.referenceImageLimit?M.map(e=>e.mediaId):[]}),Le(t),S(``),Z(`start`),Z(`end`),Ue()}catch(e){z(e instanceof Error?e.message:`Generation failed to start`)}finally{R(!1)}}}let Ge=e=>{e.key===`Enter`&&!e.shiftKey?(e.preventDefault(),We()):e.key===`Escape`&&(Y?B(!0):e.currentTarget.blur())},Ke=(e,t)=>{let n=A[e];return(0,O.jsxs)(j,{surface:`solid`,render:(0,O.jsx)(`div`,{}),className:`ai-frame-chip${n?` filled`:``}${F===e?` dragover`:``}`,role:`button`,tabIndex:0,"aria-label":`Attach ${t.toLowerCase()}`,onClick:()=>Re(t=>void Q(e,t)),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),Re(t=>void Q(e,t)))},onDragOver:t=>{t.dataTransfer.types.includes(St)&&(t.preventDefault(),t.stopPropagation(),F!==e&&I(e))},onDragLeave:()=>I(t=>t===e?null:t),onDrop:t=>{let n=t.dataTransfer.getData(St).split(`
2
+ `)[0];n&&(t.preventDefault(),t.stopPropagation(),I(null),ze(e,n))},children:[n?(0,O.jsx)(`img`,{src:n.thumbUrl,alt:t}):(0,O.jsx)(`span`,{className:`ai-frame-icon`,children:pe[e]?`…`:(0,O.jsx)(ye,{mode:`raw`,size:16})}),(0,O.jsx)(`span`,{children:t}),n&&(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,iconOnly:!0,title:`Remove ${t.toLowerCase()}`,"aria-label":`Remove ${t.toLowerCase()}`,start:(0,O.jsx)(D,{mode:`raw`,size:10}),onClick:t=>{t.stopPropagation(),Z(e)}})]},e)},qe=Y?xe.filter(e=>e.toLowerCase().includes(x.slice(1).trim().toLowerCase())):[],$=H.current?.closest(`[data-video-editor-root]`)??H.current?.ownerDocument.body;return(0,O.jsxs)(`div`,{ref:H,className:`ai-overlay text-q-caption-sm-regular text-q-text-primary`,"data-theme":`default-dark`,"data-open":a||!!n||void 0,children:[n&&(0,O.jsx)(xt,{queue:e.generationQueue,draft:n}),!n&&(0,O.jsx)(mt,{controller:e}),!n&&p?.tool===`reframe`&&(0,O.jsx)(_t,{controller:e,target:p}),!n&&s&&(0,O.jsxs)(`dialog`,{ref:ke,className:ce({elevation:`raised`},`ai-settings-popover`),"data-theme":`default-dark`,"aria-label":`Higgsfield settings`,onCancel:t=>{t.preventDefault(),e.settingsOpen.set(!1)},onPointerDown:t=>{t.target===t.currentTarget&&e.settingsOpen.set(!1)},children:[(0,O.jsxs)(`div`,{className:`ai-settings-header`,children:[(0,O.jsx)(o,{as:`span`,variant:`caption-sm-semi-bold`,children:`Higgsfield settings`}),(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,iconOnly:!0,title:`Close settings`,"aria-label":`Close settings`,start:(0,O.jsx)(D,{mode:`raw`,size:14}),onClick:()=>e.settingsOpen.set(!1)})]}),(0,O.jsx)(et,{open:s})]}),(0,O.jsx)(`div`,{className:`ai-composer`,hidden:!a||!!n||p?.tool===`reframe`,children:(0,O.jsxs)(`div`,{className:`ai-composer-main`,children:[!f&&!p&&Ne(`video`)&&Ne(`image`)&&(0,O.jsx)(g.Root,{className:`ai-kind`,value:C,variant:`soft`,shape:`rounded`,surface:`flat`,onValueChange:e=>Pe(e),children:(0,O.jsx)(g.List,{"aria-label":`Generation type`,indicator:!1,items:[{value:`image`,label:`Image`,start:(0,O.jsx)(Ae,{mode:`raw`,size:20})},{value:`video`,label:`Video`,start:(0,O.jsx)(Be,{mode:`raw`,size:20})}]})}),(0,O.jsxs)(j,{surface:`solid`,elevation:`raised`,className:`ai-compose-card`,children:[(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,iconOnly:!0,className:`ai-composer-close`,title:`Close AI composer`,"aria-label":`Close AI composer`,start:(0,O.jsx)(D,{mode:`raw`,size:14}),onClick:()=>e.open.set(!1)}),(0,O.jsxs)(`div`,{className:`ai-compose-content bg-q-background-tertiary`,children:[f&&(0,O.jsxs)(j,{surface:`solid`,className:`ai-edit-chip`,children:[(0,O.jsxs)(`span`,{className:`ai-edit-name`,children:[(0,O.jsx)(c,{mode:`raw`,size:12}),` `,f.app.name]}),(0,O.jsx)(`span`,{className:`ai-edit-asset`,title:f.assetName,children:f.assetName}),(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,iconOnly:!0,title:`Exit edit mode`,"aria-label":`Exit edit mode`,start:(0,O.jsx)(D,{mode:`raw`,size:10}),onClick:()=>e.editTarget.set(null)})]}),p?.tool===`scene-lighting`&&(0,O.jsxs)(`div`,{className:`ai-tool-config`,children:[(0,O.jsxs)(`div`,{className:`ai-tool-header`,children:[(0,O.jsx)(o,{as:`strong`,variant:`caption-sm-semi-bold`,children:`Change scene & lighting`}),(0,O.jsx)(o,{as:`span`,variant:`caption-sm-regular`,color:`tertiary`,truncate:!0,title:p.assetName,children:p.assetName})]}),(0,O.jsx)(re,{className:`ai-tool-options`,"aria-label":`Scene lighting mode`,children:[`relight`,`weather`,`time`].map(e=>(0,O.jsx)(ie,{size:`sm`,pressed:e===V,onPressedChange:()=>{Te(e),Oe(null)},children:e===`relight`?`Relight`:e===`weather`?`Weather`:`Time`},e))}),b?(0,O.jsx)(o,{variant:`caption-sm-regular`,color:`danger`,className:`ai-error`,children:b}):(0,O.jsxs)(`div`,{className:`ai-preset-grid`,children:[h.filter(e=>e.mode===V).map(e=>(0,O.jsxs)(j,{render:(0,O.jsx)(`button`,{type:`button`}),surface:`solid`,className:`ai-preset${e.id===Ee?` selected`:``}`,onClick:()=>Oe(e.id),children:[e.previewUrl&&(0,O.jsx)(ae.Root,{ratio:`square`,rounded:`sm`,children:(0,O.jsx)(ae.Image,{src:e.previewUrl,alt:``})}),(0,O.jsx)(o,{as:`span`,variant:`caption-xs-medium`,truncate:!0,children:e.name}),(0,O.jsxs)(o,{as:`small`,variant:`caption-xs-regular`,color:`tertiary`,children:[e.credits,` credits`]})]},e.id)),h.length===0&&(0,O.jsx)(he,{variant:`shine`,size:`lg`,"aria-label":`Loading presets`})]})]}),!f&&!p&&q?.supportsStartFrame&&(0,O.jsxs)(`div`,{className:`ai-frames`,children:[Ke(`start`,`Start frame`),q.supportsEndFrame&&Ke(`end`,`End frame`)]}),!p&&(0,O.jsxs)(`div`,{className:`ai-prompt-wrap`,children:[Y&&(0,O.jsx)(j,{elevation:`raised`,className:`ai-history`,"data-theme":`default-dark`,children:qe.length===0?(0,O.jsx)(o,{variant:`caption-sm-regular`,color:`tertiary`,className:`ai-history-empty`,children:`No prompt history yet`}):qe.map(e=>(0,O.jsx)(`div`,{className:`ai-history-item`,onClick:()=>{S(e),B(!0),queueMicrotask(()=>U.current?.focus())},children:e},e))}),(0,O.jsx)(ge,{ref:U,"aria-label":`Instructions`,className:`ai-prompt`,controlClassName:`ai-prompt-control`,inputClassName:`ai-prompt-input`,rows:2,placeholder:f?.app.promptPlaceholder??`Describe the scene you imagine…`,value:x,onChange:e=>{B(!1),S(e.target.value)},onKeyDown:Ge})]}),be&&(0,O.jsx)(o,{variant:`caption-sm-regular`,color:`danger`,className:`ai-error`,children:be}),(0,O.jsxs)(`div`,{className:`ai-controls`,children:[!f&&!p&&(0,O.jsx)(E,{variant:`tertiary`,size:`xxs`,iconOnly:!0,title:q?.referenceImageLimit?`Upload reference image`:`This model does not accept reference images`,"aria-label":`Upload reference image`,start:(0,O.jsx)(Me,{mode:`raw`,size:16}),disabled:!q?.referenceImageLimit||_e||M.length>=q.referenceImageLimit,onClick:()=>Re(e=>void Ve(e))}),q?.referenceImageLimit?M.map((e,t)=>(0,O.jsxs)(ae.Root,{ratio:`square`,rounded:`md`,className:`ai-reference-chip`,children:[(0,O.jsx)(ae.Image,{src:e.thumbUrl,alt:`Reference ${t+1}`}),(0,O.jsx)(E,{variant:`ghost`,size:`xxs`,iconOnly:!0,title:`Remove reference ${t+1}`,"aria-label":`Remove reference ${t+1}`,start:(0,O.jsx)(D,{mode:`raw`,size:10}),onClick:()=>He(e.mediaId)})]},e.mediaId)):null,(0,O.jsxs)(u.Root,{children:[(0,O.jsxs)(u.Trigger,{"aria-label":`Model`,render:(0,O.jsx)(E,{variant:`tertiary`,size:`xxs`,className:`ai-pill`}),children:[q?(0,O.jsxs)(`span`,{children:[(0,O.jsx)(Ie,{mode:`raw`,size:12}),` `,q.name]}):(0,O.jsx)(`span`,{children:d??`Loading models…`}),(0,O.jsx)(`span`,{className:`chev`,children:(0,O.jsx)(oe,{mode:`raw`,size:12})})]}),K.length>0&&(0,O.jsx)(u.Content,{container:$,positionerClassName:`ai-menu-positioner`,side:`top`,className:`ai-menu models`,"data-theme":`default-dark`,children:K.map(e=>(0,O.jsx)(u.Item,{title:e.name,subtitle:e.description,end:(0,O.jsxs)(O.Fragment,{children:[v(e.provider),e.id===q?.id&&(0,O.jsx)(De,{mode:`raw`,size:16})]}),onSelect:()=>X(e)},e.id))})]}),!f&&!p&&q&&q.aspectRatios.length>0&&(0,O.jsxs)(u.Root,{children:[(0,O.jsxs)(u.Trigger,{render:(0,O.jsx)(E,{variant:`tertiary`,size:`xxs`,className:`ai-pill`}),children:[(0,O.jsx)(`span`,{children:T??q.defaultAspect??``}),(0,O.jsx)(`span`,{className:`chev`,children:(0,O.jsx)(oe,{mode:`raw`,size:12})})]}),(0,O.jsx)(u.Content,{container:$,positionerClassName:`ai-menu-positioner`,side:`top`,className:`ai-menu`,"data-theme":`default-dark`,children:q.aspectRatios.map(e=>(0,O.jsx)(u.Item,{title:_[e]?`${e} · ${_[e]}`:e,end:e===T?(0,O.jsx)(De,{mode:`raw`,size:16}):void 0,onSelect:()=>se(e)},e))})]}),!f&&!p&&q&&q.durations.length>0&&(0,O.jsxs)(u.Root,{children:[(0,O.jsxs)(u.Trigger,{render:(0,O.jsx)(E,{variant:`tertiary`,size:`xxs`,className:`ai-pill`}),children:[(0,O.jsxs)(`span`,{children:[k,`s`]}),(0,O.jsx)(`span`,{className:`chev`,children:(0,O.jsx)(oe,{mode:`raw`,size:12})})]}),(0,O.jsx)(u.Content,{container:$,positionerClassName:`ai-menu-positioner`,side:`top`,className:`ai-menu`,"data-theme":`default-dark`,children:q.durations.map(e=>(0,O.jsx)(u.Item,{title:`${e}s`,end:e===k?(0,O.jsx)(De,{mode:`raw`,size:16}):void 0,onSelect:()=>le(e)},e))})]}),!f&&!p&&q&&q.audioParam!==null&&(0,O.jsxs)(`button`,{type:`button`,className:`ai-audio${ue?` on`:``}`,onClick:()=>de(e=>!e),children:[(0,O.jsx)(`span`,{className:`knob-track`,children:(0,O.jsx)(`span`,{className:`knob`})}),`Audio`]}),(0,O.jsxs)(E,{variant:`primary`,className:`ai-submit`,title:`Generate (Enter)`,disabled:!je,start:(0,O.jsx)(Ce,{mode:`raw`,className:`ai-submit-icon`,size:16}),onClick:()=>void We(),children:[(0,O.jsx)(`span`,{className:`ai-submit-label`,children:L?`Starting…`:`Generate`}),(0,O.jsx)(`small`,{children:`Press Enter`})]})]})]})]})]})})]})}export{Ot as default};
@@ -0,0 +1 @@
1
+ import{n as e,s as t,t as n}from"./jsx-runtime-B5yqYJvp.js";import{t as r}from"./react-dom-1uB7Vbbb.js";import{t as i}from"./IconCheckmark2Medium-hegaz9mQ.js";import{d as a,h as o}from"./components-tXMtIZNL.js";import{t as s}from"./tabs-XeAgs9cs.js";import{t as c,x as l}from"../editor-B-WAkLt7.js";import{t as u}from"./button-Cg0U0zpV.js";import{t as d}from"./IconCrossMedium-BsPFJzc6.js";import{a as f,i as p,n as m,o as h,r as g}from"./export-dialog-BjBskOe3.js";import{n as _,t as v}from"./IconClosedCaptioning-BPqcqKsD.js";var y=t(e(),1),b=e=>{let t=y.useId();return y.createElement(w,{...e,instanceId:t})},x=0,S=typeof y.useId==`function`?void 0:class extends y.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++x}`})}render(){return y.createElement(w,{...this.props.iconProps,instanceId:this.state.instanceId})}},C=y.forwardRef((e,t)=>S?y.createElement(S,{iconProps:{...e,svgRef:t}}):y.createElement(b,{...e,svgRef:t}));C.displayName=`CentralIconBase`;var w=({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`,b=o??n,x=l?l(h??p??`icon`):e;return y.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}},b&&!v&&y.createElement(`title`,null,b),g?y.createElement(y.Fragment,null,y.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},y.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),y.createElement(`g`,{fill:`none`,style:{color:`#fff`}},x)),y.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):x)},T=y.memo(y.forwardRef((e,t)=>y.createElement(C,{...e,ref:t,ariaLabel:`video-2, camera, movie, play`,maskId:`round-filled-radius-2-stroke-1.5-IconVideo2`},y.createElement(`path`,{d:`M14.75 4.5C16.2688 4.5 17.5 5.73122 17.5 7.25V16.75C17.5 18.2688 16.2688 19.5 14.75 19.5H4.75C3.23122 19.5 2 18.2688 2 16.75V7.25C2 5.73122 3.23122 4.5 4.75 4.5H14.75Z`,fill:`currentColor`}),y.createElement(`path`,{d:`M20.4434 7.21484C21.4284 6.82118 22.4998 7.54658 22.5 8.60742V15.3926C22.4998 16.4534 21.4284 17.1788 20.4434 16.7852L18.5 16.0078V7.99219L20.4434 7.21484Z`,fill:`currentColor`})))),E=e=>{let t=y.useId();return y.createElement(A,{...e,instanceId:t})},D=0,O=typeof y.useId==`function`?void 0:class extends y.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++D}`})}render(){return y.createElement(A,{...this.props.iconProps,instanceId:this.state.instanceId})}},k=y.forwardRef((e,t)=>O?y.createElement(O,{iconProps:{...e,svgRef:t}}):y.createElement(E,{...e,svgRef:t}));k.displayName=`CentralIconBase`;var A=({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`,b=o??n,x=l?l(h??p??`icon`):e;return y.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}},b&&!v&&y.createElement(`title`,null,b),g?y.createElement(y.Fragment,null,y.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},y.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),y.createElement(`g`,{fill:`none`,style:{color:`#fff`}},x)),y.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):x)},j=y.memo(y.forwardRef((e,t)=>y.createElement(k,{...e,ref:t,ariaLabel:`audio, music, playlist, musical-note`,maskId:`round-filled-radius-2-stroke-1.5-IconAudio`},y.createElement(`path`,{d:`M19.1835 3.83539C19.3432 3.78977 19.5022 3.90968 19.5022 4.07577V13.15C18.8575 12.7352 18.0658 12.5001 17.2522 12.5001C15.315 12.5001 13.5022 13.833 13.5022 15.7501C13.5022 17.6673 15.315 19.0001 17.2522 19.0001C19.1894 19.0001 21.0022 17.6673 21.0022 15.7501V4.07577C21.0022 2.91315 19.8894 2.07374 18.7715 2.39308L10.2693 4.82177C9.51801 5.03639 9 5.72309 9 6.50446V16.15C8.35535 15.7352 7.56365 15.5001 6.75 15.5001C4.81278 15.5001 3 16.833 3 18.7501C3 20.6673 4.81278 22.0001 6.75 22.0001C8.68722 22.0001 10.5 20.6673 10.5 18.7501V6.50446C10.5 6.39284 10.574 6.29474 10.6813 6.26408L19.1835 3.83539Z`,fill:`currentColor`})))),M=e=>{let t=y.useId();return y.createElement(I,{...e,instanceId:t})},N=0,P=typeof y.useId==`function`?void 0:class extends y.Component{state={};componentDidMount(){this.setState({instanceId:`legacy-${++N}`})}render(){return y.createElement(I,{...this.props.iconProps,instanceId:this.state.instanceId})}},F=y.forwardRef((e,t)=>P?y.createElement(P,{iconProps:{...e,svgRef:t}}):y.createElement(M,{...e,svgRef:t}));F.displayName=`CentralIconBase`;var I=({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`,b=o??n,x=l?l(h??p??`icon`):e;return y.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}},b&&!v&&y.createElement(`title`,null,b),g?y.createElement(y.Fragment,null,y.createElement(`mask`,{id:h,maskUnits:`userSpaceOnUse`,x:`0`,y:`0`,width:`24`,height:`24`},y.createElement(`rect`,{width:`24`,height:`24`,fill:`#000`}),y.createElement(`g`,{fill:`none`,style:{color:`#fff`}},x)),y.createElement(`rect`,{width:`24`,height:`24`,fill:`currentColor`,mask:`url(#${h})`})):x)},L=y.memo(y.forwardRef((e,t)=>y.createElement(F,{...e,ref:t,ariaLabel:`box-2-alt-fill, inbox, archive, tray, shelf`,maskId:`round-filled-radius-2-stroke-1.5-IconBox2AltFill`},y.createElement(`path`,{fillRule:`evenodd`,clipRule:`evenodd`,d:`M3.00001 13.7453L3.00004 5.75C3.00004 4.23122 4.23126 3.00001 5.75004 3L18.25 3C19.7688 3 21 4.23122 21 5.75V13.7466C21 13.7477 21 13.7489 21 13.75L21 18.25C21 19.7688 19.7688 21 18.25 21H5.75C4.32614 21 3.15502 19.9179 3.0142 18.5312C3.00481 18.4387 3 18.3449 3 18.25M5.75004 4.5L18.25 4.5C18.9403 4.5 19.5 5.05964 19.5 5.75V13L15.9298 13C15.5695 13 15.2601 13.2562 15.1929 13.6102C14.9078 15.1135 13.5858 16.25 12 16.25C10.4142 16.25 9.09221 15.1135 8.80706 13.6102C8.73991 13.2562 8.43051 13 8.0702 13H4.50002L4.50004 5.75C4.50004 5.05965 5.05968 4.50001 5.75004 4.5Z`,fill:`currentColor`}),y.createElement(`path`,{d:`M3 18.25V13.75C3 13.7484 3 13.7469 3.00001 13.7453`,fill:`currentColor`})))),R=t(r(),1),z=n();function B({controller:e,portal:t}){let{files:n,folder:r}=l(),a=(0,y.useRef)(null),[o,s]=(0,y.useState)(null),[u,f]=(0,y.useState)(!1),[p,m]=(0,y.useState)(null),[h,g]=(0,y.useState)(null),_=(0,y.useRef)(0);(0,y.useEffect)(()=>()=>{_.current++},[]),(0,y.useEffect)(()=>()=>{o?.url.startsWith(`blob:`)&&URL.revokeObjectURL(o.url)},[o]),(0,y.useLayoutEffect)(()=>{let e=()=>{if(!a.current)return;let e=t.getBoundingClientRect(),n=t.querySelector(`.ftr-topbar`)?.getBoundingClientRect(),r=Math.max(16,(n?.bottom??e.top)-e.top+56);a.current.style.top=`${r}px`,a.current.style.maxHeight=`${Math.max(0,e.height-r-16)}px`};e();let n=new ResizeObserver(e);n.observe(t);let r=t.querySelector(`.ftr-topbar`);return r&&n.observe(r),()=>n.disconnect()},[t,e.historyOpen,e.records.length]);let v=async(t,i)=>{if(!t.readBlob||p!==null)return;let a=++_.current;m({id:t.id,download:i}),g(null);try{if(r&&t.file){await r.show(t.file,i?`reveal`:`open`);return}let o=await t.readBlob();if(_.current!==a||!e.records.some(e=>e.id===t.id))return;if(i)await n.download(o,t.fileName,t.media);else{let r=await n.preview(o,t.fileName,t.media);if(_.current!==a||!e.records.some(e=>e.id===t.id)){r.startsWith(`blob:`)&&URL.revokeObjectURL(r);return}f(!1),s({url:r,name:t.fileName,audio:t.media===`audio`})}}catch(e){_.current===a&&g({id:t.id,message:e instanceof Error?e.message:`Could not open this export. Try again.`})}finally{_.current===a&&m(null)}},b=e.records.find(e=>e.status===`running`),x=!b&&e.records[0]?.status===`error`,S=x?d:i,C=t.querySelector(`[data-export-status-slot]`);return(0,z.jsxs)(z.Fragment,{children:[!!e.records.length&&C&&(0,R.createPortal)((0,z.jsx)(`button`,{type:`button`,className:`editor-export-status`,"data-running":!!b,"data-failed":x,"aria-label":b?`Show export progress`:`Show exported files`,"aria-expanded":e.historyOpen,onClick:()=>e.toggleHistory(),children:b?(0,z.jsx)(`span`,{className:`editor-export-spinner`}):(0,z.jsx)(S,{size:16})}),C),e.historyOpen&&!!e.records.length&&(0,R.createPortal)((0,z.jsx)(`div`,{ref:a,className:`editor-export-files`,role:`region`,"aria-label":`Exported files`,children:e.records.map(t=>(0,z.jsxs)(`article`,{className:`editor-export-file`,"aria-label":t.fileName,"data-status":t.status,children:[(0,z.jsxs)(`div`,{className:`editor-export-file-heading`,children:[(0,z.jsx)(`span`,{title:t.fileName,children:t.fileName}),(0,z.jsx)(`button`,{type:`button`,"aria-label":t.status===`running`?`Cancel export ${t.fileName}`:`Dismiss export ${t.fileName}`,onClick:()=>e.dismissRecord(t.id),children:(0,z.jsx)(d,{size:16})})]}),t.status===`running`&&(0,z.jsxs)(`div`,{className:`editor-export-progress`,role:`status`,children:[(0,z.jsx)(`div`,{role:`progressbar`,"aria-label":`Exporting ${t.fileName}`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":t.percent,children:(0,z.jsx)(`div`,{style:{width:`${t.percent}%`}})}),(0,z.jsxs)(`div`,{children:[(0,z.jsxs)(`strong`,{children:[t.percent,`%`]}),(0,z.jsx)(`span`,{children:`Exporting`})]})]}),t.status===`done`&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`p`,{className:`editor-export-ready`,title:t.file,children:r&&t.file?`Saved to ${t.file}`:`Ready at ${new Date(t.completedAt).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1})}`}),(0,z.jsxs)(`div`,{className:`editor-export-file-actions`,children:[(0,z.jsxs)(`button`,{type:`button`,className:`editor-export-open`,disabled:p!==null,"aria-busy":p?.id===t.id&&!p.download,onClick:()=>void v(t,!1),children:[(0,z.jsx)(`span`,{children:`Open`}),(0,z.jsx)(`span`,{className:`editor-export-spinner`,"aria-hidden":`true`})]}),(0,z.jsx)(`button`,{type:`button`,className:`editor-export-link`,disabled:p!==null,"aria-busy":p?.id===t.id&&p.download,onClick:()=>void v(t,!0),children:r&&t.file?`Show in folder`:`Download`})]})]}),t.status===`error`&&(0,z.jsx)(`p`,{className:`editor-export-error`,role:`alert`,children:t.error}),h?.id===t.id&&(0,z.jsx)(`p`,{className:`editor-export-error`,role:`alert`,children:h.message})]},t.id))}),t),(0,z.jsx)(c.Root,{open:!!o,onOpenChange:e=>{e||s(null)},children:(0,z.jsxs)(c.Content,{container:t,className:`editor-export-preview`,backdropClassName:`editor-export-backdrop`,"data-theme":`default-dark`,onKeyDown:e=>e.stopPropagation(),children:[(0,z.jsxs)(c.Header,{children:[(0,z.jsx)(c.Title,{children:o?.name}),(0,z.jsx)(c.CloseButton,{"aria-label":`Close exported file`})]}),o&&(o.audio?(0,z.jsx)(`audio`,{src:o.url,controls:!0,onError:()=>f(!0)},o.url):(0,z.jsx)(`video`,{src:o.url,controls:!0,playsInline:!0,onError:()=>f(!0)},o.url)),u&&(0,z.jsx)(`p`,{className:`editor-export-error`,role:`alert`,children:`This file could not be previewed. Close the preview and download it instead.`})]})})]})}function V(e){let[,t]=(0,y.useReducer)(e=>e+1,0);(0,y.useEffect)(()=>{let n=0,r=e.onChange(e=>{e?n||=requestAnimationFrame(()=>{n=0,t()}):(cancelAnimationFrame(n),n=0,t())});return()=>{cancelAnimationFrame(n),r.dispose()}},[e])}function H({label:e,children:t}){return(0,z.jsxs)(`div`,{className:`editor-export-field`,children:[(0,z.jsx)(`span`,{children:e}),t]})}function U({label:e,value:t,options:n,onChange:r,disabled:i}){return(0,z.jsx)(H,{label:e,children:(0,z.jsx)(s.Root,{className:`editor-export-segments`,variant:`segmented`,surface:`flat`,value:t,onValueChange:e=>r(String(e)),children:(0,z.jsx)(s.List,{"aria-label":e,indicator:!1,fullWidth:!0,items:n.map(e=>({...e,disabled:i||e.disabled}))})})})}var W=(e,t=``)=>e.map(e=>({value:String(e),label:e===2160?`4K`:`${e}${t}`}));function G({controller:e}){V(e);let t=(0,y.useRef)(null),[n,r]=(0,y.useState)(null);(0,y.useLayoutEffect)(()=>{let e=t.current?.closest(`section`);if(!e)return;let n=e.style.display;return e.style.display=`none`,()=>{e.style.display=n}},[]);let i=e.busy(),l=e.selection,d=l.video,f=e.scenes();return(0,z.jsx)(`div`,{ref:e=>{t.current=e,e&&r(o(e))},children:n&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(B,{controller:e,portal:n}),(0,z.jsx)(c.Root,{open:e.open,onOpenChange:t=>{t||e.requestClose()},children:(0,z.jsxs)(c.Content,{container:n,className:`editor-export-dialog`,backdropClassName:`editor-export-backdrop`,"data-theme":`default-dark`,style:{"--q-modal-width":`31rem`},onKeyDown:e=>e.stopPropagation(),children:[(0,z.jsxs)(c.Header,{children:[(0,z.jsx)(c.Title,{children:`Export`}),(0,z.jsx)(c.CloseButton,{"aria-label":`Close export settings`})]}),(0,z.jsxs)(`div`,{className:`editor-export-settings`,children:[(0,z.jsx)(s.Root,{className:`editor-export-tabs`,variant:`underline`,value:d?`video`:`audio`,onValueChange:t=>e.setMedia(t===`video`),children:(0,z.jsx)(s.List,{"aria-label":`Export type`,indicator:!1,items:[{value:`video`,label:`Video`,start:(0,z.jsx)(T,{size:16}),disabled:i},{value:`audio`,label:`Audio`,start:(0,z.jsx)(j,{size:16}),disabled:i||!e.audioOnlyPossible(),title:e.caps&&!e.audioOnlyPossible()?`Audio-only export is not supported by the renderer`:void 0},{value:`graphics`,label:`Graphics`,start:(0,z.jsx)(_,{size:16}),disabled:!0,title:`Graphics export is not available yet`},{value:`subtitles`,label:`Subtitles`,start:(0,z.jsx)(v,{size:16}),disabled:!0,title:`Subtitle export is not available yet`},{value:`xml`,label:`XML`,start:(0,z.jsx)(L,{size:16}),disabled:!0,title:`XML export is not available yet`}]})}),(0,z.jsxs)(`div`,{className:`editor-export-fields`,children:[(f.length>1||f.length>0&&!e.targetScene())&&(0,z.jsx)(H,{label:`Scene`,children:(0,z.jsx)(a,{label:`Scene`,value:e.targetScene()?.id??``,disabled:i,options:f.map(e=>({value:e.id,label:e.name})),onChange:t=>e.setScene(t||null)})}),d?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(H,{label:`Format`,children:(0,z.jsx)(K,{controller:e})}),(0,z.jsx)(U,{label:`Resolution`,value:String(l.resolution),disabled:i,onChange:t=>e.setResolution(Number(t)),options:W(l.resolution===1440?[480,720,1080,1440,2160]:[480,720,1080,2160],`p`)}),(0,z.jsx)(U,{label:`Frame Rate`,value:String(l.fps),disabled:i,onChange:t=>e.setFps(Number(t)),options:W([...new Set([24,25,30,50,60,l.fps])].sort((e,t)=>e-t))}),(0,z.jsx)(U,{label:`Audio`,value:l.audio?`include`:`mute`,disabled:i||!e.audioPossible(),onChange:t=>e.setAudio(t===`include`),options:[{value:`include`,label:`Include`},{value:`mute`,label:`Mute`}]})]}):(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(H,{label:`Format`,children:(0,z.jsx)(K,{controller:e})}),(0,z.jsx)(q,{controller:e})]})]}),!e.targetScene()&&(0,z.jsx)(`p`,{role:`status`,className:`editor-export-note`,children:f.length?`Choose a scene to export.`:`Add a scene before exporting.`}),e.phase===`error`&&(0,z.jsx)(`p`,{role:`alert`,className:`editor-export-error`,children:e.errorMessage}),e.cancelNotice&&(0,z.jsx)(`p`,{role:`status`,className:`editor-export-note`,children:`Export cancelled`}),e.capabilityError&&(0,z.jsxs)(`div`,{role:`alert`,className:`editor-export-error`,children:[(0,z.jsx)(`p`,{children:e.capabilityError}),(0,z.jsx)(u,{onClick:()=>void e.ensureCaps(),children:`Retry`})]}),!e.caps&&!e.capabilityError&&(0,z.jsx)(`p`,{role:`status`,className:`editor-export-note`,children:`Checking export support…`}),e.caps&&!e.includeVideo()&&!e.includeAudio()&&(0,z.jsx)(`p`,{role:`status`,className:`editor-export-note`,children:`This export is not supported by the renderer.`}),(0,z.jsx)(u,{className:`editor-export-submit`,disabled:!e.canExport(),onClick:()=>void e.startExport(),children:`Export ${d?`video`:`audio`}`})]})]})})]})})}function K({controller:e}){return(0,z.jsx)(a,{label:`Format`,value:e.selection.container,disabled:e.busy()||!e.caps,options:h.filter(t=>!e.selection.video||f[t].length>0).map(t=>({value:t,label:t===`webm`?`WebM`:t.toUpperCase(),disabled:!e.containerOk(t),title:e.containerTip(t)})),onChange:t=>e.setContainer(t)})}function q({controller:e}){let t=e.selection,n=e.busy();return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(H,{label:`Audio codec`,children:(0,z.jsx)(a,{label:`Audio codec`,value:t.audioCodec,disabled:n,options:m.map(t=>({value:t,label:g[t],disabled:!e.audioCodecOk(t),title:e.audioCodecTip(t)})),onChange:t=>e.setAudioCodec(t)})}),(0,z.jsx)(U,{label:`Sample rate`,value:String(t.sampleRate),disabled:n,onChange:t=>e.setSampleRate(Number(t)),options:p.map(n=>({value:String(n),label:`${n/1e3} kHz`,disabled:!e.rateEncodable(t.audioCodec,n),title:e.rateTip(n)}))})]})}export{G as default};