clipoox-render 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/server-text/titleRaster.js +1394 -0
  2. package/package.json +5 -3
  3. package/scripts/render-local.mjs +1617 -1481
  4. package/shared/transitionStarterPack.json +261 -0
  5. package/web/assets/FxEmbed-D7k1ThAF.js +1 -0
  6. package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
  7. package/web/assets/MotionEmbed-DFni5IAh.js +1 -0
  8. package/web/assets/PluginStore-BrupM_8E.js +3 -0
  9. package/web/assets/{ShotComposer-AHScyNYv.js → ShotComposer-BLztjSKy.js} +4 -4
  10. package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
  11. package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
  12. package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
  13. package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
  14. package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
  15. package/web/assets/{Whiteboard-C9Mwa3nF.js → Whiteboard-DMk0unYK.js} +3 -3
  16. package/web/assets/aerial-DT_gUtSh.js +2 -0
  17. package/web/assets/agentTools-qOww5RUs.js +2 -0
  18. package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
  19. package/web/assets/{analyzerSandbox-DQGHjUCa.js → analyzerSandbox-CJVsEhrg.js} +2 -2
  20. package/web/assets/{api-C5pOWyBM.js → api-QBI5GJTZ.js} +148 -148
  21. package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
  22. package/web/assets/breakthrough-DvkxvNK9.js +2 -0
  23. package/web/assets/{cameraPresets-CeStHDvF.js → cameraPresets-4pFeF2YG.js} +1 -1
  24. package/web/assets/{captionLayout-BAdmqwdS.js → captionLayout-C67EMVI1.js} +1 -1
  25. package/web/assets/clientExport-C4VgAJtO.js +1 -0
  26. package/web/assets/{depthEstimate-1OjTo_pb.js → depthEstimate-mnXDZMW-.js} +1 -1
  27. package/web/assets/directorTools-BOHZjcww.js +1 -0
  28. package/web/assets/{distortFrames-D39fkQ_H.js → distortFrames-Csuj2jHE.js} +2 -2
  29. package/web/assets/{distortGL-5uNfls9s.js → distortGL-BaXfN0IK.js} +2 -2
  30. package/web/assets/editTools-m0VGPmfF.js +1 -0
  31. package/web/assets/{exportEncode-pFxeatJt.js → exportEncode-D9OT7_5k.js} +1 -1
  32. package/web/assets/exportGlb-CLfTnbMG.js +2 -0
  33. package/web/assets/faceTracker-W0iZSiMe.js +1 -0
  34. package/web/assets/fightDirector-CECPf2iH.js +1 -0
  35. package/web/assets/fightDrama-CqNoa5XI.js +2 -0
  36. package/web/assets/{frameSink-CB1EghW0.js → frameSink-BGRj7wqY.js} +3 -3
  37. package/web/assets/{gpuCompose-EfzSAeMh.js → gpuCompose-CIEoLFem.js} +1 -1
  38. package/web/assets/gpuExport-uyOAyrhm.js +190 -0
  39. package/web/assets/handMatte-mHxZwLZD.js +1 -0
  40. package/web/assets/handTracker-dTVeSUzt.js +2 -0
  41. package/web/assets/{index-BGZJld3s.js → index-D7M5t2re.js} +1 -1
  42. package/web/assets/layer-worker-Cp0pjurp.js +5 -0
  43. package/web/assets/library-Dsz_MLyd.js +1 -0
  44. package/web/assets/{lottieLayer-BhLbZOpr.js → lottieLayer-CDCGeJyv.js} +5 -5
  45. package/web/assets/{lottie_light_canvas-D9fsNLID.js → lottie_light_canvas-BblLU4nU.js} +1 -1
  46. package/web/assets/main-BQ8IY0WV.css +1 -0
  47. package/web/assets/{main-BNZrzSIG.js → main-CVRIuDW2.js} +76 -76
  48. package/web/assets/{mapBake-BAG6i5fI.js → mapBake-CNMOKXA7.js} +1 -1
  49. package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
  50. package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
  51. package/web/assets/motionBlur-uAm030t9.js +1 -0
  52. package/web/assets/{objectLocate-Dhktxe5z.js → objectLocate-Cy3IFBSF.js} +1 -1
  53. package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
  54. package/web/assets/pendingMatte-C2AWApuv.js +2 -0
  55. package/web/assets/personAi-DPUnoymj.js +2 -0
  56. package/web/assets/plateCamera-C96L5GKm.js +1 -0
  57. package/web/assets/plateCameraMatch-Chk-ZjDi.js +2 -0
  58. package/web/assets/plateFollow-B9_QTgvo.js +2 -0
  59. package/web/assets/plateMatte-BiqyI_8x.js +2 -0
  60. package/web/assets/{pluginAutomation-DdZOnpoV.js → pluginAutomation-5DYldFrb.js} +1 -1
  61. package/web/assets/poseTracker-PuI8vWpR.js +1 -0
  62. package/web/assets/productTools-B1h5cgyt.js +2 -0
  63. package/web/assets/remote-BJdzzFZg.js +1241 -0
  64. package/web/assets/rigTrack-CUt4O67J.js +1 -0
  65. package/web/assets/{rotoMaskStore-DrRawyH9.js → rotoMaskStore-DIi45swK.js} +1 -1
  66. package/web/assets/{rotoMatte-2EcyuvBX.js → rotoMatte-013RKqHu.js} +1 -1
  67. package/web/assets/rotoscope-d_TUxa-J.js +1 -0
  68. package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
  69. package/web/assets/shot-worker-B1iZT6F5.js +1 -0
  70. package/web/assets/{shotFxAgent-CETPcjzU.js → shotFxAgent-BDfe73TP.js} +2 -2
  71. package/web/assets/{skin-BQG1Iz6Q.js → skin-GDY3QPkV.js} +1 -1
  72. package/web/assets/{spark.module-CMSPLU2n.js → spark.module-DdwuJ_hb.js} +10 -10
  73. package/web/assets/spellDuel-DjNN00bv.js +2 -0
  74. package/web/assets/{store-Dxq3MZF3.js → store-2zneEhhu.js} +1 -1
  75. package/web/assets/{surfaceLight-B_OSTxcx.js → surfaceLight-B_SYg_f8.js} +1 -1
  76. package/web/assets/surfacePin-zDPmq-hH.js +2 -0
  77. package/web/assets/textAnimators-Bdt5LWXk.js +1 -0
  78. package/web/assets/{thumb-xLFX6lDN.js → thumb-byAKvhQP.js} +1 -1
  79. package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
  80. package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
  81. package/web/assets/timelineComp-B73i_8vD.js +1 -0
  82. package/web/assets/timelineProps-B2pnudeT.js +1 -0
  83. package/web/assets/timelineText-BcL4Pw3C.js +1 -0
  84. package/web/assets/{titleArt-CAOxtyHl.js → titleArt-hb_T45WJ.js} +5 -5
  85. package/web/assets/{titleFrameBudget-BjW--v_T.js → titleFrameBudget-Cml-MO53.js} +970 -839
  86. package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
  87. package/web/assets/{tool-DEWWeyCz.js → tool-Bt9bclIf.js} +1 -1
  88. package/web/assets/tools-BXeJbgZJ.js +1 -0
  89. package/web/assets/toonTools-u7Y9fdEZ.js +2 -0
  90. package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
  91. package/web/assets/userFonts-BHduCNtc.js +1 -0
  92. package/web/assets/{vfxAlpha-vbbI-03F.js → vfxAlpha-DpV4rbI-.js} +2 -2
  93. package/web/assets/vfxBackground-Ddviync5.js +2 -0
  94. package/web/assets/videoExport-z5WjM0hw.js +1 -0
  95. package/web/assets/views-CsrYzCSR.js +1 -0
  96. package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
  97. package/web/assets/{windowFrames-DydW5Al5.js → windowFrames-BQEWQkEs.js} +1 -1
  98. package/web/layer-worker.html +3 -3
  99. package/web/assets/FxEmbed-B5TQxKxk.js +0 -1
  100. package/web/assets/MotionEmbed-Catb_GgA.js +0 -1
  101. package/web/assets/PluginStore-8TjQawtB.js +0 -3
  102. package/web/assets/TemplateEmbed-Cao8Z5fY.js +0 -2
  103. package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
  104. package/web/assets/TimelinePlugins-CkP5P9b_.js +0 -5
  105. package/web/assets/TimelineShotFx-DvmPZQXM.js +0 -2
  106. package/web/assets/TransitionEmbed-o4UxJ35e.js +0 -1
  107. package/web/assets/aerial-BPRLPci2.js +0 -2
  108. package/web/assets/agentTools-CSnN-LvS.js +0 -2
  109. package/web/assets/analyzerRun-5zJsmMS1.js +0 -1
  110. package/web/assets/auraTrack-pF-WhpH3.js +0 -1
  111. package/web/assets/breakthrough-DQN1i-Pw.js +0 -2
  112. package/web/assets/clientExport-Ca9a3Jiy.js +0 -1
  113. package/web/assets/desktop-BWhFnYwd.js +0 -1
  114. package/web/assets/directorTools-CvmghG_6.js +0 -1
  115. package/web/assets/editTools-CUoVvupD.js +0 -1
  116. package/web/assets/exportGlb-MK05aKqH.js +0 -2
  117. package/web/assets/faceTracker-_rQOgBvX.js +0 -1
  118. package/web/assets/fightDirector-Dt60kfbV.js +0 -1
  119. package/web/assets/fightDrama-py4jxSdn.js +0 -2
  120. package/web/assets/gpuExport-Cnv2NfEb.js +0 -189
  121. package/web/assets/handMatte-DZCsuqD2.js +0 -1
  122. package/web/assets/handTracker-Btr9L-Hu.js +0 -2
  123. package/web/assets/layer-worker-Rbo-YZv-.js +0 -5
  124. package/web/assets/library-CdukL2BW.js +0 -1
  125. package/web/assets/main-By_IEoB_.css +0 -1
  126. package/web/assets/maskTrack-AZwAVz1c.js +0 -1
  127. package/web/assets/matteFixRun-wTHGiGGf.js +0 -1
  128. package/web/assets/pendingMatte-iKz2-XBZ.js +0 -2
  129. package/web/assets/personAi-BEVyjCii.js +0 -2
  130. package/web/assets/plateCamera-D_J3-X06.js +0 -1
  131. package/web/assets/plateCameraMatch-C0peOvBn.js +0 -2
  132. package/web/assets/plateFollow-BbJMVxfg.js +0 -2
  133. package/web/assets/plateMatte-u5wKpsUN.js +0 -2
  134. package/web/assets/poseTracker--VJYw-hX.js +0 -1
  135. package/web/assets/productTools-DbhbyJxx.js +0 -2
  136. package/web/assets/remote-DXG553d8.js +0 -1220
  137. package/web/assets/rigTrack-CW9_kg5j.js +0 -1
  138. package/web/assets/rotoscope-_CYT-9ry.js +0 -1
  139. package/web/assets/shot-worker-BxIzQRZh.js +0 -1
  140. package/web/assets/spellDuel-eZvRwaxi.js +0 -2
  141. package/web/assets/surfacePin-CfLBhSrm.js +0 -2
  142. package/web/assets/timeline3d-DqXTKdEK.js +0 -2
  143. package/web/assets/timeline3dExport-MWomW4fF.js +0 -1
  144. package/web/assets/timelineProps-KL6XCR4Q.js +0 -1
  145. package/web/assets/timelineText-DEK2BRyU.js +0 -1
  146. package/web/assets/titleFrames-WfiLHzjf.js +0 -1
  147. package/web/assets/tools-CBfIZX8_.js +0 -1
  148. package/web/assets/toonTools-D7jucq3t.js +0 -2
  149. package/web/assets/trackAnchor-DFqKIb8a.js +0 -1
  150. package/web/assets/userFonts-txN4I-eo.js +0 -1
  151. package/web/assets/vfxBackground-C1dHlJN6.js +0 -2
  152. package/web/assets/vfxTrack-BmxWjlDi.js +0 -1
  153. package/web/assets/videoExport-DiNI9GY1.js +0 -1
  154. package/web/assets/views-sH39zgjD.js +0 -1
  155. package/web/assets/weaponDuel-CEvRDeuE.js +0 -1
@@ -0,0 +1 @@
1
+ import{trackPose as S}from"./poseTracker-PuI8vWpR.js";import{i1 as v,i2 as w,i3 as T}from"./remote-BJdzzFZg.js";import{b$ as q,b_ as x}from"./titleFrameBudget-Cml-MO53.js";import{u as z}from"./store-2zneEhhu.js";import{t as l}from"./api-QBI5GJTZ.js";import"./main-CVRIuDW2.js";import"./three.module-Bx43vjkH.js";import"./spark.module-DdwuJ_hb.js";import"./timelineComp-B73i_8vD.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./rigTrack-CUt4O67J.js";import"./timeline3d-YIIk_Kn2.js";import"./GLTFLoader-BHWu1lKg.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";async function Z(p,f){const m=f.params??{},s=z.getState(),r=s.clips.find(t=>t.id===m.source);if(!r||r.kind!=="video")throw Error(l("Không tìm thấy clip video để bám dáng người"));const g=document.querySelector(`video[data-clip-media="${r.id}"]`)?.currentSrc||r.url,a=m.from??0,y=m.duration??p.duration,{frames:c,aspect:b}=await S({clip:r,url:g,from:a,duration:y,fps:v.fps,person:m.person??1});if(!c.some(t=>t.lm))throw Error(l("Không thấy người trong đoạn này để gắn aura"));const{width:u,height:d}=q(s.timelineFormat),k=Math.round(b*1e3),A=1e3,M=w(c.map(t=>({t:t.t,lm:t.lm})),([t,e])=>[t,e]).map(t=>{const e=a+t[0],n=[t[0]];for(let i=1;i<t.length;i+=2){if(t[i]<0){n.push(-1,-1);continue}const h=x(r,t[i],t[i+1],e,u,d,k,A);n.push(Math.round(h.px/u*1e3)/1e3,Math.round(h.py/d*1e3)/1e3)}return n}),o=p.motion?.params??{};return{motion:T(M,{look:o.look,color:o.color,hot:o.hot,size:o.size,intensity:o.intensity,wind:[Number(o.windX)||0,Number(o.windY)||0],speed:o.speed,stretch:o.stretch,taper:o.taper})}}export{Z as runAuraTrack};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js"])))=>i.map(i=>d[i]);
2
+ import{_ as R}from"./titleFrameBudget-Cml-MO53.js";import{iQ as q,fi as B,gE as S,jl as U,iJ as N,fx as z,fl as F,fk as G,hy as H}from"./remote-BJdzzFZg.js";import{c as J}from"./cameraPresets-4pFeF2YG.js";import"./api-QBI5GJTZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const Q=()=>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 V(i,c){const e=S(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 nt(i,c){let e;try{e=q(c.getStage(),String(i.name??""))}catch(t){return{ok:!1,error:t.message}}if(!B(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,E=g+1.2,M=n?1.6+f*1.05:0,C=g+2.4+M,h=C,p=h+1.6,_=p+2.2,w=m?h+2.6:_+2.6;let l=c.getStage();w+.5>S(l).duration&&(l=V(l,Math.min(300,Math.ceil((w+.6)*10)/10)));const x=[],O=[],k=(t,r,o=!1)=>{const a=G(t);if(!a){x.push(`${t} missing`);return}const d=H(l,e.id,a,{start:r/S(l).duration,newId:Q,loop:o});d.ok?(l=d.stage,O.push({motion:t,at_s:s(r)})):x.push(`${t}: ${d.error}`)};k("xx-seal-seated",y),k("xx-bt-gather",j,!0),k("xx-bt-strain",g,!0);const T=E,D=n?U(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=S(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",p),k("xx-bt-settle",_)}c.setStage(()=>l);const{runTool:L}=await R(async()=>{const{runTool:t}=await import("./remote-BJdzzFZg.js").then(r=>r.js);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),I=[],b=async(t,r,o,a={})=>{const d=await L("add_effect",{effect:t,attach_to:e.name,start:s(r),duration:o,color:A,...a},c);d.ok?I.push({effect:t,start_s:s(r)}):x.push(`${t}: ${String(d.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",p+.62,3.2),await b("dot-pha-song-kim",p+.62,2.4,{params:{seated:1,lift:v}}),i.timing!==!1){const t=S(c.getStage()),r=z(F(t.timing,t.duration),p+.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 K=[];if(i.camera!==!1){const t=[["orbit-180",y,g],["wide-track",g,E+.4],["low-hero",E+.4,m?w:p],...m?[]:[["wide-track",p,p+2.2],["orbit-180",_,w]]];for(const[r,o,a]of t){if(a-o<.4)continue;const d=J(c.getStage(),{preset:r,subject:e.id,start:o,end:a});d.ok&&(c.setStage(()=>d.stage),K.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(p+.62),landed_s:s(_+1.4)},end_s:s(w),moves:O,effects:I,...K.length?{camera:K}:{},...x.length?{notes:x}:{}}}export{P as REALMS,nt as stageBreakthrough};
@@ -1 +1 @@
1
- import{fv as D,gS as K,iE as V,fz as L,hJ as R,iF as W}from"./remote-DXG553d8.js";const I=n=>n*Math.PI/180,y=(n,t,a)=>n<t?t:n>a?a:n,C=n=>{const t=y(n,0,1);return t*t*(3-2*t)},G={smooth:C,linear:n=>y(n,0,1),in:n=>{const t=y(n,0,1);return t*t*t},out:n=>{const t=1-y(n,0,1);return 1-t*t*t},snap:n=>1-Math.pow(1-y(n,0,1),4)},Z=Object.freeze([{id:"follow",name:"Bám theo",nameEn:"Follow"},{id:"reveal",name:"Quay vòng & lộ diện",nameEn:"Orbit & reveal"},{id:"impact",name:"Theo cú đánh",nameEn:"Impact"},{id:"director",name:"Đạo diễn hành động",nameEn:"Action director"},{id:"story",name:"Kể chuyện",nameEn:"Storytelling"}]),_=Object.freeze([{id:"side-track",cat:"follow",name:"Bám ngang",nameEn:"Side tracking",desc:"Máy quay chạy song song bên hông nhân vật, giữ khung trung cảnh — kiểu showreel game hành động.",descEn:"The camera runs alongside the subject at a medium framing — the action game showreel look.",lens:35,aim:.5,smooth:.35,path:[{u:0,offset:[4.2,.15,.4]},{u:1,offset:[4.2,.15,.4]}]},{id:"wide-track",cat:"follow",name:"Toàn cảnh bám ngang",nameEn:"Wide tracking",desc:"Toàn cảnh từ xa, ống kính rộng, thấy cả không gian và đường di chuyển.",descEn:"A wide shot from far off: the whole space and the path of the action.",lens:28,aim:.45,smooth:.6,path:[{u:0,offset:[7.5,.4,1.2]},{u:1,offset:[7.5,.4,1.2]}]},{id:"follow-behind",cat:"follow",name:"Bám sau lưng",nameEn:"Over-the-shoulder follow",desc:"Sau lưng, cao hơn đầu một chút — người xem đi cùng nhân vật.",descEn:"Behind and a little above the head — the audience moves with the subject.",lens:28,aim:.6,smooth:.3,handheld:.25,path:[{u:0,offset:[.7,.55,-2.6]},{u:1,offset:[.6,.5,-2.3]}]},{id:"low-hero",cat:"follow",name:"Góc thấp anh hùng",nameEn:"Low hero angle",desc:"Máy đặt thấp ngước lên, đẩy vào chậm — nhân vật trông mạnh mẽ.",descEn:"Low and looking up with a slow push in: the subject looks powerful.",lens:[24,28],aim:.62,smooth:.4,path:[{u:0,offset:[1.6,-.62,3.2]},{u:1,offset:[1.2,-.62,2.4],ease:"smooth"}]},{id:"worm-eye-dutch",cat:"follow",name:"Nhìn từ đất lên trời",nameEn:"Worm's-eye dutch",desc:"Máy sát đất ngước thẳng lên trời, ống kính rộng, khung nghiêng xoay dần — cảnh đấu trên không kiểu Dragon Ball.",descEn:"From the ground looking straight up, a wide lens and a slowly turning tilt — the sky battle of an anime.",lens:18,roll:[-14,10],aim:.85,smooth:.35,path:[{u:0,offset:[1.4,-.92,1.2]},{u:1,offset:[2,-.92,.4],ease:"smooth"}]},{id:"ground-level",cat:"follow",name:"Sát mặt đất",nameEn:"Ground level",desc:"Máy gần như nằm trên sàn — cho cú ngã, cú lộn, đòn quét chân.",descEn:"The camera almost on the floor: for falls, rolls and leg sweeps.",lens:22,aim:.3,smooth:.3,path:[{u:0,offset:[3,-.88,1.4]},{u:1,offset:[2.6,-.88,1]}]},{id:"orbit-180",cat:"reveal",name:"Quay vòng 180°",nameEn:"Orbit 180°",desc:"Vòng nửa quanh nhân vật từ hông sang mặt kia.",descEn:"Half a circle round the subject, from one side to the other.",lens:35,aim:.55,smooth:.4,path:[{u:0,offset:[3.6,.2,.6]},{u:1,offset:[-3.6,.2,.6],turn:180}]},{id:"bullet-time",cat:"reveal",name:"Bullet time",nameEn:"Bullet time",desc:"Vòng nhanh 270° quanh đòn đánh, sát và thấp — kiểu Ma trận.",descEn:"A fast 270° circle round the action, close and low — the Matrix look.",lens:30,aim:.55,smooth:.5,path:[{u:0,offset:[2.4,0,1.2]},{u:1,offset:[-2.4,.1,-1.2],turn:270,ease:"linear"}]},{id:"crane-down",cat:"reveal",name:"Cần cẩu hạ xuống",nameEn:"Crane down reveal",desc:"Từ trên cao hạ xuống ngang ngực, ống kính hẹp dần.",descEn:"From high above down to chest height, the lens tightening.",lens:[24,40],aim:.5,smooth:.5,path:[{u:0,offset:[2.2,3.6,4.2]},{u:1,offset:[1.6,.1,3]}]},{id:"dolly-zoom",cat:"reveal",name:"Dolly zoom (Vertigo)",nameEn:"Dolly zoom (Vertigo)",desc:"Máy lùi ra trong khi ống kính zoom vào: nhân vật giữ nguyên, hậu cảnh co giãn.",descEn:"The camera pulls back as the lens zooms in: the subject holds its size while the background warps.",lens:24,vertigo:!0,aim:.55,smooth:.4,path:[{u:0,offset:[.4,.1,2.2]},{u:1,offset:[.4,.1,6.5],ease:"smooth"}]},{id:"dutch-push",cat:"reveal",name:"Đẩy vào nghiêng",nameEn:"Dutch push-in",desc:"Đẩy vào với khung hình nghiêng dần — căng thẳng, bất an.",descEn:"A push in while the frame tilts — tension, unease.",lens:[32,45],roll:[0,14],aim:.62,smooth:.4,path:[{u:0,offset:[1.2,.2,4]},{u:1,offset:[.7,.15,2.4]}]},{id:"crash-zoom",cat:"impact",name:"Crash zoom vào đòn",nameEn:"Crash zoom on the hit",desc:"Toàn cảnh ngang, đúng đòn đầu tiên ống kính giật zoom vào cận và giữ.",descEn:"A wide side view; on the first strike the lens snaps in to a close-up and holds.",lens:26,aim:.55,smooth:.4,beats:{crash:2.6,shake:.7},path:[{u:0,offset:[5.2,.2,.6]},{u:1,offset:[5,.2,.6]}]},{id:"punch-beats",cat:"impact",name:"Punch-in theo nhịp đòn",nameEn:"Punch-in on every hit",desc:"Mỗi đòn trúng: ống kính giật vào 1 nhịp và rung — nhịp anime/game.",descEn:"Every strike kicks the lens in for a beat with a shake — the anime / game rhythm.",lens:32,aim:.55,smooth:.35,handheld:.15,beats:{punch:.35,shake:.55},path:[{u:0,offset:[3.6,.15,1]},{u:1,offset:[3.4,.15,.9]}]},{id:"whip-pan",cat:"impact",name:"Lia nhanh (whip pan)",nameEn:"Whip pan",desc:"Giữa cảnh máy lia vụt sang góc đối diện của nhân vật.",descEn:"Mid-shot the camera whips round to the opposite side of the subject.",lens:32,aim:.55,smooth:.3,path:[{u:0,offset:[3.4,.2,1.4]},{u:.46,offset:[3.4,.2,1.4]},{u:.56,offset:[-3,.25,1.8],turn:120,ease:"snap"},{u:1,offset:[-3,.25,1.6]}]},{id:"push-in",cat:"story",name:"Đẩy vào chậm",nameEn:"Slow push-in",desc:"Ngang tầm mắt, máy tiến chậm từ trung cảnh vào cận — nhấn một khoảnh khắc, một câu thoại.",descEn:"At eye level the camera creeps from a medium shot into a close-up — to stress a moment or a line.",lens:[32,45],aim:.62,smooth:.5,path:[{u:0,offset:[.5,.05,4]},{u:1,offset:[.3,.02,1.7],ease:"smooth"}]},{id:"pull-away",cat:"story",name:"Lùi xa lộ cảnh",nameEn:"Pull-away reveal",desc:"Từ cận mặt, máy lùi và nâng dần lên — lộ ra không gian quanh nhân vật, hợp cho cảnh kết.",descEn:"From a close-up the camera backs away and rises — the space around the subject is revealed, a fitting ending.",lens:[45,28],aim:.55,smooth:.5,path:[{u:0,offset:[.3,.05,1.6]},{u:1,offset:[1.6,1.8,7.5],ease:"smooth"}]},{id:"walk-lead",cat:"story",name:"Đi trước nhân vật",nameEn:"Walk-and-talk lead",desc:"Máy lùi phía trước, giữ mặt nhân vật trung cảnh khi họ bước tới — kiểu walk-and-talk.",descEn:"The camera backs up in front of the subject, holding a medium shot of the face as they walk — the walk-and-talk.",lens:35,aim:.62,smooth:.5,path:[{u:0,offset:[.35,.05,2.4]},{u:1,offset:[.3,.05,2.2]}]},{id:"slider",cat:"story",name:"Trượt ngang (slider)",nameEn:"Slider move",desc:"Máy trượt ngang chậm trước nhân vật, tiền cảnh và hậu cảnh lệch nhau tạo chiều sâu — hợp cảnh sản phẩm, phỏng vấn.",descEn:"A slow sideways slide in front of the subject; foreground and background shift for depth — product and interview shots.",lens:40,aim:.55,smooth:.5,path:[{u:0,offset:[-1.8,0,3]},{u:1,offset:[1.8,0,3],ease:"smooth"}]},{id:"arc-slow",cat:"story",name:"Vòng cung nhẹ",nameEn:"Gentle arc",desc:"Máy đi một cung 40° quanh nhân vật ở trung cảnh — cảnh thoại, cảnh suy tư có hồn hơn máy đứng yên.",descEn:"A 40° arc round the subject at a medium framing — dialogue or a thoughtful beat feels alive.",lens:40,aim:.6,smooth:.5,path:[{u:0,offset:[2.2,.05,2.6]},{u:1,offset:[.01,.05,3.4],turn:-40,ease:"smooth"}]},{id:"drone-rise",cat:"story",name:"Flycam bay lên",nameEn:"Drone rise",desc:"Từ ngang người, máy bay lên cao và lùi xa — mở cảnh hoặc kết cảnh toàn cảnh.",descEn:"From body height the camera climbs high and backs away — an establishing or closing wide shot.",lens:[28,24],aim:.5,smooth:.6,path:[{u:0,offset:[1.5,.2,3.2]},{u:1,offset:[2.5,5.5,8.5],ease:"smooth"}]},{id:"drone-dive",cat:"story",name:"Flycam bổ nhào",nameEn:"Drone dive",desc:"Từ trên cao máy lao xuống, dừng ngang tầm nhân vật — giới thiệu nhân vật giữa bối cảnh.",descEn:"From high above the camera dives down and settles at the subject's height — introduces them in their world.",lens:[24,32],aim:.55,smooth:.6,path:[{u:0,offset:[2,6.5,8]},{u:1,offset:[.6,.15,2.4],ease:"smooth"}]},{id:"fpv-sweep",cat:"story",name:"FPV lượn quanh",nameEn:"FPV sweep",desc:"Kiểu drone FPV: từ sau lưng sát thấp, lượn vòng qua hông lên trước mặt, ống kính rộng, hơi nghiêng.",descEn:"An FPV drone: low behind the subject, swooping round the side up to the front — wide lens, a slight bank.",lens:18,aim:.5,smooth:.4,handheld:.2,roll:[-10,8],path:[{u:0,offset:[.4,.3,-2.4]},{u:.5,offset:[2.6,.6,.2],turn:-85},{u:1,offset:[.3,1.2,2.6],turn:-79}]},{id:"action-director",cat:"director",name:"Đạo diễn hành động",nameEn:"Action director",desc:"Tự cắt góc theo nhịp đòn: toàn cảnh → cận góc thấp lúc trúng đòn → qua vai → toàn cảnh.",descEn:"Cuts on the beats by itself: wide → low close-up on the hit → over the shoulder → wide.",lens:28,aim:.5,smooth:.35,beats:{shake:.6},path:[{u:0,offset:[6,.3,1]},{u:1,offset:[5.6,.3,.8]}],cuts:[{offset:[6,.3,1],lens:28,aim:.5},{offset:[1.9,-.5,2.6],lens:30,aim:.55},{offset:[.7,.5,-2.4],lens:28,aim:.6},{offset:[-3.2,.1,1.6],lens:40,aim:.55}]}]),H=n=>_.find(t=>t.id===n),N=n=>Array.isArray(n)?n:[n,n];function B(n,t){if(t<=n[0].u)return n[0].offset;const a=n[n.length-1];if(t>=a.u)return a.offset;let o=0;for(;o<n.length-2&&t>=n[o+1].u;)o++;const l=n[o],s=n[o+1],h=(G[s.ease??"smooth"]??C)((t-l.u)/Math.max(1e-6,s.u-l.u)),i=l.offset,r=s.offset;if(s.turn==null)return[i[0]+(r[0]-i[0])*h,i[1]+(r[1]-i[1])*h,i[2]+(r[2]-i[2])*h];const m=Math.hypot(i[0],i[2]),u=Math.hypot(r[0],r[2]),d=Math.atan2(i[0],i[2]),f=d+Q(i,r,s.turn)*h,g=m+(u-m)*h;return[Math.sin(f)*g,i[1]+(r[1]-i[1])*h,Math.cos(f)*g]}function Q(n,t,a){const o=((Math.atan2(t[0],t[2])-Math.atan2(n[0],n[2]))*180/Math.PI+540)%360-180,l=Math.abs(a),s=Math.sign(a)||1;let h=o;for(const i of[o-360,o,o+360]){const r=Math.abs(Math.abs(i)-l),m=Math.abs(Math.abs(h)-l);(r<m-1e-9||Math.abs(r-m)<1e-9&&Math.sign(i)===s&&Math.sign(h)!==s)&&(h=i)}return I(h)}const O=(n,t)=>{const[a,o]=N(n??0);return a+(o-a)*C(t)},U=(n,t=.35)=>n<-.06?0:n<0?1+n/.06:Math.exp(-n/Math.max(.05,t)*2.2);function z(n,t,a){const o=Math.max(1e-6,a.end-a.start),l=y((t-a.start)/o,0,1),s=Math.max(.3,a.height/1.8),h=Math.max(0,n.smooth??.3),i=Math.max(1,Math.round(h*30)),r=[0,0,0];for(let e=-i;e<=i;e++){const c=a.centre(y(t+h*e/i,a.start,a.end));r[0]+=c[0],r[1]+=c[1],r[2]+=c[2]}r[0]/=2*i+1,r[1]/=2*i+1,r[2]/=2*i+1;const m=(a.beats||[]).filter(e=>e>=a.start-1e-6&&e<=a.end+1e-6);let u=B(n.path,l),d=O(n.lens,l),f=n.aim??.5,g=null;if(n.cuts?.length){g=m.filter(p=>t>=p-.05).length%n.cuts.length;const c=n.cuts[g];u=c.offset,d=c.lens??d,f=c.aim??f}const b=I(a.yaw||0),j=Math.cos(b),P=Math.sin(b),w=u[0]*s,E=u[1]*s,M=u[2]*s,k=[r[0],r[1]+a.height*f,r[2]],A=[k[0]+w*j+M*P,Math.max(.12,k[1]+E),k[2]-w*P+M*j];if(n.vertigo){const e=Math.hypot(...B(n.path,0)),c=Math.hypot(u[0],u[1],u[2]);d=d*(c/Math.max(.1,e))}const x=n.beats;if(x?.punch){let e=0;for(const c of m)e=Math.max(e,U(t-c));d*=1+x.punch*e}if(x?.crash&&m.length){const e=m[0];d*=1+(x.crash-1)*G.snap(y((t-(e-.08))/.12,0,1))}return{position:A,target:k,lens:y(d,12,200),roll:O(n.roll,l),cut:g}}function J(n,t,a,o,l){const s=n.beats?.shake;return s?t.filter(h=>h>=a-1e-6&&h<=o+1e-6).map(h=>({time:Math.round(h/Math.max(1e-6,l)*1e4)/1e4,strength:s})):[]}const Y=()=>crypto.randomUUID(),v=(n,t=1e3)=>Math.round(n*t)/t,$=n=>(D(n)?1.8*R(n):1.8)*(n.scale?.[1]||1);function nn(n,t){const a=t?n.items.find(o=>o.id===t):null;return a&&a.kind!=="fx"&&!a.hold&&!a.hidden?a:n.items.find(o=>o.kind==="person"&&!o.hidden)??n.items.find(o=>D(o)&&!o.hidden)??null}function tn(n,t){const a=typeof t.preset=="string"?H(t.preset):t.preset;if(!a)return{ok:!1,error:`unknown camera preset ${String(t.preset)}`};const o=K(n),l=n.items.find(e=>e.id===t.subject||e.name===t.subject);if(!l)return{ok:!1,error:"no subject to frame"};const s=Math.max(0,Math.min(o.duration,t.start??0)),h=Math.max(s,Math.min(o.duration,t.end??o.duration));if(h-s<.25)return{ok:!1,error:"not enough shot time after the playhead for a camera move (extend the shot)"};const i=$(l),r=V(n,l,s).rotation[1],m=L(n).filter(e=>e.who===l.id).map(e=>e.time),u={start:s,end:h,yaw:r,height:i,beats:m,centre:e=>V(n,l,e).position},d=Math.max(2,Math.round((h-s)*W)),f=[],g=(e,c)=>({id:Y(),time:v(e/o.duration,1e5),position:c.position.map(p=>v(p)),target:c.target.map(p=>v(p)),lens:v(c.lens,100),roll:v(c.roll,100)});let b=null,j=0;for(let e=0;e<=d;e++){const c=s+(h-s)*(e/d),p=z(a,c,u);if(p.cut!=null&&b!=null&&p.cut!==b){let S=s+(h-s)*((e-1)/d),T=c;for(let q=0;q<12;q++){const F=(S+T)/2;z(a,F,u).cut===b?S=F:T=F}f.push(g(S,z(a,S,u)),g(T,z(a,T,u))),j++}f.push(g(c,p)),b=p.cut}const w=[...(o.cameraKeys||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...f].sort((e,c)=>e.time-c.time),E=w[0],M=w[w.length-1],k=J(a,m,s,h,o.duration),A=k.length?[...(o.impacts||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...k].sort((e,c)=>e.time-c.time):o.impacts,x={...o,motion:"path",pathSmooth:!1,cameraMode:"track",cameraKeys:w,cameraSpec:void 0,position:E.position,target:E.target,lens:E.lens,roll:E.roll,endPosition:M.position,endTarget:M.target,endLens:M.lens,...a.handheld!=null?{handheld:a.handheld}:{},...A?{impacts:A}:{}};return{ok:!0,stage:{...n,shots:n.shots.map(e=>e.id===o.id?x:e)},preset:a.id,subject:l.name,start:v(s),end:v(h),keys:f.length,beats:m.filter(e=>e>=s&&e<=h).length,cuts:j}}export{_ as C,nn as a,Z as b,tn as c,z as p};
1
+ import{fi as D,gE as K,is as V,fm as L,hv as R,it as W}from"./remote-BJdzzFZg.js";const I=n=>n*Math.PI/180,y=(n,t,a)=>n<t?t:n>a?a:n,F=n=>{const t=y(n,0,1);return t*t*(3-2*t)},G={smooth:F,linear:n=>y(n,0,1),in:n=>{const t=y(n,0,1);return t*t*t},out:n=>{const t=1-y(n,0,1);return 1-t*t*t},snap:n=>1-Math.pow(1-y(n,0,1),4)},Z=Object.freeze([{id:"follow",name:"Bám theo",nameEn:"Follow"},{id:"reveal",name:"Quay vòng & lộ diện",nameEn:"Orbit & reveal"},{id:"impact",name:"Theo cú đánh",nameEn:"Impact"},{id:"director",name:"Đạo diễn hành động",nameEn:"Action director"},{id:"story",name:"Kể chuyện",nameEn:"Storytelling"}]),_=Object.freeze([{id:"side-track",cat:"follow",name:"Bám ngang",nameEn:"Side tracking",desc:"Máy quay chạy song song bên hông nhân vật, giữ khung trung cảnh — kiểu showreel game hành động.",descEn:"The camera runs alongside the subject at a medium framing — the action game showreel look.",lens:35,aim:.5,smooth:.35,path:[{u:0,offset:[4.2,.15,.4]},{u:1,offset:[4.2,.15,.4]}]},{id:"wide-track",cat:"follow",name:"Toàn cảnh bám ngang",nameEn:"Wide tracking",desc:"Toàn cảnh từ xa, ống kính rộng, thấy cả không gian và đường di chuyển.",descEn:"A wide shot from far off: the whole space and the path of the action.",lens:28,aim:.45,smooth:.6,path:[{u:0,offset:[7.5,.4,1.2]},{u:1,offset:[7.5,.4,1.2]}]},{id:"follow-behind",cat:"follow",name:"Bám sau lưng",nameEn:"Over-the-shoulder follow",desc:"Sau lưng, cao hơn đầu một chút — người xem đi cùng nhân vật.",descEn:"Behind and a little above the head — the audience moves with the subject.",lens:28,aim:.6,smooth:.3,handheld:.25,path:[{u:0,offset:[.7,.55,-2.6]},{u:1,offset:[.6,.5,-2.3]}]},{id:"low-hero",cat:"follow",name:"Góc thấp anh hùng",nameEn:"Low hero angle",desc:"Máy đặt thấp ngước lên, đẩy vào chậm — nhân vật trông mạnh mẽ.",descEn:"Low and looking up with a slow push in: the subject looks powerful.",lens:[24,28],aim:.62,smooth:.4,path:[{u:0,offset:[1.6,-.62,3.2]},{u:1,offset:[1.2,-.62,2.4],ease:"smooth"}]},{id:"worm-eye-dutch",cat:"follow",name:"Nhìn từ đất lên trời",nameEn:"Worm's-eye dutch",desc:"Máy sát đất ngước thẳng lên trời, ống kính rộng, khung nghiêng xoay dần — cảnh đấu trên không kiểu Dragon Ball.",descEn:"From the ground looking straight up, a wide lens and a slowly turning tilt — the sky battle of an anime.",lens:18,roll:[-14,10],aim:.85,smooth:.35,path:[{u:0,offset:[1.4,-.92,1.2]},{u:1,offset:[2,-.92,.4],ease:"smooth"}]},{id:"ground-level",cat:"follow",name:"Sát mặt đất",nameEn:"Ground level",desc:"Máy gần như nằm trên sàn — cho cú ngã, cú lộn, đòn quét chân.",descEn:"The camera almost on the floor: for falls, rolls and leg sweeps.",lens:22,aim:.3,smooth:.3,path:[{u:0,offset:[3,-.88,1.4]},{u:1,offset:[2.6,-.88,1]}]},{id:"orbit-180",cat:"reveal",name:"Quay vòng 180°",nameEn:"Orbit 180°",desc:"Vòng nửa quanh nhân vật từ hông sang mặt kia.",descEn:"Half a circle round the subject, from one side to the other.",lens:35,aim:.55,smooth:.4,path:[{u:0,offset:[3.6,.2,.6]},{u:1,offset:[-3.6,.2,.6],turn:180}]},{id:"bullet-time",cat:"reveal",name:"Bullet time",nameEn:"Bullet time",desc:"Vòng nhanh 270° quanh đòn đánh, sát và thấp — kiểu Ma trận.",descEn:"A fast 270° circle round the action, close and low — the Matrix look.",lens:30,aim:.55,smooth:.5,path:[{u:0,offset:[2.4,0,1.2]},{u:1,offset:[-2.4,.1,-1.2],turn:270,ease:"linear"}]},{id:"crane-down",cat:"reveal",name:"Cần cẩu hạ xuống",nameEn:"Crane down reveal",desc:"Từ trên cao hạ xuống ngang ngực, ống kính hẹp dần.",descEn:"From high above down to chest height, the lens tightening.",lens:[24,40],aim:.5,smooth:.5,path:[{u:0,offset:[2.2,3.6,4.2]},{u:1,offset:[1.6,.1,3]}]},{id:"dolly-zoom",cat:"reveal",name:"Dolly zoom (Vertigo)",nameEn:"Dolly zoom (Vertigo)",desc:"Máy lùi ra trong khi ống kính zoom vào: nhân vật giữ nguyên, hậu cảnh co giãn.",descEn:"The camera pulls back as the lens zooms in: the subject holds its size while the background warps.",lens:24,vertigo:!0,aim:.55,smooth:.4,path:[{u:0,offset:[.4,.1,2.2]},{u:1,offset:[.4,.1,6.5],ease:"smooth"}]},{id:"dutch-push",cat:"reveal",name:"Đẩy vào nghiêng",nameEn:"Dutch push-in",desc:"Đẩy vào với khung hình nghiêng dần — căng thẳng, bất an.",descEn:"A push in while the frame tilts — tension, unease.",lens:[32,45],roll:[0,14],aim:.62,smooth:.4,path:[{u:0,offset:[1.2,.2,4]},{u:1,offset:[.7,.15,2.4]}]},{id:"crash-zoom",cat:"impact",name:"Crash zoom vào đòn",nameEn:"Crash zoom on the hit",desc:"Toàn cảnh ngang, đúng đòn đầu tiên ống kính giật zoom vào cận và giữ.",descEn:"A wide side view; on the first strike the lens snaps in to a close-up and holds.",lens:26,aim:.55,smooth:.4,beats:{crash:2.6,shake:.7},path:[{u:0,offset:[5.2,.2,.6]},{u:1,offset:[5,.2,.6]}]},{id:"punch-beats",cat:"impact",name:"Punch-in theo nhịp đòn",nameEn:"Punch-in on every hit",desc:"Mỗi đòn trúng: ống kính giật vào 1 nhịp và rung — nhịp anime/game.",descEn:"Every strike kicks the lens in for a beat with a shake — the anime / game rhythm.",lens:32,aim:.55,smooth:.35,handheld:.15,beats:{punch:.35,shake:.55},path:[{u:0,offset:[3.6,.15,1]},{u:1,offset:[3.4,.15,.9]}]},{id:"whip-pan",cat:"impact",name:"Lia nhanh (whip pan)",nameEn:"Whip pan",desc:"Giữa cảnh máy lia vụt sang góc đối diện của nhân vật.",descEn:"Mid-shot the camera whips round to the opposite side of the subject.",lens:32,aim:.55,smooth:.3,path:[{u:0,offset:[3.4,.2,1.4]},{u:.46,offset:[3.4,.2,1.4]},{u:.56,offset:[-3,.25,1.8],turn:120,ease:"snap"},{u:1,offset:[-3,.25,1.6]}]},{id:"push-in",cat:"story",name:"Đẩy vào chậm",nameEn:"Slow push-in",desc:"Ngang tầm mắt, máy tiến chậm từ trung cảnh vào cận — nhấn một khoảnh khắc, một câu thoại.",descEn:"At eye level the camera creeps from a medium shot into a close-up — to stress a moment or a line.",lens:[32,45],aim:.62,smooth:.5,path:[{u:0,offset:[.5,.05,4]},{u:1,offset:[.3,.02,1.7],ease:"smooth"}]},{id:"pull-away",cat:"story",name:"Lùi xa lộ cảnh",nameEn:"Pull-away reveal",desc:"Từ cận mặt, máy lùi và nâng dần lên — lộ ra không gian quanh nhân vật, hợp cho cảnh kết.",descEn:"From a close-up the camera backs away and rises — the space around the subject is revealed, a fitting ending.",lens:[45,28],aim:.55,smooth:.5,path:[{u:0,offset:[.3,.05,1.6]},{u:1,offset:[1.6,1.8,7.5],ease:"smooth"}]},{id:"walk-lead",cat:"story",name:"Đi trước nhân vật",nameEn:"Walk-and-talk lead",desc:"Máy lùi phía trước, giữ mặt nhân vật trung cảnh khi họ bước tới — kiểu walk-and-talk.",descEn:"The camera backs up in front of the subject, holding a medium shot of the face as they walk — the walk-and-talk.",lens:35,aim:.62,smooth:.5,path:[{u:0,offset:[.35,.05,2.4]},{u:1,offset:[.3,.05,2.2]}]},{id:"slider",cat:"story",name:"Trượt ngang (slider)",nameEn:"Slider move",desc:"Máy trượt ngang chậm trước nhân vật, tiền cảnh và hậu cảnh lệch nhau tạo chiều sâu — hợp cảnh sản phẩm, phỏng vấn.",descEn:"A slow sideways slide in front of the subject; foreground and background shift for depth — product and interview shots.",lens:40,aim:.55,smooth:.5,path:[{u:0,offset:[-1.8,0,3]},{u:1,offset:[1.8,0,3],ease:"smooth"}]},{id:"arc-slow",cat:"story",name:"Vòng cung nhẹ",nameEn:"Gentle arc",desc:"Máy đi một cung 40° quanh nhân vật ở trung cảnh — cảnh thoại, cảnh suy tư có hồn hơn máy đứng yên.",descEn:"A 40° arc round the subject at a medium framing — dialogue or a thoughtful beat feels alive.",lens:40,aim:.6,smooth:.5,path:[{u:0,offset:[2.2,.05,2.6]},{u:1,offset:[.01,.05,3.4],turn:-40,ease:"smooth"}]},{id:"drone-rise",cat:"story",name:"Flycam bay lên",nameEn:"Drone rise",desc:"Từ ngang người, máy bay lên cao và lùi xa — mở cảnh hoặc kết cảnh toàn cảnh.",descEn:"From body height the camera climbs high and backs away — an establishing or closing wide shot.",lens:[28,24],aim:.5,smooth:.6,path:[{u:0,offset:[1.5,.2,3.2]},{u:1,offset:[2.5,5.5,8.5],ease:"smooth"}]},{id:"drone-dive",cat:"story",name:"Flycam bổ nhào",nameEn:"Drone dive",desc:"Từ trên cao máy lao xuống, dừng ngang tầm nhân vật — giới thiệu nhân vật giữa bối cảnh.",descEn:"From high above the camera dives down and settles at the subject's height — introduces them in their world.",lens:[24,32],aim:.55,smooth:.6,path:[{u:0,offset:[2,6.5,8]},{u:1,offset:[.6,.15,2.4],ease:"smooth"}]},{id:"fpv-sweep",cat:"story",name:"FPV lượn quanh",nameEn:"FPV sweep",desc:"Kiểu drone FPV: từ sau lưng sát thấp, lượn vòng qua hông lên trước mặt, ống kính rộng, hơi nghiêng.",descEn:"An FPV drone: low behind the subject, swooping round the side up to the front — wide lens, a slight bank.",lens:18,aim:.5,smooth:.4,handheld:.2,roll:[-10,8],path:[{u:0,offset:[.4,.3,-2.4]},{u:.5,offset:[2.6,.6,.2],turn:-85},{u:1,offset:[.3,1.2,2.6],turn:-79}]},{id:"action-director",cat:"director",name:"Đạo diễn hành động",nameEn:"Action director",desc:"Tự cắt góc theo nhịp đòn: toàn cảnh → cận góc thấp lúc trúng đòn → qua vai → toàn cảnh.",descEn:"Cuts on the beats by itself: wide → low close-up on the hit → over the shoulder → wide.",lens:28,aim:.5,smooth:.35,beats:{shake:.6},path:[{u:0,offset:[6,.3,1]},{u:1,offset:[5.6,.3,.8]}],cuts:[{offset:[6,.3,1],lens:28,aim:.5},{offset:[1.9,-.5,2.6],lens:30,aim:.55},{offset:[.7,.5,-2.4],lens:28,aim:.6},{offset:[-3.2,.1,1.6],lens:40,aim:.55}]}]),H=n=>_.find(t=>t.id===n),N=n=>Array.isArray(n)?n:[n,n];function B(n,t){if(t<=n[0].u)return n[0].offset;const a=n[n.length-1];if(t>=a.u)return a.offset;let o=0;for(;o<n.length-2&&t>=n[o+1].u;)o++;const l=n[o],s=n[o+1],h=(G[s.ease??"smooth"]??F)((t-l.u)/Math.max(1e-6,s.u-l.u)),i=l.offset,r=s.offset;if(s.turn==null)return[i[0]+(r[0]-i[0])*h,i[1]+(r[1]-i[1])*h,i[2]+(r[2]-i[2])*h];const m=Math.hypot(i[0],i[2]),u=Math.hypot(r[0],r[2]),d=Math.atan2(i[0],i[2]),f=d+Q(i,r,s.turn)*h,g=m+(u-m)*h;return[Math.sin(f)*g,i[1]+(r[1]-i[1])*h,Math.cos(f)*g]}function Q(n,t,a){const o=((Math.atan2(t[0],t[2])-Math.atan2(n[0],n[2]))*180/Math.PI+540)%360-180,l=Math.abs(a),s=Math.sign(a)||1;let h=o;for(const i of[o-360,o,o+360]){const r=Math.abs(Math.abs(i)-l),m=Math.abs(Math.abs(h)-l);(r<m-1e-9||Math.abs(r-m)<1e-9&&Math.sign(i)===s&&Math.sign(h)!==s)&&(h=i)}return I(h)}const O=(n,t)=>{const[a,o]=N(n??0);return a+(o-a)*F(t)},U=(n,t=.35)=>n<-.06?0:n<0?1+n/.06:Math.exp(-n/Math.max(.05,t)*2.2);function P(n,t,a){const o=Math.max(1e-6,a.end-a.start),l=y((t-a.start)/o,0,1),s=Math.max(.3,a.height/1.8),h=Math.max(0,n.smooth??.3),i=Math.max(1,Math.round(h*30)),r=[0,0,0];for(let e=-i;e<=i;e++){const c=a.centre(y(t+h*e/i,a.start,a.end));r[0]+=c[0],r[1]+=c[1],r[2]+=c[2]}r[0]/=2*i+1,r[1]/=2*i+1,r[2]/=2*i+1;const m=(a.beats||[]).filter(e=>e>=a.start-1e-6&&e<=a.end+1e-6);let u=B(n.path,l),d=O(n.lens,l),f=n.aim??.5,g=null;if(n.cuts?.length){g=m.filter(p=>t>=p-.05).length%n.cuts.length;const c=n.cuts[g];u=c.offset,d=c.lens??d,f=c.aim??f}const b=I(a.yaw||0),j=Math.cos(b),z=Math.sin(b),w=u[0]*s,E=u[1]*s,M=u[2]*s,k=[r[0],r[1]+a.height*f,r[2]],A=[k[0]+w*j+M*z,Math.max(.12,k[1]+E),k[2]-w*z+M*j];if(n.vertigo){const e=Math.hypot(...B(n.path,0)),c=Math.hypot(u[0],u[1],u[2]);d=d*(c/Math.max(.1,e))}const x=n.beats;if(x?.punch){let e=0;for(const c of m)e=Math.max(e,U(t-c));d*=1+x.punch*e}if(x?.crash&&m.length){const e=m[0];d*=1+(x.crash-1)*G.snap(y((t-(e-.08))/.12,0,1))}return{position:A,target:k,lens:y(d,12,200),roll:O(n.roll,l),cut:g}}function Y(n,t,a,o,l){const s=n.beats?.shake;return s?t.filter(h=>h>=a-1e-6&&h<=o+1e-6).map(h=>({time:Math.round(h/Math.max(1e-6,l)*1e4)/1e4,strength:s})):[]}const $=()=>crypto.randomUUID(),v=(n,t=1e3)=>Math.round(n*t)/t,J=n=>(D(n)?1.8*R(n):1.8)*(n.scale?.[1]||1);function nn(n,t){const a=t?n.items.find(o=>o.id===t):null;return a&&a.kind!=="fx"&&!a.hold&&!a.hidden?a:n.items.find(o=>o.kind==="person"&&!o.hidden)??n.items.find(o=>D(o)&&!o.hidden)??null}function tn(n,t){const a=typeof t.preset=="string"?H(t.preset):t.preset;if(!a)return{ok:!1,error:`unknown camera preset ${String(t.preset)}`};const o=K(n),l=n.items.find(e=>e.id===t.subject||e.name===t.subject);if(!l)return{ok:!1,error:"no subject to frame"};const s=Math.max(0,Math.min(o.duration,t.start??0)),h=Math.max(s,Math.min(o.duration,t.end??o.duration));if(h-s<.25)return{ok:!1,error:"not enough shot time after the playhead for a camera move (extend the shot)"};const i=J(l),r=V(n,l,s).rotation[1],m=L(n).filter(e=>e.who===l.id).map(e=>e.time),u={start:s,end:h,yaw:r,height:i,beats:m,centre:e=>V(n,l,e).position},d=Math.max(2,Math.round((h-s)*W)),f=[],g=(e,c)=>({id:$(),time:v(e/o.duration,1e5),position:c.position.map(p=>v(p)),target:c.target.map(p=>v(p)),lens:v(c.lens,100),roll:v(c.roll,100)});let b=null,j=0;for(let e=0;e<=d;e++){const c=s+(h-s)*(e/d),p=P(a,c,u);if(p.cut!=null&&b!=null&&p.cut!==b){let T=s+(h-s)*((e-1)/d),S=c;for(let q=0;q<12;q++){const C=(T+S)/2;P(a,C,u).cut===b?T=C:S=C}f.push(g(T,P(a,T,u)),g(S,P(a,S,u))),j++}f.push(g(c,p)),b=p.cut}const w=[...(o.cameraKeys||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...f].sort((e,c)=>e.time-c.time),E=w[0],M=w[w.length-1],k=Y(a,m,s,h,o.duration),A=k.length?[...(o.impacts||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...k].sort((e,c)=>e.time-c.time):o.impacts,x={...o,motion:"path",pathSmooth:!1,cameraMode:"track",cameraKeys:w,cameraSpec:void 0,position:E.position,target:E.target,lens:E.lens,roll:E.roll,endPosition:M.position,endTarget:M.target,endLens:M.lens,...a.handheld!=null?{handheld:a.handheld}:{},...A?{impacts:A}:{}};return{ok:!0,stage:{...n,shots:n.shots.map(e=>e.id===o.id?x:e)},preset:a.id,subject:l.name,start:v(s),end:v(h),keys:f.length,beats:m.filter(e=>e>=s&&e<=h).length,cuts:j}}export{_ as C,nn as a,Z as b,tn as c,P as p};
@@ -1 +1 @@
1
- import{lk as w,hZ as W,n1 as A,b0 as E,b1 as M,b2 as P,aP as $,a_ as O,aQ as L,aZ as b}from"./titleFrameBudget-BjW--v_T.js";function T(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),o={};for(let e=0,a=t.getUint16(4);e<a;e++){const l=12+e*16;o[String.fromCharCode(n[l],n[l+1],n[l+2],n[l+3])]=t.getUint32(l+8)}const s=t.getUint16(o.head+18),i=t.getUint16(o.hhea+34),g=e=>t.getUint16(o.hmtx+Math.min(e,i-1)*4),r=o.cmap,f=[];for(let e=0,a=t.getUint16(r+2);e<a;e++)f.push({platform:t.getUint16(r+4+e*8),encoding:t.getUint16(r+6+e*8),offset:r+t.getUint32(r+8+e*8)});const p=f.find(e=>e.platform===3&&e.encoding===10)||f.find(e=>e.platform===3&&e.encoding===1)||f.find(e=>e.platform===0);if(!p)throw Error("Font has no usable cmap");const h=t.getUint16(p.offset);return{unitsPerEm:s,glyphFor:e=>{if(h===4){const a=t.getUint16(p.offset+6)/2,l=p.offset+14,u=l+a*2+2,y=u+a*2,m=y+a*2;for(let d=0;d<a;d++){if(e>t.getUint16(l+d*2))continue;if(e<t.getUint16(u+d*2))return 0;const k=t.getUint16(m+d*2),x=t.getInt16(y+d*2);if(!k)return e+x&65535;const C=t.getUint16(m+d*2+k+(e-t.getUint16(u+d*2))*2);return C?C+x&65535:0}return 0}if(h===12){for(let a=0,l=t.getUint32(p.offset+12);a<l;a++){const u=p.offset+16+a*12,y=t.getUint32(u),m=t.getUint32(u+4);if(e>=y&&e<=m)return t.getUint32(u+8)+(e-y)}return 0}throw Error(`Unsupported cmap format ${h}`)},advanceOf:g}}const Z=n=>({...T(n),advances:new Map});function j(n,t,o){let s=0;for(const i of String(t).normalize("NFC")){let g=n.advances.get(i);g===void 0&&(g=n.advanceOf(n.glyphFor(i.codePointAt(0))),n.advances.set(i,g)),s+=g}return s*o/n.unitsPerEm}let U=null;const S=new Map,v=new Map;function B(n){const t=w(n);if(S.has(t.id))return Promise.resolve();let o=v.get(t.id);return o||(o=Promise.all([fetch(`/fonts/${t.file}`).then(s=>{if(!s.ok)throw Error(String(s.status));return s.arrayBuffer()}).then(s=>{S.set(t.id,Z(new Uint8Array(s)))}),document.fonts.load(`40px "${t.css}"`)]).then(()=>{}).catch(()=>{v.delete(t.id)}),v.set(t.id,o)),o}function D(n,t,o){const s=S.get(w(o).id);return s?j(s,n,t):(B(o),U??=document.createElement("canvas").getContext("2d"),U?(U.font=`${t}px "${w(o).css}"`,U.measureText(n).width):n.length*t*.55)}const F=new WeakMap,N=n=>{const t=F.get(n.captionWords);if(t&&t.style===n.captionStyle&&t.cues===n.captions)return t.prepared;const o=b(n.captionWords,n.captionStyle,n.captions);return F.set(n.captionWords,{style:n.captionStyle,cues:n.captions,prepared:o}),o},Q=(n,t)=>{const o=n.groups[t];let s=0;for(let i=o.from;i<=o.to;i++)s+=[...String(n.words[i].word)].length;return s};function V(n,t,o,s,i,g=D){const r=W(n,t,o);if(!r)return null;const f=t-r.start;if(["social","karaoke"].includes(r.captionStyle?.style||"")&&r.captionWords?.length){const c=N(r),e=A(c.groups,f);if(e<0)return null;const a=c.style.style==="karaoke",l=c.groups[e],u=E(c.style,f-l.start,Q(c,e));return{clip:r,layout:P(c,e,s,i,g),style:c.style,scale:u.scale,motion:u.m,lit:a?M(c,e,f):void 0}}const p=$(r.captionStyle),h=O(r.captions,p.cueWords).find(c=>f>=c.start&&f<c.end);return h?{clip:r,layout:L({width:s,height:i,text:h.text,style:p,measure:g,second:h.tr}),style:p,scale:1}:null}export{B as captionFontReady,V as captionFrameAt,Q as groupLetters,D as measureCaption};
1
+ import{lk as w,hZ as W,nb as A,b0 as E,b1 as M,b2 as P,aP as $,a_ as O,aQ as b,aZ as L}from"./titleFrameBudget-Cml-MO53.js";function T(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),o={};for(let e=0,a=t.getUint16(4);e<a;e++){const l=12+e*16;o[String.fromCharCode(n[l],n[l+1],n[l+2],n[l+3])]=t.getUint32(l+8)}const s=t.getUint16(o.head+18),i=t.getUint16(o.hhea+34),g=e=>t.getUint16(o.hmtx+Math.min(e,i-1)*4),r=o.cmap,f=[];for(let e=0,a=t.getUint16(r+2);e<a;e++)f.push({platform:t.getUint16(r+4+e*8),encoding:t.getUint16(r+6+e*8),offset:r+t.getUint32(r+8+e*8)});const p=f.find(e=>e.platform===3&&e.encoding===10)||f.find(e=>e.platform===3&&e.encoding===1)||f.find(e=>e.platform===0);if(!p)throw Error("Font has no usable cmap");const h=t.getUint16(p.offset);return{unitsPerEm:s,glyphFor:e=>{if(h===4){const a=t.getUint16(p.offset+6)/2,l=p.offset+14,u=l+a*2+2,y=u+a*2,m=y+a*2;for(let d=0;d<a;d++){if(e>t.getUint16(l+d*2))continue;if(e<t.getUint16(u+d*2))return 0;const k=t.getUint16(m+d*2),x=t.getInt16(y+d*2);if(!k)return e+x&65535;const C=t.getUint16(m+d*2+k+(e-t.getUint16(u+d*2))*2);return C?C+x&65535:0}return 0}if(h===12){for(let a=0,l=t.getUint32(p.offset+12);a<l;a++){const u=p.offset+16+a*12,y=t.getUint32(u),m=t.getUint32(u+4);if(e>=y&&e<=m)return t.getUint32(u+8)+(e-y)}return 0}throw Error(`Unsupported cmap format ${h}`)},advanceOf:g}}const Z=n=>({...T(n),advances:new Map});function j(n,t,o){let s=0;for(const i of String(t).normalize("NFC")){let g=n.advances.get(i);g===void 0&&(g=n.advanceOf(n.glyphFor(i.codePointAt(0))),n.advances.set(i,g)),s+=g}return s*o/n.unitsPerEm}let U=null;const S=new Map,v=new Map;function B(n){const t=w(n);if(S.has(t.id))return Promise.resolve();let o=v.get(t.id);return o||(o=Promise.all([fetch(`/fonts/${t.file}`).then(s=>{if(!s.ok)throw Error(String(s.status));return s.arrayBuffer()}).then(s=>{S.set(t.id,Z(new Uint8Array(s)))}),document.fonts.load(`40px "${t.css}"`)]).then(()=>{}).catch(()=>{v.delete(t.id)}),v.set(t.id,o)),o}function D(n,t,o){const s=S.get(w(o).id);return s?j(s,n,t):(B(o),U??=document.createElement("canvas").getContext("2d"),U?(U.font=`${t}px "${w(o).css}"`,U.measureText(n).width):n.length*t*.55)}const F=new WeakMap,N=n=>{const t=F.get(n.captionWords);if(t&&t.style===n.captionStyle&&t.cues===n.captions)return t.prepared;const o=L(n.captionWords,n.captionStyle,n.captions);return F.set(n.captionWords,{style:n.captionStyle,cues:n.captions,prepared:o}),o},Q=(n,t)=>{const o=n.groups[t];let s=0;for(let i=o.from;i<=o.to;i++)s+=[...String(n.words[i].word)].length;return s};function V(n,t,o,s,i,g=D){const r=W(n,t,o);if(!r)return null;const f=t-r.start;if(["social","karaoke"].includes(r.captionStyle?.style||"")&&r.captionWords?.length){const c=N(r),e=A(c.groups,f);if(e<0)return null;const a=c.style.style==="karaoke",l=c.groups[e],u=E(c.style,f-l.start,Q(c,e));return{clip:r,layout:P(c,e,s,i,g),style:c.style,scale:u.scale,motion:u.m,lit:a?M(c,e,f):void 0}}const p=$(r.captionStyle),h=O(r.captions,p.cueWords).find(c=>f>=c.start&&f<c.end);return h?{clip:r,layout:b({width:s,height:i,text:h.text,style:p,measure:g,second:h.tr}),style:p,scale:1}:null}export{B as captionFontReady,V as captionFrameAt,Q as groupLetters,D as measureCaption};
@@ -0,0 +1 @@
1
+ import{b$ as p,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-Cml-MO53.js";import{e as P,a as j}from"./timelineComp-B73i_8vD.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:r=1280,H:f=720}={}){const o=[];if(w(e))return[];if(e.kind==="model")return[];if(!["image","video","audio"].includes(e.kind))return[`${e.kind} layer`];const a=e.kind!=="audio"&&b(s)&&y(e),d=!a&&e.is3D===!0&&!c(e.spatialDepth);for(const t of M){if(t==="clientJobs"){Array.isArray(e.clientJobs)&&e.clientJobs.some(n=>n?.state==="pending"||n?.state==="running")&&o.push(t);continue}c(e[t])&&!(a&&J.has(t))&&!(d&&t==="is3D")&&o.push(t)}if(e.pin?.scene&&o.push("scene pin"),e.timeRemap?.blend&&e.timeRemap.blend!=="none"&&o.push("time remap frame blending"),e.kind!=="audio"&&E(e,r||1280).some(t=>t.sigma>42)&&o.push("wide shadow"),O(e)&&S(e)&&o.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||a)&&o.push("motion blur"),e.kind!=="audio"&&A(e)){const t=D(e),n=v(t);t.cover<.999||t.comet||t.crackle?o.push("edge arc"):Math.max(n.band,n.glow)>42&&o.push("wide edge")}!a&&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)&&o.push("rot"),a&&(e.transition||e._txIn||e._txOut)&&o.push("transition on a 3D layer");for(const[t,n]of Object.entries(X))!(a&&H.has(t))&&(h(e,t).length>1||Math.abs(g(e,t,0)-n)>1e-9)&&o.push(t);e.grade&&!e.colorBypass&&(e.grade.lut||B(e.grade).length)&&o.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")))&&o.push("grade window");for(const t of Array.isArray(e.effects)?e.effects:[])!t.off&&!N.has(t.type)&&o.push(`effect ${t.type}`);if(I(e,"T")&&o.push("reveal"),e.transition){const t=e.transition.spec||{},n=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))||!n(t[i]))))&&o.push(`transition ${e.transition.id}`)}return e.kind==="video"&&R(e)&&o.push("title on video"),o}function V(e,s={}){const{reasons:r}=u(e,s);return{ok:r.length===0,reasons:r}}function W(e,s={}){return[...new Set(u(e,s).codes)].sort()}function u(e,{format:s,camera:r,look:f}={}){const o=[],a=[];e=P((e||[]).filter(n=>!n.disabled),{W:p(s).width,H:p(s).height});const d=b(r)?r:null,{width:m,height:t}=p(s);d&&(e||[]).some(n=>!n.disabled&&n.kind!=="audio"&&y(n))&&d.parentId&&(o.push("camera on a parent"),a.push("camera on a parent")),k(f)&&(o.push("look"),a.push("look"));for(const n of e||[]){if(n.disabled)continue;if(n._group&&n.comp){const l=u(j(n),{format:s});l.reasons.length&&(o.push(`${n.label||n.id} (comp): ${l.reasons.join("; ")}`),a.push(...l.codes))}const i=C(n,{camera:d,W:m,H:t});i.length&&(o.push(`${n.label||n.id}: ${i.join(", ")}`),a.push(...i))}if(!o.length)for(const n of x((e||[]).filter(i=>!i.disabled))){const i=l=>{o.push(`${n.label||n.id}: ${l}`),a.push(l)};n.speedRamp&&(n._txIn||n._txOut)&&i("speed ramp in a transition"),n.timeRemap&&(n._txIn||n._txOut)&&!n._ramp&&i("time remap in a transition"),n.motionBlur&&(n._txIn||n._txOut)&&i("motion blur in a transition")}return{reasons:o,codes:a}}const Y=(e,s,r)=>(s==="video encode"||s==="finalize")&&r?.codec!=="hevc"&&e?.name!=="AbortError"&&/^(OperationError|EncodingError)$/.test(e?.name||""),q=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,V as clientExportCheck,W as clientExportCodes,C as clipBlockers,q as gpuErrorText,Y as softwareRetry};
@@ -1 +1 @@
1
- import{ne as I,nf as y,ng as N,_ as B}from"./titleFrameBudget-BjW--v_T.js";import{t as g}from"./api-C5pOWyBM.js";const C="1.31.1",H=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${C}/dist/`,l={url:"https://huggingface.co/onnx-community/depth-anything-v2-small/resolve/4472b7362082ad9968fee890ca0f1e5aca36b93d/onnx/model_quantized.onnx",sha256:"fcf51f1b230362b28690bb9d1809bf0431f29cad20534e3f589bd7285547f20d",bytes:27258801,cache:"clipoox-depth-1"},K=[.485,.456,.406],L=[.229,.224,.225],x=378;let f=null;const U=o=>[...new Uint8Array(o)].map(i=>i.toString(16).padStart(2,"0")).join("");async function W(o){const i=await caches.open(l.cache).catch(()=>null),r=await i?.match(l.url);if(r){const c=new Uint8Array(await r.arrayBuffer());if(c.length===l.bytes)return c}const h=await fetch(l.url);if(!h.ok||!h.body)throw Error(g("Không tải được mô hình độ sâu (HTTP {0})",[h.status]));const t=h.body.getReader(),n=[];let e=0;for(;;){const{done:c,value:p}=await t.read();if(c)break;n.push(p),e+=p.length,o?.(Math.min(1,e/l.bytes))}const s=new Uint8Array(e);let m=0;for(const c of n)s.set(c,m),m+=c.length;if(U(await crypto.subtle.digest("SHA-256",s))!==l.sha256)throw Error(g("Mô hình độ sâu tải về bị lỗi (mã kiểm tra không khớp) — thử lại."));return await i?.put(l.url,new Response(s,{headers:{"content-type":"application/octet-stream"}})).catch(()=>{}),s}function z(o){return f||(f=(async()=>{const i=await B(()=>import(`${H}ort.wasm.min.mjs`),[]);i.env.wasm.wasmPaths=H,i.env.wasm.numThreads=1;const r=await i.InferenceSession.create(await W(o),{executionProviders:["wasm"],graphOptimizationLevel:"all"});return Object.assign(r,{ort:i})})(),f.catch(()=>{f=null})),f}async function V(o,i){const r=document.createElement("canvas"),h=r.getContext("2d",{willReadFrequently:!0});if(o.kind==="image"){const n=new Image;return n.crossOrigin="anonymous",n.src=o.url,await new Promise((e,s)=>{n.onload=()=>e(),n.onerror=()=>s(Error(g("Không đọc được ảnh của clip")))}),r.width=n.naturalWidth,r.height=n.naturalHeight,h.drawImage(n,0,0),r}const t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=o.url;try{await new Promise((e,s)=>{t.onloadeddata=()=>e(),t.onerror=()=>s(Error(g("Không đọc được video của clip (CORS / định dạng)")))});const n=Math.max(0,Math.min(t.duration-1/60,(o.inPoint||0)+i*(o.playbackRate||1)));return await new Promise((e,s)=>{const m=window.setTimeout(()=>s(Error(g("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(m),e()},t.currentTime=n}),r.width=t.videoWidth||1280,r.height=t.videoHeight||720,h.drawImage(t,0,0),r}finally{t.removeAttribute("src"),t.load()}}async function J(o,i,r){const h=Math.max(0,Math.min(o.duration,i));if(window.__depthStub){const a=window.__depthStub(o,h);return I(a.data,a.w,a.h,h)}const[t,n]=await Promise.all([z(a=>r?.("download",a)),V(o,h)]);r?.("run");const e=n.width/Math.max(1,n.height),s=a=>Math.max(14,Math.round(a/14)*14),m=e>=1?s(x*e):x,c=e>=1?x:s(x/e),p=Object.assign(document.createElement("canvas"),{width:m,height:c}),b=p.getContext("2d",{willReadFrequently:!0});b.imageSmoothingQuality="high",b.drawImage(n,0,0,m,c);const j=b.getImageData(0,0,m,c).data,M=m*c,O=new Float32Array(3*M);for(let a=0;a<M;a++)for(let d=0;d<3;d++)O[d*M+a]=(j[a*4+d]/255-K[d])/L[d];const v=(await t.run({[t.inputNames[0]]:new t.ort.Tensor("float32",O,[1,3,c,m])}))[t.outputNames[0]],T=v.dims.at(-2),S=v.dims.at(-1),u=e>=1?y.maxSide:Math.max(2,Math.round(y.maxSide*e)),w=e>=1?Math.max(2,Math.round(y.maxSide/e)):y.maxSide,P=new Float32Array(u*w);for(let a=0;a<w;a++)for(let d=0;d<u;d++){const k=Math.floor(d*S/u),q=Math.max(k+1,Math.floor((d+1)*S/u)),A=Math.floor(a*T/w),F=Math.max(A+1,Math.floor((a+1)*T/w));let R=0,D=0;for(let _=A;_<F;_++)for(let E=k;E<q;E++)R+=v.data[_*S+E],D++;P[a*u+d]=R/Math.max(1,D)}return I(N(P),u,w,h)}export{l as DEPTH_MODEL,J as estimateDepth};
1
+ import{nl as I,nm as y,nn as N,_ as B}from"./titleFrameBudget-Cml-MO53.js";import{t as g}from"./api-QBI5GJTZ.js";const C="1.31.1",H=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${C}/dist/`,l={url:"https://huggingface.co/onnx-community/depth-anything-v2-small/resolve/4472b7362082ad9968fee890ca0f1e5aca36b93d/onnx/model_quantized.onnx",sha256:"fcf51f1b230362b28690bb9d1809bf0431f29cad20534e3f589bd7285547f20d",bytes:27258801,cache:"clipoox-depth-1"},K=[.485,.456,.406],L=[.229,.224,.225],x=378;let f=null;const U=o=>[...new Uint8Array(o)].map(i=>i.toString(16).padStart(2,"0")).join("");async function W(o){const i=await caches.open(l.cache).catch(()=>null),r=await i?.match(l.url);if(r){const c=new Uint8Array(await r.arrayBuffer());if(c.length===l.bytes)return c}const h=await fetch(l.url);if(!h.ok||!h.body)throw Error(g("Không tải được mô hình độ sâu (HTTP {0})",[h.status]));const t=h.body.getReader(),n=[];let a=0;for(;;){const{done:c,value:p}=await t.read();if(c)break;n.push(p),a+=p.length,o?.(Math.min(1,a/l.bytes))}const s=new Uint8Array(a);let m=0;for(const c of n)s.set(c,m),m+=c.length;if(U(await crypto.subtle.digest("SHA-256",s))!==l.sha256)throw Error(g("Mô hình độ sâu tải về bị lỗi (mã kiểm tra không khớp) — thử lại."));return await i?.put(l.url,new Response(s,{headers:{"content-type":"application/octet-stream"}})).catch(()=>{}),s}function z(o){return f||(f=(async()=>{const i=await B(()=>import(`${H}ort.wasm.min.mjs`),[]);i.env.wasm.wasmPaths=H,i.env.wasm.numThreads=1;const r=await i.InferenceSession.create(await W(o),{executionProviders:["wasm"],graphOptimizationLevel:"all"});return Object.assign(r,{ort:i})})(),f.catch(()=>{f=null})),f}async function V(o,i){const r=document.createElement("canvas"),h=r.getContext("2d",{willReadFrequently:!0});if(o.kind==="image"){const n=new Image;return n.crossOrigin="anonymous",n.src=o.url,await new Promise((a,s)=>{n.onload=()=>a(),n.onerror=()=>s(Error(g("Không đọc được ảnh của clip")))}),r.width=n.naturalWidth,r.height=n.naturalHeight,h.drawImage(n,0,0),r}const t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=o.url;try{await new Promise((a,s)=>{t.onloadeddata=()=>a(),t.onerror=()=>s(Error(g("Không đọc được video của clip (CORS / định dạng)")))});const n=Math.max(0,Math.min(t.duration-1/60,(o.inPoint||0)+i*(o.playbackRate||1)));return await new Promise((a,s)=>{const m=window.setTimeout(()=>s(Error(g("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(m),a()},t.currentTime=n}),r.width=t.videoWidth||1280,r.height=t.videoHeight||720,h.drawImage(t,0,0),r}finally{t.removeAttribute("src"),t.load()}}async function J(o,i,r){const h=Math.max(0,Math.min(o.duration,i));if(window.__depthStub){const e=window.__depthStub(o,h);return I(e.data,e.w,e.h,h)}const[t,n]=await Promise.all([z(e=>r?.("download",e)),V(o,h)]);r?.("run");const a=n.width/Math.max(1,n.height),s=e=>Math.max(14,Math.round(e/14)*14),m=a>=1?s(x*a):x,c=a>=1?x:s(x/a),p=Object.assign(document.createElement("canvas"),{width:m,height:c}),b=p.getContext("2d",{willReadFrequently:!0});b.imageSmoothingQuality="high",b.drawImage(n,0,0,m,c);const j=b.getImageData(0,0,m,c).data,M=m*c,O=new Float32Array(3*M);for(let e=0;e<M;e++)for(let d=0;d<3;d++)O[d*M+e]=(j[e*4+d]/255-K[d])/L[d];const v=(await t.run({[t.inputNames[0]]:new t.ort.Tensor("float32",O,[1,3,c,m])}))[t.outputNames[0]],T=v.dims.at(-2),S=v.dims.at(-1),u=a>=1?y.maxSide:Math.max(2,Math.round(y.maxSide*a)),w=a>=1?Math.max(2,Math.round(y.maxSide/a)):y.maxSide,P=new Float32Array(u*w);for(let e=0;e<w;e++)for(let d=0;d<u;d++){const k=Math.floor(d*S/u),q=Math.max(k+1,Math.floor((d+1)*S/u)),A=Math.floor(e*T/w),F=Math.max(A+1,Math.floor((e+1)*T/w));let R=0,D=0;for(let _=A;_<F;_++)for(let E=k;E<q;E++)R+=v.data[_*S+E],D++;P[e*u+d]=R/Math.max(1,D)}return I(N(P),u,w,h)}export{l as DEPTH_MODEL,J as estimateDepth};
@@ -0,0 +1 @@
1
+ import{C as P,c as M}from"./cameraPresets-4pFeF2YG.js";import{gE as g,iQ as y,fl as k,fm as x,fw as S,fv as A,fx as N,fq as C,fr as D,fp as F,jg as I,fi as j,fy as R,fo as $}from"./remote-BJdzzFZg.js";import{s as z}from"./weaponDuel-CLLgv5A4.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const L=["katana","spear","staff","fist"],v=P.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 Z(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 ee(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 te(e,a){const m=a.getStage(),f=g(m),n=f.duration;let r=k(f.timing,n);const p=x(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=C({...f,timing:r??void 0},D(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 ${I.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 se(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,ee as cameraPreset,te as setTiming,se as setTrail,Z as stageDuel};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMatte-2EcyuvBX.js","assets/titleFrameBudget-BjW--v_T.js","assets/api-C5pOWyBM.js","assets/store-Dxq3MZF3.js"])))=>i.map(i=>d[i]);
2
- import{f6 as Q,hR as R,b$ as Y,eO as Z,iM as tt,_ as et,fg as ot}from"./titleFrameBudget-BjW--v_T.js";import{c as at}from"./distortGL-5uNfls9s.js";import{I as rt,A as nt,U as it,V as st}from"./id3-BCR9Bqgo.js";const lt=["crop","mask","person","personPending","matteFix","colorPerson","distort","playbackRate","speedRamp","reverse","freeze","smoothSlow","inPoint","sourceDuration","proxy","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx","audioTools","sfx","face","roto","planar","sceneTrack","hands"],ct=["url","gcsUri","label","nodeId","start","duration","inPoint","sourceDuration","playbackRate","reverse","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx"],dt=1920,ut=e=>new Promise((p,n)=>{const l=c=>{if(!c)return n(Error("Cannot encode distort frame"));const d=new FileReader;d.onload=()=>p(String(d.result).slice(String(d.result).indexOf(",")+1)),d.onerror=()=>n(d.error),d.readAsDataURL(c)};e instanceof HTMLCanvasElement?e.toBlob(l,"image/webp",.9):e.convertToBlob({type:"image/webp",quality:.9}).then(l,n)});function mt(e,p){const n=e.distort;if(e.kind!=="image"||e.mask||e.person||(n.mesh?.keys.length??0)>1||n.puppet?.pins.some(c=>(c.keys?.length??0)>1)||(n.displace?.keys?.length??0)>1)return!1;const l=n.displace?p.find(c=>c.id===n.displace.map):null;return!l||l.kind==="image"&&!R(l)&&l.start<=e.start&&l.start+l.duration>=e.start+e.duration}async function wt(e,p,n,l,c={}){const d=e.filter(t=>Q(t)&&(t.kind==="video"||t.kind==="image")&&!R(t)&&!t.gen);if(!d.length)return{clips:e,tracks:c};const{fps:v}=Y(p),A=()=>{if(l?.aborted)throw new DOMException("Export cancelled","AbortError")},O=new Set(d.map(t=>t.id)),D={...c};let x=Math.max(0,...e.map(t=>t.track),...Object.keys(c).map(Number))+1;const h=[];for(const t of e){if(!O.has(t.id)){h.push(t);continue}const a={...t,kind:"image",warped:!0};for(const i of lt)delete a[i];if(h.push(a),t.kind==="video"&&!t.speedRamp&&!t.freeze&&(t.volume??1)>0){const i={id:`${t.id}~sound`,kind:"audio",track:x},k=t;for(const m of ct)k[m]!==void 0&&(i[m]=k[m]);c[t.track]&&(D[x]={...c[t.track]}),x++,h.push(i)}}const N=new Map(Z(e).filter(t=>t._virtual).map(t=>[t.id,t])),_=[];for(const t of d)_.push({clip:t,as:t});for(const t of tt(h))O.has(String(t._virtual))&&_.push({clip:N.get(t.id)??{...e.find(a=>a.id===t._virtual),...t,_still:!0},as:t});const w=d.some(t=>t.mask||t.person)?await et(()=>import("./rotoMatte-2EcyuvBX.js").then(t=>t.r),__vite__mapDeps([0,1,2,3])):null;w&&await w.prepareMattes(d.filter(t=>t.mask||t.person));const W=w?document.createElement("canvas"):null,T=at(),I=[],S=new Map,C=async t=>{const a=new rt({source:new it(t),formats:nt});I.push(a);const i=await a.getPrimaryVideoTrack();return i?new st(i):null},U=async t=>{let a=S.get(t);return a||(a=await createImageBitmap(await(await fetch(t,{signal:l})).blob(),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"}),S.set(t,a)),a};try{for(const{clip:t,as:a}of _){A();const i=e.find(o=>o.id===(t._virtual??t.id)),k=Math.ceil(a.duration*v),m=i.distort,$=!!(t._still||t.freeze),q=o=>{const r=o/v,u=t.playbackRate||1;return t.reverse?Math.max(0,(t.inPoint||0)+Math.max(0,t.duration-r-1/v)*u):ot(t,r,!1,$).source};let g=null,b=null;if(t.kind==="video"){const o=await C(t.url);o&&(g=o.samplesAtTimestamps(Array.from({length:k},(r,u)=>q(u))))}else b=await U(t.url);const s=m.displace?e.find(o=>o.id===m.displace.map):void 0,V=s?.kind==="video"?await C(s.url):null,L=s?.kind==="image"&&s.url&&!R(s)?await U(s.url):null,G=async o=>{if(!s||o<s.start||o>=s.start+s.duration)return null;if(L)return{source:L};if(!V)return null;const r=await V.getSample((s.inPoint||0)+(o-s.start)*(s.playbackRate||1));if(!r)return null;const u=r.toVideoFrame();return r.close(),{source:u,close:()=>u.close()}},K=mt(i,e);for(let o=0;o<k;o++){A();const r=g?(await g.next()).value??null:null;if(K&&o>0){r?.close(),await n.push("titleFrames",a.id,"=");continue}const u=r?r.toVideoFrame():null,H=u??b,y=r?r.displayWidth:b?.width??0,M=r?r.displayHeight:b?.height??0;if(!H||!y||!M){if(u?.close(),r?.close(),o===0)throw Error(`No picture for ${i.label||i.id}`);await n.push("titleFrames",a.id,"=");continue}const f=t.crop||{left:0,right:0,top:0,bottom:0},X=Math.floor(y*f.left/2)*2,j=Math.floor(M*f.top/2)*2,E=Math.max(2,Math.floor(y*(1-f.left-f.right)/2)*2),F=Math.max(2,Math.floor(M*(1-f.top-f.bottom)/2)*2),z=Math.min(1,dt/Math.max(E,F)),P=o/v,B=await G(t.start+P),J=T.render({source:H,srcW:y,srcH:M,rect:[X,j,E,F],outW:Math.max(2,Math.round(E*z)),outH:Math.max(2,Math.round(F*z)),distort:m,local:t.start+P-i.start,map:B?.source??null,matte:w&&(t.mask||t.person)?w.matteCanvas(t,P,W,!1,e):null});B?.close?.(),u?.close(),r?.close(),await n.push("titleFrames",a.id,await ut(J))}g&&await g.return(void 0)}}finally{T.dispose();for(const t of S.values())t.close();for(const t of I)t.dispose?.()}return{clips:h,tracks:D}}export{wt as distortForServer};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMatte-013RKqHu.js","assets/titleFrameBudget-Cml-MO53.js","assets/api-QBI5GJTZ.js","assets/store-2zneEhhu.js"])))=>i.map(i=>d[i]);
2
+ import{f6 as Q,hR as R,b$ as Y,eO as Z,iM as tt,_ as et,fg as ot}from"./titleFrameBudget-Cml-MO53.js";import{c as at}from"./distortGL-BaXfN0IK.js";import{I as rt,A as nt,U as it,V as st}from"./id3-BCR9Bqgo.js";const lt=["crop","mask","person","personPending","matteFix","colorPerson","distort","playbackRate","speedRamp","reverse","freeze","smoothSlow","inPoint","sourceDuration","proxy","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx","audioTools","sfx","face","roto","planar","sceneTrack","hands"],ct=["url","gcsUri","label","nodeId","start","duration","inPoint","sourceDuration","playbackRate","reverse","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx"],dt=1920,ut=e=>new Promise((p,n)=>{const l=c=>{if(!c)return n(Error("Cannot encode distort frame"));const d=new FileReader;d.onload=()=>p(String(d.result).slice(String(d.result).indexOf(",")+1)),d.onerror=()=>n(d.error),d.readAsDataURL(c)};e instanceof HTMLCanvasElement?e.toBlob(l,"image/webp",.9):e.convertToBlob({type:"image/webp",quality:.9}).then(l,n)});function mt(e,p){const n=e.distort;if(e.kind!=="image"||e.mask||e.person||(n.mesh?.keys.length??0)>1||n.puppet?.pins.some(c=>(c.keys?.length??0)>1)||(n.displace?.keys?.length??0)>1)return!1;const l=n.displace?p.find(c=>c.id===n.displace.map):null;return!l||l.kind==="image"&&!R(l)&&l.start<=e.start&&l.start+l.duration>=e.start+e.duration}async function wt(e,p,n,l,c={}){const d=e.filter(t=>Q(t)&&(t.kind==="video"||t.kind==="image")&&!R(t)&&!t.gen);if(!d.length)return{clips:e,tracks:c};const{fps:v}=Y(p),A=()=>{if(l?.aborted)throw new DOMException("Export cancelled","AbortError")},O=new Set(d.map(t=>t.id)),D={...c};let x=Math.max(0,...e.map(t=>t.track),...Object.keys(c).map(Number))+1;const h=[];for(const t of e){if(!O.has(t.id)){h.push(t);continue}const a={...t,kind:"image",warped:!0};for(const i of lt)delete a[i];if(h.push(a),t.kind==="video"&&!t.speedRamp&&!t.freeze&&(t.volume??1)>0){const i={id:`${t.id}~sound`,kind:"audio",track:x},k=t;for(const m of ct)k[m]!==void 0&&(i[m]=k[m]);c[t.track]&&(D[x]={...c[t.track]}),x++,h.push(i)}}const N=new Map(Z(e).filter(t=>t._virtual).map(t=>[t.id,t])),_=[];for(const t of d)_.push({clip:t,as:t});for(const t of tt(h))O.has(String(t._virtual))&&_.push({clip:N.get(t.id)??{...e.find(a=>a.id===t._virtual),...t,_still:!0},as:t});const w=d.some(t=>t.mask||t.person)?await et(()=>import("./rotoMatte-013RKqHu.js").then(t=>t.r),__vite__mapDeps([0,1,2,3])):null;w&&await w.prepareMattes(d.filter(t=>t.mask||t.person));const W=w?document.createElement("canvas"):null,T=at(),I=[],S=new Map,C=async t=>{const a=new rt({source:new it(t),formats:nt});I.push(a);const i=await a.getPrimaryVideoTrack();return i?new st(i):null},U=async t=>{let a=S.get(t);return a||(a=await createImageBitmap(await(await fetch(t,{signal:l})).blob(),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"}),S.set(t,a)),a};try{for(const{clip:t,as:a}of _){A();const i=e.find(o=>o.id===(t._virtual??t.id)),k=Math.ceil(a.duration*v),m=i.distort,$=!!(t._still||t.freeze),q=o=>{const r=o/v,u=t.playbackRate||1;return t.reverse?Math.max(0,(t.inPoint||0)+Math.max(0,t.duration-r-1/v)*u):ot(t,r,!1,$).source};let g=null,b=null;if(t.kind==="video"){const o=await C(t.url);o&&(g=o.samplesAtTimestamps(Array.from({length:k},(r,u)=>q(u))))}else b=await U(t.url);const s=m.displace?e.find(o=>o.id===m.displace.map):void 0,V=s?.kind==="video"?await C(s.url):null,L=s?.kind==="image"&&s.url&&!R(s)?await U(s.url):null,G=async o=>{if(!s||o<s.start||o>=s.start+s.duration)return null;if(L)return{source:L};if(!V)return null;const r=await V.getSample((s.inPoint||0)+(o-s.start)*(s.playbackRate||1));if(!r)return null;const u=r.toVideoFrame();return r.close(),{source:u,close:()=>u.close()}},K=mt(i,e);for(let o=0;o<k;o++){A();const r=g?(await g.next()).value??null:null;if(K&&o>0){r?.close(),await n.push("titleFrames",a.id,"=");continue}const u=r?r.toVideoFrame():null,H=u??b,y=r?r.displayWidth:b?.width??0,M=r?r.displayHeight:b?.height??0;if(!H||!y||!M){if(u?.close(),r?.close(),o===0)throw Error(`No picture for ${i.label||i.id}`);await n.push("titleFrames",a.id,"=");continue}const f=t.crop||{left:0,right:0,top:0,bottom:0},X=Math.floor(y*f.left/2)*2,j=Math.floor(M*f.top/2)*2,E=Math.max(2,Math.floor(y*(1-f.left-f.right)/2)*2),F=Math.max(2,Math.floor(M*(1-f.top-f.bottom)/2)*2),z=Math.min(1,dt/Math.max(E,F)),P=o/v,B=await G(t.start+P),J=T.render({source:H,srcW:y,srcH:M,rect:[X,j,E,F],outW:Math.max(2,Math.round(E*z)),outH:Math.max(2,Math.round(F*z)),distort:m,local:t.start+P-i.start,map:B?.source??null,matte:w&&(t.mask||t.person)?w.matteCanvas(t,P,W,!1,e):null});B?.close?.(),u?.close(),r?.close(),await n.push("titleFrames",a.id,await ut(J))}g&&await g.return(void 0)}}finally{T.dispose();for(const t of S.values())t.close();for(const t of I)t.dispose?.()}return{clips:h,tracks:D}}export{wt as distortForServer};
@@ -1,4 +1,4 @@
1
- import{lH as H,c2 as K,lI as $}from"./titleFrameBudget-BjW--v_T.js";const z=`#version 300 es
1
+ import{lL as H,c2 as K,lM as $}from"./titleFrameBudget-Cml-MO53.js";const z=`#version 300 es
2
2
  in vec4 a;uniform vec4 crop;out vec2 uv;out vec2 tc;
3
3
  void main(){tc=a.zw;uv=crop.xy+a.zw*crop.zw;gl_Position=vec4(a.x*2.-1.,a.y*2.-1.,0,1);}`,j=`#version 300 es
4
4
  precision highp float;in vec2 uv;in vec2 tc;uniform sampler2D src;uniform sampler2D matte;uniform float useMatte;out vec4 o;
@@ -9,4 +9,4 @@ uniform vec2 amount;uniform float rg;out vec4 o;
9
9
  void main(){vec2 s=uv;if(useLiq>.5)s+=texture(liq,uv).rg;
10
10
  if(useMap>.5){vec4 m=texture(map,uv);float l=dot(m.rgb,vec3(.2126,.7152,.0722));vec2 v=rg>.5?m.rg:vec2(l);s+=(v-.5)*2.*amount;}
11
11
  if(any(lessThan(s,vec2(0)))||any(greaterThan(s,vec2(1)))){o=vec4(0);return;}
12
- o=texture(pic,s);}`;function Z(){const r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(2,2),e=r.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:!0,alpha:!0,antialias:!1});if(!e)throw Error("WebGL2 unavailable");const a=(t,s)=>{const o=e.createProgram();for(const[m,v]of[[e.VERTEX_SHADER,t],[e.FRAGMENT_SHADER,s]]){const u=e.createShader(m);if(e.shaderSource(u,v),e.compileShader(u),!e.getShaderParameter(u,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(u)||"shader");e.attachShader(o,u)}if(e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw Error(e.getProgramInfoLog(o)||"link");return o},n=a(z,j),T=a(J,Q),R=()=>{const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);for(const[s,o]of[[e.TEXTURE_MIN_FILTER,e.LINEAR],[e.TEXTURE_MAG_FILTER,e.LINEAR],[e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE],[e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE]])e.texParameteri(e.TEXTURE_2D,s,o);return t},h=R(),L=R(),D=R(),x=R(),S=R(),I=e.createFramebuffer();let P="",w="";const i=$,d=new Float32Array((i+1)*(i+1)*4),y=new Uint16Array(i*i*6);for(let t=0,s=0;t<i;t++)for(let o=0;o<i;o++){const m=t*(i+1)+o,v=m+1,u=m+i+1,_=u+1;y.set([m,v,u,v,_,u],s),s+=6}const N=e.createVertexArray(),G=e.createBuffer(),q=e.createBuffer();e.bindVertexArray(N),e.bindBuffer(e.ARRAY_BUFFER,G),e.bufferData(e.ARRAY_BUFFER,d.byteLength,e.DYNAMIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q),e.bufferData(e.ELEMENT_ARRAY_BUFFER,y,e.STATIC_DRAW);const X=e.getAttribLocation(n,"a");e.enableVertexAttribArray(X),e.vertexAttribPointer(X,4,e.FLOAT,!1,16,0);const C=e.createVertexArray(),Y=e.createBuffer();e.bindVertexArray(C),e.bindBuffer(e.ARRAY_BUFFER,Y),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW);const O=e.getAttribLocation(T,"p");e.enableVertexAttribArray(O),e.vertexAttribPointer(O,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const B=(t,s,o)=>{e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,s),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o)};return{canvas:r,render(t){const s=Math.max(1,Math.round(t.outW)),o=Math.max(1,Math.round(t.outH));(r.width!==s||r.height!==o)&&(r.width=s,r.height=o),P!==`${s}x${o}`&&(e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_2D,S),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,s,o,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindFramebuffer(e.FRAMEBUFFER,I),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,S,0),P=`${s}x${o}`);const[m,v,u,_]=t.rect,k=u/Math.max(1,_),g=H(t.distort,t.local,k,i);for(let l=0;l<=i;l++)for(let E=0;E<=i;E++){const c=l*(i+1)+E;d[c*4]=g?g[c*2]:E/i,d[c*4+1]=g?g[c*2+1]:l/i,d[c*4+2]=E/i,d[c*4+3]=l/i}B(0,h,t.source),t.matte&&B(1,L,t.matte),e.bindFramebuffer(e.FRAMEBUFFER,I),e.viewport(0,0,s,o),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(n),e.bindVertexArray(N),e.bindBuffer(e.ARRAY_BUFFER,G),e.bufferSubData(e.ARRAY_BUFFER,0,d),e.uniform4f(e.getUniformLocation(n,"crop"),m/t.srcW,v/t.srcH,u/t.srcW,_/t.srcH),e.uniform1i(e.getUniformLocation(n,"src"),0),e.uniform1i(e.getUniformLocation(n,"matte"),1),e.uniform1f(e.getUniformLocation(n,"useMatte"),t.matte?1:0),e.drawElements(e.TRIANGLES,y.length,e.UNSIGNED_SHORT,0);const f=t.distort.liquify,b=t.distort.displace;if(f&&w!==f.f){const l=atob(f.f),E=new Float32Array(f.n*f.n*2);for(let c=0;c<E.length;c++){const M=l.charCodeAt(c);E[c]=(M>127?M-256:M)*.25/127}e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,x),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG16F,f.n,f.n,0,e.RG,e.FLOAT,E),e.pixelStorei(e.UNPACK_ALIGNMENT,4),w=f.f}const U=b?K(b,t.local):{x:0,y:0},W=!!(b&&t.map&&(U.x||U.y));W&&B(3,D,t.map),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,s,o),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(T),e.bindVertexArray(C),e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_2D,S),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,x);const A=l=>e.getUniformLocation(T,l);return e.uniform1i(A("pic"),4),e.uniform1i(A("liq"),2),e.uniform1i(A("map"),3),e.uniform1f(A("useLiq"),f?1:0),e.uniform1f(A("useMap"),W?1:0),e.uniform2f(A("amount"),U.x/Math.max(1,u),U.y/Math.max(1,_)),e.uniform1f(A("rg"),b?.channel==="rg"?1:0),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindVertexArray(null),r},dispose(){e.getExtension("WEBGL_lose_context")?.loseContext()}}}let F=null;const V=new Set;function re(r,e,a,n,T,R,h,L,D){if(F===!1||!r.distort)return null;try{F??=Z()}catch{return F=!1,null}try{return F.render({source:e,srcW:a,srcH:n,rect:T,outW:L,outH:D,distort:r.distort,local:R,map:h})}catch(x){return V.has(r.id)||(V.add(r.id),console.warn("[distort] preview skipped",r.id,x.message)),null}}const p=new Map;function te(r,e){if(!r||r.disabled||e<r.start||e>=r.start+r.duration)return null;if(r.kind==="video"){const a=document.querySelector(`video[data-clip-media="${CSS.escape(r.id)}"]`);if(a&&a.readyState>=2)return a;let n=p.get(r.url);n||(n=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous",src:r.url}),p.set(r.url,n));const T=(r.inPoint||0)+(e-r.start)*(r.playbackRate||1);return Math.abs(n.currentTime-T)>.04&&!n.seeking&&(n.currentTime=T),n.readyState>=2?n:null}if(r.kind==="image"&&r.url){let a=p.get(r.url);return a||(a=new Image,r.url.startsWith("data:")||(a.crossOrigin="anonymous"),a.src=r.url,p.set(r.url,a)),a.complete&&a.naturalWidth?a:null}return null}export{Z as c,re as d,te as m};
12
+ o=texture(pic,s);}`;function Z(){const r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(2,2),e=r.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:!0,alpha:!0,antialias:!1});if(!e)throw Error("WebGL2 unavailable");const a=(t,s)=>{const o=e.createProgram();for(const[m,v]of[[e.VERTEX_SHADER,t],[e.FRAGMENT_SHADER,s]]){const u=e.createShader(m);if(e.shaderSource(u,v),e.compileShader(u),!e.getShaderParameter(u,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(u)||"shader");e.attachShader(o,u)}if(e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw Error(e.getProgramInfoLog(o)||"link");return o},n=a(z,j),T=a(J,Q),R=()=>{const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);for(const[s,o]of[[e.TEXTURE_MIN_FILTER,e.LINEAR],[e.TEXTURE_MAG_FILTER,e.LINEAR],[e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE],[e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE]])e.texParameteri(e.TEXTURE_2D,s,o);return t},h=R(),L=R(),D=R(),x=R(),S=R(),P=e.createFramebuffer();let I="",w="";const i=$,d=new Float32Array((i+1)*(i+1)*4),y=new Uint16Array(i*i*6);for(let t=0,s=0;t<i;t++)for(let o=0;o<i;o++){const m=t*(i+1)+o,v=m+1,u=m+i+1,_=u+1;y.set([m,v,u,v,_,u],s),s+=6}const N=e.createVertexArray(),G=e.createBuffer(),q=e.createBuffer();e.bindVertexArray(N),e.bindBuffer(e.ARRAY_BUFFER,G),e.bufferData(e.ARRAY_BUFFER,d.byteLength,e.DYNAMIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,q),e.bufferData(e.ELEMENT_ARRAY_BUFFER,y,e.STATIC_DRAW);const X=e.getAttribLocation(n,"a");e.enableVertexAttribArray(X),e.vertexAttribPointer(X,4,e.FLOAT,!1,16,0);const C=e.createVertexArray(),Y=e.createBuffer();e.bindVertexArray(C),e.bindBuffer(e.ARRAY_BUFFER,Y),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW);const O=e.getAttribLocation(T,"p");e.enableVertexAttribArray(O),e.vertexAttribPointer(O,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const M=(t,s,o)=>{e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,s),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o)};return{canvas:r,render(t){const s=Math.max(1,Math.round(t.outW)),o=Math.max(1,Math.round(t.outH));(r.width!==s||r.height!==o)&&(r.width=s,r.height=o),I!==`${s}x${o}`&&(e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_2D,S),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,s,o,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindFramebuffer(e.FRAMEBUFFER,P),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,S,0),I=`${s}x${o}`);const[m,v,u,_]=t.rect,k=u/Math.max(1,_),g=H(t.distort,t.local,k,i);for(let l=0;l<=i;l++)for(let E=0;E<=i;E++){const c=l*(i+1)+E;d[c*4]=g?g[c*2]:E/i,d[c*4+1]=g?g[c*2+1]:l/i,d[c*4+2]=E/i,d[c*4+3]=l/i}M(0,h,t.source),t.matte&&M(1,L,t.matte),e.bindFramebuffer(e.FRAMEBUFFER,P),e.viewport(0,0,s,o),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(n),e.bindVertexArray(N),e.bindBuffer(e.ARRAY_BUFFER,G),e.bufferSubData(e.ARRAY_BUFFER,0,d),e.uniform4f(e.getUniformLocation(n,"crop"),m/t.srcW,v/t.srcH,u/t.srcW,_/t.srcH),e.uniform1i(e.getUniformLocation(n,"src"),0),e.uniform1i(e.getUniformLocation(n,"matte"),1),e.uniform1f(e.getUniformLocation(n,"useMatte"),t.matte?1:0),e.drawElements(e.TRIANGLES,y.length,e.UNSIGNED_SHORT,0);const f=t.distort.liquify,b=t.distort.displace;if(f&&w!==f.f){const l=atob(f.f),E=new Float32Array(f.n*f.n*2);for(let c=0;c<E.length;c++){const B=l.charCodeAt(c);E[c]=(B>127?B-256:B)*.25/127}e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,x),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG16F,f.n,f.n,0,e.RG,e.FLOAT,E),e.pixelStorei(e.UNPACK_ALIGNMENT,4),w=f.f}const U=b?K(b,t.local):{x:0,y:0},W=!!(b&&t.map&&(U.x||U.y));W&&M(3,D,t.map),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,s,o),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(T),e.bindVertexArray(C),e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_2D,S),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,x);const A=l=>e.getUniformLocation(T,l);return e.uniform1i(A("pic"),4),e.uniform1i(A("liq"),2),e.uniform1i(A("map"),3),e.uniform1f(A("useLiq"),f?1:0),e.uniform1f(A("useMap"),W?1:0),e.uniform2f(A("amount"),U.x/Math.max(1,u),U.y/Math.max(1,_)),e.uniform1f(A("rg"),b?.channel==="rg"?1:0),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindVertexArray(null),r},dispose(){e.getExtension("WEBGL_lose_context")?.loseContext()}}}let F=null;const V=new Set;function re(r,e,a,n,T,R,h,L,D){if(F===!1||!r.distort)return null;try{F??=Z()}catch{return F=!1,null}try{return F.render({source:e,srcW:a,srcH:n,rect:T,outW:L,outH:D,distort:r.distort,local:R,map:h})}catch(x){return V.has(r.id)||(V.add(r.id),console.warn("[distort] preview skipped",r.id,x.message)),null}}const p=new Map;function te(r,e){if(!r||r.disabled||e<r.start||e>=r.start+r.duration)return null;if(r.kind==="video"){const a=document.querySelector(`video[data-clip-media="${CSS.escape(r.id)}"]`);if(a&&a.readyState>=2)return a;let n=p.get(r.url);n||(n=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous",src:r.url}),p.set(r.url,n));const T=(r.inPoint||0)+(e-r.start)*(r.playbackRate||1);return Math.abs(n.currentTime-T)>.04&&!n.seeking&&(n.currentTime=T),n.readyState>=2?n:null}if(r.kind==="image"&&r.url){let a=p.get(r.url);return a||(a=new Image,r.url.startsWith("data:")||(a.crossOrigin="anonymous"),a.src=r.url,p.set(r.url,a)),a.complete&&a.naturalWidth?a:null}return null}export{Z as c,re as d,te as m};
@@ -0,0 +1 @@
1
+ import{gE as gt,iQ as tt,fi as te,fW as Ht,iR as Jt,dz as bt,f$ as kt,g0 as _t,iS as zt,fY as Tt,g8 as ee,iT as oe,iU as Ct,g4 as Ft,g7 as wt,gc as ne,g5 as Ut,ga as ae,g3 as ie,iV as re}from"./remote-BJdzzFZg.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.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??Ht.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}:{}},J=Math.max(0,u-m),ot=n==="after"?r:Math.min(r,i+(k??m)),ct=Math.min(Jt.samples,Math.max(2,Math.ceil((ot-J)*24)+1)),Mt=s.filter(O=>O.id!==p?.id),W={...c,motionEdits:{...c.motionEdits,[o.id]:Mt}},B=[],nt=[];for(let O=0;O<ct;O++){const H=J+(ot-J)*O/(ct-1),q=H/Math.max(1e-6,r),at=bt(o,W,q,f.items),C=bt(h,W,q,f.items),L=((Math.atan2(C.position[0]-at.position[0],C.position[2]-at.position[2])*180/Math.PI-(at.rotation[1]||0))%360+540)%360-180;B.push(Math.round(H*1e3)/1e3),nt.push(kt(y,H)*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}`)},T=_t(s,Q,r),Y=T.find(O=>O.id===Q.id);return Y?(g(T),{ok:!0,name:o.name,edit:pt(Y,e),edits:T.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&&!Tt.some(h=>h.id===P.id))return{ok:!1,error:`unknown preset; use one of ${Tt.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),A=E.find(h=>h.id===j.id);return A?(g(E),{ok:!0,name:o.name,edit:pt(A,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 Wt(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 Vt(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=Vt(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,A)=>A[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 ge(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])=>[$,Vt(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 A of["head","chest","hips"]){const h=d.joints[E],N=A==="head"?j.headCentre:j.joints[A];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(A)*j.height/1.8;y<.45&&b.push({joint:E,other:$.name,part:A,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 ${Ct.join(", ")}`};const e=s?.part??String(t.part??"");if(!Ft.includes(e))return{ok:!1,error:`give control (${Ct.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,R=I+et.tip(e);if(R>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*R,i[1]+w[1]/x*R,i[2]+w[2]/x*R])}}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(R=>Number.isFinite(Number(R))))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 R=[i[0]-u[0],i[1]-u[1],i[2]-u[2]];return Math.hypot(...R)>.001?R: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 A=$||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&&!A&&!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,J=!!(c.objectKeys?.[o.id]?.length||c.clipSpans?.[o.id]?.length),ot=!!i&&J&&N==="moment"&&t.path!==!1&&(k||b),ct=Number(t.fade??.6),Mt=Number(t.fade_out??.5),W=Math.max(0,n-ct-.25),B=Math.min(y,n+Mt+.25),nt=Math.max(4,Math.round((B-W)*24)+1),Q=Array.from({length:nt},(l,_)=>W+(B-W)*_/(nt-1)),T=Wt(r.jointPath(o.id,e,Q),(B-W)/(Q.length-1));let Y=null,O=u,H=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],R=x=>{const U=r.jointPath(o.id,x,I);return U.every(Boolean)?U.slice(1).reduce((st,X,dt)=>st+Math.hypot(X[0]-U[dt][0],X[2]-U[dt][2]),0):1/0},z=v.sort((x,U)=>R(x)-R(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],X=i[2]-w[2],dt=Math.hypot(x,U),mt=Math.hypot(st,X);if(dt>.12&&mt>.12){const lt=Math.max(-120,Math.min(120,((Math.atan2(st,X)-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)),Yt=st/mt,qt=X/mt;if(Math.abs($t-Z)>.12&&(H=S($t-Z)),Math.abs(lt)>2||Math.abs(Z)>.02){const Nt={scope:"after",start:M,end:M,fade:Math.max(Ht.min,M-_)},Gt=Math.max(1/24,(y-_)/(Jt.samples-2)),Ot=[],Et=[],Lt=[],Rt=[],Xt={...c,motionEdits:{...c.motionEdits,[o.id]:c.motionEdits?.[o.id]||[]}};for(let D=_;D<=y+1e-6;D+=Gt){const K=kt(Nt,D),ht=K*lt*Math.PI/180,ut=bt(o,Xt,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*Yt),Rt.push(w[2]-It*Math.sin(ht)+Dt*Math.cos(ht)-ut[2]+K*Z*qt)}const Zt=a.getStage().shots.find(D=>D.id===c.id)?.motionEdits?.[o.id]||[],At={id:crypto.randomUUID(),scope:"after",start:M,end:M,fade:Nt.fade,track:{t:Ot,turn:Et,mx:Lt,mz:Rt},label:`${e}: align the strike`},Pt=_t(Zt,At,y);Pt.some(D=>D.id===At.id)&&(a.setStage(D=>({...D,shots:D.shots.map(K=>K.id===c.id?{...K,motionEdits:{...K.motionEdits,[o.id]:Pt}}:K)})),Y={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 q=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&&(q=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,C=Number(t.fade??Math.min(.7,.45+.4*at)),it=Number(t.fade_out??Math.max(.35,C*.8)),L=h&&!i?(()=>{const l=r.rollFootAt(n,o.id,e,h,_=>({id:"__drag",scope:"moment",start:n,end:n,fade:C,..._}));return l?{fields:l.fields,miss:l.pivotMove,from:u,aimError:null}:null})():i||A?r.solveJointAt(n,o.id,e,i,l=>({id:"__drag",scope:"moment",start:n,end:n,fade:C,...l}),A,{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 V=L.fields,yt=E?ne(bt(o,c,c.duration?n/c.duration:0,f.items).pose,m,E)??{}:{},vt={...V.pose||{},...yt},St=[i?`→ ${i.map(l=>S(l)).join(", ")}`:"",A?"turned":"",E??""].filter(Boolean).join(" "),jt=!!i&&J&&N==="moment"&&t.path!==!1&&!["hips","head"].includes(e);let rt;if(jt){const l=Object.fromEntries(Object.entries(V.pose||{}).filter(([w])=>/^(wrist|ankle)/.test(w))),_={scope:"moment",start:n,end:n,fade:C,fadeOut:it},M=r.bakeJointPath(n,o.id,e,i,w=>kt(_,w),[n-C,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:C,fadeOut:it,track:M.track,label:String(t.label??`${e} ${St} (path)`)},R=_t(v,I,y),z=R.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]:R}}:x)})),L.miss=M.miss,rt={ok:!0,name:o.name,edit:pt(z,n),edits:R.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:C,fade_out:it,...t.start!=null?{start:t.start}:{},...t.end!=null?{end:t.end}:{},...Object.keys(vt).length?{joints:vt}:{},...V.move?{move_m:[V.move[0],V.move[2]]}:{},...V.stance?{stance:V.stance}:{},label:String(t.label??`${e} ${St}`)},a);if(!rt.ok)return rt;r.sync(a.getStage(),null);const G=Wt(r.jointPath(o.id,e,Q),(B-W)/(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 (${J?"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`)}H&&(F+=`${F?"; ":""}the fighters stand ${Math.abs(H)} m too ${H>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=T&&G?{peak_speed_m_s:[T.speed,G.speed],peak_jerk:[T.jerk,G.jerk],jerk_change_pct:Math.round((G.jerk-T.jerk)/Math.max(1,T.jerk)*100)}:null;return ft&&G.jerk>T.jerk*1.5&&G.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"}:{},...Y?{aligned:Y}:{},...q?{lowered_crouch:q}:{},...ft?{smoothness:ft}:{},...F?{warning:F}:{}}}function Me(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 je(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,ge as inspectPose,Me as landBlows,de as moveJoint,je as poseKey,Qt as strikesOf};
@@ -1 +1 @@
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
+ import{bS as $,bT as C}from"./api-QBI5GJTZ.js";import{lF as T,lG as q,hG as O,hH as _,lH as G,ai as D,lv as N}from"./titleFrameBudget-Cml-MO53.js";const A=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=A.taps)=>Array.from({length:n},(o,e)=>1+t*e/(n-1));function K(t){const n=+(A.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,E=m+x*L+.5,F=i+M*L+.5;if(E>=0&&F>=0&&E<=e-1&&F<=r-1)for(let g=0;g<4;g++)h[y+g]=b(a,e,r,E,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=A.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,A.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=O(_(await t.text())),o=(n.title||t.name.replace(/\.cube$/i,"")).slice(0,80),e=await C({name:o,...G(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=$(t).then(o=>{const e=T(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=q(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,A as L,tt as a,H as b,W as c,v as d,ot as e,rt as f,nt as g,Y as h,et as i,I as l,j as z};
@@ -0,0 +1,2 @@
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-Cml-MO53.js";import{dU as x}from"./remote-BJdzzFZg.js";import{Mesh as g,Color as D,CanvasTexture as y,SRGBColorSpace as M,NoColorSpace as _}from"./three.module-Bx43vjkH.js";import"./api-QBI5GJTZ.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.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 R(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{R as recipeGlb};
@@ -0,0 +1 @@
1
+ import{no as I,_ as N}from"./titleFrameBudget-Cml-MO53.js";import{a5 as B}from"./main-CVRIuDW2.js";import{t as S}from"./api-QBI5GJTZ.js";import"./remote-BJdzzFZg.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";const _=n=>+n.toFixed(4);function V(n){const i=n.length,h=n.map(e=>!!e),o=n.map((e,t)=>{if(e)return e.slice();for(let r=1;r<i;r++){const u=n[t-r],l=n[t+r];if(u)return[0,...u.slice(1)];if(l)return[0,...l.slice(1)]}return null});if(!o.some(Boolean))return[];const a=[];for(let e=0;e<i;e++){let t=0;const r=new Array(10).fill(0);let u=0,l=0;for(let d=-2;d<=2;d++){const s=e+d;if(s<0||s>=i)continue;const c=o[s],f=(h[s]?1:.15)*(3-Math.abs(d));t+=f;for(let w=0;w<10;w++)r[w]+=c[w+1]*f;u+=h[s]?c[0]:0,l++}const m=h[e]?n[e][0]:0;a.push([_(Math.min(m,u/l*1.25)),...r.map(d=>_(d/t))])}return a}const T=180/Math.PI;function R(n,i,h){const o=p=>[n[p][0]*i,n[p][1]*h,n[p][2]*i],a=(p,b)=>{const M=o(p),x=o(b);return[(M[0]+x[0])/2,(M[1]+x[1])/2,(M[2]+x[2])/2]},e=(p,b)=>[p[0]-b[0],p[1]-b[1],p[2]-b[2]],t=p=>Math.hypot(p[0],p[1],p[2]),r=a(33,133),u=a(362,263),l=Math.atan2(u[1]-r[1],u[0]-r[0]),m=p=>{const b=Math.cos(-l),M=Math.sin(-l);return[p[0]*b-p[1]*M,p[0]*M+p[1]*b,p[2]]},d=e(o(454),o(234)),s=e(o(152),o(10)),c=m(d),f=m(s),w=[(o(234)[0]+o(454)[0])/2,(o(10)[1]+o(152)[1])/2,(o(234)[2]+o(454)[2])/2];return{cx:w[0],cy:w[1],cz:w[2],w:t(d),h:t(s),roll:l*T,yaw:Math.atan2(c[2],c[0])*T,pitch:Math.atan2(-f[2],f[1])*T,eyes:[r,u],mouth:a(13,14)}}function U(n,i,h){const o=R(n,i,h),a=Math.PI/180,[e,t,r]=[-o.pitch*a,-o.yaw*a,-o.roll*a];return n.slice(0,468).map(u=>{let l=u[2]*i-o.cz;const m=(5*o.w+l)/(5*o.w);let d=(u[0]*i-o.cx)*m,s=(u[1]*h-o.cy)*m;return[d,s]=[d*Math.cos(r)-s*Math.sin(r),d*Math.sin(r)+s*Math.cos(r)],[d,l]=[d*Math.cos(t)-l*Math.sin(t),d*Math.sin(t)+l*Math.cos(t)],[s,l]=[s*Math.cos(e)+l*Math.sin(e),-s*Math.sin(e)+l*Math.cos(e)],[d/o.w,s/o.w,l/o.w]})}function H(n){const i=n.map(e=>({f:e,p:R(e.L,e.M,e.N)})),h=i.filter(e=>Math.abs(e.p.yaw)<25&&Math.abs(e.p.pitch)<25),o=(h.length?h:i).sort((e,t)=>Math.abs(e.p.yaw)+Math.abs(e.p.pitch)-Math.abs(t.p.yaw)-Math.abs(t.p.pitch)).slice(0,40),a=new Array(468*3).fill(0);for(const{f:e}of o)U(e.L,e.M,e.N).forEach((t,r)=>{a[r*3]+=t[0],a[r*3+1]+=t[1],a[r*3+2]+=t[2]});return a.map(e=>+(e/o.length).toFixed(3))}function G(n){const i=V(n.map(e=>e?e.slice(0,11):null));if(!i.length)return[];const h=n.length,o=n.map(e=>!!e),a=(e,t)=>{if(n[e])return n[e][t];for(let r=1;r<h;r++){const u=n[e-r],l=n[e+r];if(u)return u[t];if(l)return l[t]}return 0};return i.map((e,t)=>{const r=[11,12,13].map(u=>{let l=0,m=0;for(let d=-2;d<=2;d++){const s=t+d;if(s<0||s>=h)continue;const c=(o[s]?1:.15)*(3-Math.abs(d));l+=a(s,u)*c,m+=c}return+(l/m).toFixed(2)});return[...e,...r]})}function X(n){const i=n.map(a=>a.slice()),h=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];for(let a=0;a<50;a++){let e=0;for(let t=0;t<4;t++)for(let r=t+1;r<4;r++)e+=i[t][r]*i[t][r];if(e<1e-18)break;for(let t=0;t<4;t++)for(let r=t+1;r<4;r++){if(Math.abs(i[t][r])<1e-20)continue;const u=(i[r][r]-i[t][t])/(2*i[t][r]),l=Math.sign(u||1)/(Math.abs(u)+Math.sqrt(u*u+1)),m=1/Math.sqrt(l*l+1),d=l*m;for(let s=0;s<4;s++){const c=i[s][t],f=i[s][r];i[s][t]=m*c-d*f,i[s][r]=d*c+m*f}for(let s=0;s<4;s++){const c=i[t][s],f=i[r][s];i[t][s]=m*c-d*f,i[r][s]=d*c+m*f}for(let s=0;s<4;s++){const c=h[s][t],f=h[s][r];h[s][t]=m*c-d*f,h[s][r]=d*c+m*f}}}let o=0;for(let a=1;a<4;a++)i[a][a]>i[o][o]&&(o=a);return h.map(a=>a[o])}function $(n,i){const h=n.length,o=[0,0,0],a=[0,0,0];for(let g=0;g<h;g++)for(let E=0;E<3;E++)o[E]+=n[g][E]/h,a[E]+=i[g][E]/h;const e=[[0,0,0],[0,0,0],[0,0,0]];let t=0,r=0;for(let g=0;g<h;g++){const E=[0,1,2].map(D=>n[g][D]-o[D]),O=[0,1,2].map(D=>i[g][D]-a[D]);for(let D=0;D<3;D++)for(let z=0;z<3;z++)e[D][z]+=E[D]*O[z];t+=E[0]*E[0]+E[1]*E[1]+E[2]*E[2],r+=O[0]*O[0]+O[1]*O[1]+O[2]*O[2]}const[[u,l,m],[d,s,c],[f,w,p]]=e,b=[[u+s+p,c-w,f-m,l-d],[c-w,u-s-p,l+d,f+m],[f-m,l+d,-u+s-p,c+w],[l-d,f+m,c+w,-u-s+p]],[M,x,y,k]=X(b),F=[[M*M+x*x-y*y-k*k,2*(x*y-M*k),2*(x*k+M*y)],[2*(x*y+M*k),M*M-x*x+y*y-k*k,2*(y*k-M*x)],[2*(x*k-M*y),2*(y*k+M*x),M*M-x*x-y*y+k*k]],v=Math.sqrt(r/Math.max(1e-12,t)),A=[0,1,2].map(g=>a[g]-v*(F[g][0]*o[0]+F[g][1]*o[1]+F[g][2]*o[2]));return{R:F,s:v,t:A}}function Y(n){const i=Math.asin(Math.max(-1,Math.min(1,n[2][0])));return{pitch:Math.atan2(-n[2][1],n[2][2])*T,yaw:i*T,roll:Math.atan2(n[1][0],n[0][0])*T}}const q=n=>{const i=[];for(let h=0;h<n.length;h+=3)i.push([n[h],n[h+1],n[h+2]]);return i};function j(n,i,h,o){const a=R(n,i,h),e=q(o),t=5*a.w,r=n.slice(0,468).map(w=>{const p=w[2]*i-a.cz,b=(t+p)/t;return[a.cx+(w[0]*i-a.cx)*b,a.cy+(w[1]*h-a.cy)*b,p]}),{R:u,s:l,t:m}=$(e,r),d=Y(u),s=e[10],c=e[152],f=Math.hypot(c[0]-s[0],c[1]-s[1],c[2]-s[2])*l;return{cx:m[0],cy:m[1],w:l,h:f,...d,eyes:a.eyes,mouth:a.mouth}}function J(n,i,h,o){const a=R(n,i,h),e=5*o.w,t=Math.PI/180,[r,u,l]=[-o.pitch*t,-o.yaw*t,-o.roll*t];return n.slice(0,468).map(m=>{let d=m[2]*i-a.cz;const s=(e+d)/e;let c=(m[0]*i-a.cx)*s+a.cx-o.cx,f=(m[1]*h-a.cy)*s+a.cy-o.cy;return[c,f]=[c*Math.cos(l)-f*Math.sin(l),c*Math.sin(l)+f*Math.cos(l)],[c,d]=[c*Math.cos(u)-d*Math.sin(u),c*Math.sin(u)+d*Math.cos(u)],[f,d]=[f*Math.cos(r)+d*Math.sin(r),-f*Math.sin(r)+d*Math.cos(r)],[c/o.w,f/o.w,d/o.w]})}function Z(n){const i=n.filter(Boolean);if(!i.length)return{rows:n.map(()=>null),mesh:null};let h=H(i);for(let e=0;e<2;e++){const t=i.map(c=>({f:c,p:j(c.L,c.M,c.N,h)})),r=t.filter(c=>Math.abs(c.p.yaw)<25&&Math.abs(c.p.pitch)<25),u=(r.length?r:t).sort((c,f)=>Math.abs(c.p.yaw)+Math.abs(c.p.pitch)-Math.abs(f.p.yaw)-Math.abs(f.p.pitch)).slice(0,40),l=new Array(468*3).fill(0);for(const{f:c,p:f}of u)J(c.L,c.M,c.N,f).forEach((w,p)=>{l[p*3]+=w[0],l[p*3+1]+=w[1],l[p*3+2]+=w[2]});const m=q(l.map(c=>c/u.length)),d=[(m[234][0]+m[454][0])/2,(m[10][1]+m[152][1])/2,(m[234][2]+m[454][2])/2],s=Math.hypot(m[454][0]-m[234][0],m[454][1]-m[234][1],m[454][2]-m[234][2]);h=m.flatMap(c=>[0,1,2].map(f=>+((c[f]-d[f])/s).toFixed(3)))}const o=e=>Math.max(-89,Math.min(89,e));return{rows:n.map(e=>{if(!e)return null;const t=j(e.L,e.M,e.N,h),{M:r,N:u}=e;return[1,_(t.cx/r),_(t.cy/u),_(t.w/r),_(t.h/u),_(t.eyes[0][0]/r),_(t.eyes[0][1]/u),_(t.eyes[1][0]/r),_(t.eyes[1][1]/u),_(t.mouth[0]/r),_(t.mouth[1]/u),+o(t.yaw).toFixed(2),+o(t.pitch).toFixed(2),+t.roll.toFixed(2)]}),mesh:h}}const K=`https://cdn.jsdelivr.net/npm/@mediapipe/tasks-vision@${B}/wasm`,Q="/models/blaze_face_short_range.tflite",tt=640,W=10;let L=null;function nt(){if(typeof window<"u"&&window.__faceDetectorStub){const n=window.__faceDetectorStub;return Promise.resolve(n)}return L??=(async()=>{const{FilesetResolver:n,FaceDetector:i}=await N(async()=>{const{FilesetResolver:a,FaceDetector:e}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:a,FaceDetector:e}},[]),h=await n.forVisionTasks(K),o=await i.createFromOptions(h,{baseOptions:{modelAssetPath:Q,delegate:"CPU"},runningMode:"VIDEO",minDetectionConfidence:.5});return(a,e)=>o.detectForVideo(a,e).detections.map(t=>{const r=t.boundingBox,u=a.width,l=a.height;return{x:r.originX/u,y:r.originY/l,w:r.width/u,h:r.height/l,score:t.categories[0]?.score??0,keypoints:t.keypoints.map(m=>({x:m.x,y:m.y}))}})})().catch(n=>{throw L=null,n}),L}const P=n=>+n.toFixed(4);function et(n,i){const h=n.filter(o=>o.keypoints.length>=4);if(!h.length)return null;if(i){const o=e=>Math.hypot(e.x+e.w/2-i[1],e.y+e.h/2-i[2]),a=h.reduce((e,t)=>o(e)<o(t)?e:t);if(o(a)<Math.max(i[3],i[4])*1.5)return a}return h.reduce((o,a)=>o.w*o.h>a.w*a.h?o:a)}const ot=n=>[P(Math.min(1,n.score)),P(n.x+n.w/2),P(n.y+n.h/2),P(n.w),P(n.h),P(n.keypoints[0].x),P(n.keypoints[0].y),P(n.keypoints[1].x),P(n.keypoints[1].y),P(n.keypoints[3].x),P(n.keypoints[3].y)];async function at({clip:n,url:i,fps:h=W,signal:o,onProgress:a}){if(n.kind!=="video")throw Error(S("Chỉ nhận diện khuôn mặt được trên clip video"));const e=await nt(),t=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});t.src=i;try{await new Promise((y,k)=>{t.onloadeddata=()=>y(),t.onerror=()=>k(Error(S("Không đọc được video để nhận diện khuôn mặt (CORS / định dạng)")))});const r=t.videoWidth,u=t.videoHeight,l=Math.min(tt,r),m=Math.max(2,Math.round(l*u/r)),d=n.inPoint||0,s=n.duration*(n.playbackRate||1);let c=h;for(;Math.ceil(s*c)+1>I&&c>.2;)c/=2;const f=Math.min(I,Math.max(1,Math.ceil(s*c)+1)),w=Object.assign(document.createElement("canvas"),{width:l,height:m}),p=w.getContext("2d",{willReadFrequently:!0}),b=[];let M=null;for(let y=0;y<f;y++){if(o?.aborted)throw new DOMException("Đã huỷ","AbortError");const k=Math.max(0,Math.min(t.duration-1/60,d+y/c));Math.abs(t.currentTime-k)>1e-4&&await new Promise((A,g)=>{const E=window.setTimeout(()=>g(Error(S("Seek video quá lâu"))),8e3);t.onseeked=()=>{window.clearTimeout(E),A()},t.currentTime=k}),p.drawImage(t,0,0,l,m);const F=et(e(w,y+1),M),v=F?ot(F):null;b.push(v),v&&(M=v),a?.({done:y+1,total:f}),y%4===3&&await new Promise(A=>setTimeout(A,0))}const x=V(b);if(!x.length)throw Error(S("Không thấy khuôn mặt nào trong clip này (cần mặt nhìn rõ, không quá nhỏ)."));return{v:1,mw:r,mh:u,fps:+c.toFixed(4),s0:+d.toFixed(4),n:x.length,f:x}}finally{t.removeAttribute("src"),t.load()}}const rt="/models/face_landmarker.task";let C=null;function it(){if(typeof window<"u"&&window.__faceLandmarkerStub){const n=window.__faceLandmarkerStub;return Promise.resolve(n)}return typeof window<"u"&&window.__faceDetectorStub?Promise.reject(Error("No 3D face model on this page")):(C??=(async()=>{const{FilesetResolver:n,FaceLandmarker:i}=await N(async()=>{const{FilesetResolver:a,FaceLandmarker:e}=await import("./vision_bundle-9zIsgJJP.js");return{FilesetResolver:a,FaceLandmarker:e}},[]),h=await n.forVisionTasks(K),o=await i.createFromOptions(h,{baseOptions:{modelAssetPath:rt,delegate:"CPU"},runningMode:"IMAGE",numFaces:3,minFaceDetectionConfidence:.35,minFacePresenceConfidence:.35});return a=>o.detect(a).faceLandmarks.map(e=>e.map(t=>[t.x,t.y,t.z]))})().catch(n=>{throw C=null,n}),C)}let ct=null;const zt=()=>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 It(n){try{return await lt(n)}catch(i){if(i.name==="AbortError")throw i;return at(n)}}export{zt as faceMeshEdges,ot as faceSample,et as pickFace,V as smoothFaces,at as trackFace,lt as trackFace3D,It as trackFaceBest};
@@ -0,0 +1 @@
1
+ import{fy as Q,gE as V,iW as tt,iX as T,iY as et,iZ as U,i_ as H,i$ as ot,j0 as st,j1 as it,dy as nt,is as at,hv as rt,j2 as ct,j3 as mt}from"./remote-BJdzzFZg.js";import{N as L}from"./rigTrack-CUt4O67J.js";import"./api-QBI5GJTZ.js";import"./titleFrameBudget-Cml-MO53.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";const ft=()=>crypto.randomUUID(),N=C=>Math.round(C*1e3)/1e3;function At(C,l){const F=Q(C,{fighters:l.fighters,start:l.start,end:l.end,focal_length_mm:l.focal_length_mm}),u=F.stage,k=V(u),c=k.duration,[h,g]=l.fighters.map(t=>u.items.find(e=>e.name===t)),{start:M,end:j}=F.result,b=tt(l.beats,M,j),R=t=>{const e=nt(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)}},W=(t,e)=>{const m=t.attacker===h.name?h:g,w=m===h?g:h,f=x(m,e),s=x(w,e),A=t.limb&&/^(hand|foot)[LR]$/.test(t.limb)?t.limb:"handR",i=ct(f.key,A,f.scale),n=mt(s.key,s.scale),p=n.head.a.map((P,G)=>P+(n.head.b[G]-P)*.75),a=s.key.position[0]-f.key.position[0],r=s.key.position[2]-f.key.position[2],o=Math.hypot(a,r)||1,d=[a/o,0,r/o],y=[d[2],0,-d[0]],_=R(e).position,E=(f.key.position[0]+s.key.position[0])/2,Z=(f.key.position[2]+s.key.position[2])/2,O=(_[0]-E)*y[0]+(_[2]-Z)*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:i,foot:A.startsWith("foot"),atk:f.key.position,def:s.key.position,defHead:p,defFace:q,axis:d,side:[y[0]*O,0,y[2]*O],sep:o}},I=(t,e)=>({id:ft(),time:t/c,position:e.position.map(N),target:e.target.map(N),lens:Math.round(e.lens*100)/100,roll:0}),K=t=>t.time*c>=M-1e-6&&t.time*c<=j+1e-6,X=(k.cameraKeys||[]).filter(K),$=(k.cameraKeys||[]).filter(t=>!K(t)),v=[];for(const t of b){const e=t.to-.001;if(t.kind==="wide"||!t.beat){v.push(I(t.from,R(t.from)),...X.filter(i=>i.time*c>t.from+1e-6&&i.time*c<e-1e-6),I(e,R(e)));continue}const m=t.kind==="insert"?t.beat.time:Math.min(e,t.beat.time+(t.kind==="reaction"?.15:.6)),w=[];for(let i=t.from;i<=e+1e-6;i+=1/30)for(const n of[h,g]){const p=x(n,i),a=L(p.key.pose,p.key.position,p.key.yaw,p.scale);w.push(...Object.values(a))}const f=W(t.beat,m);let s=T(t.kind,f);if(t.kind==="insert"){const i=[];for(const p of[-2/30,0,2/30])for(const a of[h,g]){const r=x(a,m+p),o=L(r.key.pose,r.key.position,r.key.yaw,r.scale);i.push(...Object.values(o));for(const[d,y]of[["headA","headB"],["torsoA","torsoB"]])o[d]&&o[y]&&i.push(o[d].map((_,E)=>(_+o[y][E])/2))}let n=null;for(const p of et){const a=U(T("insert",f,{...H,insertAxis:p}),w),r=a.near??1/0,o=r>=H.clearance-1e-6,d=ot(a.position,a.target,i);(!n||o&&!n.ok||o===n.ok&&(o?d<n.n:r>n.near))&&(n={ok:o,n:d,near:r,cam:a})}s=n.cam}const A=t.kind==="insert"?s:U(s,w);v.push(I(t.from,A),I(e,A))}const S=[...$,...v].sort((t,e)=>t.time-e.time),z=S[0],D=S[S.length-1],J=b.map(t=>({from:t.from/c,to:t.to/c,kind:t.kind,frames:t.kind==="insert"&&t.beat?[t.beat.attacker]:t.kind==="reaction"&&t.beat?[t.beat.target]:[h.name,g.name]})),Y=(k.cuts||[]).filter(t=>t.to*c<=M+1e-6||t.from*c>=j-1e-6),B={...k,cameraKeys:S,position:z.position,target:z.target,lens:z.lens,endPosition:D.position,endTarget:D.target,endLens:D.lens,cuts:[...Y,...J].sort((t,e)=>t.from-e.from)};return{stage:{...u,items:it(u.items,B),shots:u.shots.map(t=>t.id===k.id?B:t)},result:{ok:!0,fighters:[h.name,g.name],start:M,end:j,cuts:b.length-1,shots:b.map(t=>({kind:t.kind,from:+t.from.toFixed(2),to:+t.to.toFixed(2)})),stats:st(b,l.beats),method:"the two-shot cut on the beats: a close-up on the striking limb from 0.08 s before each impact, a reaction over the striker's shoulder after it, the wide between, the finisher held low and still (shared/fightDirector.js, measured on a reference fight)"}}}export{At as fightDirector};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editTools-m0VGPmfF.js","assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js"])))=>i.map(i=>d[i]);
2
+ import{_ as H}from"./titleFrameBudget-Cml-MO53.js";import{gE as A,iJ as V,iK as at,hw as L,iL as it,iM as ot,hz as rt,fl as st,fv as B,fw as U,fx as J,fy as ht,dz as ct,iN as Y,hv as dt,iO as lt,iP as mt}from"./remote-BJdzzFZg.js";import{c as ut}from"./cameraPresets-4pFeF2YG.js";import"./api-QBI5GJTZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const q=()=>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(T=>{const u=T||{};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 Et(o,g,k,T,u,tt){const G=g.getStage(),et=A(G),S=et.duration,R=gt(o.rounds,u-T),P=(t,n,s)=>{const r=A(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}},z=(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,x=T,_=[k[0],k[1]],I;const l=[],E=[],j=[];for(let t=0;t<R.length;t++){const n=R[t],s=t===R.length-1,r=n.ending==="throw",e=s?u:Math.min(u-2,x+n.seconds+(n.ending==="launch"?1.2:r?1.6:0)),a=r?e-(s?2.2:1.6):e;if(a-x<1.5){j.push(`round ${t+1} skipped: no time left (extend the shot)`);break}const b=!!n.air,v=b?x+.8:x,w=b?a-.8:a;if(b){const i=A(h);for(const c of _){const d=P(c,h,x).position[1];let m=V(i.flight?.[c.id],{time:x/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 O=(i,c)=>{const d=A(h),m=d.flight?.[i];if(!m?.length)return null;const f=lt(m,c/d.duration,d.duration);return f.air>0?{pose:N=>mt(N,f,c),lift:f.altitude}:null},K=_.map(i=>({...P(i,h,v),...b?{airborne:!0}:{}})),y=at(K.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),...I!=null?{openAt:I}:{},airOf:O,debug:o.debug===!0});if(!y.beats.length){j.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=>z(c,v)),v/S,q,{replace:"span"}).stage;l.push(...y.beats.map(i=>({...i,round:t+1}))),j.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:P(i,h,d),def:P(c,h,d),start:d});h=L(h,i.id,m.atk.map(f=>z(f,d)),d/S,q,{replace:"span"}).stage,h=L(h,c.id,m.def.map(f=>z(f,d)),d/S,q,{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 F=e;if(b&&X){F=Math.min(e,p.time+1.3);const i=A(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,(F+(c.name===p.target?0:.25))/S),on:!1})}}:m)}}}if((X||r)&&!s){const i=_.find($=>$.name===p.target),c=_.find($=>$.id!==i.id),d=Math.max(p.time+(r?.75:1.05),b?F+.1:0),m=P(i,h,d),f=P(c,h,d+2),N=ot({charger:m,target:f,start:d,hold:Math.max(.4,Math.min(1.4,Number(o.charge_hold??.75))),clipKeys:$=>Y($)});h=L(h,i.id,N.keys.map($=>z($,d)),d/S,q,{replace:"span"}).stage,E.push({launch:p.time,landed:p.time+(r?0:.55),charge:N.chargeAt,dash:N.dashAt,arrive:N.arrive,who:i.name}),_=[i,c],x=N.arrive,I=N.arrive}else x=e,I=void 0}if(!l.length)return{ok:!1,error:`no fight could be planned (${j.join("; ")||"too short"})`};const Q=rt(h);h=Q.stage,g.setStage(()=>h);const W=o.land!==!1?(await H(async()=>{const{landBlows:t}=await import("./editTools-m0VGPmfF.js");return{landBlows:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))).landBlows(g,l):null;if(o.timing!==!1){const t=A(g.getStage()),n=l[l.length-1];let s=st(t.timing,t.duration);const r=[...E.map(e=>e.launch),n.time];s=B(s,l.filter(e=>e.planned!=="blocked"&&!r.includes(e.time)).map(e=>e.time),U.light,t.duration),s=B(s,l.filter(e=>e.planned==="blocked").map(e=>e.time),U.light*.7,t.duration),s=B(s,r,U.heavy,t.duration);for(const e of E)s=J(s,e.launch+.12,.3,.35,t.duration),s=J(s,e.arrive+.1,.18,.5,t.duration);o.finisher!=="none"&&(s=J(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 C=[];if(o.vfx===!0){const{runTool:t}=await H(async()=>{const{runTool:e}=await import("./remote-BJdzzFZg.js").then(a=>a.js);return{runTool:e}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10])),n=Z[String(o.element??"none")]??Z.none,s=l[l.length-1].time,r=async e=>{(await t("add_effect",e,g)).ok&&C.push(String(e.effect))};for(const e of l){if(e.planned==="miss")continue;const a=e.time===s||E.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 E)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 D=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,O)=>O[1]-w[1])[0]?.[0]??k[0].name};let r=T;for(const a of E)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 O=k.find(y=>y.name===b)??k[0],K=ut(g.getStage(),{preset:a,subject:O.id,start:v,end:w});K.ok&&(g.setStage(()=>K.stage),e.push(`${a} ${M(v)}–${M(w)} s on ${b}`))}D={director:e}}else if(o.camera!==!1)try{const t=ht(g.getStage(),{fighters:k.map(n=>n.name),start:T,end:u,focal_length_mm:Number(o.focal_length_mm)||32});g.setStage(()=>t.stage),D=t.result}catch(t){D={error:t.message}}const nt=A(g.getStage());return{ok:!0,fighters:k.map(t=>t.name),rounds:R.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:E.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 H(async()=>{const{outputDuration:t}=await import("./remote-BJdzzFZg.js").then(n=>n.jq);return{outputDuration:t}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10]))).outputDuration(nt)),...C.length?{effects:C.length}:{},...j.length?{notes:j}:{},...D?{camera:D}:{},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,Et as stageFightRounds};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-C5pOWyBM.js","assets/titleFrameBudget-BjW--v_T.js"])))=>i.map(i=>d[i]);
2
- import{_ as r}from"./titleFrameBudget-BjW--v_T.js";const c=3,f="",m=(h,s,t,e)=>!h.wants||h.wants(s,t,e);class d{wants;inline={modelFrames:{},titleFrames:{},matteFrames:{},windowFrames:{}};refs={modelFrames:{},titleFrames:{},matteFrames:{},windowFrames:{}};open=new Map;uploads=[];bytes=0;chunked=!1;signal;put;inlineLimit;chunkBytes;constructor({signal:s,put:t=u,inlineLimit:e=16*1024*1024,chunkBytes:i=6*1024*1024}={}){this.signal=s,this.put=t,this.inlineLimit=e,this.chunkBytes=i}async push(s,t,e){if(!this.chunked){if((this.inline[s][t]??=[]).push(e),this.bytes+=e.length,this.bytes>this.inlineLimit){this.chunked=!0;for(const i of Object.keys(this.inline))for(const[a,n]of Object.entries(this.inline[i]))for(const o of n)await this.add(i,a,o);this.inline={modelFrames:{},titleFrames:{},matteFrames:{},windowFrames:{}}}return}await this.add(s,t,e)}async add(s,t,e){const i=`${s}
3
- ${t}`,a=this.refs[s][t]??={chunks:[],count:0},n=this.open.get(i)??{kind:s,clip:t,frames:[],bytes:0};this.open.set(i,n),n.frames.push(e),n.bytes+=e.length,a.count++,n.bytes>=this.chunkBytes&&await this.flush(i)}async flush(s){const t=this.open.get(s);if(!t?.frames.length)return;this.open.delete(s);const e=this.refs[t.kind][t.clip],i=e.chunks.length;e.chunks.push("");const a=this.put(t.frames).then(n=>{e.chunks[i]=n});if(a.catch(()=>{}),this.uploads.push(a),this.uploads.length>=c&&await this.uploads.shift(),this.signal?.aborted)throw new DOMException("Export cancelled","AbortError")}async finish(){for(const t of[...this.open.keys()])await this.flush(t);await Promise.all(this.uploads);const s={};for(const t of["modelFrames","titleFrames","matteFrames","windowFrames"]){const e={...this.inline[t],...this.refs[t]};Object.keys(e).length&&(s[t]=e)}return s}}async function u(h){const[s]=await(await r(async()=>{const{signFrameChunks:e}=await import("./api-C5pOWyBM.js").then(i=>i.c1);return{signFrameChunks:e}},__vite__mapDeps([0,1]))).signFrameChunks(1),t=await fetch(s.uploadUrl,{method:"PUT",headers:s.headers,body:JSON.stringify({frames:h})});if(!t.ok)throw Error(`Tải khung hình xuất thất bại (${t.status})`);return s.readUrl}export{d as FrameSink,f as SKIPPED_FRAME,m as wantsFrame};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js"])))=>i.map(i=>d[i]);
2
+ import{_ as r}from"./titleFrameBudget-Cml-MO53.js";const c=3,f="",m=(h,s,t,e)=>!h.wants||h.wants(s,t,e);class d{wants;inline={modelFrames:{},titleFrames:{},matteFrames:{},windowFrames:{}};refs={modelFrames:{},titleFrames:{},matteFrames:{},windowFrames:{}};open=new Map;uploads=[];bytes=0;chunked=!1;signal;put;inlineLimit;chunkBytes;constructor({signal:s,put:t=u,inlineLimit:e=16*1024*1024,chunkBytes:i=6*1024*1024}={}){this.signal=s,this.put=t,this.inlineLimit=e,this.chunkBytes=i}async push(s,t,e){if(!this.chunked){if((this.inline[s][t]??=[]).push(e),this.bytes+=e.length,this.bytes>this.inlineLimit){this.chunked=!0;for(const i of Object.keys(this.inline))for(const[a,n]of Object.entries(this.inline[i]))for(const o of n)await this.add(i,a,o);this.inline={modelFrames:{},titleFrames:{},matteFrames:{},windowFrames:{}}}return}await this.add(s,t,e)}async add(s,t,e){const i=`${s}
3
+ ${t}`,a=this.refs[s][t]??={chunks:[],count:0},n=this.open.get(i)??{kind:s,clip:t,frames:[],bytes:0};this.open.set(i,n),n.frames.push(e),n.bytes+=e.length,a.count++,n.bytes>=this.chunkBytes&&await this.flush(i)}async flush(s){const t=this.open.get(s);if(!t?.frames.length)return;this.open.delete(s);const e=this.refs[t.kind][t.clip],i=e.chunks.length;e.chunks.push("");const a=this.put(t.frames).then(n=>{e.chunks[i]=n});if(a.catch(()=>{}),this.uploads.push(a),this.uploads.length>=c&&await this.uploads.shift(),this.signal?.aborted)throw new DOMException("Export cancelled","AbortError")}async finish(){for(const t of[...this.open.keys()])await this.flush(t);await Promise.all(this.uploads);const s={};for(const t of["modelFrames","titleFrames","matteFrames","windowFrames"]){const e={...this.inline[t],...this.refs[t]};Object.keys(e).length&&(s[t]=e)}return s}}async function u(h){const[s]=await(await r(async()=>{const{signFrameChunks:e}=await import("./api-QBI5GJTZ.js").then(i=>i.c1);return{signFrameChunks:e}},__vite__mapDeps([0,1]))).signFrameChunks(1),t=await fetch(s.uploadUrl,{method:"PUT",headers:s.headers,body:JSON.stringify({frames:h})});if(!t.ok)throw Error(`Tải khung hình xuất thất bại (${t.status})`);return s.readUrl}export{d as FrameSink,f as SKIPPED_FRAME,m as wantsFrame};
@@ -1 +1 @@
1
- import{n9 as T,lB as U,bM as V,bP as Z,bR as R,bQ as H,na as W,nb as J}from"./titleFrameBudget-BjW--v_T.js";const rt=(n,a,e)=>Math.round(Math.min(4e7,Math.max(2e6,n*a*e*.16)));function at(n,a,e,t,o,r){const i=n.crop||{left:0,right:0,top:0,bottom:0},m=Math.max(2,Math.floor(a*(1-i.left-i.right)/2)*2),c=Math.max(2,Math.floor(e*(1-i.top-i.bottom)/2)*2);let h=i.left,y=i.top,s=m/a,f=c/e,w=0,u=0,l=t,x=o;const d=T(n,t,o);if(d){const b=Math.max(d.w/m,d.h/c),v=d.w/b/a,z=d.h/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z,w=d.x,u=d.y,l=d.w,x=d.h}else if(n.fit==="cover"){const b=Math.max(t/m,o/c),v=t/b/a,z=o/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z}else{const b=Math.min(t/m,o/c);l=Math.round(m*b),x=Math.round(c*b),w=(t-l)/2,u=(o-x)/2}n.flipX&&(h+=s,s=-s),n.flipY&&(y+=f,f=-f);const M=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),p=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),k=Math.trunc((t-M)/2+r.x*t),g=Math.trunc((o-p)/2+r.y*o);return{dst:[(k+w*M/t)/t,(g+u*p/o)/o,l*M/t/t,x*p/o/o],src:[h,y,s,f]}}function et(n,a){const e=Math.min(n.visualFadeIn||0,n.duration),t=Math.min(n.visualFadeOut||0,n.duration);return e>a+1e-5?{k:Math.min(1,Math.max(0,a/e)),white:n.fadeInColor==="white"}:t>0&&a>n.duration-t+1e-5?{k:Math.min(1,Math.max(0,(n.duration-a)/t)),white:n.fadeOutColor==="white"}:{k:1,white:!1}}function tt(n,a=48e3,e=.95){const t=n[0].length,o=Math.round(a*.005),r=Math.exp(-1/(a*.05)),i=new Float32Array(t);for(let h=0;h<t;h++){let y=0;for(const s of n)y=Math.max(y,Math.abs(s[h]));i[h]=y>e?e/y:1}let m=1;const c=[];for(let h=0;h<t+o;h++){if(h<t){for(;c.length&&i[c[c.length-1]]>=i[h];)c.pop();c.push(h)}const y=h-o;if(y<0)continue;for(;c.length&&c[0]<y;)c.shift();const s=c.length?i[c[0]]:1;m=Math.min(s,1-(1-m)*r);for(const f of n)f[y]*=m}}function st(n){if(n.colorBypass)return null;const a=(n.brightness??1)*2**(n.exposure??0),e=n.contrast??1,t=n.saturation??1,o=n.hue??0;if(a===1&&e===1&&t===1&&o===0)return null;const{sat:r,rot:i}=U(t,o);return{bright:a,contrast:e,sat:r,rot:i}}function it(n,a){const e=-J*255/(255-J);return(Array.isArray(n.effects)?n.effects:[]).filter(t=>!t.off&&t.amount>.001).flatMap(t=>{if(t.type==="blur")return[{type:"blur",sigma:V(t.amount,a)}];if(t.type==="glow")return[{type:"glow",sigma:Z(a),lo:e/255,k:(255-e)/255,amount:+t.amount.toFixed(4)}];if(t.type==="rgb-split")return[{type:"shift",px:R(t.amount,a)}];if(t.type==="light-burst")return[{type:"burst",amount:t.amount,lo:e/255,k:(255-e)/255}];if(t.type==="pixelate"){const r=H(t.amount,a);return r>1?[{type:"pixel",block:r}]:[]}const o=W(t.type,t.amount);return o?[{type:"colour",m:o.m,lut:o.lut,key:`${t.type}:${t.amount}`}]:[]})}function ht(n,a,e=48e3){const t=n[0]?.length??0,o=Math.max(1,Math.round(t/a));if(Math.abs(a-1)<1e-9||t<2)return n.map(u=>u.slice(0,o));const r=2*Math.round(e*.02),i=r/2,m=Math.round(e*.01),c=4,h=new Float32Array(r);for(let u=0;u<r;u++)h[u]=.5-.5*Math.cos(2*Math.PI*u/r);const y=new Float32Array(t);for(const u of n)for(let l=0;l<t;l++)y[l]+=u[l]/n.length;const s=n.map(()=>new Float32Array(o+r)),f=new Float32Array(o+r);let w=0;for(let u=0;u*i<o;u++){const l=u*i,x=Math.min(t-1,Math.round(l*a));let d=x;if(u>0){const M=w+i;let p=-1/0;for(let k=-m;k<=m;k+=2){const g=x+k;if(g<0||g+i>t||M+i>t)continue;let F=0;for(let b=0;b<i;b+=c)F+=y[g+b]*y[M+b];F>p&&(p=F,d=g)}}for(let M=0;M<n.length;M++){const p=n[M],k=s[M];for(let g=0;g<r&&d+g<t;g++)k[l+g]+=p[d+g]*h[g]}for(let M=0;M<r&&d+M<t;M++)f[l+M]+=h[M];w=d}return s.map(u=>{const l=new Float32Array(o);for(let x=0;x<o;x++)l[x]=f[x]>.001?u[x]/f[x]:u[x];return l})}function ot(n,a=48e3){if(a!==48e3)throw Error("integratedLoudness: 48 kHz only");const e=n[0].length,t=n.map(s=>{const f=new Float64Array(e),w=new Float64Array(e);let u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=1.53512485958697*s[M]-2.69169618940638*u+1.19839281085285*l+1.69065929318241*x-.73248077421585*d;l=u,u=s[M],d=x,x=p,f[M]=p}u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=f[M]-2*u+l+1.99004745483398*x-.99007225036621*d;l=u,u=f[M],d=x,x=p,w[M]=p*p}return w}),o=.4*a,r=.1*a,i=[];for(let s=0;s+o<=e;s+=r){let f=0;for(const w of t){let u=0;for(let l=s;l<s+o;l++)u+=w[l];f+=u/o}i.push(f)}const m=s=>-.691+10*Math.log10(s),c=i.filter(s=>m(s)>-70);if(!c.length)return-1/0;const h=m(c.reduce((s,f)=>s+f,0)/c.length)-10,y=c.filter(s=>m(s)>h);return m(y.reduce((s,f)=>s+f,0)/y.length)}function ct(n,a,e=48e3){const t=ot(n,e);if(!Number.isFinite(t))return t;const o=10**((a-t)/20);for(const r of n)for(let i=0;i<r.length;i++)r[i]*=o;return tt(n,e,10**(-1.5/20)),t}function ut([n,a,e,t],o,r){return[(2+n*(o-4))/o,(2+a*(r-4))/r,e*(o-4)/o,t*(r-4)/r]}function lt(n,a,e){const[[t,o],[r,i],[m,c],[h,y]]=n,s=t-r+h-m,f=o-i+y-c;let w,u,l,x,d,M,p,k;if(Math.abs(s)<1e-9&&Math.abs(f)<1e-9)w=r-t,u=h-r,l=t,x=i-o,d=y-i,M=o,p=0,k=0;else{const K=r-h,N=m-h,_=i-y,$=c-y,j=K*$-N*_;p=(s*$-N*f)/j,k=(K*f-s*_)/j,w=r-t+p*r,u=m-t+k*m,l=t,x=i-o+p*i,d=c-o+k*c,M=o}const g=[w/a,u/e,l,x/a,d/e,M,p/a,k/e,1],[F,b,v,z,L,X,B,I,P]=g,E=L*P-X*I,G=-(b*P-v*I),Q=b*X-v*L,C=-(z*P-X*B),O=F*P-v*B,q=-(F*X-v*z),S=z*I-L*B,Y=-(F*I-b*B),D=F*L-b*z,A=F*E+b*C+v*S;return[E/A,G/A,Q/A,C/A,O/A,q/A,S/A,Y/A,D/A]}function ft(n,a,e){const t=n.crop||{left:0,right:0,top:0,bottom:0},o=Math.max(2,Math.floor(a*(1-t.left-t.right)/2)*2),r=Math.max(2,Math.floor(e*(1-t.top-t.bottom)/2)*2);let i=t.left,m=t.top,c=o/a,h=r/e;return n.flipX&&(i+=c,c=-c),n.flipY&&(m+=h,h=-h),[i,m,c,h]}function Mt(n,a,e,t,o,r,i){const m=n.crop||{left:0,right:0,top:0,bottom:0},c=Math.max(2,Math.floor(a*(1-m.left-m.right)/2)*2),h=Math.max(2,Math.floor(e*(1-m.top-m.bottom)/2)*2),y=(r.rot||0)*Math.PI/180,s=Math.cos(y),f=Math.sin(y),w=O=>Math.ceil(O/2)*2,u=w(Math.hypot(c,h)),l=i?u:w(c*Math.abs(s)+h*Math.abs(f)),x=i?u:w(c*Math.abs(f)+h*Math.abs(s)),d=Math.round(o*l/x),M=Math.round(t*x/l),p=n.fit==="cover",k=p?Math.max(d,t):Math.min(d,t),g=p?Math.max(M,o):Math.min(M,o),F=p?-Math.trunc((k-t)/2):Math.trunc((t-k)/2),b=p?-Math.trunc((g-o)/2):Math.trunc((o-g)/2),v=k/l,z=g/x,L=F+k/2,X=b+g/2,B=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),I=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),P=Math.trunc((t-B)/2+r.x*t),E=Math.trunc((o-I)/2+r.y*o),G=B/t,Q=I/o,C=(O,q)=>{const S=(O-2)/(t-4)*c-c/2,Y=(q-2)/(o-4)*h-h/2,D=L+(S*s-Y*f)*v,A=X+(S*f+Y*s)*z;return[P+D*G,E+A*Q]};return{quad:[C(0,0),C(t,0),C(0,o),C(t,o)],clip:p?[P,E,B,I]:null}}function mt(n,a,e,t){const o=t*Math.PI/180,r=Math.cos(o),i=Math.sin(o),m=a/2,c=e/2,h=(y,s)=>{const f=(y-2)/(a-4),w=(s-2)/(e-4),u=(n[0]+f*n[2])*a-m,l=(n[1]+w*n[3])*e-c;return[m+u*r-l*i,c+u*i+l*r]};return[h(0,0),h(a,0),h(0,e),h(a,e)]}export{at as a,it as b,ht as c,tt as d,et as f,rt as g,st as l,ct as n,ut as p,Mt as r,ft as s,mt as t,lt as w};
1
+ import{n3 as T,lC as U,bM as V,bP as Z,bR as R,bQ as H,n4 as W,n5 as J}from"./titleFrameBudget-Cml-MO53.js";const rt=(n,a,e)=>Math.round(Math.min(4e7,Math.max(2e6,n*a*e*.16)));function at(n,a,e,t,o,r){const i=n.crop||{left:0,right:0,top:0,bottom:0},m=Math.max(2,Math.floor(a*(1-i.left-i.right)/2)*2),c=Math.max(2,Math.floor(e*(1-i.top-i.bottom)/2)*2);let h=i.left,y=i.top,s=m/a,f=c/e,w=0,u=0,l=t,x=o;const d=T(n,t,o);if(d){const b=Math.max(d.w/m,d.h/c),v=d.w/b/a,z=d.h/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z,w=d.x,u=d.y,l=d.w,x=d.h}else if(n.fit==="cover"){const b=Math.max(t/m,o/c),v=t/b/a,z=o/b/e;h+=(s-v)/2,y+=(f-z)/2,s=v,f=z}else{const b=Math.min(t/m,o/c);l=Math.round(m*b),x=Math.round(c*b),w=(t-l)/2,u=(o-x)/2}n.flipX&&(h+=s,s=-s),n.flipY&&(y+=f,f=-f);const M=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),p=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),k=Math.trunc((t-M)/2+r.x*t),g=Math.trunc((o-p)/2+r.y*o);return{dst:[(k+w*M/t)/t,(g+u*p/o)/o,l*M/t/t,x*p/o/o],src:[h,y,s,f]}}function et(n,a){const e=Math.min(n.visualFadeIn||0,n.duration),t=Math.min(n.visualFadeOut||0,n.duration);return e>a+1e-5?{k:Math.min(1,Math.max(0,a/e)),white:n.fadeInColor==="white"}:t>0&&a>n.duration-t+1e-5?{k:Math.min(1,Math.max(0,(n.duration-a)/t)),white:n.fadeOutColor==="white"}:{k:1,white:!1}}function tt(n,a=48e3,e=.95){const t=n[0].length,o=Math.round(a*.005),r=Math.exp(-1/(a*.05)),i=new Float32Array(t);for(let h=0;h<t;h++){let y=0;for(const s of n)y=Math.max(y,Math.abs(s[h]));i[h]=y>e?e/y:1}let m=1;const c=[];for(let h=0;h<t+o;h++){if(h<t){for(;c.length&&i[c[c.length-1]]>=i[h];)c.pop();c.push(h)}const y=h-o;if(y<0)continue;for(;c.length&&c[0]<y;)c.shift();const s=c.length?i[c[0]]:1;m=Math.min(s,1-(1-m)*r);for(const f of n)f[y]*=m}}function st(n){if(n.colorBypass)return null;const a=(n.brightness??1)*2**(n.exposure??0),e=n.contrast??1,t=n.saturation??1,o=n.hue??0;if(a===1&&e===1&&t===1&&o===0)return null;const{sat:r,rot:i}=U(t,o);return{bright:a,contrast:e,sat:r,rot:i}}function it(n,a){const e=-J*255/(255-J);return(Array.isArray(n.effects)?n.effects:[]).filter(t=>!t.off&&t.amount>.001).flatMap(t=>{if(t.type==="blur")return[{type:"blur",sigma:V(t.amount,a)}];if(t.type==="glow")return[{type:"glow",sigma:Z(a),lo:e/255,k:(255-e)/255,amount:+t.amount.toFixed(4)}];if(t.type==="rgb-split")return[{type:"shift",px:R(t.amount,a)}];if(t.type==="light-burst")return[{type:"burst",amount:t.amount,lo:e/255,k:(255-e)/255}];if(t.type==="pixelate"){const r=H(t.amount,a);return r>1?[{type:"pixel",block:r}]:[]}const o=W(t.type,t.amount);return o?[{type:"colour",m:o.m,lut:o.lut,key:`${t.type}:${t.amount}`}]:[]})}function ht(n,a,e=48e3){const t=n[0]?.length??0,o=Math.max(1,Math.round(t/a));if(Math.abs(a-1)<1e-9||t<2)return n.map(u=>u.slice(0,o));const r=2*Math.round(e*.02),i=r/2,m=Math.round(e*.01),c=4,h=new Float32Array(r);for(let u=0;u<r;u++)h[u]=.5-.5*Math.cos(2*Math.PI*u/r);const y=new Float32Array(t);for(const u of n)for(let l=0;l<t;l++)y[l]+=u[l]/n.length;const s=n.map(()=>new Float32Array(o+r)),f=new Float32Array(o+r);let w=0;for(let u=0;u*i<o;u++){const l=u*i,x=Math.min(t-1,Math.round(l*a));let d=x;if(u>0){const M=w+i;let p=-1/0;for(let k=-m;k<=m;k+=2){const g=x+k;if(g<0||g+i>t||M+i>t)continue;let F=0;for(let b=0;b<i;b+=c)F+=y[g+b]*y[M+b];F>p&&(p=F,d=g)}}for(let M=0;M<n.length;M++){const p=n[M],k=s[M];for(let g=0;g<r&&d+g<t;g++)k[l+g]+=p[d+g]*h[g]}for(let M=0;M<r&&d+M<t;M++)f[l+M]+=h[M];w=d}return s.map(u=>{const l=new Float32Array(o);for(let x=0;x<o;x++)l[x]=f[x]>.001?u[x]/f[x]:u[x];return l})}function ot(n,a=48e3){if(a!==48e3)throw Error("integratedLoudness: 48 kHz only");const e=n[0].length,t=n.map(s=>{const f=new Float64Array(e),w=new Float64Array(e);let u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=1.53512485958697*s[M]-2.69169618940638*u+1.19839281085285*l+1.69065929318241*x-.73248077421585*d;l=u,u=s[M],d=x,x=p,f[M]=p}u=0,l=0,x=0,d=0;for(let M=0;M<e;M++){const p=f[M]-2*u+l+1.99004745483398*x-.99007225036621*d;l=u,u=f[M],d=x,x=p,w[M]=p*p}return w}),o=.4*a,r=.1*a,i=[];for(let s=0;s+o<=e;s+=r){let f=0;for(const w of t){let u=0;for(let l=s;l<s+o;l++)u+=w[l];f+=u/o}i.push(f)}const m=s=>-.691+10*Math.log10(s),c=i.filter(s=>m(s)>-70);if(!c.length)return-1/0;const h=m(c.reduce((s,f)=>s+f,0)/c.length)-10,y=c.filter(s=>m(s)>h);return m(y.reduce((s,f)=>s+f,0)/y.length)}function ct(n,a,e=48e3){const t=ot(n,e);if(!Number.isFinite(t))return t;const o=10**((a-t)/20);for(const r of n)for(let i=0;i<r.length;i++)r[i]*=o;return tt(n,e,10**(-1.5/20)),t}function ut([n,a,e,t],o,r){return[(2+n*(o-4))/o,(2+a*(r-4))/r,e*(o-4)/o,t*(r-4)/r]}function lt(n,a,e){const[[t,o],[r,i],[m,c],[h,y]]=n,s=t-r+h-m,f=o-i+y-c;let w,u,l,x,d,M,p,k;if(Math.abs(s)<1e-9&&Math.abs(f)<1e-9)w=r-t,u=h-r,l=t,x=i-o,d=y-i,M=o,p=0,k=0;else{const K=r-h,N=m-h,_=i-y,$=c-y,j=K*$-N*_;p=(s*$-N*f)/j,k=(K*f-s*_)/j,w=r-t+p*r,u=m-t+k*m,l=t,x=i-o+p*i,d=c-o+k*c,M=o}const g=[w/a,u/e,l,x/a,d/e,M,p/a,k/e,1],[F,b,v,z,L,X,I,B,C]=g,E=L*C-X*B,G=-(b*C-v*B),Q=b*X-v*L,P=-(z*C-X*I),O=F*C-v*I,q=-(F*X-v*z),S=z*B-L*I,Y=-(F*B-b*I),D=F*L-b*z,A=F*E+b*P+v*S;return[E/A,G/A,Q/A,P/A,O/A,q/A,S/A,Y/A,D/A]}function ft(n,a,e){const t=n.crop||{left:0,right:0,top:0,bottom:0},o=Math.max(2,Math.floor(a*(1-t.left-t.right)/2)*2),r=Math.max(2,Math.floor(e*(1-t.top-t.bottom)/2)*2);let i=t.left,m=t.top,c=o/a,h=r/e;return n.flipX&&(i+=c,c=-c),n.flipY&&(m+=h,h=-h),[i,m,c,h]}function Mt(n,a,e,t,o,r,i){const m=n.crop||{left:0,right:0,top:0,bottom:0},c=Math.max(2,Math.floor(a*(1-m.left-m.right)/2)*2),h=Math.max(2,Math.floor(e*(1-m.top-m.bottom)/2)*2),y=(r.rot||0)*Math.PI/180,s=Math.cos(y),f=Math.sin(y),w=O=>Math.ceil(O/2)*2,u=w(Math.hypot(c,h)),l=i?u:w(c*Math.abs(s)+h*Math.abs(f)),x=i?u:w(c*Math.abs(f)+h*Math.abs(s)),d=Math.round(o*l/x),M=Math.round(t*x/l),p=n.fit==="cover",k=p?Math.max(d,t):Math.min(d,t),g=p?Math.max(M,o):Math.min(M,o),F=p?-Math.trunc((k-t)/2):Math.trunc((t-k)/2),b=p?-Math.trunc((g-o)/2):Math.trunc((o-g)/2),v=k/l,z=g/x,L=F+k/2,X=b+g/2,I=Math.max(2,Math.trunc(t*r.zoom*(r.sx??1)/2)*2),B=Math.max(2,Math.trunc(o*r.zoom*(r.sy??1)/2)*2),C=Math.trunc((t-I)/2+r.x*t),E=Math.trunc((o-B)/2+r.y*o),G=I/t,Q=B/o,P=(O,q)=>{const S=(O-2)/(t-4)*c-c/2,Y=(q-2)/(o-4)*h-h/2,D=L+(S*s-Y*f)*v,A=X+(S*f+Y*s)*z;return[C+D*G,E+A*Q]};return{quad:[P(0,0),P(t,0),P(0,o),P(t,o)],clip:p?[C,E,I,B]:null}}function mt(n,a,e,t){const o=t*Math.PI/180,r=Math.cos(o),i=Math.sin(o),m=a/2,c=e/2,h=(y,s)=>{const f=(y-2)/(a-4),w=(s-2)/(e-4),u=(n[0]+f*n[2])*a-m,l=(n[1]+w*n[3])*e-c;return[m+u*r-l*i,c+u*i+l*r]};return[h(0,0),h(a,0),h(0,e),h(a,e)]}export{at as a,it as b,ht as c,tt as d,et as f,rt as g,st as l,ct as n,ut as p,Mt as r,ft as s,mt as t,lt as w};