clipoox-render 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/scripts/render-local.mjs +1480 -1479
- package/web/assets/FxEmbed-BymBArNa.js +1 -0
- package/web/assets/MotionEmbed-PmXWSWe5.js +1 -0
- package/web/assets/PluginStore-BVsm6n6N.js +3 -0
- package/web/assets/{ShotComposer-AHScyNYv.js → ShotComposer-Dprx-Yi7.js} +4 -4
- package/web/assets/TemplateEmbed-CrZXoUk_.js +2 -0
- package/web/assets/{TimelinePlugins-CkP5P9b_.js → TimelinePlugins-B1KGtbmb.js} +3 -3
- package/web/assets/TimelineShotFx-DoLx312Y.js +2 -0
- package/web/assets/TransitionEmbed-C5SUosv2.js +1 -0
- package/web/assets/{Whiteboard-C9Mwa3nF.js → Whiteboard-DybaKCdo.js} +3 -3
- package/web/assets/aerial-DSt_mJNA.js +2 -0
- package/web/assets/agentTools-CxZqRLeR.js +2 -0
- package/web/assets/analyzerRun-DCJwb_-Z.js +1 -0
- package/web/assets/{analyzerSandbox-DQGHjUCa.js → analyzerSandbox-DO5ZTv5q.js} +2 -2
- package/web/assets/{api-C5pOWyBM.js → api-BsKbf3l3.js} +4 -4
- package/web/assets/auraTrack-QR0WqBHp.js +1 -0
- package/web/assets/breakthrough-Dv1bndQb.js +2 -0
- package/web/assets/{cameraPresets-CeStHDvF.js → cameraPresets-B234aNzE.js} +1 -1
- package/web/assets/{captionLayout-BAdmqwdS.js → captionLayout-CNgb471H.js} +1 -1
- package/web/assets/clientExport-NtJmxOYP.js +1 -0
- package/web/assets/{depthEstimate-1OjTo_pb.js → depthEstimate-wVYSJtW8.js} +1 -1
- package/web/assets/directorTools-BqFcShgT.js +1 -0
- package/web/assets/{distortFrames-D39fkQ_H.js → distortFrames-D3TQNcJA.js} +2 -2
- package/web/assets/{distortGL-5uNfls9s.js → distortGL-BklPDXPq.js} +1 -1
- package/web/assets/editTools-BQlG5WB_.js +1 -0
- package/web/assets/exportEncode-CaKEPgsy.js +1 -0
- package/web/assets/exportGlb-DstxwzH5.js +2 -0
- package/web/assets/faceTracker-DWxxieVC.js +1 -0
- package/web/assets/fightDirector-OMlPZgjv.js +1 -0
- package/web/assets/fightDrama-G7bXfpQu.js +2 -0
- package/web/assets/{frameSink-CB1EghW0.js → frameSink-Dj71jCRb.js} +3 -3
- package/web/assets/{gpuCompose-EfzSAeMh.js → gpuCompose-DIxBHlTa.js} +1 -1
- package/web/assets/gpuExport-CPSw_dmq.js +189 -0
- package/web/assets/handMatte-DHsHHz4m.js +1 -0
- package/web/assets/handTracker-D_O-C4Dw.js +2 -0
- package/web/assets/{index-BGZJld3s.js → index-CZn97Ygs.js} +1 -1
- package/web/assets/layer-worker-Bar7WgOA.js +5 -0
- package/web/assets/library-BtBrCaFk.js +1 -0
- package/web/assets/{lottieLayer-BhLbZOpr.js → lottieLayer-CfUPParC.js} +4 -4
- package/web/assets/{lottie_light_canvas-D9fsNLID.js → lottie_light_canvas-7iv3btPX.js} +1 -1
- package/web/assets/main-BPmr0TOL.css +1 -0
- package/web/assets/{main-BNZrzSIG.js → main-M1vRa-gd.js} +32 -32
- package/web/assets/{mapBake-BAG6i5fI.js → mapBake-lPNhNZgv.js} +1 -1
- package/web/assets/maskTrack-D2jUh7aw.js +1 -0
- package/web/assets/matteFixRun-B7tWV9Y1.js +1 -0
- package/web/assets/motionBlur-uAm030t9.js +1 -0
- package/web/assets/{objectLocate-Dhktxe5z.js → objectLocate-BDqfSo9J.js} +1 -1
- package/web/assets/pendingMatte-q35zVaiB.js +2 -0
- package/web/assets/personAi-ZjQVo-80.js +2 -0
- package/web/assets/plateCamera-A2E_WO_x.js +1 -0
- package/web/assets/plateCameraMatch-D41LQrsm.js +2 -0
- package/web/assets/plateFollow-CNfi4xuP.js +2 -0
- package/web/assets/plateMatte-BdIxGhw5.js +2 -0
- package/web/assets/{pluginAutomation-DdZOnpoV.js → pluginAutomation-BtQ_w2TB.js} +1 -1
- package/web/assets/poseTracker-DVX__OK7.js +1 -0
- package/web/assets/productTools-r2RgILaA.js +2 -0
- package/web/assets/{remote-DXG553d8.js → remote-sTZauTqM.js} +77 -77
- package/web/assets/rigTrack-Bx9QHlFv.js +1 -0
- package/web/assets/{rotoMaskStore-DrRawyH9.js → rotoMaskStore-pxpRt5Cj.js} +1 -1
- package/web/assets/{rotoMatte-2EcyuvBX.js → rotoMatte-DyXlW4jK.js} +1 -1
- package/web/assets/rotoscope-GORCSVBr.js +1 -0
- package/web/assets/shot-worker-B8JWkmBz.js +1 -0
- package/web/assets/{shotFxAgent-CETPcjzU.js → shotFxAgent-CzHfe75S.js} +2 -2
- package/web/assets/{skin-BQG1Iz6Q.js → skin-BkaT2QuX.js} +1 -1
- package/web/assets/{spark.module-CMSPLU2n.js → spark.module-BRT8yMS4.js} +10 -10
- package/web/assets/spellDuel-BUy289OT.js +2 -0
- package/web/assets/{store-Dxq3MZF3.js → store-BSSbvpzr.js} +1 -1
- package/web/assets/{surfaceLight-B_OSTxcx.js → surfaceLight-CMaBhZ_d.js} +1 -1
- package/web/assets/surfacePin-DM9b9ubh.js +2 -0
- package/web/assets/textAnimators-Cihw35O8.js +1 -0
- package/web/assets/{thumb-xLFX6lDN.js → thumb-Cs636sYt.js} +1 -1
- package/web/assets/{timeline3d-DqXTKdEK.js → timeline3d-BEuZZOxM.js} +2 -2
- package/web/assets/{timeline3dExport-MWomW4fF.js → timeline3dExport-CmSI_pjv.js} +1 -1
- package/web/assets/timelineComp-CRRzLazc.js +1 -0
- package/web/assets/timelineProps-tN2YsMYN.js +1 -0
- package/web/assets/timelineText-CkoUgWcY.js +1 -0
- package/web/assets/{titleArt-CAOxtyHl.js → titleArt-CcTdJuOC.js} +5 -5
- package/web/assets/{titleFrameBudget-BjW--v_T.js → titleFrameBudget-3MFHWIT6.js} +1 -1
- package/web/assets/titleFrames-w-iWje9N.js +1 -0
- package/web/assets/{tool-DEWWeyCz.js → tool-BhIsq238.js} +1 -1
- package/web/assets/tools-DMUnabc_.js +1 -0
- package/web/assets/toonTools-CICrV3QB.js +2 -0
- package/web/assets/trackAnchor-D2bB5mZE.js +1 -0
- package/web/assets/userFonts-BZ4QL-zq.js +1 -0
- package/web/assets/{vfxAlpha-vbbI-03F.js → vfxAlpha-D3Dk1tfF.js} +2 -2
- package/web/assets/vfxBackground-CHlCg8lb.js +2 -0
- package/web/assets/{vfxTrack-BmxWjlDi.js → vfxTrack-CqiQDEYm.js} +1 -1
- package/web/assets/videoExport-l5MGvMn_.js +1 -0
- package/web/assets/views-BdWnG2xK.js +1 -0
- package/web/assets/weaponDuel-B2wTffPC.js +1 -0
- package/web/assets/{windowFrames-DydW5Al5.js → windowFrames-CoIyWqxr.js} +1 -1
- package/web/layer-worker.html +3 -3
- package/web/assets/FxEmbed-B5TQxKxk.js +0 -1
- package/web/assets/MotionEmbed-Catb_GgA.js +0 -1
- package/web/assets/PluginStore-8TjQawtB.js +0 -3
- package/web/assets/TemplateEmbed-Cao8Z5fY.js +0 -2
- package/web/assets/TimelineShotFx-DvmPZQXM.js +0 -2
- package/web/assets/TransitionEmbed-o4UxJ35e.js +0 -1
- package/web/assets/aerial-BPRLPci2.js +0 -2
- package/web/assets/agentTools-CSnN-LvS.js +0 -2
- package/web/assets/analyzerRun-5zJsmMS1.js +0 -1
- package/web/assets/auraTrack-pF-WhpH3.js +0 -1
- package/web/assets/breakthrough-DQN1i-Pw.js +0 -2
- package/web/assets/clientExport-Ca9a3Jiy.js +0 -1
- package/web/assets/directorTools-CvmghG_6.js +0 -1
- package/web/assets/editTools-CUoVvupD.js +0 -1
- package/web/assets/exportEncode-pFxeatJt.js +0 -1
- package/web/assets/exportGlb-MK05aKqH.js +0 -2
- package/web/assets/faceTracker-_rQOgBvX.js +0 -1
- package/web/assets/fightDirector-Dt60kfbV.js +0 -1
- package/web/assets/fightDrama-py4jxSdn.js +0 -2
- package/web/assets/gpuExport-Cnv2NfEb.js +0 -189
- package/web/assets/handMatte-DZCsuqD2.js +0 -1
- package/web/assets/handTracker-Btr9L-Hu.js +0 -2
- package/web/assets/layer-worker-Rbo-YZv-.js +0 -5
- package/web/assets/library-CdukL2BW.js +0 -1
- package/web/assets/main-By_IEoB_.css +0 -1
- package/web/assets/maskTrack-AZwAVz1c.js +0 -1
- package/web/assets/matteFixRun-wTHGiGGf.js +0 -1
- package/web/assets/pendingMatte-iKz2-XBZ.js +0 -2
- package/web/assets/personAi-BEVyjCii.js +0 -2
- package/web/assets/plateCamera-D_J3-X06.js +0 -1
- package/web/assets/plateCameraMatch-C0peOvBn.js +0 -2
- package/web/assets/plateFollow-BbJMVxfg.js +0 -2
- package/web/assets/plateMatte-u5wKpsUN.js +0 -2
- package/web/assets/poseTracker--VJYw-hX.js +0 -1
- package/web/assets/productTools-DbhbyJxx.js +0 -2
- package/web/assets/rigTrack-CW9_kg5j.js +0 -1
- package/web/assets/rotoscope-_CYT-9ry.js +0 -1
- package/web/assets/shot-worker-BxIzQRZh.js +0 -1
- package/web/assets/spellDuel-eZvRwaxi.js +0 -2
- package/web/assets/surfacePin-CfLBhSrm.js +0 -2
- package/web/assets/timelineProps-KL6XCR4Q.js +0 -1
- package/web/assets/timelineText-DEK2BRyU.js +0 -1
- package/web/assets/titleFrames-WfiLHzjf.js +0 -1
- package/web/assets/tools-CBfIZX8_.js +0 -1
- package/web/assets/toonTools-D7jucq3t.js +0 -2
- package/web/assets/trackAnchor-DFqKIb8a.js +0 -1
- package/web/assets/userFonts-txN4I-eo.js +0 -1
- package/web/assets/vfxBackground-C1dHlJN6.js +0 -2
- package/web/assets/videoExport-DiNI9GY1.js +0 -1
- package/web/assets/views-sH39zgjD.js +0 -1
- package/web/assets/weaponDuel-CEvRDeuE.js +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{j as f}from"./remote-sTZauTqM.js";import{r as l}from"./api-BsKbf3l3.js";import{p as E}from"./main-M1vRa-gd.js";import{m as b}from"./textAnimators-Cihw35O8.js";import{l as g,d as h}from"./titleArt-CcTdJuOC.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./titleFrameBudget-3MFHWIT6.js";import"./rotoMaskStore-pxpRt5Cj.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"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.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(o=>({word:Math.max(1,o.split(/\s+/).filter(Boolean).length),char:Math.max(1,o.replace(/\s/g,"").length)})),F=e=>{if(!e.animation)return 2;const o=b(e.animation,L(e.sample));return o+1.2+o/e.animation.outSpeed};function X(){const e=l.useRef(null),[o,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(a){i(t,{type:"clipoox-template-error",id:"id"in t.data?t.data.id:null,error:a.message});return}if(t.data.type==="clipoox-template-play"){d(""),y(r);return}if(t.data.type==="clipoox-template-thumb"){const a=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:a,error:w.message});return}i(t,{type:"clipoox-template-thumb",id:a,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(!o)return;let i=0,p=!0;const s=x(o),t=F(o),r=performance.now();return g(s).then(()=>{const a=()=>{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(a)};a()},a=>d(a.message)),()=>{p=!1,cancelAnimationFrame(i)}},[o]),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{X as default,F as loopLength,x as titleOf};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PluginStore-
|
|
2
|
-
import{_ as Ln,au as Pi,f as Ti}from"./titleFrameBudget-BjW--v_T.js";import{j as n,cw as Mn,ao as gn,cN as $i,N as Li}from"./remote-DXG553d8.js";import{u as wn,r as N,t as e,bX as Ei}from"./api-C5pOWyBM.js";import{u as H}from"./store-Dxq3MZF3.js";import{G as Oi}from"./lottieLayer-BhLbZOpr.js";import{b as _,c as mn,s as Ai,e as Bi,S as Gi,f as Ii,l as Qn,g as qi,L as Ki,P as Fi,i as Ui,r as Di,h as yn,j as zi,k as Ri,m as Yn,n as Wi,o as bn,q as Hi,t as Xi,v as ni,w as ii,x as ei,y as ri,z as J,A as ci,B as En,C as On,D as ti,E as Ji,F as Vi,G as Zi,H as oi,I as Qi,J as An,K as Yi,M as di,N as ne,O as ie,Q as ee,R as te}from"./main-BNZrzSIG.js";import{l as se,a as le,t as ae,r as re,b as ce,p as oe,c as de}from"./pluginAutomation-DdZOnpoV.js";function he({review:t}){const l=wn(),o=t.manifest,h=o.sounds??[],[j,u]=N.useState(null),A=N.useRef(null),p=N.useRef(new Map);N.useEffect(()=>()=>{A.current?.pause();for(const k of p.current.values())URL.revokeObjectURL(k)},[]);const c=(k,x)=>{if(A.current?.pause(),j===k){u(null);return}let T=p.current.get(k);if(!T){const b=x.split(".").pop().toLowerCase();T=URL.createObjectURL(new Blob([t.read(x)],{type:Gi[b]})),p.current.set(k,T)}const r=new Audio(T);A.current=r,r.volume=.8,u(k),r.onended=()=>u(b=>b===k?null:b),r.play().catch(()=>u(null))},g=t.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:[t.thumbnail?n.jsx("img",{alt:"",src:`data:${t.thumbnail.type};base64,${t.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:[e("Gói âm thanh")," · v",o.version," · ",o.author.name]}),n.jsx("p",{children:mn(o,l)}),n.jsx("small",{className:"muted",children:e("{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:"✓"}),e("Đọc được {0} file âm thanh ({1})",[h.length,[...new Set(t.facts.map(k=>k.format))].join(", ")])]}),n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),e("Độ 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:"!"}),e("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":e("Âm thanh trong gói"),children:h.map((k,x)=>{const T=t.facts[x],r=Ai(k,l);return n.jsxs("li",{className:`tl-sfx-item tl-sfx-plug${j===k.id?" on":""}`,children:[n.jsx("button",{className:"tl-sfx-play","aria-label":`${e("Nghe thử")} ${r}`,title:e("Nghe thử"),onClick:()=>c(k.id,k.file),children:j===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:e("Lặp được"),children:" ↻"}):null]}),n.jsxs("small",{className:"ell",children:[Bi(k.category,l)," · ",T?.format]})]}),n.jsxs("small",{children:[T?T.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.",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."},ue={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"},ge={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 X(t){const l=t||{},o=l.code&&Pn[l.code]?l.code:null;if(!o)return{text:e("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]=e(ge[h[1]]??h[1])),o==="asset"&&h[1]){const u=ue[h[1]];return{text:e(Pn.asset,[h[0],u?e(u,h.slice(2)):h[1]]),detail:l.message&&l.message!==o?String(l.message).slice(0,300):""}}const j=l.message&&l.message!==o&&!/^manifest\./.test(l.message)?String(l.message).slice(0,300):"";return{text:e(Pn[o],h),detail:j}}const me=t=>(t==="en"?Ln(()=>import("./plugin-guide.en-CGYh_9Su.js"),[]):Ln(()=>import("./plugin-guide.vi-DMphSELb.js"),[])).then(l=>l.default);function an(t,l){const o=[],h=/(`[^`]+`|\*\*[^*]+\*\*|\*[^*\s][^*]*\*|\[[^\]]+\]\((https:\/\/[^)\s]+|[a-z0-9./#-]+)\))/g;let j=0,u=0;for(const A of t.matchAll(h)){A.index>j&&o.push(t.slice(j,A.index));const p=A[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=A[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))}j=A.index+p.length}return j<t.length&&o.push(t.slice(j)),o}function pe(t){const l=t.replace(/\r/g,"").split(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/PluginStore-BVsm6n6N.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js","assets/main-M1vRa-gd.js","assets/spark.module-BRT8yMS4.js","assets/userFonts-BZ4QL-zq.js","assets/lottieLayer-CfUPParC.js","assets/desktop-BWhFnYwd.js","assets/timeline3d-BEuZZOxM.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/exportEncode-CaKEPgsy.js","assets/captionLayout-CNgb471H.js","assets/timelineText-CkoUgWcY.js","assets/titleArt-CcTdJuOC.js","assets/rotoMatte-DyXlW4jK.js","assets/distortGL-BklPDXPq.js","assets/motionBlur-uAm030t9.js","assets/main-BPmr0TOL.css","assets/pluginAutomation-BtQ_w2TB.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as Ln,au as Pi,f as Ti}from"./titleFrameBudget-3MFHWIT6.js";import{j as n,cq as Mn,am as gn,cH as $i,N as Li}from"./remote-sTZauTqM.js";import{u as wn,r as N,t as e,bX as Ei}from"./api-BsKbf3l3.js";import{u as H}from"./store-BSSbvpzr.js";import{G as Oi}from"./lottieLayer-CfUPParC.js";import{b as _,c as mn,s as Ai,e as Bi,S as Gi,f as Ii,l as Qn,g as qi,L as Ki,P as Fi,i as Ui,r as Di,h as yn,j as zi,k as Ri,m as Yn,n as Wi,o as bn,q as Hi,t as Xi,v as ni,w as ii,x as ei,y as ri,z as J,A as ci,B as En,C as On,D as ti,E as Ji,F as Vi,G as Zi,H as oi,I as Qi,J as An,K as Yi,M as di,N as ne,O as ie,Q as ee,R as te}from"./main-M1vRa-gd.js";import{l as se,a as le,t as ae,r as re,b as ce,p as oe,c as de}from"./pluginAutomation-BtQ_w2TB.js";function he({review:t}){const l=wn(),o=t.manifest,h=o.sounds??[],[j,u]=N.useState(null),A=N.useRef(null),p=N.useRef(new Map);N.useEffect(()=>()=>{A.current?.pause();for(const k of p.current.values())URL.revokeObjectURL(k)},[]);const c=(k,x)=>{if(A.current?.pause(),j===k){u(null);return}let T=p.current.get(k);if(!T){const b=x.split(".").pop().toLowerCase();T=URL.createObjectURL(new Blob([t.read(x)],{type:Gi[b]})),p.current.set(k,T)}const r=new Audio(T);A.current=r,r.volume=.8,u(k),r.onended=()=>u(b=>b===k?null:b),r.play().catch(()=>u(null))},g=t.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:[t.thumbnail?n.jsx("img",{alt:"",src:`data:${t.thumbnail.type};base64,${t.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:[e("Gói âm thanh")," · v",o.version," · ",o.author.name]}),n.jsx("p",{children:mn(o,l)}),n.jsx("small",{className:"muted",children:e("{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:"✓"}),e("Đọc được {0} file âm thanh ({1})",[h.length,[...new Set(t.facts.map(k=>k.format))].join(", ")])]}),n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),e("Độ 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:"!"}),e("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":e("Âm thanh trong gói"),children:h.map((k,x)=>{const T=t.facts[x],r=Ai(k,l);return n.jsxs("li",{className:`tl-sfx-item tl-sfx-plug${j===k.id?" on":""}`,children:[n.jsx("button",{className:"tl-sfx-play","aria-label":`${e("Nghe thử")} ${r}`,title:e("Nghe thử"),onClick:()=>c(k.id,k.file),children:j===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:e("Lặp được"),children:" ↻"}):null]}),n.jsxs("small",{className:"ell",children:[Bi(k.category,l)," · ",T?.format]})]}),n.jsxs("small",{children:[T?T.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.",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."},ue={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"},ge={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 X(t){const l=t||{},o=l.code&&Pn[l.code]?l.code:null;if(!o)return{text:e("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]=e(ge[h[1]]??h[1])),o==="asset"&&h[1]){const u=ue[h[1]];return{text:e(Pn.asset,[h[0],u?e(u,h.slice(2)):h[1]]),detail:l.message&&l.message!==o?String(l.message).slice(0,300):""}}const j=l.message&&l.message!==o&&!/^manifest\./.test(l.message)?String(l.message).slice(0,300):"";return{text:e(Pn[o],h),detail:j}}const me=t=>(t==="en"?Ln(()=>import("./plugin-guide.en-CGYh_9Su.js"),[]):Ln(()=>import("./plugin-guide.vi-DMphSELb.js"),[])).then(l=>l.default);function an(t,l){const o=[],h=/(`[^`]+`|\*\*[^*]+\*\*|\*[^*\s][^*]*\*|\[[^\]]+\]\((https:\/\/[^)\s]+|[a-z0-9./#-]+)\))/g;let j=0,u=0;for(const A of t.matchAll(h)){A.index>j&&o.push(t.slice(j,A.index));const p=A[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=A[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))}j=A.index+p.length}return j<t.length&&o.push(t.slice(j)),o}function pe(t){const l=t.replace(/\r/g,"").split(`
|
|
3
3
|
`),o=[];for(let h=0;h<l.length;){const j=l[h],u=`b${h}`;if(j.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 A=/^(#{1,4})\s+(.*)$/.exec(j);if(A){const c=Math.min(4,A[1].length+1),g=`h${c}`;o.push(n.jsx(g,{children:an(A[2],u)},u)),h++;continue}if(/^\|.*\|\s*$/.test(j)){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,T)=>n.jsx("td",{children:an(x,`${u}r${k}c${T}`)},T))},k))})]})},u));continue}if(/^\s*([-*]|\d+\.)\s+/.test(j)){const c=/^(\s*)([-*]|\d+\.)\s+/,g=/^\s*\d+\./.test(j),k=c.exec(j)[1].length,x=[];for(;h<l.length;){const r=c.exec(l[h]);if(r){const b=l[h].slice(r[0].length);if(r[1].length>k&&x.length)x[x.length-1].sub.push(b);else{if(r[1].length<k)break;x.push({text:b,sub:[]})}h++;continue}if(/^\s{2,}\S/.test(l[h])&&x.length){const b=x[x.length-1],G=l[h++].trim();b.sub.length?b.sub[b.sub.length-1]+=" "+G:b.text+=" "+G;continue}break}const T=g?"ol":"ul";o.push(n.jsx(T,{children:x.map((r,b)=>n.jsxs("li",{children:[an(r.text,`${u}-${b}`),r.sub.length>0&&n.jsx("ul",{children:r.sub.map((G,C)=>n.jsx("li",{children:an(G,`${u}-${b}-${C}`)},C))})]},b))},u));continue}if(j.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(!j.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 ke({onClose:t}){const l=wn(),[o,h]=N.useState(null),[j,u]=N.useState(!1);N.useEffect(()=>{let p=!0;return h(null),me(l).then(c=>{p&&h(c)},()=>{p&&u(!0)}),()=>{p=!1}},[l]),N.useEffect(()=>{const p=c=>{c.key==="Escape"&&(c.stopPropagation(),t())};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[t]);const A=()=>{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&&t()},children:n.jsxs("div",{className:"tl-guide",role:"dialog","aria-modal":"true","aria-label":e("Hướng dẫn làm plug-in"),children:[n.jsxs("div",{className:"tl-guide-head",children:[n.jsxs("strong",{children:["📘 ",e("Hướng dẫn làm plug-in")]}),n.jsx("button",{className:"pill-btn thin",disabled:!o,onClick:A,children:e("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:[e("Mẫu Motion")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/like-subscribe.clipoox-plugin",download:!0,children:[e("Mẫu Lottie")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/talking-head-quick.clipoox-plugin",download:!0,children:[e("Mẫu công thức")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/bds-starter.clipoox-plugin",download:!0,children:[e("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:e("Dán cho Claude / ChatGPT để AI viết plug-in theo đúng quy tắc của Clipoox"),children:[e("Plugin Dev Kit (cho AI)")," ⤓"]}),n.jsx("button",{className:"icon-btn","aria-label":e("Đóng"),onClick:t,children:"×"})]}),n.jsx("div",{className:"tl-guide-body",children:j?n.jsx("p",{className:"tl-plugin-error",children:e("Không tải được hướng dẫn.")}):o===null?n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải…")]}):n.jsx(N.Fragment,{children:pe(o)})})]})})}const Tn=[{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 xe({toast:t}){const[l,o]=N.useState(null),[h,j]=N.useState(""),[u,A]=N.useState(Tn.map(v=>v.id)),[p,c]=N.useState(null),[g,k]=N.useState(null),[x,T]=N.useState(""),r=()=>se().then(v=>o(v.endpoints)).catch(v=>T(X(v).text));N.useEffect(()=>{r()},[]);const b=v=>T(X(v).text),G=async()=>{c("add"),T("");try{const v=await le(h.trim(),u);k({id:v.id,value:v.secret}),j(""),await r(),t(e("Đã thêm webhook"),"ok")}catch(v){b(v)}finally{c(null)}},C=async v=>{c(v),T("");try{const O=await ae(v);t(O.status>=200&&O.status<300?e("Đã gửi thử — nơi nhận trả lời HTTP {0}",[O.status]):e("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){b(O)}finally{c(null)}},rn=async v=>{c(v);try{const O=await re(v);k({id:v,value:O.secret})}catch(O){b(O)}finally{c(null)}},V=async v=>{c(v);try{await ce(v),g?.id===v&&k(null),await r()}catch(O){b(O)}finally{c(null)}},Z=v=>e(Tn.find(O=>O.id===v)?.vi??v);return n.jsxs("details",{className:"tl-plugin-hooks",children:[n.jsxs("summary",{children:[n.jsxs("b",{children:["⚡ ",e("Tự động hoá (Webhook)")]})," ",n.jsx("small",{className:"muted",children:e("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"}),e("Đang tải…")]}),l&&l.length>0&&n.jsx("ul",{className:"tl-plugin-hook-list","aria-label":e("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?` · ${e("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,e("Gửi thử")]}),n.jsx("button",{className:"pill-btn thin",disabled:!!p,onClick:()=>void rn(v.id),children:e("Đổi khoá")}),n.jsx("button",{className:"pill-btn thin danger",disabled:!!p,"aria-label":e("Xoá webhook {0}",[v.url]),onClick:()=>void V(v.id),children:"✕"})]}),g?.id===v.id&&n.jsxs("p",{className:"tl-plugin-hook-secret",role:"status",children:[e("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),t(e("Đã chép khoá"),"ok")},children:e("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":e("Link webhook (https)"),value:h,onChange:v=>j(v.target.value)}),n.jsx("div",{className:"tl-plugin-hook-events",role:"group","aria-label":e("Gửi khi"),children:Tn.map(v=>n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:u.includes(v.id),onChange:O=>A(cn=>O.target.checked?[...cn,v.id]:cn.filter(S=>S!==v.id))}),e(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,e("Thêm webhook")]})]}),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",x]}),n.jsx("small",{className:"muted",children:e("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 fe=N.lazy(()=>Ln(()=>import("./PluginStore-8TjQawtB.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]))),si=[{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"}],be={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"}},je={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=(t,l)=>be[t][l==="en"?"en":"vi"],Nn=t=>t.kind==="pack"&&!!t.assets?.some(l=>l.kind==="model"),$n=(t,l)=>Bn(Nn(t)?"kit":t.kind==="motion"&&t.engine==="3d"?"motion3d":t.kind,l),ve={motion3d:["3D","3D"],model:["MÔ HÌNH","MODEL"],lut:["LOOK","LOOK"],motion:["2D","2D"],recipe:["COMBO","COMBO"],lottie:["LOTTIE","LOTTIE"]},ye=(t,l)=>{const o=t.kind==="motion"&&t.engine==="3d"?"motion3d":t.kind,h=ve[o];return h?h[l==="en"?1:0]:""},Gn=1024*1024;function Ne(t,l){const o=t.facts??{},h=u=>u.toLocaleString(l==="en"?"en-US":"vi-VN"),j=t.bytes!==void 0?t.bytes>=Gn?`${(t.bytes/Gn).toFixed(1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(t.bytes/1024))} KB`:"";return t.kind==="model"?[j,e("{0} tam giác",[h(o.triangles??0)]),...o.images?.length?[e("{0} ảnh nhúng",[o.images.length])]:[],...o.animations?.length?[e("animation: {0}",[o.animations.slice(0,3).join(", ")])]:[],e("không có link ngoài")].join(" · "):t.kind==="sequence"?[j,e("{0} khung {1} × {2}",[o.frames??0,o.width??0,o.height??0])].join(" · "):t.kind==="lut"?[j,e("LUT 3D {0}³",[o.size??0])].join(" · "):[j,`${o.width??0} × ${o.height??0}`,...t.sprite?[e("sprite {0} × {1} = {2} khung",[t.sprite.cols,t.sprite.rows,t.sprite.frames])]:[]].join(" · ")}const hi=t=>`clipoox:kit-controls:${t}`;function we(t){try{const l=JSON.parse(localStorage.getItem(hi(t))||"{}");return l&&typeof l=="object"&&!Array.isArray(l)?l:{}}catch{return{}}}function _e(t,l){try{localStorage.setItem(hi(t),JSON.stringify(l))}catch{}}const Se=["#3ee6ff","#c6f432","#ff5fa2","#ffb547","#9d7bff","#ffffff"],Ce={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}"]},li=t=>t.source?.store?` · ${e("Kho")}`:t.source?.dev?` · ${e("Bản thử – chưa duyệt")}`:"",Me=t=>t.recipe?{...t,recipe:{ops:t.recipe.ops.filter(l=>l.op!=="usePlugin")}}:t;async function ai(t){const l=j=>{const u=j;return u.op==="addMap"&&!u.geo||u.op==="updateMap"&&Array.isArray(u.places)};if(!t.some(l))return{ops:t,errors:[]};const o=[],h=[];for(const j of t){if(!l(j)){o.push(j);continue}const u=await Ei([j]);u.ops.length===1?o.push(u.ops[0]):h.push(...u.errors)}return{ops:o,errors:h}}const In=(t,l)=>Object.fromEntries(t.params.filter(o=>o.type!=="image").map(o=>[o.key,l[o.key]]));function Pe({selected:t,time:l,aspect:o,materials:h,locked:j,onCommit:u,onPatch:A,toast:p}){const c=wn(),[g,k]=N.useState(null),[x,T]=N.useState(null),[r,b]=N.useState(null),[G,C]=N.useState(null),[rn,V]=N.useState(null),[Z]=N.useState(()=>Ii()),[v,O]=N.useState(!1),[cn,S]=N.useState(!!Z),[M,K]=N.useState(null),[B,F]=N.useState(null),[pn,qn]=N.useState({}),[vn,Kn]=N.useState("all"),[P,on]=N.useState(null),_n=i=>{F({id:i.id}),Kn("all"),qn(s=>({...s,[i.id]:{...Object.fromEntries((i.manifest.controls??[]).map(a=>[a.key,a.default])),...we(i.id)}})),ni(i).then(s=>F(a=>a?.id===i.id?{id:i.id,index:s}:a),s=>F(a=>a?.id===i.id?{id:i.id,error:X(s).text}:a))},Fn=N.useRef(null),[ui,Un]=N.useState(""),gi=i=>{S(!1),Qn().then(s=>{k(s.plugins);const a=s.plugins.find(d=>d.id===i);a&&(a.kind==="pack"&&B?.id!==i&&_n(a),Un(i),window.setTimeout(()=>Un(d=>d===i?"":d),3400),requestAnimationFrame(()=>document.querySelector(`[data-plugin="${CSS.escape(i)}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})))},()=>{})},Q=N.useCallback(()=>Qn().then(i=>{k(i.plugins),T(null)},i=>{k(s=>s??[]),T(X(i).text)}),[]);N.useEffect(()=>{Q()},[Q]),N.useEffect(()=>{Z&&qi()},[Z]);const en=i=>{const s=X(i);p(s.detail?`${s.text} (${s.detail})`:s.text,"error")},mi=async i=>{b({file:i.name,stage:"reading"});try{if(await Ui(i)){const y=await Di(i),w=g?.find(L=>L.id===y.manifest.id);b({file:i.name,stage:"review",sfx:y,...w?{exists:{installed:w.version,newer:yn(y.manifest.version,w.version)>0}}:{}});return}const{bytes:s,...a}=await zi(i);if(a.manifest.kind==="pack"){const y=a.items,w=[];let L=a.thumbnail;b({file:i.name,stage:"checking",bundle:a,pack:{bytes:s,checks:[],total:y.length}});const m=Ri(a,Math.random().toString(36).slice(2,8));try{for(const E of y){const z=await Yn(Me(E),o,{assets:m.refs,readAsset:a.readAsset}).catch(R=>({ok:!1,lines:[],thumbnail:null,error:R.message}));L??=z.thumbnail,w.push({id:E.manifest.id,name:_(E.manifest,c),kind:E.manifest.kind==="motion"&&E.manifest.engine==="3d"?"motion3d":E.manifest.kind,ok:z.ok,warn:z.lines.some(R=>R.warn),...z.error?{error:z.error}:{}}),b(R=>R&&{...R,pack:{bytes:s,checks:[...w],total:y.length}})}}finally{m.drop()}const $=w.find(E=>!E.ok),q=g?.find(E=>E.id===a.manifest.id);b({file:i.name,stage:"review",bundle:{...a,thumbnail:L},pack:{bytes:s,checks:w,total:y.length},...$?{error:{text:e("Mục “{0}” không chạy được",[$.name]),detail:$.error??""}}:{},...q?{exists:{installed:q.version,newer:yn(a.manifest.version,q.version)>0}}:{}});return}b({file:i.name,stage:"checking",bundle:a});const d=await Yn(a,o),f=g?.find(y=>y.id===a.manifest.id);b({file:i.name,stage:"review",bundle:a,check:d,...d.ok?{}:{error:X({code:d.error==="nondeterministic"||d.error==="dryrun"?d.error:"code",message:d.error})},...f?{exists:{installed:f.version,newer:yn(a.manifest.version,f.version)>0}}:{}})}catch(s){b({file:i.name,stage:"review",error:X(s)})}},pi=async()=>{const i=r;if(i?.sfx){const s=i.sfx;b({...i,stage:"saving",progress:{stage:"upload",pct:0}});try{const a=await Wi(s,!!i.exists,(d,f)=>b(y=>y&&{...y,progress:{stage:d,pct:f}}));b(null),await Q(),bn(),p(a.updated?e("Đã cập nhật “{0}” lên v{1}",[_(a.plugin.manifest,c),a.plugin.version]):e("Đã 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 f=d.data;b({...i,stage:"review",progress:void 0,exists:{installed:f.installed,newer:f.newer}});return}b({...i,stage:"review",progress:void 0,error:X(a)})}return}if(i?.pack&&i.bundle){const s=i.pack,a=i.bundle.manifest;b({...i,stage:"saving",progress:{stage:"upload",pct:0}});try{const d=await Hi(s.bytes,a,i.file,!!i.exists,f=>b(y=>y&&{...y,progress:{stage:"upload",pct:f}}));b(null),await Q(),bn(),_n(d.plugin),p(d.updated?e("Đã cập nhật “{0}” lên v{1}",[_(d.plugin.manifest,c),d.plugin.version]):Nn(d.plugin.manifest)?e("Đã thêm bộ 3D “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]):e("Đã thêm gói “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]),"ok")}catch(d){const f=d;if(f.code==="exists"){const y=f.data;b({...i,stage:"review",progress:void 0,exists:{installed:y.installed,newer:y.newer}});return}b({...i,stage:"review",progress:void 0,error:X(d)})}return}if(!(!i?.bundle||!i.check?.ok)){b({...i,stage:"saving"});try{const s=await Xi({...i.bundle,thumbnail:i.check.thumbnail??i.bundle.thumbnail},!!i.exists);b(null),await Q(),bn(),p(s.updated?e("Đã cập nhật “{0}” lên v{1}",[_(s.plugin.manifest,c),s.plugin.version]):e("Đã thêm plug-in “{0}”",[_(s.plugin.manifest,c)]),"ok")}catch(s){const a=s;if(a.code==="exists"){const d=a.data;b({...i,stage:"review",exists:{installed:d.installed,newer:d.newer}});return}b({...i,stage:"review",error:X(s)})}}},dn=i=>Pi(Math.max(0,Math.min(l,Ti-i))),ki=async i=>{if(!G){if(i.kind==="sfx"||i.kind==="sfxlib"){Hn(s=>s===i.id?null:i.id);return}if(i.kind==="pack"){B?.id===i.id?F(null):_n(i);return}C(i.id);try{const s=await oi(i,k),a=s.manifest,d=_(a,c),f=H.getState();if(a.kind==="recipe"){K({id:i.id,values:J(a,{}),bundle:s});return}if(a.kind==="analyzer"){Dn(i.id,void 0,a);return}if(a.kind==="ai-template"){on({id:i.id,values:J(a,{}),bundle:s});return}if(a.kind==="motion"){const U=di(a,s.entry,{}),Y=dn(a.duration),sn=gn(f.clips,[{op:"addMotion",code:U.code,params:U.params,motionPreset:U.preset,...U.kind?{motionKind:U.kind}:{},label:`Plug-in · ${d}`,start:Y,duration:a.duration}],[],f.timelineTracks);if(sn.errors.length)throw Error(sn.errors[0]);const I=sn.clips.find(W=>!f.clips.some(nn=>nn.id===W.id));u(sn.clips.map(W=>W.id===I?.id?{...W,plugin:{id:a.id,v:a.version,kind:"motion"}}:W),I?.id);return}const y=J(a,{}),w=await En(s.lottie,a,y),L=await On(a.id,w),m=ti(s),$=dn(m),q={id:L.gcsUri,kind:"lottie",url:L.url,gcsUri:L.gcsUri,label:d,lottie:s.lottie.meta},E=H.getState(),z=gn(E.clips,[{op:"addClip",materialId:q.id,start:$,duration:m}],[q],E.timelineTracks);if(z.errors.length)throw Error(z.errors[0]);const R=z.clips.find(U=>!E.clips.some(Y=>Y.id===U.id));u(z.clips.map(U=>U.id===R?.id?{...U,label:`Plug-in · ${d}`,lottie:{...U.lottie,loop:a.loop!==!1},plugin:{id:a.id,v:a.version,kind:"lottie",params:In(a,y)}}:U),R?.id)}catch(s){en(s)}finally{C(null)}}},xi=async(i,s)=>{if(!G){C(`${i.id}/${s}`);try{const a=(await ni(i)).items.find(I=>I.manifest.id===s)?.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=pn[i.id]??{};if(a.kind==="lut"&&!t)throw ii("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 ei([{op:"usePlugin",pluginId:`${i.id}/${s}`,params:nn,...a.kind==="lut"?{clipId:t.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),Ci=Zn.find(ln=>!D.clips.some(Mi=>Mi.id===ln.id));u(Zn,Ci?.id??t?.id??null),a.kind==="lut"&&p(e("Đã áp look “{0}” cho “{1}” (chỉnh độ mạnh ở tab Màu)",[_(a,c),t.label]),"ok");return}const d=await ri(i,s),f=d.manifest,y=_(f,c),w=H.getState(),L={id:i.id,item:s,v:i.version};if(f.kind==="recipe"){K({id:i.id,item:s,values:J(f,{}),bundle:d});return}if(f.kind==="analyzer"){Dn(i.id,s,f);return}if(f.kind==="ai-template"){on({id:i.id,item:s,values:J(f,{}),bundle:d});return}if(f.kind==="motion"){const I=ci(i.id,s,d,{}),W=dn(f.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:f.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:{...L,kind:"motion"}}:D),hn?.id);return}const m=J(f,{}),$=await En(d.lottie,f,m),q=await On(i.id,$),E=ti(d),z=dn(E),R={id:q.gcsUri,kind:"lottie",url:q.url,gcsUri:q.gcsUri,label:y,lottie:d.lottie.meta},U=H.getState(),Y=gn(U.clips,[{op:"addClip",materialId:R.id,start:z,duration:E}],[R],U.timelineTracks);if(Y.errors.length)throw Error(Y.errors[0]);const sn=Y.clips.find(I=>!U.clips.some(W=>W.id===I.id));u(Y.clips.map(I=>I.id===sn?.id?{...I,label:`Plug-in · ${y}`,lottie:{...I.lottie,loop:f.loop!==!1},plugin:{...L,kind:"lottie",params:In(f,m)}}:I),sn?.id)}catch(a){en(a)}finally{C(null)}}},Dn=(i,s,a)=>{if(!t||t.kind!=="video")throw ii("needs_video");const d=H.getState(),f=g?.find(w=>w.id===i),y=gn(d.clips,[{op:"runAnalyzer",clipId:t.id,plugin:{id:i,...s?{item:s}:{},v:f?.version??a.version},values:J(a,{})}],[],d.timelineTracks);if(y.errors.length)throw Error(y.errors[0]);u(y.clips,t.id),p(e("“{0}” đang đọc clip “{1}” trên máy — xong sẽ tự áp (hoàn tác bằng ⌘Z)",[_(a,c),t.label]),"ok")},zn=()=>{if(!t)return"";const i=H.getState(),s=i.timelineMedia.find(w=>t.gcsUri&&w.gcsUri===t.gcsUri||w.url===t.url),a=t.playbackRate||1,d=t.inPoint||0,f=d+t.duration*a,y=w=>w.end>d&&w.start<f;return s?.words?.length?s.words.filter(y).map(w=>w.word).join(" "):(s?.transcript??[]).filter(y).map(w=>w.text).join(`
|
|
4
|
+
`)})},u));continue}const A=/^(#{1,4})\s+(.*)$/.exec(j);if(A){const c=Math.min(4,A[1].length+1),g=`h${c}`;o.push(n.jsx(g,{children:an(A[2],u)},u)),h++;continue}if(/^\|.*\|\s*$/.test(j)){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,T)=>n.jsx("td",{children:an(x,`${u}r${k}c${T}`)},T))},k))})]})},u));continue}if(/^\s*([-*]|\d+\.)\s+/.test(j)){const c=/^(\s*)([-*]|\d+\.)\s+/,g=/^\s*\d+\./.test(j),k=c.exec(j)[1].length,x=[];for(;h<l.length;){const r=c.exec(l[h]);if(r){const b=l[h].slice(r[0].length);if(r[1].length>k&&x.length)x[x.length-1].sub.push(b);else{if(r[1].length<k)break;x.push({text:b,sub:[]})}h++;continue}if(/^\s{2,}\S/.test(l[h])&&x.length){const b=x[x.length-1],G=l[h++].trim();b.sub.length?b.sub[b.sub.length-1]+=" "+G:b.text+=" "+G;continue}break}const T=g?"ol":"ul";o.push(n.jsx(T,{children:x.map((r,b)=>n.jsxs("li",{children:[an(r.text,`${u}-${b}`),r.sub.length>0&&n.jsx("ul",{children:r.sub.map((G,C)=>n.jsx("li",{children:an(G,`${u}-${b}-${C}`)},C))})]},b))},u));continue}if(j.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(!j.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 ke({onClose:t}){const l=wn(),[o,h]=N.useState(null),[j,u]=N.useState(!1);N.useEffect(()=>{let p=!0;return h(null),me(l).then(c=>{p&&h(c)},()=>{p&&u(!0)}),()=>{p=!1}},[l]),N.useEffect(()=>{const p=c=>{c.key==="Escape"&&(c.stopPropagation(),t())};return window.addEventListener("keydown",p,!0),()=>window.removeEventListener("keydown",p,!0)},[t]);const A=()=>{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&&t()},children:n.jsxs("div",{className:"tl-guide",role:"dialog","aria-modal":"true","aria-label":e("Hướng dẫn làm plug-in"),children:[n.jsxs("div",{className:"tl-guide-head",children:[n.jsxs("strong",{children:["📘 ",e("Hướng dẫn làm plug-in")]}),n.jsx("button",{className:"pill-btn thin",disabled:!o,onClick:A,children:e("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:[e("Mẫu Motion")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/like-subscribe.clipoox-plugin",download:!0,children:[e("Mẫu Lottie")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/talking-head-quick.clipoox-plugin",download:!0,children:[e("Mẫu công thức")," ⤓"]}),n.jsxs("a",{className:"pill-btn thin",href:"/plugin-samples/bds-starter.clipoox-plugin",download:!0,children:[e("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:e("Dán cho Claude / ChatGPT để AI viết plug-in theo đúng quy tắc của Clipoox"),children:[e("Plugin Dev Kit (cho AI)")," ⤓"]}),n.jsx("button",{className:"icon-btn","aria-label":e("Đóng"),onClick:t,children:"×"})]}),n.jsx("div",{className:"tl-guide-body",children:j?n.jsx("p",{className:"tl-plugin-error",children:e("Không tải được hướng dẫn.")}):o===null?n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải…")]}):n.jsx(N.Fragment,{children:pe(o)})})]})})}const Tn=[{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 xe({toast:t}){const[l,o]=N.useState(null),[h,j]=N.useState(""),[u,A]=N.useState(Tn.map(v=>v.id)),[p,c]=N.useState(null),[g,k]=N.useState(null),[x,T]=N.useState(""),r=()=>se().then(v=>o(v.endpoints)).catch(v=>T(X(v).text));N.useEffect(()=>{r()},[]);const b=v=>T(X(v).text),G=async()=>{c("add"),T("");try{const v=await le(h.trim(),u);k({id:v.id,value:v.secret}),j(""),await r(),t(e("Đã thêm webhook"),"ok")}catch(v){b(v)}finally{c(null)}},C=async v=>{c(v),T("");try{const O=await ae(v);t(O.status>=200&&O.status<300?e("Đã gửi thử — nơi nhận trả lời HTTP {0}",[O.status]):e("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){b(O)}finally{c(null)}},rn=async v=>{c(v);try{const O=await re(v);k({id:v,value:O.secret})}catch(O){b(O)}finally{c(null)}},V=async v=>{c(v);try{await ce(v),g?.id===v&&k(null),await r()}catch(O){b(O)}finally{c(null)}},Z=v=>e(Tn.find(O=>O.id===v)?.vi??v);return n.jsxs("details",{className:"tl-plugin-hooks",children:[n.jsxs("summary",{children:[n.jsxs("b",{children:["⚡ ",e("Tự động hoá (Webhook)")]})," ",n.jsx("small",{className:"muted",children:e("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"}),e("Đang tải…")]}),l&&l.length>0&&n.jsx("ul",{className:"tl-plugin-hook-list","aria-label":e("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?` · ${e("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,e("Gửi thử")]}),n.jsx("button",{className:"pill-btn thin",disabled:!!p,onClick:()=>void rn(v.id),children:e("Đổi khoá")}),n.jsx("button",{className:"pill-btn thin danger",disabled:!!p,"aria-label":e("Xoá webhook {0}",[v.url]),onClick:()=>void V(v.id),children:"✕"})]}),g?.id===v.id&&n.jsxs("p",{className:"tl-plugin-hook-secret",role:"status",children:[e("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),t(e("Đã chép khoá"),"ok")},children:e("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":e("Link webhook (https)"),value:h,onChange:v=>j(v.target.value)}),n.jsx("div",{className:"tl-plugin-hook-events",role:"group","aria-label":e("Gửi khi"),children:Tn.map(v=>n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:u.includes(v.id),onChange:O=>A(cn=>O.target.checked?[...cn,v.id]:cn.filter(S=>S!==v.id))}),e(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,e("Thêm webhook")]})]}),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",x]}),n.jsx("small",{className:"muted",children:e("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 fe=N.lazy(()=>Ln(()=>import("./PluginStore-BVsm6n6N.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,26]))),si=[{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"}],be={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"}},je={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=(t,l)=>be[t][l==="en"?"en":"vi"],Nn=t=>t.kind==="pack"&&!!t.assets?.some(l=>l.kind==="model"),$n=(t,l)=>Bn(Nn(t)?"kit":t.kind==="motion"&&t.engine==="3d"?"motion3d":t.kind,l),ve={motion3d:["3D","3D"],model:["MÔ HÌNH","MODEL"],lut:["LOOK","LOOK"],motion:["2D","2D"],recipe:["COMBO","COMBO"],lottie:["LOTTIE","LOTTIE"]},ye=(t,l)=>{const o=t.kind==="motion"&&t.engine==="3d"?"motion3d":t.kind,h=ve[o];return h?h[l==="en"?1:0]:""},Gn=1024*1024;function Ne(t,l){const o=t.facts??{},h=u=>u.toLocaleString(l==="en"?"en-US":"vi-VN"),j=t.bytes!==void 0?t.bytes>=Gn?`${(t.bytes/Gn).toFixed(1).replace(".",l==="en"?".":",")} MB`:`${Math.max(1,Math.round(t.bytes/1024))} KB`:"";return t.kind==="model"?[j,e("{0} tam giác",[h(o.triangles??0)]),...o.images?.length?[e("{0} ảnh nhúng",[o.images.length])]:[],...o.animations?.length?[e("animation: {0}",[o.animations.slice(0,3).join(", ")])]:[],e("không có link ngoài")].join(" · "):t.kind==="sequence"?[j,e("{0} khung {1} × {2}",[o.frames??0,o.width??0,o.height??0])].join(" · "):t.kind==="lut"?[j,e("LUT 3D {0}³",[o.size??0])].join(" · "):[j,`${o.width??0} × ${o.height??0}`,...t.sprite?[e("sprite {0} × {1} = {2} khung",[t.sprite.cols,t.sprite.rows,t.sprite.frames])]:[]].join(" · ")}const hi=t=>`clipoox:kit-controls:${t}`;function we(t){try{const l=JSON.parse(localStorage.getItem(hi(t))||"{}");return l&&typeof l=="object"&&!Array.isArray(l)?l:{}}catch{return{}}}function _e(t,l){try{localStorage.setItem(hi(t),JSON.stringify(l))}catch{}}const Se=["#3ee6ff","#c6f432","#ff5fa2","#ffb547","#9d7bff","#ffffff"],Ce={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}"]},li=t=>t.source?.store?` · ${e("Kho")}`:t.source?.dev?` · ${e("Bản thử – chưa duyệt")}`:"",Me=t=>t.recipe?{...t,recipe:{ops:t.recipe.ops.filter(l=>l.op!=="usePlugin")}}:t;async function ai(t){const l=j=>{const u=j;return u.op==="addMap"&&!u.geo||u.op==="updateMap"&&Array.isArray(u.places)};if(!t.some(l))return{ops:t,errors:[]};const o=[],h=[];for(const j of t){if(!l(j)){o.push(j);continue}const u=await Ei([j]);u.ops.length===1?o.push(u.ops[0]):h.push(...u.errors)}return{ops:o,errors:h}}const In=(t,l)=>Object.fromEntries(t.params.filter(o=>o.type!=="image").map(o=>[o.key,l[o.key]]));function Pe({selected:t,time:l,aspect:o,materials:h,locked:j,onCommit:u,onPatch:A,toast:p}){const c=wn(),[g,k]=N.useState(null),[x,T]=N.useState(null),[r,b]=N.useState(null),[G,C]=N.useState(null),[rn,V]=N.useState(null),[Z]=N.useState(()=>Ii()),[v,O]=N.useState(!1),[cn,S]=N.useState(!!Z),[M,K]=N.useState(null),[B,F]=N.useState(null),[pn,qn]=N.useState({}),[vn,Kn]=N.useState("all"),[P,on]=N.useState(null),_n=i=>{F({id:i.id}),Kn("all"),qn(s=>({...s,[i.id]:{...Object.fromEntries((i.manifest.controls??[]).map(a=>[a.key,a.default])),...we(i.id)}})),ni(i).then(s=>F(a=>a?.id===i.id?{id:i.id,index:s}:a),s=>F(a=>a?.id===i.id?{id:i.id,error:X(s).text}:a))},Fn=N.useRef(null),[ui,Un]=N.useState(""),gi=i=>{S(!1),Qn().then(s=>{k(s.plugins);const a=s.plugins.find(d=>d.id===i);a&&(a.kind==="pack"&&B?.id!==i&&_n(a),Un(i),window.setTimeout(()=>Un(d=>d===i?"":d),3400),requestAnimationFrame(()=>document.querySelector(`[data-plugin="${CSS.escape(i)}"]`)?.scrollIntoView({block:"center",behavior:"smooth"})))},()=>{})},Q=N.useCallback(()=>Qn().then(i=>{k(i.plugins),T(null)},i=>{k(s=>s??[]),T(X(i).text)}),[]);N.useEffect(()=>{Q()},[Q]),N.useEffect(()=>{Z&&qi()},[Z]);const en=i=>{const s=X(i);p(s.detail?`${s.text} (${s.detail})`:s.text,"error")},mi=async i=>{b({file:i.name,stage:"reading"});try{if(await Ui(i)){const y=await Di(i),w=g?.find(L=>L.id===y.manifest.id);b({file:i.name,stage:"review",sfx:y,...w?{exists:{installed:w.version,newer:yn(y.manifest.version,w.version)>0}}:{}});return}const{bytes:s,...a}=await zi(i);if(a.manifest.kind==="pack"){const y=a.items,w=[];let L=a.thumbnail;b({file:i.name,stage:"checking",bundle:a,pack:{bytes:s,checks:[],total:y.length}});const m=Ri(a,Math.random().toString(36).slice(2,8));try{for(const E of y){const z=await Yn(Me(E),o,{assets:m.refs,readAsset:a.readAsset}).catch(R=>({ok:!1,lines:[],thumbnail:null,error:R.message}));L??=z.thumbnail,w.push({id:E.manifest.id,name:_(E.manifest,c),kind:E.manifest.kind==="motion"&&E.manifest.engine==="3d"?"motion3d":E.manifest.kind,ok:z.ok,warn:z.lines.some(R=>R.warn),...z.error?{error:z.error}:{}}),b(R=>R&&{...R,pack:{bytes:s,checks:[...w],total:y.length}})}}finally{m.drop()}const $=w.find(E=>!E.ok),q=g?.find(E=>E.id===a.manifest.id);b({file:i.name,stage:"review",bundle:{...a,thumbnail:L},pack:{bytes:s,checks:w,total:y.length},...$?{error:{text:e("Mục “{0}” không chạy được",[$.name]),detail:$.error??""}}:{},...q?{exists:{installed:q.version,newer:yn(a.manifest.version,q.version)>0}}:{}});return}b({file:i.name,stage:"checking",bundle:a});const d=await Yn(a,o),f=g?.find(y=>y.id===a.manifest.id);b({file:i.name,stage:"review",bundle:a,check:d,...d.ok?{}:{error:X({code:d.error==="nondeterministic"||d.error==="dryrun"?d.error:"code",message:d.error})},...f?{exists:{installed:f.version,newer:yn(a.manifest.version,f.version)>0}}:{}})}catch(s){b({file:i.name,stage:"review",error:X(s)})}},pi=async()=>{const i=r;if(i?.sfx){const s=i.sfx;b({...i,stage:"saving",progress:{stage:"upload",pct:0}});try{const a=await Wi(s,!!i.exists,(d,f)=>b(y=>y&&{...y,progress:{stage:d,pct:f}}));b(null),await Q(),bn(),p(a.updated?e("Đã cập nhật “{0}” lên v{1}",[_(a.plugin.manifest,c),a.plugin.version]):e("Đã 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 f=d.data;b({...i,stage:"review",progress:void 0,exists:{installed:f.installed,newer:f.newer}});return}b({...i,stage:"review",progress:void 0,error:X(a)})}return}if(i?.pack&&i.bundle){const s=i.pack,a=i.bundle.manifest;b({...i,stage:"saving",progress:{stage:"upload",pct:0}});try{const d=await Hi(s.bytes,a,i.file,!!i.exists,f=>b(y=>y&&{...y,progress:{stage:"upload",pct:f}}));b(null),await Q(),bn(),_n(d.plugin),p(d.updated?e("Đã cập nhật “{0}” lên v{1}",[_(d.plugin.manifest,c),d.plugin.version]):Nn(d.plugin.manifest)?e("Đã thêm bộ 3D “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]):e("Đã thêm gói “{0}” ({1} mục)",[_(d.plugin.manifest,c),d.items]),"ok")}catch(d){const f=d;if(f.code==="exists"){const y=f.data;b({...i,stage:"review",progress:void 0,exists:{installed:y.installed,newer:y.newer}});return}b({...i,stage:"review",progress:void 0,error:X(d)})}return}if(!(!i?.bundle||!i.check?.ok)){b({...i,stage:"saving"});try{const s=await Xi({...i.bundle,thumbnail:i.check.thumbnail??i.bundle.thumbnail},!!i.exists);b(null),await Q(),bn(),p(s.updated?e("Đã cập nhật “{0}” lên v{1}",[_(s.plugin.manifest,c),s.plugin.version]):e("Đã thêm plug-in “{0}”",[_(s.plugin.manifest,c)]),"ok")}catch(s){const a=s;if(a.code==="exists"){const d=a.data;b({...i,stage:"review",exists:{installed:d.installed,newer:d.newer}});return}b({...i,stage:"review",error:X(s)})}}},dn=i=>Pi(Math.max(0,Math.min(l,Ti-i))),ki=async i=>{if(!G){if(i.kind==="sfx"||i.kind==="sfxlib"){Hn(s=>s===i.id?null:i.id);return}if(i.kind==="pack"){B?.id===i.id?F(null):_n(i);return}C(i.id);try{const s=await oi(i,k),a=s.manifest,d=_(a,c),f=H.getState();if(a.kind==="recipe"){K({id:i.id,values:J(a,{}),bundle:s});return}if(a.kind==="analyzer"){Dn(i.id,void 0,a);return}if(a.kind==="ai-template"){on({id:i.id,values:J(a,{}),bundle:s});return}if(a.kind==="motion"){const U=di(a,s.entry,{}),Y=dn(a.duration),sn=gn(f.clips,[{op:"addMotion",code:U.code,params:U.params,motionPreset:U.preset,...U.kind?{motionKind:U.kind}:{},label:`Plug-in · ${d}`,start:Y,duration:a.duration}],[],f.timelineTracks);if(sn.errors.length)throw Error(sn.errors[0]);const I=sn.clips.find(W=>!f.clips.some(nn=>nn.id===W.id));u(sn.clips.map(W=>W.id===I?.id?{...W,plugin:{id:a.id,v:a.version,kind:"motion"}}:W),I?.id);return}const y=J(a,{}),w=await En(s.lottie,a,y),L=await On(a.id,w),m=ti(s),$=dn(m),q={id:L.gcsUri,kind:"lottie",url:L.url,gcsUri:L.gcsUri,label:d,lottie:s.lottie.meta},E=H.getState(),z=gn(E.clips,[{op:"addClip",materialId:q.id,start:$,duration:m}],[q],E.timelineTracks);if(z.errors.length)throw Error(z.errors[0]);const R=z.clips.find(U=>!E.clips.some(Y=>Y.id===U.id));u(z.clips.map(U=>U.id===R?.id?{...U,label:`Plug-in · ${d}`,lottie:{...U.lottie,loop:a.loop!==!1},plugin:{id:a.id,v:a.version,kind:"lottie",params:In(a,y)}}:U),R?.id)}catch(s){en(s)}finally{C(null)}}},xi=async(i,s)=>{if(!G){C(`${i.id}/${s}`);try{const a=(await ni(i)).items.find(I=>I.manifest.id===s)?.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=pn[i.id]??{};if(a.kind==="lut"&&!t)throw ii("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 ei([{op:"usePlugin",pluginId:`${i.id}/${s}`,params:nn,...a.kind==="lut"?{clipId:t.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),Ci=Zn.find(ln=>!D.clips.some(Mi=>Mi.id===ln.id));u(Zn,Ci?.id??t?.id??null),a.kind==="lut"&&p(e("Đã áp look “{0}” cho “{1}” (chỉnh độ mạnh ở tab Màu)",[_(a,c),t.label]),"ok");return}const d=await ri(i,s),f=d.manifest,y=_(f,c),w=H.getState(),L={id:i.id,item:s,v:i.version};if(f.kind==="recipe"){K({id:i.id,item:s,values:J(f,{}),bundle:d});return}if(f.kind==="analyzer"){Dn(i.id,s,f);return}if(f.kind==="ai-template"){on({id:i.id,item:s,values:J(f,{}),bundle:d});return}if(f.kind==="motion"){const I=ci(i.id,s,d,{}),W=dn(f.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:f.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:{...L,kind:"motion"}}:D),hn?.id);return}const m=J(f,{}),$=await En(d.lottie,f,m),q=await On(i.id,$),E=ti(d),z=dn(E),R={id:q.gcsUri,kind:"lottie",url:q.url,gcsUri:q.gcsUri,label:y,lottie:d.lottie.meta},U=H.getState(),Y=gn(U.clips,[{op:"addClip",materialId:R.id,start:z,duration:E}],[R],U.timelineTracks);if(Y.errors.length)throw Error(Y.errors[0]);const sn=Y.clips.find(I=>!U.clips.some(W=>W.id===I.id));u(Y.clips.map(I=>I.id===sn?.id?{...I,label:`Plug-in · ${y}`,lottie:{...I.lottie,loop:f.loop!==!1},plugin:{...L,kind:"lottie",params:In(f,m)}}:I),sn?.id)}catch(a){en(a)}finally{C(null)}}},Dn=(i,s,a)=>{if(!t||t.kind!=="video")throw ii("needs_video");const d=H.getState(),f=g?.find(w=>w.id===i),y=gn(d.clips,[{op:"runAnalyzer",clipId:t.id,plugin:{id:i,...s?{item:s}:{},v:f?.version??a.version},values:J(a,{})}],[],d.timelineTracks);if(y.errors.length)throw Error(y.errors[0]);u(y.clips,t.id),p(e("“{0}” đang đọc clip “{1}” trên máy — xong sẽ tự áp (hoàn tác bằng ⌘Z)",[_(a,c),t.label]),"ok")},zn=()=>{if(!t)return"";const i=H.getState(),s=i.timelineMedia.find(w=>t.gcsUri&&w.gcsUri===t.gcsUri||w.url===t.url),a=t.playbackRate||1,d=t.inPoint||0,f=d+t.duration*a,y=w=>w.end>d&&w.start<f;return s?.words?.length?s.words.filter(y).map(w=>w.word).join(" "):(s?.transcript??[]).filter(y).map(w=>w.text).join(`
|
|
5
5
|
`)},Rn=()=>({plugin:P.item?`${P.id}/${P.item}`:P.id,params:P.values,transcript:zn(),title:t?.label??"",duration:t?.duration??0,source:t?.id}),fi=async()=>{if(!(!P||G)){C(`ai:${P.id}`);try{const i=await oe(Rn());on(s=>s&&{...s,price:i.max_credits,doc:void 0})}catch(i){p(X(i).text,"error")}finally{C(null)}}},bi=async()=>{if(!(!P?.price||G)){C(`ai:${P.id}`);try{const i=await de(Rn(),P.price);on(s=>s&&{...s,doc:i}),p(e("Đã viết “{0}” — {1} credit",[i.title,i.credits]),"ok")}catch(i){p(X(i).text,"error")}finally{C(null)}}},ji=i=>{const s=i.format==="json"?"json":"md",a=i.format==="json"&&i.json!==void 0?JSON.stringify(i.json,null,2):i.text,d=Object.assign(document.createElement("a"),{href:URL.createObjectURL(new Blob([a],{type:i.format==="json"?"application/json":"text/markdown"})),download:`${i.title.replace(/[\\/:*?"<>|]+/g,"-").slice(0,80)||"clipoox"}.${s}`});d.click(),setTimeout(()=>URL.revokeObjectURL(d.href),2e3)},vi=async()=>{if(!(!M||G)){C(M.id);try{const i=H.getState(),s=t;if(M.item){const w=await ei([{op:"usePlugin",pluginId:`${M.id}/${M.item}`,params:M.values,...s?{clipId:s.id}:{}}],{items:g??[],clips:i.clips,playhead:l,locale:c}),L=await ai(w.ops),m=Mn(i.clips,L.ops,[...h,...w.materials],i.timelineTracks,i.timelineCamera,{W:o.width,H:o.height,motion:i.timelineMotion,brand:i.timelineBrand}),$=_(M.bundle.manifest,c),q=[...L.errors,...m.skipped.map(E=>E.error)];if(!m.result||!m.ops.length){p(e("“{0}” không áp dụng được bước nào: {1}",[$,q[0]??"—"]),"error");return}u(w.tagPlugins(i.clips,m.result.clips),null),p(q.length?e("Đã chạy “{0}”: {1} bước. Bỏ qua: {2}",[$,m.ops.length,q.join("; ")]):e("Đã chạy “{0}”: {1} bước (hoàn tác bằng ⌘Z)",[$,m.ops.length]),m.ops.length?"ok":"error");return}const a=await ai(Ji(M.bundle,M.values,{clip:s?.id??null,playhead:l,clipStart:s?.start??null,clipEnd:s?s.start+s.duration:null})),d=Mn(i.clips,a.ops,h,i.timelineTracks,i.timelineCamera,{W:o.width,H:o.height,motion:i.timelineMotion,brand:i.timelineBrand}),f=_(M.bundle.manifest,c),y=[...a.errors,...d.skipped.map(w=>w.error)];if(!d.result||!d.ops.length){p(e("“{0}” không áp dụng được bước nào: {1}",[f,y[0]??"—"]),"error");return}u(d.result.clips,null),p(y.length?e("Đã chạy “{0}”: {1} bước. Bỏ qua: {2}",[f,d.ops.length,y.join("; ")]):e("Đã chạy “{0}”: {1} bước (hoàn tác bằng ⌘Z)",[f,d.ops.length]),d.ops.length?"ok":"error")}catch(i){en(i)}finally{C(null)}}},Wn=(i,s)=>{qn(a=>({...a,[i]:s})),_e(i,s)},yi=i=>H.getState().clips.filter(s=>s.plugin?.id===i&&s.plugin?.kind==="motion"&&s.motion),Ni=(i,s)=>{const a=pn[i.id]??{},d=H.getState(),f=new Map(s.items.map(L=>[L.manifest.id,L.manifest]));let y=0;const w=d.clips.map(L=>{const m=L.plugin,$=m?.id===i.id&&m.item?f.get(m.item):void 0;if(!$||!L.motion)return L;const q=Object.fromEntries($.params.filter(E=>E.link&&a[E.link]!==void 0).map(E=>[E.key,a[E.link]]));return Object.keys(q).length?(y++,{...L,motion:{...L.motion,params:{...L.motion.params,...q}}}):L});if(!y){p(e("Chưa có lớp nào của bộ này trong dự án."),"error");return}u(w,null),p(e("Đã áp điều khiển chung cho {0} lớp (hoàn tác bằng ⌘Z)",[y]),"ok")},wi=async i=>{V(null);try{await ne(i.id,!i.enabled),await Q(),bn()}catch(s){en(s)}},[tn,Hn]=N.useState(null),[Sn,Xn]=N.useState(""),Jn=async i=>{const s=Vi(i);if(!(!s||Sn)){Xn(i);try{const a=await Zi(s.pack,s.sound),d=H.getState(),f=gn(d.clips,[{op:"addSfx",sfxId:i,at:dn(a.duration),volume:$i,sound:a}],[],d.timelineTracks);if(f.errors.length)throw Error(f.errors[0]);u(f.clips,f.clips.find(y=>!d.clips.some(w=>w.id===y.id))?.id??null)}catch(a){en(a)}finally{Xn("")}}},_i=async i=>{if(V(null),!!window.confirm(e("Gỡ plug-in “{0}”? Các lớp đã thêm vào video vẫn giữ nguyên.",[_(i.manifest,c)])))try{await ie(i.id),await Q(),bn(),tn===i.id&&Hn(null),p(e("Đã gỡ “{0}”",[_(i.manifest,c)]),"ok")}catch(s){en(s)}},kn=t,xn=kn?.plugin,Si=xn?g?.find(i=>i.id===xn.id):void 0,fn=(g??[]).filter(i=>i.enabled),Cn=(g??[]).filter(i=>!i.enabled),Vn=i=>n.jsxs("div",{className:`tl-plugin-tile${i.enabled?"":" off"}${ui===i.id?" flash":""}`,"data-plugin":i.id,children:[n.jsxs("button",{className:`tl-plugin-use${tn===i.id||B?.id===i.id?" on":""}`,disabled:!i.enabled||!!G,"aria-expanded":i.kind==="sfx"||i.kind==="sfxlib"?tn===i.id:i.kind==="pack"?B?.id===i.id:void 0,"aria-label":i.kind==="recipe"?e("Mở công thức {0}",[_(i.manifest,c)]):i.kind==="sfx"?e("Mở gói âm thanh {0}",[_(i.manifest,c)]):i.kind==="sfxlib"?e("Mở kho âm thanh {0}",[_(i.manifest,c)]):i.kind==="pack"?e("Mở gói {0}",[_(i.manifest,c)]):e("Thêm plug-in {0}",[_(i.manifest,c)]),onClick:()=>void ki(i),children:[n.jsxs("span",{className:"tl-plugin-thumb",children:[i.thumbnailUrl?n.jsx("img",{src:i.thumbnailUrl,alt:"",loading:"lazy",onError:s=>{s.currentTarget.style.visibility="hidden"}}):n.jsx("b",{children:i.kind==="analyzer"?"⌖":i.kind==="ai-template"?"✎":i.kind==="recipe"?"▶":i.kind==="sfx"?"♪":i.kind==="sfxlib"?"📚":Nn(i.manifest)?"◈":i.kind==="pack"?"⧉":"✦"}),G===i.id&&n.jsx("i",{className:"spin"})]}),n.jsxs("span",{className:"tl-plugin-name",children:[n.jsx("strong",{title:_(i.manifest,c),children:_(i.manifest,c)}),n.jsxs("small",{children:[$n(i.manifest,c),i.kind==="sfx"?` · ${e("{0} âm thanh",[i.manifest.sounds?.length??0])}`:""," · v",i.version,i.kind==="pack"?` · ${e("{0} mục",[i.manifest.items?.length??0])}`:"",li(i),i.enabled?"":` · ${e("Đã tắt")}`]})]})]}),n.jsx("button",{className:"tl-plugin-more","aria-label":e("Tuỳ chọn {0}",[_(i.manifest,c)]),"aria-expanded":rn===i.id,onClick:()=>V(s=>s===i.id?null:i.id),children:"⋯"}),rn===i.id&&n.jsxs("div",{className:"tl-plugin-menu",role:"menu",children:[n.jsx("p",{children:mn(i.manifest,c)||"—"}),n.jsxs("small",{className:"muted",children:[e("Tác giả"),": ",i.manifest.author.name,i.manifest.author.url?` · ${i.manifest.author.url}`:""]}),n.jsx("button",{role:"menuitem",onClick:()=>void wi(i),children:i.enabled?e("Tắt plug-in"):e("Bật plug-in")}),n.jsx("button",{role:"menuitem",className:"danger",onClick:()=>void _i(i),children:e("Gỡ plug-in")})]})]},i.id);return n.jsxs("section",{className:"tl-plugins","aria-label":e("Plug-in của tôi"),children:[n.jsxs("div",{className:"tl-plugins-head",children:[n.jsxs("div",{children:[n.jsx("h4",{children:e("Plug-in của tôi")}),n.jsx("small",{className:"muted",children:e("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:["🛍 ",e("Kho Plug-in")]}),n.jsxs("button",{className:"pill-btn",disabled:!!r&&r.stage!=="review",onClick:()=>Fn.current?.click(),children:["+ ",e("Thêm plug-in")]}),n.jsxs("button",{className:"pill-btn",onClick:()=>O(!0),children:["📘 ",e("Hướng dẫn plug-in")]})]}),n.jsx("input",{ref:Fn,type:"file",hidden:!0,"aria-label":e("Chọn file plug-in"),accept:".clipoox-plugin,.zip,application/zip",onChange:i=>{const s=i.target.files?.[0];i.target.value="",s&&mi(s)}})]}),r&&n.jsxs("div",{className:`tl-plugin-review${r.error?" bad":""}`,role:"dialog","aria-label":e("Kiểm tra plug-in"),children:[r.stage==="reading"&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang đọc {0}…",[r.file])]}),r.stage==="checking"&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang chạy thử trong sandbox…")]}),r.sfx&&n.jsx(he,{review:r.sfx}),r.progress&&n.jsxs("p",{className:"tl-plugin-step",role:"status",children:[n.jsx("i",{className:"spin"}),r.progress.stage==="upload"?e("Đang tải gói lên… {0}%",[r.progress.pct??0]):r.pack?e("Máy chủ đang kiểm tra từng mục…"):e("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:[$n(r.bundle.manifest,c)," · v",r.bundle.manifest.version," · ",r.bundle.manifest.author.name]}),n.jsx("p",{children:mn(r.bundle.manifest,c)}),n.jsxs("small",{className:"muted",children:[r.bundle.manifest.kind==="pack"?e("{0} mục",[r.bundle.manifest.items?.length??0]):e("{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?` · ${e("đã 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:e("Tài nguyên ({0})",[r.bundle.assets.length])}),n.jsxs("ul",{className:"tl-plugin-checks","aria-label":e("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:e("Gói {0} MB",[((r.pack?.bytes.length??0)/Gn).toFixed(1).replace(".",c==="en"?".":",")])})," ",n.jsxs("small",{className:"muted",children:["— ",e("giới hạn 200 MB · GLB ≤ 20 MB, ≤ 300 000 tam giác")]})]})]}),r.bundle.assets.slice(0,12).map(i=>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.name})," ",n.jsxs("small",{className:"muted",children:["— ",Ne(i,c)]})]})]},i.name)),r.bundle.assets.length>12&&n.jsxs("li",{className:"ok",children:[n.jsx("span",{"aria-hidden":!0,children:"✓"}),e("+ {0} tài nguyên khác",[r.bundle.assets.length-12])]})]}),n.jsx("h6",{className:"tl-plugin-subhead",children:e("Chạy thử từng mục")})]}),r.pack&&n.jsxs("ul",{className:"tl-plugin-checks","aria-label":e("Chạy thử từng mục"),children:[r.stage==="checking"&&n.jsxs("li",{className:"ok",children:[n.jsx("i",{className:"spin"}),e("Đang chạy thử mục {0} / {1}…",[r.pack.checks.length+1,r.pack.total])]}),r.pack.checks.map(i=>n.jsxs("li",{className:i.ok?i.warn?"warn":"ok":"bad",children:[n.jsx("span",{"aria-hidden":!0,children:i.ok?i.warn?"!":"✓":"✕"}),i.name," ",n.jsx("small",{className:"muted",children:Bn(i.kind,c)}),i.error&&n.jsxs("small",{children:[" — ",i.error]})]},i.id))]}),r.check&&n.jsx("ul",{className:"tl-plugin-checks",children:r.check.lines.map((i,s)=>{const[a,d]=Ce[i.key],f=!i.ok||i.warn;return n.jsxs("li",{className:i.ok?i.warn?"warn":"ok":"bad",children:[n.jsx("span",{"aria-hidden":!0,children:i.ok?i.warn?"!":"✓":"✕"}),e(f&&d?d:a,i.key==="permission"?[e(je[String(i.args?.[0])]??String(i.args?.[0]))]:i.args??[]),i.detail&&n.jsxs("small",{children:[" — ",i.detail]})]},s)})}),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 i=(r.bundle??r.sfx).manifest.version;return n.jsx("p",{className:"tl-plugin-note",children:r.exists.newer?e("Đã cài v{0}. Cập nhật lên v{1}?",[r.exists.installed,i]):e("Đã cài v{0} — cài lại bản v{1} này?",[r.exists.installed,i])})})(),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 pi(),children:r.exists?r.exists.newer?e("Cập nhật plug-in"):e("Cài lại plug-in"):e("Cài plug-in")}),r.stage==="saving"&&n.jsxs("button",{className:"pill-btn accent",disabled:!0,children:[n.jsx("i",{className:"spin"}),e("Đang lưu…")]}),n.jsx("button",{className:"pill-btn",disabled:r.stage==="saving",onClick:()=>b(null),children:r.error?e("Đóng"):e("Huỷ")})]})]}),xn&&kn&&n.jsx($e,{clip:kn,pref:xn,item:Si,materials:h,locked:j,onPatch:A,toast:p,fail:en},`${kn.id}:${kn.url}:${xn.v}`),M&&(()=>{const i=M.bundle.manifest,s=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":e("Công thức {0}",[_(i,c)]),children:[n.jsxs("h5",{children:["▶ ",_(i,c)," ",n.jsxs("small",{className:"muted",children:["v",i.version]})]}),n.jsx("p",{className:"muted",children:mn(i,c)}),i.params.length>0&&n.jsx("div",{className:"tl-plugin-params",children:i.params.map(d=>n.jsx(jn,{p:d,value:M.values[d.key],locale:c,disabled:!1,onBegin:()=>{},onChange:f=>K(y=>y&&{...y,values:{...y.values,[d.key]:f}})},d.key))}),a&&n.jsx("small",{className:t?"muted":"tl-warn",children:t?e("Áp dụng cho clip đang chọn: {0}",[t.label]):e("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&&!t||!s?.enabled,onClick:()=>void vi(),children:G===M.id?e("Đang chạy…"):e("Chạy công thức")}),n.jsx("button",{className:"pill-btn",onClick:()=>K(null),children:e("Đóng")})]})]})})(),P&&(()=>{const i=P.bundle.manifest,s=g?.find(f=>f.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":e("Mẫu AI {0}",[_(i,c)]),children:[n.jsxs("h5",{children:["✎ ",_(i,c)," ",n.jsxs("small",{className:"muted",children:["v",i.version," · ",e("Mẫu AI")]})]}),n.jsx("p",{className:"muted",children:mn(i,c)}),i.params.length>0&&n.jsx("div",{className:"tl-plugin-params",children:i.params.map(f=>n.jsx(jn,{p:f,value:P.values[f.key],locale:c,disabled:d,onBegin:()=>{},onChange:y=>on(w=>w&&{...w,values:{...w.values,[f.key]:y},price:void 0})},f.key))}),n.jsx("small",{className:t&&a?"muted":"tl-warn",children:t?a?e("Đọc lời thoại của: {0}",[t.label]):e("Clip “{0}” chưa có lời thoại — bấm Transcript cho clip trước.",[t.label]):e("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:e("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||!t||!a||!s?.enabled,onClick:()=>void fi(),children:[d?n.jsx("i",{className:"spin"}):null,e("Xem giá")]}):n.jsxs("button",{className:"pill-btn accent",disabled:!!G,onClick:()=>void bi(),children:[d?n.jsx("i",{className:"spin"}):null,e("Chạy (tối đa {0} credit)",[P.price])]}),n.jsx("button",{className:"pill-btn",onClick:()=>on(null),children:e("Đóng")})]}),P.doc&&n.jsxs("div",{className:"tl-plugin-doc",children:[n.jsx("textarea",{readOnly:!0,"aria-label":e("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(e("Đã chép tài liệu"),"ok")},children:e("Chép")}),n.jsx("button",{className:"pill-btn thin",onClick:()=>ji(P.doc),children:P.doc.format==="json"?e("Tải .json"):e("Tải .md")}),n.jsx("small",{className:"muted",children:e("{0} credit · đã gửi tới webhook (nếu có)",[P.doc.credits])})]})]})]})})(),x&&n.jsxs("p",{className:"tl-plugin-error",role:"alert",children:["⚠ ",e("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"}),e("Đ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:e("Chưa có plug-in nào")}),n.jsx("p",{children:e("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:["🛍 ",e("Mở Kho Plug-in")]}),n.jsxs("button",{className:"pill-btn",onClick:()=>O(!0),children:["📘 ",e("Đọc hướng dẫn làm plug-in")]}),n.jsxs("div",{className:"tl-plugins-samples",children:[n.jsx("small",{className:"muted",children:e("Thử {0} plug-in mẫu:",[si.length])}),si.map(i=>n.jsxs("a",{className:"pill-btn thin",href:`/plugin-samples/${i.file}`,download:!0,children:[Bn(i.kind,c)," ⤓"]},i.file))]})]}),fn.length>0&&n.jsx("div",{className:"tl-plugin-grid",children:fn.map(Vn)}),(()=>{const i=tn?fn.find(s=>s.id===tn&&s.kind==="sfxlib"):void 0;return i?n.jsxs("section",{className:"tl-plugin-pack","aria-label":e("Âm thanh trong {0}",[_(i.manifest,c)]),children:[n.jsx("small",{className:"muted sfxlib-hint",children:e("cũng có trong mục SFX (tab Âm thanh)")}),n.jsx(Ki,{item:i,busy:Sn,onAdd:s=>void Jn(s)})]}):null})(),(()=>{const i=tn?fn.find(s=>s.id===tn&&s.kind==="sfx"):void 0;return i?n.jsxs("section",{className:"tl-plugin-pack","aria-label":e("Âm thanh trong {0}",[_(i.manifest,c)]),children:[n.jsxs("h5",{children:["♪ ",_(i.manifest,c)," ",n.jsxs("small",{className:"muted",children:[e("{0} âm thanh",[i.manifest.sounds?.length??0])," · ",e("cũng có trong mục SFX (tab Âm thanh)")]})]}),n.jsx(Fi,{packs:[i],busy:Sn,showPack:!1,onAdd:s=>void Jn(s)})]}):null})(),(()=>{const i=B?fn.find(m=>m.id===B.id&&m.kind==="pack"):void 0;if(!i||!B)return null;const s=B.index,a=Nn(i.manifest),d=s?.manifest.controls??[],f=s?.manifest.categories??[],y=pn[i.id]??{},w=s?s.items.filter(m=>vn==="all"||m.manifest.category===vn):[],L=a&&d.length?yi(i.id).length:0;return n.jsxs("section",{className:`tl-plugin-pack${a?" kit":""}`,"aria-label":e("Các mục trong {0}",[_(i.manifest,c)]),children:[n.jsxs("h5",{children:[a?"◈":"⧉"," ",_(i.manifest,c)," ",n.jsxs("small",{className:"muted",children:[e("{0} mục",[i.manifest.items?.length??0]),li(i)," · ",a?e("bấm một mục để thêm vào playhead; look áp lên clip đang chọn"):e("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]}),!s&&!B.error&&n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải gói…")]}),d.length>0&&n.jsxs("div",{className:"tl-kit-controls",role:"group","aria-label":e("Điều khiển chung của bộ"),children:[n.jsxs("h6",{children:[e("Điều khiển chung của bộ")," ",n.jsx("small",{className:"muted",children:e("á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:$=>Wn(i.id,{...y,[m.key]:$})}),m.type==="color"&&n.jsx("span",{className:"tl-kit-swatches",role:"group","aria-label":e("Màu gợi ý"),children:Se.map($=>n.jsx("button",{type:"button",className:String(y[m.key]).toLowerCase()===$?"on":"",style:{background:$},"aria-label":$,onClick:()=>Wn(i.id,{...y,[m.key]:$})},$))})]},m.key))}),n.jsx("button",{className:"pill-btn thin",disabled:j||!L||!s,onClick:()=>s&&Ni(i,s),children:e("Áp cho {0} lớp của bộ trong dự án",[L])})]}),f.length>0&&s&&n.jsx("div",{className:"tl-kit-chips",role:"group","aria-label":e("Nhóm"),children:[{id:"all",name:{vi:"Tất cả",en:"All"}},...f].map(m=>{const $=m.id==="all"?s.items.length:s.items.filter(q=>q.manifest.category===m.id).length;return $||m.id==="all"?n.jsxs("button",{type:"button",className:`tl-kit-chip${vn===m.id?" on":""}`,"aria-pressed":vn===m.id,onClick:()=>Kn(m.id),children:[m.name[c==="en"?"en":"vi"]," ",n.jsx("span",{children:$})]},m.id):null})}),s&&n.jsx("div",{className:`tl-plugin-items${a?" kit":""}`,children:w.map(({manifest:m,thumbnail:$})=>{const q=`${i.id}/${m.id}`,E=a?ye(m,c):"";return n.jsxs("button",{className:"tl-plugin-item","data-item":m.id,"data-kind":m.kind,disabled:!!G,title:mn(m,c),"aria-label":m.kind==="recipe"?e("Mở công thức {0}",[_(m,c)]):m.kind==="lut"?e("Áp look {0} cho clip đang chọn",[_(m,c)]):e("Thêm {0}",[_(m,c)]),onClick:()=>void xi(i,m.id),children:[n.jsxs("span",{className:"tl-plugin-thumb",children:[$?n.jsx("img",{src:`data:${$.type};base64,${$.data}`,alt:""}):n.jsx("b",{children:m.kind==="analyzer"?"⌖":m.kind==="ai-template"?"✎":m.kind==="recipe"?"▶":m.kind==="model"?"◈":m.kind==="lut"?"◐":"✦"}),E&&n.jsx("span",{className:`tl-kit-badge ${m.kind}`,children:E}),G===q&&n.jsx("i",{className:"spin"})]}),n.jsxs("span",{className:"tl-plugin-name",children:[n.jsx("strong",{children:_(m,c)}),n.jsxs("small",{children:[$n(m,c),m.duration?` · ${m.duration} s`:""]})]})]},m.id)})})]})})(),Cn.length>0&&n.jsxs("details",{className:"tl-plugin-off",children:[n.jsx("summary",{children:e("Đã tắt ({0})",[Cn.length])}),n.jsx("div",{className:"tl-plugin-grid",children:Cn.map(Vn)})]}),g&&g.length>0&&n.jsx("small",{className:"muted tl-plugins-foot",children:e("{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(xe,{toast:p}),v&&n.jsx(ke,{onClose:()=>O(!1)}),cn&&n.jsx(N.Suspense,{fallback:null,children:n.jsx(fe,{installed:g??[],initialId:Z,onClose:()=>S(!1),onInstalled:()=>void Q(),onUse:gi,toast:p})})]})}function jn({p:t,value:l,locale:o,disabled:h,onBegin:j,onChange:u,onImage:A,media:p,linked:c}){const g=An(t,o),k=l??t.default;if(c&&t.type!=="asset"){const x=n.jsx(jn,{p:t,value:l,locale:o,disabled:h,onBegin:j,onChange:u,onImage:A});return n.jsxs("div",{className:"tl-plugin-linked",children:[x,n.jsxs("span",{className:"tl-plugin-link",title:e("Theo điều khiển chung của bộ"),children:["🔗 ",e("theo bộ")]})]})}if(t.type==="asset"){const x=t.accept==="model"?"model":"image",T=(p??[]).filter(b=>b.kind===x&&typeof b.gcsUri=="string"),r=T.find(b=>b.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"?e("Chưa chọn GLB"):e("Chưa chọn ảnh"),children:x==="model"?"◈":""}),n.jsxs("select",{"aria-label":g,value:typeof k=="string"?k:"",disabled:h,onFocus:j,onChange:b=>u(b.target.value),children:[n.jsx("option",{value:"",children:x==="model"?e("— Mẫu của bộ (không dùng GLB của bạn) —"):e("— Không dùng ảnh —")}),T.map(b=>n.jsx("option",{value:b.gcsUri,children:String(b.label||b.gcsUri.split("/").pop()).slice(0,40)},b.gcsUri))]})]}),!T.length&&n.jsx("small",{className:"muted",children:x==="model"?e("Thêm file .glb vào Media trước (kéo thả vào Media)."):e("Thêm ảnh PNG / JPEG / WebP vào Media trước.")})]})}return t.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=>{j(),u(x.target.checked)}}),g]}):t.type==="number"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsx(Li,{"aria-label":g,value:Number(k),min:t.min,max:t.max,precision:3,disabled:h,onCommit:x=>{j(),u(Yi(t,x))}})]}):t.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:j,onChange:x=>u(x.target.value)}),n.jsx("code",{children:String(k)})]})]}):t.type==="select"?n.jsxs("label",{className:"tl-motion-param",children:[g,n.jsx("select",{"aria-label":g,value:String(k),disabled:h,onFocus:j,onChange:x=>u(x.target.value),children:t.options.map(x=>n.jsx("option",{value:x.value,children:An({...t,label:x.label},o)},x.value))})]}):t.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:e("Ảnh mặc định")}),n.jsx(Te,{label:g,disabled:h,onPick:x=>A?.(x)})]})]}):n.jsxs("label",{className:"tl-motion-param tl-plugin-text",children:[g,t.multiline?n.jsx("textarea",{"aria-label":g,rows:2,value:String(k),maxLength:t.maxLength,disabled:h,onFocus:j,onKeyDown:x=>x.stopPropagation(),onChange:x=>u(x.target.value)}):n.jsx("input",{type:"text","aria-label":g,value:String(k),maxLength:t.maxLength,disabled:h,onFocus:j,onKeyDown:x=>x.stopPropagation(),onChange:x=>u(x.target.value)})]})}function Te({label:t,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:e("Chọn ảnh…")}),n.jsx("input",{ref:h,type:"file",hidden:!0,"aria-label":t,accept:"image/png,image/jpeg,image/webp",onChange:j=>{const u=j.target.files?.[0];j.target.value="",u&&o(u)}})]})}function $e({clip:t,pref:l,item:o,materials:h,locked:j,onPatch:u,toast:A,fail:p}){const c=wn(),[g,k]=N.useState(null),[x,T]=N.useState({}),[r,b]=N.useState(!1),G=l.kind==="motion"||l.kind==="lottie"||l.kind==="recipe";if(N.useEffect(()=>{let S=!0;return o&&G&&(l.item?ri(o,l.item):oi(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:["◈ ",t.label]}),n.jsx("small",{className:"muted",children:e("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:e("Lớp plug-in")}),n.jsxs("p",{className:"tl-plugin-step",children:[n.jsx("i",{className:"spin"}),e("Đang tải gói…")]})]});if(!C)return n.jsxs("section",{className:"tl-plugin-inspector",children:[n.jsx("h5",{children:e("Lớp plug-in")}),n.jsx("small",{className:"muted",children:e("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,V=l.kind==="motion"?{...J(C,{}),...t.motion?.params}:{...J(C,l.params??{}),...x},Z=(S,M)=>{if(!t.motion)return;const K=C.params.find(F=>F.key===S)?.type==="asset",B={...t.motion.assets??{}};K&&(delete B[`@${S}`],typeof M=="string"&&M&&(B[`@${S}`]=M)),u(t.id,{motion:{...t.motion,params:{...t.motion.params,[S]:M},...K?{assets:B}:{}}},!1)},v=Object.keys(x).length>0,O=async(S,M)=>{if(g?.lottie){b(!0);try{const K=S?g.lottie:{data:await Oi(t.url)},B=await On(l.id,await En(K,C,M)),F=S?o?.version??C.version:l.v;u(t.id,{url:B.url,gcsUri:B.gcsUri,...S?{lottie:{...g.lottie.meta,loop:t.lottie?.loop??C.loop!==!1}}:{},plugin:{id:l.id,...l.item?{item:l.item}:{},v:F,kind:"lottie",params:In(C,M)}},!0),T({}),A(e("Đã áp dụng tham số plug-in"),"ok")}catch(K){p(K)}finally{b(!1)}}},cn=async()=>{if(g){if(l.kind==="motion"&&t.motion){const S=Object.fromEntries(Object.entries(t.motion.params??{}).filter(([F])=>C.params.some(pn=>pn.key===F))),M=l.item?ci(l.id,l.item,g,S):di(C,g.entry,S),K=o?.version??C.version;let B={};try{C.uses?.length&&(B=ee(await te(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(t.id,{motion:{...M,...Object.keys(B).length?{assets:B}:{}},plugin:{id:l.id,...l.item?{item:l.item}:{},v:K,kind:"motion"}},!0),A(e("Đã cập nhật lớp lên v{0}",[K]),"ok");return}O(!0,V)}};return n.jsxs("section",{className:"tl-plugin-inspector","aria-label":e("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:j||r||!g,onClick:()=>void cn(),children:["↑ ",e("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:V[S.key],locale:c,disabled:j||r,media:h,linked:!!S.link,onBegin:()=>{l.kind==="motion"&&u(t.id,{},!0)},onChange:M=>{l.kind==="motion"?Z(S.key,M):T(K=>({...K,[S.key]:M}))},onImage:M=>void Qi(M).then(K=>T(B=>({...B,[S.key]:K})),p)},S.key))}):n.jsx("small",{className:"muted",children:e("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:j||r||!v||!g,onClick:()=>void O(!1,V),children:r?e("Đang áp dụng…"):e("Áp dụng")}),n.jsx("button",{className:"pill-btn",disabled:j||r||!g,title:e("Về hoạt ảnh gốc của plug-in với giá trị mặc định"),onClick:()=>void O(!0,J(C,{})),children:e("Đặt lại")})]}),l.kind==="motion"&&n.jsx("small",{className:"muted",children:e("Thay đổi hiện ngay trên Monitor. Code của lớp ở tab Edit.")}),l.kind==="motion"&&t.motion?.assets&&n.jsxs("div",{className:"tl-plugin-assets",children:[n.jsx("small",{className:"muted",children:e("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(t.motion.assets).map(S=>n.jsxs("li",{children:[n.jsx("b",{children:S.startsWith("@")?e("của bạn: {0}",[An(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 qe=Object.freeze(Object.defineProperty({__proto__:null,default:Pe},Symbol.toStringTag,{value:"Module"}));export{qe as T,X as p};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/thumb-Cs636sYt.js","assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js","assets/vfxBackground-CHlCg8lb.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as A}from"./titleFrameBudget-3MFHWIT6.js";import{fz as X,a as y,hY as K,hZ as oe,j as n,eh as ie,el as re}from"./remote-sTZauTqM.js";import{u as le,r as g,t as a}from"./api-BsKbf3l3.js";import{v as ce}from"./vfxTrack-CqiQDEYm.js";import{u as H}from"./store-BSSbvpzr.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const he=c=>{let h=0;for(let b=0;b<c.length;b++)h=Math.imul(h,31)+c.charCodeAt(b)|0;return String(h>>>0)},U=c=>he(JSON.stringify([c.items.filter(h=>h.kind==="fx"||h.trackAnchor||h.kind==="person"),c.shots.map(h=>[h.duration,h.fxTiming,h.objectKeys,h.position,h.target,h.lens,h.cameraKeys]),c.plate]));function de({entry:c}){const h=g.useRef(null),[b,M]=g.useState(!1);return g.useEffect(()=>{const f=h.current,j=f?.getContext("2d");if(!f||!j)return;let k=0,R=!1;return A(async()=>{const{drawThumb:x,thumbRestTime:$,thumbLoopLength:_}=await import("./thumb-Cs636sYt.js").then(S=>S.e);return{drawThumb:x,thumbRestTime:$,thumbLoopLength:_}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])).then(({drawThumb:x,thumbRestTime:$,thumbLoopLength:_})=>{if(R)return;if(!b){x(j,c,$(c),f.width,f.height);return}const S=performance.now(),l=_(c),E=()=>{x(j,c,(performance.now()-S)/1e3%l,f.width,f.height),k=requestAnimationFrame(E)};k=requestAnimationFrame(E)}),()=>{R=!0,cancelAnimationFrame(k)}},[c,b]),n.jsx("canvas",{ref:h,width:128,height:72,"aria-hidden":"true",onMouseEnter:()=>M(!0),onMouseLeave:()=>M(!1)})}function Ne({clip:c,locked:h,ensureScene:b,openShot:M}){le();const f=H(e=>e.toast),[,j]=g.useState(0),[k,R]=g.useState(X[0].id),[x,$]=g.useState(""),[_,S]=g.useState(!1),[l,E]=g.useState(null),[G,V]=g.useState(0),[z,D]=g.useState({}),[B,J]=g.useState(""),d=c.vfxShot?.shotNodeId&&y()?.getNode(c.vfxShot.shotNodeId)?c.vfxShot.shotNodeId:null,P=d?y()?.getNode(d):null,p=P?.data?.shotScene??null,F=p?p.items.filter(e=>e.kind==="fx"):[],C=p?.items.find(e=>e.kind==="person"&&!e.hidden)??null,Q=p?.shots.find(e=>e.id===p.activeShot),Y=g.useMemo(()=>ce(c),[c]),O=!!p&&F.length>0&&P?.data?.vfxRenderHash!==U(p),Z=g.useMemo(()=>{const e=K(x).trim();return oe.filter(s=>e?K(`${s.name} ${s.desc} ${s.keywords} ${s.id}`).includes(e):s.category===k)},[k,x]),N=async(e,s,o)=>{const r=y()?.getNode(e),u=r?.data?.shotScene;if(!u)throw new Error(a("Cảnh VFX không còn trên Canvas"));let m=structuredClone(u);const{runTool:t}=await A(async()=>{const{runTool:v}=await import("./remote-sTZauTqM.js").then(L=>L.jq);return{runTool:v}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10])),i=await t(s,o,{getStage:()=>m,setStage:v=>{m=v(m)},engine:()=>null,timelineClip:v=>H.getState().clips.find(L=>L.id===v)});if(i.ok===!1)throw new Error(i.error||s);return y()?.updateNodeData(e,{shotScene:m}),j(v=>v+1),i},T=async(e,s)=>{if(h){f(a("Track đã khóa"),"error");return}E(e);try{await s()}catch(o){f(o.message,"error")}finally{E(null)}},W=e=>T(a("Đang thêm hiệu ứng"),async()=>{const s=d??b(c);if(!s)throw new Error(a("Không tạo được cảnh VFX"));const o=y()?.getNode(s)?.data?.shotScene,r=o.items.find(i=>i.kind==="person"&&!i.hidden),u=e.attach==="body"||e.attach==="hand"||e.attach==="gun",m=e.attach==="path"||e.attach==="sky",t=r?.position??[0,0,0];await N(s,"add_effect",{effect:e.id,vfx_layer:e.attach==="body"||e.attach==="ground"?"behind":"front",...r&&u?{attach_to:r.name,...e.attach!=="body"?{hand:"right"}:{}}:{},...r&&m?{from:`${r.name}.hand_right`,to:[t[0]+3,t[1]+1.2,t[2]]}:{}}),S(!1)}),w=(e,s)=>T(a("Đang cập nhật"),()=>N(d,"update_effect",{name:e.name,...s})),q=e=>{const s=p?.items.find(r=>r.trackAnchor?.effect===e.id);if(s)return{kind:"track",source:s.trackAnchor.source};const o=e.fx?.attach;return o&&C&&o.to===C.id?o.hand?{kind:"hand",side:o.hand==="L"?"left":"right"}:{kind:"body"}:{kind:"none"}},ee=(e,s)=>T(a("Đang gắn hiệu ứng"),async()=>{if(q(e).kind==="track"&&await N(d,"follow_track",{name:e.name,stop:!0}),s==="none"){e.fx?.attach&&await N(d,"update_effect",{name:e.name,attach_to:"none"});return}if(s==="body"||s==="hand-right"||s==="hand-left"){if(!C)throw new Error(a("Cảnh VFX không có người đứng thế"));await N(d,"update_effect",{name:e.name,attach_to:C.name,hand:s==="body"?"none":s==="hand-left"?"left":"right"});return}const[r,u,m]=s.split(":");await N(d,"follow_track",{name:e.name,source:r,...r==="object"?{object:u}:{},...r==="hand"?{side:u,point:m||"palm"}:{}})}),te=()=>T(a("Đang đọc người trong video"),async()=>{const{withBackgroundScene:e}=await A(async()=>{const{withBackgroundScene:r}=await import("./vfxBackground-CHlCg8lb.js");return{withBackgroundScene:r}},__vite__mapDeps([11,3,2,1,4,5,6,7,8,9,10])),s=Number(B),o=await e(d,r=>r.run("follow_plate",s>=8&&s<=300?{lens_mm:s}:{}),{timeoutMs:6e5});if(o.ok===!1)throw new Error(o.error||"follow_plate");j(r=>r+1),f(o.camera?a("Đã khớp camera ({0} mm, cao {1} m, nghiêng {2}°) và cho người đứng thế bám theo người trong video",[o.camera.lens_mm,o.camera.height_m.toFixed(2),o.camera.tilt_deg.toFixed(1)]):a("Người đứng thế đã bám theo người trong video"),"info")}),ne=()=>T(a("Đang render hiệu ứng"),async()=>{const{withBackgroundScene:e}=await A(async()=>{const{withBackgroundScene:t}=await import("./vfxBackground-CHlCg8lb.js");return{withBackgroundScene:t}},__vite__mapDeps([11,3,2,1,4,5,6,7,8,9,10])),{shotFps:s}=await A(async()=>{const{shotFps:t}=await import("./remote-sTZauTqM.js").then(i=>i.jk);return{shotFps:t}},__vite__mapDeps([1,2,3,4,5,6,7,8,9,10]));V(0);const o=y()?.getNode(d)?.data?.shotScene,r=o.shots.find(t=>t.id===o.activeShot),u=await e(d,t=>t.exportVfx({fps:s(r),height:720,vfxAlpha:"auto"},V),{timeoutMs:12e4});y()?.updateNodeData(d,{vfxRenderHash:U(y()?.getNode(d)?.data?.shotScene)}),j(t=>t+1);const m=u.passes.filter(t=>t.alpha).length;f(u.placed?m?a("Đã render {0} lớp hiệu ứng lên video ({1} lớp có kênh trong suốt cho khói / bụi)",[u.passes.length,m]):a("Đã render {0} lớp hiệu ứng lên video",[u.passes.length]):a("Đã render; video hiệu ứng nằm trên Canvas"),"info")}),I=Y.flatMap(e=>e.source==="hand"?["right","left"].flatMap(s=>["palm","index","pinch","wrist"].map(o=>({value:`hand:${s}:${o}`,label:`${a(s==="right"?"Tay phải (tracking)":"Tay trái (tracking)")} · ${a(o==="palm"?"lòng bàn tay":o==="index"?"ngón trỏ":o==="pinch"?"chỗ chụm":"cổ tay")}`}))):[{value:e.source==="object"?`object:${e.object}`:e.source,label:e.source==="object"?`${a("Vật thể 3D")} ${e.label.replace(/^Vật thể 3D /,"")}`:a(e.label)}]),ae=e=>e.kind==="none"?"none":e.kind==="body"?"body":e.kind==="hand"?`hand-${e.side}`:I.find(s=>s.value===e.source)?.value??I.find(s=>s.value.split(":")[0]===e.source.split(":")[0])?.value??e.source;return n.jsxs("div",{className:"tl-shotfx",children:[n.jsxs("div",{className:"tl-3d-row",children:[n.jsx("button",{className:"pill-btn",disabled:!!l,onClick:()=>S(e=>!e),children:_?a("Đóng kho hiệu ứng"):a("✦ Thêm hiệu ứng 3D")}),d&&n.jsx("button",{className:"pill-btn",disabled:!!l,onClick:()=>M(c),children:a("Mở trong 3D Shot")})]}),_&&n.jsxs("div",{className:"tl-shotfx-gallery",children:[n.jsx("input",{className:"tl-shotfx-search",placeholder:a("Tìm hiệu ứng (aura, sét, khói…)"),value:x,onChange:e=>$(e.target.value)}),!x&&n.jsx("div",{className:"tl-shotfx-cats",children:X.map(e=>n.jsx("button",{className:`tl-shotfx-cat${e.id===k?" on":""}`,onClick:()=>R(e.id),children:a(e.name)},e.id))}),n.jsx("div",{className:"tl-shotfx-grid",children:Z.slice(0,60).map(e=>n.jsxs("button",{className:"tl-shotfx-card",title:a(e.desc),disabled:!!l,onClick:()=>void W(e),children:[n.jsx(de,{entry:e}),n.jsx("span",{children:a(e.name)})]},e.id))})]}),F.length>0&&n.jsx("div",{className:"tl-shotfx-list",children:F.map(e=>{const s=ie(e,Q),o=q(e),r=re[e.fx.preset]?.params??[],u=(t,i)=>{D(v=>{const{[`${e.id}:${t}`]:L,...se}=v;return se}),w(e,t==="intensity"?{intensity:i}:{params:{[t]:i}})},m=(t,i)=>z[`${e.id}:${t}`]??i;return n.jsxs("div",{className:"tl-shotfx-item",children:[n.jsxs("div",{className:"tl-shotfx-head",children:[n.jsx("input",{type:"color",value:e.color,disabled:!!l,onChange:t=>void w(e,{color:t.target.value}),title:a("Màu")}),n.jsx("b",{children:e.name}),n.jsxs("select",{value:e.vfxLayer??"behind",disabled:!!l,onChange:t=>void w(e,{vfx_layer:t.target.value}),children:[n.jsx("option",{value:"behind",children:a("Sau người")}),n.jsx("option",{value:"front",children:a("Trước người")})]}),n.jsx("button",{className:"tl-shotfx-del",disabled:!!l,title:a("Xoá hiệu ứng"),onClick:()=>void T(a("Đang xoá"),()=>N(d,"remove_effect",{name:e.name})),children:"✕"})]}),n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a("Bám theo")}),n.jsxs("select",{value:ae(o),disabled:!!l,onChange:t=>void ee(e,t.target.value),children:[n.jsx("option",{value:"none",children:a("Đứng yên trong cảnh")}),C&&n.jsxs(n.Fragment,{children:[n.jsx("option",{value:"body",children:a("Người (thân)")}),n.jsx("option",{value:"hand-right",children:a("Người · tay phải")}),n.jsx("option",{value:"hand-left",children:a("Người · tay trái")})]}),I.map(t=>n.jsx("option",{value:t.value,children:t.label},t.value))]})]}),n.jsxs("div",{className:"tl-shotfx-time",children:[n.jsxs("label",{children:[a("Bắt đầu")," ",n.jsx("input",{type:"number",min:0,step:.1,value:+s.start.toFixed(2),disabled:!!l,onChange:t=>void w(e,{start:Math.max(0,Number(t.target.value)||0)})})]}),n.jsxs("label",{children:[a("Dài")," ",n.jsx("input",{type:"number",min:.2,step:.1,value:+s.duration.toFixed(2),disabled:!!l,onChange:t=>void w(e,{duration:Math.max(.2,Number(t.target.value)||.2)})})]}),n.jsxs("label",{children:[n.jsx("input",{type:"checkbox",checked:s.loop,disabled:!!l,onChange:t=>void w(e,{loop:t.target.checked})})," ",a("Lặp")]})]}),n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a("Độ mạnh")}),n.jsx("input",{type:"range",min:.1,max:3,step:.05,value:m("intensity",e.fx.intensity),disabled:!!l,onChange:t=>D(i=>({...i,[`${e.id}:intensity`]:Number(t.target.value)})),onMouseUp:t=>u("intensity",Number(t.target.value)),onKeyUp:t=>u("intensity",Number(t.target.value))})]}),r.map(t=>t.type==="enum"?n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a(t.label??t.key)}),n.jsx("select",{value:String(e.fx.params[t.key]??t.def),disabled:!!l,onChange:i=>void w(e,{params:{[t.key]:i.target.value}}),children:(t.options??[]).map(i=>n.jsx("option",{value:i,children:i},i))})]},t.key):n.jsxs("label",{className:"tl-shotfx-field",children:[n.jsx("span",{children:a(t.label??t.key)}),n.jsx("input",{type:"range",min:t.min,max:t.max,step:((t.max??1)-(t.min??0))/100,value:m(t.key,Number(e.fx.params[t.key]??t.def)),disabled:!!l,onChange:i=>D(v=>({...v,[`${e.id}:${t.key}`]:Number(i.target.value)})),onMouseUp:i=>u(t.key,Number(i.target.value)),onKeyUp:i=>u(t.key,Number(i.target.value))})]},t.key))]},e.id)})}),d&&C&&F.length>0&&n.jsxs("div",{className:"tl-3d-row",children:[n.jsx("button",{className:"pill-btn",disabled:!!l,onClick:()=>void te(),title:a("Đọc tư thế người trong video (miễn phí, trong trình duyệt): hiệu ứng gắn vào người sẽ chạy theo họ"),children:a("Bám người thật (tư thế)")}),n.jsx("input",{className:"tl-shotfx-lens",type:"number",min:8,max:300,step:1,value:B,disabled:!!l,placeholder:a("Ống kính mm"),title:a("Tiêu cự ống kính đã quay (mm, khổ phim 36 mm). Để trống: tự giả định 28 mm — ống kính chính của điện thoại"),onChange:e=>J(e.target.value)})]}),p?.plate?.match&&n.jsx("p",{className:"tl-vfx-hint",children:a("Camera đã khớp với video: {0} mm · cao {1} m · nghiêng {2}°",[p.plate.match.lens,p.plate.match.height.toFixed(2),p.plate.match.tilt.toFixed(1)])}),d&&F.length>0&&n.jsxs("div",{className:"tl-3d-row",children:[n.jsx("button",{className:`pill-btn${O?" on":""}`,disabled:!!l,onClick:()=>void ne(),children:l===a("Đang render hiệu ứng")?`${a("Đang render")} ${G}%`:O?a("▶ Render hiệu ứng lên video"):a("Render lại")}),O&&n.jsx("span",{className:"tl-shotfx-stale",children:a("Đã sửa, cần render lại")})]}),l&&l!==a("Đang render hiệu ứng")&&n.jsxs("p",{className:"tl-vfx-hint",children:[l,"…"]})]})}export{Ne as default,U as vfxSceneHash};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as c}from"./remote-sTZauTqM.js";import{r as p}from"./api-BsKbf3l3.js";import{gR as g}from"./titleFrameBudget-3MFHWIT6.js";import{d}from"./main-M1vRa-gd.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";const f=["https://admin.clipoox.com","http://localhost:3000","http://localhost:5173"];function G(){const m=p.useRef(null),[e,l]=p.useState(null);return p.useEffect(()=>{const r=(t,i)=>t.source?.postMessage(i,{targetOrigin:t.origin}),n=t=>{if(!f.includes(t.origin)||t.source!==window.parent||!t.data||typeof t.data!="object")return;let i;try{i=g(t.data.transition)}catch(o){r(t,{type:"clipoox-transition-error",id:"id"in t.data?t.data.id:null,error:o.message});return}if(t.data.type==="clipoox-transition-play"){l(i);return}if(t.data.type==="clipoox-transition-thumb"){const o=Object.assign(document.createElement("canvas"),{width:640,height:360}),s=o.getContext("2d");d(s,i,Number.isFinite(t.data.p)?Number(t.data.p):.5,640,360),r(t,{type:"clipoox-transition-thumb",id:t.data.id,png:o.toDataURL("image/png")})}},a=t=>n(t);return window.addEventListener("message",a),window.parent?.postMessage({type:"clipoox-transition-ready"},"*"),()=>window.removeEventListener("message",a)},[]),p.useEffect(()=>{const r=m.current,n=r?.getContext("2d");if(!r||!n||!e)return;let a=0;const t=performance.now(),i=e.duration*1e3,o=600,s=u=>{const h=(u-t)%(i+2*o)-o;d(n,e,Math.max(0,Math.min(1,h/i)),r.width,r.height),a=requestAnimationFrame(s)};return a=requestAnimationFrame(s),()=>cancelAnimationFrame(a)},[e]),c.jsx("div",{style:{margin:0,background:"#000",width:"100vw",height:"100vh",display:"grid",placeItems:"center"},children:c.jsx("canvas",{ref:m,width:1280,height:720,style:{width:"100%",height:"100%",objectFit:"contain"},"aria-label":"Transition preview"})})}export{G as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as u,a as I}from"./remote-
|
|
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
|
|
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{
|
|
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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-sTZauTqM.js","assets/api-BsKbf3l3.js","assets/titleFrameBudget-3MFHWIT6.js","assets/three.module-Bx43vjkH.js","assets/GLTFLoader-Dy6SrZg8.js","assets/store-BSSbvpzr.js","assets/rotoMaskStore-pxpRt5Cj.js","assets/textAnimators-Cihw35O8.js","assets/timelineComp-CRRzLazc.js","assets/rigTrack-Bx9QHlFv.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as et}from"./titleFrameBudget-3MFHWIT6.js";import{jh as U,iR as V,fh as B,gD as y,dy as b,fj as G,ji as at,iK as ot,hx as J,fA as it,fu as nt,fv as Q,fk as rt,hu as st,iP as ct}from"./remote-sTZauTqM.js";import{c as mt}from"./cameraPresets-B234aNzE.js";import"./api-BsKbf3l3.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./store-BSSbvpzr.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";const C=()=>crypto.randomUUID(),u=o=>Math.round(o*100)/100,lt=o=>st(o)*(o.scale[1]||1);function W(o,c){const a=y(o),k=a.duration/c,e=l=>l?.map(i=>({...i,time:Math.min(1,i.time*k)})),s={...a,duration:c,cameraKeys:e(a.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(a.objectKeys||{}).map(([l,i])=>[l,e(i)||[]])),...a.flight?{flight:Object.fromEntries(Object.entries(a.flight).map(([l,i])=>[l,e(i)||[]]))}:{}};return{...o,shots:o.shots.map(l=>l.id===a.id?s:l)}}function z(o,c,a,k,e){const s=y(o),l=s.duration,i=(s.objectKeys?.[c.id]||[]).filter(p=>p.time*l<a-1e-6);return{...o,shots:o.shots.map(p=>p.id===s.id?{...p,objectKeys:{...p.objectKeys,[c.id]:[...i,{id:C(),time:a/l,position:k.map(_=>+_.toFixed(3)),rotation:[0,+e.toFixed(1),0],scale:c.scale}]}}:p)}}const X=(o,c)=>Math.atan2(c[0]-o[0],c[2]-o[2])*180/Math.PI;async function St(o,c){const a=U.find(t=>t.id===String(o.move??""));if(!a)return{ok:!1,error:`unknown move; use one of ${U.map(t=>t.id).join(", ")}`};const k=c.getStage();let e,s;try{e=V(k,String(o.name??""))}catch(t){return{ok:!1,error:t.message}}if(!B(e))return{ok:!1,error:`'${e.name}' is not a person`};const l=y(k),i=Math.max(0,Number(o.time??0)||0);if(o.target!=null)try{s=V(k,String(o.target))}catch(t){return{ok:!1,error:t.message}}else{const t=b(e,l,Math.min(1,i/l.duration)).position,m=k.items.filter(n=>n.id!==e.id&&B(n)&&!n.hidden).map(n=>{const r=b(n,l,Math.min(1,i/l.duration)).position;return{i:n,d:Math.hypot(r[0]-t[0],r[2]-t[2])}}).sort((n,r)=>n.d-r.d)[0];if(!m)return{ok:!1,error:"no target: put another person in the scene or give target"};s=m.i}const p=G(a.id),_=at(a.id);if(!p||!_)return{ok:!1,error:`the clip ${a.id} is missing`};const M=[];let h=k;i+p.duration+1.6>l.duration&&(h=W(h,Math.min(300,Math.ceil((i+p.duration+1.8)*10)/10)));let S=y(h),w=S.duration;const j=i+_.at,$=j+(a.ranged?a.travel??.6:0),g=b(e,{...S,flight:void 0},Math.min(1,i/w)).position,v=b(s,{...S,flight:void 0},Math.min(1,$/w)).position,F=X(g,v);let x=g;if(!a.ranged){const t=(_.dz+(a.reach??.8))*lt(e),m=Math.hypot(v[0]-g[0],v[2]-g[2])||1,n=(g[0]-v[0])/m,r=(g[2]-v[2])/m;x=[v[0]+n*t,g[1],v[2]+r*t];const f=Math.hypot(x[0]-g[0],x[2]-g[2]);if(f>.3&&i>.25){const d=Math.min(.8,Math.max(.2,f/6),i);h=z(h,e,i-d,g,F),M.push(`${e.name} closes ${u(f)} m in ${u(d)} s before the strike${f>3?" (for a longer approach play ac-superman-glide / ac-burst-dash before)":""}`)}}h=z(h,e,i,x,F);const H=(t,m,n)=>{const r=y(n),f=r.flight?.[t.id];return!!f?.length&&ct(f,Math.min(1,m/r.duration),r.duration).air>.5};a.land&&H(e,i,h)&&(S=y(h),w=S.duration,h={...h,shots:h.shots.map(t=>t.id===S.id?{...t,flight:{...t.flight,[e.id]:ot(t.flight?.[e.id],{time:j/w,on:!1})}}:t)},M.push(`${e.name} lands on the strike (flight off at ${u(j)} s)`));const O=J(h,e.id,p,{start:i/y(h).duration,newId:C,loop:!1});if(!O.ok)return{ok:!1,error:O.error};c.setStage(()=>O.stage);const{runTool:Y}=await et(async()=>{const{runTool:t}=await import("./remote-sTZauTqM.js").then(m=>m.jq);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),q=[];for(const t of a.fx){const m=t.at==="strike"?j:i,n={effect:t.fx,start:u(m),duration:t.duration,...t.params?{params:t.params}:{},...o.color?{color:o.color}:{}},r=it(t.fx)?.attach==="path",f=t.place==="self"?{...n,attach_to:e.name}:t.place==="target"?{...n,at:`${s.name}.chest`}:t.place==="trail"?{...n,from:`${e.name}.chest`,to:`${s.name}.chest`}:t.place==="path"?{...n,from:`${e.name}.hand_right`,to:`${s.name}.chest`}:r?{...n,from:`${e.name}.feet`,to:`${s.name}.feet`}:{...n,at:`${s.name}.feet`},d=await Y("add_effect",f,c);d.ok?q.push({effect:t.fx,start_s:u(m)}):M.push(`${t.fx}: ${String(d.error)}`)}const K=String(o.react??"hit");let T=null;if(K!=="none"){const t=H(s,$,c.getStage()),[m,n]=K==="block"?t?["ac-air-block",.16]:["xx-palm-shield",.22]:K==="evade"?t?a.heavy?["ac-backflip-evade",.3]:["ac-corkscrew-dodge",.2]:["xx-teleport",.26]:t?[a.heavy?"ac-air-knocked-spin":"ac-air-recoil",0]:[(a.heavy,"xx-knocked-flying"),0],r=Math.max(0,$-n),f=G(m);if(f){let d=c.getStage();const D=y(d),E=D.duration,L=b(s,{...D,flight:void 0},Math.min(1,r/E)).position,Z=b(e,D,Math.min(1,r/E)).position;d=z(d,s,r,L,X(L,Z)),r+f.duration+.3>E&&(d=W(d,Math.min(300,Math.ceil((r+f.duration+.4)*10)/10)));const P=J(d,s.id,f,{start:r/y(d).duration,newId:C,loop:!1});if(P.ok){if(c.setStage(()=>P.stage),T={motion:m,at_s:u(r)},K==="hit"&&o.timing!==!1){const I=y(c.getStage()),tt=nt(rt(I.timing,I.duration),[$],a.heavy?Q.heavy:Q.medium,I.duration);c.setStage(N=>({...N,shots:N.shots.map(R=>R.id===I.id?{...R,timing:tt??void 0}:R)}))}}else M.push(`${s.name} ${m}: ${P.error}`)}}const A=[];if(o.camera===!0){const t=[["wide-track",e,i,$+.2]];a.heavy&&t.push(["low-hero",s,$+.2,$+1.4]);for(const[m,n,r,f]of t){const d=mt(c.getStage(),{preset:m,subject:n.id,start:r,end:f});d.ok&&(c.setStage(()=>d.stage),A.push(`${m} ${u(r)}–${u(f)} s`))}}return{ok:!0,move:a.id,attacker:e.name,target:s.name,start_s:u(i),strike_s:u(j),impact_s:u($),end_s:u(i+p.duration),effects:q,...T?{reaction:T}:{},...A.length?{camera:A}:{},...M.length?{notes:M}:{}}}export{St as aerialStrike};
|
|
@@ -0,0 +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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{u as v}from"./store-BSSbvpzr.js";import{t as S}from"./api-BsKbf3l3.js";import{am as A}from"./remote-sTZauTqM.js";import{ac as y,z as k,ad as I,l as P,w as _,y as j,H as F}from"./main-M1vRa-gd.js";import{runAnalyzerCode as R}from"./analyzerSandbox-DO5ZTv5q.js";import{e as E}from"./pluginAutomation-BtQ_w2TB.js";import"./titleFrameBudget-3MFHWIT6.js";import"./three.module-Bx43vjkH.js";import"./GLTFLoader-Dy6SrZg8.js";import"./rotoMaskStore-pxpRt5Cj.js";import"./textAnimators-Cihw35O8.js";import"./timelineComp-CRRzLazc.js";import"./rigTrack-Bx9QHlFv.js";import"./spark.module-BRT8yMS4.js";import"./userFonts-BZ4QL-zq.js";import"./lottieLayer-CfUPParC.js";import"./desktop-BWhFnYwd.js";import"./timeline3d-BEuZZOxM.js";import"./RoomEnvironment-Dmv_G5ka.js";import"./exportEncode-CaKEPgsy.js";import"./captionLayout-CNgb471H.js";import"./timelineText-CkoUgWcY.js";import"./titleArt-CcTdJuOC.js";import"./rotoMatte-DyXlW4jK.js";import"./distortGL-BklPDXPq.js";import"./motionBlur-uAm030t9.js";async function $(t){const{plugins:o}=await P(),n=o.find(a=>a.id===t.id&&a.enabled);if(!n)throw _("use_missing",[t.id]);const r=t.item?await j(n,t.item):await F(n);if(r.manifest.kind!=="analyzer")throw _("use_plugin",[0,t.item?`${t.id}/${t.item}`:t.id],"not an analyzer plug-in");return r}async function H(t,o,n){if(window.__analyzerFramesStub)return window.__analyzerFramesStub(t,o);const r=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});r.src=t.url;try{await new Promise((l,h)=>{r.onloadeddata=()=>l(),r.onerror=()=>h(Error(S("Không đọc được video của clip (CORS / định dạng)")))});const a=r.videoWidth||1280,d=r.videoHeight||720,e=Math.min(o.width,a),s=Math.max(2,Math.round(e*d/a)),i=Object.assign(document.createElement("canvas"),{width:e,height:s}),m=i.getContext("2d",{willReadFrequently:!0}),p=t.playbackRate||1,b=t.inPoint||0,z=Math.min(t.duration,o.maxSeconds),c=Math.max(1,Math.floor(z*o.fps)),g=new Uint8Array(e*s*c);for(let l=0;l<c;l++){n?.aborted;const h=Math.max(0,Math.min(r.duration-1/60,b+l/o.fps*p));Math.abs(r.currentTime-h)>1e-4&&await new Promise((u,f)=>{const x=window.setTimeout(()=>f(Error(S("Seek video quá lâu"))),8e3);r.onseeked=()=>{window.clearTimeout(x),u()},r.currentTime=h}),m.drawImage(r,0,0,e,s);const w=m.getImageData(0,0,e,s).data,M=l*e*s;for(let u=0,f=0;u<w.length;u+=4,f++)g[M+f]=w[u]*77+w[u+1]*150+w[u+2]*29>>8}return{fps:o.fps,width:e,height:s,count:c,data:g,sourceWidth:a,sourceHeight:d}}finally{r.removeAttribute("src"),r.load()}}function O(t){const o=v.getState().timelineMedia.find(i=>t.gcsUri&&i.gcsUri===t.gcsUri||i.url===t.url),n=t.playbackRate||1,r=t.inPoint||0,a=i=>+((i-r)/n).toFixed(3),d=i=>a(i.end)>0&&a(i.start)<t.duration,e=(o?.words??[]).filter(d).slice(0,y.words).map(i=>({start:a(i.start),end:a(i.end),word:String(i.word).slice(0,60)})),s=(o?.pauses??[]).filter(d).map(i=>({start:a(i.start),end:a(i.end)}));return{words:e,pauses:s}}async function ut(t,o){const n=o.params??{};if(!n.plugin?.id)throw Error("runAnalyzer: no plug-in");if(t.kind!=="video"||!t.url)throw Error(S("Plug-in phân tích cần một clip video"));const r=await $(n.plugin),a=r.manifest,d=a.sample??{fps:y.fps.default,width:y.width.default,maxSeconds:y.maxSeconds.default},e=await H(t,d),s={clip:{duration:t.duration,width:e.sourceWidth,height:e.sourceHeight},frames:{fps:e.fps,width:e.width,height:e.height,count:e.count,data:e.data},...O(t),params:k(a,n.values??{})},i=I(await R(r.entry,s),t.id);if(!i.ops.length)return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:n.plugin.item?`${n.plugin.id}/${n.plugin.item}`:n.plugin.id,ops:0,summary:i.summary}),{};const m=A([t],i.ops);if(m.errors?.length)throw Error(String(m.errors[0]).slice(0,200));const p=m.clips.find(g=>g.id===t.id);if(!p)throw Error("runAnalyzer: the clip was lost");const{id:b,clientJobs:z,...c}=p;return E("plugin.analyzed",{project_id:v.getState().canvasId??null,clip_id:t.id,plugin:n.plugin.item?`${n.plugin.id}/${n.plugin.item}`:n.plugin.id,ops:i.ops.length,summary:i.summary}),c}export{ut as runAnalyzerJob};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ac as d}from"./main-
|
|
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=`
|
|
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
|
|
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};
|