clipoox-render 0.1.0 → 0.2.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 (144) hide show
  1. package/package.json +1 -1
  2. package/scripts/render-local.mjs +1480 -1479
  3. package/web/assets/FxEmbed-BymBArNa.js +1 -0
  4. package/web/assets/MotionEmbed-PmXWSWe5.js +1 -0
  5. package/web/assets/PluginStore-BVsm6n6N.js +3 -0
  6. package/web/assets/{ShotComposer-AHScyNYv.js → ShotComposer-Dprx-Yi7.js} +4 -4
  7. package/web/assets/TemplateEmbed-CrZXoUk_.js +2 -0
  8. package/web/assets/{TimelinePlugins-CkP5P9b_.js → TimelinePlugins-B1KGtbmb.js} +3 -3
  9. package/web/assets/TimelineShotFx-DoLx312Y.js +2 -0
  10. package/web/assets/TransitionEmbed-C5SUosv2.js +1 -0
  11. package/web/assets/{Whiteboard-C9Mwa3nF.js → Whiteboard-DybaKCdo.js} +3 -3
  12. package/web/assets/aerial-DSt_mJNA.js +2 -0
  13. package/web/assets/agentTools-CxZqRLeR.js +2 -0
  14. package/web/assets/analyzerRun-DCJwb_-Z.js +1 -0
  15. package/web/assets/{analyzerSandbox-DQGHjUCa.js → analyzerSandbox-DO5ZTv5q.js} +2 -2
  16. package/web/assets/{api-C5pOWyBM.js → api-BsKbf3l3.js} +4 -4
  17. package/web/assets/auraTrack-QR0WqBHp.js +1 -0
  18. package/web/assets/breakthrough-Dv1bndQb.js +2 -0
  19. package/web/assets/{cameraPresets-CeStHDvF.js → cameraPresets-B234aNzE.js} +1 -1
  20. package/web/assets/{captionLayout-BAdmqwdS.js → captionLayout-CNgb471H.js} +1 -1
  21. package/web/assets/clientExport-NtJmxOYP.js +1 -0
  22. package/web/assets/{depthEstimate-1OjTo_pb.js → depthEstimate-wVYSJtW8.js} +1 -1
  23. package/web/assets/directorTools-BqFcShgT.js +1 -0
  24. package/web/assets/{distortFrames-D39fkQ_H.js → distortFrames-D3TQNcJA.js} +2 -2
  25. package/web/assets/{distortGL-5uNfls9s.js → distortGL-BklPDXPq.js} +1 -1
  26. package/web/assets/editTools-BQlG5WB_.js +1 -0
  27. package/web/assets/exportEncode-CaKEPgsy.js +1 -0
  28. package/web/assets/exportGlb-DstxwzH5.js +2 -0
  29. package/web/assets/faceTracker-DWxxieVC.js +1 -0
  30. package/web/assets/fightDirector-OMlPZgjv.js +1 -0
  31. package/web/assets/fightDrama-G7bXfpQu.js +2 -0
  32. package/web/assets/{frameSink-CB1EghW0.js → frameSink-Dj71jCRb.js} +3 -3
  33. package/web/assets/{gpuCompose-EfzSAeMh.js → gpuCompose-DIxBHlTa.js} +1 -1
  34. package/web/assets/gpuExport-CPSw_dmq.js +189 -0
  35. package/web/assets/handMatte-DHsHHz4m.js +1 -0
  36. package/web/assets/handTracker-D_O-C4Dw.js +2 -0
  37. package/web/assets/{index-BGZJld3s.js → index-CZn97Ygs.js} +1 -1
  38. package/web/assets/layer-worker-Bar7WgOA.js +5 -0
  39. package/web/assets/library-BtBrCaFk.js +1 -0
  40. package/web/assets/{lottieLayer-BhLbZOpr.js → lottieLayer-CfUPParC.js} +4 -4
  41. package/web/assets/{lottie_light_canvas-D9fsNLID.js → lottie_light_canvas-7iv3btPX.js} +1 -1
  42. package/web/assets/main-BPmr0TOL.css +1 -0
  43. package/web/assets/{main-BNZrzSIG.js → main-M1vRa-gd.js} +32 -32
  44. package/web/assets/{mapBake-BAG6i5fI.js → mapBake-lPNhNZgv.js} +1 -1
  45. package/web/assets/maskTrack-D2jUh7aw.js +1 -0
  46. package/web/assets/matteFixRun-B7tWV9Y1.js +1 -0
  47. package/web/assets/motionBlur-uAm030t9.js +1 -0
  48. package/web/assets/{objectLocate-Dhktxe5z.js → objectLocate-BDqfSo9J.js} +1 -1
  49. package/web/assets/pendingMatte-q35zVaiB.js +2 -0
  50. package/web/assets/personAi-ZjQVo-80.js +2 -0
  51. package/web/assets/plateCamera-A2E_WO_x.js +1 -0
  52. package/web/assets/plateCameraMatch-D41LQrsm.js +2 -0
  53. package/web/assets/plateFollow-CNfi4xuP.js +2 -0
  54. package/web/assets/plateMatte-BdIxGhw5.js +2 -0
  55. package/web/assets/{pluginAutomation-DdZOnpoV.js → pluginAutomation-BtQ_w2TB.js} +1 -1
  56. package/web/assets/poseTracker-DVX__OK7.js +1 -0
  57. package/web/assets/productTools-r2RgILaA.js +2 -0
  58. package/web/assets/{remote-DXG553d8.js → remote-sTZauTqM.js} +77 -77
  59. package/web/assets/rigTrack-Bx9QHlFv.js +1 -0
  60. package/web/assets/{rotoMaskStore-DrRawyH9.js → rotoMaskStore-pxpRt5Cj.js} +1 -1
  61. package/web/assets/{rotoMatte-2EcyuvBX.js → rotoMatte-DyXlW4jK.js} +1 -1
  62. package/web/assets/rotoscope-GORCSVBr.js +1 -0
  63. package/web/assets/shot-worker-B8JWkmBz.js +1 -0
  64. package/web/assets/{shotFxAgent-CETPcjzU.js → shotFxAgent-CzHfe75S.js} +2 -2
  65. package/web/assets/{skin-BQG1Iz6Q.js → skin-BkaT2QuX.js} +1 -1
  66. package/web/assets/{spark.module-CMSPLU2n.js → spark.module-BRT8yMS4.js} +10 -10
  67. package/web/assets/spellDuel-BUy289OT.js +2 -0
  68. package/web/assets/{store-Dxq3MZF3.js → store-BSSbvpzr.js} +1 -1
  69. package/web/assets/{surfaceLight-B_OSTxcx.js → surfaceLight-CMaBhZ_d.js} +1 -1
  70. package/web/assets/surfacePin-DM9b9ubh.js +2 -0
  71. package/web/assets/textAnimators-Cihw35O8.js +1 -0
  72. package/web/assets/{thumb-xLFX6lDN.js → thumb-Cs636sYt.js} +1 -1
  73. package/web/assets/{timeline3d-DqXTKdEK.js → timeline3d-BEuZZOxM.js} +2 -2
  74. package/web/assets/{timeline3dExport-MWomW4fF.js → timeline3dExport-CmSI_pjv.js} +1 -1
  75. package/web/assets/timelineComp-CRRzLazc.js +1 -0
  76. package/web/assets/timelineProps-tN2YsMYN.js +1 -0
  77. package/web/assets/timelineText-CkoUgWcY.js +1 -0
  78. package/web/assets/{titleArt-CAOxtyHl.js → titleArt-CcTdJuOC.js} +5 -5
  79. package/web/assets/{titleFrameBudget-BjW--v_T.js → titleFrameBudget-3MFHWIT6.js} +1 -1
  80. package/web/assets/titleFrames-w-iWje9N.js +1 -0
  81. package/web/assets/{tool-DEWWeyCz.js → tool-BhIsq238.js} +1 -1
  82. package/web/assets/tools-DMUnabc_.js +1 -0
  83. package/web/assets/toonTools-CICrV3QB.js +2 -0
  84. package/web/assets/trackAnchor-D2bB5mZE.js +1 -0
  85. package/web/assets/userFonts-BZ4QL-zq.js +1 -0
  86. package/web/assets/{vfxAlpha-vbbI-03F.js → vfxAlpha-D3Dk1tfF.js} +2 -2
  87. package/web/assets/vfxBackground-CHlCg8lb.js +2 -0
  88. package/web/assets/{vfxTrack-BmxWjlDi.js → vfxTrack-CqiQDEYm.js} +1 -1
  89. package/web/assets/videoExport-l5MGvMn_.js +1 -0
  90. package/web/assets/views-BdWnG2xK.js +1 -0
  91. package/web/assets/weaponDuel-B2wTffPC.js +1 -0
  92. package/web/assets/{windowFrames-DydW5Al5.js → windowFrames-CoIyWqxr.js} +1 -1
  93. package/web/layer-worker.html +3 -3
  94. package/web/assets/FxEmbed-B5TQxKxk.js +0 -1
  95. package/web/assets/MotionEmbed-Catb_GgA.js +0 -1
  96. package/web/assets/PluginStore-8TjQawtB.js +0 -3
  97. package/web/assets/TemplateEmbed-Cao8Z5fY.js +0 -2
  98. package/web/assets/TimelineShotFx-DvmPZQXM.js +0 -2
  99. package/web/assets/TransitionEmbed-o4UxJ35e.js +0 -1
  100. package/web/assets/aerial-BPRLPci2.js +0 -2
  101. package/web/assets/agentTools-CSnN-LvS.js +0 -2
  102. package/web/assets/analyzerRun-5zJsmMS1.js +0 -1
  103. package/web/assets/auraTrack-pF-WhpH3.js +0 -1
  104. package/web/assets/breakthrough-DQN1i-Pw.js +0 -2
  105. package/web/assets/clientExport-Ca9a3Jiy.js +0 -1
  106. package/web/assets/directorTools-CvmghG_6.js +0 -1
  107. package/web/assets/editTools-CUoVvupD.js +0 -1
  108. package/web/assets/exportEncode-pFxeatJt.js +0 -1
  109. package/web/assets/exportGlb-MK05aKqH.js +0 -2
  110. package/web/assets/faceTracker-_rQOgBvX.js +0 -1
  111. package/web/assets/fightDirector-Dt60kfbV.js +0 -1
  112. package/web/assets/fightDrama-py4jxSdn.js +0 -2
  113. package/web/assets/gpuExport-Cnv2NfEb.js +0 -189
  114. package/web/assets/handMatte-DZCsuqD2.js +0 -1
  115. package/web/assets/handTracker-Btr9L-Hu.js +0 -2
  116. package/web/assets/layer-worker-Rbo-YZv-.js +0 -5
  117. package/web/assets/library-CdukL2BW.js +0 -1
  118. package/web/assets/main-By_IEoB_.css +0 -1
  119. package/web/assets/maskTrack-AZwAVz1c.js +0 -1
  120. package/web/assets/matteFixRun-wTHGiGGf.js +0 -1
  121. package/web/assets/pendingMatte-iKz2-XBZ.js +0 -2
  122. package/web/assets/personAi-BEVyjCii.js +0 -2
  123. package/web/assets/plateCamera-D_J3-X06.js +0 -1
  124. package/web/assets/plateCameraMatch-C0peOvBn.js +0 -2
  125. package/web/assets/plateFollow-BbJMVxfg.js +0 -2
  126. package/web/assets/plateMatte-u5wKpsUN.js +0 -2
  127. package/web/assets/poseTracker--VJYw-hX.js +0 -1
  128. package/web/assets/productTools-DbhbyJxx.js +0 -2
  129. package/web/assets/rigTrack-CW9_kg5j.js +0 -1
  130. package/web/assets/rotoscope-_CYT-9ry.js +0 -1
  131. package/web/assets/shot-worker-BxIzQRZh.js +0 -1
  132. package/web/assets/spellDuel-eZvRwaxi.js +0 -2
  133. package/web/assets/surfacePin-CfLBhSrm.js +0 -2
  134. package/web/assets/timelineProps-KL6XCR4Q.js +0 -1
  135. package/web/assets/timelineText-DEK2BRyU.js +0 -1
  136. package/web/assets/titleFrames-WfiLHzjf.js +0 -1
  137. package/web/assets/tools-CBfIZX8_.js +0 -1
  138. package/web/assets/toonTools-D7jucq3t.js +0 -2
  139. package/web/assets/trackAnchor-DFqKIb8a.js +0 -1
  140. package/web/assets/userFonts-txN4I-eo.js +0 -1
  141. package/web/assets/vfxBackground-C1dHlJN6.js +0 -2
  142. package/web/assets/videoExport-DiNI9GY1.js +0 -1
  143. package/web/assets/views-sH39zgjD.js +0 -1
  144. package/web/assets/weaponDuel-CEvRDeuE.js +0 -1
@@ -1,3 +0,0 @@
1
- import{r as vn,j as s}from"./remote-DXG553d8.js";import{u as on,r as d,t as a}from"./api-C5pOWyBM.js";import{ao as bn,ap as Nn,aq as hn,ar as un,as as q,at as R,au as X,av as kn,M as wn,aw as yn,z as Cn,ax as Sn,ay as Ln,o as Mn,az as Dn,aA as H,aB as Un,aC as $n,e as Pn,aD as Tn}from"./main-BNZrzSIG.js";import{d as An,k as In,m as Kn,l as En}from"./lottieLayer-BhLbZOpr.js";import{p as Vn}from"./TimelinePlugins-CkP5P9b_.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./titleArt-CAOxtyHl.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";import"./pluginAutomation-DdZOnpoV.js";const pn=[{id:"all",vi:"Tất cả",en:"All"},{id:"motion",vi:"Motion",en:"Motion"},{id:"lottie",vi:"Lottie",en:"Lottie"},{id:"recipe",vi:"Công thức",en:"Recipe"},{id:"sfx",vi:"Âm thanh",en:"Sounds"},{id:"pack",vi:"Gói ngách",en:"Niche pack"},{id:"kit",vi:"Bộ 3D",en:"3D kit"},{id:"sfxlib",vi:"Kho âm thanh",en:"Sound library"},{id:"link",vi:"Cho AI agent",en:"AI agents"}],V=e=>e.kind==="pack"&&!!e.kit?.modelAssets,J=e=>V(e)?"kit":e.kind,F=e=>e.kind==="link"&&!!e.link,Fn=e=>{e.link&&window.open(e.link.url,"_blank","noopener,noreferrer")},mn=(e,l)=>e>=1024*1024?`${(e/1024/1024).toFixed(e>=10*1024*1024?0:1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(e/1024))} KB`,Q=({n:e=28})=>s.jsx("span",{className:"ps-wave","aria-hidden":!0,children:Array.from({length:e},(l,r)=>s.jsx("i",{style:{height:`${18+Math.round(72*Math.abs(Math.sin(r*1.37)*Math.cos(r*.41)))}%`}},r))}),gn=(e,l)=>pn.find(r=>r.id===e)?.[l==="en"?"en":"vi"]??e,Bn=5e3,On=600*1e3,dn=e=>e.normalize("NFD").replace(/[̀-ͯ]/g,"").replace(/đ/gi,"d").toLowerCase(),Rn=e=>{const l=(r,o)=>r>0&&o>0?Math.min(r,o):r>0?r:o;return R({priceVnd:l(e.priceVnd,e.passVnd??0),priceUsd:l(e.priceUsd,e.passUsd??0)})};function vs({installed:e,initialId:l=null,onClose:r,onInstalled:o,onUse:j,toast:c}){const p=on(),u=p==="en"?"en":"vi",[b,C]=d.useState(null),[g,k]=d.useState([]),[M,A]=d.useState(""),[S,t]=d.useState("all"),[h,f]=d.useState("all"),[D,K]=d.useState(""),[x,w]=d.useState(null),[$,P]=d.useState(""),[T,v]=d.useState({}),[U,L]=d.useState(""),y=d.useCallback(()=>bn().then(n=>(k(n.owned),n.owned)).catch(()=>[]),[]),[I,G]=d.useState(!1);d.useEffect(()=>{Nn().then(n=>C(n.items),n=>{C([]),A(n.message)}),y().finally(()=>G(!0))},[y]);const E=d.useRef(!1);d.useEffect(()=>{if(!l||E.current||b===null||!I)return;E.current=!0;const n=b.find(i=>i.id===l)??g.find(i=>i.storeId===l&&i.item)?.item;n?w(n):c(a("Không tìm thấy plug-in này trong kho."),"error")},[l,b,g,I,c]),d.useEffect(()=>{const n=i=>{i.key==="Escape"&&(i.stopPropagation(),x?w(null):r())};return window.addEventListener("keydown",n,!0),()=>window.removeEventListener("keydown",n,!0)},[x,r]);const Y=Object.keys(T).join(",");d.useEffect(()=>{if(!Y)return;const n=window.setInterval(()=>{y().then(i=>{v(m=>{const N={...m};for(const O of Object.keys(N))(an(i,O)||Date.now()-N[O]>On)&&delete N[O];return N})})},Bn);return()=>window.clearInterval(n)},[Y,y]);const B=n=>g.some(i=>i.storeId===n&&i.owned),z=n=>g.find(i=>i.storeId===n),Z=n=>g.some(i=>i.storeId===n&&i.status==="refunded"),nn=n=>e.some(i=>i.id===n&&i.source?.store===n),W=async n=>{P(n.id);try{await Ln(n.id),o(),Mn(),L(n.id),c(a("Đã cài “{0}” vào Plug-in của tôi",[n.name[u]]),"ok")}catch(i){const m=Vn(i);c(m.text,"error")}finally{P("")}},sn=d.useRef({}),en=n=>n?.owned?n.expiresAt?String(n.expiresAt):"life":"none",an=(n,i)=>{const m=n.find(N=>N.storeId===i);return!!m?.owned&&en(m)!==(sn.current[i]??"none")},tn=(n,i)=>{sn.current[n.id]=en(z(n.id)),Sn(n.id,i),v(m=>({...m,[n.id]:Date.now()}))},xn=async n=>{const i=await y();an(i,n)?(v(m=>{const N={...m};return delete N[n],N}),c(a("Thanh toán xong — plug-in đã thuộc về bạn"),"ok")):c(a("Chưa thấy thanh toán. Nếu bạn vừa chuyển khoản, đợi một chút rồi kiểm tra lại."),"error")},jn=g.filter(n=>n.item).map(n=>n.item),_=(S==="owned"?jn:(b??[]).filter(n=>S==="all"||(S==="free"?n.free:!n.free))).filter(n=>(h==="all"||J(n)===h)&&(!D.trim()||dn(D).split(/\s+/).every(i=>dn(`${n.name.vi} ${n.name.en} ${n.description.vi} ${n.description.en} ${n.author.name} ${n.tags.join(" ")}`).includes(i)))),fn=[{id:"all",label:a("Plug-in")},{id:"free",label:a("Miễn phí")},{id:"paid",label:a("Trả phí")},{id:"owned",label:a("Đã sở hữu")}],ln=(n,i)=>$===n.id?s.jsxs("button",{className:i,disabled:!0,children:[s.jsx("i",{className:"spin"})," ",a("Đang cài…")]}):nn(n.id)||U===n.id?s.jsxs(s.Fragment,{children:[j?s.jsxs("button",{className:`${i} ps-use`,onClick:()=>j(n.id),children:["✓ ",a("Đã cài · Dùng ngay")]}):s.jsxs("span",{className:`${i} ps-use`,role:"status",children:["✓ ",a("Đã cài")]}),s.jsx("button",{className:"ps-reinstall",title:a("Cài lại plug-in"),onClick:()=>void W(n),children:a("Cài lại")})]}):s.jsx("button",{className:i,onClick:()=>void W(n),children:a("Cài plug-in")}),rn=(n,i=!1)=>{const m=`ad-use${i?" ps-big":""}`;if(F(n))return s.jsxs("button",{className:m,onClick:()=>Fn(n),children:[n.link.label?.[u]||a("Hướng dẫn cài")," ↗"]});if(n.free)return ln(n,m);if(T[n.id])return s.jsx("button",{className:`${m} ps-wait`,onClick:()=>void xn(n.id),children:a("Đã thanh toán? Kiểm tra lại")});if(n.kind==="sfxlib"){const N=z(n.id);if(!i&&!N?.owned)return s.jsx("button",{className:m,onClick:()=>w(n),children:N?.expiresAt?a("Gia hạn"):a("Xem & mua")});if(i)return s.jsx(_n,{item:n,owned:N,busy:$===n.id,installed:nn(n.id),onInstall:()=>void W(n),onBuy:O=>tn(n,O)})}return B(n.id)?ln(n,m):s.jsx("button",{className:m,onClick:()=>tn(n),children:a("Mua · {0}",[R(n)])})},cn=n=>{if(n.free)return s.jsx("span",{className:"ps-price free",children:a("Miễn phí")});const i=z(n.id);return i?.owned?s.jsxs("span",{className:"ps-price owned",children:["✓ ",i.expiresAt?a("Vé đến {0}",[X(i.expiresAt,p)]):a("Đã sở hữu")]}):s.jsx("span",{className:"ps-price",children:n.kind==="sfxlib"?(n.passVnd||n.passUsd)&&!(n.priceVnd||n.priceUsd)?a("{0} / 30 ngày",[q(n)]):a("từ {0}",[Rn(n)]):R(n)})};return vn.createPortal(s.jsx("div",{className:"ad-backdrop",role:"dialog","aria-modal":"true","aria-label":a("Kho Plug-in"),onMouseDown:n=>{n.target===n.currentTarget&&r()},children:s.jsxs("section",{className:"ad-drawer ps-drawer",onMouseDown:n=>n.stopPropagation(),children:[s.jsxs("header",{className:"ad-head",children:[s.jsxs("div",{className:"ad-title",children:["🛍 ",a("Kho Plug-in")]}),s.jsxs("span",{className:"ad-count",children:[_.length," ",a("mục")]}),s.jsx("div",{className:"grow"}),s.jsx("button",{className:"ad-iconbtn",title:a("Đóng"),"aria-label":a("Đóng"),onClick:r,children:"✕"})]}),s.jsx("nav",{className:"ad-sources",children:fn.map(n=>s.jsxs("button",{className:`ad-tab${S===n.id?" on":""}`,"aria-pressed":S===n.id,onClick:()=>t(n.id),children:[n.id==="all"&&s.jsx("span",{className:"ad-pin",children:"⧉"}),n.label,n.id==="owned"&&g.filter(i=>i.owned).length>0&&s.jsx("span",{className:"ps-n",children:g.filter(i=>i.owned).length})]},n.id))}),s.jsxs("div",{className:"ad-tools",children:[s.jsx("input",{className:"ad-search","aria-label":a("Tìm plug-in"),placeholder:a("Tìm plug-in, tác giả, thẻ…"),value:D,onChange:n=>K(n.target.value),onKeyDown:n=>n.stopPropagation()}),s.jsx("div",{className:"ad-chips",role:"group","aria-label":a("Loại plug-in"),children:pn.map(n=>s.jsx("button",{className:`ad-chip${h===n.id?" on":""}`,"aria-pressed":h===n.id,onClick:()=>f(n.id),children:n[u]},n.id))})]}),s.jsxs("div",{className:"ad-notice",children:[s.jsxs("b",{children:["⧉ ",a("Plug-in không tốn credit.")]})," ",h==="sfxlib"?a("Kho âm thanh: mua một lần hoặc vé 30 ngày trên clipoox.com, tính là 1 plug-in; âm chỉ chép vào dự án khi bạn dùng."):a("Bản miễn phí cài ngay; bản trả phí mua một lần trên clipoox.com (chuyển khoản / thẻ), cài lại bất cứ lúc nào.")]}),s.jsxs("div",{className:"ad-content",children:[M&&s.jsx("p",{role:"alert",className:"ad-alert",children:M}),b===null&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),b!==null&&!_.length&&s.jsx("div",{className:"ad-empty",children:S==="owned"?a("Bạn chưa mua plug-in nào."):D?a("Không có plug-in khớp tìm kiếm."):a("Kho chưa có plug-in nào trong nhóm này.")}),s.jsx("div",{className:"ad-grid",children:_.map(n=>s.jsxs("article",{className:"ad-card ps-card","data-store":n.id,children:[s.jsxs("button",{className:"ad-prev ps-open","aria-label":a("Xem {0}",[n.name[u]]),onClick:()=>w(n),children:[n.thumbnailUrl?s.jsx("img",{src:n.thumbnailUrl,alt:"",loading:"lazy"}):n.kind==="sfx"||n.kind==="sfxlib"?s.jsx(Q,{}):s.jsx("span",{className:"ad-ph",children:"⧉"}),s.jsx("span",{className:"ad-badge",children:(F(n)?n.link.platform:gn(J(n),p)).toUpperCase()}),n.featured&&s.jsxs("span",{className:"ps-featured",title:a("Đối tác tiên phong của Clipoox"),children:["★ ",a("Đối tác tiên phong")]}),n.private&&s.jsxs("span",{className:"ps-private",title:a("Chỉ các tài khoản được Clipoox chọn mới thấy gói này"),children:["🔒 ",a("Gói riêng")]})]}),s.jsxs("div",{className:"ad-meta",children:[s.jsx("div",{className:"ad-name",title:n.name[u],children:n.name[u]}),s.jsxs("div",{className:"ad-sub ps-sub",children:[s.jsxs("span",{className:"ps-by",children:[n.author.name," · v",n.version]}),cn(n)]}),n.kind==="pack"&&!V(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["⧉ ",a("{0} mục trong gói",[n.itemCount??0])]}),V(n)&&s.jsxs("div",{className:"ps-kit-meta",children:["◈ ",s.jsx("b",{children:n.kit.items})," ",a("mục")," · ",s.jsx("b",{children:n.kit.models})," ",a("mô hình 3D")," · ",s.jsx("b",{children:n.kit.looks})," ",a("look")," · ",mn(n.kit.bytes,u)]}),F(n)&&s.jsxs("div",{className:"ps-sounds-meta",children:["↗ ",a("Cài trong {0} trên máy bạn",[n.link.platform])]}),n.kind==="sfx"&&s.jsxs("div",{className:"ps-sounds-meta",children:["♪ ",a("{0} âm thanh",[n.soundCount??0])," · ",hn(n.totalDuration)]}),n.kind==="sfxlib"&&s.jsxs("div",{className:"ps-sounds-meta",children:["📚 ",a("{0} âm thanh",[(n.soundCount??0).toLocaleString(u==="en"?"en-US":"vi-VN")])," · ",un(n.totalDuration,u)]}),n.kind==="sfxlib"&&!n.free&&!B(n.id)&&s.jsx("div",{className:"ps-sounds-meta ps-lib-prices",children:[n.passVnd||n.passUsd?a("{0} / 30 ngày",[q(n)]):"",n.priceVnd||n.priceUsd?a("{0} trọn đời",[R(n)]):""].filter(Boolean).join(" · ")}),U===n.id&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi")]}),T[n.id]&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán…")]}),Z(n.id)&&!B(n.id)&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn đã hoàn tiền")}),s.jsx("div",{className:"ad-actions",children:rn(n)})]})]},n.id))})]}),x&&s.jsx(Gn,{item:x,locale:u,owned:B(x.id),free:x.free,waiting:!!T[x.id],refunded:Z(x.id),action:rn(x,!0),price:cn(x),installed:U===x.id,onClose:()=>w(null)},`${x.id}:${B(x.id)}`)]})}),document.body)}function Gn({item:e,locale:l,owned:r,free:o,waiting:j,refunded:c,action:p,price:u,installed:b,onClose:C}){const g=d.useRef(null),[k,M]=d.useState(!1),[A,S]=d.useState(!1);return d.useEffect(()=>{if(!(o||r)||e.kind==="recipe"||e.kind==="sfx"||e.kind==="pack"||e.kind==="sfxlib"||e.kind==="link")return;let t=!0,h=0,f=null;const D=`store-preview:${e.id}`,K={v:""},x=performance.now();return(async()=>{try{f=await kn(e.id)}catch{t&&S(!0);return}if(!t||!f)return;const w=f.manifest,$=640,P=360;if(w.kind==="motion"){const T=wn(w,f.entry,{}),v=w.duration,U=async()=>{if(t){try{const L=await Kn({layer:D,motion:T,t:(performance.now()-x)/1e3%v,width:$,height:P,duration:v}),y=g.current?.getContext("2d");y&&t&&(y.clearRect(0,0,$,P),y.drawImage(L,0,0),M(!0)),L.close()}catch{}h=requestAnimationFrame(()=>void U())}};U()}else{const T=await yn(f.lottie,w,Cn(w,{}));K.v=URL.createObjectURL(new Blob([JSON.stringify(T)],{type:"application/json"}));const v=f.lottie.meta,U=Math.min($/v.w,P/v.h),L={W:Math.max(2,Math.round(v.w*U/2)*2),H:Math.max(2,Math.round(v.h*U/2)*2)},y=v.op-v.ip,I=document.createElement("canvas");I.width=L.W,I.height=L.H;const G=async()=>{if(t){try{await En(D,K.v,L,Math.floor((performance.now()-x)/1e3*v.fr%y),I);const E=g.current?.getContext("2d");E&&t&&(E.clearRect(0,0,$,P),E.drawImage(I,($-L.W)/2,(P-L.H)/2),M(!0))}catch{}h=requestAnimationFrame(()=>void G())}};G()}})(),()=>{t=!1,cancelAnimationFrame(h),An(D),In(D),K.v&&URL.revokeObjectURL(K.v)}},[e.id,e.kind,o,r]),s.jsx("div",{className:"ad-preview-modal",onMouseDown:t=>{t.target===t.currentTarget&&C()},children:s.jsxs("div",{className:"ad-preview-box ps-detail",role:"dialog","aria-label":e.name[l],children:[s.jsxs("header",{children:[s.jsx("b",{children:e.name[l]}),s.jsx("button",{className:"ad-iconbtn","aria-label":a("Đóng"),onClick:C,children:"✕"})]}),e.kind==="sfxlib"?s.jsx(Wn,{item:e,locale:l}):e.kind==="sfx"?s.jsx(zn,{item:e,locale:l,owned:r,free:o}):s.jsxs("div",{className:"ps-stage",children:[s.jsx("canvas",{ref:g,width:640,height:360,style:{display:k?"block":"none"}}),!k&&(e.previewUrl&&/\.(mp4|webm)(\?|$)/.test(e.previewUrl)?s.jsx("video",{src:e.previewUrl,autoPlay:!0,muted:!0,loop:!0,playsInline:!0}):e.previewUrl||e.thumbnailUrl?s.jsx("img",{src:e.previewUrl||e.thumbnailUrl,alt:""}):s.jsx("span",{className:"ad-ph",children:"⧉"})),s.jsx("span",{className:"ps-stage-note",children:k?a("Xem thử trực tiếp trong sandbox"):o||r?A?a("Không tải được bản xem thử"):e.kind==="recipe"?a("Công thức chạy trên clip bạn chọn"):e.kind==="pack"?a("Gói {0} mục — cài rồi dùng từng mục trong tab Plug-in",[e.itemCount??0]):F(e)?a("Cài trong {0} trên máy bạn — không cài vào Timeline",[e.link.platform]):a("Đang tải bản xem thử…"):a("Mua để xem thử trực tiếp và dùng")})]}),e.kind==="pack"&&s.jsx(qn,{item:e,locale:l}),s.jsxs("div",{className:"ps-info",children:[e.featured&&s.jsxs("p",{className:"ps-featured-line",children:["★ ",a("Đối tác tiên phong của Clipoox")]}),e.private&&s.jsxs("p",{className:"ps-private-line",children:["🔒 ",a("Gói riêng: chỉ các tài khoản được Clipoox chọn mới thấy và cài được.")]}),s.jsxs("div",{className:"ps-row",children:[u,s.jsxs("span",{className:"ps-kind",children:[F(e)?e.link.platform:gn(J(e),l)," · v",e.version," · ",e.author.name,e.kit?` · ${mn(e.kit.bytes,l)}`:"",V(e)?` · ${a("GLB ≤ 20 MB, ≤ 300 000 tam giác")}`:""]})]}),s.jsx("p",{children:e.description[l]}),F(e)&&e.link.commands.length>0&&s.jsx(Hn,{commands:e.link.commands}),e.params.length>0&&s.jsxs("p",{className:"ps-params",children:[s.jsxs("b",{children:[a("Tham số chỉnh được"),":"]})," ",e.params.map(t=>t.label[l]).join(" · ")]}),j&&s.jsxs("div",{className:"ps-waiting",role:"status",children:[s.jsx("i",{className:"spin"}),a("Đang chờ thanh toán… Hoàn tất trên trang clipoox.com vừa mở, rồi quay lại đây.")]}),c&&!r&&s.jsx("div",{className:"ps-waiting bad",children:a("Đơn mua này đã được hoàn tiền nên không cài mới được. Các clip đã dùng vẫn giữ nguyên.")}),b&&s.jsxs("div",{className:"ps-installed",role:"status",children:["✓ ",a("Đã cài vào Plug-in của tôi — mở tab Plug-in để dùng.")]}),s.jsx("div",{className:"ad-actions",children:p}),V(e)&&!o&&!r&&s.jsxs("div",{className:"ps-lock",children:["🔒 ",a("Mô hình và texture chỉ tải về máy sau khi mua. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")]}),V(e)&&(o||r)&&s.jsx("small",{className:"muted",children:a("Tài nguyên 3D chỉ chép vào dự án khi bạn dùng một mục. Lớp đã dựng vẫn giữ nếu bộ bị gỡ hay ngừng bán.")}),!o&&!r&&e.kind!=="sfxlib"&&s.jsx("small",{className:"muted",children:a("Thanh toán một lần trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit.")})]})]})})}function Hn({commands:e}){const[l,r]=d.useState(!1),o=()=>{navigator.clipboard?.writeText(e.join(`
2
- `)).then(()=>{r(!0),window.setTimeout(()=>r(!1),2e3)},()=>{})};return s.jsxs("div",{className:"ps-cmds",children:[s.jsxs("div",{className:"ps-cmds-head",children:[s.jsx("b",{children:a("Lệnh cài")}),s.jsx("span",{className:"muted",children:a("chạy trong terminal trên máy bạn")}),s.jsx("button",{className:"ad-chip",onClick:o,children:l?`✓ ${a("Đã chép")}`:a("Chép lệnh")})]}),s.jsx("pre",{children:e.join(`
3
- `)})]})}function qn({item:e,locale:l}){const[r,o]=d.useState(null);if(d.useEffect(()=>{let c=!0;return Tn(e.id).then(p=>{c&&o(p.items)},()=>{c&&o([])}),()=>{c=!1}},[e.id]),!r?.length)return null;const j=c=>c.kind==="model"?a("Mô hình"):c.kind==="lut"?"Look":c.kind==="motion"&&c.engine==="3d"?"3D":c.kind==="recipe"?a("Combo"):c.kind==="lottie"?"Lottie":"2D";return s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"ps-items-head",children:[s.jsx("b",{children:a("{0} mục trong gói",[r.length])})," · ",s.jsx("span",{className:"muted",children:a("ảnh chụp từ lần chạy thử")})]}),s.jsx("div",{className:"ps-items",children:r.slice(0,24).map(c=>s.jsxs("figure",{children:[c.thumbnail?s.jsx("img",{src:`data:${c.thumbnail.type};base64,${c.thumbnail.data}`,alt:""}):s.jsx("span",{className:"ph",children:c.kind==="model"?"◈":"✦"}),s.jsxs("figcaption",{title:c.name[l],children:[j(c)," · ",c.name[l]]})]},c.id))})]})}function zn({item:e,locale:l,owned:r,free:o}){const[j,c]=d.useState(null),[p,u]=d.useState(!1),[b,C]=d.useState(!1),[g,k]=d.useState(null),M=d.useRef(null),A=d.useRef(0);d.useEffect(()=>{let t=!0;return $n(e.id).then(h=>{t&&(c(h.sounds),u(h.full))},()=>{t&&C(!0)}),()=>{t=!1,M.current?.pause(),window.clearTimeout(A.current)}},[e.id,r,o]);const S=t=>{if(M.current?.pause(),window.clearTimeout(A.current),g===t.id||!t.url){k(null);return}const h=new Audio(t.url);M.current=h,h.volume=.8,k(t.id),h.onended=()=>k(f=>f===t.id?null:f),t.preview&&(A.current=window.setTimeout(()=>{h.pause(),k(f=>f===t.id?null:f)},H.previewSeconds*1e3+300)),h.play().catch(()=>k(null))};return s.jsxs("div",{className:"ps-sounds","data-full":p?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Q,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["♪ ",a("{0} âm thanh",[e.soundCount??j?.length??0])," · ",hn(e.totalDuration)]}),s.jsx("small",{className:"muted",children:p?a("Nghe đầy đủ — bấm ▶"):a("Nghe thử {0} âm thanh đầu, mỗi âm tối đa {1} giây. Mua để nghe đủ và dùng.",[H.previewCount,H.previewSeconds])})]})]}),b&&s.jsx("p",{className:"ad-alert",role:"alert",children:a("Không tải được bản xem thử")}),j===null&&!b&&s.jsx("p",{className:"ad-muted",children:a("Đang tải…")}),j&&s.jsx("ul",{className:"ps-sound-list","aria-label":a("Âm thanh trong gói"),children:j.map(t=>{const h=t.name?.[l]||t.name?.vi||t.id;return s.jsxs("li",{className:`${g===t.id?"on":""}${t.url?"":" locked"}`,"data-store-sound":t.id,children:[s.jsx("button",{className:"tl-sfx-play",disabled:!t.url,"aria-label":t.url?`${a("Nghe thử")} ${h}`:a("Mua để nghe {0}",[h]),title:t.url?a("Nghe thử"):a("Mua để nghe"),onClick:()=>S(t),children:t.url?g===t.id?"■":"▶":"🔒"}),s.jsxs("span",{className:"ps-sound-name",children:[s.jsxs("span",{className:"ell",children:[h,t.loop?" ↻":""]}),s.jsxs("small",{className:"muted ell",children:[Pn(t.category,l),t.tags.length?` · ${t.tags.slice(0,3).join(", ")}`:""]})]}),s.jsxs("small",{className:"muted",children:[t.preview&&(t.previewSeconds??0)<t.duration-.05?`▶ ${(t.previewSeconds??0).toFixed(1)}s / `:"",t.duration.toFixed(1),"s"]})]},t.id)})})]})}function Wn({item:e,locale:l}){const r=d.useCallback(p=>Dn(e.id,p),[e.id]),[o,j]=d.useState(null),c=d.useCallback(async p=>{const u=await r(p);return j(u.access.full),u},[r]);return s.jsxs("div",{className:"ps-sounds","data-full":o?"1":"0",children:[s.jsxs("div",{className:"ps-sounds-head",children:[e.thumbnailUrl?s.jsx("img",{src:e.thumbnailUrl,alt:""}):s.jsx(Q,{n:40}),s.jsxs("div",{children:[s.jsxs("b",{children:["📚 ",a("{0} âm thanh",[(e.soundCount??0).toLocaleString(l==="en"?"en-US":"vi-VN")])," · ",un(e.totalDuration,l)]}),s.jsxs("div",{className:"ps-stats",children:[(e.folders?.length??0)>0&&s.jsxs("span",{children:[s.jsx("b",{children:e.folders.length})," ",a("thư mục")]}),s.jsxs("span",{children:[s.jsx("b",{children:"48 kHz"})," stereo"]}),s.jsxs("span",{children:["v",e.version]})]}),s.jsx("small",{className:"muted",children:o?a("Nghe đầy đủ — thêm âm từ mục SFX của Timeline."):a("Nghe thử mọi âm ({0} giây, chất lượng thấp). Mua để nghe đủ và dùng.",[H.previewSeconds])})]})]}),s.jsx(Un,{libId:e.id,fetchPage:c,variant:"store"})]})}function _n({item:e,owned:l,busy:r,installed:o,onInstall:j,onBuy:c}){const p=on(),u=(e.passVnd??0)>0||(e.passUsd??0)>0,b=e.priceVnd>0||e.priceUsd>0,C=s.jsx("button",{className:"ad-use ps-big",disabled:r,onClick:j,children:r?a("Đang cài…"):o?a("Cài lại"):a("Cài plug-in")});return l?.owned&&!l.expiresAt?C:l?.owned?s.jsxs("div",{className:"ps-lib-buy-wrap",children:[C,u&&s.jsx("button",{className:"ad-use ps-big ps-alt",onClick:()=>c("pass"),children:a("Gia hạn thêm 30 ngày · {0}",[q(e)])}),s.jsx("small",{className:"muted",children:a("Vé đến {0}. Gia hạn cộng nối từ ngày đó, không tự trừ tiền.",[X(l.expiresAt,p)])})]}):s.jsxs("div",{className:"ps-lib-buy-wrap",children:[l?.expiresAt&&s.jsx("div",{className:"ps-waiting",children:a("Vé 30 ngày đã hết hạn ngày {0}. Âm đã dùng trong dự án vẫn giữ nguyên.",[X(l.expiresAt,p)])}),s.jsxs("div",{className:"ps-lib-buy",children:[u&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("pass"),children:[a("Vé 30 ngày · {0}",[q(e)]),s.jsx("small",{children:a("Trả lại để gia hạn, không tự trừ tiền")})]}),b&&s.jsxs("button",{className:"ad-use ps-big",onClick:()=>c("lifetime"),children:[a("Mua trọn đời · {0}",[R(e)]),s.jsx("small",{children:a("Một lần, gồm các đợt âm mới")})]})]}),s.jsx("small",{className:"muted",children:a("Thanh toán trên clipoox.com: chuyển khoản (VND) hoặc thẻ quốc tế (USD). Không trừ credit. Âm đã dùng trong dự án vẫn giữ khi vé hết hạn.")})]})}export{vs as default};
@@ -1,2 +0,0 @@
1
- import{j as f}from"./remote-DXG553d8.js";import{r as l}from"./api-C5pOWyBM.js";import{p as E}from"./main-BNZrzSIG.js";import{o as b}from"./rigTrack-CW9_kg5j.js";import{l as g,d as h}from"./titleArt-CAOxtyHl.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./titleFrameBudget-BjW--v_T.js";import"./rotoMaskStore-DrRawyH9.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./lottieLayer-BhLbZOpr.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";const j=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],x=e=>({text:e.sample,fontSize:e.defaults.fontSize,color:e.defaults.color,accentColor:e.defaults.accentColor,placement:"center",align:e.defaults.align,fontFamily:e.defaults.fontFamily,styleId:"classic",design:e.design,animation:e.animation}),L=e=>e.split(`
2
- `).map(a=>({word:Math.max(1,a.split(/\s+/).filter(Boolean).length),char:Math.max(1,a.replace(/\s/g,"").length)})),F=e=>{if(!e.animation)return 2;const a=b(e.animation,L(e.sample));return a+1.2+a/e.animation.outSpeed};function N(){const e=l.useRef(null),[a,y]=l.useState(null),[u,d]=l.useState("");return l.useEffect(()=>{const i=(t,r)=>t.source?.postMessage(r,{targetOrigin:t.origin}),p=async t=>{if(!j.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;let r;try{r=E(t.data.template)}catch(o){i(t,{type:"clipoox-template-error",id:"id"in t.data?t.data.id:null,error:o.message});return}if(t.data.type==="clipoox-template-play"){d(""),y(r);return}if(t.data.type==="clipoox-template-thumb"){const o=t.data.id,n=x(r),c=Object.assign(document.createElement("canvas"),{width:1280,height:720}),m=c.getContext("2d");if(!m)return;try{await g(n),h(m,n)}catch(w){i(t,{type:"clipoox-template-error",id:o,error:w.message});return}i(t,{type:"clipoox-template-thumb",id:o,png:c.toDataURL("image/png")})}},s=t=>void p(t);return window.addEventListener("message",s),window.parent?.postMessage({type:"clipoox-template-ready"},"*"),()=>window.removeEventListener("message",s)},[]),l.useEffect(()=>{if(!a)return;let i=0,p=!0;const s=x(a),t=F(a),r=performance.now();return g(s).then(()=>{const o=()=>{const n=e.current?.getContext("2d");if(!p||!n)return;const c=(performance.now()-r)/1e3%t;n.clearRect(0,0,1280,720);try{h(n,s,{time:c,duration:t})}catch(m){d(m.message);return}i=requestAnimationFrame(o)};o()},o=>d(o.message)),()=>{p=!1,cancelAnimationFrame(i)}},[a]),f.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[f.jsx("canvas",{ref:e,width:1280,height:720,style:{width:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Template preview"}),u&&f.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:u})]})}export{N as default,F as loopLength,x as titleOf};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/thumb-xLFX6lDN.js","assets/remote-DXG553d8.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-Dxq3MZF3.js","assets/rotoMaskStore-DrRawyH9.js","assets/rigTrack-CW9_kg5j.js","assets/vfxBackground-C1dHlJN6.js"])))=>i.map(i=>d[i]);
2
- import{_ as A}from"./titleFrameBudget-BjW--v_T.js";import{fN as q,a as y,ib as H,ic as oe,j as n,ev as ie,ez as re}from"./remote-DXG553d8.js";import{u as le,r as g,t as a}from"./api-C5pOWyBM.js";import{v as ce}from"./vfxTrack-BmxWjlDi.js";import{u as K}from"./store-Dxq3MZF3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.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-xLFX6lDN.js").then(S=>S.e);return{drawThumb:x,thumbRestTime:$,thumbLoopLength:_}},__vite__mapDeps([0,1,2,3,4,5,6,7,8])).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 je({clip:c,locked:h,ensureScene:b,openShot:M}){le();const f=K(e=>e.toast),[,j]=g.useState(0),[k,R]=g.useState(q[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),W=g.useMemo(()=>ce(c),[c]),O=!!p&&F.length>0&&P?.data?.vfxRenderHash!==U(p),Y=g.useMemo(()=>{const e=H(x).trim();return oe.filter(s=>e?H(`${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-DXG553d8.js").then(L=>L.jH);return{runTool:v}},__vite__mapDeps([1,2,3,4,5,6,7,8])),i=await t(s,o,{getStage:()=>m,setStage:v=>{m=v(m)},engine:()=>null,timelineClip:v=>K.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)}},Z=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})),X=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(X(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-C1dHlJN6.js");return{withBackgroundScene:r}},__vite__mapDeps([9,3,2,1,4,5,6,7,8])),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-C1dHlJN6.js");return{withBackgroundScene:t}},__vite__mapDeps([9,3,2,1,4,5,6,7,8])),{shotFps:s}=await A(async()=>{const{shotFps:t}=await import("./remote-DXG553d8.js").then(i=>i.jA);return{shotFps:t}},__vite__mapDeps([1,2,3,4,5,6,7,8]));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=W.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:q.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:Y.slice(0,60).map(e=>n.jsxs("button",{className:"tl-shotfx-card",title:a(e.desc),disabled:!!l,onClick:()=>void Z(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=X(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{je as default,U as vfxSceneHash};
@@ -1 +0,0 @@
1
- import{j as m}from"./remote-DXG553d8.js";import{r as p}from"./api-C5pOWyBM.js";import{gR as g}from"./titleFrameBudget-BjW--v_T.js";import{d}from"./main-BNZrzSIG.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./lottieLayer-BhLbZOpr.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./titleArt-CAOxtyHl.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";const f=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"];function W(){const c=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=c.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]),m.jsx("div",{style:{margin:0,background:"#000",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:m.jsx("canvas",{ref:c,width:1280,height:720,style:{width:"100%",height:"100%",objectFit:"contain"},"aria-label":"Transition preview"})})}export{W as default};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-DXG553d8.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-Dxq3MZF3.js","assets/rotoMaskStore-DrRawyH9.js","assets/rigTrack-CW9_kg5j.js"])))=>i.map(i=>d[i]);
2
- import{_ as et}from"./titleFrameBudget-BjW--v_T.js";import{jx as U,j5 as q,fv as V,gS as y,dM as b,fx as B,jy as at,i_ as ot,hM as G,fO as it,fI as nt,fJ as Q,fy as rt,hJ as st,j3 as ct}from"./remote-DXG553d8.js";import{c as mt}from"./cameraPresets-CeStHDvF.js";import"./api-C5pOWyBM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.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 Mt(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=q(k,String(o.name??""))}catch(t){return{ok:!1,error:t.message}}if(!V(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=q(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&&V(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=B(a.id),_=at(a.id);if(!p||!_)return{ok:!1,error:`the clip ${a.id} is missing`};const v=[];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,M=b(s,{...S,flight:void 0},Math.min(1,$/w)).position,F=X(g,M);let x=g;if(!a.ranged){const t=(_.dz+(a.reach??.8))*lt(e),m=Math.hypot(M[0]-g[0],M[2]-g[2])||1,n=(g[0]-M[0])/m,r=(g[2]-M[2])/m;x=[M[0]+n*t,g[1],M[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),v.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 R=(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&&R(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)},v.push(`${e.name} lands on the strike (flight off at ${u(j)} s)`));const K=G(h,e.id,p,{start:i/y(h).duration,newId:C,loop:!1});if(!K.ok)return{ok:!1,error:K.error};c.setStage(()=>K.stage);const{runTool:Y}=await et(async()=>{const{runTool:t}=await import("./remote-DXG553d8.js").then(m=>m.jH);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7])),J=[];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?J.push({effect:t.fx,start_s:u(m)}):v.push(`${t.fx}: ${String(d.error)}`)}const I=String(o.react??"hit");let T=null;if(I!=="none"){const t=R(s,$,c.getStage()),[m,n]=I==="block"?t?["ac-air-block",.16]:["xx-palm-shield",.22]:I==="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=B(m);if(f){let d=c.getStage();const A=y(d),D=A.duration,L=b(s,{...A,flight:void 0},Math.min(1,r/D)).position,Z=b(e,A,Math.min(1,r/D)).position;d=z(d,s,r,L,X(L,Z)),r+f.duration+.3>D&&(d=W(d,Math.min(300,Math.ceil((r+f.duration+.4)*10)/10)));const P=G(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)},I==="hit"&&o.timing!==!1){const O=y(c.getStage()),tt=nt(rt(O.timing,O.duration),[$],a.heavy?Q.heavy:Q.medium,O.duration);c.setStage(N=>({...N,shots:N.shots.map(H=>H.id===O.id?{...H,timing:tt??void 0}:H)}))}}else v.push(`${s.name} ${m}: ${P.error}`)}}const E=[];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),E.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:J,...T?{reaction:T}:{},...E.length?{camera:E}:{},...v.length?{notes:v}:{}}}export{Mt as aerialStrike};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/views-sH39zgjD.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/skin-BQG1Iz6Q.js","assets/remote-DXG553d8.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/store-Dxq3MZF3.js","assets/rotoMaskStore-DrRawyH9.js","assets/rigTrack-CW9_kg5j.js"])))=>i.map(i=>d[i]);
2
- import{_ as K}from"./titleFrameBudget-BjW--v_T.js";import{gS as y,gD as D,gF as _,iy as M,j5 as v,gE as S,d_ as O,jl as q,gL as F,gM as z,gI as G,gJ as E,gK as P,gN as V,gH as U,fZ as C}from"./remote-DXG553d8.js";import{f as L,d as H,e as N}from"./skin-BQG1Iz6Q.js";import"./api-C5pOWyBM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const A=["humanoid","quadruped","chain","hinge","wheels"],T=()=>crypto.randomUUID(),J=o=>Math.round(o*100)/100,w=o=>o.joints.filter(n=>!O(o.joints,n)).map(n=>n.name);function re(o,n){const i=o.rig,e=y(n),r=(e.objectKeys?.[o.id]||[]).filter(a=>a.bones),u=new Set;for(const a of r)for(const[s,t]of Object.entries(a.bones))t.some(c=>Math.abs(c)>.05)&&u.add(s);const g=w(i);return{rig:i.kind,rig_source:i.source,fingers:_(i),bones:g.filter(a=>!M(a)),..._(i)?{finger_bones:"thumb|index|middle|ring|pinky + 1..3 + L|R (e.g. index2R); hand shapes via set_pose hands curl them"}:{},keyed_bones:[...u],bone_key_times:r.map(a=>J(a.time*e.duration)),...i.bones?{posed_bones:Object.keys(i.bones)}:{},...D(i)?{posable:"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze and resolve_hits work on it like on a mannequin"}:{}}}function x(o,n){const i=w(o);return i.find(e=>e===n)??i.find(e=>e.toLowerCase()===n.toLowerCase())??null}const R=o=>Array.isArray(o)&&o.length===3&&o.every(n=>Number.isFinite(Number(n)))?o.map(n=>Math.round(Math.max(-S.angle,Math.min(S.angle,Number(n)))*100)/100):null;function $(o,n,i,e,r){o.setStage(u=>{const g=y(u),a=u.items.find(d=>d.id===n.id),s=g.objectKeys?.[n.id]||[],t=(d,h)=>{const k=s.find(j=>Math.abs(j.time-d)<1e-6),p=C(a,g,d);return{...k,id:k?.id||T(),time:d,position:p.position,rotation:p.rotation,scale:p.scale,bones:h}};let c=[...s];if(!s.some(d=>d.bones)&&i>1e-6){const d=t(0,{...a.rig?.bones||{}});c=[...c.filter(h=>h.id!==d.id),d]}const m=U(c,i,a.rig?.bones),{poseEase:f,...b}=t(i,{...m,...e}),l=r&&r!=="smooth"?{...b,poseEase:r}:b;return c=[...c.filter(d=>d.id!==l.id),l].sort((d,h)=>d.time-h.time),{...u,shots:u.shots.map(d=>d.id===g.id?{...d,objectKeys:{...d.objectKeys,[n.id]:c}}:d)}})}async function B(o,n){const i=o.engine();if(!i)return null;for(let e=0;e<200;e++){i.sync(o.getStage(),null);const r=i.objects.children.find(u=>u.userData.id===n)?.children[0];if(r)return r;await new Promise(u=>setTimeout(u,100))}return null}async function I(o,n){const i=v(o.getStage(),String(n.name));if(i.kind!=="model"||!i.model)return{ok:!1,error:`'${i.name}' is not a GLB model; people (mannequins) are already posable`};const e=String(n.kind??"humanoid");if(!A.includes(e))return{ok:!1,error:`unknown kind '${e}'; use ${A.join(", ")}`};const r=[];let u=n.ai===!0;if(u&&e!=="humanoid")return{ok:!1,error:"the AI auto-rig is for humanoid characters only; use the free template of that kind (ai:false)"};u&&!q(o.userText)&&(u=!1,r.push("ai:true refused — the user did not ask for the paid AI auto-rig; the free humanoid template was used (no credits). Only use ai:true when the user explicitly asks for AI / auto-rig."));const g=await B(o,i.id);if(!g)return{ok:!1,error:`${i.name} is not loaded (renderer not ready or the GLB failed to load)`};const a=e==="humanoid"&&!u&&n.file_skeleton!==!1?o.engine()?.nativeSkeleton?.(i.id):null;if(a?.ok)return o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:void 0,skeleton:"native"}:d)})),o.engine()?.sync(o.getStage(),null),{ok:!0,name:i.name,rig:"humanoid",source:"file",bones:a.bones,fileBones:a.total,credits:0,paid:!1,...r.length?{notes:r}:{},hint:"the model plays on its own skeleton and skin from the file (as in Blender): set_pose, play_motion, stage_spell_duel, hold_prop and set_gaze work on it"};const s=L(g);if(s.isEmpty())return{ok:!1,error:`${i.name} has no geometry to rig`};let t,c=0,m=null;if(u){const l=(o.rigViews??(await K(async()=>{const{renderRigViews:p}=await import("./views-sH39zgjD.js");return{renderRigViews:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]))).renderRigViews)(g),d=o.rigAgent??(await K(async()=>{const{rigAgent:p}=await import("./api-C5pOWyBM.js").then(j=>j.c1);return{rigAgent:p}},__vite__mapDeps([5,6]))).rigAgent,h={requestId:T(),front:l.front,side:l.side,name:i.name};let k;try{k=await d(h)}catch(p){if(!(p instanceof TypeError))return{ok:!1,error:p.message||"AI auto-rig failed (no credits charged)"};k=await d(h)}if(!k.humanoid||!k.landmarks||!k.landmarks.humanoid)return{ok:!1,error:"the AI did not see a humanoid in this model; no credits were charged. Use a free template: quadruped / chain / hinge / wheels, or humanoid.",credits:0};t=F(k.landmarks,l.frame),c=k.credits,m=z(k.landmarks,l.frame)}else{const l=e==="humanoid"?H(g):null;t=G(e,{min:s.min.toArray(),max:s.max.toArray()},{segments:Number(n.segments)||4,...l?{tips:l}:{}})}e==="humanoid"&&n.fingers!==!1&&(t=E(t,{positions:N(g).positions,tips:m})),o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:t,skeleton:void 0}:d)}));const f=o.engine();let b;if(f){f.sync(o.getStage(),null),await f.rigReady();const l=f.objects.children.find(d=>d.userData.id===i.id)?.children[0]?.userData.rig;l&&(b={vertices:l.info.vertices,ms:l.info.ms,source:l.info.source})}return{ok:!0,name:i.name,rig:t.kind,source:t.source,joints:t.joints.length,fingers:_(t),bones:w(t).filter(l=>!M(l)),credits:c,paid:u,...b?{weights:b}:{},...r.length?{notes:r}:{},hint:t.kind==="humanoid"?"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze, resolve_hits now work on it; set_bone_rotation / set_bone_keys turn single bones":"turn its bones with set_bone_rotation / set_bone_keys (time = a key)"}}async function Z(o,n){const i=o.getStage(),e=v(i,String(n.name)),r=String(n.action||"");if(e.locked)return{ok:!1,error:`${e.name} is locked in the composer`};const u=s=>s.map(t=>(({bones:c,...m})=>m)(t));if(r==="remove")return!e.rig&&e.skeleton!=="native"?{ok:!1,error:`${e.name} has no skeleton`}:(o.setStage(s=>({...s,items:s.items.map(t=>t.id!==e.id?t:(({rig:c,skeleton:m,...f})=>f)(t)),shots:s.shots.map(t=>t.objectKeys?.[e.id]?{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}}:t)})),{ok:!0,name:e.name,removed:"skeleton and its bone keys"});if(!e.rig)return{ok:!1,error:`${e.name} has no editable skeleton; rig_template gives it one`};if(r==="reset_bones")return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id&&t.rig?{...t,rig:(({bones:c,...m})=>m)(t.rig)}:t),shots:s.shots.map(t=>t.id!==s.activeShot||!t.objectKeys?.[e.id]?t:{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}})})),{ok:!0,name:e.name,reset:"every bone back to rest (bone keys of this shot removed)"};const g=await B(o,e.id);if(!g)return{ok:!1,error:`${e.name} is not loaded (it needs the 3D view: a scene open in the composer or the render machine)`};let a;if(r==="mirror"){const s=L(g);a=P(e.rig,(s.min.x+s.max.x)/2)}else if(r==="fingers")a=n.on===!1?V(e.rig):_(e.rig)?e.rig:E(e.rig,{positions:N(g).positions});else return{ok:!1,error:"action must be remove, reset_bones, mirror or fingers"};return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id?{...t,rig:a}:t)})),{ok:!0,name:e.name,action:r,joints:a.joints.length,fingers:_(a)}}async function se(o,n,i){try{if(o==="auto_rig")return await I(i,n);if(o==="rig_template")return await I(i,{...n,ai:!1});if(o==="rig_edit")return await Z(i,n);const e=i.getStage(),r=v(e,String(n.name)),u=y(e);if(!r.rig)return{ok:!1,error:`${r.name} has no skeleton; call auto_rig first (people mannequins use set_pose)`};const g=n.ease==null?void 0:String(n.ease);if(g&&!["smooth","snap","hold","overshoot"].includes(g))return{ok:!1,error:`unknown ease '${g}'`};if(o==="set_bone_rotation"){const a=x(r.rig,String(n.bone??"")),s=R(n.rotation_deg);if(!a)return{ok:!1,error:`unknown bone '${String(n.bone)}' of ${r.name}; bones: ${w(r.rig).join(", ")}`};if(!s)return{ok:!1,error:"rotation_deg must be [x, y, z] degrees"};if(n.time==null)return i.setStage(c=>({...c,items:c.items.map(m=>{if(m.id!==r.id||!m.rig)return m;const f={...m.rig.bones||{},[a]:s};return s.every(b=>b===0)&&delete f[a],{...m,rig:{...m.rig,...Object.keys(f).length?{bones:f}:{bones:void 0}}}}),shots:c.shots.map(m=>m.id!==c.activeShot||!m.objectKeys?.[r.id]?.some(f=>f.bones)?m:{...m,objectKeys:{...m.objectKeys,[r.id]:m.objectKeys[r.id].map(f=>f.bones?{...f,bones:{...f.bones,[a]:s}}:f)}})})),{ok:!0,name:r.name,bone:a,rotation_deg:s,whole_shot:!0};const t=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,t,{[a]:s},g),{ok:!0,name:r.name,bone:a,rotation_deg:s,time:Number(n.time),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(c=>c.bones).length}}if(o==="set_bone_keys"){if(n.time==null)return{ok:!1,error:"set_bone_keys needs time (seconds); use set_bone_rotation without time for the whole shot"};const a=n.bones&&typeof n.bones=="object"&&!Array.isArray(n.bones)?Object.entries(n.bones):[];if(!a.length)return{ok:!1,error:"bones must map bone names to [x, y, z] degrees"};const s={},t=[];for(const[m,f]of a.slice(0,S.joints)){const b=x(r.rig,m),l=R(f);!b||!l?t.push(m):s[b]=l}if(t.length)return{ok:!1,error:`unknown bones or bad angles: ${t.join(", ")}; bones: ${w(r.rig).join(", ")}`};const c=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,c,s,g),{ok:!0,name:r.name,time:Number(n.time),bones_set:Object.keys(s),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(m=>m.bones).length}}return{ok:!1,error:`unknown tool '${o}'`}}catch(e){return{ok:!1,error:e.message||String(e)}}}export{A as RIG_TEMPLATE_KINDS,re as rigSummary,se as runRigTool,w as turnableBones};
@@ -1 +0,0 @@
1
- import{u as v}from"./store-Dxq3MZF3.js";import{t as S}from"./api-C5pOWyBM.js";import{ao as A}from"./remote-DXG553d8.js";import{ac as y,z as k,ad as I,l as P,w as _,y as j,H as F}from"./main-BNZrzSIG.js";import{runAnalyzerCode as R}from"./analyzerSandbox-DQGHjUCa.js";import{e as E}from"./pluginAutomation-DdZOnpoV.js";import"./titleFrameBudget-BjW--v_T.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./lottieLayer-BhLbZOpr.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./titleArt-CAOxtyHl.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";async function $(t){const{plugins:o}=await P(),e=o.find(a=>a.id===t.id&&a.enabled);if(!e)throw _("use_missing",[t.id]);const n=t.item?await j(e,t.item):await F(e);if(n.manifest.kind!=="analyzer")throw _("use_plugin",[0,t.item?`${t.id}/${t.item}`:t.id],"not an analyzer plug-in");return n}async function H(t,o,e){if(window.__analyzerFramesStub)return window.__analyzerFramesStub(t,o);const n=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});n.src=t.url;try{await new Promise((l,h)=>{n.onloadeddata=()=>l(),n.onerror=()=>h(Error(S("Không đọc được video của clip (CORS / định dạng)")))});const a=n.videoWidth||1280,d=n.videoHeight||720,r=Math.min(o.width,a),s=Math.max(2,Math.round(r*d/a)),i=Object.assign(document.createElement("canvas"),{width:r,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(r*s*c);for(let l=0;l<c;l++){e?.aborted;const h=Math.max(0,Math.min(n.duration-1/60,b+l/o.fps*p));Math.abs(n.currentTime-h)>1e-4&&await new Promise((u,f)=>{const x=window.setTimeout(()=>f(Error(S("Seek video quá lâu"))),8e3);n.onseeked=()=>{window.clearTimeout(x),u()},n.currentTime=h}),m.drawImage(n,0,0,r,s);const w=m.getImageData(0,0,r,s).data,M=l*r*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:r,height:s,count:c,data:g,sourceWidth:a,sourceHeight:d}}finally{n.removeAttribute("src"),n.load()}}function O(t){const o=v.getState().timelineMedia.find(i=>t.gcsUri&&i.gcsUri===t.gcsUri||i.url===t.url),e=t.playbackRate||1,n=t.inPoint||0,a=i=>+((i-n)/e).toFixed(3),d=i=>a(i.end)>0&&a(i.start)<t.duration,r=(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:r,pauses:s}}async function ot(t,o){const e=o.params??{};if(!e.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 n=await $(e.plugin),a=n.manifest,d=a.sample??{fps:y.fps.default,width:y.width.default,maxSeconds:y.maxSeconds.default},r=await H(t,d),s={clip:{duration:t.duration,width:r.sourceWidth,height:r.sourceHeight},frames:{fps:r.fps,width:r.width,height:r.height,count:r.count,data:r.data},...O(t),params:k(a,e.values??{})},i=I(await R(n.entry,s),t.id);if(!i.ops.length)return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:e.plugin.item?`${e.plugin.id}/${e.plugin.item}`:e.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:e.plugin.item?`${e.plugin.id}/${e.plugin.item}`:e.plugin.id,ops:i.ops.length,summary:i.summary}),c}export{ot as runAnalyzerJob};
@@ -1 +0,0 @@
1
- import{trackPose as S}from"./poseTracker--VJYw-hX.js";import{iM as v,iN as w,iO as N}from"./remote-DXG553d8.js";import{b$ as T,b_ as q}from"./titleFrameBudget-BjW--v_T.js";import{u as x}from"./store-Dxq3MZF3.js";import{t as l}from"./api-C5pOWyBM.js";import"./main-BNZrzSIG.js";import"./three.module-Bx43vjkH.js";import"./spark.module-CMSPLU2n.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";import"./userFonts-txN4I-eo.js";import"./lottieLayer-BhLbZOpr.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./titleArt-CAOxtyHl.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.js";async function Q(p,f){const e=f.params??{},s=x.getState(),r=s.clips.find(t=>t.id===e.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=e.from??0,y=e.duration??p.duration,{frames:c,aspect:b}=await S({clip:r,url:g,from:a,duration:y,fps:v.fps,person:e.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}=T(s.timelineFormat),k=Math.round(b*1e3),M=1e3,A=w(c.map(t=>({t:t.t,lm:t.lm})),([t,m])=>[t,m]).map(t=>{const m=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=q(r,t[i],t[i+1],m,u,d,k,M);n.push(Math.round(h.px/u*1e3)/1e3,Math.round(h.py/d*1e3)/1e3)}return n}),o=p.motion?.params??{};return{motion:N(A,{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{Q as runAuraTrack};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-DXG553d8.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-Dxq3MZF3.js","assets/rotoMaskStore-DrRawyH9.js","assets/rigTrack-CW9_kg5j.js"])))=>i.map(i=>d[i]);
2
- import{_ as R}from"./titleFrameBudget-BjW--v_T.js";import{j5 as q,fv as z,gS as x,jz as B,i_ as N,fK as H,fy as U,fx as F,hM as G}from"./remote-DXG553d8.js";import{c as V}from"./cameraPresets-CeStHDvF.js";import"./api-C5pOWyBM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const J=()=>crypto.randomUUID(),s=i=>Math.round(i*100)/100,P={"luyen-khi":{color:"#e6f2ff",tiers:9,core:!1,name:"Luyện khí"},"truc-co":{color:"#5cff9a",tiers:3,core:!1,name:"Trúc cơ"},"ket-dan":{color:"#ffcf4a",tiers:9,core:!0,name:"Kết đan"},"nguyen-anh":{color:"#b066ff",tiers:12,core:!0,name:"Nguyên anh"},"hoa-than":{color:"#5cc8ff",tiers:12,core:!0,name:"Hoá thần"}};function Q(i,c){const e=x(i),$=e.duration/c,u=n=>n?.map(f=>({...f,time:Math.min(1,f.time*$)})),m={...e,duration:c,cameraKeys:u(e.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(e.objectKeys||{}).map(([n,f])=>[n,u(f)||[]])),...e.flight?{flight:Object.fromEntries(Object.entries(e.flight).map(([n,f])=>[n,u(f)||[]]))}:{}};return{...i,shots:i.shots.map(n=>n.id===e.id?m:n)}}async function ot(i,c){let e;try{e=q(c.getStage(),String(i.name??""))}catch(t){return{ok:!1,error:t.message}}if(!z(e))return{ok:!1,error:`'${e.name}' is not a person`};const $=String(i.realm??"ket-dan"),u=P[$];if(!u)return{ok:!1,error:`unknown realm; use one of ${Object.keys(P).join(", ")}`};const m=i.outcome==="fail",n=i.tribulation!==!1,f=Math.max(1,Math.min(9,Number(i.strikes??4)||4)),v=Math.max(.8,Math.min(12,Number(i.height??2)||2)),y=Math.max(0,Number(i.start??0)||0),A=String(i.color??u.color),j=y+2.6,g=j+3.2,K=g+1.2,M=n?1.6+f*1.05:0,C=g+2.4+M,h=C,d=h+1.6,_=d+2.2,w=m?h+2.6:_+2.6;let l=c.getStage();w+.5>x(l).duration&&(l=Q(l,Math.min(300,Math.ceil((w+.6)*10)/10)));const S=[],O=[],k=(t,r,o=!1)=>{const a=F(t);if(!a){S.push(`${t} missing`);return}const p=G(l,e.id,a,{start:r/x(l).duration,newId:J,loop:o});p.ok?(l=p.stage,O.push({motion:t,at_s:s(r)})):S.push(`${t}: ${p.error}`)};k("xx-seal-seated",y),k("xx-bt-gather",j,!0),k("xx-bt-strain",g,!0);const T=K,D=n?B(M+1.2,f).map(t=>T+t):[];for(const t of D)k("xx-bt-endure",Math.max(g,t-.12));if(m)k("xx-bt-backlash",h);else{const t=x(l),r=t.duration;let o=N(t.flight?.[e.id],{time:h/r,on:!0,height:v});o=N(o,{time:(_+1.4)/r,on:!1}),l={...l,shots:l.shots.map(a=>a.id===t.id?{...a,flight:{...a.flight,[e.id]:o}}:a)},k("xx-bt-lotus-air",h,!0),k("xx-bt-roar",d),k("xx-bt-settle",_)}c.setStage(()=>l);const{runTool:L}=await R(async()=>{const{runTool:t}=await import("./remote-DXG553d8.js").then(r=>r.jH);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7])),I=[],b=async(t,r,o,a={})=>{const p=await L("add_effect",{effect:t,attach_to:e.name,start:s(r),duration:o,color:A,...a},c);p.ok?I.push({effect:t,start_s:s(r)}):S.push(`${t}: ${String(p.error)}`)};if(await b("linh-khi-quy-nguyen",y+.6,g-y+1),await b("kinh-mach-kim",j+.8,4),await b("canh-gioi-ket-dan",g-.4,2.4+M+.8,{params:{tiers:u.tiers}}),n&&await b(m?"kiep-van-huyet":"kiep-van-thien-loi",T,M+1.2,{params:{strikes:f},color:m?"#ff3040":"#9fd8ff"}),m)await b("huyet-vu",h+.5,1.6);else if(u.core&&await b("kim-dan-thanh",h+.2,1.8,{params:{seated:1,lift:v}}),await b("thien-quang-tru-kim",d+.62,3.2),await b("dot-pha-song-kim",d+.62,2.4,{params:{seated:1,lift:v}}),i.timing!==!1){const t=x(c.getStage()),r=H(U(t.timing,t.duration),d+.7,.45,.35,t.duration);c.setStage(o=>({...o,shots:o.shots.map(a=>a.id===t.id?{...a,timing:r??void 0}:a)}))}const E=[];if(i.camera!==!1){const t=[["orbit-180",y,g],["wide-track",g,K+.4],["low-hero",K+.4,m?w:d],...m?[]:[["wide-track",d,d+2.2],["orbit-180",_,w]]];for(const[r,o,a]of t){if(a-o<.4)continue;const p=V(c.getStage(),{preset:r,subject:e.id,start:o,end:a});p.ok&&(c.setStage(()=>p.stage),E.push(`${r} ${s(o)}–${s(a)} s`))}}return{ok:!0,name:e.name,realm:u.name,outcome:m?"fail":"success",start_s:s(y),gather_s:s(j),tribulation_s:n?s(T):null,strikes_s:D.map(s),...m?{backlash_s:s(h)}:{rise_s:s(h),burst_s:s(d+.62),landed_s:s(_+1.4)},end_s:s(w),moves:O,effects:I,...E.length?{camera:E}:{},...S.length?{notes:S}:{}}}export{P as REALMS,ot as stageBreakthrough};
@@ -1 +0,0 @@
1
- import{b$ as d,f7 as b,f8 as y,lf as k,eO as x,cK as w,e_ as E,ii as O,lg as S,fD as _,eG as A,eH as D,eK as v,ea as h,ec as g,lh as B,U as T,W as $,li as I,hR as R,bJ as L}from"./titleFrameBudget-BjW--v_T.js";import{bg as P,bh as j}from"./remote-DXG553d8.js";import"./api-C5pOWyBM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const z=new Set(["opacity","x","y","zoom","blur","exposure","dirBlur","zoomBlur","rgbSplit","invert","glitch","rot","spinBlur","dirBlurV"]),F=e=>!(e?.dirBlur&&(e.zoom||e.blur||e.zoomBlur))&&!(e?.zoomBlur&&(e.x||e.y||e.blur||e.dirBlur)),K=new Set(["id","name","category","duration","tags","version","sortOrder","a","b","flash","light","mask","zoomAt"]),M=["colorPerson","matte","shocks","impacts","smoothSlow","reverse","revealType","rotFit","is3D","space","bend","bendStrip","device","deviceScreen","join","audioFx","audioTools","muffle","trail","path","links","element","modelGround","modelRotation","modelSpin","modelAnim","modelDepth","spatialDepth","pendingPin","personPending","samPending","gen","clientJobs","mapAnno","seam","warped"],X={rx:0,ry:0,rz:0,ax:0,ay:0,depth:0,tiltX:0,tiltY:0},H=new Set(["rot","sx","sy","depth","tiltX","tiltY"]),J=new Set(["is3D","spatialDepth"]),N=new Set(["blur","glow","light-burst","rgb-split","pixelate","sepia","invert","mono","duotone","luma-invert",...Object.keys(L)]),c=e=>e!=null&&e!==!1&&!(Array.isArray(e)&&!e.length);function C(e,{camera:s=null,W:a=1280,H:f=720}={}){const n=[];if(w(e))return[];if(e.kind==="model")return[];if(!["image","video","audio"].includes(e.kind))return[`${e.kind} layer`];const r=e.kind!=="audio"&&b(s)&&y(e),p=!r&&e.is3D===!0&&!c(e.spatialDepth);for(const t of M){if(t==="clientJobs"){Array.isArray(e.clientJobs)&&e.clientJobs.some(o=>o?.state==="pending"||o?.state==="running")&&n.push(t);continue}c(e[t])&&!(r&&J.has(t))&&!(p&&t==="is3D")&&n.push(t)}if(e.pin?.scene&&n.push("scene pin"),e.timeRemap?.blend&&e.timeRemap.blend!=="none"&&n.push("time remap frame blending"),e.kind!=="audio"&&E(e,a||1280).some(t=>t.sigma>42)&&n.push("wide shadow"),O(e)&&S(e)&&n.push("shadow on an adjustment layer"),e.motionBlur&&e.kind!=="audio"&&((e.effects||[]).some(t=>!t.off)||e.pin||e.parentId||_(e)||e.layout!==void 0||e.rotFit||r)&&n.push("motion blur"),e.kind!=="audio"&&A(e)){const t=D(e),o=v(t);t.cover<.999||t.comet||t.crackle?n.push("edge arc"):Math.max(o.band,o.glow)>42&&n.push("wide edge")}!r&&e.kind!=="audio"&&(h(e,"rot").length>1||Math.abs(g(e,"rot",0))>1e-9)&&((e.effects||[]).some(t=>!t.off)||e.layout!==void 0||e.rotFit)&&n.push("rot"),r&&(e.transition||e._txIn||e._txOut)&&n.push("transition on a 3D layer");for(const[t,o]of Object.entries(X))!(r&&H.has(t))&&(h(e,t).length>1||Math.abs(g(e,t,0)-o)>1e-9)&&n.push(t);e.grade&&!e.colorBypass&&(e.grade.lut||B(e.grade).length)&&n.push("grade"),e.grade&&!e.colorBypass&&T(e.grade).some(t=>$(t)&&(t.window?.type==="person"||t.qualifier&&(t.window?.type==="polygon"||t.motion||t.window?.type==="face")))&&n.push("grade window");for(const t of Array.isArray(e.effects)?e.effects:[])!t.off&&!N.has(t.type)&&n.push(`effect ${t.type}`);if(I(e,"T")&&n.push("reveal"),e.transition){const t=e.transition.spec||{},o=i=>!!e.transition.ramp||F(i);(Object.keys(t).some(i=>!K.has(i))||["a","b"].some(i=>t[i]&&(Object.keys(t[i]).some(l=>!z.has(l))||!o(t[i]))))&&n.push(`transition ${e.transition.id}`)}return e.kind==="video"&&R(e)&&n.push("title on video"),n}function ee(e,s={}){const{reasons:a}=u(e,s);return{ok:a.length===0,reasons:a}}function te(e,s={}){return[...new Set(u(e,s).codes)].sort()}function u(e,{format:s,camera:a,look:f}={}){const n=[],r=[];e=P((e||[]).filter(o=>!o.disabled),{W:d(s).width,H:d(s).height});const p=b(a)?a:null,{width:m,height:t}=d(s);p&&(e||[]).some(o=>!o.disabled&&o.kind!=="audio"&&y(o))&&p.parentId&&(n.push("camera on a parent"),r.push("camera on a parent")),k(f)&&(n.push("look"),r.push("look"));for(const o of e||[]){if(o.disabled)continue;if(o._group&&o.comp){const l=u(j(o),{format:s});l.reasons.length&&(n.push(`${o.label||o.id} (comp): ${l.reasons.join("; ")}`),r.push(...l.codes))}const i=C(o,{camera:p,W:m,H:t});i.length&&(n.push(`${o.label||o.id}: ${i.join(", ")}`),r.push(...i))}if(!n.length)for(const o of x((e||[]).filter(i=>!i.disabled))){const i=l=>{n.push(`${o.label||o.id}: ${l}`),r.push(l)};o.speedRamp&&(o._txIn||o._txOut)&&i("speed ramp in a transition"),o.timeRemap&&(o._txIn||o._txOut)&&!o._ramp&&i("time remap in a transition"),o.motionBlur&&(o._txIn||o._txOut)&&i("motion blur in a transition")}return{reasons:n,codes:r}}const oe=(e,s,a)=>(s==="video encode"||s==="finalize")&&a?.codec!=="hevc"&&e?.name!=="AbortError"&&/^(OperationError|EncodingError)$/.test(e?.name||""),ne=e=>!(typeof DOMException<"u"&&e instanceof DOMException)&&!(e instanceof TypeError)&&!(e instanceof Error&&/^media \d{3}$/.test(e.message))?"":(e.message||"").replace(/\b(?:https?|blob|data):\S*/gi,"").replace(/\s+/g," ").trim();export{M as HEAVY_FIELDS,ee as clientExportCheck,te as clientExportCodes,C as clipBlockers,ne as gpuErrorText,oe as softwareRetry};
@@ -1 +0,0 @@
1
- import{C,c as M}from"./cameraPresets-CeStHDvF.js";import{gS as g,j5 as y,fy as k,fz as D,fJ as S,fI as A,fK as N,fD as P,fE as I,fC as F,ju as x,fv as j,fL as R,fB as $}from"./remote-DXG553d8.js";import{s as z}from"./weaponDuel-CEvRDeuE.js";import"./api-C5pOWyBM.js";import"./titleFrameBudget-BjW--v_T.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const L=["katana","spear","staff","fist"],v=C.map(e=>e.id),O=()=>crypto.randomUUID(),w=e=>Math.round(e*100)/100,b=(e,a)=>L.includes(e)?e:a,E=(e,a,m)=>({...e,shots:e.shots.map(f=>f.id===a?{...f,...m}:f)}),T=e=>{const a=g(e),m=k(a.timing,a.duration);return{hit_stops:m?.holds.length??0,slow_spans:m?.slows??[],scene_s:a.duration,video_s:w($(a)),...a.impactFrame?{impact_frame:a.impactFrame}:{}}};function V(e,a){const m=a.getStage(),f=g(m),n=Array.isArray(e.fighters)?e.fighters.map(String):[];if(n.length!==2)return{ok:!1,error:"give fighters: [first attacker, opponent] (two person names)"};let r;try{r=n.map(t=>y(m,t))}catch(t){return{ok:!1,error:t.message}}for(const t of r)if(!j(t))return{ok:!1,error:`'${t.name}' is not a person (or a humanoid-rigged model)`};const p=Array.isArray(e.weapons)?e.weapons:[e.weapons??e.weapon,e.weapons??e.weapon],c=[b(p[0],"katana"),b(p[1]??p[0],b(p[0],"katana"))],h=Math.max(0,Math.min(f.duration,Number(e.start??0)||0)),i=z(m,{a:r[0].id,b:r[1].id,packs:c,exchanges:Number(e.exchanges??4)||4,seed:Number(e.seed)||1,start:h,hitStops:e.hit_stops!==!1},O);if(!i.ok)return{ok:!1,error:i.error};let s=i.stage;const l=Math.min(g(s).duration,i.end+.4),u=String(e.camera??"fight");let o={kept:"your own camera"};if(u==="fight")try{const t=R(s,{fighters:r.map(_=>_.name),start:h,end:l,focal_length_mm:Number(e.focal_length_mm)||32});s=t.stage,o={fight_camera:t.result}}catch(t){o={error:t.message}}else if(u!=="none"){const t=M(s,{preset:u,subject:r[0].id,start:h,end:l});t.ok?(s=t.stage,o={preset:t.preset,subject:t.subject,keys:t.keys,cuts:t.cuts}):o={error:t.error}}if(e.impact_frame&&e.impact_frame!=="none"){const t=F({style:e.impact_frame,strength:e.impact_strength??.8});t&&(s=E(s,g(s).id,{impactFrame:t}))}return a.setStage(()=>s),{ok:!0,fighters:r.map(t=>t.name),weapons:c,start:h,end:i.end,shot_duration_s:g(s).duration,exchange:i.plan.map(t=>({time_s:t.time,attacker:t.attackerName,attack:t.attack,defence:t.defence,result:t.result})),camera:o,timing:T(s),...i.notes.length?{notes:i.notes}:{},hint:"weapons are put in the hands with a trail (set_trail to restyle); re-run with another seed for another plan; add impact effects at the strike times of blocked / body results (none on a miss = a dodge) and set_timing for slow motion on the finisher"}}function X(e,a){const m=a.getStage(),f=g(m);if(!v.includes(String(e.preset)))return{ok:!1,error:`unknown preset; use one of ${v.join(", ")}`};let n;try{n=y(m,String(e.subject??""))}catch(h){return{ok:!1,error:h.message}}const r=Math.max(0,Number(e.start??0)||0),p=e.end==null?f.duration:Number(e.end),c=M(m,{preset:String(e.preset),subject:n.id,start:r,end:p});return c.ok?(a.setStage(()=>c.stage),{ok:!0,preset:c.preset,subject:n.name,start:w(c.start),end:w(c.end),camera_keys:c.keys,hit_beats:c.beats,cuts:c.cuts,note:"camera keys inside the span are replaced; the preset tracks the subject's motion, so bake it AFTER the motion is final"}):{ok:!1,error:c.error}}function Z(e,a){const m=a.getStage(),f=g(m),n=f.duration;let r=k(f.timing,n);const p=D(m).map(o=>o.time).filter(o=>o>.05&&o<n-.05),c=S[e.strength]??S.medium,h=String(e.hit_stops??"keep");if(h==="none"&&(r=k({holds:[],slows:r?.slows??[]},n)),h==="auto"){if(!p.length)return{ok:!1,error:"no strike in the shot to stop on (stage_fight / stage_duel / play_motion strikes first, or give hit_stops_at)"};r=A(r,p,c,n)}if(Array.isArray(e.hit_stops_at)&&(r=A(r,e.hit_stops_at.map(Number).filter(o=>Number.isFinite(o)&&o>=0&&o<=n),c,n)),e.clear_slow_motion&&(r=k({holds:r?.holds??[],slows:[]},n)),e.slow_finisher){if(!p.length)return{ok:!1,error:"no strike in the shot for slow_finisher"};r=N(r,p[p.length-1],.3,.3,n)}for(const o of Array.isArray(e.slow_motion)?e.slow_motion:[]){const t=Number(o?.at);if(!Number.isFinite(t))return{ok:!1,error:"slow_motion entries need at (scene seconds)"};r=N(r,t,Math.max(.05,Math.min(3,Number(o.half??.35)||.35)),Math.max(.1,Math.min(1,Number(o.speed??.3)||.3)),n)}const i=Number(e._from)||0;if(i>0){const o=k(f.timing,n);r=k({holds:[...(o?.holds??[]).filter(t=>t.at<i),...(r?.holds??[]).filter(t=>t.at>=i)],slows:[...(o?.slows??[]).filter(t=>t.start<i),...(r?.slows??[]).filter(t=>t.start>=i)]},n)}let s={timing:r??void 0},l=null;if(e.preset==="sakuga"){if(l=P({...f,timing:r??void 0},I(m).filter(_=>_.at>.05&&_.at<n-.05),{keepLook:!1}),!l)return{ok:!1,error:"no blow in the shot for preset sakuga (stage_fight / resolve_hits first)"};let o=l.shot.timing??null,t=l.shot.impacts;if(i>0){const _=k(f.timing,n);o=k({holds:[...(_?.holds??[]).filter(d=>d.at<i),...(o?.holds??[]).filter(d=>d.at>=i)],slows:[...(_?.slows??[]).filter(d=>d.start<i),...(o?.slows??[]).filter(d=>d.start>=i)]},n),t=[...(f.impacts??[]).filter(d=>d.time*n<i),...(t??[]).filter(d=>d.time*n>=i)]}s={timing:o??void 0,impacts:t,impactFrame:l.shot.impactFrame}}if(e.impact_frame==="none")s={...s,impactFrame:void 0};else if(e.impact_frame!=null){const o=F({style:e.impact_frame,strength:e.impact_strength??f.impactFrame?.strength??.8});if(!o)return{ok:!1,error:`impact_frame: one of ${x.join(", ")} or none`};s={...s,impactFrame:o}}const u=E(m,f.id,s);return a.setStage(()=>u),{ok:!0,...T(u),strike_beats:p.map(w).slice(0,30),...l?{sakuga:{blows:l.plan.kinds.length,kinds:l.plan.kinds.slice(0,30),finisher_s:l.plan.finisher==null?null:w(l.plan.finisher)}}:{},note:"a render-time warp: preview and export freeze / slow these scene instants; impact frames flash on every hit-stop"}}function ee(e,a){const m=a.getStage(),f=Array.isArray(e.names)?e.names.map(String):e.name!=null?[String(e.name)]:[];if(!f.length)return{ok:!1,error:"give names: weapons, or people (their held weapons)"};const n=new Set;for(const i of f){let s;try{s=y(m,i)}catch(l){return{ok:!1,error:l.message}}if(s.kind==="prop"&&s.hold)n.add(s.id);else if(j(s)){const l=m.items.filter(u=>u.kind==="prop"&&u.hold?.by===s.id);if(!l.length)return{ok:!1,error:`${s.name} holds nothing (hold_prop / play_motion a weapon clip / stage_duel first)`};l.forEach(u=>n.add(u.id))}else return{ok:!1,error:`'${s.name}' is not a held weapon or a person`}}const r=e.on!==!1,p={},c=typeof e.color=="string"&&/^#[0-9a-f]{6}$/i.test(e.color)?e.color:void 0,h=e.length!=null&&Number.isFinite(Number(e.length))?Math.max(.03,Math.min(.5,Number(e.length))):void 0;return a.setStage(i=>({...i,items:i.items.map(s=>{if(!n.has(s.id))return s;if(!r){p[s.name]="off";const{trail:u,...o}=s;return o}const l={...s.trail||{},...e.style==="smear"||e.style==="ribbon"?{style:e.style}:{},...c?{color:c}:{},...h!=null?{length:h}:{}};return p[s.name]=l,{...s,trail:l}})})),{ok:!0,trails:p}}export{v as CAMERA_PRESET_IDS,L as DUEL_PACKS,X as cameraPreset,Z as setTiming,ee as setTrail,V as stageDuel};
@@ -1 +0,0 @@
1
- import{gS as gt,j5 as tt,fv as te,g7 as Jt,j6 as Wt,dM as bt,gc as kt,gd as _t,j7 as zt,g9 as Ct,gl as ee,j8 as oe,j9 as Tt,gh as Ft,gk as wt,gp as ne,gi as Ut,gn as ae,gg as ie,ja as re}from"./remote-DXG553d8.js";import"./api-C5pOWyBM.js";import"./titleFrameBudget-BjW--v_T.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const Bt=t=>Math.round(t*100)/100,pt=(t,a)=>({id:t.id,label:t.label??"",scope:t.scope,start_s:t.start,end_s:t.scope==="after"?null:t.end,fade_s:t.fade,...t.fadeOut!=null?{fade_out_s:t.fadeOut}:{},...t.track?{track:{from_s:t.track.t[0],to_s:t.track.t[t.track.t.length-1],samples:t.track.t.length,joints:Object.keys(t.track.pose||{}),...t.track.turn?{turn_deg_max:Math.round(Math.max(...t.track.turn.map(Math.abs)))}:{}}}:{},...t.off?{off:!0}:{},weight_now:Bt(kt(t,a)),...t.pose?{joints:t.pose}:{},...t.stance?{stance:t.stance}:{},...t.preset?{preset:t.preset}:{},...t.move?{move_m:[t.move[0],t.move[2]]}:{},...t.turn?{turn_deg:t.turn}:{}});function Kt(t,a){const f=a.getStage(),c=gt(f),r=c.duration;let o;try{o=tt(f,String(t.name??""))}catch(h){return{ok:!1,error:h.message}}if(!te(o))return{ok:!1,error:`'${o.name}' is not a person (or a humanoid-rigged model)`};const s=c.motionEdits?.[o.id]||[],e=Math.max(0,Math.min(r,Number(t.at??0)||0)),g=h=>a.setStage(N=>({...N,shots:N.shots.map(y=>y.id===c.id?{...y,motionEdits:{...y.motionEdits,[o.id]:h}}:y)}));if(t.remove!=null){const h=String(t.remove),N=h==="all"?[]:s.filter(y=>y.id!==h);return N.length===s.length&&h!=="all"?{ok:!1,error:`no edit '${h}' on ${o.name}; edits: ${s.map(y=>y.id).join(", ")||"none"}`}:(g(N),{ok:!0,name:o.name,removed:h==="all"?s.length:1,edits:N.map(y=>pt(y,e))})}const p=t.id!=null?s.find(h=>h.id===String(t.id)):void 0;if(t.id!=null&&!p)return{ok:!1,error:`no edit '${String(t.id)}' on ${o.name}`};const n=["moment","span","after"].includes(String(t.scope))?String(t.scope):p?.scope??"moment",d=(c.clipSpans?.[o.id]||[]).find(h=>e>=h.start-.001&&e<=h.end+.001);let u=p?.start??e,i=p?.end??e;if((t.at!=null||!p)&&(u=e,i=e),n==="span"){if(t.start!=null||t.end!=null)u=Number(t.start??u),i=Number(t.end??i);else if(d)u=d.start,i=d.end;else if(!p)return{ok:!1,error:`no motion block at ${e} s on ${o.name}: give start and end for scope span`}}const m=Number(t.fade??p?.fade??Jt.default),k=t.fade_out!=null?Number(t.fade_out):p?.fadeOut;if(t.face_toward!=null){let h;try{h=tt(f,String(t.face_toward))}catch(O){return{ok:!1,error:O.message}}if(h.id===o.id)return{ok:!1,error:"face_toward another object"};const N=Math.max(0,Math.min(1,Number(t.face_strength??1))),y={scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{}},W=Math.max(0,u-m),ot=n==="after"?r:Math.min(r,i+(k??m)),ct=Math.min(Wt.samples,Math.max(2,Math.ceil((ot-W)*24)+1)),Mt=s.filter(O=>O.id!==p?.id),H={...c,motionEdits:{...c.motionEdits,[o.id]:Mt}},B=[],nt=[];for(let O=0;O<ct;O++){const J=W+(ot-W)*O/(ct-1),V=J/Math.max(1e-6,r),at=bt(o,H,V,f.items),T=bt(h,H,V,f.items),L=((Math.atan2(T.position[0]-at.position[0],T.position[2]-at.position[2])*180/Math.PI-(at.rotation[1]||0))%360+540)%360-180;B.push(Math.round(J*1e3)/1e3),nt.push(kt(y,J)*N*L)}const q={id:p?.id??crypto.randomUUID(),scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{},track:{t:B,turn:nt},label:String(t.label??`${o.name} faces ${h.name}`)},C=_t(s,q,r),Q=C.find(O=>O.id===q.id);return Q?(g(C),{ok:!0,name:o.name,edit:pt(Q,e),edits:C.length,...d?{motion_block:{label:d.label,start_s:d.start,end_s:d.end}}:{},note:"the heading follows the target frame by frame (keys untouched); inspect_pose to check, then move_joint for contact"}):{ok:!1,error:`${o.name} already faces ${h.name} there`}}const b={};for(const[h,N]of Object.entries(t.joints||{})){if(!(h in zt)&&!/^(grip|index|thumb)[LR]$|^(headPitch|headRoll)$/.test(h))return{ok:!1,error:`unknown joint '${h}'; joints: ${Object.keys(zt).join(", ")}`};Number.isFinite(Number(N))&&(b[h]=Number(N))}const P=t.preset!=null?t.preset==="none"?null:{id:String(t.preset),amount:Number(t.preset_amount??.7),...t.preset_arms?{arms:!0}:{}}:p?.preset;if(P&&!Ct.some(h=>h.id===P.id))return{ok:!1,error:`unknown preset; use one of ${Ct.map(h=>h.id).join(", ")}`};const $=Array.isArray(t.move_m)?[Number(t.move_m[0])||0,0,Number(t.move_m[1])||0]:p?.move,j={...p||{},id:p?.id??crypto.randomUUID(),scope:n,start:u,end:i,fade:m,...k!=null?{fadeOut:k}:{},...Object.keys(b).length?{pose:{...t.id!=null?p?.pose:{},...b}}:{},...t.stance?{stance:{...p?.stance||{},...t.stance}}:{},preset:P??void 0,move:$,...t.turn_deg!=null?{turn:Number(t.turn_deg)}:{},...typeof t.off=="boolean"?{off:t.off}:{},label:String(t.label??p?.label??"Agent")},E=_t(s,j,r),R=E.find(h=>h.id===j.id);return R?(g(E),{ok:!0,name:o.name,edit:pt(R,e),edits:E.length,...d?{motion_block:{label:d.label,start_s:d.start,end_s:d.end}}:{},note:"a correction on top of the motion (keys untouched); render_preview / check_shot to see it; edit_motion with id to refine, remove to drop it"}):{ok:!1,error:"the edit changes nothing: give joints, stance, preset, move_m or turn_deg"}}const S=t=>Math.round(t*1e3)/1e3;function qt(t,a){return(t.clipSpans?.[a]||[]).flatMap(f=>{const c=re(f.clip),r=c?.strike;return!r||!c?.duration?[]:[{at:S(f.start+r.t*(f.end-f.start)/c.duration),limb:r.limb,zone:r.zone,cls:r.cls,clip:f.clip}]})}function Ht(t,a){if(t.some(e=>!e)||t.length<4)return null;const f=t,c=(e,g)=>e.map((p,n)=>(p-g[n])/a),r=f.slice(1).map((e,g)=>c(e,f[g])),o=r.slice(1).map((e,g)=>c(e,r[g])),s=o.slice(1).map((e,g)=>c(e,o[g]));return{speed:Bt(Math.max(...r.map(e=>Math.hypot(...e)))),jerk:Math.round(Math.max(0,...s.map(e=>Math.hypot(...e))))}}const et={surface:t=>({head:.1,chest:.13,hips:.14})[t]??.05,tip:t=>t.startsWith("hand")?.08:t.startsWith("foot")?.06:0};function Gt(t,a,f,c){const r=[a[0]-c[0],a[2]-c[2]];return{forward:S(r[0]*t.facing[0]+r[1]*t.facing[2]),up:S(a[1]-f),side:S(r[0]*t.side[0]+r[1]*t.side[2])}}function se(t){const a=t.joints,f=[];if(!a.footL||!a.footR||!a.hips||!a.chest||!a.head)return{facts:f,ground:0,base:[0,0,0]};const c=.045*t.height,r=Math.min(t.ground,Math.min(a.footL[1],a.footR[1])-c),o=[a.hips[0],r,a.hips[2]],s=t.height,e=m=>m>a.head[1]+.08*s?"above the head":m>a.head[1]-.08*s?"at head height":m>a.chest[1]-.07*s?"at chest height":m>a.hips[1]-.05*s?"at waist height":m>r+.3*s?"at thigh height":"low, near the knees / floor";for(const m of["R","L"]){const k=a[`hand${m}`];if(!k)continue;const b=Gt(t,k,r,o);f.push(`hand${m} ${e(k[1])}, ${b.forward>.15?`${S(b.forward)} m in front`:b.forward<-.15?`${S(-b.forward)} m behind`:"beside the body"}`)}const g=[a.chest[0]-a.hips[0],a.chest[1]-a.hips[1],a.chest[2]-a.hips[2]],p=g[0]*t.facing[0]+g[2]*t.facing[2],n=Math.round(Math.atan2(p,g[1])*180/Math.PI);f.push(Math.abs(n)<8?"torso upright":`torso leans ${n>0?"forward":"back"} ${Math.abs(n)}°`),f.push(`feet ${S(Math.hypot(a.footL[0]-a.footR[0],a.footL[2]-a.footR[2]))} m apart`);const d=Math.min(a.footL[1],a.footR[1])-c-t.ground;d>.08?f.push(`airborne: feet ${S(d)} m off the ground`):Math.abs(a.footL[1]-a.footR[1])>.12&&f.push(`one foot raised ${S(Math.abs(a.footL[1]-a.footR[1]))} m (${a.footL[1]>a.footR[1]?"footL":"footR"})`),f.push(`hips ${S(a.hips[1]-r)} m above the feet (standing ≈ ${S(.5*s)})`);const u=(m,k)=>{const b=m[0]*t.facing[0]+m[2]*t.facing[2],P=m[1],$=(m[0]*t.side[0]+m[2]*t.side[2])*(k==="L"?-1:1),j=[[b,"forward"],[-b,"back"],[P,"up"],[-P,"down"],[$,k?"out":"to its R side"],[-$,k?"in":"to its L side"]];return j.sort((E,R)=>R[0]-E[0]),j[1][0]>.45?`${j[0][1]}-${j[1][1]}`:j[0][1]};for(const m of["R","L"]){const k=t.axes[`hand${m}`],b=t.fingers[m];if(!k)continue;const P=Object.entries(wt).map(([$,j])=>[$,Math.abs(j.grip-b.grip)+Math.abs(j.index-b.index)+.5*Math.abs(j.thumb-b.thumb)]).sort(($,j)=>$[1]-j[1])[0][0];f.push(`hand${m} ${P}: fingers point ${u(k.main,m)}, palm faces ${u(k.second,m)}`)}for(const m of["R","L"]){const k=t.axes[`foot${m}`];k&&f.push(`foot${m} toes point ${u(k.main,m)}`)}const i=t.axes.head;if(i){const m=Math.round(Math.asin(Math.max(-1,Math.min(1,i.second[0]*t.side[0]+i.second[2]*t.side[2])))*180/Math.PI);f.push(`face looks ${u(i.main)}${Math.abs(m)>8?`, head tilted ${Math.abs(m)}° toward its ${m>0?"R":"L"} shoulder`:""}`)}return{facts:f,ground:r,base:o}}function ke(t,a){const f=a.getStage(),c=gt(f),r=a.engine();let o;try{o=tt(f,String(t.name??""))}catch(n){return{ok:!1,error:n.message}}if(o.kind!=="person")return{ok:!1,error:`'${o.name}' is not a person`};if(!r)return{ok:!1,error:"the 3D view is not ready"};r.sync(f,null);const s=(Array.isArray(t.times)?t.times:[t.at??0]).slice(0,6).map(n=>Math.max(0,Math.min(c.duration,Number(n)||0))),e=f.items.filter(n=>n.kind==="person"&&n.id!==o.id),g=s.map(n=>{const d=r.jointsAt(n,o.id);if(!d)return{at_s:n,error:"not built"};const{facts:u,ground:i,base:m}=se(d),k=Object.fromEntries(Object.entries(d.joints).map(([$,j])=>[$,Gt(d,j,i,m)])),b=[];for(const $ of e){const j=r.jointsAt(n,$.id);if(j)for(const E of["handR","handL","footR","footL"])for(const R of["head","chest","hips"]){const h=d.joints[E],N=R==="head"?j.headCentre:j.joints[R];if(!h||!N)continue;const y=Math.hypot(h[0]-N[0],h[1]-N[1],h[2]-N[2])-et.tip(E)-et.surface(R)*j.height/1.8;y<.45&&b.push({joint:E,other:$.name,part:R,gap_m:S(Math.max(0,y))})}}b.sort(($,j)=>$.gap_m-j.gap_m);const P=Object.fromEntries(ee.map($=>[$.id,d.joints[$.part]]).filter(([,$])=>!!$));return{at_s:n,facing:d.facing,controls:P,joints_world:d.joints,head_centre:d.headCentre,joints_local:k,axes:d.axes,fingers:d.fingers,reads:u,...b.length?{near_others:b.slice(0,6)}:{}}}),p=qt(c,o.id);return{ok:!0,name:o.name,...p.length?{strikes:p}:{},frames:g,note:"joints_world = world metres (move_joint to); joints_local = metres in the person's frame: forward, up above its feet, side (+ toward its …R limbs). head = a point in front of the face (head_centre = the skull, for contact). near_others gap_m = the gap between the surfaces (0 = touching). axes: hand {main = fingers, second = palm}, foot {main = toes}, head {main = face, second = top of the head}, world unit vectors; fingers = curls 0..100. Check again after a fix."}}function de(t,a){const f=a.getStage(),c=gt(f),r=a.engine();let o;try{o=tt(f,String(t.name??""))}catch(l){return{ok:!1,error:l.message}}if(o.kind!=="person")return{ok:!1,error:`'${o.name}' is not a person`};const s=t.control!=null?oe(t.control):null;if(t.control!=null&&!s)return{ok:!1,error:`control must be one of ${Tt.join(", ")}`};const e=s?.part??String(t.part??"");if(!Ft.includes(e))return{ok:!1,error:`give control (${Tt.join(", ")}) or part (${Ft.join(", ")})`};if(!r)return{ok:!1,error:"the 3D view is not ready"};r.sync(f,null);const g=qt(c,o.id),p=t.at==="impact"?g.find(l=>l.limb===e)??g[0]:null;if(t.at==="impact"&&!p)return{ok:!1,error:`${o.name} plays no strike clip here: give at in seconds`};const n=p?p.at:Math.max(0,Math.min(c.duration,Number(t.at??0)||0)),d=r.jointsAt(n,o.id),u=d?.joints[e];if(!d||!u)return{ok:!1,error:`no ${e} on ${o.name}`};let i=null;if(Array.isArray(t.to)&&t.to.length===3)i=t.to.map(Number);else if(t.offset_m&&typeof t.offset_m=="object"){const l=t.offset_m,_=Number(l.forward)||0,M=Number(l.up)||0,v=Number(l.side)||0;i=[u[0]+_*d.facing[0]+v*d.side[0],u[1]+M,u[2]+_*d.facing[2]+v*d.side[2]]}else if(t.to_object&&typeof t.to_object=="object"){const l=t.to_object;let _;try{_=tt(f,String(l.name??""))}catch(z){return{ok:!1,error:z.message}}const M=String(l.part??"chest"),v=_.kind==="person"?r.jointsAt(n,_.id):null;if(i=v?(M==="head"?v.headCentre:v.joints[M])??null:r.worldPositionOf(_.id),!i)return{ok:!1,error:`no ${M} on ${_.name}`};const I=v?et.surface(M)*v.height/1.8:0,A=I+et.tip(e);if(A>0){const z=d.joints.chest??u,w=[z[0]-i[0],z[1]-i[1],z[2]-i[2]],x=Math.hypot(...w);x>.001&&(i=[i[0]+w[0]/x*A,i[1]+w[1]/x*A,i[2]+w[2]/x*A])}}if(i&&i.some(l=>!Number.isFinite(l)))return{ok:!1,error:"to must be 3 finite numbers"};const m=e.slice(-1),k=e==="handL"||e==="handR",b=e==="footL"||e==="footR",P=(l,_)=>{if(l==null)return null;if(Array.isArray(l)&&l.length===3&&l.every(A=>Number.isFinite(Number(A))))return l.map(Number);const M=String(l),v=m==="L"?-1:1,I={forward:d.facing,back:[-d.facing[0],0,-d.facing[2]],up:[0,1,0],down:[0,-1,0],out:[d.side[0]*v,0,d.side[2]*v],in:[-d.side[0]*v,0,-d.side[2]*v]};if(M==="target"){if(!i)return`${_} 'target' needs to / to_object`;const A=[i[0]-u[0],i[1]-u[1],i[2]-u[2]];return Math.hypot(...A)>.001?A:null}return I[M]??`${_} must be forward / back / up / down / in / out / target or [x, y, z]`},$=P(k?t.fingers:b?t.toes:e==="head"?t.face:void 0,k?"fingers":b?"toes":"face"),j=P(k?t.palm:void 0,"palm");for(const l of[$,j])if(typeof l=="string")return{ok:!1,error:l};if(!k&&!b&&e!=="head"&&(t.fingers||t.palm||t.toes||t.face))return{ok:!1,error:"fingers / palm are for a hand, toes for a foot, face for the head"};const E=t.hand_shape!=null?String(t.hand_shape):null;if(E&&(!k||!(E in wt)))return{ok:!1,error:`hand_shape is for a hand: ${Object.keys(wt).join(", ")}`};const R=$||j?{...$?{main:$}:{},...j?{second:j}:{}}:void 0,h=(e==="footL"||e==="footR")&&Number.isFinite(Number(t.roll_deg))&&Number(t.roll_deg)!==0?Math.max(-45,Math.min(70,Number(t.roll_deg))):0;if(!i&&!R&&!E&&!h)return{ok:!1,error:"give a target (to [x, y, z], offset_m {forward, up, side}, to_object {name, part}), a direction (fingers / palm, toes, face) or hand_shape"};const N=["moment","span","after"].includes(String(t.scope))?String(t.scope):e==="hips"?"after":"moment",y=c.duration,W=!!(c.objectKeys?.[o.id]?.length||c.clipSpans?.[o.id]?.length),ot=!!i&&W&&N==="moment"&&t.path!==!1&&(k||b),ct=Number(t.fade??.6),Mt=Number(t.fade_out??.5),H=Math.max(0,n-ct-.25),B=Math.min(y,n+Mt+.25),nt=Math.max(4,Math.round((B-H)*24)+1),q=Array.from({length:nt},(l,_)=>H+(B-H)*_/(nt-1)),C=Ht(r.jointPath(o.id,e,q),(B-H)/(q.length-1));let Q=null,O=u,J=0;if(ot&&t.align!==!1){const l=(c.clipSpans?.[o.id]||[]).find(x=>n>=x.start-.001&&n<=x.end+.001),_=l?l.start:Math.max(0,n-.7),M=Math.max(_+.05,Math.min(n,_+Number(t.warp_s??.6))),v=["footL","footR"].filter(x=>x!==e),I=[_,(_+M)/2,M,n],A=x=>{const U=r.jointPath(o.id,x,I);return U.every(Boolean)?U.slice(1).reduce((st,Y,dt)=>st+Math.hypot(Y[0]-U[dt][0],Y[2]-U[dt][2]),0):1/0},z=v.sort((x,U)=>A(x)-A(U))[0],w=r.jointPath(o.id,z,[n])[0];if(w){const x=u[0]-w[0],U=u[2]-w[2],st=i[0]-w[0],Y=i[2]-w[2],dt=Math.hypot(x,U),mt=Math.hypot(st,Y);if(dt>.12&&mt>.12){const lt=Math.max(-120,Math.min(120,((Math.atan2(st,Y)-Math.atan2(x,U))*180/Math.PI+540)%360-180)),$t=mt-dt,xt=Number(t.step_max_m??.05),Z=Math.max(-xt,Math.min(xt,$t)),Qt=st/mt,Vt=Y/mt;if(Math.abs($t-Z)>.12&&(J=S($t-Z)),Math.abs(lt)>2||Math.abs(Z)>.02){const Nt={scope:"after",start:M,end:M,fade:Math.max(Jt.min,M-_)},Xt=Math.max(1/24,(y-_)/(Wt.samples-2)),Ot=[],Et=[],Lt=[],At=[],Yt={...c,motionEdits:{...c.motionEdits,[o.id]:c.motionEdits?.[o.id]||[]}};for(let D=_;D<=y+1e-6;D+=Xt){const K=kt(Nt,D),ht=K*lt*Math.PI/180,ut=bt(o,Yt,y?D/y:0,f.items).position,It=ut[0]-w[0],Dt=ut[2]-w[2];Ot.push(Math.round(D*1e3)/1e3),Et.push(K*lt),Lt.push(w[0]+It*Math.cos(ht)+Dt*Math.sin(ht)-ut[0]+K*Z*Qt),At.push(w[2]-It*Math.sin(ht)+Dt*Math.cos(ht)-ut[2]+K*Z*Vt)}const Zt=a.getStage().shots.find(D=>D.id===c.id)?.motionEdits?.[o.id]||[],Rt={id:crypto.randomUUID(),scope:"after",start:M,end:M,fade:Nt.fade,track:{t:Ot,turn:Et,mx:Lt,mz:At},label:`${e}: align the strike`},Pt=_t(Zt,Rt,y);Pt.some(D=>D.id===Rt.id)&&(a.setStage(D=>({...D,shots:D.shots.map(K=>K.id===c.id?{...K,motionEdits:{...K.motionEdits,[o.id]:Pt}}:K)})),Q={turn_deg:Math.round(lt),step_m:S(Z),pivot:z},r.sync(a.getStage(),null),O=r.jointsAt(n,o.id)?.joints[e]??u)}}}}let V=0;if(ot&&t.level!==!1&&i&&O[1]-i[1]>.04){const l=(d?.height??1.8)/1.8,_=Math.min(.45,(O[1]-i[1])/(.45*l)),M=Number(t.fade??.5);Kt({name:o.name,at:n,scope:"moment",fade:M,fade_out:Math.max(.35,M*.8),stance:{crouch:Math.round(_*100)/100},label:`${e}: drop the level`},a).ok&&(V=Math.round(_*100)/100,r.sync(a.getStage(),null),O=r.jointsAt(n,o.id)?.joints[e]??O)}const at=i?Math.hypot(i[0]-O[0],i[1]-O[1],i[2]-O[2]):0,T=Number(t.fade??Math.min(.7,.45+.4*at)),it=Number(t.fade_out??Math.max(.35,T*.8)),L=h&&!i?(()=>{const l=r.rollFootAt(n,o.id,e,h,_=>({id:"__drag",scope:"moment",start:n,end:n,fade:T,..._}));return l?{fields:l.fields,miss:l.pivotMove,from:u,aimError:null}:null})():i||R?r.solveJointAt(n,o.id,e,i,l=>({id:"__drag",scope:"moment",start:n,end:n,fade:T,...l}),R,{lockFeet:t.lock_feet===!0}):{fields:{},miss:0,from:u,aimError:null};if(!L)return{ok:!1,error:`could not pose ${o.name} at ${n} s`};const G=L.fields,yt=E?ne(bt(o,c,c.duration?n/c.duration:0,f.items).pose,m,E)??{}:{},vt={...G.pose||{},...yt},St=[i?`→ ${i.map(l=>S(l)).join(", ")}`:"",R?"turned":"",E??""].filter(Boolean).join(" "),jt=!!i&&W&&N==="moment"&&t.path!==!1&&!["hips","head"].includes(e);let rt;if(jt){const l=Object.fromEntries(Object.entries(G.pose||{}).filter(([w])=>/^(wrist|ankle)/.test(w))),_={scope:"moment",start:n,end:n,fade:T,fadeOut:it},M=r.bakeJointPath(n,o.id,e,i,w=>kt(_,w),[n-T,n+it],{...l,...yt});if(!M)return{ok:!1,error:`could not pose ${o.name} along its path`};const v=a.getStage().shots.find(w=>w.id===c.id)?.motionEdits?.[o.id]||[],I={id:crypto.randomUUID(),scope:"moment",start:n,end:n,fade:T,fadeOut:it,track:M.track,label:String(t.label??`${e} ${St} (path)`)},A=_t(v,I,y),z=A.find(w=>w.id===I.id);if(!z)return{ok:!1,error:"the move changes nothing"};a.setStage(w=>({...w,shots:w.shots.map(x=>x.id===c.id?{...x,motionEdits:{...x.motionEdits,[o.id]:A}}:x)})),L.miss=M.miss,rt={ok:!0,name:o.name,edit:pt(z,n),edits:A.length,note:"carried along the motion's own path (keys untouched); edit_motion remove to drop it"}}else rt=Kt({name:o.name,at:n,scope:N,fade:T,fade_out:it,...t.start!=null?{start:t.start}:{},...t.end!=null?{end:t.end}:{},...Object.keys(vt).length?{joints:vt}:{},...G.move?{move_m:[G.move[0],G.move[2]]}:{},...G.stance?{stance:G.stance}:{},label:String(t.label??`${e} ${St}`)},a);if(!rt.ok)return rt;r.sync(a.getStage(),null);const X=Ht(r.jointPath(o.id,e,q),(B-H)/(q.length-1));let F="";if(i&&L.miss>.04){const l=d.joints.hips??u,_=i[0]-l[0],M=i[2]-l[2],v=Math.hypot(_,M),I=v>.05?Math.round(Math.atan2(_*d.facing[2]-M*d.facing[0],_*d.facing[0]+M*d.facing[2])*180/Math.PI):0;F=`${e} stays ${L.miss} m short (out of reach or at a joint limit)`+(Math.abs(I)>50?`: ${o.name} faces ${Math.abs(I)}° away from the target — turn first (${W?"edit_motion face_toward the target, scope span":`edit_motion turn_deg ${I}, scope span`}), then move_joint again`:`: the target is ${S(v)} m from the hips — step closer: edit_motion move_m [${S(_/v*(L.miss+.03))}, ${S(M/v*(L.miss+.03))}] (scope span), then move_joint again; or pick another time`)}J&&(F+=`${F?"; ":""}the fighters stand ${Math.abs(J)} m too ${J>0?"far apart":"close"} for this blow as the clip throws it: re-block their marks (stand_at / set_transform before the motion) rather than stretching the limb`),L.aimError!=null&&L.aimError>12&&(F+=`${F?"; ":""}${k?"the hand":b?"the foot":"the face"} points ${L.aimError}° off the asked direction (the wrist / ankle / neck limit) — turn the forearm (move_joint elbow) or the body first`);const ft=C&&X?{peak_speed_m_s:[C.speed,X.speed],peak_jerk:[C.jerk,X.jerk],jerk_change_pct:Math.round((X.jerk-C.jerk)/Math.max(1,C.jerk)*100)}:null;return ft&&X.jerk>C.jerk*1.5&&X.jerk>800&&(F+=`${F?"; ":""}the fix makes ${e} ${ft.jerk_change_pct}% jerkier — ${jt?"lengthen fade / fade_out":"try path mode (a moving person, scope moment) or lengthen fade / fade_out"}, face_toward first so less is corrected, or fix the motion itself`),{...rt,part:e,...Ut(e)?{control:Ut(e).id}:{},from:L.from,...i?{to:i.map(S),miss_m:L.miss}:{},...L.aimError!=null?{aim_error_deg:L.aimError}:{},...jt?{mode:"path"}:{},...Q?{aligned:Q}:{},...V?{lowered_crouch:V}:{},...ft?{smoothness:ft}:{},...F?{warning:F}:{}}}function _e(t,a){const f=t.engine();if(!f)return null;const c=a.filter(s=>(s.planned==="head"||s.planned==="body")&&s.limb&&/^(hand|foot)[LR]$/.test(s.limb)).sort((s,e)=>s.time-e.time),r=s=>{f.sync(t.getStage(),null);const e=t.getStage(),g=e.items.find(m=>m.name===s.attacker),p=e.items.find(m=>m.name===s.target),n=g&&f.jointsAt(s.time,g.id),d=p&&f.jointsAt(s.time,p.id),u=n?.joints[s.limb],i=s.planned==="head"?d?.headCentre:d?.joints.chest;return!u||!i||!d?null:S(Math.hypot(u[0]-i[0],u[1]-i[1],u[2]-i[2])-et.tip(s.limb)-et.surface(s.planned==="head"?"head":"chest")*d.height/1.8)},o=[];for(const s of c){const e=r(s);let g=e;for(let p=0;p<2&&g!=null&&Math.abs(g)>.015;p++){const n=a.filter(b=>b.attacker===s.attacker&&b!==s).map(b=>b.time),d=Math.max(-1/0,...n.filter(b=>b<s.time)),u=Math.min(1/0,...n.filter(b=>b>s.time)),i=Math.max(.15,Math.min(.45,.8*(s.time-d))),m=Math.max(.15,Math.min(.4,.8*(u-s.time)));if(!de({name:s.attacker,part:s.limb,at:s.time,to_object:{name:s.target,part:s.planned==="head"?"head":"chest"},align:!1,level:!1,fade:i,fade_out:m,label:"land the blow"},t).ok)break;g=r(s)}o.push({time_s:S(s.time),attacker:s.attacker,limb:s.limb,zone:s.planned,gap_before_m:e,gap_after_m:g})}return o}function ge(t,a){const f=a.getStage(),c=gt(f);let r;try{r=tt(f,String(t.name??""))}catch(n){return{ok:!1,error:n.message}}if(r.kind!=="person")return{ok:!1,error:`'${r.name}' is not a person`};const o=Math.max(0,Math.min(c.duration,Number(t.at)||0)),s=c.duration?o/c.duration:0,e=t.breakdown_bias==null?null:Math.max(0,Math.min(1,Number(t.breakdown_bias))),g=e==null?ae(c,r,s):ie(c,r,s,e);if(!g)return{ok:!1,error:`no pose keys on both sides of ${o} s for a breakdown — set keys first (pose_key / set_pose)`};a.setStage(n=>({...n,shots:n.shots.map(d=>d.id===c.id?g:d)}));const p=g.objectKeys?.[r.id]||[];return{ok:!0,name:r.name,at_s:o,kind:e==null?"key":"breakdown",...e!=null?{bias:e}:{},keys_s:p.filter(n=>n.pose).map(n=>S(n.time*c.duration)).slice(0,40)}}export{Kt as editMotion,ke as inspectPose,_e as landBlows,de as moveJoint,ge as poseKey,qt as strikesOf};
@@ -1 +0,0 @@
1
- import{bS as $,bT as C}from"./api-C5pOWyBM.js";import{hG as T,hH as q,lE as O,lF as _,lG as G,ai as D,lv as N}from"./titleFrameBudget-BjW--v_T.js";const E=Object.freeze({fisheye:.45,dispersion:.018,burst:.5,streak:.32,taps:8}),H=t=>[1+2.2*t,.88+1.8*t,.55+.9*t].map(n=>+n.toFixed(4));function v(t,n,o){const e=Math.max(t,Math.trunc(t*o/2)*2),r=Math.max(n,Math.trunc(n*o/2)*2);return{sw:e,sh:r,ox:Math.trunc((e-t)/2),oy:Math.trunc((r-n)/2)}}const W=(t,n)=>({w:Math.max(2,Math.trunc(t/4)*2),h:Math.max(2,Math.trunc(n/4)*2)}),j=(t,n=E.taps)=>Array.from({length:n},(o,e)=>1+t*e/(n-1));function K(t){const n=+(E.fisheye*t).toFixed(4);let o=1+n;for(let e=0;e<20;e++)o-=(o*o*o-o*o-n)/(3*o*o-2*o);return{K:n,m:+o.toFixed(4)}}function b(t,n,o,e,r,a){const d=Math.max(0,Math.min(n-1.001,e)),l=Math.max(0,Math.min(o-1.001,r)),f=d|0,m=l|0,i=d-f,u=l-m,h=(m*n+f)*4+a,c=h+4,s=h+n*4,x=s+4;return(t[h]*(1-i)+t[c]*i)*(1-u)+(t[s]*(1-i)+t[x]*i)*u}const z=(t,n,o,e,r)=>[(e+t.ox+.5)*n/t.sw-.5,(r+t.oy+.5)*o/t.sh-.5];function X(t,n,o,e){const r=j(e).map(l=>v(n,o,l)),a=new Uint8ClampedArray(t.length),d=r.length;for(let l=0;l<o;l++)for(let f=0;f<n;f++){const m=(l*n+f)*4,i=[0,0,0,0];for(const u of r){const[h,c]=z(u,n,o,f,l);for(let s=0;s<4;s++)i[s]+=b(t,n,o,h,c,s)}for(let u=0;u<4;u++)a[m+u]=Math.round(i[u]/d)}return a}function tt(t,n,o,e,r){if(!(n>.001))return!1;const a=new Uint8ClampedArray(o);if(t==="fisheye"){const{K:d,m:l}=K(n),f=v(e,r,l),m=e/2,i=r/2,u=4/(e*e+r*r),h=new Uint8ClampedArray(a.length);for(let c=0;c<r;c++)for(let s=0;s<e;s++){const x=s-m,M=c-i,L=1+d*(x*x+M*M)*u,y=(c*e+s)*4,A=m+x*L+.5,F=i+M*L+.5;if(A>=0&&F>=0&&A<=e-1&&F<=r-1)for(let g=0;g<4;g++)h[y+g]=b(a,e,r,A,F,g)}for(let c=0;c<r;c++)for(let s=0;s<e;s++){const[x,M]=z(f,e,r,s,c),L=(c*e+s)*4;for(let y=0;y<4;y++)o[L+y]=b(h,e,r,x,M,y)}return!0}if(t==="dispersion"){const d=E.dispersion*n,l=v(e,r,1+2*d),f=v(e,r,1+d);for(let m=0;m<r;m++)for(let i=0;i<e;i++){const u=(m*e+i)*4,[h,c]=z(l,e,r,i,m),[s,x]=z(f,e,r,i,m);o[u]=b(a,e,r,h,c,0),o[u+1]=b(a,e,r,s,x,1)}return!0}return t==="zoom-streak"?(o.set(X(a,e,r,E.streak*n)),!0):!1}const w=new Map,k=new Map,P=new Map,S=new Set;async function et(t){if(t.size>4e7)throw Error("File LUT tối đa 40 MB");const n=T(q(await t.text())),o=(n.title||t.name.replace(/\.cube$/i,"")).slice(0,80),e=await $({name:o,...O(n)});return w.set(e.id,n),S.forEach(r=>r()),e}function Y(t){if(w.has(t))return Promise.resolve(w.get(t));let n=k.get(t);return n||(n=C(t).then(o=>{const e=_(o);return w.set(t,e),S.forEach(r=>r()),e}).finally(()=>k.delete(t)),k.set(t,n)),n}function I(t){const n=w.get(t.id);if(!n)return Y(t.id).catch(()=>{}),null;const o=`${t.id}:${t.mix??1}`;let e=P.get(o);return e||(e=G(n,t.mix??1),P.set(o,e)),e}const p=new Map;function nt(t){if(!t)return null;const n=t.lut?I(t.lut):null;if(t.lut&&!n)return null;if(!D(t.mixer))return n;const o=`${t.lut?`${t.lut.id}:${t.lut.mix??1}`:"-"}|${JSON.stringify(t.mixer)}`;let e=p.get(o);return e||(e=N(t.mixer,n),p.set(o,e),p.size>24&&p.delete(p.keys().next().value)),e}const U=Object.freeze({codec:"h264",quality:"recommended",container:"mp4"}),B={h264:{low:4,recommended:8,high:16},hevc:{low:2.5,recommended:5,high:10}};function J(t,{width:n,height:o,fps:e}){const r=t??U,a=n*o/(1920*1080)*(e/30);return Math.round(B[r.codec][r.quality]*1e6*Math.max(.2,a))}const ot=(t,n,o)=>Math.round((J(t,n)+16e4)*Math.max(0,o)/8),Q={low:.5,recommended:1,high:2};function rt(t,{width:n,height:o,fps:e},r){const a=t??U;return Math.round(Math.min(4e7,Math.max(5e5,r(n,o,e)*Q[a.quality]*(a.codec==="hevc"?B.hevc.recommended/B.h264.recommended:1))))}export{U as D,E as L,tt as a,H as b,W as c,v as d,ot as e,Y as f,nt as g,rt as h,et as i,I as l,j as z};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GLTFExporter-BuGYM-Ik.js","assets/three.module-Bx43vjkH.js"])))=>i.map(i=>d[i]);
2
- import{_ as T}from"./titleFrameBudget-BjW--v_T.js";import{e5 as x}from"./remote-DXG553d8.js";import{Mesh as g,Color as D,CanvasTexture as y,SRGBColorSpace as M,NoColorSpace as _}from"./three.module-Bx43vjkH.js";import"./api-C5pOWyBM.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";async function d(e,n=15e3){const i=performance.now();for(;!(e.image&&(e.image.complete??!0)&&(e.image.naturalWidth??e.image.width??0)>0);){if(performance.now()-i>n)return null;await new Promise(a=>setTimeout(a,50))}return e.image}function b(e){const n=e.naturalWidth||e.width,i=e.naturalHeight||e.height,a=document.createElement("canvas");a.width=n,a.height=i;const r=a.getContext("2d",{willReadFrequently:!0});return r.drawImage(e,0,0),{c:a,g:r,data:r.getImageData(0,0,n,i),w:n,h:i}}const f=e=>e<=.04045?e/12.92:((e+.055)/1.055)**2.4,w=(e,n,i)=>{const a=Math.min(1,Math.max(0,(i-e)/(n-e)));return a*a*(3-2*a)};function S(e,n){const{c:i,g:a,data:r}=b(e),u=new D(n),t=r.data;for(let s=0;s<t.length;s+=4){const c=f(t[s]/255)-u.r,l=f(t[s+1]/255)-u.g,o=f(t[s+2]/255)-u.b;Math.hypot(c,l,o)<.09&&(t[s+3]=0)}a.putImageData(r,0,0);const p=new y(i);return p.colorSpace=M,p.flipY=!0,p}function k(e){const{c:n,g:i,data:a}=b(e),r=a.data;for(let t=0;t<r.length;t+=4){const p=f(r[t]/255),s=f(r[t+1]/255),c=f(r[t+2]/255),l=.2126*p+.7152*s+.0722*c,o=Math.max(p,s,c),h=Math.min(p,s,c),m=w(.12,.32,l)*(1-w(.55,.85,o>0?(o-h)/o:0));r[t]=255,r[t+1]=Math.round((.07+(.62-.07)*m)*255),r[t+2]=0,r[t+3]=255}i.putImageData(a,0,0);const u=new y(n);return u.colorSpace=_,u.flipY=!0,u}async function B(e){const n=x(e),i=new Map,a=[];n.traverse(t=>{t instanceof g&&a.push(t)});for(const t of a){const p=Array.isArray(t.material)?t.material:[t.material],s=[];for(const c of p){let l=i.get(c);if(!l){l=c;const o=c;if(o.map&&(o.userData.keyout||o.userData.autoFinish)){const h=await d(o.map);if(h){const m=o.clone();m.onBeforeCompile=()=>{},o.userData.keyout&&(m.map=S(h,o.userData.keyout),m.alphaTest=.5,m.transparent=!1),o.userData.autoFinish&&(m.roughness=1,m.roughnessMap=k(h),m.clearcoat=.25),l=m}}else o.map&&await d(o.map);i.set(c,l)}s.push(l)}t.material=Array.isArray(t.material)?s:s[0]}const{GLTFExporter:r}=await T(async()=>{const{GLTFExporter:t}=await import("./GLTFExporter-BuGYM-Ik.js");return{GLTFExporter:t}},__vite__mapDeps([0,1])),u=await new r().parseAsync(n,{binary:!0,maxTextureSize:4096});return n.traverse(t=>{t instanceof g&&t.geometry.dispose()}),new Blob([u],{type:"model/gltf-binary"})}export{B as recipeGlb};
@@ -1 +0,0 @@
1
- import{nh as I,_ as N}from"./titleFrameBudget-BjW--v_T.js";import{a3 as B}from"./main-BNZrzSIG.js";import{t as S}from"./api-C5pOWyBM.js";import"./remote-DXG553d8.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";import"./spark.module-CMSPLU2n.js";import"./userFonts-txN4I-eo.js";import"./lottieLayer-BhLbZOpr.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-DqXTKdEK.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-pFxeatJt.js";import"./captionLayout-BAdmqwdS.js";import"./timelineText-DEK2BRyU.js";import"./titleArt-CAOxtyHl.js";import"./rotoMatte-2EcyuvBX.js";import"./distortGL-5uNfls9s.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 Tt=()=>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 Rt(n){try{return await lt(n)}catch(i){if(i.name==="AbortError")throw i;return at(n)}}export{Tt as faceMeshEdges,ot as faceSample,et as pickFace,V as smoothFaces,at as trackFace,lt as trackFace3D,Rt as trackFaceBest};
@@ -1 +0,0 @@
1
- import{fL as Y,gS as Z,jb as tt,jc as P,jd as et,je as T,jf as U,jg as ot,jh as st,ji as nt,dL as it,iE as at,hJ as rt,jj as ct,jk as mt}from"./remote-DXG553d8.js";import{ad as H}from"./rigTrack-CW9_kg5j.js";import"./api-C5pOWyBM.js";import"./titleFrameBudget-BjW--v_T.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";const ft=()=>crypto.randomUUID(),J=R=>Math.round(R*1e3)/1e3;function bt(R,l){const K=Y(R,{fighters:l.fighters,start:l.start,end:l.end,focal_length_mm:l.focal_length_mm}),u=K.stage,k=Z(u),c=k.duration,[h,g]=l.fighters.map(t=>u.items.find(e=>e.name===t)),{start:A,end:M}=K.result,b=tt(l.beats,A,M),_=t=>{const e=it(k,Math.max(0,Math.min(1,t/c)));return{position:[...e.position],target:[...e.target],lens:e.lens}},x=(t,e)=>{const m=at(u,t,e);return{key:{pose:m.pose,position:m.position,yaw:m.rotation[1]},scale:rt(m)}},N=(t,e)=>{const m=t.attacker===h.name?h:g,j=m===h?g:h,f=x(m,e),s=x(j,e),w=t.limb&&/^(hand|foot)[LR]$/.test(t.limb)?t.limb:"handR",n=ct(f.key,w,f.scale),i=mt(s.key,s.scale),d=i.head.a.map((O,V)=>O+(i.head.b[V]-O)*.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,p=[a/o,0,r/o],y=[p[2],0,-p[0]],C=_(e).position,F=(f.key.position[0]+s.key.position[0])/2,G=(f.key.position[2]+s.key.position[2])/2,B=(C[0]-F)*y[0]+(C[2]-G)*y[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:w.startsWith("foot"),atk:f.key.position,def:s.key.position,defHead:d,defFace:Q,axis:p,side:[y[0]*B,0,y[2]*B],sep:o}},I=(t,e)=>({id:ft(),time:t/c,position:e.position.map(J),target:e.target.map(J),lens:Math.round(e.lens*100)/100,roll:0}),L=t=>t.time*c>=A-1e-6&&t.time*c<=M+1e-6,W=(k.cameraKeys||[]).filter(L),X=(k.cameraKeys||[]).filter(t=>!L(t)),z=[];for(const t of b){const e=t.to-.001;if(t.kind==="wide"||!t.beat){z.push(I(t.from,_(t.from)),...W.filter(n=>n.time*c>t.from+1e-6&&n.time*c<e-1e-6),I(e,_(e)));continue}const m=t.kind==="insert"?t.beat.time:Math.min(e,t.beat.time+(t.kind==="reaction"?.15:.6)),j=[];for(let n=t.from;n<=e+1e-6;n+=1/30)for(const i of[h,g]){const d=x(i,n),a=H(d.key.pose,d.key.position,d.key.yaw,d.scale);j.push(...Object.values(a))}const f=N(t.beat,m);let s=P(t.kind,f);if(t.kind==="insert"){const n=[];for(const d of[-2/30,0,2/30])for(const a of[h,g]){const r=x(a,m+d),o=H(r.key.pose,r.key.position,r.key.yaw,r.scale);n.push(...Object.values(o));for(const[p,y]of[["headA","headB"],["torsoA","torsoB"]])o[p]&&o[y]&&n.push(o[p].map((C,F)=>(C+o[y][F])/2))}let i=null;for(const d of et){const a=T(P("insert",f,{...U,insertAxis:d}),j),r=a.near??1/0,o=r>=U.clearance-1e-6,p=ot(a.position,a.target,n);(!i||o&&!i.ok||o===i.ok&&(o?p<i.n:r>i.near))&&(i={ok:o,n:p,near:r,cam:a})}s=i.cam}const w=t.kind==="insert"?s:T(s,j);z.push(I(t.from,w),I(e,w))}const S=[...X,...z].sort((t,e)=>t.time-e.time),D=S[0],E=S[S.length-1],$=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]})),q=(k.cuts||[]).filter(t=>t.to*c<=A+1e-6||t.from*c>=M-1e-6),v={...k,cameraKeys:S,position:D.position,target:D.target,lens:D.lens,endPosition:E.position,endTarget:E.target,endLens:E.lens,cuts:[...q,...$].sort((t,e)=>t.from-e.from)};return{stage:{...u,items:nt(u.items,v),shots:u.shots.map(t=>t.id===k.id?v:t)},result:{ok:!0,fighters:[h.name,g.name],start:A,end:M,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{bt as fightDirector};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editTools-CUoVvupD.js","assets/remote-DXG553d8.js","assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-Dxq3MZF3.js","assets/rotoMaskStore-DrRawyH9.js","assets/rigTrack-CW9_kg5j.js"])))=>i.map(i=>d[i]);
2
- import{_ as z}from"./titleFrameBudget-BjW--v_T.js";import{gS as E,i_ as V,i$ as at,hK as L,j0 as it,j1 as ot,hN as rt,fy as st,fI as B,fJ as J,fK as U,fL as ht,dM as ct,j2 as Y,hJ as dt,j3 as lt,j4 as mt}from"./remote-DXG553d8.js";import{c as ut}from"./cameraPresets-CeStHDvF.js";import"./api-C5pOWyBM.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-Dxq3MZF3.js";import"./rotoMaskStore-DrRawyH9.js";import"./rigTrack-CW9_kg5j.js";const C=()=>crypto.randomUUID(),M=o=>Math.round(o*100)/100,ft=o=>(o.kind==="model"?(o.model?.height??2)/1.8:dt(o))*(o.scale[1]||1),Z={none:{hit:"va-cham-anime",heavy:"va-cham-huyet",aura:"",dash:"",burst:"vong-xung-kich"},lightning:{hit:"va-cham-dien",heavy:"hoa-loi-xanh",aura:"hao-quang-lam",dash:"luot-chem-loi",burst:"vong-xung-kich"},fire:{hit:"va-cham-anime",heavy:"va-cham-huyet",aura:"hao-quang-do",dash:"cot-lua-hoat-hinh",burst:"vong-xung-kich"},dark:{hit:"va-cham-huyet",heavy:"vong-xung-kich-tim",aura:"hao-quang-tim",dash:"luot-chem-loi",burst:"vong-xung-kich-tim"}};function gt(o,g){const k=(Array.isArray(o)?o:[]).slice(0,5).map(A=>{const u=A||{};return{seconds:Math.max(1.5,Math.min(20,Number(u.seconds)||2.5)),tempo:Math.max(0,Math.min(1,Number(u.tempo??.8))),ending:["none","launch","knockdown","throw"].includes(String(u.ending))?String(u.ending):"none",...u.blocks!=null?{blocks:Number(u.blocks)}:{},...u.kicks!=null?{kicks:Number(u.kicks)}:{},...u.evades!=null?{evades:Number(u.evades)}:{},...u.air?{air:!0,height:Math.max(1.5,Math.min(12,Number(u.height)||3))}:{}}});return k.length?(k[k.length-1].ending==="launch"&&k.push({seconds:2.5,tempo:1,ending:"knockdown"}),k):[{seconds:g*.42,tempo:.75,ending:"launch"},{seconds:g*.58,tempo:1,ending:"knockdown"}]}async function Nt(o,g,k,A,u,tt){const G=g.getStage(),et=E(G),S=et.duration,I=gt(o.rounds,u-A),T=(t,n,s)=>{const r=E(n),e=ct(n.items.find(a=>a.id===t.id),{...r,flight:void 0},Math.min(1,s/r.duration));return{id:t.id,name:t.name,position:[...e.position],yaw:e.rotation[1],scale:ft(t),pose:e.pose}},K=(t,n)=>({time:t.time-n,pose:t.pose,position:t.position,yaw:t.yaw,...t.plant?{plant:t.plant}:{},...t.air?{air:!0}:{},...t.pitch!=null?{pitch:t.pitch}:{},...t.strike?{strike:t.strike}:{},...t.hit?{hit:t.hit}:{}});let h=G,N=A,_=[k[0],k[1]],O;const l=[],$=[],D=[];for(let t=0;t<I.length;t++){const n=I[t],s=t===I.length-1,r=n.ending==="throw",e=s?u:Math.min(u-2,N+n.seconds+(n.ending==="launch"?1.2:r?1.6:0)),a=r?e-(s?2.2:1.6):e;if(a-N<1.5){D.push(`round ${t+1} skipped: no time left (extend the shot)`);break}const b=!!n.air,v=b?N+.8:N,w=b?a-.8:a;if(b){const i=E(h);for(const c of _){const d=T(c,h,N).position[1];let m=V(i.flight?.[c.id],{time:N/S,on:!0,height:n.height??3,ground:d});m=V(m,{time:Math.min(1,e/S),on:!1}),h={...h,shots:h.shots.map(f=>f.id===i.id?{...f,flight:{...f.flight,[c.id]:m}}:f)}}}const R=(i,c)=>{const d=E(h),m=d.flight?.[i];if(!m?.length)return null;const f=lt(m,c/d.duration,d.duration);return f.air>0?{pose:x=>mt(x,f,c),lift:f.altitude}:null},F=_.map(i=>({...T(i,h,v),...b?{airborne:!0}:{}})),y=at(F.map(({pose:i,...c})=>c),v,w,{style:tt,seed:(Number(o.seed)||7)+t*101,intensity:Math.max(0,Math.min(1,Number(o.intensity??.85))),finisher:r?"none":s?n.ending==="none"?o.finisher==="knockdown"?"knockdown":"none":n.ending:n.ending==="launch"?"launch":"none",kicks:n.kicks??Number(o.kicks??0),evades:n.evades??Number(o.evades??0),blocks:n.blocks??Number(o.blocks??.2),tempo:n.tempo,clipKeys:i=>Y(i),...O!=null?{openAt:O}:{},airOf:R,debug:o.debug===!0});if(!y.beats.length){D.push(`round ${t+1}: ${y.notes.join("; ")||"no exchange planned"}`);break}for(const i of _)h=L(h,i.id,(y.tracks[i.id]||[]).map(c=>K(c,v)),v/S,C,{replace:"span"}).stage;l.push(...y.beats.map(i=>({...i,round:t+1}))),D.push(...y.notes.map(i=>`round ${t+1}: ${i}`));let p=y.beats[y.beats.length-1];if(r){const i=_.find(f=>f.name===p.attacker)??_[0],c=_.find(f=>f.id!==i.id),d=Math.max(p.time+.35,a-.1),m=it({atk:T(i,h,d),def:T(c,h,d),start:d});h=L(h,i.id,m.atk.map(f=>K(f,d)),d/S,C,{replace:"span"}).stage,h=L(h,c.id,m.def.map(f=>K(f,d)),d/S,C,{replace:"span"}).stage,p={...p,time:m.slam,attacker:i.name,target:c.name,clip:"throw",limb:"footR",zone:"body",planned:"body",cls:"throw"},l.push({...p,round:t+1})}const X=n.ending==="launch"&&p.planned!=="miss"&&p.planned!=="blocked";let q=e;if(b&&X){q=Math.min(e,p.time+1.3);const i=E(h);for(const c of _){const d=(i.flight?.[c.id]||[]).filter(m=>m.time<=p.time/S+1e-6);h={...h,shots:h.shots.map(m=>m.id===i.id?{...m,flight:{...m.flight,[c.id]:V(d,{time:Math.min(1,(q+(c.name===p.target?0:.25))/S),on:!1})}}:m)}}}if((X||r)&&!s){const i=_.find(j=>j.name===p.target),c=_.find(j=>j.id!==i.id),d=Math.max(p.time+(r?.75:1.05),b?q+.1:0),m=T(i,h,d),f=T(c,h,d+2),x=ot({charger:m,target:f,start:d,hold:Math.max(.4,Math.min(1.4,Number(o.charge_hold??.75))),clipKeys:j=>Y(j)});h=L(h,i.id,x.keys.map(j=>K(j,d)),d/S,C,{replace:"span"}).stage,$.push({launch:p.time,landed:p.time+(r?0:.55),charge:x.chargeAt,dash:x.dashAt,arrive:x.arrive,who:i.name}),_=[i,c],N=x.arrive,O=x.arrive}else N=e,O=void 0}if(!l.length)return{ok:!1,error:`no fight could be planned (${D.join("; ")||"too short"})`};const Q=rt(h);h=Q.stage,g.setStage(()=>h);const W=o.land!==!1?(await z(async()=>{const{landBlows:t}=await import("./editTools-CUoVvupD.js");return{landBlows:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8]))).landBlows(g,l):null;if(o.timing!==!1){const t=E(g.getStage()),n=l[l.length-1];let s=st(t.timing,t.duration);const r=[...$.map(e=>e.launch),n.time];s=B(s,l.filter(e=>e.planned!=="blocked"&&!r.includes(e.time)).map(e=>e.time),J.light,t.duration),s=B(s,l.filter(e=>e.planned==="blocked").map(e=>e.time),J.light*.7,t.duration),s=B(s,r,J.heavy,t.duration);for(const e of $)s=U(s,e.launch+.12,.3,.35,t.duration),s=U(s,e.arrive+.1,.18,.5,t.duration);o.finisher!=="none"&&(s=U(s,n.time+.05,.25,.35,t.duration)),g.setStage(e=>({...e,shots:e.shots.map(a=>a.id===t.id?{...a,timing:s??void 0}:a)}))}const H=[];if(o.vfx===!0){const{runTool:t}=await z(async()=>{const{runTool:e}=await import("./remote-DXG553d8.js").then(a=>a.jH);return{runTool:e}},__vite__mapDeps([1,2,3,4,5,6,7,8])),n=Z[String(o.element??"none")]??Z.none,s=l[l.length-1].time,r=async e=>{(await t("add_effect",e,g)).ok&&H.push(String(e.effect))};for(const e of l){if(e.planned==="miss")continue;const a=e.time===s||$.some(b=>b.launch===e.time);await r({effect:e.planned==="blocked"?n.burst:a?n.heavy:n.hit,attach_to:e.target,start:e.time,duration:a?.4:.26,intensity:a?.32:.26})}for(const e of $)await r({effect:"bui-hoat-hinh",attach_to:e.who,start:e.landed,duration:.7,intensity:.4,params:{power:.6,puffs:8,tint:.9}}),await r({effect:"mat-dat-vo",attach_to:e.who,start:e.charge,duration:1.2,intensity:.45}),n.aura&&await r({effect:n.aura,attach_to:e.who,start:e.charge,duration:e.dash-e.charge+.3,intensity:.6}),n.dash&&await r({effect:n.dash,attach_to:e.who,start:e.dash,duration:.45,intensity:.7}),await r({effect:"xung-kich",attach_to:e.who,start:e.arrive,duration:.5,intensity:.3});o.finisher!=="none"&&String(o.element)==="lightning"&&await r({effect:"loi-kiep",from:`${l[l.length-1].attacker}.hand_right`,to:`${l[l.length-1].target}.chest`,start:s-.05,duration:.45,intensity:.4})}let P=null;if(o.director_camera===!0){const t=l[l.length-1],n=[],s=(a,b)=>{const v=new Map;for(const w of l)w.time>=a&&w.time<=b&&v.set(w.attacker,(v.get(w.attacker)??0)+1);return[...v.entries()].sort((w,R)=>R[1]-w[1])[0]?.[0]??k[0].name};let r=A;for(const a of $)n.push(["punch-beats",s(r,a.launch),r,a.launch+.12],["side-track",a.who,a.launch+.12,a.charge],["low-hero",a.who,a.charge,a.arrive]),r=a.arrive;t.time-.5-r>.4&&n.push(["punch-beats",s(r,t.time),r,t.time-.5]),n.push(["orbit-180",t.attacker,Math.max(r,t.time-.5),u]);const e=[];for(const[a,b,v,w]of n){if(w-v<.25)continue;const R=k.find(y=>y.name===b)??k[0],F=ut(g.getStage(),{preset:a,subject:R.id,start:v,end:w});F.ok&&(g.setStage(()=>F.stage),e.push(`${a} ${M(v)}–${M(w)} s on ${b}`))}P={director:e}}else if(o.camera!==!1)try{const t=ht(g.getStage(),{fighters:k.map(n=>n.name),start:A,end:u,focal_length_mm:Number(o.focal_length_mm)||32});g.setStage(()=>t.stage),P=t.result}catch(t){P={error:t.message}}const nt=E(g.getStage());return{ok:!0,fighters:k.map(t=>t.name),rounds:I.map((t,n)=>({round:n+1,tempo:t.tempo,ending:t.ending,beats:l.filter(s=>s.round===n+1).length})),...W?.length?{contact:W}:{},exchange:l.map(t=>({time_s:M(t.time),round:t.round,attacker:t.attacker,target:t.target,strike:t.cls,result:t.planned})),drama:$.map(t=>({launched:t.who,launch_s:M(t.launch),landed_s:M(t.landed),charge_s:M(t.charge),dash_s:M(t.dash),arrive_s:M(t.arrive)})),resolved:Q.outcomes.slice(0,30).map(t=>({time_s:t.time_s,attacker:t.attacker,result:t.result,gap_m:t.gap_m})),video_s:M((await z(async()=>{const{outputDuration:t}=await import("./remote-DXG553d8.js").then(n=>n.jF);return{outputDuration:t}},__vite__mapDeps([1,2,3,4,5,6,7,8]))).outputDuration(nt)),...H.length?{effects:H.length}:{},...D.length?{notes:D}:{},...P?{camera:P}:{},hint:"camera_preset per round (punch-beats / action-director on the exchanges, low-hero / orbit-180 on the charge and the finisher) reads better than one fight camera; add_effect on the drama times for more"}}export{gt as normalizeRounds,Nt as stageFightRounds};