clipoox-render 0.4.7 → 0.4.8
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 +2 -2
- package/scripts/render-local.mjs +2367 -1534
- package/shared/photocraft/LICENSE.txt +206 -0
- package/shared/photocraft/clipoox_photo.js +396 -0
- package/shared/photocraft/clipoox_photo_bg.wasm +0 -0
- package/web/assets/{FxEmbed-B-D-tbgP.js → FxEmbed-adbxHEBi.js} +1 -1
- package/web/assets/ImageStudio-CMxiT1jp.js +3 -0
- package/web/assets/ImageStudio-De_DCTrz.css +1 -0
- package/web/assets/{MotionEmbed-eB-zRpv9.js → MotionEmbed-CDUIyjk0.js} +1 -1
- package/web/assets/{PluginStore-D6UvvVXA.js → PluginStore-By_pdOOg.js} +2 -2
- package/web/assets/ShotComposer-DcwWZ-eP.css +1 -0
- package/web/assets/ShotComposer-XIbJ4nNm.js +287 -0
- package/web/assets/{TemplateEmbed-DZNaQAJ-.js → TemplateEmbed-a01nKECT.js} +1 -1
- package/web/assets/{TimelinePlugins-zhB9Uqav.js → TimelinePlugins-CqLMVjuh.js} +4 -4
- package/web/assets/TimelineShotFx-QmkyCg31.js +2 -0
- package/web/assets/{TransitionEmbed-r_B0toRr.js → TransitionEmbed-Cbwlxfl2.js} +1 -1
- package/web/assets/{Whiteboard-f6owS-ne.js → Whiteboard-ChYqIr3v.js} +1 -1
- package/web/assets/{aerial-DIj143Yz.js → aerial-CZeCeacv.js} +2 -2
- package/web/assets/{agentTools-CoNs1wCQ.js → agentTools-DW2ETnxE.js} +2 -2
- package/web/assets/{aiInbetween-ZFNHEXdI.js → aiInbetween-De98iM4m.js} +2 -2
- package/web/assets/analyzerRun-D5-g-Vxe.js +1 -0
- package/web/assets/{analyzerSandbox-C2rd6s8U.js → analyzerSandbox-E3CdovIk.js} +1 -1
- package/web/assets/{api-DJC95K48.js → api-CZoVJ9Fy.js} +87 -87
- package/web/assets/auraTrack-ClhHuqlf.js +1 -0
- package/web/assets/{breakthrough-DiHiElqL.js → breakthrough-DTpiUIZd.js} +2 -2
- package/web/assets/{cameraPresets-DfKERP1j.js → cameraPresets-DD0WmxiI.js} +1 -1
- package/web/assets/{cameraTracker-DFjnZ7tw.js → cameraTracker-Df9jWmz6.js} +2 -2
- package/web/assets/{captionLayout-CAuhUiW9.js → captionLayout-eiu9QPJu.js} +1 -1
- package/web/assets/{clientExport-DyqpYM6h.js → clientExport-BXegTdNc.js} +1 -1
- package/web/assets/{clientJobs-BqkjV5Ld.js → clientJobs-eB-lNyin.js} +2 -2
- package/web/assets/clipoox_photo_bg-BQ0aVNY0.wasm +0 -0
- package/web/assets/depthEstimate-CfwX-tXP.js +1 -0
- package/web/assets/{directorTools-CLn4xt6m.js → directorTools-ABbI8m0e.js} +1 -1
- package/web/assets/distortFrames-DMnZ8OYh.js +2 -0
- package/web/assets/distortGL-DQu0Df2c.js +18 -0
- package/web/assets/{domino-BDKBYrNQ.js → domino-trmDBvfH.js} +1 -1
- package/web/assets/{editTools-BqKU-ucA.js → editTools-DEFo9Ahv.js} +1 -1
- package/web/assets/{engine-B2YPWQZ2.js → engine-Y-GotDIy.js} +1 -1
- package/web/assets/exportGlb-BeLpJKJT.js +2 -0
- package/web/assets/{faceTracker-DsmLlUZ1.js → faceTracker-BeSFnLM8.js} +1 -1
- package/web/assets/{fightDirector-BIVLGhAP.js → fightDirector-Dfz3vu5-.js} +1 -1
- package/web/assets/{fightDrama-B_jDQ-cW.js → fightDrama-CNVn69s0.js} +2 -2
- package/web/assets/{focusTool-mWs2Eikj.js → focusTool-Dd2UDkiO.js} +1 -1
- package/web/assets/{frameSink-DWkHUnvV.js → frameSink-Rj02YES5.js} +3 -3
- package/web/assets/{glTransitionSources.generated-BJuEUz3E.js → glTransitionSources.generated-Cs8lVRqs.js} +438 -2
- package/web/assets/{gpuCompose-Fi0sIUI9.js → gpuCompose-DkkKH1Ab.js} +1 -1
- package/web/assets/gpuExport-DwrXpVGF.js +199 -0
- package/web/assets/{handMatte-CvFkZKTL.js → handMatte-B5sUeqKi.js} +1 -1
- package/web/assets/{handTracker-CF1hqh09.js → handTracker-CQV-D7va.js} +2 -2
- package/web/assets/i18n-ClNt3LKg.js +3 -0
- package/web/assets/{index-EegUntr6.js → index-D2u6mD-8.js} +1 -1
- package/web/assets/layer-worker-DP0N05Ua.js +5 -0
- package/web/assets/library-cb43ZEmy.js +1 -0
- package/web/assets/{lottieLayer-Dp_vGTy8.js → lottieLayer-DEw0c3to.js} +4 -4
- package/web/assets/main-C_XcvNyC.js +311 -0
- package/web/assets/{main-B_MAOvi6.css → main-DlzdW5C4.css} +1 -1
- package/web/assets/{mapBake-CEmw-e9Y.js → mapBake-BUWz0cSx.js} +1 -1
- package/web/assets/{maskTrack-CADMBJDf.js → maskTrack-GYpJyKFw.js} +1 -1
- package/web/assets/matteFixRun-BCVsuSxf.js +1 -0
- package/web/assets/{objectLocate-DWsEG8eK.js → objectLocate-CjIlo_u0.js} +1 -1
- package/web/assets/{objectSegmenter-oGv8YQbI.js → objectSegmenter-C4T9qgUL.js} +1 -1
- package/web/assets/{objectTrack.worker-B6RVfsq4.js → objectTrack.worker-BVvsDmR0.js} +1161 -770
- package/web/assets/{pathTracer-DxqKEvC7.js → pathTracer-DgL1_83l.js} +2 -2
- package/web/assets/{pendingMatte-Taa0BlLI.js → pendingMatte-DPTe6xoZ.js} +2 -2
- package/web/assets/peopleMatte-C1hruEM6.js +1 -0
- package/web/assets/{personAi-BebqXrqD.js → personAi-Cjg9KKeH.js} +2 -2
- package/web/assets/{personHq-Cyq9HWnW.js → personHq-CBP8v_cw.js} +2 -2
- package/web/assets/photo.worker-DK_ulTzR.js +1 -0
- package/web/assets/photoRun-lZ2BdSEk.js +2 -0
- package/web/assets/photoTools-DmUh69Qk.js +1 -0
- package/web/assets/plateCamera-DLqlXhMp.js +1 -0
- package/web/assets/{plateCameraMatch-1_DuZ0LV.js → plateCameraMatch-4VUlUMi-.js} +2 -2
- package/web/assets/{plateFollow-Ztxwpq5v.js → plateFollow-D2rjnmZA.js} +2 -2
- package/web/assets/plateMatte-0tTG7oeO.js +2 -0
- package/web/assets/{pluginAutomation-D73Az7HS.js → pluginAutomation-ClFdpcCR.js} +1 -1
- package/web/assets/popTools-B38V4wub.js +1 -0
- package/web/assets/{poseTracker-b1h08oRY.js → poseTracker-qtuytI-L.js} +1 -1
- package/web/assets/{productTools-CoJ_Fnfc.js → productTools-DlC5vWjx.js} +2 -2
- package/web/assets/remote-CpkPQOQH.js +989 -0
- package/web/assets/{rigTrack-B9r9wrdV.js → rigTrack-BbKqZGs7.js} +1 -1
- package/web/assets/{rotoMaskStore-RmW40Pcn.js → rotoMaskStore-BZBJLcCp.js} +1 -1
- package/web/assets/{rotoMatte-DisQplSv.js → rotoMatte-BI-vjjrv.js} +1 -1
- package/web/assets/rotoscope-DuNcCxQy.js +1 -0
- package/web/assets/{sceneTrack-DyVxpl7i.js → sceneTrack-CO4fTjft.js} +1 -1
- package/web/assets/sceneTrack-_n6WKKQv.js +1 -0
- package/web/assets/{sceneTrack.worker-DKVLLgf9.js → sceneTrack.worker-f2d-WOzw.js} +1207 -816
- package/web/assets/{shot-worker-DM5PUQ6g.js → shot-worker-BSmfIXHO.js} +1 -1
- package/web/assets/{shotFxAgent-CsW0MAiG.js → shotFxAgent-L2GG88W3.js} +1 -1
- package/web/assets/{skin-CXvqtCZI.js → skin-CirUiqcr.js} +1 -1
- package/web/assets/{spark.module-B341moK0.js → spark.module-3Q8DniuL.js} +1 -1
- package/web/assets/{spellDuel-KCMEFHLA.js → spellDuel-2CDLbiLQ.js} +2 -2
- package/web/assets/{store-xR02oY0m.js → store-D3Y663py.js} +1 -1
- package/web/assets/{surfaceLight-DBfJxggM.js → surfaceLight--HQj7xhO.js} +1 -1
- package/web/assets/{surfacePin-i-X1Dz68.js → surfacePin-BCmgw-40.js} +2 -2
- package/web/assets/{textAnimators-CeMuG34D.js → textAnimators-C4eMnVRD.js} +1 -1
- package/web/assets/{thumb-DzNl15MN.js → thumb-M9B_goj-.js} +1 -1
- package/web/assets/{timeline3d-D0Ws4lcp.js → timeline3d-BcW68fQr.js} +2 -2
- package/web/assets/{timeline3dExport-BO--SpAn.js → timeline3dExport-DgnorHLm.js} +1 -1
- package/web/assets/timelineComp-Ciu9JCWJ.js +1 -0
- package/web/assets/timelineOps-f1WsVbgS.js +526 -0
- package/web/assets/{timelineProps-Cm_Irino.js → timelineProps-CE1R11Hx.js} +1 -1
- package/web/assets/{timelineText-DjPW2-dd.js → timelineText-Cppd4KB7.js} +1 -1
- package/web/assets/{titleArt-BSu80bfN.js → titleArt-D0YI5xT2.js} +3 -3
- package/web/assets/{titleFrameBudget-BW-N1-cw.js → titleFrameBudget-h4nOQ5u9.js} +1382 -991
- package/web/assets/titleFrames-DnCzi_AI.js +1 -0
- package/web/assets/{tool-Bboi3NDg.js → tool-tp6gat1J.js} +1 -1
- package/web/assets/{tools-kgYkohv8.js → tools-C07G9KUM.js} +1 -1
- package/web/assets/{toonTools-Bxz_HSqT.js → toonTools-Cazx2CL7.js} +2 -2
- package/web/assets/{trackAnchor-DK9cEMCf.js → trackAnchor-DoqFDcJB.js} +1 -1
- package/web/assets/{userFonts-DSkZHfmh.js → userFonts-BlVEJfDk.js} +1 -1
- package/web/assets/{vfxAlpha-B0rNpKZN.js → vfxAlpha-Bp6VgIGN.js} +1 -1
- package/web/assets/vfxBackground-BFq44Srn.js +2 -0
- package/web/assets/{videoExport-Cu0vw-dL.js → videoExport-Cz02XKtX.js} +1 -1
- package/web/assets/{views-CmulxRJP.js → views-CNF3Afse.js} +1 -1
- package/web/assets/{weaponDuel-DuuMMfzY.js → weaponDuel-ChqBQo_b.js} +1 -1
- package/web/assets/{windowFrames-BP2oDn-n.js → windowFrames-dBMXwGek.js} +1 -1
- package/web/layer-worker.html +3 -3
- package/web/shot-worker.html +24 -24
- package/web/assets/ShotComposer-CoxtWL6A.js +0 -287
- package/web/assets/ShotComposer-deLi4grZ.css +0 -1
- package/web/assets/TimelineShotFx-muTN__gf.js +0 -2
- package/web/assets/analyzerRun-BswbLsRF.js +0 -1
- package/web/assets/auraTrack-C9diszRB.js +0 -1
- package/web/assets/depthEstimate-HrGq0Ffx.js +0 -1
- package/web/assets/distortFrames-D-DK2HlN.js +0 -2
- package/web/assets/distortGL-waTJhiOf.js +0 -12
- package/web/assets/exportGlb-Cm07JQXt.js +0 -2
- package/web/assets/gpuExport-Dlf6YjLs.js +0 -198
- package/web/assets/i18n-C9zFX25m.js +0 -3
- package/web/assets/layer-worker-Drj-NLVj.js +0 -5
- package/web/assets/library-BhH-xsMR.js +0 -1
- package/web/assets/main-DAk1Tv1E.js +0 -309
- package/web/assets/matteFixRun-BHD3Qnta.js +0 -1
- package/web/assets/plateCamera-D1A1iEpf.js +0 -1
- package/web/assets/plateMatte-CWT1ymGj.js +0 -2
- package/web/assets/remote-kxNNhmis.js +0 -974
- package/web/assets/rotoscope-Z8bn-jRs.js +0 -1
- package/web/assets/sceneTrack-BKknn180.js +0 -1
- package/web/assets/timelineComp-D8PHGHgQ.js +0 -1
- package/web/assets/timelineOps-CEGk2t4h.js +0 -525
- package/web/assets/titleFrames-BHFaInux.js +0 -1
- package/web/assets/vfxBackground-CBTDl1xA.js +0 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{trackPose as S}from"./poseTracker-qtuytI-L.js";import{cO as v,cP as w,cQ as z}from"./timelineOps-f1WsVbgS.js";import{b_ as T,cz as q}from"./titleFrameBudget-h4nOQ5u9.js";import{u as x}from"./store-D3Y663py.js";import{t as l}from"./i18n-ClNt3LKg.js";import"./personHq-CBP8v_cw.js";import"./matteQuality-9X-jgJrH.js";import"./api-CZoVJ9Fy.js";import"./index-CKtv7gGE.js";import"./rigTrack-BbKqZGs7.js";import"./sceneTrack-CO4fTjft.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./clientJobs-CuuUyhEy.js";async function _(s,f){const e=f.params??{},a=x.getState(),r=a.clips.find(t=>t.id===e.source);if(!r||r.kind!=="video")throw Error(l("Không tìm thấy clip video để bám dáng người"));const g=document.querySelector(`video[data-clip-media="${r.id}"]`)?.currentSrc||r.url,p=e.from??0,y=e.duration??s.duration,{frames:c,aspect:k}=await S({clip:r,url:g,from:p,duration:y,fps:v.fps,person:e.person??1});if(!c.some(t=>t.lm))throw Error(l("Không thấy người trong đoạn này để gắn aura"));const{width:u,height:d}=T(a.timelineFormat),b=Math.round(k*1e3),A=1e3,M=w(c.map(t=>({t:t.t,lm:t.lm})),([t,n])=>[t,n]).map(t=>{const n=p+t[0],m=[t[0]];for(let i=1;i<t.length;i+=2){if(t[i]<0){m.push(-1,-1);continue}const h=q(r,t[i],t[i+1],n,u,d,b,A);m.push(Math.round(h.px/u*1e3)/1e3,Math.round(h.py/d*1e3)/1e3)}return m}),o=s.motion?.params??{};return{motion:z(M,{look:o.look,color:o.color,hot:o.hot,size:o.size,intensity:o.intensity,wind:[Number(o.windX)||0,Number(o.windY)||0],speed:o.speed,stretch:o.stretch,taper:o.taper})}}export{_ as runAuraTrack};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-
|
|
2
|
-
import{_ as R}from"./titleFrameBudget-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-CpkPQOQH.js","assets/index-CKtv7gGE.js","assets/i18n-ClNt3LKg.js","assets/api-CZoVJ9Fy.js","assets/titleFrameBudget-h4nOQ5u9.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-D3Y663py.js","assets/rotoMaskStore-BZBJLcCp.js","assets/sceneTrack-CO4fTjft.js","assets/timelineOps-f1WsVbgS.js","assets/cameraTracker-Df9jWmz6.js","assets/textAnimators-C4eMnVRD.js","assets/timelineComp-Ciu9JCWJ.js","assets/rigTrack-BbKqZGs7.js","assets/clientJobs-CuuUyhEy.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as R}from"./titleFrameBudget-h4nOQ5u9.js";import{fg as U,bU as q,de as x,fD as B,f9 as N,c7 as z,bX as F,bW as G,eh as H}from"./remote-CpkPQOQH.js";import{c as V}from"./cameraPresets-DD0WmxiI.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const W=()=>crypto.randomUUID(),s=i=>Math.round(i*100)/100,P={"luyen-khi":{color:"#e6f2ff",tiers:9,core:!1,name:"Luyện khí"},"truc-co":{color:"#5cff9a",tiers:3,core:!1,name:"Trúc cơ"},"ket-dan":{color:"#ffcf4a",tiers:9,core:!0,name:"Kết đan"},"nguyen-anh":{color:"#b066ff",tiers:12,core:!0,name:"Nguyên anh"},"hoa-than":{color:"#5cc8ff",tiers:12,core:!0,name:"Hoá thần"}};function X(i,c){const e=x(i),j=e.duration/c,f=n=>n?.map(u=>({...u,time:Math.min(1,u.time*j)})),m={...e,duration:c,cameraKeys:f(e.cameraKeys)??[],objectKeys:Object.fromEntries(Object.entries(e.objectKeys||{}).map(([n,u])=>[n,f(u)||[]])),...e.flight?{flight:Object.fromEntries(Object.entries(e.flight).map(([n,u])=>[n,f(u)||[]]))}:{},...e.focus?.keys?{focus:{...e.focus,keys:f(e.focus.keys)}}:{}};return{...i,shots:i.shots.map(n=>n.id===e.id?m:n)}}async function ht(i,c){let e;try{e=U(c.getStage(),String(i.name??""))}catch(t){return{ok:!1,error:t.message}}if(!q(e))return{ok:!1,error:`'${e.name}' is not a person`};const j=String(i.realm??"ket-dan"),f=P[j];if(!f)return{ok:!1,error:`unknown realm; use one of ${Object.keys(P).join(", ")}`};const m=i.outcome==="fail",n=i.tribulation!==!1,u=Math.max(1,Math.min(9,Number(i.strikes??4)||4)),v=Math.max(.8,Math.min(12,Number(i.height??2)||2)),y=Math.max(0,Number(i.start??0)||0),A=String(i.color??f.color),M=y+2.6,g=M+3.2,O=g+1.2,$=n?1.6+u*1.05:0,C=g+2.4+$,h=C,p=h+1.6,_=p+2.2,w=m?h+2.6:_+2.6;let l=c.getStage();w+.5>x(l).duration&&(l=X(l,Math.min(300,Math.ceil((w+.6)*10)/10)));const S=[],E=[],k=(t,r,o=!1)=>{const a=G(t);if(!a){S.push(`${t} missing`);return}const d=H(l,e.id,a,{start:r/x(l).duration,newId:W,loop:o});d.ok?(l=d.stage,E.push({motion:t,at_s:s(r)})):S.push(`${t}: ${d.error}`)};k("xx-seal-seated",y),k("xx-bt-gather",M,!0),k("xx-bt-strain",g,!0);const T=O,K=n?B($+1.2,u).map(t=>T+t):[];for(const t of K)k("xx-bt-endure",Math.max(g,t-.12));if(m)k("xx-bt-backlash",h);else{const t=x(l),r=t.duration;let o=N(t.flight?.[e.id],{time:h/r,on:!0,height:v});o=N(o,{time:(_+1.4)/r,on:!1}),l={...l,shots:l.shots.map(a=>a.id===t.id?{...a,flight:{...a.flight,[e.id]:o}}:a)},k("xx-bt-lotus-air",h,!0),k("xx-bt-roar",p),k("xx-bt-settle",_)}c.setStage(()=>l);const{runTool:L}=await R(async()=>{const{runTool:t}=await import("./remote-CpkPQOQH.js").then(r=>r.fO);return{runTool:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15])),I=[],b=async(t,r,o,a={})=>{const d=await L("add_effect",{effect:t,attach_to:e.name,start:s(r),duration:o,color:A,...a},c);d.ok?I.push({effect:t,start_s:s(r)}):S.push(`${t}: ${String(d.error)}`)};if(await b("linh-khi-quy-nguyen",y+.6,g-y+1),await b("kinh-mach-kim",M+.8,4),await b("canh-gioi-ket-dan",g-.4,2.4+$+.8,{params:{tiers:f.tiers}}),n&&await b(m?"kiep-van-huyet":"kiep-van-thien-loi",T,$+1.2,{params:{strikes:u},color:m?"#ff3040":"#9fd8ff"}),m)await b("huyet-vu",h+.5,1.6);else if(f.core&&await b("kim-dan-thanh",h+.2,1.8,{params:{seated:1,lift:v}}),await b("thien-quang-tru-kim",p+.62,3.2),await b("dot-pha-song-kim",p+.62,2.4,{params:{seated:1,lift:v}}),i.timing!==!1){const t=x(c.getStage()),r=z(F(t.timing,t.duration),p+.7,.45,.35,t.duration);c.setStage(o=>({...o,shots:o.shots.map(a=>a.id===t.id?{...a,timing:r??void 0}:a)}))}const D=[];if(i.camera!==!1){const t=[["orbit-180",y,g],["wide-track",g,O+.4],["low-hero",O+.4,m?w:p],...m?[]:[["wide-track",p,p+2.2],["orbit-180",_,w]]];for(const[r,o,a]of t){if(a-o<.4)continue;const d=V(c.getStage(),{preset:r,subject:e.id,start:o,end:a});d.ok&&(c.setStage(()=>d.stage),D.push(`${r} ${s(o)}–${s(a)} s`))}}return{ok:!0,name:e.name,realm:f.name,outcome:m?"fail":"success",start_s:s(y),gather_s:s(M),tribulation_s:n?s(T):null,strikes_s:K.map(s),...m?{backlash_s:s(h)}:{rise_s:s(h),burst_s:s(p+.62),landed_s:s(_+1.4)},end_s:s(w),moves:E,effects:I,...D.length?{camera:D}:{},...S.length?{notes:S}:{}}}export{P as REALMS,ht as stageBreakthrough};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{bU as D,de as K,f4 as V,bY as L,ee as R,f5 as W}from"./remote-kxNNhmis.js";const I=n=>n*Math.PI/180,y=(n,t,a)=>n<t?t:n>a?a:n,F=n=>{const t=y(n,0,1);return t*t*(3-2*t)},G={smooth:F,linear:n=>y(n,0,1),in:n=>{const t=y(n,0,1);return t*t*t},out:n=>{const t=1-y(n,0,1);return 1-t*t*t},snap:n=>1-Math.pow(1-y(n,0,1),4)},Z=Object.freeze([{id:"follow",name:"Bám theo",nameEn:"Follow"},{id:"reveal",name:"Quay vòng & lộ diện",nameEn:"Orbit & reveal"},{id:"impact",name:"Theo cú đánh",nameEn:"Impact"},{id:"director",name:"Đạo diễn hành động",nameEn:"Action director"},{id:"story",name:"Kể chuyện",nameEn:"Storytelling"}]),U=Object.freeze([{id:"side-track",cat:"follow",name:"Bám ngang",nameEn:"Side tracking",desc:"Máy quay chạy song song bên hông nhân vật, giữ khung trung cảnh — kiểu showreel game hành động.",descEn:"The camera runs alongside the subject at a medium framing — the action game showreel look.",lens:35,aim:.5,smooth:.35,path:[{u:0,offset:[4.2,.15,.4]},{u:1,offset:[4.2,.15,.4]}]},{id:"wide-track",cat:"follow",name:"Toàn cảnh bám ngang",nameEn:"Wide tracking",desc:"Toàn cảnh từ xa, ống kính rộng, thấy cả không gian và đường di chuyển.",descEn:"A wide shot from far off: the whole space and the path of the action.",lens:28,aim:.45,smooth:.6,path:[{u:0,offset:[7.5,.4,1.2]},{u:1,offset:[7.5,.4,1.2]}]},{id:"follow-behind",cat:"follow",name:"Bám sau lưng",nameEn:"Over-the-shoulder follow",desc:"Sau lưng, cao hơn đầu một chút — người xem đi cùng nhân vật.",descEn:"Behind and a little above the head — the audience moves with the subject.",lens:28,aim:.6,smooth:.3,handheld:.25,path:[{u:0,offset:[.7,.55,-2.6]},{u:1,offset:[.6,.5,-2.3]}]},{id:"low-hero",cat:"follow",name:"Góc thấp anh hùng",nameEn:"Low hero angle",desc:"Máy đặt thấp ngước lên, đẩy vào chậm — nhân vật trông mạnh mẽ.",descEn:"Low and looking up with a slow push in: the subject looks powerful.",lens:[24,28],aim:.62,smooth:.4,path:[{u:0,offset:[1.6,-.62,3.2]},{u:1,offset:[1.2,-.62,2.4],ease:"smooth"}]},{id:"worm-eye-dutch",cat:"follow",name:"Nhìn từ đất lên trời",nameEn:"Worm's-eye dutch",desc:"Máy sát đất ngước thẳng lên trời, ống kính rộng, khung nghiêng xoay dần — cảnh đấu trên không kiểu Dragon Ball.",descEn:"From the ground looking straight up, a wide lens and a slowly turning tilt — the sky battle of an anime.",lens:18,roll:[-14,10],aim:.85,smooth:.35,path:[{u:0,offset:[1.4,-.92,1.2]},{u:1,offset:[2,-.92,.4],ease:"smooth"}]},{id:"ground-level",cat:"follow",name:"Sát mặt đất",nameEn:"Ground level",desc:"Máy gần như nằm trên sàn — cho cú ngã, cú lộn, đòn quét chân.",descEn:"The camera almost on the floor: for falls, rolls and leg sweeps.",lens:22,aim:.3,smooth:.3,path:[{u:0,offset:[3,-.88,1.4]},{u:1,offset:[2.6,-.88,1]}]},{id:"orbit-180",cat:"reveal",name:"Quay vòng 180°",nameEn:"Orbit 180°",desc:"Vòng nửa quanh nhân vật từ hông sang mặt kia.",descEn:"Half a circle round the subject, from one side to the other.",lens:35,aim:.55,smooth:.4,path:[{u:0,offset:[3.6,.2,.6]},{u:1,offset:[-3.6,.2,.6],turn:180}]},{id:"bullet-time",cat:"reveal",name:"Bullet time",nameEn:"Bullet time",desc:"Vòng nhanh 270° quanh đòn đánh, sát và thấp — kiểu Ma trận.",descEn:"A fast 270° circle round the action, close and low — the Matrix look.",lens:30,aim:.55,smooth:.5,path:[{u:0,offset:[2.4,0,1.2]},{u:1,offset:[-2.4,.1,-1.2],turn:270,ease:"linear"}]},{id:"crane-down",cat:"reveal",name:"Cần cẩu hạ xuống",nameEn:"Crane down reveal",desc:"Từ trên cao hạ xuống ngang ngực, ống kính hẹp dần.",descEn:"From high above down to chest height, the lens tightening.",lens:[24,40],aim:.5,smooth:.5,path:[{u:0,offset:[2.2,3.6,4.2]},{u:1,offset:[1.6,.1,3]}]},{id:"dolly-zoom",cat:"reveal",name:"Dolly zoom (Vertigo)",nameEn:"Dolly zoom (Vertigo)",desc:"Máy lùi ra trong khi ống kính zoom vào: nhân vật giữ nguyên, hậu cảnh co giãn.",descEn:"The camera pulls back as the lens zooms in: the subject holds its size while the background warps.",lens:24,vertigo:!0,aim:.55,smooth:.4,path:[{u:0,offset:[.4,.1,2.2]},{u:1,offset:[.4,.1,6.5],ease:"smooth"}]},{id:"dutch-push",cat:"reveal",name:"Đẩy vào nghiêng",nameEn:"Dutch push-in",desc:"Đẩy vào với khung hình nghiêng dần — căng thẳng, bất an.",descEn:"A push in while the frame tilts — tension, unease.",lens:[32,45],roll:[0,14],aim:.62,smooth:.4,path:[{u:0,offset:[1.2,.2,4]},{u:1,offset:[.7,.15,2.4]}]},{id:"crash-zoom",cat:"impact",name:"Crash zoom vào đòn",nameEn:"Crash zoom on the hit",desc:"Toàn cảnh ngang, đúng đòn đầu tiên ống kính giật zoom vào cận và giữ.",descEn:"A wide side view; on the first strike the lens snaps in to a close-up and holds.",lens:26,aim:.55,smooth:.4,beats:{crash:2.6,shake:.7},path:[{u:0,offset:[5.2,.2,.6]},{u:1,offset:[5,.2,.6]}]},{id:"punch-beats",cat:"impact",name:"Punch-in theo nhịp đòn",nameEn:"Punch-in on every hit",desc:"Mỗi đòn trúng: ống kính giật vào 1 nhịp và rung — nhịp anime/game.",descEn:"Every strike kicks the lens in for a beat with a shake — the anime / game rhythm.",lens:32,aim:.55,smooth:.35,handheld:.15,beats:{punch:.35,shake:.55},path:[{u:0,offset:[3.6,.15,1]},{u:1,offset:[3.4,.15,.9]}]},{id:"whip-pan",cat:"impact",name:"Lia nhanh (whip pan)",nameEn:"Whip pan",desc:"Giữa cảnh máy lia vụt sang góc đối diện của nhân vật.",descEn:"Mid-shot the camera whips round to the opposite side of the subject.",lens:32,aim:.55,smooth:.3,path:[{u:0,offset:[3.4,.2,1.4]},{u:.46,offset:[3.4,.2,1.4]},{u:.56,offset:[-3,.25,1.8],turn:120,ease:"snap"},{u:1,offset:[-3,.25,1.6]}]},{id:"push-in",cat:"story",name:"Đẩy vào chậm",nameEn:"Slow push-in",desc:"Ngang tầm mắt, máy tiến chậm từ trung cảnh vào cận — nhấn một khoảnh khắc, một câu thoại.",descEn:"At eye level the camera creeps from a medium shot into a close-up — to stress a moment or a line.",lens:[32,45],aim:.62,smooth:.5,path:[{u:0,offset:[.5,.05,4]},{u:1,offset:[.3,.02,1.7],ease:"smooth"}]},{id:"pull-away",cat:"story",name:"Lùi xa lộ cảnh",nameEn:"Pull-away reveal",desc:"Từ cận mặt, máy lùi và nâng dần lên — lộ ra không gian quanh nhân vật, hợp cho cảnh kết.",descEn:"From a close-up the camera backs away and rises — the space around the subject is revealed, a fitting ending.",lens:[45,28],aim:.55,smooth:.5,path:[{u:0,offset:[.3,.05,1.6]},{u:1,offset:[1.6,1.8,7.5],ease:"smooth"}]},{id:"walk-lead",cat:"story",name:"Đi trước nhân vật",nameEn:"Walk-and-talk lead",desc:"Máy lùi phía trước, giữ mặt nhân vật trung cảnh khi họ bước tới — kiểu walk-and-talk.",descEn:"The camera backs up in front of the subject, holding a medium shot of the face as they walk — the walk-and-talk.",lens:35,aim:.62,smooth:.5,path:[{u:0,offset:[.35,.05,2.4]},{u:1,offset:[.3,.05,2.2]}]},{id:"slider",cat:"story",name:"Trượt ngang (slider)",nameEn:"Slider move",desc:"Máy trượt ngang chậm trước nhân vật, tiền cảnh và hậu cảnh lệch nhau tạo chiều sâu — hợp cảnh sản phẩm, phỏng vấn.",descEn:"A slow sideways slide in front of the subject; foreground and background shift for depth — product and interview shots.",lens:40,aim:.55,smooth:.5,path:[{u:0,offset:[-1.8,0,3]},{u:1,offset:[1.8,0,3],ease:"smooth"}]},{id:"arc-slow",cat:"story",name:"Vòng cung nhẹ",nameEn:"Gentle arc",desc:"Máy đi một cung 40° quanh nhân vật ở trung cảnh — cảnh thoại, cảnh suy tư có hồn hơn máy đứng yên.",descEn:"A 40° arc round the subject at a medium framing — dialogue or a thoughtful beat feels alive.",lens:40,aim:.6,smooth:.5,path:[{u:0,offset:[2.2,.05,2.6]},{u:1,offset:[.01,.05,3.4],turn:-40,ease:"smooth"}]},{id:"drone-rise",cat:"story",name:"Flycam bay lên",nameEn:"Drone rise",desc:"Từ ngang người, máy bay lên cao và lùi xa — mở cảnh hoặc kết cảnh toàn cảnh.",descEn:"From body height the camera climbs high and backs away — an establishing or closing wide shot.",lens:[28,24],aim:.5,smooth:.6,path:[{u:0,offset:[1.5,.2,3.2]},{u:1,offset:[2.5,5.5,8.5],ease:"smooth"}]},{id:"drone-dive",cat:"story",name:"Flycam bổ nhào",nameEn:"Drone dive",desc:"Từ trên cao máy lao xuống, dừng ngang tầm nhân vật — giới thiệu nhân vật giữa bối cảnh.",descEn:"From high above the camera dives down and settles at the subject's height — introduces them in their world.",lens:[24,32],aim:.55,smooth:.6,path:[{u:0,offset:[2,6.5,8]},{u:1,offset:[.6,.15,2.4],ease:"smooth"}]},{id:"fpv-sweep",cat:"story",name:"FPV lượn quanh",nameEn:"FPV sweep",desc:"Kiểu drone FPV: từ sau lưng sát thấp, lượn vòng qua hông lên trước mặt, ống kính rộng, hơi nghiêng.",descEn:"An FPV drone: low behind the subject, swooping round the side up to the front — wide lens, a slight bank.",lens:18,aim:.5,smooth:.4,handheld:.2,roll:[-10,8],path:[{u:0,offset:[.4,.3,-2.4]},{u:.5,offset:[2.6,.6,.2],turn:-85},{u:1,offset:[.3,1.2,2.6],turn:-79}]},{id:"action-director",cat:"director",name:"Đạo diễn hành động",nameEn:"Action director",desc:"Tự cắt góc theo nhịp đòn: toàn cảnh → cận góc thấp lúc trúng đòn → qua vai → toàn cảnh.",descEn:"Cuts on the beats by itself: wide → low close-up on the hit → over the shoulder → wide.",lens:28,aim:.5,smooth:.35,beats:{shake:.6},path:[{u:0,offset:[6,.3,1]},{u:1,offset:[5.6,.3,.8]}],cuts:[{offset:[6,.3,1],lens:28,aim:.5},{offset:[1.9,-.5,2.6],lens:30,aim:.55},{offset:[.7,.5,-2.4],lens:28,aim:.6},{offset:[-3.2,.1,1.6],lens:40,aim:.55}]}]),_=n=>U.find(t=>t.id===n),H=n=>Array.isArray(n)?n:[n,n];function B(n,t){if(t<=n[0].u)return n[0].offset;const a=n[n.length-1];if(t>=a.u)return a.offset;let o=0;for(;o<n.length-2&&t>=n[o+1].u;)o++;const l=n[o],s=n[o+1],h=(G[s.ease??"smooth"]??F)((t-l.u)/Math.max(1e-6,s.u-l.u)),i=l.offset,r=s.offset;if(s.turn==null)return[i[0]+(r[0]-i[0])*h,i[1]+(r[1]-i[1])*h,i[2]+(r[2]-i[2])*h];const m=Math.hypot(i[0],i[2]),u=Math.hypot(r[0],r[2]),d=Math.atan2(i[0],i[2]),f=d+N(i,r,s.turn)*h,g=m+(u-m)*h;return[Math.sin(f)*g,i[1]+(r[1]-i[1])*h,Math.cos(f)*g]}function N(n,t,a){const o=((Math.atan2(t[0],t[2])-Math.atan2(n[0],n[2]))*180/Math.PI+540)%360-180,l=Math.abs(a),s=Math.sign(a)||1;let h=o;for(const i of[o-360,o,o+360]){const r=Math.abs(Math.abs(i)-l),m=Math.abs(Math.abs(h)-l);(r<m-1e-9||Math.abs(r-m)<1e-9&&Math.sign(i)===s&&Math.sign(h)!==s)&&(h=i)}return I(h)}const O=(n,t)=>{const[a,o]=H(n??0);return a+(o-a)*F(t)},Q=(n,t=.35)=>n<-.06?0:n<0?1+n/.06:Math.exp(-n/Math.max(.05,t)*2.2);function P(n,t,a){const o=Math.max(1e-6,a.end-a.start),l=y((t-a.start)/o,0,1),s=Math.max(.3,a.height/1.8),h=Math.max(0,n.smooth??.3),i=Math.max(1,Math.round(h*30)),r=[0,0,0];for(let e=-i;e<=i;e++){const c=a.centre(y(t+h*e/i,a.start,a.end));r[0]+=c[0],r[1]+=c[1],r[2]+=c[2]}r[0]/=2*i+1,r[1]/=2*i+1,r[2]/=2*i+1;const m=(a.beats||[]).filter(e=>e>=a.start-1e-6&&e<=a.end+1e-6);let u=B(n.path,l),d=O(n.lens,l),f=n.aim??.5,g=null;if(n.cuts?.length){g=m.filter(p=>t>=p-.05).length%n.cuts.length;const c=n.cuts[g];u=c.offset,d=c.lens??d,f=c.aim??f}const b=I(a.yaw||0),j=Math.cos(b),z=Math.sin(b),w=u[0]*s,E=u[1]*s,M=u[2]*s,k=[r[0],r[1]+a.height*f,r[2]],A=[k[0]+w*j+M*z,Math.max(.12,k[1]+E),k[2]-w*z+M*j];if(n.vertigo){const e=Math.hypot(...B(n.path,0)),c=Math.hypot(u[0],u[1],u[2]);d=d*(c/Math.max(.1,e))}const x=n.beats;if(x?.punch){let e=0;for(const c of m)e=Math.max(e,Q(t-c));d*=1+x.punch*e}if(x?.crash&&m.length){const e=m[0];d*=1+(x.crash-1)*G.snap(y((t-(e-.08))/.12,0,1))}return{position:A,target:k,lens:y(d,12,200),roll:O(n.roll,l),cut:g}}function Y(n,t,a,o,l){const s=n.beats?.shake;return s?t.filter(h=>h>=a-1e-6&&h<=o+1e-6).map(h=>({time:Math.round(h/Math.max(1e-6,l)*1e4)/1e4,strength:s})):[]}const $=()=>crypto.randomUUID(),v=(n,t=1e3)=>Math.round(n*t)/t,J=n=>(D(n)?1.8*R(n):1.8)*(n.scale?.[1]||1);function nn(n,t){const a=t?n.items.find(o=>o.id===t):null;return a&&a.kind!=="fx"&&!a.hold&&!a.hidden?a:n.items.find(o=>o.kind==="person"&&!o.hidden)??n.items.find(o=>D(o)&&!o.hidden)??null}function tn(n,t){const a=typeof t.preset=="string"?_(t.preset):t.preset;if(!a)return{ok:!1,error:`unknown camera preset ${String(t.preset)}`};const o=K(n),l=n.items.find(e=>e.id===t.subject||e.name===t.subject);if(!l)return{ok:!1,error:"no subject to frame"};const s=Math.max(0,Math.min(o.duration,t.start??0)),h=Math.max(s,Math.min(o.duration,t.end??o.duration));if(h-s<.25)return{ok:!1,error:"not enough shot time after the playhead for a camera move (extend the shot)"};const i=J(l),r=V(n,l,s).rotation[1],m=L(n).filter(e=>e.who===l.id).map(e=>e.time),u={start:s,end:h,yaw:r,height:i,beats:m,centre:e=>V(n,l,e).position},d=Math.max(2,Math.round((h-s)*W)),f=[],g=(e,c)=>({id:$(),time:v(e/o.duration,1e5),position:c.position.map(p=>v(p)),target:c.target.map(p=>v(p)),lens:v(c.lens,100),roll:v(c.roll,100)});let b=null,j=0;for(let e=0;e<=d;e++){const c=s+(h-s)*(e/d),p=P(a,c,u);if(p.cut!=null&&b!=null&&p.cut!==b){let T=s+(h-s)*((e-1)/d),S=c;for(let q=0;q<12;q++){const C=(T+S)/2;P(a,C,u).cut===b?T=C:S=C}f.push(g(T,P(a,T,u)),g(S,P(a,S,u))),j++}f.push(g(c,p)),b=p.cut}const w=[...(o.cameraKeys||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...f].sort((e,c)=>e.time-c.time),E=w[0],M=w[w.length-1],k=Y(a,m,s,h,o.duration),A=k.length?[...(o.impacts||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...k].sort((e,c)=>e.time-c.time):o.impacts,x={...o,motion:"path",pathSmooth:!1,cameraMode:"track",cameraKeys:w,cameraSpec:void 0,position:E.position,target:E.target,lens:E.lens,roll:E.roll,endPosition:M.position,endTarget:M.target,endLens:M.lens,...a.handheld!=null?{handheld:a.handheld}:{},...A?{impacts:A}:{}};return{ok:!0,stage:{...n,shots:n.shots.map(e=>e.id===o.id?x:e)},preset:a.id,subject:l.name,start:v(s),end:v(h),keys:f.length,beats:m.filter(e=>e>=s&&e<=h).length,cuts:j}}export{U as C,nn as a,Z as b,tn as c,P as p};
|
|
1
|
+
import{bU as D,de as K,f4 as V,bY as L,ee as R,f5 as W}from"./remote-CpkPQOQH.js";const I=n=>n*Math.PI/180,y=(n,t,a)=>n<t?t:n>a?a:n,F=n=>{const t=y(n,0,1);return t*t*(3-2*t)},G={smooth:F,linear:n=>y(n,0,1),in:n=>{const t=y(n,0,1);return t*t*t},out:n=>{const t=1-y(n,0,1);return 1-t*t*t},snap:n=>1-Math.pow(1-y(n,0,1),4)},Z=Object.freeze([{id:"follow",name:"Bám theo",nameEn:"Follow"},{id:"reveal",name:"Quay vòng & lộ diện",nameEn:"Orbit & reveal"},{id:"impact",name:"Theo cú đánh",nameEn:"Impact"},{id:"director",name:"Đạo diễn hành động",nameEn:"Action director"},{id:"story",name:"Kể chuyện",nameEn:"Storytelling"}]),U=Object.freeze([{id:"side-track",cat:"follow",name:"Bám ngang",nameEn:"Side tracking",desc:"Máy quay chạy song song bên hông nhân vật, giữ khung trung cảnh — kiểu showreel game hành động.",descEn:"The camera runs alongside the subject at a medium framing — the action game showreel look.",lens:35,aim:.5,smooth:.35,path:[{u:0,offset:[4.2,.15,.4]},{u:1,offset:[4.2,.15,.4]}]},{id:"wide-track",cat:"follow",name:"Toàn cảnh bám ngang",nameEn:"Wide tracking",desc:"Toàn cảnh từ xa, ống kính rộng, thấy cả không gian và đường di chuyển.",descEn:"A wide shot from far off: the whole space and the path of the action.",lens:28,aim:.45,smooth:.6,path:[{u:0,offset:[7.5,.4,1.2]},{u:1,offset:[7.5,.4,1.2]}]},{id:"follow-behind",cat:"follow",name:"Bám sau lưng",nameEn:"Over-the-shoulder follow",desc:"Sau lưng, cao hơn đầu một chút — người xem đi cùng nhân vật.",descEn:"Behind and a little above the head — the audience moves with the subject.",lens:28,aim:.6,smooth:.3,handheld:.25,path:[{u:0,offset:[.7,.55,-2.6]},{u:1,offset:[.6,.5,-2.3]}]},{id:"low-hero",cat:"follow",name:"Góc thấp anh hùng",nameEn:"Low hero angle",desc:"Máy đặt thấp ngước lên, đẩy vào chậm — nhân vật trông mạnh mẽ.",descEn:"Low and looking up with a slow push in: the subject looks powerful.",lens:[24,28],aim:.62,smooth:.4,path:[{u:0,offset:[1.6,-.62,3.2]},{u:1,offset:[1.2,-.62,2.4],ease:"smooth"}]},{id:"worm-eye-dutch",cat:"follow",name:"Nhìn từ đất lên trời",nameEn:"Worm's-eye dutch",desc:"Máy sát đất ngước thẳng lên trời, ống kính rộng, khung nghiêng xoay dần — cảnh đấu trên không kiểu Dragon Ball.",descEn:"From the ground looking straight up, a wide lens and a slowly turning tilt — the sky battle of an anime.",lens:18,roll:[-14,10],aim:.85,smooth:.35,path:[{u:0,offset:[1.4,-.92,1.2]},{u:1,offset:[2,-.92,.4],ease:"smooth"}]},{id:"ground-level",cat:"follow",name:"Sát mặt đất",nameEn:"Ground level",desc:"Máy gần như nằm trên sàn — cho cú ngã, cú lộn, đòn quét chân.",descEn:"The camera almost on the floor: for falls, rolls and leg sweeps.",lens:22,aim:.3,smooth:.3,path:[{u:0,offset:[3,-.88,1.4]},{u:1,offset:[2.6,-.88,1]}]},{id:"orbit-180",cat:"reveal",name:"Quay vòng 180°",nameEn:"Orbit 180°",desc:"Vòng nửa quanh nhân vật từ hông sang mặt kia.",descEn:"Half a circle round the subject, from one side to the other.",lens:35,aim:.55,smooth:.4,path:[{u:0,offset:[3.6,.2,.6]},{u:1,offset:[-3.6,.2,.6],turn:180}]},{id:"bullet-time",cat:"reveal",name:"Bullet time",nameEn:"Bullet time",desc:"Vòng nhanh 270° quanh đòn đánh, sát và thấp — kiểu Ma trận.",descEn:"A fast 270° circle round the action, close and low — the Matrix look.",lens:30,aim:.55,smooth:.5,path:[{u:0,offset:[2.4,0,1.2]},{u:1,offset:[-2.4,.1,-1.2],turn:270,ease:"linear"}]},{id:"crane-down",cat:"reveal",name:"Cần cẩu hạ xuống",nameEn:"Crane down reveal",desc:"Từ trên cao hạ xuống ngang ngực, ống kính hẹp dần.",descEn:"From high above down to chest height, the lens tightening.",lens:[24,40],aim:.5,smooth:.5,path:[{u:0,offset:[2.2,3.6,4.2]},{u:1,offset:[1.6,.1,3]}]},{id:"dolly-zoom",cat:"reveal",name:"Dolly zoom (Vertigo)",nameEn:"Dolly zoom (Vertigo)",desc:"Máy lùi ra trong khi ống kính zoom vào: nhân vật giữ nguyên, hậu cảnh co giãn.",descEn:"The camera pulls back as the lens zooms in: the subject holds its size while the background warps.",lens:24,vertigo:!0,aim:.55,smooth:.4,path:[{u:0,offset:[.4,.1,2.2]},{u:1,offset:[.4,.1,6.5],ease:"smooth"}]},{id:"dutch-push",cat:"reveal",name:"Đẩy vào nghiêng",nameEn:"Dutch push-in",desc:"Đẩy vào với khung hình nghiêng dần — căng thẳng, bất an.",descEn:"A push in while the frame tilts — tension, unease.",lens:[32,45],roll:[0,14],aim:.62,smooth:.4,path:[{u:0,offset:[1.2,.2,4]},{u:1,offset:[.7,.15,2.4]}]},{id:"crash-zoom",cat:"impact",name:"Crash zoom vào đòn",nameEn:"Crash zoom on the hit",desc:"Toàn cảnh ngang, đúng đòn đầu tiên ống kính giật zoom vào cận và giữ.",descEn:"A wide side view; on the first strike the lens snaps in to a close-up and holds.",lens:26,aim:.55,smooth:.4,beats:{crash:2.6,shake:.7},path:[{u:0,offset:[5.2,.2,.6]},{u:1,offset:[5,.2,.6]}]},{id:"punch-beats",cat:"impact",name:"Punch-in theo nhịp đòn",nameEn:"Punch-in on every hit",desc:"Mỗi đòn trúng: ống kính giật vào 1 nhịp và rung — nhịp anime/game.",descEn:"Every strike kicks the lens in for a beat with a shake — the anime / game rhythm.",lens:32,aim:.55,smooth:.35,handheld:.15,beats:{punch:.35,shake:.55},path:[{u:0,offset:[3.6,.15,1]},{u:1,offset:[3.4,.15,.9]}]},{id:"whip-pan",cat:"impact",name:"Lia nhanh (whip pan)",nameEn:"Whip pan",desc:"Giữa cảnh máy lia vụt sang góc đối diện của nhân vật.",descEn:"Mid-shot the camera whips round to the opposite side of the subject.",lens:32,aim:.55,smooth:.3,path:[{u:0,offset:[3.4,.2,1.4]},{u:.46,offset:[3.4,.2,1.4]},{u:.56,offset:[-3,.25,1.8],turn:120,ease:"snap"},{u:1,offset:[-3,.25,1.6]}]},{id:"push-in",cat:"story",name:"Đẩy vào chậm",nameEn:"Slow push-in",desc:"Ngang tầm mắt, máy tiến chậm từ trung cảnh vào cận — nhấn một khoảnh khắc, một câu thoại.",descEn:"At eye level the camera creeps from a medium shot into a close-up — to stress a moment or a line.",lens:[32,45],aim:.62,smooth:.5,path:[{u:0,offset:[.5,.05,4]},{u:1,offset:[.3,.02,1.7],ease:"smooth"}]},{id:"pull-away",cat:"story",name:"Lùi xa lộ cảnh",nameEn:"Pull-away reveal",desc:"Từ cận mặt, máy lùi và nâng dần lên — lộ ra không gian quanh nhân vật, hợp cho cảnh kết.",descEn:"From a close-up the camera backs away and rises — the space around the subject is revealed, a fitting ending.",lens:[45,28],aim:.55,smooth:.5,path:[{u:0,offset:[.3,.05,1.6]},{u:1,offset:[1.6,1.8,7.5],ease:"smooth"}]},{id:"walk-lead",cat:"story",name:"Đi trước nhân vật",nameEn:"Walk-and-talk lead",desc:"Máy lùi phía trước, giữ mặt nhân vật trung cảnh khi họ bước tới — kiểu walk-and-talk.",descEn:"The camera backs up in front of the subject, holding a medium shot of the face as they walk — the walk-and-talk.",lens:35,aim:.62,smooth:.5,path:[{u:0,offset:[.35,.05,2.4]},{u:1,offset:[.3,.05,2.2]}]},{id:"slider",cat:"story",name:"Trượt ngang (slider)",nameEn:"Slider move",desc:"Máy trượt ngang chậm trước nhân vật, tiền cảnh và hậu cảnh lệch nhau tạo chiều sâu — hợp cảnh sản phẩm, phỏng vấn.",descEn:"A slow sideways slide in front of the subject; foreground and background shift for depth — product and interview shots.",lens:40,aim:.55,smooth:.5,path:[{u:0,offset:[-1.8,0,3]},{u:1,offset:[1.8,0,3],ease:"smooth"}]},{id:"arc-slow",cat:"story",name:"Vòng cung nhẹ",nameEn:"Gentle arc",desc:"Máy đi một cung 40° quanh nhân vật ở trung cảnh — cảnh thoại, cảnh suy tư có hồn hơn máy đứng yên.",descEn:"A 40° arc round the subject at a medium framing — dialogue or a thoughtful beat feels alive.",lens:40,aim:.6,smooth:.5,path:[{u:0,offset:[2.2,.05,2.6]},{u:1,offset:[.01,.05,3.4],turn:-40,ease:"smooth"}]},{id:"drone-rise",cat:"story",name:"Flycam bay lên",nameEn:"Drone rise",desc:"Từ ngang người, máy bay lên cao và lùi xa — mở cảnh hoặc kết cảnh toàn cảnh.",descEn:"From body height the camera climbs high and backs away — an establishing or closing wide shot.",lens:[28,24],aim:.5,smooth:.6,path:[{u:0,offset:[1.5,.2,3.2]},{u:1,offset:[2.5,5.5,8.5],ease:"smooth"}]},{id:"drone-dive",cat:"story",name:"Flycam bổ nhào",nameEn:"Drone dive",desc:"Từ trên cao máy lao xuống, dừng ngang tầm nhân vật — giới thiệu nhân vật giữa bối cảnh.",descEn:"From high above the camera dives down and settles at the subject's height — introduces them in their world.",lens:[24,32],aim:.55,smooth:.6,path:[{u:0,offset:[2,6.5,8]},{u:1,offset:[.6,.15,2.4],ease:"smooth"}]},{id:"fpv-sweep",cat:"story",name:"FPV lượn quanh",nameEn:"FPV sweep",desc:"Kiểu drone FPV: từ sau lưng sát thấp, lượn vòng qua hông lên trước mặt, ống kính rộng, hơi nghiêng.",descEn:"An FPV drone: low behind the subject, swooping round the side up to the front — wide lens, a slight bank.",lens:18,aim:.5,smooth:.4,handheld:.2,roll:[-10,8],path:[{u:0,offset:[.4,.3,-2.4]},{u:.5,offset:[2.6,.6,.2],turn:-85},{u:1,offset:[.3,1.2,2.6],turn:-79}]},{id:"action-director",cat:"director",name:"Đạo diễn hành động",nameEn:"Action director",desc:"Tự cắt góc theo nhịp đòn: toàn cảnh → cận góc thấp lúc trúng đòn → qua vai → toàn cảnh.",descEn:"Cuts on the beats by itself: wide → low close-up on the hit → over the shoulder → wide.",lens:28,aim:.5,smooth:.35,beats:{shake:.6},path:[{u:0,offset:[6,.3,1]},{u:1,offset:[5.6,.3,.8]}],cuts:[{offset:[6,.3,1],lens:28,aim:.5},{offset:[1.9,-.5,2.6],lens:30,aim:.55},{offset:[.7,.5,-2.4],lens:28,aim:.6},{offset:[-3.2,.1,1.6],lens:40,aim:.55}]}]),_=n=>U.find(t=>t.id===n),H=n=>Array.isArray(n)?n:[n,n];function B(n,t){if(t<=n[0].u)return n[0].offset;const a=n[n.length-1];if(t>=a.u)return a.offset;let o=0;for(;o<n.length-2&&t>=n[o+1].u;)o++;const l=n[o],s=n[o+1],h=(G[s.ease??"smooth"]??F)((t-l.u)/Math.max(1e-6,s.u-l.u)),i=l.offset,r=s.offset;if(s.turn==null)return[i[0]+(r[0]-i[0])*h,i[1]+(r[1]-i[1])*h,i[2]+(r[2]-i[2])*h];const m=Math.hypot(i[0],i[2]),u=Math.hypot(r[0],r[2]),d=Math.atan2(i[0],i[2]),f=d+N(i,r,s.turn)*h,g=m+(u-m)*h;return[Math.sin(f)*g,i[1]+(r[1]-i[1])*h,Math.cos(f)*g]}function N(n,t,a){const o=((Math.atan2(t[0],t[2])-Math.atan2(n[0],n[2]))*180/Math.PI+540)%360-180,l=Math.abs(a),s=Math.sign(a)||1;let h=o;for(const i of[o-360,o,o+360]){const r=Math.abs(Math.abs(i)-l),m=Math.abs(Math.abs(h)-l);(r<m-1e-9||Math.abs(r-m)<1e-9&&Math.sign(i)===s&&Math.sign(h)!==s)&&(h=i)}return I(h)}const O=(n,t)=>{const[a,o]=H(n??0);return a+(o-a)*F(t)},Q=(n,t=.35)=>n<-.06?0:n<0?1+n/.06:Math.exp(-n/Math.max(.05,t)*2.2);function P(n,t,a){const o=Math.max(1e-6,a.end-a.start),l=y((t-a.start)/o,0,1),s=Math.max(.3,a.height/1.8),h=Math.max(0,n.smooth??.3),i=Math.max(1,Math.round(h*30)),r=[0,0,0];for(let e=-i;e<=i;e++){const c=a.centre(y(t+h*e/i,a.start,a.end));r[0]+=c[0],r[1]+=c[1],r[2]+=c[2]}r[0]/=2*i+1,r[1]/=2*i+1,r[2]/=2*i+1;const m=(a.beats||[]).filter(e=>e>=a.start-1e-6&&e<=a.end+1e-6);let u=B(n.path,l),d=O(n.lens,l),f=n.aim??.5,g=null;if(n.cuts?.length){g=m.filter(p=>t>=p-.05).length%n.cuts.length;const c=n.cuts[g];u=c.offset,d=c.lens??d,f=c.aim??f}const b=I(a.yaw||0),j=Math.cos(b),z=Math.sin(b),w=u[0]*s,E=u[1]*s,M=u[2]*s,k=[r[0],r[1]+a.height*f,r[2]],A=[k[0]+w*j+M*z,Math.max(.12,k[1]+E),k[2]-w*z+M*j];if(n.vertigo){const e=Math.hypot(...B(n.path,0)),c=Math.hypot(u[0],u[1],u[2]);d=d*(c/Math.max(.1,e))}const x=n.beats;if(x?.punch){let e=0;for(const c of m)e=Math.max(e,Q(t-c));d*=1+x.punch*e}if(x?.crash&&m.length){const e=m[0];d*=1+(x.crash-1)*G.snap(y((t-(e-.08))/.12,0,1))}return{position:A,target:k,lens:y(d,12,200),roll:O(n.roll,l),cut:g}}function Y(n,t,a,o,l){const s=n.beats?.shake;return s?t.filter(h=>h>=a-1e-6&&h<=o+1e-6).map(h=>({time:Math.round(h/Math.max(1e-6,l)*1e4)/1e4,strength:s})):[]}const $=()=>crypto.randomUUID(),v=(n,t=1e3)=>Math.round(n*t)/t,J=n=>(D(n)?1.8*R(n):1.8)*(n.scale?.[1]||1);function nn(n,t){const a=t?n.items.find(o=>o.id===t):null;return a&&a.kind!=="fx"&&!a.hold&&!a.hidden?a:n.items.find(o=>o.kind==="person"&&!o.hidden)??n.items.find(o=>D(o)&&!o.hidden)??null}function tn(n,t){const a=typeof t.preset=="string"?_(t.preset):t.preset;if(!a)return{ok:!1,error:`unknown camera preset ${String(t.preset)}`};const o=K(n),l=n.items.find(e=>e.id===t.subject||e.name===t.subject);if(!l)return{ok:!1,error:"no subject to frame"};const s=Math.max(0,Math.min(o.duration,t.start??0)),h=Math.max(s,Math.min(o.duration,t.end??o.duration));if(h-s<.25)return{ok:!1,error:"not enough shot time after the playhead for a camera move (extend the shot)"};const i=J(l),r=V(n,l,s).rotation[1],m=L(n).filter(e=>e.who===l.id).map(e=>e.time),u={start:s,end:h,yaw:r,height:i,beats:m,centre:e=>V(n,l,e).position},d=Math.max(2,Math.round((h-s)*W)),f=[],g=(e,c)=>({id:$(),time:v(e/o.duration,1e5),position:c.position.map(p=>v(p)),target:c.target.map(p=>v(p)),lens:v(c.lens,100),roll:v(c.roll,100)});let b=null,j=0;for(let e=0;e<=d;e++){const c=s+(h-s)*(e/d),p=P(a,c,u);if(p.cut!=null&&b!=null&&p.cut!==b){let T=s+(h-s)*((e-1)/d),S=c;for(let q=0;q<12;q++){const C=(T+S)/2;P(a,C,u).cut===b?T=C:S=C}f.push(g(T,P(a,T,u)),g(S,P(a,S,u))),j++}f.push(g(c,p)),b=p.cut}const w=[...(o.cameraKeys||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...f].sort((e,c)=>e.time-c.time),E=w[0],M=w[w.length-1],k=Y(a,m,s,h,o.duration),A=k.length?[...(o.impacts||[]).filter(e=>e.time*o.duration<s-1e-6||e.time*o.duration>h+1e-6),...k].sort((e,c)=>e.time-c.time):o.impacts,x={...o,motion:"path",pathSmooth:!1,cameraMode:"track",cameraKeys:w,cameraSpec:void 0,position:E.position,target:E.target,lens:E.lens,roll:E.roll,endPosition:M.position,endTarget:M.target,endLens:M.lens,...a.handheld!=null?{handheld:a.handheld}:{},...A?{impacts:A}:{}};return{ok:!0,stage:{...n,shots:n.shots.map(e=>e.id===o.id?x:e)},preset:a.id,subject:l.name,start:v(s),end:v(h),keys:f.length,beats:m.filter(e=>e>=s&&e<=h).length,cuts:j}}export{U as C,nn as a,Z as b,tn as c,P as p};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{G as de,
|
|
1
|
+
import{G as de,hl as St,eX as jt,eY as At,nc as pe,d1 as dt,aB as Ot,nd as Dt,bt as Kt,by as qt,ne as ge,cE as Ut,cC as Gt,cT as Xt,fp as It,nf as ye,ng as bt,e_ as Me,fe as xe,gJ as we,fg as be,gL as ke,lB as Te,dZ as Ae,d$ as ve,fd as Pe,gK as Yt,bw as Se,nh as Jt,e0 as Oe,lf as Ie}from"./titleFrameBudget-h4nOQ5u9.js";import{h as ae,A as Ee,j as Et,t as Ne}from"./textAnimators-C4eMnVRD.js";import{N as Fe,O as re,V as Re,p as ze,C as Ce,W as $e,F as Le,t as _e}from"./sceneTrack-CO4fTjft.js";const Nt="vfx-speed-bolt",et=Object.freeze({chunks:15,perChunk:75,fps:30,length:[.1,1.5],width:[.3,3],jag:[0,1.5]}),je=/^#[0-9a-fA-F]{6}$/,it=t=>Math.round(t*1e4)/1e4,Ft=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,Zt=t=>Math.round(Math.max(0,Math.min(1,t))*1295).toString(36).padStart(2,"0");function Ve(t){if(t.length<2)return{n:0,fps:et.fps,t0:0};const e=t[0][0],n=t.at(-1)[0]-e,a=et.chunks*et.perChunk,r=Math.min(et.fps,Math.max(1,Math.floor((a-1)/Math.max(.001,n)))),o=Math.min(a,Math.floor(n*r+1e-6)+1),i=c=>{let h=1;for(;h<t.length-1&&t[h][0]<c;)h++;const u=t[h-1],d=t[h],f=Math.max(0,Math.min(1,(c-u[0])/(d[0]-u[0]||1)));return[u[1]+(d[1]-u[1])*f,u[2]+(d[2]-u[2])*f]};let l="";for(let c=0;c<o;c++){const[h,u]=i(e+c/r);l+=Zt(h)+Zt(u)}const s={n:o,fps:r,t0:it(e)};for(let c=0;c*et.perChunk*4<l.length;c++)s["p"+c]=l.slice(c*et.perChunk*4,(c+1)*et.perChunk*4);return s}function Tn({id:t,at:e,duration:n,color:a,width:r,length:o,jag:i,source:l,point:s}){const c=de.find(w=>w.id===Nt),h=.03,u=s??[.5,.5],d={x:it(Math.max(0,Math.min(1-2*h,u[0]-h))),y:it(Math.max(0,Math.min(1-2*h,u[1]-h))),w:2*h,h:2*h},f={...c.params,color:je.test(a??"")?a:c.params.color,width:it(Ft(r,et.width,1)),length:it(Ft(o,et.length,.4)),jag:it(Ft(i,et.jag,.6))};return{id:t,nodeId:"",kind:"image",url:"",volume:0,start:it(e),duration:it(n),label:"Vệt sét",motionV:2,posX:0,posY:0,scale:1,opacity:0,motion:St({code:`@preset:${Nt}`,params:f,preset:Nt}),pendingPin:{source:l,at:it(e),region:d,mode:"bolt",...s?{}:{person:!0}}}}function An(t,e){if(e.length<2)return{pendingPin:void 0,opacity:0};const n=Object.fromEntries(Object.entries(t.motion.params).filter(([a])=>!/^p\d+$/.test(a)));return{pendingPin:void 0,opacity:1,motion:{...t.motion,params:{...n,...Ve(e)}}}}const Be=["classic","duotone-stack","outline-punch","accent-bar","neon-edge","echo-stack","tape-label","serif-year"],vn=[{id:"duotone-stack",name:"Tầng màu",sample:`ĐÁNH THỨC
|
|
2
2
|
Ý TƯỞNG`,category:"Bold",fontFamily:"Anton",fontSize:78,color:"#f8f8f2",accentColor:"#32d8cd",placement:"center",preset:"rise-pop"},{id:"outline-punch",name:"Viền bật",sample:"BỨT PHÁ",category:"Bold",fontFamily:"Montserrat",fontSize:82,color:"#ffffff",accentColor:"#ffb938",placement:"center",preset:"punch-in"},{id:"accent-bar",name:"Dải nhấn",sample:`ĐIỀU MỚI
|
|
3
|
-
BẮT ĐẦU`,category:"Social",fontFamily:"Be Vietnam Pro",fontSize:70,color:"#171b20",accentColor:"#dfff48",placement:"center",preset:"slide-left"},{id:"neon-edge",name:"Sắc điện",sample:"TỎA SÁNG",category:"Social",fontFamily:"Bungee",fontSize:66,color:"#f6fbff",accentColor:"#5de9ff",placement:"center",preset:"punch-in"},{id:"echo-stack",name:"Vang âm",sample:"TẠO KHÁC BIỆT",category:"Minimal",fontFamily:"Oswald",fontSize:82,color:"#ffffff",accentColor:"#9a73ff",placement:"center",preset:"rise-pop"},{id:"tape-label",name:"Nhãn băng keo",sample:"JAPAN, 1957",category:"Collage",fontFamily:"Oswald",fontSize:46,color:"#2a241c",accentColor:"#e6d9b8",placement:"top",preset:"slide-left"},{id:"serif-year",name:"Năm chữ có chân",sample:"1957",category:"Collage",fontFamily:"Playfair Display",fontSize:96,color:"#d62b25",accentColor:"#d62b25",placement:"top",preset:"pop-in"}],De={"word-pop":{in:[{unit:"word",stagger:.12,duration:.35,easing:"easeOutBack",from:{opacity:0,scale:.4}}]},"word-rise":{in:[{unit:"word",stagger:.1,duration:.4,easing:"easeOutCubic",from:{opacity:0,y:.6}}]},"line-slam":{in:[{unit:"line",stagger:.25,duration:.32,easing:"easeOutBack",from:{opacity:0,scale:2.2,blur:.2}}]},"type-on":{in:[{unit:"char",stagger:.04,duration:.05,easing:"linear",from:{opacity:0}}],out:"none"},"slide-in":{in:[{unit:"line",stagger:.15,duration:.45,easing:"easeOutQuart",from:{opacity:0,x:-1.5},mask:!0}]},"wipe-in":{in:[{unit:"line",stagger:.15,duration:.5,easing:"easeOutCubic",from:{wipeX:0}}]},"word-blur":{in:[{unit:"word",stagger:.09,duration:.2,easing:"easeOutCubic",from:{opacity:0,blur:.55}}]},"blur-rescale":{in:[{unit:"line",stagger:.08,duration:.24,easing:"easeOutExpo",from:{opacity:0,scale:1.6,blur:.45}}]},"flicker-on":{in:[{unit:"line",stagger:.06,duration:.4,easing:"linear",from:{flicker:1}}]},"slam-blur":{in:[{unit:"word",stagger:.08,duration:.26,easing:"easeOutExpo",from:{opacity:0,x:-2.2,scaleX:1.9,blur:.6,rotate:-6}}]},"slam-blur-right":{in:[{unit:"word",stagger:.08,duration:.26,easing:"easeOutExpo",from:{opacity:0,x:2.2,scaleX:1.9,blur:.6,rotate:6}}]},"glitch-scatter":{in:[{unit:"char",order:"random",stagger:.03,duration:.42,easing:"easeOutExpo",from:{opacity:0,scatter:2.6,rotate:-25,pixels:1,glitch:.8}}]},"pixel-burst":{in:[{unit:"word",stagger:.1,duration:.5,easing:"easeOutCubic",from:{opacity:.2,pixels:1,glitch:1,scaleX:1.25}}]},"glitch-in":{in:[{unit:"char",stagger:.025,duration:.24,easing:"easeOutCubic",from:{opacity:0,glitch:1,y:.25}}]},"mask-rise":{in:[{unit:"line",stagger:.08,duration:.36,easing:"easeOutCubic",mask:!0,from:{y:1.1}},{unit:"line",start:.1,duration:1.3,easing:"easeOutCubic",from:{brightness:.45}}]}},$t=Object.freeze(Object.fromEntries(Object.entries(De).map(([t,e])=>[t,Object.freeze(ae(e,`titleAnimations.${t}`))])));Object.freeze(Object.keys($t));const Zt=Object.freeze({weight:800,lineHeight:1.3,uppercase:!1,layers:[{type:"text",fill:"{color}",shadow:{color:"#000000",blur:.18,x:0,y:.03}}]}),mt=t=>Array.isArray(t)?t.map(mt):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([,e])=>e!==null).map(([e,n])=>[e,mt(n)])):t,Ke=t=>{if(t.length>2e4)throw Error("design: too long");try{return mt(JSON.parse(t))}catch{throw Error("design: invalid JSON")}},qe=["none","push-in","pull-out","pan-left","pan-right","slide-up","slide-left","pop-in","rise-pop","punch-in"];function Pn(t,e){if(!qe.includes(t)||!Number.isFinite(e)||e<1/30)throw Error("Invalid motion preset or duration");const n=(r,o=0,i=0,l=1)=>({time:r,x:o,y:i,zoom:l}),a=Math.min(.5,e/3);switch(t){case"none":return[];case"push-in":return[n(0),n(e,0,0,1.15)];case"pull-out":return[n(0,0,0,1.15),n(e)];case"pan-left":return[n(0,.07,0,1.2),n(e,-.07,0,1.2)];case"pan-right":return[n(0,-.07,0,1.2),n(e,.07,0,1.2)];case"slide-up":return[n(0,0,1),n(a),n(e)];case"slide-left":return[n(0,1),n(a),n(e)];case"pop-in":return[n(0,0,0,.25),n(a),n(e)];case"rise-pop":return[n(0,0,.22,.55),n(a*.7,0,-.025,1.08),n(a,0,0,1),n(e)];case"punch-in":return[n(0,0,0,.25),n(a*.7,0,0,1.13),n(a,0,0,1),n(e)]}}function Ue(t){if(typeof t.text!="string"||!t.text.trim()||t.text.length>200)throw Error("Text requires 1–200 characters");const e=t.fontSize??56,n=t.color??"#ffffff",a=t.placement??"lower";if(!Number.isFinite(e)||e<24||e>96||!/^#[0-9a-f]{6}$/i.test(n)||!["top","center","lower"].includes(a))throw Error("Invalid text style");const r=t.fontFamily??"Arial",o=t.align??"center";if(!Ee(r)||!["left","center","right"].includes(o))throw Error("Invalid font or alignment");const i=t.styleId??"classic",l=t.accentColor??"#32d8cd";if(!Be.includes(i)||!/^#[0-9a-f]{6}$/i.test(l))throw Error("Invalid text template style");const s={text:t.text,fontSize:e,color:n,placement:a,fontFamily:r,align:o,styleId:i,accentColor:l},c=typeof t.design=="string"?Ke(t.design):mt(t.design);if(typeof t.animation=="string"&&!Object.hasOwn($t,t.animation))throw Error(`Unknown title animation "${t.animation.slice(0,64)}"`);const h=mt(typeof t.animation=="string"?$t[t.animation]:t.animation);if(c!=null)s.design=Et(c),typeof t.templateId=="string"&&/^[a-z0-9][a-z0-9-]{1,63}$/.test(t.templateId)&&(s.templateId=t.templateId);else if(typeof t.templateId=="string"&&t.templateId)throw Error(`Unknown text template "${t.templateId.slice(0,64)}" (not published)`);h!=null&&(s.design||(s.design=Et(Zt)),s.animation=ae(h));const u=Ne(mt(t.animators));return u.length&&(s.design||(s.design=Et(Zt)),s.animators=u),s}const Ge={"muapi:seedance-2.5":{label:"Seedance 2.5",min:4,max:8},"muapi:wan-3.0-prime":{label:"Wan 3.0 Prime",min:2,max:8},"muapi:seedance-2.0":{label:"Seedance 2.0",min:4,max:8},"vertex:veo-omni":{label:"Gemini Omni 1.2",min:3,max:15},"muapi:seedance-2.5@480p":{label:"Seedance 2.5 · 480p",min:4,max:8,generator:"muapi:seedance-2.5",resolution:"480p"},"muapi:seedance-2.0-mini@480p":{label:"Seedance 2.0 Mini · 480p",min:4,max:8,generator:"muapi:seedance-2.0-mini",resolution:"480p"}},Sn=t=>{const e=Ge[t];return{generator:e?.generator||t,...e?.resolution?{resolution:e.resolution}:{}}},On=4,In={"openai:gpt-image-2.5-flare":{label:"GPT Image 2.5 Flare"},"openai:gpt-image-2.5-sunburst":{label:"GPT Image 2.5 Sunburst"},"openai:gpt-image-2.6-flare":{label:"GPT Image 2.6 Flare"},"openai:gpt-image-2.6-sunburst":{label:"GPT Image 2.6 Sunburst"}},En="openai:gpt-image-2.5-flare",Ht=Object.freeze(["lots","route","area","label","pin","photo","callout","overlay","icon"]),Lt=Object.freeze({glow:{vi:"Đường phát sáng",en:"Glowing line",color:"#3cf2d0",layers:[{w:18,blur:12,a:.5},{w:6},{w:2,c:"#ffffff",a:.85}]},dashed:{vi:"Nét đứt",en:"Dashed",color:"#ffffff",layers:[{w:12,blur:8,a:.35},{w:4,dash:[14,10]}]},"dashed-ring":{vi:"Vành đai (đỏ, gạch trắng)",en:"Ring road (red, white dashes)",color:"#ff2d3a",layers:[{w:24,blur:12,a:.55},{w:11},{w:3,c:"#ffffff",dash:[18,14]}]},"gradient-highway":{vi:"Cao tốc (cam → vàng)",en:"Expressway (orange → yellow)",color:"#ff7a1a",layers:[{w:26,blur:14,a:.6},{w:11},{w:5,c:"#ffd23a"},{w:1.6,c:"#fff7c2",a:.9}]},metro:{vi:"Metro (xanh ngọc)",en:"Metro line (cyan)",color:"#22e3ff",layers:[{w:18,blur:10,a:.5},{w:6},{w:1.8,c:"#ffffff",dash:[10,8],a:.9}]},link:{vi:"Đường liên kết (hồng, nét đứt)",en:"Link road (magenta, dashed)",color:"#ff2bd6",layers:[{w:16,blur:9,a:.5},{w:5},{w:2,c:"#ffffff",dash:[12,10],a:.95}]},thin:{vi:"Đường mảnh (trắng)",en:"Thin road (white)",color:"#ffffff",layers:[{w:7,blur:4,a:.3},{w:2.6}]},river:{vi:"Sông (xanh ngọc)",en:"River (teal)",color:"#1fd1c1",layers:[{w:28,blur:16,a:.45},{w:9,a:.9},{w:2.5,c:"#b9fff6",a:.6}]},trail:{vi:"Dải sáng nhiều làn (vàng)",en:"Light-trail lanes (gold)",color:"#ffdf1f",lanes:!0,layers:[{w:2.2},{w:2.2}]}}),Nn=Object.freeze(Object.keys(Lt)),Xe=Object.freeze(["rise","fade","wipe"]),Ye=/^#[0-9a-f]{6}$/i,R=(t,e,n)=>Math.max(e,Math.min(n,t)),_=t=>+t.toFixed(3),I=t=>+t.toFixed(4),Je=.2,ie=Ot["ease-in-out"],Vt=Ot["ease-out"],Qe=Ot["back-out"];function rt(t,e,n,a){if(!Array.isArray(t)||t.length<e||t.length>n)throw Error(`${a} needs ${e}–${n} points [u,v]`);return t.map(r=>{if(!Array.isArray(r)||r.length!==2||!r.every(o=>Number.isFinite(o)&&o>=-1&&o<=2))throw Error(`${a}: points are [u,v] (0..1 of the map picture)`);return[r[0],r[1]]})}const J=(t,e=60)=>typeof t=="string"?t.replace(/\s+/g," ").trim().slice(0,e):"",Ze=(t,e)=>typeof t=="string"&&Ye.test(t)?t.toLowerCase():e;function oe(t,e){const n=Math.min(1.5,2560/Math.max(t,e));return[Math.round(t*n),Math.round(e*n)]}function He(t,e){const[n,a]=oe(t,e),r=Math.min(n,a)/1e3,o=(n-1e3*r)/2,i=(a-1e3*r)/2;return{size:[n,a],pt:([l,s])=>[_((l*n/t-o)/r),_((s*a/e-i)/r)],len:l=>l*n/t/r}}function Wt(t,e=!1){if(t.length<3)return t;const n=t.length,a=s=>e?t[(s+n)%n]:t[R(s,0,n-1)],r=[],o=e?n:n-1,i=t.reduce((s,c,h)=>h?s+Math.hypot(c[0]-t[h-1][0],c[1]-t[h-1][1]):0,0),l=R(Math.round(i/10/o),2,Math.floor(240/o));for(let s=0;s<o;s++){const c=a(s-1),h=a(s),u=a(s+1),d=a(s+2);for(let f=0;f<l;f++){const w=f/l,g=w*w,T=g*w;r.push([0,1].map(O=>.5*(2*h[O]+(-c[O]+u[O])*w+(2*c[O]-5*h[O]+4*u[O]-d[O])*g+(-c[O]+3*h[O]-3*u[O]+d[O])*T)))}}return e||r.push(t[n-1]),r}const se=t=>t.reduce((e,n,a)=>a?e+Math.hypot(n[0]-t[a-1][0],n[1]-t[a-1][1]):0,0),wt=(t,e)=>{let n=Math.atan2(e,t)*180/Math.PI;return n>90&&(n-=180),n<=-90&&(n+=180),n};function We(t,e){const n=se(t);if(n<1)return{x:t[0][0],y:t[0][1],angle:0,nx:0,ny:-1};const a=[0];for(let u=1;u<t.length;u++)a.push(a[u-1]+Math.hypot(t[u][0]-t[u-1][0],t[u][1]-t[u-1][1]));const r=u=>{u=R(u,0,n);let d=1;for(;d<a.length-1&&a[d]<u;)d++;const f=(u-a[d-1])/(a[d]-a[d-1]||1);return[t[d-1][0]+(t[d][0]-t[d-1][0])*f,t[d-1][1]+(t[d][1]-t[d-1][1])*f]},o=Math.min(n/2,e*.55);let i=null;for(let u=0;u<=20;u++){const d=o+(n-2*o)*u/20,f=r(d-o),w=r(d+o),g=w[0]-f[0],T=w[1]-f[1],O=Math.hypot(g,T)||1;let B=0;for(let V=1;V<8;V++){const E=r(d-o+2*o*V/8);B=Math.max(B,Math.abs((E[0]-f[0])*T-(E[1]-f[1])*g)/O)}const U=B+Math.abs(d-n/2)/n*e*.15;(!i||U<i.score)&&(i={score:U,c:d,dx:g,dy:T})}const[l,s]=r(i.c),c=wt(i.dx,i.dy),h=c*Math.PI/180;return{x:l,y:s,angle:c,nx:Math.sin(h),ny:-Math.cos(h)}}function le(t,e=8){const n=se(t);if(n<1)return[{x:t[0][0],y:t[0][1],nx:0,ny:-1,s:0}];const a=[0];for(let l=1;l<t.length;l++)a.push(a[l-1]+Math.hypot(t[l][0]-t[l-1][0],t[l][1]-t[l-1][1]));const r=l=>{let s=1;for(;s<a.length-1&&a[s]<l;)s++;const c=(l-a[s-1])/(a[s]-a[s-1]||1);return[t[s-1][0]+(t[s][0]-t[s-1][0])*c,t[s-1][1]+(t[s][1]-t[s-1][1])*c]},o=R(Math.round(n/e),8,120),i=Array.from({length:o+1},(l,s)=>r(n*s/o));return i.map((l,s)=>{const c=i[Math.max(0,s-1)],h=i[Math.min(o,s+1)],u=h[0]-c[0],d=h[1]-c[1],f=Math.hypot(u,d)||1;return{x:l[0],y:l[1],nx:-d/f,ny:u/f,s:n*s/o}})}function ce(t,e){const n=t.map(i=>i.y),a=Math.min(...n),r=Math.max(...n)-a,o=Number.isFinite(e)?R(e,.1,1):r>24?.3:1;return t.map(i=>r>1e-6?I(o+(1-o)*(i.y-a)/r):1)}function tn(t,{lanes:e=9,width:n=70,taper:a}={}){const r=le(t),o=ce(r,a),i=R(Math.round(e),2,11),l=o.map(s=>n/2*s);return{lanes:Array.from({length:i},(s,c)=>{const h=c/(i-1)*2-1;return r.map((u,d)=>[u.x+u.nx*h*l[d],u.y+u.ny*h*l[d]])}),half:l,S:r,k:o}}const Rt=(t,e=0)=>((t+1)*.6180339887+e*.3819660113)%1;function en(t,{main:e,draw:n,dur:a,B:r,px:o,L:i}){t.lanes.length;const l=t.half.reduce((c,h)=>c+h,0)/t.half.length,s=[G("g","road glow",i(t.S.map(c=>[c.x,c.y])),!1,{stroke:q(e,r.len(l*1.8),{blur:r.len(l*.8),opacity:.28}),draw:[0,n]})];return t.lanes.forEach((c,h)=>{const u=Rt(h),d=n*.35*Rt(h,1),f=Math.min(a,d+n*.65);s.push(G("l"+(h+1),`lane ${h+1}`,i(c),!1,{stroke:q(e,r.len(o(h%3===1?3.4:2.2)),{blur:r.len(o(.8)),opacity:.8+.2*u}),draw:[d,f]}));const w=G("p"+(h+1),`streak ${h+1}`,i(c),!1,{stroke:q("#fffbe6",r.len(o(4.2)),{blur:r.len(o(2.4))})}),g=1.1+.9*Rt(h,2),T=[{time:I(f),value:-1}];for(let O=f;O<a&&T.length<58;)O+=2*g,T.push({time:I(O),value:1}),O<a&&T.push({time:I(O+.002),value:-1});w.ops=[{op:"trim",start:0,end:_(.08+.1*u),offset:0}],w.keys={"ops.0.offset":T,opacity:[{time:I(f),value:0,ease:Vt},{time:I(Math.min(f+.25,f+a)),value:1}]},s.push(w)}),s}const nn={weight:900,lineHeight:1.25,uppercase:!0,layers:[{type:"text",fill:"#000000",opacity:.45,offset:{x:.05,y:.16},shadow:{color:"#000000",blur:.35,x:0,y:0}},{type:"text",fill:"#6f7480",offset:{x:.018,y:.09}},{type:"text",fill:"#8e939d",offset:{x:.012,y:.06}},{type:"text",fill:"#b4b8c0",offset:{x:.006,y:.03}},{type:"text",fill:"#ffffff",stroke:{color:"#d9dce2",width:.02}}]},zt=t=>t===" "?.32:/[IÍÌỈĨỊ1.,:;!|'’]/.test(t)?.34:/[MWƯỨỪỬỮỰ]/.test(t)?.88:.7,an=t=>{let e=0,n=0,a=0;for(let r=0;r<t.length;r++){const o=t[r],i=t[(r+1)%t.length],l=o[0]*i[1]-i[0]*o[1];e+=l,n+=(o[0]+i[0])*l,a+=(o[1]+i[1])*l}return Math.abs(e)<1e-6?[t.reduce((r,o)=>r+o[0],0)/t.length,t.reduce((r,o)=>r+o[1],0)/t.length]:[n/(3*e),a/(3*e)]};function rn(t){const e=t.reduce((i,l)=>i+l[0],0)/t.length,n=t.reduce((i,l)=>i+l[1],0)/t.length;let a=0,r=0,o=0;for(const i of t){const l=i[0]-e,s=i[1]-n;a+=l*l,r+=l*s,o+=s*s}return wt(Math.cos(.5*Math.atan2(2*r,a-o)),Math.sin(.5*Math.atan2(2*r,a-o)))}function on(t){if(t!==void 0){if(!t||typeof t!="object"||!["w","s","e","n"].every(e=>Number.isFinite(t[e]))||t.w>=t.e||t.s>=t.n||t.w<-180||t.e>180||t.s<-85||t.n>85||t.proj!==void 0&&!["linear","mercator"].includes(t.proj))throw Error("Map bounds are {w,s,e,n} degrees (west < east, south < north) and proj linear | mercator");return t}}function Fn(t){if(t==null)return null;const e=Array.isArray(t)?{w:t[0],s:t[1],e:t[2],n:t[3]}:{w:t.w??t.west,s:t.s??t.south,e:t.e??t.east,n:t.n??t.north,...t.proj?{proj:t.proj}:{}};return on(e)}const ut=t=>Math.log(Math.tan(Math.PI/4+t*Math.PI/360));function sn(t,e,n){const a=(e-t.w)/(t.e-t.w),r=t.proj==="mercator"?(ut(t.n)-ut(n))/(ut(t.n)-ut(t.s)):(t.n-n)/(t.n-t.s);return[+a.toFixed(5),+r.toFixed(5)]}const ln=(t,e,n)=>[t.w+e*(t.e-t.w),t.proj==="mercator"?Math.atan(Math.sinh(ut(t.n)-n*(ut(t.n)-ut(t.s))))*180/Math.PI:t.n-n*(t.n-t.s)];function te(t){let e=0;for(let n=1;n<t.length;n++){const[a,r]=[t[n-1],t[n]],o=Math.PI/180,i=(r[1]-a[1])*o,l=(r[0]-a[0])*o,s=Math.sin(i/2)**2+Math.cos(a[1]*o)*Math.cos(r[1]*o)*Math.sin(l/2)**2;e+=12742*Math.asin(Math.sqrt(s))}return e}const ee=t=>t>=1?`~${(t>=10?Math.round(t):Math.round(t*10)/10).toString().replace(".",",")} km`:`~${Math.round(t*1e3/10)*10} m`;function tt(t,e,n){const a=e?.mapBounds;let r=null;if(t.geojson!=null){let i=typeof t.geojson=="string"?JSON.parse(t.geojson):t.geojson;i?.type==="FeatureCollection"&&(i=i.features?.[0]),i?.type==="Feature"&&(i=i.geometry);const l=i?.coordinates;if(r=i?.type==="Point"?[l]:i?.type==="LineString"||i?.type==="MultiPoint"?l:i?.type==="Polygon"||i?.type==="MultiLineString"?l?.[0]:i?.type==="MultiPolygon"?l?.[0]?.[0]:null,!Array.isArray(r))throw Error("GeoJSON must be a Point, LineString or Polygon (or a Feature of one)");(i.type==="Polygon"||i.type==="MultiPolygon")&&(r=r.slice(0,-1))}else t.lonlat!=null&&(r=t.lonlat);if(r){if(!a)throw Error("lon / lat points need the map bounds: send bounds [west, south, east, north] once (annotateMap / flyTo / setMapBounds)");if(!Array.isArray(r)||!r.every(i=>Array.isArray(i)&&i.length>=2&&i.every(Number.isFinite)))throw Error("lonlat points are [lon, lat]");return{uv:ne(r.map(i=>sn(a,i[0],i[1])),n),ll:r}}const o=Array.isArray(t.points)?ne(t.points,n):t.points;return{uv:o,ll:a&&Array.isArray(o)&&o.every(i=>Array.isArray(i)&&i.length===2)?o.map(i=>ln(a,i[0],i[1])):null}}function ne(t,e){if(!Array.isArray(t)||t.length<=e)return t;const n=(a,r)=>{if(a.length<3)return a;const[o,i]=[a[0],a.at(-1)],l=i[0]-o[0],s=i[1]-o[1],c=Math.hypot(l,s)||1e-9;let h=0,u=0;for(let d=1;d<a.length-1;d++){const f=Math.abs((a[d][0]-o[0])*s-(a[d][1]-o[1])*l)/c;f>h&&(h=f,u=d)}return h>r?[...n(a.slice(0,u+1),r).slice(0,-1),...n(a.slice(u),r)]:[o,i]};for(let a=1e-5;;a*=1.6){const r=n(t,a);if(r.length<=e)return r}}const G=(t,e,n,a,{fill:r,stroke:o,opacity:i=1,draw:l,show:s}={})=>{const c={id:t,name:e,type:"path",params:{pts:n.map(h=>[_(h[0]),_(h[1])]),closed:a},pos:[0,0],rot:0,scale:[1,1],opacity:i,fill:r??{type:"none"},stroke:o??null};return l&&(c.ops=[{op:"trim",start:0,end:1,offset:0}],c.keys={"ops.0.end":[{time:I(l[0]),value:0,ease:ie},{time:I(l[1]),value:1}]}),s&&(c.keys={...c.keys,opacity:[{time:I(s[0]),value:0,ease:Vt},{time:I(s[1]),value:i}]}),c},ht=(t,e,n,a,r,{fill:o,stroke:i,opacity:l=1,show:s}={})=>{const c={id:t,name:e,type:"ellipse",params:{w:_(a),h:_(r)},pos:[_(n[0]),_(n[1])],rot:0,scale:[1,1],opacity:l,fill:o??{type:"none"},stroke:i??null};return s&&(c.keys={opacity:[{time:I(s[0]),value:0,ease:Vt},{time:I(s[1]),value:l}]}),c},q=(t,e,{blur:n,dash:a,opacity:r}={})=>({color:t,width:_(R(e,0,240)),cap:"round",join:"round",...n?{blur:_(R(n,0,200))}:{},...a?{dash:a.map(_)}:{},...r!==void 0&&r<1?{opacity:_(r)}:{}});function Mt({fill:t="#ffffff",outline:e="#000000",glow:n,uppercase:a=!0,italic:r=!1}={}){return{weight:800,lineHeight:1.3,uppercase:a,...r?{lines:[{scale:1,italic:!0}]}:{},layers:[...n?[{type:"text",fill:n,shadow:{color:n,blur:.45,x:0,y:0},opacity:.9}]:[],{type:"text",fill:t,stroke:{color:e,width:.09},shadow:{color:"#000000",blur:.22,x:0,y:.04}}]}}function xt({text:t,px:e,W:n,H:a,font:r="Be Vietnam Pro",design:o,color:i="#ffffff",animation:l}){const s=Math.min(n/1280,a/720);let c=e/s,h=1;return c<24?(h=c/24,c=24):c>96&&(h=c/96,c=96),{title:Ue({text:t,fontSize:Math.round(c),color:i,placement:"center",fontFamily:r,align:"center",design:o,...l?{animation:l}:{}}),scale:I(R(h,.05,4)),label:t.slice(0,40)}}function cn(t,e,n,a,r,o){const i=[];for(let l=0;l<=10;l++){const s=r+(o-r)*l/10,c=R(s-t.start,0,t.duration),h=[[0,0],[1,0],[0,1]].map(([g,T])=>It(t,g,T,c,s,n,a,e));if(h.some(g=>!g))continue;ye(t,n,a);const[u,d]=[bt(t,0,0,n,a),bt(t,1,1,n,a)],f=d[0]-u[0],w=d[1]-u[1];i.push(Math.max(Math.hypot(h[1][0]-h[0][0],h[1][1]-h[0][1])/f,Math.hypot(h[2][0]-h[0][0],h[2][1]-h[0][1])/w))}return i.sort((l,s)=>l-s),R(i.length?i[i.length>>1]:1,.25,6)}function fe(t,e,n,a,r,o,i,l,s=[0,0]){const c=w=>{const g=It(t,e,n,R(w-t.start,0,t.duration),w,o,i,l);return g?[(g[0]+s[0]-o/2)/o,(g[1]+s[1]-i/2)/i]:null},h=Math.max(1,Math.min(120,Math.ceil((r-a)/Je))),u=[];for(let w=0;w<=h;w++){const g=a+(r-a)*w/h,T=c(g);T&&u.push([g-a,T])}if(!u.length)return null;if(u.every(([,w])=>Math.abs(w[0]-u[0][1][0])<1e-4&&Math.abs(w[1]-u[0][1][1])<1e-4))return{posX:I(R(u[0][1][0],-1,1)),posY:I(R(u[0][1][1],-1,1))};const f=w=>u.map(([g,T])=>({time:I(g),value:I(R(T[w],-1,1)),ease:"auto"}));return{x:f(0),y:f(1)}}const he=(t,e)=>{if(!e)return t;if("posX"in e)return{...t,posX:e.posX,posY:e.posY};let n={...t,motionV:2,motionKeys:[]};return n={...n,...dt(n,"x",e.x)},n={...n,...dt(n,"y",e.y)},n};function Rn(t,{base:e,W:n=1280,H:a=720,cam:r=null,materials:o=[]}){const i=t.kind;if(!Ht.includes(i))throw Error(`Map annotation kind must be ${Ht.join("/")}`);if(!e||!["image","video"].includes(e.kind)||e.title||e.shape||e.motion||e.card)throw Error("Map annotations go on a map / drone image or video clip");const l=Number.isFinite(t.at)?t.at:e.start,s=Number.isFinite(t.duration)?t.duration:e.start+e.duration-l;if(!(s>=.2)||l<e.start-1e-6||l+s>e.start+e.duration+1e-6)throw Error("The annotation must lie inside the map clip");const c=R(Number.isFinite(t.draw)?t.draw:1.1,.2,8),h=jt(r)&&At(e),u=cn(e,h?r:null,n,a,Math.min(l+c,l+s),l+s),d=(p,y)=>{const m=Math.min(l+s,l+c+.5);return It(e,p,y,R(m-e.start,0,e.duration),m,n,a,h?r:null)},f=He(n,a),w=p=>bt(e,p[0],p[1],n,a),g=p=>p/u,T=p=>Ze(t.color,p),O=p=>({nodeId:"",kind:"image",url:"",volume:0,start:+l.toFixed(4),duration:+s.toFixed(4),parentId:e.id,motionV:2,motionKeys:[],...At(e)?{is3D:!0,spatialDepth:.002}:{},exit:{type:"fade",duration:Math.min(.4,s/4)},...p,mapAnno:{base:e.id,kind:i}}),B=(p,y)=>O({label:y,shape:{v:2,items:p,size:f.size},posX:0,posY:0,scale:1}),U=p=>{const y=Math.abs(p)*Math.PI/180,m=Math.cos(y),k=Math.sin(y),b=1280,A=720;return Math.min(n/(b*m+A*k),a/(b*k+A*m))/Math.min(n/b,a/A)},V=(p,[y,m],k,b,A,v,N)=>{const x=xt({text:p,px:g(b),W:n,H:a,design:A,animation:N});return x.scale=I(R(x.scale/U(k),.05,4)),O({...x,posX:I((y-n/2)/n),posY:I((m-a/2)/a),rotation:_(k),start:+(l+v).toFixed(4),duration:+Math.max(.2,s-v).toFixed(4),enter:{type:"fade",duration:.35}})},E=(p,y,m,k,b=0)=>{const A=l+b,v=fe(e,y,m,A,l+s,n,a,h?r:null,k);return he({nodeId:"",kind:"image",url:"",volume:0,start:+A.toFixed(4),duration:+(s-b).toFixed(4),motionV:2,motionKeys:[],exit:{type:"fade",duration:Math.min(.35,s/4)},...p,mapAnno:{base:e.id,kind:i,follow:[I(y),I(m),_(k[0]),_(k[1])]}},v)},$=[],L=(p,y)=>p.map(m=>f.pt(m));switch(i){case"route":{const p=tt(t,e,200),y=rt(p.uv,2,200,"A route"),m=Lt[t.style]??Lt.glow,k=T(m.color),b=t.smooth===!1?y.map(w):Wt(y.map(w)),A=m.lanes?tn(b,{lanes:Number.isFinite(t.lanes)?t.lanes:11,width:g(Number.isFinite(t.width)?R(t.width,10,600):70),taper:t.taper}):null,v=A?en(A,{main:k,draw:c,dur:s,B:f,px:g,L}):m.layers.map((P,C)=>G("s"+(C+1),`${t.style??"glow"} ${C+1}`,L(b),!1,{stroke:q(P.c??k,f.len(g(P.w)),{blur:P.blur?f.len(g(P.blur)):void 0,dash:P.dash?.map(F=>f.len(g(F))),opacity:P.a}),draw:[0,c]}));if(t.arrow&&!A){const P=b.at(-1),C=b[Math.max(0,b.length-4)],F=Math.atan2(P[1]-C[1],P[0]-C[0]),D=g(Math.max(16,m.layers[1]?.w*2.2||16)),M=(z,K)=>[P[0]+Math.cos(F+K)*z,P[1]+Math.sin(F+K)*z];v.push(G("s9","arrow",L([M(D*.4,0),M(D,Math.PI*.82),M(D*.25,Math.PI),M(D,-Math.PI*.82)]),!0,{fill:{type:"color",color:m.layers[1]?.c??k},stroke:q("#ffffff",f.len(g(1.5)),{opacity:.8}),show:[c*.92,c]}))}$.push(B(v,`Map · ${J(t.text)||m.en}`));const N=t.distance&&p.ll?ee(te(p.ll)):"",x=[J(t.text),N].filter(Boolean).join(" · "),S=x.normalize("NFC").split(" ").filter(Boolean);if(x&&(t.labelLook==="stand"||A&&t.labelLook!=="flat")&&S.length<=8&&S.join("").length<=40){const P=A?.S??le(b),C=A?.k??ce(P,t.taper),F=A?.half??P.map(()=>g(Math.max(...m.layers.map(Q=>Q.w))/2)),D=Number.isFinite(t.textSize)?R(t.textSize,10,80):40,M=g(D),z=P.at(-1).s,K=C.map(Q=>.55+.45*Q),X=Q=>{const nt=R(Q/(z||1),0,1)*(P.length-1),Y=Math.min(P.length-2,Math.floor(nt)),Z=nt-Y,W=P[Y],ft=P[Y+1]??W,at=(kt,me)=>kt+(me-kt)*Z;return{x:at(W.x,ft.x),y:at(W.y,ft.y),nx:at(W.nx,ft.nx),ny:at(W.ny,ft.ny),k:at(K[Y],K[Y+1]??K[Y]),half:at(F[Y],F[Y+1]??F[Y])}},ct=Q=>[...Q].reduce((nt,Y)=>nt+zt(Y.toUpperCase()),0),ot=(S.reduce((Q,nt)=>Q+ct(nt),0)+zt(" ")*(S.length-1))*M*X(z/2).k;let H=R(z/2-ot/2,0,Math.max(0,z-ot)),gt=0;const yt=Math.min(.07,Math.max(.03,(s-c*.6-.8)/Math.max(1,S.join("").length)));for(const Q of S){const nt=X(H).k,Y=ct(Q)*M*nt,Z=X(H+Y/2),W=Z.ny>0?-1:1,ft=Z.k,at=Z.half+M*ft*.62,kt=wt(-Z.ny*W,Z.nx*W);$.push(V(Q,[Z.x+Z.nx*W*at,Z.y+Z.ny*W*at],kt,D*ft,nn,c*.6+gt*yt,{in:[{unit:"char",stagger:yt,duration:.5,easing:"easeOutBack",from:{opacity:0,y:.55,blur:.3}}],out:"reverse",outSpeed:1.8})),gt+=[...Q].length,H+=Y*1.02+zt(" ")*M*nt}}else if(x){const P=Number.isFinite(t.textSize)?R(t.textSize,10,80):22,C=x.length*P*.62/u,F=We(b,C),D=m.layers[1]?.w>=9,M=D?0:g(Math.max(...m.layers.map(z=>z.w))/2)+g(P)*.75;$.push(V(x,[F.x+F.nx*M,F.y+F.ny*M],F.angle,P,Mt({fill:"#ffffff",outline:D?k:"#000000"}),c*.7))}break}case"area":{const p=rt(tt(t,e,200).uv,3,200,"An area"),y=T("#39ff6a"),m=t.smooth?Wt(p.map(w),!0):p.map(w),k=[G("s1","fill",L(m),!0,{fill:{type:"color",color:y,opacity:.38},show:[c*.5,c]}),G("s2","glow",L(m),!0,{stroke:q(y,f.len(g(14)),{blur:f.len(g(10)),opacity:.75}),draw:[0,c]}),G("s3","edge",L(m),!0,{stroke:q(y,f.len(g(3.5))),draw:[0,c]})];$.push(B(k,`Map · ${J(t.text)||"area"}`));const b=J(t.text);if(b){const A=an(m),v=Number.isFinite(t.textSize)?R(t.textSize,10,80):24;$.push(V(b,A,rn(m),v,Mt({fill:"#ffffff",outline:y}),c*.8))}break}case"lots":{const p=rt(tt(t,e,4).uv,4,4,"A lot block").map(w),y=Array.isArray(t.labels)?t.labels.map(M=>J(M,12)).filter(Boolean).slice(0,10):[],m=R(Math.round(t.count??(y.length||4)),1,10),k=(M,z)=>Math.hypot(M[0]-z[0],M[1]-z[1]),b=(M,z,K)=>[M[0]+(z[0]-M[0])*K,M[1]+(z[1]-M[1])*K],[A,v,N,x]=k(p[0],p[1])+k(p[3],p[2])>=k(p[1],p[2])+k(p[0],p[3])?[p[0],p[1],p[3],p[2]]:[p[1],p[2],p[0],p[3]],S=T("#ffe066"),P="#2a2100",C=Math.min(.18,s/(3*m)),F=[G("s1","block glow",L(p),!0,{stroke:q("#ffffff",f.len(g(10)),{blur:f.len(g(8)),opacity:.55}),draw:[0,c*.8]})],D=[];for(let M=0;M<m;M++){const z=[b(A,v,M/m),b(A,v,(M+1)/m),b(N,x,(M+1)/m),b(N,x,M/m)];D.push(z),F.push(G("l"+(M+1),y[M]||`Lô ${M+1}`,L(z),!0,{fill:{type:"color",color:S,opacity:Number.isFinite(t.fillOpacity)?R(t.fillOpacity,.1,1):.9},stroke:q(P,f.len(g(1.4)),{opacity:.8}),opacity:1,show:[c*.6+M*C,c*.6+M*C+.25]}))}F.push(G("s2","block edge",L(p),!0,{stroke:q("#ffffff",f.len(g(2.4))),draw:[0,c*.8]})),$.push(B(F.slice(0,24),`Map · ${y.length?y[0]+"–"+y.at(-1):"lots"}`)),D.forEach((M,z)=>{if(!y[z])return;const K=M.reduce((gt,yt)=>[gt[0]+yt[0]/4,gt[1]+yt[1]/4],[0,0]),X=k(M[0],M[1]),ct=k(M[1],M[2]),ot=ct>=X?[(M[0][0]+M[1][0])/2-(M[3][0]+M[2][0])/2,(M[0][1]+M[1][1])/2-(M[3][1]+M[2][1])/2]:[M[1][0]-M[0][0],M[1][1]-M[0][1]],H=Math.min(Math.min(X,ct)*.55*u,Number.isFinite(t.textSize)?t.textSize:22);$.push(V(y[z],K,wt(ot[0],ot[1]),H,Mt({fill:P,outline:S,uppercase:!0}),c*.6+z*C+.15))});break}case"label":{const p=tt(t,e,2),[y,m]=rt(p.uv,2,2,"A measure").map(w),k=J(t.text,24)||(t.distance&&p.ll?ee(te(p.ll)):"");if(!k)throw Error('A measure label needs its text (e.g. "20m")');const b=T("#ff2a2a"),A=m[0]-y[0],v=m[1]-y[1],N=Math.hypot(A,v)||1,x=-v/N,S=A/N,P=g(9),C=X=>[[X[0]+x*P,X[1]+S*P],[X[0]-x*P,X[1]-S*P]],F=[G("s1","measure",L([y,m]),!1,{stroke:q("#ffffff",f.len(g(2.2))),draw:[0,c*.6]}),G("s2","tick a",L(C(y)),!1,{stroke:q("#ffffff",f.len(g(2.2))),show:[0,.2]}),G("s3","tick b",L(C(m)),!1,{stroke:q("#ffffff",f.len(g(2.2))),show:[c*.5,c*.6]})];$.push(B(F,`Map · ${k}`));const D=Number.isFinite(t.textSize)?R(t.textSize,10,80):30,M=wt(A,v),z=M*Math.PI/180,K=g(D)*.8;$.push(V(k,[(y[0]+m[0])/2+Math.sin(z)*K,(y[1]+m[1])/2-Math.cos(z)*K],M,D,{weight:900,lineHeight:1.3,uppercase:!1,lines:[{scale:1,italic:!0}],layers:[{type:"text",fill:b,stroke:{color:"#ffffff",width:.12},shadow:{color:"#000000",blur:.25,x:0,y:.05}}]},c*.5));break}case"pin":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A pin"),m=T("#3cf2d0"),k=J(t.text,24),b=a>n,A=(Number.isFinite(t.height)?t.height:b?.2:.26)*a,v=(b?.085:.06)*Math.min(n,a)*(b?1.6:1.4),N=[n/2,a/2],x=[n/2,a/2-A],S=[ht("s1","ground glow",f.pt(N),f.len(v*1.6),f.len(v*.55),{stroke:q(m,f.len(v*.35),{blur:f.len(v*.3),opacity:.7})}),G("s2","beam",L([[N[0]-v*.05,N[1]],[N[0]+v*.05,N[1]],[x[0]+v*.42,x[1]],[x[0]-v*.42,x[1]]]),!0,{fill:{type:"linear",stops:[["#e9fffb",0],[m,1]],angle:90,opacity:.55},stroke:q(m,f.len(4),{blur:f.len(6),opacity:.8})}),ht("s3","badge glow",f.pt(x),f.len(v*2.15),f.len(v*2.15),{stroke:q(m,f.len(v*.3),{blur:f.len(v*.28),opacity:.8})}),ht("s4","badge",f.pt(x),f.len(v*2),f.len(v*2),{fill:{type:"radial",stops:[["#9ffff1",0],[m,.7],["#0f8f86",1]],opacity:.95},stroke:q("#eafffb",f.len(3))}),ht("s5","point",f.pt(N),f.len(9),f.len(9),{fill:{type:"color",color:"#ffffff"},stroke:q(m,f.len(3))})],P={type:"slide-down",duration:.55,amount:.06,ease:Qe};$.push(E({label:`Map · pin ${k||""}`.trim(),shape:{v:2,items:S,size:f.size},enter:P},p,y,[0,0]));const C=t.materialId?o.find(F=>F.id===t.materialId&&F.kind==="image"):null;if(C){const F=Number.isInteger(C.width)&&C.width>1?C.width:1e3,D=Number.isInteger(C.height)&&C.height>1?C.height:1e3,M=Ut(F,D),z=Math.min(M.w,M.h),K=Math.min(n/F,a/D),X=I(R(v*1.7/(z*K),.02,4));$.push(E({nodeId:C.id,url:C.url,...C.gcsUri?{gcsUri:C.gcsUri}:{},label:"Map · logo",scale:X,mask:Gt({mw:F,mh:D},[Xt({kind:"circle",cx:.5,cy:.5,w:I(z/M.w),h:I(z/M.h),rot:0},M.w,M.h)]),mapSize:[F,D],enter:P},p,y,[0,-A]))}else if(k){const F=xt({text:k,px:Math.min(v*.42,v*3.2/Math.max(4,k.length)),W:n,H:a,font:"Be Vietnam Pro",design:{weight:800,lineHeight:1.3,uppercase:!0,layers:[{type:"text",fill:"#063b37",shadow:{color:"#ffffff",blur:.15,x:0,y:0}}]}});$.push(E({...F,enter:P},p,y,[0,-A]))}if(k&&C){const F=xt({text:k,px:22,W:n,H:a,design:Mt({fill:"#ffffff",outline:m})});$.push(E({...F,enter:P},p,y,[0,-A+v*1.45]))}break}case"photo":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A photo bubble"),m=o.find(H=>H.id===t.materialId&&H.kind==="image");if(!m?.url)throw Error("A photo bubble needs an image from Media (materialId)");const k=T("#ffd23a"),b=(Number.isFinite(t.size)?t.size:.17)*Math.min(n,a)*(a>n?1.5:1.2),A=d(p,y),v=Array.isArray(t.offset)&&t.offset.length===2&&t.offset.every(Number.isFinite)?[t.offset[0]*n,t.offset[1]*a]:[A&&A[0]<n*.35?b*.95:-b*.95,A&&A[1]<a*.38?b*1.05:-b*1.05],N=[n/2+v[0],a/2+v[1]],x=[n/2,a/2],S=Math.atan2(x[1]-N[1],x[0]-N[0]),P=b/2,C=[N[0]+Math.cos(S+Math.PI/2)*P*.62,N[1]+Math.sin(S+Math.PI/2)*P*.62],F=[N[0]+Math.cos(S-Math.PI/2)*P*.62,N[1]+Math.sin(S-Math.PI/2)*P*.62],D=[G("s1","cone",L([C,x,F]),!0,{fill:{type:"linear",stops:[[k,0],["#fff6c8",1]],angle:_(S*180/Math.PI),opacity:.6},show:[.25,.6]}),ht("s2","point",f.pt(x),f.len(10),f.len(10),{fill:{type:"color",color:"#ffffff"},stroke:q(k,f.len(3)),show:[0,.2]}),ht("s3","ring glow",f.pt(N),f.len(b*1.08),f.len(b*1.08),{stroke:q(k,f.len(b*.06),{blur:f.len(b*.06),opacity:.85}),show:[.1,.4]})];$.push(E({label:"Map · photo cone",shape:{v:2,items:D,size:f.size}},p,y,[0,0]));const M=Number.isInteger(m.width)&&m.width>1?m.width:1e3,z=Number.isInteger(m.height)&&m.height>1?m.height:1e3,K=Ut(M,z),X=Math.min(K.w,K.h),ct=Math.min(n/M,a/z);$.push(E({nodeId:m.id,url:m.url,...m.gcsUri?{gcsUri:m.gcsUri}:{},label:`Map · ${J(t.text)||m.label||"photo"}`,scale:I(R(b/(X*ct),.02,4)),mapSize:[M,z],mask:Gt({mw:M,mh:z},[Xt({kind:"circle",cx:.5,cy:.5,w:I(X/K.w),h:I(X/K.h),rot:0},K.w,K.h)]),edge:{color:k,width:.012,glow:.7},enter:{type:"pop",duration:.45}},p,y,v,.15));const ot=J(t.text,28);if(ot){const H=xt({text:ot,px:20,W:n,H:a,design:Mt({fill:"#ffffff",outline:"#000000"})});$.push(E({...H,enter:{type:"fade",duration:.3}},p,y,[v[0],v[1]-P-16],.35))}break}case"callout":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A callout"),m=J(t.text,40),k=J(t.subText,60),b=T("#c9a45c");if(!m)throw Error("A callout needs its text");const A=d(p,y),v=!!A&&A[1]<a*.38,N=!!A&&A[0]>n*.62,x=N?-1:1,S=v?-1:1,P=(Number.isFinite(t.height)?t.height:.16)*a*S,C=[n/2,a/2],F=[n/2+n*.04*x,a/2-P],D=[G("s1","leader",L([C,[C[0],F[1]+8],F]),!1,{stroke:q(b,f.len(2.4)),draw:[0,.45]}),ht("s2","point",f.pt(C),f.len(11),f.len(11),{fill:{type:"color",color:b},stroke:q("#ffffff",f.len(2.5))})];$.push(E({label:"Map · callout leader",shape:{v:2,items:D,size:f.size}},p,y,[0,0]));const M=xt({text:k?`${m}
|
|
3
|
+
BẮT ĐẦU`,category:"Social",fontFamily:"Be Vietnam Pro",fontSize:70,color:"#171b20",accentColor:"#dfff48",placement:"center",preset:"slide-left"},{id:"neon-edge",name:"Sắc điện",sample:"TỎA SÁNG",category:"Social",fontFamily:"Bungee",fontSize:66,color:"#f6fbff",accentColor:"#5de9ff",placement:"center",preset:"punch-in"},{id:"echo-stack",name:"Vang âm",sample:"TẠO KHÁC BIỆT",category:"Minimal",fontFamily:"Oswald",fontSize:82,color:"#ffffff",accentColor:"#9a73ff",placement:"center",preset:"rise-pop"},{id:"tape-label",name:"Nhãn băng keo",sample:"JAPAN, 1957",category:"Collage",fontFamily:"Oswald",fontSize:46,color:"#2a241c",accentColor:"#e6d9b8",placement:"top",preset:"slide-left"},{id:"serif-year",name:"Năm chữ có chân",sample:"1957",category:"Collage",fontFamily:"Playfair Display",fontSize:96,color:"#d62b25",accentColor:"#d62b25",placement:"top",preset:"pop-in"}],De={"word-pop":{in:[{unit:"word",stagger:.12,duration:.35,easing:"easeOutBack",from:{opacity:0,scale:.4}}]},"word-rise":{in:[{unit:"word",stagger:.1,duration:.4,easing:"easeOutCubic",from:{opacity:0,y:.6}}]},"line-slam":{in:[{unit:"line",stagger:.25,duration:.32,easing:"easeOutBack",from:{opacity:0,scale:2.2,blur:.2}}]},"type-on":{in:[{unit:"char",stagger:.04,duration:.05,easing:"linear",from:{opacity:0}}],out:"none"},"slide-in":{in:[{unit:"line",stagger:.15,duration:.45,easing:"easeOutQuart",from:{opacity:0,x:-1.5},mask:!0}]},"wipe-in":{in:[{unit:"line",stagger:.15,duration:.5,easing:"easeOutCubic",from:{wipeX:0}}]},"word-blur":{in:[{unit:"word",stagger:.09,duration:.2,easing:"easeOutCubic",from:{opacity:0,blur:.55}}]},"blur-rescale":{in:[{unit:"line",stagger:.08,duration:.24,easing:"easeOutExpo",from:{opacity:0,scale:1.6,blur:.45}}]},"flicker-on":{in:[{unit:"line",stagger:.06,duration:.4,easing:"linear",from:{flicker:1}}]},"slam-blur":{in:[{unit:"word",stagger:.08,duration:.26,easing:"easeOutExpo",from:{opacity:0,x:-2.2,scaleX:1.9,blur:.6,rotate:-6}}]},"slam-blur-right":{in:[{unit:"word",stagger:.08,duration:.26,easing:"easeOutExpo",from:{opacity:0,x:2.2,scaleX:1.9,blur:.6,rotate:6}}]},"glitch-scatter":{in:[{unit:"char",order:"random",stagger:.03,duration:.42,easing:"easeOutExpo",from:{opacity:0,scatter:2.6,rotate:-25,pixels:1,glitch:.8}}]},"pixel-burst":{in:[{unit:"word",stagger:.1,duration:.5,easing:"easeOutCubic",from:{opacity:.2,pixels:1,glitch:1,scaleX:1.25}}]},"glitch-in":{in:[{unit:"char",stagger:.025,duration:.24,easing:"easeOutCubic",from:{opacity:0,glitch:1,y:.25}}]},"mask-rise":{in:[{unit:"line",stagger:.08,duration:.36,easing:"easeOutCubic",mask:!0,from:{y:1.1}},{unit:"line",start:.1,duration:1.3,easing:"easeOutCubic",from:{brightness:.45}}]}},$t=Object.freeze(Object.fromEntries(Object.entries(De).map(([t,e])=>[t,Object.freeze(ae(e,`titleAnimations.${t}`))])));Object.freeze(Object.keys($t));const Qt=Object.freeze({weight:800,lineHeight:1.3,uppercase:!1,layers:[{type:"text",fill:"{color}",shadow:{color:"#000000",blur:.18,x:0,y:.03}}]}),mt=t=>Array.isArray(t)?t.map(mt):t&&typeof t=="object"?Object.fromEntries(Object.entries(t).filter(([,e])=>e!==null).map(([e,n])=>[e,mt(n)])):t,Ke=t=>{if(t.length>2e4)throw Error("design: too long");try{return mt(JSON.parse(t))}catch{throw Error("design: invalid JSON")}},qe=["none","push-in","pull-out","pan-left","pan-right","slide-up","slide-left","pop-in","rise-pop","punch-in"];function Pn(t,e){if(!qe.includes(t)||!Number.isFinite(e)||e<1/30)throw Error("Invalid motion preset or duration");const n=(r,o=0,i=0,l=1)=>({time:r,x:o,y:i,zoom:l}),a=Math.min(.5,e/3);switch(t){case"none":return[];case"push-in":return[n(0),n(e,0,0,1.15)];case"pull-out":return[n(0,0,0,1.15),n(e)];case"pan-left":return[n(0,.07,0,1.2),n(e,-.07,0,1.2)];case"pan-right":return[n(0,-.07,0,1.2),n(e,.07,0,1.2)];case"slide-up":return[n(0,0,1),n(a),n(e)];case"slide-left":return[n(0,1),n(a),n(e)];case"pop-in":return[n(0,0,0,.25),n(a),n(e)];case"rise-pop":return[n(0,0,.22,.55),n(a*.7,0,-.025,1.08),n(a,0,0,1),n(e)];case"punch-in":return[n(0,0,0,.25),n(a*.7,0,0,1.13),n(a,0,0,1),n(e)]}}function Ue(t){if(typeof t.text!="string"||!t.text.trim()||t.text.length>200)throw Error("Text requires 1–200 characters");const e=t.fontSize??56,n=t.color??"#ffffff",a=t.placement??"lower";if(!Number.isFinite(e)||e<24||e>96||!/^#[0-9a-f]{6}$/i.test(n)||!["top","center","lower"].includes(a))throw Error("Invalid text style");const r=t.fontFamily??"Arial",o=t.align??"center";if(!Ee(r)||!["left","center","right"].includes(o))throw Error("Invalid font or alignment");const i=t.styleId??"classic",l=t.accentColor??"#32d8cd";if(!Be.includes(i)||!/^#[0-9a-f]{6}$/i.test(l))throw Error("Invalid text template style");const s={text:t.text,fontSize:e,color:n,placement:a,fontFamily:r,align:o,styleId:i,accentColor:l},c=typeof t.design=="string"?Ke(t.design):mt(t.design);if(typeof t.animation=="string"&&!Object.hasOwn($t,t.animation))throw Error(`Unknown title animation "${t.animation.slice(0,64)}"`);const h=mt(typeof t.animation=="string"?$t[t.animation]:t.animation);if(c!=null)s.design=Et(c),typeof t.templateId=="string"&&/^[a-z0-9][a-z0-9-]{1,63}$/.test(t.templateId)&&(s.templateId=t.templateId);else if(typeof t.templateId=="string"&&t.templateId)throw Error(`Unknown text template "${t.templateId.slice(0,64)}" (not published)`);h!=null&&(s.design||(s.design=Et(Qt)),s.animation=ae(h));const u=Ne(mt(t.animators));return u.length&&(s.design||(s.design=Et(Qt)),s.animators=u),s}const Ge={"muapi:seedance-2.5":{label:"Seedance 2.5",min:4,max:8},"muapi:wan-3.0-prime":{label:"Wan 3.0 Prime",min:2,max:8},"muapi:seedance-2.0":{label:"Seedance 2.0",min:4,max:8},"vertex:veo-omni":{label:"Gemini Omni 1.2",min:3,max:15},"muapi:seedance-2.5@480p":{label:"Seedance 2.5 · 480p",min:4,max:8,generator:"muapi:seedance-2.5",resolution:"480p"},"muapi:seedance-2.0-mini@480p":{label:"Seedance 2.0 Mini · 480p",min:4,max:8,generator:"muapi:seedance-2.0-mini",resolution:"480p"}},Sn=t=>{const e=Ge[t];return{generator:e?.generator||t,...e?.resolution?{resolution:e.resolution}:{}}},On=4,In={"openai:gpt-image-2.5-flare":{label:"GPT Image 2.5 Flare"},"openai:gpt-image-2.5-sunburst":{label:"GPT Image 2.5 Sunburst"},"openai:gpt-image-2.6-flare":{label:"GPT Image 2.6 Flare"},"openai:gpt-image-2.6-sunburst":{label:"GPT Image 2.6 Sunburst"}},En="openai:gpt-image-2.5-flare",Ht=Object.freeze(["lots","route","area","label","pin","photo","callout","overlay","icon"]),Lt=Object.freeze({glow:{vi:"Đường phát sáng",en:"Glowing line",color:"#3cf2d0",layers:[{w:18,blur:12,a:.5},{w:6},{w:2,c:"#ffffff",a:.85}]},dashed:{vi:"Nét đứt",en:"Dashed",color:"#ffffff",layers:[{w:12,blur:8,a:.35},{w:4,dash:[14,10]}]},"dashed-ring":{vi:"Vành đai (đỏ, gạch trắng)",en:"Ring road (red, white dashes)",color:"#ff2d3a",layers:[{w:24,blur:12,a:.55},{w:11},{w:3,c:"#ffffff",dash:[18,14]}]},"gradient-highway":{vi:"Cao tốc (cam → vàng)",en:"Expressway (orange → yellow)",color:"#ff7a1a",layers:[{w:26,blur:14,a:.6},{w:11},{w:5,c:"#ffd23a"},{w:1.6,c:"#fff7c2",a:.9}]},metro:{vi:"Metro (xanh ngọc)",en:"Metro line (cyan)",color:"#22e3ff",layers:[{w:18,blur:10,a:.5},{w:6},{w:1.8,c:"#ffffff",dash:[10,8],a:.9}]},link:{vi:"Đường liên kết (hồng, nét đứt)",en:"Link road (magenta, dashed)",color:"#ff2bd6",layers:[{w:16,blur:9,a:.5},{w:5},{w:2,c:"#ffffff",dash:[12,10],a:.95}]},thin:{vi:"Đường mảnh (trắng)",en:"Thin road (white)",color:"#ffffff",layers:[{w:7,blur:4,a:.3},{w:2.6}]},river:{vi:"Sông (xanh ngọc)",en:"River (teal)",color:"#1fd1c1",layers:[{w:28,blur:16,a:.45},{w:9,a:.9},{w:2.5,c:"#b9fff6",a:.6}]},trail:{vi:"Dải sáng nhiều làn (vàng)",en:"Light-trail lanes (gold)",color:"#ffdf1f",lanes:!0,layers:[{w:2.2},{w:2.2}]}}),Nn=Object.freeze(Object.keys(Lt)),Xe=Object.freeze(["rise","fade","wipe"]),Ye=/^#[0-9a-f]{6}$/i,R=(t,e,n)=>Math.max(e,Math.min(n,t)),_=t=>+t.toFixed(3),I=t=>+t.toFixed(4),Je=.2,ie=Ot["ease-in-out"],Vt=Ot["ease-out"],Ze=Ot["back-out"];function rt(t,e,n,a){if(!Array.isArray(t)||t.length<e||t.length>n)throw Error(`${a} needs ${e}–${n} points [u,v]`);return t.map(r=>{if(!Array.isArray(r)||r.length!==2||!r.every(o=>Number.isFinite(o)&&o>=-1&&o<=2))throw Error(`${a}: points are [u,v] (0..1 of the map picture)`);return[r[0],r[1]]})}const J=(t,e=60)=>typeof t=="string"?t.replace(/\s+/g," ").trim().slice(0,e):"",Qe=(t,e)=>typeof t=="string"&&Ye.test(t)?t.toLowerCase():e;function oe(t,e){const n=Math.min(1.5,2560/Math.max(t,e));return[Math.round(t*n),Math.round(e*n)]}function He(t,e){const[n,a]=oe(t,e),r=Math.min(n,a)/1e3,o=(n-1e3*r)/2,i=(a-1e3*r)/2;return{size:[n,a],pt:([l,s])=>[_((l*n/t-o)/r),_((s*a/e-i)/r)],len:l=>l*n/t/r}}function Wt(t,e=!1){if(t.length<3)return t;const n=t.length,a=s=>e?t[(s+n)%n]:t[R(s,0,n-1)],r=[],o=e?n:n-1,i=t.reduce((s,c,h)=>h?s+Math.hypot(c[0]-t[h-1][0],c[1]-t[h-1][1]):0,0),l=R(Math.round(i/10/o),2,Math.floor(240/o));for(let s=0;s<o;s++){const c=a(s-1),h=a(s),u=a(s+1),d=a(s+2);for(let f=0;f<l;f++){const w=f/l,g=w*w,T=g*w;r.push([0,1].map(O=>.5*(2*h[O]+(-c[O]+u[O])*w+(2*c[O]-5*h[O]+4*u[O]-d[O])*g+(-c[O]+3*h[O]-3*u[O]+d[O])*T)))}}return e||r.push(t[n-1]),r}const se=t=>t.reduce((e,n,a)=>a?e+Math.hypot(n[0]-t[a-1][0],n[1]-t[a-1][1]):0,0),wt=(t,e)=>{let n=Math.atan2(e,t)*180/Math.PI;return n>90&&(n-=180),n<=-90&&(n+=180),n};function We(t,e){const n=se(t);if(n<1)return{x:t[0][0],y:t[0][1],angle:0,nx:0,ny:-1};const a=[0];for(let u=1;u<t.length;u++)a.push(a[u-1]+Math.hypot(t[u][0]-t[u-1][0],t[u][1]-t[u-1][1]));const r=u=>{u=R(u,0,n);let d=1;for(;d<a.length-1&&a[d]<u;)d++;const f=(u-a[d-1])/(a[d]-a[d-1]||1);return[t[d-1][0]+(t[d][0]-t[d-1][0])*f,t[d-1][1]+(t[d][1]-t[d-1][1])*f]},o=Math.min(n/2,e*.55);let i=null;for(let u=0;u<=20;u++){const d=o+(n-2*o)*u/20,f=r(d-o),w=r(d+o),g=w[0]-f[0],T=w[1]-f[1],O=Math.hypot(g,T)||1;let B=0;for(let V=1;V<8;V++){const E=r(d-o+2*o*V/8);B=Math.max(B,Math.abs((E[0]-f[0])*T-(E[1]-f[1])*g)/O)}const U=B+Math.abs(d-n/2)/n*e*.15;(!i||U<i.score)&&(i={score:U,c:d,dx:g,dy:T})}const[l,s]=r(i.c),c=wt(i.dx,i.dy),h=c*Math.PI/180;return{x:l,y:s,angle:c,nx:Math.sin(h),ny:-Math.cos(h)}}function le(t,e=8){const n=se(t);if(n<1)return[{x:t[0][0],y:t[0][1],nx:0,ny:-1,s:0}];const a=[0];for(let l=1;l<t.length;l++)a.push(a[l-1]+Math.hypot(t[l][0]-t[l-1][0],t[l][1]-t[l-1][1]));const r=l=>{let s=1;for(;s<a.length-1&&a[s]<l;)s++;const c=(l-a[s-1])/(a[s]-a[s-1]||1);return[t[s-1][0]+(t[s][0]-t[s-1][0])*c,t[s-1][1]+(t[s][1]-t[s-1][1])*c]},o=R(Math.round(n/e),8,120),i=Array.from({length:o+1},(l,s)=>r(n*s/o));return i.map((l,s)=>{const c=i[Math.max(0,s-1)],h=i[Math.min(o,s+1)],u=h[0]-c[0],d=h[1]-c[1],f=Math.hypot(u,d)||1;return{x:l[0],y:l[1],nx:-d/f,ny:u/f,s:n*s/o}})}function ce(t,e){const n=t.map(i=>i.y),a=Math.min(...n),r=Math.max(...n)-a,o=Number.isFinite(e)?R(e,.1,1):r>24?.3:1;return t.map(i=>r>1e-6?I(o+(1-o)*(i.y-a)/r):1)}function tn(t,{lanes:e=9,width:n=70,taper:a}={}){const r=le(t),o=ce(r,a),i=R(Math.round(e),2,11),l=o.map(s=>n/2*s);return{lanes:Array.from({length:i},(s,c)=>{const h=c/(i-1)*2-1;return r.map((u,d)=>[u.x+u.nx*h*l[d],u.y+u.ny*h*l[d]])}),half:l,S:r,k:o}}const Rt=(t,e=0)=>((t+1)*.6180339887+e*.3819660113)%1;function en(t,{main:e,draw:n,dur:a,B:r,px:o,L:i}){t.lanes.length;const l=t.half.reduce((c,h)=>c+h,0)/t.half.length,s=[G("g","road glow",i(t.S.map(c=>[c.x,c.y])),!1,{stroke:q(e,r.len(l*1.8),{blur:r.len(l*.8),opacity:.28}),draw:[0,n]})];return t.lanes.forEach((c,h)=>{const u=Rt(h),d=n*.35*Rt(h,1),f=Math.min(a,d+n*.65);s.push(G("l"+(h+1),`lane ${h+1}`,i(c),!1,{stroke:q(e,r.len(o(h%3===1?3.4:2.2)),{blur:r.len(o(.8)),opacity:.8+.2*u}),draw:[d,f]}));const w=G("p"+(h+1),`streak ${h+1}`,i(c),!1,{stroke:q("#fffbe6",r.len(o(4.2)),{blur:r.len(o(2.4))})}),g=1.1+.9*Rt(h,2),T=[{time:I(f),value:-1}];for(let O=f;O<a&&T.length<58;)O+=2*g,T.push({time:I(O),value:1}),O<a&&T.push({time:I(O+.002),value:-1});w.ops=[{op:"trim",start:0,end:_(.08+.1*u),offset:0}],w.keys={"ops.0.offset":T,opacity:[{time:I(f),value:0,ease:Vt},{time:I(Math.min(f+.25,f+a)),value:1}]},s.push(w)}),s}const nn={weight:900,lineHeight:1.25,uppercase:!0,layers:[{type:"text",fill:"#000000",opacity:.45,offset:{x:.05,y:.16},shadow:{color:"#000000",blur:.35,x:0,y:0}},{type:"text",fill:"#6f7480",offset:{x:.018,y:.09}},{type:"text",fill:"#8e939d",offset:{x:.012,y:.06}},{type:"text",fill:"#b4b8c0",offset:{x:.006,y:.03}},{type:"text",fill:"#ffffff",stroke:{color:"#d9dce2",width:.02}}]},zt=t=>t===" "?.32:/[IÍÌỈĨỊ1.,:;!|'’]/.test(t)?.34:/[MWƯỨỪỬỮỰ]/.test(t)?.88:.7,an=t=>{let e=0,n=0,a=0;for(let r=0;r<t.length;r++){const o=t[r],i=t[(r+1)%t.length],l=o[0]*i[1]-i[0]*o[1];e+=l,n+=(o[0]+i[0])*l,a+=(o[1]+i[1])*l}return Math.abs(e)<1e-6?[t.reduce((r,o)=>r+o[0],0)/t.length,t.reduce((r,o)=>r+o[1],0)/t.length]:[n/(3*e),a/(3*e)]};function rn(t){const e=t.reduce((i,l)=>i+l[0],0)/t.length,n=t.reduce((i,l)=>i+l[1],0)/t.length;let a=0,r=0,o=0;for(const i of t){const l=i[0]-e,s=i[1]-n;a+=l*l,r+=l*s,o+=s*s}return wt(Math.cos(.5*Math.atan2(2*r,a-o)),Math.sin(.5*Math.atan2(2*r,a-o)))}function on(t){if(t!==void 0){if(!t||typeof t!="object"||!["w","s","e","n"].every(e=>Number.isFinite(t[e]))||t.w>=t.e||t.s>=t.n||t.w<-180||t.e>180||t.s<-85||t.n>85||t.proj!==void 0&&!["linear","mercator"].includes(t.proj))throw Error("Map bounds are {w,s,e,n} degrees (west < east, south < north) and proj linear | mercator");return t}}function Fn(t){if(t==null)return null;const e=Array.isArray(t)?{w:t[0],s:t[1],e:t[2],n:t[3]}:{w:t.w??t.west,s:t.s??t.south,e:t.e??t.east,n:t.n??t.north,...t.proj?{proj:t.proj}:{}};return on(e)}const ut=t=>Math.log(Math.tan(Math.PI/4+t*Math.PI/360));function sn(t,e,n){const a=(e-t.w)/(t.e-t.w),r=t.proj==="mercator"?(ut(t.n)-ut(n))/(ut(t.n)-ut(t.s)):(t.n-n)/(t.n-t.s);return[+a.toFixed(5),+r.toFixed(5)]}const ln=(t,e,n)=>[t.w+e*(t.e-t.w),t.proj==="mercator"?Math.atan(Math.sinh(ut(t.n)-n*(ut(t.n)-ut(t.s))))*180/Math.PI:t.n-n*(t.n-t.s)];function te(t){let e=0;for(let n=1;n<t.length;n++){const[a,r]=[t[n-1],t[n]],o=Math.PI/180,i=(r[1]-a[1])*o,l=(r[0]-a[0])*o,s=Math.sin(i/2)**2+Math.cos(a[1]*o)*Math.cos(r[1]*o)*Math.sin(l/2)**2;e+=12742*Math.asin(Math.sqrt(s))}return e}const ee=t=>t>=1?`~${(t>=10?Math.round(t):Math.round(t*10)/10).toString().replace(".",",")} km`:`~${Math.round(t*1e3/10)*10} m`;function tt(t,e,n){const a=e?.mapBounds;let r=null;if(t.geojson!=null){let i=typeof t.geojson=="string"?JSON.parse(t.geojson):t.geojson;i?.type==="FeatureCollection"&&(i=i.features?.[0]),i?.type==="Feature"&&(i=i.geometry);const l=i?.coordinates;if(r=i?.type==="Point"?[l]:i?.type==="LineString"||i?.type==="MultiPoint"?l:i?.type==="Polygon"||i?.type==="MultiLineString"?l?.[0]:i?.type==="MultiPolygon"?l?.[0]?.[0]:null,!Array.isArray(r))throw Error("GeoJSON must be a Point, LineString or Polygon (or a Feature of one)");(i.type==="Polygon"||i.type==="MultiPolygon")&&(r=r.slice(0,-1))}else t.lonlat!=null&&(r=t.lonlat);if(r){if(!a)throw Error("lon / lat points need the map bounds: send bounds [west, south, east, north] once (annotateMap / flyTo / setMapBounds)");if(!Array.isArray(r)||!r.every(i=>Array.isArray(i)&&i.length>=2&&i.every(Number.isFinite)))throw Error("lonlat points are [lon, lat]");return{uv:ne(r.map(i=>sn(a,i[0],i[1])),n),ll:r}}const o=Array.isArray(t.points)?ne(t.points,n):t.points;return{uv:o,ll:a&&Array.isArray(o)&&o.every(i=>Array.isArray(i)&&i.length===2)?o.map(i=>ln(a,i[0],i[1])):null}}function ne(t,e){if(!Array.isArray(t)||t.length<=e)return t;const n=(a,r)=>{if(a.length<3)return a;const[o,i]=[a[0],a.at(-1)],l=i[0]-o[0],s=i[1]-o[1],c=Math.hypot(l,s)||1e-9;let h=0,u=0;for(let d=1;d<a.length-1;d++){const f=Math.abs((a[d][0]-o[0])*s-(a[d][1]-o[1])*l)/c;f>h&&(h=f,u=d)}return h>r?[...n(a.slice(0,u+1),r).slice(0,-1),...n(a.slice(u),r)]:[o,i]};for(let a=1e-5;;a*=1.6){const r=n(t,a);if(r.length<=e)return r}}const G=(t,e,n,a,{fill:r,stroke:o,opacity:i=1,draw:l,show:s}={})=>{const c={id:t,name:e,type:"path",params:{pts:n.map(h=>[_(h[0]),_(h[1])]),closed:a},pos:[0,0],rot:0,scale:[1,1],opacity:i,fill:r??{type:"none"},stroke:o??null};return l&&(c.ops=[{op:"trim",start:0,end:1,offset:0}],c.keys={"ops.0.end":[{time:I(l[0]),value:0,ease:ie},{time:I(l[1]),value:1}]}),s&&(c.keys={...c.keys,opacity:[{time:I(s[0]),value:0,ease:Vt},{time:I(s[1]),value:i}]}),c},ht=(t,e,n,a,r,{fill:o,stroke:i,opacity:l=1,show:s}={})=>{const c={id:t,name:e,type:"ellipse",params:{w:_(a),h:_(r)},pos:[_(n[0]),_(n[1])],rot:0,scale:[1,1],opacity:l,fill:o??{type:"none"},stroke:i??null};return s&&(c.keys={opacity:[{time:I(s[0]),value:0,ease:Vt},{time:I(s[1]),value:l}]}),c},q=(t,e,{blur:n,dash:a,opacity:r}={})=>({color:t,width:_(R(e,0,240)),cap:"round",join:"round",...n?{blur:_(R(n,0,200))}:{},...a?{dash:a.map(_)}:{},...r!==void 0&&r<1?{opacity:_(r)}:{}});function Mt({fill:t="#ffffff",outline:e="#000000",glow:n,uppercase:a=!0,italic:r=!1}={}){return{weight:800,lineHeight:1.3,uppercase:a,...r?{lines:[{scale:1,italic:!0}]}:{},layers:[...n?[{type:"text",fill:n,shadow:{color:n,blur:.45,x:0,y:0},opacity:.9}]:[],{type:"text",fill:t,stroke:{color:e,width:.09},shadow:{color:"#000000",blur:.22,x:0,y:.04}}]}}function xt({text:t,px:e,W:n,H:a,font:r="Be Vietnam Pro",design:o,color:i="#ffffff",animation:l}){const s=Math.min(n/1280,a/720);let c=e/s,h=1;return c<24?(h=c/24,c=24):c>96&&(h=c/96,c=96),{title:Ue({text:t,fontSize:Math.round(c),color:i,placement:"center",fontFamily:r,align:"center",design:o,...l?{animation:l}:{}}),scale:I(R(h,.05,4)),label:t.slice(0,40)}}function cn(t,e,n,a,r,o){const i=[];for(let l=0;l<=10;l++){const s=r+(o-r)*l/10,c=R(s-t.start,0,t.duration),h=[[0,0],[1,0],[0,1]].map(([g,T])=>It(t,g,T,c,s,n,a,e));if(h.some(g=>!g))continue;ye(t,n,a);const[u,d]=[bt(t,0,0,n,a),bt(t,1,1,n,a)],f=d[0]-u[0],w=d[1]-u[1];i.push(Math.max(Math.hypot(h[1][0]-h[0][0],h[1][1]-h[0][1])/f,Math.hypot(h[2][0]-h[0][0],h[2][1]-h[0][1])/w))}return i.sort((l,s)=>l-s),R(i.length?i[i.length>>1]:1,.25,6)}function fe(t,e,n,a,r,o,i,l,s=[0,0]){const c=w=>{const g=It(t,e,n,R(w-t.start,0,t.duration),w,o,i,l);return g?[(g[0]+s[0]-o/2)/o,(g[1]+s[1]-i/2)/i]:null},h=Math.max(1,Math.min(120,Math.ceil((r-a)/Je))),u=[];for(let w=0;w<=h;w++){const g=a+(r-a)*w/h,T=c(g);T&&u.push([g-a,T])}if(!u.length)return null;if(u.every(([,w])=>Math.abs(w[0]-u[0][1][0])<1e-4&&Math.abs(w[1]-u[0][1][1])<1e-4))return{posX:I(R(u[0][1][0],-1,1)),posY:I(R(u[0][1][1],-1,1))};const f=w=>u.map(([g,T])=>({time:I(g),value:I(R(T[w],-1,1)),ease:"auto"}));return{x:f(0),y:f(1)}}const he=(t,e)=>{if(!e)return t;if("posX"in e)return{...t,posX:e.posX,posY:e.posY};let n={...t,motionV:2,motionKeys:[]};return n={...n,...dt(n,"x",e.x)},n={...n,...dt(n,"y",e.y)},n};function Rn(t,{base:e,W:n=1280,H:a=720,cam:r=null,materials:o=[]}){const i=t.kind;if(!Ht.includes(i))throw Error(`Map annotation kind must be ${Ht.join("/")}`);if(!e||!["image","video"].includes(e.kind)||e.title||e.shape||e.motion||e.card)throw Error("Map annotations go on a map / drone image or video clip");const l=Number.isFinite(t.at)?t.at:e.start,s=Number.isFinite(t.duration)?t.duration:e.start+e.duration-l;if(!(s>=.2)||l<e.start-1e-6||l+s>e.start+e.duration+1e-6)throw Error("The annotation must lie inside the map clip");const c=R(Number.isFinite(t.draw)?t.draw:1.1,.2,8),h=jt(r)&&At(e),u=cn(e,h?r:null,n,a,Math.min(l+c,l+s),l+s),d=(p,y)=>{const m=Math.min(l+s,l+c+.5);return It(e,p,y,R(m-e.start,0,e.duration),m,n,a,h?r:null)},f=He(n,a),w=p=>bt(e,p[0],p[1],n,a),g=p=>p/u,T=p=>Qe(t.color,p),O=p=>({nodeId:"",kind:"image",url:"",volume:0,start:+l.toFixed(4),duration:+s.toFixed(4),parentId:e.id,motionV:2,motionKeys:[],...At(e)?{is3D:!0,spatialDepth:.002}:{},exit:{type:"fade",duration:Math.min(.4,s/4)},...p,mapAnno:{base:e.id,kind:i}}),B=(p,y)=>O({label:y,shape:{v:2,items:p,size:f.size},posX:0,posY:0,scale:1}),U=p=>{const y=Math.abs(p)*Math.PI/180,m=Math.cos(y),k=Math.sin(y),b=1280,A=720;return Math.min(n/(b*m+A*k),a/(b*k+A*m))/Math.min(n/b,a/A)},V=(p,[y,m],k,b,A,v,N)=>{const x=xt({text:p,px:g(b),W:n,H:a,design:A,animation:N});return x.scale=I(R(x.scale/U(k),.05,4)),O({...x,posX:I((y-n/2)/n),posY:I((m-a/2)/a),rotation:_(k),start:+(l+v).toFixed(4),duration:+Math.max(.2,s-v).toFixed(4),enter:{type:"fade",duration:.35}})},E=(p,y,m,k,b=0)=>{const A=l+b,v=fe(e,y,m,A,l+s,n,a,h?r:null,k);return he({nodeId:"",kind:"image",url:"",volume:0,start:+A.toFixed(4),duration:+(s-b).toFixed(4),motionV:2,motionKeys:[],exit:{type:"fade",duration:Math.min(.35,s/4)},...p,mapAnno:{base:e.id,kind:i,follow:[I(y),I(m),_(k[0]),_(k[1])]}},v)},$=[],L=(p,y)=>p.map(m=>f.pt(m));switch(i){case"route":{const p=tt(t,e,200),y=rt(p.uv,2,200,"A route"),m=Lt[t.style]??Lt.glow,k=T(m.color),b=t.smooth===!1?y.map(w):Wt(y.map(w)),A=m.lanes?tn(b,{lanes:Number.isFinite(t.lanes)?t.lanes:11,width:g(Number.isFinite(t.width)?R(t.width,10,600):70),taper:t.taper}):null,v=A?en(A,{main:k,draw:c,dur:s,B:f,px:g,L}):m.layers.map((P,C)=>G("s"+(C+1),`${t.style??"glow"} ${C+1}`,L(b),!1,{stroke:q(P.c??k,f.len(g(P.w)),{blur:P.blur?f.len(g(P.blur)):void 0,dash:P.dash?.map(F=>f.len(g(F))),opacity:P.a}),draw:[0,c]}));if(t.arrow&&!A){const P=b.at(-1),C=b[Math.max(0,b.length-4)],F=Math.atan2(P[1]-C[1],P[0]-C[0]),D=g(Math.max(16,m.layers[1]?.w*2.2||16)),M=(z,K)=>[P[0]+Math.cos(F+K)*z,P[1]+Math.sin(F+K)*z];v.push(G("s9","arrow",L([M(D*.4,0),M(D,Math.PI*.82),M(D*.25,Math.PI),M(D,-Math.PI*.82)]),!0,{fill:{type:"color",color:m.layers[1]?.c??k},stroke:q("#ffffff",f.len(g(1.5)),{opacity:.8}),show:[c*.92,c]}))}$.push(B(v,`Map · ${J(t.text)||m.en}`));const N=t.distance&&p.ll?ee(te(p.ll)):"",x=[J(t.text),N].filter(Boolean).join(" · "),S=x.normalize("NFC").split(" ").filter(Boolean);if(x&&(t.labelLook==="stand"||A&&t.labelLook!=="flat")&&S.length<=8&&S.join("").length<=40){const P=A?.S??le(b),C=A?.k??ce(P,t.taper),F=A?.half??P.map(()=>g(Math.max(...m.layers.map(Z=>Z.w))/2)),D=Number.isFinite(t.textSize)?R(t.textSize,10,80):40,M=g(D),z=P.at(-1).s,K=C.map(Z=>.55+.45*Z),X=Z=>{const nt=R(Z/(z||1),0,1)*(P.length-1),Y=Math.min(P.length-2,Math.floor(nt)),Q=nt-Y,W=P[Y],ft=P[Y+1]??W,at=(kt,me)=>kt+(me-kt)*Q;return{x:at(W.x,ft.x),y:at(W.y,ft.y),nx:at(W.nx,ft.nx),ny:at(W.ny,ft.ny),k:at(K[Y],K[Y+1]??K[Y]),half:at(F[Y],F[Y+1]??F[Y])}},ct=Z=>[...Z].reduce((nt,Y)=>nt+zt(Y.toUpperCase()),0),ot=(S.reduce((Z,nt)=>Z+ct(nt),0)+zt(" ")*(S.length-1))*M*X(z/2).k;let H=R(z/2-ot/2,0,Math.max(0,z-ot)),gt=0;const yt=Math.min(.07,Math.max(.03,(s-c*.6-.8)/Math.max(1,S.join("").length)));for(const Z of S){const nt=X(H).k,Y=ct(Z)*M*nt,Q=X(H+Y/2),W=Q.ny>0?-1:1,ft=Q.k,at=Q.half+M*ft*.62,kt=wt(-Q.ny*W,Q.nx*W);$.push(V(Z,[Q.x+Q.nx*W*at,Q.y+Q.ny*W*at],kt,D*ft,nn,c*.6+gt*yt,{in:[{unit:"char",stagger:yt,duration:.5,easing:"easeOutBack",from:{opacity:0,y:.55,blur:.3}}],out:"reverse",outSpeed:1.8})),gt+=[...Z].length,H+=Y*1.02+zt(" ")*M*nt}}else if(x){const P=Number.isFinite(t.textSize)?R(t.textSize,10,80):22,C=x.length*P*.62/u,F=We(b,C),D=m.layers[1]?.w>=9,M=D?0:g(Math.max(...m.layers.map(z=>z.w))/2)+g(P)*.75;$.push(V(x,[F.x+F.nx*M,F.y+F.ny*M],F.angle,P,Mt({fill:"#ffffff",outline:D?k:"#000000"}),c*.7))}break}case"area":{const p=rt(tt(t,e,200).uv,3,200,"An area"),y=T("#39ff6a"),m=t.smooth?Wt(p.map(w),!0):p.map(w),k=[G("s1","fill",L(m),!0,{fill:{type:"color",color:y,opacity:.38},show:[c*.5,c]}),G("s2","glow",L(m),!0,{stroke:q(y,f.len(g(14)),{blur:f.len(g(10)),opacity:.75}),draw:[0,c]}),G("s3","edge",L(m),!0,{stroke:q(y,f.len(g(3.5))),draw:[0,c]})];$.push(B(k,`Map · ${J(t.text)||"area"}`));const b=J(t.text);if(b){const A=an(m),v=Number.isFinite(t.textSize)?R(t.textSize,10,80):24;$.push(V(b,A,rn(m),v,Mt({fill:"#ffffff",outline:y}),c*.8))}break}case"lots":{const p=rt(tt(t,e,4).uv,4,4,"A lot block").map(w),y=Array.isArray(t.labels)?t.labels.map(M=>J(M,12)).filter(Boolean).slice(0,10):[],m=R(Math.round(t.count??(y.length||4)),1,10),k=(M,z)=>Math.hypot(M[0]-z[0],M[1]-z[1]),b=(M,z,K)=>[M[0]+(z[0]-M[0])*K,M[1]+(z[1]-M[1])*K],[A,v,N,x]=k(p[0],p[1])+k(p[3],p[2])>=k(p[1],p[2])+k(p[0],p[3])?[p[0],p[1],p[3],p[2]]:[p[1],p[2],p[0],p[3]],S=T("#ffe066"),P="#2a2100",C=Math.min(.18,s/(3*m)),F=[G("s1","block glow",L(p),!0,{stroke:q("#ffffff",f.len(g(10)),{blur:f.len(g(8)),opacity:.55}),draw:[0,c*.8]})],D=[];for(let M=0;M<m;M++){const z=[b(A,v,M/m),b(A,v,(M+1)/m),b(N,x,(M+1)/m),b(N,x,M/m)];D.push(z),F.push(G("l"+(M+1),y[M]||`Lô ${M+1}`,L(z),!0,{fill:{type:"color",color:S,opacity:Number.isFinite(t.fillOpacity)?R(t.fillOpacity,.1,1):.9},stroke:q(P,f.len(g(1.4)),{opacity:.8}),opacity:1,show:[c*.6+M*C,c*.6+M*C+.25]}))}F.push(G("s2","block edge",L(p),!0,{stroke:q("#ffffff",f.len(g(2.4))),draw:[0,c*.8]})),$.push(B(F.slice(0,24),`Map · ${y.length?y[0]+"–"+y.at(-1):"lots"}`)),D.forEach((M,z)=>{if(!y[z])return;const K=M.reduce((gt,yt)=>[gt[0]+yt[0]/4,gt[1]+yt[1]/4],[0,0]),X=k(M[0],M[1]),ct=k(M[1],M[2]),ot=ct>=X?[(M[0][0]+M[1][0])/2-(M[3][0]+M[2][0])/2,(M[0][1]+M[1][1])/2-(M[3][1]+M[2][1])/2]:[M[1][0]-M[0][0],M[1][1]-M[0][1]],H=Math.min(Math.min(X,ct)*.55*u,Number.isFinite(t.textSize)?t.textSize:22);$.push(V(y[z],K,wt(ot[0],ot[1]),H,Mt({fill:P,outline:S,uppercase:!0}),c*.6+z*C+.15))});break}case"label":{const p=tt(t,e,2),[y,m]=rt(p.uv,2,2,"A measure").map(w),k=J(t.text,24)||(t.distance&&p.ll?ee(te(p.ll)):"");if(!k)throw Error('A measure label needs its text (e.g. "20m")');const b=T("#ff2a2a"),A=m[0]-y[0],v=m[1]-y[1],N=Math.hypot(A,v)||1,x=-v/N,S=A/N,P=g(9),C=X=>[[X[0]+x*P,X[1]+S*P],[X[0]-x*P,X[1]-S*P]],F=[G("s1","measure",L([y,m]),!1,{stroke:q("#ffffff",f.len(g(2.2))),draw:[0,c*.6]}),G("s2","tick a",L(C(y)),!1,{stroke:q("#ffffff",f.len(g(2.2))),show:[0,.2]}),G("s3","tick b",L(C(m)),!1,{stroke:q("#ffffff",f.len(g(2.2))),show:[c*.5,c*.6]})];$.push(B(F,`Map · ${k}`));const D=Number.isFinite(t.textSize)?R(t.textSize,10,80):30,M=wt(A,v),z=M*Math.PI/180,K=g(D)*.8;$.push(V(k,[(y[0]+m[0])/2+Math.sin(z)*K,(y[1]+m[1])/2-Math.cos(z)*K],M,D,{weight:900,lineHeight:1.3,uppercase:!1,lines:[{scale:1,italic:!0}],layers:[{type:"text",fill:b,stroke:{color:"#ffffff",width:.12},shadow:{color:"#000000",blur:.25,x:0,y:.05}}]},c*.5));break}case"pin":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A pin"),m=T("#3cf2d0"),k=J(t.text,24),b=a>n,A=(Number.isFinite(t.height)?t.height:b?.2:.26)*a,v=(b?.085:.06)*Math.min(n,a)*(b?1.6:1.4),N=[n/2,a/2],x=[n/2,a/2-A],S=[ht("s1","ground glow",f.pt(N),f.len(v*1.6),f.len(v*.55),{stroke:q(m,f.len(v*.35),{blur:f.len(v*.3),opacity:.7})}),G("s2","beam",L([[N[0]-v*.05,N[1]],[N[0]+v*.05,N[1]],[x[0]+v*.42,x[1]],[x[0]-v*.42,x[1]]]),!0,{fill:{type:"linear",stops:[["#e9fffb",0],[m,1]],angle:90,opacity:.55},stroke:q(m,f.len(4),{blur:f.len(6),opacity:.8})}),ht("s3","badge glow",f.pt(x),f.len(v*2.15),f.len(v*2.15),{stroke:q(m,f.len(v*.3),{blur:f.len(v*.28),opacity:.8})}),ht("s4","badge",f.pt(x),f.len(v*2),f.len(v*2),{fill:{type:"radial",stops:[["#9ffff1",0],[m,.7],["#0f8f86",1]],opacity:.95},stroke:q("#eafffb",f.len(3))}),ht("s5","point",f.pt(N),f.len(9),f.len(9),{fill:{type:"color",color:"#ffffff"},stroke:q(m,f.len(3))})],P={type:"slide-down",duration:.55,amount:.06,ease:Ze};$.push(E({label:`Map · pin ${k||""}`.trim(),shape:{v:2,items:S,size:f.size},enter:P},p,y,[0,0]));const C=t.materialId?o.find(F=>F.id===t.materialId&&F.kind==="image"):null;if(C){const F=Number.isInteger(C.width)&&C.width>1?C.width:1e3,D=Number.isInteger(C.height)&&C.height>1?C.height:1e3,M=Ut(F,D),z=Math.min(M.w,M.h),K=Math.min(n/F,a/D),X=I(R(v*1.7/(z*K),.02,4));$.push(E({nodeId:C.id,url:C.url,...C.gcsUri?{gcsUri:C.gcsUri}:{},label:"Map · logo",scale:X,mask:Gt({mw:F,mh:D},[Xt({kind:"circle",cx:.5,cy:.5,w:I(z/M.w),h:I(z/M.h),rot:0},M.w,M.h)]),mapSize:[F,D],enter:P},p,y,[0,-A]))}else if(k){const F=xt({text:k,px:Math.min(v*.42,v*3.2/Math.max(4,k.length)),W:n,H:a,font:"Be Vietnam Pro",design:{weight:800,lineHeight:1.3,uppercase:!0,layers:[{type:"text",fill:"#063b37",shadow:{color:"#ffffff",blur:.15,x:0,y:0}}]}});$.push(E({...F,enter:P},p,y,[0,-A]))}if(k&&C){const F=xt({text:k,px:22,W:n,H:a,design:Mt({fill:"#ffffff",outline:m})});$.push(E({...F,enter:P},p,y,[0,-A+v*1.45]))}break}case"photo":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A photo bubble"),m=o.find(H=>H.id===t.materialId&&H.kind==="image");if(!m?.url)throw Error("A photo bubble needs an image from Media (materialId)");const k=T("#ffd23a"),b=(Number.isFinite(t.size)?t.size:.17)*Math.min(n,a)*(a>n?1.5:1.2),A=d(p,y),v=Array.isArray(t.offset)&&t.offset.length===2&&t.offset.every(Number.isFinite)?[t.offset[0]*n,t.offset[1]*a]:[A&&A[0]<n*.35?b*.95:-b*.95,A&&A[1]<a*.38?b*1.05:-b*1.05],N=[n/2+v[0],a/2+v[1]],x=[n/2,a/2],S=Math.atan2(x[1]-N[1],x[0]-N[0]),P=b/2,C=[N[0]+Math.cos(S+Math.PI/2)*P*.62,N[1]+Math.sin(S+Math.PI/2)*P*.62],F=[N[0]+Math.cos(S-Math.PI/2)*P*.62,N[1]+Math.sin(S-Math.PI/2)*P*.62],D=[G("s1","cone",L([C,x,F]),!0,{fill:{type:"linear",stops:[[k,0],["#fff6c8",1]],angle:_(S*180/Math.PI),opacity:.6},show:[.25,.6]}),ht("s2","point",f.pt(x),f.len(10),f.len(10),{fill:{type:"color",color:"#ffffff"},stroke:q(k,f.len(3)),show:[0,.2]}),ht("s3","ring glow",f.pt(N),f.len(b*1.08),f.len(b*1.08),{stroke:q(k,f.len(b*.06),{blur:f.len(b*.06),opacity:.85}),show:[.1,.4]})];$.push(E({label:"Map · photo cone",shape:{v:2,items:D,size:f.size}},p,y,[0,0]));const M=Number.isInteger(m.width)&&m.width>1?m.width:1e3,z=Number.isInteger(m.height)&&m.height>1?m.height:1e3,K=Ut(M,z),X=Math.min(K.w,K.h),ct=Math.min(n/M,a/z);$.push(E({nodeId:m.id,url:m.url,...m.gcsUri?{gcsUri:m.gcsUri}:{},label:`Map · ${J(t.text)||m.label||"photo"}`,scale:I(R(b/(X*ct),.02,4)),mapSize:[M,z],mask:Gt({mw:M,mh:z},[Xt({kind:"circle",cx:.5,cy:.5,w:I(X/K.w),h:I(X/K.h),rot:0},K.w,K.h)]),edge:{color:k,width:.012,glow:.7},enter:{type:"pop",duration:.45}},p,y,v,.15));const ot=J(t.text,28);if(ot){const H=xt({text:ot,px:20,W:n,H:a,design:Mt({fill:"#ffffff",outline:"#000000"})});$.push(E({...H,enter:{type:"fade",duration:.3}},p,y,[v[0],v[1]-P-16],.35))}break}case"callout":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A callout"),m=J(t.text,40),k=J(t.subText,60),b=T("#c9a45c");if(!m)throw Error("A callout needs its text");const A=d(p,y),v=!!A&&A[1]<a*.38,N=!!A&&A[0]>n*.62,x=N?-1:1,S=v?-1:1,P=(Number.isFinite(t.height)?t.height:.16)*a*S,C=[n/2,a/2],F=[n/2+n*.04*x,a/2-P],D=[G("s1","leader",L([C,[C[0],F[1]+8],F]),!1,{stroke:q(b,f.len(2.4)),draw:[0,.45]}),ht("s2","point",f.pt(C),f.len(11),f.len(11),{fill:{type:"color",color:b},stroke:q("#ffffff",f.len(2.5))})];$.push(E({label:"Map · callout leader",shape:{v:2,items:D,size:f.size}},p,y,[0,0]));const M=xt({text:k?`${m}
|
|
4
4
|
${k}`:m,px:24,W:n,H:a,design:{weight:800,lineHeight:1.35,uppercase:!1,...k?{lines:[{scale:1},{scale:.62,weight:500,fill:"#e8dcc0"}]}:{},layers:[{type:"box",fill:"#0f1b30",radius:.18,padX:.55,padY:.32,opacity:.92},{type:"text",fill:"#ffffff"},{type:"underline",fill:b,height:.06,width:.35,offsetY:.25}]}}),z=Math.max(...M.title.text.split(`
|
|
5
5
|
`).map(K=>K.length))*M.title.fontSize*.3*Math.min(n/1280,a/720)*M.scale;$.push(E({...M,enter:{type:v?"slide-down":"slide-up",duration:.4,amount:.04}},p,y,[(n*.04+z)*x,-P-30*S],.3));break}case"icon":{const[[p,y]]=rt(tt(t,e,1).uv,1,1,"A map icon"),m=J(t.text,40),k=J(t.subText,40),b=Dt.includes(t.look)?t.look:Dt.includes(t.style)?t.style:"gold-pin",A=Kt[t.icon]?t.icon:qt(t.icon)??qt(m)??"location",v={...ge.params,icon:A,look:b,label:m,sub:k,color:T(Se(b)),size:R(Number.isFinite(t.size)?t.size:1,.5,2),pulse:t.pulse===!0||t.pulse!==!1&&(b==="tag"||b==="beacon")?1:0};$.push(E({label:`Map · ${m||Kt[A].vi}`,motion:St({code:`@preset:${Jt}`,params:v,preset:Jt})},p,y,[0,0]));break}case"overlay":{const p=pe(rt(tt(t,e,4).uv,4,4,"An overlay")),y=o.find(A=>A.id===t.materialId&&A.kind==="image");if(!y?.url)throw Error("An overlay needs an image from Media (materialId): the master plan / render");const m=Xe.includes(t.reveal)?t.reveal:"rise",k=m==="rise"?_(Math.min(c*1.2,s*.6)):void 0,b={nodeId:y.id,url:y.url,...y.gcsUri?{gcsUri:y.gcsUri}:{},kind:"image",label:`Map · ${y.label||"overlay"}`,volume:0,start:+l.toFixed(4),duration:+s.toFixed(4),motionV:2,motionKeys:[],pin:{clip:e.id,corners:p.map(A=>[I(A[0]),I(A[1])]),...k?{rise:k}:{}},enter:{type:"fade",duration:m==="fade"?Math.min(1.2,s/3):.3},exit:{type:"fade",duration:Math.min(.4,s/4)},mapAnno:{base:e.id,kind:i}};if(m==="wipe"&&Object.assign(b,{revealType:"wipe-up",...dt({motionKeys:[]},"reveal",[{time:0,value:0,ease:ie},{time:_(Math.min(c*1.2,s*.6)),value:1}])}),$.push(b),t.outline!==!1){const A=p.map(w);$.push(B([G("s1","glow",L(A),!0,{stroke:q(T("#3cf2d0"),f.len(g(12)),{blur:f.len(g(9)),opacity:.8}),draw:[0,c]}),G("s2","edge",L(A),!0,{stroke:q(T("#3cf2d0"),f.len(g(3))),draw:[0,c]})],"Map · overlay edge"))}break}}return{layers:$,applied:`map ${i}${t.text?` "${J(t.text,30)}"`:""} @ ${_(l)}s`}}function zn(t,e,{W:n=1280,H:a=720,cam:r=null}){const o=tt({...e,points:e.point!=null?[e.point]:e.points,lonlat:e.lonlat!=null&&!Array.isArray(e.lonlat[0])?[e.lonlat]:e.lonlat},t,1).uv;let[i,l]=Array.isArray(o?.[0])&&o[0].length===2&&o[0].every(Number.isFinite)?o[0]:[.5,.5],s=R(Number.isFinite(e.zoom)?e.zoom:1.6,.3,Oe);const c=R(Number.isFinite(e.tilt)?e.tilt:0,0,70),h=Number.isFinite(e.at)?e.at:t.start,u=R(Number.isFinite(e.duration)?e.duration:3,.3,60),d=h+u;if(h<t.start-1e-6||d>t.start+t.duration+1e-6)throw Error("The move must lie inside the map clip");const f=jt(r)&&At(t);let w="auto";const g=(U,V,E)=>f?fn(t,r,U,V,E,c,h,d,n,a,w):{patch:hn(t,U,V,E,h,d,n,a,w)};let T=g(i,l,s),O="";if(e.keepInside!==!1){const U=Tt(t,f?r:null,h,h,n,a),V=U?h:d,E=p=>Tt(f?t:{...t,...p.patch},f?p.camera:null,V,d,n,a),$=()=>{if(E(T))return!0;if(!E(g(.5,.5,s)))return!1;let p=0,y=1;for(let m=0;m<14;m++){const k=(p+y)/2;E(g(i+(.5-i)*k,l+(.5-l)*k,s))?y=k:p=k}return i+=(.5-i)*y,l+=(.5-l)*y,T=g(i,l,s),O="aim",!0};for(let p=0;p<24&&!$();p++)s=Math.min(4,s*1.04),T=g(i,l,s),O="zoom";const L=un(f?T.camera?.motionKeys:{...t,...T.patch}.motionKeys,f?null:t.start,h);L!=null&&Tt(t,f?r:null,L,h,n,a)&&!Tt(f?t:{...t,...T.patch},f?T.camera:null,L,h,n,a)&&(w=Ot["easy-ease"],T=g(i,l,s))}const B=O?` (kept on the map: ${O==="zoom"?"more zoom":"aim nudged"})`:"";return f?{camera:T.camera,applied:`fly to [${_(i)}, ${_(l)}] ×${_(s)}${c?` tilt ${c}°`:""} ${_(h)}→${_(d)}s (camera)${B}`}:{patch:T.patch,applied:`fly to [${_(i)}, ${_(l)}] ×${_(s)} ${_(h)}→${_(d)}s (map layer)${B}`}}function fn(t,e,n,a,r,o,i,l,s,c,h="auto"){const[u,d]=bt(t,n,a,s,c),f=Me(t,R(l-t.start,0,t.duration),s,c),[w,g,T]=f.corners,O=u/s,B=d/c,U=[0,1,2].map(m=>w[m]+(g[m]-w[m])*O+(T[m]-w[m])*B),V=Pe(s,c),E=o*Math.PI/180,$=5*V,L=(U[2]-$*Math.cos(E))/V,p={cx:U[0]/s,cy:(U[1]+$*Math.sin(E))/c,cz:L,zoom:r,tilt:o};let y={...e??xe,enabled:!0,motionV:2,motionKeys:e?.motionKeys??[]};for(const[m,k]of Object.entries(p)){const b=we(y,m),A=be(y,m,i),v=b.filter(S=>S.time<i-1/60||S.time>l+1/60),N=v.filter(S=>S.time<i),x=v.filter(S=>S.time>l);y=ke(y,m,[...N,{time:I(i),value:I(A),ease:h},{time:I(l),value:I(R(k,...mn(m))),...x.length?{ease:"auto"}:{}},...x])}return{camera:Te(y)}}function hn(t,e,n,a,r,o,i,l,s="auto"){const[c,h]=bt(t,e,n,i,l),u={x:-(c-i/2)*a/i,y:-(h-l/2)*a/l,zoom:a};let d={};for(const[f,w]of Object.entries(u)){const g={...t,...d},T=r-t.start,O=o-t.start,B=Ae(g,f),U=ve(g,f,T),V=B.filter(E=>E.time<T-1/60||E.time>O+1/60);d={...d,...dt(g,f,[...V.filter(E=>E.time<T),{time:I(T),value:I(U),ease:s},{time:I(O),value:I(f==="zoom"?w:R(w,-10,10)),...V.some(E=>E.time>O)?{ease:"auto"}:{}},...V.filter(E=>E.time>O)])}}return d}function un(t,e,n){const a=e??0,r=(t||[]).map(o=>o.time+a).filter(o=>o<n-1/60);return r.length?Math.max(...r):null}function Tt(t,e,n,a,r,o){const i=(l,s,c)=>{let h=0;for(let u=0;u<4;u++){const d=l[u],f=l[(u+1)%4],w=(f[0]-d[0])*(c-d[1])-(f[1]-d[1])*(s-d[0]);if(u===0)h=Math.sign(w);else if(Math.sign(w)!==h&&w!==0)return!1}return!0};for(let l=0;l<=8;l++){const s=n+(a-n)*l/8,c=R(s-t.start,0,t.duration),h=[[0,0],[1,0],[1,1],[0,1]].map(([u,d])=>It(t,u,d,c,s,r,o,e));if(h.some(u=>!u)||![[1,1],[r-1,1],[r-1,o-1],[1,o-1]].every(([u,d])=>i(h,u,d)))return!1}return!0}const mn=t=>[Yt[t].min,Yt[t].max];function Cn(t,e,n=1280,a=720){const r=new Map(t.map(o=>[o.id,o]));return t.map(o=>{const i=o.mapAnno?.follow,l=i&&r.get(o.mapAnno.base);if(!l)return o;const s=fe(l,i[0],i[1],o.start,o.start+o.duration,n,a,jt(e)&&At(l)?e:null,[i[2],i[3]]);if(!s)return o;const c={...o,motionKeys:(o.motionKeys||[]).map(h=>{const{x:u,y:d,...f}=h;if(f.ease){const{x:w,y:g,...T}=f.ease;f.ease=Object.keys(T).length?T:void 0,f.ease||delete f.ease}return f}).filter(h=>Object.keys(h).some(u=>u!=="time"&&u!=="ease"))};return he(c,s)})}const _t=Object.freeze({width:[2,80],length:[.05,3],points:256}),pt=t=>Math.round(t*1e3)/1e3,j=t=>Math.round(t*1e4)/1e4,vt=(t,[e,n],a)=>Number.isFinite(t)?Math.min(n,Math.max(e,t)):a,dn=/^#[0-9a-fA-F]{6}$/;function Bt(t,e){const[n,a]=oe(t,e),r=Math.min(n,a)/1e3,o=(n-1e3*r)/2,i=(a-1e3*r)/2;return{size:[n,a],pt:([l,s])=>[pt((l*n/t-o)/r),pt((s*a/e-i)/r)],len:l=>l*n/t/r}}const $n=Bt,pn=(t,e,n)=>n==="energy"?[{name:"aura",color:t,width:e*6,blur:e*5,opacity:.4},{name:"glow",color:t,width:e*3.2,blur:e*2.4,opacity:.8},{name:"line",color:t,width:e*1.2},{name:"core",color:"#ffffff",width:Math.max(1,e*.6),opacity:1}]:[{name:"glow",color:t,width:e*3.2,blur:e*2.4,opacity:.55},{name:"line",color:t,width:e},{name:"core",color:"#ffffff",width:Math.max(1,e*.35),opacity:.9}],Pt=Object.freeze({strands:12,color:"#c25bff",width:8});function gn(t,e){const n=[0];for(let o=1;o<t.length;o++)n.push(n[o-1]+Math.hypot(t[o][0]-t[o-1][0],t[o][1]-t[o-1][1]));const a=Math.max(90,e*20),r=e*2.6;return Array.from({length:Pt.strands},(o,i)=>t.map((l,s)=>{const c=t[Math.max(0,s-1)],h=t[Math.min(t.length-1,s+1)],u=h[0]-c[0],d=h[1]-c[1],f=Math.hypot(u,d)||1,w=r*Math.sin(2*Math.PI*n[s]/a+i*2*Math.PI/Pt.strands)*(.55+.45*Math.cos(i*1.7));return[l[0]-d/f*w,l[1]+u/f*w]}))}function yn(t,e,n,a){const r=(i,l,s,c)=>({id:i,name:l,type:"path",params:{pts:s.map(h=>a.pt(h)),closed:!1},pos:[0,0],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:c.color,width:pt(vt(a.len(c.width),[0,240],1)),cap:"round",join:"round",...c.blur?{blur:pt(Math.min(200,a.len(c.blur)))}:{},...c.opacity?{opacity:c.opacity}:{}}}),o=[r("s1","trail aura",t,{color:e,width:n*9,blur:n*8,opacity:.45}),r("s2","trail glow",t,{color:e,width:n*4,blur:n*3,opacity:.85})];return gn(t,n).forEach((i,l)=>{o.push(r("r"+(2*l+1),`trail strand ${l+1}`,i,{color:e,width:n*.7,blur:n*.5,opacity:1})),o.push(r("r"+(2*l+2),`trail strand core ${l+1}`,i,{color:"#fbe6ff",width:Math.max(1,n*.22),opacity:.95}))}),o}function ue(t,e,n,a,r){return r==="ribbon"?yn(t,e,n,a):pn(e,n,r).map((o,i)=>({id:"s"+(i+1),name:`trail ${o.name}`,type:"path",params:{pts:t.map(l=>a.pt(l)),closed:!1},pos:[0,0],rot:0,scale:[1,1],opacity:1,fill:{type:"none"},stroke:{color:o.color,width:pt(vt(a.len(o.width),[0,240],1)),cap:"round",join:"round",...o.blur?{blur:pt(Math.min(200,a.len(o.blur)))}:{},...o.opacity?{opacity:o.opacity}:{}}}))}const Ct=Object.freeze({vanish:[.5,.42],flow:1.15,spread:.05});function Mn(t,e,n,{color:a,width:r,length:o,vanish:i,flow:l,ring:s,spread:c}){const h=t.map(([f,w,g])=>[j(f),j(w/e),j(g/n)]),u=Array.isArray(i)&&i.length===2?i:Ct.vanish,d="const TR="+JSON.stringify(h)+`;function render(ctx,t,env){
|
|
6
6
|
const {width:W,height:H,params:p}=env,col=p.color||'#c25bff',L=Math.max(.2,+p.length||1.6),wk=(+p.width||8)*H/720,flow=Math.max(0,+p.flow||0),V=[(+p.vx||.5)*W,(+p.vy||.42)*H],RG=Math.max(0,+p.ring||0)*H
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{iP as w,hV as W,nw as A,b0 as P,b1 as E,b2 as M,aP as $,a_ as O,aQ as L,aZ as b}from"./titleFrameBudget-h4nOQ5u9.js";function T(n){const t=new DataView(n.buffer,n.byteOffset,n.byteLength),o={};for(let e=0,a=t.getUint16(4);e<a;e++){const l=12+e*16;o[String.fromCharCode(n[l],n[l+1],n[l+2],n[l+3])]=t.getUint32(l+8)}const s=t.getUint16(o.head+18),i=t.getUint16(o.hhea+34),g=e=>t.getUint16(o.hmtx+Math.min(e,i-1)*4),r=o.cmap,f=[];for(let e=0,a=t.getUint16(r+2);e<a;e++)f.push({platform:t.getUint16(r+4+e*8),encoding:t.getUint16(r+6+e*8),offset:r+t.getUint32(r+8+e*8)});const p=f.find(e=>e.platform===3&&e.encoding===10)||f.find(e=>e.platform===3&&e.encoding===1)||f.find(e=>e.platform===0);if(!p)throw Error("Font has no usable cmap");const h=t.getUint16(p.offset);return{unitsPerEm:s,glyphFor:e=>{if(h===4){const a=t.getUint16(p.offset+6)/2,l=p.offset+14,u=l+a*2+2,y=u+a*2,m=y+a*2;for(let d=0;d<a;d++){if(e>t.getUint16(l+d*2))continue;if(e<t.getUint16(u+d*2))return 0;const k=t.getUint16(m+d*2),x=t.getInt16(y+d*2);if(!k)return e+x&65535;const C=t.getUint16(m+d*2+k+(e-t.getUint16(u+d*2))*2);return C?C+x&65535:0}return 0}if(h===12){for(let a=0,l=t.getUint32(p.offset+12);a<l;a++){const u=p.offset+16+a*12,y=t.getUint32(u),m=t.getUint32(u+4);if(e>=y&&e<=m)return t.getUint32(u+8)+(e-y)}return 0}throw Error(`Unsupported cmap format ${h}`)},advanceOf:g}}const V=n=>({...T(n),advances:new Map});function j(n,t,o){let s=0;for(const i of String(t).normalize("NFC")){let g=n.advances.get(i);g===void 0&&(g=n.advanceOf(n.glyphFor(i.codePointAt(0))),n.advances.set(i,g)),s+=g}return s*o/n.unitsPerEm}let U=null;const S=new Map,v=new Map;function B(n){const t=w(n);if(S.has(t.id))return Promise.resolve();let o=v.get(t.id);return o||(o=Promise.all([fetch(`/fonts/${t.file}`).then(s=>{if(!s.ok)throw Error(String(s.status));return s.arrayBuffer()}).then(s=>{S.set(t.id,V(new Uint8Array(s)))}),document.fonts.load(`40px "${t.css}"`)]).then(()=>{}).catch(()=>{v.delete(t.id)}),v.set(t.id,o)),o}function D(n,t,o){const s=S.get(w(o).id);return s?j(s,n,t):(B(o),U??=document.createElement("canvas").getContext("2d"),U?(U.font=`${t}px "${w(o).css}"`,U.measureText(n).width):n.length*t*.55)}const F=new WeakMap,N=n=>{const t=F.get(n.captionWords);if(t&&t.style===n.captionStyle&&t.cues===n.captions)return t.prepared;const o=b(n.captionWords,n.captionStyle,n.captions);return F.set(n.captionWords,{style:n.captionStyle,cues:n.captions,prepared:o}),o},Q=(n,t)=>{const o=n.groups[t];let s=0;for(let i=o.from;i<=o.to;i++)s+=[...String(n.words[i].word)].length;return s};function Z(n,t,o,s,i,g=D){const r=W(n,t,o);if(!r)return null;const f=t-r.start;if(["social","karaoke"].includes(r.captionStyle?.style||"")&&r.captionWords?.length){const c=N(r),e=A(c.groups,f);if(e<0)return null;const a=c.style.style==="karaoke",l=c.groups[e],u=P(c.style,f-l.start,Q(c,e));return{clip:r,layout:M(c,e,s,i,g),style:c.style,scale:u.scale,motion:u.m,lit:a?E(c,e,f):void 0}}const p=$(r.captionStyle),h=O(r.captions,p.cueWords).find(c=>f>=c.start&&f<c.end);return h?{clip:r,layout:L({width:s,height:i,text:h.text,style:p,measure:g,second:h.tr}),style:p,scale:1}:null}export{B as captionFontReady,Z as captionFrameAt,Q as groupLetters,D as measureCaption};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b_ as p,
|
|
1
|
+
import{b_ as p,eX as b,eY as y,iK as x,eC as w,cG as E,eO as O,id as S,iL as A,fr as D,eu as _,ev as v,ey as B,dZ as u,d$ as f,iM as T,U as L,W as $,iN as I,hN as P,bL as R}from"./titleFrameBudget-h4nOQ5u9.js";import{e as j,a as z}from"./timelineComp-Ciu9JCWJ.js";const F=new Set(["opacity","x","y","zoom","blur","exposure","dirBlur","zoomBlur","rgbSplit","invert","glitch","rot","spinBlur","dirBlurV"]),M=e=>!(e?.dirBlur&&(e.zoom||e.blur||e.zoomBlur))&&!(e?.zoomBlur&&(e.x||e.y||e.blur||e.dirBlur)),X=new Set(["id","name","category","duration","tags","version","sortOrder","a","b","flash","light","mask","zoomAt","gl"]),N=["colorPerson","matte","shocks","impacts","smoothSlow","reverse","revealType","rotFit","is3D","space","bend","bendStrip","device","deviceScreen","join","audioFx","audioTools","muffle","trail","path","links","element","modelGround","modelRotation","modelSpin","modelAnim","modelDepth","spatialDepth","pendingPin","personPending","samPending","gen","clientJobs","mapAnno","seam","warped"],K={rx:0,ry:0,rz:0,depth:0,tiltX:0,tiltY:0},C=new Set(["rot","sx","sy","depth","tiltX","tiltY"]),H=new Set(["is3D","spatialDepth"]),J=new Set(["blur","glow","light-burst","rgb-split","pixelate","sepia","invert","mono","duotone","luma-invert",...Object.keys(R)]),c=e=>e!=null&&e!==!1&&!(Array.isArray(e)&&!e.length);function Y(e,{camera:a=null,W:r=1280,H:m=720}={}){const n=[];if(E(e))return[];if(e.kind==="model")return[];if(!["image","video","audio"].includes(e.kind))return[`${e.kind} layer`];const i=e.kind!=="audio"&&b(a)&&y(e),d=!i&&e.is3D===!0&&!c(e.spatialDepth);for(const t of N){if(t==="clientJobs"){Array.isArray(e.clientJobs)&&e.clientJobs.some(o=>o?.state==="pending"||o?.state==="running")&&n.push(t);continue}c(e[t])&&!(i&&H.has(t))&&!(d&&t==="is3D")&&n.push(t)}if(e.pin?.scene&&n.push("scene pin"),e.timeRemap?.blend&&e.timeRemap.blend!=="none"&&n.push("time remap frame blending"),e.kind!=="audio"&&O(e,r||1280).some(t=>t.sigma>42)&&n.push("wide shadow"),S(e)&&A(e)&&n.push("shadow on an adjustment layer"),e.motionBlur&&e.kind!=="audio"&&((e.effects||[]).some(t=>!t.off)||e.pin||e.parentId||D(e)||e.layout!==void 0||e.rotFit||i)&&n.push("motion blur"),e.kind!=="audio"&&_(e)){const t=v(e),o=B(t);t.crackle?n.push("edge crackle"):Math.max(o.band,o.glow)>42&&n.push("wide edge")}const l=!i&&e.kind!=="audio"&&(u(e,"rot").length>1||Math.abs(f(e,"rot",0))>1e-9);l&&((e.effects||[]).some(t=>!t.off)||e.layout!==void 0||e.rotFit)&&n.push("rot"),!i&&e.kind!=="audio"&&["ax","ay"].some(t=>u(e,t).length>1||Math.abs(f(e,t,0))>1e-9)&&l&&n.push("anchor with rotation"),i&&(e.transition||e._txIn||e._txOut)&&n.push("transition on a 3D layer");for(const[t,o]of Object.entries(K))!(i&&C.has(t))&&(u(e,t).length>1||Math.abs(f(e,t,0)-o)>1e-9)&&n.push(t);e.grade&&!e.colorBypass&&(e.grade.lut||T(e.grade).length)&&n.push("grade"),e.grade&&!e.colorBypass&&L(e.grade).some(t=>$(t)&&(t.window?.type==="person"||t.qualifier&&(t.window?.type==="polygon"||t.motion||t.window?.type==="face")))&&n.push("grade window");for(const t of Array.isArray(e.effects)?e.effects:[])!t.off&&!J.has(t.type)&&n.push(`effect ${t.type}`);if(I(e,"T")&&n.push("reveal"),e.transition){const t=e.transition.spec||{},o=s=>!!e.transition.ramp||M(s);(Object.keys(t).some(s=>!X.has(s))||["a","b"].some(s=>t[s]&&(Object.keys(t[s]).some(k=>!F.has(k))||!o(t[s]))))&&n.push(`transition ${e.transition.id}`)}return e.kind==="video"&&P(e)&&n.push("title on video"),n}function V(e,a={}){const{reasons:r}=h(e,a);return{ok:r.length===0,reasons:r}}function W(e,a={}){return[...new Set(h(e,a).codes)].sort()}function h(e,{format:a,camera:r,look:m}={}){const n=[],i=[];e=j((e||[]).filter(t=>!t.disabled),{W:p(a).width,H:p(a).height});const d=b(r)?r:null,{width:l,height:g}=p(a);d&&(e||[]).some(t=>!t.disabled&&t.kind!=="audio"&&y(t))&&d.parentId&&(n.push("camera on a parent"),i.push("camera on a parent")),x(m)&&(n.push("look"),i.push("look"));for(const t of e||[]){if(t.disabled)continue;if(t._group&&t.comp){const s=h(z(t),{format:a});s.reasons.length&&(n.push(`${t.label||t.id} (comp): ${s.reasons.join("; ")}`),i.push(...s.codes))}const o=Y(t,{camera:d,W:l,H:g});o.length&&(n.push(`${t.label||t.id}: ${o.join(", ")}`),i.push(...o))}if(!n.length)for(const t of w((e||[]).filter(o=>!o.disabled))){const o=s=>{n.push(`${t.label||t.id}: ${s}`),i.push(s)};t.timeRemap&&(t._txIn||t._txOut)&&!t._ramp&&o("time remap in a transition"),t.motionBlur&&(t._txIn||t._txOut)&&o("motion blur in a transition")}return{reasons:n,codes:i}}const q=(e,a,r)=>(a==="video encode"||a==="finalize")&&r?.codec!=="hevc"&&e?.name!=="AbortError"&&/^(OperationError|EncodingError)$/.test(e?.name||""),Z=e=>!(typeof DOMException<"u"&&e instanceof DOMException)&&!(e instanceof TypeError)&&!(e instanceof Error&&/^media \d{3}$/.test(e.message))?"":(e.message||"").replace(/\b(?:https?|blob|data):\S*/gi,"").replace(/\s+/g," ").trim();export{N as HEAVY_FIELDS,V as clientExportCheck,W as clientExportCodes,Y as clipBlockers,Z as gpuErrorText,q as softwareRetry};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-
|
|
2
|
-
import{_ as c}from"./titleFrameBudget-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/main-C_XcvNyC.js","assets/titleFrameBudget-h4nOQ5u9.js","assets/remote-CpkPQOQH.js","assets/index-CKtv7gGE.js","assets/i18n-ClNt3LKg.js","assets/api-CZoVJ9Fy.js","assets/three.module-Bx43vjkH.js","assets/gltfLoader-U0Eebg7v.js","assets/store-D3Y663py.js","assets/rotoMaskStore-BZBJLcCp.js","assets/sceneTrack-CO4fTjft.js","assets/timelineOps-f1WsVbgS.js","assets/cameraTracker-Df9jWmz6.js","assets/textAnimators-C4eMnVRD.js","assets/timelineComp-Ciu9JCWJ.js","assets/rigTrack-BbKqZGs7.js","assets/clientJobs-CuuUyhEy.js","assets/spark.module-3Q8DniuL.js","assets/userFonts-BlVEJfDk.js","assets/lottieLayer-DEw0c3to.js","assets/timeline3d-BcW68fQr.js","assets/RoomEnvironment-Dmv_G5ka.js","assets/glTransitionSources.generated-Cs8lVRqs.js","assets/captionLayout-eiu9QPJu.js","assets/timelineText-Cppd4KB7.js","assets/titleArt-D0YI5xT2.js","assets/personHq-CBP8v_cw.js","assets/matteQuality-9X-jgJrH.js","assets/sceneTrack-_n6WKKQv.js","assets/rotoMatte-BI-vjjrv.js","assets/objectSegmenter-C4T9qgUL.js","assets/cutoutClean-CLYYAuXg.js","assets/distortGL-DQu0Df2c.js","assets/motionBlur-uAm030t9.js","assets/main-DlzdW5C4.css","assets/poseTracker-qtuytI-L.js","assets/rotoscope-DuNcCxQy.js","assets/maskTrack-GYpJyKFw.js","assets/auraTrack-ClhHuqlf.js","assets/mapBake-BUWz0cSx.js","assets/gpuCompose-DkkKH1Ab.js","assets/id3-arvEpAg7.js","assets/output-p-Q7qous.js","assets/handTracker-CQV-D7va.js","assets/handMatte-B5sUeqKi.js","assets/matteFixRun-BCVsuSxf.js","assets/depthEstimate-CfwX-tXP.js","assets/faceTracker-BeSFnLM8.js","assets/analyzerRun-D5-g-Vxe.js","assets/analyzerSandbox-E3CdovIk.js","assets/pluginAutomation-ClFdpcCR.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{_ as c}from"./titleFrameBudget-h4nOQ5u9.js";import{r as p}from"./index-CKtv7gGE.js";import{u as d}from"./store-D3Y663py.js";import{t as l}from"./i18n-ClNt3LKg.js";import{am as I}from"./api-CZoVJ9Fy.js";import{listClientJobs as w,claimable as E,KINDS as b,markClientJob as P}from"./clientJobs-CuuUyhEy.js";const f=t=>document.querySelector(`video[data-clip-media="${CSS.escape(t.id)}"]`)?.currentSrc||t.url,m={cutout:async(t,a)=>{const{cutoutImage:r}=await c(async()=>{const{cutoutImage:e}=await import("./main-C_XcvNyC.js").then(o=>o.am);return{cutoutImage:e}},__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,27,28,29,30,31,32,33,34])),n=a.params?.mode==="person"?"person":"object";return{mask:await r({clip:t,url:t.url,mode:n,pts:n==="object"?[{x:.5,y:.55}]:[]})}},"pose-track":async(t,a)=>{const{runPoseTrack:r}=await c(async()=>{const{runPoseTrack:n}=await import("./poseTracker-qtuytI-L.js");return{runPoseTrack:n}},__vite__mapDeps([35,1,8,3,4,26,27,5,15]));return r(t,a)},rotoscope:async(t,a)=>{const{runRotoscope:r}=await c(async()=>{const{runRotoscope:n}=await import("./rotoscope-DuNcCxQy.js");return{runRotoscope:n}},__vite__mapDeps([36,4,3,5,1,11,10,12,13,14,8,15,16]));return r(t,a)},"mask-track":async(t,a)=>{const{runMaskTrack:r}=await c(async()=>{const{runMaskTrack:n}=await import("./maskTrack-GYpJyKFw.js");return{runMaskTrack:n}},__vite__mapDeps([37,1,11,10,12,13,14,5,4,3,8,15,16,28]));return r(t,a)},"aura-pose":async(t,a)=>{const{runAuraTrack:r}=await c(async()=>{const{runAuraTrack:n}=await import("./auraTrack-ClhHuqlf.js");return{runAuraTrack:n}},__vite__mapDeps([38,35,1,8,3,4,26,27,5,15,11,10,12,13,14,16]));return r(t,a)},"map-bake":async t=>{const{bakeMap:a}=await c(async()=>{const{bakeMap:r}=await import("./mapBake-BUWz0cSx.js");return{bakeMap:r}},__vite__mapDeps([39,19,1,15,4,3,5,40,41,42]));return a(t,d.getState().timelineFormat)},"hand-track":async(t,a)=>{const{runHandTrack:r}=await c(async()=>{const{runHandTrack:n}=await import("./handTracker-CQV-D7va.js");return{runHandTrack:n}},__vite__mapDeps([43,1,8,3,4,26,27,5,11,10,12,13,14,15,16,44]));return r(t,a)},"matte-fix":async(t,a)=>{const{runMatteFixJob:r}=await c(async()=>{const{runMatteFixJob:n}=await import("./matteFixRun-BCVsuSxf.js");return{runMatteFixJob:n}},__vite__mapDeps([45,8,1,3,4,26,27,5,11,10,12,13,14,15,16,44,0,2,6,7,9,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34]));return r(t,a)},"camera-track":async(t,a)=>{const{runCameraTrackJob:r}=await c(async()=>{const{runCameraTrackJob:n}=await import("./main-C_XcvNyC.js").then(e=>e.an);return{runCameraTrackJob:n}},__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,27,28,29,30,31,32,33,34]));return r(t,a)},"camera-place":async(t,a)=>{const{runCameraPlaceJob:r}=await c(async()=>{const{runCameraPlaceJob:n}=await import("./main-C_XcvNyC.js").then(e=>e.an);return{runCameraPlaceJob:n}},__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,27,28,29,30,31,32,33,34]));return r(t,a)},"object-track":async(t,a)=>{const{runObjectTrackJob:r}=await c(async()=>{const{runObjectTrackJob:n}=await import("./main-C_XcvNyC.js").then(e=>e.ao);return{runObjectTrackJob:n}},__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,27,28,29,30,31,32,33,34]));return r(t,a)},"object-place":async(t,a)=>{const{runObjectPlaceJob:r}=await c(async()=>{const{runObjectPlaceJob:n}=await import("./main-C_XcvNyC.js").then(e=>e.ao);return{runObjectPlaceJob:n}},__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,27,28,29,30,31,32,33,34]));return r(t,a)},"depth-map":async t=>{const[{estimateDepth:a},{upgradeDepthWindows:r},{secondariesOf:n,withSecondaries:e}]=await Promise.all([c(()=>import("./depthEstimate-CfwX-tXP.js"),__vite__mapDeps([46,1,4,3])),c(()=>import("./timelineOps-f1WsVbgS.js").then(u=>u.db),__vite__mapDeps([11,1,10,12,13,14,5,4,3,8,15,16])),c(()=>import("./titleFrameBudget-h4nOQ5u9.js").then(u=>u.nS),[])]),o=await a(t,t.duration/2),i=r(n(t.grade));return{depthMap:o,...i.upgraded&&t.grade?{grade:e(t.grade,i.list)}:{}}},"face-3d":async t=>{const{trackFace3D:a}=await c(async()=>{const{trackFace3D:n}=await import("./faceTracker-BeSFnLM8.js");return{trackFace3D:n}},__vite__mapDeps([47,1,26,27,5,4,3])),r=await a({clip:t,url:f(t)});return{face:t.face?.fix?{...r,fix:t.face.fix}:r}},"color-face":async t=>{if(t.face)return{};const{trackFace:a}=await c(async()=>{const{trackFace:r}=await import("./faceTracker-BeSFnLM8.js");return{trackFace:r}},__vite__mapDeps([47,1,26,27,5,4,3]));return{face:await a({clip:t,url:f(t)})}},"color-person":async t=>{if(t.colorPerson)return{};if(t.person&&!t.person.src)return{colorPerson:t.person};const{segmentPerson:a}=await c(async()=>{const{segmentPerson:r}=await import("./personHq-CBP8v_cw.js").then(n=>n.i);return{segmentPerson:r}},__vite__mapDeps([26,1,27,5,4,3]));return{colorPerson:await a({clip:t,url:f(t)})}},"plugin-analyze":async(t,a)=>{const{runAnalyzerJob:r}=await c(async()=>{const{runAnalyzerJob:n}=await import("./analyzerRun-D5-g-Vxe.js");return{runAnalyzerJob:n}},__vite__mapDeps([48,8,1,3,4,11,10,12,13,14,5,15,16,0,2,6,7,9,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,49,50]));return r(t,a)}},T=Math.random().toString(36).slice(2,10),_=(t,a,r,n={},e)=>d.setState(o=>({clips:o.clips.map(i=>i.id!==t||!i.clientJobs?.some(u=>u.id===a)?i:{...P(i,a,{state:r,...e?{error:e}:{},by:T}),...n})}));async function R({only:t}={}){const a=[],r=new Set;for(;;){const n=d.getState().clips,e=w(n).find(i=>!r.has(i.id)&&m[i.kind]&&E(i)&&(!t?.length||t.includes(i.kind)));if(!e)break;r.add(e.id);const o=n.find(i=>i.id===e.clipId);if(o){_(e.clipId,e.id,"running");try{const i=await m[e.kind](o,e);_(e.clipId,e.id,"done",i),a.push({id:e.id,kind:e.kind,clipId:e.clipId,ok:!0})}catch(i){const u=String(i?.message||i||"failed").slice(0,200);_(e.clipId,e.id,"failed",{},u),a.push({id:e.id,kind:e.kind,clipId:e.clipId,ok:!1,error:u})}}}return a}function S(){const t=d(o=>o.clips),a=d(o=>o.toast),r=p.useRef(!1),[n,e]=p.useState(0);p.useEffect(()=>{if(r.current)return;const o=w(t).find(s=>m[s.kind]&&E(s));if(!o)return;const i=t.find(s=>s.id===o.clipId);if(!i)return;r.current=!0;const u=d.getState().canvasId;_(o.clipId,o.id,"running");const k=l(b[o.kind]?.vi??o.kind),y=()=>d.getState().canvasId===u&&d.getState().clips.find(s=>s.id===o.clipId)?.clientJobs?.some(s=>s.id===o.id&&s.createdAt===o.createdAt&&s.state==="running");m[o.kind](i,o).then(s=>{y()&&(_(o.clipId,o.id,"done",s),a(l("Đã xong trên máy: {0}",[k]),"ok"))},s=>{I("client-job",s?.message||"failed",{jobKind:o.kind,op:o.op,duration:i.duration,sourceDuration:i.sourceDuration}),y()&&(_(o.clipId,o.id,"failed",{},s?.message||"failed"),a(l("Chưa xong trên máy: {0} — {1}",[k,s?.message||""]),"error"))}).finally(()=>{r.current=!1,e(s=>s+1)})},[t,n,a])}export{m as CLIENT_JOB_RUNNERS,R as runPendingClientJobs,S as useClientJobs};
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{nJ as k,nK as O,nL as y,_ as I}from"./titleFrameBudget-h4nOQ5u9.js";import{t as p}from"./i18n-ClNt3LKg.js";import"./index-CKtv7gGE.js";const H="1.31.1",T=`https://cdn.jsdelivr.net/npm/onnxruntime-web@${H}/dist/`,l={url:"https://huggingface.co/onnx-community/depth-anything-v2-small/resolve/4472b7362082ad9968fee890ca0f1e5aca36b93d/onnx/model_quantized.onnx",sha256:"fcf51f1b230362b28690bb9d1809bf0431f29cad20534e3f589bd7285547f20d",bytes:27258801,cache:"clipoox-depth-1"},j=[.485,.456,.406],q=[.229,.224,.225],x=378;let g=null;const F=e=>[...new Uint8Array(e)].map(o=>o.toString(16).padStart(2,"0")).join("");async function K(e){const o=await caches.open(l.cache).catch(()=>null),n=await o?.match(l.url);if(n){const d=new Uint8Array(await n.arrayBuffer());if(d.length===l.bytes)return d}const c=await fetch(l.url);if(!c.ok||!c.body)throw Error(p("Không tải được mô hình độ sâu (HTTP {0})",[c.status]));const a=c.body.getReader(),t=[];let r=0;for(;;){const{done:d,value:h}=await a.read();if(d)break;t.push(h),r+=h.length,e?.(Math.min(1,r/l.bytes))}const i=new Uint8Array(r);let u=0;for(const d of t)i.set(d,u),u+=d.length;if(F(await crypto.subtle.digest("SHA-256",i))!==l.sha256)throw Error(p("Mô hình độ sâu tải về bị lỗi (mã kiểm tra không khớp) — thử lại."));return await o?.put(l.url,new Response(i,{headers:{"content-type":"application/octet-stream"}})).catch(()=>{}),i}function P(e){return g||(g=(async()=>{const o=await I(()=>import(`${T}ort.wasm.min.mjs`),[]);o.env.wasm.wasmPaths=T,o.env.wasm.numThreads=1;const n=await o.InferenceSession.create(await K(e),{executionProviders:["wasm"],graphOptimizationLevel:"all"});return Object.assign(n,{ort:o})})(),g.catch(()=>{g=null})),g}async function L(e,o){const n=document.createElement("canvas"),c=n.getContext("2d",{willReadFrequently:!0});if(e.kind==="image"){const t=new Image;return t.crossOrigin="anonymous",t.src=e.url,await new Promise((r,i)=>{t.onload=()=>r(),t.onerror=()=>i(Error(p("Không đọc được ảnh của clip")))}),n.width=t.naturalWidth,n.height=t.naturalHeight,c.drawImage(t,0,0),n}const a=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous"});a.src=e.url;try{await new Promise((r,i)=>{a.onloadeddata=()=>r(),a.onerror=()=>i(Error(p("Không đọc được video của clip (CORS / định dạng)")))});const t=Math.max(0,Math.min(a.duration-1/60,(e.inPoint||0)+o*(e.playbackRate||1)));return await new Promise((r,i)=>{const u=window.setTimeout(()=>i(Error(p("Seek video quá lâu"))),8e3);a.onseeked=()=>{window.clearTimeout(u),r()},a.currentTime=t}),n.width=a.videoWidth||1280,n.height=a.videoHeight||720,c.drawImage(a,0,0),n}finally{a.removeAttribute("src"),a.load()}}async function A(e,o){const n=o.width/Math.max(1,o.height),c=s=>Math.max(14,Math.round(s/14)*14),a=n>=1?c(x*n):x,t=n>=1?x:c(x/n),r=Object.assign(document.createElement("canvas"),{width:a,height:t}),i=r.getContext("2d",{willReadFrequently:!0});i.imageSmoothingQuality="high",i.drawImage(o,0,0,a,t);const u=i.getImageData(0,0,a,t).data,d=a*t,h=new Float32Array(3*d);for(let s=0;s<d;s++)for(let m=0;m<3;m++)h[m*d+s]=(u[s*4+m]/255-j[m])/q[m];const f=(await e.run({[e.inputNames[0]]:new e.ort.Tensor("float32",h,[1,3,t,a])}))[e.outputNames[0]];return{d:f,dh:f.dims.at(-2),dw:f.dims.at(-1)}}async function U(e,o){if(window.__depthStub){const r=window.__depthStub({kind:"image"},0);return{data:r.data,w:r.w,h:r.h}}const n=await P(r=>o?.("download",r));o?.("run");const{d:c,dw:a,dh:t}=await A(n,e);return{data:k(c.data),w:a,h:t}}async function W(e,o,n){const c=Math.max(0,Math.min(e.duration,o));if(window.__depthStub){const s=window.__depthStub(e,c);return O(s.data,s.w,s.h,c)}const[a,t]=await Promise.all([P(s=>n?.("download",s)),L(e,c)]);n?.("run");const{d:r,dw:i,dh:u}=await A(a,t),d=t.width/Math.max(1,t.height),h=d>=1?y.maxSide:Math.max(2,Math.round(y.maxSide*d)),w=d>=1?Math.max(2,Math.round(y.maxSide/d)):y.maxSide,f=new Float32Array(h*w);for(let s=0;s<w;s++)for(let m=0;m<h;m++){const _=Math.floor(m*i/h),R=Math.max(_+1,Math.floor((m+1)*i/h)),v=Math.floor(s*u/w),D=Math.max(v+1,Math.floor((s+1)*u/w));let S=0,E=0;for(let b=v;b<D;b++)for(let M=_;M<R;M++)S+=r.data[b*i+M],E++;f[s*h+m]=S/Math.max(1,E)}return O(k(f),h,w,c)}export{l as DEPTH_MODEL,U as depthOfPicture,W as estimateDepth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as P,c as v}from"./cameraPresets-
|
|
1
|
+
import{C as P,c as v}from"./cameraPresets-DD0WmxiI.js";import{de as g,fg as y,bX as k,bY as C,c6 as S,c5 as A,c7 as N,c0 as D,c1 as $,b$ as F,fy as x,bU as j,c8 as I,b_ as R}from"./remote-CpkPQOQH.js";import{s as U}from"./weaponDuel-ChqBQo_b.js";import"./index-CKtv7gGE.js";import"./i18n-ClNt3LKg.js";import"./api-CZoVJ9Fy.js";import"./titleFrameBudget-h4nOQ5u9.js";import"./three.module-Bx43vjkH.js";import"./gltfLoader-U0Eebg7v.js";import"./store-D3Y663py.js";import"./rotoMaskStore-BZBJLcCp.js";import"./sceneTrack-CO4fTjft.js";import"./timelineOps-f1WsVbgS.js";import"./cameraTracker-Df9jWmz6.js";import"./textAnimators-C4eMnVRD.js";import"./timelineComp-Ciu9JCWJ.js";import"./rigTrack-BbKqZGs7.js";import"./clientJobs-CuuUyhEy.js";const z=["katana","spear","staff","fist"],M=P.map(t=>t.id),L=()=>crypto.randomUUID(),w=t=>Math.round(t*100)/100,b=(t,a)=>z.includes(t)?t:a,E=(t,a,l)=>({...t,shots:t.shots.map(c=>c.id===a?{...c,...l}:c)}),T=t=>{const a=g(t),l=k(a.timing,a.duration);return{hit_stops:l?.holds.length??0,slow_spans:l?.slows??[],scene_s:a.duration,video_s:w(R(a)),...a.impactFrame?{impact_frame:a.impactFrame}:{}}};function nt(t,a){const l=a.getStage(),c=g(l),n=Array.isArray(t.fighters)?t.fighters.map(String):[];if(n.length!==2)return{ok:!1,error:"give fighters: [first attacker, opponent] (two person names)"};let r;try{r=n.map(e=>y(l,e))}catch(e){return{ok:!1,error:e.message}}for(const e of r)if(!j(e))return{ok:!1,error:`'${e.name}' is not a person (or a humanoid-rigged model)`};const p=Array.isArray(t.weapons)?t.weapons:[t.weapons??t.weapon,t.weapons??t.weapon],f=[b(p[0],"katana"),b(p[1]??p[0],b(p[0],"katana"))],h=Math.max(0,Math.min(c.duration,Number(t.start??0)||0)),i=U(l,{a:r[0].id,b:r[1].id,packs:f,exchanges:Number(t.exchanges??4)||4,seed:Number(t.seed)||1,start:h,hitStops:t.hit_stops!==!1},L);if(!i.ok)return{ok:!1,error:i.error};let o=i.stage;const m=Math.min(g(o).duration,i.end+.4),u=String(t.camera??"fight");let s={kept:"your own camera"};if(u==="fight")try{const e=I(o,{fighters:r.map(_=>_.name),start:h,end:m,focal_length_mm:Number(t.focal_length_mm)||32});o=e.stage,s={fight_camera:e.result}}catch(e){s={error:e.message}}else if(u!=="none"){const e=v(o,{preset:u,subject:r[0].id,start:h,end:m});e.ok?(o=e.stage,s={preset:e.preset,subject:e.subject,keys:e.keys,cuts:e.cuts}):s={error:e.error}}if(t.impact_frame&&t.impact_frame!=="none"){const e=F({style:t.impact_frame,strength:t.impact_strength??.8});e&&(o=E(o,g(o).id,{impactFrame:e}))}return a.setStage(()=>o),{ok:!0,fighters:r.map(e=>e.name),weapons:f,start:h,end:i.end,shot_duration_s:g(o).duration,exchange:i.plan.map(e=>({time_s:e.time,attacker:e.attackerName,attack:e.attack,defence:e.defence,result:e.result})),camera:s,timing:T(o),...i.notes.length?{notes:i.notes}:{},hint:"weapons are put in the hands with a trail (set_trail to restyle); re-run with another seed for another plan; add impact effects at the strike times of blocked / body results (none on a miss = a dodge) and set_timing for slow motion on the finisher"}}function it(t,a){const l=a.getStage(),c=g(l);if(!M.includes(String(t.preset)))return{ok:!1,error:`unknown preset; use one of ${M.join(", ")}`};let n;try{n=y(l,String(t.subject??""))}catch(h){return{ok:!1,error:h.message}}const r=Math.max(0,Number(t.start??0)||0),p=t.end==null?c.duration:Number(t.end),f=v(l,{preset:String(t.preset),subject:n.id,start:r,end:p});return f.ok?(a.setStage(()=>f.stage),{ok:!0,preset:f.preset,subject:n.name,start:w(f.start),end:w(f.end),camera_keys:f.keys,hit_beats:f.beats,cuts:f.cuts,note:"camera keys inside the span are replaced; the preset tracks the subject's motion, so bake it AFTER the motion is final"}):{ok:!1,error:f.error}}function at(t,a){const l=a.getStage(),c=g(l),n=c.duration;let r=k(c.timing,n);const p=C(l).map(s=>s.time).filter(s=>s>.05&&s<n-.05),f=S[t.strength]??S.medium,h=String(t.hit_stops??"keep");if(h==="none"&&(r=k({holds:[],slows:r?.slows??[]},n)),h==="auto"){if(!p.length)return{ok:!1,error:"no strike in the shot to stop on (stage_fight / stage_duel / play_motion strikes first, or give hit_stops_at)"};r=A(r,p,f,n)}if(Array.isArray(t.hit_stops_at)&&(r=A(r,t.hit_stops_at.map(Number).filter(s=>Number.isFinite(s)&&s>=0&&s<=n),f,n)),t.clear_slow_motion&&(r=k({holds:r?.holds??[],slows:[]},n)),t.slow_finisher){if(!p.length)return{ok:!1,error:"no strike in the shot for slow_finisher"};r=N(r,p[p.length-1],.3,.3,n)}for(const s of Array.isArray(t.slow_motion)?t.slow_motion:[]){const e=Number(s?.at);if(!Number.isFinite(e))return{ok:!1,error:"slow_motion entries need at (scene seconds)"};r=N(r,e,Math.max(.05,Math.min(3,Number(s.half??.35)||.35)),Math.max(.1,Math.min(1,Number(s.speed??.3)||.3)),n)}const i=Number(t._from)||0;if(i>0){const s=k(c.timing,n);r=k({holds:[...(s?.holds??[]).filter(e=>e.at<i),...(r?.holds??[]).filter(e=>e.at>=i)],slows:[...(s?.slows??[]).filter(e=>e.start<i),...(r?.slows??[]).filter(e=>e.start>=i)]},n)}let o={timing:r??void 0},m=null;if(t.preset==="sakuga"){if(m=D({...c,timing:r??void 0},$(l).filter(_=>_.at>.05&&_.at<n-.05),{keepLook:!1}),!m)return{ok:!1,error:"no blow in the shot for preset sakuga (stage_fight / resolve_hits first)"};let s=m.shot.timing??null,e=m.shot.impacts;if(i>0){const _=k(c.timing,n);s=k({holds:[...(_?.holds??[]).filter(d=>d.at<i),...(s?.holds??[]).filter(d=>d.at>=i)],slows:[...(_?.slows??[]).filter(d=>d.start<i),...(s?.slows??[]).filter(d=>d.start>=i)]},n),e=[...(c.impacts??[]).filter(d=>d.time*n<i),...(e??[]).filter(d=>d.time*n>=i)]}o={timing:s??void 0,impacts:e,impactFrame:m.shot.impactFrame}}if(t.impact_frame==="none")o={...o,impactFrame:void 0};else if(t.impact_frame!=null){const s=F({style:t.impact_frame,strength:t.impact_strength??c.impactFrame?.strength??.8});if(!s)return{ok:!1,error:`impact_frame: one of ${x.join(", ")} or none`};o={...o,impactFrame:s}}const u=E(l,c.id,o);return a.setStage(()=>u),{ok:!0,...T(u),strike_beats:p.map(w).slice(0,30),...m?{sakuga:{blows:m.plan.kinds.length,kinds:m.plan.kinds.slice(0,30),finisher_s:m.plan.finisher==null?null:w(m.plan.finisher)}}:{},note:"a render-time warp: preview and export freeze / slow these scene instants; impact frames flash on every hit-stop"}}function mt(t,a){const l=a.getStage(),c=Array.isArray(t.names)?t.names.map(String):t.name!=null?[String(t.name)]:[];if(!c.length)return{ok:!1,error:"give names: weapons, or people (their held weapons)"};const n=new Set;for(const i of c){let o;try{o=y(l,i)}catch(m){return{ok:!1,error:m.message}}if(o.kind==="prop"&&o.hold)n.add(o.id);else if(j(o)){const m=l.items.filter(u=>u.kind==="prop"&&u.hold?.by===o.id);if(!m.length)return{ok:!1,error:`${o.name} holds nothing (hold_prop / play_motion a weapon clip / stage_duel first)`};m.forEach(u=>n.add(u.id))}else return{ok:!1,error:`'${o.name}' is not a held weapon or a person`}}const r=t.on!==!1,p={},f=typeof t.color=="string"&&/^#[0-9a-f]{6}$/i.test(t.color)?t.color:void 0,h=t.length!=null&&Number.isFinite(Number(t.length))?Math.max(.03,Math.min(.5,Number(t.length))):void 0;return a.setStage(i=>({...i,items:i.items.map(o=>{if(!n.has(o.id))return o;if(!r){p[o.name]="off";const{trail:u,...s}=o;return s}const m={...o.trail||{},...t.style==="smear"||t.style==="ribbon"?{style:t.style}:{},...f?{color:f}:{},...h!=null?{length:h}:{}};return p[o.name]=m,{...o,trail:m}})})),{ok:!0,trails:p}}export{M as CAMERA_PRESET_IDS,z as DUEL_PACKS,it as cameraPreset,at as setTiming,mt as setTrail,nt as stageDuel};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/rotoMatte-BI-vjjrv.js","assets/titleFrameBudget-h4nOQ5u9.js","assets/api-CZoVJ9Fy.js","assets/i18n-ClNt3LKg.js","assets/index-CKtv7gGE.js","assets/store-D3Y663py.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{eW as X,hN as T,b_ as Q,jf as Y,gH as Z,eC as tt,iJ as et,_ as ot,f4 as at}from"./titleFrameBudget-h4nOQ5u9.js";import{c as rt,f as it}from"./distortGL-DQu0Df2c.js";import{I as nt,A as st,U as lt,V as ct}from"./id3-arvEpAg7.js";const dt=["crop","mask","person","personPending","matteFix","colorPerson","distort","playbackRate","speedRamp","reverse","freeze","smoothSlow","inPoint","sourceDuration","proxy","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx","audioTools","sfx","face","roto","planar","sceneTrack","hands"],ut=["url","gcsUri","label","nodeId","start","duration","inPoint","sourceDuration","playbackRate","reverse","volume","audioFadeIn","audioFadeOut","duck","muffle","audioFx"],ft=1920,mt=o=>new Promise((v,s)=>{const l=n=>{if(!n)return s(Error("Cannot encode distort frame"));const c=new FileReader;c.onload=()=>v(String(c.result).slice(String(c.result).indexOf(",")+1)),c.onerror=()=>s(c.error),c.readAsDataURL(n)};o instanceof HTMLCanvasElement?o.toBlob(l,"image/webp",.9):o.convertToBlob({type:"image/webp",quality:.9}).then(l,s)});function pt(o,v){const s=o.distort;if(o.kind!=="image"||o.mask||o.person||(s.mesh?.keys.length??0)>1||s.puppet?.pins.some(n=>(n.keys?.length??0)>1)||(s.displace?.keys?.length??0)>1)return!1;const l=s.displace?v.find(n=>n.id===s.displace.map):null;return!l||l.kind==="image"&&!T(l)&&l.start<=o.start&&l.start+l.duration>=o.start+o.duration}async function kt(o,v,s,l,n={}){const c=o.filter(t=>X(t)&&(t.kind==="video"||t.kind==="image")&&!T(t)&&!t.gen);if(!c.length)return{clips:o,tracks:n};const{fps:b}=Q(v),D=()=>{if(l?.aborted)throw new DOMException("Export cancelled","AbortError")},O=new Set(c.map(t=>t.id)),K={...n},w=[];for(const t of o){if(!O.has(t.id)){w.push(t);continue}const a={...t,kind:"image",warped:!0};for(const u of dt)delete a[u];if(t.face){const u=Y(t,b);u&&(a.face=u)}w.push(a);const d=Object.values(n).some(u=>u?.solo)&&!n[t.track]?.solo;if(t.kind==="video"&&!t.speedRamp&&!t.freeze&&(t.volume??1)>0&&!n[t.track]?.muted&&!d){const u=[...o,...w].filter(e=>e.kind==="audio"),g=e=>u.filter(m=>m.track===e&&m.start<t.start+t.duration-1e-6&&m.start+m.duration>t.start+1e-6).length,x=[...Z].sort((e,m)=>g(e)-g(m))[0],M={id:`${t.id}~sound`,kind:"audio",track:x},p=t;for(const e of ut)p[e]!==void 0&&(M[e]=p[e]);const h=(n[t.track]?.gain??1)/(n[x]?.gain??1);Math.abs(h-1)>1e-6&&(M.volume=+Math.min(1,(t.volume??1)*h).toFixed(4)),w.push(M)}}const $=new Map(tt(o).filter(t=>t._virtual).map(t=>[t.id,t])),P=[];for(const t of c)P.push({clip:t,as:t});for(const t of et(w))O.has(String(t._virtual))&&P.push({clip:$.get(t.id)??{...o.find(a=>a.id===t._virtual),...t,_still:!0},as:t});const y=c.some(t=>t.mask||t.person)?await ot(()=>import("./rotoMatte-BI-vjjrv.js").then(t=>t.r),__vite__mapDeps([0,1,2,3,4,5])):null;y&&await y.prepareMattes(c.filter(t=>t.mask||t.person));const j=y?document.createElement("canvas"):null,I=rt(),C=[],R=new Map,U=async t=>{const a=new nt({source:new lt(t),formats:st});C.push(a);const d=await a.getPrimaryVideoTrack();return d?new ct(d):null},V=async t=>{let a=R.get(t);return a||(a=await createImageBitmap(await(await fetch(t,{signal:l})).blob(),{imageOrientation:"from-image",premultiplyAlpha:"none",colorSpaceConversion:"none"}),R.set(t,a)),a};try{for(const{clip:t,as:a}of P){D();const d=o.find(r=>r.id===(t._virtual??t.id)),u=Math.ceil(a.duration*b),g=d.distort,x=!!(t._still||t.freeze),M=r=>{const i=r/b,f=t.playbackRate||1;return t.reverse?Math.max(0,(t.inPoint||0)+Math.max(0,t.duration-i-1/b)*f):at(t,i,!1,x).source};let p=null,h=null;if(t.kind==="video"){const r=await U(t.url);r&&(p=r.samplesAtTimestamps(Array.from({length:u},(i,f)=>M(f))))}else h=await V(t.url);const e=g.displace?o.find(r=>r.id===g.displace.map):void 0,m=e?.kind==="video"?await U(e.url):null,H=e?.kind==="image"&&e.url&&!T(e)?await V(e.url):null,q=async r=>{if(!e||r<e.start||r>=e.start+e.duration)return null;if(H)return{source:H};if(!m)return null;const i=await m.getSample((e.inPoint||0)+(r-e.start)*(e.playbackRate||1));if(!i)return null;const f=i.toVideoFrame();return i.close(),{source:f,close:()=>f.close()}},G=pt(d,o);for(let r=0;r<u;r++){D();const i=p?(await p.next()).value??null:null;if(G&&r>0){i?.close(),await s.push("titleFrames",a.id,"=");continue}const f=i?i.toVideoFrame():null,L=f??h,_=i?i.displayWidth:h?.width??0,F=i?i.displayHeight:h?.height??0;if(!L||!_||!F){if(f?.close(),i?.close(),r===0)throw Error(`No picture for ${d.label||d.id}`);await s.push("titleFrames",a.id,"=");continue}const k=t.crop||{left:0,right:0,top:0,bottom:0},W=Math.floor(_*k.left/2)*2,z=Math.floor(F*k.top/2)*2,S=Math.max(2,Math.floor(_*(1-k.left-k.right)/2)*2),A=Math.max(2,Math.floor(F*(1-k.top-k.bottom)/2)*2),B=Math.min(1,ft/Math.max(S,A)),E=r/b,N=await q(t.start+E),J=I.render({source:L,srcW:_,srcH:F,rect:[W,z,S,A],outW:Math.max(2,Math.round(S*B)),outH:Math.max(2,Math.round(A*B)),distort:g,local:t.start+E-d.start,face:it(d,t.start+E-d.start,[W,z,S,A],_,F),map:N?.source??null,matte:y&&(t.mask||t.person)?y.matteCanvas(t,E,j,!1,o):null});N?.close?.(),f?.close(),i?.close(),await s.push("titleFrames",a.id,await mt(J))}p&&await p.return(void 0)}}finally{I.dispose();for(const t of R.values())t.close();for(const t of C)t.dispose?.()}return{clips:w,tracks:K}}export{kt as distortForServer};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{jg as Q,c1 as J,jh as Z,dQ as ee,ji as re,jj as p}from"./titleFrameBudget-h4nOQ5u9.js";const te=`#version 300 es
|
|
2
|
+
in vec4 a;uniform vec4 crop;out vec2 uv;out vec2 tc;
|
|
3
|
+
void main(){tc=a.zw;uv=crop.xy+a.zw*crop.zw;gl_Position=vec4(a.x*2.-1.,a.y*2.-1.,0,1);}`,ne=`#version 300 es
|
|
4
|
+
precision highp float;in vec2 uv;in vec2 tc;uniform sampler2D src;uniform sampler2D matte;uniform float useMatte;out vec4 o;
|
|
5
|
+
void main(){vec4 c=texture(src,uv);if(useMatte>.5)c.a*=texture(matte,tc).r;o=vec4(c.rgb*c.a,c.a);}`,ae=`#version 300 es
|
|
6
|
+
in vec2 p;out vec2 uv;void main(){uv=p;gl_Position=vec4(p.x*2.-1.,1.-p.y*2.,0,1);}`,oe=`#version 300 es
|
|
7
|
+
precision highp float;in vec2 uv;uniform sampler2D pic;uniform sampler2D liq;uniform float useLiq;uniform sampler2D map;uniform float useMap;
|
|
8
|
+
uniform vec2 amount;uniform float rg;uniform vec4 mapRect;uniform int nb;uniform vec4 bul[${p.bulges}];uniform int nd;uniform vec4 dropA[${p.drops}];uniform vec4 dropB[${p.drops}];uniform vec2 fsz;out vec4 o;
|
|
9
|
+
vec2 face(vec2 s){vec2 p=s*fsz;
|
|
10
|
+
for(int i=0;i<${p.drops};i++){if(i>=nd)break;vec2 d=p-dropA[i].xy*fsz,n=dropA[i].zw;float a=dot(d,n),b=-d.x*n.y+d.y*n.x;vec4 B=dropB[i];
|
|
11
|
+
if(abs(b)>=B.x||a<=0.)continue;float w=1.-smoothstep(.55*B.x,B.x,abs(b));float src=a<B.y+B.z?a*B.y/(B.y+B.z):a-B.z*max(0.,1.-(a-(B.y+B.z))/B.w);p+=(src-a)*w*n;}
|
|
12
|
+
for(int i=0;i<${p.bulges};i++){if(i>=nb)break;vec2 c=bul[i].xy*fsz,d=p-c;float r=length(d),R=bul[i].z;if(r>=R)continue;float q=1.-(r/R)*(r/R);p=c+d*(1.-bul[i].w*q*q);}
|
|
13
|
+
return p/fsz;}
|
|
14
|
+
void main(){vec2 s=uv;if(nb>0||nd>0)s=face(s);if(useLiq>.5)s+=texture(liq,uv).rg;
|
|
15
|
+
vec2 mu=(uv-mapRect.xy)/(mapRect.zw-mapRect.xy);
|
|
16
|
+
if(useMap>.5&&all(greaterThanEqual(mu,vec2(0)))&&all(lessThanEqual(mu,vec2(1)))){vec4 m=texture(map,mu);float l=dot(m.rgb,vec3(.2126,.7152,.0722));vec2 v=rg>.5?m.rg:vec2(l);s+=(v-.5)*2.*amount;}
|
|
17
|
+
if(any(lessThan(s,vec2(0)))||any(greaterThan(s,vec2(1)))){o=vec4(0);return;}
|
|
18
|
+
o=texture(pic,s);}`;function ie(){const r=typeof document<"u"?document.createElement("canvas"):new OffscreenCanvas(2,2),e=r.getContext("webgl2",{premultipliedAlpha:!0,preserveDrawingBuffer:!0,alpha:!0,antialias:!1});if(!e)throw Error("WebGL2 unavailable");const a=(t,s)=>{const n=e.createProgram();for(const[A,b]of[[e.VERTEX_SHADER,t],[e.FRAGMENT_SHADER,s]]){const c=e.createShader(A);if(e.shaderSource(c,b),e.compileShader(c),!e.getShaderParameter(c,e.COMPILE_STATUS))throw Error(e.getShaderInfoLog(c)||"shader");e.attachShader(n,c)}if(e.linkProgram(n),!e.getProgramParameter(n,e.LINK_STATUS))throw Error(e.getProgramInfoLog(n)||"link");return n},o=a(te,ne),l=a(ae,oe),d=()=>{const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);for(const[s,n]of[[e.TEXTURE_MIN_FILTER,e.LINEAR],[e.TEXTURE_MAG_FILTER,e.LINEAR],[e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE],[e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE]])e.texParameteri(e.TEXTURE_2D,s,n);return t},L=d(),D=d(),S=d(),_=d(),w=d(),G=e.createFramebuffer();let N="",C="";const i=re,v=new Float32Array((i+1)*(i+1)*4),M=new Uint16Array(i*i*6);for(let t=0,s=0;t<i;t++)for(let n=0;n<i;n++){const A=t*(i+1)+n,b=A+1,c=A+i+1,x=c+1;M.set([A,b,c,b,x,c],s),s+=6}const X=e.createVertexArray(),z=e.createBuffer(),j=e.createBuffer();e.bindVertexArray(X),e.bindBuffer(e.ARRAY_BUFFER,z),e.bufferData(e.ARRAY_BUFFER,v.byteLength,e.DYNAMIC_DRAW),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,j),e.bufferData(e.ELEMENT_ARRAY_BUFFER,M,e.STATIC_DRAW);const O=e.getAttribLocation(o,"a");e.enableVertexAttribArray(O),e.vertexAttribPointer(O,4,e.FLOAT,!1,16,0);const q=e.createVertexArray(),H=e.createBuffer();e.bindVertexArray(q),e.bindBuffer(e.ARRAY_BUFFER,H),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW);const V=e.getAttribLocation(l,"p");e.enableVertexAttribArray(V),e.vertexAttribPointer(V,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const I=(t,s,n)=>{e.activeTexture(e.TEXTURE0+t),e.bindTexture(e.TEXTURE_2D,s),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL,!1),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n)};return{canvas:r,render(t){const s=Math.max(1,Math.round(t.outW)),n=Math.max(1,Math.round(t.outH));(r.width!==s||r.height!==n)&&(r.width=s,r.height=n),N!==`${s}x${n}`&&(e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_2D,w),e.texImage2D(e.TEXTURE_2D,0,e.RGBA8,s,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.bindFramebuffer(e.FRAMEBUFFER,G),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,w,0),N=`${s}x${n}`);const[A,b,c,x]=t.rect,K=c/Math.max(1,x),F=Q(t.distort,t.local,K,i);for(let f=0;f<=i;f++)for(let T=0;T<=i;T++){const m=f*(i+1)+T;v[m*4]=F?F[m*2]:T/i,v[m*4+1]=F?F[m*2+1]:f/i,v[m*4+2]=T/i,v[m*4+3]=f/i}I(0,L,t.source),t.matte&&I(1,D,t.matte),e.bindFramebuffer(e.FRAMEBUFFER,G),e.viewport(0,0,s,n),e.disable(e.BLEND),e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(o),e.bindVertexArray(X),e.bindBuffer(e.ARRAY_BUFFER,z),e.bufferSubData(e.ARRAY_BUFFER,0,v),e.uniform4f(e.getUniformLocation(o,"crop"),A/t.srcW,b/t.srcH,c/t.srcW,x/t.srcH),e.uniform1i(e.getUniformLocation(o,"src"),0),e.uniform1i(e.getUniformLocation(o,"matte"),1),e.uniform1f(e.getUniformLocation(o,"useMatte"),t.matte?1:0),e.drawElements(e.TRIANGLES,M.length,e.UNSIGNED_SHORT,0);const E=t.distort.liquify,g=t.distort.displace;if(E&&C!==E.f){const f=atob(E.f),T=new Float32Array(E.n*E.n*2);for(let m=0;m<T.length;m++){const P=f.charCodeAt(m);T[m]=(P>127?P-256:P)*.25/127}e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,_),e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG16F,E.n,E.n,0,e.RG,e.FLOAT,T),e.pixelStorei(e.UNPACK_ALIGNMENT,4),C=E.f}const h=g?J(g,t.local):{x:0,y:0},W=!!(g&&t.map&&(h.x||h.y));W&&I(3,S,t.map),e.bindFramebuffer(e.FRAMEBUFFER,null),e.viewport(0,0,s,n),e.clear(e.COLOR_BUFFER_BIT),e.useProgram(l),e.bindVertexArray(q),e.activeTexture(e.TEXTURE4),e.bindTexture(e.TEXTURE_2D,w),e.activeTexture(e.TEXTURE2),e.bindTexture(e.TEXTURE_2D,_);const u=f=>e.getUniformLocation(l,f);e.uniform1i(u("pic"),4),e.uniform1i(u("liq"),2),e.uniform1i(u("map"),3),e.uniform1f(u("useLiq"),E?1:0),e.uniform1f(u("useMap"),W?1:0),e.uniform2f(u("amount"),h.x/Math.max(1,c),h.y/Math.max(1,x)),e.uniform1f(u("rg"),g?.channel==="rg"?1:0);const y=g?.rect??[0,0,1,1];e.uniform4f(u("mapRect"),y[0],y[1],y[2],y[3]);const R=t.face,k=R?.bulges.length??0,Y=R?.drops.length??0;return e.uniform1i(u("nb"),k),e.uniform1i(u("nd"),Y),R&&(e.uniform2f(u("fsz"),R.size[0],R.size[1]),k&&e.uniform4fv(u("bul"),new Float32Array(R.bulges.flat())),Y&&(e.uniform4fv(u("dropA"),new Float32Array(R.drops.flatMap(f=>f.slice(0,4)))),e.uniform4fv(u("dropB"),new Float32Array(R.drops.flatMap(f=>f.slice(4,8)))))),e.drawArrays(e.TRIANGLE_STRIP,0,4),e.bindVertexArray(null),r},dispose(){e.getExtension("WEBGL_lose_context")?.loseContext()}}}function se(r,e,a,o,l){const d=r.distort?.face;return d?.length?Z(d,ee(r,e),e,a,o,l):null}let B=null;const $=new Set;function ce(r,e,a,o,l,d,L,D,S){if(B===!1||!r.distort)return null;try{B??=ie()}catch{return B=!1,null}try{return B.render({source:e,srcW:a,srcH:o,rect:l,outW:D,outH:S,distort:r.distort,local:d,map:L,face:se(r,d,l,a,o)})}catch(_){return $.has(r.id)||($.add(r.id),console.warn("[distort] preview skipped",r.id,_.message)),null}}const U=new Map;function fe(r,e){if(!r||r.disabled||e<r.start||e>=r.start+r.duration)return null;if(r.kind==="video"){const a=document.querySelector(`video[data-clip-media="${CSS.escape(r.id)}"]`);if(a&&a.readyState>=2)return a;let o=U.get(r.url);o||(o=Object.assign(document.createElement("video"),{muted:!0,playsInline:!0,preload:"auto",crossOrigin:"anonymous",src:r.url}),U.set(r.url,o));const l=(r.inPoint||0)+(e-r.start)*(r.playbackRate||1);return Math.abs(o.currentTime-l)>.04&&!o.seeking&&(o.currentTime=l),o.readyState>=2?o:null}if(r.kind==="image"&&r.url){let a=U.get(r.url);return a||(a=new Image,r.url.startsWith("data:")||(a.crossOrigin="anonymous"),a.src=r.url,U.set(r.url,a)),a.complete&&a.naturalWidth?a:null}return null}export{ie as c,ce as d,se as f,fe as m};
|