clipoox-render 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/server-text/titleRaster.js +1394 -0
  2. package/package.json +5 -3
  3. package/scripts/render-local.mjs +1514 -1379
  4. package/shared/transitionStarterPack.json +261 -0
  5. package/web/assets/{FxEmbed-BymBArNa.js → FxEmbed-D7k1ThAF.js} +1 -1
  6. package/web/assets/{GLTFLoader-Dy6SrZg8.js → GLTFLoader-BHWu1lKg.js} +1 -1
  7. package/web/assets/{MotionEmbed-PmXWSWe5.js → MotionEmbed-DFni5IAh.js} +1 -1
  8. package/web/assets/PluginStore-BrupM_8E.js +3 -0
  9. package/web/assets/{ShotComposer-Dprx-Yi7.js → ShotComposer-BLztjSKy.js} +4 -4
  10. package/web/assets/TemplateEmbed-BbAimhLj.js +2 -0
  11. package/web/assets/TimelinePlugins-BI1bE9pX.js +5 -0
  12. package/web/assets/TimelinePlugins-DYarX9RK.css +1 -0
  13. package/web/assets/TimelineShotFx-CQN3WIfN.js +2 -0
  14. package/web/assets/TransitionEmbed-CmoIrHVr.js +1 -0
  15. package/web/assets/{Whiteboard-DybaKCdo.js → Whiteboard-DMk0unYK.js} +3 -3
  16. package/web/assets/aerial-DT_gUtSh.js +2 -0
  17. package/web/assets/{agentTools-CxZqRLeR.js → agentTools-qOww5RUs.js} +2 -2
  18. package/web/assets/analyzerRun-B2FLUp4G.js +1 -0
  19. package/web/assets/{analyzerSandbox-DO5ZTv5q.js → analyzerSandbox-CJVsEhrg.js} +2 -2
  20. package/web/assets/{api-BsKbf3l3.js → api-QBI5GJTZ.js} +148 -148
  21. package/web/assets/auraTrack-CEs_Q9EP.js +1 -0
  22. package/web/assets/{breakthrough-Dv1bndQb.js → breakthrough-DvkxvNK9.js} +2 -2
  23. package/web/assets/{cameraPresets-B234aNzE.js → cameraPresets-4pFeF2YG.js} +1 -1
  24. package/web/assets/{captionLayout-CNgb471H.js → captionLayout-C67EMVI1.js} +1 -1
  25. package/web/assets/{clientExport-NtJmxOYP.js → clientExport-C4VgAJtO.js} +1 -1
  26. package/web/assets/{depthEstimate-wVYSJtW8.js → depthEstimate-mnXDZMW-.js} +1 -1
  27. package/web/assets/{directorTools-BqFcShgT.js → directorTools-BOHZjcww.js} +1 -1
  28. package/web/assets/{distortFrames-D3TQNcJA.js → distortFrames-Csuj2jHE.js} +2 -2
  29. package/web/assets/{distortGL-BklPDXPq.js → distortGL-BaXfN0IK.js} +2 -2
  30. package/web/assets/{editTools-BQlG5WB_.js → editTools-m0VGPmfF.js} +1 -1
  31. package/web/assets/{exportEncode-CaKEPgsy.js → exportEncode-D9OT7_5k.js} +1 -1
  32. package/web/assets/{exportGlb-DstxwzH5.js → exportGlb-CLfTnbMG.js} +1 -1
  33. package/web/assets/faceTracker-W0iZSiMe.js +1 -0
  34. package/web/assets/fightDirector-CECPf2iH.js +1 -0
  35. package/web/assets/{fightDrama-G7bXfpQu.js → fightDrama-CqNoa5XI.js} +2 -2
  36. package/web/assets/{frameSink-Dj71jCRb.js → frameSink-BGRj7wqY.js} +3 -3
  37. package/web/assets/{gpuCompose-DIxBHlTa.js → gpuCompose-CIEoLFem.js} +1 -1
  38. package/web/assets/gpuExport-uyOAyrhm.js +190 -0
  39. package/web/assets/handMatte-mHxZwLZD.js +1 -0
  40. package/web/assets/handTracker-dTVeSUzt.js +2 -0
  41. package/web/assets/{index-CZn97Ygs.js → index-D7M5t2re.js} +1 -1
  42. package/web/assets/layer-worker-Cp0pjurp.js +5 -0
  43. package/web/assets/library-Dsz_MLyd.js +1 -0
  44. package/web/assets/{lottieLayer-CfUPParC.js → lottieLayer-CDCGeJyv.js} +5 -5
  45. package/web/assets/{lottie_light_canvas-7iv3btPX.js → lottie_light_canvas-BblLU4nU.js} +1 -1
  46. package/web/assets/main-BQ8IY0WV.css +1 -0
  47. package/web/assets/{main-M1vRa-gd.js → main-CVRIuDW2.js} +76 -76
  48. package/web/assets/{mapBake-lPNhNZgv.js → mapBake-CNMOKXA7.js} +1 -1
  49. package/web/assets/maskTrack-Dtv6Jr06.js +1 -0
  50. package/web/assets/matteFixRun-BLDH2AjH.js +1 -0
  51. package/web/assets/{objectLocate-BDqfSo9J.js → objectLocate-Cy3IFBSF.js} +1 -1
  52. package/web/assets/{objectTrack.worker-ENzKeSiV.js → objectTrack.worker-BlZkgpOX.js} +483 -352
  53. package/web/assets/pendingMatte-C2AWApuv.js +2 -0
  54. package/web/assets/personAi-DPUnoymj.js +2 -0
  55. package/web/assets/plateCamera-C96L5GKm.js +1 -0
  56. package/web/assets/{plateCameraMatch-D41LQrsm.js → plateCameraMatch-Chk-ZjDi.js} +2 -2
  57. package/web/assets/{plateFollow-CNfi4xuP.js → plateFollow-B9_QTgvo.js} +2 -2
  58. package/web/assets/plateMatte-BiqyI_8x.js +2 -0
  59. package/web/assets/{pluginAutomation-BtQ_w2TB.js → pluginAutomation-5DYldFrb.js} +1 -1
  60. package/web/assets/poseTracker-PuI8vWpR.js +1 -0
  61. package/web/assets/{productTools-r2RgILaA.js → productTools-B1h5cgyt.js} +2 -2
  62. package/web/assets/remote-BJdzzFZg.js +1241 -0
  63. package/web/assets/{rigTrack-Bx9QHlFv.js → rigTrack-CUt4O67J.js} +1 -1
  64. package/web/assets/{rotoMaskStore-pxpRt5Cj.js → rotoMaskStore-DIi45swK.js} +1 -1
  65. package/web/assets/{rotoMatte-DyXlW4jK.js → rotoMatte-013RKqHu.js} +1 -1
  66. package/web/assets/{rotoscope-GORCSVBr.js → rotoscope-d_TUxa-J.js} +1 -1
  67. package/web/assets/{sceneTrack.worker-CEvCN5OB.js → sceneTrack.worker-CT4uoTKn.js} +475 -344
  68. package/web/assets/{shot-worker-B8JWkmBz.js → shot-worker-B1iZT6F5.js} +1 -1
  69. package/web/assets/{shotFxAgent-CzHfe75S.js → shotFxAgent-BDfe73TP.js} +2 -2
  70. package/web/assets/{skin-BkaT2QuX.js → skin-GDY3QPkV.js} +1 -1
  71. package/web/assets/{spark.module-BRT8yMS4.js → spark.module-DdwuJ_hb.js} +1 -1
  72. package/web/assets/{spellDuel-BUy289OT.js → spellDuel-DjNN00bv.js} +2 -2
  73. package/web/assets/{store-BSSbvpzr.js → store-2zneEhhu.js} +1 -1
  74. package/web/assets/{surfaceLight-CMaBhZ_d.js → surfaceLight-B_SYg_f8.js} +1 -1
  75. package/web/assets/surfacePin-zDPmq-hH.js +2 -0
  76. package/web/assets/{textAnimators-Cihw35O8.js → textAnimators-Bdt5LWXk.js} +1 -1
  77. package/web/assets/{thumb-Cs636sYt.js → thumb-byAKvhQP.js} +1 -1
  78. package/web/assets/timeline3d-YIIk_Kn2.js +2 -0
  79. package/web/assets/timeline3dExport-CEH1RjNf.js +1 -0
  80. package/web/assets/{timelineComp-CRRzLazc.js → timelineComp-B73i_8vD.js} +1 -1
  81. package/web/assets/{timelineProps-tN2YsMYN.js → timelineProps-B2pnudeT.js} +1 -1
  82. package/web/assets/{timelineText-CkoUgWcY.js → timelineText-BcL4Pw3C.js} +1 -1
  83. package/web/assets/{titleArt-CcTdJuOC.js → titleArt-hb_T45WJ.js} +5 -5
  84. package/web/assets/{titleFrameBudget-3MFHWIT6.js → titleFrameBudget-Cml-MO53.js} +970 -839
  85. package/web/assets/titleFrames-Dw0PEBdV.js +1 -0
  86. package/web/assets/{tool-BhIsq238.js → tool-Bt9bclIf.js} +1 -1
  87. package/web/assets/{tools-DMUnabc_.js → tools-BXeJbgZJ.js} +1 -1
  88. package/web/assets/{toonTools-CICrV3QB.js → toonTools-u7Y9fdEZ.js} +2 -2
  89. package/web/assets/trackAnchor-9MnVHe4S.js +1 -0
  90. package/web/assets/{userFonts-BZ4QL-zq.js → userFonts-BHduCNtc.js} +1 -1
  91. package/web/assets/{vfxAlpha-D3Dk1tfF.js → vfxAlpha-DpV4rbI-.js} +1 -1
  92. package/web/assets/vfxBackground-Ddviync5.js +2 -0
  93. package/web/assets/{videoExport-l5MGvMn_.js → videoExport-z5WjM0hw.js} +1 -1
  94. package/web/assets/{views-BdWnG2xK.js → views-CsrYzCSR.js} +1 -1
  95. package/web/assets/weaponDuel-CLLgv5A4.js +1 -0
  96. package/web/assets/{windowFrames-CoIyWqxr.js → windowFrames-BQEWQkEs.js} +1 -1
  97. package/web/layer-worker.html +3 -3
  98. package/web/assets/PluginStore-BVsm6n6N.js +0 -3
  99. package/web/assets/TemplateEmbed-CrZXoUk_.js +0 -2
  100. package/web/assets/TimelinePlugins-B1KGtbmb.js +0 -5
  101. package/web/assets/TimelinePlugins-B5WmAawO.css +0 -1
  102. package/web/assets/TimelineShotFx-DoLx312Y.js +0 -2
  103. package/web/assets/TransitionEmbed-C5SUosv2.js +0 -1
  104. package/web/assets/aerial-DSt_mJNA.js +0 -2
  105. package/web/assets/analyzerRun-DCJwb_-Z.js +0 -1
  106. package/web/assets/auraTrack-QR0WqBHp.js +0 -1
  107. package/web/assets/desktop-BWhFnYwd.js +0 -1
  108. package/web/assets/faceTracker-DWxxieVC.js +0 -1
  109. package/web/assets/fightDirector-OMlPZgjv.js +0 -1
  110. package/web/assets/gpuExport-CPSw_dmq.js +0 -189
  111. package/web/assets/handMatte-DHsHHz4m.js +0 -1
  112. package/web/assets/handTracker-D_O-C4Dw.js +0 -2
  113. package/web/assets/layer-worker-Bar7WgOA.js +0 -5
  114. package/web/assets/library-BtBrCaFk.js +0 -1
  115. package/web/assets/main-BPmr0TOL.css +0 -1
  116. package/web/assets/maskTrack-D2jUh7aw.js +0 -1
  117. package/web/assets/matteFixRun-B7tWV9Y1.js +0 -1
  118. package/web/assets/pendingMatte-q35zVaiB.js +0 -2
  119. package/web/assets/personAi-ZjQVo-80.js +0 -2
  120. package/web/assets/plateCamera-A2E_WO_x.js +0 -1
  121. package/web/assets/plateMatte-BdIxGhw5.js +0 -2
  122. package/web/assets/poseTracker-DVX__OK7.js +0 -1
  123. package/web/assets/remote-sTZauTqM.js +0 -1220
  124. package/web/assets/surfacePin-DM9b9ubh.js +0 -2
  125. package/web/assets/timeline3d-BEuZZOxM.js +0 -2
  126. package/web/assets/timeline3dExport-CmSI_pjv.js +0 -1
  127. package/web/assets/titleFrames-w-iWje9N.js +0 -1
  128. package/web/assets/trackAnchor-D2bB5mZE.js +0 -1
  129. package/web/assets/vfxBackground-CHlCg8lb.js +0 -2
  130. package/web/assets/vfxTrack-CqiQDEYm.js +0 -1
  131. package/web/assets/weaponDuel-B2wTffPC.js +0 -1
@@ -0,0 +1,2 @@
1
+ import{j as f}from"./remote-BJdzzFZg.js";import{r as l}from"./api-QBI5GJTZ.js";import{p as E}from"./main-CVRIuDW2.js";import{m as b}from"./textAnimators-Bdt5LWXk.js";import{l as g,d as h}from"./titleArt-hb_T45WJ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./titleFrameBudget-Cml-MO53.js";import"./rotoMaskStore-DIi45swK.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";const j=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"],x=e=>({text:e.sample,fontSize:e.defaults.fontSize,color:e.defaults.color,accentColor:e.defaults.accentColor,placement:"center",align:e.defaults.align,fontFamily:e.defaults.fontFamily,styleId:"classic",design:e.design,animation:e.animation}),L=e=>e.split(`
2
+ `).map(a=>({word:Math.max(1,a.split(/\s+/).filter(Boolean).length),char:Math.max(1,a.replace(/\s/g,"").length)})),F=e=>{if(!e.animation)return 2;const a=b(e.animation,L(e.sample));return a+1.2+a/e.animation.outSpeed};function V(){const e=l.useRef(null),[a,y]=l.useState(null),[u,d]=l.useState("");return l.useEffect(()=>{const i=(t,r)=>t.source?.postMessage(r,{targetOrigin:t.origin}),p=async t=>{if(!j.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;let r;try{r=E(t.data.template)}catch(o){i(t,{type:"clipoox-template-error",id:"id"in t.data?t.data.id:null,error:o.message});return}if(t.data.type==="clipoox-template-play"){d(""),y(r);return}if(t.data.type==="clipoox-template-thumb"){const o=t.data.id,n=x(r),m=Object.assign(document.createElement("canvas"),{width:1280,height:720}),c=m.getContext("2d");if(!c)return;try{await g(n),h(c,n)}catch(w){i(t,{type:"clipoox-template-error",id:o,error:w.message});return}i(t,{type:"clipoox-template-thumb",id:o,png:m.toDataURL("image/png")})}},s=t=>void p(t);return window.addEventListener("message",s),window.parent?.postMessage({type:"clipoox-template-ready"},"*"),()=>window.removeEventListener("message",s)},[]),l.useEffect(()=>{if(!a)return;let i=0,p=!0;const s=x(a),t=F(a),r=performance.now();return g(s).then(()=>{const o=()=>{const n=e.current?.getContext("2d");if(!p||!n)return;const m=(performance.now()-r)/1e3%t;n.clearRect(0,0,1280,720);try{h(n,s,{time:m,duration:t})}catch(c){d(c.message);return}i=requestAnimationFrame(o)};o()},o=>d(o.message)),()=>{p=!1,cancelAnimationFrame(i)}},[a]),f.jsxs("div",{style:{margin:0,background:"repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/24px 24px",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:[f.jsx("canvas",{ref:e,width:1280,height:720,style:{width:"100%",maxHeight:"100vh",objectFit:"contain"},"aria-label":"Template preview"}),u&&f.jsx("p",{role:"alert",style:{position:"fixed",bottom:8,left:8,color:"#ff8080",font:"12px sans-serif"},children:u})]})}export{V as default,F as loopLength,x as titleOf};
@@ -0,0 +1,5 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PluginStore-BrupM_8E.js","assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js","assets/main-CVRIuDW2.js","assets/spark.module-DdwuJ_hb.js","assets/userFonts-BHduCNtc.js","assets/lottieLayer-CDCGeJyv.js","assets/timeline3d-YIIk_Kn2.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-D9OT7_5k.js","assets/captionLayout-C67EMVI1.js","assets/timelineText-BcL4Pw3C.js","assets/titleArt-hb_T45WJ.js","assets/rotoMatte-013RKqHu.js","assets/distortGL-BaXfN0IK.js","assets/motionBlur-uAm030t9.js","assets/main-BQ8IY0WV.css","assets/pluginAutomation-5DYldFrb.js"])))=>i.map(i=>d[i]);
2
+ import{_ as Ln,au as $e,f as Te}from"./titleFrameBudget-Cml-MO53.js";import{j as n,cr as Mn,am as gn,cI as Le,N as Ee}from"./remote-BJdzzFZg.js";import{u as wn,r as N,t as i,bX as Ae}from"./api-QBI5GJTZ.js";import{u as H}from"./store-2zneEhhu.js";import{G as Oe}from"./lottieLayer-CDCGeJyv.js";import{b as _,c as pn,s as Be,e as Ge,S as Ie,f as Ue,l as Qn,g as qe,L as Fe,P as Ke,i as De,r as ze,h as yn,j as Re,k as We,m as Yn,n as He,o as bn,q as Ve,t as Xe,v as ne,w as ee,x as ie,y as re,z as X,A as ce,B as En,C as An,D as se,E as Je,F as Ze,G as Qe,H as oe,I as Ye,J as On,K as ni,M as de,N as he,O as ei,Q as ii,R as si,T as ti,U as li}from"./main-CVRIuDW2.js";import{l as ai,a as ri,t as ci,r as oi,b as di,p as hi,c as ui}from"./pluginAutomation-5DYldFrb.js";function gi({review:s}){const l=wn(),o=s.manifest,h=o.sounds??[],[f,u]=N.useState(null),L=N.useRef(null),p=N.useRef(new Map);N.useEffect(()=>()=>{L.current?.pause();for(const k of p.current.values())URL.revokeObjectURL(k)},[]);const c=(k,x)=>{if(L.current?.pause(),f===k){u(null);return}let $=p.current.get(k);if(!$){const j=x.split(".").pop().toLowerCase();$=URL.createObjectURL(new Blob([s.read(x)],{type:Ie[j]})),p.current.set(k,$)}const r=new Audio($);L.current=r,r.volume=.8,u(k),r.onended=()=>u(j=>j===k?null:j),r.play().catch(()=>u(null))},g=s.facts.reduce((k,x)=>k+x.duration,0);return n.jsxs("div",{className:"tl-plugin-sfx-review",children:[n.jsxs("div",{className:"tl-plugin-card",children:[s.thumbnail?n.jsx("img",{alt:"",src:`data:${s.thumbnail.type};base64,${s.thumbnail.data}`}):n.jsx("span",{className:"tl-plugin-wave","aria-hidden":!0,children:Array.from({length:18},(k,x)=>n.jsx("i",{style:{height:`${20+Math.round(70*Math.abs(Math.sin(x*1.7)))}%`}},x))}),n.jsxs("div",{children:[n.jsx("strong",{children:_(o,l)}),n.jsxs("small",{children:[i("Gói âm thanh")," · v",o.version," · ",o.author.name]}),n.jsx("p",{children:pn(o,l)}),n.jsx("small",{className:"muted",children:i("{0} âm thanh · tổng {1} giây",[h.length,g.toFixed(1)])})]})]}),n.jsxs("ul",{className:"tl-plugin-checks",children:[n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),i("Đọc được {0} file âm thanh ({1})",[h.length,[...new Set(s.facts.map(k=>k.format))].join(", ")])]}),n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),i("Độ dài trong giới hạn (≤ 30 giây, âm nền / lặp ≤ 120 giây)")]}),n.jsxs("li",{className:"warn",children:[n.jsx("span",{"aria-hidden":!0,children:"!"}),i("Khi cài, máy chủ kiểm tra lại từng file và cân bằng âm lượng như thư viện SFX của Clipoox.")]})]}),n.jsx("ul",{className:"tl-sfx-list tl-plugin-sfx-list","aria-label":i("Âm thanh trong gói"),children:h.map((k,x)=>{const $=s.facts[x],r=Be(k,l);return n.jsxs("li",{className:`tl-sfx-item tl-sfx-plug${f===k.id?" on":""}`,children:[n.jsx("button",{className:"tl-sfx-play","aria-label":`${i("Nghe thử")} ${r}`,title:i("Nghe thử"),onClick:()=>c(k.id,k.file),children:f===k.id?"■":"▶"}),n.jsxs("span",{className:"tl-sfx-name",children:[n.jsxs("span",{className:"ell",title:k.tags.join(", "),children:[r,k.loop?n.jsx("i",{className:"tl-sfx-loop",title:i("Lặp được"),children:" ↻"}):null]}),n.jsxs("small",{className:"ell",children:[Ge(k.category,l)," · ",$?.format]})]}),n.jsxs("small",{children:[$?$.duration.toFixed(1):"–","s"]})]},k.id)})})]})}const Pn={bad_package:"File này không phải gói plug-in hợp lệ.",not_zip:"File này không phải gói .clipoox-plugin (phải là một file nén zip).",too_large:"Gói quá lớn (tối đa {0} MB).",path:"Gói chứa đường dẫn không an toàn: “{0}”. Hãy nén lại chỉ các file của plug-in.",extra_file:"Gói có file không được phép: “{0}”. Chỉ cần manifest.json, file chính (hoặc thư mục sounds/) và ảnh thumbnail.",too_many_files:"Gói có quá nhiều file (tối đa {0}).",no_manifest:"Gói thiếu file manifest.json.",manifest_json:"Không đọc được manifest.json (JSON chưa đúng).",manifest_field:"manifest.json: trường “{0}” {1}.",unknown_key:"manifest.json có trường lạ “{0}”.",forbidden_key:"Gói có khoá bị cấm “{0}”.",too_deep:"Dữ liệu trong {0} lồng quá sâu.",kind:"Loại plug-in “{0}” không được hỗ trợ (motion, lottie, recipe, analyzer, ai-template).",kind_later:"Loại plug-in “{0}” sẽ có ở bản sau.",min_app:"Plug-in này cần phiên bản Clipoox mới hơn (API {0}).",permissions:"Plug-in xin quyền “{0}” — loại plug-in này không được cấp quyền đó.",permission_needed:'Plug-in loại {0} phải khai báo quyền "permissions": [{1}] để khách thấy trước khi cài.',ai_template:"File mẫu AI (template.json) chưa đúng.",analyzer_result:"Plug-in phân tích trả về kết quả không hợp lệ.",analyzer_op:"Thao tác {0}: “{1}” — plug-in phân tích chỉ được đặt key / hiệu ứng / crop / rung cho chính clip đó.",use_ai_template:"“{0}” là mẫu AI: nó viết tài liệu, không đặt gì lên timeline — chạy ở tab Plug-in hoặc MCP run_ai_template.",not_ai_template:"“{0}” không phải plug-in mẫu AI.",store_paid_kind:"“{0}” là mẫu AI (tốn credit mỗi lần chạy) — Kho Plug-in chỉ nhận plug-in miễn phí khi chạy. Bỏ mục này khỏi gói rồi gửi lại; vẫn cài riêng từ file được.",no_transcript:"Clip này chưa có lời thoại — bấm Transcript cho clip trước.",max_credits:"Lần chạy này có thể tốn tới {0} credit — hãy xác nhận giá trước.",insufficient_credits:"Không đủ credit — nạp thêm để chạy mẫu AI.",ai_failed:"AI chưa viết được tài liệu — không trừ credit. Thử lại.",webhook_url:"Link webhook phải là link https:// đầy đủ.",webhook_https:"Chỉ nhận link https:// (cổng 443).",webhook_private:"Địa chỉ này là mạng nội bộ — dùng link webhook công khai mà Make, Zapier hoặc n8n đưa.",webhook_event:"Sự kiện webhook không hợp lệ.",webhook_limit:"Mỗi tài khoản tối đa 5 webhook.",webhook_missing:"Không tìm thấy webhook này (có thể đã xoá).",too_many_params:"Plug-in có tối đa {0} tham số.",param_type:"Tham số “{0}”: kiểu “{1}” chưa dùng được cho plug-in {2}.",param_value:"Giá trị của “{0}” không hợp lệ.",image_large:"Ảnh quá lớn (tối đa {0} MB).",no_entry:"Không thấy file “{0}” trong gói.",entry_large:"File “{0}” quá lớn.",encoding:"File trong gói phải là văn bản UTF-8.",code:"Code motion của plug-in không chạy được.",lottie:"File Lottie của plug-in không hợp lệ.",bind:"Tham số “{0}” không gắn được: không thấy “{1}” trong hoạt ảnh.",recipe_json:'recipe.json chưa đúng (cần dạng {"ops": [ … ]}).',recipe_ops:"Công thức có tối đa {0} bước.",recipe_op:"Bước {0}: thao tác “{1}” không dùng được trong plug-in.",paid_op:"Bước {0}: “{1}” là thao tác tốn credit — plug-in không được dùng.",recipe_field:"Bước {0}: trường “{1}” không được phép.",placeholder:"Bước {0}: {{{1}}} chưa được khai báo trong params.",needs_clip:"Chọn một clip trên timeline trước khi chạy.",needs_video:"Chọn một clip video trên timeline trước khi chạy plug-in phân tích.",thumbnail:"Ảnh thumbnail phải là PNG, WebP hoặc JPEG, tối đa 256 KB.",limit:"Tài khoản đã có đủ {0} plug-in. Gỡ bớt trước khi thêm.",rate:"Cài quá nhiều lần liên tiếp — thử lại sau vài phút.",not_found:"Không tìm thấy plug-in này (có thể đã gỡ).",nondeterministic:"Plug-in vẽ ra hai hình khác nhau cho cùng một thời điểm — video xuất sẽ không giống Monitor. Đừng lưu biến giữa các khung hình.",dryrun:"Chạy thử trên timeline mẫu: không bước nào áp dụng được.",not_owned:"Plug-in này cần mua trên clipoox.com trước khi cài.",refunded:"Đơn mua plug-in này đã hoàn tiền nên không cài mới được.",archived:"Plug-in này không còn trong kho.",sfx_package:"Gói âm thanh được cài từ file .clipoox-plugin, không phải dạng bundle.",not_sfx:"File này không phải gói âm thanh.",too_many_sounds:"Gói âm thanh có tối đa {0} âm thanh.",sound_format:"“{0}” không phải file âm thanh đúng định dạng (wav, mp3, ogg, flac, m4a — đuôi file phải khớp nội dung).",sound_header:"Không đọc được phần đầu file “{0}”.",sound_video:"“{0}” có hình (video) — gói âm thanh chỉ nhận file tiếng.",sound_long:"“{0}” dài quá: tối đa {1} giây.",sound_short:"“{0}” ngắn quá (dưới 0,05 giây).",sound_silent:"“{0}” im lặng hoàn toàn.",sound_rate:"“{0}”: tần số lấy mẫu không hợp lệ (8–192 kHz).",sound_channels:"“{0}”: quá nhiều kênh (tối đa 8).",sound_decode:"Không giải mã được “{0}”.",sound_large:"“{0}” quá lớn (tối đa {1} MB mỗi file).",sound_unlisted:"“{0}” nằm trong thư mục sounds/ nhưng chưa khai báo trong manifest.json.",not_zip_sfx:"Gói âm thanh phải là file nén zip.",sha256:"File tải lên bị lỗi giữa đường (mã kiểm tra không khớp) — thử lại.",busy:"Máy chủ đang xử lý gói âm thanh khác — thử lại sau một phút.",asset:"Tài nguyên “{0}”: {1}.",use_asset:"Mục “{0}” dùng tài nguyên “{1}” mà gói không có (hoặc sai loại).",use_missing:"Không tìm thấy “{0}” trong plug-in đã cài.",pass_ended:"Vé 30 ngày của “{0}” đã hết hạn — gia hạn trên clipoox.com để dùng tiếp. Lớp đã thêm vào video vẫn giữ nguyên.",use_assets:"“{0}” cần tài nguyên 3D nhưng chỗ này chưa nạp được — dùng trong tab Plug-in.",pack_only:"Mục loại “{0}” chỉ có trong gói có thư mục assets/.",item_budget:"Mục “{0}”: tài nguyên tổng {1} MB — tối đa {2} MB mỗi mục.",item_pixels:"Mục “{0}”: ảnh giải mã ra {1} MB — tối đa {2} MB mỗi mục.",model_anim:"Mục “{0}”: GLB không có animation “{1}”.",param_link:"Mục “{0}”: tham số “{1}” gắn với điều khiển chung “{2}” không có hoặc khác kiểu.",item_category:"Mục “{0}”: nhóm “{1}” chưa khai báo trong categories."},pi={too_large:"quá lớn (tối đa {0} MB)",not_image:"không phải ảnh PNG / WebP / JPEG đọc được",magic:"đuôi file không khớp nội dung (thật ra là {0})",image_size:"ảnh {0} lớn quá (tối đa {1})",glb_header:"không phải file GLB hợp lệ",glb_version:"GLB phiên bản {0} — cần glTF 2.0",glb_length:"file GLB bị cắt dở",glb_json_large:"phần JSON của GLB quá lớn",glb_json:"không đọc được phần JSON của GLB",glb_uri:"trỏ ra file hoặc link ngoài “{0}” — hãy nhúng mọi thứ vào GLB",glb_compressed:"dùng nén {0} chưa hỗ trợ — hãy xuất GLB không nén",glb_extension:"cần extension {0} chưa hỗ trợ",glb_buffers:"cấu trúc buffer không hợp lệ (chỉ một buffer BIN nhúng)",glb_nodes:"cây node quá lớn hoặc quá sâu (tối đa {0})",glb_range:"dữ liệu “{0}” nằm ngoài file",glb_sparse:"dùng accessor sparse chưa hỗ trợ",glb_triangles:"{0} tam giác — quá {1}",glb_vertices:"{0} đỉnh — quá {1}",glb_images:"{0} ảnh nhúng — tối đa {1}",glb_image:"ảnh nhúng số {0} không phải PNG / JPEG / WebP hợp lệ",lut:"LUT .cube không đọc được {0}",lut_size:"LUT {0}³ lớn quá (tối đa {1}³)",seq_frames:"{0} khung — tối đa {1}",seq_size:"các khung không cùng kích thước",seq_format:"chuỗi ảnh hỏng"},mi={type:"sai kiểu dữ liệu",required:"đang thiếu",length:"dài quá hoặc rỗng",format:"sai định dạng",range:"ngoài khoảng cho phép",duplicate:"bị trùng"};function V(s){const l=s||{},o=l.code&&Pn[l.code]?l.code:null;if(!o)return{text:i("Không cài được plug-in: {0}",[String(l.message||"").slice(0,200)]),detail:""};const h=[...l.args||[]];if(o==="manifest_field"&&h[1]&&(h[1]=i(mi[h[1]]??h[1])),o==="asset"&&h[1]){const u=pi[h[1]];return{text:i(Pn.asset,[h[0],u?i(u,h.slice(2)):h[1]]),detail:l.message&&l.message!==o?String(l.message).slice(0,300):""}}const f=l.message&&l.message!==o&&!/^manifest\./.test(l.message)?String(l.message).slice(0,300):"";return{text:i(Pn[o],h),detail:f}}const ki=s=>(s==="en"?Ln(()=>import("./plugin-guide.en-CGYh_9Su.js"),[]):Ln(()=>import("./plugin-guide.vi-DMphSELb.js"),[])).then(l=>l.default);function an(s,l){const o=[],h=/(`[^`]+`|\*\*[^*]+\*\*|\*[^*\s][^*]*\*|\[[^\]]+\]\((https:\/\/[^)\s]+|[a-z0-9./#-]+)\))/g;let f=0,u=0;for(const L of s.matchAll(h)){L.index>f&&o.push(s.slice(f,L.index));const p=L[0],c=`${l}-${u++}`;if(p.startsWith("`"))o.push(n.jsx("code",{children:p.slice(1,-1)},c));else if(p.startsWith("**"))o.push(n.jsx("strong",{children:p.slice(2,-2)},c));else if(p.startsWith("*"))o.push(n.jsx("em",{children:p.slice(1,-1)},c));else{const g=p.slice(1,p.indexOf("]")),k=L[2];o.push(k.startsWith("https://")?n.jsx("a",{href:k,target:"_blank",rel:"noopener noreferrer",children:g},c):n.jsx("span",{className:"tl-guide-ref",children:g},c))}f=L.index+p.length}return f<s.length&&o.push(s.slice(f)),o}function xi(s){const l=s.replace(/\r/g,"").split(`
3
+ `),o=[];for(let h=0;h<l.length;){const f=l[h],u=`b${h}`;if(f.startsWith("```")){const c=[];for(h++;h<l.length&&!l[h].startsWith("```");)c.push(l[h++]);h++,o.push(n.jsx("pre",{children:n.jsx("code",{children:c.join(`
4
+ `)})},u));continue}const L=/^(#{1,4})\s+(.*)$/.exec(f);if(L){const c=Math.min(4,L[1].length+1),g=`h${c}`;o.push(n.jsx(g,{children:an(L[2],u)},u)),h++;continue}if(/^\|.*\|\s*$/.test(f)){const c=[];for(;h<l.length&&/^\|.*\|\s*$/.test(l[h]);){const g=l[h].trim().slice(1,-1).split("|").map(k=>k.trim());g.every(k=>/^:?-{2,}:?$/.test(k))||c.push(g),h++}o.push(n.jsx("div",{className:"tl-guide-table",children:n.jsxs("table",{children:[n.jsx("thead",{children:n.jsx("tr",{children:c[0].map((g,k)=>n.jsx("th",{children:an(g,`${u}h${k}`)},k))})}),n.jsx("tbody",{children:c.slice(1).map((g,k)=>n.jsx("tr",{children:g.map((x,$)=>n.jsx("td",{children:an(x,`${u}r${k}c${$}`)},$))},k))})]})},u));continue}if(/^\s*([-*]|\d+\.)\s+/.test(f)){const c=/^(\s*)([-*]|\d+\.)\s+/,g=/^\s*\d+\./.test(f),k=c.exec(f)[1].length,x=[];for(;h<l.length;){const r=c.exec(l[h]);if(r){const j=l[h].slice(r[0].length);if(r[1].length>k&&x.length)x[x.length-1].sub.push(j);else{if(r[1].length<k)break;x.push({text:j,sub:[]})}h++;continue}if(/^\s{2,}\S/.test(l[h])&&x.length){const j=x[x.length-1],G=l[h++].trim();j.sub.length?j.sub[j.sub.length-1]+=" "+G:j.text+=" "+G;continue}break}const $=g?"ol":"ul";o.push(n.jsx($,{children:x.map((r,j)=>n.jsxs("li",{children:[an(r.text,`${u}-${j}`),r.sub.length>0&&n.jsx("ul",{children:r.sub.map((G,C)=>n.jsx("li",{children:an(G,`${u}-${j}-${C}`)},C))})]},j))},u));continue}if(f.startsWith(">")){const c=[];for(;h<l.length&&l[h].startsWith(">");)c.push(l[h++].replace(/^>\s?/,""));o.push(n.jsx("blockquote",{children:an(c.join(" "),u)},u));continue}if(!f.trim()){h++;continue}const p=[];for(;h<l.length&&l[h].trim()&&!/^(#|```|\||>|\s*([-*]|\d+\.)\s)/.test(l[h]);)p.push(l[h++]);o.push(n.jsx("p",{children:an(p.join(" "),u)},u))}return o}function fi({onClose:s}){const l=wn(),[o,h]=N.useState(null),[f,u]=N.useState(!1);N.useEffect(()=>{let p=!0;return h(null),ki(l).then(c=>{p&&h(c)},()=>{p&&u(!0)}),()=>{p=!1}},[l]),N.useEffect(()=>{const p=c=>{c.key==="Escape"&&(c.stopPropagation(),s())};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[s]);const L=()=>{if(!o)return;const p=Object.assign(document.createElement("a"),{href:URL.createObjectURL(new Blob([o],{type:"text/markdown"})),download:`clipoox-plugin-guide.${l==="en"?"en":"vi"}.md`});p.click(),setTimeout(()=>URL.revokeObjectURL(p.href),1e3)};return n.jsx("div",{className:"tl-guide-backdrop",onMouseDown:p=>{p.target===p.currentTarget&&s()},children:n.jsxs("div",{className:"tl-guide",role:"dialog","aria-modal":"true","aria-label":i("Hướng dẫn làm plug-in"),children:[n.jsxs("div",{className:"tl-guide-head",children:[n.jsxs("strong",{children:["📘 ",i("Hướng dẫn làm plug-in")]}),n.jsx("button",{className:"pill-btn thin",disabled:!o,onClick:L,children:i("Tải hướng dẫn (.md)")}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/lower-third-clipoox.clipoox-plugin",download:!0,children:[i("Mẫu Motion")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/like-subscribe.clipoox-plugin",download:!0,children:[i("Mẫu Lottie")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/talking-head-quick.clipoox-plugin",download:!0,children:[i("Mẫu công thức")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/bds-starter.clipoox-plugin",download:!0,children:[i("Mẫu gói ngách BĐS")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin accent",href:"/plugin-dev-kit.md",download:"clipoox-plugin-dev-kit.md",title:i("Dán cho Claude / ChatGPT để AI viết plug-in theo đúng quy tắc của Clipoox"),children:[i("Plugin Dev Kit (cho AI)")," ⤓"]}),n.jsx("button",{className:"icon-btn","aria-label":i("Đóng"),onClick:s,children:"×"})]}),n.jsx("div",{className:"tl-guide-body",children:f?n.jsx("p",{className:"tl-plugin-error",children:i("Không tải được hướng dẫn.")}):o===null?n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang tải…")]}):n.jsx(N.Fragment,{children:xi(o)})})]})})}const $n=[{id:"export.done",vi:"Xuất video xong"},{id:"ai.document.ready",vi:"Tài liệu AI xong"},{id:"plugin.analyzed",vi:"Plug-in phân tích xong"}];function bi({toast:s}){const[l,o]=N.useState(null),[h,f]=N.useState(""),[u,L]=N.useState($n.map(v=>v.id)),[p,c]=N.useState(null),[g,k]=N.useState(null),[x,$]=N.useState(""),r=()=>ai().then(v=>o(v.endpoints)).catch(v=>$(V(v).text));N.useEffect(()=>{r()},[]);const j=v=>$(V(v).text),G=async()=>{c("add"),$("");try{const v=await ri(h.trim(),u);k({id:v.id,value:v.secret}),f(""),await r(),s(i("Đã thêm webhook"),"ok")}catch(v){j(v)}finally{c(null)}},C=async v=>{c(v),$("");try{const O=await ci(v);s(O.status>=200&&O.status<300?i("Đã gửi thử — nơi nhận trả lời HTTP {0}",[O.status]):i("Gửi thử chưa tới nơi ({0}) — kiểm tra link và kịch bản Make đang chạy",[O.error||`HTTP ${O.status}`]),O.status>=200&&O.status<300?"ok":"error"),await r()}catch(O){j(O)}finally{c(null)}},rn=async v=>{c(v);try{const O=await oi(v);k({id:v,value:O.secret})}catch(O){j(O)}finally{c(null)}},J=async v=>{c(v);try{await di(v),g?.id===v&&k(null),await r()}catch(O){j(O)}finally{c(null)}},Z=v=>i($n.find(O=>O.id===v)?.vi??v);return n.jsxs("details",{className:"tl-plugin-hooks",children:[n.jsxs("summary",{children:[n.jsxs("b",{children:["⚡ ",i("Tự động hoá (Webhook)")]})," ",n.jsx("small",{className:"muted",children:i("Make, Zapier, n8n nhận tin khi video xuất xong hoặc tài liệu AI xong")})]}),l===null&&!x&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang tải…")]}),l&&l.length>0&&n.jsx("ul",{className:"tl-plugin-hook-list","aria-label":i("Webhook của tôi"),children:l.map(v=>n.jsxs("li",{children:[n.jsxs("div",{className:"tl-plugin-hook-url",children:[n.jsx("code",{title:v.url,children:v.url}),n.jsxs("small",{className:"muted",children:[v.events.map(Z).join(" · "),v.lastAt?` · ${i("lần gửi cuối")}: ${typeof v.lastStatus=="number"&&v.lastStatus>=200&&v.lastStatus<300?`✓ ${v.lastStatus}`:`⚠ ${v.lastStatus}`}`:""]})]}),n.jsxs("div",{className:"tl-plugin-hook-actions",children:[n.jsxs("button",{className:"pill-btn thin",disabled:!!p,onClick:()=>void C(v.id),children:[p===v.id?n.jsx("i",{className:"spin"}):null,i("Gửi thử")]}),n.jsx("button",{className:"pill-btn thin",disabled:!!p,onClick:()=>void rn(v.id),children:i("Đổi khoá")}),n.jsx("button",{className:"pill-btn thin danger",disabled:!!p,"aria-label":i("Xoá webhook {0}",[v.url]),onClick:()=>void J(v.id),children:"✕"})]}),g?.id===v.id&&n.jsxs("p",{className:"tl-plugin-hook-secret",role:"status",children:[i("Khoá ký (chỉ hiện một lần — dán vào Make để kiểm chữ ký):")," ",n.jsx("code",{children:g.value}),n.jsx("button",{className:"pill-btn thin",onClick:()=>{navigator.clipboard?.writeText(g.value),s(i("Đã chép khoá"),"ok")},children:i("Chép")})]})]},v.id))}),l&&l.length<5&&n.jsxs("div",{className:"tl-plugin-hook-add",children:[n.jsx("input",{type:"url",inputMode:"url",placeholder:"https://hook.eu2.make.com/…","aria-label":i("Link webhook (https)"),value:h,onChange:v=>f(v.target.value)}),n.jsx("div",{className:"tl-plugin-hook-events",role:"group","aria-label":i("Gửi khi"),children:$n.map(v=>n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:u.includes(v.id),onChange:O=>L(cn=>O.target.checked?[...cn,v.id]:cn.filter(S=>S!==v.id))}),i(v.vi)]},v.id))}),n.jsxs("button",{className:"pill-btn accent",disabled:!!p||!/^https:\/\/\S+\.\S+/.test(h.trim())||!u.length,onClick:()=>void G(),children:[p==="add"?n.jsx("i",{className:"spin"}):null,i("Thêm webhook")]})]}),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",x]}),n.jsx("small",{className:"muted",children:i("Mỗi lần gửi có chữ ký X-Clipoox-Signature (HMAC-SHA256). Xem cách nối Make trong Hướng dẫn plug-in, mục 17.")})]})}const ji=N.lazy(()=>Ln(()=>import("./PluginStore-BrupM_8E.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]))),te=[{file:"lower-third-clipoox.clipoox-plugin",kind:"motion"},{file:"like-subscribe.clipoox-plugin",kind:"lottie"},{file:"talking-head-quick.clipoox-plugin",kind:"recipe"},{file:"sfx-starter.clipoox-plugin",kind:"sfx"},{file:"bds-starter.clipoox-plugin",kind:"pack"},{file:"hologram-studio.clipoox-plugin",kind:"kit"},{file:"auto-zoom-screen.clipoox-plugin",kind:"analyzer"},{file:"lesson-kit.clipoox-plugin",kind:"ai-template"},{file:"lecture-studio.clipoox-plugin",kind:"pack"}],vi={motion:{vi:"Motion",en:"Motion"},lottie:{vi:"Lottie",en:"Lottie"},recipe:{vi:"Công thức",en:"Recipe"},sfx:{vi:"Âm thanh",en:"Sounds"},pack:{vi:"Gói ngách",en:"Niche pack"},model:{vi:"Mô hình 3D",en:"3D model"},lut:{vi:"Look màu",en:"Colour look"},kit:{vi:"Bộ 3D",en:"3D kit"},motion3d:{vi:"Motion 3D",en:"Motion 3D"},sfxlib:{vi:"Kho âm thanh",en:"Sound library"},analyzer:{vi:"Phân tích clip",en:"Clip analyzer"},"ai-template":{vi:"Mẫu AI",en:"AI template"}},yi={footage:"đọc khung hình nhỏ (đen trắng) + lời thoại của clip bạn chọn, ngay trên máy — không gửi đi đâu",transcript:"đọc lời thoại của clip bạn chọn, AI của Clipoox viết tài liệu (tính credit, báo giá trước)"},Bn=(s,l)=>vi[s][l==="en"?"en":"vi"],Nn=s=>s.kind==="pack"&&!!s.assets?.some(l=>l.kind==="model"),Tn=(s,l)=>Bn(Nn(s)?"kit":s.kind==="motion"&&s.engine==="3d"?"motion3d":s.kind,l),Ni={motion3d:["3D","3D"],model:["MÔ HÌNH","MODEL"],lut:["LOOK","LOOK"],motion:["2D","2D"],recipe:["COMBO","COMBO"],lottie:["LOTTIE","LOTTIE"]},wi=(s,l)=>{const o=s.kind==="motion"&&s.engine==="3d"?"motion3d":s.kind,h=Ni[o];return h?h[l==="en"?1:0]:""},Gn=1024*1024;function _i(s,l){const o=s.facts??{},h=u=>u.toLocaleString(l==="en"?"en-US":"vi-VN"),f=s.bytes!==void 0?s.bytes>=Gn?`${(s.bytes/Gn).toFixed(1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(s.bytes/1024))} KB`:"";return s.kind==="model"?[f,i("{0} tam giác",[h(o.triangles??0)]),...o.images?.length?[i("{0} ảnh nhúng",[o.images.length])]:[],...o.animations?.length?[i("animation: {0}",[o.animations.slice(0,3).join(", ")])]:[],i("không có link ngoài")].join(" · "):s.kind==="sequence"?[f,i("{0} khung {1} × {2}",[o.frames??0,o.width??0,o.height??0])].join(" · "):s.kind==="lut"?[f,i("LUT 3D {0}³",[o.size??0])].join(" · "):[f,`${o.width??0} × ${o.height??0}`,...s.sprite?[i("sprite {0} × {1} = {2} khung",[s.sprite.cols,s.sprite.rows,s.sprite.frames])]:[]].join(" · ")}const ue=s=>`clipoox:kit-controls:${s}`;function Si(s){try{const l=JSON.parse(localStorage.getItem(ue(s))||"{}");return l&&typeof l=="object"&&!Array.isArray(l)?l:{}}catch{return{}}}function Ci(s,l){try{localStorage.setItem(ue(s),JSON.stringify(l))}catch{}}const Mi=["#3ee6ff","#c6f432","#ff5fa2","#ffb547","#9d7bff","#ffffff"],Pi={compile:["Chạy được trong sandbox (không mạng, không truy cập trang)","Không chạy được"],frames:["Đã vẽ thử {0} khung hình"],speed:["Tốc độ: {0} ms / khung","Hơi chậm: {0} ms / khung — xuất video sẽ lâu hơn"],same:["Vẽ lại cho cùng kết quả — video xuất giống Monitor","Hai lần vẽ cùng thời điểm cho kết quả khác nhau"],blank:["Có hình trong khung thử","Các khung thử đều trống — kiểm tra thời lượng và màu"],binds:["Gắn được {0} tham số vào hoạt ảnh"],dryrun:["Chạy thử trên timeline mẫu: {0} bước áp dụng, {1} bước bỏ qua (cần lời thoại / video)"],analyze:["Chạy thử trên video mẫu: {0} thao tác cho clip, {1} ms","Chạy thử trên video mẫu không ra thao tác nào"],template:["Mẫu AI hợp lệ: kết quả {0}, tối đa {1} token"],permission:["Quyền: {0}"]},le=s=>s.source?.store?` · ${i("Kho")}`:s.source?.dev?` · ${i("Bản thử – chưa duyệt")}`:"",$i=s=>s.recipe?{...s,recipe:{ops:s.recipe.ops.filter(l=>l.op!=="usePlugin")}}:s;async function ae(s){const l=f=>{const u=f;return u.op==="addMap"&&!u.geo||u.op==="updateMap"&&Array.isArray(u.places)};if(!s.some(l))return{ops:s,errors:[]};const o=[],h=[];for(const f of s){if(!l(f)){o.push(f);continue}const u=await Ae([f]);u.ops.length===1?o.push(u.ops[0]):h.push(...u.errors)}return{ops:o,errors:h}}const In=(s,l)=>Object.fromEntries(s.params.filter(o=>o.type!=="image").map(o=>[o.key,l[o.key]]));function Ti({selected:s,time:l,aspect:o,materials:h,locked:f,onCommit:u,onPatch:L,toast:p}){const c=wn(),[g,k]=N.useState(null),[x,$]=N.useState(null),[r,j]=N.useState(null),[G,C]=N.useState(null),[rn,J]=N.useState(null),[Z]=N.useState(()=>Ue()),[v,O]=N.useState(!1),[cn,S]=N.useState(!!Z),[M,q]=N.useState(null),[B,F]=N.useState(null),[mn,Un]=N.useState({}),[vn,qn]=N.useState("all"),[P,on]=N.useState(null),_n=e=>{F({id:e.id}),qn("all"),Un(t=>({...t,[e.id]:{...Object.fromEntries((e.manifest.controls??[]).map(a=>[a.key,a.default])),...Si(e.id)}})),ne(e).then(t=>F(a=>a?.id===e.id?{id:e.id,index:t}:a),t=>F(a=>a?.id===e.id?{id:e.id,error:V(t).text}:a))},Fn=N.useRef(null),[ge,Kn]=N.useState(""),pe=e=>{S(!1),Qn().then(t=>{k(t.plugins);const a=t.plugins.find(d=>d.id===e);a&&(a.kind==="pack"&&B?.id!==e&&_n(a),Kn(e),window.setTimeout(()=>Kn(d=>d===e?"":d),3400),requestAnimationFrame(()=>document.querySelector(`[data-plugin="${CSS.escape(e)}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})))},()=>{})},Q=N.useCallback(()=>Qn().then(e=>{k(e.plugins),$(null)},e=>{k(t=>t??[]),$(V(e).text)}),[]);N.useEffect(()=>{Q()},[Q]),N.useEffect(()=>{Z&&qe()},[Z]);const en=e=>{const t=V(e);p(t.detail?`${t.text} (${t.detail})`:t.text,"error")},me=async e=>{j({file:e.name,stage:"reading"});try{if(await De(e)){const y=await ze(e),w=g?.find(E=>E.id===y.manifest.id);j({file:e.name,stage:"review",sfx:y,...w?{exists:{installed:w.version,newer:yn(y.manifest.version,w.version)>0}}:{}});return}const{bytes:t,...a}=await Re(e);if(a.manifest.kind==="pack"){const y=a.items,w=[];let E=a.thumbnail;j({file:e.name,stage:"checking",bundle:a,pack:{bytes:t,checks:[],total:y.length}});const m=We(a,Math.random().toString(36).slice(2,8));try{for(const A of y){const z=await Yn($i(A),o,{assets:m.refs,readAsset:a.readAsset}).catch(R=>({ok:!1,lines:[],thumbnail:null,error:R.message}));E??=z.thumbnail,w.push({id:A.manifest.id,name:_(A.manifest,c),kind:A.manifest.kind==="motion"&&A.manifest.engine==="3d"?"motion3d":A.manifest.kind,ok:z.ok,warn:z.lines.some(R=>R.warn),...z.error?{error:z.error}:{}}),j(R=>R&&{...R,pack:{bytes:t,checks:[...w],total:y.length}})}}finally{m.drop()}const T=w.find(A=>!A.ok),U=g?.find(A=>A.id===a.manifest.id);j({file:e.name,stage:"review",bundle:{...a,thumbnail:E},pack:{bytes:t,checks:w,total:y.length},...T?{error:{text:i("Mục “{0}” không chạy được",[T.name]),detail:T.error??""}}:{},...U?{exists:{installed:U.version,newer:yn(a.manifest.version,U.version)>0}}:{}});return}j({file:e.name,stage:"checking",bundle:a});const d=await Yn(a,o),b=g?.find(y=>y.id===a.manifest.id);j({file:e.name,stage:"review",bundle:a,check:d,...d.ok?{}:{error:V({code:d.error==="nondeterministic"||d.error==="dryrun"?d.error:"code",message:d.error})},...b?{exists:{installed:b.version,newer:yn(a.manifest.version,b.version)>0}}:{}})}catch(t){j({file:e.name,stage:"review",error:V(t)})}},ke=async()=>{const e=r;if(e?.sfx){const t=e.sfx;j({...e,stage:"saving",progress:{stage:"upload",pct:0}});try{const a=await He(t,!!e.exists,(d,b)=>j(y=>y&&{...y,progress:{stage:d,pct:b}}));j(null),await Q(),bn(),p(a.updated?i("Đã cập nhật “{0}” lên v{1}",[_(a.plugin.manifest,c),a.plugin.version]):i("Đã thêm gói âm thanh “{0}” ({1} âm thanh) — có trong mục SFX",[_(a.plugin.manifest,c),a.plugin.manifest.sounds?.length??0]),"ok")}catch(a){const d=a;if(d.code==="exists"){const b=d.data;j({...e,stage:"review",progress:void 0,exists:{installed:b.installed,newer:b.newer}});return}j({...e,stage:"review",progress:void 0,error:V(a)})}return}if(e?.pack&&e.bundle){const t=e.pack,a=e.bundle.manifest;j({...e,stage:"saving",progress:{stage:"upload",pct:0}});try{const d=await Ve(t.bytes,a,e.file,!!e.exists,b=>j(y=>y&&{...y,progress:{stage:"upload",pct:b}}));j(null),await Q(),bn(),_n(d.plugin),p(d.updated?i("Đã cập nhật “{0}” lên v{1}",[_(d.plugin.manifest,c),d.plugin.version]):Nn(d.plugin.manifest)?i("Đã thêm bộ 3D “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]):i("Đã thêm gói “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]),"ok")}catch(d){const b=d;if(b.code==="exists"){const y=b.data;j({...e,stage:"review",progress:void 0,exists:{installed:y.installed,newer:y.newer}});return}j({...e,stage:"review",progress:void 0,error:V(d)})}return}if(!(!e?.bundle||!e.check?.ok)){j({...e,stage:"saving"});try{const t=await Xe({...e.bundle,thumbnail:e.check.thumbnail??e.bundle.thumbnail},!!e.exists);j(null),await Q(),bn(),p(t.updated?i("Đã cập nhật “{0}” lên v{1}",[_(t.plugin.manifest,c),t.plugin.version]):i("Đã thêm plug-in “{0}”",[_(t.plugin.manifest,c)]),"ok")}catch(t){const a=t;if(a.code==="exists"){const d=a.data;j({...e,stage:"review",exists:{installed:d.installed,newer:d.newer}});return}j({...e,stage:"review",error:V(t)})}}},dn=e=>$e(Math.max(0,Math.min(l,Te-e))),xe=async e=>{if(!G){if(e.access?.expired){de(e.id,"pass");return}if(e.kind==="sfx"||e.kind==="sfxlib"){Hn(t=>t===e.id?null:e.id);return}if(e.kind==="pack"){B?.id===e.id?F(null):_n(e);return}C(e.id);try{const t=await oe(e,k),a=t.manifest,d=_(a,c),b=H.getState();if(a.kind==="recipe"){q({id:e.id,values:X(a,{}),bundle:t});return}if(a.kind==="analyzer"){Dn(e.id,void 0,a);return}if(a.kind==="ai-template"){on({id:e.id,values:X(a,{}),bundle:t});return}if(a.kind==="motion"){const K=he(a,t.entry,{}),Y=dn(a.duration),tn=gn(b.clips,[{op:"addMotion",code:K.code,params:K.params,motionPreset:K.preset,...K.kind?{motionKind:K.kind}:{},label:`Plug-in · ${d}`,start:Y,duration:a.duration}],[],b.timelineTracks);if(tn.errors.length)throw Error(tn.errors[0]);const I=tn.clips.find(W=>!b.clips.some(nn=>nn.id===W.id));u(tn.clips.map(W=>W.id===I?.id?{...W,plugin:{id:a.id,v:a.version,kind:"motion"}}:W),I?.id);return}const y=X(a,{}),w=await En(t.lottie,a,y),E=await An(a.id,w),m=se(t),T=dn(m),U={id:E.gcsUri,kind:"lottie",url:E.url,gcsUri:E.gcsUri,label:d,lottie:t.lottie.meta},A=H.getState(),z=gn(A.clips,[{op:"addClip",materialId:U.id,start:T,duration:m}],[U],A.timelineTracks);if(z.errors.length)throw Error(z.errors[0]);const R=z.clips.find(K=>!A.clips.some(Y=>Y.id===K.id));u(z.clips.map(K=>K.id===R?.id?{...K,label:`Plug-in · ${d}`,lottie:{...K.lottie,loop:a.loop!==!1},plugin:{id:a.id,v:a.version,kind:"lottie",params:In(a,y)}}:K),R?.id)}catch(t){en(t)}finally{C(null)}}},fe=async(e,t)=>{if(!G){C(`${e.id}/${t}`);try{const a=(await ne(e)).items.find(I=>I.manifest.id===t)?.manifest;if(a&&(a.kind==="model"||a.kind==="lut"||a.kind==="motion"&&(a.uses?.length||a.params.some(I=>I.link||I.type==="asset")))){const I=H.getState(),W=mn[e.id]??{};if(a.kind==="lut"&&!s)throw ee("needs_clip");const nn=Object.fromEntries(a.params.filter(ln=>ln.link&&W[ln.link]!==void 0).map(ln=>[ln.key,W[ln.link]])),hn=await ie([{op:"usePlugin",pluginId:`${e.id}/${t}`,params:nn,...a.kind==="lut"?{clipId:s.id}:{start:dn(a.duration??5)}}],{items:g??[],clips:I.clips,playhead:l,locale:c}),D=H.getState(),un=Mn(D.clips,hn.ops,[...h,...hn.materials],D.timelineTracks,D.timelineCamera,{W:o.width,H:o.height,motion:D.timelineMotion,brand:D.timelineBrand});if(!un.result||!un.ops.length)throw Error(un.skipped[0]?.error??"—");const Zn=hn.tagPlugins(D.clips,un.result.clips),Me=Zn.find(ln=>!D.clips.some(Pe=>Pe.id===ln.id));u(Zn,Me?.id??s?.id??null),a.kind==="lut"&&p(i("Đã áp look “{0}” cho “{1}” (chỉnh độ mạnh ở tab Màu)",[_(a,c),s.label]),"ok");return}const d=await re(e,t),b=d.manifest,y=_(b,c),w=H.getState(),E={id:e.id,item:t,v:e.version};if(b.kind==="recipe"){q({id:e.id,item:t,values:X(b,{}),bundle:d});return}if(b.kind==="analyzer"){Dn(e.id,t,b);return}if(b.kind==="ai-template"){on({id:e.id,item:t,values:X(b,{}),bundle:d});return}if(b.kind==="motion"){const I=ce(e.id,t,d,{}),W=dn(b.duration),nn=gn(w.clips,[{op:"addMotion",code:I.code,params:I.params,motionPreset:I.preset,...I.kind?{motionKind:I.kind}:{},label:`Plug-in · ${y}`,start:W,duration:b.duration}],[],w.timelineTracks);if(nn.errors.length)throw Error(nn.errors[0]);const hn=nn.clips.find(D=>!w.clips.some(un=>un.id===D.id));u(nn.clips.map(D=>D.id===hn?.id?{...D,plugin:{...E,kind:"motion"}}:D),hn?.id);return}const m=X(b,{}),T=await En(d.lottie,b,m),U=await An(e.id,T),A=se(d),z=dn(A),R={id:U.gcsUri,kind:"lottie",url:U.url,gcsUri:U.gcsUri,label:y,lottie:d.lottie.meta},K=H.getState(),Y=gn(K.clips,[{op:"addClip",materialId:R.id,start:z,duration:A}],[R],K.timelineTracks);if(Y.errors.length)throw Error(Y.errors[0]);const tn=Y.clips.find(I=>!K.clips.some(W=>W.id===I.id));u(Y.clips.map(I=>I.id===tn?.id?{...I,label:`Plug-in · ${y}`,lottie:{...I.lottie,loop:b.loop!==!1},plugin:{...E,kind:"lottie",params:In(b,m)}}:I),tn?.id)}catch(a){en(a)}finally{C(null)}}},Dn=(e,t,a)=>{if(!s||s.kind!=="video")throw ee("needs_video");const d=H.getState(),b=g?.find(w=>w.id===e),y=gn(d.clips,[{op:"runAnalyzer",clipId:s.id,plugin:{id:e,...t?{item:t}:{},v:b?.version??a.version},values:X(a,{})}],[],d.timelineTracks);if(y.errors.length)throw Error(y.errors[0]);u(y.clips,s.id),p(i("“{0}” đang đọc clip “{1}” trên máy — xong sẽ tự áp (hoàn tác bằng ⌘Z)",[_(a,c),s.label]),"ok")},zn=()=>{if(!s)return"";const e=H.getState(),t=e.timelineMedia.find(w=>s.gcsUri&&w.gcsUri===s.gcsUri||w.url===s.url),a=s.playbackRate||1,d=s.inPoint||0,b=d+s.duration*a,y=w=>w.end>d&&w.start<b;return t?.words?.length?t.words.filter(y).map(w=>w.word).join(" "):(t?.transcript??[]).filter(y).map(w=>w.text).join(`
5
+ `)},Rn=()=>({plugin:P.item?`${P.id}/${P.item}`:P.id,params:P.values,transcript:zn(),title:s?.label??"",duration:s?.duration??0,source:s?.id}),be=async()=>{if(!(!P||G)){C(`ai:${P.id}`);try{const e=await hi(Rn());on(t=>t&&{...t,price:e.max_credits,doc:void 0})}catch(e){p(V(e).text,"error")}finally{C(null)}}},je=async()=>{if(!(!P?.price||G)){C(`ai:${P.id}`);try{const e=await ui(Rn(),P.price);on(t=>t&&{...t,doc:e}),p(i("Đã viết “{0}” — {1} credit",[e.title,e.credits]),"ok")}catch(e){p(V(e).text,"error")}finally{C(null)}}},ve=e=>{const t=e.format==="json"?"json":"md",a=e.format==="json"&&e.json!==void 0?JSON.stringify(e.json,null,2):e.text,d=Object.assign(document.createElement("a"),{href:URL.createObjectURL(new Blob([a],{type:e.format==="json"?"application/json":"text/markdown"})),download:`${e.title.replace(/[\\/:*?"<>|]+/g,"-").slice(0,80)||"clipoox"}.${t}`});d.click(),setTimeout(()=>URL.revokeObjectURL(d.href),2e3)},ye=async()=>{if(!(!M||G)){C(M.id);try{const e=H.getState(),t=s;if(M.item){const w=await ie([{op:"usePlugin",pluginId:`${M.id}/${M.item}`,params:M.values,...t?{clipId:t.id}:{}}],{items:g??[],clips:e.clips,playhead:l,locale:c}),E=await ae(w.ops),m=Mn(e.clips,E.ops,[...h,...w.materials],e.timelineTracks,e.timelineCamera,{W:o.width,H:o.height,motion:e.timelineMotion,brand:e.timelineBrand}),T=_(M.bundle.manifest,c),U=[...E.errors,...m.skipped.map(A=>A.error)];if(!m.result||!m.ops.length){p(i("“{0}” không áp dụng được bước nào: {1}",[T,U[0]??"—"]),"error");return}u(w.tagPlugins(e.clips,m.result.clips),null),p(U.length?i("Đã chạy “{0}”: {1} bước. Bỏ qua: {2}",[T,m.ops.length,U.join("; ")]):i("Đã chạy “{0}”: {1} bước (hoàn tác bằng ⌘Z)",[T,m.ops.length]),m.ops.length?"ok":"error");return}const a=await ae(Je(M.bundle,M.values,{clip:t?.id??null,playhead:l,clipStart:t?.start??null,clipEnd:t?t.start+t.duration:null})),d=Mn(e.clips,a.ops,h,e.timelineTracks,e.timelineCamera,{W:o.width,H:o.height,motion:e.timelineMotion,brand:e.timelineBrand}),b=_(M.bundle.manifest,c),y=[...a.errors,...d.skipped.map(w=>w.error)];if(!d.result||!d.ops.length){p(i("“{0}” không áp dụng được bước nào: {1}",[b,y[0]??"—"]),"error");return}u(d.result.clips,null),p(y.length?i("Đã chạy “{0}”: {1} bước. Bỏ qua: {2}",[b,d.ops.length,y.join("; ")]):i("Đã chạy “{0}”: {1} bước (hoàn tác bằng ⌘Z)",[b,d.ops.length]),d.ops.length?"ok":"error")}catch(e){en(e)}finally{C(null)}}},Wn=(e,t)=>{Un(a=>({...a,[e]:t})),Ci(e,t)},Ne=e=>H.getState().clips.filter(t=>t.plugin?.id===e&&t.plugin?.kind==="motion"&&t.motion),we=(e,t)=>{const a=mn[e.id]??{},d=H.getState(),b=new Map(t.items.map(E=>[E.manifest.id,E.manifest]));let y=0;const w=d.clips.map(E=>{const m=E.plugin,T=m?.id===e.id&&m.item?b.get(m.item):void 0;if(!T||!E.motion)return E;const U=Object.fromEntries(T.params.filter(A=>A.link&&a[A.link]!==void 0).map(A=>[A.key,a[A.link]]));return Object.keys(U).length?(y++,{...E,motion:{...E.motion,params:{...E.motion.params,...U}}}):E});if(!y){p(i("Chưa có lớp nào của bộ này trong dự án."),"error");return}u(w,null),p(i("Đã áp điều khiển chung cho {0} lớp (hoàn tác bằng ⌘Z)",[y]),"ok")},_e=async e=>{J(null);try{await ei(e.id,!e.enabled),await Q(),bn()}catch(t){en(t)}},[sn,Hn]=N.useState(null),[Sn,Vn]=N.useState(""),Xn=async e=>{const t=Ze(e);if(!(!t||Sn)){Vn(e);try{const a=await Qe(t.pack,t.sound),d=H.getState(),b=gn(d.clips,[{op:"addSfx",sfxId:e,at:dn(a.duration),volume:Le,sound:a}],[],d.timelineTracks);if(b.errors.length)throw Error(b.errors[0]);u(b.clips,b.clips.find(y=>!d.clips.some(w=>w.id===y.id))?.id??null)}catch(a){en(a)}finally{Vn("")}}},Se=async e=>{if(J(null),!!window.confirm(i("Gỡ plug-in “{0}”? Các lớp đã thêm vào video vẫn giữ nguyên.",[_(e.manifest,c)])))try{await ii(e.id),await Q(),bn(),sn===e.id&&Hn(null),p(i("Đã gỡ “{0}”",[_(e.manifest,c)]),"ok")}catch(t){en(t)}},kn=s,xn=kn?.plugin,Ce=xn?g?.find(e=>e.id===xn.id):void 0,fn=(g??[]).filter(e=>e.enabled),Cn=(g??[]).filter(e=>!e.enabled),Jn=e=>n.jsxs("div",{className:`tl-plugin-tile${e.enabled?"":" off"}${e.access?.expired?" expired":""}${ge===e.id?" flash":""}`,"data-plugin":e.id,children:[n.jsxs("button",{className:`tl-plugin-use${sn===e.id||B?.id===e.id?" on":""}`,disabled:!e.enabled||!!G,"aria-expanded":e.kind==="sfx"||e.kind==="sfxlib"?sn===e.id:e.kind==="pack"?B?.id===e.id:void 0,"aria-label":e.access?.expired?i("Gia hạn plug-in {0}",[_(e.manifest,c)]):e.kind==="recipe"?i("Mở công thức {0}",[_(e.manifest,c)]):e.kind==="sfx"?i("Mở gói âm thanh {0}",[_(e.manifest,c)]):e.kind==="sfxlib"?i("Mở kho âm thanh {0}",[_(e.manifest,c)]):e.kind==="pack"?i("Mở gói {0}",[_(e.manifest,c)]):i("Thêm plug-in {0}",[_(e.manifest,c)]),title:e.access?.expired?i("Vé 30 ngày đã hết hạn — bấm để gia hạn trên clipoox.com"):void 0,onClick:()=>void xe(e),children:[n.jsxs("span",{className:"tl-plugin-thumb",children:[e.access?.expired&&n.jsx("span",{className:"tl-plugin-ribbon",children:i("Hết hạn")}),e.thumbnailUrl?n.jsx("img",{src:e.thumbnailUrl,alt:"",loading:"lazy",onError:t=>{t.currentTarget.style.visibility="hidden"}}):n.jsx("b",{children:e.kind==="analyzer"?"⌖":e.kind==="ai-template"?"✎":e.kind==="recipe"?"▶":e.kind==="sfx"?"♪":e.kind==="sfxlib"?"📚":Nn(e.manifest)?"◈":e.kind==="pack"?"⧉":"✦"}),G===e.id&&n.jsx("i",{className:"spin"})]}),n.jsxs("span",{className:"tl-plugin-name",children:[n.jsx("strong",{title:_(e.manifest,c),children:_(e.manifest,c)}),n.jsxs("small",{children:[Tn(e.manifest,c),e.kind==="sfx"?` · ${i("{0} âm thanh",[e.manifest.sounds?.length??0])}`:""," · v",e.version,e.kind==="pack"?` · ${i("{0} mục",[e.manifest.items?.length??0])}`:"",le(e),e.enabled?"":` · ${i("Đã tắt")}`]})]})]}),n.jsx("button",{className:"tl-plugin-more","aria-label":i("Tuỳ chọn {0}",[_(e.manifest,c)]),"aria-expanded":rn===e.id,onClick:()=>J(t=>t===e.id?null:e.id),children:"⋯"}),rn===e.id&&n.jsxs("div",{className:"tl-plugin-menu",role:"menu",children:[n.jsx("p",{children:pn(e.manifest,c)||"—"}),n.jsxs("small",{className:"muted",children:[i("Tác giả"),": ",e.manifest.author.name,e.manifest.author.url?` · ${e.manifest.author.url}`:""]}),n.jsx("button",{role:"menuitem",onClick:()=>void _e(e),children:e.enabled?i("Tắt plug-in"):i("Bật plug-in")}),n.jsx("button",{role:"menuitem",className:"danger",onClick:()=>void Se(e),children:i("Gỡ plug-in")})]}),e.access&&n.jsx(Li,{item:e,locale:c})]},e.id);return n.jsxs("section",{className:"tl-plugins","aria-label":i("Plug-in của tôi"),children:[n.jsxs("div",{className:"tl-plugins-head",children:[n.jsxs("div",{children:[n.jsx("h4",{children:i("Plug-in của tôi")}),n.jsx("small",{className:"muted",children:i("Hiệu ứng motion, hoạt ảnh Lottie, công thức chỉnh sửa và gói âm thanh do cộng đồng làm")})]}),n.jsxs("div",{className:"tl-plugins-actions",children:[n.jsxs("button",{className:"pill-btn accent",onClick:()=>S(!0),children:["🛍 ",i("Kho Plug-in")]}),n.jsxs("button",{className:"pill-btn",disabled:!!r&&r.stage!=="review",onClick:()=>Fn.current?.click(),children:["+ ",i("Thêm plug-in")]}),n.jsxs("button",{className:"pill-btn",onClick:()=>O(!0),children:["📘 ",i("Hướng dẫn plug-in")]})]}),n.jsx("input",{ref:Fn,type:"file",hidden:!0,"aria-label":i("Chọn file plug-in"),accept:".clipoox-plugin,.zip,application/zip",onChange:e=>{const t=e.target.files?.[0];e.target.value="",t&&me(t)}})]}),r&&n.jsxs("div",{className:`tl-plugin-review${r.error?" bad":""}`,role:"dialog","aria-label":i("Kiểm tra plug-in"),children:[r.stage==="reading"&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang đọc {0}…",[r.file])]}),r.stage==="checking"&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang chạy thử trong sandbox…")]}),r.sfx&&n.jsx(gi,{review:r.sfx}),r.progress&&n.jsxs("p",{className:"tl-plugin-step",role:"status",children:[n.jsx("i",{className:"spin"}),r.progress.stage==="upload"?i("Đang tải gói lên… {0}%",[r.progress.pct??0]):r.pack?i("Máy chủ đang kiểm tra từng mục…"):i("Máy chủ đang kiểm tra và cân bằng âm lượng từng âm thanh…")]}),r.bundle&&n.jsxs("div",{className:"tl-plugin-card",children:[(r.check?.thumbnail??r.bundle.thumbnail)&&n.jsx("img",{alt:"",src:`data:${(r.check?.thumbnail??r.bundle.thumbnail).type};base64,${(r.check?.thumbnail??r.bundle.thumbnail).data}`}),n.jsxs("div",{children:[n.jsx("strong",{children:_(r.bundle.manifest,c)}),n.jsxs("small",{children:[Tn(r.bundle.manifest,c)," · v",r.bundle.manifest.version," · ",r.bundle.manifest.author.name]}),n.jsx("p",{children:pn(r.bundle.manifest,c)}),n.jsxs("small",{className:"muted",children:[r.bundle.manifest.kind==="pack"?i("{0} mục",[r.bundle.manifest.items?.length??0]):i("{0} tham số",[r.bundle.manifest.params.length]),r.bundle.lottie?.removed&&r.bundle.lottie.removed.expressions+r.bundle.lottie.removed.assets+r.bundle.lottie.removed.fonts>0?` · ${i("đã bỏ {0} phần không an toàn (biểu thức / link ngoài)",[r.bundle.lottie.removed.expressions+r.bundle.lottie.removed.assets+r.bundle.lottie.removed.fonts])}`:""]})]})]}),r.bundle?.assets&&r.bundle.assets.length>0&&n.jsxs(n.Fragment,{children:[n.jsx("h6",{className:"tl-plugin-subhead",children:i("Tài nguyên ({0})",[r.bundle.assets.length])}),n.jsxs("ul",{className:"tl-plugin-checks","aria-label":i("Tài nguyên"),children:[n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),n.jsxs("div",{className:"tl-plugin-fact",children:[n.jsx("b",{children:i("Gói {0} MB",[((r.pack?.bytes.length??0)/Gn).toFixed(1).replace(".",c==="en"?".":",")])})," ",n.jsxs("small",{className:"muted",children:["— ",i("giới hạn 200 MB · GLB ≤ 20 MB, ≤ 300 000 tam giác")]})]})]}),r.bundle.assets.slice(0,12).map(e=>n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),n.jsxs("div",{className:"tl-plugin-fact",children:[n.jsx("b",{children:e.name})," ",n.jsxs("small",{className:"muted",children:["— ",_i(e,c)]})]})]},e.name)),r.bundle.assets.length>12&&n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),i("+ {0} tài nguyên khác",[r.bundle.assets.length-12])]})]}),n.jsx("h6",{className:"tl-plugin-subhead",children:i("Chạy thử từng mục")})]}),r.pack&&n.jsxs("ul",{className:"tl-plugin-checks","aria-label":i("Chạy thử từng mục"),children:[r.stage==="checking"&&n.jsxs("li",{className:"ok",children:[n.jsx("i",{className:"spin"}),i("Đang chạy thử mục {0} / {1}…",[r.pack.checks.length+1,r.pack.total])]}),r.pack.checks.map(e=>n.jsxs("li",{className:e.ok?e.warn?"warn":"ok":"bad",children:[n.jsx("span",{"aria-hidden":!0,children:e.ok?e.warn?"!":"✓":"✕"}),e.name," ",n.jsx("small",{className:"muted",children:Bn(e.kind,c)}),e.error&&n.jsxs("small",{children:[" — ",e.error]})]},e.id))]}),r.check&&n.jsx("ul",{className:"tl-plugin-checks",children:r.check.lines.map((e,t)=>{const[a,d]=Pi[e.key],b=!e.ok||e.warn;return n.jsxs("li",{className:e.ok?e.warn?"warn":"ok":"bad",children:[n.jsx("span",{"aria-hidden":!0,children:e.ok?e.warn?"!":"✓":"✕"}),i(b&&d?d:a,e.key==="permission"?[i(yi[String(e.args?.[0])]??String(e.args?.[0]))]:e.args??[]),e.detail&&n.jsxs("small",{children:[" — ",e.detail]})]},t)})}),r.error&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",r.error.text,r.error.detail&&n.jsx("small",{children:r.error.detail})]}),r.exists&&!r.error&&(()=>{const e=(r.bundle??r.sfx).manifest.version;return n.jsx("p",{className:"tl-plugin-note",children:r.exists.newer?i("Đã cài v{0}. Cập nhật lên v{1}?",[r.exists.installed,e]):i("Đã cài v{0} — cài lại bản v{1} này?",[r.exists.installed,e])})})(),n.jsxs("div",{className:"tl-plugin-review-actions",children:[r.stage==="review"&&(r.check?.ok||r.sfx||r.pack)&&!r.error&&n.jsx("button",{className:"pill-btn accent",onClick:()=>void ke(),children:r.exists?r.exists.newer?i("Cập nhật plug-in"):i("Cài lại plug-in"):i("Cài plug-in")}),r.stage==="saving"&&n.jsxs("button",{className:"pill-btn accent",disabled:!0,children:[n.jsx("i",{className:"spin"}),i("Đang lưu…")]}),n.jsx("button",{className:"pill-btn",disabled:r.stage==="saving",onClick:()=>j(null),children:r.error?i("Đóng"):i("Huỷ")})]})]}),xn&&kn&&n.jsx(Ai,{clip:kn,pref:xn,item:Ce,materials:h,locked:f,onPatch:L,toast:p,fail:en},`${kn.id}:${kn.url}:${xn.v}`),M&&(()=>{const e=M.bundle.manifest,t=g?.find(d=>d.id===M.id),a=/\{\{\s*clip/.test(JSON.stringify(M.bundle.recipe?.ops??[]));return n.jsxs("div",{className:"tl-plugin-recipe",role:"group","aria-label":i("Công thức {0}",[_(e,c)]),children:[n.jsxs("h5",{children:["▶ ",_(e,c)," ",n.jsxs("small",{className:"muted",children:["v",e.version]})]}),n.jsx("p",{className:"muted",children:pn(e,c)}),e.params.length>0&&n.jsx("div",{className:"tl-plugin-params",children:e.params.map(d=>n.jsx(jn,{p:d,value:M.values[d.key],locale:c,disabled:!1,onBegin:()=>{},onChange:b=>q(y=>y&&{...y,values:{...y.values,[d.key]:b}})},d.key))}),a&&n.jsx("small",{className:s?"muted":"tl-warn",children:s?i("Áp dụng cho clip đang chọn: {0}",[s.label]):i("Chọn một clip trên timeline trước khi chạy.")}),n.jsxs("div",{className:"tl-plugin-review-actions",children:[n.jsx("button",{className:"pill-btn accent",disabled:!!G||a&&!s||!t?.enabled,onClick:()=>void ye(),children:G===M.id?i("Đang chạy…"):i("Chạy công thức")}),n.jsx("button",{className:"pill-btn",onClick:()=>q(null),children:i("Đóng")})]})]})})(),P&&(()=>{const e=P.bundle.manifest,t=g?.find(b=>b.id===P.id),a=zn().length,d=G===`ai:${P.id}`;return n.jsxs("div",{className:"tl-plugin-recipe tl-plugin-ai",role:"group","aria-label":i("Mẫu AI {0}",[_(e,c)]),children:[n.jsxs("h5",{children:["✎ ",_(e,c)," ",n.jsxs("small",{className:"muted",children:["v",e.version," · ",i("Mẫu AI")]})]}),n.jsx("p",{className:"muted",children:pn(e,c)}),e.params.length>0&&n.jsx("div",{className:"tl-plugin-params",children:e.params.map(b=>n.jsx(jn,{p:b,value:P.values[b.key],locale:c,disabled:d,onBegin:()=>{},onChange:y=>on(w=>w&&{...w,values:{...w.values,[b.key]:y},price:void 0})},b.key))}),n.jsx("small",{className:s&&a?"muted":"tl-warn",children:s?a?i("Đọc lời thoại của: {0}",[s.label]):i("Clip “{0}” chưa có lời thoại — bấm Transcript cho clip trước.",[s.label]):i("Chọn clip có lời thoại trên timeline.")}),P.price!==void 0&&!P.doc&&n.jsx("p",{className:"tl-plugin-note",role:"status",children:i("Tối đa {0} credit — tính theo lượng AI thật sự viết, thường ít hơn.",[P.price])}),n.jsxs("div",{className:"tl-plugin-review-actions",children:[P.price===void 0||P.doc?n.jsxs("button",{className:"pill-btn accent",disabled:!!G||!s||!a||!t?.enabled,onClick:()=>void be(),children:[d?n.jsx("i",{className:"spin"}):null,i("Xem giá")]}):n.jsxs("button",{className:"pill-btn accent",disabled:!!G,onClick:()=>void je(),children:[d?n.jsx("i",{className:"spin"}):null,i("Chạy (tối đa {0} credit)",[P.price])]}),n.jsx("button",{className:"pill-btn",onClick:()=>on(null),children:i("Đóng")})]}),P.doc&&n.jsxs("div",{className:"tl-plugin-doc",children:[n.jsx("textarea",{readOnly:!0,"aria-label":i("Tài liệu AI"),value:P.doc.format==="json"&&P.doc.json!==void 0?JSON.stringify(P.doc.json,null,2):P.doc.text}),n.jsxs("div",{className:"tl-plugin-review-actions",children:[n.jsx("button",{className:"pill-btn thin",onClick:()=>{navigator.clipboard?.writeText(P.doc.text),p(i("Đã chép tài liệu"),"ok")},children:i("Chép")}),n.jsx("button",{className:"pill-btn thin",onClick:()=>ve(P.doc),children:P.doc.format==="json"?i("Tải .json"):i("Tải .md")}),n.jsx("small",{className:"muted",children:i("{0} credit · đã gửi tới webhook (nếu có)",[P.doc.credits])})]})]})]})})(),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",i("Không tải được danh sách plug-in: {0}",[x])]}),g===null&&!x&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang tải plug-in…")]}),g&&!g.length&&!r&&n.jsxs("div",{className:"tl-plugins-empty",children:[n.jsx("b",{"aria-hidden":!0,children:"⧉"}),n.jsx("strong",{children:i("Chưa có plug-in nào")}),n.jsx("p",{children:i("Plug-in thêm hiệu ứng motion, hoạt ảnh Lottie, công thức chỉnh sửa nhanh hoặc gói âm thanh do cộng đồng làm. Chọn trong Kho Plug-in, hoặc thêm file .clipoox-plugin bạn có.")}),n.jsxs("button",{className:"pill-btn accent",onClick:()=>S(!0),children:["🛍 ",i("Mở Kho Plug-in")]}),n.jsxs("button",{className:"pill-btn",onClick:()=>O(!0),children:["📘 ",i("Đọc hướng dẫn làm plug-in")]}),n.jsxs("div",{className:"tl-plugins-samples",children:[n.jsx("small",{className:"muted",children:i("Thử {0} plug-in mẫu:",[te.length])}),te.map(e=>n.jsxs("a",{className:"pill-btn thin",href:`/plugin-samples/${e.file}`,download:!0,children:[Bn(e.kind,c)," ⤓"]},e.file))]})]}),fn.length>0&&n.jsx("div",{className:"tl-plugin-grid",children:fn.map(Jn)}),(()=>{const e=sn?fn.find(t=>t.id===sn&&t.kind==="sfxlib"):void 0;return e?n.jsxs("section",{className:"tl-plugin-pack","aria-label":i("Âm thanh trong {0}",[_(e.manifest,c)]),children:[n.jsx("small",{className:"muted sfxlib-hint",children:i("cũng có trong mục SFX (tab Âm thanh)")}),n.jsx(Fe,{item:e,busy:Sn,onAdd:t=>void Xn(t)})]}):null})(),(()=>{const e=sn?fn.find(t=>t.id===sn&&t.kind==="sfx"):void 0;return e?n.jsxs("section",{className:"tl-plugin-pack","aria-label":i("Âm thanh trong {0}",[_(e.manifest,c)]),children:[n.jsxs("h5",{children:["♪ ",_(e.manifest,c)," ",n.jsxs("small",{className:"muted",children:[i("{0} âm thanh",[e.manifest.sounds?.length??0])," · ",i("cũng có trong mục SFX (tab Âm thanh)")]})]}),n.jsx(Ke,{packs:[e],busy:Sn,showPack:!1,onAdd:t=>void Xn(t)})]}):null})(),(()=>{const e=B?fn.find(m=>m.id===B.id&&m.kind==="pack"):void 0;if(!e||!B)return null;const t=B.index,a=Nn(e.manifest),d=t?.manifest.controls??[],b=t?.manifest.categories??[],y=mn[e.id]??{},w=t?t.items.filter(m=>vn==="all"||m.manifest.category===vn):[],E=a&&d.length?Ne(e.id).length:0;return n.jsxs("section",{className:`tl-plugin-pack${a?" kit":""}`,"aria-label":i("Các mục trong {0}",[_(e.manifest,c)]),children:[n.jsxs("h5",{children:[a?"◈":"⧉"," ",_(e.manifest,c)," ",n.jsxs("small",{className:"muted",children:[i("{0} mục",[e.manifest.items?.length??0]),le(e)," · ",a?i("bấm một mục để thêm vào playhead; look áp lên clip đang chọn"):i("bấm một mục để thêm vào playhead; công thức chạy trên clip đang chọn")]})]}),B.error&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",B.error]}),!t&&!B.error&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang tải gói…")]}),d.length>0&&n.jsxs("div",{className:"tl-kit-controls",role:"group","aria-label":i("Điều khiển chung của bộ"),children:[n.jsxs("h6",{children:[i("Điều khiển chung của bộ")," ",n.jsx("small",{className:"muted",children:i("áp cho mọi mục có 🔗")})]}),n.jsx("div",{className:"tl-plugin-params",children:d.map(m=>n.jsxs("div",{className:"tl-kit-control",children:[n.jsx(jn,{p:m,value:y[m.key],locale:c,disabled:!1,onBegin:()=>{},onChange:T=>Wn(e.id,{...y,[m.key]:T})}),m.type==="color"&&n.jsx("span",{className:"tl-kit-swatches",role:"group","aria-label":i("Màu gợi ý"),children:Mi.map(T=>n.jsx("button",{type:"button",className:String(y[m.key]).toLowerCase()===T?"on":"",style:{background:T},"aria-label":T,onClick:()=>Wn(e.id,{...y,[m.key]:T})},T))})]},m.key))}),n.jsx("button",{className:"pill-btn thin",disabled:f||!E||!t,onClick:()=>t&&we(e,t),children:i("Áp cho {0} lớp của bộ trong dự án",[E])})]}),b.length>0&&t&&n.jsx("div",{className:"tl-kit-chips",role:"group","aria-label":i("Nhóm"),children:[{id:"all",name:{vi:"Tất cả",en:"All"}},...b].map(m=>{const T=m.id==="all"?t.items.length:t.items.filter(U=>U.manifest.category===m.id).length;return T||m.id==="all"?n.jsxs("button",{type:"button",className:`tl-kit-chip${vn===m.id?" on":""}`,"aria-pressed":vn===m.id,onClick:()=>qn(m.id),children:[m.name[c==="en"?"en":"vi"]," ",n.jsx("span",{children:T})]},m.id):null})}),t&&n.jsx("div",{className:`tl-plugin-items${a?" kit":""}`,children:w.map(({manifest:m,thumbnail:T})=>{const U=`${e.id}/${m.id}`,A=a?wi(m,c):"";return n.jsxs("button",{className:"tl-plugin-item","data-item":m.id,"data-kind":m.kind,disabled:!!G,title:pn(m,c),"aria-label":m.kind==="recipe"?i("Mở công thức {0}",[_(m,c)]):m.kind==="lut"?i("Áp look {0} cho clip đang chọn",[_(m,c)]):i("Thêm {0}",[_(m,c)]),onClick:()=>void fe(e,m.id),children:[n.jsxs("span",{className:"tl-plugin-thumb",children:[T?n.jsx("img",{src:`data:${T.type};base64,${T.data}`,alt:""}):n.jsx("b",{children:m.kind==="analyzer"?"⌖":m.kind==="ai-template"?"✎":m.kind==="recipe"?"▶":m.kind==="model"?"◈":m.kind==="lut"?"◐":"✦"}),A&&n.jsx("span",{className:`tl-kit-badge ${m.kind}`,children:A}),G===U&&n.jsx("i",{className:"spin"})]}),n.jsxs("span",{className:"tl-plugin-name",children:[n.jsx("strong",{children:_(m,c)}),n.jsxs("small",{children:[Tn(m,c),m.duration?` · ${m.duration} s`:""]})]})]},m.id)})})]})})(),Cn.length>0&&n.jsxs("details",{className:"tl-plugin-off",children:[n.jsx("summary",{children:i("Đã tắt ({0})",[Cn.length])}),n.jsx("div",{className:"tl-plugin-grid",children:Cn.map(Jn)})]}),g&&g.length>0&&n.jsx("small",{className:"muted tl-plugins-foot",children:i("{0} / 50 plug-in · chỉ tài khoản của bạn thấy · bấm để thêm vào playhead",[g.length])}),g&&n.jsx(bi,{toast:p}),v&&n.jsx(fi,{onClose:()=>O(!1)}),cn&&n.jsx(N.Suspense,{fallback:null,children:n.jsx(ji,{installed:g??[],initialId:Z,onClose:()=>S(!1),onInstalled:()=>void Q(),onUse:pe,toast:p})})]})}function Li({item:s,locale:l}){const o=s.access,h=Math.max(1,Math.ceil((o.expiresAt-Date.now())/864e5)),f=!o.expired&&h<=3,u=o.passVnd>0?`${o.passVnd.toLocaleString("vi-VN")}đ`:"",L=o.passUsd>0?`$${Number.isInteger(o.passUsd)?o.passUsd:o.passUsd.toFixed(2)}`:"",p=l==="en"?L||u:u||L;return n.jsxs("div",{className:`tl-plugin-pass${o.expired?" ended":f?" soon":""}`,"data-pass":o.expired?"ended":f?"soon":"active",children:[n.jsx("span",{className:"tl-plugin-pass-state",children:o.expired?i("Vé đã hết hạn {0}",[si(o.expiresAt,l)]):f?i("Vé sắp hết hạn · còn {0} ngày",[h]):i("Vé 30 ngày · còn {0} ngày",[h])}),(o.expired||f)&&n.jsx("button",{className:"tl-plugin-renew",onClick:()=>de(s.id,"pass"),children:p?i("Gia hạn 30 ngày · {0}",[p]):i("Gia hạn 30 ngày")})]})}function jn({p:s,value:l,locale:o,disabled:h,onBegin:f,onChange:u,onImage:L,media:p,linked:c}){const g=On(s,o),k=l??s.default;if(c&&s.type!=="asset"){const x=n.jsx(jn,{p:s,value:l,locale:o,disabled:h,onBegin:f,onChange:u,onImage:L});return n.jsxs("div",{className:"tl-plugin-linked",children:[x,n.jsxs("span",{className:"tl-plugin-link",title:i("Theo điều khiển chung của bộ"),children:["🔗 ",i("theo bộ")]})]})}if(s.type==="asset"){const x=s.accept==="model"?"model":"image",$=(p??[]).filter(j=>j.kind===x&&typeof j.gcsUri=="string"),r=$.find(j=>j.gcsUri===k);return n.jsxs("div",{className:"tl-motion-param tl-plugin-image tl-plugin-asset",children:[n.jsx("span",{children:g}),n.jsxs("span",{children:[r&&x==="image"&&r.url?n.jsx("img",{src:r.url,alt:""}):n.jsx("i",{title:x==="model"?i("Chưa chọn GLB"):i("Chưa chọn ảnh"),children:x==="model"?"◈":""}),n.jsxs("select",{"aria-label":g,value:typeof k=="string"?k:"",disabled:h,onFocus:f,onChange:j=>u(j.target.value),children:[n.jsx("option",{value:"",children:x==="model"?i("— Mẫu của bộ (không dùng GLB của bạn) —"):i("— Không dùng ảnh —")}),$.map(j=>n.jsx("option",{value:j.gcsUri,children:String(j.label||j.gcsUri.split("/").pop()).slice(0,40)},j.gcsUri))]})]}),!$.length&&n.jsx("small",{className:"muted",children:x==="model"?i("Thêm file .glb vào Media trước (kéo thả vào Media)."):i("Thêm ảnh PNG / JPEG / WebP vào Media trước.")})]})}return s.type==="boolean"?n.jsxs("label",{className:"tl-motion-param check",children:[n.jsx("input",{type:"checkbox","aria-label":g,checked:!!k,disabled:h,onChange:x=>{f(),u(x.target.checked)}}),g]}):s.type==="number"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsx(Ee,{"aria-label":g,value:Number(k),min:s.min,max:s.max,precision:3,disabled:h,onCommit:x=>{f(),u(ni(s,x))}})]}):s.type==="color"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsxs("span",{className:"tl-motion-color",children:[n.jsx("input",{type:"color","aria-label":g,value:String(k),disabled:h,onFocus:f,onChange:x=>u(x.target.value)}),n.jsx("code",{children:String(k)})]})]}):s.type==="select"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsx("select",{"aria-label":g,value:String(k),disabled:h,onFocus:f,onChange:x=>u(x.target.value),children:s.options.map(x=>n.jsx("option",{value:x.value,children:On({...s,label:x.label},o)},x.value))})]}):s.type==="image"?n.jsxs("div",{className:"tl-motion-param tl-plugin-image",children:[n.jsx("span",{children:g}),n.jsxs("span",{children:[typeof k=="string"&&k.startsWith("data:")?n.jsx("img",{src:k,alt:""}):n.jsx("i",{title:i("Ảnh mặc định")}),n.jsx(Ei,{label:g,disabled:h,onPick:x=>L?.(x)})]})]}):n.jsxs("label",{className:"tl-motion-param tl-plugin-text",children:[g,s.multiline?n.jsx("textarea",{"aria-label":g,rows:2,value:String(k),maxLength:s.maxLength,disabled:h,onFocus:f,onKeyDown:x=>x.stopPropagation(),onChange:x=>u(x.target.value)}):n.jsx("input",{type:"text","aria-label":g,value:String(k),maxLength:s.maxLength,disabled:h,onFocus:f,onKeyDown:x=>x.stopPropagation(),onChange:x=>u(x.target.value)})]})}function Ei({label:s,disabled:l,onPick:o}){const h=N.useRef(null);return n.jsxs(n.Fragment,{children:[n.jsx("button",{type:"button",className:"pill-btn thin",disabled:l,onClick:()=>h.current?.click(),children:i("Chọn ảnh…")}),n.jsx("input",{ref:h,type:"file",hidden:!0,"aria-label":s,accept:"image/png,image/jpeg,image/webp",onChange:f=>{const u=f.target.files?.[0];f.target.value="",u&&o(u)}})]})}function Ai({clip:s,pref:l,item:o,materials:h,locked:f,onPatch:u,toast:L,fail:p}){const c=wn(),[g,k]=N.useState(null),[x,$]=N.useState({}),[r,j]=N.useState(!1),G=l.kind==="motion"||l.kind==="lottie"||l.kind==="recipe";if(N.useEffect(()=>{let S=!0;return o&&G&&(l.item?re(o,l.item):oe(o)).then(M=>{S&&k(M)},()=>{}),()=>{S=!1}},[o,l.item,G]),l.kind==="model")return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsxs("h5",{children:["◈ ",s.label]}),n.jsx("small",{className:"muted",children:i("Lớp 3D từ bộ “{0}”. Xoay, keyframe, chuyển động 3D, animation của GLB và camera Timeline chỉnh ở tab 3D. Gỡ bộ thì lớp vẫn giữ.",[o?_(o.manifest,c):l.id])})]});const C=g?.manifest??(l.item?void 0:o?.manifest);if(!C&&l.item&&o)return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsx("h5",{children:i("Lớp plug-in")}),n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),i("Đang tải gói…")]})]});if(!C)return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsx("h5",{children:i("Lớp plug-in")}),n.jsx("small",{className:"muted",children:i("Plug-in này đã gỡ khỏi tài khoản. Lớp vẫn chạy bình thường; tham số motion vẫn sửa được ở tab Edit.")})]});const rn=o&&yn(o.version,l.v)>0,J=l.kind==="motion"?{...X(C,{}),...s.motion?.params}:{...X(C,l.params??{}),...x},Z=(S,M)=>{if(!s.motion)return;const q=C.params.find(F=>F.key===S)?.type==="asset",B={...s.motion.assets??{}};q&&(delete B[`@${S}`],typeof M=="string"&&M&&(B[`@${S}`]=M)),u(s.id,{motion:{...s.motion,params:{...s.motion.params,[S]:M},...q?{assets:B}:{}}},!1)},v=Object.keys(x).length>0,O=async(S,M)=>{if(g?.lottie){j(!0);try{const q=S?g.lottie:{data:await Oe(s.url)},B=await An(l.id,await En(q,C,M)),F=S?o?.version??C.version:l.v;u(s.id,{url:B.url,gcsUri:B.gcsUri,...S?{lottie:{...g.lottie.meta,loop:s.lottie?.loop??C.loop!==!1}}:{},plugin:{id:l.id,...l.item?{item:l.item}:{},v:F,kind:"lottie",params:In(C,M)}},!0),$({}),L(i("Đã áp dụng tham số plug-in"),"ok")}catch(q){p(q)}finally{j(!1)}}},cn=async()=>{if(g){if(l.kind==="motion"&&s.motion){const S=Object.fromEntries(Object.entries(s.motion.params??{}).filter(([F])=>C.params.some(mn=>mn.key===F))),M=l.item?ce(l.id,l.item,g,S):he(C,g.entry,S),q=o?.version??C.version;let B={};try{C.uses?.length&&(B=ti(await li(l.id,C.uses)))}catch(F){p(F);return}for(const F of C.params)F.type==="asset"&&typeof S[F.key]=="string"&&S[F.key]&&(B[`@${F.key}`]=S[F.key]);u(s.id,{motion:{...M,...Object.keys(B).length?{assets:B}:{}},plugin:{id:l.id,...l.item?{item:l.item}:{},v:q,kind:"motion"}},!0),L(i("Đã cập nhật lớp lên v{0}",[q]),"ok");return}O(!0,J)}};return n.jsxs("section",{className:"tl-plugin-inspector","aria-label":i("Tham số plug-in"),children:[n.jsxs("h5",{children:["⧉ ",_(C,c)," ",n.jsxs("small",{className:"muted",children:["v",l.v]})]}),rn&&n.jsxs("button",{className:"pill-btn thin tl-plugin-update",disabled:f||r||!g,onClick:()=>void cn(),children:["↑ ",i("Cập nhật lớp lên v{0}",[o.version])]}),C.params.length?n.jsx("div",{className:"tl-plugin-params",children:C.params.map(S=>n.jsx(jn,{p:S,value:J[S.key],locale:c,disabled:f||r,media:h,linked:!!S.link,onBegin:()=>{l.kind==="motion"&&u(s.id,{},!0)},onChange:M=>{l.kind==="motion"?Z(S.key,M):$(q=>({...q,[S.key]:M}))},onImage:M=>void Ye(M).then(q=>$(B=>({...B,[S.key]:q})),p)},S.key))}):n.jsx("small",{className:"muted",children:i("Plug-in này không có tham số.")}),l.kind==="lottie"&&n.jsxs("div",{className:"tl-plugin-review-actions",children:[n.jsx("button",{className:"pill-btn accent",disabled:f||r||!v||!g,onClick:()=>void O(!1,J),children:r?i("Đang áp dụng…"):i("Áp dụng")}),n.jsx("button",{className:"pill-btn",disabled:f||r||!g,title:i("Về hoạt ảnh gốc của plug-in với giá trị mặc định"),onClick:()=>void O(!0,X(C,{})),children:i("Đặt lại")})]}),l.kind==="motion"&&n.jsx("small",{className:"muted",children:i("Thay đổi hiện ngay trên Monitor. Code của lớp ở tab Edit.")}),l.kind==="motion"&&s.motion?.assets&&n.jsxs("div",{className:"tl-plugin-assets",children:[n.jsx("small",{className:"muted",children:i("Tài nguyên của lớp (đã chép vào dự án — gỡ bộ vẫn giữ)")}),n.jsx("ul",{children:Object.keys(s.motion.assets).map(S=>n.jsxs("li",{children:[n.jsx("b",{children:S.startsWith("@")?i("của bạn: {0}",[On(C.params.find(M=>`@${M.key}`===S)??{key:S.slice(1),label:{vi:S.slice(1),en:S.slice(1)}},c)]):S}),n.jsx("span",{children:"✓"})]},S))})]})]})}const Ki=Object.freeze(Object.defineProperty({__proto__:null,default:Ti},Symbol.toStringTag,{value:"Module"}));export{Ki as T,V as p};
@@ -0,0 +1 @@
1
+ .tl-plugins{display:flex;flex-direction:column;gap:10px;padding:2px 0 10px;min-width:0}.tl-plugins h4{margin:0;font-size:13px;color:#e6e8ec}.tl-plugins h5{margin:0 0 4px;font-size:12px;color:#e6e8ec;display:flex;gap:6px;align-items:baseline}.tl-plugins p{margin:0;font-size:11.5px;line-height:1.5;color:#aab3ac}.tl-plugins small{line-height:1.45}.tl-plugins-head{display:flex;flex-direction:column;gap:8px}.tl-plugins-head>div:first-child{display:flex;flex-direction:column;gap:2px}.tl-plugins-actions{display:flex;gap:6px;flex-wrap:wrap}.tl-plugins-empty{display:flex;flex-direction:column;align-items:center;gap:8px;padding:18px 12px;border:1px dashed #38423a;border-radius:12px;text-align:center;background:#0f130f}.tl-plugins-empty>b{font-size:28px;color:#c6f432;line-height:1}.tl-plugins-empty strong{font-size:13px;color:#e6e8ec}.tl-plugins-samples{display:flex;flex-wrap:wrap;gap:6px;justify-content:center;align-items:center}.tl-plugins-samples a{text-decoration:none}.tl-plugin-grid{display:flex;flex-direction:column;gap:6px}.tl-plugin-tile{position:relative;border:1px solid #283129;border-radius:10px;background:#0f130f;min-width:0}.tl-plugin-tile:hover{border-color:#c6f43299}.tl-plugin-tile.off{opacity:.55}.tl-plugin-tile.expired{border-color:#3a2f22}.tl-plugin-tile.expired .tl-plugin-thumb img{filter:grayscale(1) brightness(.6)}.tl-plugin-tile.expired .tl-plugin-name strong{color:#b9bfba}.tl-plugin-ribbon{position:absolute;left:4px;top:4px;z-index:1;padding:2px 6px;border-radius:4px;border:1px solid #f0b44c66;background:#0b0d0bdd;color:#f0b44c;font-size:9px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;line-height:1.3}.tl-plugin-pass{display:flex;flex-direction:column;gap:7px;margin:0 6px;padding:8px 2px;border-top:1px solid #1f271f}.tl-plugin-pass-state{display:flex;align-items:center;gap:6px;font-size:11px;line-height:1.35;color:#9aa49c}.tl-plugin-pass-state:before{content:"";flex:none;width:6px;height:6px;border-radius:50%;background:#7bd88f}.tl-plugin-pass.soon .tl-plugin-pass-state{color:#f0b44c}.tl-plugin-pass.soon .tl-plugin-pass-state:before{background:#f0b44c}.tl-plugin-pass.ended .tl-plugin-pass-state{color:#f2c27a}.tl-plugin-pass.ended .tl-plugin-pass-state:before{background:#ff6b5b}.tl-plugin-renew{display:block;width:100%;height:30px;padding:0 10px;border:0;border-radius:8px;background:#c6f432;color:#0b0f0b;font:inherit;font-size:12px;font-weight:700;letter-spacing:.01em;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.tl-plugin-renew:hover{background:#d6ff52}.tl-plugin-renew:focus-visible{outline:2px solid #e6e8ec;outline-offset:2px}.tl-plugin-pass.soon .tl-plugin-renew{background:transparent;color:#c6f432;box-shadow:inset 0 0 0 1px #c6f43266}.tl-plugin-pass.soon .tl-plugin-renew:hover{background:#c6f4321a}.tl-plugin-use{display:grid;grid-template-columns:96px minmax(0,1fr);gap:10px;align-items:center;width:100%;padding:6px 30px 6px 6px;border:0;background:none;color:#c8cec9;text-align:left;cursor:pointer;min-width:0;border-radius:10px}.tl-plugin-use:disabled{cursor:default}.tl-plugin-use:focus-visible{outline:2px solid #c6f432;outline-offset:-2px}.tl-plugin-thumb{position:relative;display:grid;place-items:center;aspect-ratio:16/9;border-radius:6px;overflow:hidden;background:#15181d}.tl-plugin-thumb img{width:100%;height:100%;object-fit:cover}.tl-plugin-thumb b{font-size:20px;color:#c6f432}.tl-plugin-thumb .spin{position:absolute;right:4px;bottom:4px}.tl-plugin-name{display:flex;flex-direction:column;gap:3px;min-width:0}.tl-plugin-name strong{font-size:12px;line-height:1.45;color:#e6e8ec;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.tl-plugin-name small{font-size:10.5px;color:#8f9a91}.tl-plugin-more{position:absolute;right:4px;top:6px;width:22px;height:22px;border:0;border-radius:6px;background:none;color:#8f9a91;cursor:pointer;font-size:14px;line-height:1}.tl-plugin-more:hover,.tl-plugin-more[aria-expanded=true]{background:#1c231c;color:#e6e8ec}.tl-plugin-menu{position:absolute;z-index:5;left:0;right:0;top:100%;margin-top:4px;display:flex;flex-direction:column;gap:6px;padding:8px;border:1px solid #38423a;border-radius:10px;background:#11161a;box-shadow:0 10px 24px #00000080}.tl-plugin-menu button{border:1px solid #2b3330;border-radius:7px;background:#161b1f;color:#e6e8ec;font-size:11.5px;padding:5px 8px;text-align:left;cursor:pointer}.tl-plugin-menu button:hover{border-color:#c6f43299}.tl-plugin-menu button.danger{color:#ff8f8f}.tl-plugin-review,.tl-plugin-recipe,.tl-plugin-inspector{display:flex;flex-direction:column;gap:8px;padding:10px;border:1px solid #c6f43255;border-radius:12px;background:#11160f}.tl-plugin-review.bad{border-color:#ff6b6b66;background:#1a1112}.tl-plugin-card{display:flex;flex-direction:column;gap:8px;min-width:0}.tl-plugin-card img{width:100%;aspect-ratio:16/9;object-fit:cover;border-radius:8px;background:#15181d}.tl-plugin-card>div{display:flex;flex-direction:column;gap:3px;min-width:0}.tl-plugin-card strong{font-size:13px;color:#e6e8ec;line-height:1.45}.tl-plugin-card small{font-size:10.5px;color:#8f9a91}.tl-plugin-checks{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:4px}.tl-plugin-checks li{display:flex;gap:6px;font-size:11.5px;line-height:1.45;color:#c8cec9}.tl-plugin-checks li>span{flex:none;width:14px;text-align:center;font-weight:700}.tl-plugin-checks li.ok>span{color:#c6f432}.tl-plugin-checks li.warn>span{color:#ffc24b}.tl-plugin-checks li.bad{color:#ffb3b3}.tl-plugin-checks li.bad>span{color:#ff6b6b}.tl-plugin-checks small{color:#8f9a91}.tl-plugin-error{display:flex;flex-direction:column;gap:3px;margin:0;font-size:12px;line-height:1.5;color:#ffb3b3}.tl-plugin-error small{font:10.5px/1.4 ui-monospace,Menlo,monospace;color:#c99;word-break:break-word}.tl-plugin-note{font-size:12px;color:#ffd27a!important}.tl-plugin-step{display:flex;gap:8px;align-items:center;font-size:12px;color:#aab3ac;margin:0}.tl-plugin-review-actions{display:flex;gap:6px;flex-wrap:wrap}.tl-plugin-update{align-self:flex-start}.tl-plugin-params{display:flex;flex-direction:column;gap:7px}.tl-plugin-params .tl-motion-param{display:grid;grid-template-columns:minmax(0,42%) minmax(0,1fr);align-items:center;gap:8px;font-size:11.5px;color:#aab3ac;line-height:1.4}.tl-plugin-params .tl-motion-param.check{display:flex}.tl-plugin-params input[type=text],.tl-plugin-params textarea,.tl-plugin-params select,.tl-plugin-params input:not([type]){width:100%;min-width:0;box-sizing:border-box}.tl-plugin-image>span{display:flex;align-items:center;gap:6px;min-width:0}.tl-plugin-image img,.tl-plugin-image i{width:30px;height:30px;border-radius:6px;object-fit:cover;flex:none;background:#15181d;border:1px dashed #38423a}.tl-plugin-image button{font-size:11px}.tl-plugin-off summary{cursor:pointer;font-size:11.5px;color:#8f9a91;margin-bottom:6px}.tl-plugins-foot{font-size:10.5px;color:#8f9a91}.tl-warn{color:#ffc24b;font-size:11px}.tl-guide-backdrop{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:#050709b8;padding:16px}.tl-guide{display:flex;flex-direction:column;width:min(860px,100%);max-height:min(88vh,1000px);border:1px solid #2b3330;border-radius:14px;background:#0f1215;box-shadow:0 24px 60px #0009;overflow:hidden}.tl-guide-head{display:flex;flex-wrap:wrap;gap:6px;align-items:center;padding:10px 12px;border-bottom:1px solid #222a26}.tl-guide-head strong{flex:1 1 auto;font-size:13px;color:#e6e8ec}.tl-guide-head a{text-decoration:none}.tl-guide-body{overflow:auto;padding:6px 22px 22px;color:#c8cec9;font-size:13px;line-height:1.65}.tl-guide-body h2{font-size:20px;color:#e6e8ec;margin:16px 0 6px;line-height:1.4}.tl-guide-body h3{font-size:16px;color:#c6f432;margin:20px 0 6px;line-height:1.45}.tl-guide-body h4,.tl-guide-body h5{font-size:13.5px;color:#e6e8ec;margin:14px 0 4px;line-height:1.5}.tl-guide-body p{margin:6px 0}.tl-guide-body ul,.tl-guide-body ol{margin:4px 0;padding-left:22px}.tl-guide-body li{margin:2px 0}.tl-guide-body code{font:12px/1.5 ui-monospace,Menlo,monospace;background:#1a1f1c;border-radius:4px;padding:1px 4px;color:#e6e8ec}.tl-guide-body pre{background:#0a0d0b;border:1px solid #222a26;border-radius:8px;padding:10px 12px;overflow:auto}.tl-guide-body pre code{background:none;padding:0;font-size:11.5px}.tl-guide-body blockquote{margin:8px 0;padding:6px 12px;border-left:3px solid #c6f432;background:#121811;color:#c8cec9}.tl-guide-body a{color:#c6f432}.tl-guide-table{overflow:auto}.tl-guide-body table{border-collapse:collapse;margin:8px 0;font-size:12px}.tl-guide-body th,.tl-guide-body td{border:1px solid #2b3330;padding:5px 8px;text-align:left;vertical-align:top}.tl-guide-body th{background:#151a17;color:#e6e8ec}.ps-drawer .ad-grid{grid-template-columns:repeat(auto-fill,minmax(200px,1fr))}.ps-open{display:block;width:calc(100% - 16px);padding:0;border:0;cursor:pointer;background:#15181d}.ps-price{position:absolute;right:8px;top:8px;z-index:2;padding:4px 8px;border-radius:7px;background:#070907db;border:1px solid var(--border-strong);font-size:11px;font-weight:800;color:#f2f4f0;line-height:1.3}.ps-price.free{color:#0b1106;background:var(--accent);border-color:var(--accent)}.ps-price.owned{color:var(--accent)}.ps-sub{text-transform:none}.ps-n{margin-left:6px;min-width:18px;height:18px;padding:0 5px;border-radius:9px;background:var(--accent);color:#0b1106;font-size:10.5px;font-weight:800;display:inline-grid;place-items:center}.ps-waiting{display:flex;gap:7px;align-items:center;margin-top:8px;font-size:11.5px;line-height:1.45;color:#ffd27a}.ps-waiting.bad{color:#ff9b9b}.ps-drawer .ad-use.ps-wait,.ps-drawer .ad-use.ps-wait:hover:not(:disabled){background:#1d2416;color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent);opacity:1}.ad-use.ps-big{flex:0 1 auto;padding:0 22px;height:40px}.ps-detail{width:min(760px,100%);max-height:calc(100% - 20px);overflow:auto}.ps-stage{position:relative;aspect-ratio:16/9;border-radius:10px;overflow:hidden;background:repeating-conic-gradient(#1d2026 0 25%,#16181c 0 50%) 0 0/16px 16px;margin-bottom:12px}.ps-stage canvas,.ps-stage img,.ps-stage video{width:100%;height:100%;object-fit:contain;display:block}.ps-stage-note{position:absolute;left:10px;bottom:10px;padding:4px 8px;border-radius:7px;background:#070907d1;color:#c8cec9;font-size:11px}.ps-info{display:flex;flex-direction:column;gap:8px}.ps-info p{margin:0;font-size:13px;line-height:1.55;color:#c8cec9}.ps-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.ps-row .ps-price{position:static}.ps-kind{font-size:12px;color:var(--text-muted)}.ps-params{font-size:12px!important;color:#aab3ac!important}.tl-plugins .spin,.ps-drawer .spin,.tl-guide .spin{display:inline-block;flex:none;width:10px;height:10px;border:2px solid #c6f43244;border-top-color:#c6f432;border-radius:50%;animation:plg-spin .8s linear infinite;vertical-align:-1px}.ps-waiting .spin{border-color:#ffd27a44;border-top-color:#ffd27a}@keyframes plg-spin{to{transform:rotate(360deg)}}.ps-drawer .ad-name{font-size:15px;line-height:1.45}.ps-drawer .ps-sub{font-size:12.5px;margin-top:4px}.ps-drawer .ad-notice{font-size:13px;line-height:1.5}.ps-drawer .ad-tab,.ps-drawer .ad-chip{font-size:13.5px}.ps-drawer .ad-search{font-size:14px}.ps-drawer .ad-use{font-size:14px;height:38px}.ps-drawer .ad-badge{font-size:10.5px}.ps-drawer .ps-price{font-size:13px;padding:5px 9px}.ps-drawer .ps-waiting{font-size:13px}.ps-drawer .ad-empty{font-size:14px}.ps-detail header b{font-size:17px}.ps-info p{font-size:14.5px!important;line-height:1.6!important}.ps-info .ps-params{font-size:13.5px!important}.ps-info .ps-kind{font-size:13.5px}.ps-info small{font-size:12.5px;line-height:1.5}.ps-stage-note{font-size:12.5px}.ps-drawer .ps-sub{align-items:center;gap:8px}.ps-drawer .ps-sub .ps-price{position:static;flex:none}.ps-drawer .ps-by{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tl-sfx-item.tl-sfx-plug{grid-template-columns:26px minmax(0,1fr) auto 26px}.tl-sfx-plug .tl-sfx-name small{font-size:10px;color:#8f9a91;line-height:1.35}.tl-sfx-loop{font-style:normal;color:#c6f432}.tl-sfx-plugins h5{color:#e6e8ec}.tl-plugin-use.on{outline:1px solid #c6f432;outline-offset:-1px}.tl-plugin-pack{margin-top:10px;padding:8px;border:1px solid var(--border,#2a2f36);border-radius:8px;background:#ffffff05}.tl-plugin-pack h5{margin:0 0 6px;font-size:12.5px;line-height:1.5;display:flex;flex-wrap:wrap;gap:6px;align-items:baseline;color:#e6e8ec}.tl-plugin-pack h5 small{font-weight:400;font-size:10.5px}.tl-plugin-pack .tl-sfx-list,.tl-plugin-sfx-list{list-style:none;margin:0;padding:0;display:grid;gap:2px;max-height:260px;overflow:auto}.tl-plugin-sfx-review{display:flex;flex-direction:column;gap:10px}.tl-plugin-sfx-list .tl-sfx-item{grid-template-columns:26px minmax(0,1fr) auto}.tl-plugin-wave,.ps-wave{display:flex;align-items:center;justify-content:center;gap:3px;width:100%;aspect-ratio:16/9;border-radius:8px;background:#15181d;padding:0 10%;box-sizing:border-box}.tl-plugin-wave i,.ps-wave i{display:block;flex:1 1 0;max-width:6px;border-radius:3px;background:#c6f432;opacity:.9}.ps-sounds-meta{margin-top:4px;font-size:12px;color:#c6f432;font-weight:600}.ps-sounds{display:flex;flex-direction:column;gap:10px;margin-bottom:12px}.ps-sounds-head{display:grid;grid-template-columns:160px minmax(0,1fr);gap:12px;align-items:center}.ps-sounds-head img,.ps-sounds-head .ps-wave{width:160px;aspect-ratio:16/9;object-fit:cover;border-radius:8px}.ps-sounds-head b{display:block;font-size:14px;color:#e6e8ec;margin-bottom:4px}.ps-sounds-head small{font-size:12.5px;line-height:1.5}.ps-sound-list{list-style:none;margin:0;display:grid;gap:2px;max-height:300px;overflow:auto;border:1px solid var(--border,#2a2f36);border-radius:8px;padding:4px}.ps-sound-list li{display:grid;grid-template-columns:28px minmax(0,1fr) auto;gap:8px;align-items:center;padding:4px 6px;border-radius:6px;font-size:13px;line-height:1.5}.ps-sound-list li.on,.ps-sound-list li:hover{background:#ffffff0f}.ps-sound-list li.locked{opacity:.55}.ps-sound-list .ps-sound-name{display:grid;min-width:0}.ps-sound-list .ps-sound-name small{font-size:11px}.ps-sound-list .tl-sfx-play{width:26px;height:26px;border-radius:50%;border:1px solid var(--border,#2a2f36);background:transparent;color:#e6e8ec;font-size:10px;cursor:pointer}.ps-sound-list .tl-sfx-play:disabled{cursor:not-allowed}@media(max-width:560px){.ps-sounds-head{grid-template-columns:1fr}.ps-sounds-head img,.ps-sounds-head .ps-wave{width:100%}}.timeline-workspace .tl-sfx .tl-sfx-plugins .tl-sfx-list{max-height:220px}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins{flex:none}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins .tl-sfx-list{flex:none;max-height:176px;min-height:0}.timeline-workspace .tl-plugin-sfx-review .tl-sfx-list{max-height:240px}.tl-plugin-items{display:grid;grid-template-columns:repeat(auto-fill,minmax(92px,1fr));gap:6px}.tl-plugin-item{display:flex;flex-direction:column;gap:4px;padding:6px;border:1px solid #283129;border-radius:8px;background:#0f130f;color:inherit;text-align:left;cursor:pointer;min-width:0}.tl-plugin-item:hover:not(:disabled){border-color:#c6f43299}.tl-plugin-item:disabled{opacity:.6;cursor:default}.tl-plugin-item .tl-plugin-thumb{width:100%;aspect-ratio:16/9;height:auto}.tl-plugin-item .tl-plugin-name strong{font-size:12px}.ps-open{position:relative}.ps-featured{position:absolute;left:8px;bottom:8px;padding:2px 8px;border-radius:999px;background:#c6f432;color:#0b0d0f;font-size:10.5px;font-weight:700;letter-spacing:.02em}.ps-featured-line{margin:0 0 6px;color:#c6f432;font-weight:600;font-size:12.5px}.ps-private{position:absolute;right:8px;top:8px;padding:2px 8px;border-radius:999px;background:#0b0d0fd1;color:#f4f5f7;border:1px solid rgba(255,255,255,.18);font-size:10.5px;font-weight:700}.ps-private-line{margin:0 0 6px;color:#f4f5f7;opacity:.85;font-weight:600;font-size:12.5px}.sfxlib{display:flex;flex-direction:column;gap:6px;min-height:0}.sfxlib-tools{display:flex;gap:8px;align-items:center}.sfxlib-tools .ad-search{flex:1;min-width:0}.sfxlib-tools .sfxlib-folder{flex:none;width:190px}.sfxlib-chip span{opacity:.6}.sfxlib-chip.on{background:var(--accent-soft);color:var(--accent);border-color:#b4e36a73}select.sfxlib-chip{appearance:none;padding-right:9px}.sfxlib-count{margin:0;font-size:11.5px;color:var(--text-muted)}.sfxlib-more{width:100%;margin-top:4px;min-height:30px;border-radius:8px;border:1px dashed var(--border-strong);background:transparent;color:var(--text-muted);cursor:pointer;font-size:12px}.sfxlib-more:hover:not(:disabled){color:var(--text);border-color:#b4e36a73}.sfxlib-list.locked .tl-sfx-name,.sfxlib-list.locked small{opacity:.5}.timeline-workspace .tl-sfx-docked .tl-sfx-plugins .tl-sfx-list.sfxlib-list{max-height:none;flex:none}.sfxlib-store .ps-sound-list{max-height:340px;overflow:auto}.ps-stats{display:flex;flex-wrap:wrap;gap:4px 14px;font-size:12.5px;color:var(--text-muted);margin-bottom:4px}.ps-sounds-head .ps-stats b{display:inline;font-size:12.5px;margin:0;color:#e6e8ec}.ps-lib-prices{color:#8f9a91!important;font-weight:500!important}.ps-lib-buy-wrap{display:flex;flex-direction:column;gap:8px}.ps-lib-buy{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:8px}.ps-drawer .ps-lib-buy .ad-use{height:auto;padding:9px 12px;line-height:1.3}.ps-lib-buy .ad-use small{display:block;font-size:11.5px;font-weight:500;opacity:.75}.ps-drawer .ad-use.ps-alt{background:transparent;color:var(--accent);box-shadow:inset 0 0 0 1px var(--accent)}.tl-sfx-plugins select.sfxlib-source{appearance:none;-webkit-appearance:none;width:100%;margin:0 0 8px;padding:7px 30px 7px 10px;border-radius:9px;border:1px solid var(--border-strong);color:var(--text);font-size:12px;font-weight:600;cursor:pointer;background:var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238A8F98' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center}.tl-sfx-plugins select.sfxlib-source:hover{border-color:#b4e36a73}.tl-sfx-plugins select.sfxlib-source:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.sfxlib-head{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:linear-gradient(135deg,#b4e36a1a,#b4e36a05 60%);border:1px solid rgba(180,227,106,.18)}.sfxlib-icon{flex:none;width:34px;height:34px;border-radius:9px;background:#11160d;border:1px solid rgba(180,227,106,.3);display:flex;align-items:center;justify-content:center;gap:2px}.sfxlib-icon i{display:block;width:2px;border-radius:1px;background:var(--accent)}.sfxlib-title{display:grid;min-width:0;flex:1;line-height:1.3}.sfxlib-title strong{font-size:12.5px;color:var(--text)}.sfxlib-title small{font-size:10.5px;color:var(--text-muted)}.sfxlib-badge{flex:none;font-size:10px;font-weight:700;padding:3px 7px;border-radius:999px;background:var(--accent-soft);color:var(--accent);white-space:nowrap}.sfxlib-badge.off{background:#e8b0631f;color:#f0c27e}.sfxlib-pass{display:flex;align-items:center;gap:10px;padding:8px 10px;border-radius:10px;background:#e8b06312;border:1px solid rgba(232,176,99,.28)}.sfxlib-pass-ic{flex:none;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;background:#e8b06329;font-size:13px}.sfxlib-pass-text{display:grid;gap:2px;min-width:0;flex:1}.sfxlib-pass-text b{font-size:11.5px;color:#f3d3a3;font-weight:700}.sfxlib-pass-text small{font-size:10.5px;line-height:1.4;color:#c9ad87}.sfxlib-renew{flex:none;border:0;border-radius:999px;padding:6px 12px;background:var(--accent);color:#0b1106;font-weight:700;font-size:11.5px;cursor:pointer}.sfxlib-renew:hover{filter:brightness(1.08)}.sfxlib-chips{display:flex;flex-wrap:nowrap;gap:5px;overflow-x:auto;scrollbar-width:none;padding-bottom:1px;mask-image:linear-gradient(90deg,#000 88%,transparent)}.sfxlib-chips::-webkit-scrollbar{display:none}.sfxlib-chip{flex:none;border:1px solid var(--border);background:var(--surface-2);color:var(--text-muted);border-radius:999px;padding:3px 10px;font-size:11px;cursor:pointer;white-space:nowrap}.sfxlib-chip:hover{color:var(--text);border-color:var(--border-strong)}.sfxlib-panel .sfxlib-count{padding:0 2px}.sfxlib-panel .sfxlib-more{border-style:solid;border-color:var(--border);background:var(--surface-2);border-radius:999px}.sfxlib-hint{display:block;margin:0 0 6px;font-size:11px}.tl-plugin-items.kit{grid-template-columns:repeat(auto-fill,minmax(150px,1fr));gap:7px}.tl-plugin-items.kit .tl-plugin-name strong{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:block}.tl-kit-badge{position:absolute;left:4px;top:4px;padding:1px 5px;border-radius:4px;background:#070907d1;font-size:9px;font-weight:800;letter-spacing:.04em;color:#c6f432;line-height:1.5}.tl-kit-badge.model{color:#7fe3ff}.tl-kit-badge.lut{color:#ffc24b}.tl-kit-controls{display:flex;flex-direction:column;gap:7px;padding:9px;margin:4px 0 8px;border:1px solid #2b3a2c;border-radius:10px;background:#0d120d}.tl-kit-controls h6{margin:0;font-size:11.5px;color:#e6e8ec;display:flex;justify-content:space-between;gap:8px;align-items:baseline;line-height:1.5}.tl-kit-controls h6 small{font-weight:500}.tl-kit-control{display:flex;flex-direction:column;gap:4px}.tl-kit-swatches{display:flex;gap:5px;flex-wrap:wrap;padding-left:calc(42% + 8px)}.tl-kit-swatches button{width:18px;height:18px;border-radius:5px;border:1px solid #38423a;padding:0;cursor:pointer}.tl-kit-swatches button.on{outline:2px solid #e6e8ec;outline-offset:1px}.tl-kit-controls>.pill-btn{align-self:flex-start}.tl-kit-chips{display:flex;flex-wrap:wrap;gap:5px;margin:0 0 7px}.tl-kit-chip{border:1px solid #38423a;background:transparent;color:#aab3ac;border-radius:999px;padding:2px 9px;font-size:11.5px;line-height:1.5;cursor:pointer}.tl-kit-chip span{opacity:.6}.tl-kit-chip.on{background:#c6f4321f;color:#c6f432;border-color:#c6f43273}.tl-plugin-subhead{margin:2px 0 0;font-size:11.5px;color:#c8cec9;font-weight:700}.tl-plugin-fact{min-width:0;overflow-wrap:anywhere}.tl-plugin-fact b{font-weight:600;color:#e6e8ec}.tl-plugin-linked{display:flex;flex-direction:column;gap:3px}.tl-plugin-link{align-self:flex-end;display:inline-flex;align-items:center;gap:3px;font-size:10px;line-height:1.5;color:#7fe3ff;border:1px solid #2a4a55;border-radius:999px;padding:0 6px;white-space:nowrap}.tl-plugin-asset select{min-width:0;flex:1}.tl-plugin-asset i{display:inline-grid;place-items:center;font-style:normal;color:#7fe3ff}.tl-plugin-assets{display:flex;flex-direction:column;gap:4px;border-top:1px solid #222a26;padding-top:8px}.tl-plugin-assets ul{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:2px;font-size:11px;color:#aab3ac}.tl-plugin-assets li{display:flex;justify-content:space-between;gap:6px}.tl-plugin-assets b{color:#c8cec9;font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ps-drawer .ad-card{display:flex;flex-direction:column}.ps-drawer .ad-meta{flex:1;display:flex;flex-direction:column}.ps-drawer .ad-actions{margin-top:auto;padding-top:10px}.ps-kit-meta{font-size:12px;color:#c8cec9;line-height:1.5;margin-top:4px;min-height:3em;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}.ps-kit-meta b{color:#c6f432}.ps-items{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:6px;margin:0 0 12px}.ps-items figure{margin:0;display:flex;flex-direction:column;gap:3px;min-width:0}.ps-items img,.ps-items .ph{width:100%;aspect-ratio:16/9;border-radius:6px;display:block;background:#15181d;object-fit:cover}.ps-items .ph{display:grid;place-items:center;color:#7fe3ff}.ps-items figcaption{font-size:10.5px;color:#aab3ac;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ps-lock{display:flex;gap:6px;align-items:center;font-size:12px;color:#aab3ac;padding:7px 10px;border:1px dashed #38423a;border-radius:8px}@media(max-width:720px){.ps-items{grid-template-columns:repeat(3,minmax(0,1fr))}}.ps-items-head{margin:0 0 6px;font-size:12px;color:#c8cec9}.tl-plugin-doc{display:flex;flex-direction:column;gap:6px}.tl-plugin-doc textarea{width:100%;min-height:180px;max-height:360px;box-sizing:border-box;resize:vertical;font:12px/1.5 ui-monospace,SFMono-Regular,Menlo,monospace;color:#dfe6e0;background:#0b0f0a;border:1px solid #2a3328;border-radius:8px;padding:8px}.tl-plugin-hooks{margin-top:10px;padding:8px 10px;border:1px solid #2a3328;border-radius:12px;background:#0f130e;display:flex;flex-direction:column;gap:8px}.tl-plugin-hooks>summary{cursor:pointer;font-size:12px;color:#dfe6e0;display:flex;flex-wrap:wrap;gap:6px;align-items:baseline}.tl-plugin-hooks[open]>summary{margin-bottom:8px}.tl-plugin-hooks>small{display:block;margin-top:6px;line-height:1.45}.tl-plugin-hook-list{list-style:none;margin:0 0 8px;padding:0;display:flex;flex-direction:column;gap:6px}.tl-plugin-hook-list>li{display:flex;flex-wrap:wrap;gap:6px;align-items:center;justify-content:space-between;padding:6px 8px;border-radius:8px;background:#141a13}.tl-plugin-hook-url{display:flex;flex-direction:column;min-width:0;flex:1 1 180px}.tl-plugin-hook-url code{font-size:11.5px;color:#c6f432;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.tl-plugin-hook-url small{font-size:11px}.tl-plugin-hook-actions{display:flex;gap:4px;flex-wrap:wrap}.tl-plugin-hook-secret{flex-basis:100%;margin:2px 0 0;font-size:11.5px;color:#ffd27a;display:flex;flex-wrap:wrap;gap:6px;align-items:center}.tl-plugin-hook-secret code{word-break:break-all;color:#fff;background:#0b0f0a;padding:2px 6px;border-radius:6px}.tl-plugin-hook-add{display:flex;flex-direction:column;gap:6px}.tl-plugin-hook-add input[type=url]{width:100%;box-sizing:border-box}.tl-plugin-hook-events{display:flex;flex-wrap:wrap;gap:10px;font-size:11.5px;color:#aab3ac}.tl-plugin-hook-events label{display:flex;gap:4px;align-items:center}.ps-cmds{border:1px solid rgba(198,244,50,.25);border-radius:12px;background:#0d100c;padding:10px 12px}.ps-cmds-head{display:flex;align-items:center;gap:8px;margin-bottom:8px;font-size:12px}.ps-cmds-head .muted{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ps-cmds pre{margin:0;font:12px/1.6 ui-monospace,SFMono-Regular,Menlo,monospace;color:#e6ffe0;white-space:pre-wrap;word-break:break-all;user-select:all}.ps-drawer .ad-actions{flex-wrap:wrap;align-items:center}.ad-use.ps-use,.ad-use.ps-use:hover:not(:disabled){background:#16210f;color:var(--accent);box-shadow:inset 0 0 0 1.5px var(--accent);opacity:1}.ad-use.ps-use:hover:not(:disabled){background:#1d2c12}.ps-reinstall{background:none;border:0;padding:4px 2px;color:var(--text-dim,#9aa39a);font-size:12.5px;text-decoration:underline;text-underline-offset:3px;cursor:pointer}.ps-reinstall:hover{color:var(--text,#e8ece8)}.ps-installed{margin-top:8px;padding:7px 10px;border-radius:10px;background:#16210f;color:var(--accent);font-size:13px;font-weight:600;animation:ps-pop .35s ease-out}@keyframes ps-pop{0%{transform:scale(.96);opacity:0}to{transform:none;opacity:1}}.tl-plugin-tile.flash{animation:tl-plugin-flash 1.6s ease-out 2}@keyframes tl-plugin-flash{0%{box-shadow:0 0 #c6f432aa}50%{box-shadow:0 0 0 6px #c6f43244}to{box-shadow:0 0 #c6f43200}}
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/thumb-byAKvhQP.js","assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js","assets/trackAnchor-9MnVHe4S.js","assets/shotFxAgent-BDfe73TP.js","assets/vfxBackground-Ddviync5.js"])))=>i.map(i=>d[i]);
2
+ import{_ as $}from"./titleFrameBudget-Cml-MO53.js";import{fA as nt,a as w,iI as at,i9 as vt,j as e,ei as bt,em as kt,am as yt}from"./remote-BJdzzFZg.js";import{u as jt,r as u,t as a}from"./api-QBI5GJTZ.js";import{u as F}from"./store-2zneEhhu.js";import{ag as Nt,ah as D,ai as wt}from"./main-CVRIuDW2.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";const _t=i=>{let h=0;for(let k=0;k<i.length;k++)h=Math.imul(h,31)+i.charCodeAt(k)|0;return String(h>>>0)},st=i=>_t(JSON.stringify([i.items.filter(h=>h.kind==="fx"||h.trackAnchor||h.kind==="person"),i.shots.map(h=>[h.duration,h.fxTiming,h.objectKeys,h.position,h.target,h.lens,h.cameraKeys]),i.plate]));function St({entry:i}){const h=u.useRef(null),[k,B]=u.useState(!1);return u.useEffect(()=>{const y=h.current,A=y?.getContext("2d");if(!y||!A)return;let x=0,E=!1;return $(async()=>{const{drawThumb:j,thumbRestTime:L,thumbLoopLength:N}=await import("./thumb-byAKvhQP.js").then(I=>I.e);return{drawThumb:j,thumbRestTime:L,thumbLoopLength:N}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(({drawThumb:j,thumbRestTime:L,thumbLoopLength:N})=>{if(E)return;if(!k){j(A,i,L(i),y.width,y.height);return}const I=performance.now(),P=N(i),O=()=>{j(A,i,(performance.now()-I)/1e3%P,y.width,y.height),x=requestAnimationFrame(O)};x=requestAnimationFrame(O)}),()=>{E=!0,cancelAnimationFrame(x)}},[i,k]),e.jsx("canvas",{ref:h,width:128,height:72,"aria-hidden":"true",onMouseEnter:()=>B(!0),onMouseLeave:()=>B(!1)})}function Wt({clip:i,locked:h,ensureScene:k,openShot:B,time:y,onBegin:A}){jt();const x=F(t=>t.toast),[,E]=u.useState(0),[j,L]=u.useState(nt[0].id),[N,I]=u.useState(""),[P,O]=u.useState(!1),[c,K]=u.useState(null),[it,U]=u.useState(0),[ot,X]=u.useState({}),[G,rt]=u.useState(""),d=i.vfxShot?.shotNodeId&&w()?.getNode(i.vfxShot.shotNodeId)?i.vfxShot.shotNodeId:null,J=d?w()?.getNode(d):null,f=J?.data?.shotScene??null,R=f?f.items.filter(t=>t.kind==="fx"):[],T=f?.items.find(t=>t.kind==="person"&&!t.hidden)??null,lt=f?.shots.find(t=>t.id===f.activeShot),q=u.useMemo(()=>Nt(i),[i]),[v,Q]=u.useState(null),W=D(t=>t.want),ct=D(t=>t.ask),V=D(t=>t.got),z=W?.kind==="shot3d"&&W.clipId===i.id;u.useEffect(()=>{if(V?.kind!=="shot3d"||V.clipId!==i.id)return;D.setState({got:null});const t=i.crop??{left:0,right:0,top:0,bottom:0};Q({u:t.left+V.media[0]*(1-t.left-t.right),v:t.top+V.media[1]*(1-t.top-t.bottom),t:Z()})},[V]);const ht=F(t=>t.clips.filter(s=>s.vfx?.source===i.id).length),Y=F(t=>t.clips.some(s=>s.vfxFinish===i.id)),H=!!f&&R.length>0&&J?.data?.vfxRenderHash!==st(f),dt=u.useMemo(()=>{const t=at(N).trim();return vt.filter(s=>t?at(`${s.name} ${s.desc} ${s.keywords} ${s.id}`).includes(t):s.category===j)},[j,N]),_=async(t,s,o)=>{const r=w()?.getNode(t),p=r?.data?.shotScene;if(!p)throw new Error(a("Cảnh VFX không còn trên Canvas"));let g=structuredClone(p);const{runTool:n}=await $(async()=>{const{runTool:m}=await import("./remote-BJdzzFZg.js").then(b=>b.js);return{runTool:m}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10])),l=await n(s,o,{getStage:()=>g,setStage:m=>{g=m(g)},engine:()=>null,timelineClip:m=>F.getState().clips.find(b=>b.id===m)});if(l.ok===!1)throw new Error(l.error||s);return w()?.updateNodeData(t,{shotScene:g}),E(m=>m+1),l},M=async(t,s)=>{if(h){x(a("Track đã khóa"),"error");return}K(t);try{await s()}catch(o){x(o.message,"error")}finally{K(null)}};function Z(){return Math.round(Math.max(0,Math.min(Math.max(0,i.duration-.2),(y??i.start)-i.start))*100)/100}const mt=t=>M(a("Đang thêm hiệu ứng"),async()=>{const s=d??k(i);if(!s)throw new Error(a("Không tạo được cảnh VFX"));const o=w()?.getNode(s)?.data?.shotScene,r=o.items.find(b=>b.kind==="person"&&!b.hidden),p=t.attach==="body"||t.attach==="hand"||t.attach==="gun",g=t.attach==="path"||t.attach==="sky",n=r?.position??[0,0,0],l=Z();let m;if(v){const{scenePoint:b}=await $(async()=>{const{scenePoint:xt}=await import("./trackAnchor-9MnVHe4S.js");return{scenePoint:xt}},__vite__mapDeps([11,1,2,3,4,5,6,7,8,9,10,12])),C=b(o,v.t,v.u,v.v,!(t.attach==="hand"||t.attach==="gun"||t.attach==="free"));m=g?{from:r?`${r.name}.hand_right`:[C[0]-3,C[1]+1.2,C[2]],to:C}:{at:C}}else m={...r&&p?{attach_to:r.name,...t.attach!=="body"?{hand:"right"}:{}}:{},...r&&g?{from:`${r.name}.hand_right`,to:[n[0]+3,n[1]+1.2,n[2]]}:{}};await _(s,"add_effect",{effect:t.id,vfx_layer:t.attach==="body"||t.attach==="ground"?"behind":"front",...l>0?{start:l}:{},...m}),O(!1)}),tt=t=>{if(h){x(a("Track đã khóa"),"error");return}const s=F.getState(),o=yt(s.clips,[{op:"finishVfx",clipId:i.id,...t?{}:{booleanValue:!1}}],[],s.timelineTracks);if(o.errors.length){x(a(o.errors[0].replace(/^finishVfx: /,"")),"error");return}A?.(),F.setState({clips:o.clips}),x(t?a("Đã hoàn thiện: phát sáng, màu theo phim, ánh sáng hắt lên người, hạt phim chung."):a("Đã bỏ phần hoàn thiện VFX."),"ok")},S=(t,s)=>M(a("Đang cập nhật"),()=>_(d,"update_effect",{name:t.name,...s})),et=t=>{const s=f?.items.find(r=>r.trackAnchor?.effect===t.id);if(s)return{kind:"track",source:s.trackAnchor.source};const o=t.fx?.attach;return o&&T&&o.to===T.id?o.hand?{kind:"hand",side:o.hand==="L"?"left":"right"}:{kind:"body"}:{kind:"none"}},ut=(t,s)=>M(a("Đang gắn hiệu ứng"),async()=>{if(et(t).kind==="track"&&await _(d,"follow_track",{name:t.name,stop:!0}),s==="none"){t.fx?.attach&&await _(d,"update_effect",{name:t.name,attach_to:"none"});return}if(s==="body"||s==="hand-right"||s==="hand-left"){if(!T)throw new Error(a("Cảnh VFX không có người đứng thế"));await _(d,"update_effect",{name:t.name,attach_to:T.name,hand:s==="body"?"none":s==="hand-left"?"left":"right"});return}const r=wt(s);await _(d,"follow_track",{name:t.name,source:r.source,...r.object?{object:r.object}:{},...r.source==="hand"?{side:r.hand,point:r.point}:{}})}),pt=()=>M(a("Đang đọc người trong video"),async()=>{const{withBackgroundScene:t}=await $(async()=>{const{withBackgroundScene:r}=await import("./vfxBackground-Ddviync5.js");return{withBackgroundScene:r}},__vite__mapDeps([13,3,2,1,4,5,6,7,8,9,10])),s=Number(G),o=await t(d,r=>r.run("follow_plate",s>=8&&s<=300?{lens_mm:s}:{}),{timeoutMs:6e5});if(o.ok===!1)throw new Error(o.error||"follow_plate");E(r=>r+1),x(o.camera?a("Đã khớp camera ({0} mm, cao {1} m, nghiêng {2}°) và cho người đứng thế bám theo người trong video",[o.camera.lens_mm,o.camera.height_m.toFixed(2),o.camera.tilt_deg.toFixed(1)]):a("Người đứng thế đã bám theo người trong video"),"info")}),gt=()=>M(a("Đang render hiệu ứng"),async()=>{const{withBackgroundScene:t}=await $(async()=>{const{withBackgroundScene:n}=await import("./vfxBackground-Ddviync5.js");return{withBackgroundScene:n}},__vite__mapDeps([13,3,2,1,4,5,6,7,8,9,10])),{shotFps:s}=await $(async()=>{const{shotFps:n}=await import("./remote-BJdzzFZg.js").then(l=>l.jm);return{shotFps:n}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10]));U(0);const o=w()?.getNode(d)?.data?.shotScene,r=o.shots.find(n=>n.id===o.activeShot),p=await t(d,n=>n.exportVfx({fps:s(r),height:720,vfxAlpha:"auto"},U),{timeoutMs:12e4});w()?.updateNodeData(d,{vfxRenderHash:st(w()?.getNode(d)?.data?.shotScene)}),E(n=>n+1);const g=p.passes.filter(n=>n.alpha).length;x(p.placed?g?a("Đã render {0} lớp hiệu ứng lên video ({1} lớp có kênh trong suốt cho khói / bụi)",[p.passes.length,g]):a("Đã render {0} lớp hiệu ứng lên video",[p.passes.length]):a("Đã render; video hiệu ứng nằm trên Canvas"),"info")}),ft=t=>t.kind==="none"?"none":t.kind==="body"?"body":t.kind==="hand"?`hand-${t.side}`:q.find(s=>s.value===t.source)?.value??q.find(s=>s.value.split(":")[0]===t.source.split(":")[0])?.value??t.source;return e.jsxs("div",{className:"tl-shotfx",children:[e.jsxs("div",{className:"tl-3d-row",children:[e.jsx("button",{className:"pill-btn",disabled:!!c,onClick:()=>O(t=>!t),children:P?a("Đóng kho hiệu ứng"):a("✦ Thêm hiệu ứng 3D")}),d&&e.jsx("button",{className:"pill-btn",disabled:!!c,onClick:()=>B(i),children:a("Mở trong 3D Shot")})]}),e.jsxs("div",{className:"tl-vfxf-place",children:[e.jsxs("button",{type:"button",className:`tl-vfxf-pick${z?" on":""}`,"aria-pressed":z,title:a("Chọn điểm trên Monitor: hiệu ứng mới đặt đúng chỗ đó, từ playhead"),onClick:()=>ct("shot3d",i.id),children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"16",height:"16",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"12",r:"7"}),e.jsx("circle",{cx:"12",cy:"12",r:"2",fill:"currentColor"}),e.jsx("path",{d:"M12 2v3M12 19v3M2 12h3M19 12h3"})]}),e.jsx("span",{className:"txt",children:v?a("Điểm đặt: {0}% · {1}% (giây {2})",[Math.round(v.u*100),Math.round(v.v*100),v.t.toFixed(1)]):a("Chọn điểm")})]}),v&&e.jsx("button",{type:"button",className:"tl-vfxf-clear","aria-label":a("Bỏ điểm (gắn vào người như cũ)"),title:a("Bỏ điểm (gắn vào người như cũ)"),onClick:()=>Q(null),children:"×"})]}),P&&e.jsxs("div",{className:"tl-shotfx-gallery",children:[e.jsx("input",{className:"tl-shotfx-search",placeholder:a("Tìm hiệu ứng (aura, sét, khói…)"),value:N,onChange:t=>I(t.target.value)}),!N&&e.jsx("div",{className:"tl-shotfx-cats",children:nt.map(t=>e.jsx("button",{className:`tl-shotfx-cat${t.id===j?" on":""}`,onClick:()=>L(t.id),children:a(t.name)},t.id))}),e.jsx("div",{className:"tl-shotfx-grid",children:dt.slice(0,60).map(t=>e.jsxs("button",{className:"tl-shotfx-card",title:a(t.desc),disabled:!!c,onClick:()=>void mt(t),children:[e.jsx(St,{entry:t}),e.jsx("span",{children:a(t.name)})]},t.id))})]}),R.length>0&&e.jsx("div",{className:"tl-shotfx-list",children:R.map(t=>{const s=bt(t,lt),o=et(t),r=kt[t.fx.preset]?.params??[],p=(n,l)=>{X(m=>{const{[`${t.id}:${n}`]:b,...C}=m;return C}),S(t,n==="intensity"?{intensity:l}:{params:{[n]:l}})},g=(n,l)=>ot[`${t.id}:${n}`]??l;return e.jsxs("div",{className:"tl-shotfx-item",children:[e.jsxs("div",{className:"tl-shotfx-head",children:[e.jsx("input",{type:"color",value:t.color,disabled:!!c,onChange:n=>void S(t,{color:n.target.value}),title:a("Màu")}),e.jsx("b",{children:t.name}),e.jsxs("select",{value:t.vfxLayer??"behind",disabled:!!c,onChange:n=>void S(t,{vfx_layer:n.target.value}),children:[e.jsx("option",{value:"behind",children:a("Sau người")}),e.jsx("option",{value:"front",children:a("Trước người")})]}),e.jsx("button",{className:"tl-shotfx-del",disabled:!!c,title:a("Xoá hiệu ứng"),onClick:()=>void M(a("Đang xoá"),()=>_(d,"remove_effect",{name:t.name})),children:"✕"})]}),e.jsxs("label",{className:"tl-shotfx-field",children:[e.jsx("span",{children:a("Bám theo")}),e.jsxs("select",{value:ft(o),disabled:!!c,onChange:n=>void ut(t,n.target.value),children:[e.jsx("option",{value:"none",children:a("Đứng yên trong cảnh")}),T&&e.jsxs(e.Fragment,{children:[e.jsx("option",{value:"body",children:a("Người (thân)")}),e.jsx("option",{value:"hand-right",children:a("Người · tay phải")}),e.jsx("option",{value:"hand-left",children:a("Người · tay trái")})]}),q.map(n=>e.jsx("option",{value:n.value,children:n.label},n.value))]})]}),e.jsxs("div",{className:"tl-shotfx-time",children:[e.jsxs("label",{children:[a("Bắt đầu")," ",e.jsx("input",{type:"number",min:0,step:.1,value:+s.start.toFixed(2),disabled:!!c,onChange:n=>void S(t,{start:Math.max(0,Number(n.target.value)||0)})})]}),e.jsxs("label",{children:[a("Dài")," ",e.jsx("input",{type:"number",min:.2,step:.1,value:+s.duration.toFixed(2),disabled:!!c,onChange:n=>void S(t,{duration:Math.max(.2,Number(n.target.value)||.2)})})]}),e.jsxs("label",{children:[e.jsx("input",{type:"checkbox",checked:s.loop,disabled:!!c,onChange:n=>void S(t,{loop:n.target.checked})})," ",a("Lặp")]})]}),e.jsxs("label",{className:"tl-shotfx-field",children:[e.jsx("span",{children:a("Độ mạnh")}),e.jsx("input",{type:"range",min:.1,max:3,step:.05,value:g("intensity",t.fx.intensity),disabled:!!c,onChange:n=>X(l=>({...l,[`${t.id}:intensity`]:Number(n.target.value)})),onMouseUp:n=>p("intensity",Number(n.target.value)),onKeyUp:n=>p("intensity",Number(n.target.value))})]}),r.map(n=>n.type==="enum"?e.jsxs("label",{className:"tl-shotfx-field",children:[e.jsx("span",{children:a(n.label??n.key)}),e.jsx("select",{value:String(t.fx.params[n.key]??n.def),disabled:!!c,onChange:l=>void S(t,{params:{[n.key]:l.target.value}}),children:(n.options??[]).map(l=>e.jsx("option",{value:l,children:l},l))})]},n.key):e.jsxs("label",{className:"tl-shotfx-field",children:[e.jsx("span",{children:a(n.label??n.key)}),e.jsx("input",{type:"range",min:n.min,max:n.max,step:((n.max??1)-(n.min??0))/100,value:g(n.key,Number(t.fx.params[n.key]??n.def)),disabled:!!c,onChange:l=>X(m=>({...m,[`${t.id}:${n.key}`]:Number(l.target.value)})),onMouseUp:l=>p(n.key,Number(l.target.value)),onKeyUp:l=>p(n.key,Number(l.target.value))})]},n.key))]},t.id)})}),d&&T&&R.length>0&&e.jsxs("div",{className:"tl-3d-row",children:[e.jsx("button",{className:"pill-btn",disabled:!!c,onClick:()=>void pt(),title:a("Đọc tư thế người trong video (miễn phí, trong trình duyệt): hiệu ứng gắn vào người sẽ chạy theo họ"),children:a("Bám người thật (tư thế)")}),e.jsx("input",{className:"tl-shotfx-lens",type:"number",min:8,max:300,step:1,value:G,disabled:!!c,placeholder:a("Ống kính mm"),title:a("Tiêu cự ống kính đã quay (mm, khổ phim 36 mm). Để trống: tự giả định 28 mm — ống kính chính của điện thoại"),onChange:t=>rt(t.target.value)})]}),f?.plate?.match&&e.jsx("p",{className:"tl-vfx-hint",children:a("Camera đã khớp với video: {0} mm · cao {1} m · nghiêng {2}°",[f.plate.match.lens,f.plate.match.height.toFixed(2),f.plate.match.tilt.toFixed(1)])}),d&&R.length>0&&e.jsxs("div",{className:"tl-3d-row",children:[e.jsx("button",{className:`pill-btn${H?" on":""}`,disabled:!!c,onClick:()=>void gt(),children:c===a("Đang render hiệu ứng")?`${a("Đang render")} ${it}%`:H?a("▶ Render hiệu ứng lên video"):a("Render lại")}),H&&e.jsx("span",{className:"tl-shotfx-stale",children:a("Đã sửa, cần render lại")})]}),ht>0&&e.jsxs("div",{className:"tl-3d-row",children:[e.jsx("button",{className:"pill-btn",disabled:!!c,onClick:()=>tt(!0),children:Y?a("✨ Làm lại phần hoàn thiện"):a("✨ Hoàn thiện giống thật")}),Y&&e.jsx("button",{className:"pill-btn",disabled:!!c,onClick:()=>tt(!1),children:a("Bỏ hoàn thiện")})]}),c&&c!==a("Đang render hiệu ứng")&&e.jsxs("p",{className:"tl-vfx-hint",children:[c,"…"]})]})}export{Wt as default,st as vfxSceneHash};
@@ -0,0 +1 @@
1
+ import{j as c}from"./remote-BJdzzFZg.js";import{r as p}from"./api-QBI5GJTZ.js";import{gR as g}from"./titleFrameBudget-Cml-MO53.js";import{d}from"./main-CVRIuDW2.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";const f=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"];function B(){const m=p.useRef(null),[e,l]=p.useState(null);return p.useEffect(()=>{const r=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),n=t=>{if(!f.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;let i;try{i=g(t.data.transition)}catch(o){r(t,{type:"clipoox-transition-error",id:"id"in t.data?t.data.id:null,error:o.message});return}if(t.data.type==="clipoox-transition-play"){l(i);return}if(t.data.type==="clipoox-transition-thumb"){const o=Object.assign(document.createElement("canvas"),{width:640,height:360}),s=o.getContext("2d");d(s,i,Number.isFinite(t.data.p)?Number(t.data.p):.5,640,360),r(t,{type:"clipoox-transition-thumb",id:t.data.id,png:o.toDataURL("image/png")})}},a=t=>n(t);return window.addEventListener("message",a),window.parent?.postMessage({type:"clipoox-transition-ready"},"*"),()=>window.removeEventListener("message",a)},[]),p.useEffect(()=>{const r=m.current,n=r?.getContext("2d");if(!r||!n||!e)return;let a=0;const t=performance.now(),i=e.duration*1e3,o=600,s=u=>{const h=(u-t)%(i+2*o)-o;d(n,e,Math.max(0,Math.min(1,h/i)),r.width,r.height),a=requestAnimationFrame(s)};return a=requestAnimationFrame(s),()=>cancelAnimationFrame(a)},[e]),c.jsx("div",{style:{margin:0,background:"#000",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:c.jsx("canvas",{ref:m,width:1280,height:720,style:{width:"100%",height:"100%",objectFit:"contain"},"aria-label":"Transition preview"})})}export{B as default};
@@ -1,3 +1,3 @@
1
- import{j as u,a as I}from"./remote-sTZauTqM.js";import{u as ut,r as h,t as m,c as ht}from"./api-BsKbf3l3.js";import{u as pt}from"./store-BSSbvpzr.js";import{u as ft,W as U,a as dt}from"./main-M1vRa-gd.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./titleFrameBudget-3MFHWIT6.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const tt=(i,p,c,o,f,s)=>{const a=f-c,r=s-o,d=a*a+r*r,v=d?Math.max(0,Math.min(1,((i-c)*a+(p-o)*r)/d)):0;return Math.hypot(i-(c+v*a),p-(o+v*r))};function R(i){if(i.type==="pen"){const s=i.points||[];let a=1/0,r=1/0,d=-1/0,v=-1/0;for(let x=0;x<s.length;x+=2)a=Math.min(a,s[x]),r=Math.min(r,s[x+1]),d=Math.max(d,s[x]),v=Math.max(v,s[x+1]);return s.length?{x:a,y:r,w:d-a,h:v-r}:{x:0,y:0,w:0,h:0}}if(i.type==="text"){const s=String(i.text||"").split(`
2
- `),a=i.size||36;return{x:i.x||0,y:i.y||0,w:Math.max(...s.map(r=>r.length),1)*a*.6,h:s.length*a*1.25}}const p=i.x||0,c=i.y||0,o=i.w||0,f=i.h||0;return{x:Math.min(p,p+o),y:Math.min(c,c+f),w:Math.abs(o),h:Math.abs(f)}}function H(i,p,c,o=8){for(let f=i.length-1;f>=0;f--){const s=i[f],a=(s.width||2)/2+o;if(s.type==="pen"){const r=s.points||[];for(let d=0;d+3<r.length;d+=2)if(tt(p,c,r[d],r[d+1],r[d+2],r[d+3])<=a)return s;if(r.length===2&&Math.hypot(p-r[0],c-r[1])<=a)return s}else if(s.type==="arrow"){if(tt(p,c,s.x||0,s.y||0,(s.x||0)+(s.w||0),(s.y||0)+(s.h||0))<=a)return s}else{const r=R(s);if(p>=r.x-a&&p<=r.x+r.w+a&&c>=r.y-a&&c<=r.y+r.h+a)return s}}return null}function yt(i,p,c){return i.type==="pen"?{...i,points:(i.points||[]).map((o,f)=>o+(f%2?c:p))}:{...i,x:(i.x||0)+p,y:(i.y||0)+c}}function et(i){if(!Array.isArray(i))return[];const p=[];for(const c of i.slice(0,2e3)){if(!c||typeof c!="object"||!["pen","arrow","rect","ellipse","text"].includes(c.type))continue;const o=c;p.push({id:String(o.id||Math.random().toString(36).slice(2)),type:o.type,color:/^#[0-9a-fA-F]{3,8}$/.test(String(o.color))?o.color:"#111111",width:Math.max(1,Math.min(48,Number(o.width)||4)),...o.type==="pen"?{points:(Array.isArray(o.points)?o.points:[]).slice(0,4e3).map(f=>Math.round(Number(f)||0))}:{},...o.type!=="pen"?{x:Math.round(Number(o.x)||0),y:Math.round(Number(o.y)||0)}:{},...o.type==="rect"||o.type==="ellipse"||o.type==="arrow"?{w:Math.round(Number(o.w)||0),h:Math.round(Number(o.h)||0)}:{},...o.type==="text"?{text:String(o.text||"").slice(0,2e3),size:Math.max(10,Math.min(200,Number(o.size)||36))}:{}})}return p}const mt=["#ffffff","#111111","#e5484d","#f5a524","#f7ce46","#3fb950","#4c8dff","#7c66ff","#ef5da8","#8a93a6"],q=()=>Math.random().toString(36).slice(2,10);function Ft({nodeId:i}){ut();const p=pt(t=>t.toast),c=ft(t=>t.close),o=I()?.getNode(i),[f,s]=h.useState(()=>o?.data?.wbAspect in U?(o?.data).wbAspect:"16:9"),{w:a,h:r}=U[f],[d,v]=h.useState(()=>et(o?.data?.wbShapes)),[x,nt]=h.useState("pen"),[j,J]=h.useState("#111111"),[C,rt]=h.useState(6),[T,P]=h.useState(null),[M,_]=h.useState(null),[z,O]=h.useState(!1),A=h.useRef([]),B=h.useRef([]),E=h.useRef(null),S=h.useRef(null),L=h.useRef(null),X=h.useRef(null),[,D]=h.useState(0),w=h.useRef(d);w.current=d;const N=t=>{A.current=[...A.current.slice(-49),w.current],B.current=[],v(t)},Y=()=>{const t=A.current.pop();t&&(B.current.push(w.current),v(t),P(null))},G=()=>{const t=B.current.pop();t&&(A.current.push(w.current),v(t),P(null))},K=h.useCallback(()=>{I()?.updateNodeData(i,{wbShapes:et(w.current),wbAspect:f})},[i,f]),$=h.useCallback(()=>{K(),c()},[K,c]);h.useEffect(()=>{const t=e=>{M||(e.key==="Escape"&&$(),(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="z"&&(e.preventDefault(),e.shiftKey?G():Y()),(e.key==="Delete"||e.key==="Backspace")&&T&&N(w.current.filter(n=>n.id!==T)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[T,M,$]);const Q=t=>{const e=L.current.getBoundingClientRect();return{x:Math.round((t.clientX-e.left)*(a/e.width)),y:Math.round((t.clientY-e.top)*(r/e.height))}},ot=t=>{const e=Q(t);if(M){W();return}if(x==="text"){t.preventDefault(),_({x:e.x,y:e.y,value:""});return}if(t.target.setPointerCapture?.(t.pointerId),x==="select"){const n=H(w.current,e.x,e.y);P(n?.id||null),n&&(S.current={id:n.id,lx:e.x,ly:e.y});return}if(x==="eraser"){const n=H(w.current,e.x,e.y);n&&N(w.current.filter(l=>l.id!==n.id)),S.current={id:"__erase__",lx:e.x,ly:e.y};return}E.current=x==="pen"?{id:q(),type:"pen",color:j,width:C,points:[e.x,e.y]}:{id:q(),type:x,color:j,width:C,x:e.x,y:e.y,w:0,h:0},D(n=>n+1)},it=t=>{if(t.buttons!==1)return;const e=Q(t);if(S.current){if(S.current.id==="__erase__"){const l=H(w.current,e.x,e.y);l&&N(w.current.filter(y=>y.id!==l.id))}else{const{id:l,lx:y,ly:g}=S.current;S.current={id:l,lx:e.x,ly:e.y},v(k=>k.map(b=>b.id===l?yt(b,e.x-y,e.y-g):b))}return}const n=E.current;if(n)if(n.type==="pen"){const l=n.points,y=l.length;Math.hypot(e.x-l[y-2],e.y-l[y-1])>=3&&y<4e3&&(l.push(e.x,e.y),D(g=>g+1))}else n.w=e.x-(n.x||0),n.h=e.y-(n.y||0),D(l=>l+1)},V=()=>{if(S.current){S.current.id!=="__erase__"&&N(w.current),S.current=null;return}const t=E.current;if(E.current=null,!t)return;const e=R(t);if(t.type!=="pen"&&e.w<3&&e.h<3){D(n=>n+1);return}N([...w.current,t])},Z=dt(()=>W()),W=()=>{const t=M;_(null),t&&t.value.trim()&&N([...w.current,{id:q(),type:"text",x:t.x,y:t.y,text:t.value.slice(0,2e3),color:j,width:C,size:Math.round(C*4+16)}])},F=(t,e)=>{if(t.strokeStyle=e.color,t.fillStyle=e.color,t.lineWidth=e.width,t.lineCap="round",t.lineJoin="round",e.type==="pen"){const n=e.points||[];if(n.length<2)return;t.beginPath(),t.moveTo(n[0],n[1]);for(let l=2;l<n.length;l+=2)t.lineTo(n[l],n[l+1]);n.length===2&&t.lineTo(n[0]+.1,n[1]),t.stroke()}else if(e.type==="arrow"){const n=e.x||0,l=e.y||0,y=n+(e.w||0),g=l+(e.h||0);t.beginPath(),t.moveTo(n,l),t.lineTo(y,g),t.stroke();const k=Math.atan2(g-l,y-n),b=Math.max(14,e.width*3.2);t.beginPath(),t.moveTo(y,g),t.lineTo(y-b*Math.cos(k-.45),g-b*Math.sin(k-.45)),t.moveTo(y,g),t.lineTo(y-b*Math.cos(k+.45),g-b*Math.sin(k+.45)),t.stroke()}else if(e.type==="rect"){const n=R(e);t.strokeRect(n.x,n.y,n.w,n.h)}else if(e.type==="ellipse"){const n=R(e);t.beginPath(),t.ellipse(n.x+n.w/2,n.y+n.h/2,Math.max(1,n.w/2),Math.max(1,n.h/2),0,0,Math.PI*2),t.stroke()}else if(e.type==="text"){const n=e.size||36;t.font=`600 ${n}px system-ui, -apple-system, sans-serif`,t.textBaseline="top",String(e.text||"").split(`
3
- `).forEach((l,y)=>t.fillText(l,e.x||0,(e.y||0)+y*n*1.25))}},st=()=>{const t=L.current?.getContext("2d");if(t){t.fillStyle="#ffffff",t.fillRect(0,0,a,r);for(const e of d)F(t,e);if(E.current&&F(t,E.current),T){const e=d.find(n=>n.id===T);if(e){const n=R(e);t.save(),t.strokeStyle="#4c8dff",t.lineWidth=2,t.setLineDash([8,6]),t.strokeRect(n.x-8,n.y-8,n.w+16,n.h+16),t.restore()}}}};h.useEffect(st);const at=async()=>{if(!z){W(),O(!0);try{K();const t=document.createElement("canvas");t.width=a,t.height=r;const e=t.getContext("2d");e.fillStyle="#ffffff",e.fillRect(0,0,a,r);for(const b of w.current)F(e,b);const n=await new Promise(b=>t.toBlob(b,"image/png"));if(!n)throw Error("Canvas export failed");const{url:l,gcsUri:y}=await ht(new File([n],"whiteboard.png",{type:"image/png"}),void 0,"image"),g=I(),k=g?.getNode(i)?.position||g?.centerFlowPos()||{x:0,y:0};g?.addNode("image",{url:l,gcsUri:y,label:"Whiteboard sketch"},{x:k.x+420,y:k.y},{sourceIds:[i]}),p(m("Đã xuất bản vẽ thành node Image — dùng làm ảnh tham chiếu được ngay."),"ok"),c()}catch(t){p(t.message,"error")}finally{O(!1)}}},lt=h.useMemo(()=>{const t=X.current?.getBoundingClientRect();return t?t.width/a:.5},[M,f]),ct=[["select","⬚",m("Chọn / di chuyển")],["pen","✎",m("Bút vẽ")],["arrow","↗",m("Mũi tên")],["rect","▭",m("Khung chữ nhật")],["ellipse","◯",m("Elip")],["eraser","⌫",m("Tẩy")],["text","T",m("Chữ")]];return u.jsxs("div",{className:"wb-backdrop",children:[u.jsxs("header",{children:[u.jsx("button",{onClick:$,title:m("Lưu và quay lại Canvas"),children:"↩"}),u.jsx("span",{children:m("Whiteboard — vẽ nháp ý tưởng, Export thành ảnh tham chiếu")}),u.jsx("select",{value:f,onChange:t=>s(t.target.value),"aria-label":m("Tỷ lệ khung"),children:Object.keys(U).map(t=>u.jsx("option",{value:t,children:t},t))}),u.jsx("button",{className:"primary",disabled:z,onClick:at,children:z?m("Đang xuất…"):"Export"})]}),u.jsx("div",{className:"wb-stage",children:u.jsxs("div",{className:"wb-frame",ref:X,style:{aspectRatio:`${a} / ${r}`},children:[u.jsx("canvas",{ref:L,width:a,height:r,style:{cursor:x==="select"?"default":x==="text"?"text":"crosshair"},onPointerDown:ot,onPointerMove:it,onPointerUp:V,onPointerLeave:V}),M&&u.jsx("textarea",{className:"wb-textedit",rows:2,ref:t=>t?.focus({preventScroll:!0}),onPointerDown:t=>t.stopPropagation(),style:{left:`${M.x/a*100}%`,top:`${M.y/r*100}%`,color:j,fontSize:Math.max(12,Math.round((C*4+16)*lt))},value:M.value,placeholder:m("Nhập chữ… Enter để đặt"),onChange:t=>_(e=>e&&{...e,value:t.target.value}),onKeyDown:t=>{Z.onKeyDown(t)||t.key==="Escape"&&_(null)},onCompositionEnd:Z.onCompositionEnd,onBlur:W})]})}),u.jsxs("footer",{children:[u.jsxs("div",{className:"wb-tools",children:[ct.map(([t,e,n])=>u.jsx("button",{className:x===t?"on":"",title:n,onClick:()=>{nt(t),P(null)},children:e},t)),u.jsx("span",{className:"wb-sep"}),u.jsx("button",{title:m("Hoàn tác"),onClick:Y,children:"↶"}),u.jsx("button",{title:m("Làm lại"),onClick:G,children:"↷"})]}),u.jsxs("div",{className:"wb-colors",children:[mt.map(t=>u.jsx("button",{className:`wb-swatch ${j===t?"on":""}`,style:{background:t},onClick:()=>J(t),"aria-label":t},t)),u.jsx("input",{type:"color",value:j,title:m("Màu tùy chọn"),onChange:t=>J(t.target.value)})]}),u.jsxs("label",{className:"wb-width",title:m("Độ dày nét / cỡ chữ"),children:[u.jsx("svg",{viewBox:"0 0 20 20",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:u.jsx("path",{d:"M3 15c3-6 6-9 14-11"})}),u.jsx("input",{type:"range",min:2,max:24,value:C,onChange:t=>rt(Number(t.target.value))})]})]})]})}export{Ft as default};
1
+ import{j as u,a as I}from"./remote-BJdzzFZg.js";import{u as ut,r as h,t as m,c as ht}from"./api-QBI5GJTZ.js";import{u as pt}from"./store-2zneEhhu.js";import{u as ft,W as U,a as dt}from"./main-CVRIuDW2.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DIi45swK.js";import"./titleFrameBudget-Cml-MO53.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";const tt=(i,p,c,o,f,s)=>{const a=f-c,r=s-o,d=a*a+r*r,v=d?Math.max(0,Math.min(1,((i-c)*a+(p-o)*r)/d)):0;return Math.hypot(i-(c+v*a),p-(o+v*r))};function R(i){if(i.type==="pen"){const s=i.points||[];let a=1/0,r=1/0,d=-1/0,v=-1/0;for(let x=0;x<s.length;x+=2)a=Math.min(a,s[x]),r=Math.min(r,s[x+1]),d=Math.max(d,s[x]),v=Math.max(v,s[x+1]);return s.length?{x:a,y:r,w:d-a,h:v-r}:{x:0,y:0,w:0,h:0}}if(i.type==="text"){const s=String(i.text||"").split(`
2
+ `),a=i.size||36;return{x:i.x||0,y:i.y||0,w:Math.max(...s.map(r=>r.length),1)*a*.6,h:s.length*a*1.25}}const p=i.x||0,c=i.y||0,o=i.w||0,f=i.h||0;return{x:Math.min(p,p+o),y:Math.min(c,c+f),w:Math.abs(o),h:Math.abs(f)}}function H(i,p,c,o=8){for(let f=i.length-1;f>=0;f--){const s=i[f],a=(s.width||2)/2+o;if(s.type==="pen"){const r=s.points||[];for(let d=0;d+3<r.length;d+=2)if(tt(p,c,r[d],r[d+1],r[d+2],r[d+3])<=a)return s;if(r.length===2&&Math.hypot(p-r[0],c-r[1])<=a)return s}else if(s.type==="arrow"){if(tt(p,c,s.x||0,s.y||0,(s.x||0)+(s.w||0),(s.y||0)+(s.h||0))<=a)return s}else{const r=R(s);if(p>=r.x-a&&p<=r.x+r.w+a&&c>=r.y-a&&c<=r.y+r.h+a)return s}}return null}function yt(i,p,c){return i.type==="pen"?{...i,points:(i.points||[]).map((o,f)=>o+(f%2?c:p))}:{...i,x:(i.x||0)+p,y:(i.y||0)+c}}function et(i){if(!Array.isArray(i))return[];const p=[];for(const c of i.slice(0,2e3)){if(!c||typeof c!="object"||!["pen","arrow","rect","ellipse","text"].includes(c.type))continue;const o=c;p.push({id:String(o.id||Math.random().toString(36).slice(2)),type:o.type,color:/^#[0-9a-fA-F]{3,8}$/.test(String(o.color))?o.color:"#111111",width:Math.max(1,Math.min(48,Number(o.width)||4)),...o.type==="pen"?{points:(Array.isArray(o.points)?o.points:[]).slice(0,4e3).map(f=>Math.round(Number(f)||0))}:{},...o.type!=="pen"?{x:Math.round(Number(o.x)||0),y:Math.round(Number(o.y)||0)}:{},...o.type==="rect"||o.type==="ellipse"||o.type==="arrow"?{w:Math.round(Number(o.w)||0),h:Math.round(Number(o.h)||0)}:{},...o.type==="text"?{text:String(o.text||"").slice(0,2e3),size:Math.max(10,Math.min(200,Number(o.size)||36))}:{}})}return p}const mt=["#ffffff","#111111","#e5484d","#f5a524","#f7ce46","#3fb950","#4c8dff","#7c66ff","#ef5da8","#8a93a6"],q=()=>Math.random().toString(36).slice(2,10);function $t({nodeId:i}){ut();const p=pt(t=>t.toast),c=ft(t=>t.close),o=I()?.getNode(i),[f,s]=h.useState(()=>o?.data?.wbAspect in U?(o?.data).wbAspect:"16:9"),{w:a,h:r}=U[f],[d,v]=h.useState(()=>et(o?.data?.wbShapes)),[x,nt]=h.useState("pen"),[j,J]=h.useState("#111111"),[C,rt]=h.useState(6),[T,P]=h.useState(null),[M,_]=h.useState(null),[z,O]=h.useState(!1),A=h.useRef([]),B=h.useRef([]),E=h.useRef(null),S=h.useRef(null),L=h.useRef(null),X=h.useRef(null),[,D]=h.useState(0),w=h.useRef(d);w.current=d;const N=t=>{A.current=[...A.current.slice(-49),w.current],B.current=[],v(t)},Y=()=>{const t=A.current.pop();t&&(B.current.push(w.current),v(t),P(null))},G=()=>{const t=B.current.pop();t&&(A.current.push(w.current),v(t),P(null))},K=h.useCallback(()=>{I()?.updateNodeData(i,{wbShapes:et(w.current),wbAspect:f})},[i,f]),$=h.useCallback(()=>{K(),c()},[K,c]);h.useEffect(()=>{const t=e=>{M||(e.key==="Escape"&&$(),(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="z"&&(e.preventDefault(),e.shiftKey?G():Y()),(e.key==="Delete"||e.key==="Backspace")&&T&&N(w.current.filter(n=>n.id!==T)))};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[T,M,$]);const Q=t=>{const e=L.current.getBoundingClientRect();return{x:Math.round((t.clientX-e.left)*(a/e.width)),y:Math.round((t.clientY-e.top)*(r/e.height))}},ot=t=>{const e=Q(t);if(M){W();return}if(x==="text"){t.preventDefault(),_({x:e.x,y:e.y,value:""});return}if(t.target.setPointerCapture?.(t.pointerId),x==="select"){const n=H(w.current,e.x,e.y);P(n?.id||null),n&&(S.current={id:n.id,lx:e.x,ly:e.y});return}if(x==="eraser"){const n=H(w.current,e.x,e.y);n&&N(w.current.filter(l=>l.id!==n.id)),S.current={id:"__erase__",lx:e.x,ly:e.y};return}E.current=x==="pen"?{id:q(),type:"pen",color:j,width:C,points:[e.x,e.y]}:{id:q(),type:x,color:j,width:C,x:e.x,y:e.y,w:0,h:0},D(n=>n+1)},it=t=>{if(t.buttons!==1)return;const e=Q(t);if(S.current){if(S.current.id==="__erase__"){const l=H(w.current,e.x,e.y);l&&N(w.current.filter(y=>y.id!==l.id))}else{const{id:l,lx:y,ly:g}=S.current;S.current={id:l,lx:e.x,ly:e.y},v(k=>k.map(b=>b.id===l?yt(b,e.x-y,e.y-g):b))}return}const n=E.current;if(n)if(n.type==="pen"){const l=n.points,y=l.length;Math.hypot(e.x-l[y-2],e.y-l[y-1])>=3&&y<4e3&&(l.push(e.x,e.y),D(g=>g+1))}else n.w=e.x-(n.x||0),n.h=e.y-(n.y||0),D(l=>l+1)},V=()=>{if(S.current){S.current.id!=="__erase__"&&N(w.current),S.current=null;return}const t=E.current;if(E.current=null,!t)return;const e=R(t);if(t.type!=="pen"&&e.w<3&&e.h<3){D(n=>n+1);return}N([...w.current,t])},Z=dt(()=>W()),W=()=>{const t=M;_(null),t&&t.value.trim()&&N([...w.current,{id:q(),type:"text",x:t.x,y:t.y,text:t.value.slice(0,2e3),color:j,width:C,size:Math.round(C*4+16)}])},F=(t,e)=>{if(t.strokeStyle=e.color,t.fillStyle=e.color,t.lineWidth=e.width,t.lineCap="round",t.lineJoin="round",e.type==="pen"){const n=e.points||[];if(n.length<2)return;t.beginPath(),t.moveTo(n[0],n[1]);for(let l=2;l<n.length;l+=2)t.lineTo(n[l],n[l+1]);n.length===2&&t.lineTo(n[0]+.1,n[1]),t.stroke()}else if(e.type==="arrow"){const n=e.x||0,l=e.y||0,y=n+(e.w||0),g=l+(e.h||0);t.beginPath(),t.moveTo(n,l),t.lineTo(y,g),t.stroke();const k=Math.atan2(g-l,y-n),b=Math.max(14,e.width*3.2);t.beginPath(),t.moveTo(y,g),t.lineTo(y-b*Math.cos(k-.45),g-b*Math.sin(k-.45)),t.moveTo(y,g),t.lineTo(y-b*Math.cos(k+.45),g-b*Math.sin(k+.45)),t.stroke()}else if(e.type==="rect"){const n=R(e);t.strokeRect(n.x,n.y,n.w,n.h)}else if(e.type==="ellipse"){const n=R(e);t.beginPath(),t.ellipse(n.x+n.w/2,n.y+n.h/2,Math.max(1,n.w/2),Math.max(1,n.h/2),0,0,Math.PI*2),t.stroke()}else if(e.type==="text"){const n=e.size||36;t.font=`600 ${n}px system-ui, -apple-system, sans-serif`,t.textBaseline="top",String(e.text||"").split(`
3
+ `).forEach((l,y)=>t.fillText(l,e.x||0,(e.y||0)+y*n*1.25))}},st=()=>{const t=L.current?.getContext("2d");if(t){t.fillStyle="#ffffff",t.fillRect(0,0,a,r);for(const e of d)F(t,e);if(E.current&&F(t,E.current),T){const e=d.find(n=>n.id===T);if(e){const n=R(e);t.save(),t.strokeStyle="#4c8dff",t.lineWidth=2,t.setLineDash([8,6]),t.strokeRect(n.x-8,n.y-8,n.w+16,n.h+16),t.restore()}}}};h.useEffect(st);const at=async()=>{if(!z){W(),O(!0);try{K();const t=document.createElement("canvas");t.width=a,t.height=r;const e=t.getContext("2d");e.fillStyle="#ffffff",e.fillRect(0,0,a,r);for(const b of w.current)F(e,b);const n=await new Promise(b=>t.toBlob(b,"image/png"));if(!n)throw Error("Canvas export failed");const{url:l,gcsUri:y}=await ht(new File([n],"whiteboard.png",{type:"image/png"}),void 0,"image"),g=I(),k=g?.getNode(i)?.position||g?.centerFlowPos()||{x:0,y:0};g?.addNode("image",{url:l,gcsUri:y,label:"Whiteboard sketch"},{x:k.x+420,y:k.y},{sourceIds:[i]}),p(m("Đã xuất bản vẽ thành node Image — dùng làm ảnh tham chiếu được ngay."),"ok"),c()}catch(t){p(t.message,"error")}finally{O(!1)}}},lt=h.useMemo(()=>{const t=X.current?.getBoundingClientRect();return t?t.width/a:.5},[M,f]),ct=[["select","⬚",m("Chọn / di chuyển")],["pen","✎",m("Bút vẽ")],["arrow","↗",m("Mũi tên")],["rect","▭",m("Khung chữ nhật")],["ellipse","◯",m("Elip")],["eraser","⌫",m("Tẩy")],["text","T",m("Chữ")]];return u.jsxs("div",{className:"wb-backdrop",children:[u.jsxs("header",{children:[u.jsx("button",{onClick:$,title:m("Lưu và quay lại Canvas"),children:"↩"}),u.jsx("span",{children:m("Whiteboard — vẽ nháp ý tưởng, Export thành ảnh tham chiếu")}),u.jsx("select",{value:f,onChange:t=>s(t.target.value),"aria-label":m("Tỷ lệ khung"),children:Object.keys(U).map(t=>u.jsx("option",{value:t,children:t},t))}),u.jsx("button",{className:"primary",disabled:z,onClick:at,children:z?m("Đang xuất…"):"Export"})]}),u.jsx("div",{className:"wb-stage",children:u.jsxs("div",{className:"wb-frame",ref:X,style:{aspectRatio:`${a} / ${r}`},children:[u.jsx("canvas",{ref:L,width:a,height:r,style:{cursor:x==="select"?"default":x==="text"?"text":"crosshair"},onPointerDown:ot,onPointerMove:it,onPointerUp:V,onPointerLeave:V}),M&&u.jsx("textarea",{className:"wb-textedit",rows:2,ref:t=>t?.focus({preventScroll:!0}),onPointerDown:t=>t.stopPropagation(),style:{left:`${M.x/a*100}%`,top:`${M.y/r*100}%`,color:j,fontSize:Math.max(12,Math.round((C*4+16)*lt))},value:M.value,placeholder:m("Nhập chữ… Enter để đặt"),onChange:t=>_(e=>e&&{...e,value:t.target.value}),onKeyDown:t=>{Z.onKeyDown(t)||t.key==="Escape"&&_(null)},onCompositionEnd:Z.onCompositionEnd,onBlur:W})]})}),u.jsxs("footer",{children:[u.jsxs("div",{className:"wb-tools",children:[ct.map(([t,e,n])=>u.jsx("button",{className:x===t?"on":"",title:n,onClick:()=>{nt(t),P(null)},children:e},t)),u.jsx("span",{className:"wb-sep"}),u.jsx("button",{title:m("Hoàn tác"),onClick:Y,children:"↶"}),u.jsx("button",{title:m("Làm lại"),onClick:G,children:"↷"})]}),u.jsxs("div",{className:"wb-colors",children:[mt.map(t=>u.jsx("button",{className:`wb-swatch ${j===t?"on":""}`,style:{background:t},onClick:()=>J(t),"aria-label":t},t)),u.jsx("input",{type:"color",value:j,title:m("Màu tùy chọn"),onChange:t=>J(t.target.value)})]}),u.jsxs("label",{className:"wb-width",title:m("Độ dày nét / cỡ chữ"),children:[u.jsx("svg",{viewBox:"0 0 20 20",width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:u.jsx("path",{d:"M3 15c3-6 6-9 14-11"})}),u.jsx("input",{type:"range",min:2,max:24,value:C,onChange:t=>rt(Number(t.target.value))})]})]})]})}export{$t as default};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js"])))=>i.map(i=>d[i]);
2
+ import{_ as et}from"./titleFrameBudget-Cml-MO53.js";import{jj as q,iQ as B,fi as J,gE as k,dz as b,fk as Q,jk as at,iJ as ot,hy as V,fB as it,fv as nt,fw as G,fl as rt,hv as st,iO as ct}from"./remote-BJdzzFZg.js";import{c as mt}from"./cameraPresets-4pFeF2YG.js";import"./api-QBI5GJTZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const F=()=>crypto.randomUUID(),u=o=>Math.round(o*100)/100,lt=o=>st(o)*(o.scale[1]||1);function W(o,c){const a=k(o),y=a.duration/c,e=l=>l?.map(i=>({...i,time:Math.min(1,i.time*y)})),s={...a,duration:c,cameraKeys:e(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([l,i])=>[l,e(i)||[]])),...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([l,i])=>[l,e(i)||[]]))}:{}};return{...o,shots:o.shots.map(l=>l.id===a.id?s:l)}}function C(o,c,a,y,e){const s=k(o),l=s.duration,i=(s.objectKeys?.[c.id]||[]).filter(p=>p.time*l<a-1e-6);return{...o,shots:o.shots.map(p=>p.id===s.id?{...p,objectKeys:{...p.objectKeys,[c.id]:[...i,{id:F(),time:a/l,position:y.map(_=>+_.toFixed(3)),rotation:[0,+e.toFixed(1),0],scale:c.scale}]}}:p)}}const X=(o,c)=>Math.atan2(c[0]-o[0],c[2]-o[2])*180/Math.PI;async function St(o,c){const a=q.find(t=>t.id===String(o.move??""));if(!a)return{ok:!1,error:`unknown move; use one of ${q.map(t=>t.id).join(", ")}`};const y=c.getStage();let e,s;try{e=B(y,String(o.name??""))}catch(t){return{ok:!1,error:t.message}}if(!J(e))return{ok:!1,error:`'${e.name}' is not a person`};const l=k(y),i=Math.max(0,Number(o.time??0)||0);if(o.target!=null)try{s=B(y,String(o.target))}catch(t){return{ok:!1,error:t.message}}else{const t=b(e,l,Math.min(1,i/l.duration)).position,m=y.items.filter(n=>n.id!==e.id&&J(n)&&!n.hidden).map(n=>{const r=b(n,l,Math.min(1,i/l.duration)).position;return{i:n,d:Math.hypot(r[0]-t[0],r[2]-t[2])}}).sort((n,r)=>n.d-r.d)[0];if(!m)return{ok:!1,error:"no target: put another person in the scene or give target"};s=m.i}const p=Q(a.id),_=at(a.id);if(!p||!_)return{ok:!1,error:`the clip ${a.id} is missing`};const M=[];let h=y;i+p.duration+1.6>l.duration&&(h=W(h,Math.min(300,Math.ceil((i+p.duration+1.8)*10)/10)));let S=k(h),w=S.duration;const j=i+_.at,$=j+(a.ranged?a.travel??.6:0),g=b(e,{...S,flight:void 0},Math.min(1,i/w)).position,v=b(s,{...S,flight:void 0},Math.min(1,$/w)).position,H=X(g,v);let x=g;if(!a.ranged){const t=(_.dz+(a.reach??.8))*lt(e),m=Math.hypot(v[0]-g[0],v[2]-g[2])||1,n=(g[0]-v[0])/m,r=(g[2]-v[2])/m;x=[v[0]+n*t,g[1],v[2]+r*t];const f=Math.hypot(x[0]-g[0],x[2]-g[2]);if(f>.3&&i>.25){const d=Math.min(.8,Math.max(.2,f/6),i);h=C(h,e,i-d,g,H),M.push(`${e.name} closes ${u(f)} m in ${u(d)} s before the strike${f>3?" (for a longer approach play ac-superman-glide / ac-burst-dash before)":""}`)}}h=C(h,e,i,x,H);const R=(t,m,n)=>{const r=k(n),f=r.flight?.[t.id];return!!f?.length&&ct(f,Math.min(1,m/r.duration),r.duration).air>.5};a.land&&R(e,i,h)&&(S=k(h),w=S.duration,h={...h,shots:h.shots.map(t=>t.id===S.id?{...t,flight:{...t.flight,[e.id]:ot(t.flight?.[e.id],{time:j/w,on:!1})}}:t)},M.push(`${e.name} lands on the strike (flight off at ${u(j)} s)`));const K=V(h,e.id,p,{start:i/k(h).duration,newId:F,loop:!1});if(!K.ok)return{ok:!1,error:K.error};c.setStage(()=>K.stage);const{runTool:Y}=await et(async()=>{const{runTool:t}=await import("./remote-BJdzzFZg.js").then(m=>m.js);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),L=[];for(const t of a.fx){const m=t.at==="strike"?j:i,n={effect:t.fx,start:u(m),duration:t.duration,...t.params?{params:t.params}:{},...o.color?{color:o.color}:{}},r=it(t.fx)?.attach==="path",f=t.place==="self"?{...n,attach_to:e.name}:t.place==="target"?{...n,at:`${s.name}.chest`}:t.place==="trail"?{...n,from:`${e.name}.chest`,to:`${s.name}.chest`}:t.place==="path"?{...n,from:`${e.name}.hand_right`,to:`${s.name}.chest`}:r?{...n,from:`${e.name}.feet`,to:`${s.name}.feet`}:{...n,at:`${s.name}.feet`},d=await Y("add_effect",f,c);d.ok?L.push({effect:t.fx,start_s:u(m)}):M.push(`${t.fx}: ${String(d.error)}`)}const O=String(o.react??"hit");let T=null;if(O!=="none"){const t=R(s,$,c.getStage()),[m,n]=O==="block"?t?["ac-air-block",.16]:["xx-palm-shield",.22]:O==="evade"?t?a.heavy?["ac-backflip-evade",.3]:["ac-corkscrew-dodge",.2]:["xx-teleport",.26]:t?[a.heavy?"ac-air-knocked-spin":"ac-air-recoil",0]:[(a.heavy,"xx-knocked-flying"),0],r=Math.max(0,$-n),f=Q(m);if(f){let d=c.getStage();const A=k(d),D=A.duration,N=b(s,{...A,flight:void 0},Math.min(1,r/D)).position,Z=b(e,A,Math.min(1,r/D)).position;d=C(d,s,r,N,X(N,Z)),r+f.duration+.3>D&&(d=W(d,Math.min(300,Math.ceil((r+f.duration+.4)*10)/10)));const P=V(d,s.id,f,{start:r/k(d).duration,newId:F,loop:!1});if(P.ok){if(c.setStage(()=>P.stage),T={motion:m,at_s:u(r)},O==="hit"&&o.timing!==!1){const I=k(c.getStage()),tt=nt(rt(I.timing,I.duration),[$],a.heavy?G.heavy:G.medium,I.duration);c.setStage(U=>({...U,shots:U.shots.map(z=>z.id===I.id?{...z,timing:tt??void 0}:z)}))}}else M.push(`${s.name} ${m}: ${P.error}`)}}const E=[];if(o.camera===!0){const t=[["wide-track",e,i,$+.2]];a.heavy&&t.push(["low-hero",s,$+.2,$+1.4]);for(const[m,n,r,f]of t){const d=mt(c.getStage(),{preset:m,subject:n.id,start:r,end:f});d.ok&&(c.setStage(()=>d.stage),E.push(`${m} ${u(r)}–${u(f)} s`))}}return{ok:!0,move:a.id,attacker:e.name,target:s.name,start_s:u(i),strike_s:u(j),impact_s:u($),end_s:u(i+p.duration),effects:L,...T?{reaction:T}:{},...E.length?{camera:E}:{},...M.length?{notes:M}:{}}}export{St as aerialStrike};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/views-BdWnG2xK.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/skin-BkaT2QuX.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js"])))=>i.map(i=>d[i]);
2
- import{_ as K}from"./titleFrameBudget-3MFHWIT6.js";import{gD as y,gp as N,gr as _,ii as M,iR as v,gq as S,dM as O,j5 as q,gx as z,gy as F,gu as G,gv as E,gw as P,gz as V,gt as U,fL as C}from"./remote-sTZauTqM.js";import{f as L,d as H,e as T}from"./skin-BkaT2QuX.js";import"./api-BsKbf3l3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const A=["humanoid","quadruped","chain","hinge","wheels"],B=()=>crypto.randomUUID(),J=o=>Math.round(o*100)/100,w=o=>o.joints.filter(n=>!O(o.joints,n)).map(n=>n.name);function ae(o,n){const i=o.rig,e=y(n),r=(e.objectKeys?.[o.id]||[]).filter(a=>a.bones),u=new Set;for(const a of r)for(const[s,t]of Object.entries(a.bones))t.some(c=>Math.abs(c)>.05)&&u.add(s);const g=w(i);return{rig:i.kind,rig_source:i.source,fingers:_(i),bones:g.filter(a=>!M(a)),..._(i)?{finger_bones:"thumb|index|middle|ring|pinky + 1..3 + L|R (e.g. index2R); hand shapes via set_pose hands curl them"}:{},keyed_bones:[...u],bone_key_times:r.map(a=>J(a.time*e.duration)),...i.bones?{posed_bones:Object.keys(i.bones)}:{},...N(i)?{posable:"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze and resolve_hits work on it like on a mannequin"}:{}}}function x(o,n){const i=w(o);return i.find(e=>e===n)??i.find(e=>e.toLowerCase()===n.toLowerCase())??null}const R=o=>Array.isArray(o)&&o.length===3&&o.every(n=>Number.isFinite(Number(n)))?o.map(n=>Math.round(Math.max(-S.angle,Math.min(S.angle,Number(n)))*100)/100):null;function $(o,n,i,e,r){o.setStage(u=>{const g=y(u),a=u.items.find(d=>d.id===n.id),s=g.objectKeys?.[n.id]||[],t=(d,h)=>{const k=s.find(j=>Math.abs(j.time-d)<1e-6),p=C(a,g,d);return{...k,id:k?.id||B(),time:d,position:p.position,rotation:p.rotation,scale:p.scale,bones:h}};let c=[...s];if(!s.some(d=>d.bones)&&i>1e-6){const d=t(0,{...a.rig?.bones||{}});c=[...c.filter(h=>h.id!==d.id),d]}const m=U(c,i,a.rig?.bones),{poseEase:f,...b}=t(i,{...m,...e}),l=r&&r!=="smooth"?{...b,poseEase:r}:b;return c=[...c.filter(d=>d.id!==l.id),l].sort((d,h)=>d.time-h.time),{...u,shots:u.shots.map(d=>d.id===g.id?{...d,objectKeys:{...d.objectKeys,[n.id]:c}}:d)}})}async function D(o,n){const i=o.engine();if(!i)return null;for(let e=0;e<200;e++){i.sync(o.getStage(),null);const r=i.objects.children.find(u=>u.userData.id===n)?.children[0];if(r)return r;await new Promise(u=>setTimeout(u,100))}return null}async function I(o,n){const i=v(o.getStage(),String(n.name));if(i.kind!=="model"||!i.model)return{ok:!1,error:`'${i.name}' is not a GLB model; people (mannequins) are already posable`};const e=String(n.kind??"humanoid");if(!A.includes(e))return{ok:!1,error:`unknown kind '${e}'; use ${A.join(", ")}`};const r=[];let u=n.ai===!0;if(u&&e!=="humanoid")return{ok:!1,error:"the AI auto-rig is for humanoid characters only; use the free template of that kind (ai:false)"};u&&!q(o.userText)&&(u=!1,r.push("ai:true refused — the user did not ask for the paid AI auto-rig; the free humanoid template was used (no credits). Only use ai:true when the user explicitly asks for AI / auto-rig."));const g=await D(o,i.id);if(!g)return{ok:!1,error:`${i.name} is not loaded (renderer not ready or the GLB failed to load)`};const a=e==="humanoid"&&!u&&n.file_skeleton!==!1?o.engine()?.nativeSkeleton?.(i.id):null;if(a?.ok)return o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:void 0,skeleton:"native"}:d)})),o.engine()?.sync(o.getStage(),null),{ok:!0,name:i.name,rig:"humanoid",source:"file",bones:a.bones,fileBones:a.total,credits:0,paid:!1,...r.length?{notes:r}:{},hint:"the model plays on its own skeleton and skin from the file (as in Blender): set_pose, play_motion, stage_spell_duel, hold_prop and set_gaze work on it"};const s=L(g);if(s.isEmpty())return{ok:!1,error:`${i.name} has no geometry to rig`};let t,c=0,m=null;if(u){const l=(o.rigViews??(await K(async()=>{const{renderRigViews:p}=await import("./views-BdWnG2xK.js");return{renderRigViews:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).renderRigViews)(g),d=o.rigAgent??(await K(async()=>{const{rigAgent:p}=await import("./api-BsKbf3l3.js").then(j=>j.c1);return{rigAgent:p}},__vite__mapDeps([5,6]))).rigAgent,h={requestId:B(),front:l.front,side:l.side,name:i.name};let k;try{k=await d(h)}catch(p){if(!(p instanceof TypeError))return{ok:!1,error:p.message||"AI auto-rig failed (no credits charged)"};k=await d(h)}if(!k.humanoid||!k.landmarks||!k.landmarks.humanoid)return{ok:!1,error:"the AI did not see a humanoid in this model; no credits were charged. Use a free template: quadruped / chain / hinge / wheels, or humanoid.",credits:0};t=z(k.landmarks,l.frame),c=k.credits,m=F(k.landmarks,l.frame)}else{const l=e==="humanoid"?H(g):null;t=G(e,{min:s.min.toArray(),max:s.max.toArray()},{segments:Number(n.segments)||4,...l?{tips:l}:{}})}e==="humanoid"&&n.fingers!==!1&&(t=E(t,{positions:T(g).positions,tips:m})),o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:t,skeleton:void 0}:d)}));const f=o.engine();let b;if(f){f.sync(o.getStage(),null),await f.rigReady();const l=f.objects.children.find(d=>d.userData.id===i.id)?.children[0]?.userData.rig;l&&(b={vertices:l.info.vertices,ms:l.info.ms,source:l.info.source})}return{ok:!0,name:i.name,rig:t.kind,source:t.source,joints:t.joints.length,fingers:_(t),bones:w(t).filter(l=>!M(l)),credits:c,paid:u,...b?{weights:b}:{},...r.length?{notes:r}:{},hint:t.kind==="humanoid"?"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze, resolve_hits now work on it; set_bone_rotation / set_bone_keys turn single bones":"turn its bones with set_bone_rotation / set_bone_keys (time = a key)"}}async function 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,...f})=>f)(t)),shots:s.shots.map(t=>t.objectKeys?.[e.id]?{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}}:t)})),{ok:!0,name:e.name,removed:"skeleton and its bone keys"});if(!e.rig)return{ok:!1,error:`${e.name} has no editable skeleton; rig_template gives it one`};if(r==="reset_bones")return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id&&t.rig?{...t,rig:(({bones:c,...m})=>m)(t.rig)}:t),shots:s.shots.map(t=>t.id!==s.activeShot||!t.objectKeys?.[e.id]?t:{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}})})),{ok:!0,name:e.name,reset:"every bone back to rest (bone keys of this shot removed)"};const g=await D(o,e.id);if(!g)return{ok:!1,error:`${e.name} is not loaded (it needs the 3D view: a scene open in the composer or the render machine)`};let a;if(r==="mirror"){const s=L(g);a=P(e.rig,(s.min.x+s.max.x)/2)}else if(r==="fingers")a=n.on===!1?V(e.rig):_(e.rig)?e.rig:E(e.rig,{positions:T(g).positions});else return{ok:!1,error:"action must be remove, reset_bones, mirror or fingers"};return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id?{...t,rig:a}:t)})),{ok:!0,name:e.name,action:r,joints:a.joints.length,fingers:_(a)}}async function de(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 g=n.ease==null?void 0:String(n.ease);if(g&&!["smooth","snap","hold","overshoot"].includes(g))return{ok:!1,error:`unknown ease '${g}'`};if(o==="set_bone_rotation"){const a=x(r.rig,String(n.bone??"")),s=R(n.rotation_deg);if(!a)return{ok:!1,error:`unknown bone '${String(n.bone)}' of ${r.name}; bones: ${w(r.rig).join(", ")}`};if(!s)return{ok:!1,error:"rotation_deg must be [x, y, z] degrees"};if(n.time==null)return i.setStage(c=>({...c,items:c.items.map(m=>{if(m.id!==r.id||!m.rig)return m;const f={...m.rig.bones||{},[a]:s};return s.every(b=>b===0)&&delete f[a],{...m,rig:{...m.rig,...Object.keys(f).length?{bones:f}:{bones:void 0}}}}),shots:c.shots.map(m=>m.id!==c.activeShot||!m.objectKeys?.[r.id]?.some(f=>f.bones)?m:{...m,objectKeys:{...m.objectKeys,[r.id]:m.objectKeys[r.id].map(f=>f.bones?{...f,bones:{...f.bones,[a]:s}}:f)}})})),{ok:!0,name:r.name,bone:a,rotation_deg:s,whole_shot:!0};const t=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,t,{[a]:s},g),{ok:!0,name:r.name,bone:a,rotation_deg:s,time:Number(n.time),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(c=>c.bones).length}}if(o==="set_bone_keys"){if(n.time==null)return{ok:!1,error:"set_bone_keys needs time (seconds); use set_bone_rotation without time for the whole shot"};const a=n.bones&&typeof n.bones=="object"&&!Array.isArray(n.bones)?Object.entries(n.bones):[];if(!a.length)return{ok:!1,error:"bones must map bone names to [x, y, z] degrees"};const s={},t=[];for(const[m,f]of a.slice(0,S.joints)){const b=x(r.rig,m),l=R(f);!b||!l?t.push(m):s[b]=l}if(t.length)return{ok:!1,error:`unknown bones or bad angles: ${t.join(", ")}; bones: ${w(r.rig).join(", ")}`};const c=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,c,s,g),{ok:!0,name:r.name,time:Number(n.time),bones_set:Object.keys(s),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(m=>m.bones).length}}return{ok:!1,error:`unknown tool '${o}'`}}catch(e){return{ok:!1,error:e.message||String(e)}}}export{A as RIG_TEMPLATE_KINDS,ae as rigSummary,de as runRigTool,w as turnableBones};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/views-CsrYzCSR.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-BHWu1lKg.js","assets/skin-GDY3QPkV.js","assets/remote-BJdzzFZg.js","assets/api-QBI5GJTZ.js","assets/titleFrameBudget-Cml-MO53.js","assets/store-2zneEhhu.js","assets/rotoMaskStore-DIi45swK.js","assets/textAnimators-Bdt5LWXk.js","assets/timelineComp-B73i_8vD.js","assets/rigTrack-CUt4O67J.js"])))=>i.map(i=>d[i]);
2
+ import{_ as A}from"./titleFrameBudget-Cml-MO53.js";import{gE as y,gq as O,gs as _,il as M,iQ as v,gr as S,dN as q,j4 as D,gy as z,gz as F,gv as G,gw as E,gx as P,gA as V,gu as U,fM as C}from"./remote-BJdzzFZg.js";import{f as L,d as H,e as N}from"./skin-GDY3QPkV.js";import"./api-QBI5GJTZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";const K=["humanoid","quadruped","chain","hinge","wheels"],T=()=>crypto.randomUUID(),Q=o=>Math.round(o*100)/100,w=o=>o.joints.filter(n=>!q(o.joints,n)).map(n=>n.name);function ae(o,n){const i=o.rig,e=y(n),r=(e.objectKeys?.[o.id]||[]).filter(a=>a.bones),u=new Set;for(const a of r)for(const[s,t]of Object.entries(a.bones))t.some(c=>Math.abs(c)>.05)&&u.add(s);const g=w(i);return{rig:i.kind,rig_source:i.source,fingers:_(i),bones:g.filter(a=>!M(a)),..._(i)?{finger_bones:"thumb|index|middle|ring|pinky + 1..3 + L|R (e.g. index2R); hand shapes via set_pose hands curl them"}:{},keyed_bones:[...u],bone_key_times:r.map(a=>Q(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 g=y(u),a=u.items.find(d=>d.id===n.id),s=g.objectKeys?.[n.id]||[],t=(d,h)=>{const k=s.find(j=>Math.abs(j.time-d)<1e-6),p=C(a,g,d);return{...k,id:k?.id||T(),time:d,position:p.position,rotation:p.rotation,scale:p.scale,bones:h}};let c=[...s];if(!s.some(d=>d.bones)&&i>1e-6){const d=t(0,{...a.rig?.bones||{}});c=[...c.filter(h=>h.id!==d.id),d]}const m=U(c,i,a.rig?.bones),{poseEase:f,...b}=t(i,{...m,...e}),l=r&&r!=="smooth"?{...b,poseEase:r}:b;return c=[...c.filter(d=>d.id!==l.id),l].sort((d,h)=>d.time-h.time),{...u,shots:u.shots.map(d=>d.id===g.id?{...d,objectKeys:{...d.objectKeys,[n.id]:c}}:d)}})}async function B(o,n){const i=o.engine();if(!i)return null;for(let e=0;e<200;e++){i.sync(o.getStage(),null);const r=i.objects.children.find(u=>u.userData.id===n)?.children[0];if(r)return r;await new Promise(u=>setTimeout(u,100))}return null}async function I(o,n){const i=v(o.getStage(),String(n.name));if(i.kind!=="model"||!i.model)return{ok:!1,error:`'${i.name}' is not a GLB model; people (mannequins) are already posable`};const e=String(n.kind??"humanoid");if(!K.includes(e))return{ok:!1,error:`unknown kind '${e}'; use ${K.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&&!D(o.userText)&&(u=!1,r.push("ai:true refused — the user did not ask for the paid AI auto-rig; the free humanoid template was used (no credits). Only use ai:true when the user explicitly asks for AI / auto-rig."));const g=await B(o,i.id);if(!g)return{ok:!1,error:`${i.name} is not loaded (renderer not ready or the GLB failed to load)`};const a=e==="humanoid"&&!u&&n.file_skeleton!==!1?o.engine()?.nativeSkeleton?.(i.id):null;if(a?.ok)return o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:void 0,skeleton:"native"}:d)})),o.engine()?.sync(o.getStage(),null),{ok:!0,name:i.name,rig:"humanoid",source:"file",bones:a.bones,fileBones:a.total,credits:0,paid:!1,...r.length?{notes:r}:{},hint:"the model plays on its own skeleton and skin from the file (as in Blender): set_pose, play_motion, stage_spell_duel, hold_prop and set_gaze work on it"};const s=L(g);if(s.isEmpty())return{ok:!1,error:`${i.name} has no geometry to rig`};let t,c=0,m=null;if(u){const l=(o.rigViews??(await A(async()=>{const{renderRigViews:p}=await import("./views-CsrYzCSR.js");return{renderRigViews:p}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11]))).renderRigViews)(g),d=o.rigAgent??(await A(async()=>{const{rigAgent:p}=await import("./api-QBI5GJTZ.js").then(j=>j.c1);return{rigAgent:p}},__vite__mapDeps([5,6]))).rigAgent,h={requestId:T(),front:l.front,side:l.side,name:i.name};let k;try{k=await d(h)}catch(p){if(!(p instanceof TypeError))return{ok:!1,error:p.message||"AI auto-rig failed (no credits charged)"};k=await d(h)}if(!k.humanoid||!k.landmarks||!k.landmarks.humanoid)return{ok:!1,error:"the AI did not see a humanoid in this model; no credits were charged. Use a free template: quadruped / chain / hinge / wheels, or humanoid.",credits:0};t=z(k.landmarks,l.frame),c=k.credits,m=F(k.landmarks,l.frame)}else{const l=e==="humanoid"?H(g):null;t=G(e,{min:s.min.toArray(),max:s.max.toArray()},{segments:Number(n.segments)||4,...l?{tips:l}:{}})}e==="humanoid"&&n.fingers!==!1&&(t=E(t,{positions:N(g).positions,tips:m})),o.setStage(l=>({...l,items:l.items.map(d=>d.id===i.id?{...d,rig:t,skeleton:void 0}:d)}));const f=o.engine();let b;if(f){f.sync(o.getStage(),null),await f.rigReady();const l=f.objects.children.find(d=>d.userData.id===i.id)?.children[0]?.userData.rig;l&&(b={vertices:l.info.vertices,ms:l.info.ms,source:l.info.source})}return{ok:!0,name:i.name,rig:t.kind,source:t.source,joints:t.joints.length,fingers:_(t),bones:w(t).filter(l=>!M(l)),credits:c,paid:u,...b?{weights:b}:{},...r.length?{notes:r}:{},hint:t.kind==="humanoid"?"humanoid skeleton: set_pose, play_motion, hold_prop, set_gaze, resolve_hits now work on it; set_bone_rotation / set_bone_keys turn single bones":"turn its bones with set_bone_rotation / set_bone_keys (time = a key)"}}async function J(o,n){const i=o.getStage(),e=v(i,String(n.name)),r=String(n.action||"");if(e.locked)return{ok:!1,error:`${e.name} is locked in the composer`};const u=s=>s.map(t=>(({bones:c,...m})=>m)(t));if(r==="remove")return!e.rig&&e.skeleton!=="native"?{ok:!1,error:`${e.name} has no skeleton`}:(o.setStage(s=>({...s,items:s.items.map(t=>t.id!==e.id?t:(({rig:c,skeleton:m,...f})=>f)(t)),shots:s.shots.map(t=>t.objectKeys?.[e.id]?{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}}:t)})),{ok:!0,name:e.name,removed:"skeleton and its bone keys"});if(!e.rig)return{ok:!1,error:`${e.name} has no editable skeleton; rig_template gives it one`};if(r==="reset_bones")return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id&&t.rig?{...t,rig:(({bones:c,...m})=>m)(t.rig)}:t),shots:s.shots.map(t=>t.id!==s.activeShot||!t.objectKeys?.[e.id]?t:{...t,objectKeys:{...t.objectKeys,[e.id]:u(t.objectKeys[e.id])}})})),{ok:!0,name:e.name,reset:"every bone back to rest (bone keys of this shot removed)"};const g=await B(o,e.id);if(!g)return{ok:!1,error:`${e.name} is not loaded (it needs the 3D view: a scene open in the composer or the render machine)`};let a;if(r==="mirror"){const s=L(g);a=P(e.rig,(s.min.x+s.max.x)/2)}else if(r==="fingers")a=n.on===!1?V(e.rig):_(e.rig)?e.rig:E(e.rig,{positions:N(g).positions});else return{ok:!1,error:"action must be remove, reset_bones, mirror or fingers"};return o.setStage(s=>({...s,items:s.items.map(t=>t.id===e.id?{...t,rig:a}:t)})),{ok:!0,name:e.name,action:r,joints:a.joints.length,fingers:_(a)}}async function de(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 J(i,n);const e=i.getStage(),r=v(e,String(n.name)),u=y(e);if(!r.rig)return{ok:!1,error:`${r.name} has no skeleton; call auto_rig first (people mannequins use set_pose)`};const g=n.ease==null?void 0:String(n.ease);if(g&&!["smooth","snap","hold","overshoot"].includes(g))return{ok:!1,error:`unknown ease '${g}'`};if(o==="set_bone_rotation"){const a=x(r.rig,String(n.bone??"")),s=R(n.rotation_deg);if(!a)return{ok:!1,error:`unknown bone '${String(n.bone)}' of ${r.name}; bones: ${w(r.rig).join(", ")}`};if(!s)return{ok:!1,error:"rotation_deg must be [x, y, z] degrees"};if(n.time==null)return i.setStage(c=>({...c,items:c.items.map(m=>{if(m.id!==r.id||!m.rig)return m;const f={...m.rig.bones||{},[a]:s};return s.every(b=>b===0)&&delete f[a],{...m,rig:{...m.rig,...Object.keys(f).length?{bones:f}:{bones:void 0}}}}),shots:c.shots.map(m=>m.id!==c.activeShot||!m.objectKeys?.[r.id]?.some(f=>f.bones)?m:{...m,objectKeys:{...m.objectKeys,[r.id]:m.objectKeys[r.id].map(f=>f.bones?{...f,bones:{...f.bones,[a]:s}}:f)}})})),{ok:!0,name:r.name,bone:a,rotation_deg:s,whole_shot:!0};const t=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,t,{[a]:s},g),{ok:!0,name:r.name,bone:a,rotation_deg:s,time:Number(n.time),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(c=>c.bones).length}}if(o==="set_bone_keys"){if(n.time==null)return{ok:!1,error:"set_bone_keys needs time (seconds); use set_bone_rotation without time for the whole shot"};const a=n.bones&&typeof n.bones=="object"&&!Array.isArray(n.bones)?Object.entries(n.bones):[];if(!a.length)return{ok:!1,error:"bones must map bone names to [x, y, z] degrees"};const s={},t=[];for(const[m,f]of a.slice(0,S.joints)){const b=x(r.rig,m),l=R(f);!b||!l?t.push(m):s[b]=l}if(t.length)return{ok:!1,error:`unknown bones or bad angles: ${t.join(", ")}; bones: ${w(r.rig).join(", ")}`};const c=Math.max(0,Math.min(1,Number(n.time)/u.duration));return $(i,r,c,s,g),{ok:!0,name:r.name,time:Number(n.time),bones_set:Object.keys(s),bone_keys:(y(i.getStage()).objectKeys?.[r.id]||[]).filter(m=>m.bones).length}}return{ok:!1,error:`unknown tool '${o}'`}}catch(e){return{ok:!1,error:e.message||String(e)}}}export{K as RIG_TEMPLATE_KINDS,ae as rigSummary,de as runRigTool,w as turnableBones};
@@ -0,0 +1 @@
1
+ import{u as v}from"./store-2zneEhhu.js";import{t as S}from"./api-QBI5GJTZ.js";import{am as A}from"./remote-BJdzzFZg.js";import{ae as y,z as k,af as I,l as P,w as _,y as j,H as F}from"./main-CVRIuDW2.js";import{runAnalyzerCode as R}from"./analyzerSandbox-CJVsEhrg.js";import{e as E}from"./pluginAutomation-5DYldFrb.js";import"./titleFrameBudget-Cml-MO53.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";async function $(t){const{plugins:o}=await P(),r=o.find(a=>a.id===t.id&&a.enabled);if(!r)throw _("use_missing",[t.id]);const n=t.item?await j(r,t.item):await F(r);if(n.manifest.kind!=="analyzer")throw _("use_plugin",[0,t.item?`${t.id}/${t.item}`:t.id],"not an analyzer plug-in");return n}async function H(t,o,r){if(window.__analyzerFramesStub)return window.__analyzerFramesStub(t,o);const n=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});n.src=t.url;try{await new Promise((l,h)=>{n.onloadeddata=()=>l(),n.onerror=()=>h(Error(S("Không đọc được video của clip (CORS / định dạng)")))});const a=n.videoWidth||1280,d=n.videoHeight||720,e=Math.min(o.width,a),s=Math.max(2,Math.round(e*d/a)),i=Object.assign(document.createElement("canvas"),{width:e,height:s}),m=i.getContext("2d",{willReadFrequently:!0}),p=t.playbackRate||1,b=t.inPoint||0,z=Math.min(t.duration,o.maxSeconds),c=Math.max(1,Math.floor(z*o.fps)),g=new Uint8Array(e*s*c);for(let l=0;l<c;l++){r?.aborted;const h=Math.max(0,Math.min(n.duration-1/60,b+l/o.fps*p));Math.abs(n.currentTime-h)>1e-4&&await new Promise((u,f)=>{const x=window.setTimeout(()=>f(Error(S("Seek video quá lâu"))),8e3);n.onseeked=()=>{window.clearTimeout(x),u()},n.currentTime=h}),m.drawImage(n,0,0,e,s);const w=m.getImageData(0,0,e,s).data,M=l*e*s;for(let u=0,f=0;u<w.length;u+=4,f++)g[M+f]=w[u]*77+w[u+1]*150+w[u+2]*29>>8}return{fps:o.fps,width:e,height:s,count:c,data:g,sourceWidth:a,sourceHeight:d}}finally{n.removeAttribute("src"),n.load()}}function O(t){const o=v.getState().timelineMedia.find(i=>t.gcsUri&&i.gcsUri===t.gcsUri||i.url===t.url),r=t.playbackRate||1,n=t.inPoint||0,a=i=>+((i-n)/r).toFixed(3),d=i=>a(i.end)>0&&a(i.start)<t.duration,e=(o?.words??[]).filter(d).slice(0,y.words).map(i=>({start:a(i.start),end:a(i.end),word:String(i.word).slice(0,60)})),s=(o?.pauses??[]).filter(d).map(i=>({start:a(i.start),end:a(i.end)}));return{words:e,pauses:s}}async function dt(t,o){const r=o.params??{};if(!r.plugin?.id)throw Error("runAnalyzer: no plug-in");if(t.kind!=="video"||!t.url)throw Error(S("Plug-in phân tích cần một clip video"));const n=await $(r.plugin),a=n.manifest,d=a.sample??{fps:y.fps.default,width:y.width.default,maxSeconds:y.maxSeconds.default},e=await H(t,d),s={clip:{duration:t.duration,width:e.sourceWidth,height:e.sourceHeight},frames:{fps:e.fps,width:e.width,height:e.height,count:e.count,data:e.data},...O(t),params:k(a,r.values??{})},i=I(await R(n.entry,s),t.id);if(!i.ops.length)return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:r.plugin.item?`${r.plugin.id}/${r.plugin.item}`:r.plugin.id,ops:0,summary:i.summary}),{};const m=A([t],i.ops);if(m.errors?.length)throw Error(String(m.errors[0]).slice(0,200));const p=m.clips.find(g=>g.id===t.id);if(!p)throw Error("runAnalyzer: the clip was lost");const{id:b,clientJobs:z,...c}=p;return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:r.plugin.item?`${r.plugin.id}/${r.plugin.item}`:r.plugin.id,ops:i.ops.length,summary:i.summary}),c}export{dt as runAnalyzerJob};
@@ -1,4 +1,4 @@
1
- import{ac as d}from"./main-M1vRa-gd.js";import"./titleFrameBudget-3MFHWIT6.js";import"./remote-sTZauTqM.js";import"./api-BsKbf3l3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const u=`
1
+ import{ae as d}from"./main-CVRIuDW2.js";import"./titleFrameBudget-Cml-MO53.js";import"./remote-BJdzzFZg.js";import"./api-QBI5GJTZ.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-BHWu1lKg.js";import"./store-2zneEhhu.js";import"./rotoMaskStore-DIi45swK.js";import"./textAnimators-Bdt5LWXk.js";import"./timelineComp-B73i_8vD.js";import"./rigTrack-CUt4O67J.js";import"./spark.module-DdwuJ_hb.js";import"./userFonts-BHduCNtc.js";import"./lottieLayer-CDCGeJyv.js";import"./timeline3d-YIIk_Kn2.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-D9OT7_5k.js";import"./captionLayout-C67EMVI1.js";import"./timelineText-BcL4Pw3C.js";import"./titleArt-hb_T45WJ.js";import"./rotoMatte-013RKqHu.js";import"./distortGL-BaXfN0IK.js";import"./motionBlur-uAm030t9.js";const u=`
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}}
@@ -30,4 +30,4 @@ onmessage=(e)=>{
30
30
  w.postMessage({req:m.req,code:m.code,input:m.input},[m.input.frames.data.buffer])
31
31
  }
32
32
  parent.postMessage({type:'boot'},'*')
33
- <\/script>`;let n=null,s=null,l=0;const a=new Map;function p(){if(s&&n?.isConnected)return s;n?.remove();const e=document.createElement("iframe");return n=e,e.setAttribute("sandbox","allow-scripts"),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.title="analyzer-sandbox",e.style.cssText="position:fixed;width:1px;height:1px;left:-10px;top:-10px;border:0;opacity:0;pointer-events:none",e.srcdoc=f,s=new Promise((t,r)=>{const m=window.setTimeout(()=>{s=null,r(Error("Analyzer sandbox did not start"))},8e3),o=i=>{i.source===e.contentWindow&&i.data?.type==="boot"&&(window.clearTimeout(m),window.removeEventListener("message",o),t())};window.addEventListener("message",o)}),document.body.appendChild(e),s}typeof window<"u"&&window.addEventListener("message",e=>{if(!n||e.source!==n.contentWindow||e.data?.type!=="analyzed")return;const t=a.get(e.data.req);t&&(a.delete(e.data.req),window.clearTimeout(t.timer),"result"in e.data?t.resolve(e.data.result):t.reject(Error(String(e.data.error||"analyzer failed"))))});async function $(e,t){await p();const r=++l;return new Promise((m,o)=>{const i=window.setTimeout(()=>{a.delete(r),o(Error("the analyzer timed out"))},d.timeoutMs+4e3);a.set(r,{resolve:m,reject:o,timer:i}),n.contentWindow.postMessage({type:"analyze",req:r,code:e,input:t},"*",[t.frames.data.buffer])})}export{$ as runAnalyzerCode};
33
+ <\/script>`;let n=null,s=null,l=0;const a=new Map;function p(){if(s&&n?.isConnected)return s;n?.remove();const e=document.createElement("iframe");return n=e,e.setAttribute("sandbox","allow-scripts"),e.setAttribute("aria-hidden","true"),e.tabIndex=-1,e.title="analyzer-sandbox",e.style.cssText="position:fixed;width:1px;height:1px;left:-10px;top:-10px;border:0;opacity:0;pointer-events:none",e.srcdoc=f,s=new Promise((t,r)=>{const m=window.setTimeout(()=>{s=null,r(Error("Analyzer sandbox did not start"))},8e3),o=i=>{i.source===e.contentWindow&&i.data?.type==="boot"&&(window.clearTimeout(m),window.removeEventListener("message",o),t())};window.addEventListener("message",o)}),document.body.appendChild(e),s}typeof window<"u"&&window.addEventListener("message",e=>{if(!n||e.source!==n.contentWindow||e.data?.type!=="analyzed")return;const t=a.get(e.data.req);t&&(a.delete(e.data.req),window.clearTimeout(t.timer),"result"in e.data?t.resolve(e.data.result):t.reject(Error(String(e.data.error||"analyzer failed"))))});async function I(e,t){await p();const r=++l;return new Promise((m,o)=>{const i=window.setTimeout(()=>{a.delete(r),o(Error("the analyzer timed out"))},d.timeoutMs+4e3);a.set(r,{resolve:m,reject:o,timer:i}),n.contentWindow.postMessage({type:"analyze",req:r,code:e,input:t},"*",[t.frames.data.buffer])})}export{I as runAnalyzerCode};