clipoox-render 0.2.0 → 0.3.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 (131) hide show
  1. package/dist/server-text/titleRaster.js +1394 -0
  2. package/package.json +5 -3
  3. package/scripts/render-local.mjs +1514 -1379
  4. package/shared/transitionStarterPack.json +261 -0
  5. package/web/assets/{FxEmbed-BymBArNa.js → FxEmbed-D7k1ThAF.js} +1 -1
  6. package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
  7. package/web/assets/{MotionEmbed-PmXWSWe5.js → MotionEmbed-DFni5IAh.js} +1 -1
  8. package/web/assets/PluginStore-BrupM_8E.js +3 -0
  9. package/web/assets/{ShotComposer-Dprx-Yi7.js → ShotComposer-BLztjSKy.js} +4 -4
  10. package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
  11. package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
  12. package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
  13. package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
  14. package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
  15. package/web/assets/{Whiteboard-DybaKCdo.js → Whiteboard-DMk0unYK.js} +3 -3
  16. package/web/assets/aerial-DT_gUtSh.js +2 -0
  17. package/web/assets/{agentTools-CxZqRLeR.js → agentTools-qOww5RUs.js} +2 -2
  18. package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
  19. package/web/assets/{analyzerSandbox-DO5ZTv5q.js → analyzerSandbox-CJVsEhrg.js} +2 -2
  20. package/web/assets/{api-BsKbf3l3.js → api-QBI5GJTZ.js} +148 -148
  21. package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
  22. package/web/assets/{breakthrough-Dv1bndQb.js → breakthrough-DvkxvNK9.js} +2 -2
  23. package/web/assets/{cameraPresets-B234aNzE.js → cameraPresets-4pFeF2YG.js} +1 -1
  24. package/web/assets/{captionLayout-CNgb471H.js → captionLayout-C67EMVI1.js} +1 -1
  25. package/web/assets/{clientExport-NtJmxOYP.js → clientExport-C4VgAJtO.js} +1 -1
  26. package/web/assets/{depthEstimate-wVYSJtW8.js → depthEstimate-mnXDZMW-.js} +1 -1
  27. package/web/assets/{directorTools-BqFcShgT.js → directorTools-BOHZjcww.js} +1 -1
  28. package/web/assets/{distortFrames-D3TQNcJA.js → distortFrames-Csuj2jHE.js} +2 -2
  29. package/web/assets/{distortGL-BklPDXPq.js → distortGL-BaXfN0IK.js} +2 -2
  30. package/web/assets/{editTools-BQlG5WB_.js → editTools-m0VGPmfF.js} +1 -1
  31. package/web/assets/{exportEncode-CaKEPgsy.js → exportEncode-D9OT7_5k.js} +1 -1
  32. package/web/assets/{exportGlb-DstxwzH5.js → exportGlb-CLfTnbMG.js} +1 -1
  33. package/web/assets/faceTracker-W0iZSiMe.js +1 -0
  34. package/web/assets/fightDirector-CECPf2iH.js +1 -0
  35. package/web/assets/{fightDrama-G7bXfpQu.js → fightDrama-CqNoa5XI.js} +2 -2
  36. package/web/assets/{frameSink-Dj71jCRb.js → frameSink-BGRj7wqY.js} +3 -3
  37. package/web/assets/{gpuCompose-DIxBHlTa.js → gpuCompose-CIEoLFem.js} +1 -1
  38. package/web/assets/gpuExport-uyOAyrhm.js +190 -0
  39. package/web/assets/handMatte-mHxZwLZD.js +1 -0
  40. package/web/assets/handTracker-dTVeSUzt.js +2 -0
  41. package/web/assets/{index-CZn97Ygs.js → index-D7M5t2re.js} +1 -1
  42. package/web/assets/layer-worker-Cp0pjurp.js +5 -0
  43. package/web/assets/library-Dsz_MLyd.js +1 -0
  44. package/web/assets/{lottieLayer-CfUPParC.js → lottieLayer-CDCGeJyv.js} +5 -5
  45. package/web/assets/{lottie_light_canvas-7iv3btPX.js → lottie_light_canvas-BblLU4nU.js} +1 -1
  46. package/web/assets/main-BQ8IY0WV.css +1 -0
  47. package/web/assets/{main-M1vRa-gd.js → main-CVRIuDW2.js} +76 -76
  48. package/web/assets/{mapBake-lPNhNZgv.js → mapBake-CNMOKXA7.js} +1 -1
  49. package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
  50. package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
  51. package/web/assets/{objectLocate-BDqfSo9J.js → objectLocate-Cy3IFBSF.js} +1 -1
  52. package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
  53. package/web/assets/pendingMatte-C2AWApuv.js +2 -0
  54. package/web/assets/personAi-DPUnoymj.js +2 -0
  55. package/web/assets/plateCamera-C96L5GKm.js +1 -0
  56. package/web/assets/{plateCameraMatch-D41LQrsm.js → plateCameraMatch-Chk-ZjDi.js} +2 -2
  57. package/web/assets/{plateFollow-CNfi4xuP.js → plateFollow-B9_QTgvo.js} +2 -2
  58. package/web/assets/plateMatte-BiqyI_8x.js +2 -0
  59. package/web/assets/{pluginAutomation-BtQ_w2TB.js → pluginAutomation-5DYldFrb.js} +1 -1
  60. package/web/assets/poseTracker-PuI8vWpR.js +1 -0
  61. package/web/assets/{productTools-r2RgILaA.js → productTools-B1h5cgyt.js} +2 -2
  62. package/web/assets/remote-BJdzzFZg.js +1241 -0
  63. package/web/assets/{rigTrack-Bx9QHlFv.js → rigTrack-CUt4O67J.js} +1 -1
  64. package/web/assets/{rotoMaskStore-pxpRt5Cj.js → rotoMaskStore-DIi45swK.js} +1 -1
  65. package/web/assets/{rotoMatte-DyXlW4jK.js → rotoMatte-013RKqHu.js} +1 -1
  66. package/web/assets/{rotoscope-GORCSVBr.js → rotoscope-d_TUxa-J.js} +1 -1
  67. package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
  68. package/web/assets/{shot-worker-B8JWkmBz.js → shot-worker-B1iZT6F5.js} +1 -1
  69. package/web/assets/{shotFxAgent-CzHfe75S.js → shotFxAgent-BDfe73TP.js} +2 -2
  70. package/web/assets/{skin-BkaT2QuX.js → skin-GDY3QPkV.js} +1 -1
  71. package/web/assets/{spark.module-BRT8yMS4.js → spark.module-DdwuJ_hb.js} +1 -1
  72. package/web/assets/{spellDuel-BUy289OT.js → spellDuel-DjNN00bv.js} +2 -2
  73. package/web/assets/{store-BSSbvpzr.js → store-2zneEhhu.js} +1 -1
  74. package/web/assets/{surfaceLight-CMaBhZ_d.js → surfaceLight-B_SYg_f8.js} +1 -1
  75. package/web/assets/surfacePin-zDPmq-hH.js +2 -0
  76. package/web/assets/{textAnimators-Cihw35O8.js → textAnimators-Bdt5LWXk.js} +1 -1
  77. package/web/assets/{thumb-Cs636sYt.js → thumb-byAKvhQP.js} +1 -1
  78. package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
  79. package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
  80. package/web/assets/{timelineComp-CRRzLazc.js → timelineComp-B73i_8vD.js} +1 -1
  81. package/web/assets/{timelineProps-tN2YsMYN.js → timelineProps-B2pnudeT.js} +1 -1
  82. package/web/assets/{timelineText-CkoUgWcY.js → timelineText-BcL4Pw3C.js} +1 -1
  83. package/web/assets/{titleArt-CcTdJuOC.js → titleArt-hb_T45WJ.js} +5 -5
  84. package/web/assets/{titleFrameBudget-3MFHWIT6.js → titleFrameBudget-Cml-MO53.js} +970 -839
  85. package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
  86. package/web/assets/{tool-BhIsq238.js → tool-Bt9bclIf.js} +1 -1
  87. package/web/assets/{tools-DMUnabc_.js → tools-BXeJbgZJ.js} +1 -1
  88. package/web/assets/{toonTools-CICrV3QB.js → toonTools-u7Y9fdEZ.js} +2 -2
  89. package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
  90. package/web/assets/{userFonts-BZ4QL-zq.js → userFonts-BHduCNtc.js} +1 -1
  91. package/web/assets/{vfxAlpha-D3Dk1tfF.js → vfxAlpha-DpV4rbI-.js} +1 -1
  92. package/web/assets/vfxBackground-Ddviync5.js +2 -0
  93. package/web/assets/{videoExport-l5MGvMn_.js → videoExport-z5WjM0hw.js} +1 -1
  94. package/web/assets/{views-BdWnG2xK.js → views-CsrYzCSR.js} +1 -1
  95. package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
  96. package/web/assets/{windowFrames-CoIyWqxr.js → windowFrames-BQEWQkEs.js} +1 -1
  97. package/web/layer-worker.html +3 -3
  98. package/web/assets/PluginStore-BVsm6n6N.js +0 -3
  99. package/web/assets/TemplateEmbed-CrZXoUk_.js +0 -2
  100. package/web/assets/TimelinePlugins-B1KGtbmb.js +0 -5
  101. package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
  102. package/web/assets/TimelineShotFx-DoLx312Y.js +0 -2
  103. package/web/assets/TransitionEmbed-C5SUosv2.js +0 -1
  104. package/web/assets/aerial-DSt_mJNA.js +0 -2
  105. package/web/assets/analyzerRun-DCJwb_-Z.js +0 -1
  106. package/web/assets/auraTrack-QR0WqBHp.js +0 -1
  107. package/web/assets/desktop-BWhFnYwd.js +0 -1
  108. package/web/assets/faceTracker-DWxxieVC.js +0 -1
  109. package/web/assets/fightDirector-OMlPZgjv.js +0 -1
  110. package/web/assets/gpuExport-CPSw_dmq.js +0 -189
  111. package/web/assets/handMatte-DHsHHz4m.js +0 -1
  112. package/web/assets/handTracker-D_O-C4Dw.js +0 -2
  113. package/web/assets/layer-worker-Bar7WgOA.js +0 -5
  114. package/web/assets/library-BtBrCaFk.js +0 -1
  115. package/web/assets/main-BPmr0TOL.css +0 -1
  116. package/web/assets/maskTrack-D2jUh7aw.js +0 -1
  117. package/web/assets/matteFixRun-B7tWV9Y1.js +0 -1
  118. package/web/assets/pendingMatte-q35zVaiB.js +0 -2
  119. package/web/assets/personAi-ZjQVo-80.js +0 -2
  120. package/web/assets/plateCamera-A2E_WO_x.js +0 -1
  121. package/web/assets/plateMatte-BdIxGhw5.js +0 -2
  122. package/web/assets/poseTracker-DVX__OK7.js +0 -1
  123. package/web/assets/remote-sTZauTqM.js +0 -1220
  124. package/web/assets/surfacePin-DM9b9ubh.js +0 -2
  125. package/web/assets/timeline3d-BEuZZOxM.js +0 -2
  126. package/web/assets/timeline3dExport-CmSI_pjv.js +0 -1
  127. package/web/assets/titleFrames-w-iWje9N.js +0 -1
  128. package/web/assets/trackAnchor-D2bB5mZE.js +0 -1
  129. package/web/assets/vfxBackground-CHlCg8lb.js +0 -2
  130. package/web/assets/vfxTrack-CqiQDEYm.js +0 -1
  131. package/web/assets/weaponDuel-B2wTffPC.js +0 -1
@@ -1 +0,0 @@
1
- .tl-plugins{display:flex;flex-direction:column;gap:10px;padding:2px 0 10px;min-width:0}.tl-plugins h4{margin:0;font-size:13px;color:#e6e8ec}.tl-plugins h5{margin:0 0 4px;font-size:12px;color:#e6e8ec;display:flex;gap:6px;align-items:baseline}.tl-plugins p{margin:0;font-size:11.5px;line-height:1.5;color:#aab3ac}.tl-plugins small{line-height:1.45}.tl-plugins-head{display:flex;flex-direction:column;gap:8px}.tl-plugins-head>div:first-child{display:flex;flex-direction:column;gap:2px}.tl-plugins-actions{display:flex;gap:6px;flex-wrap:wrap}.tl-plugins-empty{display:flex;flex-direction:column;align-items:center;gap:8px;padding:18px 12px;border:1px dashed #38423a;border-radius:12px;text-align:center;background:#0f130f}.tl-plugins-empty>b{font-size:28px;color:#c6f432;line-height:1}.tl-plugins-empty strong{font-size:13px;color:#e6e8ec}.tl-plugins-samples{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;align-items:center}.tl-plugins-samples a{text-decoration:none}.tl-plugin-grid{display:flex;flex-direction:column;gap:6px}.tl-plugin-tile{position:relative;border:1px solid #283129;border-radius:10px;background:#0f130f;min-width:0}.tl-plugin-tile:hover{border-color:#c6f43299}.tl-plugin-tile.off{opacity:.55}.tl-plugin-use{display:grid;grid-template-columns:96px minmax(0,1fr);gap:10px;align-items:center;width:100%;padding:6px 30px 6px 6px;border:0;background:none;color:#c8cec9;text-align:left;cursor:pointer;min-width:0;border-radius:10px}.tl-plugin-use:disabled{cursor:default}.tl-plugin-use:focus-visible{outline:2px solid #c6f432;outline-offset:-2px}.tl-plugin-thumb{position:relative;display:grid;place-items:center;aspect-ratio:16/9;border-radius:6px;overflow:hidden;background:#15181d}.tl-plugin-thumb img{width:100%;height:100%;object-fit:cover}.tl-plugin-thumb b{font-size:20px;color:#c6f432}.tl-plugin-thumb .spin{position:absolute;right:4px;bottom:4px}.tl-plugin-name{display:flex;flex-direction:column;gap:3px;min-width:0}.tl-plugin-name strong{font-size:12px;line-height:1.45;color:#e6e8ec;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.tl-plugin-name small{font-size:10.5px;color:#8f9a91}.tl-plugin-more{position:absolute;right:4px;top:6px;width:22px;height:22px;border:0;border-radius:6px;background:none;color:#8f9a91;cursor:pointer;font-size:14px;line-height:1}.tl-plugin-more:hover,.tl-plugin-more[aria-expanded=true]{background:#1c231c;color:#e6e8ec}.tl-plugin-menu{position:absolute;z-index:5;left:0;right:0;top:100%;margin-top:4px;display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid #38423a;border-radius:10px;background:#11161a;box-shadow:0 10px 24px #00000080}.tl-plugin-menu button{border:1px solid #2b3330;border-radius:7px;background:#161b1f;color:#e6e8ec;font-size:11.5px;padding:5px 8px;text-align:left;cursor:pointer}.tl-plugin-menu button:hover{border-color:#c6f43299}.tl-plugin-menu button.danger{color:#ff8f8f}.tl-plugin-review,.tl-plugin-recipe,.tl-plugin-inspector{display:flex;flex-direction:column;gap:8px;padding:10px;border:1px solid #c6f43255;border-radius:12px;background:#11160f}.tl-plugin-review.bad{border-color:#ff6b6b66;background:#1a1112}.tl-plugin-card{display:flex;flex-direction:column;gap:8px;min-width:0}.tl-plugin-card img{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:8px;background:#15181d}.tl-plugin-card>div{display:flex;flex-direction:column;gap:3px;min-width:0}.tl-plugin-card strong{font-size:13px;color:#e6e8ec;line-height:1.45}.tl-plugin-card small{font-size:10.5px;color:#8f9a91}.tl-plugin-checks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.tl-plugin-checks li{display:flex;gap:6px;font-size:11.5px;line-height:1.45;color:#c8cec9}.tl-plugin-checks li>span{flex:none;width:14px;text-align:center;font-weight:700}.tl-plugin-checks li.ok>span{color:#c6f432}.tl-plugin-checks li.warn>span{color:#ffc24b}.tl-plugin-checks li.bad{color:#ffb3b3}.tl-plugin-checks li.bad>span{color:#ff6b6b}.tl-plugin-checks small{color:#8f9a91}.tl-plugin-error{display:flex;flex-direction:column;gap:3px;margin:0;font-size:12px;line-height:1.5;color:#ffb3b3}.tl-plugin-error small{font:10.5px/1.4 ui-monospace,Menlo,monospace;color:#c99;word-break:break-word}.tl-plugin-note{font-size:12px;color:#ffd27a!important}.tl-plugin-step{display:flex;gap:8px;align-items:center;font-size:12px;color:#aab3ac;margin:0}.tl-plugin-review-actions{display:flex;gap:6px;flex-wrap:wrap}.tl-plugin-update{align-self:flex-start}.tl-plugin-params{display:flex;flex-direction:column;gap:7px}.tl-plugin-params .tl-motion-param{display:grid;grid-template-columns:minmax(0,42%) minmax(0,1fr);align-items:center;gap:8px;font-size:11.5px;color:#aab3ac;line-height:1.4}.tl-plugin-params .tl-motion-param.check{display:flex}.tl-plugin-params input[type=text],.tl-plugin-params textarea,.tl-plugin-params select,.tl-plugin-params input:not([type]){width:100%;min-width:0;box-sizing:border-box}.tl-plugin-image>span{display:flex;align-items:center;gap:6px;min-width:0}.tl-plugin-image img,.tl-plugin-image i{width:30px;height:30px;border-radius:6px;object-fit:cover;flex:none;background:#15181d;border:1px dashed #38423a}.tl-plugin-image button{font-size:11px}.tl-plugin-off summary{cursor:pointer;font-size:11.5px;color:#8f9a91;margin-bottom:6px}.tl-plugins-foot{font-size:10.5px;color:#8f9a91}.tl-warn{color:#ffc24b;font-size:11px}.tl-guide-backdrop{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:#050709b8;padding:16px}.tl-guide{display:flex;flex-direction:column;width:min(860px,100%);max-height:min(88vh,1000px);border:1px solid #2b3330;border-radius:14px;background:#0f1215;box-shadow:0 24px 60px #0009;overflow:hidden}.tl-guide-head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:10px 12px;border-bottom:1px solid #222a26}.tl-guide-head strong{flex:1 1 auto;font-size:13px;color:#e6e8ec}.tl-guide-head a{text-decoration:none}.tl-guide-body{overflow:auto;padding:6px 22px 22px;color:#c8cec9;font-size:13px;line-height:1.65}.tl-guide-body h2{font-size:20px;color:#e6e8ec;margin:16px 0 6px;line-height:1.4}.tl-guide-body h3{font-size:16px;color:#c6f432;margin:20px 0 6px;line-height:1.45}.tl-guide-body h4,.tl-guide-body h5{font-size:13.5px;color:#e6e8ec;margin:14px 0 4px;line-height:1.5}.tl-guide-body p{margin:6px 0}.tl-guide-body ul,.tl-guide-body ol{margin:4px 0;padding-left:22px}.tl-guide-body li{margin:2px 0}.tl-guide-body code{font:12px/1.5 ui-monospace,Menlo,monospace;background:#1a1f1c;border-radius:4px;padding:1px 4px;color:#e6e8ec}.tl-guide-body pre{background:#0a0d0b;border:1px solid #222a26;border-radius:8px;padding:10px 12px;overflow:auto}.tl-guide-body pre code{background:none;padding:0;font-size:11.5px}.tl-guide-body blockquote{margin:8px 0;padding:6px 12px;border-left:3px solid #c6f432;background:#121811;color:#c8cec9}.tl-guide-body a{color:#c6f432}.tl-guide-table{overflow:auto}.tl-guide-body table{border-collapse:collapse;margin:8px 0;font-size:12px}.tl-guide-body th,.tl-guide-body td{border:1px solid #2b3330;padding:5px 8px;text-align:left;vertical-align:top}.tl-guide-body th{background:#151a17;color:#e6e8ec}.ps-drawer .ad-grid{grid-template-columns:repeat(auto-fill,minmax(200px,1fr))}.ps-open{display:block;width:calc(100% - 16px);padding:0;border:0;cursor:pointer;background:#15181d}.ps-price{position:absolute;right:8px;top:8px;z-index:2;padding:4px 8px;border-radius:7px;background:#070907db;border:1px solid var(--border-strong);font-size:11px;font-weight:800;color:#f2f4f0;line-height:1.3}.ps-price.free{color:#0b1106;background:var(--accent);border-color:var(--accent)}.ps-price.owned{color:var(--accent)}.ps-sub{text-transform:none}.ps-n{margin-left:6px;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--accent);color:#0b1106;font-size:10.5px;font-weight:800;display:inline-grid;place-items:center}.ps-waiting{display:flex;gap:7px;align-items:center;margin-top:8px;font-size:11.5px;line-height:1.45;color:#ffd27a}.ps-waiting.bad{color:#ff9b9b}.ps-drawer .ad-use.ps-wait,.ps-drawer .ad-use.ps-wait:hover:not(:disabled){background:#1d2416;color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent);opacity:1}.ad-use.ps-big{flex:0 1 auto;padding:0 22px;height:40px}.ps-detail{width:min(760px,100%);max-height:calc(100% - 20px);overflow:auto}.ps-stage{position:relative;aspect-ratio:16/9;border-radius:10px;overflow:hidden;background:repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/16px 16px;margin-bottom:12px}.ps-stage canvas,.ps-stage img,.ps-stage video{width:100%;height:100%;object-fit:contain;display:block}.ps-stage-note{position:absolute;left:10px;bottom:10px;padding:4px 8px;border-radius:7px;background:#070907d1;color:#c8cec9;font-size:11px}.ps-info{display:flex;flex-direction:column;gap:8px}.ps-info p{margin:0;font-size:13px;line-height:1.55;color:#c8cec9}.ps-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.ps-row .ps-price{position:static}.ps-kind{font-size:12px;color:var(--text-muted)}.ps-params{font-size:12px!important;color:#aab3ac!important}.tl-plugins .spin,.ps-drawer .spin,.tl-guide .spin{display:inline-block;flex:none;width:10px;height:10px;border:2px solid #c6f43244;border-top-color:#c6f432;border-radius:50%;animation:plg-spin .8s linear infinite;vertical-align:-1px}.ps-waiting .spin{border-color:#ffd27a44;border-top-color:#ffd27a}@keyframes plg-spin{to{transform:rotate(360deg)}}.ps-drawer .ad-name{font-size:15px;line-height:1.45}.ps-drawer .ps-sub{font-size:12.5px;margin-top:4px}.ps-drawer .ad-notice{font-size:13px;line-height:1.5}.ps-drawer .ad-tab,.ps-drawer .ad-chip{font-size:13.5px}.ps-drawer .ad-search{font-size:14px}.ps-drawer .ad-use{font-size:14px;height:38px}.ps-drawer .ad-badge{font-size:10.5px}.ps-drawer .ps-price{font-size:13px;padding:5px 9px}.ps-drawer .ps-waiting{font-size:13px}.ps-drawer .ad-empty{font-size:14px}.ps-detail header b{font-size:17px}.ps-info p{font-size:14.5px!important;line-height:1.6!important}.ps-info .ps-params{font-size:13.5px!important}.ps-info .ps-kind{font-size:13.5px}.ps-info small{font-size:12.5px;line-height:1.5}.ps-stage-note{font-size:12.5px}.ps-drawer .ps-sub{align-items:center;gap:8px}.ps-drawer .ps-sub .ps-price{position:static;flex:none}.ps-drawer .ps-by{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tl-sfx-item.tl-sfx-plug{grid-template-columns:26px minmax(0,1fr) auto 26px}.tl-sfx-plug .tl-sfx-name small{font-size:10px;color:#8f9a91;line-height:1.35}.tl-sfx-loop{font-style:normal;color:#c6f432}.tl-sfx-plugins h5{color:#e6e8ec}.tl-plugin-use.on{outline:1px solid #c6f432;outline-offset:-1px}.tl-plugin-pack{margin-top:10px;padding:8px;border:1px solid var(--border,#2a2f36);border-radius:8px;background:#ffffff05}.tl-plugin-pack h5{margin:0 0 6px;font-size:12.5px;line-height:1.5;display:flex;flex-wrap:wrap;gap:6px;align-items:baseline;color:#e6e8ec}.tl-plugin-pack h5 small{font-weight:400;font-size:10.5px}.tl-plugin-pack .tl-sfx-list,.tl-plugin-sfx-list{list-style:none;margin:0;padding:0;display:grid;gap:2px;max-height:260px;overflow:auto}.tl-plugin-sfx-review{display:flex;flex-direction:column;gap:10px}.tl-plugin-sfx-list .tl-sfx-item{grid-template-columns:26px minmax(0,1fr) auto}.tl-plugin-wave,.ps-wave{display:flex;align-items:center;justify-content:center;gap:3px;width:100%;aspect-ratio:16/9;border-radius:8px;background:#15181d;padding:0 10%;box-sizing:border-box}.tl-plugin-wave i,.ps-wave i{display:block;flex:1 1 0;max-width:6px;border-radius:3px;background:#c6f432;opacity:.9}.ps-sounds-meta{margin-top:4px;font-size:12px;color:#c6f432;font-weight:600}.ps-sounds{display:flex;flex-direction:column;gap:10px;margin-bottom:12px}.ps-sounds-head{display:grid;grid-template-columns:160px minmax(0,1fr);gap:12px;align-items:center}.ps-sounds-head img,.ps-sounds-head .ps-wave{width:160px;aspect-ratio:16/9;object-fit:cover;border-radius:8px}.ps-sounds-head b{display:block;font-size:14px;color:#e6e8ec;margin-bottom:4px}.ps-sounds-head small{font-size:12.5px;line-height:1.5}.ps-sound-list{list-style:none;margin:0;display:grid;gap:2px;max-height:300px;overflow:auto;border:1px solid var(--border,#2a2f36);border-radius:8px;padding:4px}.ps-sound-list li{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:8px;align-items:center;padding:4px 6px;border-radius:6px;font-size:13px;line-height:1.5}.ps-sound-list li.on,.ps-sound-list li:hover{background:#ffffff0f}.ps-sound-list li.locked{opacity:.55}.ps-sound-list .ps-sound-name{display:grid;min-width:0}.ps-sound-list .ps-sound-name small{font-size:11px}.ps-sound-list .tl-sfx-play{width:26px;height:26px;border-radius:50%;border:1px solid var(--border,#2a2f36);background:transparent;color:#e6e8ec;font-size:10px;cursor:pointer}.ps-sound-list .tl-sfx-play:disabled{cursor:not-allowed}@media(max-width:560px){.ps-sounds-head{grid-template-columns:1fr}.ps-sounds-head img,.ps-sounds-head .ps-wave{width:100%}}.timeline-workspace .tl-sfx .tl-sfx-plugins .tl-sfx-list{max-height:220px}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins{flex:none}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins .tl-sfx-list{flex:none;max-height:176px;min-height:0}.timeline-workspace .tl-plugin-sfx-review .tl-sfx-list{max-height:240px}.tl-plugin-items{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:6px}.tl-plugin-item{display:flex;flex-direction:column;gap:4px;padding:6px;border:1px solid #283129;border-radius:8px;background:#0f130f;color:inherit;text-align:left;cursor:pointer;min-width:0}.tl-plugin-item:hover:not(:disabled){border-color:#c6f43299}.tl-plugin-item:disabled{opacity:.6;cursor:default}.tl-plugin-item .tl-plugin-thumb{width:100%;aspect-ratio:16/9;height:auto}.tl-plugin-item .tl-plugin-name strong{font-size:12px}.ps-open{position:relative}.ps-featured{position:absolute;left:8px;bottom:8px;padding:2px 8px;border-radius:999px;background:#c6f432;color:#0b0d0f;font-size:10.5px;font-weight:700;letter-spacing:.02em}.ps-featured-line{margin:0 0 6px;color:#c6f432;font-weight:600;font-size:12.5px}.ps-private{position:absolute;right:8px;top:8px;padding:2px 8px;border-radius:999px;background:#0b0d0fd1;color:#f4f5f7;border:1px solid rgba(255,255,255,.18);font-size:10.5px;font-weight:700}.ps-private-line{margin:0 0 6px;color:#f4f5f7;opacity:.85;font-weight:600;font-size:12.5px}.sfxlib{display:flex;flex-direction:column;gap:6px;min-height:0}.sfxlib-tools{display:flex;gap:8px;align-items:center}.sfxlib-tools .ad-search{flex:1;min-width:0}.sfxlib-tools .sfxlib-folder{flex:none;width:190px}.sfxlib-chip span{opacity:.6}.sfxlib-chip.on{background:var(--accent-soft);color:var(--accent);border-color:#b4e36a73}select.sfxlib-chip{appearance:none;padding-right:9px}.sfxlib-count{margin:0;font-size:11.5px;color:var(--text-muted)}.sfxlib-more{width:100%;margin-top:4px;min-height:30px;border-radius:8px;border:1px dashed var(--border-strong);background:transparent;color:var(--text-muted);cursor:pointer;font-size:12px}.sfxlib-more:hover:not(:disabled){color:var(--text);border-color:#b4e36a73}.sfxlib-list.locked .tl-sfx-name,.sfxlib-list.locked small{opacity:.5}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins .tl-sfx-list.sfxlib-list{max-height:none;flex:none}.sfxlib-store .ps-sound-list{max-height:340px;overflow:auto}.ps-stats{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12.5px;color:var(--text-muted);margin-bottom:4px}.ps-sounds-head .ps-stats b{display:inline;font-size:12.5px;margin:0;color:#e6e8ec}.ps-lib-prices{color:#8f9a91!important;font-weight:500!important}.ps-lib-buy-wrap{display:flex;flex-direction:column;gap:8px}.ps-lib-buy{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:8px}.ps-drawer .ps-lib-buy .ad-use{height:auto;padding:9px 12px;line-height:1.3}.ps-lib-buy .ad-use small{display:block;font-size:11.5px;font-weight:500;opacity:.75}.ps-drawer .ad-use.ps-alt{background:transparent;color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}.tl-sfx-plugins select.sfxlib-source{appearance:none;-webkit-appearance:none;width:100%;margin:0 0 8px;padding:7px 30px 7px 10px;border-radius:9px;border:1px solid var(--border-strong);color:var(--text);font-size:12px;font-weight:600;cursor:pointer;background:var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A8F98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center}.tl-sfx-plugins select.sfxlib-source:hover{border-color:#b4e36a73}.tl-sfx-plugins select.sfxlib-source:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.sfxlib-head{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:linear-gradient(135deg,#b4e36a1a,#b4e36a05 60%);border:1px solid rgba(180,227,106,.18)}.sfxlib-icon{flex:none;width:34px;height:34px;border-radius:9px;background:#11160d;border:1px solid rgba(180,227,106,.3);display:flex;align-items:center;justify-content:center;gap:2px}.sfxlib-icon i{display:block;width:2px;border-radius:1px;background:var(--accent)}.sfxlib-title{display:grid;min-width:0;flex:1;line-height:1.3}.sfxlib-title strong{font-size:12.5px;color:var(--text)}.sfxlib-title small{font-size:10.5px;color:var(--text-muted)}.sfxlib-badge{flex:none;font-size:10px;font-weight:700;padding:3px 7px;border-radius:999px;background:var(--accent-soft);color:var(--accent);white-space:nowrap}.sfxlib-badge.off{background:#e8b0631f;color:#f0c27e}.sfxlib-pass{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:#e8b06312;border:1px solid rgba(232,176,99,.28)}.sfxlib-pass-ic{flex:none;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;background:#e8b06329;font-size:13px}.sfxlib-pass-text{display:grid;gap:2px;min-width:0;flex:1}.sfxlib-pass-text b{font-size:11.5px;color:#f3d3a3;font-weight:700}.sfxlib-pass-text small{font-size:10.5px;line-height:1.4;color:#c9ad87}.sfxlib-renew{flex:none;border:0;border-radius:999px;padding:6px 12px;background:var(--accent);color:#0b1106;font-weight:700;font-size:11.5px;cursor:pointer}.sfxlib-renew:hover{filter:brightness(1.08)}.sfxlib-chips{display:flex;flex-wrap:nowrap;gap:5px;overflow-x:auto;scrollbar-width:none;padding-bottom:1px;mask-image:linear-gradient(90deg,#000 88%,transparent)}.sfxlib-chips::-webkit-scrollbar{display:none}.sfxlib-chip{flex:none;border:1px solid var(--border);background:var(--surface-2);color:var(--text-muted);border-radius:999px;padding:3px 10px;font-size:11px;cursor:pointer;white-space:nowrap}.sfxlib-chip:hover{color:var(--text);border-color:var(--border-strong)}.sfxlib-panel .sfxlib-count{padding:0 2px}.sfxlib-panel .sfxlib-more{border-style:solid;border-color:var(--border);background:var(--surface-2);border-radius:999px}.sfxlib-hint{display:block;margin:0 0 6px;font-size:11px}.tl-plugin-items.kit{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:7px}.tl-plugin-items.kit .tl-plugin-name strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}.tl-kit-badge{position:absolute;left:4px;top:4px;padding:1px 5px;border-radius:4px;background:#070907d1;font-size:9px;font-weight:800;letter-spacing:.04em;color:#c6f432;line-height:1.5}.tl-kit-badge.model{color:#7fe3ff}.tl-kit-badge.lut{color:#ffc24b}.tl-kit-controls{display:flex;flex-direction:column;gap:7px;padding:9px;margin:4px 0 8px;border:1px solid #2b3a2c;border-radius:10px;background:#0d120d}.tl-kit-controls h6{margin:0;font-size:11.5px;color:#e6e8ec;display:flex;justify-content:space-between;gap:8px;align-items:baseline;line-height:1.5}.tl-kit-controls h6 small{font-weight:500}.tl-kit-control{display:flex;flex-direction:column;gap:4px}.tl-kit-swatches{display:flex;gap:5px;flex-wrap:wrap;padding-left:calc(42% + 8px)}.tl-kit-swatches button{width:18px;height:18px;border-radius:5px;border:1px solid #38423a;padding:0;cursor:pointer}.tl-kit-swatches button.on{outline:2px solid #e6e8ec;outline-offset:1px}.tl-kit-controls>.pill-btn{align-self:flex-start}.tl-kit-chips{display:flex;flex-wrap:wrap;gap:5px;margin:0 0 7px}.tl-kit-chip{border:1px solid #38423a;background:transparent;color:#aab3ac;border-radius:999px;padding:2px 9px;font-size:11.5px;line-height:1.5;cursor:pointer}.tl-kit-chip span{opacity:.6}.tl-kit-chip.on{background:#c6f4321f;color:#c6f432;border-color:#c6f43273}.tl-plugin-subhead{margin:2px 0 0;font-size:11.5px;color:#c8cec9;font-weight:700}.tl-plugin-fact{min-width:0;overflow-wrap:anywhere}.tl-plugin-fact b{font-weight:600;color:#e6e8ec}.tl-plugin-linked{display:flex;flex-direction:column;gap:3px}.tl-plugin-link{align-self:flex-end;display:inline-flex;align-items:center;gap:3px;font-size:10px;line-height:1.5;color:#7fe3ff;border:1px solid #2a4a55;border-radius:999px;padding:0 6px;white-space:nowrap}.tl-plugin-asset select{min-width:0;flex:1}.tl-plugin-asset i{display:inline-grid;place-items:center;font-style:normal;color:#7fe3ff}.tl-plugin-assets{display:flex;flex-direction:column;gap:4px;border-top:1px solid #222a26;padding-top:8px}.tl-plugin-assets ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px;font-size:11px;color:#aab3ac}.tl-plugin-assets li{display:flex;justify-content:space-between;gap:6px}.tl-plugin-assets b{color:#c8cec9;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ps-drawer .ad-card{display:flex;flex-direction:column}.ps-drawer .ad-meta{flex:1;display:flex;flex-direction:column}.ps-drawer .ad-actions{margin-top:auto;padding-top:10px}.ps-kit-meta{font-size:12px;color:#c8cec9;line-height:1.5;margin-top:4px;min-height:3em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.ps-kit-meta b{color:#c6f432}.ps-items{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;margin:0 0 12px}.ps-items figure{margin:0;display:flex;flex-direction:column;gap:3px;min-width:0}.ps-items img,.ps-items .ph{width:100%;aspect-ratio:16/9;border-radius:6px;display:block;background:#15181d;object-fit:cover}.ps-items .ph{display:grid;place-items:center;color:#7fe3ff}.ps-items figcaption{font-size:10.5px;color:#aab3ac;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ps-lock{display:flex;gap:6px;align-items:center;font-size:12px;color:#aab3ac;padding:7px 10px;border:1px dashed #38423a;border-radius:8px}@media(max-width:720px){.ps-items{grid-template-columns:repeat(3,minmax(0,1fr))}}.ps-items-head{margin:0 0 6px;font-size:12px;color:#c8cec9}.tl-plugin-doc{display:flex;flex-direction:column;gap:6px}.tl-plugin-doc textarea{width:100%;min-height:180px;max-height:360px;box-sizing:border-box;resize:vertical;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#dfe6e0;background:#0b0f0a;border:1px solid #2a3328;border-radius:8px;padding:8px}.tl-plugin-hooks{margin-top:10px;padding:8px 10px;border:1px solid #2a3328;border-radius:12px;background:#0f130e;display:flex;flex-direction:column;gap:8px}.tl-plugin-hooks>summary{cursor:pointer;font-size:12px;color:#dfe6e0;display:flex;flex-wrap:wrap;gap:6px;align-items:baseline}.tl-plugin-hooks[open]>summary{margin-bottom:8px}.tl-plugin-hooks>small{display:block;margin-top:6px;line-height:1.45}.tl-plugin-hook-list{list-style:none;margin:0 0 8px;padding:0;display:flex;flex-direction:column;gap:6px}.tl-plugin-hook-list>li{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:space-between;padding:6px 8px;border-radius:8px;background:#141a13}.tl-plugin-hook-url{display:flex;flex-direction:column;min-width:0;flex:1 1 180px}.tl-plugin-hook-url code{font-size:11.5px;color:#c6f432;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tl-plugin-hook-url small{font-size:11px}.tl-plugin-hook-actions{display:flex;gap:4px;flex-wrap:wrap}.tl-plugin-hook-secret{flex-basis:100%;margin:2px 0 0;font-size:11.5px;color:#ffd27a;display:flex;flex-wrap:wrap;gap:6px;align-items:center}.tl-plugin-hook-secret code{word-break:break-all;color:#fff;background:#0b0f0a;padding:2px 6px;border-radius:6px}.tl-plugin-hook-add{display:flex;flex-direction:column;gap:6px}.tl-plugin-hook-add input[type=url]{width:100%;box-sizing:border-box}.tl-plugin-hook-events{display:flex;flex-wrap:wrap;gap:10px;font-size:11.5px;color:#aab3ac}.tl-plugin-hook-events label{display:flex;gap:4px;align-items:center}.ps-cmds{border:1px solid rgba(198,244,50,.25);border-radius:12px;background:#0d100c;padding:10px 12px}.ps-cmds-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;font-size:12px}.ps-cmds-head .muted{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ps-cmds pre{margin:0;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;color:#e6ffe0;white-space:pre-wrap;word-break:break-all;user-select:all}.ps-drawer .ad-actions{flex-wrap:wrap;align-items:center}.ad-use.ps-use,.ad-use.ps-use:hover:not(:disabled){background:#16210f;color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);opacity:1}.ad-use.ps-use:hover:not(:disabled){background:#1d2c12}.ps-reinstall{background:none;border:0;padding:4px 2px;color:var(--text-dim,#9aa39a);font-size:12.5px;text-decoration:underline;text-underline-offset:3px;cursor:pointer}.ps-reinstall:hover{color:var(--text,#e8ece8)}.ps-installed{margin-top:8px;padding:7px 10px;border-radius:10px;background:#16210f;color:var(--accent);font-size:13px;font-weight:600;animation:ps-pop .35s ease-out}@keyframes ps-pop{0%{transform:scale(.96);opacity:0}to{transform:none;opacity:1}}.tl-plugin-tile.flash{animation:tl-plugin-flash 1.6s ease-out 2}@keyframes tl-plugin-flash{0%{box-shadow:0 0 #c6f432aa}50%{box-shadow:0 0 0 6px #c6f43244}to{box-shadow:0 0 #c6f43200}}
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/thumb-Cs636sYt.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js","assets/vfxBackground-CHlCg8lb.js"])))=>i.map(i=>d[i]);
2
- import{_ as A}from"./titleFrameBudget-3MFHWIT6.js";import{fz as X,a as y,hY as K,hZ as oe,j as n,eh as ie,el as re}from"./remote-sTZauTqM.js";import{u as le,r as g,t as a}from"./api-BsKbf3l3.js";import{v as ce}from"./vfxTrack-CqiQDEYm.js";import{u as H}from"./store-BSSbvpzr.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const he=c=>{let h=0;for(let b=0;b<c.length;b++)h=Math.imul(h,31)+c.charCodeAt(b)|0;return String(h>>>0)},U=c=>he(JSON.stringify([c.items.filter(h=>h.kind==="fx"||h.trackAnchor||h.kind==="person"),c.shots.map(h=>[h.duration,h.fxTiming,h.objectKeys,h.position,h.target,h.lens,h.cameraKeys]),c.plate]));function de({entry:c}){const h=g.useRef(null),[b,M]=g.useState(!1);return g.useEffect(()=>{const f=h.current,j=f?.getContext("2d");if(!f||!j)return;let k=0,R=!1;return A(async()=>{const{drawThumb:x,thumbRestTime:$,thumbLoopLength:_}=await import("./thumb-Cs636sYt.js").then(S=>S.e);return{drawThumb:x,thumbRestTime:$,thumbLoopLength:_}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(({drawThumb:x,thumbRestTime:$,thumbLoopLength:_})=>{if(R)return;if(!b){x(j,c,$(c),f.width,f.height);return}const S=performance.now(),l=_(c),E=()=>{x(j,c,(performance.now()-S)/1e3%l,f.width,f.height),k=requestAnimationFrame(E)};k=requestAnimationFrame(E)}),()=>{R=!0,cancelAnimationFrame(k)}},[c,b]),n.jsx("canvas",{ref:h,width:128,height:72,"aria-hidden":"true",onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1)})}function Ne({clip:c,locked:h,ensureScene:b,openShot:M}){le();const f=H(e=>e.toast),[,j]=g.useState(0),[k,R]=g.useState(X[0].id),[x,$]=g.useState(""),[_,S]=g.useState(!1),[l,E]=g.useState(null),[G,V]=g.useState(0),[z,D]=g.useState({}),[B,J]=g.useState(""),d=c.vfxShot?.shotNodeId&&y()?.getNode(c.vfxShot.shotNodeId)?c.vfxShot.shotNodeId:null,P=d?y()?.getNode(d):null,p=P?.data?.shotScene??null,F=p?p.items.filter(e=>e.kind==="fx"):[],C=p?.items.find(e=>e.kind==="person"&&!e.hidden)??null,Q=p?.shots.find(e=>e.id===p.activeShot),Y=g.useMemo(()=>ce(c),[c]),O=!!p&&F.length>0&&P?.data?.vfxRenderHash!==U(p),Z=g.useMemo(()=>{const e=K(x).trim();return oe.filter(s=>e?K(`${s.name} ${s.desc} ${s.keywords} ${s.id}`).includes(e):s.category===k)},[k,x]),N=async(e,s,o)=>{const r=y()?.getNode(e),u=r?.data?.shotScene;if(!u)throw new Error(a("Cảnh VFX không còn trên Canvas"));let m=structuredClone(u);const{runTool:t}=await A(async()=>{const{runTool:v}=await import("./remote-sTZauTqM.js").then(L=>L.jq);return{runTool:v}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10])),i=await t(s,o,{getStage:()=>m,setStage:v=>{m=v(m)},engine:()=>null,timelineClip:v=>H.getState().clips.find(L=>L.id===v)});if(i.ok===!1)throw new Error(i.error||s);return y()?.updateNodeData(e,{shotScene:m}),j(v=>v+1),i},T=async(e,s)=>{if(h){f(a("Track đã khóa"),"error");return}E(e);try{await s()}catch(o){f(o.message,"error")}finally{E(null)}},W=e=>T(a("Đang thêm hiệu ứng"),async()=>{const s=d??b(c);if(!s)throw new Error(a("Không tạo được cảnh VFX"));const o=y()?.getNode(s)?.data?.shotScene,r=o.items.find(i=>i.kind==="person"&&!i.hidden),u=e.attach==="body"||e.attach==="hand"||e.attach==="gun",m=e.attach==="path"||e.attach==="sky",t=r?.position??[0,0,0];await N(s,"add_effect",{effect:e.id,vfx_layer:e.attach==="body"||e.attach==="ground"?"behind":"front",...r&&u?{attach_to:r.name,...e.attach!=="body"?{hand:"right"}:{}}:{},...r&&m?{from:`${r.name}.hand_right`,to:[t[0]+3,t[1]+1.2,t[2]]}:{}}),S(!1)}),w=(e,s)=>T(a("Đang cập nhật"),()=>N(d,"update_effect",{name:e.name,...s})),q=e=>{const s=p?.items.find(r=>r.trackAnchor?.effect===e.id);if(s)return{kind:"track",source:s.trackAnchor.source};const o=e.fx?.attach;return o&&C&&o.to===C.id?o.hand?{kind:"hand",side:o.hand==="L"?"left":"right"}:{kind:"body"}:{kind:"none"}},ee=(e,s)=>T(a("Đang gắn hiệu ứng"),async()=>{if(q(e).kind==="track"&&await N(d,"follow_track",{name:e.name,stop:!0}),s==="none"){e.fx?.attach&&await N(d,"update_effect",{name:e.name,attach_to:"none"});return}if(s==="body"||s==="hand-right"||s==="hand-left"){if(!C)throw new Error(a("Cảnh VFX không có người đứng thế"));await N(d,"update_effect",{name:e.name,attach_to:C.name,hand:s==="body"?"none":s==="hand-left"?"left":"right"});return}const[r,u,m]=s.split(":");await N(d,"follow_track",{name:e.name,source:r,...r==="object"?{object:u}:{},...r==="hand"?{side:u,point:m||"palm"}:{}})}),te=()=>T(a("Đang đọc người trong video"),async()=>{const{withBackgroundScene:e}=await A(async()=>{const{withBackgroundScene:r}=await import("./vfxBackground-CHlCg8lb.js");return{withBackgroundScene:r}},__vite__mapDeps([11,3,2,1,4,5,6,7,8,9,10])),s=Number(B),o=await e(d,r=>r.run("follow_plate",s>=8&&s<=300?{lens_mm:s}:{}),{timeoutMs:6e5});if(o.ok===!1)throw new Error(o.error||"follow_plate");j(r=>r+1),f(o.camera?a("Đã khớp camera ({0} mm, cao {1} m, nghiêng {2}°) và cho người đứng thế bám theo người trong video",[o.camera.lens_mm,o.camera.height_m.toFixed(2),o.camera.tilt_deg.toFixed(1)]):a("Người đứng thế đã bám theo người trong video"),"info")}),ne=()=>T(a("Đang render hiệu ứng"),async()=>{const{withBackgroundScene:e}=await A(async()=>{const{withBackgroundScene:t}=await import("./vfxBackground-CHlCg8lb.js");return{withBackgroundScene:t}},__vite__mapDeps([11,3,2,1,4,5,6,7,8,9,10])),{shotFps:s}=await A(async()=>{const{shotFps:t}=await import("./remote-sTZauTqM.js").then(i=>i.jk);return{shotFps:t}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10]));V(0);const o=y()?.getNode(d)?.data?.shotScene,r=o.shots.find(t=>t.id===o.activeShot),u=await e(d,t=>t.exportVfx({fps:s(r),height:720,vfxAlpha:"auto"},V),{timeoutMs:12e4});y()?.updateNodeData(d,{vfxRenderHash:U(y()?.getNode(d)?.data?.shotScene)}),j(t=>t+1);const m=u.passes.filter(t=>t.alpha).length;f(u.placed?m?a("Đã render {0} lớp hiệu ứng lên video ({1} lớp có kênh trong suốt cho khói / bụi)",[u.passes.length,m]):a("Đã render {0} lớp hiệu ứng lên video",[u.passes.length]):a("Đã render; video hiệu ứng nằm trên Canvas"),"info")}),I=Y.flatMap(e=>e.source==="hand"?["right","left"].flatMap(s=>["palm","index","pinch","wrist"].map(o=>({value:`hand:${s}:${o}`,label:`${a(s==="right"?"Tay phải (tracking)":"Tay trái (tracking)")} · ${a(o==="palm"?"lòng bàn tay":o==="index"?"ngón trỏ":o==="pinch"?"chỗ chụm":"cổ tay")}`}))):[{value:e.source==="object"?`object:${e.object}`:e.source,label:e.source==="object"?`${a("Vật thể 3D")} ${e.label.replace(/^Vật thể 3D /,"")}`:a(e.label)}]),ae=e=>e.kind==="none"?"none":e.kind==="body"?"body":e.kind==="hand"?`hand-${e.side}`:I.find(s=>s.value===e.source)?.value??I.find(s=>s.value.split(":")[0]===e.source.split(":")[0])?.value??e.source;return n.jsxs("div",{className:"tl-shotfx",children:[n.jsxs("div",{className:"tl-3d-row",children:[n.jsx("button",{className:"pill-btn",disabled:!!l,onClick:()=>S(e=>!e),children:_?a("Đóng kho hiệu ứng"):a("✦ Thêm hiệu ứng 3D")}),d&&n.jsx("button",{className:"pill-btn",disabled:!!l,onClick:()=>M(c),children:a("Mở trong 3D Shot")})]}),_&&n.jsxs("div",{className:"tl-shotfx-gallery",children:[n.jsx("input",{className:"tl-shotfx-search",placeholder:a("Tìm hiệu ứng (aura, sét, khói…)"),value:x,onChange:e=>$(e.target.value)}),!x&&n.jsx("div",{className:"tl-shotfx-cats",children:X.map(e=>n.jsx("button",{className:`tl-shotfx-cat${e.id===k?" on":""}`,onClick:()=>R(e.id),children:a(e.name)},e.id))}),n.jsx("div",{className:"tl-shotfx-grid",children:Z.slice(0,60).map(e=>n.jsxs("button",{className:"tl-shotfx-card",title:a(e.desc),disabled:!!l,onClick:()=>void W(e),children:[n.jsx(de,{entry:e}),n.jsx("span",{children:a(e.name)})]},e.id))})]}),F.length>0&&n.jsx("div",{className:"tl-shotfx-list",children:F.map(e=>{const s=ie(e,Q),o=q(e),r=re[e.fx.preset]?.params??[],u=(t,i)=>{D(v=>{const{[`${e.id}:${t}`]:L,...se}=v;return se}),w(e,t==="intensity"?{intensity:i}:{params:{[t]:i}})},m=(t,i)=>z[`${e.id}:${t}`]??i;return n.jsxs("div",{className:"tl-shotfx-item",children:[n.jsxs("div",{className:"tl-shotfx-head",children:[n.jsx("input",{type:"color",value:e.color,disabled:!!l,onChange:t=>void w(e,{color:t.target.value}),title:a("Màu")}),n.jsx("b",{children:e.name}),n.jsxs("select",{value:e.vfxLayer??"behind",disabled:!!l,onChange:t=>void w(e,{vfx_layer:t.target.value}),children:[n.jsx("option",{value:"behind",children:a("Sau người")}),n.jsx("option",{value:"front",children:a("Trước người")})]}),n.jsx("button",{className:"tl-shotfx-del",disabled:!!l,title:a("Xoá hiệu ứng"),onClick:()=>void T(a("Đang xoá"),()=>N(d,"remove_effect",{name:e.name})),children:"✕"})]}),n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a("Bám theo")}),n.jsxs("select",{value:ae(o),disabled:!!l,onChange:t=>void ee(e,t.target.value),children:[n.jsx("option",{value:"none",children:a("Đứng yên trong cảnh")}),C&&n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"body",children:a("Người (thân)")}),n.jsx("option",{value:"hand-right",children:a("Người · tay phải")}),n.jsx("option",{value:"hand-left",children:a("Người · tay trái")})]}),I.map(t=>n.jsx("option",{value:t.value,children:t.label},t.value))]})]}),n.jsxs("div",{className:"tl-shotfx-time",children:[n.jsxs("label",{children:[a("Bắt đầu")," ",n.jsx("input",{type:"number",min:0,step:.1,value:+s.start.toFixed(2),disabled:!!l,onChange:t=>void w(e,{start:Math.max(0,Number(t.target.value)||0)})})]}),n.jsxs("label",{children:[a("Dài")," ",n.jsx("input",{type:"number",min:.2,step:.1,value:+s.duration.toFixed(2),disabled:!!l,onChange:t=>void w(e,{duration:Math.max(.2,Number(t.target.value)||.2)})})]}),n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:s.loop,disabled:!!l,onChange:t=>void w(e,{loop:t.target.checked})})," ",a("Lặp")]})]}),n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a("Độ mạnh")}),n.jsx("input",{type:"range",min:.1,max:3,step:.05,value:m("intensity",e.fx.intensity),disabled:!!l,onChange:t=>D(i=>({...i,[`${e.id}:intensity`]:Number(t.target.value)})),onMouseUp:t=>u("intensity",Number(t.target.value)),onKeyUp:t=>u("intensity",Number(t.target.value))})]}),r.map(t=>t.type==="enum"?n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a(t.label??t.key)}),n.jsx("select",{value:String(e.fx.params[t.key]??t.def),disabled:!!l,onChange:i=>void w(e,{params:{[t.key]:i.target.value}}),children:(t.options??[]).map(i=>n.jsx("option",{value:i,children:i},i))})]},t.key):n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a(t.label??t.key)}),n.jsx("input",{type:"range",min:t.min,max:t.max,step:((t.max??1)-(t.min??0))/100,value:m(t.key,Number(e.fx.params[t.key]??t.def)),disabled:!!l,onChange:i=>D(v=>({...v,[`${e.id}:${t.key}`]:Number(i.target.value)})),onMouseUp:i=>u(t.key,Number(i.target.value)),onKeyUp:i=>u(t.key,Number(i.target.value))})]},t.key))]},e.id)})}),d&&C&&F.length>0&&n.jsxs("div",{className:"tl-3d-row",children:[n.jsx("button",{className:"pill-btn",disabled:!!l,onClick:()=>void te(),title:a("Đọc tư thế người trong video (miễn phí, trong trình duyệt): hiệu ứng gắn vào người sẽ chạy theo họ"),children:a("Bám người thật (tư thế)")}),n.jsx("input",{className:"tl-shotfx-lens",type:"number",min:8,max:300,step:1,value:B,disabled:!!l,placeholder:a("Ống kính mm"),title:a("Tiêu cự ống kính đã quay (mm, khổ phim 36 mm). Để trống: tự giả định 28 mm — ống kính chính của điện thoại"),onChange:e=>J(e.target.value)})]}),p?.plate?.match&&n.jsx("p",{className:"tl-vfx-hint",children:a("Camera đã khớp với video: {0} mm · cao {1} m · nghiêng {2}°",[p.plate.match.lens,p.plate.match.height.toFixed(2),p.plate.match.tilt.toFixed(1)])}),d&&F.length>0&&n.jsxs("div",{className:"tl-3d-row",children:[n.jsx("button",{className:`pill-btn${O?" on":""}`,disabled:!!l,onClick:()=>void ne(),children:l===a("Đang render hiệu ứng")?`${a("Đang render")} ${G}%`:O?a("▶ Render hiệu ứng lên video"):a("Render lại")}),O&&n.jsx("span",{className:"tl-shotfx-stale",children:a("Đã sửa, cần render lại")})]}),l&&l!==a("Đang render hiệu ứng")&&n.jsxs("p",{className:"tl-vfx-hint",children:[l,"…"]})]})}export{Ne as default,U as vfxSceneHash};
@@ -1 +0,0 @@
1
- import{j as c}from"./remote-sTZauTqM.js";import{r as p}from"./api-BsKbf3l3.js";import{gR as g}from"./titleFrameBudget-3MFHWIT6.js";import{d}from"./main-M1vRa-gd.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const f=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"];function G(){const m=p.useRef(null),[e,l]=p.useState(null);return p.useEffect(()=>{const r=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),n=t=>{if(!f.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;let i;try{i=g(t.data.transition)}catch(o){r(t,{type:"clipoox-transition-error",id:"id"in t.data?t.data.id:null,error:o.message});return}if(t.data.type==="clipoox-transition-play"){l(i);return}if(t.data.type==="clipoox-transition-thumb"){const o=Object.assign(document.createElement("canvas"),{width:640,height:360}),s=o.getContext("2d");d(s,i,Number.isFinite(t.data.p)?Number(t.data.p):.5,640,360),r(t,{type:"clipoox-transition-thumb",id:t.data.id,png:o.toDataURL("image/png")})}},a=t=>n(t);return window.addEventListener("message",a),window.parent?.postMessage({type:"clipoox-transition-ready"},"*"),()=>window.removeEventListener("message",a)},[]),p.useEffect(()=>{const r=m.current,n=r?.getContext("2d");if(!r||!n||!e)return;let a=0;const t=performance.now(),i=e.duration*1e3,o=600,s=u=>{const h=(u-t)%(i+2*o)-o;d(n,e,Math.max(0,Math.min(1,h/i)),r.width,r.height),a=requestAnimationFrame(s)};return a=requestAnimationFrame(s),()=>cancelAnimationFrame(a)},[e]),c.jsx("div",{style:{margin:0,background:"#000",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:c.jsx("canvas",{ref:m,width:1280,height:720,style:{width:"100%",height:"100%",objectFit:"contain"},"aria-label":"Transition preview"})})}export{G as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js"])))=>i.map(i=>d[i]);
2
- import{_ as et}from"./titleFrameBudget-3MFHWIT6.js";import{jh as U,iR as V,fh as B,gD as y,dy as b,fj as G,ji as at,iK as ot,hx as J,fA as it,fu as nt,fv as Q,fk as rt,hu as st,iP as ct}from"./remote-sTZauTqM.js";import{c as mt}from"./cameraPresets-B234aNzE.js";import"./api-BsKbf3l3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const C=()=>crypto.randomUUID(),u=o=>Math.round(o*100)/100,lt=o=>st(o)*(o.scale[1]||1);function W(o,c){const a=y(o),k=a.duration/c,e=l=>l?.map(i=>({...i,time:Math.min(1,i.time*k)})),s={...a,duration:c,cameraKeys:e(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([l,i])=>[l,e(i)||[]])),...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([l,i])=>[l,e(i)||[]]))}:{}};return{...o,shots:o.shots.map(l=>l.id===a.id?s:l)}}function z(o,c,a,k,e){const s=y(o),l=s.duration,i=(s.objectKeys?.[c.id]||[]).filter(p=>p.time*l<a-1e-6);return{...o,shots:o.shots.map(p=>p.id===s.id?{...p,objectKeys:{...p.objectKeys,[c.id]:[...i,{id:C(),time:a/l,position:k.map(_=>+_.toFixed(3)),rotation:[0,+e.toFixed(1),0],scale:c.scale}]}}:p)}}const X=(o,c)=>Math.atan2(c[0]-o[0],c[2]-o[2])*180/Math.PI;async function St(o,c){const a=U.find(t=>t.id===String(o.move??""));if(!a)return{ok:!1,error:`unknown move; use one of ${U.map(t=>t.id).join(", ")}`};const k=c.getStage();let e,s;try{e=V(k,String(o.name??""))}catch(t){return{ok:!1,error:t.message}}if(!B(e))return{ok:!1,error:`'${e.name}' is not a person`};const l=y(k),i=Math.max(0,Number(o.time??0)||0);if(o.target!=null)try{s=V(k,String(o.target))}catch(t){return{ok:!1,error:t.message}}else{const t=b(e,l,Math.min(1,i/l.duration)).position,m=k.items.filter(n=>n.id!==e.id&&B(n)&&!n.hidden).map(n=>{const r=b(n,l,Math.min(1,i/l.duration)).position;return{i:n,d:Math.hypot(r[0]-t[0],r[2]-t[2])}}).sort((n,r)=>n.d-r.d)[0];if(!m)return{ok:!1,error:"no target: put another person in the scene or give target"};s=m.i}const p=G(a.id),_=at(a.id);if(!p||!_)return{ok:!1,error:`the clip ${a.id} is missing`};const M=[];let h=k;i+p.duration+1.6>l.duration&&(h=W(h,Math.min(300,Math.ceil((i+p.duration+1.8)*10)/10)));let S=y(h),w=S.duration;const j=i+_.at,$=j+(a.ranged?a.travel??.6:0),g=b(e,{...S,flight:void 0},Math.min(1,i/w)).position,v=b(s,{...S,flight:void 0},Math.min(1,$/w)).position,F=X(g,v);let x=g;if(!a.ranged){const t=(_.dz+(a.reach??.8))*lt(e),m=Math.hypot(v[0]-g[0],v[2]-g[2])||1,n=(g[0]-v[0])/m,r=(g[2]-v[2])/m;x=[v[0]+n*t,g[1],v[2]+r*t];const f=Math.hypot(x[0]-g[0],x[2]-g[2]);if(f>.3&&i>.25){const d=Math.min(.8,Math.max(.2,f/6),i);h=z(h,e,i-d,g,F),M.push(`${e.name} closes ${u(f)} m in ${u(d)} s before the strike${f>3?" (for a longer approach play ac-superman-glide / ac-burst-dash before)":""}`)}}h=z(h,e,i,x,F);const H=(t,m,n)=>{const r=y(n),f=r.flight?.[t.id];return!!f?.length&&ct(f,Math.min(1,m/r.duration),r.duration).air>.5};a.land&&H(e,i,h)&&(S=y(h),w=S.duration,h={...h,shots:h.shots.map(t=>t.id===S.id?{...t,flight:{...t.flight,[e.id]:ot(t.flight?.[e.id],{time:j/w,on:!1})}}:t)},M.push(`${e.name} lands on the strike (flight off at ${u(j)} s)`));const O=J(h,e.id,p,{start:i/y(h).duration,newId:C,loop:!1});if(!O.ok)return{ok:!1,error:O.error};c.setStage(()=>O.stage);const{runTool:Y}=await et(async()=>{const{runTool:t}=await import("./remote-sTZauTqM.js").then(m=>m.jq);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),q=[];for(const t of a.fx){const m=t.at==="strike"?j:i,n={effect:t.fx,start:u(m),duration:t.duration,...t.params?{params:t.params}:{},...o.color?{color:o.color}:{}},r=it(t.fx)?.attach==="path",f=t.place==="self"?{...n,attach_to:e.name}:t.place==="target"?{...n,at:`${s.name}.chest`}:t.place==="trail"?{...n,from:`${e.name}.chest`,to:`${s.name}.chest`}:t.place==="path"?{...n,from:`${e.name}.hand_right`,to:`${s.name}.chest`}:r?{...n,from:`${e.name}.feet`,to:`${s.name}.feet`}:{...n,at:`${s.name}.feet`},d=await Y("add_effect",f,c);d.ok?q.push({effect:t.fx,start_s:u(m)}):M.push(`${t.fx}: ${String(d.error)}`)}const K=String(o.react??"hit");let T=null;if(K!=="none"){const t=H(s,$,c.getStage()),[m,n]=K==="block"?t?["ac-air-block",.16]:["xx-palm-shield",.22]:K==="evade"?t?a.heavy?["ac-backflip-evade",.3]:["ac-corkscrew-dodge",.2]:["xx-teleport",.26]:t?[a.heavy?"ac-air-knocked-spin":"ac-air-recoil",0]:[(a.heavy,"xx-knocked-flying"),0],r=Math.max(0,$-n),f=G(m);if(f){let d=c.getStage();const D=y(d),E=D.duration,L=b(s,{...D,flight:void 0},Math.min(1,r/E)).position,Z=b(e,D,Math.min(1,r/E)).position;d=z(d,s,r,L,X(L,Z)),r+f.duration+.3>E&&(d=W(d,Math.min(300,Math.ceil((r+f.duration+.4)*10)/10)));const P=J(d,s.id,f,{start:r/y(d).duration,newId:C,loop:!1});if(P.ok){if(c.setStage(()=>P.stage),T={motion:m,at_s:u(r)},K==="hit"&&o.timing!==!1){const I=y(c.getStage()),tt=nt(rt(I.timing,I.duration),[$],a.heavy?Q.heavy:Q.medium,I.duration);c.setStage(N=>({...N,shots:N.shots.map(R=>R.id===I.id?{...R,timing:tt??void 0}:R)}))}}else M.push(`${s.name} ${m}: ${P.error}`)}}const A=[];if(o.camera===!0){const t=[["wide-track",e,i,$+.2]];a.heavy&&t.push(["low-hero",s,$+.2,$+1.4]);for(const[m,n,r,f]of t){const d=mt(c.getStage(),{preset:m,subject:n.id,start:r,end:f});d.ok&&(c.setStage(()=>d.stage),A.push(`${m} ${u(r)}–${u(f)} s`))}}return{ok:!0,move:a.id,attacker:e.name,target:s.name,start_s:u(i),strike_s:u(j),impact_s:u($),end_s:u(i+p.duration),effects:q,...T?{reaction:T}:{},...A.length?{camera:A}:{},...M.length?{notes:M}:{}}}export{St as aerialStrike};
@@ -1 +0,0 @@
1
- import{u as v}from"./store-BSSbvpzr.js";import{t as S}from"./api-BsKbf3l3.js";import{am as A}from"./remote-sTZauTqM.js";import{ac as y,z as k,ad as I,l as P,w as _,y as j,H as F}from"./main-M1vRa-gd.js";import{runAnalyzerCode as R}from"./analyzerSandbox-DO5ZTv5q.js";import{e as E}from"./pluginAutomation-BtQ_w2TB.js";import"./titleFrameBudget-3MFHWIT6.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";async function $(t){const{plugins:o}=await P(),n=o.find(a=>a.id===t.id&&a.enabled);if(!n)throw _("use_missing",[t.id]);const r=t.item?await j(n,t.item):await F(n);if(r.manifest.kind!=="analyzer")throw _("use_plugin",[0,t.item?`${t.id}/${t.item}`:t.id],"not an analyzer plug-in");return r}async function H(t,o,n){if(window.__analyzerFramesStub)return window.__analyzerFramesStub(t,o);const r=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});r.src=t.url;try{await new Promise((l,h)=>{r.onloadeddata=()=>l(),r.onerror=()=>h(Error(S("Không đọc được video của clip (CORS / định dạng)")))});const a=r.videoWidth||1280,d=r.videoHeight||720,e=Math.min(o.width,a),s=Math.max(2,Math.round(e*d/a)),i=Object.assign(document.createElement("canvas"),{width:e,height:s}),m=i.getContext("2d",{willReadFrequently:!0}),p=t.playbackRate||1,b=t.inPoint||0,z=Math.min(t.duration,o.maxSeconds),c=Math.max(1,Math.floor(z*o.fps)),g=new Uint8Array(e*s*c);for(let l=0;l<c;l++){n?.aborted;const h=Math.max(0,Math.min(r.duration-1/60,b+l/o.fps*p));Math.abs(r.currentTime-h)>1e-4&&await new Promise((u,f)=>{const x=window.setTimeout(()=>f(Error(S("Seek video quá lâu"))),8e3);r.onseeked=()=>{window.clearTimeout(x),u()},r.currentTime=h}),m.drawImage(r,0,0,e,s);const w=m.getImageData(0,0,e,s).data,M=l*e*s;for(let u=0,f=0;u<w.length;u+=4,f++)g[M+f]=w[u]*77+w[u+1]*150+w[u+2]*29>>8}return{fps:o.fps,width:e,height:s,count:c,data:g,sourceWidth:a,sourceHeight:d}}finally{r.removeAttribute("src"),r.load()}}function O(t){const o=v.getState().timelineMedia.find(i=>t.gcsUri&&i.gcsUri===t.gcsUri||i.url===t.url),n=t.playbackRate||1,r=t.inPoint||0,a=i=>+((i-r)/n).toFixed(3),d=i=>a(i.end)>0&&a(i.start)<t.duration,e=(o?.words??[]).filter(d).slice(0,y.words).map(i=>({start:a(i.start),end:a(i.end),word:String(i.word).slice(0,60)})),s=(o?.pauses??[]).filter(d).map(i=>({start:a(i.start),end:a(i.end)}));return{words:e,pauses:s}}async function ut(t,o){const n=o.params??{};if(!n.plugin?.id)throw Error("runAnalyzer: no plug-in");if(t.kind!=="video"||!t.url)throw Error(S("Plug-in phân tích cần một clip video"));const r=await $(n.plugin),a=r.manifest,d=a.sample??{fps:y.fps.default,width:y.width.default,maxSeconds:y.maxSeconds.default},e=await H(t,d),s={clip:{duration:t.duration,width:e.sourceWidth,height:e.sourceHeight},frames:{fps:e.fps,width:e.width,height:e.height,count:e.count,data:e.data},...O(t),params:k(a,n.values??{})},i=I(await R(r.entry,s),t.id);if(!i.ops.length)return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:n.plugin.item?`${n.plugin.id}/${n.plugin.item}`:n.plugin.id,ops:0,summary:i.summary}),{};const m=A([t],i.ops);if(m.errors?.length)throw Error(String(m.errors[0]).slice(0,200));const p=m.clips.find(g=>g.id===t.id);if(!p)throw Error("runAnalyzer: the clip was lost");const{id:b,clientJobs:z,...c}=p;return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:n.plugin.item?`${n.plugin.id}/${n.plugin.item}`:n.plugin.id,ops:i.ops.length,summary:i.summary}),c}export{ut as runAnalyzerJob};
@@ -1 +0,0 @@
1
- import{trackPose as S}from"./poseTracker-DVX__OK7.js";import{ix as v,iy as w,iz as x}from"./remote-sTZauTqM.js";import{b$ as z,b_ as T}from"./titleFrameBudget-3MFHWIT6.js";import{u as q}from"./store-BSSbvpzr.js";import{t as l}from"./api-BsKbf3l3.js";import"./main-M1vRa-gd.js";import"./three.module-Bx43vjkH.js";import"./spark.module-BRT8yMS4.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";async function tt(p,f){const m=f.params??{},s=q.getState(),r=s.clips.find(t=>t.id===m.source);if(!r||r.kind!=="video")throw Error(l("Không tìm thấy clip video để bám dáng người"));const g=document.querySelector(`video[data-clip-media="${r.id}"]`)?.currentSrc||r.url,a=m.from??0,y=m.duration??p.duration,{frames:c,aspect:b}=await S({clip:r,url:g,from:a,duration:y,fps:v.fps,person:m.person??1});if(!c.some(t=>t.lm))throw Error(l("Không thấy người trong đoạn này để gắn aura"));const{width:u,height:d}=z(s.timelineFormat),k=Math.round(b*1e3),A=1e3,M=w(c.map(t=>({t:t.t,lm:t.lm})),([t,e])=>[t,e]).map(t=>{const e=a+t[0],n=[t[0]];for(let i=1;i<t.length;i+=2){if(t[i]<0){n.push(-1,-1);continue}const h=T(r,t[i],t[i+1],e,u,d,k,A);n.push(Math.round(h.px/u*1e3)/1e3,Math.round(h.py/d*1e3)/1e3)}return n}),o=p.motion?.params??{};return{motion:x(M,{look:o.look,color:o.color,hot:o.hot,size:o.size,intensity:o.intensity,wind:[Number(o.windX)||0,Number(o.windY)||0],speed:o.speed,stretch:o.stretch,taper:o.taper})}}export{tt as runAuraTrack};
@@ -1 +0,0 @@
1
- const s=()=>(typeof window<"u"?window.clipooxDesktop:void 0)??null,f=()=>s()?.media??null,w=()=>s()?.exportFile??null;async function p(i,c,a,n){const r=w();if(!r)throw Error("No desktop export bridge");const t=await r.begin(c.token,a,n);if(!t.ok||!t.id)throw Error(t.reason||"Cannot save here");try{for(let e=0;e<i.size;e+=d)if(!(await r.write(t.id,await i.slice(e,e+d).arrayBuffer())).ok)throw Error("Write failed");const o=await r.finish(t.id);if(!o.ok||!o.path)throw Error("Save failed");return{path:o.path,name:o.name||`${a}.${n}`}}catch(o){throw await r.abort(t.id).catch(()=>{}),o}}const d=8*1024*1024;export{s as desktop,w as exportFileBridge,f as localMediaBridge,p as saveExport};
@@ -1 +0,0 @@
1
- import{nh as I,_ as N}from"./titleFrameBudget-3MFHWIT6.js";import{a3 as B}from"./main-M1vRa-gd.js";import{t as S}from"./api-BsKbf3l3.js";import"./remote-sTZauTqM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const _=n=>+n.toFixed(4);function V(n){const i=n.length,h=n.map(e=>!!e),o=n.map((e,t)=>{if(e)return e.slice();for(let r=1;r<i;r++){const u=n[t-r],l=n[t+r];if(u)return[0,...u.slice(1)];if(l)return[0,...l.slice(1)]}return null});if(!o.some(Boolean))return[];const a=[];for(let e=0;e<i;e++){let t=0;const r=new Array(10).fill(0);let u=0,l=0;for(let d=-2;d<=2;d++){const s=e+d;if(s<0||s>=i)continue;const c=o[s],f=(h[s]?1:.15)*(3-Math.abs(d));t+=f;for(let w=0;w<10;w++)r[w]+=c[w+1]*f;u+=h[s]?c[0]:0,l++}const m=h[e]?n[e][0]:0;a.push([_(Math.min(m,u/l*1.25)),...r.map(d=>_(d/t))])}return a}const T=180/Math.PI;function R(n,i,h){const o=p=>[n[p][0]*i,n[p][1]*h,n[p][2]*i],a=(p,b)=>{const M=o(p),x=o(b);return[(M[0]+x[0])/2,(M[1]+x[1])/2,(M[2]+x[2])/2]},e=(p,b)=>[p[0]-b[0],p[1]-b[1],p[2]-b[2]],t=p=>Math.hypot(p[0],p[1],p[2]),r=a(33,133),u=a(362,263),l=Math.atan2(u[1]-r[1],u[0]-r[0]),m=p=>{const b=Math.cos(-l),M=Math.sin(-l);return[p[0]*b-p[1]*M,p[0]*M+p[1]*b,p[2]]},d=e(o(454),o(234)),s=e(o(152),o(10)),c=m(d),f=m(s),w=[(o(234)[0]+o(454)[0])/2,(o(10)[1]+o(152)[1])/2,(o(234)[2]+o(454)[2])/2];return{cx:w[0],cy:w[1],cz:w[2],w:t(d),h:t(s),roll:l*T,yaw:Math.atan2(c[2],c[0])*T,pitch:Math.atan2(-f[2],f[1])*T,eyes:[r,u],mouth:a(13,14)}}function U(n,i,h){const o=R(n,i,h),a=Math.PI/180,[e,t,r]=[-o.pitch*a,-o.yaw*a,-o.roll*a];return n.slice(0,468).map(u=>{let l=u[2]*i-o.cz;const m=(5*o.w+l)/(5*o.w);let d=(u[0]*i-o.cx)*m,s=(u[1]*h-o.cy)*m;return[d,s]=[d*Math.cos(r)-s*Math.sin(r),d*Math.sin(r)+s*Math.cos(r)],[d,l]=[d*Math.cos(t)-l*Math.sin(t),d*Math.sin(t)+l*Math.cos(t)],[s,l]=[s*Math.cos(e)+l*Math.sin(e),-s*Math.sin(e)+l*Math.cos(e)],[d/o.w,s/o.w,l/o.w]})}function H(n){const i=n.map(e=>({f:e,p:R(e.L,e.M,e.N)})),h=i.filter(e=>Math.abs(e.p.yaw)<25&&Math.abs(e.p.pitch)<25),o=(h.length?h:i).sort((e,t)=>Math.abs(e.p.yaw)+Math.abs(e.p.pitch)-Math.abs(t.p.yaw)-Math.abs(t.p.pitch)).slice(0,40),a=new Array(468*3).fill(0);for(const{f:e}of o)U(e.L,e.M,e.N).forEach((t,r)=>{a[r*3]+=t[0],a[r*3+1]+=t[1],a[r*3+2]+=t[2]});return a.map(e=>+(e/o.length).toFixed(3))}function G(n){const i=V(n.map(e=>e?e.slice(0,11):null));if(!i.length)return[];const h=n.length,o=n.map(e=>!!e),a=(e,t)=>{if(n[e])return n[e][t];for(let r=1;r<h;r++){const u=n[e-r],l=n[e+r];if(u)return u[t];if(l)return l[t]}return 0};return i.map((e,t)=>{const r=[11,12,13].map(u=>{let l=0,m=0;for(let d=-2;d<=2;d++){const s=t+d;if(s<0||s>=h)continue;const c=(o[s]?1:.15)*(3-Math.abs(d));l+=a(s,u)*c,m+=c}return+(l/m).toFixed(2)});return[...e,...r]})}function X(n){const i=n.map(a=>a.slice()),h=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(let a=0;a<50;a++){let e=0;for(let t=0;t<4;t++)for(let r=t+1;r<4;r++)e+=i[t][r]*i[t][r];if(e<1e-18)break;for(let t=0;t<4;t++)for(let r=t+1;r<4;r++){if(Math.abs(i[t][r])<1e-20)continue;const u=(i[r][r]-i[t][t])/(2*i[t][r]),l=Math.sign(u||1)/(Math.abs(u)+Math.sqrt(u*u+1)),m=1/Math.sqrt(l*l+1),d=l*m;for(let s=0;s<4;s++){const c=i[s][t],f=i[s][r];i[s][t]=m*c-d*f,i[s][r]=d*c+m*f}for(let s=0;s<4;s++){const c=i[t][s],f=i[r][s];i[t][s]=m*c-d*f,i[r][s]=d*c+m*f}for(let s=0;s<4;s++){const c=h[s][t],f=h[s][r];h[s][t]=m*c-d*f,h[s][r]=d*c+m*f}}}let o=0;for(let a=1;a<4;a++)i[a][a]>i[o][o]&&(o=a);return h.map(a=>a[o])}function $(n,i){const h=n.length,o=[0,0,0],a=[0,0,0];for(let g=0;g<h;g++)for(let E=0;E<3;E++)o[E]+=n[g][E]/h,a[E]+=i[g][E]/h;const e=[[0,0,0],[0,0,0],[0,0,0]];let t=0,r=0;for(let g=0;g<h;g++){const E=[0,1,2].map(D=>n[g][D]-o[D]),O=[0,1,2].map(D=>i[g][D]-a[D]);for(let D=0;D<3;D++)for(let z=0;z<3;z++)e[D][z]+=E[D]*O[z];t+=E[0]*E[0]+E[1]*E[1]+E[2]*E[2],r+=O[0]*O[0]+O[1]*O[1]+O[2]*O[2]}const[[u,l,m],[d,s,c],[f,w,p]]=e,b=[[u+s+p,c-w,f-m,l-d],[c-w,u-s-p,l+d,f+m],[f-m,l+d,-u+s-p,c+w],[l-d,f+m,c+w,-u-s+p]],[M,x,y,k]=X(b),F=[[M*M+x*x-y*y-k*k,2*(x*y-M*k),2*(x*k+M*y)],[2*(x*y+M*k),M*M-x*x+y*y-k*k,2*(y*k-M*x)],[2*(x*k-M*y),2*(y*k+M*x),M*M-x*x-y*y+k*k]],v=Math.sqrt(r/Math.max(1e-12,t)),A=[0,1,2].map(g=>a[g]-v*(F[g][0]*o[0]+F[g][1]*o[1]+F[g][2]*o[2]));return{R:F,s:v,t:A}}function Y(n){const i=Math.asin(Math.max(-1,Math.min(1,n[2][0])));return{pitch:Math.atan2(-n[2][1],n[2][2])*T,yaw:i*T,roll:Math.atan2(n[1][0],n[0][0])*T}}const q=n=>{const i=[];for(let h=0;h<n.length;h+=3)i.push([n[h],n[h+1],n[h+2]]);return i};function j(n,i,h,o){const a=R(n,i,h),e=q(o),t=5*a.w,r=n.slice(0,468).map(w=>{const p=w[2]*i-a.cz,b=(t+p)/t;return[a.cx+(w[0]*i-a.cx)*b,a.cy+(w[1]*h-a.cy)*b,p]}),{R:u,s:l,t:m}=$(e,r),d=Y(u),s=e[10],c=e[152],f=Math.hypot(c[0]-s[0],c[1]-s[1],c[2]-s[2])*l;return{cx:m[0],cy:m[1],w:l,h:f,...d,eyes:a.eyes,mouth:a.mouth}}function J(n,i,h,o){const a=R(n,i,h),e=5*o.w,t=Math.PI/180,[r,u,l]=[-o.pitch*t,-o.yaw*t,-o.roll*t];return n.slice(0,468).map(m=>{let d=m[2]*i-a.cz;const s=(e+d)/e;let c=(m[0]*i-a.cx)*s+a.cx-o.cx,f=(m[1]*h-a.cy)*s+a.cy-o.cy;return[c,f]=[c*Math.cos(l)-f*Math.sin(l),c*Math.sin(l)+f*Math.cos(l)],[c,d]=[c*Math.cos(u)-d*Math.sin(u),c*Math.sin(u)+d*Math.cos(u)],[f,d]=[f*Math.cos(r)+d*Math.sin(r),-f*Math.sin(r)+d*Math.cos(r)],[c/o.w,f/o.w,d/o.w]})}function Z(n){const i=n.filter(Boolean);if(!i.length)return{rows:n.map(()=>null),mesh:null};let h=H(i);for(let e=0;e<2;e++){const t=i.map(c=>({f:c,p:j(c.L,c.M,c.N,h)})),r=t.filter(c=>Math.abs(c.p.yaw)<25&&Math.abs(c.p.pitch)<25),u=(r.length?r:t).sort((c,f)=>Math.abs(c.p.yaw)+Math.abs(c.p.pitch)-Math.abs(f.p.yaw)-Math.abs(f.p.pitch)).slice(0,40),l=new Array(468*3).fill(0);for(const{f:c,p:f}of u)J(c.L,c.M,c.N,f).forEach((w,p)=>{l[p*3]+=w[0],l[p*3+1]+=w[1],l[p*3+2]+=w[2]});const m=q(l.map(c=>c/u.length)),d=[(m[234][0]+m[454][0])/2,(m[10][1]+m[152][1])/2,(m[234][2]+m[454][2])/2],s=Math.hypot(m[454][0]-m[234][0],m[454][1]-m[234][1],m[454][2]-m[234][2]);h=m.flatMap(c=>[0,1,2].map(f=>+((c[f]-d[f])/s).toFixed(3)))}const o=e=>Math.max(-89,Math.min(89,e));return{rows:n.map(e=>{if(!e)return null;const t=j(e.L,e.M,e.N,h),{M:r,N:u}=e;return[1,_(t.cx/r),_(t.cy/u),_(t.w/r),_(t.h/u),_(t.eyes[0][0]/r),_(t.eyes[0][1]/u),_(t.eyes[1][0]/r),_(t.eyes[1][1]/u),_(t.mouth[0]/r),_(t.mouth[1]/u),+o(t.yaw).toFixed(2),+o(t.pitch).toFixed(2),+t.roll.toFixed(2)]}),mesh:h}}const K=`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${B}/wasm`,Q="/models/blaze_face_short_range.tflite",tt=640,W=10;let L=null;function nt(){if(typeof window<"u"&&window.__faceDetectorStub){const n=window.__faceDetectorStub;return Promise.resolve(n)}return L??=(async()=>{const{FilesetResolver:n,FaceDetector:i}=await N(async()=>{const{FilesetResolver:a,FaceDetector:e}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:a,FaceDetector:e}},[]),h=await n.forVisionTasks(K),o=await i.createFromOptions(h,{baseOptions:{modelAssetPath:Q,delegate:"CPU"},runningMode:"VIDEO",minDetectionConfidence:.5});return(a,e)=>o.detectForVideo(a,e).detections.map(t=>{const r=t.boundingBox,u=a.width,l=a.height;return{x:r.originX/u,y:r.originY/l,w:r.width/u,h:r.height/l,score:t.categories[0]?.score??0,keypoints:t.keypoints.map(m=>({x:m.x,y:m.y}))}})})().catch(n=>{throw L=null,n}),L}const P=n=>+n.toFixed(4);function et(n,i){const h=n.filter(o=>o.keypoints.length>=4);if(!h.length)return null;if(i){const o=e=>Math.hypot(e.x+e.w/2-i[1],e.y+e.h/2-i[2]),a=h.reduce((e,t)=>o(e)<o(t)?e:t);if(o(a)<Math.max(i[3],i[4])*1.5)return a}return h.reduce((o,a)=>o.w*o.h>a.w*a.h?o:a)}const ot=n=>[P(Math.min(1,n.score)),P(n.x+n.w/2),P(n.y+n.h/2),P(n.w),P(n.h),P(n.keypoints[0].x),P(n.keypoints[0].y),P(n.keypoints[1].x),P(n.keypoints[1].y),P(n.keypoints[3].x),P(n.keypoints[3].y)];async function at({clip:n,url:i,fps:h=W,signal:o,onProgress:a}){if(n.kind!=="video")throw Error(S("Chỉ nhận diện khuôn mặt được trên clip video"));const e=await nt(),t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=i;try{await new Promise((y,k)=>{t.onloadeddata=()=>y(),t.onerror=()=>k(Error(S("Không đọc được video để nhận diện khuôn mặt (CORS / định dạng)")))});const r=t.videoWidth,u=t.videoHeight,l=Math.min(tt,r),m=Math.max(2,Math.round(l*u/r)),d=n.inPoint||0,s=n.duration*(n.playbackRate||1);let c=h;for(;Math.ceil(s*c)+1>I&&c>.2;)c/=2;const f=Math.min(I,Math.max(1,Math.ceil(s*c)+1)),w=Object.assign(document.createElement("canvas"),{width:l,height:m}),p=w.getContext("2d",{willReadFrequently:!0}),b=[];let M=null;for(let y=0;y<f;y++){if(o?.aborted)throw new DOMException("Đã huỷ","AbortError");const k=Math.max(0,Math.min(t.duration-1/60,d+y/c));Math.abs(t.currentTime-k)>1e-4&&await new Promise((A,g)=>{const E=window.setTimeout(()=>g(Error(S("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(E),A()},t.currentTime=k}),p.drawImage(t,0,0,l,m);const F=et(e(w,y+1),M),v=F?ot(F):null;b.push(v),v&&(M=v),a?.({done:y+1,total:f}),y%4===3&&await new Promise(A=>setTimeout(A,0))}const x=V(b);if(!x.length)throw Error(S("Không thấy khuôn mặt nào trong clip này (cần mặt nhìn rõ, không quá nhỏ)."));return{v:1,mw:r,mh:u,fps:+c.toFixed(4),s0:+d.toFixed(4),n:x.length,f:x}}finally{t.removeAttribute("src"),t.load()}}const rt="/models/face_landmarker.task";let C=null;function it(){if(typeof window<"u"&&window.__faceLandmarkerStub){const n=window.__faceLandmarkerStub;return Promise.resolve(n)}return typeof window<"u"&&window.__faceDetectorStub?Promise.reject(Error("No 3D face model on this page")):(C??=(async()=>{const{FilesetResolver:n,FaceLandmarker:i}=await N(async()=>{const{FilesetResolver:a,FaceLandmarker:e}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:a,FaceLandmarker:e}},[]),h=await n.forVisionTasks(K),o=await i.createFromOptions(h,{baseOptions:{modelAssetPath:rt,delegate:"CPU"},runningMode:"IMAGE",numFaces:3,minFaceDetectionConfidence:.35,minFacePresenceConfidence:.35});return a=>o.detect(a).faceLandmarks.map(e=>e.map(t=>[t.x,t.y,t.z]))})().catch(n=>{throw C=null,n}),C)}let ct=null;const It=()=>ct??=N(()=>import("./vision_bundle-9zIsgJJP.js"),[]).then(n=>n.FaceLandmarker.FACE_LANDMARKS_TESSELATION.map(i=>[i.start,i.end]));function st(n,i){if(!n.length)return null;const h=o=>{const a=o.map(t=>t[0]),e=o.map(t=>t[1]);return[(Math.min(...a)+Math.max(...a))/2,(Math.min(...e)+Math.max(...e))/2,Math.max(...a)-Math.min(...a)]};if(i){const o=e=>{const t=h(e);return Math.hypot(t[0]-i[1],t[1]-i[2])},a=n.reduce((e,t)=>o(e)<o(t)?e:t);if(o(a)<i[3]*1.5)return a}return n.reduce((o,a)=>h(o)[2]>h(a)[2]?o:a)}function ht(n,i,h,o,a,e,t){a.getContext("2d").drawImage(i,0,0,h,o);const u=n(a,t);if(u.length)return u;const l=e.getContext("2d"),m=[];for(const[d,s]of[[0,0],[.5,0],[0,.5],[.5,.5],[.25,.25]]){l.drawImage(a,d*h,s*o,h/2,o/2,0,0,e.width,e.height);for(const c of n(e,t))m.push(c.map(([f,w,p])=>[d+f/2,s+w/2,p/2]));if(m.length)break}return m}async function lt({clip:n,url:i,fps:h=W*1.5,signal:o,onProgress:a}){if(n.kind!=="video")throw Error(S("Chỉ nhận diện khuôn mặt được trên clip video"));const e=await it(),t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=i;try{await new Promise((F,v)=>{t.onloadeddata=()=>F(),t.onerror=()=>v(Error(S("Không đọc được video để nhận diện khuôn mặt (CORS / định dạng)")))});const r=t.videoWidth,u=t.videoHeight,l=Math.min(960,r),m=Math.max(2,Math.round(l*u/r)),d=n.inPoint||0,s=n.duration*(n.playbackRate||1);let c=h;for(;Math.ceil(s*c)+1>I&&c>.2;)c/=2;const f=Math.min(I,Math.max(1,Math.ceil(s*c)+1)),w=Object.assign(document.createElement("canvas"),{width:l,height:m}),p=Object.assign(document.createElement("canvas"),{width:l,height:m}),b=[];let M=null;for(let F=0;F<f;F++){if(o?.aborted)throw new DOMException("Đã huỷ","AbortError");const v=Math.max(0,Math.min(t.duration-1/60,d+F/c));Math.abs(t.currentTime-v)>1e-4&&await new Promise((g,E)=>{const O=window.setTimeout(()=>E(Error(S("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(O),g()},t.currentTime=v});const A=st(ht(e,t,l,m,w,p,F+1),M);if(b.push(A?{L:A,M:r,N:u}:null),A){const g=R(A,r,u);M=[1,g.cx/r,g.cy/u,g.w/r]}a?.({done:F+1,total:f}),F%3===2&&await new Promise(g=>setTimeout(g,0))}const{rows:x,mesh:y}=Z(b),k=G(x);if(!k.length||!y)throw Error(S("Không thấy khuôn mặt nào trong clip này (cần mặt nhìn rõ, không quá nhỏ)."));return{v:2,mw:r,mh:u,fps:+c.toFixed(4),s0:+d.toFixed(4),n:k.length,f:k,mesh:y}}finally{t.removeAttribute("src"),t.load()}}async function Lt(n){try{return await lt(n)}catch(i){if(i.name==="AbortError")throw i;return at(n)}}export{It as faceMeshEdges,ot as faceSample,et as pickFace,V as smoothFaces,at as trackFace,lt as trackFace3D,Lt as trackFaceBest};
@@ -1 +0,0 @@
1
- import{fx as Q,gD as V,iX as tt,iY as T,iZ as et,i_ as U,i$ as H,j0 as ot,j1 as st,j2 as nt,dx as it,ip as at,hu as rt,j3 as ct,j4 as mt}from"./remote-sTZauTqM.js";import{N as L}from"./rigTrack-Bx9QHlFv.js";import"./api-BsKbf3l3.js";import"./titleFrameBudget-3MFHWIT6.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";const ft=()=>crypto.randomUUID(),N=C=>Math.round(C*1e3)/1e3;function xt(C,l){const v=Q(C,{fighters:l.fighters,start:l.start,end:l.end,focal_length_mm:l.focal_length_mm}),y=v.stage,k=V(y),c=k.duration,[h,g]=l.fighters.map(t=>y.items.find(e=>e.name===t)),{start:A,end:j}=v.result,b=tt(l.beats,A,j),D=t=>{const e=it(k,Math.max(0,Math.min(1,t/c)));return{position:[...e.position],target:[...e.target],lens:e.lens}},M=(t,e)=>{const m=at(y,t,e);return{key:{pose:m.pose,position:m.position,yaw:m.rotation[1]},scale:rt(m)}},X=(t,e)=>{const m=t.attacker===h.name?h:g,w=m===h?g:h,f=M(m,e),s=M(w,e),x=t.limb&&/^(hand|foot)[LR]$/.test(t.limb)?t.limb:"handR",n=ct(f.key,x,f.scale),i=mt(s.key,s.scale),p=i.head.a.map((P,G)=>P+(i.head.b[G]-P)*.75),a=s.key.position[0]-f.key.position[0],r=s.key.position[2]-f.key.position[2],o=Math.hypot(a,r)||1,d=[a/o,0,r/o],u=[d[2],0,-d[0]],_=D(e).position,K=(f.key.position[0]+s.key.position[0])/2,Z=(f.key.position[2]+s.key.position[2])/2,O=(_[0]-K)*u[0]+(_[2]-Z)*u[2]>=0?1:-1,q=[Math.sin(s.key.yaw*Math.PI/180),0,Math.cos(s.key.yaw*Math.PI/180)];return{contact:n,foot:x.startsWith("foot"),atk:f.key.position,def:s.key.position,defHead:p,defFace:q,axis:d,side:[u[0]*O,0,u[2]*O],sep:o}},I=(t,e)=>({id:ft(),time:t/c,position:e.position.map(N),target:e.target.map(N),lens:Math.round(e.lens*100)/100,roll:0}),B=t=>t.time*c>=A-1e-6&&t.time*c<=j+1e-6,$=(k.cameraKeys||[]).filter(B),J=(k.cameraKeys||[]).filter(t=>!B(t)),R=[];for(const t of b){const e=t.to-.001;if(t.kind==="wide"||!t.beat){R.push(I(t.from,D(t.from)),...$.filter(n=>n.time*c>t.from+1e-6&&n.time*c<e-1e-6),I(e,D(e)));continue}const m=t.kind==="insert"?t.beat.time:Math.min(e,t.beat.time+(t.kind==="reaction"?.15:.6)),w=[];for(let n=t.from;n<=e+1e-6;n+=1/30)for(const i of[h,g]){const p=M(i,n),a=L(p.key.pose,p.key.position,p.key.yaw,p.scale);w.push(...Object.values(a))}const f=X(t.beat,m);let s=T(t.kind,f);if(t.kind==="insert"){const n=[];for(const p of[-2/30,0,2/30])for(const a of[h,g]){const r=M(a,m+p),o=L(r.key.pose,r.key.position,r.key.yaw,r.scale);n.push(...Object.values(o));for(const[d,u]of[["headA","headB"],["torsoA","torsoB"]])o[d]&&o[u]&&n.push(o[d].map((_,K)=>(_+o[u][K])/2))}let i=null;for(const p of et){const a=U(T("insert",f,{...H,insertAxis:p}),w),r=a.near??1/0,o=r>=H.clearance-1e-6,d=ot(a.position,a.target,n);(!i||o&&!i.ok||o===i.ok&&(o?d<i.n:r>i.near))&&(i={ok:o,n:d,near:r,cam:a})}s=i.cam}const x=t.kind==="insert"?s:U(s,w);R.push(I(t.from,x),I(e,x))}const S=[...J,...R].sort((t,e)=>t.time-e.time),z=S[0],F=S[S.length-1],W=b.map(t=>({from:t.from/c,to:t.to/c,kind:t.kind,frames:t.kind==="insert"&&t.beat?[t.beat.attacker]:t.kind==="reaction"&&t.beat?[t.beat.target]:[h.name,g.name]})),Y=(k.cuts||[]).filter(t=>t.to*c<=A+1e-6||t.from*c>=j-1e-6),E={...k,cameraKeys:S,position:z.position,target:z.target,lens:z.lens,endPosition:F.position,endTarget:F.target,endLens:F.lens,cuts:[...Y,...W].sort((t,e)=>t.from-e.from)};return{stage:{...y,items:nt(y.items,E),shots:y.shots.map(t=>t.id===k.id?E:t)},result:{ok:!0,fighters:[h.name,g.name],start:A,end:j,cuts:b.length-1,shots:b.map(t=>({kind:t.kind,from:+t.from.toFixed(2),to:+t.to.toFixed(2)})),stats:st(b,l.beats),method:"the two-shot cut on the beats: a close-up on the striking limb from 0.08 s before each impact, a reaction over the striker's shoulder after it, the wide between, the finisher held low and still (shared/fightDirector.js, measured on a reference fight)"}}}export{xt as fightDirector};
@@ -1,189 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/titleFrames-w-iWje9N.js","assets/titleFrameBudget-3MFHWIT6.js","assets/titleArt-CcTdJuOC.js","assets/textAnimators-Cihw35O8.js","assets/lottieLayer-CfUPParC.js","assets/rigTrack-Bx9QHlFv.js","assets/api-BsKbf3l3.js","assets/frameSink-Dj71jCRb.js","assets/timeline3dExport-CmSI_pjv.js","assets/timeline3d-BEuZZOxM.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/rotoMatte-DyXlW4jK.js","assets/store-BSSbvpzr.js","assets/captionLayout-CNgb471H.js"])))=>i.map(i=>d[i]);
2
- import{b$ as Ro,U as qt,eQ as Io,eO as io,cK as Co,au as Xo,f7 as Oo,lg as zo,hR as $t,iM as Go,_ as Pt,ii as ro,aq as qo,lh as Qt,aR as $o,aP as ao,hZ as jo,h_ as Ho,li as no,en as Vo,e_ as so,cb as Zt,cd as Yo,fD as Ko,f8 as jt,f6 as Wo,W as Jt,eG as co,eI as lo,eH as fo,cS as Ht,eK as Qo,dU as uo,lj as Zo,cc as Jo,f0 as ei,fw as ti,e$ as oi,hT as ii,er as Vt,jS as ri,eA as mo,ez as ai,lk as ni,ll as si,b2 as ci,aQ as li,lm as fi,ln as ui,lo as mi,bF as pi,aG as _o,lp as xi,h as Fo,lq as di,lr as vi,ef as hi,eg as bi,ai as Ei,ls as gi,eB as Ti,eC as wi,eD as yi,ex as Ri,eE as _i,lt as Fi,fh as Ai,co as Mi,i1 as Si,lu as Di,hX as ki,eF as po,lv as Ui,V as Pi,X as Bi,a0 as xo,lw as vo,Y as ho,an as Ni,lx as Li,ei as Ii,a2 as Ci,a3 as Xi,ly as Oi,a4 as zi,eh as Gi,a5 as qi,ab as $i,aa as ji,a8 as Hi,a6 as Mt,eL as Vi,ej as Yi,lz as Ki,lA as Wi}from"./titleFrameBudget-3MFHWIT6.js";import{b as Qi,e as Zi,a as Ji}from"./timelineComp-CRRzLazc.js";import{l as ot,f as Bt,p as Nt,s as bo,w as It,r as er,a as Lt,t as tr,n as or,g as Ao,b as Eo,c as Mo,d as ir}from"./gpuCompose-DIxBHlTa.js";import{t as rr}from"./motionBlur-uAm030t9.js";import{f as ar,h as So,z as nr,L as sr,d as cr,c as lr,l as fr,b as ur}from"./exportEncode-CaKEPgsy.js";import{c as mr}from"./distortGL-BklPDXPq.js";import{c as eo,V as pr,a as xr,I as dr,A as vr,U as hr,b as br}from"./id3-BCR9Bqgo.js";import{S as go,B as Er,O as gr,M as Tr,a as wr,C as yr,A as Rr}from"./output-BwZzMbp-.js";import"./api-BsKbf3l3.js";const Ct=48e3,Do=192e3,_r=4,ko=(v,y)=>y?.name==="AbortError"||v>=_r?null:Math.min(2**(v-1),4);async function Fr(v,y){for(let R=1;;R++){let e;try{e=await fetch(v,{signal:y})}catch(z){const h=y?.aborted?null:ko(R,z);if(h===null)throw z;await new Promise(N=>setTimeout(N,h*1e3));continue}if(!e.ok)throw Error(`media ${e.status}`);return e.blob()}}const Uo=()=>xr("aac",{numberOfChannels:2,sampleRate:Ct,bitrate:Do}).catch(()=>!1),Fa=async(v,y)=>await eo("avc",{width:v,height:y}).catch(()=>!1)&&Uo(),Aa=(v,y)=>eo("hevc",{width:v,height:y}).catch(()=>!1);async function Ma(v,y){try{const{width:R,height:e,fps:z}=Ro(v),h=y?.codec==="hevc";return typeof VideoEncoder>"u"||typeof AudioEncoder>"u"||typeof OfflineAudioContext>"u"||!new OffscreenCanvas(2,2).getContext("webgl2")||!(await VideoEncoder.isConfigSupported({codec:h?"hvc1.1.6.L153.B0":"avc1.640034",width:R,height:e,bitrate:So(y,{width:R,height:e,fps:z},Ao),framerate:z,hardwareAcceleration:"prefer-hardware"})).supported?!1:await eo(h?"hevc":"avc",{width:R,height:e})&&await Uo()}catch{return!1}}class Ar{frames=new Map;async push(y,R,e){let z=this.frames.get(R);z||(z=[],this.frames.set(R,z)),z.push(e)}}async function To(v,y,R,e,z,h,N){const A=y.get(R.url);if(!A)return null;if(_o(R)&&!R._still){const I=`${R.id}
3
- remap
4
- ${h}`,X=Math.round((e-h)*z);let $=v.get(I);if(!$){const te=A.samplesAtTimestamps(xi(R,h-R.start,Math.max(1,Math.round(N*z)),z))[Symbol.asyncIterator]();$={iterator:te,peek:null,current:null,ts0:0,idx:0,next:async()=>{const oe=await te.next();return oe.done?null:oe.value}},v.set(I,$)}for(;($.idx??0)<=X;){const te=await $.iterator.next();if($.idx=($.idx??0)+1,te.done)break;te.value&&te.value!==$.current&&($.current?.close(),$.current=te.value)}return $.current}const ee=!!(R._still||R.freeze),ie=ee?1:R.playbackRate||1,ae=!ee&&Fo(R),me=ae?di(R,h,N).start:(R.inPoint||0)+(ee?0:(h-R.start)*ie),de=`${R.id}
5
- ${ee?"still":h}`;let p=v.get(de);if(!p){const I=A.samples(Math.max(0,me-.5))[Symbol.asyncIterator]();if(p={iterator:I,peek:null,current:null,ts0:me,next:async()=>{const X=await I.next();return X.done?null:X.value}},p.peek=await p.next(),!ee){for(;p.peek&&p.peek.timestamp<me-1e-4;)p.peek.close(),p.peek=await p.next();p.ts0=p.peek?.timestamp??me}if(ae){const X=O=>Number(O.toFixed(6)),$=h-R.start,te=vi(R,$,$+N),oe=te.slice(0,-1).map(([O,_e],Te)=>{const[Oe,we]=te[Te+1];return{xa:X(O),dx:X(Oe-O),k:Oe-O>1e-9?X((we-_e)/(Oe-O)):0}}).filter(O=>O.dx>1e-9);p.out=O=>oe.reduce((_e,Te)=>_e+Math.min(Te.dx,Math.max(0,O-Te.xa))*Te.k,0)}v.set(de,p)}if(ee){const I=Math.round(me*z);for(;p.peek&&Math.round(p.peek.timestamp*z)<=I;)p.current?.close(),p.current=p.peek,p.peek=await p.next();return p.current??p.peek}const T=Math.round((e-h)*z),_=I=>p.out?p.out(I-p.ts0):(I-p.ts0)/ie;for(;p.peek&&Math.round(_(p.peek.timestamp)*z)<=T;)p.current?.close(),p.current=p.peek,p.peek=await p.next();return p.current??p.peek}const Mr=`#version 300 es
6
- in vec2 p;uniform vec4 dst;uniform vec4 src;out vec2 uv;
7
- void main(){uv=src.xy+p*src.zw;vec2 q=dst.xy+p*dst.zw;gl_Position=vec4(q.x*2.-1.,1.-q.y*2.,0,1);}`,Sr=`#version 300 es
8
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float alpha;uniform float fade;uniform float white;
9
- uniform float bright;uniform float contrast;uniform mat3 sat;uniform mat3 rot;uniform float colour;out vec4 o;
10
- uniform sampler2D matte;uniform float useMatte;uniform vec4 mrect;
11
- // chroma key (shared/chromaKey.js, the server's geq on the decoded picture): alpha = clip((d − similarity) / blend), d = |CbCr − key|
12
- // / (255√2) with the picture's own Cb / Cr (8-bit studio range, back from RGB with its matrix: kmat 1 = BT.709, 0 = BT.601) and the
13
- // key's BT.601 Cb / Cr; then despill (mix 0.5) pulls the green / blue cast back by spill
14
- uniform vec4 key;uniform vec4 keyOpt;
15
- // the grade's 1D LUT (shared/timelineGrade.js gradeLut, 256 entries: an 8-bit input lands on an entry) and its 3D table (the colour
16
- // mixer, timelineMixer.js mixerLut; ffmpeg lut3d trilinear), each on 8-bit values like the server's lut1d / lut3d
17
- uniform highp sampler2D lut1;uniform highp sampler3D lut3;uniform float useL1;uniform float useL3;
18
- vec3 tri(vec3 q){int n=textureSize(lut3,0).x;vec3 p=q*float(n-1),f=floor(p),w=p-f;ivec3 i=ivec3(f),j=min(i+1,ivec3(n-1));
19
- vec3 c000=texelFetch(lut3,i,0).rgb,c100=texelFetch(lut3,ivec3(j.x,i.y,i.z),0).rgb,c010=texelFetch(lut3,ivec3(i.x,j.y,i.z),0).rgb,c110=texelFetch(lut3,ivec3(j.x,j.y,i.z),0).rgb;
20
- vec3 c001=texelFetch(lut3,ivec3(i.x,i.y,j.z),0).rgb,c101=texelFetch(lut3,ivec3(j.x,i.y,j.z),0).rgb,c011=texelFetch(lut3,ivec3(i.x,j.y,j.z),0).rgb,c111=texelFetch(lut3,j,0).rgb;
21
- return mix(mix(mix(c000,c100,w.x),mix(c010,c110,w.x),w.y),mix(mix(c001,c101,w.x),mix(c011,c111,w.x),w.y),w.z);}
22
- void main(){vec4 c=texture(tex,uv);vec3 rgb=c.rgb;
23
- if(keyOpt.x>.5){vec3 q=floor(rgb*255.+.5);float k=224./255.;
24
- float u=keyOpt.w>.5?floor((-.114572*q.r-.385428*q.g+.5*q.b)*k+128.5):floor((-.168736*q.r-.331264*q.g+.5*q.b)*k+128.5);
25
- float v=keyOpt.w>.5?floor((.5*q.r-.454153*q.g-.045847*q.b)*k+128.5):floor((.5*q.r-.418688*q.g-.081312*q.b)*k+128.5);
26
- float d=length(vec2(u-key.x,v-key.y))/360.62445840513925,a=key.w>1e-4?clamp((d-key.z)/key.w,0.,1.):step(key.z,d)-step(d,key.z)*0.;
27
- c.a*=floor(a*255.)/255.;
28
- if(keyOpt.z>0.){if(keyOpt.y>.5){float m=max(0.,rgb.b-(rgb.r*.5+rgb.g*.5));rgb.b=max(0.,rgb.b-m*keyOpt.z);}else{float m=max(0.,rgb.g-(rgb.r*.5+rgb.b*.5));rgb.g=max(0.,rgb.g-m*keyOpt.z);}}}
29
- if(useMatte>.5)c.a*=texture(matte,(uv-mrect.xy)/mrect.zw).r;
30
- if(colour>.5){rgb=clamp(rgb*bright,0.,1.);rgb=clamp((rgb-.5)*contrast+.5,0.,1.);rgb=clamp(sat*rgb,0.,1.);rgb=clamp(rot*rgb,0.,1.);}
31
- if(useL1>.5){ivec3 k=ivec3(floor(rgb*255.+.5));rgb=floor(vec3(texelFetch(lut1,ivec2(k.r,0),0).r,texelFetch(lut1,ivec2(k.g,0),0).g,texelFetch(lut1,ivec2(k.b,0),0).b)*255.+.5)/255.;}
32
- if(useL3>.5)rgb=floor(clamp(tri(floor(rgb*255.+.5)/255.),0.,1.)*255.+.5)/255.;
33
- rgb=white>.5?1.-(1.-rgb)*fade:rgb*fade;o=vec4(rgb,c.a*alpha);}`,q=`#version 300 es
34
- in vec2 p;out vec2 uv;void main(){uv=p;gl_Position=vec4(p*2.-1.,0,1);}`,Dr=`#version 300 es
35
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 step;uniform float sigma;out vec4 o;
36
- void main(){int r=min(int(ceil(sigma*3.)),128);vec4 acc=vec4(0);float wsum=0.;
37
- for(int i=-r;i<=r;i++){float w=exp(-float(i*i)/(2.*sigma*sigma));acc+=texture(tex,uv+step*float(i))*w;wsum+=w;}
38
- o=acc/wsum;}`,kr=`#version 300 es
39
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float lo;uniform float k;out vec4 o;
40
- void main(){vec4 c=texture(tex,uv);o=vec4(clamp(lo+c.rgb*k,0.,1.),c.a);}`,Ur=`#version 300 es
41
- precision highp float;in vec2 uv;uniform sampler2D a;uniform sampler2D b;uniform float amount;out vec4 o;
42
- void main(){vec4 x=texture(a,uv),y=texture(b,uv);o=mix(x,1.-(1.-x)*(1.-y),amount);}`,Pr=`#version 300 es
43
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 step;uniform float b;uniform int reach;out vec4 o;
44
- void main(){vec4 acc=texture(tex,uv);float ws=1.;float w=1.;
45
- for(int i=1;i<=512;i++){if(i>reach)break;w*=b;acc+=(texture(tex,uv+step*float(i))+texture(tex,uv-step*float(i)))*w;ws+=2.*w;}
46
- o=acc/ws;}`,Br=`#version 300 es
47
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float taps[16];uniform int n;uniform vec2 ctr;out vec4 o;
48
- void main(){vec4 acc=vec4(0);for(int i=0;i<16;i++){if(i>=n)break;acc+=texture(tex,ctr+(uv-ctr)/taps[i]);}o=acc/float(n);}`,Nr=`#version 300 es
49
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float sx[8];uniform float sy[8];uniform int n;uniform vec3 gain;out vec4 o;
50
- void main(){vec4 acc=vec4(0);for(int i=0;i<8;i++){if(i>=n)break;acc+=texture(tex,vec2(.5)+(uv-vec2(.5))/vec2(sx[i],sy[i]));}
51
- acc/=float(n);o=vec4(min(acc.rgb*gain,1.),acc.a);}`,Lr=`#version 300 es
52
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float gain;out vec4 o;
53
- void main(){vec4 c=texture(tex,uv);o=vec4(min(c.rgb*gain,1.),c.a);}`,Ir=`#version 300 es
54
- precision highp float;in vec2 uv;uniform sampler2D a;uniform sampler2D b;uniform float w;out vec4 o;
55
- void main(){o=mix(texture(a,uv),texture(b,uv),w);}`,Cr=`#version 300 es
56
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec4 colour;uniform float usetex;out vec4 o;
57
- void main(){o=usetex>.5?texture(tex,vec2(uv.x,1.-uv.y)):colour;}`,Xr=`#version 300 es
58
- precision highp float;uniform sampler2D tex;uniform mat3 inv;uniform vec2 size;uniform vec4 rnd;uniform float keepPre;out vec4 o;
59
- // a pinned screen's rounded corners (shared/cornerPin.js pinRoundGraph): the server's geq mask on the stretched plane BEFORE its
60
- // 2 px inset, at pixel centres, kept at least rnd.z (the portal dive's fade to square corners); rnd.w = on
61
- float corner(ivec2 i){if(rnd.w<.5)return 1.;vec2 k=size/(size-4.),X=(vec2(i)+.5-2.)*k;
62
- float dx=max(0.,max(rnd.x-X.x,X.x-(size.x-rnd.x))),dy=max(0.,max(rnd.y-X.y,X.y-(size.y-rnd.y)));
63
- float m=clamp((1.-sqrt(pow(dx/rnd.x,2.)+pow(dy/rnd.y,2.)))*min(rnd.x,rnd.y)+.5,0.,1.);return max(floor(m*255.)/255.,rnd.z);}
64
- vec4 px(ivec2 i){ivec2 s=ivec2(size);i=clamp(i,ivec2(0),s-1);vec4 c=texelFetch(tex,ivec2(i.x,s.y-1-i.y),0);float a=c.a*corner(i);return vec4(c.rgb*a,a);}
65
- void main(){vec2 d=vec2(gl_FragCoord.x-.5,size.y-gl_FragCoord.y-.5);vec3 q=inv*vec3(d,1.);vec2 u=floor(q.xy/q.z*256.+.5)/256.;
66
- vec2 f=floor(u),w=u-f;ivec2 i=ivec2(f);
67
- vec4 c=mix(mix(px(i),px(i+ivec2(1,0)),w.x),mix(px(i+ivec2(0,1)),px(i+ivec2(1,1)),w.x),w.y);
68
- o=keepPre>.5?c:c.a>0.?vec4(c.rgb/c.a,c.a):vec4(0);}`,Or=`#version 300 es
69
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 size;uniform int kind;uniform float e;uniform float f;uniform float inv;
70
- uniform vec2 ctr;uniform vec3 csh;uniform float count;out vec4 o;
71
- void main(){vec4 c=texture(tex,uv);float X=gl_FragCoord.x-.5,Y=size.y-gl_FragCoord.y-.5,W=size.x,H=size.y,r;
72
- float cx=ctr.x*W,cy=ctr.y*H,dx=X-cx,dy=Y-cy,R=length(vec2(max(cx,W-cx),max(cy,H-cy)));
73
- if(kind<=2){float lin=(X/W-.5)*csh.x+(Y/H-.5)*csh.y,h=csh.z;if(kind==2)r=abs(lin)/h;else{float u=(lin+h)/(2.*h);r=kind==1?mod(u*count,1.):u;}}
74
- else if(kind==3)r=length(vec2(dx,dy))/R;
75
- else if(kind==4)r=(abs(dx)/max(cx,W-cx)+abs(dy)/max(cy,H-cy))/2.;
76
- else if(kind==5){float u=X/W,v=Y/H,A=W/H;r=.1+.78*length(vec2(dx,dy))/R+.12*((sin(u*A*5.3+1.7)*sin(v*4.9+.4)+.55*sin(u*A*11.3-v*9.7+2.3)+.3*sin(u*A*19.1+v*17.3+.7))/1.85);}
77
- else{float a=atan(dx,-dy);if(a<0.)a+=6.283185307179586;r=a/6.283185307179586;}
78
- float m=clamp((e-r)/f,0.,1.);if(inv>.5)m=1.-m;m=floor(m*255.+.5)/255.;o=vec4(c.rgb,c.a*m);}`,zr=`#version 300 es
79
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform highp sampler2D lut;uniform float m[12];uniform float useM;uniform float useL;out vec4 o;
80
- void main(){vec4 c=texture(tex,uv),v=floor(c*255.+.5);vec3 q=v.rgb;
81
- if(useM>.5){vec3 r;for(int i=0;i<3;i++)r[i]=floor(v.r*m[i*4]+.5)+floor(v.g*m[i*4+1]+.5)+floor(v.b*m[i*4+2]+.5)+floor(v.a*m[i*4+3]+.5);q=clamp(r,0.,255.);}
82
- if(useL>.5)q=vec3(texelFetch(lut,ivec2(int(q.r),0),0).r,texelFetch(lut,ivec2(int(q.g),1),0).r,texelFetch(lut,ivec2(int(q.b),2),0).r)*255.;
83
- o=vec4(q/255.,c.a);}`,Gr=`#version 300 es
84
- precision highp float;uniform sampler2D tex;uniform int px;out vec4 o;
85
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);int W=textureSize(tex,0).x;vec4 c=texelFetch(tex,p,0);
86
- o=vec4(texelFetch(tex,ivec2(clamp(p.x+px,0,W-1),p.y),0).r,c.g,texelFetch(tex,ivec2(clamp(p.x-px,0,W-1),p.y),0).b,c.a);}`,qr=`#version 300 es
87
- precision highp float;uniform sampler2D tex;uniform int b;uniform ivec2 small;out vec4 o;
88
- void main(){ivec2 s=textureSize(tex,0),k=ivec2(gl_FragCoord.xy);k.y=small.y-1-k.y;vec4 sum=vec4(0);float n=0.;
89
- for(int j=0;j<64;j++){if(j>=b)break;int y=k.y*b+j;if(y>=s.y)break;for(int i=0;i<64;i++){if(i>=b)break;int x=k.x*b+i;if(x>=s.x)break;sum+=texelFetch(tex,ivec2(x,s.y-1-y),0);n+=1.;}}
90
- o=sum/n;}`,$r=`#version 300 es
91
- precision highp float;uniform sampler2D small;uniform int b;uniform vec2 size;out vec4 o;
92
- void main(){ivec2 p=ivec2(gl_FragCoord.xy),ss=textureSize(small,0);int y=int(size.y)-1-p.y;o=texelFetch(small,ivec2(p.x/b,ss.y-1-y/b),0);}`,jr=`#version 300 es
93
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform vec2 off;uniform vec3 col;uniform float op;uniform float times;uniform vec2 dil;out vec4 o;
94
- void main(){vec2 p=uv-off;float v=0.;if(p.x>=0.&&p.x<=1.&&p.y>=0.&&p.y<=1.)v=floor(texture(tex,p).a*255.+.5);
95
- float a=dil.y>0.?clamp(floor((v-dil.x)*dil.y),0.,255.):times<1.5?floor(v*op):floor(255.*(1.-pow(1.-v/255.*op,times)));
96
- o=vec4(col,a/255.);}`,Hr=`#version 300 es
97
- precision highp float;uniform sampler2D tex;uniform float harden;out vec4 o;
98
- void main(){float a=floor(texelFetch(tex,ivec2(gl_FragCoord.xy),0).a*255.+.5);if(harden>0.)a=clamp((a-128.)*harden+128.,0.,255.);o=vec4(a/255.,0,0,1);}`,Vr=`#version 300 es
99
- precision highp float;uniform sampler2D tex;uniform ivec2 dir;uniform float sigma;out vec4 o;
100
- void main(){ivec2 p=ivec2(gl_FragCoord.xy),n=textureSize(tex,0);int r=min(int(ceil(sigma*3.)),128);float acc=0.,ws=0.;
101
- for(int i=-r;i<=r;i++){float w=exp(-float(i*i)/(2.*sigma*sigma));ivec2 q=p+dir*i;
102
- if(q.x>=0&&q.y>=0&&q.x<n.x&&q.y<n.y)acc+=texelFetch(tex,q,0).r*w;ws+=w;}
103
- o=vec4(floor(acc/ws*255.+.5)/255.,0,0,1);}`,Yr=`#version 300 es
104
- precision highp float;uniform sampler2D a;uniform sampler2D b;out vec4 o;
105
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);float x=floor(texelFetch(a,p,0).r*255.+.5),y=floor(texelFetch(b,p,0).r*255.+.5);
106
- o=vec4(floor(x*clamp(2.*(1.-y/max(x,1.)),0.,1.))/255.,0,0,1);}`,Kr=`#version 300 es
107
- precision highp float;uniform sampler2D pic;uniform sampler2D band;uniform sampler2D glow;uniform vec3 col;uniform float k;uniform float am;out vec4 o;
108
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);float b=floor(texelFetch(band,p,0).r*255.+.5),g=floor(texelFetch(glow,p,0).r*255.+.5);
109
- float rim=clamp(floor(b+g*k),0.,255.);if(am<255.)rim=floor(rim*am/255.);
110
- vec4 P=texelFetch(pic,p,0);float ra=rim/255.,oa=ra+P.a*(1.-ra);
111
- o=vec4(oa>0.?(col*ra+P.rgb*P.a*(1.-ra))/oa:P.rgb,oa);}`,Wr=`#version 300 es
112
- precision highp float;in vec2 uv;uniform sampler2D tex;out vec4 o;void main(){vec4 c=texture(tex,uv);o=vec4(c.rgb*c.a,c.a)*.25;}`,Qr=`#version 300 es
113
- precision highp float;in vec2 uv;uniform sampler2D tex;out vec4 o;void main(){vec4 c=texture(tex,uv);o=c.a>0.?vec4(min(c.rgb/c.a,1.),c.a):vec4(0);}`,Zr=`#version 300 es
114
- precision highp float;uniform sampler2D tex;uniform vec2 big;uniform vec2 small;uniform vec4 q1;uniform vec4 q2;uniform float useQ;
115
- uniform vec4 w1;uniform vec4 w2;uniform float useW;uniform float inv;out vec4 o;
116
- float rp(float v,float lo,float hi,float ss){return clamp((v-lo)/ss+1.,0.,1.)*clamp((hi-v)/ss+1.,0.,1.);}
117
- void main(){vec2 X=floor(gl_FragCoord.xy),c=(X+.5)*big/small;vec3 a=vec3(0);
118
- for(int j=0;j<2;j++)for(int i=0;i<2;i++)a+=texture(tex,(c+vec2(float(i)*2.-1.,float(j)*2.-1.))/big).rgb;
119
- vec3 p=floor(a/4.*255.+.5)/255.;float m=1.;
120
- if(useQ>.5){float h=atan(sqrt(3.)*(p.g-p.b),2.*p.r-p.g-p.b)*180./3.14159265358979;if(h<0.)h+=360.;
121
- float d=abs(h-q1.x);if(d>180.)d=360.-d;float mh=q1.y>=360.?1.:clamp((q1.y/2.+q1.z-d)/q1.z,0.,1.);
122
- float ch=max(max(p.r,p.g),p.b)-min(min(p.r,p.g),p.b),l=.2126*p.r+.7152*p.g+.0722*p.b;
123
- m*=mh*rp(ch,q2.x,q2.y,q1.w)*rp(l,q2.z,q2.w,q1.w);}
124
- if(useW>.5){float dx=X.x/small.x-w1.x,dy=X.y/small.y-w1.y,x=dx*w2.x-dy*w2.y,y=dx*w2.y+dy*w2.x;
125
- if(w2.w>1.5)m*=clamp(.5-y/w1.w,0.,1.);
126
- else{float nx=abs(x)/w1.z,ny=abs(y)/w2.z,dist=w2.w>.5?max(nx,ny):length(vec2(nx,ny));m*=clamp((1.+w1.w/2.-dist)/w1.w,0.,1.);}}
127
- if(inv>.5)m=1.-m;o=vec4(floor(255.*m+1e-4)/255.,0,0,1);}`,Jr=`#version 300 es
128
- precision highp float;uniform sampler2D tex;uniform highp sampler2D lut;uniform highp sampler3D t3;uniform float useT;uniform float useL;
129
- uniform float useS;uniform mat3 sat;uniform float useR;uniform mat3 rot;out vec4 o;
130
- vec3 tri(vec3 q){int n=textureSize(t3,0).x;vec3 p=q*float(n-1),f=floor(p),w=p-f;ivec3 i=ivec3(f),j=min(i+1,ivec3(n-1));
131
- vec3 c000=texelFetch(t3,i,0).rgb,c100=texelFetch(t3,ivec3(j.x,i.y,i.z),0).rgb,c010=texelFetch(t3,ivec3(i.x,j.y,i.z),0).rgb,c110=texelFetch(t3,ivec3(j.x,j.y,i.z),0).rgb;
132
- vec3 c001=texelFetch(t3,ivec3(i.x,i.y,j.z),0).rgb,c101=texelFetch(t3,ivec3(j.x,i.y,j.z),0).rgb,c011=texelFetch(t3,ivec3(i.x,j.y,j.z),0).rgb,c111=texelFetch(t3,j,0).rgb;
133
- return mix(mix(mix(c000,c100,w.x),mix(c010,c110,w.x),w.y),mix(mix(c001,c101,w.x),mix(c011,c111,w.x),w.y),w.z);}
134
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);vec3 g=floor(c.rgb*255.+.5);
135
- if(useT>.5)g=floor(clamp(tri(g/255.),0.,1.)*255.+.5);
136
- if(useL>.5){ivec3 k=ivec3(g);g=floor(vec3(texelFetch(lut,ivec2(k.r,0),0).r,texelFetch(lut,ivec2(k.g,0),0).g,texelFetch(lut,ivec2(k.b,0),0).b)*255.+.5);}
137
- if(useS>.5)g=floor(clamp(sat*(g/255.),0.,1.)*255.+.5);
138
- if(useR>.5)g=floor(clamp(rot*(g/255.),0.,1.)*255.+.5);
139
- o=vec4(g/255.,c.a);}`,ea=`#version 300 es
140
- precision highp float;uniform sampler2D base;uniform sampler2D over;uniform sampler2D mask;uniform vec2 msz;uniform float full;out vec4 o;
141
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 b=texelFetch(base,P,0),g=texelFetch(over,P,0);if(full>.5){o=g;return;}
142
- vec3 q=floor(b.rgb*255.+.5),G=floor(g.rgb*255.+.5);float m=floor(texture(mask,gl_FragCoord.xy/msz).r*255.+.5);
143
- o=vec4((q+floor((m*(G-q)+128.)/256.))/255.,b.a);}`,ta=`#version 300 es
144
- precision highp float;uniform sampler2D tex;uniform float k[9];uniform float rdiv;out vec4 o;
145
- void main(){ivec2 P=ivec2(gl_FragCoord.xy),S=textureSize(tex,0);vec3 s=vec3(0);
146
- for(int j=0;j<3;j++)for(int i=0;i<3;i++){int x=abs(P.x+i-1),y=abs(P.y+j-1);x=x>=S.x?2*S.x-1-x:x;y=y>=S.y?2*S.y-1-y:y;s+=floor(texelFetch(tex,ivec2(x,y),0).rgb*255.+.5)*k[j*3+i];}
147
- vec4 c=texelFetch(tex,P,0);o=vec4(clamp(floor(s*rdiv+.5),0.,255.)/255.,c.a);}`,oa=`#version 300 es
148
- precision highp float;uniform sampler2D tex;uniform sampler2D grain;out vec4 o;
149
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);float n=floor(texelFetch(grain,P,0).r*255.+.5)-128.;o=vec4(clamp(floor(c.rgb*255.+.5)+n,0.,255.)/255.,c.a);}`,ia=`#version 300 es
150
- precision highp float;uniform sampler2D res;uniform sampler2D outp;uniform sampler2D inp;out vec4 o;
151
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 r=texelFetch(res,P,0);vec3 R=floor(r.rgb*255.+.5),O=floor(texelFetch(outp,P,0).rgb*255.+.5),I=floor(texelFetch(inp,P,0).rgb*255.+.5);
152
- vec3 d=clamp(O-I+128.,0.,255.);o=vec4(clamp(R+d-128.,0.,255.)/255.,r.a);}`,ra=`#version 300 es
153
- precision highp float;uniform sampler2D tex;uniform sampler2D soft;uniform float t;out vec4 o;
154
- void main(){ivec2 P=ivec2(gl_FragCoord.xy);vec4 c=texelFetch(tex,P,0);vec3 V=floor(c.rgb*255.+.5),B=floor(texelFetch(soft,P,0).rgb*255.+.5);
155
- vec3 x=clamp(V-B+128.,0.,255.)-128.,g=clamp((abs(x)-t)/t,0.,1.),d=clamp(floor(128.+x*g*g*(3.-2.*g)+.5),0.,255.);
156
- o=vec4(clamp(B+d-128.,0.,255.)/255.,c.a);}`,aa=`#version 300 es
157
- precision highp float;in vec2 uv;uniform sampler2D top;uniform sampler2D bg;uniform int mode;out vec4 o;
158
- void main(){vec4 s=texture(top,uv),b=texture(bg,uv);vec3 Bp=floor(b.rgb*255.+.5),S=floor(s.rgb*255.+.5);float a=floor(s.a*255.+.5),ab=b.a;
159
- if(mode==1){o=vec4(min(vec3(255.),Bp+floor(S*a/255.+.5))/255.,min(1.,a/255.+ab));return;}
160
- // the backdrop is premultiplied (a comp's own transparent picture, gpuExport frames mode): blended against its straight colour, and
161
- // where it is transparent the layer shows as itself (W3C / After Effects); an opaque backdrop (ab = 1) is the formula as before
162
- vec3 B=ab>0.?(ab<1.?floor(Bp/ab+.5):Bp):vec3(0),X;
163
- if(mode==2)X=255.-floor((255.-B)*(255.-S)/255.);
164
- else if(mode==3)X=floor(B*S/255.);
165
- else if(mode==4)X=mix(255.-2.*floor((255.-B)*(255.-S)/255.),2.*floor(B*S/255.),step(B,vec3(127.5)));
166
- else if(mode==5)X=max(B,S);else if(mode==6)X=min(B,S);else if(mode==7)X=abs(B-S);else X=B+S-2.*floor(B*S/255.);
167
- X=clamp(X,0.,255.);if(ab<1.)X=mix(S,X,ab);o=vec4(floor((X*a+Bp*(255.-a))/255.+.5)/255.,ab<1.?a/255.+ab*(1.-a/255.):b.a);}`,na=`#version 300 es
168
- precision highp float;uniform sampler2D tex;uniform int ss;out vec4 o;
169
- void main(){ivec2 p=ivec2(gl_FragCoord.xy)*ss;vec4 c=vec4(0);for(int j=0;j<4;j++){if(j>=ss)break;for(int i=0;i<4;i++){if(i>=ss)break;c+=texelFetch(tex,p+ivec2(i,j),0);}}
170
- c/=float(ss*ss);o=c.a>0.?vec4(c.rgb/c.a,c.a):vec4(0);}`,sa=`#version 300 es
171
- precision highp float;uniform sampler2D tex;uniform int px;out vec4 o;
172
- void main(){ivec2 p=ivec2(gl_FragCoord.xy);int W=textureSize(tex,0).x;vec4 c=texelFetch(tex,p,0);int xr=p.x-px,xb=p.x+px;
173
- o=vec4(xr>=0&&xr<W?texelFetch(tex,ivec2(xr,p.y),0).r:0.,c.g,xb>=0&&xb<W?texelFetch(tex,ivec2(xb,p.y),0).b:0.,c.a);}`,ca=`#version 300 es
174
- precision highp float;uniform sampler2D tex;uniform vec2 size;uniform vec2 msize;uniform float v;uniform float fr;out vec4 o;
175
- float sh(float Y){float band=floor(Y*24./size.y),k=mod(band*73.+fr*151.+17.,97.)/97.;return k>1.-v*.6?(k-.5)*2.*v*.15:0.;}
176
- float mx(vec2 s){float X=(s.x+.5)*size.x/msize.x-.5,Y=(s.y+.5)*size.y/msize.y-.5;return floor(clamp(X-size.x*sh(Y),0.,size.x-1.));}
177
- void main(){float X=gl_FragCoord.x-.5,Y=size.y-gl_FragCoord.y-.5;vec2 p=vec2((X+.5)*msize.x/size.x-.5,(Y+.5)*msize.y/size.y-.5),f=floor(p),w=p-f;
178
- vec2 a=clamp(f,vec2(0),msize-1.),b=clamp(f+1.,vec2(0),msize-1.);
179
- float m=mix(mix(mx(a),mx(vec2(b.x,a.y)),w.x),mix(mx(vec2(a.x,b.y)),mx(b),w.x),w.y);
180
- o=texelFetch(tex,ivec2(clamp(int(floor(m+.5)),0,int(size.x)-1),int(size.y)-1-int(Y)),0);}`,la=`#version 300 es
181
- precision highp float;uniform sampler2D tex;uniform vec2 size;uniform float a[8];uniform float sx[8];uniform float sy[8];out vec4 o;
182
- void main(){vec2 p=vec2(gl_FragCoord.x-.5,size.y-gl_FragCoord.y-.5),c=size*.5-.5;vec4 acc=vec4(0);
183
- for(int k=0;k<8;k++){vec2 d=p-c;float cs=cos(a[k]),sn=sin(a[k]);vec2 q=vec2(d.x*cs+d.y*sn,-d.x*sn+d.y*cs);vec2 s=q/vec2(sx[k],sy[k])+c;
184
- vec2 uv=vec2((s.x+.5)/size.x,1.-(s.y+.5)/size.y);acc+=(uv.x<0.||uv.x>1.||uv.y<0.||uv.y>1.)?vec4(0):texture(tex,uv);}
185
- o=acc/8.;}`,fa=`#version 300 es
186
- precision highp float;in vec2 uv;uniform sampler2D tex;uniform float w;out vec4 o;
187
- void main(){vec4 c=texture(tex,uv);o=vec4(mix(c.rgb,1.-c.rgb,w),c.a);}`,ua=`#version 300 es
188
- precision highp float;in vec2 uv;uniform sampler2D tex;out vec4 o;void main(){o=texture(tex,uv);}`,ma=["wipe","blinds","split","iris","diamond","burn"];function wo(v,y){const R=Math.max(1e-4,v.feather??.05),e=v.progress?Vt(v.progress,y)??0:y,z=(v.angle??0)*Math.PI/180,h=Math.cos(z),N=Math.sin(z),A=ma.indexOf(v.type??"");return{type:"txMask",kind:A<0?6:A,e:e*(1+2*R)-R,f:R,inv:!!v.invert,cx:v.cx??.5,cy:v.cy??.5,c:h,s:N,h:.5*(Math.abs(h)+Math.abs(N)),count:v.count??8}}function yo(v,y,R,e,z=0,h){if(!v)return[];const N=ee=>Vt(v[ee],y)??0,A=[];if(v.zoomBlur&&A.push({type:"txZoom",taps:Ti(),w:N("zoomBlur"),...h?{c:[h.cx,1-h.cy]}:{}}),v.spinBlur){const ee=wi(R,e),ie=ae=>Math.max(2,Math.round(ae/2)*2);A.push({type:"txSpin",a:ee.map(ae=>+ae.a.toFixed(6)),sx:ee.map(ae=>ie(R*ae.scale)/R),sy:ee.map(ae=>ie(e*ae.scale)/e),w:N("spinBlur")})}if(v.dirBlur){const ee=po*R/1280,ie=ee/(1+ee);A.push({type:"txDir",b:ie,reach:Math.min(512,Math.ceil(Math.log(.001)/Math.log(ie))),w:N("dirBlur")})}if(v.dirBlurV){const ee=po*R/1280,ie=ee/(1+ee);A.push({type:"txDir",b:ie,reach:Math.min(512,Math.ceil(Math.log(.001)/Math.log(ie))),w:N("dirBlurV"),v:!0})}return v.blur&&A.push({type:"txGauss",sigma:yi*R/1280,w:N("blur")}),v.glitch&&A.push({type:"txGlitch",v:N("glitch"),fr:Math.floor(z*30+.5)}),v.rgbSplit&&A.push({type:"txRgb",px:Math.trunc(N("rgbSplit")*Ri*R/1280+.5)}),v.exposure&&A.push({type:"txExpo",gain:_i,w:N("exposure")}),v.invert&&A.push({type:"txInv",w:N("invert")}),A}function pa(v,y){const R=new OffscreenCanvas(v,y),e=R.getContext("webgl2",{premultipliedAlpha:!1,preserveDrawingBuffer:!0,antialias:!1});if(!e)throw Error("WebGL2 unavailable");const z=(n,s)=>{const o=e.createShader(n);if(e.shaderSource(o,s),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw Error(String(e.getShaderInfoLog(o)));return o},h=(n,s)=>{const o=e.createProgram();if(e.attachShader(o,z(e.VERTEX_SHADER,n)),e.attachShader(o,z(e.FRAGMENT_SHADER,s)),e.bindAttribLocation(o,0,"p"),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw Error(String(e.getProgramInfoLog(o)));return o},N=h(Mr,Sr),A=h(q,jr),ee=h(q,Hr),ie=h(q,Vr),ae=h(q,Yr),me=h(q,Kr),de=h(q,Wr),p=h(q,Qr),T=h(q,Zr),_=h(q,Dr),I=h(q,kr),X=h(q,Ur),$=h(q,ua),te=h(q,Nr),oe=h(q,Jr),O=h(q,ea),_e=h(q,ta),Te=h(q,oa),Oe=h(q,ra),we=h(q,ia),Ye=h(q,Pr),ze=h(q,Br),lt=h(q,Lr),Fe=h(q,Ir),ft=h(q,Cr),Ke=h(q,Xr),ye=h(q,Or),Ge=h(q,zr),We=h(q,Gr),Ae=h(q,qr),Le=h(q,$r),it=h(q,aa),Q=h(q,na),be=h(q,sa),ut=h(q,fa),qe=h(q,ca),De=h(q,la),rt=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,rt),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,0,0);const $e=n=>s=>e.getUniformLocation(n,s),F=$e(N);e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1);const pe=()=>{const n=e.createTexture();e.bindTexture(e.TEXTURE_2D,n);for(const[s,o]of[[e.TEXTURE_MIN_FILTER,e.LINEAR],[e.TEXTURE_MAG_FILTER,e.LINEAR],[e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE],[e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE]])e.texParameteri(e.TEXTURE_2D,s,o);return n},mt=pe(),wt=pe();let je=null;const at=pe(),pt=e.createTexture(),Ie={l1:"",l3:""};let yt=!1,Xt=!1,ke=null;const Yt={add:1,screen:2,multiply:3,overlay:4,lighten:5,darken:6,difference:7,exclusion:8};let Ce=0;const Rt=pe();let k=[],He=!1,nt=null;const St=n=>{const s=Ve(),o=(n+1)%3,f=(n+2)%3;for(const w of k){let m=n;e.disable(e.BLEND),w.sigma>.05&&(j(_,s[o].fb,[s[n].tex],d=>{e.uniform1i(d("tex"),0),e.uniform2f(d("step"),1/v,0),e.uniform1f(d("sigma"),w.sigma)}),j(_,s[f].fb,[s[o].tex],d=>{e.uniform1i(d("tex"),0),e.uniform2f(d("step"),0,1/y),e.uniform1f(d("sigma"),w.sigma)}),m=f),ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);const[t,c,u]=[1,3,5].map(d=>parseInt(w.color.slice(d,d+2),16)/255);j(A,null,[s[m].tex],d=>{e.uniform1i(d("tex"),0),e.uniform2f(d("off"),Math.trunc(w.dx)/v,-Math.trunc(w.dy)/y),e.uniform3f(d("col"),t,c,u),e.uniform1f(d("op"),w.opacity),e.uniform1f(d("times"),w.times),e.uniform2f(d("dil"),w.dilate?+(Ki*255).toFixed(3):0,w.dilate?+(1/Wi).toFixed(3):0)})}},Qe=n=>{const s=Ve();if(He){ue(nt.fb),e.enable(e.BLEND),e.blendFunc(e.ONE,e.ONE),j(de,nt.fb,[s[n].tex],o=>e.uniform1i(o("tex"),0)),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA);return}if(k.length&&St(n),Ce){Xe(s[n].tex);return}ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),j($,null,[s[n].tex],o=>e.uniform1i(o("tex"),0))},Xe=n=>{ue(null),e.bindTexture(e.TEXTURE_2D,Rt),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA8,0,0,v,y,0),e.disable(e.BLEND),j(it,null,[n,Rt],s=>{e.uniform1i(s("top"),0),e.uniform1i(s("bg"),1),e.uniform1i(s("mode"),Ce)})};let Ue=null;const Ve=()=>Ue??=[Me(),Me(),Me()],Ze=new Map,_t=n=>{let s=Ze.get(n);if(s)return s;const o=()=>{const f=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,v*n,y*n,0,e.RGBA,e.UNSIGNED_BYTE,null);const w=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,w),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,f,0),{tex:f,fb:w}};return s={plane:o(),out:o()},Ze.set(n,s),s},Je=new Map,Ft=new Map,Dt=n=>{let s=Je.get(n.key);if(s)return s;s=pe();const o=new Uint8Array(256*3);(n.lut??[]).forEach((f,w)=>o.set(f,w*256)),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,256,3,0,e.RED,e.UNSIGNED_BYTE,o),e.pixelStorei(e.UNPACK_ALIGNMENT,4);for(const f of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,f,e.NEAREST);return Je.set(n.key,s),s},Ot=(n,s)=>{const o=`${n}x${s}`;let f=Ft.get(o);if(f)return f;const w=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);for(const t of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,t,e.NEAREST);const m=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,m),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,w,0),f={tex:w,fb:m},Ft.set(o,f),f},zt=new Map,Kt=(n,s)=>{const o=`${n}x${s}`;let f=zt.get(o);return f||(f=[0,1].map(()=>{const w=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);const m=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,m),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,w,0),{tex:w,fb:m}}),zt.set(o,f),f)},Me=()=>{const n=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,v,y,0,e.RGBA,e.UNSIGNED_BYTE,null);const s=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,s),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,n,0),{tex:n,fb:s}},ue=n=>{e.bindFramebuffer(e.FRAMEBUFFER,n),e.viewport(0,0,v,y)},j=(n,s,o,f)=>st(n,s,v,y,o,f),st=(n,s,o,f,w,m)=>{e.bindFramebuffer(e.FRAMEBUFFER,s),e.viewport(0,0,o,f),e.useProgram(n);const t=$e(n);w.forEach((c,u)=>{e.activeTexture(e.TEXTURE0+u),e.bindTexture(e.TEXTURE_2D,c)}),m(t),e.drawArrays(e.TRIANGLE_STRIP,0,4),w.length>1&&At(),e.activeTexture(e.TEXTURE0)},At=()=>{e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,wt),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,at),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_3D,pt),e.activeTexture(e.TEXTURE0)},xt=(n,s=0)=>{const o=Ve();let f=s;const w=(t,c,u,d)=>{j(_,o[c].fb,[o[t].tex],r=>{e.uniform1i(r("tex"),0),e.uniform2f(r("step"),1/v,0),e.uniform1f(r("sigma"),d)}),j(_,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform2f(r("step"),0,1/y),e.uniform1f(r("sigma"),d)})},m=(t,c,u,d)=>j(Fe,o[u].fb,[o[t].tex,o[c].tex],r=>{e.uniform1i(r("a"),0),e.uniform1i(r("b"),1),e.uniform1f(r("w"),d)});for(const t of n){const[c,u,d]=[f,(f+1)%3,(f+2)%3];if(t.type==="blur"){t.sigma>.05&&(w(c,u,d,t.sigma),f=d);continue}if(t.type==="colour"){const r=Dt(t);j(Ge,o[u].fb,[o[c].tex,r],b=>{e.uniform1i(b("tex"),0),e.uniform1i(b("lut"),1),e.uniform1f(b("useM"),t.m?1:0),e.uniform1f(b("useL"),t.lut?1:0),t.m&&e.uniform1fv(b("m"),t.m.flatMap(M=>[M[0],M[1],M[2],M[3]??0]))}),f=u;continue}if(t.type==="txRgb"){t.px>0&&(j(be,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform1i(r("px"),t.px)}),f=u);continue}if(t.type==="txGlitch"){t.v>1e-4&&(j(qe,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform2f(r("size"),v,y),e.uniform2f(r("msize"),Math.max(2,Math.round(v/4)),Math.max(2,Math.round(y/4))),e.uniform1f(r("v"),t.v),e.uniform1f(r("fr"),t.fr)}),f=u);continue}if(t.type==="txInv"){t.w>1e-4&&(j(ut,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform1f(r("w"),Math.min(1,t.w))}),f=u);continue}if(t.type==="shift"){j(We,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform1i(r("px"),t.px)}),f=u;continue}if(t.type==="pixel"){const r=Math.ceil(v/t.block),b=Math.ceil(y/t.block),M=Ot(r,b);e.bindFramebuffer(e.FRAMEBUFFER,M.fb),e.viewport(0,0,r,b),e.useProgram(Ae),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,o[c].tex),e.uniform1i(e.getUniformLocation(Ae,"tex"),0),e.uniform1i(e.getUniformLocation(Ae,"b"),t.block),e.uniform2i(e.getUniformLocation(Ae,"small"),r,b),e.drawArrays(e.TRIANGLE_STRIP,0,4),j(Le,o[u].fb,[M.tex],W=>{e.uniform1i(W("small"),0),e.uniform1i(W("b"),t.block),e.uniform2f(W("size"),v,y)}),f=u;continue}if(t.type==="txMask"){j(ye,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform2f(r("size"),v,y),e.uniform1i(r("kind"),t.kind),e.uniform1f(r("e"),t.e),e.uniform1f(r("f"),t.f),e.uniform1f(r("inv"),t.inv?1:0),e.uniform2f(r("ctr"),t.cx,t.cy),e.uniform3f(r("csh"),t.c,t.s,t.h),e.uniform1f(r("count"),t.count)}),f=u;continue}if(t.type==="txGauss"||t.type==="txDir"||t.type==="txZoom"||t.type==="txSpin"||t.type==="txExpo"){if(!(t.w>1e-4))continue;let r=u;t.type==="txGauss"?(w(c,u,d,t.sigma),r=d):t.type==="txDir"?j(Ye,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),t.v?e.uniform2f(M("step"),0,1/y):e.uniform2f(M("step"),1/v,0),e.uniform1f(M("b"),t.b),e.uniform1i(M("reach"),t.reach)}):t.type==="txZoom"?j(ze,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),e.uniform1fv(M("taps"),t.taps),e.uniform1i(M("n"),t.taps.length),e.uniform2f(M("ctr"),t.c?.[0]??.5,t.c?.[1]??.5)}):t.type==="txSpin"?j(De,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),e.uniform2f(M("size"),v,y),e.uniform1fv(M("a"),t.a),e.uniform1fv(M("sx"),t.sx),e.uniform1fv(M("sy"),t.sy)}):j(lt,o[u].fb,[o[c].tex],M=>{e.uniform1i(M("tex"),0),e.uniform1f(M("gain"),t.gain)});const b=r===d?u:d;m(c,r,b,Math.min(1,t.w)),f=b;continue}if(t.type==="burst"){const{w:r,h:b}=lr(v,y),[M,W]=Kt(r,b),K=nr(sr.burst*t.amount).map(V=>cr(r,b,V));j(I,o[u].fb,[o[c].tex],V=>{e.uniform1i(V("tex"),0),e.uniform1f(V("lo"),t.lo),e.uniform1f(V("k"),t.k)}),st($,M.fb,r,b,[o[u].tex],V=>e.uniform1i(V("tex"),0)),st(te,W.fb,r,b,[M.tex],V=>{e.uniform1i(V("tex"),0),e.uniform1i(V("n"),K.length),e.uniform1fv(V("sx"),K.map(Ee=>Ee.sw/r)),e.uniform1fv(V("sy"),K.map(Ee=>Ee.sh/b)),e.uniform3f(V("gain"),...ur(t.amount))}),j(X,o[d].fb,[o[c].tex,W.tex],V=>{e.uniform1i(V("a"),0),e.uniform1i(V("b"),1),e.uniform1f(V("amount"),+t.amount.toFixed(4))}),f=d;continue}j(I,o[u].fb,[o[c].tex],r=>{e.uniform1i(r("tex"),0),e.uniform1f(r("lo"),t.lo),e.uniform1f(r("k"),t.k)}),w(u,d,u,t.sigma),j(X,o[d].fb,[o[c].tex,o[u].tex],r=>{e.uniform1i(r("a"),0),e.uniform1i(r("b"),1),e.uniform1f(r("amount"),t.amount)}),f=d}return f};let ct=null,i="",l=[],U="";const x=(n,s)=>{if(U!==`${n}x${s}`){for(const o of l)e.deleteTexture(o.tex),e.deleteFramebuffer(o.fb);l=Array.from({length:4},()=>{const o=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);const f=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,f),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),{tex:o,fb:f}}),U=`${n}x${s}`}return l},g=(n,s,o,f)=>{const w=e.getParameter(e.FRAMEBUFFER_BINDING),m=e.getParameter(e.VIEWPORT),t=e.isEnabled(e.BLEND),c=x(f.ew,f.eh),u=(r,b,M,W)=>{e.bindFramebuffer(e.FRAMEBUFFER,c[b].fb),e.viewport(0,0,f.ew,f.eh),e.useProgram(r);const K=$e(r);M.forEach((V,Ee)=>{e.activeTexture(e.TEXTURE0+Ee),e.bindTexture(e.TEXTURE_2D,c[V].tex)}),W(K),e.drawArrays(e.TRIANGLE_STRIP,0,4),M.length>1&&At(),e.activeTexture(e.TEXTURE0)};e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,c[0].fb),e.viewport(0,0,f.ew,f.eh),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT);{const r=kt(n,o);e.bindFramebuffer(e.FRAMEBUFFER,c[0].fb),e.viewport(0,0,f.ew,f.eh),e.disable(e.BLEND),vt(n,[0,0,1,1],s,1,1,!1,r==="win"?null:o,r)}u(ee,1,[0],r=>{e.uniform1i(r("tex"),0),e.uniform1f(r("harden"),f.harden?Vi:0)});const d=(r,b,M,W)=>{u(ie,b,[r],K=>{e.uniform1i(K("tex"),0),e.uniform2i(K("dir"),1,0),e.uniform1f(K("sigma"),W)}),u(ie,M,[b],K=>{e.uniform1i(K("tex"),0),e.uniform2i(K("dir"),0,1),e.uniform1f(K("sigma"),W)})};d(1,2,3,f.band),u(ae,2,[1,3],r=>{e.uniform1i(r("a"),0),e.uniform1i(r("b"),1)}),d(2,1,3,f.glow),u(me,1,[0,2,3],r=>{e.uniform1i(r("pic"),0),e.uniform1i(r("band"),1),e.uniform1i(r("glow"),2),e.uniform3f(r("col"),...f.col),e.uniform1f(r("k"),f.k),e.uniform1f(r("am"),f.am)}),e.bindFramebuffer(e.FRAMEBUFFER,w),e.viewport(m[0],m[1],m[2],m[3]),t&&e.enable(e.BLEND)};let C=null,P="",se=null,Y=[],Z="";const a=new Map,S=new Map,ce=new Map,ve=new Map,le=new Map,Re=new Map,ne=pe(),B=(n,s)=>{const o=pe();e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,n,s,0,e.RGBA,e.UNSIGNED_BYTE,null);const f=e.createFramebuffer();return e.bindFramebuffer(e.FRAMEBUFFER,f),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,o,0),{tex:o,fb:f}},Pe=(n,s,o)=>{const f=e.getParameter(e.FRAMEBUFFER_BINDING),w=e.getParameter(e.VIEWPORT),m=e.isEnabled(e.BLEND),t=n.w,c=n.h;if(Z!==`${t}x${c}`){for(const H of Y)e.deleteTexture(H.tex),e.deleteFramebuffer(H.fb);Y=Array.from({length:7},()=>B(t,c)),Z=`${t}x${c}`}e.disable(e.BLEND),e.bindFramebuffer(e.FRAMEBUFFER,Y[0].fb),e.viewport(0,0,t,c),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),vt(n,[0,1,1,-1],[0,0,1,1],1,1,!1,s,"base");let u=0;const d=H=>[H[0],H[3],H[6],H[1],H[4],H[7],H[2],H[5],H[8]],r=(H,G,ht,et)=>{e.bindFramebuffer(e.FRAMEBUFFER,Y[G].fb),e.viewport(0,0,t,c),e.useProgram(H);const Be=$e(H);ht.forEach((bt,Et)=>{e.activeTexture(e.TEXTURE0+Et),e.bindTexture(bt.d3?e.TEXTURE_3D:e.TEXTURE_2D,bt.t)}),et(Be),e.drawArrays(e.TRIANGLE_STRIP,0,4),At()},b=H=>({t:Y[H].tex}),M=(H,G,ht,et)=>{r(_,G,[b(H)],Be=>{e.uniform1i(Be("tex"),0),e.uniform2f(Be("step"),1/t,0),e.uniform1f(Be("sigma"),et)}),r(_,ht,[b(G)],Be=>{e.uniform1i(Be("tex"),0),e.uniform2f(Be("step"),0,1/c),e.uniform1f(Be("sigma"),et)})},W=o.list,K=W.map(H=>Jt(H)),V=Pi(W),Ee=new Set;for(const[H,G]of W.entries()){const ht=V[H];if(H===ht&&W.some((E,D)=>D>H&&V[D]===H&&K[D])&&(r($,2,[b(u)],E=>e.uniform1i(E("tex"),0)),Ee.add(H)),!K[H])continue;const et=H!==ht&&Ee.has(ht)?G.branch:void 0,Be=et?2:u;let bt=ne,Et=[1,1];if(G.qualifier){const E=Math.max(2,Math.trunc((t+Mt-1)/Mt)),D=Math.max(2,Math.trunc((c+Mt-1)/Mt)),L=`${E}x${D}`;let re=a.get(L);re||(re=B(E,D),a.set(L,re));const J=G.qualifier,xe=Math.max(.001,J.soft??.3),Se=G.window,Tt=-(Se?.rot??0)*Math.PI/180;e.bindFramebuffer(e.FRAMEBUFFER,re.fb),e.viewport(0,0,E,D),e.useProgram(T),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Y[Be].tex);const ge=$e(T);e.uniform1i(ge("tex"),0),e.uniform2f(ge("big"),t,c),e.uniform2f(ge("small"),E,D),e.uniform4f(ge("q1"),J.hue,J.hueWidth,Math.max(1,xe*60),Math.max(.001,xe*.2)),e.uniform4f(ge("q2"),J.satMin,J.satMax,J.lumMin,J.lumMax),e.uniform1f(ge("useQ"),1),e.uniform1f(ge("useW"),Se?1:0),Se&&(e.uniform4f(ge("w1"),Se.cx,Se.cy,Math.max(1e-4,Se.w/2),Math.max(.001,Se.feather??.2)),e.uniform4f(ge("w2"),Math.cos(Tt),Math.sin(Tt),Math.max(1e-4,Se.h/2),Se.type==="gradient"?2:Se.type==="rect"?1:0)),e.uniform1f(ge("inv"),G.invert?1:0),e.drawArrays(e.TRIANGLE_STRIP,0,4),bt=re.tex,Et=[E*Mt,D*Mt]}else if(!G.whole&&Bi(G)&&G.window?.type!=="person"){const E=`${o.clip}#${H}`,D=`${t}x${c}@${o.local??0}`,L=vo,re=Math.max(2,Math.min(vo*2,Math.round(L*c/t)));let J=ve.get(E);if(J||(J={tex:pe(),at:""},ve.set(E,J)),J.at!==D){const xe=xo(G,o.src,o.local??0,c/t,null),Se=new Uint8Array(L*re);for(let Tt=0;Tt<re;Tt++)for(let ge=0;ge<L;ge++)Se[Tt*L+ge]=Math.round(xe((ge+.5)/L,(Tt+.5)/re,0,0,0)*255);e.bindTexture(e.TEXTURE_2D,J.tex),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,L,re,0,e.RED,e.UNSIGNED_BYTE,Se),e.pixelStorei(e.UNPACK_ALIGNMENT,4),J.at=D}bt=J.tex,Et=[t,c]}else if(!G.whole){const E=ho(G)?o.src?.depthMap:void 0,D=`${o.clip}#${H}@${t}x${c}${E?`@${E.at}:${E.data.length}:${E.data.slice(0,24)}`:""}`;let L=S.get(D);if(!L){const re=Ni(G,t,c,ho(G)?xo(G,o.src,0,c/t):null);L=pe(),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,re.w4,re.h4,0,e.RED,e.UNSIGNED_BYTE,re.px),e.pixelStorei(e.UNPACK_ALIGNMENT,4),S.set(D,L)}bt=L,Et=[t,c]}const Ut=G.adjust??{},to=Li(G),Wt=`${o.clip}#${H}`;let Gt=ce.get(Wt);if(to&&!Gt){const E=new Float32Array(1024);for(let D=0;D<256;D++)["r","g","b"].forEach((L,re)=>{E[D*4+re]=+Ii(Ut,L,D/255,G.wheels,G.curves).toFixed(6)}),E[D*4+3]=1;Gt=pe(),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,256,1,0,e.RGBA,e.FLOAT,E);for(const D of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,D,e.NEAREST);ce.set(Wt,Gt)}let gt=null;if(Ci(G)){const E=`${Wt}:${JSON.stringify([G.cst,G.look,G.lut,G.mixer])}`;if(gt=le.get(E)??null,!gt){const D=Xi(G,L=>fr(L));if(!D)throw Error(`LUT "${G.lut?.name??""}" chưa tải xong`);gt=e.createTexture(),e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_3D,gt),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage3D(e.TEXTURE_3D,0,e.RGB32F,D.size,D.size,D.size,0,e.RGB,e.FLOAT,D.data),e.pixelStorei(e.UNPACK_ALIGNMENT,4);for(const L of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_3D,L,e.NEAREST);for(const L of[e.TEXTURE_WRAP_S,e.TEXTURE_WRAP_T,e.TEXTURE_WRAP_R])e.texParameteri(e.TEXTURE_3D,L,e.CLAMP_TO_EDGE);e.activeTexture(e.TEXTURE0),le.set(E,gt)}}const{sat:Po,rot:Bo}=Oi(Ut.saturation??1,Ut.hue??0);r(oe,3,[b(Be),{t:Gt??at},{t:gt??pt,d3:!0}],E=>{e.uniform1i(E("tex"),0),e.uniform1i(E("lut"),1),e.uniform1i(E("t3"),2),e.uniform1f(E("useT"),gt?1:0),e.uniform1f(E("useL"),to?1:0),e.uniform1f(E("useS"),(Ut.saturation??1)!==1?1:0),e.uniform1f(E("useR"),(Ut.hue??0)!==0?1:0),e.uniformMatrix3fv(E("sat"),!1,d(Po)),e.uniformMatrix3fv(E("rot"),!1,d(Bo))}),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_3D,null),e.activeTexture(e.TEXTURE0),At();let fe=3;const tt=(E,D)=>[3,4,5].find(L=>L!==E&&L!==D);if((G.blur??0)>0){const E=tt(fe),D=tt(fe,E);M(fe,E,D,Math.max(.1,+((G.blur??0)*zi*t).toFixed(3))),fe=D}const oo=Gi({sharpness:G.sharpen??0});if(oo){const E=tt(fe);r(_e,E,[b(fe)],D=>{e.uniform1i(D("tex"),0),e.uniform1fv(D("k"),oo),e.uniform1f(D("rdiv"),1/Yi)}),fe=E}const he=G.fx?qi(G.fx,t):null;if(he&&(he.type==="glow"||he.type==="halation")){const E=tt(fe),D=tt(fe,E);r(I,E,[b(fe)],xe=>{e.uniform1i(xe("tex"),0),e.uniform1f(xe("lo"),he.lo),e.uniform1f(xe("k"),he.k)});let L=E;he.tint&&(r(Ge,D,[b(E),{t:at}],xe=>{e.uniform1i(xe("tex"),0),e.uniform1i(xe("lut"),1),e.uniform1f(xe("useM"),1),e.uniform1f(xe("useL"),0),e.uniform1fv(xe("m"),he.tint.flat())}),L=D),M(L,L===E?D:E,L,he.sigma);const J=6;r(X,J,[b(fe),b(L)],xe=>{e.uniform1i(xe("a"),0),e.uniform1i(xe("b"),1),e.uniform1f(xe("amount"),he.amount)}),r($,3,[b(J)],xe=>e.uniform1i(xe("tex"),0)),fe=3}else if(he?.type==="grain"){const E=$i(o.frame??0),D=`${E}:${t}x${c}:${he.amp}`;let L=Re.get(D);if(!L){if(Re.size>8){for(const J of Re.values())e.deleteTexture(J);Re.clear()}L=pe(),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.R8,t,c,0,e.RED,e.UNSIGNED_BYTE,ji(E,t,c,he.amp)),e.pixelStorei(e.UNPACK_ALIGNMENT,4),Re.set(D,L)}const re=tt(fe);r(Te,re,[b(fe),{t:L}],J=>{e.uniform1i(J("tex"),0),e.uniform1i(J("grain"),1)}),fe=re}else if(he?.type==="denoise"){const E=tt(fe),D=tt(fe,E);M(fe,E,D,he.sigma),r(Oe,6,[b(fe),b(D)],L=>{e.uniform1i(L("tex"),0),e.uniform1i(L("soft"),1),e.uniform1f(L("t"),he.t)}),r($,3,[b(6)],L=>e.uniform1i(L("tex"),0)),fe=3}else if(he?.type==="swirl"){const E=D=>Math.max(2,Math.round(D/2)*2);for(const D of Hi(t,c,he.deg)){const L=tt(fe);r(De,L,[b(fe)],re=>{e.uniform1i(re("tex"),0),e.uniform2f(re("size"),t,c),e.uniform1fv(re("a"),D.map(J=>+J.a.toFixed(6))),e.uniform1fv(re("sx"),D.map(J=>E(t*J.scale)/t)),e.uniform1fv(re("sy"),D.map(J=>E(c*J.scale)/c))}),fe=L}}const No=et==="parallel"?2:u,Lo=et==="parallel"?6:1-u;r(O,Lo,[b(No),b(fe),{t:bt}],E=>{e.uniform1i(E("base"),0),e.uniform1i(E("over"),1),e.uniform1i(E("mask"),2),e.uniform2f(E("msz"),Et[0],Et[1]),e.uniform1f(E("full"),G.whole?1:0)}),et==="parallel"&&r(we,1-u,[b(u),b(6),b(2)],E=>{e.uniform1i(E("res"),0),e.uniform1i(E("outp"),1),e.uniform1i(E("inp"),2)}),u=1-u}se=Y[u].tex,e.bindFramebuffer(e.FRAMEBUFFER,f),e.viewport(w[0],w[1],w[2],w[3]),m&&e.enable(e.BLEND)},kt=(n,s)=>C?(P!==C.key&&(Pe(n,s,C),P=C.key),"win"):"pic",dt=(n,s,o,f,w,m,t)=>{if(!ct){const M=kt(n,t);vt(n,s,o,f,w,m,M==="win"?null:t,M);return}const c=je??[0,0,1,1];i!==ct.key&&(g(n,c,t,ct),i=ct.key);const u=(o[0]-c[0])/c[2],d=(o[1]-c[1])/c[3],r=o[2]/c[2],b=o[3]/c[3];vt(n,s,[u,1-d,r,-b],f,w,m,null,"edge")},vt=(n,s,o,f,w,m,t,c)=>{const u=c==="edge"||c==="win",d=c==="pic"||c==="base";if(e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,mt),d&&e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n.source),e.uniform4f(F("dst"),s[0],s[1],s[2],s[3]),e.uniform4f(F("src"),o[0],o[1],o[2],o[3]),e.uniform1f(F("alpha"),f),e.uniform1f(F("fade"),w),e.uniform1f(F("white"),m?1:0),e.uniform1f(F("colour"),t?1:0),e.uniform1i(F("tex"),0),e.uniform1i(F("matte"),1),e.uniform1f(F("useMatte"),je&&(c==="pic"||c==="win")?1:0),ke&&!u?(e.uniform4f(F("key"),ke.u,ke.v,ke.similarity,ke.blend),e.uniform4f(F("keyOpt"),1,ke.blue?1:0,ke.spill,n.bt709?1:0)):e.uniform4f(F("keyOpt"),0,0,0,0),e.uniform1i(F("lut1"),2),e.uniform1i(F("lut3"),3),e.uniform1f(F("useL1"),yt&&!u?1:0),e.uniform1f(F("useL3"),Xt&&!u?1:0),je&&e.uniform4f(F("mrect"),je[0],je[1],je[2],je[3]),e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,wt),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,at),e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_3D,pt),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,c==="edge"?l[1].tex:c==="win"?se:mt),t){const r=b=>[b[0],b[3],b[6],b[1],b[4],b[7],b[2],b[5],b[8]];e.uniform1f(F("bright"),t.bright),e.uniform1f(F("contrast"),t.contrast),e.uniformMatrix3fv(F("sat"),!1,r(t.sat)),e.uniformMatrix3fv(F("rot"),!1,r(t.rot))}e.drawArrays(e.TRIANGLE_STRIP,0,4)};return{canvas:R,clear(n=1){ue(null),e.clearColor(0,0,0,n),e.clear(e.COLOR_BUFFER_BIT)},pixels(){ue(null);const n=new Uint8ClampedArray(v*y*4),s=v*4,o=new Uint8ClampedArray(v*y*4);e.readPixels(0,0,v,y,e.RGBA,e.UNSIGNED_BYTE,n);for(let f=0;f<y;f++){const w=(y-1-f)*s,m=f*s;for(let t=0;t<s;t+=4){const c=n[w+t+3];if(o[m+t+3]=c,c){const u=255/c;o[m+t]=n[w+t]*u,o[m+t+1]=n[w+t+1]*u,o[m+t+2]=n[w+t+2]*u}}}return o},draw(n,s,o,f,w,m,t=null,c=[],u=null){if(!c.length&&!Ce&&!k.length&&!He){ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),dt(n,s,o,f,w,m,t);return}Ue??=[Me(),Me(),Me()],ue(Ue[0].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),dt(n,u??s,o,f,w,m,t);const d=xt(c);if(ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),Ce||k.length||He){let r=d;u&&(r=(d+1)%3,ue(Ue[r].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Ue[d].tex),e.uniform4f(F("dst"),s[0],s[1],s[2],s[3]),e.uniform4f(F("src"),0,1,1,-1),e.uniform1f(F("alpha"),1),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("colour"),0),e.uniform1f(F("useMatte"),0),e.drawArrays(e.TRIANGLE_STRIP,0,4)),Qe(r);return}if(!u){j($,null,[Ue[d].tex],r=>e.uniform1i(r("tex"),0));return}e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Ue[d].tex),e.uniform4f(F("dst"),s[0],s[1],s[2],s[3]),e.uniform4f(F("src"),0,1,1,-1),e.uniform1f(F("alpha"),1),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("colour"),0),e.uniform1f(F("useMatte"),0),e.drawArrays(e.TRIANGLE_STRIP,0,4)},warp(n,s,o,f,w,m,t,c,u,d=null,r=null,b=[]){const M=Ve();ue(M[0].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),dt(n,s,o,f,w,m,t);const W=xt(c),K=Ce||k.length||He||b.length?(W+1)%3:-1;K>=0?(ue(M[K].fb),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT)):(ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)),r&&(e.enable(e.SCISSOR_TEST),e.scissor(r[0],y-r[1]-r[3],r[2],r[3])),j(Ke,K>=0?M[K].fb:null,[M[W].tex],V=>{e.uniform1i(V("tex"),0),e.uniform2f(V("size"),v,y),e.uniform1f(V("keepPre"),0),e.uniformMatrix3fv(V("inv"),!1,[u[0],u[3],u[6],u[1],u[4],u[7],u[2],u[5],u[8]]),e.uniform4f(V("rnd"),d?.[0]??0,d?.[1]??0,d?.[2]??0,d?1:0)}),e.disable(e.SCISSOR_TEST),K>=0&&Qe(b.length?xt(b,K):K)},adjust(n,s,o){const f=Ve();if(ue(null),e.bindTexture(e.TEXTURE_2D,Rt),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA8,0,0,v,y,0),ue(f[0].fb),e.disable(e.BLEND),e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,Rt),e.uniform4f(F("dst"),0,0,1,1),e.uniform4f(F("src"),0,1,1,-1),e.uniform1i(F("tex"),0),e.uniform1f(F("alpha"),1),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("useMatte"),0),e.uniform1f(F("colour"),n?1:0),n){const m=t=>[t[0],t[3],t[6],t[1],t[4],t[7],t[2],t[5],t[8]];e.uniform1f(F("bright"),n.bright),e.uniform1f(F("contrast"),n.contrast),e.uniformMatrix3fv(F("sat"),!1,m(n.sat)),e.uniformMatrix3fv(F("rot"),!1,m(n.rot))}e.drawArrays(e.TRIANGLE_STRIP,0,4);const w=xt(s);ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),e.useProgram(N),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,f[w].tex),e.uniform4f(F("dst"),0,0,1,1),e.uniform4f(F("src"),0,1,1,-1),e.uniform1f(F("alpha"),o),e.uniform1f(F("fade"),1),e.uniform1f(F("white"),0),e.uniform1f(F("colour"),0),e.uniform1f(F("useMatte"),0),e.drawArrays(e.TRIANGLE_STRIP,0,4)},grade(n,s){if(yt=!!n,Xt=!!s,n&&Ie.l1!==n.key){const o=new Float32Array(1024);for(let f=0;f<256;f++)o[f*4]=n.r[f],o[f*4+1]=n.g[f],o[f*4+2]=n.b[f],o[f*4+3]=1;e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,at),e.texImage2D(e.TEXTURE_2D,0,e.RGBA32F,256,1,0,e.RGBA,e.FLOAT,o);for(const f of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_2D,f,e.NEAREST);e.activeTexture(e.TEXTURE0),Ie.l1=n.key}if(s&&Ie.l3!==s.key){e.activeTexture(e.TEXTURE3),e.bindTexture(e.TEXTURE_3D,pt),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage3D(e.TEXTURE_3D,0,e.RGB32F,s.size,s.size,s.size,0,e.RGB,e.FLOAT,s.data),e.pixelStorei(e.UNPACK_ALIGNMENT,4);for(const o of[e.TEXTURE_MIN_FILTER,e.TEXTURE_MAG_FILTER])e.texParameteri(e.TEXTURE_3D,o,e.NEAREST);for(const o of[e.TEXTURE_WRAP_S,e.TEXTURE_WRAP_T,e.TEXTURE_WRAP_R])e.texParameteri(e.TEXTURE_3D,o,e.CLAMP_TO_EDGE);e.activeTexture(e.TEXTURE0),Ie.l3=s.key}},key(n){if(!n){ke=null;return}const[s,o,f]=[1,3,5].map(m=>parseInt(n.color.slice(m,m+2),16)),w=224/255;ke={u:Math.round(-.168736*w*s-.331264*w*o+.5*w*f+128),v:Math.round(.5*w*s-.418688*w*o-.081312*w*f+128),similarity:n.similarity,blend:n.blend,spill:+n.spill.toFixed(3),blue:f>o}},mode(n){Ce=n&&Yt[n]||0},shadow(n){k=n},blurBegin(){nt??=Me(),ue(nt.fb),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),He=!0},blurEnd(){He=!1;const n=Ve();e.disable(e.BLEND),j(p,n[0].fb,[nt.tex],s=>e.uniform1i(s("tex"),0)),Qe(0)},windows(n){C=n},edge(n){ct=n},warpBig(n,s,o,f,w,m,t,c,u,d=[]){const r=_t(u),b=v*u,M=y*u;e.bindFramebuffer(e.FRAMEBUFFER,r.plane.fb),e.viewport(0,0,b,M),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),dt(n,s,o,f,w,m,t);const W=It(c.map(([Ee,H])=>[Ee*u,H*u]),b,M);e.bindFramebuffer(e.FRAMEBUFFER,r.out.fb),e.viewport(0,0,b,M),e.useProgram(Ke),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,r.plane.tex);const K=$e(Ke);if(e.uniform1i(K("tex"),0),e.uniform2f(K("size"),b,M),e.uniform1f(K("keepPre"),1),e.uniform4f(K("rnd"),0,0,0,0),e.uniformMatrix3fv(K("inv"),!1,[W[0],W[3],W[6],W[1],W[4],W[7],W[2],W[5],W[8]]),e.drawArrays(e.TRIANGLE_STRIP,0,4),ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),!d.length&&!Ce&&!k.length&&!He){j(Q,null,[r.out.tex],Ee=>{e.uniform1i(Ee("tex"),0),e.uniform1i(Ee("ss"),u)});return}const V=Ve();e.disable(e.BLEND),j(Q,V[0].fb,[r.out.tex],Ee=>{e.uniform1i(Ee("tex"),0),e.uniform1i(Ee("ss"),u)}),Qe(xt(d,0))},matte(n,s=[0,0,1,1]){je=n?s:null,n&&(e.activeTexture(e.TEXTURE1),e.bindTexture(e.TEXTURE_2D,wt),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n),e.activeTexture(e.TEXTURE0))},overlay(n,s){ue(null),e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA),s&&(e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,mt),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,s.w,s.h,0,e.RGBA,e.UNSIGNED_BYTE,s.data)),j(ft,null,s?[mt]:[],o=>{e.uniform1i(o("tex"),0),e.uniform1f(o("usetex"),s?1:0),e.uniform4f(o("colour"),...n??[0,0,0,0])})},finish(){e.finish()}}}let Ne="";const Sa=()=>Ne;async function xa(v,{format:y,encode:R=null,tracks:e={},camera:z=null,signal:h,onProgress:N,frames:A,software:ee=!1,liveMotion:ie=!1,range:ae,only:me,sink:de}){const p=performance.now(),{width:T,height:_,fps:I}=Ro(y);Ne="layers",await Promise.all([...new Set(v.filter(i=>!i.colorBypass).flatMap(i=>qt(i.grade).map(l=>l?.lut?.id)).filter(i=>!!i))].map(i=>ar(i))),Io(io(v.filter(i=>!i.disabled)));const X=v.filter(i=>!i.disabled&&!Co(i)),$=io(X),te=Xo(X.reduce((i,l)=>Math.max(i,l.start+l.duration),0)),oe=Math.round(te*I);if(!(oe>0)&&!A)throw Error("Empty timeline");const O=Oo(z)?z:null,_e=zo($,e,O?i=>ki(i,O,T,_):void 0),Te=i=>_e.find(l=>i>=l.start-1e-6&&i<l.start+l.duration-1e-6)??null,Oe=()=>{if(h?.aborted)throw new DOMException("Export cancelled","AbortError")},we=i=>ie&&!A&&!!i.motion&&!i._virtual&&!i.warped,Ye=i=>A||me!=="audio"&&(!ae||i.start<ae.to/I+1e-6&&i.start+i.duration>ae.from/I-1e-6),ze=new Ar,lt=[...X.filter(i=>$t(i)&&!we(i)),...Go(X)].filter(Ye);lt.length&&await(await Pt(async()=>{const{renderTitleFrames:i}=await import("./titleFrames-w-iWje9N.js");return{renderTitleFrames:i}},__vite__mapDeps([0,1,2,3,4,5,6,7]))).renderTitleFrames(lt,y,ze,h);const Fe=new Map;if(X.some(i=>we(i)&&Ye(i))){const i=await Pt(()=>import("./titleFrames-w-iWje9N.js"),__vite__mapDeps([0,1,2,3,4,5,6,7]));for(const l of X.filter(U=>we(U)&&Ye(U)))Fe.set(l.id,i.liveMotion(l,X,y))}X.some(i=>i.kind==="model")&&await(await Pt(async()=>{const{render3DFrames:i}=await import("./timeline3dExport-CmSI_pjv.js");return{render3DFrames:i}},__vite__mapDeps([8,1,9,10,11,6,12,7]))).render3DFrames(v.filter(i=>!i.disabled),y,ze,h,z);for(const i of $.filter(l=>l._group&&l.comp)){const l=[],U=Math.max(1,Math.ceil(i.duration*I-1e-6));await xa(Zi(Ji(i),{W:T,H:_}),{format:y,signal:h,frames:{times:Array.from({length:U},(x,g)=>Qi(i,g/I)),push:(x,g)=>{l[x]=g}}}),ze.frames.set(i.id,l)}const ft=performance.now();Oe(),Ne="mattes";const Ke=X.filter(i=>i.mask||i.person),ye=Ke.length?await Pt(()=>import("./rotoMatte-DyXlW4jK.js").then(i=>i.r),__vite__mapDeps([13,1,6,14])):null;ye&&await ye.prepareMattes(Ke);const Ge=ye?document.createElement("canvas"):null;Ne="media";const We=new Map,Ae=new Map,Le=new Map,it=i=>{let l=We.get(i);return l||(l=new dr({source:new hr(i,{getRetryDelay:ko}),formats:vr}),We.set(i,l)),l};for(const i of X){if(i.kind==="video"&&!Ae.has(i.url)){const l=await it(i.url).getPrimaryVideoTrack();l&&Ae.set(i.url,new pr(l))}if(i.kind==="image"&&!$t(i)&&!ro(i)&&!i._group&&!Le.has(i.url)){const l=await createImageBitmap(await Fr(i.url,h),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"});Le.set(i.url,{source:l,w:l.width,h:l.height,close:()=>l.close()})}}const Q=new Map,be=async(i,l)=>{const U=Fe.get(i.id);if(U)return{source:await U.frame(Math.round((l-i.start)*I)),w:U.W,h:U.H};const x=ze.frames.get(i.id);if(!x?.length)return null;let g=x.length===1?0:Math.max(0,Math.min(Math.round((l-i.start)*I),Math.ceil(i.duration*I)-1,x.length-1));for(;g>0&&x[g]==="=";)g--;const C=Q.get(i.id);if(C&&C.index===g)return C.pic;C?.pic?.close?.();const P=await createImageBitmap(await(await fetch(`data:image/webp;base64,${x[g]}`)).blob(),{premultiplyAlpha:"none",colorSpaceConversion:"none"}),se={source:P,w:P.width,h:P.height,close:()=>P.close()};return Q.set(i.id,{index:g,pic:se}),se},ut=X.filter(i=>qo(i)),qe=ut.length?await Pt(()=>import("./captionLayout-CNgb471H.js"),__vite__mapDeps([15,1])):null,De=new Map,rt=new Map;if(qe){for(const i of new Set(ut.flatMap(l=>[Qt($o(l.captionStyle).font),Qt(ao(l.captionStyle).font)])))if(await qe.captionFontReady(i.id),!De.has(i.id)){const l=new Uint8Array(await(await fetch(`/fonts/${i.file}`,{signal:h})).arrayBuffer());let U="";for(let x=0;x<l.length;x+=32768)U+=String.fromCharCode(...l.subarray(x,x+32768));De.set(i.id,`@font-face{font-family:'${i.family}';src:url(data:font/${i.file.endsWith(".otf")?"otf":"ttf"};base64,${btoa(U)})}`)}}const $e=new Map,F=async(i,l,U)=>{let x=$e.get(l.start);if(!x||x.owner!==i){const S=ni(i,l.start,l.duration);x={plan:S,starts:si(S.entries,I),owner:i},$e.clear(),$e.set(l.start,x)}const g=U-Math.round(l.start*I);let C=-1;for(let S=0;S<x.starts.length&&x.starts[S]<=g;S++)C=S;const P=x.plan.entries[C];if(!P||P.blank)return null;const se=x.plan.social?x.plan.social.style:ao(i.captionStyle),Y=x.plan.social?ci(x.plan.social,P.gi,T,_,qe.measureCaption):li({width:T,height:_,text:P.text,style:se,measure:qe.measureCaption,second:P.second}),Z=fi(Y,se,x.plan.social?P.scale:1,T,_,P.active,P.motion);let a=rt.get(Z);if(!a){const S=Qt(se.font),ce=URL.createObjectURL(new Blob([Z.replace("<defs>",`<defs><style>${De.get(S.id)??""}</style>`)],{type:"image/svg+xml"}));try{const ve=new Image(T,_);ve.src=ce,await ve.decode();const le=await createImageBitmap(ve,{premultiplyAlpha:"none"});a={source:le,w:T,h:_,close:()=>le.close()}}finally{URL.revokeObjectURL(ce)}if(rt.size>64){const[ve,le]=rt.entries().next().value;le.close?.(),rt.delete(ve)}rt.set(Z,a)}return a},pe=[0,0,1,1],mt=new Map,wt=["x","y","zoom","rot","sx","sy"],je=(i,l,U,x)=>{const g=`${i.id}@${l.start}`;let C=mt.get(g);if(!C){const se=Math.max(1,Math.ceil(l.duration/.1-1e-6)),Y=Array.from({length:se+1},(S,ce)=>l.start+l.duration*ce/se),Z=Y.map(S=>Zt(i,S-i.start,T,_)),a=S=>+(+S).toFixed(3);C={ts:Y.map(S=>+S.toFixed(5)),v:Object.fromEntries(wt.map(S=>[S,Z.map(ce=>a(ce[S]??(S==="sx"||S==="sy"?1:0)))]))},mt.set(g,C)}const P={...x};for(const se of wt){const Y=C.v[se];if(Y.every(ce=>ce===Y[0])){P[se]=Y[0];continue}let Z=C.ts.findIndex((ce,ve)=>ve<C.ts.length-1&&U<C.ts[ve+1]);Z<0&&(Z=C.ts.length-2);const a=+(Y[Z+1]-Y[Z]).toFixed(3),S=C.ts[Z+1]-C.ts[Z];P[se]=Math.abs(Y[Z+1]-Y[Z])<1e-4?Y[Z]:Y[Z]+a*Math.max(0,Math.min(1,(U-C.ts[Z])/S))}return P},at=new Map,pt=new Map,Ie=(i,l,U,x=i,g="")=>{if(!ui(x))return Eo(x,T);const C=`${i.id}${g}@${l.start}`;let P=pt.get(C);P||(P=mi(x,{offset:l.start-i.start,duration:l.duration,fps:I}),pt.set(C,P));const se=U-Math.round(l.start*I),Y=P.find(Z=>se>=Z.from&&se<Z.to)??P[P.length-1];return Eo({effects:pi(x,Y.t)},T)},yt=new Map,Xt=(i,l,U)=>{const x=`${i.id}@${l.start}`;yt.has(x)||yt.set(x,O?Fi(i,O,l.start,l.duration,T,_):null);const g=yt.get(x);return g?Ie(i,l,U,g,":dof"):[]},ke=new Map,Yt=i=>{const l=JSON.stringify(i.grade);let U=ke.get(l);if(!U){const x=P=>Array.from(P,se=>+se.toFixed(6)),g=hi(i.grade)?bi(i.grade):null,C=i.grade.mixer&&Ei(i.grade.mixer)?gi(i.grade.mixer):null;U={l1:g?{key:`1${l}`,r:x(g.r),g:x(g.g),b:x(g.b)}:null,l3:C?{key:`3${l}`,size:C.size,data:Float32Array.from(C.data,P=>+P.toFixed(6))}:null},ke.set(l,U)}return U};let Ce=null;const Rt=async(i,l,U)=>{const x=X.find(P=>P.id===i);if(!x||l<x.start||l>=x.start+x.duration)return null;if($t(x)){const P=await be(x,l);return P&&{source:P.source,w:P.w,h:P.h}}if(x.kind==="image"){const P=Le.get(x.url);return P?{source:P.source,w:P.w,h:P.h}:null}if(x.kind!=="video")return null;const g=await To(Me,Ae,x,l,I,Math.max(U.start,x.start),U.duration);if(!g)return null;const C=g.toVideoFrame();return{source:C,w:g.displayWidth,h:g.displayHeight,close:()=>C.close()}};Ne="output";const k=pa(T,_),He=So(R,{width:T,height:_,fps:I},Ao),nt=R?.codec==="hevc",St=R?.container==="mov",Qe=!A&&!de&&te*He/8>15e7&&!!navigator.storage?.getDirectory;let Xe=null,Ue;if(Qe){const i=await navigator.storage.getDirectory(),l=`gpu-export-${crypto.randomUUID()}.${St?"mov":"mp4"}`,U=await i.getFileHandle(l,{create:!0});Xe={dir:i,handle:U,name:l},Ue=new go(await U.createWritable(),{chunked:!0,chunkSize:1<<20})}else Ue=de&&!A?new go(de,{chunked:!0,chunkSize:1<<22}):new Er;const Ve=de&&!A?!1:Qe?"reserve":"in-memory",Ze=new gr({format:St?new Tr({fastStart:Ve}):new wr({fastStart:Ve}),target:Ue}),_t=new yr(k.canvas,{codec:nt?"hevc":"avc",bitrate:He,keyFrameInterval:2,...nt?{hardwareAcceleration:"prefer-hardware"}:ee?{hardwareAcceleration:"prefer-software"}:{}}),Je=me==="audio"?0:Math.max(0,Math.min(oe,ae?.from??0)),Ft=me==="audio"?0:Math.max(Je,Math.min(oe,ae?.to??oe));me!=="audio"&&Ze.addVideoTrack(_t,{frameRate:I,...Qe?{maximumPacketCount:Ft-Je+8}:{}});const Dt=new Rr({codec:"aac",bitrate:Do});me!=="video"&&Ze.addAudioTrack(Dt,Qe?{maximumPacketCount:Math.ceil(te*Ct/1024)+16}:{}),A||await Ze.start();const Ot=A?new OffscreenCanvas(T,_):null,zt=Ot?.getContext("2d"),Kt=async i=>{zt.putImageData(new ImageData(k.pixels(),T,_),0,0);const l=new Uint8Array(await(await Ot.convertToBlob({type:"image/webp",quality:.9})).arrayBuffer());let U="";for(let x=0;x<l.length;x+=32768)U+=String.fromCharCode(...l.subarray(x,x+32768));A.push(i,btoa(U))},Me=new Map;let ue=0;const j={decode:0,matte:0,titles:0,captions:0,encode:0},st=async(i,l)=>{const U=performance.now();try{return await l}finally{j[i]+=performance.now()-U}},At=(i,l)=>{const U=performance.now();try{return l()}finally{j[i]+=performance.now()-U}};try{for(let l=A?0:Je,U=A?A.times.length:Ft;l<U;l++){Oe(),Ne="frame";const x=A?A.times[l]:l/I,g=Te(x);k.clear(A?0:1);const C=g&&qe?jo(X,g.start+1e-5,e):void 0,P=C&&g?Ho(g.visuals,C.captionStyle?.layerTrack):-1,se=async()=>{const Y=C&&g&&await st("captions",F(C,g,l));Y&&(k.shadow([]),k.edge(null),k.windows(null),k.matte(null),k.mode(void 0),k.key(null),k.grade(null,null),k.draw(Y,pe,pe,1,1,!1,null,[]))};for(const[Y,Z]of(g?.visuals??[]).entries()){let a=Z;if(Y===P&&await se(),a.kind==="audio")continue;const S=g?no(a,g.start,g.start+g.duration):null,ce=S?a._txIn===S?"b":"a":null,ve=S?Vo(S,x):0;e:{if(a.kind==="model"){k.matte(null),k.edge(null),k.windows(null),k.mode(void 0),k.shadow(so(a,T)),k.key(null),k.grade(null,null);const m=await be(a,x);m&&k.draw(m,pe,pe,1,1,!1,null,[]);break e}const le=x-a.start,Re=Zt(a,le,T,_),ne=(Yo(a)||Ko(a))&&!S&&!(O&&jt(a))&&!a.pin?je(a,g,x,Re):Re;if(!(ne.opacity>1e-4))break e;if(ro(a)){k.adjust(ot(a),Ie(a,g,l),Math.min(1,ne.opacity));break e}let B=null,Pe=null;if($t(a)||a._group)B=await st("titles",be(a,x));else if(a.kind==="image")B=Le.get(a.url)??null;else if(a.kind==="video"){const m=await st("decode",To(Me,Ae,a,x,I,g.start,g.duration));m&&(Pe=m.toVideoFrame(),B={source:Pe,w:m.displayWidth,h:m.displayHeight,bt709:Pe.colorSpace?.matrix?Pe.colorSpace.matrix==="bt709":m.displayHeight>=720})}if(!B)break e;if(Wo(a)){const m=a.crop||{left:0,right:0,top:0,bottom:0},t=Math.floor(B.w*m.left/2)*2,c=Math.floor(B.h*m.top/2)*2,u=Math.max(2,Math.floor(B.w*(1-m.left-m.right)/2)*2),d=Math.max(2,Math.floor(B.h*(1-m.top-m.bottom)/2)*2),r=a.distort.displace?await Rt(a.distort.displace.map,x,g):null;Ce??=mr();const b=Ce.render({source:B.source,srcW:B.w,srcH:B.h,rect:[t,c,u,d],outW:u,outH:d,distort:a.distort,local:le,map:r?.source??null,matte:ye&&(a.mask||a.person)?ye.matteCanvas(a,le,Ge,!1,X):null});r?.close?.(),B={source:b,w:u,h:d,bt709:B.bt709},a={...a,crop:void 0,mask:void 0,person:void 0}}if(ye&&(a.mask||a.person)){const m=a.crop||{left:0,right:0,top:0,bottom:0},t=Math.max(2,Math.floor(B.w*(1-m.left-m.right)/2)*2),c=Math.max(2,Math.floor(B.h*(1-m.top-m.bottom)/2)*2);k.matte(At("matte",()=>ye.matteCanvas(a,le,Ge,!1,X)),[m.left,m.top,t/B.w,c/B.h])}else k.matte(null);k.mode(a.blend),k.key(a.key),k.shadow(so(a,T));{const m=a.colorBypass?[]:qt(a.grade).filter(Jt);k.windows(m.length?{key:`${a.id}@${l}`,list:qt(a.grade),clip:a.id,src:a,frame:Math.round((x-a.start)*I),local:Math.round((x-a.start)*I)/I}:null)}if(co(a)&&lo(fo(a),le)>.001){const m=fo(a),t=ye&&(a.mask||a.person),c=a.crop||{left:0,right:0,top:0,bottom:0},u=t?Math.max(2,Math.floor(t.mw*(1-c.left-c.right)/2)*2):B.w,d=t?Math.max(2,Math.floor(t.mh*(1-c.top-c.bottom)/2)*2):B.h,r=u>=d?Ht:Math.max(8,Math.trunc(Ht*u/d/8)*8),b=u>=d?Math.max(8,Math.trunc(Ht*d/u/8)*8):Ht,M=Qo(m),W=lo(m,le),K=!!m.keys?.length||m.amount<.999;k.edge({key:`${a.id}@${l}`,ew:r,eh:b,band:M.band,glow:M.glow,k:m.glow,col:[1,3,5].map(V=>parseInt(m.color.slice(V,V+2),16)/255),am:K?Math.trunc(255*W):255,harden:!!t})}else k.edge(null);{const m=a.grade&&!a.colorBypass?Yt(a):null;k.grade(m?.l1??null,m?.l3??null)}if(a.pin&&!(O&&jt(a))&&g&&uo(a,X,g.start,T,_,O)){const m=uo(a,X,x,T,_,O)??[[0,0],[0,0],[0,0],[0,0]],t=Bt(a,le),c=Zo(a,X,T,_,O),u=a.pin.dive,d=c&&!a.pin.scene?[+(c[0]*T).toFixed(3),+(c[1]*_).toFixed(3),u?Math.max(0,Math.min(1,(x-u.at)/u.dur)):0]:null;k.warp(B,Nt([0,0,1,1],T,_),bo(a,B.w,B.h),Math.min(1,ne.opacity),t.k,t.white,ot(a),Ie(a,g,l),It(m,T,_),d),Pe?.close();break e}const kt=Jo(a,"rot")||ei(a),dt=()=>a.motionBlur?rr(x,I).map(m=>({...Zt(a,m-a.start,T,_),rot:ne.rot,opacity:ne.opacity})):[ne];if((kt||Math.abs(ne.rot||0)>1e-9)&&!(O&&jt(a))){const m=Bt(a,le),t=S&&ce?[...yo(S.spec[ce],ve,T,_,x,S.spec.zoomAt),...ce==="b"&&S.spec.mask?[wo(S.spec.mask,ve)]:[]]:[];a.motionBlur&&k.blurBegin();for(const c of dt()){const u=er(a,B.w,B.h,T,_,c,kt);k.warp(B,Nt([0,0,1,1],T,_),bo(a,B.w,B.h),Math.min(1,ne.opacity),m.k,m.white,ot(a),[],It(u.quad,T,_),null,u.clip,t)}a.motionBlur&&k.blurEnd(),Pe?.close();break e}if(O&&jt(a)){const m=ti(a,le,O,x,T,_);if(m){const t=Lt(a,B.w,B.h,T,_,{x:0,y:0,zoom:1}),c=Bt(a,le),u=Ie(a,g,l);let d=at.get(a.id);d===void 0&&(d=a.effects?.some(b=>!b.off)||a.mask||a.person||co(a)||!a.colorBypass&&qt(a.grade).some(Jt)?1:oi(ii(a,O,T,_),B.w,B.h,T,_),at.set(a.id,d));const r=Xt(a,g,l);d>1&&!u.length?k.warpBig(B,Nt(t.dst,T,_),t.src,Math.min(1,ne.opacity),c.k,c.white,ot(a),m.quad,d,r):k.warp(B,Nt(t.dst,T,_),t.src,Math.min(1,ne.opacity),c.k,c.white,ot(a),u,It(m.quad,T,_),null,null,r)}Pe?.close();break e}if(a.motionBlur&&!S&&!Ie(a,g,l).length){const m=Bt(a,le);k.blurBegin();for(const t of dt()){const c=Lt(a,B.w,B.h,T,_,t);k.draw(B,c.dst,c.src,Math.min(1,ne.opacity),m.k,m.white,ot(a),[])}k.blurEnd(),Pe?.close();break e}const{dst:vt,src:n}=Lt(a,B.w,B.h,T,_,ne),s=Bt(a,le),o=[...Ie(a,g,l),...S&&ce?yo(S.spec[ce],ve,T,_,x,S.spec.zoomAt):[],...S&&ce==="b"&&S.spec.mask?[wo(S.spec.mask,ve)]:[]],f=S&&ce?S.spec[ce]?.rot:null;if(f){const m=Vt(f,ve)??0;k.warp(B,Nt([0,0,1,1],T,_),n,Math.min(1,ne.opacity),s.k,s.white,ot(a),[],It(tr(vt,T,_,m),T,_),null,null,o),Pe?.close();break e}if(o.length>0&&!!g&&!a.layout&&!no(a,g.start,g.start+g.duration)&&ri(a,g.start,g.start+g.duration,T,_)){const m=Lt(a,B.w,B.h,T,_,{x:0,y:0,zoom:1}),t=Lt({},T,_,T,_,ne);k.draw(B,t.dst,m.src,Math.min(1,ne.opacity),s.k,s.white,ot(a),o,m.dst)}else k.draw(B,vt,n,Math.min(1,ne.opacity),s.k,s.white,ot(a),o);Pe?.close()}if(S&&ce==="b"){if(S.spec.light){const Re=Math.max(2,Math.ceil(T/mo)),ne=Math.max(2,Math.ceil(_/mo));k.overlay(null,{data:ai(S.spec,ve,Re,ne),w:Re,h:ne})}const le=S.spec.flash;if(le){const Re=Vt(le.opacity,ve)??0;if(Re>1e-4){const ne=parseInt(le.color.slice(1),16);k.overlay([(ne>>16&255)/255,(ne>>8&255)/255,(ne&255)/255,Math.min(1,Re)],null)}}}}P>=0&&P>=(g?.visuals.length??0)&&await se();for(const[Y,Z]of Me){const a=Y.split(`
189
- `)[0],S=$.find(ce=>ce.id===a);(!S||x>S.start+S.duration+1)&&(Z.current?.close(),Z.peek?.close(),await Z.iterator.return?.(),Me.delete(Y))}if(A){await Kt(l);continue}Ne="video encode",await st("encode",_t.add((l-Je)/I,1/I)),N?.((me==="video"?1:.9)*(l+1-Je)/Math.max(1,Ft-Je))}if(A)return{blob:new Blob,ms:{titles:0,video:0,audio:0,total:Math.round(performance.now()-p)}};const i=performance.now();if(me==="video")_t.close(),Ne="finalize",await Ze.finalize();else{Ne="audio";const l=new Map($.map(x=>[x.id,x])),U=await va(X.map(x=>l.get(x.id)??x),_e,te,e,it,h);typeof y.loudness=="number"&&or([U.getChannelData(0),U.getChannelData(1)],y.loudness,Ct),Ne="audio encode",await Dt.add(U),ue=performance.now()-i,me!=="audio"&&_t.close(),Dt.close(),Ne="finalize",await Ze.finalize()}}catch(i){throw await Ze.cancel().catch(()=>{}),Xe&&await Xe.dir.removeEntry(Xe.name).catch(()=>{}),i}finally{for(const i of Me.values())i.current?.close(),i.peek?.close();Ce?.dispose();for(const i of Le.values())i.close?.();for(const i of Q.values())i.pic?.close?.();for(const i of Fe.values())i.close();for(const i of rt.values())i.close?.();for(const i of We.values())i.dispose?.()}N?.(1),Ne="file";const xt=Xe?await Xe.handle.getFile():de?new Blob([]):new Blob([Ue.buffer],{type:St?"video/quicktime":"video/mp4"});Xe&&setTimeout(()=>void Xe.dir.removeEntry(Xe.name).catch(()=>{}),600*1e3);const ct=performance.now()-p;return{blob:xt,ms:{titles:Math.round(ft-p),video:Math.round(ct-(ft-p)-ue),audio:Math.round(ue),total:Math.round(ct),parts:Object.fromEntries(Object.entries(j).map(([i,l])=>[i,Math.round(l)]))}}}function da(v,y,R,e,z){const h=[new Float32Array(Math.max(1,Math.round(z*R))),new Float32Array(Math.max(1,Math.round(z*R)))],N=Math.round(Ui*R);return y.forEach((A,ee)=>{if(A.silent)return;const ie=Math.round((A.t1-A.t0)*R)+(ee<y.length-1?N:0),ae=Math.abs(A.rate),me=Math.round(A.t0*R),de=Math.max(0,Math.round(((A.rate>0?A.s0:A.s0-ae*ie/R)-e)*R)),p=Math.min(v[0].length,Math.round(((A.rate>0?A.s0+ae*ie/R:A.s0)-e)*R));if(p-de<2)return;const T=(p-de)/ie,_=Math.round(.06*R),I=Math.max(0,de-_),X=Math.min(v[0].length,p+_);let $=v.map(oe=>oe.slice(I,X));A.rate<0&&$.forEach(oe=>oe.reverse());const te=Math.round((A.rate<0?X-p:de-I)/T);$=Mo($,T,R).map(oe=>oe.subarray(te,te+ie));for(let oe=0;oe<2;oe++)for(let O=0;O<ie&&me+O<h[oe].length;O++){const _e=(ee>0&&O<N?O/N:1)*(ee<y.length-1&&O>=ie-N?(ie-O)/N:1);h[oe][me+O]+=($[oe][O]??0)*_e}}),h}async function va(v,y,R,e,z,h){const N=new OfflineAudioContext({numberOfChannels:2,length:Math.max(1,Math.round(R*Ct)),sampleRate:Ct}),A=1/200,ee=v.filter(p=>(p.kind==="video"||p.kind==="audio")&&!p.freeze&&!Fo(p)&&(p.volume??1)>0),ie=p=>(p.kind==="video"||p.kind==="audio")&&!!p.url,ae=new Map;for(const p of y.flatMap(T=>T.audios))!ie(p)||ae.has(p.url)||ae.set(p.url,await z(p.url).getPrimaryAudioTrack().then(T=>!!T,()=>!1));const me=p=>ie(p)&&!!ae.get(p.url);for(const p of ee){if(h?.aborted)throw new DOMException("Export cancelled","AbortError");const T=Math.max(2,Math.ceil(p.duration/A)+1),_=new Float32Array(T);let I=!1;const X=Ai(p.track,e);for(let Q=0;Q<T;Q++){const be=p.start+Math.min(p.duration,Q*A),ut=y.find(De=>be>=De.start-1e-6&&be<De.start+De.duration-1e-6),qe=ut?.audios.some(De=>De.id===p.id)?Mi(p,be-p.start)*X.gain/Si(ut.audios,me):0;_[Q]=qe,qe>0&&(I=!0)}if(!I)continue;const $=await z(p.url).getPrimaryAudioTrack();if(!$)continue;const te=_o(p)?Di(p,0,p.duration):null,oe=p.playbackRate||1,O=new br($),_e=te?te.flatMap(Q=>[Q.s0,Q.s1]):[],Te=te?Math.max(0,Math.min(..._e)-.2):p.inPoint||0,Oe=te?Math.max(..._e)+.2:Te+p.duration*oe,we=[];let Ye=Te;for await(const Q of O.samples(Te,Oe))we.length||(Ye=Q.timestamp),we.push(Q.toAudioBuffer()),Q.close();if(!we.length)continue;const ze=we[0].sampleRate,lt=we.reduce((Q,be)=>Q+be.length,0);let Fe=[new Float32Array(lt),new Float32Array(lt)],ft=0;for(const Q of we){for(let be=0;be<2;be++)Fe[be].set(Q.getChannelData(Math.min(be,Q.numberOfChannels-1)),ft);ft+=Q.length}te?Fe=da(Fe,te,ze,Ye,p.duration):oe!==1&&(Fe=Mo(Fe,oe,ze));const Ke=N.createBuffer(2,Fe[0].length,ze);for(let Q=0;Q<2;Q++)Ke.copyToChannel(Fe[Q],Q);const ye=N.createBufferSource();ye.buffer=Ke;const Ge=N.createGain();Ge.gain.value=0,Ge.gain.setValueCurveAtTime(_,p.start,Math.max(A,p.duration));const We=N.createChannelSplitter(2),Ae=N.createChannelMerger(2),Le=N.createGain(),it=N.createGain();Le.gain.value=X.left,it.gain.value=X.right,ye.connect(Ge),Ge.connect(We),We.connect(Le,0),We.connect(it,1),Le.connect(Ae,0,0),it.connect(Ae,0,1),Ae.connect(N.destination),ye.start(p.start,te?0:Math.max(0,Te-Ye)/oe,p.duration)}const de=await N.startRendering();return ir([de.getChannelData(0),de.getChannelData(1)]),de}export{Aa as canEncodeHevc,Fa as canEncodeMp4,xa as exportOnGpu,Ao as gpuBitrate,Sa as gpuExportStage,Ma as gpuExportSupported};
@@ -1 +0,0 @@
1
- import{a8 as kt,a9 as Ft}from"./main-M1vRa-gd.js";import{iI as V,iJ as It}from"./remote-sTZauTqM.js";import"./titleFrameBudget-3MFHWIT6.js";import"./api-BsKbf3l3.js";import"./store-BSSbvpzr.js";import"./three.module-Bx43vjkH.js";import"./spark.module-BRT8yMS4.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const dt=Object.freeze({core:.5,band:.16,ring:.55,sep:22,lo:.1,hi:.78,guideR:2,guideEps:.002,maxW:512,choke:[.5,.66],close:.08,closeArm:.22,chokeAI:[.45,.62],chokeArm:[.22,.4]}),ut=[[0,1],[1,2],[2,3],[3,4],[0,5],[5,6],[6,7],[7,8],[5,9],[9,10],[10,11],[11,12],[9,13],[13,14],[14,15],[15,16],[13,17],[0,17],[17,18],[18,19],[19,20]],at=[0,1,5,9,13,17];function X(l,t,n,g,A,d,y=255){const a=Math.max(0,Math.floor(Math.min(t[0],n[0])-g)),e=Math.min(A-1,Math.ceil(Math.max(t[0],n[0])+g)),M=Math.max(0,Math.floor(Math.min(t[1],n[1])-g)),p=Math.min(d-1,Math.ceil(Math.max(t[1],n[1])+g)),U=n[0]-t[0],i=n[1]-t[1],f=U*U+i*i||1,c=g*g;for(let m=M;m<=p;m++)for(let o=a;o<=e;o++){const N=o+.5-t[0],z=m+.5-t[1],$=Math.max(0,Math.min(1,(N*U+z*i)/f)),H=N-$*U,B=z-$*i;H*H+B*B<=c&&l[m*A+o]<y&&(l[m*A+o]=y)}return l}function W(l,t,n,g,A=255){const d=t.length;if(d<3)return l;let y=1/0,a=-1/0;for(const M of t)M[1]<y&&(y=M[1]),M[1]>a&&(a=M[1]);y=Math.max(0,Math.floor(y)),a=Math.min(g-1,Math.ceil(a));const e=[];for(let M=y;M<=a;M++){const p=M+.5;e.length=0;for(let i=0,f=d-1;i<d;f=i++){const c=t[f],m=t[i];(c[1]<=p&&m[1]>p||m[1]<=p&&c[1]>p)&&e.push([c[0]+(p-c[1])/(m[1]-c[1])*(m[0]-c[0]),m[1]>c[1]?1:-1])}if(e.length<2)continue;e.sort((i,f)=>i[0]-f[0]);let U=0;for(let i=0;i<e.length-1;i++){if(U+=e[i][1],!U)continue;const f=Math.max(0,Math.ceil(e[i][0]-.5)),c=Math.min(n-1,Math.floor(e[i+1][0]-.5)),m=M*n;for(let o=f;o<=c;o++)l[m+o]<A&&(l[m+o]=A)}}return l}function ht(l,t,n,g){const A=t+1,d=l.map(y=>{const a=new Float64Array(A*(n+1));for(let e=0;e<n;e++){let M=0;for(let p=0;p<t;p++)M+=y[e*t+p],a[(e+1)*A+p+1]=a[e*A+p+1]+M}return a});return(y,a,e)=>{const M=d[y],p=Math.max(0,a-g),U=Math.min(t,a+g+1),i=Math.max(0,e-g),f=Math.min(n,e+g+1);return M[f*A+U]-M[i*A+U]-M[f*A+p]+M[i*A+p]}}function Yt(l,t,n,g,A={}){const{learned:d=null,...y}=A,a={...dt,...y},e=t*n,M=new Uint8Array(e),p=new Uint8Array(e),U=new Uint8Array(e),i=new Uint8Array(e),f=new Uint8Array(e),c=(g||[]).filter(r=>r?.lm?.length>=21);if(!c.length)return new Uint8Array(e);const m=r=>r.map(([h,x])=>[h*t,x*n]);let o=0;for(const r of c){o=Math.max(o,Math.hypot((r.lm[0][0]-r.lm[9][0])*t,(r.lm[0][1]-r.lm[9][1])*n)),W(M,m(V(r.lm,t,n,{edge:r.edge?r.edge.map(x=>Math.min(0,x)):null,scale:a.core})),t,n),W(i,m(V(r.lm,t,n,{edge:r.edge})),t,n),W(p,m(V(r.lm,t,n,{edge:r.edge,grow:a.band})),t,n),W(U,m(V(r.lm,t,n,{edge:r.edge,grow:a.ring})),t,n);const h=V(r.lm,t,n,{edge:r.edge,grow:a.band});W(f,m(It.map(x=>h[x])),t,n)}if(d){const r=new Uint8Array(e),h=new Uint8Array(e);for(const u of c){const s=u.lm.map(([P,L])=>[P*t,L*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]),k=Array.isArray(u.armDir)?u.armDir:[(s[0][0]-s[9][0])/(F||1),(s[0][1]-s[9][1])/(F||1)],I=[s[0][0]+k[0]*4*F,s[0][1]+k[1]*4*F];for(const[P,L]of ut)X(r,s[P],s[L],.45*F,t,n),X(h,s[P],s[L],.08*F,t,n);W(r,at.map(P=>s[P]),t,n),W(h,at.map(P=>s[P]),t,n);const Q=[s[0][0]+k[0]*Math.max(t,n)*1.5,s[0][1]+k[1]*Math.max(t,n)*1.5];X(r,s[0],Q,1.6*F,t,n),X(h,s[0],I,.12*F,t,n)}const x=new Uint8Array(e);for(const u of c){const s=u.lm.map(([k,I])=>[k*t,I*n]),F=Math.hypot(s[0][0]-s[9][0],s[0][1]-s[9][1]);for(const[k,I]of ut)X(x,s[k],s[I],.45*F,t,n);W(x,at.map(k=>s[k]),t,n)}const j=[];for(let u=0;u<e;u+=2)if(h[u]&&x[u]&&d[u]>.6){const s=u*4;j.push([l[s],l[s+1],l[s+2]])}j.sort((u,s)=>u[0]+u[1]+u[2]-s[0]-s[1]-s[2]);const S=j.length>=30?[0,1,2].map(u=>{const s=j.slice(Math.floor(j.length*u/3),Math.floor(j.length*(u+1)/3));return[0,1,2].map(F=>s.reduce((k,I)=>k+I[F],0)/s.length)}):null,D=new Float32Array(e),T=new Float32Array(e),q=new Float32Array(e),C=new Float32Array(e);for(let u=0;u<e;u++)if(d[u]<.1){const s=u*4;D[u]=1,T[u]=l[s],q[u]=l[s+1],C[u]=l[s+2]}const E=S?ht([D,T,q,C],t,n,Math.max(4,Math.round(o*.6))):null,Z=u=>{if(!S||!x[u])return 1;const s=u%t,F=u/t|0,k=E(0,s,F);if(k<4)return 1;const I=[E(1,s,F)/k,E(2,s,F)/k,E(3,s,F)/k],Q=u*4,P=[l[Q],l[Q+1],l[Q+2]];let L=0,et=1/0;for(const it of S){const R=[it[0]-I[0],it[1]-I[1],it[2]-I[2]],lt=R[0]*R[0]+R[1]*R[1]+R[2]*R[2];et=Math.min(et,Math.sqrt(lt)),lt>=1&&(L=Math.max(L,((P[0]-I[0])*R[0]+(P[1]-I[1])*R[1]+(P[2]-I[2])*R[2])/lt))}if(et<a.sep)return 1;const rt=Math.max(0,Math.min(1,(L-.12)/.2));return rt*rt*(3-2*rt)},v=d,G=new Uint8Array(e),[O,K]=a.chokeAI,[gt,Ut]=a.chokeArm;for(let u=0;u<e;u++){if(!r[u])continue;const s=x[u]?O:gt,F=x[u]?K:Ut;if(v[u]<s)continue;const k=Math.max(0,Math.min(1,(v[u]-s)/(F-s)))*Z(u);G[u]=Math.round(255*k*k*(3-2*k))}return Mt(G,t,n,{snapped:h,band:r,core:h,arm:f,r:1,rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.03*o*o)})}const N=[];for(let r=0;r<e;r+=3)if(M[r]){const h=r*4;N.push([l[h],l[h+1],l[h+2]])}if(N.length<12)return i;N.sort((r,h)=>r[0]+r[1]+r[2]-h[0]-h[1]-h[2]);const z=r=>{const h=N.slice(Math.floor(N.length*r/3),Math.floor(N.length*(r+1)/3));return[0,1,2].map(x=>h.reduce((j,S)=>j+S[x],0)/h.length)},$=[z(0),z(1),z(2)],H=new Float32Array(e),B=new Float32Array(e),w=new Float32Array(e),tt=new Float32Array(e);let st=0,ct=0,ft=0,_=0;for(let r=0;r<e;r++)if(U[r]&&!p[r]){const h=r*4;H[r]=1,B[r]=l[h],w[r]=l[h+1],tt[r]=l[h+2],st+=B[r],ct+=w[r],ft+=tt[r],_++}const yt=_?[st/_,ct/_,ft/_]:null,b=ht([H,B,w,tt],t,n,Math.max(3,Math.round(o*.45))),J=new Float32Array(e),nt=new Uint8Array(e);for(let r=0;r<n;r++)for(let h=0;h<t;h++){const x=r*t+h;if(!p[x]&&!(d&&U[x]&&!f[x]&&d[x]>.3))continue;if(nt[x]=1,M[x]){J[x]=1;continue}const j=b(0,h,r),S=j>2?[b(1,h,r)/j,b(2,h,r)/j,b(3,h,r)/j]:yt;if(!S){J[x]=i[x]/255;continue}const D=x*4,T=[l[D],l[D+1],l[D+2]];let q=0,C=1/0;for(const G of $){const O=[G[0]-S[0],G[1]-S[1],G[2]-S[2]],K=O[0]*O[0]+O[1]*O[1]+O[2]*O[2];C=Math.min(C,Math.sqrt(K)),!(K<1)&&(q=Math.max(q,((T[0]-S[0])*O[0]+(T[1]-S[1])*O[1]+(T[2]-S[2])*O[2])/K))}const E=d&&!f[x]?d[x]:null;if(C<a.sep){J[x]=E??i[x]/255;continue}const Z=Math.max(0,Math.min(1,(q-a.lo)/(a.hi-a.lo))),v=Z*Z*(3-2*Z);J[x]=E===null?v:E*v}const xt=kt(J,Ft(l,t,n),t,n,{r:a.guideR,eps:a.guideEps}),ot=new Uint8Array(e),[mt,At]=a.choke;for(let r=0;r<e;r++){if(!nt[r])continue;if(M[r]){ot[r]=255;continue}const h=Math.max(0,Math.min(1,(xt[r]-mt)/(At-mt)));ot[r]=Math.round(255*h*h*(3-2*h))}return Mt(ot,t,n,{snapped:i,band:nt,core:M,arm:f,r:Math.max(1,Math.round(o*a.close)),rArm:Math.max(2,Math.round(o*a.closeArm)),small:Math.round(.12*o*o)})}function pt(l,t,n,g,A,d,y){const a=2*d+1,e=new Uint8Array(n+a),M=new Uint8Array(n+a),p=f=>{const c=Math.max(0,Math.min(n-1,f-d));return l[g+c*A]},U=n+2*d,i=y?(f,c)=>f>c?f:c:(f,c)=>f<c?f:c;for(let f=0;f<U;f+=a){const c=Math.min(U,f+a);e[f]=p(f);for(let m=f+1;m<c;m++)e[m]=i(e[m-1],p(m));M[c-1]=p(c-1);for(let m=c-2;m>=f;m--)M[m]=i(M[m+1],p(m))}for(let f=0;f<n;f++)t[g+f*A]=i(M[f],e[f+2*d]??e[U-1])}function Y(l,t,n,g,A){const d=new Uint8Array(l.length),y=new Uint8Array(l.length);for(let a=0;a<n;a++)pt(l,d,t,a*t,1,g,A);for(let a=0;a<t;a++)pt(d,y,n,a,t,g,A);return y}function Mt(l,t,n,{snapped:g,band:A,core:d,arm:y,r:a,rArm:e,small:M}){const p=t*n,U=new Uint8Array(p);for(let o=0;o<p;o++)U[o]=l[o]>=128?255:0;const i=Y(Y(U,t,n,a,!0),t,n,a,!1),f=Y(Y(U,t,n,e,!0),t,n,e,!1);for(let o=0;o<p;o++)!U[o]&&A[o]&&(y[o]&&(i[o]||f[o])||!y[o]&&i[o]&&d[o])&&(l[o]=255);jt(l,t,n,d,M,y);const c=new Uint8Array(p),m=[];for(let o=0;o<p;o++)d[o]&&l[o]>=64&&m.push(o);for(;m.length;){const o=m.pop();if(c[o]||l[o]<64)continue;c[o]=1;const N=o%t;N>0&&m.push(o-1),N<t-1&&m.push(o+1),o>=t&&m.push(o-t),o<p-t&&m.push(o+t)}for(let o=0;o<p;o++)c[o]||(l[o]=l[o]>=64?0:l[o]);return l}function jt(l,t,n,g,A=0,d=null){const y=t*n,a=new Int32Array(y),e=[];for(let i=0;i<t;i++)e.push(i,(n-1)*t+i);for(let i=0;i<n;i++)e.push(i*t,i*t+t-1);const M=(i,f)=>{for(;e.length;){const c=e.pop();if(a[c]||l[c]>=128)continue;a[c]=i,f?.push(c);const m=c%t;m>0&&e.push(c-1),m<t-1&&e.push(c+1),c>=t&&e.push(c-t),c<y-t&&e.push(c+t)}};M(-1);for(let i=0,f=1;i<y;i++){if(a[i]||l[i]>=128)continue;const c=[];e.push(i),M(f++,c);const m=c.length<A&&(!d||c.every(o=>d[o]));for(const o of c)(m||g[o])&&(l[o]=255)}const p=new Uint8Array(y);for(let i=0;i<y;i++)p[i]=a[i]===-1||a[i]>0&&l[i]<128?255:0;const U=Y(p,t,n,2,!0);for(let i=0;i<y;i++)l[i]&&l[i]<255&&!U[i]&&(l[i]=255);return l}function $t(l,t,n=dt.maxW){const g=Math.min(n,l),A=Math.max(2,Math.round(g*t/l/2)*2);return{w:Math.round(g/2)*2,h:A}}export{dt as HAND_MATTE,X as fillCapsule,W as fillPolygon,Yt as handMatteFrame,$t as handMatteSize};