clipoox-render 0.4.5 → 0.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/render-local.mjs +999 -779
- package/web/assets/{FxEmbed-DbfuM8Yo.js → FxEmbed-ROS6C_HI.js} +1 -1
- package/web/assets/{MotionEmbed-CBQ-8Tzh.js → MotionEmbed-E2hCysi-.js} +1 -1
- package/web/assets/{PluginStore-OOEx0lP5.js → PluginStore-CwUSpwPp.js} +1 -1
- package/web/assets/{ShotComposer-Cng515xa.js → ShotComposer-DLxWpdYH.js} +8 -8
- package/web/assets/{TemplateEmbed-hjwM2b0o.js → TemplateEmbed-qG1AXdtf.js} +1 -1
- package/web/assets/{TimelinePlugins-D-NakABP.js → TimelinePlugins-CB1b6-Cb.js} +3 -3
- package/web/assets/{TimelineShotFx-D3kGhHN3.js → TimelineShotFx-CyHTgJHj.js} +2 -2
- package/web/assets/{TransitionEmbed-DR26yI3a.js → TransitionEmbed-Dym9P7--.js} +1 -1
- package/web/assets/{Whiteboard-BhxY0D0Z.js → Whiteboard-BdGjJZXW.js} +1 -1
- package/web/assets/{aerial-BisYSXzG.js → aerial-yLD_gDzw.js} +2 -2
- package/web/assets/{agentTools-CPFQeiDP.js → agentTools-B7g6tXTR.js} +2 -2
- package/web/assets/{aiInbetween-AOOM1e6p.js → aiInbetween-6eKDYbYS.js} +2 -2
- package/web/assets/{analyzerRun-Dtp2o7gT.js → analyzerRun-Cr-_79RH.js} +1 -1
- package/web/assets/{analyzerSandbox-BG_3Cea1.js → analyzerSandbox-N92T6amg.js} +1 -1
- package/web/assets/{api-BFN7blbw.js → api-Dnl2uaKO.js} +3 -3
- package/web/assets/auraTrack-C8eAEIWQ.js +1 -0
- package/web/assets/{breakthrough-0qFpZW-V.js → breakthrough-DSiuVwEX.js} +2 -2
- package/web/assets/{cameraPresets-eK3mP7qb.js → cameraPresets-Cfn7qhXK.js} +1 -1
- package/web/assets/{cameraTracker-BAQHuTV-.js → cameraTracker-DHdF8Zqx.js} +5 -5
- package/web/assets/{captionLayout-CWPcbid-.js → captionLayout-cckQ7p-t.js} +1 -1
- package/web/assets/{clientExport-DvpTTndR.js → clientExport-pkLbOmEF.js} +1 -1
- package/web/assets/{clientJobs-CIrYTMpn.js → clientJobs-CcsLDqFM.js} +2 -2
- package/web/assets/{depthEstimate-B7D7cGCl.js → depthEstimate-Cav4MmQ1.js} +1 -1
- package/web/assets/{directorTools-CJD4Huqk.js → directorTools-DMsatulF.js} +1 -1
- package/web/assets/{distortFrames-BLt1icUb.js → distortFrames-D_v-aSVO.js} +2 -2
- package/web/assets/{distortGL-BA5molk-.js → distortGL-vhnBRB59.js} +1 -1
- package/web/assets/domino-DBrinEUu.js +1 -0
- package/web/assets/{editTools-NKLsWZD1.js → editTools-BNnAvCw-.js} +1 -1
- package/web/assets/{engine-DioUF2mX.js → engine-Co-ivzlQ.js} +1 -1
- package/web/assets/{exportGlb-BOdI9cVS.js → exportGlb-D3PrWUvi.js} +1 -1
- package/web/assets/{faceTracker-D7CbF-qX.js → faceTracker-ClR-lS6Y.js} +1 -1
- package/web/assets/fightDirector-BlpVAURl.js +1 -0
- package/web/assets/{fightDrama-DIPcRKnc.js → fightDrama-BK0QidpM.js} +2 -2
- package/web/assets/{focusTool-vfabPqQ5.js → focusTool-sVOb2GGS.js} +1 -1
- package/web/assets/{frameSink-DYs2gTzq.js → frameSink-CSRqCnwI.js} +3 -3
- package/web/assets/{glTransitionSources.generated-DM5sRMX2.js → glTransitionSources.generated-q0H-ZbnZ.js} +2 -2
- package/web/assets/{gpuCompose-DbnZuelB.js → gpuCompose-B5bgbHdQ.js} +1 -1
- package/web/assets/{gpuExport-CQ7ZhpsX.js → gpuExport-oA2mUsdm.js} +7 -7
- package/web/assets/{handMatte-DIbMuqCu.js → handMatte-Dj2taFoC.js} +1 -1
- package/web/assets/handTracker-c6_rvuwA.js +2 -0
- package/web/assets/i18n-C9zFX25m.js +3 -0
- package/web/assets/{index-BfrDwjDI.js → index-Ds_8isyf.js} +1 -1
- package/web/assets/{layer-worker-DK67WH1a.js → layer-worker-ClVZG6ZW.js} +3 -3
- package/web/assets/library-BK0QVG4O.js +1 -0
- package/web/assets/{lottieLayer-C2YbiXhK.js → lottieLayer-Cv8ub9f6.js} +1 -1
- package/web/assets/{main-B27kf5aL.css → main-B_MAOvi6.css} +1 -1
- package/web/assets/{main-BKatDoGw.js → main-CwrkBJ63.js} +104 -104
- package/web/assets/{mapBake-C-G7WpFM.js → mapBake-DtQboFIX.js} +1 -1
- package/web/assets/{maskTrack-LMrwm5ub.js → maskTrack-D4QZfMWc.js} +1 -1
- package/web/assets/{matteFixRun-B38CbeEt.js → matteFixRun-CytaeRzS.js} +1 -1
- package/web/assets/{objectLocate-CKi3OTnL.js → objectLocate-XuAcemlO.js} +1 -1
- package/web/assets/{objectSegmenter-CziPuM61.js → objectSegmenter-D66spD7o.js} +1 -1
- package/web/assets/{objectTrack.worker-b7DJ-ub6.js → objectTrack.worker-BZS6WZ6l.js} +547 -327
- package/web/assets/{pathTracer-bqau16sX.js → pathTracer-DykgPkkh.js} +2 -2
- package/web/assets/{pendingMatte-CQb7jPg1.js → pendingMatte-BWBIWajI.js} +2 -2
- package/web/assets/{personAi-CQntGDqK.js → personAi-EhBknW6X.js} +2 -2
- package/web/assets/{personHq-B1c0QVJT.js → personHq-Ca351o06.js} +2 -2
- package/web/assets/{plateCamera-D7iLiNBy.js → plateCamera-BcdXD1uI.js} +1 -1
- package/web/assets/{plateCameraMatch-BM88dx-a.js → plateCameraMatch-GPZl1fQQ.js} +2 -2
- package/web/assets/{plateFollow-4iGUDTu1.js → plateFollow-CJUilsNV.js} +2 -2
- package/web/assets/{plateMatte-zTyuHHqh.js → plateMatte-CoEoVjxZ.js} +2 -2
- package/web/assets/{pluginAutomation-DSg-sYLF.js → pluginAutomation-DAPHWZPN.js} +1 -1
- package/web/assets/{poseTracker-DZl8l2qS.js → poseTracker-CzEKvJph.js} +1 -1
- package/web/assets/{productTools-B-jh8ukh.js → productTools-ce-zyZO0.js} +2 -2
- package/web/assets/remote-8XzEAnAJ.js +974 -0
- package/web/assets/{rigTrack-XaMj1yaH.js → rigTrack-DMyqb0pb.js} +1 -1
- package/web/assets/{rotoMaskStore-DdpmT9C3.js → rotoMaskStore-pE1AIt3I.js} +1 -1
- package/web/assets/{rotoMatte-i-cJTYmK.js → rotoMatte-7b7Ow64f.js} +1 -1
- package/web/assets/{rotoscope-DqRSWmHR.js → rotoscope-BUqNTKLd.js} +1 -1
- package/web/assets/{sceneTrack-DIPzBmMK.js → sceneTrack-CA21MCOP.js} +1 -1
- package/web/assets/{sceneTrack-Bbov7zET.js → sceneTrack-DlAH5s74.js} +1 -1
- package/web/assets/{sceneTrack.worker-Bav9h0pv.js → sceneTrack.worker-COlhlHRe.js} +547 -327
- package/web/assets/{shot-worker-m-q77W9f.js → shot-worker-DL1ZoIym.js} +1 -1
- package/web/assets/{shotFxAgent-DIMS7BGA.js → shotFxAgent-DqngnGFb.js} +1 -1
- package/web/assets/{skin-DrUzJE1u.js → skin-xFScwS3T.js} +1 -1
- package/web/assets/{spark.module-Y1SEI8Xz.js → spark.module-DjaIF6J1.js} +1 -1
- package/web/assets/{spellDuel-DNnyQDVr.js → spellDuel-BYNtnE8f.js} +2 -2
- package/web/assets/{store-GFMJzaWS.js → store-CpqHUcA2.js} +1 -1
- package/web/assets/{surfaceLight-C--moyc9.js → surfaceLight-C7YI9SV8.js} +1 -1
- package/web/assets/{surfacePin-B4-1UqXD.js → surfacePin-CzpUj1Cw.js} +2 -2
- package/web/assets/{textAnimators-BVXTl8bU.js → textAnimators-B9vO_hbP.js} +1 -1
- package/web/assets/{thumb-CTfDJgLp.js → thumb-BTFsBS1u.js} +1 -1
- package/web/assets/{timeline3d-Dn7PqmEe.js → timeline3d-DrFaMPPB.js} +2 -2
- package/web/assets/{timeline3dExport-DCOr6ARB.js → timeline3dExport-Uo0S0CR0.js} +1 -1
- package/web/assets/{timelineComp-Dx_kED5V.js → timelineComp-i-zdaoB2.js} +1 -1
- package/web/assets/timelineOps-DSSaDsU2.js +525 -0
- package/web/assets/{timelineProps-eYgO6gs5.js → timelineProps-0v-s69pw.js} +1 -1
- package/web/assets/{timelineText-RKyRP988.js → timelineText-DurRhyuh.js} +1 -1
- package/web/assets/{titleArt-CUtA0C3I.js → titleArt-CnC0A7x7.js} +3 -3
- package/web/assets/{titleFrameBudget-X7HLSDre.js → titleFrameBudget-DsM0V482.js} +801 -581
- package/web/assets/{titleFrames-aMG7HdVe.js → titleFrames-C8kvflgT.js} +1 -1
- package/web/assets/{tool-DpFjybaq.js → tool-D1FpErrX.js} +1 -1
- package/web/assets/{tools-CeOU0p13.js → tools-DIvrRu-5.js} +1 -1
- package/web/assets/toonTools-D9MNdRty.js +2 -0
- package/web/assets/{trackAnchor-hAOtEhKO.js → trackAnchor-XvUuvkWP.js} +1 -1
- package/web/assets/{userFonts-1kuRjWOo.js → userFonts-Djka6RJX.js} +1 -1
- package/web/assets/{vfxAlpha-DxS5-QwY.js → vfxAlpha-B-JzzRI1.js} +1 -1
- package/web/assets/vfxBackground-b053ziDK.js +2 -0
- package/web/assets/{videoExport-Cg4B2Nyh.js → videoExport-NN-QijHd.js} +1 -1
- package/web/assets/{views-CUXyRb9x.js → views-RQBs4zva.js} +1 -1
- package/web/assets/{weaponDuel-nFECu9nk.js → weaponDuel-DKAEYJjO.js} +1 -1
- package/web/assets/{windowFrames-1wAkkWnv.js → windowFrames-DhhJLIs-.js} +1 -1
- package/web/layer-worker.html +3 -3
- package/web/shot-worker.html +23 -23
- package/web/assets/auraTrack-D_gxHNVe.js +0 -1
- package/web/assets/fightDirector-CYP8jxo8.js +0 -1
- package/web/assets/handTracker-DY_g5Xmg.js +0 -2
- package/web/assets/i18n-BJppIrtF.js +0 -3
- package/web/assets/library-B6KsZUKq.js +0 -1
- package/web/assets/remote-DJd9xWjn.js +0 -963
- package/web/assets/timelineOps-afzSo188.js +0 -525
- package/web/assets/toonTools-DLmo37Z_.js +0 -2
- package/web/assets/vfxBackground-CYpaQaTa.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/views-
|
|
2
|
-
import{_ as K}from"./titleFrameBudget-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/views-RQBs4zva.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/skin-xFScwS3T.js","assets/remote-8XzEAnAJ.js","assets/index-CKtv7gGE.js","assets/i18n-C9zFX25m.js","assets/api-Dnl2uaKO.js","assets/titleFrameBudget-DsM0V482.js","assets/store-CpqHUcA2.js","assets/rotoMaskStore-pE1AIt3I.js","assets/sceneTrack-DlAH5s74.js","assets/timelineOps-DSSaDsU2.js","assets/cameraTracker-DHdF8Zqx.js","assets/textAnimators-B9vO_hbP.js","assets/timelineComp-i-zdaoB2.js","assets/rigTrack-DMyqb0pb.js","assets/clientJobs-CuuUyhEy.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as K}from"./titleFrameBudget-DsM0V482.js";import{de as y,d0 as O,d2 as _,e_ as M,fg as v,d1 as S,am as D,fp as q,d8 as V,d9 as z,d5 as F,d6 as E,d7 as G,da as P,d4 as U,cm as C}from"./remote-8XzEAnAJ.js";import{f as L,d as H,e as T}from"./skin-xFScwS3T.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const A=["humanoid","quadruped","chain","hinge","wheels"],B=()=>crypto.randomUUID(),J=o=>Math.round(o*100)/100,w=o=>o.joints.filter(n=>!D(o.joints,n)).map(n=>n.name);function fe(o,n){const i=o.rig,e=y(n),r=(e.objectKeys?.[o.id]||[]).filter(a=>a.bones),u=new Set;for(const a of r)for(const[s,t]of Object.entries(a.bones))t.some(c=>Math.abs(c)>.05)&&u.add(s);const f=w(i);return{rig:i.kind,rig_source:i.source,fingers:_(i),bones:f.filter(a=>!M(a)),..._(i)?{finger_bones:"thumb|index|middle|ring|pinky + 1..3 + L|R (e.g. index2R); hand shapes via set_pose hands curl them"}:{},keyed_bones:[...u],bone_key_times:r.map(a=>J(a.time*e.duration)),...i.bones?{posed_bones:Object.keys(i.bones)}:{},...O(i)?{posable:"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze and resolve_hits work on it like on a mannequin"}:{}}}function x(o,n){const i=w(o);return i.find(e=>e===n)??i.find(e=>e.toLowerCase()===n.toLowerCase())??null}const R=o=>Array.isArray(o)&&o.length===3&&o.every(n=>Number.isFinite(Number(n)))?o.map(n=>Math.round(Math.max(-S.angle,Math.min(S.angle,Number(n)))*100)/100):null;function $(o,n,i,e,r){o.setStage(u=>{const f=y(u),a=u.items.find(d=>d.id===n.id),s=f.objectKeys?.[n.id]||[],t=(d,h)=>{const p=s.find(j=>Math.abs(j.time-d)<1e-6),k=C(a,f,d);return{...p,id:p?.id||B(),time:d,position:k.position,rotation:k.rotation,scale:k.scale,bones:h}};let c=[...s];if(!s.some(d=>d.bones)&&i>1e-6){const d=t(0,{...a.rig?.bones||{}});c=[...c.filter(h=>h.id!==d.id),d]}const m=U(c,i,a.rig?.bones),{poseEase:g,...b}=t(i,{...m,...e}),l=r&&r!=="smooth"?{...b,poseEase:r}:b;return c=[...c.filter(d=>d.id!==l.id),l].sort((d,h)=>d.time-h.time),{...u,shots:u.shots.map(d=>d.id===f.id?{...d,objectKeys:{...d.objectKeys,[n.id]:c}}:d)}})}async function N(o,n){const i=o.engine();if(!i)return null;for(let e=0;e<200;e++){i.sync(o.getStage(),null);const r=i.objects.children.find(u=>u.userData.id===n)?.children[0];if(r)return r;await new Promise(u=>setTimeout(u,100))}return null}async function I(o,n){const i=v(o.getStage(),String(n.name));if(i.kind!=="model"||!i.model)return{ok:!1,error:`'${i.name}' is not a GLB model; people (mannequins) are already posable`};const e=String(n.kind??"humanoid");if(!A.includes(e))return{ok:!1,error:`unknown kind '${e}'; use ${A.join(", ")}`};const r=[];let u=n.ai===!0;if(u&&e!=="humanoid")return{ok:!1,error:"the AI auto-rig is for humanoid characters only; use the free template of that kind (ai:false)"};u&&!q(o.userText)&&(u=!1,r.push("ai:true refused — the user did not ask for the paid AI auto-rig; the free humanoid template was used (no credits). Only use ai:true when the user explicitly asks for AI / auto-rig."));const f=await N(o,i.id);if(!f)return{ok:!1,error:`${i.name} is not loaded (renderer not ready or the GLB failed to load)`};const a=e==="humanoid"&&!u&&n.file_skeleton!==!1?o.engine()?.nativeSkeleton?.(i.id):null;if(a?.ok)return o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:void 0,skeleton:"native"}:d)})),o.engine()?.sync(o.getStage(),null),{ok:!0,name:i.name,rig:"humanoid",source:"file",bones:a.bones,fileBones:a.total,credits:0,paid:!1,...r.length?{notes:r}:{},hint:"the model plays on its own skeleton and skin from the file (as in Blender): set_pose, play_motion, stage_spell_duel, hold_prop and set_gaze work on it"};const s=L(f);if(s.isEmpty())return{ok:!1,error:`${i.name} has no geometry to rig`};let t,c=0,m=null;if(u){const l=(o.rigViews??(await K(async()=>{const{renderRigViews:k}=await import("./views-RQBs4zva.js");return{renderRigViews:k}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17]))).renderRigViews)(f),d=o.rigAgent??(await K(async()=>{const{rigAgent:k}=await import("./api-Dnl2uaKO.js").then(j=>j.bV);return{rigAgent:k}},__vite__mapDeps([7,8,6,5]))).rigAgent,h={requestId:B(),front:l.front,side:l.side,name:i.name};let p;try{p=await d(h)}catch(k){if(!(k instanceof TypeError))return{ok:!1,error:k.message||"AI auto-rig failed (no credits charged)"};p=await d(h)}if(!p.humanoid||!p.landmarks||!p.landmarks.humanoid)return{ok:!1,error:"the AI did not see a humanoid in this model; no credits were charged. Use a free template: quadruped / chain / hinge / wheels, or humanoid.",credits:0};t=V(p.landmarks,l.frame),c=p.credits,m=z(p.landmarks,l.frame)}else{const l=e==="humanoid"?H(f):null;t=F(e,{min:s.min.toArray(),max:s.max.toArray()},{segments:Number(n.segments)||4,...l?{tips:l}:{}})}e==="humanoid"&&n.fingers!==!1&&(t=E(t,{positions:T(f).positions,tips:m})),o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:t,skeleton:void 0}:d)}));const g=o.engine();let b;if(g){g.sync(o.getStage(),null),await g.rigReady();const l=g.objects.children.find(d=>d.userData.id===i.id)?.children[0]?.userData.rig;l&&(b={vertices:l.info.vertices,ms:l.info.ms,source:l.info.source})}return{ok:!0,name:i.name,rig:t.kind,source:t.source,joints:t.joints.length,fingers:_(t),bones:w(t).filter(l=>!M(l)),credits:c,paid:u,...b?{weights:b}:{},...r.length?{notes:r}:{},hint:t.kind==="humanoid"?"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze, resolve_hits now work on it; set_bone_rotation / set_bone_keys turn single bones":"turn its bones with set_bone_rotation / set_bone_keys (time = a key)"}}async function Q(o,n){const i=o.getStage(),e=v(i,String(n.name)),r=String(n.action||"");if(e.locked)return{ok:!1,error:`${e.name} is locked in the composer`};const u=s=>s.map(t=>(({bones:c,...m})=>m)(t));if(r==="remove")return!e.rig&&e.skeleton!=="native"?{ok:!1,error:`${e.name} has no skeleton`}:(o.setStage(s=>({...s,items:s.items.map(t=>t.id!==e.id?t:(({rig:c,skeleton:m,...g})=>g)(t)),shots:s.shots.map(t=>t.objectKeys?.[e.id]?{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}}:t)})),{ok:!0,name:e.name,removed:"skeleton and its bone keys"});if(!e.rig)return{ok:!1,error:`${e.name} has no editable skeleton; rig_template gives it one`};if(r==="reset_bones")return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id&&t.rig?{...t,rig:(({bones:c,...m})=>m)(t.rig)}:t),shots:s.shots.map(t=>t.id!==s.activeShot||!t.objectKeys?.[e.id]?t:{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}})})),{ok:!0,name:e.name,reset:"every bone back to rest (bone keys of this shot removed)"};const f=await N(o,e.id);if(!f)return{ok:!1,error:`${e.name} is not loaded (it needs the 3D view: a scene open in the composer or the render machine)`};let a;if(r==="mirror"){const s=L(f);a=G(e.rig,(s.min.x+s.max.x)/2)}else if(r==="fingers")a=n.on===!1?P(e.rig):_(e.rig)?e.rig:E(e.rig,{positions:T(f).positions});else return{ok:!1,error:"action must be remove, reset_bones, mirror or fingers"};return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id?{...t,rig:a}:t)})),{ok:!0,name:e.name,action:r,joints:a.joints.length,fingers:_(a)}}async function ge(o,n,i){try{if(o==="auto_rig")return await I(i,n);if(o==="rig_template")return await I(i,{...n,ai:!1});if(o==="rig_edit")return await Q(i,n);const e=i.getStage(),r=v(e,String(n.name)),u=y(e);if(!r.rig)return{ok:!1,error:`${r.name} has no skeleton; call auto_rig first (people mannequins use set_pose)`};const f=n.ease==null?void 0:String(n.ease);if(f&&!["smooth","snap","hold","overshoot"].includes(f))return{ok:!1,error:`unknown ease '${f}'`};if(o==="set_bone_rotation"){const a=x(r.rig,String(n.bone??"")),s=R(n.rotation_deg);if(!a)return{ok:!1,error:`unknown bone '${String(n.bone)}' of ${r.name}; bones: ${w(r.rig).join(", ")}`};if(!s)return{ok:!1,error:"rotation_deg must be [x, y, z] degrees"};if(n.time==null)return i.setStage(c=>({...c,items:c.items.map(m=>{if(m.id!==r.id||!m.rig)return m;const g={...m.rig.bones||{},[a]:s};return s.every(b=>b===0)&&delete g[a],{...m,rig:{...m.rig,...Object.keys(g).length?{bones:g}:{bones:void 0}}}}),shots:c.shots.map(m=>m.id!==c.activeShot||!m.objectKeys?.[r.id]?.some(g=>g.bones)?m:{...m,objectKeys:{...m.objectKeys,[r.id]:m.objectKeys[r.id].map(g=>g.bones?{...g,bones:{...g.bones,[a]:s}}:g)}})})),{ok:!0,name:r.name,bone:a,rotation_deg:s,whole_shot:!0};const t=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,t,{[a]:s},f),{ok:!0,name:r.name,bone:a,rotation_deg:s,time:Number(n.time),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(c=>c.bones).length}}if(o==="set_bone_keys"){if(n.time==null)return{ok:!1,error:"set_bone_keys needs time (seconds); use set_bone_rotation without time for the whole shot"};const a=n.bones&&typeof n.bones=="object"&&!Array.isArray(n.bones)?Object.entries(n.bones):[];if(!a.length)return{ok:!1,error:"bones must map bone names to [x, y, z] degrees"};const s={},t=[];for(const[m,g]of a.slice(0,S.joints)){const b=x(r.rig,m),l=R(g);!b||!l?t.push(m):s[b]=l}if(t.length)return{ok:!1,error:`unknown bones or bad angles: ${t.join(", ")}; bones: ${w(r.rig).join(", ")}`};const c=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,c,s,f),{ok:!0,name:r.name,time:Number(n.time),bones_set:Object.keys(s),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(m=>m.bones).length}}return{ok:!1,error:`unknown tool '${o}'`}}catch(e){return{ok:!1,error:e.message||String(e)}}}export{A as RIG_TEMPLATE_KINDS,fe as rigSummary,ge as runRigTool,w as turnableBones};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-
|
|
2
|
-
import{_ as X}from"./titleFrameBudget-X7HLSDre.js";import{Vector3 as y,Quaternion as P,Matrix4 as f0,MathUtils as d0}from"./three.module-Bx43vjkH.js";import{fq as u0,c$ as G,cm as g0}from"./remote-DJd9xWjn.js";import"./index-CKtv7gGE.js";import"./i18n-BJppIrtF.js";import"./api-BFN7blbw.js";import"./gltfLoader-U0Eebg7v.js";import"./store-GFMJzaWS.js";import"./rotoMaskStore-DdpmT9C3.js";import"./sceneTrack-Bbov7zET.js";import"./timelineOps-afzSo188.js";import"./cameraTracker-BAQHuTV-.js";import"./textAnimators-BVXTl8bU.js";import"./timelineComp-Dx_kED5V.js";import"./rigTrack-XaMj1yaH.js";import"./clientJobs-CuuUyhEy.js";const S=[["Hips",-1,[-0,.998041,-.04945],[0,0,1,.999907,.0136606,-0,-.0136606,.999907,0]],["Spine1",0,[.051311,593e-6,-0],[0,0,1,.999761,.021882,-0,-.021882,.999761,0]],["Spine2",1,[.072061,-0,-0],[0,0,1,.996725,.0808625,-0,-.0808625,.996725,0]],["Chest",2,[.07262,-666e-6,0],[0,-0,1,.999994,.0035373,-0,-.0035373,.999994,0]],["Neck1",3,[.263508,0,-0],[0,-0,1,.955736,-.294227,-0,.294227,.955736,0]],["Neck2",4,[.078721,-0,-0],[0,-0,1,.955736,-.294227,-0,.294227,.955736,0]],["Head",5,[.066593,0,-0],[0,0,1,.99186,.127333,-0,-.127333,.99186,0]],["Jaw",6,[.001112,.030213,-0],[0,-0,1,.993077,.117469,0,-.117469,.993077,0]],["LeftEye",6,[.042952,.08224,.031058],[.0044487,.0660371,.997807,.997739,-.0672143,0,.0670669,.995551,-.0661868]],["RightEye",6,[.042952,.08224,-.031058],[-.0044487,-.0660372,.997807,.997739,-.0672143,0,.0670669,.995551,.0661868]],["LeftShoulder",3,[.233884,.050382,.016136],[.921321,.345331,-.178644,-.167278,-.0627034,-.983914,-.350978,.936384,-38e-7]],["LeftArm",10,[.15743,0,-0],[.625469,.30709,-.717276,-.779093,.295836,-.552716,.0424628,.904531,.424287]],["LeftForeArm",11,[.28916,0,-0],[.696738,.0084563,-.717276,-.576315,.601968,-.552716,.427104,.798475,.424287]],["LeftHand",12,[.270262,0,-0],[.569773,-.372535,-.732514,-.632077,.370991,-.680326,.525201,.850637,-.0240902]],["LeftHandThumbEnd",13,[.113477,.077498,.039575],[.140756,-.990044,-79e-7,-.551423,-.0783898,-.830535,.822266,.116907,-.556967]],["LeftHandMiddleEnd",13,[.182395,-.008716,.031144],[.133607,-.0617277,-.98911,-.897912,.41484,-.147177,.419408,.907798,-5e-7]],["RightShoulder",3,[.233885,.050382,-.016167],[.921321,.345322,-.178662,.167297,.0627049,.983911,.350969,-.936387,1e-7]],["RightArm",16,[-.157431,-0,0],[.625486,.307069,-.71727,.779079,-.295836,.552736,-.042466,-.904538,-.424272]],["RightForeArm",17,[-.289151,-0,0],[.696744,.0084371,-.71727,.576308,-.601957,.552736,-.427102,-.798484,-.424272]],["RightHand",18,[-.270262,-0,0],[.569771,-.372527,-.732519,.63209,-.370982,.680319,-.525189,-.850644,.024096]],["RightHandThumbEnd",19,[-.113478,-.077498,-.039576],[.140744,-.990046,0,.551427,.0783904,.830532,-.822265,-.116892,.556971]],["RightHandMiddleEnd",19,[-.182397,.008714,-.031142],[.133623,-.061737,-.989107,.897903,-.414853,.147196,-.419421,-.907792,-0]],["LeftLeg",0,[-.083079,.021259,.100069],[.069814,-.0161318,.99743,-.995982,-.0573394,.0687854,.0560824,-.998224,-.02007]],["LeftShin",22,[.433003,-0,-0],[.0623291,-.0353456,.99743,-.97107,.228674,.0687854,-.230517,-.972861,-.02007]],["LeftFoot",23,[.424241,0,-0],[.181266,-.0693106,.980989,-.357152,-.934046,0,.916289,-.350362,-.194065]],["LeftToeBase",24,[.141328,-0,0],[.184973,-.0537256,.981274,-.278923,-.960313,0,.94233,-.2737,-.192618]],["RightLeg",0,[-.083079,.021259,-.100015],[.0698141,-.0161298,.99743,.995982,.0573387,-.0687855,-.0560818,.998224,.020068]],["RightShin",26,[-.433004,0,-0],[.0623297,-.0353437,.99743,.97107,-.228674,-.0687855,.230517,.972861,.020068]],["RightFoot",27,[-.42424,-0,-0],[.181266,-.0693107,.980989,.357152,.934046,-0,-.916289,.350362,.194065]],["RightToeBase",28,[-.141328,0,-0],[.184973,-.0537262,.981274,.278927,.960312,-0,-.942329,.273704,.192617]]],E=30,F=4,l0={Hips:"Hips",Spine1:"Spine",Spine2:"Spine1",Chest:"Spine2",Neck1:"Neck",Neck2:"Neck",Head:"Head",Jaw:"Head",LeftEye:"Head",RightEye:"Head",LeftShoulder:"LeftShoulder",LeftArm:"LeftArm",LeftForeArm:"LeftForeArm",LeftHand:"LeftHand",LeftHandThumbEnd:"LeftHand",LeftHandMiddleEnd:"LeftHand",RightShoulder:"RightShoulder",RightArm:"RightArm",RightForeArm:"RightForeArm",RightHand:"RightHand",RightHandThumbEnd:"RightHand",RightHandMiddleEnd:"RightHand",LeftLeg:"LeftUpLeg",LeftShin:"LeftLeg",LeftFoot:"LeftFoot",LeftToeBase:"LeftToeBase",RightLeg:"RightUpLeg",RightShin:"RightLeg",RightFoot:"RightFoot",RightToeBase:"RightToeBase"},e0=[...new Set(Object.values(l0))],w0=S.map(o=>o[0]),Y=S.length,O=S.map(o=>o[1]),L0=S.map(o=>new y(...o[2])),y0=S.map(o=>{const n=o[3];return new P().setFromRotationMatrix(new f0().set(n[0],n[1],n[2],0,n[3],n[4],n[5],0,n[6],n[7],n[8],0,0,0,0,1))});S[0][2][1];function R0(o){const n=new Array(Y);for(let i=0;i<Y;i++)n[i]=O[i]<0?new y:L0[i].clone().applyQuaternion(o[O[i]]).add(n[O[i]]);return n}R0(y0);const w=1e-6,l=o=>Math.round(o*1e3)/1e3,b0=[["hips","Hips"],["neck","Neck1"],["upL","RightArm"],["foreL","RightForeArm"],["handL","RightHand"],["upR","LeftArm"],["foreR","LeftForeArm"],["handR","LeftHand"],["thighL","RightLeg"],["shinL","RightShin"],["footL","RightFoot"],["thighR","LeftLeg"],["shinR","LeftShin"],["footR","LeftFoot"]],E0=[["head","Head"],["toeL","RightToeBase"],["toeR","LeftToeBase"],["eyeA","LeftEye"],["eyeB","RightEye"]],Z=Object.fromEntries(w0.map((o,n)=>[o,n])),o0=(o,n)=>(o.objectKeys?.[n]||[]).filter(i=>i.pose).sort((i,r)=>i.time-r.time);function S0(o,n,i){const r=o0(o,n),h=Math.max(w,o.duration),d=.5/E/h;if(r.length<2)return{error:"needs two pose keys"};const c=e=>r.reduce((m,f)=>Math.abs(f.time-e)<Math.abs(m.time-e)?f:m);if(i.from!=null||i.to!=null){const e=i.from!=null?c(i.from):null,m=i.to!=null?c(i.to):null;if(e&&Math.abs(e.time-i.from)>d)return{error:`no pose key at ${l(i.from*h)} s`};if(m&&Math.abs(m.time-i.to)>d)return{error:`no pose key at ${l(i.to*h)} s`};const f=e??[...r].reverse().find(b=>b.time<m.time-w),R=m??r.find(b=>b.time>e.time+w);return!f||!R||R.time<=f.time+w?{error:"key B must come after key A"}:{a:f,b:R}}const u=i.at??0;let s=0;return r.forEach((e,m)=>{e.time<=u+d&&(s=m)}),s>=r.length-1&&(s=r.length-2),{a:r[s],b:r[s+1]}}function t0(o,n,i){o.userData.bot.repose(n.pose??{}),o.updateMatrixWorld(!0);const h=new P().setFromAxisAngle(new y(0,1,0),d0.degToRad(n.rotation[1]||0)),d=n.scale?.[1]||1,c=new y(n.position[0],n.position[1]-i,n.position[2]),u={};for(const s of e0){const e=o.getObjectByName(`mixamorig${s}`);if(!e)throw new Error(`mannequin bone missing: ${s}`);const m=e.getWorldPosition(new y).multiplyScalar(d).applyQuaternion(h).add(c),f=h.clone().multiply(e.getWorldQuaternion(new P));u[s]={q:f.toArray(),p:m.toArray()}}return u}async function A0(o,n,i,r){const h=o.shots.find(t=>t.id===o.activeShot),d=o.items.find(t=>t.id===n);if(!h||!d)throw new Error("person not found");const c=Math.max(w,h.duration),u=S0(h,n,i);if("error"in u)throw new Error(u.error);const{a:s,b:e}=u,m=(e.time-s.time)*c,f=await r.bot(d),R={},b=f.userData.botRest;if(!b)throw new Error("mannequin not ready");const n0=d.scale?.[1]||1;for(const t of e0){const a=b[t];if(!a)throw new Error(`mannequin bone missing: ${t}`);R[t]={q:a.q,p:a.p.map(p=>p*n0)}}const x=t=>g0(d,h,Math.max(0,Math.min(c,t))/c),M=s.time*c,H=e.time*c,_=x(M).position[1],j=Array.from({length:F},(t,a)=>x(M-(F-1-a)/E)),D=j.map(t=>t0(f,t,_)),i0=Array.from({length:4},(t,a)=>t0(f,x(H+a/E),_)),T=await r.call({rest:R,context:D,target:i0,seconds:Math.round(m*1e3)/1e3}),g=T.frames.length;if(g<2)throw new Error("the model returned no motion");const $=t=>new y(t[0],t[1]+_,t[2]),q=T.frames.map(t=>({f:Object.fromEntries(b0.map(([a,p])=>[a,$(t.p[Z[p]])])),x:Object.fromEntries(E0.map(([a,p])=>[a,$(t.p[Z[p]])]))})),r0=Math.min(...q.map(({f:t})=>Math.min(t.footL.y,t.footR.y))),J=new y(...D[F-1].Hips.p).setY(0),K=j[F-1].position,z={x:J.x-K[0],z:J.z-K[2]},C=s.pose??{},B=e.pose??{};let L=q.map(({f:t,x:a},p)=>{const A=u0(t,a),W=(p+1)/g,N=Math.min(t.footL.y,t.footR.y)-r0;return{pose:{...W<.5?C:B,...G(C,B,W),...A.pose},position:[t.hips.x-z.x,_+(N>.04?N:0),t.hips.z-z.z],yaw:A.yaw,air:N>.04}});const U=L[g-1],Q=t=>(t%360+540)%360-180;let v=s.rotation[1];L=L.map(t=>{const a=v+Q(t.yaw-v);return v=a,{...t,yaw:a}});const a0=e.position[0]-U.position[0],s0=e.position[2]-U.position[2],m0=Q(e.rotation[1]-L[g-1].yaw),V=Math.min(8,g);L=L.map((t,a)=>{const p=(a+1)/g,A=Math.max(0,(a-(g-V))/Math.max(1,V-1));return{...t,position:[l(t.position[0]+a0*p),l(t.position[1]),l(t.position[2]+s0*p)],yaw:Math.round((t.yaw+m0*p)*10)/10,pose:A>0?{...t.pose,...G(t.pose,B,A)}:t.pose}});const k=g/E,h0=k>=m?m:Math.min(m,k*1.35),c0=r.newId??(()=>crypto.randomUUID()),I=[];L.forEach((t,a)=>{const p=M+(a+1)/g*h0;p>=H-.5/E||a%2===1&&a!==g-1&&p<H-1.5/E||I.push({id:c0(),time:p/c,position:t.position,rotation:[s.rotation[0],t.yaw,s.rotation[2]],scale:s.scale,pose:t.pose,auto:"mocap",...t.air?{air:!0}:{}})});const p0=[...(h.objectKeys?.[n]||[]).filter(t=>t.time<=s.time+w||t.time>=e.time-w),...I].sort((t,a)=>t.time-a.time);return{stage:{...o,shots:o.shots.map(t=>t.id===h.id?{...t,objectKeys:{...t.objectKeys,[n]:p0}}:t)},keys:I.length,from_s:l(M),to_s:l(H),gap_s:l(m),motion_s:l(k),tight:k/m>1.35,end_gap_m:T.endGap}}async function M0(){const{ShotEngine:o}=await X(async()=>{const{ShotEngine:r}=await import("./remote-DJd9xWjn.js").then(h=>h.fM);return{ShotEngine:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),n=await X(()=>import("./api-BFN7blbw.js").then(r=>r.bV),__vite__mapDeps([3,4,2,1])),i=o.bot;if(!i)throw new Error("mannequin not available");return i.ready()||await i.load(),{bot:r=>i.build(r.pose??{},"#888888",void 0,"x"),call:r=>n.shotInbetween(r)}}async function K0(o,n,i){const r=n.getStage(),h=r.shots.find(e=>e.id===r.activeShot),d=String(o.name??"").trim().toLowerCase(),c=r.items.find(e=>e.id===o.name||e.name.trim().toLowerCase()===d);if(!h||!c)return{ok:!1,error:`no person named '${String(o.name??"")}'`};if(c.kind!=="person")return{ok:!1,error:`'${c.name}' is not a person`};const u=Math.max(w,h.duration),s=e=>o[e]==null?void 0:Math.max(0,Math.min(u,Number(o[e])||0))/u;try{const e=await A0(r,c.id,{at:s("at"),from:s("from"),to:s("to")},i??await M0());return n.setStage(()=>e.stage),{ok:!0,name:c.name,...e,stage:void 0,...e.tight?{note:`the move wants ~${e.motion_s} s but the gap is ${e.gap_s} s: it was sped up — move key B later for a calmer move`}:{}}}catch(e){const m=o0(h,c.id).map(f=>l(f.time*u));return{ok:!1,error:e.message,pose_keys_s:m}}}export{A0 as aiInbetween,M0 as editorInbetweenDeps,S0 as inbetweenKeys,K0 as inbetweenTool};
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-8XzEAnAJ.js","assets/index-CKtv7gGE.js","assets/i18n-C9zFX25m.js","assets/api-Dnl2uaKO.js","assets/titleFrameBudget-DsM0V482.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-CpqHUcA2.js","assets/rotoMaskStore-pE1AIt3I.js","assets/sceneTrack-DlAH5s74.js","assets/timelineOps-DSSaDsU2.js","assets/cameraTracker-DHdF8Zqx.js","assets/textAnimators-B9vO_hbP.js","assets/timelineComp-i-zdaoB2.js","assets/rigTrack-DMyqb0pb.js","assets/clientJobs-CuuUyhEy.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as X}from"./titleFrameBudget-DsM0V482.js";import{Vector3 as y,Quaternion as P,Matrix4 as f0,MathUtils as d0}from"./three.module-Bx43vjkH.js";import{fq as u0,c$ as G,cm as g0}from"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const S=[["Hips",-1,[-0,.998041,-.04945],[0,0,1,.999907,.0136606,-0,-.0136606,.999907,0]],["Spine1",0,[.051311,593e-6,-0],[0,0,1,.999761,.021882,-0,-.021882,.999761,0]],["Spine2",1,[.072061,-0,-0],[0,0,1,.996725,.0808625,-0,-.0808625,.996725,0]],["Chest",2,[.07262,-666e-6,0],[0,-0,1,.999994,.0035373,-0,-.0035373,.999994,0]],["Neck1",3,[.263508,0,-0],[0,-0,1,.955736,-.294227,-0,.294227,.955736,0]],["Neck2",4,[.078721,-0,-0],[0,-0,1,.955736,-.294227,-0,.294227,.955736,0]],["Head",5,[.066593,0,-0],[0,0,1,.99186,.127333,-0,-.127333,.99186,0]],["Jaw",6,[.001112,.030213,-0],[0,-0,1,.993077,.117469,0,-.117469,.993077,0]],["LeftEye",6,[.042952,.08224,.031058],[.0044487,.0660371,.997807,.997739,-.0672143,0,.0670669,.995551,-.0661868]],["RightEye",6,[.042952,.08224,-.031058],[-.0044487,-.0660372,.997807,.997739,-.0672143,0,.0670669,.995551,.0661868]],["LeftShoulder",3,[.233884,.050382,.016136],[.921321,.345331,-.178644,-.167278,-.0627034,-.983914,-.350978,.936384,-38e-7]],["LeftArm",10,[.15743,0,-0],[.625469,.30709,-.717276,-.779093,.295836,-.552716,.0424628,.904531,.424287]],["LeftForeArm",11,[.28916,0,-0],[.696738,.0084563,-.717276,-.576315,.601968,-.552716,.427104,.798475,.424287]],["LeftHand",12,[.270262,0,-0],[.569773,-.372535,-.732514,-.632077,.370991,-.680326,.525201,.850637,-.0240902]],["LeftHandThumbEnd",13,[.113477,.077498,.039575],[.140756,-.990044,-79e-7,-.551423,-.0783898,-.830535,.822266,.116907,-.556967]],["LeftHandMiddleEnd",13,[.182395,-.008716,.031144],[.133607,-.0617277,-.98911,-.897912,.41484,-.147177,.419408,.907798,-5e-7]],["RightShoulder",3,[.233885,.050382,-.016167],[.921321,.345322,-.178662,.167297,.0627049,.983911,.350969,-.936387,1e-7]],["RightArm",16,[-.157431,-0,0],[.625486,.307069,-.71727,.779079,-.295836,.552736,-.042466,-.904538,-.424272]],["RightForeArm",17,[-.289151,-0,0],[.696744,.0084371,-.71727,.576308,-.601957,.552736,-.427102,-.798484,-.424272]],["RightHand",18,[-.270262,-0,0],[.569771,-.372527,-.732519,.63209,-.370982,.680319,-.525189,-.850644,.024096]],["RightHandThumbEnd",19,[-.113478,-.077498,-.039576],[.140744,-.990046,0,.551427,.0783904,.830532,-.822265,-.116892,.556971]],["RightHandMiddleEnd",19,[-.182397,.008714,-.031142],[.133623,-.061737,-.989107,.897903,-.414853,.147196,-.419421,-.907792,-0]],["LeftLeg",0,[-.083079,.021259,.100069],[.069814,-.0161318,.99743,-.995982,-.0573394,.0687854,.0560824,-.998224,-.02007]],["LeftShin",22,[.433003,-0,-0],[.0623291,-.0353456,.99743,-.97107,.228674,.0687854,-.230517,-.972861,-.02007]],["LeftFoot",23,[.424241,0,-0],[.181266,-.0693106,.980989,-.357152,-.934046,0,.916289,-.350362,-.194065]],["LeftToeBase",24,[.141328,-0,0],[.184973,-.0537256,.981274,-.278923,-.960313,0,.94233,-.2737,-.192618]],["RightLeg",0,[-.083079,.021259,-.100015],[.0698141,-.0161298,.99743,.995982,.0573387,-.0687855,-.0560818,.998224,.020068]],["RightShin",26,[-.433004,0,-0],[.0623297,-.0353437,.99743,.97107,-.228674,-.0687855,.230517,.972861,.020068]],["RightFoot",27,[-.42424,-0,-0],[.181266,-.0693107,.980989,.357152,.934046,-0,-.916289,.350362,.194065]],["RightToeBase",28,[-.141328,0,-0],[.184973,-.0537262,.981274,.278927,.960312,-0,-.942329,.273704,.192617]]],E=30,F=4,l0={Hips:"Hips",Spine1:"Spine",Spine2:"Spine1",Chest:"Spine2",Neck1:"Neck",Neck2:"Neck",Head:"Head",Jaw:"Head",LeftEye:"Head",RightEye:"Head",LeftShoulder:"LeftShoulder",LeftArm:"LeftArm",LeftForeArm:"LeftForeArm",LeftHand:"LeftHand",LeftHandThumbEnd:"LeftHand",LeftHandMiddleEnd:"LeftHand",RightShoulder:"RightShoulder",RightArm:"RightArm",RightForeArm:"RightForeArm",RightHand:"RightHand",RightHandThumbEnd:"RightHand",RightHandMiddleEnd:"RightHand",LeftLeg:"LeftUpLeg",LeftShin:"LeftLeg",LeftFoot:"LeftFoot",LeftToeBase:"LeftToeBase",RightLeg:"RightUpLeg",RightShin:"RightLeg",RightFoot:"RightFoot",RightToeBase:"RightToeBase"},e0=[...new Set(Object.values(l0))],w0=S.map(o=>o[0]),Y=S.length,O=S.map(o=>o[1]),L0=S.map(o=>new y(...o[2])),y0=S.map(o=>{const n=o[3];return new P().setFromRotationMatrix(new f0().set(n[0],n[1],n[2],0,n[3],n[4],n[5],0,n[6],n[7],n[8],0,0,0,0,1))});S[0][2][1];function R0(o){const n=new Array(Y);for(let i=0;i<Y;i++)n[i]=O[i]<0?new y:L0[i].clone().applyQuaternion(o[O[i]]).add(n[O[i]]);return n}R0(y0);const w=1e-6,l=o=>Math.round(o*1e3)/1e3,b0=[["hips","Hips"],["neck","Neck1"],["upL","RightArm"],["foreL","RightForeArm"],["handL","RightHand"],["upR","LeftArm"],["foreR","LeftForeArm"],["handR","LeftHand"],["thighL","RightLeg"],["shinL","RightShin"],["footL","RightFoot"],["thighR","LeftLeg"],["shinR","LeftShin"],["footR","LeftFoot"]],E0=[["head","Head"],["toeL","RightToeBase"],["toeR","LeftToeBase"],["eyeA","LeftEye"],["eyeB","RightEye"]],Z=Object.fromEntries(w0.map((o,n)=>[o,n])),o0=(o,n)=>(o.objectKeys?.[n]||[]).filter(i=>i.pose).sort((i,r)=>i.time-r.time);function S0(o,n,i){const r=o0(o,n),h=Math.max(w,o.duration),d=.5/E/h;if(r.length<2)return{error:"needs two pose keys"};const c=e=>r.reduce((m,f)=>Math.abs(f.time-e)<Math.abs(m.time-e)?f:m);if(i.from!=null||i.to!=null){const e=i.from!=null?c(i.from):null,m=i.to!=null?c(i.to):null;if(e&&Math.abs(e.time-i.from)>d)return{error:`no pose key at ${l(i.from*h)} s`};if(m&&Math.abs(m.time-i.to)>d)return{error:`no pose key at ${l(i.to*h)} s`};const f=e??[...r].reverse().find(b=>b.time<m.time-w),R=m??r.find(b=>b.time>e.time+w);return!f||!R||R.time<=f.time+w?{error:"key B must come after key A"}:{a:f,b:R}}const u=i.at??0;let s=0;return r.forEach((e,m)=>{e.time<=u+d&&(s=m)}),s>=r.length-1&&(s=r.length-2),{a:r[s],b:r[s+1]}}function t0(o,n,i){o.userData.bot.repose(n.pose??{}),o.updateMatrixWorld(!0);const h=new P().setFromAxisAngle(new y(0,1,0),d0.degToRad(n.rotation[1]||0)),d=n.scale?.[1]||1,c=new y(n.position[0],n.position[1]-i,n.position[2]),u={};for(const s of e0){const e=o.getObjectByName(`mixamorig${s}`);if(!e)throw new Error(`mannequin bone missing: ${s}`);const m=e.getWorldPosition(new y).multiplyScalar(d).applyQuaternion(h).add(c),f=h.clone().multiply(e.getWorldQuaternion(new P));u[s]={q:f.toArray(),p:m.toArray()}}return u}async function A0(o,n,i,r){const h=o.shots.find(t=>t.id===o.activeShot),d=o.items.find(t=>t.id===n);if(!h||!d)throw new Error("person not found");const c=Math.max(w,h.duration),u=S0(h,n,i);if("error"in u)throw new Error(u.error);const{a:s,b:e}=u,m=(e.time-s.time)*c,f=await r.bot(d),R={},b=f.userData.botRest;if(!b)throw new Error("mannequin not ready");const n0=d.scale?.[1]||1;for(const t of e0){const a=b[t];if(!a)throw new Error(`mannequin bone missing: ${t}`);R[t]={q:a.q,p:a.p.map(p=>p*n0)}}const x=t=>g0(d,h,Math.max(0,Math.min(c,t))/c),M=s.time*c,H=e.time*c,_=x(M).position[1],j=Array.from({length:F},(t,a)=>x(M-(F-1-a)/E)),D=j.map(t=>t0(f,t,_)),i0=Array.from({length:4},(t,a)=>t0(f,x(H+a/E),_)),T=await r.call({rest:R,context:D,target:i0,seconds:Math.round(m*1e3)/1e3}),g=T.frames.length;if(g<2)throw new Error("the model returned no motion");const $=t=>new y(t[0],t[1]+_,t[2]),q=T.frames.map(t=>({f:Object.fromEntries(b0.map(([a,p])=>[a,$(t.p[Z[p]])])),x:Object.fromEntries(E0.map(([a,p])=>[a,$(t.p[Z[p]])]))})),r0=Math.min(...q.map(({f:t})=>Math.min(t.footL.y,t.footR.y))),J=new y(...D[F-1].Hips.p).setY(0),K=j[F-1].position,z={x:J.x-K[0],z:J.z-K[2]},C=s.pose??{},B=e.pose??{};let L=q.map(({f:t,x:a},p)=>{const A=u0(t,a),W=(p+1)/g,N=Math.min(t.footL.y,t.footR.y)-r0;return{pose:{...W<.5?C:B,...G(C,B,W),...A.pose},position:[t.hips.x-z.x,_+(N>.04?N:0),t.hips.z-z.z],yaw:A.yaw,air:N>.04}});const U=L[g-1],Q=t=>(t%360+540)%360-180;let v=s.rotation[1];L=L.map(t=>{const a=v+Q(t.yaw-v);return v=a,{...t,yaw:a}});const a0=e.position[0]-U.position[0],s0=e.position[2]-U.position[2],m0=Q(e.rotation[1]-L[g-1].yaw),V=Math.min(8,g);L=L.map((t,a)=>{const p=(a+1)/g,A=Math.max(0,(a-(g-V))/Math.max(1,V-1));return{...t,position:[l(t.position[0]+a0*p),l(t.position[1]),l(t.position[2]+s0*p)],yaw:Math.round((t.yaw+m0*p)*10)/10,pose:A>0?{...t.pose,...G(t.pose,B,A)}:t.pose}});const k=g/E,h0=k>=m?m:Math.min(m,k*1.35),c0=r.newId??(()=>crypto.randomUUID()),I=[];L.forEach((t,a)=>{const p=M+(a+1)/g*h0;p>=H-.5/E||a%2===1&&a!==g-1&&p<H-1.5/E||I.push({id:c0(),time:p/c,position:t.position,rotation:[s.rotation[0],t.yaw,s.rotation[2]],scale:s.scale,pose:t.pose,auto:"mocap",...t.air?{air:!0}:{}})});const p0=[...(h.objectKeys?.[n]||[]).filter(t=>t.time<=s.time+w||t.time>=e.time-w),...I].sort((t,a)=>t.time-a.time);return{stage:{...o,shots:o.shots.map(t=>t.id===h.id?{...t,objectKeys:{...t.objectKeys,[n]:p0}}:t)},keys:I.length,from_s:l(M),to_s:l(H),gap_s:l(m),motion_s:l(k),tight:k/m>1.35,end_gap_m:T.endGap}}async function M0(){const{ShotEngine:o}=await X(async()=>{const{ShotEngine:r}=await import("./remote-8XzEAnAJ.js").then(h=>h.fM);return{ShotEngine:r}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),n=await X(()=>import("./api-Dnl2uaKO.js").then(r=>r.bV),__vite__mapDeps([3,4,2,1])),i=o.bot;if(!i)throw new Error("mannequin not available");return i.ready()||await i.load(),{bot:r=>i.build(r.pose??{},"#888888",void 0,"x"),call:r=>n.shotInbetween(r)}}async function K0(o,n,i){const r=n.getStage(),h=r.shots.find(e=>e.id===r.activeShot),d=String(o.name??"").trim().toLowerCase(),c=r.items.find(e=>e.id===o.name||e.name.trim().toLowerCase()===d);if(!h||!c)return{ok:!1,error:`no person named '${String(o.name??"")}'`};if(c.kind!=="person")return{ok:!1,error:`'${c.name}' is not a person`};const u=Math.max(w,h.duration),s=e=>o[e]==null?void 0:Math.max(0,Math.min(u,Number(o[e])||0))/u;try{const e=await A0(r,c.id,{at:s("at"),from:s("from"),to:s("to")},i??await M0());return n.setStage(()=>e.stage),{ok:!0,name:c.name,...e,stage:void 0,...e.tight?{note:`the move wants ~${e.motion_s} s but the gap is ${e.gap_s} s: it was sped up — move key B later for a calmer move`}:{}}}catch(e){const m=o0(h,c.id).map(f=>l(f.time*u));return{ok:!1,error:e.message,pose_keys_s:m}}}export{A0 as aiInbetween,M0 as editorInbetweenDeps,S0 as inbetweenKeys,K0 as inbetweenTool};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as v}from"./store-
|
|
1
|
+
import{u as v}from"./store-CpqHUcA2.js";import{t as S}from"./i18n-C9zFX25m.js";import{t as A}from"./timelineOps-DSSaDsU2.js";import{Y as y,A as I,Z as k,l as P,x as _,z as j,I as F}from"./main-CwrkBJ63.js";import{runAnalyzerCode as R}from"./analyzerSandbox-N92T6amg.js";import{e as E}from"./pluginAutomation-DAPHWZPN.js";import"./titleFrameBudget-DsM0V482.js";import"./index-CKtv7gGE.js";import"./sceneTrack-DlAH5s74.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./api-Dnl2uaKO.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";import"./remote-8XzEAnAJ.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./rotoMaskStore-pE1AIt3I.js";import"./spark.module-DjaIF6J1.js";import"./userFonts-Djka6RJX.js";import"./lottieLayer-Cv8ub9f6.js";import"./timeline3d-DrFaMPPB.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./glTransitionSources.generated-q0H-ZbnZ.js";import"./clientJobs-CcsLDqFM.js";import"./captionLayout-cckQ7p-t.js";import"./timelineText-DurRhyuh.js";import"./titleArt-CnC0A7x7.js";import"./personHq-Ca351o06.js";import"./matteQuality-9X-jgJrH.js";import"./sceneTrack-CA21MCOP.js";import"./rotoMatte-7b7Ow64f.js";import"./objectSegmenter-D66spD7o.js";import"./cutoutClean-CLYYAuXg.js";import"./distortGL-vhnBRB59.js";import"./motionBlur-uAm030t9.js";async function $(t){const{plugins:a}=await P(),n=a.find(e=>e.id===t.id&&e.enabled);if(!n)throw _("use_missing",[t.id]);const r=t.item?await j(n,t.item):await F(n);if(r.manifest.kind!=="analyzer")throw _("use_plugin",[0,t.item?`${t.id}/${t.item}`:t.id],"not an analyzer plug-in");return r}async function O(t,a,n){if(window.__analyzerFramesStub)return window.__analyzerFramesStub(t,a);const r=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});r.src=t.url;try{await new Promise((l,h)=>{r.onloadeddata=()=>l(),r.onerror=()=>h(Error(S("Không đọc được video của clip (CORS / định dạng)")))});const e=r.videoWidth||1280,d=r.videoHeight||720,o=Math.min(a.width,e),s=Math.max(2,Math.round(o*d/e)),i=Object.assign(document.createElement("canvas"),{width:o,height:s}),u=i.getContext("2d",{willReadFrequently:!0}),c=t.playbackRate||1,b=t.inPoint||0,z=Math.min(t.duration,a.maxSeconds),p=Math.max(1,Math.floor(z*a.fps)),g=new Uint8Array(o*s*p);for(let l=0;l<p;l++){n?.aborted;const h=Math.max(0,Math.min(r.duration-1/60,b+l/a.fps*c));Math.abs(r.currentTime-h)>1e-4&&await new Promise((m,f)=>{const M=window.setTimeout(()=>f(Error(S("Seek video quá lâu"))),8e3);r.onseeked=()=>{window.clearTimeout(M),m()},r.currentTime=h}),u.drawImage(r,0,0,o,s);const w=u.getImageData(0,0,o,s).data,x=l*o*s;for(let m=0,f=0;m<w.length;m+=4,f++)g[x+f]=w[m]*77+w[m+1]*150+w[m+2]*29>>8}return{fps:a.fps,width:o,height:s,count:p,data:g,sourceWidth:e,sourceHeight:d}}finally{r.removeAttribute("src"),r.load()}}function T(t){const a=v.getState().timelineMedia.find(i=>t.gcsUri&&i.gcsUri===t.gcsUri||i.url===t.url),n=t.playbackRate||1,r=t.inPoint||0,e=i=>+((i-r)/n).toFixed(3),d=i=>e(i.end)>0&&e(i.start)<t.duration,o=(a?.words??[]).filter(d).slice(0,y.words).map(i=>({start:e(i.start),end:e(i.end),word:String(i.word).slice(0,60)})),s=(a?.pauses??[]).filter(d).map(i=>({start:e(i.start),end:e(i.end)}));return{words:o,pauses:s}}async function St(t,a){const n=a.params??{};if(!n.plugin?.id)throw Error("runAnalyzer: no plug-in");if(t.kind!=="video"||!t.url)throw Error(S("Plug-in phân tích cần một clip video"));const r=await $(n.plugin),e=r.manifest,d=e.sample??{fps:y.fps.default,width:y.width.default,maxSeconds:y.maxSeconds.default},o=await O(t,d),s={clip:{duration:t.duration,width:o.sourceWidth,height:o.sourceHeight},frames:{fps:o.fps,width:o.width,height:o.height,count:o.count,data:o.data},...T(t),params:I(e,n.values??{})},i=k(await R(r.entry,s),t.id);if(!i.ops.length)return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:n.plugin.item?`${n.plugin.id}/${n.plugin.item}`:n.plugin.id,ops:0,summary:i.summary}),{};const u=A([t],i.ops);if(u.errors?.length)throw Error(String(u.errors[0]).slice(0,200));const c=u.clips.find(g=>g.id===t.id);if(!c)throw Error("runAnalyzer: the clip was lost");const{id:b,clientJobs:z,...p}=c;return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:n.plugin.item?`${n.plugin.id}/${n.plugin.item}`:n.plugin.id,ops:i.ops.length,summary:i.summary}),p}export{St as runAnalyzerJob};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{Y as d}from"./main-
|
|
1
|
+
import{Y as d}from"./main-CwrkBJ63.js";import"./titleFrameBudget-DsM0V482.js";import"./remote-8XzEAnAJ.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";import"./spark.module-DjaIF6J1.js";import"./userFonts-Djka6RJX.js";import"./lottieLayer-Cv8ub9f6.js";import"./timeline3d-DrFaMPPB.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./glTransitionSources.generated-q0H-ZbnZ.js";import"./clientJobs-CcsLDqFM.js";import"./captionLayout-cckQ7p-t.js";import"./timelineText-DurRhyuh.js";import"./titleArt-CnC0A7x7.js";import"./personHq-Ca351o06.js";import"./matteQuality-9X-jgJrH.js";import"./sceneTrack-CA21MCOP.js";import"./rotoMatte-7b7Ow64f.js";import"./objectSegmenter-D66spD7o.js";import"./cutoutClean-CLYYAuXg.js";import"./distortGL-vhnBRB59.js";import"./motionBlur-uAm030t9.js";const p=`
|
|
2
2
|
const clamp=(v,a,b)=>Math.min(b,Math.max(a,v))
|
|
3
3
|
function frameAt(f,i){const n=f.width*f.height;return f.data.subarray(i*n,(i+1)*n)}
|
|
4
4
|
function diff(f,i,j){const a=frameAt(f,i),b=frameAt(f,j),W=f.width,H=f.height;let s=0,sx=0,sy=0;for(let y=0;y<H;y++)for(let x=0;x<W;x++){const k=y*W+x,d=Math.abs(a[k]-b[k]);if(d>24){s+=d;sx+=x*d;sy+=y*d}}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clientExport-
|
|
2
|
-
import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn as bd,hJ as Rd,eT as Sd,eD as Fa,iF as ja,f as Cd}from"./titleFrameBudget-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/clientExport-pkLbOmEF.js","assets/titleFrameBudget-DsM0V482.js","assets/timelineComp-i-zdaoB2.js","assets/gpuExport-oA2mUsdm.js","assets/glTransitionSources.generated-q0H-ZbnZ.js","assets/gpuCompose-B5bgbHdQ.js","assets/motionBlur-uAm030t9.js","assets/distortGL-vhnBRB59.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/i18n-C9zFX25m.js","assets/index-CKtv7gGE.js","assets/timelineText-DurRhyuh.js","assets/store-CpqHUcA2.js","assets/titleArt-CnC0A7x7.js","assets/textAnimators-B9vO_hbP.js","assets/frameSink-CSRqCnwI.js","assets/distortFrames-D_v-aSVO.js","assets/timeline3dExport-Uo0S0CR0.js","assets/timeline3d-DrFaMPPB.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/titleFrames-C8kvflgT.js","assets/lottieLayer-Cv8ub9f6.js","assets/rigTrack-DMyqb0pb.js","assets/rotoMatte-7b7Ow64f.js","assets/windowFrames-DhhJLIs-.js","assets/rotoMaskStore-pE1AIt3I.js","assets/sceneTrack-DlAH5s74.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{nk as vd,ig as Ed,mP as Td,nl as wd,nm as Id,ic as Ad,b_ as Xt,_ as pe,nn as bd,hJ as Rd,eT as Sd,eD as Fa,iF as ja,f as Cd}from"./titleFrameBudget-DsM0V482.js";import{g as Yn,t as De}from"./i18n-C9zFX25m.js";import{r as Pd}from"./index-CKtv7gGE.js";const kd=["alpha","alpha-inverted","luma","luma-inverted","depth"],Ww=.04,Yi=.05,Gw=n=>n.mode.endsWith("-inverted"),Kw=n=>new Set(n.filter(e=>e.matte&&!e.disabled).map(e=>e.matte.source));function Od(n){const e=new Map(n.map(r=>[r.id,r])),t=new Set;for(const r of n){if(r.matte===void 0)continue;const s=r.matte;if(!s||typeof s!="object"||Object.keys(s).some(a=>!["source","mode","feather","depth"].includes(a))||!kd.includes(s.mode)||typeof s.source!="string")throw Error("Invalid track matte");if(s.mode==="depth"!=(s.depth!==void 0)||s.depth!==void 0&&!(Number.isFinite(s.depth)&&s.depth>=0&&s.depth<=1))throw Error("Invalid track matte depth");if(s.feather!==void 0&&!(Number.isFinite(s.feather)&&s.feather>=0&&s.feather<=Yi))throw Error("Invalid track matte feather");const o=e.get(s.source);if(!o||o.id===r.id||r.kind==="audio"||o.kind==="audio"||o.nullLayer||o.adjust||r.adjust||r.nullLayer)throw Error("Invalid track matte source");if(o.matte)throw Error("A matte source cannot have its own track matte");if(t.has(o.id))throw Error("A layer can be the matte of only one layer");t.add(o.id)}}const Qw=n=>+(Math.max(0,Math.min(1,n))*Yi).toFixed(5),Jw=n=>+Math.max(0,Math.min(1,(n??0)/Yi)).toFixed(4),Ba=Object.freeze([["audioFx"],["audioTools"],["duck"],["muffle"],["captionWords","captionStyle"],["captions"],["bubble"],["layout"],["effects"],["distort"],["shadow"],["glow"],["sticker"],["edge"],["enter"],["exit"],["blend"],["motionBlur"],["grade"],["key"],["face"],["colorPerson"],["depthMap"],["roto"],["planar"],["pin"],["pendingPin"],["mask"],["person","personPending"],["revealType","reveal"],["visualFadeIn","visualFadeOut","fadeInColor","fadeOutColor"],["motionKeys"],["speedRamp"],["timeRemap"],["transition"],["join"],["matte"],["seam"]]),Ru={opacity:[0,1],volume:[0,1],brightness:[0,2],contrast:[0,2],visualFadeIn:[0,4],visualFadeOut:[0,4]};function Dd(n){let e=n;for(const[t,[r,s]]of Object.entries(Ru)){const o=n[t];o===void 0||Number.isFinite(o)&&o>=r&&o<=s||(e===n&&(e={...n}),Number.isFinite(o)?e[t]=Math.min(s,Math.max(r,o)):delete e[t])}return e}const $a=n=>{try{return Id(n),null}catch(e){return String(e?.message||e)}},Nd=(n,e)=>e.some(t=>n[t]!==void 0),Hr=(n,e)=>{const t={...n};for(const r of e)delete t[r];return t};function Vd(n){let e=$a(n);if(!e)return{clip:n,dropped:[],reason:null};const t=e;let r=n;const s=[];for(let o=0,a=!0;a&&o<Ba.length;o++){a=!1;for(const u of Ba){if(!Nd(r,u))continue;const l=Hr(r,u),d=$a(l);if(!d)return s.push(...u.filter(p=>r[p]!==void 0)),{clip:l,dropped:s,reason:t};if(d!==e){s.push(...u.filter(p=>r[p]!==void 0)),r=l,e=d,a=!0;break}}}return{clip:null,dropped:s,reason:t}}function Md(n){if(!Array.isArray(n))return{clips:n,fixes:[]};const e=[],t=(a,u,l)=>e.push({clipId:a.id,label:String(a.label??"").slice(0,60),start:a.start,track:a.track,dropped:u,reason:String(l||"").slice(0,160)});let s=vd(n).map((a,u)=>{if(!a||typeof a!="object")return a;const l=n[u];l&&(JSON.stringify(l.captions)!==JSON.stringify(a.captions)||JSON.stringify(l.captionWords)!==JSON.stringify(a.captionWords))&&t(a,["captions"],"subtitle cues overlapped or ran past the clip");const d=Dd(a);d!==a&&t(a,Object.keys(Ru).filter(v=>d[v]!==a[v]),"value out of range (clamped)");const p=Vd(d);return!p.clip||!p.dropped.length?d:(t(d,p.dropped,p.reason),p.clip)});const o=new Set(s.map(a=>a?.id));s=s.map(a=>{if(!a||typeof a!="object")return a;let u=a;if(u.parentId&&(!o.has(u.parentId)||Ed(s,u.id,u.parentId))&&(t(u,["parentId"],"parent layer missing or looping"),u=Hr(u,["parentId"])),u.transition!==void 0)try{Td(u,s)}catch(l){wd(s,u)||t(u,["transition"],l?.message),u=Hr(u,["transition"])}return u});for(let a=0;a<8;a++)try{Od(s);break}catch(u){const l=s.findIndex(d=>d?.matte!==void 0);if(l<0)break;t(s[l],["matte"],u?.message),s=s.map((d,p)=>p===l?Hr(d,["matte"]):d)}return{clips:s,fixes:e}}const Ld=["mp3","wav","m4a","aac","flac","ogg","oga","opus","weba","aif","aiff"];function xd(n){if(!n)return!1;if(typeof n.type=="string"&&n.type.startsWith("audio/"))return!0;if(typeof n.type=="string"&&n.type)return!1;const e=typeof n.name=="string"?n.name.split(".").pop().toLowerCase():"";return Ld.includes(e)}let Ii=null,qa=Promise.resolve();const ns=new Set,za=()=>ns.forEach(n=>n());function Ud(n){const e=()=>new Promise(r=>{if(!ns.size)return r(!1);Ii={names:n,resolve:s=>{Ii=null,za(),r(s)}},za()}),t=qa.then(e,e);return qa=t,t}function Xw(){return Pd.useSyncExternalStore(n=>(ns.add(n),()=>{ns.delete(n)}),()=>Ii,()=>null)}const Ha="application/vnd.clipoox.export-progress";new TextEncoder;function Fd(){let n=new Uint8Array(0),e=-1,t=!1;const r=new TextDecoder;return{push(s){const o=[];if(e>=0)return s.length&&o.push({type:"data",chunk:s}),e-=s.length,o;const a=new Uint8Array(n.length+s.length);a.set(n),a.set(s,n.length);let u=0;for(;;){const l=a.indexOf(10,u);if(l<0)break;const d=r.decode(a.subarray(u,l)),p=d[0],v=d.slice(2);if(u=l+1,p==="P"){const E=Number(v);Number.isFinite(E)&&o.push({type:"progress",value:Math.max(0,Math.min(1,E))})}else if(p==="R")try{o.push({type:"review",review:JSON.parse(decodeURIComponent(v))})}catch{o.push({type:"review",review:null})}else if(p==="T")try{o.push({type:"timings",timings:JSON.parse(decodeURIComponent(v))})}catch{}else if(p==="E"){let E={};try{E=JSON.parse(v)}catch{}o.push({type:"error",error:String(E.error||"Export failed"),status:Number(E.status)||500})}else if(p==="S"){let E={};try{E=JSON.parse(decodeURIComponent(v))}catch{}typeof E.gcsUri=="string"&&(t=!0,o.push({type:"stored",gcsUri:E.gcsUri,size:Number(E.size)||0}))}else if(p==="F"){e=Number(v)||0,o.push({type:"file",size:e});const E=a.subarray(u);return E.length&&o.push({type:"data",chunk:E}),e-=E.length,n=new Uint8Array(0),o}}return n=a.slice(u),o},get complete(){return e===0||t}}}async function jd(n){let e;try{e=await n.text()}catch(t){if(n.ok)throw Wa(t);return{}}if(!e)return{};try{return JSON.parse(e)}catch(t){if(n.ok&&/^\s*([{[]|$)/.test(e))throw Wa(t);return{}}}const Wa=n=>Object.assign(Error("reply lost"),{code:"reply_lost",cause:n}),Bd=600,Yw=600,ui=n=>String(n).padStart(2,"0");function Zw(n){const e=Math.max(0,Math.round(Number(n)||0)),t=Math.floor(e/3600),r=Math.floor(e/60)%60;return t?`${t}:${ui(r)}:${ui(e%60)}`:`${r}:${ui(e%60)}`}const rs="application/vnd.clipoox.analysis-progress+json";function Su(n,e){const t=Math.max(1,Number(e)||1),r=Math.max(0,Number(n)||0);return r<=t?.9*r/t:.9+.079*(1-Math.exp(-(r-t)/t))}const $d=30;function qd(n){const e=Number(n?.duration),t=Number.isFinite(e)&&e>0?Math.min(e,Bd):$d,r={id:"fetch",seconds:2+t*.03};if(n?.mode==="music")return[r,{id:"beats",seconds:2+t*.08}];if(n?.mode==="reference")return[r,{id:"rhythm",seconds:12+t*.25}];const s=t>600?3:1,o={id:"cuts",seconds:1+t*.08},a={id:"speech",seconds:4+t*.12/s};return n?.audioOnly?[r,o,a]:[r,o,{id:"scenes",seconds:(Math.ceil(t/120)*15+t*.15)/s},a]}function eI(n,e){const t=(n||[]).map(qd),r=t.flat().reduce((l,d)=>l+d.seconds,0)||1,s=Su(e,r);let o=Math.min(r,s/.9*r)-1e-9,a=0,u=t[0]?.[0]?.id||"fetch";e:for(const[l,d]of t.entries())for(const p of d){if(a=l,u=p.id,o<p.seconds)break e;o-=p.seconds}return{fraction:s,index:a,count:t.length,stage:u}}const Ga={video:{fetch:.03,cuts:.12,scenes:.7,speech:1},audio:{fetch:.03,cuts:.12,scenes:.12,speech:1}};function tI(n,e=!1){const t=e?Ga.audio:Ga.video,r=["fetch","cuts","scenes","speech"],s=r.indexOf(n?.stage);if(s<0)return 0;const o=s?t[r[s-1]]:0,a=t[r[s]],u=Number(n.total)>0?Math.min(1,Math.max(0,Number(n.done)||0)/Number(n.total)):0,l=Math.max(1,Number(n.count)||1),d=Math.min(l-1,Math.max(0,Number(n.index)||0));return Math.min(.99,(d+o+(a-o)*u)/l)}function nI(n,e=!0){const t=Math.round(Math.max(0,Math.min(1,Number(n)||0))*100);return e?Math.min(99,t):t}const zd=()=>{};var Ka={};/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2017 Google LLC
|
|
5
5
|
*
|
|
@@ -3155,4 +3155,4 @@ This typically indicates that your device does not have a healthy Internet conne
|
|
|
3155
3155
|
* limitations under the License.
|
|
3156
3156
|
*/function Gv(n){if(n.limitType==="L"&&n.explicitOrderBy.length===0)throw new x(N.UNIMPLEMENTED,"limitToLast() queries require specifying at least one orderBy() clause")}class Kv{convertValue(e,t="none"){switch(St(e)){case 0:return null;case 1:return e.booleanValue;case 2:return se(e.integerValue||e.doubleValue);case 3:return this.convertTimestamp(e.timestampValue);case 4:return this.convertServerTimestamp(e,t);case 5:return e.stringValue;case 6:return this.convertBytes(Rt(e.bytesValue));case 7:return this.convertReference(e.referenceValue);case 8:return this.convertGeoPoint(e.geoPointValue);case 9:return this.convertArray(e.arrayValue,t);case 11:return this.convertObject(e.mapValue,t);case 10:return this.convertVectorValue(e.mapValue);default:throw H(62114,{value:e})}}convertObject(e,t){return this.convertObjectMap(e.fields,t)}convertObjectMap(e,t="none"){const r={};return mr(e,((s,o)=>{r[s]=this.convertValue(o,t)})),r}convertVectorValue(e){var t,r,s;const o=(s=(r=(t=e.fields)===null||t===void 0?void 0:t[Li].arrayValue)===null||r===void 0?void 0:r.values)===null||s===void 0?void 0:s.map((a=>se(a.doubleValue)));return new wt(o)}convertGeoPoint(e){return new Tt(se(e.latitude),se(e.longitude))}convertArray(e,t){return(e.values||[]).map((r=>this.convertValue(r,t)))}convertServerTimestamp(e,t){switch(t){case"previous":const r=Cs(e);return r==null?null:this.convertValue(r,t);case"estimate":return this.convertTimestamp(sr(e));default:return null}}convertTimestamp(e){const t=bt(e);return new ae(t.seconds,t.nanos)}convertDocumentKey(e,t){const r=te.fromString(e);ne(ah(r),9688,{name:e});const s=new ir(r.get(1),r.get(3)),o=new U(r.popFirst(5));return s.isEqual(t)||nt(`Document ${o} contains a document reference within a different database (${s.projectId}/${s.database}) which is not supported. It will be treated as a reference in the current database (${t.projectId}/${t.database}) instead.`),o}}class Hn{constructor(e,t){this.hasPendingWrites=e,this.fromCache=t}isEqual(e){return this.hasPendingWrites===e.hasPendingWrites&&this.fromCache===e.fromCache}}class jt extends Ch{constructor(e,t,r,s,o,a){super(e,t,r,s,a),this._firestore=e,this._firestoreImpl=e,this.metadata=o}exists(){return super.exists()}data(e={}){if(this._document){if(this._converter){const t=new ts(this._firestore,this._userDataWriter,this._key,this._document,this.metadata,null);return this._converter.fromFirestore(t,e)}return this._userDataWriter.convertValue(this._document.data.value,e.serverTimestamps)}}get(e,t={}){if(this._document){const r=this._document.data.field(Ph("DocumentSnapshot.get",e));if(r!==null)return this._userDataWriter.convertValue(r,t.serverTimestamps)}}toJSON(){if(this.metadata.hasPendingWrites)throw new x(N.FAILED_PRECONDITION,"DocumentSnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e=this._document,t={};return t.type=jt._jsonSchemaVersion,t.bundle="",t.bundleSource="DocumentSnapshot",t.bundleName=this._key.toString(),!e||!e.isValidDocument()||!e.isFoundDocument()?t:(this._userDataWriter.convertObjectMap(e.data.value.mapValue.fields,"previous"),t.bundle=(this._firestore,this.ref.path,"NOT SUPPORTED"),t)}}jt._jsonSchemaVersion="firestore/documentSnapshot/1.0",jt._jsonSchema={type:ce("string",jt._jsonSchemaVersion),bundleSource:ce("string","DocumentSnapshot"),bundleName:ce("string"),bundle:ce("string")};class ts extends jt{data(e={}){return super.data(e)}}class un{constructor(e,t,r,s){this._firestore=e,this._userDataWriter=t,this._snapshot=s,this.metadata=new Hn(s.hasPendingWrites,s.fromCache),this.query=r}get docs(){const e=[];return this.forEach((t=>e.push(t))),e}get size(){return this._snapshot.docs.size}get empty(){return this.size===0}forEach(e,t){this._snapshot.docs.forEach((r=>{e.call(t,new ts(this._firestore,this._userDataWriter,r.key,r,new Hn(this._snapshot.mutatedKeys.has(r.key),this._snapshot.fromCache),this.query.converter))}))}docChanges(e={}){const t=!!e.includeMetadataChanges;if(t&&this._snapshot.excludesMetadataChanges)throw new x(N.INVALID_ARGUMENT,"To include metadata changes with your document changes, you must also pass { includeMetadataChanges:true } to onSnapshot().");return this._cachedChanges&&this._cachedChangesIncludeMetadataChanges===t||(this._cachedChanges=(function(s,o){if(s._snapshot.oldDocs.isEmpty()){let a=0;return s._snapshot.docChanges.map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);return u.doc,{type:"added",doc:l,oldIndex:-1,newIndex:a++}}))}{let a=s._snapshot.oldDocs;return s._snapshot.docChanges.filter((u=>o||u.type!==3)).map((u=>{const l=new ts(s._firestore,s._userDataWriter,u.doc.key,u.doc,new Hn(s._snapshot.mutatedKeys.has(u.doc.key),s._snapshot.fromCache),s.query.converter);let d=-1,p=-1;return u.type!==0&&(d=a.indexOf(u.doc.key),a=a.delete(u.doc.key)),u.type!==1&&(a=a.add(u.doc),p=a.indexOf(u.doc.key)),{type:Qv(u.type),doc:l,oldIndex:d,newIndex:p}}))}})(this,t),this._cachedChangesIncludeMetadataChanges=t),this._cachedChanges}toJSON(){if(this.metadata.hasPendingWrites)throw new x(N.FAILED_PRECONDITION,"QuerySnapshot.toJSON() attempted to serialize a document with pending writes. Await waitForPendingWrites() before invoking toJSON().");const e={};e.type=un._jsonSchemaVersion,e.bundleSource="QuerySnapshot",e.bundleName=mo.newId(),this._firestore._databaseId.database,this._firestore._databaseId.projectId;const t=[],r=[],s=[];return this.docs.forEach((o=>{o._document!==null&&(t.push(o._document),r.push(this._userDataWriter.convertObjectMap(o._document.data.value.mapValue.fields,"previous")),s.push(o.ref.path))})),e.bundle=(this._firestore,this.query._query,e.bundleName,"NOT SUPPORTED"),e}}function Qv(n){switch(n){case 0:return"added";case 2:case 3:return"modified";case 1:return"removed";default:return H(61501,{type:n})}}un._jsonSchemaVersion="firestore/querySnapshot/1.0",un._jsonSchema={type:ce("string",un._jsonSchemaVersion),bundleSource:ce("string","QuerySnapshot"),bundleName:ce("string"),bundle:ce("string")};class kh extends Kv{constructor(e){super(),this.firestore=e}convertBytes(e){return new Be(e)}convertReference(e){const t=this.convertDocumentKey(e,this.firestore._databaseId);return new Ce(this.firestore,null,t)}}function Jv(n,...e){var t,r,s;n=xe(n);let o={includeMetadataChanges:!1,source:"default"},a=0;typeof e[a]!="object"||wu(e[a])||(o=e[a++]);const u={includeMetadataChanges:o.includeMetadataChanges,source:o.source};if(wu(e[a])){const v=e[a];e[a]=(t=v.next)===null||t===void 0?void 0:t.bind(v),e[a+1]=(r=v.error)===null||r===void 0?void 0:r.bind(v),e[a+2]=(s=v.complete)===null||s===void 0?void 0:s.bind(v)}let l,d,p;if(n instanceof Ce)d=Xr(n.firestore,Xi),p=Eo(n._key.path),l={next:v=>{e[a]&&e[a](Xv(d,n,v))},error:e[a+1],complete:e[a+2]};else{const v=Xr(n,Ls);d=Xr(v.firestore,Xi),p=v._query;const E=new kh(d);l={next:C=>{e[a]&&e[a](new un(d,E,v,C))},error:e[a+1],complete:e[a+2]},Gv(n._query)}return(function(E,C,V,M){const k=new Mv(M),q=new Ev(C,k,V);return E.asyncQueue.enqueueAndForget((async()=>gv(await mu(E),q))),()=>{k.Ou(),E.asyncQueue.enqueueAndForget((async()=>_v(await mu(E),q)))}})($v(d),p,u,l)}function Xv(n,e,t){const r=t.docs.get(e._key),s=new kh(n);return new jt(n,s,e._key,r,new Hn(t.hasPendingWrites,t.fromCache),e.converter)}(function(e,t=!0){(function(s){En=s})(yn),ln(new $t("firestore",((r,{instanceIdentifier:s,options:o})=>{const a=r.getProvider("app").getImmediate(),u=new Xi(new Zg(r.getProvider("auth-internal")),new n_(a,r.getProvider("app-check-internal")),(function(d,p){if(!Object.prototype.hasOwnProperty.apply(d.options,["projectId"]))throw new x(N.INVALID_ARGUMENT,'"projectId" not provided in firebase.initializeApp.');return new ir(d.options.projectId,p)})(a,s),a);return o=Object.assign({useFetchStreams:t},o),u._setSettings(o),u}),"PUBLIC").setMultipleInstances(!0)),vt(bc,Rc,e),vt(bc,Rc,"esm2017")})();const Yv=typeof location<"u"&&/^(localhost|127\.0\.0\.1)$/.test(location.hostname),Zv={apiKey:"AIzaSyDzUGG3LEJbx0XccOWH2xEhZcttMw_238E",authDomain:Yv?"mrcong-d8b07.firebaseapp.com":location.host,projectId:"mrcong-d8b07",storageBucket:"mrcong-d8b07.firebasestorage.app",messagingSenderId:"926811951160",appId:"1:926811951160:web:acdfdd0941e12be35d96cd"},Oh=yp()[0]||Uu(Zv),rt=Qg(Oh),eE=Bv(Oh),sI=(async()=>{if(typeof location>"u")return;const n=/[#&]t=([^&]+)/.exec(location.hash);if(n){history.replaceState(null,"",location.pathname+location.search);try{await km(rt,decodeURIComponent(n[1]))}catch(e){console.warn("[auth] sso handoff failed:",e?.code||e?.message)}}})();async function iI(){const n=new Xe;n.addScope("email"),n.addScope("profile"),n.setCustomParameters({prompt:"select_account"});try{return await rg(rt,n)}catch(e){const t=e?.code||"";if(["auth/popup-blocked","auth/popup-closed-by-user","auth/cancelled-popup-request","auth/operation-not-supported-in-this-environment"].includes(t))return await ug(rt,n),null;throw e}}const wi={code:null};hg(rt).catch(n=>{wi.code=n?.code||n?.message||"unknown",console.warn("[auth] redirect result:",wi.code),document.dispatchEvent(new CustomEvent("clipoox:auth-error",{detail:wi.code}))});const oI=(n,e)=>Nm(rt,n.trim(),e),aI=n=>Dm(rt,n.trim()),cI=()=>xm(rt),uI=n=>Lm(rt,n);async function tE(){const n=rt.currentUser;return n?n.getIdToken():null}function lI(n,e,t){return Jv(jv(eE,"users",n),r=>{!r.exists()&&!r.metadata.fromCache&&t?.();const s=r.data()||{},o=typeof s.planCredits=="number"?s.planCredits:0,a=typeof s.extraCredits=="number"?s.extraCredits:0,u=typeof s.credits=="number"?s.credits:0,l=o===0&&a===0&&!s.planExpiresAt;e({credits:l?u:Math.round((o+a)*100)/100,planCredits:o,extraCredits:a,activePlan:s.activePlan||"free",planExpiresAt:typeof s.planExpiresAt?.toMillis=="function"?s.planExpiresAt.toMillis():typeof s.planExpiresAt=="number"?s.planExpiresAt:null})},()=>e({credits:0,planCredits:0,extraCredits:0,activePlan:"free"}))}async function b(n){const e=await jd(n).catch(r=>{throw Object.assign(new Error(De("Mất kết nối khi đang chờ kết quả từ máy chủ. Hãy thử lại.")),{status:n.status,code:r?.code||"reply_lost"})}),t=n.ok&&typeof e.error=="string"&&typeof e.status=="number"&&e.status>=400;if(!n.ok||t){const r=t?e.status:n.status,s=new Error(e.error||`${n.status} ${n.statusText}`);throw s.status=r,s.code=e.code,s.data=e,s}return e}async function kt(){const n=await tE();return n?{"X-Firebase-Token":n}:{}}const j=async n=>fetch(n,{headers:await kt()}),nE=()=>j("/api/mocap/hy/status").then(n=>n.ok?n.json():null),O=async(n,e,t="POST")=>fetch(n,{method:t,headers:{"Content-Type":"application/json","Accept-Language":Yn(),...await kt()},body:JSON.stringify(n.startsWith("/api/agent")||n.startsWith("/api/shot-agent")?{...e,locale:Yn()}:e)}),rE=()=>j("/api/me").then(n=>b(n)),sE=()=>j("/api/health").then(n=>b(n)),iE=()=>j("/api/generate").then(n=>b(n)).then(n=>n.generators),oE=(n,e)=>O("/api/generate/estimate",{generator:n,inputs:e}).then(t=>b(t)),aE=(n,e,t)=>O("/api/generate",{generator:n,inputs:e,canvasId:t}).then(r=>b(r)),cE=(n,e=!1)=>{const t=new URL(`/api/jobs/${n}`,window.location.origin);return e&&t.searchParams.set("poll","1"),j(t.toString()).then(r=>b(r)).then(r=>r.job)},uE=(n,e=50)=>{const t=new URL("/api/jobs",window.location.origin);return n&&t.searchParams.set("canvasId",n),t.searchParams.set("limit",String(e)),j(t.toString()).then(r=>b(r)).then(r=>r.jobs)},lE=(n,e,t)=>O("/api/media/trim",{videoUrl:n,start:e,end:t}).then(r=>b(r)),hE=(n,e)=>O("/api/media/region-splice",{sourceUrl:n,regions:e}).then(t=>b(t)),dE=(n,e)=>O("/api/media/frame",{videoUrl:n,...e}).then(t=>b(t)),Dh=(n,e,t,r)=>O("/api/uploads/sign",{filename:n,contentType:e,kind:t,...r?{rightsConfirmed:!0}:{}}).then(s=>b(s));function fE(n){return new Promise(e=>{const t=document.createElement(n.type.startsWith("audio/")?"audio":"video"),r=URL.createObjectURL(n),s=a=>{clearTimeout(o),t.onloadedmetadata=t.onerror=null,t.removeAttribute("src"),t.load(),URL.revokeObjectURL(r),e(a)},o=setTimeout(()=>s(null),1e4);t.preload="metadata",t.onloadedmetadata=()=>s(Number.isFinite(t.duration)?t.duration:null),t.onerror=()=>s(null),t.src=r})}async function pE(n,e,t,r=!1){const s=xd(n)||t==="audio"||t==="voice";if(s&&!r&&!await Ud([n.name]))throw new Error(De("Cần xác nhận quyền sử dụng bản nhạc trước khi tải lên"));if(/^(video|audio)\//.test(n.type)&&typeof document<"u"){const a=await fE(n);if(a!==null&&a>Cd+.001)throw new Error(De("Video/âm thanh đầu vào tối đa 20 phút"))}const o=await Dh(n.name,n.type||"application/octet-stream",t,s);return await new Promise((a,u)=>{const l=new XMLHttpRequest;l.open("PUT",o.uploadUrl),Object.entries(o.headers).forEach(([d,p])=>l.setRequestHeader(d,p)),l.upload.onprogress=d=>{d.lengthComputable&&e&&e(Math.round(d.loaded/d.total*100))},l.onload=()=>l.status>=200&&l.status<300?a():u(new Error(`upload failed: ${l.status}`)),l.onerror=()=>u(new Error("upload network error")),l.send(n)}),{url:o.readUrl,gcsUri:o.gcsUri,...o.rightsConfirmed?{rightsConfirmed:o.rightsConfirmed}:{}}}const mE=(n,e,t)=>O("/api/uploads/sign",{filename:n,contentType:e,temp:t}).then(r=>b(r)),gE=()=>j("/api/uploads/temp").then(n=>b(n)),_E=n=>O("/api/uploads/temp/sign",{gcsUri:n}).then(e=>b(e)),yE=n=>O("/api/uploads/temp",n,"DELETE").then(e=>b(e));function vE(n,e,t,r){return new Promise((s,o)=>{const a=new XMLHttpRequest;a.open("PUT",n.uploadUrl),Object.entries(n.headers).forEach(([u,l])=>a.setRequestHeader(u,l)),a.upload.onprogress=u=>{u.lengthComputable&&t?.(u.loaded,u.total)},a.onload=()=>a.status>=200&&a.status<300?s():o(new Error(`upload failed: ${a.status}`)),a.onerror=()=>o(new Error("upload network error")),a.onabort=()=>o(Object.assign(new Error(De("Đã huỷ gửi tạm")),{name:"AbortError"})),r?.addEventListener("abort",()=>a.abort(),{once:!0}),a.send(e)})}const EE=n=>O("/api/uploads/model-url",{gcsUri:n}).then(e=>b(e)).then(e=>e.url),TE=n=>O("/api/plugins/asset-urls",{uris:n}).then(e=>b(e)).then(e=>e.urls),wE=n=>O("/api/outputs/sign",n).then(e=>b(e)).then(e=>e.url),IE=(n={})=>O("/api/canvases",n).then(e=>b(e)).then(e=>e.canvas),AE=n=>j(`/api/canvases/${n}`).then(e=>b(e)).then(e=>e.canvas),bE=(n,e)=>O(`/api/canvases/${n}`,e,"PUT").then(t=>b(t)),RE=(n,e)=>j(`/api/canvases/${encodeURIComponent(n)}/shot-rev/${encodeURIComponent(e)}`).then(t=>b(t)),SE=n=>j(`/api/canvases/${encodeURIComponent(n)}/timeline-rev`).then(e=>b(e)),CE=n=>j(`/api/timeline-docs/${encodeURIComponent(n)}/rev`).then(e=>b(e)),PE=n=>O(`/api/canvases/${n}`,{},"DELETE").then(e=>b(e)),kE=n=>O("/api/blender/device/approve",{userCode:n}).then(e=>b(e)),OE=()=>j("/api/blender-remote/devices").then(n=>b(n)),DE=n=>O("/api/blender-remote/missions",n).then(e=>b(e)),NE=(n=8)=>j(`/api/blender-remote/missions?limit=${n}`).then(e=>b(e)),VE=n=>j(`/api/blender-remote/missions/${encodeURIComponent(n)}`).then(e=>b(e)),ME=n=>O("/api/blender-remote/vcam/session",{deviceId:n}).then(e=>b(e)),LE=n=>O(`/api/blender-remote/missions/${encodeURIComponent(n)}/cancel`,{}).then(e=>b(e)),xE=n=>j(`/api/canvases${n?`?limit=${n}`:""}`).then(e=>b(e)).then(e=>e.canvases),UE=(n,e)=>O(`/api/canvases/${n}/archive`,{archived:e}).then(t=>b(t)),FE=n=>O(`/api/canvases/${n}/duplicate`,{}).then(e=>b(e)).then(e=>e.canvas),jE=()=>j("/api/skills").then(n=>b(n)),BE=n=>O("/api/skills",n).then(e=>b(e)).then(e=>e.skill),$E=(n,e)=>O(`/api/skills/${n}`,e,"PUT").then(t=>b(t)).then(t=>t.skill),qE=n=>O(`/api/skills/${n}`,{},"DELETE").then(e=>b(e)),zE=()=>j("/api/series").then(n=>b(n)),HE=n=>j(`/api/series/${encodeURIComponent(n)}`).then(e=>b(e)),WE=(n,e)=>O(`/api/series/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),GE=n=>j(`/api/sets/${encodeURIComponent(n)}`).then(e=>b(e)),KE=(n,e,t)=>O(`/api/sets/${encodeURIComponent(n)}`,{name:e,recipe:t},"PUT").then(r=>b(r)),QE=async n=>{const e=await j(`/api/timeline-docs/${encodeURIComponent(n)}`);return e.status===404?null:(await b(e)).timeline},JE=(n,e)=>O(`/api/timeline-docs/${encodeURIComponent(n)}`,e,"PUT").then(t=>b(t)),XE=async(n,e,t)=>{const r=await O(`/api/timeline-docs/${encodeURIComponent(n)}/copy`,{id:e,nodeId:t.nodeId,...t.canvasId?{canvasId:t.canvasId}:{}});return r.status===404?!1:(await b(r),!0)},YE=()=>j("/api/canvas-inbox").then(n=>b(n)),ZE=n=>O("/api/canvas-inbox/consume",{ids:n}).then(e=>b(e)),eT=(n,e,t="upload")=>j("/api/assets?"+new URLSearchParams({source:t,...n?{kind:n}:{},...e?{cursor:e}:{}})).then(r=>b(r)),tT=(n,e)=>O("/api/director/"+encodeURIComponent(n)+"/context",e,"PUT").then(t=>b(t)),nT=n=>j(`/api/director/${encodeURIComponent(n)}`).then(e=>b(e)),rT=n=>j(`/api/director-references/${encodeURIComponent(n)}`).then(e=>b(e)),sT=(n,e,t,r)=>O(`/api/director-references/${encodeURIComponent(n)}`,{gcsUri:e,label:t,role:r}).then(s=>b(s)),iT=n=>j(`/api/library${n?`?kind=${encodeURIComponent(n)}`:""}`).then(e=>b(e)).then(e=>e.assets),oT=()=>j("/api/library/usage").then(n=>b(n)),aT=n=>O("/api/library/pin",n).then(e=>b(e)),cT=n=>O(`/api/library/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),uT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),lT=(n,e)=>O(`/api/timeline-agent/${encodeURIComponent(n)}/locate-object`,e).then(t=>b(t)),hT=n=>O("/api/timeline-agent/usage",{events:n}).then(e=>b(e));async function dT(n,e,t,r){const s=`/api/timeline-agent/${encodeURIComponent(n)}/describe`;if(!r)return O(s,{items:e,locale:t}).then(v=>b(v));const o=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({items:e,locale:t})});if(!o.ok||!(o.headers.get("Content-Type")||"").startsWith(rs)||!o.body)return b(o);const a=o.body.pipeThrough(new TextDecoderStream).getReader();let u="",l=null;const d=v=>{if(!v.trim())return;const E=JSON.parse(v);if(E&&typeof E=="object"&&E.progress)try{r(E.progress)}catch{}else l=E};for(;;){const{value:v,done:E}=await a.read();if(E)break;u+=v;let C;for(;(C=u.indexOf(`
|
|
3157
3157
|
`))>=0;)d(u.slice(0,C)),u=u.slice(C+1)}d(u);const p=l||{};if(typeof p.error=="string"&&typeof p.status=="number"&&p.status>=400){const v=new Error(p.error);throw v.status=p.status,v.code=p.code,v.data=p,v}if(!l)throw new Error(De("Phân tích bị ngắt giữa chừng. Hãy thử lại."));return l}async function fT(n,e,t={}){const r=await fetch(`/api/transcribe/${encodeURIComponent(n)}`,{method:"POST",signal:t.signal,headers:{"Content-Type":"application/json",Accept:`${rs}, application/json;q=0.9`,"Accept-Language":Yn(),...await kt()},body:JSON.stringify({...e,terms:t.terms||"",locale:t.locale||Yn()})});if(!r.ok||!(r.headers.get("Content-Type")||"").startsWith(rs)||!r.body)return b(r).then(d=>d.item);const s=r.body.pipeThrough(new TextDecoderStream).getReader();let o="",a=null;const u=d=>{if(!d.trim())return;const p=JSON.parse(d);if(p&&typeof p=="object"&&p.progress)try{t.onProgress?.(p.progress)}catch{}else a=p};for(;;){const{value:d,done:p}=await s.read();if(p)break;o+=d;let v;for(;(v=o.indexOf(`
|
|
3158
|
-
`))>=0;)u(o.slice(0,v)),o=o.slice(v+1)}u(o);const l=a||{};if(typeof l.error=="string"&&typeof l.status=="number"&&l.status>=400){const d=new Error(l.error);throw d.status=l.status,d.code=l.code,d}if(!l.item)throw new Error(De("Chép lời bị ngắt giữa chừng. Hãy thử lại."));return l.item}const pT=(n,e,t=0)=>j(`/api/timeline-agent/plan-price?model=${encodeURIComponent(n)}&chars=${Math.round(e)}&refs=${t}`).then(r=>b(r)),mT=(n,e=!0)=>j(`/api/timeline-agent/describe-price?audioOnly=${e?1:0}${n&&n>0?`&duration=${Math.ceil(n)}`:""}`).then(t=>b(t)),gT=(n,e,t)=>O("/api/timeline/multicam/sync",{canvasId:n,items:e,...t?{main:t}:{}}).then(r=>b(r)),xs=(n,e)=>`/api/production/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,_T=(n,e)=>j(xs(n,e)).then(t=>b(t)),yT=(n,e,t)=>O(`${xs(n,e)}/quote`,{imageGenerator:t}).then(r=>b(r)),vT=(n,e,t,r)=>O(`${xs(n,e)}/${t}`,{revision:r}).then(s=>b(s)),ET=(n,e,t,r,s,o,a,u)=>O(`/api/director/${encodeURIComponent(n)}`,{input:e,requestId:t,referenceIds:r,defaults:s,...o?{skill:o.id?{id:o.id}:{title:o.title,instruction:o.instruction}}:{},...a?{model:a}:{},...u?{aspectRatio:u}:{}}).then(l=>b(l)),TT=(n,e,t,r)=>O(`${xs(n,e)}/accept`,{revision:t,totalCredits:r}).then(s=>b(s)),wT=n=>O(`/api/director/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),IT=(n,e,t,r)=>O("/api/agent",{messages:n.map(({role:s,content:o})=>({role:s,content:o})),canvas:e,model:t||void 0,defaults:r}).then(s=>b(s)),AT=()=>j("/api/agent/models").then(n=>n.json()),bT=(n="published",e)=>j("/api/model-library?"+new URLSearchParams({status:n,...e?{cursor:e}:{}})).then(t=>b(t)),RT=()=>j("/api/model-library/categories").then(n=>b(n)),ST=(n,e)=>O("/api/model-library/"+encodeURIComponent(n)+"/thumbnail",{gcsUri:e}).then(t=>b(t)),CT=n=>O("/api/model-library",n).then(e=>b(e)),PT=(n,e)=>O("/api/model-library/"+encodeURIComponent(n),{status:e},"PATCH").then(t=>b(t)),kT=(n={})=>j("/api/asset-library?"+new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0&&e!=="").map(([e,t])=>[e,String(t)]))).then(e=>b(e)),OT=n=>j("/api/asset-library/categories"+(n?"?kind="+n:"")).then(e=>b(e)),DT=n=>j("/api/asset-library/"+encodeURIComponent(n)).then(e=>b(e)).then(e=>e.item),NT=(n="published")=>j("/api/text-templates?"+new URLSearchParams({status:n})).then(e=>b(e)),VT=()=>j("/api/brands").then(n=>b(n)),MT=()=>j("/api/fonts").then(n=>b(n)),LT=n=>O("/api/fonts",n).then(e=>b(e)),xT=n=>O("/api/fonts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),UT=(n,e)=>O("/api/brands"+(e?"/"+encodeURIComponent(e):""),n,e?"PUT":"POST").then(t=>b(t)),FT=n=>O("/api/brands/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),jT=n=>O("/api/luts",n).then(e=>b(e)),BT=()=>j("/api/luts").then(n=>b(n)),$T=n=>O("/api/luts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),qT=n=>j("/api/luts/"+encodeURIComponent(n)).then(e=>b(e)),zT=(n="published")=>j("/api/transitions?"+new URLSearchParams({status:n})).then(e=>b(e)),HT=n=>O("/api/model-library/share",n).then(e=>b(e)),WT=()=>j("/api/shot-agent").then(n=>b(n)),GT=(n,e,t)=>O("/api/shot-agent/estimate",{scene:n,messages:e,model:t}).then(r=>b(r)),KT=(n,e,t,r)=>O("/api/shot-agent",{scene:n,messages:e,requestId:t,model:r}).then(s=>b(s)),QT=n=>O("/api/shot-agent/mission/turn",n).then(e=>b(e)),JT=(n,e="build")=>O("/api/shot-agent/mission/quote",{model:n,kind:e}).then(t=>b(t)),XT=n=>O("/api/shot-agent/mission/cancel",{missionId:n}).then(e=>b(e)),YT=n=>O("/api/shot-agent/remote/poll",n).then(e=>b(e)),ZT=n=>O("/api/shot-agent/live/poll",n).then(e=>b(e)),ew=n=>O("/api/timeline-live/poll",n).then(e=>b(e)),tw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/progress`,e).then(t=>b(t)),nw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),rw=(n,e)=>O(`/api/shot-agent/live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),sw=(n,e)=>O(`/api/shot-agent/remote/missions/${encodeURIComponent(n)}/status`,e).then(t=>b(t)),iw=n=>O("/api/person-mattes",{data:n}).then(e=>b(e)).then(e=>e.ref),ow=async n=>{const e=await j(`/api/person-mattes/${n}`);return e.ok||await b(e),e.text()},aw=n=>O("/api/roto-masks",{data:n}).then(e=>b(e)).then(e=>e.ref),cw=async n=>{const e=await j(`/api/roto-masks/${n}`);return e.ok||await b(e),e.text()},uw=n=>O("/api/shot-scenes",{data:n}).then(e=>b(e)).then(e=>e.ref),lw=async n=>{const e=await j(`/api/shot-scenes/${n}`);return e.ok||await b(e),e.text()},hw=n=>O("/api/color-agent/price",n).then(e=>b(e)),dw=(n,e)=>O(`/api/color-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),fw=n=>O("/api/broll-prompt/price",n).then(e=>b(e)),pw=(n,e)=>O(`/api/broll-prompt/${encodeURIComponent(n)}`,e).then(t=>b(t)),mw=n=>O("/api/geo/hd",n).then(e=>b(e)),gw=async n=>{const e=await O("/api/geo/blender-city",n);if(!e.ok)throw await b(e),Error("Blender city failed");return{script:await e.text(),buildings:Number(e.headers.get("x-city-buildings"))||0}},_w=n=>O("/api/geo/resolve",{ops:n}).then(e=>b(e)),yw=(n,e=!0,t="vi")=>j(`/api/geo/search?${new URLSearchParams({q:n,shape:e?"1":"0",lang:t})}`).then(r=>b(r)).then(r=>r.results),vw=n=>O("/api/caption-keywords/price",{words:n}).then(e=>b(e)),Ew=(n,e,t)=>O(`/api/caption-keywords/${encodeURIComponent(n)}`,{words:e,locale:t}).then(r=>b(r)),Tw=(n,e)=>O("/api/caption-translate/price",{lines:n,target:e}).then(t=>b(t)),ww=(n,e,t)=>O(`/api/caption-translate/${encodeURIComponent(n)}`,{lines:e,target:t}).then(r=>b(r)),Iw=n=>O("/api/media-peaks",{url:n}).then(e=>b(e)),Aw=n=>O("/api/stabilize",n).then(e=>b(e)),bw=n=>O("/api/audio-tools",n).then(e=>b(e)),Rw=n=>O("/api/media/frames/sign",{count:n}).then(e=>b(e)).then(e=>e.chunks);let Sw=null;const Nh=()=>Sw??=j("/api/media/render-target").then(n=>n.ok?n.json():{}).then(n=>({url:n?.url||"",gpu:n?.gpu!==!1})).catch(()=>({url:"",gpu:!1})),vr=()=>Nh().then(n=>n.url),Vh=n=>n<=30?1:Math.min(8,Math.ceil(n/10));function Cw(n){vr().then(e=>{if(e)for(let t=0;t<Vh(n);t++)fetch(`${e}/api/health`,{cache:"no-store"}).catch(()=>{})}).catch(()=>{})}async function Pw(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/media/proxy`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify({gcsUri:n})});if(s.status===429&&r<6){await xo(1e4,e);continue}const o=await b(s);return o.needed&&o.url&&o.gcsUri?{url:o.url,gcsUri:o.gcsUri,fps:Number(o.fps),width:Number(o.width),height:Number(o.height),...o.alpha===!0?{alpha:!0}:{}}:null}}let Au=null;const kw=()=>Au??=vr().then(async n=>fetch(`${n}/api/shot-inbetween`,{headers:await kt()})).then(n=>b(n)).catch(()=>(Au=null,{available:!1,maxSeconds:0}));async function Ow(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/shot-inbetween`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify(n)});if(s.status===429&&r<6){await xo(5e3,e);continue}return b(s)}}const bu=[5,10,15,20,30,30,30,30,30,30].map(n=>n*1e3),xo=(n,e)=>new Promise((t,r)=>{const s=setTimeout(t,n);e?.addEventListener("abort",()=>{clearTimeout(s),r(new DOMException("Aborted","AbortError"))},{once:!0})});function Mh(n){try{const e=n.headers.get("X-Clipoox-Review"),t=e?JSON.parse(decodeURIComponent(e)):null;return t&&Array.isArray(t.checks)&&Array.isArray(t.platforms)?t:null}catch{return null}}const Ut=.9;async function Dw(n,e){const t=Number(n.headers.get("Content-Length"))||0;if(!n.body||!t)return n.blob();const r=n.body.getReader(),s=[];let o=0;for(;;){const{done:a,value:u}=await r.read();if(a)break;s.push(u),o+=u.length,e(Math.min(1,o/t))}return new Blob(s,{type:n.headers.get("Content-Type")||"video/mp4"})}let Us=null,ys=null,vs=null;const Lh=n=>{const e=/^(\d+)\/(\d+)$/.exec(n.headers.get("X-Clipoox-Export-Quota")||"");return e?{used:+e[1],limit:+e[2]}:null};async function Nw(n,e,t,r,s){if(!n.body)throw new Error("Export failed (empty reply)");const o=n.body.getReader(),a=Fd(),u=[];let l=0,d=0,p=null,v=null,E=0;for(;;){const{done:C,value:V}=await o.read();if(C)break;for(const M of a.push(V))if(M.type==="progress")t?.(Ut*M.value);else if(M.type==="review"){const k=M.review;p=k&&Array.isArray(k.checks)&&Array.isArray(k.platforms)?k:null}else if(M.type==="timings")v=M.timings;else{if(M.type==="error")throw Object.assign(new Error(Uo(M.error)),{status:M.status});M.type==="file"?(l=M.size,E=performance.now(),e?.("download")):M.type==="stored"?(vs={gcsUri:M.gcsUri,size:M.size},l=M.size,E=performance.now()):M.type==="data"&&(u.push(M.chunk),d+=M.chunk.length,t?.(Ut+(1-Ut)*(l?Math.min(1,d/l):0)))}}if(!a.complete)throw new Error("Export interrupted — please try again");return s&&(Us={totalMs:Math.round(performance.now()-s.start),framesMs:Math.round(s.posted-s.start),renderMs:Math.round((E||performance.now())-s.posted),downloadMs:E?Math.round(performance.now()-E):0,server:v}),v&&s&&console.info("[export] timings",{server:v,browser:{frames_ms:Math.round(s.posted-s.start),request_to_file_ms:Math.round(E-s.posted),download_ms:Math.round(performance.now()-E),total_ms:Math.round(performance.now()-s.start),bytes:l}}),r?.(p),new Blob(vs?[]:u,{type:"video/mp4"})}function Uo(n){const e=/^Media exceeds (\d+) MB per export/.exec(n||"");if(e)return De("Video, ảnh và nhạc gốc trong Timeline nặng hơn {0} MB cho một lần xuất. Hãy cắt bớt hoặc bỏ các clip dài không dùng tới rồi xuất lại.",[e[1]]);const t=/^Media link missing: “(.*)” \(([\d.]+)s\)/.exec(n||"");return t?De("Lớp “{0}” (giây {1}) chưa có file media. Mở lớp đó chọn lại media, hoặc xoá lớp rồi xuất lại.",[t[1],t[2]]):/^MP4 render failed|Error opening input|Stream #\d|Input #\d|\/tmp\/canvas-/.test(n||"")?(console.warn("[export] render failed:",n),De("Không xuất được video lần này. Nếu bạn vừa sửa Timeline trong lúc xuất, hãy chờ lưu xong rồi bấm xuất lại. Nếu vẫn lỗi, hãy báo Clipoox.")):n||""}function xh(n){return n.code==="export_quota"?Object.assign(new Error(De("Bạn đã dùng hết lượt xuất video tháng này")),{planGate:{kind:"count",plan:n.plan||"free",offer:n.offer??null,seconds:0,limit:Number(n.limit)||0,used:Number(n.used)||0,resetAt:Number(n.resetAt)||0}}):n.code==="plan_required"&&n.offer?Object.assign(new Error(De("Cần nâng cấp gói để xuất video dài hơn")),{planGate:{kind:"length",plan:n.plan||"free",offer:n.offer,seconds:Number(n.seconds)||0}}):null}let Je=[];const Vw=n=>n.map(e=>e.replace(/[^A-Za-z0-9 _.:-]/g,"").slice(0,48)).filter(Boolean).slice(0,16).join(",");async function Mw(n,e,t,r,s,o,a,u){try{if(localStorage.getItem("clipoox.gpuExport")==="off")return Je=["off in this browser"],null}catch{}if(!(await Nh()).gpu)return Je=["off on the server"],null;const l=e.format||{resolution:"720p",aspectRatio:"16:9",fps:30},{clientExportCheck:d,clientExportCodes:p,softwareRetry:v,gpuErrorText:E}=await pe(async()=>{const{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}=await import("./clientExport-DvpTTndR.js");return{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}},__vite__mapDeps([0,1,2])),C=d(n,{format:l,camera:e.camera,look:e.look,encode:e.encode});if(!C.ok)return console.info("[export] server render:",C.reasons.slice(0,5).join(" · ")),Je=p(n,{format:l,camera:e.camera,look:e.look,encode:e.encode}),null;const V=await pe(()=>import("./gpuExport-CQ7ZhpsX.js"),__vite__mapDeps([3,1,4,2,5,6,7,8,9,10,11]));if(!await V.gpuExportSupported(l,e.encode))return console.info("[export] server render: no hardware video encoder here"),Je=[e.encode?.codec==="hevc"&&await V.gpuExportSupported(l)?"no hevc encoder":"no hardware encoder"],null;const M=n.reduce((k,q)=>q.disabled?k:Math.max(k,q.start+q.duration),0);{const k=await O("/api/media/client-export/check",{seconds:M,...e.aiJob?{aiJob:e.aiJob}:{}});if(k.status===402){const z=xh(await k.json().catch(()=>({})));if(z)throw z}if(!k.ok)return Je=[`plan check ${k.status}`],null;const q=(await k.json().catch(()=>null))?.hold;u.hold=typeof q=="string"?q:null}r?.("local"),s?.(0);try{let k=!1;const q=_=>V.exportOnGpu(n,{format:l,encode:e.encode,tracks:e.tracks,camera:e.camera,signal:t,onProgress:m=>s?.(m),software:_}),{blob:z,ms:B}=await q(!1).catch(_=>{if(t?.aborted||!v(_,V.gpuExportStage(),e.encode))throw _;return console.warn("[export] hardware encoder failed, again with the software encoder:",_),s?.(0),k=!0,q(!0)}),{width:Y,height:he,fps:P}=Xt(l);Us={totalMs:Math.round(performance.now()-a.start),framesMs:B.titles,renderMs:B.video+B.audio,downloadMs:0,server:{gpu:!0,...B}};{const _=await O("/api/media/client-export/done",{seconds:M,...u.hold?{hold:u.hold}:{},...k?{software:!0}:{},ms:B.total,titlesMs:B.titles,audioMs:B.audio,width:Y,height:he,fps:P,clips:n.length,...e.aiJob?{aiJob:e.aiJob}:{}}).catch(()=>null);_?.ok&&(ys=Lh(_)),u.hold=null}return o?.(null),z}catch(k){if(t?.aborted||k?.name==="AbortError")throw k;return console.warn("[export] GPU export failed, the server renders it:",k),Je=[`gpu failed: ${k?.name||"Error"} at ${V.gpuExportStage()||"start"}`,...E(k)?[`gpu error: ${E(k)}`]:[]],r?.("frames"),s?.(null),null}}async function Lw(n,e,t={},r,s,o){r?.("frames"),o?.(null);const a={start:performance.now(),posted:0};t.mode===void 0&&(Us=null,ys=null,vs=null),n=Ad(n,Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30}).fps);{const{expandComps:P}=await pe(async()=>{const{expandComps:m}=await import("./timelineComp-Dx_kED5V.js").then(g=>g.t);return{expandComps:m}},__vite__mapDeps([2,1])),_=Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30});n=P(n.filter(m=>!m.disabled),{W:_.width,H:_.height})}n=n.filter(P=>!P.disabled).map(bd);const u=Md(n);n=u.clips;const l=n.filter(P=>P.title&&!P.url&&!Rd(P));if(l.length){const P=new Map((await(await pe(async()=>{const{materializeTitles:_}=await import("./timelineText-RKyRP988.js");return{materializeTitles:_}},__vite__mapDeps([12,13,1,11,14,15,10]))).materializeTitles(l)).map(_=>[_.id,_]));n=n.map(_=>P.get(_.id)??_)}if(u.fixes.length&&s){const P=s;s=_=>P({..._??{ok:!0,checks:[],platforms:[],duration:0,ms:0},fixes:[...u.fixes,..._?.fixes??[]].slice(0,10)})}if(Je=t.breakdown?["breakdown"]:[],t.mode===void 0&&!t.breakdown){const P={hold:null},_=await Mw(n,t,e,r,o,s,a,P);if(_)return _;P.hold&&(t={...t,hold:P.hold})}t.mode===void 0&&Cw(n.reduce((P,_)=>_.disabled?P:Math.max(P,_.start+_.duration),0)),n.some(P=>P.join)&&(n=[...n,...(await pe(async()=>{const{joinDecoLayers:P}=await import("./titleFrameBudget-X7HLSDre.js").then(_=>_.nM);return{joinDecoLayers:P}},[])).joinDecoLayers(n)]);const d=new(await pe(async()=>{const{FrameSink:P}=await import("./frameSink-DYs2gTzq.js");return{FrameSink:P}},__vite__mapDeps([16,1]))).FrameSink({signal:e}),p=t.format||{resolution:"720p",aspectRatio:"16:9",fps:30};if(n.some(Sd)){const P=await(await pe(async()=>{const{distortForServer:_}=await import("./distortFrames-BLt1icUb.js");return{distortForServer:_}},__vite__mapDeps([17,1,7,8]))).distortForServer(n,p,d,e,t.tracks);n=P.clips,t={...t,tracks:P.tracks}}if(n.some(P=>P.kind==="model")&&await(await pe(async()=>{const{render3DFrames:P}=await import("./timeline3dExport-DCOr6ARB.js");return{render3DFrames:P}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(n,p,d,e,t.camera),n.some(P=>Fa(P.title)||P.shape||P.motion||P.lottie||P.card||P.geo)&&await(await pe(async()=>{const{renderTitleFrames:P}=await import("./titleFrames-aMG7HdVe.js");return{renderTitleFrames:P}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...n,...ja(n)],p,d,e,t.camera),n.some(P=>P.mask||P.person)){const P=await pe(()=>import("./rotoMatte-i-cJTYmK.js").then(_=>_.r),__vite__mapDeps([26,1,13,11]));await P.renderMatteFrames([...n,...P.maskedCopies(n)],Xt(p).fps,d,e)}{const P=await pe(()=>import("./windowFrames-1wAkkWnv.js"),__vite__mapDeps([27,1,26,13,11,10]));P.hasMovingWindows(n)&&await P.renderWindowFrames(n,Xt(p).fps,d,e)}{const{groupedLevels:P}=await pe(async()=>{const{groupedLevels:m}=await import("./timelineComp-Dx_kED5V.js").then(g=>g.t);return{groupedLevels:m}},__vite__mapDeps([2,1])),_=Xt(p);for(const m of P(n,{W:_.width,H:_.height})){if(m.some(g=>g.kind==="model")&&await(await pe(async()=>{const{render3DFrames:g}=await import("./timeline3dExport-DCOr6ARB.js");return{render3DFrames:g}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(m,p,d,e,null),m.some(g=>Fa(g.title)||g.shape||g.motion||g.lottie||g.card||g.geo)&&await(await pe(async()=>{const{renderTitleFrames:g}=await import("./titleFrames-aMG7HdVe.js");return{renderTitleFrames:g}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...m,...ja(m)],p,d,e,null),m.some(g=>g.mask||g.person)){const g=await pe(()=>import("./rotoMatte-i-cJTYmK.js").then(T=>T.r),__vite__mapDeps([26,1,13,11]));await g.renderMatteFrames([...m,...g.maskedCopies(m)],_.fps,d,e)}{const g=await pe(()=>import("./windowFrames-1wAkkWnv.js"),__vite__mapDeps([27,1,26,13,11,10]));g.hasMovingWindows(m)&&await g.renderWindowFrames(m,_.fps,d,e)}}}n.some(P=>P.mask||P.planar||P.sceneTrack)&&(n=await(await pe(async()=>{const{packMasks:P}=await import("./rotoMaskStore-DdpmT9C3.js");return{packMasks:P}},__vite__mapDeps([28,1,29,10,11]))).packMasks(n));const v=JSON.stringify({clips:n,...t,...await d.finish()}),E=await vr();r?.("render");const C=typeof CompressionStream=="function"&&v.length>256*1024,V=C?await new Response(new Blob([v]).stream().pipeThrough(new CompressionStream("gzip"))).blob():v;a.posted=performance.now();const M=!!o&&t.mode===void 0,k=async P=>fetch(P,{method:"POST",signal:e,headers:{"Content-Type":"application/json","X-Clipoox-Frames-Ms":String(Math.round(a.posted-a.start)),...t.mode===void 0&&Je.length?{"X-Clipoox-Gpu-Skip":Vw(Je)}:{},...M?{Accept:`${Ha}, video/mp4;q=0.9, */*;q=0.5`}:{},...C?{"Content-Encoding":"gzip"}:{},...await kt()},body:V}),q=n.reduce((P,_)=>Math.max(P,_.start+_.duration),0),z=performance.now();let B=!1;const Y=o?setInterval(()=>{B||o(Ut*Su((performance.now()-z)/1e3,10+q*.8))},500):null,he=P=>{B=!0,o?.(P)};try{let P;for(let _=0;;_++){try{P=await k(`${E}/api/media/timeline`)}catch(m){if(!E||e?.aborted)throw m;P=await k("/api/media/timeline")}if(P.status!==429||_>=bu.length)break;r?.("queue"),await xo(bu[_],e),r?.("render")}if(P.ok&&t.mode===void 0&&(ys=Lh(P)),P.ok&&M&&(P.headers.get("Content-Type")||"").startsWith(Ha))return await Nw(P,r,he,s,a);if(r?.("download"),!P.ok){const _=await P.json().catch(()=>({}));{const m=xh(_);if(m)throw m}throw _.clip?new Error(De("Không xuất được: clip “{0}” (giây {1}) có dữ liệu lỗi — {2}. Hãy sửa hoặc xoá clip đó rồi xuất lại.",[_.clip.label||"?",Number(_.clip.start||0).toFixed(1),_.reason||_.error||""])):new Error(_.code==="render_unavailable"?De("Máy render đang bận hoặc vừa khởi động lại, bản xuất này quá nặng để chạy dự phòng. Hãy xuất lại sau khoảng 1 phút."):Uo(_.error)||`Export failed (${P.status})`)}return s?.(Mh(P)),o?(he(Ut),await Dw(P,_=>he(Ut+(1-Ut)*_))):P.blob()}finally{Y&&clearInterval(Y)}}const xw=n=>j(`/api/motion-agent/price${n?`?chars=${n.chars}&duration=${n.duration}&kind=${n.kind}`:""}`).then(e=>b(e)),Uw=n=>O("/api/motion-agent",n).then(e=>b(e)).then(e=>{if(e.error)throw Object.assign(new Error(e.error),{status:e.status});return e}),Fw=()=>j("/api/rig-agent/price").then(n=>b(n)),jw=n=>O("/api/rig-agent",n).then(e=>b(e)),Bw=()=>{const n=navigator.userAgent,e=/(Edg|OPR|Firefox|Chrome|Version)\/(\d+)/.exec(n),t=e?(e[1]==="Edg"?"Edge":e[1]==="OPR"?"Opera":e[1]==="Version"?"Safari":e[1])+" "+e[2]:"other";return/Windows/.test(n)?`${t} Windows`:/Mac OS X/.test(n)?`${t} macOS`:/Android/.test(n)?`${t} Android`:/iPhone|iPad/.test(n)?`${t} iOS`:`${t} other`};function $w(n,e,t={}){try{const r=navigator;O("/api/client-log",{kind:n,message:String(e||"").slice(0,300),detail:{browser:Bw(),cores:r.hardwareConcurrency,memory:r.deviceMemory,...t}}).catch(()=>{})}catch{}}const hI=Object.freeze(Object.defineProperty({__proto__:null,acceptProduction:TT,addUserFont:LT,approveBlenderDevice:kE,archiveCanvas:UE,askAgent:IT,askShotAgent:KT,attachDirectorReference:sT,brollPrompt:pw,brollPromptPrice:fw,cancelRemoteMission:LE,canvasInbox:YE,captionKeywords:Ew,captionKeywordsPrice:vw,captionTranslate:ww,captionTranslatePrice:Tw,clearDirector:wT,colorAgent:dw,colorAgentPrice:hw,consumeCanvasInbox:ZE,copyTimelineDoc:XE,createCanvas:IE,createLibraryModel:CT,createRemoteMission:DE,createSkill:BE,createVcamSession:ME,deleteBrand:FT,deleteCanvas:PE,deleteLibraryAsset:cT,deleteLut:$T,deleteSkill:qE,deleteTempUploads:yE,deleteUserFont:xT,describeFootage:dT,describePrice:mT,duplicateCanvas:FE,estimate:oE,estimateShotAgent:GT,exportReviewOf:Mh,exportTimeline:Lw,extractFrame:dE,fetchHealth:sE,fetchLut:qT,freeTranscript:fT,friendlyExportError:Uo,geoSearch:yw,getAssetLibraryItem:DT,getCanvas:AE,getCanvasShotRev:RE,getCanvasTimelineRev:SE,getDirector:nT,getPersonMatte:ow,getProduction:_T,getRemoteMission:VE,getRotoMask:cw,getSeries:HE,getSet:GE,getShotScene:lw,getTimelineDoc:QE,getTimelineDocRev:CE,get lastExportQuota(){return ys},get lastExportStored(){return vs},get lastExportTimes(){return Us},libraryUsage:oT,listAgentModels:AT,listAssetLibrary:kT,listAssetLibraryCategories:OT,listAssets:eT,listBlenderDevices:OE,listBrands:VT,listCanvases:xE,listDirectorReferences:rT,listGenerators:iE,listJobs:uE,listLibrary:iT,listModelCategories:RT,listModelLibrary:bT,listMyLuts:BT,listRemoteMissions:NE,listSeries:zE,listSkills:jE,listTempUploads:gE,listTextTemplates:NT,listTransitions:zT,listUserFonts:MT,locateObject:lT,mapBlenderScript:gw,mapHd:mw,me:rE,mediaPeaks:Iw,mediaProxy:Pw,mocapRegionStatus:nE,modelReadUrl:EE,motionAgent:Uw,motionAgentPrice:xw,motionUsage:hT,multicamSync:gT,pinToLibrary:aT,pluginAssetUrls:TE,pollJob:cE,prewarmCount:Vh,processAudio:bw,productionAction:vT,publishLibraryModel:PT,putSigned:vE,quoteProduction:yT,reportClient:$w,requestTempUpload:mE,requestUpload:Dh,resolveMapPlaces:_w,rigAgent:jw,rigAgentPrice:Fw,runGenerator:aE,saveBrand:UT,saveCanvas:bE,saveLut:jT,saveModelThumbnail:ST,savePersonMatte:iw,saveProjectContext:tT,saveRotoMask:aw,saveSeries:WE,saveSet:KE,saveShotScene:uw,saveTimelineDoc:JE,sendDirector:ET,shareModelAsset:HT,shotAgentInfo:WT,shotInbetween:Ow,shotInbetweenInfo:kw,shotLivePoll:ZT,shotLiveResult:rw,shotMissionCancel:XT,shotMissionQuote:JT,shotMissionTurn:QT,shotRemotePoll:YT,shotRemoteReport:sw,signFrameChunks:Rw,signOutput:wE,signTempUpload:_E,spliceRegionsMedia:hE,stabilizeClip:Aw,timelineAgent:uT,timelineAgentPrice:pT,timelineLivePoll:ew,timelineLiveProgress:tw,timelineLiveResult:nw,trimMedia:lE,updateSkill:$E,uploadFile:pE},Symbol.toStringTag,{value:"Module"}));export{_E as $,UT as A,jE as B,$E as C,BE as D,qE as E,_T as F,vT as G,yT as H,TT as I,rT as J,sT as K,AT as L,ET as M,nT as N,wT as O,tT as P,uE as Q,Uw as R,xw as S,HT as T,iT as U,oT as V,xd as W,cT as X,bT as Y,eT as Z,DT as _,cE as a,ME as a$,mE as a0,vE as a1,gE as a2,yE as a3,BT as a4,hT as a5,Tw as a6,ww as a7,vw as a8,Ew as a9,Bd as aA,Zw as aB,ew as aC,vs as aD,nw as aE,tw as aF,CE as aG,SE as aH,kd as aI,Jw as aJ,Qw as aK,Lw as aL,Us as aM,ys as aN,Aw as aO,bw as aP,Xw as aQ,wi as aR,aI as aS,iI as aT,oI as aU,kE as aV,OE as aW,NE as aX,VE as aY,DE as aZ,LE as a_,fT as aa,nI as ab,eI as ac,tI as ad,NT as ae,yw as af,mw as ag,gw as ah,kT as ai,Su as aj,gT as ak,$w as al,Gw as am,Ww as an,Kw as ao,EE as ap,zT as aq,Pw as ar,$T as as,hw as at,dw as au,fw as av,pw as aw,pT as ax,uT as ay,Yw as az,hE as b,FE as b0,UE as b1,ln as b2,$t as b3,vt as b4,ke as b5,xe as b6,to as b7,Yd as b8,Fu as b9,KT as bA,ZT as bB,rw as bC,HE as bD,zE as bE,WE as bF,GE as bG,nE as bH,qT as bI,jT as bJ,TE as bK,aw as bL,cw as bM,_w as bN,iw as bO,Od as bP,MT as bQ,xT as bR,LT as bS,ow as bT,lT as bU,hI as bV,_n as ba,Vu as bb,Mu as bc,st as bd,yp as be,sI as bf,uI as bg,lI as bh,iE as bi,uw as bj,lw as bk,RT as bl,ST as bm,CT as bn,PT as bo,RE as bp,XT as bq,QT as br,YT as bs,sw as bt,JT as bu,KE as bv,Fw as bw,jw as bx,GT as by,WT as bz,dT as c,mT as d,oE as e,JE as f,QE as g,XE as h,AE as i,IE as j,bE as k,YE as l,ZE as m,dE as n,Ud as o,aT as p,xE as q,aE as r,wE as s,PE as t,pE as u,cI as v,tE as w,lE as x,VT as y,FT as z};
|
|
3158
|
+
`))>=0;)u(o.slice(0,v)),o=o.slice(v+1)}u(o);const l=a||{};if(typeof l.error=="string"&&typeof l.status=="number"&&l.status>=400){const d=new Error(l.error);throw d.status=l.status,d.code=l.code,d}if(!l.item)throw new Error(De("Chép lời bị ngắt giữa chừng. Hãy thử lại."));return l.item}const pT=(n,e,t=0)=>j(`/api/timeline-agent/plan-price?model=${encodeURIComponent(n)}&chars=${Math.round(e)}&refs=${t}`).then(r=>b(r)),mT=(n,e=!0)=>j(`/api/timeline-agent/describe-price?audioOnly=${e?1:0}${n&&n>0?`&duration=${Math.ceil(n)}`:""}`).then(t=>b(t)),gT=(n,e,t)=>O("/api/timeline/multicam/sync",{canvasId:n,items:e,...t?{main:t}:{}}).then(r=>b(r)),xs=(n,e)=>`/api/production/${encodeURIComponent(n)}/${encodeURIComponent(e)}`,_T=(n,e)=>j(xs(n,e)).then(t=>b(t)),yT=(n,e,t)=>O(`${xs(n,e)}/quote`,{imageGenerator:t}).then(r=>b(r)),vT=(n,e,t,r)=>O(`${xs(n,e)}/${t}`,{revision:r}).then(s=>b(s)),ET=(n,e,t,r,s,o,a,u)=>O(`/api/director/${encodeURIComponent(n)}`,{input:e,requestId:t,referenceIds:r,defaults:s,...o?{skill:o.id?{id:o.id}:{title:o.title,instruction:o.instruction}}:{},...a?{model:a}:{},...u?{aspectRatio:u}:{}}).then(l=>b(l)),TT=(n,e,t,r)=>O(`${xs(n,e)}/accept`,{revision:t,totalCredits:r}).then(s=>b(s)),wT=n=>O(`/api/director/${encodeURIComponent(n)}`,{},"DELETE").then(e=>b(e)),IT=(n,e,t,r)=>O("/api/agent",{messages:n.map(({role:s,content:o})=>({role:s,content:o})),canvas:e,model:t||void 0,defaults:r}).then(s=>b(s)),AT=()=>j("/api/agent/models").then(n=>n.json()),bT=(n="published",e)=>j("/api/model-library?"+new URLSearchParams({status:n,...e?{cursor:e}:{}})).then(t=>b(t)),RT=()=>j("/api/model-library/categories").then(n=>b(n)),ST=(n,e)=>O("/api/model-library/"+encodeURIComponent(n)+"/thumbnail",{gcsUri:e}).then(t=>b(t)),CT=n=>O("/api/model-library",n).then(e=>b(e)),PT=(n,e)=>O("/api/model-library/"+encodeURIComponent(n),{status:e},"PATCH").then(t=>b(t)),kT=(n={})=>j("/api/asset-library?"+new URLSearchParams(Object.entries(n).filter(([,e])=>e!==void 0&&e!=="").map(([e,t])=>[e,String(t)]))).then(e=>b(e)),OT=n=>j("/api/asset-library/categories"+(n?"?kind="+n:"")).then(e=>b(e)),DT=n=>j("/api/asset-library/"+encodeURIComponent(n)).then(e=>b(e)).then(e=>e.item),NT=(n="published")=>j("/api/text-templates?"+new URLSearchParams({status:n})).then(e=>b(e)),VT=()=>j("/api/brands").then(n=>b(n)),MT=()=>j("/api/fonts").then(n=>b(n)),LT=n=>O("/api/fonts",n).then(e=>b(e)),xT=n=>O("/api/fonts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),UT=(n,e)=>O("/api/brands"+(e?"/"+encodeURIComponent(e):""),n,e?"PUT":"POST").then(t=>b(t)),FT=n=>O("/api/brands/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),jT=n=>O("/api/luts",n).then(e=>b(e)),BT=()=>j("/api/luts").then(n=>b(n)),$T=n=>O("/api/luts/"+encodeURIComponent(n),{},"DELETE").then(e=>b(e)),qT=n=>j("/api/luts/"+encodeURIComponent(n)).then(e=>b(e)),zT=(n="published")=>j("/api/transitions?"+new URLSearchParams({status:n})).then(e=>b(e)),HT=n=>O("/api/model-library/share",n).then(e=>b(e)),WT=()=>j("/api/shot-agent").then(n=>b(n)),GT=(n,e,t)=>O("/api/shot-agent/estimate",{scene:n,messages:e,model:t}).then(r=>b(r)),KT=(n,e,t,r)=>O("/api/shot-agent",{scene:n,messages:e,requestId:t,model:r}).then(s=>b(s)),QT=n=>O("/api/shot-agent/mission/turn",n).then(e=>b(e)),JT=(n,e="build")=>O("/api/shot-agent/mission/quote",{model:n,kind:e}).then(t=>b(t)),XT=n=>O("/api/shot-agent/mission/cancel",{missionId:n}).then(e=>b(e)),YT=n=>O("/api/shot-agent/remote/poll",n).then(e=>b(e)),ZT=n=>O("/api/shot-agent/live/poll",n).then(e=>b(e)),ew=n=>O("/api/timeline-live/poll",n).then(e=>b(e)),tw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/progress`,e).then(t=>b(t)),nw=(n,e)=>O(`/api/timeline-live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),rw=(n,e)=>O(`/api/shot-agent/live/${encodeURIComponent(n)}/result`,e).then(t=>b(t)),sw=(n,e)=>O(`/api/shot-agent/remote/missions/${encodeURIComponent(n)}/status`,e).then(t=>b(t)),iw=n=>O("/api/person-mattes",{data:n}).then(e=>b(e)).then(e=>e.ref),ow=async n=>{const e=await j(`/api/person-mattes/${n}`);return e.ok||await b(e),e.text()},aw=n=>O("/api/roto-masks",{data:n}).then(e=>b(e)).then(e=>e.ref),cw=async n=>{const e=await j(`/api/roto-masks/${n}`);return e.ok||await b(e),e.text()},uw=n=>O("/api/shot-scenes",{data:n}).then(e=>b(e)).then(e=>e.ref),lw=async n=>{const e=await j(`/api/shot-scenes/${n}`);return e.ok||await b(e),e.text()},hw=n=>O("/api/color-agent/price",n).then(e=>b(e)),dw=(n,e)=>O(`/api/color-agent/${encodeURIComponent(n)}`,e).then(t=>b(t)),fw=n=>O("/api/broll-prompt/price",n).then(e=>b(e)),pw=(n,e)=>O(`/api/broll-prompt/${encodeURIComponent(n)}`,e).then(t=>b(t)),mw=n=>O("/api/geo/hd",n).then(e=>b(e)),gw=async n=>{const e=await O("/api/geo/blender-city",n);if(!e.ok)throw await b(e),Error("Blender city failed");return{script:await e.text(),buildings:Number(e.headers.get("x-city-buildings"))||0}},_w=n=>O("/api/geo/resolve",{ops:n}).then(e=>b(e)),yw=(n,e=!0,t="vi")=>j(`/api/geo/search?${new URLSearchParams({q:n,shape:e?"1":"0",lang:t})}`).then(r=>b(r)).then(r=>r.results),vw=n=>O("/api/caption-keywords/price",{words:n}).then(e=>b(e)),Ew=(n,e,t)=>O(`/api/caption-keywords/${encodeURIComponent(n)}`,{words:e,locale:t}).then(r=>b(r)),Tw=(n,e)=>O("/api/caption-translate/price",{lines:n,target:e}).then(t=>b(t)),ww=(n,e,t)=>O(`/api/caption-translate/${encodeURIComponent(n)}`,{lines:e,target:t}).then(r=>b(r)),Iw=n=>O("/api/media-peaks",{url:n}).then(e=>b(e)),Aw=n=>O("/api/stabilize",n).then(e=>b(e)),bw=n=>O("/api/audio-tools",n).then(e=>b(e)),Rw=n=>O("/api/media/frames/sign",{count:n}).then(e=>b(e)).then(e=>e.chunks);let Sw=null;const Nh=()=>Sw??=j("/api/media/render-target").then(n=>n.ok?n.json():{}).then(n=>({url:n?.url||"",gpu:n?.gpu!==!1})).catch(()=>({url:"",gpu:!1})),vr=()=>Nh().then(n=>n.url),Vh=n=>n<=30?1:Math.min(8,Math.ceil(n/10));function Cw(n){vr().then(e=>{if(e)for(let t=0;t<Vh(n);t++)fetch(`${e}/api/health`,{cache:"no-store"}).catch(()=>{})}).catch(()=>{})}async function Pw(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/media/proxy`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify({gcsUri:n})});if(s.status===429&&r<6){await xo(1e4,e);continue}const o=await b(s);return o.needed&&o.url&&o.gcsUri?{url:o.url,gcsUri:o.gcsUri,fps:Number(o.fps),width:Number(o.width),height:Number(o.height),...o.alpha===!0?{alpha:!0}:{}}:null}}let Au=null;const kw=()=>Au??=vr().then(async n=>fetch(`${n}/api/shot-inbetween`,{headers:await kt()})).then(n=>b(n)).catch(()=>(Au=null,{available:!1,maxSeconds:0}));async function Ow(n,e){const t=await vr();for(let r=0;;r++){const s=await fetch(`${t}/api/shot-inbetween`,{method:"POST",signal:e,headers:{"Content-Type":"application/json",...await kt()},body:JSON.stringify(n)});if(s.status===429&&r<6){await xo(5e3,e);continue}return b(s)}}const bu=[5,10,15,20,30,30,30,30,30,30].map(n=>n*1e3),xo=(n,e)=>new Promise((t,r)=>{const s=setTimeout(t,n);e?.addEventListener("abort",()=>{clearTimeout(s),r(new DOMException("Aborted","AbortError"))},{once:!0})});function Mh(n){try{const e=n.headers.get("X-Clipoox-Review"),t=e?JSON.parse(decodeURIComponent(e)):null;return t&&Array.isArray(t.checks)&&Array.isArray(t.platforms)?t:null}catch{return null}}const Ut=.9;async function Dw(n,e){const t=Number(n.headers.get("Content-Length"))||0;if(!n.body||!t)return n.blob();const r=n.body.getReader(),s=[];let o=0;for(;;){const{done:a,value:u}=await r.read();if(a)break;s.push(u),o+=u.length,e(Math.min(1,o/t))}return new Blob(s,{type:n.headers.get("Content-Type")||"video/mp4"})}let Us=null,ys=null,vs=null;const Lh=n=>{const e=/^(\d+)\/(\d+)$/.exec(n.headers.get("X-Clipoox-Export-Quota")||"");return e?{used:+e[1],limit:+e[2]}:null};async function Nw(n,e,t,r,s){if(!n.body)throw new Error("Export failed (empty reply)");const o=n.body.getReader(),a=Fd(),u=[];let l=0,d=0,p=null,v=null,E=0;for(;;){const{done:C,value:V}=await o.read();if(C)break;for(const M of a.push(V))if(M.type==="progress")t?.(Ut*M.value);else if(M.type==="review"){const k=M.review;p=k&&Array.isArray(k.checks)&&Array.isArray(k.platforms)?k:null}else if(M.type==="timings")v=M.timings;else{if(M.type==="error")throw Object.assign(new Error(Uo(M.error)),{status:M.status});M.type==="file"?(l=M.size,E=performance.now(),e?.("download")):M.type==="stored"?(vs={gcsUri:M.gcsUri,size:M.size},l=M.size,E=performance.now()):M.type==="data"&&(u.push(M.chunk),d+=M.chunk.length,t?.(Ut+(1-Ut)*(l?Math.min(1,d/l):0)))}}if(!a.complete)throw new Error("Export interrupted — please try again");return s&&(Us={totalMs:Math.round(performance.now()-s.start),framesMs:Math.round(s.posted-s.start),renderMs:Math.round((E||performance.now())-s.posted),downloadMs:E?Math.round(performance.now()-E):0,server:v}),v&&s&&console.info("[export] timings",{server:v,browser:{frames_ms:Math.round(s.posted-s.start),request_to_file_ms:Math.round(E-s.posted),download_ms:Math.round(performance.now()-E),total_ms:Math.round(performance.now()-s.start),bytes:l}}),r?.(p),new Blob(vs?[]:u,{type:"video/mp4"})}function Uo(n){const e=/^Media exceeds (\d+) MB per export/.exec(n||"");if(e)return De("Video, ảnh và nhạc gốc trong Timeline nặng hơn {0} MB cho một lần xuất. Hãy cắt bớt hoặc bỏ các clip dài không dùng tới rồi xuất lại.",[e[1]]);const t=/^Media link missing: “(.*)” \(([\d.]+)s\)/.exec(n||"");return t?De("Lớp “{0}” (giây {1}) chưa có file media. Mở lớp đó chọn lại media, hoặc xoá lớp rồi xuất lại.",[t[1],t[2]]):/^MP4 render failed|Error opening input|Stream #\d|Input #\d|\/tmp\/canvas-/.test(n||"")?(console.warn("[export] render failed:",n),De("Không xuất được video lần này. Nếu bạn vừa sửa Timeline trong lúc xuất, hãy chờ lưu xong rồi bấm xuất lại. Nếu vẫn lỗi, hãy báo Clipoox.")):n||""}function xh(n){return n.code==="export_quota"?Object.assign(new Error(De("Bạn đã dùng hết lượt xuất video tháng này")),{planGate:{kind:"count",plan:n.plan||"free",offer:n.offer??null,seconds:0,limit:Number(n.limit)||0,used:Number(n.used)||0,resetAt:Number(n.resetAt)||0}}):n.code==="plan_required"&&n.offer?Object.assign(new Error(De("Cần nâng cấp gói để xuất video dài hơn")),{planGate:{kind:"length",plan:n.plan||"free",offer:n.offer,seconds:Number(n.seconds)||0}}):null}let Je=[];const Vw=n=>n.map(e=>e.replace(/[^A-Za-z0-9 _.:-]/g,"").slice(0,48)).filter(Boolean).slice(0,16).join(",");async function Mw(n,e,t,r,s,o,a,u){try{if(localStorage.getItem("clipoox.gpuExport")==="off")return Je=["off in this browser"],null}catch{}if(!(await Nh()).gpu)return Je=["off on the server"],null;const l=e.format||{resolution:"720p",aspectRatio:"16:9",fps:30},{clientExportCheck:d,clientExportCodes:p,softwareRetry:v,gpuErrorText:E}=await pe(async()=>{const{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}=await import("./clientExport-pkLbOmEF.js");return{clientExportCheck:k,clientExportCodes:q,softwareRetry:z,gpuErrorText:B}},__vite__mapDeps([0,1,2])),C=d(n,{format:l,camera:e.camera,look:e.look,encode:e.encode});if(!C.ok)return console.info("[export] server render:",C.reasons.slice(0,5).join(" · ")),Je=p(n,{format:l,camera:e.camera,look:e.look,encode:e.encode}),null;const V=await pe(()=>import("./gpuExport-oA2mUsdm.js"),__vite__mapDeps([3,1,4,2,5,6,7,8,9,10,11]));if(!await V.gpuExportSupported(l,e.encode))return console.info("[export] server render: no hardware video encoder here"),Je=[e.encode?.codec==="hevc"&&await V.gpuExportSupported(l)?"no hevc encoder":"no hardware encoder"],null;const M=n.reduce((k,q)=>q.disabled?k:Math.max(k,q.start+q.duration),0);{const k=await O("/api/media/client-export/check",{seconds:M,...e.aiJob?{aiJob:e.aiJob}:{}});if(k.status===402){const z=xh(await k.json().catch(()=>({})));if(z)throw z}if(!k.ok)return Je=[`plan check ${k.status}`],null;const q=(await k.json().catch(()=>null))?.hold;u.hold=typeof q=="string"?q:null}r?.("local"),s?.(0);try{let k=!1;const q=_=>V.exportOnGpu(n,{format:l,encode:e.encode,tracks:e.tracks,camera:e.camera,signal:t,onProgress:m=>s?.(m),software:_}),{blob:z,ms:B}=await q(!1).catch(_=>{if(t?.aborted||!v(_,V.gpuExportStage(),e.encode))throw _;return console.warn("[export] hardware encoder failed, again with the software encoder:",_),s?.(0),k=!0,q(!0)}),{width:Y,height:he,fps:P}=Xt(l);Us={totalMs:Math.round(performance.now()-a.start),framesMs:B.titles,renderMs:B.video+B.audio,downloadMs:0,server:{gpu:!0,...B}};{const _=await O("/api/media/client-export/done",{seconds:M,...u.hold?{hold:u.hold}:{},...k?{software:!0}:{},ms:B.total,titlesMs:B.titles,audioMs:B.audio,width:Y,height:he,fps:P,clips:n.length,...e.aiJob?{aiJob:e.aiJob}:{}}).catch(()=>null);_?.ok&&(ys=Lh(_)),u.hold=null}return o?.(null),z}catch(k){if(t?.aborted||k?.name==="AbortError")throw k;return console.warn("[export] GPU export failed, the server renders it:",k),Je=[`gpu failed: ${k?.name||"Error"} at ${V.gpuExportStage()||"start"}`,...E(k)?[`gpu error: ${E(k)}`]:[]],r?.("frames"),s?.(null),null}}async function Lw(n,e,t={},r,s,o){r?.("frames"),o?.(null);const a={start:performance.now(),posted:0};t.mode===void 0&&(Us=null,ys=null,vs=null),n=Ad(n,Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30}).fps);{const{expandComps:P}=await pe(async()=>{const{expandComps:m}=await import("./timelineComp-i-zdaoB2.js").then(g=>g.t);return{expandComps:m}},__vite__mapDeps([2,1])),_=Xt(t.format||{resolution:"720p",aspectRatio:"16:9",fps:30});n=P(n.filter(m=>!m.disabled),{W:_.width,H:_.height})}n=n.filter(P=>!P.disabled).map(bd);const u=Md(n);n=u.clips;const l=n.filter(P=>P.title&&!P.url&&!Rd(P));if(l.length){const P=new Map((await(await pe(async()=>{const{materializeTitles:_}=await import("./timelineText-DurRhyuh.js");return{materializeTitles:_}},__vite__mapDeps([12,13,1,11,14,15,10]))).materializeTitles(l)).map(_=>[_.id,_]));n=n.map(_=>P.get(_.id)??_)}if(u.fixes.length&&s){const P=s;s=_=>P({..._??{ok:!0,checks:[],platforms:[],duration:0,ms:0},fixes:[...u.fixes,..._?.fixes??[]].slice(0,10)})}if(Je=t.breakdown?["breakdown"]:[],t.mode===void 0&&!t.breakdown){const P={hold:null},_=await Mw(n,t,e,r,o,s,a,P);if(_)return _;P.hold&&(t={...t,hold:P.hold})}t.mode===void 0&&Cw(n.reduce((P,_)=>_.disabled?P:Math.max(P,_.start+_.duration),0)),n.some(P=>P.join)&&(n=[...n,...(await pe(async()=>{const{joinDecoLayers:P}=await import("./titleFrameBudget-DsM0V482.js").then(_=>_.nM);return{joinDecoLayers:P}},[])).joinDecoLayers(n)]);const d=new(await pe(async()=>{const{FrameSink:P}=await import("./frameSink-CSRqCnwI.js");return{FrameSink:P}},__vite__mapDeps([16,1]))).FrameSink({signal:e}),p=t.format||{resolution:"720p",aspectRatio:"16:9",fps:30};if(n.some(Sd)){const P=await(await pe(async()=>{const{distortForServer:_}=await import("./distortFrames-D_v-aSVO.js");return{distortForServer:_}},__vite__mapDeps([17,1,7,8]))).distortForServer(n,p,d,e,t.tracks);n=P.clips,t={...t,tracks:P.tracks}}if(n.some(P=>P.kind==="model")&&await(await pe(async()=>{const{render3DFrames:P}=await import("./timeline3dExport-Uo0S0CR0.js");return{render3DFrames:P}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(n,p,d,e,t.camera),n.some(P=>Fa(P.title)||P.shape||P.motion||P.lottie||P.card||P.geo)&&await(await pe(async()=>{const{renderTitleFrames:P}=await import("./titleFrames-C8kvflgT.js");return{renderTitleFrames:P}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...n,...ja(n)],p,d,e,t.camera),n.some(P=>P.mask||P.person)){const P=await pe(()=>import("./rotoMatte-7b7Ow64f.js").then(_=>_.r),__vite__mapDeps([26,1,13,11]));await P.renderMatteFrames([...n,...P.maskedCopies(n)],Xt(p).fps,d,e)}{const P=await pe(()=>import("./windowFrames-DhhJLIs-.js"),__vite__mapDeps([27,1,26,13,11,10]));P.hasMovingWindows(n)&&await P.renderWindowFrames(n,Xt(p).fps,d,e)}{const{groupedLevels:P}=await pe(async()=>{const{groupedLevels:m}=await import("./timelineComp-i-zdaoB2.js").then(g=>g.t);return{groupedLevels:m}},__vite__mapDeps([2,1])),_=Xt(p);for(const m of P(n,{W:_.width,H:_.height})){if(m.some(g=>g.kind==="model")&&await(await pe(async()=>{const{render3DFrames:g}=await import("./timeline3dExport-Uo0S0CR0.js");return{render3DFrames:g}},__vite__mapDeps([18,1,19,20,21,22,16,10,11]))).render3DFrames(m,p,d,e,null),m.some(g=>Fa(g.title)||g.shape||g.motion||g.lottie||g.card||g.geo)&&await(await pe(async()=>{const{renderTitleFrames:g}=await import("./titleFrames-C8kvflgT.js");return{renderTitleFrames:g}},__vite__mapDeps([23,1,14,15,24,25,10,11,16]))).renderTitleFrames([...m,...ja(m)],p,d,e,null),m.some(g=>g.mask||g.person)){const g=await pe(()=>import("./rotoMatte-7b7Ow64f.js").then(T=>T.r),__vite__mapDeps([26,1,13,11]));await g.renderMatteFrames([...m,...g.maskedCopies(m)],_.fps,d,e)}{const g=await pe(()=>import("./windowFrames-DhhJLIs-.js"),__vite__mapDeps([27,1,26,13,11,10]));g.hasMovingWindows(m)&&await g.renderWindowFrames(m,_.fps,d,e)}}}n.some(P=>P.mask||P.planar||P.sceneTrack)&&(n=await(await pe(async()=>{const{packMasks:P}=await import("./rotoMaskStore-pE1AIt3I.js");return{packMasks:P}},__vite__mapDeps([28,1,29,10,11]))).packMasks(n));const v=JSON.stringify({clips:n,...t,...await d.finish()}),E=await vr();r?.("render");const C=typeof CompressionStream=="function"&&v.length>256*1024,V=C?await new Response(new Blob([v]).stream().pipeThrough(new CompressionStream("gzip"))).blob():v;a.posted=performance.now();const M=!!o&&t.mode===void 0,k=async P=>fetch(P,{method:"POST",signal:e,headers:{"Content-Type":"application/json","X-Clipoox-Frames-Ms":String(Math.round(a.posted-a.start)),...t.mode===void 0&&Je.length?{"X-Clipoox-Gpu-Skip":Vw(Je)}:{},...M?{Accept:`${Ha}, video/mp4;q=0.9, */*;q=0.5`}:{},...C?{"Content-Encoding":"gzip"}:{},...await kt()},body:V}),q=n.reduce((P,_)=>Math.max(P,_.start+_.duration),0),z=performance.now();let B=!1;const Y=o?setInterval(()=>{B||o(Ut*Su((performance.now()-z)/1e3,10+q*.8))},500):null,he=P=>{B=!0,o?.(P)};try{let P;for(let _=0;;_++){try{P=await k(`${E}/api/media/timeline`)}catch(m){if(!E||e?.aborted)throw m;P=await k("/api/media/timeline")}if(P.status!==429||_>=bu.length)break;r?.("queue"),await xo(bu[_],e),r?.("render")}if(P.ok&&t.mode===void 0&&(ys=Lh(P)),P.ok&&M&&(P.headers.get("Content-Type")||"").startsWith(Ha))return await Nw(P,r,he,s,a);if(r?.("download"),!P.ok){const _=await P.json().catch(()=>({}));{const m=xh(_);if(m)throw m}throw _.clip?new Error(De("Không xuất được: clip “{0}” (giây {1}) có dữ liệu lỗi — {2}. Hãy sửa hoặc xoá clip đó rồi xuất lại.",[_.clip.label||"?",Number(_.clip.start||0).toFixed(1),_.reason||_.error||""])):new Error(_.code==="render_unavailable"?De("Máy render đang bận hoặc vừa khởi động lại, bản xuất này quá nặng để chạy dự phòng. Hãy xuất lại sau khoảng 1 phút."):Uo(_.error)||`Export failed (${P.status})`)}return s?.(Mh(P)),o?(he(Ut),await Dw(P,_=>he(Ut+(1-Ut)*_))):P.blob()}finally{Y&&clearInterval(Y)}}const xw=n=>j(`/api/motion-agent/price${n?`?chars=${n.chars}&duration=${n.duration}&kind=${n.kind}`:""}`).then(e=>b(e)),Uw=n=>O("/api/motion-agent",n).then(e=>b(e)).then(e=>{if(e.error)throw Object.assign(new Error(e.error),{status:e.status});return e}),Fw=()=>j("/api/rig-agent/price").then(n=>b(n)),jw=n=>O("/api/rig-agent",n).then(e=>b(e)),Bw=()=>{const n=navigator.userAgent,e=/(Edg|OPR|Firefox|Chrome|Version)\/(\d+)/.exec(n),t=e?(e[1]==="Edg"?"Edge":e[1]==="OPR"?"Opera":e[1]==="Version"?"Safari":e[1])+" "+e[2]:"other";return/Windows/.test(n)?`${t} Windows`:/Mac OS X/.test(n)?`${t} macOS`:/Android/.test(n)?`${t} Android`:/iPhone|iPad/.test(n)?`${t} iOS`:`${t} other`};function $w(n,e,t={}){try{const r=navigator;O("/api/client-log",{kind:n,message:String(e||"").slice(0,300),detail:{browser:Bw(),cores:r.hardwareConcurrency,memory:r.deviceMemory,...t}}).catch(()=>{})}catch{}}const hI=Object.freeze(Object.defineProperty({__proto__:null,acceptProduction:TT,addUserFont:LT,approveBlenderDevice:kE,archiveCanvas:UE,askAgent:IT,askShotAgent:KT,attachDirectorReference:sT,brollPrompt:pw,brollPromptPrice:fw,cancelRemoteMission:LE,canvasInbox:YE,captionKeywords:Ew,captionKeywordsPrice:vw,captionTranslate:ww,captionTranslatePrice:Tw,clearDirector:wT,colorAgent:dw,colorAgentPrice:hw,consumeCanvasInbox:ZE,copyTimelineDoc:XE,createCanvas:IE,createLibraryModel:CT,createRemoteMission:DE,createSkill:BE,createVcamSession:ME,deleteBrand:FT,deleteCanvas:PE,deleteLibraryAsset:cT,deleteLut:$T,deleteSkill:qE,deleteTempUploads:yE,deleteUserFont:xT,describeFootage:dT,describePrice:mT,duplicateCanvas:FE,estimate:oE,estimateShotAgent:GT,exportReviewOf:Mh,exportTimeline:Lw,extractFrame:dE,fetchHealth:sE,fetchLut:qT,freeTranscript:fT,friendlyExportError:Uo,geoSearch:yw,getAssetLibraryItem:DT,getCanvas:AE,getCanvasShotRev:RE,getCanvasTimelineRev:SE,getDirector:nT,getPersonMatte:ow,getProduction:_T,getRemoteMission:VE,getRotoMask:cw,getSeries:HE,getSet:GE,getShotScene:lw,getTimelineDoc:QE,getTimelineDocRev:CE,get lastExportQuota(){return ys},get lastExportStored(){return vs},get lastExportTimes(){return Us},libraryUsage:oT,listAgentModels:AT,listAssetLibrary:kT,listAssetLibraryCategories:OT,listAssets:eT,listBlenderDevices:OE,listBrands:VT,listCanvases:xE,listDirectorReferences:rT,listGenerators:iE,listJobs:uE,listLibrary:iT,listModelCategories:RT,listModelLibrary:bT,listMyLuts:BT,listRemoteMissions:NE,listSeries:zE,listSkills:jE,listTempUploads:gE,listTextTemplates:NT,listTransitions:zT,listUserFonts:MT,locateObject:lT,mapBlenderScript:gw,mapHd:mw,me:rE,mediaPeaks:Iw,mediaProxy:Pw,mocapRegionStatus:nE,modelReadUrl:EE,motionAgent:Uw,motionAgentPrice:xw,motionUsage:hT,multicamSync:gT,pinToLibrary:aT,pluginAssetUrls:TE,pollJob:cE,prewarmCount:Vh,processAudio:bw,productionAction:vT,publishLibraryModel:PT,putSigned:vE,quoteProduction:yT,reportClient:$w,requestTempUpload:mE,requestUpload:Dh,resolveMapPlaces:_w,rigAgent:jw,rigAgentPrice:Fw,runGenerator:aE,saveBrand:UT,saveCanvas:bE,saveLut:jT,saveModelThumbnail:ST,savePersonMatte:iw,saveProjectContext:tT,saveRotoMask:aw,saveSeries:WE,saveSet:KE,saveShotScene:uw,saveTimelineDoc:JE,sendDirector:ET,shareModelAsset:HT,shotAgentInfo:WT,shotInbetween:Ow,shotInbetweenInfo:kw,shotLivePoll:ZT,shotLiveResult:rw,shotMissionCancel:XT,shotMissionQuote:JT,shotMissionTurn:QT,shotRemotePoll:YT,shotRemoteReport:sw,signFrameChunks:Rw,signOutput:wE,signTempUpload:_E,spliceRegionsMedia:hE,stabilizeClip:Aw,timelineAgent:uT,timelineAgentPrice:pT,timelineLivePoll:ew,timelineLiveProgress:tw,timelineLiveResult:nw,trimMedia:lE,updateSkill:$E,uploadFile:pE},Symbol.toStringTag,{value:"Module"}));export{_E as $,UT as A,jE as B,$E as C,BE as D,qE as E,_T as F,vT as G,yT as H,TT as I,rT as J,sT as K,AT as L,ET as M,nT as N,wT as O,tT as P,uE as Q,Uw as R,xw as S,HT as T,iT as U,oT as V,xd as W,cT as X,bT as Y,eT as Z,DT as _,cE as a,ME as a$,mE as a0,vE as a1,gE as a2,yE as a3,BT as a4,hT as a5,Tw as a6,ww as a7,vw as a8,Ew as a9,Bd as aA,Zw as aB,ew as aC,vs as aD,nw as aE,tw as aF,CE as aG,SE as aH,kd as aI,Jw as aJ,Qw as aK,Lw as aL,Us as aM,ys as aN,Aw as aO,bw as aP,Xw as aQ,wi as aR,aI as aS,iI as aT,oI as aU,kE as aV,OE as aW,NE as aX,VE as aY,DE as aZ,LE as a_,fT as aa,nI as ab,eI as ac,tI as ad,NT as ae,yw as af,mw as ag,gw as ah,kT as ai,Su as aj,gT as ak,$w as al,Gw as am,Ww as an,Kw as ao,EE as ap,zT as aq,Pw as ar,$T as as,hw as at,dw as au,fw as av,pw as aw,pT as ax,uT as ay,Yw as az,hE as b,FE as b0,UE as b1,ln as b2,$t as b3,vt as b4,ke as b5,xe as b6,to as b7,Yd as b8,Fu as b9,KT as bA,ZT as bB,rw as bC,HE as bD,zE as bE,WE as bF,GE as bG,nE as bH,qT as bI,jT as bJ,TE as bK,aw as bL,cw as bM,_w as bN,iw as bO,Od as bP,MT as bQ,xT as bR,LT as bS,ow as bT,lT as bU,hI as bV,_n as ba,Vu as bb,Mu as bc,st as bd,yp as be,sI as bf,uI as bg,lI as bh,iE as bi,uw as bj,lw as bk,RT as bl,ST as bm,CT as bn,PT as bo,RE as bp,XT as bq,QT as br,YT as bs,sw as bt,JT as bu,KE as bv,Fw as bw,jw as bx,GT as by,WT as bz,dT as c,mT as d,oE as e,JE as f,QE as g,XE as h,AE as i,IE as j,bE as k,YE as l,ZE as m,dE as n,Ud as o,aT as p,xE as q,aE as r,wE as s,PE as t,pE as u,cI as v,tE as w,lE as x,VT as y,FT as z};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{trackPose as M}from"./poseTracker-CzEKvJph.js";import{cJ as S,cK as v,cL as K}from"./timelineOps-DSSaDsU2.js";import{b_ as T,cw as q}from"./titleFrameBudget-DsM0V482.js";import{u as x}from"./store-CpqHUcA2.js";import{t as l}from"./i18n-C9zFX25m.js";import"./personHq-Ca351o06.js";import"./matteQuality-9X-jgJrH.js";import"./api-Dnl2uaKO.js";import"./index-CKtv7gGE.js";import"./rigTrack-DMyqb0pb.js";import"./sceneTrack-DlAH5s74.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./clientJobs-CuuUyhEy.js";async function _(s,f){const e=f.params??{},a=x.getState(),r=a.clips.find(t=>t.id===e.source);if(!r||r.kind!=="video")throw Error(l("Không tìm thấy clip video để bám dáng người"));const g=document.querySelector(`video[data-clip-media="${r.id}"]`)?.currentSrc||r.url,p=e.from??0,y=e.duration??s.duration,{frames:c,aspect:k}=await M({clip:r,url:g,from:p,duration:y,fps:S.fps,person:e.person??1});if(!c.some(t=>t.lm))throw Error(l("Không thấy người trong đoạn này để gắn aura"));const{width:u,height:d}=T(a.timelineFormat),b=Math.round(k*1e3),w=1e3,A=v(c.map(t=>({t:t.t,lm:t.lm})),([t,n])=>[t,n]).map(t=>{const n=p+t[0],m=[t[0]];for(let i=1;i<t.length;i+=2){if(t[i]<0){m.push(-1,-1);continue}const h=q(r,t[i],t[i+1],n,u,d,b,w);m.push(Math.round(h.px/u*1e3)/1e3,Math.round(h.py/d*1e3)/1e3)}return m}),o=s.motion?.params??{};return{motion:K(A,{look:o.look,color:o.color,hot:o.hot,size:o.size,intensity:o.intensity,wind:[Number(o.windX)||0,Number(o.windY)||0],speed:o.speed,stretch:o.stretch,taper:o.taper})}}export{_ as runAuraTrack};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-
|
|
2
|
-
import{_ as R}from"./titleFrameBudget-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-8XzEAnAJ.js","assets/index-CKtv7gGE.js","assets/i18n-C9zFX25m.js","assets/api-Dnl2uaKO.js","assets/titleFrameBudget-DsM0V482.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-CpqHUcA2.js","assets/rotoMaskStore-pE1AIt3I.js","assets/sceneTrack-DlAH5s74.js","assets/timelineOps-DSSaDsU2.js","assets/cameraTracker-DHdF8Zqx.js","assets/textAnimators-B9vO_hbP.js","assets/timelineComp-i-zdaoB2.js","assets/rigTrack-DMyqb0pb.js","assets/clientJobs-CuuUyhEy.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as R}from"./titleFrameBudget-DsM0V482.js";import{fg as U,bU as q,de as x,fD as B,f9 as N,c7 as z,bX as F,bW as G,eh as H}from"./remote-8XzEAnAJ.js";import{c as V}from"./cameraPresets-Cfn7qhXK.js";import"./index-CKtv7gGE.js";import"./i18n-C9zFX25m.js";import"./api-Dnl2uaKO.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-CpqHUcA2.js";import"./rotoMaskStore-pE1AIt3I.js";import"./sceneTrack-DlAH5s74.js";import"./timelineOps-DSSaDsU2.js";import"./cameraTracker-DHdF8Zqx.js";import"./textAnimators-B9vO_hbP.js";import"./timelineComp-i-zdaoB2.js";import"./rigTrack-DMyqb0pb.js";import"./clientJobs-CuuUyhEy.js";const W=()=>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 X(i,c){const e=x(i),j=e.duration/c,f=n=>n?.map(u=>({...u,time:Math.min(1,u.time*j)})),m={...e,duration:c,cameraKeys:f(e.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(e.objectKeys||{}).map(([n,u])=>[n,f(u)||[]])),...e.flight?{flight:Object.fromEntries(Object.entries(e.flight).map(([n,u])=>[n,f(u)||[]]))}:{},...e.focus?.keys?{focus:{...e.focus,keys:f(e.focus.keys)}}:{}};return{...i,shots:i.shots.map(n=>n.id===e.id?m:n)}}async function ht(i,c){let e;try{e=U(c.getStage(),String(i.name??""))}catch(t){return{ok:!1,error:t.message}}if(!q(e))return{ok:!1,error:`'${e.name}' is not a person`};const j=String(i.realm??"ket-dan"),f=P[j];if(!f)return{ok:!1,error:`unknown realm; use one of ${Object.keys(P).join(", ")}`};const m=i.outcome==="fail",n=i.tribulation!==!1,u=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??f.color),M=y+2.6,g=M+3.2,O=g+1.2,$=n?1.6+u*1.05:0,C=g+2.4+$,h=C,p=h+1.6,_=p+2.2,w=m?h+2.6:_+2.6;let l=c.getStage();w+.5>x(l).duration&&(l=X(l,Math.min(300,Math.ceil((w+.6)*10)/10)));const S=[],E=[],k=(t,r,o=!1)=>{const a=G(t);if(!a){S.push(`${t} missing`);return}const d=H(l,e.id,a,{start:r/x(l).duration,newId:W,loop:o});d.ok?(l=d.stage,E.push({motion:t,at_s:s(r)})):S.push(`${t}: ${d.error}`)};k("xx-seal-seated",y),k("xx-bt-gather",M,!0),k("xx-bt-strain",g,!0);const T=O,K=n?B($+1.2,u).map(t=>T+t):[];for(const t of K)k("xx-bt-endure",Math.max(g,t-.12));if(m)k("xx-bt-backlash",h);else{const t=x(l),r=t.duration;let o=N(t.flight?.[e.id],{time:h/r,on:!0,height:v});o=N(o,{time:(_+1.4)/r,on:!1}),l={...l,shots:l.shots.map(a=>a.id===t.id?{...a,flight:{...a.flight,[e.id]:o}}:a)},k("xx-bt-lotus-air",h,!0),k("xx-bt-roar",p),k("xx-bt-settle",_)}c.setStage(()=>l);const{runTool:L}=await R(async()=>{const{runTool:t}=await import("./remote-8XzEAnAJ.js").then(r=>r.fO);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),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)}):S.push(`${t}: ${String(d.error)}`)};if(await b("linh-khi-quy-nguyen",y+.6,g-y+1),await b("kinh-mach-kim",M+.8,4),await b("canh-gioi-ket-dan",g-.4,2.4+$+.8,{params:{tiers:f.tiers}}),n&&await b(m?"kiep-van-huyet":"kiep-van-thien-loi",T,$+1.2,{params:{strikes:u},color:m?"#ff3040":"#9fd8ff"}),m)await b("huyet-vu",h+.5,1.6);else if(f.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=x(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 D=[];if(i.camera!==!1){const t=[["orbit-180",y,g],["wide-track",g,O+.4],["low-hero",O+.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=V(c.getStage(),{preset:r,subject:e.id,start:o,end:a});d.ok&&(c.setStage(()=>d.stage),D.push(`${r} ${s(o)}–${s(a)} s`))}}return{ok:!0,name:e.name,realm:f.name,outcome:m?"fail":"success",start_s:s(y),gather_s:s(M),tribulation_s:n?s(T):null,strikes_s:K.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:E,effects:I,...D.length?{camera:D}:{},...S.length?{notes:S}:{}}}export{P as REALMS,ht as stageBreakthrough};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bU as D,de as K,f4 as V,bY as L,ee as R,f5 as W}from"./remote-DJd9xWjn.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"}]),U=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}]}]),_=n=>U.find(t=>t.id===n),H=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+N(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 N(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]=H(n??0);return a+(o-a)*F(t)},Q=(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,Q(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"?_(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{U as C,nn as a,Z as b,tn as c,P as p};
|
|
1
|
+
import{bU as D,de as K,f4 as V,bY as L,ee as R,f5 as W}from"./remote-8XzEAnAJ.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"}]),U=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}]}]),_=n=>U.find(t=>t.id===n),H=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+N(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 N(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]=H(n??0);return a+(o-a)*F(t)},Q=(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,Q(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"?_(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{U as C,nn as a,Z as b,tn as c,P as p};
|