@aixcut/vibevideo 0.1.0-beta.0 → 0.1.0-beta.1
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/README.md +35 -5
- package/dist/skills/vibevideo/SKILL.md +75 -0
- package/dist/skills/vibevideo/assets/pixi/01-kinetic-title.mjs +76 -0
- package/dist/skills/vibevideo/assets/pixi/02-flow-map.mjs +76 -0
- package/dist/skills/vibevideo/assets/pixi/03-nested-board.mjs +69 -0
- package/dist/skills/vibevideo/assets/pixi/04-compact-callout.mjs +40 -0
- package/dist/skills/vibevideo/assets/pixi/README.md +11 -0
- package/dist/skills/vibevideo/references/authoring.md +160 -0
- package/dist/skills/vibevideo/references/editing-and-reload.md +99 -0
- package/dist/skills/vibevideo/references/editor-connection.md +44 -0
- package/dist/skills/vibevideo/references/examples.md +230 -0
- package/dist/skills/vibevideo/references/graphic-workflow.md +167 -0
- package/dist/skills/vibevideo/references/hevc-encoder.md +12 -0
- package/dist/skills/vibevideo/references/runtime-api.md +211 -0
- package/dist/skills/vibevideo/references/validation.md +109 -0
- package/dist/skills/vibevideo-cli/SKILL.md +86 -0
- package/dist/skills/vibevideo-cli/references/agent-protocol.md +39 -0
- package/dist/skills-manifest.json +14 -0
- package/dist/studio/assets/{browserAll-wERvpUP9.js → browserAll-0i6gm1iO.js} +1 -1
- package/dist/studio/assets/{index-bnkX1rLy.js → index-DqX5Prpj.js} +3 -3
- package/dist/studio/assets/{prores-encoder-mediabunny-hm5PQfLy.js → prores-encoder-mediabunny-DjdaA3bm.js} +2 -2
- package/dist/studio/assets/{webworkerAll-Baf-n-Bc.js → webworkerAll-Xo9FRLTy.js} +1 -1
- package/dist/studio/index.html +1 -1
- package/package.json +1 -1
- package/src/cli.mjs +30 -3
- package/src/skills.mjs +110 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/browserAll-0i6gm1iO.js","assets/webworkerAll-Xo9FRLTy.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var Rq=Object.defineProperty;var Bq=(t,e,n)=>e in t?Rq(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ct=(t,e,n)=>Bq(t,typeof e!="symbol"?e+"":e,n);function Fq(t,e){for(var n=0;n<e.length;n++){const r=e[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in t)){const a=Object.getOwnPropertyDescriptor(r,i);a&&Object.defineProperty(t,i,a.get?a:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const a of i)if(a.type==="childList")for(const s of a.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(i){const a={};return i.integrity&&(a.integrity=i.integrity),i.referrerPolicy&&(a.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?a.credentials="include":i.crossOrigin==="anonymous"?a.credentials="omit":a.credentials="same-origin",a}function r(i){if(i.ep)return;i.ep=!0;const a=n(i);fetch(i.href,a)}})();const zq="modulepreload",Lq=function(t){return"/"+t},A5={},Af=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const s=document.querySelector("meta[property=csp-nonce]"),o=(s==null?void 0:s.nonce)||(s==null?void 0:s.getAttribute("nonce"));i=Promise.allSettled(n.map(c=>{if(c=Lq(c),c in A5)return;A5[c]=!0;const l=c.endsWith(".css"),d=l?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const u=document.createElement("link");if(u.rel=l?"stylesheet":zq,l||(u.as="script"),u.crossOrigin="",u.href=c,o&&u.setAttribute("nonce",o),document.head.appendChild(u),l)return new Promise((h,f)=>{u.addEventListener("load",h),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${c}`)))})}))}function a(s){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s}return i.then(s=>{for(const o of s||[])o.status==="rejected"&&a(o.reason);return e().catch(a)})};function D1(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var $R={exports:{}},vw={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -380,7 +380,7 @@ Error generating stack: `+r.message+`
|
|
|
380
380
|
*
|
|
381
381
|
* This source code is licensed under the MIT license found in the
|
|
382
382
|
* LICENSE file in the root directory of this source tree.
|
|
383
|
-
*/var qp=I;function yQ(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var bQ=typeof Object.is=="function"?Object.is:yQ,xQ=qp.useState,vQ=qp.useEffect,wQ=qp.useLayoutEffect,TQ=qp.useDebugValue;function kQ(t,e){var n=e(),r=xQ({inst:{value:n,getSnapshot:e}}),i=r[0].inst,a=r[1];return wQ(function(){i.value=n,i.getSnapshot=e,_T(i)&&a({inst:i})},[t,n,e]),vQ(function(){return _T(i)&&a({inst:i}),t(function(){_T(i)&&a({inst:i})})},[t]),TQ(n),n}function _T(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!bQ(t,n)}catch{return!0}}function SQ(t,e){return e()}var CQ=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?SQ:kQ;F9.useSyncExternalStore=qp.useSyncExternalStore!==void 0?qp.useSyncExternalStore:CQ;B9.exports=F9;var EQ=B9.exports;const MQ=(t,e)=>{if(vf(e))return e;if(aQ(e)&&vf(e.defaultValue))return e.defaultValue;if(typeof t=="function")return"";if(Array.isArray(t)){const n=t[t.length-1];return typeof n=="function"?"":n}return t},AQ={t:MQ,ready:!1},IQ=()=>()=>{},to=(t,e={})=>{var C,M,A;const{i18n:n}=e,{i18n:r,defaultNS:i}=I.useContext(mQ)||{},a=n||r||hQ();a&&!a.reportNamespaces&&(a.reportNamespaces=new gQ),a||UC(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=I.useMemo(()=>{var D;return{...dQ(),...(D=a==null?void 0:a.options)==null?void 0:D.react,...e}},[a,e]),{useSuspense:o,keyPrefix:c}=s,l=i||((C=a==null?void 0:a.options)==null?void 0:C.defaultNS),d=vf(l)?[l]:l||["translation"],u=I.useMemo(()=>d,d);(A=(M=a==null?void 0:a.reportNamespaces)==null?void 0:M.addUsedNamespaces)==null||A.call(M,u);const h=I.useRef(0),f=I.useCallback(D=>{if(!a)return IQ;const{bindI18n:F,bindI18nStore:O}=s,V=()=>{h.current+=1,D()};return F&&a.on(F,V),O&&a.store.on(O,V),()=>{F&&F.split(" ").forEach(N=>a.off(N,V)),O&&O.split(" ").forEach(N=>a.store.off(N,V))}},[a,s]),p=I.useRef(),m=I.useCallback(()=>{if(!a)return AQ;const D=!!(a.isInitialized||a.initializedStoreOnce)&&u.every(j=>iQ(j,a,s)),F=e.lng||a.language,O=h.current,V=p.current;if(V&&V.ready===D&&V.lng===F&&V.keyPrefix===c&&V.revision===O)return V;const Y={t:a.getFixedT(F,s.nsMode==="fallback"?u:u[0],c),ready:D,lng:F,keyPrefix:c,revision:O};return p.current=Y,Y},[a,u,c,s,e.lng]),[y,g]=I.useState(0),{t:b,ready:x}=EQ.useSyncExternalStore(f,m,m);I.useEffect(()=>{if(a&&!x&&!o){const D=()=>g(F=>F+1);e.lng?LD(a,e.lng,u,D):HC(a,u,D)}},[a,e.lng,u,x,o,y]);const v=a||{},w=I.useRef(null),T=I.useRef(),S=D=>{const F=Object.getOwnPropertyDescriptors(D);F.__original&&delete F.__original;const O=Object.create(Object.getPrototypeOf(D),F);if(!Object.prototype.hasOwnProperty.call(O,"__original"))try{Object.defineProperty(O,"__original",{value:D,writable:!1,enumerable:!1,configurable:!1})}catch{}return O},k=I.useMemo(()=>{const D=v,F=D==null?void 0:D.language;let O=D;D&&(w.current&&w.current.__original===D?T.current!==F?(O=S(D),w.current=O,T.current=F):O=w.current:(O=S(D),w.current=O,T.current=F));const V=!x&&!o?(...Y)=>(UC(a,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),b(...Y)):b,N=[V,O,x];return N.t=V,N.i18n=O,N.ready=x,N},[b,v,x,v.resolvedLanguage,v.language,v.languages]);if(a&&o&&!x)throw new Promise(D=>{const F=()=>D();e.lng?LD(a,e.lng,u,F):HC(a,u,F)});return k};function DQ(){let t=!1,e=Promise.resolve();return{render(n){const r=e.then(async()=>{if(t)throw new Error("aixcut-render/disposed");PQ(n);const i=n.target.getContext("2d");if(!i)throw new Error("aixcut-render/canvas-context-unavailable");n.target.width=n.outputWidth,n.target.height=n.outputHeight,n.transparentBackground?i.clearRect(0,0,n.outputWidth,n.outputHeight):(i.fillStyle="#000000",i.fillRect(0,0,n.outputWidth,n.outputHeight));const a=n.outputWidth/n.width,s=n.outputHeight/n.height;i.setTransform(a,0,0,s,0,0);const o=[];for(const c of n.clips){if(_D(n.signal),c.enabled===!1||n.timeUs<c.startUs||n.timeUs>=c.startUs+c.durationUs)continue;const l=await n.prepareLayer(c,{timeUs:n.timeUs,scaleX:a,scaleY:s,signal:n.signal});if(_D(n.signal),!!l){if(!l.source&&!l.floatFrame)throw new Error(`aixcut-render/frame-unavailable:${c.id}`);if(n.linearOutput&&l.floatFrame)jD(n.linearOutput,n.outputWidth,n.outputHeight,l.floatFrame,l.projection,l.sourceWidth,l.sourceHeight,a,s,l.opacity,l.blendMode);else if(n.linearOutput&&l.source){const d=document.createElement("canvas");d.width=Math.max(1,Math.ceil(l.sourceWidth*l.sourceScaleX)),d.height=Math.max(1,Math.ceil(l.sourceHeight*l.sourceScaleY));const u=d.getContext("2d",{colorSpace:"display-p3",colorType:"float16"});if(!u)throw new Error("aixcut-render/high-precision-canvas-unavailable");u.drawImage(l.source,0,0,d.width,d.height);const h=RQ(d);jD(n.linearOutput,n.outputWidth,n.outputHeight,h,l.projection,l.sourceWidth,l.sourceHeight,a,s,l.opacity,l.blendMode),d.width=d.height=1}else l.source&&NQ(i,l);o.push(l.value)}}return{canvas:n.target,timeUs:n.timeUs,layers:o}});return e=r.then(()=>{},()=>{}),r},dispose(){t=!0}}}function PQ(t){if(!Number.isSafeInteger(t.timeUs))throw new Error("aixcut-render/invalid-time");for(const[e,n]of Object.entries({width:t.width,height:t.height,outputWidth:t.outputWidth,outputHeight:t.outputHeight}))if(!Number.isSafeInteger(n)||n<=0)throw new Error(`aixcut-render/invalid-${e}`)}function _D(t){if(t!=null&&t.aborted)throw t.reason??new DOMException("Aborted","AbortError")}function NQ(t,e){const{renderRect:n,anchorPoint:r,rotation:i}=e.projection;t.save();try{t.globalAlpha=Math.max(0,Math.min(1,e.opacity)),t.globalCompositeOperation=e.blendMode==="normal"?"source-over":e.blendMode,t.translate(r.x,r.y),t.rotate(i*Math.PI/180),t.drawImage(e.source,n.sx*e.sourceScaleX,n.sy*e.sourceScaleY,n.sw*e.sourceScaleX,n.sh*e.sourceScaleY,n.dx-r.x,n.dy-r.y,n.dw,n.dh)}finally{t.restore(),typeof ImageBitmap<"u"&&e.source instanceof ImageBitmap&&e.source.close()}}let jT,UT;function OQ(){if(jT&&UT)return{half:jT,halfLinear:UT};const t=new Float32Array(65536),e=new Float32Array(65536);for(let n=0;n<t.length;n++){const r=n>>10&31,i=n&1023,a=r===31?0:(n&32768?-1:1)*(r?(1+i/1024)*2**(r-15):i*2**-24);t[n]=a,e[n]=BQ(a)}return jT=t,UT=e,{half:t,halfLinear:e}}function jD(t,e,n,r,i,a,s,o,c,l,d){const u=i.renderRect;if(!u.dw||!u.dh||!u.sw||!u.sh||l<=0)return;const h=new Uint16Array(r.pixels),{half:f,halfLinear:p}=OQ(),m=i.rotation*Math.PI/180,y=Math.cos(m),g=Math.sin(m),b=i.anchorPoint,x=[[u.dx,u.dy],[u.dx+u.dw,u.dy],[u.dx+u.dw,u.dy+u.dh],[u.dx,u.dy+u.dh]].map(([k,C])=>({x:(b.x+y*(k-b.x)-g*(C-b.y))*o,y:(b.y+g*(k-b.x)+y*(C-b.y))*c})),v=Math.max(0,Math.floor(Math.min(...x.map(k=>k.x)))),w=Math.max(0,Math.floor(Math.min(...x.map(k=>k.y)))),T=Math.min(e,Math.ceil(Math.max(...x.map(k=>k.x)))),S=Math.min(n,Math.ceil(Math.max(...x.map(k=>k.y))));for(let k=w;k<S;k++)for(let C=v;C<T;C++){const M=(C+.5)/o-b.x,A=(k+.5)/c-b.y,D=(y*M+g*A+b.x-u.dx)/u.dw,F=(-g*M+y*A+b.y-u.dy)/u.dh;if(D<0||D>=1||F<0||F>=1)continue;const O=(u.sx+D*u.sw)*r.width/a-.5,V=(u.sy+F*u.sh)*r.height/s-.5,N=Math.floor(O),Y=Math.floor(V),j=O-N,J=V-Y;let ee=0,ue=0,Q=0,z=0;for(let pe=0;pe<2;pe++)for(let Me=0;Me<2;Me++){const Se=(Math.max(0,Math.min(r.height-1,Y+pe))*r.width+Math.max(0,Math.min(r.width-1,N+Me)))*4,_=(Me?j:1-j)*(pe?J:1-J)*UD(f[h[Se+3]]);ee+=_,ue+=p[h[Se]]*_,Q+=p[h[Se+1]]*_,z+=p[h[Se+2]]*_}if(ee<=0)continue;const G=(k*e+C)*4,K=ee*UD(l);t[G]+=K*(HT(t[G],ue/ee,d)-t[G]),t[G+1]+=K*(HT(t[G+1],Q/ee,d)-t[G+1]),t[G+2]+=K*(HT(t[G+2],z/ee,d)-t[G+2])}}function RQ(t){const e=t.getContext("2d",{colorSpace:"display-p3",colorType:"float16"});if(!e)throw new Error("aixcut-render/high-precision-canvas-unavailable");const n=e.getImageData(0,0,t.width,t.height,{colorSpace:"display-p3",pixelFormat:"rgba-float16"});if(n.data.BYTES_PER_ELEMENT!==2)throw new Error("aixcut-render/float16-readback-unavailable");return{width:t.width,height:t.height,pixels:n.data.buffer}}function BQ(t){return Math.abs(t)<=.04045?t/12.92:Math.sign(t)*Math.pow((Math.abs(t)+.055)/1.055,2.4)}function HT(t,e,n){switch(n){case"multiply":return t*e;case"screen":return t+e-t*e;case"overlay":return t<=.5?2*t*e:1-2*(1-t)*(1-e);case"darken":return Math.min(t,e);case"lighten":return Math.max(t,e);case"color-dodge":return t===0?0:e>=1?1:Math.min(1,t/(1-e));case"color-burn":return t>=1?1:e<=0?0:1-Math.min(1,(1-t)/e);case"hard-light":return e<=.5?2*t*e:1-2*(1-t)*(1-e);case"soft-light":return e<=.5?t-(1-2*e)*t*(1-t):t+(2*e-1)*((t<=.25?((16*t-12)*t+4)*t:Math.sqrt(t))-t);case"difference":return Math.abs(t-e);case"exclusion":return t+e-2*t*e;default:return e}}const UD=t=>Math.max(0,Math.min(1,t)),FQ=[{pattern:/Date\.now\s*\(/,message:"页面不能用 Date.now() 当主时钟"},{pattern:/requestAnimationFrame\s*\(/,message:"页面不能自己启动 requestAnimationFrame"},{pattern:/\.setAnimationLoop\s*\(/,message:"页面不能自己启动 Three.js 动画循环"}];function z9(t){return FQ.filter(e=>e.pattern.test(t)).map(e=>e.message)}function zQ(t,e){var r,i;let n=e;if(/\.html?$/i.test(t)){const s=[...e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)].filter(([,o])=>/\btype\s*=\s*(['"])module\1/i.test(o??""));if(s.length!==1)throw new Error("HTML 文件需要且只能包含一个内联 module 脚本。");if(/\bsrc\s*=\s*(['"])[^'"]+\1/i.test(((r=s[0])==null?void 0:r[1])??""))throw new Error("动态图形 module 必须内联在 HTML 文件中。");n=((i=s[0])==null?void 0:i[2])??""}else if(!/\.(?:m?js)$/i.test(t))throw new Error("仅支持 HTML、JavaScript、视频和图片文件。");if(!LQ(n))throw new Error("动态图形 module 必须导出 mount。");return n.trim()}function LQ(t){return/\bexport\s+default\s+(?:async\s+)?function\b|\bexport\s+default\s+[A-Za-z_$][\w$]*\s*;?/m.test(t)||/\bexport\s+default\s+(?:async\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/m.test(t)||/\bexport\s+(?:async\s+)?function\s+mount\s*\(/m.test(t)||/\bexport\s*\{[^}]*\bmount\s+as\s+default\b[^}]*\}/m.test(t)}var ba=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGLLoader="webgl-loader",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.WebGPULoader="webgpu-loader",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.CanvasLoader="canvas-loader",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.TextureUploaderWebGL="texture-uploader-webgl",t.TextureUploaderWebGPU="texture-uploader-webgpu",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(ba||{});const GC=t=>{if(typeof t=="function"||typeof t=="object"&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={...typeof t.extension!="object"?{type:t.extension}:t.extension,ref:t}}if(typeof t=="object")t={...t};else throw new Error("Invalid extension type");return typeof t.type=="string"&&(t.type=[t.type]),t},Xy=(t,e)=>GC(t).priority??e,Rf={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(GC).forEach(e=>{e.type.forEach(n=>{var r,i;return(i=(r=this._removeHandlers)[n])==null?void 0:i.call(r,e)})}),this},add(...t){return t.map(GC).forEach(e=>{e.type.forEach(n=>{var a,s;const r=this._addHandlers,i=this._queue;r[n]?(s=r[n])==null||s.call(r,e):(i[n]=i[n]||[],(a=i[n])==null||a.push(e))})}),this},handle(t,e,n){var s;const r=this._addHandlers,i=this._removeHandlers;if(r[t]||i[t])throw new Error(`Extension type ${t} already has a handler`);r[t]=e,i[t]=n;const a=this._queue;return a[t]&&((s=a[t])==null||s.forEach(o=>e(o)),delete a[t]),this},handleByMap(t,e){return this.handle(t,n=>{n.name&&(e[n.name]=n.ref)},n=>{n.name&&delete e[n.name]})},handleByNamedList(t,e,n=-1){return this.handle(t,r=>{e.findIndex(a=>a.name===r.name)>=0||(e.push({name:r.name,value:r.ref}),e.sort((a,s)=>Xy(s.value,n)-Xy(a.value,n)))},r=>{const i=e.findIndex(a=>a.name===r.name);i!==-1&&e.splice(i,1)})},handleByList(t,e,n=-1){return this.handle(t,r=>{e.includes(r.ref)||(e.push(r.ref),e.sort((i,a)=>Xy(a,n)-Xy(i,n)))},r=>{const i=e.indexOf(r.ref);i!==-1&&e.splice(i,1)})},mixin(t,...e){for(const n of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(n))}},_Q={extension:{type:ba.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Af(()=>import("./browserAll-wERvpUP9.js"),__vite__mapDeps([0,1]))}},jQ={extension:{type:ba.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Af(()=>import("./webworkerAll-Baf-n-Bc.js"),[])}};class Yi{constructor(e,n,r){this._x=n||0,this._y=r||0,this._observer=e}clone(e){return new Yi(e??this._observer,this._x,this._y)}set(e=0,n=e){return(this._x!==e||this._y!==n)&&(this._x=e,this._y=n,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}var L9={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,l,d){this.fn=c,this.context=l,this.once=d||!1}function a(c,l,d,u,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new i(d,u||c,h),p=n?n+l:l;return c._events[p]?c._events[p].fn?c._events[p]=[c._events[p],f]:c._events[p].push(f):(c._events[p]=f,c._eventsCount++),c}function s(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],d,u;if(this._eventsCount===0)return l;for(u in d=this._events)e.call(d,u)&&l.push(n?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},o.prototype.listeners=function(l){var d=n?n+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,p=new Array(f);h<f;h++)p[h]=u[h].fn;return p},o.prototype.listenerCount=function(l){var d=n?n+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,h,f,p){var m=n?n+l:l;if(!this._events[m])return!1;var y=this._events[m],g=arguments.length,b,x;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),g){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,u),!0;case 4:return y.fn.call(y.context,d,u,h),!0;case 5:return y.fn.call(y.context,d,u,h,f),!0;case 6:return y.fn.call(y.context,d,u,h,f,p),!0}for(x=1,b=new Array(g-1);x<g;x++)b[x-1]=arguments[x];y.fn.apply(y.context,b)}else{var v=y.length,w;for(x=0;x<v;x++)switch(y[x].once&&this.removeListener(l,y[x].fn,void 0,!0),g){case 1:y[x].fn.call(y[x].context);break;case 2:y[x].fn.call(y[x].context,d);break;case 3:y[x].fn.call(y[x].context,d,u);break;case 4:y[x].fn.call(y[x].context,d,u,h);break;default:if(!b)for(w=1,b=new Array(g-1);w<g;w++)b[w-1]=arguments[w];y[x].fn.apply(y[x].context,b)}}return!0},o.prototype.on=function(l,d,u){return a(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return a(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,h){var f=n?n+l:l;if(!this._events[f])return this;if(!d)return s(this,f),this;var p=this._events[f];if(p.fn)p.fn===d&&(!h||p.once)&&(!u||p.context===u)&&s(this,f);else{for(var m=0,y=[],g=p.length;m<g;m++)(p[m].fn!==d||h&&!p[m].once||u&&p[m].context!==u)&&y.push(p[m]);y.length?this._events[f]=y.length===1?y[0]:y:s(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=n?n+l:l,this._events[d]&&s(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(L9);var UQ=L9.exports;const G1=D1(UQ),HQ=Math.PI*2,VQ=180/Math.PI,GQ=Math.PI/180;class rc{constructor(e=0,n=0){this.x=0,this.y=0,this.x=e,this.y=n}clone(){return new rc(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,n=e){return this.x=e,this.y=n,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return VT.x=0,VT.y=0,VT}}const VT=new rc;class yr{constructor(e=1,n=0,r=0,i=1,a=0,s=0){this.array=null,this.a=e,this.b=n,this.c=r,this.d=i,this.tx=a,this.ty=s}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,n,r,i,a,s){return this.a=e,this.b=n,this.c=r,this.d=i,this.tx=a,this.ty=s,this}toArray(e,n){this.array||(this.array=new Float32Array(9));const r=n||this.array;return e?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(e,n){n=n||new rc;const r=e.x,i=e.y;return n.x=this.a*r+this.c*i+this.tx,n.y=this.b*r+this.d*i+this.ty,n}applyInverse(e,n){n=n||new rc;const r=this.a,i=this.b,a=this.c,s=this.d,o=this.tx,c=this.ty,l=1/(r*s+a*-i),d=e.x,u=e.y;return n.x=s*l*d+-a*l*u+(c*a-o*s)*l,n.y=r*l*u+-i*l*d+(-c*r+o*i)*l,n}translate(e,n){return this.tx+=e,this.ty+=n,this}scale(e,n){return this.a*=e,this.d*=n,this.c*=e,this.b*=n,this.tx*=e,this.ty*=n,this}rotate(e){const n=Math.cos(e),r=Math.sin(e),i=this.a,a=this.c,s=this.tx;return this.a=i*n-this.b*r,this.b=i*r+this.b*n,this.c=a*n-this.d*r,this.d=a*r+this.d*n,this.tx=s*n-this.ty*r,this.ty=s*r+this.ty*n,this}append(e){const n=this.a,r=this.b,i=this.c,a=this.d;return this.a=e.a*n+e.b*i,this.b=e.a*r+e.b*a,this.c=e.c*n+e.d*i,this.d=e.c*r+e.d*a,this.tx=e.tx*n+e.ty*i+this.tx,this.ty=e.tx*r+e.ty*a+this.ty,this}appendFrom(e,n){const r=e.a,i=e.b,a=e.c,s=e.d,o=e.tx,c=e.ty,l=n.a,d=n.b,u=n.c,h=n.d;return this.a=r*l+i*u,this.b=r*d+i*h,this.c=a*l+s*u,this.d=a*d+s*h,this.tx=o*l+c*u+n.tx,this.ty=o*d+c*h+n.ty,this}setTransform(e,n,r,i,a,s,o,c,l){return this.a=Math.cos(o+l)*a,this.b=Math.sin(o+l)*a,this.c=-Math.sin(o-c)*s,this.d=Math.cos(o-c)*s,this.tx=e-(r*this.a+i*this.c),this.ty=n-(r*this.b+i*this.d),this}prepend(e){const n=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const r=this.a,i=this.c;this.a=r*e.a+this.b*e.c,this.b=r*e.b+this.b*e.d,this.c=i*e.a+this.d*e.c,this.d=i*e.b+this.d*e.d}return this.tx=n*e.a+this.ty*e.c+e.tx,this.ty=n*e.b+this.ty*e.d+e.ty,this}decompose(e){const n=this.a,r=this.b,i=this.c,a=this.d,s=e.pivot,o=-Math.atan2(-i,a),c=Math.atan2(r,n),l=Math.abs(o+c);let d=Math.sqrt(n*n+r*r);return l<1e-5||Math.abs(HQ-l)<1e-5?(e.rotation=c,e.skew.x=e.skew.y=0):Math.abs(Math.PI-l)<1e-5?(e.rotation=c-Math.PI,e.skew.x=e.skew.y=0,d=-d):(e.rotation=0,e.skew.x=o,e.skew.y=c),e.scale.x=d,e.scale.y=Math.sqrt(i*i+a*a),e.position.x=this.tx+(s.x*n+s.y*i),e.position.y=this.ty+(s.x*r+s.y*a),e}invert(){const e=this.a,n=this.b,r=this.c,i=this.d,a=this.tx,s=e*i-n*r;return this.a=i/s,this.b=-n/s,this.c=-r/s,this.d=e/s,this.tx=(r*this.ty-i*a)/s,this.ty=-(e*this.ty-n*a)/s,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new yr;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return WQ.identity()}static get shared(){return qQ.identity()}}const qQ=new yr,WQ=new yr,Rd=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Bd=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Fd=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],zd=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],qC=[],_9=[],Yy=Math.sign;function XQ(){for(let t=0;t<16;t++){const e=[];qC.push(e);for(let n=0;n<16;n++){const r=Yy(Rd[t]*Rd[n]+Fd[t]*Bd[n]),i=Yy(Bd[t]*Rd[n]+zd[t]*Bd[n]),a=Yy(Rd[t]*Fd[n]+Fd[t]*zd[n]),s=Yy(Bd[t]*Fd[n]+zd[t]*zd[n]);for(let o=0;o<16;o++)if(Rd[o]===r&&Bd[o]===i&&Fd[o]===a&&zd[o]===s){e.push(o);break}}}for(let t=0;t<16;t++){const e=new yr;e.set(Rd[t],Bd[t],Fd[t],zd[t],0,0),_9.push(e)}}XQ();const jn={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>Rd[t],uY:t=>Bd[t],vX:t=>Fd[t],vY:t=>zd[t],inv:t=>t&8?t&15:-t&7,add:(t,e)=>qC[t][e],sub:(t,e)=>qC[t][jn.inv(e)],rotate180:t=>t^4,isVertical:t=>(t&3)===2,byDirection:(t,e)=>Math.abs(t)*2<=Math.abs(e)?e>=0?jn.S:jn.N:Math.abs(e)*2<=Math.abs(t)?t>0?jn.E:jn.W:e>0?t>0?jn.SE:jn.SW:t>0?jn.NE:jn.NW,matrixAppendRotationInv:(t,e,n=0,r=0,i=0,a=0)=>{const s=_9[jn.inv(e)],o=s.a,c=s.b,l=s.c,d=s.d,u=n-Math.min(0,o*i,l*a,o*i+l*a),h=r-Math.min(0,c*i,d*a,c*i+d*a),f=t.a,p=t.b,m=t.c,y=t.d;t.a=o*f+c*m,t.b=o*p+c*y,t.c=l*f+d*m,t.d=l*p+d*y,t.tx=u*f+h*m+t.tx,t.ty=u*p+h*y+t.ty},transformRectCoords:(t,e,n,r)=>{const{x:i,y:a,width:s,height:o}=t,{x:c,y:l,width:d,height:u}=e;return n===jn.E?(r.set(i+c,a+l,s,o),r):n===jn.S?r.set(d-a-o+c,i+l,o,s):n===jn.W?r.set(d-i-s+c,u-a-o+l,s,o):n===jn.N?r.set(a+c,u-i-s+l,o,s):r.set(i+c,a+l,s,o)}},Ky=[new rc,new rc,new rc,new rc];class ic{constructor(e=0,n=0,r=0,i=0){this.type="rectangle",this.x=Number(e),this.y=Number(n),this.width=Number(r),this.height=Number(i)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new ic(0,0,0,0)}clone(){return new ic(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,n){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&n>=this.y&&n<this.y+this.height}strokeContains(e,n,r,i=.5){const{width:a,height:s}=this;if(a<=0||s<=0)return!1;const o=this.x,c=this.y,l=r*(1-i),d=r-l,u=o-l,h=o+a+l,f=c-l,p=c+s+l,m=o+d,y=o+a-d,g=c+d,b=c+s-d;return e>=u&&e<=h&&n>=f&&n<=p&&!(e>m&&e<y&&n>g&&n<b)}intersects(e,n){if(!n){const k=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=k)return!1;const M=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>M}const r=this.left,i=this.right,a=this.top,s=this.bottom;if(i<=r||s<=a)return!1;const o=Ky[0].set(e.left,e.top),c=Ky[1].set(e.left,e.bottom),l=Ky[2].set(e.right,e.top),d=Ky[3].set(e.right,e.bottom);if(l.x<=o.x||c.y<=o.y)return!1;const u=Math.sign(n.a*n.d-n.b*n.c);if(u===0||(n.apply(o,o),n.apply(c,c),n.apply(l,l),n.apply(d,d),Math.max(o.x,c.x,l.x,d.x)<=r||Math.min(o.x,c.x,l.x,d.x)>=i||Math.max(o.y,c.y,l.y,d.y)<=a||Math.min(o.y,c.y,l.y,d.y)>=s))return!1;const h=u*(c.y-o.y),f=u*(o.x-c.x),p=h*r+f*a,m=h*i+f*a,y=h*r+f*s,g=h*i+f*s;if(Math.max(p,m,y,g)<=h*o.x+f*o.y||Math.min(p,m,y,g)>=h*d.x+f*d.y)return!1;const b=u*(o.y-l.y),x=u*(l.x-o.x),v=b*r+x*a,w=b*i+x*a,T=b*r+x*s,S=b*i+x*s;return!(Math.max(v,w,T,S)<=b*o.x+x*o.y||Math.min(v,w,T,S)>=b*d.x+x*d.y)}pad(e=0,n=e){return this.x-=e,this.y-=n,this.width+=e*2,this.height+=n*2,this}fit(e){const n=Math.max(this.x,e.x),r=Math.min(this.x+this.width,e.x+e.width),i=Math.max(this.y,e.y),a=Math.min(this.y+this.height,e.y+e.height);return this.x=n,this.width=Math.max(r-n,0),this.y=i,this.height=Math.max(a-i,0),this}ceil(e=1,n=.001){const r=Math.ceil((this.x+this.width-n)*e)/e,i=Math.ceil((this.y+this.height-n)*e)/e;return this.x=Math.floor((this.x+n)*e)/e,this.y=Math.floor((this.y+n)*e)/e,this.width=r-this.x,this.height=i-this.y,this}scale(e,n=e){return this.x*=e,this.y*=n,this.width*=e,this.height*=n,this}enlarge(e){const n=Math.min(this.x,e.x),r=Math.max(this.x+this.width,e.x+e.width),i=Math.min(this.y,e.y),a=Math.max(this.y+this.height,e.y+e.height);return this.x=n,this.width=r-n,this.y=i,this.height=a-i,this}getBounds(e){return e||(e=new ic),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const n=e.x,r=e.y,i=e.x+e.width,a=e.y+e.height;return n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height&&i>=this.x&&i<=this.x+this.width&&a>=this.y&&a<=this.y+this.height}set(e,n,r,i){return this.x=e,this.y=n,this.width=r,this.height=i,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const GT={default:-1};function gu(t="default"){return GT[t]===void 0&&(GT[t]=-1),++GT[t]}const HD=new Set,Wp="8.0.0",nh="8.21.0",YQ="8.22.0",Xh={quiet:!1,noColor:!1},Ci=(t,e,n=3)=>{if(Xh.quiet||HD.has(e))return;let r=new Error().stack;const i=`${e}
|
|
383
|
+
*/var qp=I;function yQ(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var bQ=typeof Object.is=="function"?Object.is:yQ,xQ=qp.useState,vQ=qp.useEffect,wQ=qp.useLayoutEffect,TQ=qp.useDebugValue;function kQ(t,e){var n=e(),r=xQ({inst:{value:n,getSnapshot:e}}),i=r[0].inst,a=r[1];return wQ(function(){i.value=n,i.getSnapshot=e,_T(i)&&a({inst:i})},[t,n,e]),vQ(function(){return _T(i)&&a({inst:i}),t(function(){_T(i)&&a({inst:i})})},[t]),TQ(n),n}function _T(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!bQ(t,n)}catch{return!0}}function SQ(t,e){return e()}var CQ=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?SQ:kQ;F9.useSyncExternalStore=qp.useSyncExternalStore!==void 0?qp.useSyncExternalStore:CQ;B9.exports=F9;var EQ=B9.exports;const MQ=(t,e)=>{if(vf(e))return e;if(aQ(e)&&vf(e.defaultValue))return e.defaultValue;if(typeof t=="function")return"";if(Array.isArray(t)){const n=t[t.length-1];return typeof n=="function"?"":n}return t},AQ={t:MQ,ready:!1},IQ=()=>()=>{},to=(t,e={})=>{var C,M,A;const{i18n:n}=e,{i18n:r,defaultNS:i}=I.useContext(mQ)||{},a=n||r||hQ();a&&!a.reportNamespaces&&(a.reportNamespaces=new gQ),a||UC(a,"NO_I18NEXT_INSTANCE","useTranslation: You will need to pass in an i18next instance by using initReactI18next");const s=I.useMemo(()=>{var D;return{...dQ(),...(D=a==null?void 0:a.options)==null?void 0:D.react,...e}},[a,e]),{useSuspense:o,keyPrefix:c}=s,l=i||((C=a==null?void 0:a.options)==null?void 0:C.defaultNS),d=vf(l)?[l]:l||["translation"],u=I.useMemo(()=>d,d);(A=(M=a==null?void 0:a.reportNamespaces)==null?void 0:M.addUsedNamespaces)==null||A.call(M,u);const h=I.useRef(0),f=I.useCallback(D=>{if(!a)return IQ;const{bindI18n:F,bindI18nStore:O}=s,V=()=>{h.current+=1,D()};return F&&a.on(F,V),O&&a.store.on(O,V),()=>{F&&F.split(" ").forEach(N=>a.off(N,V)),O&&O.split(" ").forEach(N=>a.store.off(N,V))}},[a,s]),p=I.useRef(),m=I.useCallback(()=>{if(!a)return AQ;const D=!!(a.isInitialized||a.initializedStoreOnce)&&u.every(j=>iQ(j,a,s)),F=e.lng||a.language,O=h.current,V=p.current;if(V&&V.ready===D&&V.lng===F&&V.keyPrefix===c&&V.revision===O)return V;const Y={t:a.getFixedT(F,s.nsMode==="fallback"?u:u[0],c),ready:D,lng:F,keyPrefix:c,revision:O};return p.current=Y,Y},[a,u,c,s,e.lng]),[y,g]=I.useState(0),{t:b,ready:x}=EQ.useSyncExternalStore(f,m,m);I.useEffect(()=>{if(a&&!x&&!o){const D=()=>g(F=>F+1);e.lng?LD(a,e.lng,u,D):HC(a,u,D)}},[a,e.lng,u,x,o,y]);const v=a||{},w=I.useRef(null),T=I.useRef(),S=D=>{const F=Object.getOwnPropertyDescriptors(D);F.__original&&delete F.__original;const O=Object.create(Object.getPrototypeOf(D),F);if(!Object.prototype.hasOwnProperty.call(O,"__original"))try{Object.defineProperty(O,"__original",{value:D,writable:!1,enumerable:!1,configurable:!1})}catch{}return O},k=I.useMemo(()=>{const D=v,F=D==null?void 0:D.language;let O=D;D&&(w.current&&w.current.__original===D?T.current!==F?(O=S(D),w.current=O,T.current=F):O=w.current:(O=S(D),w.current=O,T.current=F));const V=!x&&!o?(...Y)=>(UC(a,"USE_T_BEFORE_READY","useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t."),b(...Y)):b,N=[V,O,x];return N.t=V,N.i18n=O,N.ready=x,N},[b,v,x,v.resolvedLanguage,v.language,v.languages]);if(a&&o&&!x)throw new Promise(D=>{const F=()=>D();e.lng?LD(a,e.lng,u,F):HC(a,u,F)});return k};function DQ(){let t=!1,e=Promise.resolve();return{render(n){const r=e.then(async()=>{if(t)throw new Error("aixcut-render/disposed");PQ(n);const i=n.target.getContext("2d");if(!i)throw new Error("aixcut-render/canvas-context-unavailable");n.target.width=n.outputWidth,n.target.height=n.outputHeight,n.transparentBackground?i.clearRect(0,0,n.outputWidth,n.outputHeight):(i.fillStyle="#000000",i.fillRect(0,0,n.outputWidth,n.outputHeight));const a=n.outputWidth/n.width,s=n.outputHeight/n.height;i.setTransform(a,0,0,s,0,0);const o=[];for(const c of n.clips){if(_D(n.signal),c.enabled===!1||n.timeUs<c.startUs||n.timeUs>=c.startUs+c.durationUs)continue;const l=await n.prepareLayer(c,{timeUs:n.timeUs,scaleX:a,scaleY:s,signal:n.signal});if(_D(n.signal),!!l){if(!l.source&&!l.floatFrame)throw new Error(`aixcut-render/frame-unavailable:${c.id}`);if(n.linearOutput&&l.floatFrame)jD(n.linearOutput,n.outputWidth,n.outputHeight,l.floatFrame,l.projection,l.sourceWidth,l.sourceHeight,a,s,l.opacity,l.blendMode);else if(n.linearOutput&&l.source){const d=document.createElement("canvas");d.width=Math.max(1,Math.ceil(l.sourceWidth*l.sourceScaleX)),d.height=Math.max(1,Math.ceil(l.sourceHeight*l.sourceScaleY));const u=d.getContext("2d",{colorSpace:"display-p3",colorType:"float16"});if(!u)throw new Error("aixcut-render/high-precision-canvas-unavailable");u.drawImage(l.source,0,0,d.width,d.height);const h=RQ(d);jD(n.linearOutput,n.outputWidth,n.outputHeight,h,l.projection,l.sourceWidth,l.sourceHeight,a,s,l.opacity,l.blendMode),d.width=d.height=1}else l.source&&NQ(i,l);o.push(l.value)}}return{canvas:n.target,timeUs:n.timeUs,layers:o}});return e=r.then(()=>{},()=>{}),r},dispose(){t=!0}}}function PQ(t){if(!Number.isSafeInteger(t.timeUs))throw new Error("aixcut-render/invalid-time");for(const[e,n]of Object.entries({width:t.width,height:t.height,outputWidth:t.outputWidth,outputHeight:t.outputHeight}))if(!Number.isSafeInteger(n)||n<=0)throw new Error(`aixcut-render/invalid-${e}`)}function _D(t){if(t!=null&&t.aborted)throw t.reason??new DOMException("Aborted","AbortError")}function NQ(t,e){const{renderRect:n,anchorPoint:r,rotation:i}=e.projection;t.save();try{t.globalAlpha=Math.max(0,Math.min(1,e.opacity)),t.globalCompositeOperation=e.blendMode==="normal"?"source-over":e.blendMode,t.translate(r.x,r.y),t.rotate(i*Math.PI/180),t.drawImage(e.source,n.sx*e.sourceScaleX,n.sy*e.sourceScaleY,n.sw*e.sourceScaleX,n.sh*e.sourceScaleY,n.dx-r.x,n.dy-r.y,n.dw,n.dh)}finally{t.restore(),typeof ImageBitmap<"u"&&e.source instanceof ImageBitmap&&e.source.close()}}let jT,UT;function OQ(){if(jT&&UT)return{half:jT,halfLinear:UT};const t=new Float32Array(65536),e=new Float32Array(65536);for(let n=0;n<t.length;n++){const r=n>>10&31,i=n&1023,a=r===31?0:(n&32768?-1:1)*(r?(1+i/1024)*2**(r-15):i*2**-24);t[n]=a,e[n]=BQ(a)}return jT=t,UT=e,{half:t,halfLinear:e}}function jD(t,e,n,r,i,a,s,o,c,l,d){const u=i.renderRect;if(!u.dw||!u.dh||!u.sw||!u.sh||l<=0)return;const h=new Uint16Array(r.pixels),{half:f,halfLinear:p}=OQ(),m=i.rotation*Math.PI/180,y=Math.cos(m),g=Math.sin(m),b=i.anchorPoint,x=[[u.dx,u.dy],[u.dx+u.dw,u.dy],[u.dx+u.dw,u.dy+u.dh],[u.dx,u.dy+u.dh]].map(([k,C])=>({x:(b.x+y*(k-b.x)-g*(C-b.y))*o,y:(b.y+g*(k-b.x)+y*(C-b.y))*c})),v=Math.max(0,Math.floor(Math.min(...x.map(k=>k.x)))),w=Math.max(0,Math.floor(Math.min(...x.map(k=>k.y)))),T=Math.min(e,Math.ceil(Math.max(...x.map(k=>k.x)))),S=Math.min(n,Math.ceil(Math.max(...x.map(k=>k.y))));for(let k=w;k<S;k++)for(let C=v;C<T;C++){const M=(C+.5)/o-b.x,A=(k+.5)/c-b.y,D=(y*M+g*A+b.x-u.dx)/u.dw,F=(-g*M+y*A+b.y-u.dy)/u.dh;if(D<0||D>=1||F<0||F>=1)continue;const O=(u.sx+D*u.sw)*r.width/a-.5,V=(u.sy+F*u.sh)*r.height/s-.5,N=Math.floor(O),Y=Math.floor(V),j=O-N,J=V-Y;let ee=0,ue=0,Q=0,z=0;for(let pe=0;pe<2;pe++)for(let Me=0;Me<2;Me++){const Se=(Math.max(0,Math.min(r.height-1,Y+pe))*r.width+Math.max(0,Math.min(r.width-1,N+Me)))*4,_=(Me?j:1-j)*(pe?J:1-J)*UD(f[h[Se+3]]);ee+=_,ue+=p[h[Se]]*_,Q+=p[h[Se+1]]*_,z+=p[h[Se+2]]*_}if(ee<=0)continue;const G=(k*e+C)*4,K=ee*UD(l);t[G]+=K*(HT(t[G],ue/ee,d)-t[G]),t[G+1]+=K*(HT(t[G+1],Q/ee,d)-t[G+1]),t[G+2]+=K*(HT(t[G+2],z/ee,d)-t[G+2])}}function RQ(t){const e=t.getContext("2d",{colorSpace:"display-p3",colorType:"float16"});if(!e)throw new Error("aixcut-render/high-precision-canvas-unavailable");const n=e.getImageData(0,0,t.width,t.height,{colorSpace:"display-p3",pixelFormat:"rgba-float16"});if(n.data.BYTES_PER_ELEMENT!==2)throw new Error("aixcut-render/float16-readback-unavailable");return{width:t.width,height:t.height,pixels:n.data.buffer}}function BQ(t){return Math.abs(t)<=.04045?t/12.92:Math.sign(t)*Math.pow((Math.abs(t)+.055)/1.055,2.4)}function HT(t,e,n){switch(n){case"multiply":return t*e;case"screen":return t+e-t*e;case"overlay":return t<=.5?2*t*e:1-2*(1-t)*(1-e);case"darken":return Math.min(t,e);case"lighten":return Math.max(t,e);case"color-dodge":return t===0?0:e>=1?1:Math.min(1,t/(1-e));case"color-burn":return t>=1?1:e<=0?0:1-Math.min(1,(1-t)/e);case"hard-light":return e<=.5?2*t*e:1-2*(1-t)*(1-e);case"soft-light":return e<=.5?t-(1-2*e)*t*(1-t):t+(2*e-1)*((t<=.25?((16*t-12)*t+4)*t:Math.sqrt(t))-t);case"difference":return Math.abs(t-e);case"exclusion":return t+e-2*t*e;default:return e}}const UD=t=>Math.max(0,Math.min(1,t)),FQ=[{pattern:/Date\.now\s*\(/,message:"页面不能用 Date.now() 当主时钟"},{pattern:/requestAnimationFrame\s*\(/,message:"页面不能自己启动 requestAnimationFrame"},{pattern:/\.setAnimationLoop\s*\(/,message:"页面不能自己启动 Three.js 动画循环"}];function z9(t){return FQ.filter(e=>e.pattern.test(t)).map(e=>e.message)}function zQ(t,e){var r,i;let n=e;if(/\.html?$/i.test(t)){const s=[...e.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi)].filter(([,o])=>/\btype\s*=\s*(['"])module\1/i.test(o??""));if(s.length!==1)throw new Error("HTML 文件需要且只能包含一个内联 module 脚本。");if(/\bsrc\s*=\s*(['"])[^'"]+\1/i.test(((r=s[0])==null?void 0:r[1])??""))throw new Error("动态图形 module 必须内联在 HTML 文件中。");n=((i=s[0])==null?void 0:i[2])??""}else if(!/\.(?:m?js)$/i.test(t))throw new Error("仅支持 HTML、JavaScript、视频和图片文件。");if(!LQ(n))throw new Error("动态图形 module 必须导出 mount。");return n.trim()}function LQ(t){return/\bexport\s+default\s+(?:async\s+)?function\b|\bexport\s+default\s+[A-Za-z_$][\w$]*\s*;?/m.test(t)||/\bexport\s+default\s+(?:async\s*)?(?:\([^)]*\)|[A-Za-z_$][\w$]*)\s*=>/m.test(t)||/\bexport\s+(?:async\s+)?function\s+mount\s*\(/m.test(t)||/\bexport\s*\{[^}]*\bmount\s+as\s+default\b[^}]*\}/m.test(t)}var ba=(t=>(t.Application="application",t.WebGLPipes="webgl-pipes",t.WebGLPipesAdaptor="webgl-pipes-adaptor",t.WebGLSystem="webgl-system",t.WebGLLoader="webgl-loader",t.WebGPUPipes="webgpu-pipes",t.WebGPUPipesAdaptor="webgpu-pipes-adaptor",t.WebGPUSystem="webgpu-system",t.WebGPULoader="webgpu-loader",t.CanvasSystem="canvas-system",t.CanvasPipesAdaptor="canvas-pipes-adaptor",t.CanvasPipes="canvas-pipes",t.CanvasLoader="canvas-loader",t.Asset="asset",t.LoadParser="load-parser",t.ResolveParser="resolve-parser",t.CacheParser="cache-parser",t.DetectionParser="detection-parser",t.MaskEffect="mask-effect",t.BlendMode="blend-mode",t.TextureSource="texture-source",t.TextureUploaderWebGL="texture-uploader-webgl",t.TextureUploaderWebGPU="texture-uploader-webgpu",t.Environment="environment",t.ShapeBuilder="shape-builder",t.Batcher="batcher",t))(ba||{});const GC=t=>{if(typeof t=="function"||typeof t=="object"&&t.extension){if(!t.extension)throw new Error("Extension class must have an extension object");t={...typeof t.extension!="object"?{type:t.extension}:t.extension,ref:t}}if(typeof t=="object")t={...t};else throw new Error("Invalid extension type");return typeof t.type=="string"&&(t.type=[t.type]),t},Xy=(t,e)=>GC(t).priority??e,Rf={_addHandlers:{},_removeHandlers:{},_queue:{},remove(...t){return t.map(GC).forEach(e=>{e.type.forEach(n=>{var r,i;return(i=(r=this._removeHandlers)[n])==null?void 0:i.call(r,e)})}),this},add(...t){return t.map(GC).forEach(e=>{e.type.forEach(n=>{var a,s;const r=this._addHandlers,i=this._queue;r[n]?(s=r[n])==null||s.call(r,e):(i[n]=i[n]||[],(a=i[n])==null||a.push(e))})}),this},handle(t,e,n){var s;const r=this._addHandlers,i=this._removeHandlers;if(r[t]||i[t])throw new Error(`Extension type ${t} already has a handler`);r[t]=e,i[t]=n;const a=this._queue;return a[t]&&((s=a[t])==null||s.forEach(o=>e(o)),delete a[t]),this},handleByMap(t,e){return this.handle(t,n=>{n.name&&(e[n.name]=n.ref)},n=>{n.name&&delete e[n.name]})},handleByNamedList(t,e,n=-1){return this.handle(t,r=>{e.findIndex(a=>a.name===r.name)>=0||(e.push({name:r.name,value:r.ref}),e.sort((a,s)=>Xy(s.value,n)-Xy(a.value,n)))},r=>{const i=e.findIndex(a=>a.name===r.name);i!==-1&&e.splice(i,1)})},handleByList(t,e,n=-1){return this.handle(t,r=>{e.includes(r.ref)||(e.push(r.ref),e.sort((i,a)=>Xy(a,n)-Xy(i,n)))},r=>{const i=e.indexOf(r.ref);i!==-1&&e.splice(i,1)})},mixin(t,...e){for(const n of e)Object.defineProperties(t.prototype,Object.getOwnPropertyDescriptors(n))}},_Q={extension:{type:ba.Environment,name:"browser",priority:-1},test:()=>!0,load:async()=>{await Af(()=>import("./browserAll-0i6gm1iO.js"),__vite__mapDeps([0,1]))}},jQ={extension:{type:ba.Environment,name:"webworker",priority:0},test:()=>typeof self<"u"&&self.WorkerGlobalScope!==void 0,load:async()=>{await Af(()=>import("./webworkerAll-Xo9FRLTy.js"),[])}};class Yi{constructor(e,n,r){this._x=n||0,this._y=r||0,this._observer=e}clone(e){return new Yi(e??this._observer,this._x,this._y)}set(e=0,n=e){return(this._x!==e||this._y!==n)&&(this._x=e,this._y=n,this._observer._onUpdate(this)),this}copyFrom(e){return(this._x!==e.x||this._y!==e.y)&&(this._x=e.x,this._y=e.y,this._observer._onUpdate(this)),this}copyTo(e){return e.set(this._x,this._y),e}equals(e){return e.x===this._x&&e.y===this._y}toString(){return`[pixi.js/math:ObservablePoint x=${this._x} y=${this._y} scope=${this._observer}]`}get x(){return this._x}set x(e){this._x!==e&&(this._x=e,this._observer._onUpdate(this))}get y(){return this._y}set y(e){this._y!==e&&(this._y=e,this._observer._onUpdate(this))}}var L9={exports:{}};(function(t){var e=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(c,l,d){this.fn=c,this.context=l,this.once=d||!1}function a(c,l,d,u,h){if(typeof d!="function")throw new TypeError("The listener must be a function");var f=new i(d,u||c,h),p=n?n+l:l;return c._events[p]?c._events[p].fn?c._events[p]=[c._events[p],f]:c._events[p].push(f):(c._events[p]=f,c._eventsCount++),c}function s(c,l){--c._eventsCount===0?c._events=new r:delete c._events[l]}function o(){this._events=new r,this._eventsCount=0}o.prototype.eventNames=function(){var l=[],d,u;if(this._eventsCount===0)return l;for(u in d=this._events)e.call(d,u)&&l.push(n?u.slice(1):u);return Object.getOwnPropertySymbols?l.concat(Object.getOwnPropertySymbols(d)):l},o.prototype.listeners=function(l){var d=n?n+l:l,u=this._events[d];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,p=new Array(f);h<f;h++)p[h]=u[h].fn;return p},o.prototype.listenerCount=function(l){var d=n?n+l:l,u=this._events[d];return u?u.fn?1:u.length:0},o.prototype.emit=function(l,d,u,h,f,p){var m=n?n+l:l;if(!this._events[m])return!1;var y=this._events[m],g=arguments.length,b,x;if(y.fn){switch(y.once&&this.removeListener(l,y.fn,void 0,!0),g){case 1:return y.fn.call(y.context),!0;case 2:return y.fn.call(y.context,d),!0;case 3:return y.fn.call(y.context,d,u),!0;case 4:return y.fn.call(y.context,d,u,h),!0;case 5:return y.fn.call(y.context,d,u,h,f),!0;case 6:return y.fn.call(y.context,d,u,h,f,p),!0}for(x=1,b=new Array(g-1);x<g;x++)b[x-1]=arguments[x];y.fn.apply(y.context,b)}else{var v=y.length,w;for(x=0;x<v;x++)switch(y[x].once&&this.removeListener(l,y[x].fn,void 0,!0),g){case 1:y[x].fn.call(y[x].context);break;case 2:y[x].fn.call(y[x].context,d);break;case 3:y[x].fn.call(y[x].context,d,u);break;case 4:y[x].fn.call(y[x].context,d,u,h);break;default:if(!b)for(w=1,b=new Array(g-1);w<g;w++)b[w-1]=arguments[w];y[x].fn.apply(y[x].context,b)}}return!0},o.prototype.on=function(l,d,u){return a(this,l,d,u,!1)},o.prototype.once=function(l,d,u){return a(this,l,d,u,!0)},o.prototype.removeListener=function(l,d,u,h){var f=n?n+l:l;if(!this._events[f])return this;if(!d)return s(this,f),this;var p=this._events[f];if(p.fn)p.fn===d&&(!h||p.once)&&(!u||p.context===u)&&s(this,f);else{for(var m=0,y=[],g=p.length;m<g;m++)(p[m].fn!==d||h&&!p[m].once||u&&p[m].context!==u)&&y.push(p[m]);y.length?this._events[f]=y.length===1?y[0]:y:s(this,f)}return this},o.prototype.removeAllListeners=function(l){var d;return l?(d=n?n+l:l,this._events[d]&&s(this,d)):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o})(L9);var UQ=L9.exports;const G1=D1(UQ),HQ=Math.PI*2,VQ=180/Math.PI,GQ=Math.PI/180;class rc{constructor(e=0,n=0){this.x=0,this.y=0,this.x=e,this.y=n}clone(){return new rc(this.x,this.y)}copyFrom(e){return this.set(e.x,e.y),this}copyTo(e){return e.set(this.x,this.y),e}equals(e){return e.x===this.x&&e.y===this.y}set(e=0,n=e){return this.x=e,this.y=n,this}toString(){return`[pixi.js/math:Point x=${this.x} y=${this.y}]`}static get shared(){return VT.x=0,VT.y=0,VT}}const VT=new rc;class yr{constructor(e=1,n=0,r=0,i=1,a=0,s=0){this.array=null,this.a=e,this.b=n,this.c=r,this.d=i,this.tx=a,this.ty=s}fromArray(e){this.a=e[0],this.b=e[1],this.c=e[3],this.d=e[4],this.tx=e[2],this.ty=e[5]}set(e,n,r,i,a,s){return this.a=e,this.b=n,this.c=r,this.d=i,this.tx=a,this.ty=s,this}toArray(e,n){this.array||(this.array=new Float32Array(9));const r=n||this.array;return e?(r[0]=this.a,r[1]=this.b,r[2]=0,r[3]=this.c,r[4]=this.d,r[5]=0,r[6]=this.tx,r[7]=this.ty,r[8]=1):(r[0]=this.a,r[1]=this.c,r[2]=this.tx,r[3]=this.b,r[4]=this.d,r[5]=this.ty,r[6]=0,r[7]=0,r[8]=1),r}apply(e,n){n=n||new rc;const r=e.x,i=e.y;return n.x=this.a*r+this.c*i+this.tx,n.y=this.b*r+this.d*i+this.ty,n}applyInverse(e,n){n=n||new rc;const r=this.a,i=this.b,a=this.c,s=this.d,o=this.tx,c=this.ty,l=1/(r*s+a*-i),d=e.x,u=e.y;return n.x=s*l*d+-a*l*u+(c*a-o*s)*l,n.y=r*l*u+-i*l*d+(-c*r+o*i)*l,n}translate(e,n){return this.tx+=e,this.ty+=n,this}scale(e,n){return this.a*=e,this.d*=n,this.c*=e,this.b*=n,this.tx*=e,this.ty*=n,this}rotate(e){const n=Math.cos(e),r=Math.sin(e),i=this.a,a=this.c,s=this.tx;return this.a=i*n-this.b*r,this.b=i*r+this.b*n,this.c=a*n-this.d*r,this.d=a*r+this.d*n,this.tx=s*n-this.ty*r,this.ty=s*r+this.ty*n,this}append(e){const n=this.a,r=this.b,i=this.c,a=this.d;return this.a=e.a*n+e.b*i,this.b=e.a*r+e.b*a,this.c=e.c*n+e.d*i,this.d=e.c*r+e.d*a,this.tx=e.tx*n+e.ty*i+this.tx,this.ty=e.tx*r+e.ty*a+this.ty,this}appendFrom(e,n){const r=e.a,i=e.b,a=e.c,s=e.d,o=e.tx,c=e.ty,l=n.a,d=n.b,u=n.c,h=n.d;return this.a=r*l+i*u,this.b=r*d+i*h,this.c=a*l+s*u,this.d=a*d+s*h,this.tx=o*l+c*u+n.tx,this.ty=o*d+c*h+n.ty,this}setTransform(e,n,r,i,a,s,o,c,l){return this.a=Math.cos(o+l)*a,this.b=Math.sin(o+l)*a,this.c=-Math.sin(o-c)*s,this.d=Math.cos(o-c)*s,this.tx=e-(r*this.a+i*this.c),this.ty=n-(r*this.b+i*this.d),this}prepend(e){const n=this.tx;if(e.a!==1||e.b!==0||e.c!==0||e.d!==1){const r=this.a,i=this.c;this.a=r*e.a+this.b*e.c,this.b=r*e.b+this.b*e.d,this.c=i*e.a+this.d*e.c,this.d=i*e.b+this.d*e.d}return this.tx=n*e.a+this.ty*e.c+e.tx,this.ty=n*e.b+this.ty*e.d+e.ty,this}decompose(e){const n=this.a,r=this.b,i=this.c,a=this.d,s=e.pivot,o=-Math.atan2(-i,a),c=Math.atan2(r,n),l=Math.abs(o+c);let d=Math.sqrt(n*n+r*r);return l<1e-5||Math.abs(HQ-l)<1e-5?(e.rotation=c,e.skew.x=e.skew.y=0):Math.abs(Math.PI-l)<1e-5?(e.rotation=c-Math.PI,e.skew.x=e.skew.y=0,d=-d):(e.rotation=0,e.skew.x=o,e.skew.y=c),e.scale.x=d,e.scale.y=Math.sqrt(i*i+a*a),e.position.x=this.tx+(s.x*n+s.y*i),e.position.y=this.ty+(s.x*r+s.y*a),e}invert(){const e=this.a,n=this.b,r=this.c,i=this.d,a=this.tx,s=e*i-n*r;return this.a=i/s,this.b=-n/s,this.c=-r/s,this.d=e/s,this.tx=(r*this.ty-i*a)/s,this.ty=-(e*this.ty-n*a)/s,this}isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.tx===0&&this.ty===0}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}clone(){const e=new yr;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(e){return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyFrom(e){return this.a=e.a,this.b=e.b,this.c=e.c,this.d=e.d,this.tx=e.tx,this.ty=e.ty,this}equals(e){return e.a===this.a&&e.b===this.b&&e.c===this.c&&e.d===this.d&&e.tx===this.tx&&e.ty===this.ty}toString(){return`[pixi.js:Matrix a=${this.a} b=${this.b} c=${this.c} d=${this.d} tx=${this.tx} ty=${this.ty}]`}static get IDENTITY(){return WQ.identity()}static get shared(){return qQ.identity()}}const qQ=new yr,WQ=new yr,Rd=[1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1,0,1],Bd=[0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1,-1],Fd=[0,-1,-1,-1,0,1,1,1,0,1,1,1,0,-1,-1,-1],zd=[1,1,0,-1,-1,-1,0,1,-1,-1,0,1,1,1,0,-1],qC=[],_9=[],Yy=Math.sign;function XQ(){for(let t=0;t<16;t++){const e=[];qC.push(e);for(let n=0;n<16;n++){const r=Yy(Rd[t]*Rd[n]+Fd[t]*Bd[n]),i=Yy(Bd[t]*Rd[n]+zd[t]*Bd[n]),a=Yy(Rd[t]*Fd[n]+Fd[t]*zd[n]),s=Yy(Bd[t]*Fd[n]+zd[t]*zd[n]);for(let o=0;o<16;o++)if(Rd[o]===r&&Bd[o]===i&&Fd[o]===a&&zd[o]===s){e.push(o);break}}}for(let t=0;t<16;t++){const e=new yr;e.set(Rd[t],Bd[t],Fd[t],zd[t],0,0),_9.push(e)}}XQ();const jn={E:0,SE:1,S:2,SW:3,W:4,NW:5,N:6,NE:7,MIRROR_VERTICAL:8,MAIN_DIAGONAL:10,MIRROR_HORIZONTAL:12,REVERSE_DIAGONAL:14,uX:t=>Rd[t],uY:t=>Bd[t],vX:t=>Fd[t],vY:t=>zd[t],inv:t=>t&8?t&15:-t&7,add:(t,e)=>qC[t][e],sub:(t,e)=>qC[t][jn.inv(e)],rotate180:t=>t^4,isVertical:t=>(t&3)===2,byDirection:(t,e)=>Math.abs(t)*2<=Math.abs(e)?e>=0?jn.S:jn.N:Math.abs(e)*2<=Math.abs(t)?t>0?jn.E:jn.W:e>0?t>0?jn.SE:jn.SW:t>0?jn.NE:jn.NW,matrixAppendRotationInv:(t,e,n=0,r=0,i=0,a=0)=>{const s=_9[jn.inv(e)],o=s.a,c=s.b,l=s.c,d=s.d,u=n-Math.min(0,o*i,l*a,o*i+l*a),h=r-Math.min(0,c*i,d*a,c*i+d*a),f=t.a,p=t.b,m=t.c,y=t.d;t.a=o*f+c*m,t.b=o*p+c*y,t.c=l*f+d*m,t.d=l*p+d*y,t.tx=u*f+h*m+t.tx,t.ty=u*p+h*y+t.ty},transformRectCoords:(t,e,n,r)=>{const{x:i,y:a,width:s,height:o}=t,{x:c,y:l,width:d,height:u}=e;return n===jn.E?(r.set(i+c,a+l,s,o),r):n===jn.S?r.set(d-a-o+c,i+l,o,s):n===jn.W?r.set(d-i-s+c,u-a-o+l,s,o):n===jn.N?r.set(a+c,u-i-s+l,o,s):r.set(i+c,a+l,s,o)}},Ky=[new rc,new rc,new rc,new rc];class ic{constructor(e=0,n=0,r=0,i=0){this.type="rectangle",this.x=Number(e),this.y=Number(n),this.width=Number(r),this.height=Number(i)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}isEmpty(){return this.left===this.right||this.top===this.bottom}static get EMPTY(){return new ic(0,0,0,0)}clone(){return new ic(this.x,this.y,this.width,this.height)}copyFromBounds(e){return this.x=e.minX,this.y=e.minY,this.width=e.maxX-e.minX,this.height=e.maxY-e.minY,this}copyFrom(e){return this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height,this}copyTo(e){return e.copyFrom(this),e}contains(e,n){return this.width<=0||this.height<=0?!1:e>=this.x&&e<this.x+this.width&&n>=this.y&&n<this.y+this.height}strokeContains(e,n,r,i=.5){const{width:a,height:s}=this;if(a<=0||s<=0)return!1;const o=this.x,c=this.y,l=r*(1-i),d=r-l,u=o-l,h=o+a+l,f=c-l,p=c+s+l,m=o+d,y=o+a-d,g=c+d,b=c+s-d;return e>=u&&e<=h&&n>=f&&n<=p&&!(e>m&&e<y&&n>g&&n<b)}intersects(e,n){if(!n){const k=this.x<e.x?e.x:this.x;if((this.right>e.right?e.right:this.right)<=k)return!1;const M=this.y<e.y?e.y:this.y;return(this.bottom>e.bottom?e.bottom:this.bottom)>M}const r=this.left,i=this.right,a=this.top,s=this.bottom;if(i<=r||s<=a)return!1;const o=Ky[0].set(e.left,e.top),c=Ky[1].set(e.left,e.bottom),l=Ky[2].set(e.right,e.top),d=Ky[3].set(e.right,e.bottom);if(l.x<=o.x||c.y<=o.y)return!1;const u=Math.sign(n.a*n.d-n.b*n.c);if(u===0||(n.apply(o,o),n.apply(c,c),n.apply(l,l),n.apply(d,d),Math.max(o.x,c.x,l.x,d.x)<=r||Math.min(o.x,c.x,l.x,d.x)>=i||Math.max(o.y,c.y,l.y,d.y)<=a||Math.min(o.y,c.y,l.y,d.y)>=s))return!1;const h=u*(c.y-o.y),f=u*(o.x-c.x),p=h*r+f*a,m=h*i+f*a,y=h*r+f*s,g=h*i+f*s;if(Math.max(p,m,y,g)<=h*o.x+f*o.y||Math.min(p,m,y,g)>=h*d.x+f*d.y)return!1;const b=u*(o.y-l.y),x=u*(l.x-o.x),v=b*r+x*a,w=b*i+x*a,T=b*r+x*s,S=b*i+x*s;return!(Math.max(v,w,T,S)<=b*o.x+x*o.y||Math.min(v,w,T,S)>=b*d.x+x*d.y)}pad(e=0,n=e){return this.x-=e,this.y-=n,this.width+=e*2,this.height+=n*2,this}fit(e){const n=Math.max(this.x,e.x),r=Math.min(this.x+this.width,e.x+e.width),i=Math.max(this.y,e.y),a=Math.min(this.y+this.height,e.y+e.height);return this.x=n,this.width=Math.max(r-n,0),this.y=i,this.height=Math.max(a-i,0),this}ceil(e=1,n=.001){const r=Math.ceil((this.x+this.width-n)*e)/e,i=Math.ceil((this.y+this.height-n)*e)/e;return this.x=Math.floor((this.x+n)*e)/e,this.y=Math.floor((this.y+n)*e)/e,this.width=r-this.x,this.height=i-this.y,this}scale(e,n=e){return this.x*=e,this.y*=n,this.width*=e,this.height*=n,this}enlarge(e){const n=Math.min(this.x,e.x),r=Math.max(this.x+this.width,e.x+e.width),i=Math.min(this.y,e.y),a=Math.max(this.y+this.height,e.y+e.height);return this.x=n,this.width=r-n,this.y=i,this.height=a-i,this}getBounds(e){return e||(e=new ic),e.copyFrom(this),e}containsRect(e){if(this.width<=0||this.height<=0)return!1;const n=e.x,r=e.y,i=e.x+e.width,a=e.y+e.height;return n>=this.x&&n<this.x+this.width&&r>=this.y&&r<this.y+this.height&&i>=this.x&&i<=this.x+this.width&&a>=this.y&&a<=this.y+this.height}set(e,n,r,i){return this.x=e,this.y=n,this.width=r,this.height=i,this}toString(){return`[pixi.js/math:Rectangle x=${this.x} y=${this.y} width=${this.width} height=${this.height}]`}}const GT={default:-1};function gu(t="default"){return GT[t]===void 0&&(GT[t]=-1),++GT[t]}const HD=new Set,Wp="8.0.0",nh="8.21.0",YQ="8.22.0",Xh={quiet:!1,noColor:!1},Ci=(t,e,n=3)=>{if(Xh.quiet||HD.has(e))return;let r=new Error().stack;const i=`${e}
|
|
384
384
|
Deprecated since v${t}`,a=typeof console.groupCollapsed=="function"&&!Xh.noColor;typeof r>"u"?console.warn("PixiJS Deprecation Warning: ",i):(r=r.split(`
|
|
385
385
|
`).splice(n).join(`
|
|
386
386
|
`),a?(console.groupCollapsed("%cPixiJS Deprecation Warning: %c%s","color:#614108;background:#fffbe6","font-weight:normal;color:#614108;background:#fffbe6",i),console.warn(r),console.groupEnd()):(console.warn("PixiJS Deprecation Warning: ",i),console.warn(r))),HD.add(e)};Object.defineProperties(Ci,{quiet:{get:()=>Xh.quiet,set:t=>{Xh.quiet=t},enumerable:!0,configurable:!1},noColor:{get:()=>Xh.noColor,set:t=>{Xh.noColor=t},enumerable:!0,configurable:!1}});const j9=()=>{};function KQ(t){return t.endsWith("int")}function VD(t){return t+=t===0?1:0,--t,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t+1}function Ev(t){return!(t&t-1)&&!!t}function ZQ(t){const e={};for(const n in t)t[n]!==void 0&&(e[n]=t[n]);return e}const GD=Object.create(null);function QQ(t){const e=GD[t];return e===void 0&&(GD[t]=gu("resource")),e}const U9=class H9 extends G1{constructor(e={}){super(),this._resourceType="textureSampler",this._maxAnisotropy=1,this.destroyed=!1,e={...H9.defaultOptions,...e},this.addressMode=e.addressMode,this.addressModeU=e.addressModeU??this.addressModeU,this.addressModeV=e.addressModeV??this.addressModeV,this.addressModeW=e.addressModeW??this.addressModeW,this.scaleMode=e.scaleMode,this.magFilter=e.magFilter??this.magFilter,this.minFilter=e.minFilter??this.minFilter,this.mipmapFilter=e.mipmapFilter??this.mipmapFilter,this.lodMinClamp=e.lodMinClamp,this.lodMaxClamp=e.lodMaxClamp,this.compare=e.compare,this.maxAnisotropy=e.maxAnisotropy??1}set addressMode(e){this.addressModeU=e,this.addressModeV=e,this.addressModeW=e}get addressMode(){return this.addressModeU}set wrapMode(e){Ci(Wp,"TextureStyle.wrapMode is now TextureStyle.addressMode"),this.addressMode=e}get wrapMode(){return this.addressMode}set scaleMode(e){this.magFilter=e,this.minFilter=e,this.mipmapFilter=e}get scaleMode(){return this.magFilter}set maxAnisotropy(e){this._maxAnisotropy=Math.min(e,16),this._maxAnisotropy>1&&(this.scaleMode="linear")}get maxAnisotropy(){return this._maxAnisotropy}get _resourceId(){return this._sharedResourceId||this._generateResourceId()}update(){this._sharedResourceId=null,this.emit("change",this)}_generateResourceId(){const e=`${this.addressModeU}-${this.addressModeV}-${this.addressModeW}-${this.magFilter}-${this.minFilter}-${this.mipmapFilter}-${this.lodMinClamp}-${this.lodMaxClamp}-${this.compare}-${this._maxAnisotropy}`;return this._sharedResourceId=QQ(e),this._resourceId}destroy(){this.destroyed=!0,this.emit("destroy",this),this.emit("change",this),this.removeAllListeners()}};U9.defaultOptions={addressMode:"clamp-to-edge",scaleMode:"linear"};let Sx=U9;const V9=class G9 extends G1{constructor(e={}){super(),this.options=e,this._gpuData=Object.create(null),this._gcLastUsed=-1,this.uid=gu("textureSource"),this._resourceType="textureSource",this._resourceId=gu("resource"),this.uploadMethodId="unknown",this._resolution=1,this.pixelWidth=1,this.pixelHeight=1,this.width=1,this.height=1,this.sampleCount=1,this.mipLevelCount=1,this.autoGenerateMipmaps=!1,this.format="rgba8unorm",this.dimension="2d",this.viewDimension="2d",this.arrayLayerCount=1,this.depth=1,this._ownsStyle=!1,this.antialias=!1,this.transient=!1,this.storage=!1,this._batchTick=-1,this._textureBindLocation=-1;const n=e;e={...G9.defaultOptions,...e};const r=JQ(e),i=r==="3d"||r==="1d"?r:"2d";$Q(n,r,i),this.label=e.label??"",this.resource=e.resource,this.autoGarbageCollect=e.autoGarbageCollect,this._resolution=e.resolution,e.width?this.pixelWidth=e.width*this._resolution:this.pixelWidth=this.resource?this.resourceWidth??1:1,e.height?this.pixelHeight=e.height*this._resolution:this.pixelHeight=this.resource?this.resourceHeight??1:1,this.width=this.pixelWidth/this._resolution,this.height=this.pixelHeight/this._resolution,this.format=e.format,this.dimension=i,this.viewDimension=r,this.arrayLayerCount=e.arrayLayerCount,this.depth=i==="3d"?e.depth??1:1,this.mipLevelCount=e.mipLevelCount,this.autoGenerateMipmaps=e.autoGenerateMipmaps,this.sampleCount=e.sampleCount,this.antialias=i==="3d"?!1:e.antialias,this.transient=e.transient??!1,this.storage=e.storage??!1,this.alphaMode=e.alphaMode,this.style=new Sx(ZQ(e)),this._ownsStyle=!0,this.destroyed=!1,this._refreshPOT()}get depthOrArrayLayers(){return this.dimension==="3d"?this.depth:this.arrayLayerCount||1}get source(){return this}get style(){return this._style}set style(e){var n,r;this.style!==e&&(this._ownsStyle=!1,(n=this._style)==null||n.off("change",this._onStyleChange,this),this._style=e,(r=this._style)==null||r.on("change",this._onStyleChange,this),this._onStyleChange())}set maxAnisotropy(e){this._style.maxAnisotropy=e}get maxAnisotropy(){return this._style.maxAnisotropy}get addressMode(){return this._style.addressMode}set addressMode(e){this._style.addressMode=e}get repeatMode(){return this._style.addressMode}set repeatMode(e){this._style.addressMode=e}get magFilter(){return this._style.magFilter}set magFilter(e){this._style.magFilter=e}get minFilter(){return this._style.minFilter}set minFilter(e){this._style.minFilter=e}get mipmapFilter(){return this._style.mipmapFilter}set mipmapFilter(e){this._style.mipmapFilter=e}get lodMinClamp(){return this._style.lodMinClamp}set lodMinClamp(e){this._style.lodMinClamp=e}get lodMaxClamp(){return this._style.lodMaxClamp}set lodMaxClamp(e){this._style.lodMaxClamp=e}_onStyleChange(){this.emit("styleChange",this)}update(){if(this.resource){const e=this._resolution;if(this.resize(this.resourceWidth/e,this.resourceHeight/e))return}this.emit("update",this)}destroy(){this.destroyed=!0,this.unload(),this.emit("destroy",this),this._style&&(this._ownsStyle&&this._style.destroy(),this._style=null),this.uploadMethodId=null,this.resource=null,this.removeAllListeners()}unload(){var e,n;this._resourceId=gu("resource"),this.emit("change",this),this.emit("unload",this);for(const r in this._gpuData)(n=(e=this._gpuData[r])==null?void 0:e.destroy)==null||n.call(e);this._gpuData=Object.create(null)}get resourceWidth(){const{resource:e}=this;return e.naturalWidth||e.videoWidth||e.displayWidth||e.width}get resourceHeight(){const{resource:e}=this;return e.naturalHeight||e.videoHeight||e.displayHeight||e.height}get resolution(){return this._resolution}set resolution(e){this._resolution!==e&&(this._resolution=e,this.width=this.pixelWidth/e,this.height=this.pixelHeight/e)}resize(e,n,r){r||(r=this._resolution),e||(e=this.width),n||(n=this.height);const i=Math.round(e*r),a=Math.round(n*r);return this.width=i/r,this.height=a/r,this._resolution=r,this.pixelWidth===i&&this.pixelHeight===a?!1:(this._refreshPOT(),this.pixelWidth=i,this.pixelHeight=a,this.emit("resize",this),this._resourceId=gu("resource"),this.emit("change",this),!0)}updateMipmaps(){this.autoGenerateMipmaps&&this.mipLevelCount>1&&this.emit("updateMipmaps",this)}set wrapMode(e){this._style.wrapMode=e}get wrapMode(){return this._style.wrapMode}set scaleMode(e){this._style.scaleMode=e}get scaleMode(){return this._style.scaleMode}_refreshPOT(){this.isPowerOfTwo=Ev(this.pixelWidth)&&Ev(this.pixelHeight)}static test(e){throw new Error("Unimplemented")}};V9.defaultOptions={resolution:1,format:"bgra8unorm",alphaMode:"premultiply-alpha-on-upload",arrayLayerCount:1,mipLevelCount:1,autoGenerateMipmaps:!1,sampleCount:1,antialias:!1,autoGarbageCollect:!1};let hs=V9;function JQ(t){return t.viewDimension?t.viewDimension:t.depth?"3d":t.arrayLayerCount>1?"2d-array":"2d"}function $Q(t,e,n){if(t.depth!==void 0&&typeof t.depth!="number")throw new Error(`[TextureSource] depth is a 3D texture's depth in texels, but got ${t.depth}. For a depth buffer, use the depth option of a RenderTarget or the renderer.`);if(t.depth&&t.arrayLayerCount>1)throw new Error("[TextureSource] depth and arrayLayerCount can't be combined: use depth for a 3D texture or arrayLayerCount for a 2D array.");if(t.depth&&e!=="3d")throw new Error(`[TextureSource] depth makes a 3D texture, but viewDimension is '${e}'. Use arrayLayerCount for layered textures.`);if(e==="3d"&&t.arrayLayerCount>1)throw new Error("[TextureSource] a 3D texture takes depth, not arrayLayerCount.");if(t.dimensions&&t.dimensions!==n)throw new Error(`[TextureSource] dimensions '${t.dimensions}' doesn't match viewDimension '${e}'. Leave dimensions out; it is derived from the view.`);if(t.dimensions&&Ci(YQ,"TextureSource dimensions is derived from viewDimension and depth; leave it out."),n==="3d"&&t.antialias)throw new Error("[TextureSource] a 3D texture can't be antialiased: WebGPU has no multisampled 3D textures.")}class q4 extends hs{constructor(e){const n=e.depth??e.arrayLayerCount??1,r=e.resource||new Float32Array(e.width*e.height*n*4);let i=e.format;i||(r instanceof Float32Array?i="rgba32float":r instanceof Int32Array||r instanceof Uint32Array?i="rgba32uint":r instanceof Int16Array||r instanceof Uint16Array?i="rgba16uint":(r instanceof Int8Array,i="bgra8unorm"));const a=KQ(i)||n>1;super({...a&&{alphaMode:"no-premultiply-alpha"},...e,resource:r,format:i}),this.uploadMethodId="buffer",this._updateStart=0,this._updateEnd=1/0}update(e=0,n=1/0){if((e>0||n<1/0)&&this.depthOrArrayLayers>1)throw new Error("[BufferImageSource] a 3D texture or 2D array uploads whole: call update() with no range.");this._updateStart=e,this._updateEnd=n,super.update(),this._updateStart=0,this._updateEnd=1/0}static test(e){return e instanceof Int8Array||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array}}q4.extension=ba.TextureSource;const qD=new yr;class eJ{constructor(e,n){this.mapCoord=new yr,this.uClampFrame=new Float32Array(4),this.uClampOffset=new Float32Array(2),this._updateID=0,this.clampOffset=0,typeof n>"u"?this.clampMargin=e.width<10?0:.5:this.clampMargin=n,this.isSimple=!1,this.texture=e}get texture(){return this._texture}set texture(e){var n;this._texture!==e&&((n=this._texture)==null||n.removeListener("update",this.update,this),this._texture=e,this._texture.addListener("update",this.update,this)),this.update()}destroy(){var e;(e=this._texture)==null||e.removeListener("update",this.update,this),this._texture=null}multiplyUvs(e,n){n===void 0&&(n=e);const r=this.mapCoord;for(let i=0;i<e.length;i+=2){const a=e[i],s=e[i+1];n[i]=a*r.a+s*r.c+r.tx,n[i+1]=a*r.b+s*r.d+r.ty}return n}update(){const e=this._texture;this._updateID++;const n=e.uvs;this.mapCoord.set(n.x1-n.x0,n.y1-n.y0,n.x3-n.x0,n.y3-n.y0,n.x0,n.y0);const r=e.orig,i=e.trim;i&&(qD.set(r.width/i.width,0,0,r.height/i.height,-i.x/i.width,-i.y/i.height),this.mapCoord.append(qD));const a=e.source,s=this.uClampFrame,o=this.clampMargin/a._resolution,c=this.clampOffset/a._resolution;return s[0]=(e.frame.x+o+c)/a.width,s[1]=(e.frame.y+o+c)/a.height,s[2]=(e.frame.x+e.frame.width-o+c)/a.width,s[3]=(e.frame.y+e.frame.height-o+c)/a.height,this.uClampOffset[0]=this.clampOffset/a.pixelWidth,this.uClampOffset[1]=this.clampOffset/a.pixelHeight,this.isSimple=e.frame.width===a.width&&e.frame.height===a.height&&e.rotate===0,!0}}class ni extends G1{constructor({source:e,label:n,frame:r,orig:i,trim:a,defaultAnchor:s,defaultBorders:o,rotate:c,dynamic:l}={}){if(super(),this.uid=gu("texture"),this.uvs={x0:0,y0:0,x1:0,y1:0,x2:0,y2:0,x3:0,y3:0},this.frame=new ic,this.noFrame=!1,this.dynamic=!1,this.isTexture=!0,this.label=n,this.source=(e==null?void 0:e.source)??new hs,this.noFrame=!r,r)this.frame.copyFrom(r);else{const{width:d,height:u}=this._source;this.frame.width=d,this.frame.height=u}this.orig=i||this.frame,this.trim=a,this.rotate=c??0,this.defaultAnchor=s,this.defaultBorders=o,this.destroyed=!1,this.dynamic=l||!1,this.updateUvs()}set source(e){this._source&&this._source.off("resize",this.update,this),this._source=e,e.on("resize",this.update,this),this.emit("update",this)}get source(){return this._source}get textureMatrix(){return this._textureMatrix||(this._textureMatrix=new eJ(this)),this._textureMatrix}get width(){return this.orig.width}get height(){return this.orig.height}updateUvs(){const{uvs:e,frame:n}=this,{width:r,height:i}=this._source,a=n.x/r,s=n.y/i,o=n.width/r,c=n.height/i;let l=this.rotate;if(l){const d=o/2,u=c/2,h=a+d,f=s+u;l=jn.add(l,jn.NW),e.x0=h+d*jn.uX(l),e.y0=f+u*jn.uY(l),l=jn.add(l,2),e.x1=h+d*jn.uX(l),e.y1=f+u*jn.uY(l),l=jn.add(l,2),e.x2=h+d*jn.uX(l),e.y2=f+u*jn.uY(l),l=jn.add(l,2),e.x3=h+d*jn.uX(l),e.y3=f+u*jn.uY(l)}else e.x0=a,e.y0=s,e.x1=a+o,e.y1=s,e.x2=a+o,e.y2=s+c,e.x3=a,e.y3=s+c}destroy(e=!1){this._source&&(this._source.off("resize",this.update,this),e&&(this._source.destroy(),this._source=null)),this._textureMatrix=null,this.destroyed=!0,this.emit("destroy",this),this.removeAllListeners()}update(){this.noFrame&&(this.frame.width=this._source.width,this.frame.height=this._source.height),this.updateUvs(),this.emit("update",this)}get baseTexture(){return Ci(Wp,"Texture.baseTexture is now Texture.source"),this._source}}ni.EMPTY=new ni({label:"EMPTY",source:new hs({label:"EMPTY"})});ni.EMPTY.destroy=j9;ni.WHITE=new ni({source:new q4({resource:new Uint8Array([255,255,255,255]),width:1,height:1,alphaMode:"premultiply-alpha-on-upload",label:"WHITE"}),label:"WHITE"});ni.WHITE.destroy=j9;function tJ(t,e,n){const{width:r,height:i}=n.orig,a=n.trim;if(a){const s=a.width,o=a.height;t.minX=a.x-e._x*r,t.maxX=t.minX+s,t.minY=a.y-e._y*i,t.maxY=t.minY+o}else t.minX=-e._x*r,t.maxX=t.minX+r,t.minY=-e._y*i,t.maxY=t.minY+i}const WD=new yr;class Xu{constructor(e=1/0,n=1/0,r=-1/0,i=-1/0){this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=WD,this.minX=e,this.minY=n,this.maxX=r,this.maxY=i}isEmpty(){return this.minX>this.maxX||this.minY>this.maxY}get rectangle(){this._rectangle||(this._rectangle=new ic);const e=this._rectangle;return this.minX>this.maxX||this.minY>this.maxY?(e.x=0,e.y=0,e.width=0,e.height=0):e.copyFromBounds(this),e}clear(){return this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,this.matrix=WD,this}set(e,n,r,i){this.minX=e,this.minY=n,this.maxX=r,this.maxY=i}addFrame(e,n,r,i,a){a||(a=this.matrix);const s=a.a,o=a.b,c=a.c,l=a.d,d=a.tx,u=a.ty;let h=this.minX,f=this.minY,p=this.maxX,m=this.maxY,y=s*e+c*n+d,g=o*e+l*n+u;y<h&&(h=y),g<f&&(f=g),y>p&&(p=y),g>m&&(m=g),y=s*r+c*n+d,g=o*r+l*n+u,y<h&&(h=y),g<f&&(f=g),y>p&&(p=y),g>m&&(m=g),y=s*e+c*i+d,g=o*e+l*i+u,y<h&&(h=y),g<f&&(f=g),y>p&&(p=y),g>m&&(m=g),y=s*r+c*i+d,g=o*r+l*i+u,y<h&&(h=y),g<f&&(f=g),y>p&&(p=y),g>m&&(m=g),this.minX=h,this.minY=f,this.maxX=p,this.maxY=m}addRect(e,n){this.addFrame(e.x,e.y,e.x+e.width,e.y+e.height,n)}addBounds(e,n){this.addFrame(e.minX,e.minY,e.maxX,e.maxY,n)}addBoundsMask(e){this.minX=this.minX>e.minX?this.minX:e.minX,this.minY=this.minY>e.minY?this.minY:e.minY,this.maxX=this.maxX<e.maxX?this.maxX:e.maxX,this.maxY=this.maxY<e.maxY?this.maxY:e.maxY}applyMatrix(e){const n=this.minX,r=this.minY,i=this.maxX,a=this.maxY,{a:s,b:o,c,d:l,tx:d,ty:u}=e;let h=s*n+c*r+d,f=o*n+l*r+u;this.minX=h,this.minY=f,this.maxX=h,this.maxY=f,h=s*i+c*r+d,f=o*i+l*r+u,this.minX=h<this.minX?h:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=h>this.maxX?h:this.maxX,this.maxY=f>this.maxY?f:this.maxY,h=s*n+c*a+d,f=o*n+l*a+u,this.minX=h<this.minX?h:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=h>this.maxX?h:this.maxX,this.maxY=f>this.maxY?f:this.maxY,h=s*i+c*a+d,f=o*i+l*a+u,this.minX=h<this.minX?h:this.minX,this.minY=f<this.minY?f:this.minY,this.maxX=h>this.maxX?h:this.maxX,this.maxY=f>this.maxY?f:this.maxY}fit(e){return this.minX<e.left&&(this.minX=e.left),this.maxX>e.right&&(this.maxX=e.right),this.minY<e.top&&(this.minY=e.top),this.maxY>e.bottom&&(this.maxY=e.bottom),this}fitBounds(e,n,r,i){return this.minX<e&&(this.minX=e),this.maxX>n&&(this.maxX=n),this.minY<r&&(this.minY=r),this.maxY>i&&(this.maxY=i),this}pad(e,n=e){return this.minX-=e,this.maxX+=e,this.minY-=n,this.maxY+=n,this}ceil(){return this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this}clone(){return new Xu(this.minX,this.minY,this.maxX,this.maxY)}scale(e,n=e){return this.minX*=e,this.minY*=n,this.maxX*=e,this.maxY*=n,this}get x(){return this.minX}set x(e){const n=this.maxX-this.minX;this.minX=e,this.maxX=e+n}get y(){return this.minY}set y(e){const n=this.maxY-this.minY;this.minY=e,this.maxY=e+n}get width(){return this.maxX-this.minX}set width(e){this.maxX=this.minX+e}get height(){return this.maxY-this.minY}set height(e){this.maxY=this.minY+e}get left(){return this.minX}get right(){return this.maxX}get top(){return this.minY}get bottom(){return this.maxY}get isPositive(){return this.maxX-this.minX>0&&this.maxY-this.minY>0}get isValid(){return this.minX+this.minY!==1/0}addVertexData(e,n,r,i){let a=this.minX,s=this.minY,o=this.maxX,c=this.maxY;i||(i=this.matrix);const l=i.a,d=i.b,u=i.c,h=i.d,f=i.tx,p=i.ty;for(let m=n;m<r;m+=2){const y=e[m],g=e[m+1],b=l*y+u*g+f,x=d*y+h*g+p;a=b<a?b:a,s=x<s?x:s,o=b>o?b:o,c=x>c?x:c}this.minX=a,this.minY=s,this.maxX=o,this.maxY=c}containsPoint(e,n){return this.minX<=e&&this.minY<=n&&this.maxX>=e&&this.maxY>=n}toString(){return`[pixi.js:Bounds minX=${this.minX} minY=${this.minY} maxX=${this.maxX} maxY=${this.maxY} width=${this.width} height=${this.height}]`}copyFrom(e){return this.minX=e.minX,this.minY=e.minY,this.maxX=e.maxX,this.maxY=e.maxY,this}}for(var nJ={grad:.9,turn:360,rad:360/(2*Math.PI)},Dc=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},ac=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},Mv=function(t){var e=Math.round(100*t)/100;return Math.round(255*e)===255*t?e:Math.round(1e3*t)/1e3},os=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},q9=function(t){return(t=isFinite(t)?t%360:0)<0?t+360:t},WC=function(t,e){return e===void 0&&(e=0),ac(t,e)%360},XD=function(t){return{r:os(t.r,0,255),g:os(t.g,0,255),b:os(t.b,0,255),a:os(t.a)}},qT=function(t){return{r:ac(t.r),g:ac(t.g),b:ac(t.b),a:Mv(t.a)}},rJ=/^#([0-9a-f]{3,8})$/i,Yh=function(t,e){var n=t.charCodeAt(e);return(15&n)+9*(n>>6)},Zy=function(t,e){return Yh(t,e)<<4|Yh(t,e+1)},W9=[],Qy=0;Qy<256;Qy++)W9.push((Qy<16?"0":"")+Qy.toString(16));var Jy=function(t){return W9[os(t,0,255)]},X9=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=Math.max(e,n,r),s=a-Math.min(e,n,r),o=s?a===e?(n-r)/s:a===n?2+(r-e)/s:4+(e-n)/s:0;return{h:60*(o<0?o+6:o),s:a?s/a*100:0,v:a/255*100,a:i}},Y9=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var a=Math.floor(e),s=r*(1-n),o=r*(1-(e-a)*n),c=r*(1-(1-e+a)*n),l=a%6;return{r:255*[r,o,s,s,c,r][l],g:255*[c,r,r,o,s,s][l],b:255*[s,s,c,r,r,o][l],a:i}},YD=function(t){return{h:q9(t.h),s:os(t.s,0,100),l:os(t.l,0,100),a:os(t.a)}},KD=function(t){return{h:WC(t.h),s:ac(t.s),l:ac(t.l),a:Mv(t.a)}},ZD=function(t){return Y9((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},Kh=function(t){return{h:(e=X9(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},iJ=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)%\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)%\s*(?:,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*)?\)$/i,aJ=/^hsla?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(deg|rad|grad|turn)?\s+([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)%\s+([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)%\s*(?:\/\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*)?\)$/i,sJ=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*(?:,\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*)?\)$/i,oJ=/^rgba?\(\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s+([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s+([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*(?:\/\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:e[+-]?\d+)?)(%)?\s*)?\)$/i,XC={string:[[function(t){if(!rJ.test(t))return null;var e=t.length;return e<=5?{r:17*Yh(t,1),g:17*Yh(t,2),b:17*Yh(t,3),a:e===5?17*Yh(t,4)/255:1}:e===7||e===9?{r:Zy(t,1),g:Zy(t,3),b:Zy(t,5),a:e===9?Zy(t,7)/255:1}:null},"hex"],[function(t){var e=sJ.exec(t)||oJ.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:XD({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=iJ.exec(t)||aJ.exec(t);if(!e)return null;var n,r,i=YD({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(nJ[r.toLowerCase()]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ZD(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,a=i===void 0?1:i;return Dc(e)&&Dc(n)&&Dc(r)?XD({r:Number(e),g:Number(n),b:Number(r),a:Number(a)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,a=i===void 0?1:i;if(!Dc(e)||!Dc(n)||!Dc(r))return null;var s=YD({h:Number(e),s:Number(n),l:Number(r),a:Number(a)});return ZD(s)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,a=i===void 0?1:i;if(!Dc(e)||!Dc(n)||!Dc(r))return null;var s=function(o){return{h:q9(o.h),s:os(o.s,0,100),v:os(o.v,0,100),a:os(o.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(a)});return Y9(s)},"hsv"]]},QD=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},cJ=function(t){return typeof t=="string"?QD(t.trim(),XC.string):typeof t=="object"&&t!==null?QD(t,XC.object):[null,void 0]},WT=function(t,e,n){var r=Kh(t);return{h:r.h,s:os(r.s+e*(n?r.s:100),0,100),l:r.l,a:r.a}},XT=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},JD=function(t,e,n){var r=Kh(t);return{h:r.h,s:r.s,l:os(r.l+e*(n?r.l:100),0,100),a:r.a}},YC=function(){function t(e){this.parsed=cJ(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return ac(XT(this.rgba),2)},t.prototype.isDark=function(){return XT(this.rgba)<.5},t.prototype.isLight=function(){return XT(this.rgba)>=.5},t.prototype.toHex=function(){return e=qT(this.rgba),n=e.r,r=e.g,i=e.b,s=(a=e.a)<1?Jy(ac(255*a)):"","#"+Jy(n)+Jy(r)+Jy(i)+s;var e,n,r,i,a,s},t.prototype.toRgb=function(){return qT(this.rgba)},t.prototype.toRgbString=function(){return e=qT(this.rgba),n=e.r,r=e.g,i=e.b,(a=e.a)<1?"rgba("+n+", "+r+", "+i+", "+a+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,a},t.prototype.toHsl=function(){return KD(Kh(this.rgba))},t.prototype.toHslString=function(){return e=KD(Kh(this.rgba)),n=e.h,r=e.s,i=e.l,(a=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+a+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,a},t.prototype.toHsv=function(){return e=X9(this.rgba),{h:WC(e.h),s:ac(e.s),v:ac(e.v),a:Mv(e.a)};var e},t.prototype.invert=function(){return Ho({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e,n){return e===void 0&&(e=.1),Ho(WT(this.rgba,e,n==null?void 0:n.relative))},t.prototype.desaturate=function(e,n){return e===void 0&&(e=.1),Ho(WT(this.rgba,-e,n==null?void 0:n.relative))},t.prototype.grayscale=function(){return Ho(WT(this.rgba,-1))},t.prototype.lighten=function(e,n){return e===void 0&&(e=.1),Ho(JD(this.rgba,e,n==null?void 0:n.relative))},t.prototype.darken=function(e,n){return e===void 0&&(e=.1),Ho(JD(this.rgba,-e,n==null?void 0:n.relative))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(Kh(this.rgba).h+e)},t.prototype.alpha=function(e){return typeof e=="number"?Ho({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):Mv(this.rgba.a);var n},t.prototype.hue=function(e){var n=Kh(this.rgba);return typeof e=="number"?Ho({h:e,s:n.s,l:n.l,a:n.a}):WC(n.h)},t.prototype.isEqual=function(e){return this.toHex()===Ho(e).toHex()},t}(),Ho=function(t){return t instanceof YC?t:new YC(t)},$D=[],lJ=function(t){t.forEach(function(e){$D.indexOf(e)<0&&(e(YC,XC),$D.push(e))})},uJ=function(t,e){var n={white:"#ffffff",bisque:"#ffe4c4",blue:"#0000ff",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",antiquewhite:"#faebd7",aqua:"#00ffff",azure:"#f0ffff",whitesmoke:"#f5f5f5",papayawhip:"#ffefd5",plum:"#dda0dd",blanchedalmond:"#ffebcd",black:"#000000",gold:"#ffd700",goldenrod:"#daa520",gainsboro:"#dcdcdc",cornsilk:"#fff8dc",cornflowerblue:"#6495ed",burlywood:"#deb887",aquamarine:"#7fffd4",beige:"#f5f5dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkkhaki:"#bdb76b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",peachpuff:"#ffdab9",darkmagenta:"#8b008b",darkred:"#8b0000",darkorchid:"#9932cc",darkorange:"#ff8c00",darkslateblue:"#483d8b",gray:"#808080",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",deeppink:"#ff1493",deepskyblue:"#00bfff",wheat:"#f5deb3",firebrick:"#b22222",floralwhite:"#fffaf0",ghostwhite:"#f8f8ff",darkviolet:"#9400d3",magenta:"#ff00ff",green:"#008000",dodgerblue:"#1e90ff",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",blueviolet:"#8a2be2",forestgreen:"#228b22",lawngreen:"#7cfc00",indianred:"#cd5c5c",indigo:"#4b0082",fuchsia:"#ff00ff",brown:"#a52a2a",maroon:"#800000",mediumblue:"#0000cd",lightcoral:"#f08080",darkturquoise:"#00ced1",lightcyan:"#e0ffff",ivory:"#fffff0",lightyellow:"#ffffe0",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",linen:"#faf0e6",mediumaquamarine:"#66cdaa",lemonchiffon:"#fffacd",lime:"#00ff00",khaki:"#f0e68c",mediumseagreen:"#3cb371",limegreen:"#32cd32",mediumspringgreen:"#00fa9a",lightskyblue:"#87cefa",lightblue:"#add8e6",midnightblue:"#191970",lightpink:"#ffb6c1",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",mintcream:"#f5fffa",lightslategray:"#778899",lightslategrey:"#778899",navajowhite:"#ffdead",navy:"#000080",mediumvioletred:"#c71585",powderblue:"#b0e0e6",palegoldenrod:"#eee8aa",oldlace:"#fdf5e6",paleturquoise:"#afeeee",mediumturquoise:"#48d1cc",mediumorchid:"#ba55d3",rebeccapurple:"#663399",lightsteelblue:"#b0c4de",mediumslateblue:"#7b68ee",thistle:"#d8bfd8",tan:"#d2b48c",orchid:"#da70d6",mediumpurple:"#9370db",purple:"#800080",pink:"#ffc0cb",skyblue:"#87ceeb",springgreen:"#00ff7f",palegreen:"#98fb98",red:"#ff0000",yellow:"#ffff00",slateblue:"#6a5acd",lavenderblush:"#fff0f5",peru:"#cd853f",palevioletred:"#db7093",violet:"#ee82ee",teal:"#008080",slategray:"#708090",slategrey:"#708090",aliceblue:"#f0f8ff",darkseagreen:"#8fbc8f",darkolivegreen:"#556b2f",greenyellow:"#adff2f",seagreen:"#2e8b57",seashell:"#fff5ee",tomato:"#ff6347",silver:"#c0c0c0",sienna:"#a0522d",lavender:"#e6e6fa",lightgreen:"#90ee90",orange:"#ffa500",orangered:"#ff4500",steelblue:"#4682b4",royalblue:"#4169e1",turquoise:"#40e0d0",yellowgreen:"#9acd32",salmon:"#fa8072",saddlebrown:"#8b4513",sandybrown:"#f4a460",rosybrown:"#bc8f8f",darksalmon:"#e9967a",lightgoldenrodyellow:"#fafad2",snow:"#fffafa",lightgrey:"#d3d3d3",lightgray:"#d3d3d3",dimgray:"#696969",dimgrey:"#696969",olivedrab:"#6b8e23",olive:"#808000"},r={};for(var i in n)r[n[i]]=i;var a={};t.prototype.toName=function(s){if(!(this.rgba.a||this.rgba.r||this.rgba.g||this.rgba.b))return"transparent";var o,c,l=r[this.toHex()];if(l)return l;if(s!=null&&s.closest){var d=this.toRgb(),u=1/0,h="black";if(!a.length)for(var f in n)a[f]=new t(n[f]).toRgb();for(var p in n){var m=(o=d,c=a[p],Math.pow(o.r-c.r,2)+Math.pow(o.g-c.g,2)+Math.pow(o.b-c.b,2));m<u&&(u=m,h=p)}return h}},e.string.push([function(s){var o=s.toLowerCase(),c=o==="transparent"?"#0000":n[o];return typeof c=="string"?new t(c).toRgb():null},"name"])};lJ([uJ]);const Xp=class I0{constructor(e=16777215){this._value=null,this._components=new Float32Array(4),this._components.fill(1),this._int=16777215,this.value=e}get red(){return this._components[0]}get green(){return this._components[1]}get blue(){return this._components[2]}get alpha(){return this._components[3]}setValue(e){return this.value=e,this}set value(e){if(e instanceof I0)this._value=this._cloneSource(e._value),this._int=e._int,this._components.set(e._components);else{if(e===null)throw new Error("Cannot set Color#value to null");(this._value===null||!this._isSourceEqual(this._value,e))&&(this._value=this._cloneSource(e),this._normalize(this._value))}}get value(){return this._value}_cloneSource(e){return typeof e=="string"||typeof e=="number"||e instanceof Number||e===null?e:Array.isArray(e)||ArrayBuffer.isView(e)?e.slice(0):typeof e=="object"&&e!==null?{...e}:e}_isSourceEqual(e,n){const r=typeof e;if(r!==typeof n)return!1;if(r==="number"||r==="string"||e instanceof Number)return e===n;if(Array.isArray(e)&&Array.isArray(n)||ArrayBuffer.isView(e)&&ArrayBuffer.isView(n))return e.length!==n.length?!1:e.every((a,s)=>a===n[s]);if(e!==null&&n!==null){const a=Object.keys(e),s=Object.keys(n);return a.length!==s.length?!1:a.every(o=>e[o]===n[o])}return e===n}toRgba(){const[e,n,r,i]=this._components;return{r:e,g:n,b:r,a:i}}toRgb(){const[e,n,r]=this._components;return{r:e,g:n,b:r}}toRgbaString(){const[e,n,r]=this.toUint8RgbArray();return`rgba(${e},${n},${r},${this.alpha})`}toUint8RgbArray(e){const[n,r,i]=this._components;return this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb),e[0]=Math.round(n*255),e[1]=Math.round(r*255),e[2]=Math.round(i*255),e}toArray(e){this._arrayRgba||(this._arrayRgba=[]),e||(e=this._arrayRgba);const[n,r,i,a]=this._components;return e[0]=n,e[1]=r,e[2]=i,e[3]=a,e}toRgbArray(e){this._arrayRgb||(this._arrayRgb=[]),e||(e=this._arrayRgb);const[n,r,i]=this._components;return e[0]=n,e[1]=r,e[2]=i,e}toNumber(){return this._int}toBgrNumber(){const[e,n,r]=this.toUint8RgbArray();return(r<<16)+(n<<8)+e}toLittleEndianNumber(){const e=this._int;return(e>>16)+(e&65280)+((e&255)<<16)}multiply(e){const[n,r,i,a]=I0._temp.setValue(e)._components;return this._components[0]*=n,this._components[1]*=r,this._components[2]*=i,this._components[3]*=a,this._refreshInt(),this._value=null,this}premultiply(e,n=!0){return n&&(this._components[0]*=e,this._components[1]*=e,this._components[2]*=e),this._components[3]=e,this._refreshInt(),this._value=null,this}toPremultiplied(e,n=!0){if(e===1)return(255<<24)+this._int;if(e===0)return n?0:this._int;let r=this._int>>16&255,i=this._int>>8&255,a=this._int&255;return n&&(r=r*e+.5|0,i=i*e+.5|0,a=a*e+.5|0),(e*255<<24)+(r<<16)+(i<<8)+a}toHex(){const e=this._int.toString(16);return`#${"000000".substring(0,6-e.length)+e}`}toHexa(){const n=Math.round(this._components[3]*255).toString(16);return this.toHex()+"00".substring(0,2-n.length)+n}setAlpha(e){return this._components[3]=this._clamp(e),this._value=null,this}_normalize(e){let n,r,i,a;if((typeof e=="number"||e instanceof Number)&&e>=0&&e<=16777215){const s=e;n=(s>>16&255)/255,r=(s>>8&255)/255,i=(s&255)/255,a=1}else if((Array.isArray(e)||e instanceof Float32Array)&&e.length>=3&&e.length<=4)e=this._clamp(e),[n,r,i,a=1]=e;else if((e instanceof Uint8Array||e instanceof Uint8ClampedArray)&&e.length>=3&&e.length<=4)e=this._clamp(e,0,255),[n,r,i,a=255]=e,n/=255,r/=255,i/=255,a/=255;else if(typeof e=="string"||typeof e=="object"){if(typeof e=="string"){const o=I0.HEX_PATTERN.exec(e);o&&(e=`#${o[2]}`)}const s=Ho(e);s.isValid()&&({r:n,g:r,b:i,a}=s.rgba,n/=255,r/=255,i/=255)}if(n!==void 0)this._components[0]=n,this._components[1]=r,this._components[2]=i,this._components[3]=a,this._refreshInt();else throw new Error(`Unable to convert color ${e}`)}_refreshInt(){this._clamp(this._components);const[e,n,r]=this._components;this._int=(e*255<<16)+(n*255<<8)+(r*255|0)}_clamp(e,n=0,r=1){return typeof e=="number"?Math.min(Math.max(e,n),r):(e.forEach((i,a)=>{e[a]=Math.min(Math.max(i,n),r)}),e)}static isColorLike(e){return e==null?!1:typeof e=="number"||typeof e=="string"||e instanceof Number||e instanceof I0||Array.isArray(e)||e instanceof Uint8Array||e instanceof Uint8ClampedArray||e instanceof Float32Array||e.r!==void 0&&e.g!==void 0&&e.b!==void 0||e.r!==void 0&&e.g!==void 0&&e.b!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0||e.h!==void 0&&e.s!==void 0&&e.l!==void 0&&e.a!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0||e.h!==void 0&&e.s!==void 0&&e.v!==void 0&&e.a!==void 0}};Xp.shared=new Xp;Xp._temp=new Xp;Xp.HEX_PATTERN=/^(#|0x)?(([a-f0-9]{3}){1,2}([a-f0-9]{2})?)$/i;let dJ=Xp;const fJ={cullArea:null,cullable:!1,cullableChildren:!0};let YT=0;const e8=500;function hc(...t){YT!==e8&&(YT++,YT===e8?console.warn("PixiJS Warning: too many warnings, no more warnings will be reported to the console by PixiJS."):console.warn("PixiJS Warning: ",...t))}const K9={_registeredResources:new Set,register(t){this._registeredResources.add(t)},unregister(t){this._registeredResources.delete(t)},release(){this._registeredResources.forEach(t=>t.clear())},get registeredCount(){return this._registeredResources.size},isRegistered(t){return this._registeredResources.has(t)},reset(){this._registeredResources.clear()}};class hJ{constructor(e,n){this._pool=[],this._count=0,this._index=0,this._classType=e,n&&this.prepopulate(n)}prepopulate(e){for(let n=0;n<e;n++)this._pool[this._index++]=new this._classType;this._count+=e}get(e){var r;let n;return this._index>0?n=this._pool[--this._index]:(n=new this._classType,this._count++),(r=n.init)==null||r.call(n,e),n}return(e){var n;(n=e.reset)==null||n.call(e),this._pool[this._index++]=e}get totalSize(){return this._count}get totalFree(){return this._index}get totalUsed(){return this._count-this._index}clear(){if(this._pool.length>0&&this._pool[0].destroy)for(let e=0;e<this._index;e++)this._pool[e].destroy();this._pool.length=0,this._count=0,this._index=0}}class pJ{constructor(){this._poolsByClass=new Map}prepopulate(e,n){this.getPool(e).prepopulate(n)}get(e,n){return this.getPool(e).get(n)}return(e){this.getPool(e.constructor).return(e)}getPool(e){return this._poolsByClass.has(e)||this._poolsByClass.set(e,new hJ(e)),this._poolsByClass.get(e)}stats(){const e={};return this._poolsByClass.forEach(n=>{const r=e[n._classType.name]?n._classType.name+n._classType.ID:n._classType.name;e[r]={free:n.totalFree,used:n.totalUsed,size:n.totalSize}}),e}clear(){this._poolsByClass.forEach(e=>e.clear()),this._poolsByClass.clear()}}const wf=new pJ;K9.register(wf);const mJ={get isCachedAsTexture(){var t;return!!((t=this.renderGroup)!=null&&t.isCachedAsTexture)},cacheAsTexture(t){typeof t=="boolean"&&t===!1?this.disableRenderGroup():(this.enableRenderGroup(),this.renderGroup.enableCacheAsTexture(t===!0?{}:t))},updateCacheTexture(){var t;(t=this.renderGroup)==null||t.updateCacheTexture()},get cacheAsBitmap(){return this.isCachedAsTexture},set cacheAsBitmap(t){Ci("v8.6.0","cacheAsBitmap is deprecated, use cacheAsTexture instead."),this.cacheAsTexture(t)}};function gJ(t,e,n){const r=t.length;let i;if(e>=r||n===0)return;n=e+n>r?r-e:n;const a=r-n;for(i=e;i<a;++i)t[i]=t[i+n];t.length=a}const yJ={allowChildren:!0,removeChildren(t=0,e){var a;const n=e??this.children.length,r=n-t,i=[];if(r>0&&r<=n){for(let o=n-1;o>=t;o--){const c=this.children[o];c&&(i.push(c),c.parent=null)}gJ(this.children,t,r);const s=this.renderGroup||this.parentRenderGroup;s&&s.removeChildren(i);for(let o=0;o<i.length;++o){const c=i[o];(a=c.parentRenderLayer)==null||a.detach(c),this.emit("childRemoved",c,this,o),i[o].emit("removed",this)}return i.length>0&&this._didViewChangeTick++,i}else if(r===0&&this.children.length===0)return i;throw new RangeError("removeChildren: numeric values are outside the acceptable range.")},removeChildAt(t){const e=this.getChildAt(t);return this.removeChild(e)},getChildAt(t){if(t<0||t>=this.children.length)throw new Error(`getChildAt: Index (${t}) does not exist.`);return this.children[t]},setChildIndex(t,e){if(e<0||e>=this.children.length)throw new Error(`The index ${e} supplied is out of bounds ${this.children.length}`);this.getChildIndex(t),this.addChildAt(t,e)},getChildIndex(t){const e=this.children.indexOf(t);if(e===-1)throw new Error("The supplied Container must be a child of the caller");return e},addChildAt(t,e){this.allowChildren||Ci(Wp,"addChildAt: Only Containers will be allowed to add children in v8.0.0");const{children:n}=this;if(e<0||e>n.length)throw new Error(`${t}addChildAt: The index ${e} supplied is out of bounds ${n.length}`);const r=t.parent===this;if(t.parent){const a=t.parent.children.indexOf(t);if(r){if(a===e)return t;t.parent.children.splice(a,1)}else t.removeFromParent()}e===n.length?n.push(t):n.splice(e,0,t);const i=this.renderGroup||this.parentRenderGroup;return this.sortableChildren&&(this.sortDirty=!0),r?(i&&(i.structureDidChange=!0),t):(t.parent=this,t.didChange=!0,t._updateFlags=15,i&&i.addChild(t),this.emit("childAdded",t,this,e),t.emit("added",this),t)},swapChildren(t,e){if(t===e)return;const n=this.getChildIndex(t),r=this.getChildIndex(e);this.children[n]=e,this.children[r]=t;const i=this.renderGroup||this.parentRenderGroup;i&&(i.structureDidChange=!0),this._didContainerChangeTick++},removeFromParent(){var t;(t=this.parent)==null||t.removeChild(this)},reparentChild(...t){return t.length===1?this.reparentChildAt(t[0],this.children.length):(t.forEach(e=>this.reparentChildAt(e,this.children.length)),t[0])},reparentChildAt(t,e){if(t.parent===this)return this.setChildIndex(t,e),t;const n=t.worldTransform.clone();t.removeFromParent(),this.addChildAt(t,e);const r=this.worldTransform.clone();return r.invert(),n.prepend(r),t.setFromMatrix(n),t},replaceChild(t,e){t.updateLocalTransform(),this.addChildAt(e,this.getChildIndex(t)),e.setFromMatrix(t.localTransform),e.updateLocalTransform(),this.removeChild(t)}},bJ={collectRenderables(t,e,n){this.parentRenderLayer&&this.parentRenderLayer!==n||this.globalDisplayStatus<7||!this.includeInBuild||(this.sortableChildren&&this.sortChildren(),this.isSimple?this.collectRenderablesSimple(t,e,n):this.renderGroup?e.renderPipes.renderGroup.addRenderGroup(this.renderGroup,t):this.collectRenderablesWithEffects(t,e,n))},collectRenderablesSimple(t,e,n){const r=this.children,i=r.length;for(let a=0;a<i;a++)r[a].collectRenderables(t,e,n)},collectRenderablesWithEffects(t,e,n){const{renderPipes:r}=e;for(let i=0;i<this.effects.length;i++){const a=this.effects[i];r[a.pipe].push(a,this,t)}this.collectRenderablesSimple(t,e,n);for(let i=this.effects.length-1;i>=0;i--){const a=this.effects[i];r[a.pipe].pop(a,this,t)}}};class t8{constructor(){this.pipe="filter",this.priority=1}destroy(){for(let e=0;e<this.filters.length;e++)this.filters[e].destroy();this.filters=null,this.filterArea=null}}class xJ{constructor(){this._effectClasses=[],this._tests=[],this._initialized=!1}init(){this._initialized||(this._initialized=!0,this._effectClasses.forEach(e=>{this.add({test:e.test,maskClass:e})}))}add(e){this._tests.push(e)}getMaskEffect(e){this._initialized||this.init();for(let n=0;n<this._tests.length;n++){const r=this._tests[n];if(r.test(e))return wf.get(r.maskClass,e)}return e}returnMaskEffect(e){wf.return(e)}}const KC=new xJ;Rf.handleByList(ba.MaskEffect,KC._effectClasses);const vJ={_maskEffect:null,_maskOptions:{inverse:!1,channel:"red"},_filterEffect:null,effects:[],_markStructureAsChanged(){const t=this.renderGroup||this.parentRenderGroup;t&&(t.structureDidChange=!0)},addEffect(t){this.effects.indexOf(t)===-1&&(this.effects.push(t),this.effects.sort((n,r)=>n.priority-r.priority),this._markStructureAsChanged(),this._updateIsSimple())},removeEffect(t){const e=this.effects.indexOf(t);e!==-1&&(this.effects.splice(e,1),this._markStructureAsChanged(),this._updateIsSimple())},set mask(t){const e=this._maskEffect;(e==null?void 0:e.mask)!==t&&(e&&(this.removeEffect(e),KC.returnMaskEffect(e),this._maskEffect=null),t!=null&&(this._maskEffect=KC.getMaskEffect(t),this.addEffect(this._maskEffect)))},get mask(){var t;return(t=this._maskEffect)==null?void 0:t.mask},setMask(t){this._maskOptions={...this._maskOptions,...t},t.mask&&(this.mask=t.mask),this._markStructureAsChanged()},set filters(t){var a;!Array.isArray(t)&&t&&(t=[t]);const e=this._filterEffect||(this._filterEffect=new t8);t=t;const n=(t==null?void 0:t.length)>0,r=((a=e.filters)==null?void 0:a.length)>0,i=n!==r;t=Array.isArray(t)?t.slice(0):t,e.filters=Object.freeze(t),i&&(n?this.addEffect(e):(this.removeEffect(e),e.filters=t??null))},get filters(){var t;return(t=this._filterEffect)==null?void 0:t.filters},set filterArea(t){this._filterEffect||(this._filterEffect=new t8),this._filterEffect.filterArea=t},get filterArea(){var t;return(t=this._filterEffect)==null?void 0:t.filterArea}},wJ={label:null,get name(){return Ci(Wp,"Container.name property has been removed, use Container.label instead"),this.label},set name(t){Ci(Wp,"Container.name property has been removed, use Container.label instead"),this.label=t},getChildByName(t,e=!1){return this.getChildByLabel(t,e)},getChildByLabel(t,e=!1){const n=this.children;for(let r=0;r<n.length;r++){const i=n[r];if(i.label===t||t instanceof RegExp&&t.test(i.label))return i}if(e)for(let r=0;r<n.length;r++){const a=n[r].getChildByLabel(t,!0);if(a)return a}return null},getChildrenByLabel(t,e=!1,n=[]){const r=this.children;for(let i=0;i<r.length;i++){const a=r[i];(a.label===t||t instanceof RegExp&&t.test(a.label))&&n.push(a)}if(e)for(let i=0;i<r.length;i++)r[i].getChildrenByLabel(t,!0,n);return n}},pa=wf.getPool(yr),Jc=wf.getPool(Xu),TJ=new yr,kJ={getFastGlobalBounds(t,e){e||(e=new Xu),e.clear(),this._getGlobalBoundsRecursive(!!t,e,this.parentRenderLayer),e.isValid||e.set(0,0,0,0);const n=this.renderGroup||this.parentRenderGroup;return e.applyMatrix(n.worldTransform),e},_getGlobalBoundsRecursive(t,e,n){let r=e;if(t&&this.parentRenderLayer&&this.parentRenderLayer!==n||this.localDisplayStatus!==7||!this.measurable)return;const i=!!this.effects.length;if((this.renderGroup||i)&&(r=Jc.get().clear()),this.boundsArea)e.addRect(this.boundsArea,this.worldTransform);else{if(this.renderPipeId){const s=this.bounds;r.addFrame(s.minX,s.minY,s.maxX,s.maxY,this.groupTransform)}const a=this.children;for(let s=0;s<a.length;s++)a[s]._getGlobalBoundsRecursive(t,r,n)}if(i){let a=!1;const s=this.renderGroup||this.parentRenderGroup;for(let o=0;o<this.effects.length;o++)this.effects[o].addBounds&&(a||(a=!0,r.applyMatrix(s.worldTransform)),this.effects[o].addBounds(r,!0));a&&r.applyMatrix(s.worldTransform.copyTo(TJ).invert()),e.addBounds(r),Jc.return(r)}else this.renderGroup&&(e.addBounds(r,this.relativeGroupTransform),Jc.return(r))}};function Z9(t,e,n){n.clear();let r,i;return t.parent?e?r=t.parent.worldTransform:(i=pa.get().identity(),r=W4(t,i)):r=yr.IDENTITY,Q9(t,n,r,e),i&&pa.return(i),n.isValid||n.set(0,0,0,0),n}function Q9(t,e,n,r){var o,c;if(!t.visible||!t.measurable)return;let i;r?i=t.worldTransform:(t.updateLocalTransform(),i=pa.get(),i.appendFrom(t.localTransform,n));const a=e,s=!!t.effects.length;if(s&&(e=Jc.get().clear()),t.boundsArea)e.addRect(t.boundsArea,i);else{const l=t.bounds;l&&!l.isEmpty()&&(e.matrix=i,e.addBounds(l));for(let d=0;d<t.children.length;d++)Q9(t.children[d],e,i,r)}if(s){for(let l=0;l<t.effects.length;l++)(c=(o=t.effects[l]).addBounds)==null||c.call(o,e);a.addBounds(e,yr.IDENTITY),Jc.return(e)}r||pa.return(i)}function W4(t,e){const n=t.parent;return n&&(W4(n,e),n.updateLocalTransform(),e.append(n.localTransform)),e}function SJ(t,e){if(t===16777215||!e)return e;if(e===16777215||!t)return t;const n=t>>16&255,r=t>>8&255,i=t&255,a=e>>16&255,s=e>>8&255,o=e&255,c=n*a/255|0,l=r*s/255|0,d=i*o/255|0;return(c<<16)+(l<<8)+d}const n8=16777215;function r8(t,e){return t===n8?e:e===n8?t:SJ(t,e)}function lg(t){return((t&255)<<16)+(t&65280)+(t>>16&255)}const CJ={getGlobalAlpha(t){if(t)return this.renderGroup?this.renderGroup.worldAlpha:this.parentRenderGroup?this.parentRenderGroup.worldAlpha*this.alpha:this.alpha;let e=this.alpha,n=this.parent;for(;n;)e*=n.alpha,n=n.parent;return e},getGlobalTransform(t=new yr,e){if(e)return t.copyFrom(this.worldTransform);this.updateLocalTransform();const n=W4(this,pa.get().identity());return t.appendFrom(this.localTransform,n),pa.return(n),t},getGlobalTint(t){if(t)return this.renderGroup?lg(this.renderGroup.worldColor):this.parentRenderGroup?lg(r8(this.localColor,this.parentRenderGroup.worldColor)):this.tint;let e=this.localColor,n=this.parent;for(;n;)e=r8(e,n.localColor),n=n.parent;return lg(e)}};function J9(t,e,n){return e.clear(),n||(n=yr.IDENTITY),$9(t,e,n,t,!0),e.isValid||e.set(0,0,0,0),e}function $9(t,e,n,r,i){var c,l;let a;if(i)a=pa.get(),a=n.copyTo(a);else{if(!t.visible||!t.measurable)return;t.updateLocalTransform();const d=t.localTransform;a=pa.get(),a.appendFrom(d,n)}const s=e,o=!!t.effects.length;if(o&&(e=Jc.get().clear()),t.boundsArea)e.addRect(t.boundsArea,a);else{t.renderPipeId&&(e.matrix=a,e.addBounds(t.bounds));const d=t.children;for(let u=0;u<d.length;u++)$9(d[u],e,a,r,!1)}if(o){for(let d=0;d<t.effects.length;d++)(l=(c=t.effects[d]).addLocalBounds)==null||l.call(c,e,r);s.addBounds(e,yr.IDENTITY),Jc.return(e)}pa.return(a)}function ez(t,e){const n=t.children;for(let r=0;r<n.length;r++){const i=n[r],a=i.uid,s=(i._didViewChangeTick&65535)<<16|i._didContainerChangeTick&65535,o=e.index;(e.data[o]!==a||e.data[o+1]!==s)&&(e.data[e.index]=a,e.data[e.index+1]=s,e.didChange=!0),e.index=o+2,i.children.length&&ez(i,e)}return e.didChange}const EJ=new yr,MJ={_localBoundsCacheId:-1,_localBoundsCacheData:null,_setWidth(t,e){const n=Math.sign(this.scale.x)||1;e!==0?this.scale.x=t/e*n:this.scale.x=n},_setHeight(t,e){const n=Math.sign(this.scale.y)||1;e!==0?this.scale.y=t/e*n:this.scale.y=n},getLocalBounds(){this._localBoundsCacheData||(this._localBoundsCacheData={data:[],index:1,didChange:!1,localBounds:new Xu});const t=this._localBoundsCacheData;return t.index=1,t.didChange=!1,t.data[0]!==this._didViewChangeTick&&(t.didChange=!0,t.data[0]=this._didViewChangeTick),ez(this,t),t.didChange&&J9(this,t.localBounds,EJ),t.localBounds},getBounds(t,e){return Z9(this,t,e||new Xu)}},AJ={_onRender:null,set onRender(t){const e=this.renderGroup||this.parentRenderGroup;if(!t){this._onRender&&(e==null||e.removeOnRender(this)),this._onRender=null;return}this._onRender||e==null||e.addOnRender(this),this._onRender=t},get onRender(){return this._onRender}},IJ={_zIndex:0,sortDirty:!1,sortableChildren:!1,get zIndex(){return this._zIndex},set zIndex(t){this._zIndex!==t&&(this._zIndex=t,this.depthOfChildModified())},depthOfChildModified(){this.parent&&(this.parent.sortableChildren=!0,this.parent.sortDirty=!0),this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0)},sortChildren(){this.sortDirty&&(this.sortDirty=!1,this.children.sort(DJ))}};function DJ(t,e){return t._zIndex-e._zIndex}const PJ={getGlobalPosition(t=new rc,e=!1){return this.parent?this.parent.toGlobal(this._position,t,e):(t.x=this._position.x,t.y=this._position.y),t},toGlobal(t,e,n=!1){const r=this.getGlobalTransform(pa.get(),n);return e=r.apply(t,e),pa.return(r),e},toLocal(t,e,n,r){e&&(t=e.toGlobal(t,n,r));const i=this.getGlobalTransform(pa.get(),r);return n=i.applyInverse(t,n),pa.return(i),n}};class NJ{constructor(){this.uid=gu("instructionSet"),this.instructions=[],this.instructionSize=0,this.renderables=[],this.gcTick=0}reset(){this.instructionSize=0}destroy(){var e,n;if(this.renderPipes)for(const r in this.renderPipes)(n=(e=this.renderPipes[r]).destroyInstructionSet)==null||n.call(e,this);this.instructions.length=0,this.renderables.length=0,this.renderPipes=null,this.gcTick=0}add(e){this.instructions[this.instructionSize++]=e}log(){this.instructions.length=this.instructionSize,console.table(this.instructions,["type","action"])}}class OJ{constructor(){this._screenSizes=new Map,this._widths=[],this._heights=[],this._logicalWidths=[],this._logicalHeights=[]}get size(){return this._screenSizes.size}set(e,n,r,i=1){const a=this._screenSizes.get(e);return a&&a.pixelWidth===n&&a.pixelHeight===r&&a.resolution===i?!1:(this._screenSizes.set(e,{pixelWidth:n,pixelHeight:r,resolution:i}),this._update(),!0)}remove(e){return this._screenSizes.delete(e)?(this._update(),!0):!1}getFittingWidth(e,n=1){return this._getFittingAxis(e,n,this._widths,this._logicalWidths)}getFittingHeight(e,n=1){return this._getFittingAxis(e,n,this._heights,this._logicalHeights)}hasWidth(e){return this._widths.includes(e)}hasHeight(e){return this._heights.includes(e)}_getFittingAxis(e,n,r,i){let a;for(let s=0;s<r.length;s++)if(r[s]>=e){a=r[s];break}for(let s=0;s<i.length;s++){const o=Math.ceil(i[s]*n-1e-6);if(o>=e)return a===void 0?o:Math.min(a,o)}return a}_update(){const e=[...this._screenSizes.values()];this._widths=$y(e.map(n=>n.pixelWidth)),this._heights=$y(e.map(n=>n.pixelHeight)),this._logicalWidths=$y(e.map(n=>n.pixelWidth/n.resolution)),this._logicalHeights=$y(e.map(n=>n.pixelHeight/n.resolution))}}function $y(t){return t.filter((e,n)=>t.indexOf(e)===n).sort((e,n)=>e-n)}let RJ=0;const KT=32767,BJ=4294967296,FJ=8589934592,i8=Object.create(null);let zJ=0;function LJ(t){const e=i8[t];return e!==void 0?e:i8[t]=zJ++}function _J(t,e,n,r,i,a){return(t<<17)+(e<<2)+((r?1:0)<<1)+(n?1:0)+(a==="nearest"?1:0)*BJ+LJ(i)*FJ}class jJ extends G1{constructor(e){super(),this._buckets=new Map,this._poolKey=Object.create(null),this._poolStyle=Object.create(null),this._screens=new OJ,this._enableFullScreen=!1,this.textureOptions=e||{}}get textureStyle(){return Ci(nh,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle||(this._textureStyle=new Sx(this.textureOptions)),this._textureStyle}set textureStyle(e){Ci(nh,"TexturePool.textureStyle is no longer used, pooled textures carry their own style. Pass scaleMode in the request instead."),this._textureStyle=e}get enableFullScreen(){return Ci(nh,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){Ci(nh,"TexturePool.enableFullScreen is no longer used, the pool sizes textures to the screens registered with setScreenSize."),this._enableFullScreen=e}createTexture(...e){let n=e[0];typeof n=="number"&&(Ci(nh,"TexturePool.createTexture params are now an options object. See params: { width, height, antialias, autoGenerateMipmaps }"),n={width:n,height:e[1],antialias:e[2]??!1,autoGenerateMipmaps:e[3]??!1});const r=n.format??this.textureOptions.format??hs.defaultOptions.format,i=n.scaleMode??this.textureOptions.scaleMode??Sx.defaultOptions.scaleMode,a=new hs({...this.textureOptions,width:n.width,height:n.height,resolution:1,antialias:n.antialias??!1,autoGarbageCollect:!1,autoGenerateMipmaps:n.autoGenerateMipmaps??!1,format:r,scaleMode:i});return new ni({source:a,label:`texturePool_${RJ++}`})}getOptimalTexture(...e){let n=e[0];typeof n=="number"&&(Ci(nh,"TexturePool.getOptimalTexture params are now an options object. See params: { width, height, resolution, antialias, autoGenerateMipmaps }"),n={width:n,height:e[1],resolution:e[2]??1,antialias:e[3]??!1,autoGenerateMipmaps:e[4]??!1});const{width:r,height:i}=this.getOptimalSize(n.width,n.height,n.resolution??1);return this._getTexture(r,i,n)}getAlignedTexture(e,n,r){const i=e.source,a=n/i._resolution;return this._getTexture(Math.ceil(i.pixelWidth*a-1e-6),Math.ceil(i.pixelHeight*a-1e-6),{width:e.frame.width,height:e.frame.height,resolution:n,format:r})}_getTexture(e,n,r){const i=r.width,a=r.height,s=r.resolution??1,o=r.antialias??!1,c=r.autoGenerateMipmaps??!1,l=r.format??this.textureOptions.format??hs.defaultOptions.format,d=r.scaleMode??this.textureOptions.scaleMode??Sx.defaultOptions.scaleMode;(e>KT||n>KT)&&hc(`TexturePool: ${e}x${n} is larger than the ${KT}px pool key limit, textures of this size may be pooled together`);const u=_J(e,n,o,c,l,d);let h=this._buckets.get(u);h||(h=[],this._buckets.set(u,h));let f=h.pop();return f||(f=this.createTexture({width:e,height:n,antialias:o,autoGenerateMipmaps:c,format:l,scaleMode:d}),this._poolStyle[f.uid]=f.source.style),f.source._resolution=s,f.source.width=e/s,f.source.height=n/s,f.source.pixelWidth=e,f.source.pixelHeight=n,f.frame.x=0,f.frame.y=0,f.frame.width=i,f.frame.height=a,f.updateUvs(),this._poolKey[f.uid]=u,f}getOptimalSize(e,n,r=1){const i=Math.ceil(e*r-1e-6),a=Math.ceil(n*r-1e-6),s=VD(i),o=this._screens.getFittingWidth(i,r),c=VD(a),l=this._screens.getFittingHeight(a,r);return{width:o!==void 0?Math.min(o,s):s,height:l!==void 0?Math.min(l,c):c}}getSameSizeTexture(e,n=!1){const r=e.source;return this.getOptimalTexture({width:e.width,height:e.height,resolution:r._resolution,antialias:n})}returnTexture(e,n=!1){const r=e.uid,i=this._poolKey[r];if(i===void 0){hc("TexturePool: returnTexture was passed a texture that did not come from this pool, ignoring it");return}const a=this._poolStyle[r];n&&e.source.style!==a&&(e.source.style=a);const s=this._buckets.get(i);if(!s){this._dropTextures([e],!0);return}s.push(e)}setScreenSize(e,n,r,i=1){this._screens.set(e,n,r,i)&&this._pruneScreenTextures()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenTextures()}_pruneScreenTextures(){for(const[e,n]of this._buckets){const r=e>>>0,i=r>>>17,a=r>>>2&32767;(Ev(i)||this._screens.hasWidth(i))&&(Ev(a)||this._screens.hasHeight(a))||(this._dropTextures(n,!0),this._buckets.delete(e))}}_dropTextures(e,n){n&&e.length>0&&this.emit("evict");for(let r=0;r<e.length;r++){const i=e[r];delete this._poolKey[i.uid],delete this._poolStyle[i.uid],n&&i.destroy(!0)}}clear(e){for(const n of this._buckets.values())this._dropTextures(n,e!==!1);this._buckets.clear()}}const tz=new jJ;K9.register(tz);class UJ{constructor(){this.renderPipeId="renderGroup",this.root=null,this.canBundle=!1,this.renderGroupParent=null,this.renderGroupChildren=[],this.worldTransform=new yr,this.worldColorAlpha=4294967295,this.worldColor=16777215,this.worldAlpha=1,this.childrenToUpdate=Object.create(null),this.updateTick=0,this.gcTick=0,this.childrenRenderablesToUpdate={list:[],index:0},this.structureDidChange=!0,this.instructionSet=new NJ,this._onRenderContainers=[],this.textureNeedsUpdate=!0,this.isCachedAsTexture=!1,this._matrixDirty=7}init(e){this.root=e,e._onRender&&this.addOnRender(e),e.didChange=!0;const n=e.children;for(let r=0;r<n.length;r++){const i=n[r];i._updateFlags=15,this.addChild(i)}}enableCacheAsTexture(e={}){this.textureOptions=e,this.isCachedAsTexture=!0,this.textureNeedsUpdate=!0}disableCacheAsTexture(){this.isCachedAsTexture=!1,this.texture&&(tz.returnTexture(this.texture),this.texture=null)}updateCacheTexture(){this.textureNeedsUpdate=!0;const e=this._parentCacheAsTextureRenderGroup;e&&!e.textureNeedsUpdate&&e.updateCacheTexture()}reset(){this.renderGroupChildren.length=0;for(const e in this.childrenToUpdate){const n=this.childrenToUpdate[e];n.list.fill(null),n.index=0}this.childrenRenderablesToUpdate.index=0,this.childrenRenderablesToUpdate.list.fill(null),this.root=null,this.updateTick=0,this.structureDidChange=!0,this._onRenderContainers.length=0,this.renderGroupParent=null,this.disableCacheAsTexture()}get localTransform(){return this.root.localTransform}addRenderGroupChild(e){e.renderGroupParent&&e.renderGroupParent._removeRenderGroupChild(e),e.renderGroupParent=this,this.renderGroupChildren.push(e)}_removeRenderGroupChild(e){const n=this.renderGroupChildren.indexOf(e);n>-1&&this.renderGroupChildren.splice(n,1),e.renderGroupParent=null}addChild(e){if(this.structureDidChange=!0,e.parentRenderGroup=this,e.updateTick=-1,e.parent===this.root?e.relativeRenderGroupDepth=1:e.relativeRenderGroupDepth=e.parent.relativeRenderGroupDepth+1,e.didChange=!0,this.onChildUpdate(e),e.renderGroup){this.addRenderGroupChild(e.renderGroup);return}e._onRender&&this.addOnRender(e);const n=e.children;for(let r=0;r<n.length;r++)this.addChild(n[r])}removeChild(e){if(this.structureDidChange=!0,e._onRender&&(e.renderGroup||this.removeOnRender(e)),e.parentRenderGroup=null,e.renderGroup){this._removeRenderGroupChild(e.renderGroup);return}const n=e.children;for(let r=0;r<n.length;r++)this.removeChild(n[r])}removeChildren(e){for(let n=0;n<e.length;n++)this.removeChild(e[n])}onChildUpdate(e){let n=this.childrenToUpdate[e.relativeRenderGroupDepth];n||(n=this.childrenToUpdate[e.relativeRenderGroupDepth]={index:0,list:[]}),n.list[n.index++]=e}updateRenderable(e){e.globalDisplayStatus<7||(this.instructionSet.renderPipes[e.renderPipeId].updateRenderable(e),e.didViewUpdate=!1)}onChildViewUpdate(e){this.childrenRenderablesToUpdate.list[this.childrenRenderablesToUpdate.index++]=e}get isRenderable(){return this.root.localDisplayStatus===7&&this.worldAlpha>0}addOnRender(e){this._onRenderContainers.indexOf(e)===-1&&this._onRenderContainers.push(e)}removeOnRender(e){const n=this._onRenderContainers.indexOf(e);n!==-1&&this._onRenderContainers.splice(n,1)}runOnRender(e){for(let n=0;n<this._onRenderContainers.length;n++)this._onRenderContainers[n]._onRender(e)}destroy(){var e;this.disableCacheAsTexture(),this.renderGroupParent=null,this.root=null,this.childrenRenderablesToUpdate=null,this.childrenToUpdate=null,this.renderGroupChildren=null,this._onRenderContainers=null,(e=this.instructionSet)==null||e.destroy(),this.instructionSet=null}getChildren(e=[]){const n=this.root.children;for(let r=0;r<n.length;r++)this._getChildren(n[r],e);return e}_getChildren(e,n=[]){if(n.push(e),e.renderGroup)return n;const r=e.children;for(let i=0;i<r.length;i++)this._getChildren(r[i],n);return n}invalidateMatrices(){this._matrixDirty=7}get inverseWorldTransform(){return this._matrixDirty&1?(this._matrixDirty&=-2,this._inverseWorldTransform||(this._inverseWorldTransform=new yr),this._inverseWorldTransform.copyFrom(this.worldTransform).invert()):this._inverseWorldTransform}get textureOffsetInverseTransform(){return this._matrixDirty&2?(this._matrixDirty&=-3,this._textureOffsetInverseTransform||(this._textureOffsetInverseTransform=new yr),this._textureOffsetInverseTransform.copyFrom(this.inverseWorldTransform).translate(-this._textureBounds.x,-this._textureBounds.y)):this._textureOffsetInverseTransform}get inverseParentTextureTransform(){if(!(this._matrixDirty&4))return this._inverseParentTextureTransform;this._matrixDirty&=-5;const e=this._parentCacheAsTextureRenderGroup;return e?(this._inverseParentTextureTransform||(this._inverseParentTextureTransform=new yr),this._inverseParentTextureTransform.copyFrom(this.worldTransform).prepend(e.inverseWorldTransform).translate(-e._textureBounds.x,-e._textureBounds.y)):this.worldTransform}get cacheToLocalTransform(){return this.isCachedAsTexture?this.textureOffsetInverseTransform:this._parentCacheAsTextureRenderGroup?this._parentCacheAsTextureRenderGroup.textureOffsetInverseTransform:null}}function HJ(t,e,n={}){for(const r in e)!n[r]&&e[r]!==void 0&&(t[r]=e[r])}const ZT=new Yi(null),eb=new Yi(null),QT=new Yi(null,1,1),tb=new Yi(null),a8=1,VJ=2,JT=4;class q1 extends G1{constructor(e={}){var n,r;super(),this.uid=gu("renderable"),this._updateFlags=15,this.renderGroup=null,this.parentRenderGroup=null,this.parentRenderGroupIndex=0,this.didChange=!1,this.didViewUpdate=!1,this.relativeRenderGroupDepth=0,this.children=[],this.parent=null,this.includeInBuild=!0,this.measurable=!0,this.isSimple=!0,this.parentRenderLayer=null,this.updateTick=-1,this.localTransform=new yr,this.relativeGroupTransform=new yr,this.groupTransform=this.relativeGroupTransform,this.destroyed=!1,this._position=new Yi(this,0,0),this._scale=QT,this._pivot=eb,this._origin=tb,this._skew=ZT,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._rotation=0,this.localColor=16777215,this.localAlpha=1,this.groupAlpha=1,this.groupColor=16777215,this.groupColorAlpha=4294967295,this.localBlendMode="inherit",this.groupBlendMode="normal",this.localDisplayStatus=7,this.globalDisplayStatus=7,this._didContainerChangeTick=0,this._didViewChangeTick=0,this._didLocalTransformChangeId=-1,this.effects=[],HJ(this,e,{children:!0,parent:!0,effects:!0}),(n=e.children)==null||n.forEach(i=>this.addChild(i)),(r=e.parent)==null||r.addChild(this)}static mixin(e){Ci("8.8.0","Container.mixin is deprecated, please use extensions.mixin instead."),Rf.mixin(q1,e)}set _didChangeId(e){this._didViewChangeTick=e>>12&4095,this._didContainerChangeTick=e&4095}get _didChangeId(){return this._didContainerChangeTick&4095|(this._didViewChangeTick&4095)<<12}addChild(...e){if(this.allowChildren||Ci(Wp,"addChild: Only Containers will be allowed to add children in v8.0.0"),e.length>1){for(let i=0;i<e.length;i++)this.addChild(e[i]);return e[0]}const n=e[0],r=this.renderGroup||this.parentRenderGroup;return n.parent===this?(this.children.splice(this.children.indexOf(n),1),this.children.push(n),r&&(r.structureDidChange=!0),n):(n.parent&&n.parent.removeChild(n),this.children.push(n),this.sortableChildren&&(this.sortDirty=!0),n.parent=this,n.didChange=!0,n._updateFlags=15,r&&r.addChild(n),this.emit("childAdded",n,this,this.children.length-1),n.emit("added",this),this._didViewChangeTick++,n._zIndex!==0&&n.depthOfChildModified(),n)}removeChild(...e){if(e.length>1){for(let i=0;i<e.length;i++)this.removeChild(e[i]);return e[0]}const n=e[0],r=this.children.indexOf(n);return r>-1&&(this._didViewChangeTick++,this.children.splice(r,1),this.renderGroup?this.renderGroup.removeChild(n):this.parentRenderGroup&&this.parentRenderGroup.removeChild(n),n.parentRenderLayer&&n.parentRenderLayer.detach(n),n.parent=null,this.emit("childRemoved",n,this,r),n.emit("removed",this)),n}_onUpdate(e){e&&e===this._skew&&this._updateSkew(),this._didContainerChangeTick++,!this.didChange&&(this.didChange=!0,this.parentRenderGroup&&this.parentRenderGroup.onChildUpdate(this))}set isRenderGroup(e){!!this.renderGroup!==e&&(e?this.enableRenderGroup():this.disableRenderGroup())}get isRenderGroup(){return!!this.renderGroup}enableRenderGroup(){if(this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),this.renderGroup=wf.get(UJ,this),this.groupTransform=yr.IDENTITY,e==null||e.addChild(this),this._updateIsSimple()}disableRenderGroup(){if(!this.renderGroup)return;const e=this.parentRenderGroup;e==null||e.removeChild(this),wf.return(this.renderGroup),this.renderGroup=null,this.groupTransform=this.relativeGroupTransform,e==null||e.addChild(this),this._updateIsSimple()}_updateIsSimple(){this.isSimple=!this.renderGroup&&this.effects.length===0}get worldTransform(){return this._worldTransform||(this._worldTransform=new yr),this.renderGroup?this._worldTransform.copyFrom(this.renderGroup.worldTransform):this.parentRenderGroup&&this._worldTransform.appendFrom(this.relativeGroupTransform,this.parentRenderGroup.worldTransform),this._worldTransform}get x(){return this._position.x}set x(e){this._position.x=e}get y(){return this._position.y}set y(e){this._position.y=e}get position(){return this._position}set position(e){this._position.copyFrom(e)}get rotation(){return this._rotation}set rotation(e){this._rotation!==e&&(this._rotation=e,this._onUpdate(this._skew))}get angle(){return this.rotation*VQ}set angle(e){this.rotation=e*GQ}get pivot(){return this._pivot===eb&&(this._pivot=new Yi(this,0,0)),this._pivot}set pivot(e){this._pivot===eb&&(this._pivot=new Yi(this,0,0),this._origin!==tb&&hc("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._pivot.set(e):this._pivot.copyFrom(e)}get skew(){return this._skew===ZT&&(this._skew=new Yi(this,0,0)),this._skew}set skew(e){this._skew===ZT&&(this._skew=new Yi(this,0,0)),this._skew.copyFrom(e)}get scale(){return this._scale===QT&&(this._scale=new Yi(this,1,1)),this._scale}set scale(e){this._scale===QT&&(this._scale=new Yi(this,0,0)),typeof e=="string"&&(e=parseFloat(e)),typeof e=="number"?this._scale.set(e):this._scale.copyFrom(e)}get origin(){return this._origin===tb&&(this._origin=new Yi(this,0,0)),this._origin}set origin(e){this._origin===tb&&(this._origin=new Yi(this,0,0),this._pivot!==eb&&hc("Setting both a pivot and origin on a Container is not recommended. This can lead to unexpected behavior if not handled carefully.")),typeof e=="number"?this._origin.set(e):this._origin.copyFrom(e)}get width(){return Math.abs(this.scale.x*this.getLocalBounds().width)}set width(e){const n=this.getLocalBounds().width;this._setWidth(e,n)}get height(){return Math.abs(this.scale.y*this.getLocalBounds().height)}set height(e){const n=this.getLocalBounds().height;this._setHeight(e,n)}getSize(e){e||(e={});const n=this.getLocalBounds();return e.width=Math.abs(this.scale.x*n.width),e.height=Math.abs(this.scale.y*n.height),e}setSize(e,n){const r=this.getLocalBounds();typeof e=="object"?(n=e.height??e.width,e=e.width):n??(n=e),e!==void 0&&this._setWidth(e,r.width),n!==void 0&&this._setHeight(n,r.height)}_updateSkew(){const e=this._rotation,n=this._skew;this._cx=Math.cos(e+n._y),this._sx=Math.sin(e+n._y),this._cy=-Math.sin(e-n._x),this._sy=Math.cos(e-n._x)}updateTransform(e){return this.position.set(typeof e.x=="number"?e.x:this.position.x,typeof e.y=="number"?e.y:this.position.y),this.scale.set(typeof e.scaleX=="number"?e.scaleX:this.scale.x,typeof e.scaleY=="number"?e.scaleY:this.scale.y),this.rotation=typeof e.rotation=="number"?e.rotation:this.rotation,this.skew.set(typeof e.skewX=="number"?e.skewX:this.skew.x,typeof e.skewY=="number"?e.skewY:this.skew.y),this.pivot.set(typeof e.pivotX=="number"?e.pivotX:this.pivot.x,typeof e.pivotY=="number"?e.pivotY:this.pivot.y),this.origin.set(typeof e.originX=="number"?e.originX:this.origin.x,typeof e.originY=="number"?e.originY:this.origin.y),this}setFromMatrix(e){e.decompose(this)}updateLocalTransform(){const e=this._didContainerChangeTick;if(this._didLocalTransformChangeId===e)return;this._didLocalTransformChangeId=e;const n=this.localTransform,r=this._scale,i=this._pivot,a=this._origin,s=this._position,o=r._x,c=r._y,l=i._x,d=i._y,u=-a._x,h=-a._y;n.a=this._cx*o,n.b=this._sx*o,n.c=this._cy*c,n.d=this._sy*c,n.tx=s._x-(l*n.a+d*n.c)+(u*n.a+h*n.c)-u,n.ty=s._y-(l*n.b+d*n.d)+(u*n.b+h*n.d)-h}set alpha(e){e!==this.localAlpha&&(this.localAlpha=e,this._updateFlags|=a8,this._onUpdate())}get alpha(){return this.localAlpha}set tint(e){const n=typeof e=="number"?lg(e):dJ.shared.setValue(e??16777215).toBgrNumber();n!==this.localColor&&(this.localColor=n,this._updateFlags|=a8,this._onUpdate())}get tint(){return lg(this.localColor)}set blendMode(e){this.localBlendMode!==e&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=VJ,this.localBlendMode=e,this._onUpdate())}get blendMode(){return this.localBlendMode}get visible(){return!!(this.localDisplayStatus&2)}set visible(e){const n=e?2:0;(this.localDisplayStatus&2)!==n&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=JT,this.localDisplayStatus^=2,this._onUpdate(),this.emit("visibleChanged",e))}get culled(){return!(this.localDisplayStatus&4)}set culled(e){const n=e?0:4;(this.localDisplayStatus&4)!==n&&(this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._updateFlags|=JT,this.localDisplayStatus^=4,this._onUpdate())}get renderable(){return!!(this.localDisplayStatus&1)}set renderable(e){const n=e?1:0;(this.localDisplayStatus&1)!==n&&(this._updateFlags|=JT,this.localDisplayStatus^=1,this.parentRenderGroup&&(this.parentRenderGroup.structureDidChange=!0),this._onUpdate())}get isRenderable(){return this.localDisplayStatus===7&&this.groupAlpha>0}destroy(e=!1){var i;if(this.destroyed)return;this.destroyed=!0;let n;if(this.children.length&&(n=this.removeChildren(0,this.children.length)),this.removeFromParent(),this.parent=null,this._maskEffect=null,this._filterEffect=null,this.effects=null,this._position=null,this._scale=null,this._pivot=null,this._origin=null,this._skew=null,this.emit("destroyed",this),this.removeAllListeners(),(typeof e=="boolean"?e:e==null?void 0:e.children)&&n)for(let a=0;a<n.length;++a)n[a].destroy(e);(i=this.renderGroup)==null||i.destroy(),this.renderGroup=null}}Rf.mixin(q1,yJ,kJ,PJ,AJ,MJ,vJ,wJ,IJ,fJ,mJ,CJ,bJ);class GJ extends q1{constructor(e){super(e),this.canBundle=!0,this.allowChildren=!1,this._roundPixels=0,this._lastUsed=-1,this._gpuData=Object.create(null),this.autoGarbageCollect=!0,this._gcLastUsed=-1,this._bounds=new Xu(0,1,0,0),this._boundsDirty=!0,this.autoGarbageCollect=e.autoGarbageCollect??!0}get bounds(){return this._boundsDirty?(this.updateBounds(),this._boundsDirty=!1,this._bounds):this._bounds}get roundPixels(){return!!this._roundPixels}set roundPixels(e){this._roundPixels=e?1:0}containsPoint(e){const n=this.bounds,{x:r,y:i}=e;return r>=n.minX&&r<=n.maxX&&i>=n.minY&&i<=n.maxY}onViewUpdate(){if(this._didViewChangeTick++,this._boundsDirty=!0,this.didViewUpdate)return;this.didViewUpdate=!0;const e=this.renderGroup||this.parentRenderGroup;e&&e.onChildViewUpdate(this)}unload(){var e;this.emit("unload",this);for(const n in this._gpuData)(e=this._gpuData[n])==null||e.destroy();this._gpuData=Object.create(null),this.onViewUpdate()}destroy(e){this.unload(),super.destroy(e),this._bounds=null}collectRenderablesSimple(e,n,r){const{renderPipes:i}=n;i.blendMode.pushBlendMode(this,this.groupBlendMode,e);const s=i[this.renderPipeId];s!=null&&s.addRenderable&&s.addRenderable(this,e),this.didViewUpdate=!1;const o=this.children,c=o.length;for(let l=0;l<c;l++)o[l].collectRenderables(e,n,r);i.blendMode.popBlendMode(e)}}class jg extends GJ{constructor(e=ni.EMPTY){e instanceof ni&&(e={texture:e});const{texture:n=ni.EMPTY,anchor:r,roundPixels:i,width:a,height:s,...o}=e;super({label:"Sprite",...o}),this.renderPipeId="sprite",this.batched=!0,this._visualBounds={minX:0,maxX:1,minY:0,maxY:0},this._anchor=new Yi({_onUpdate:()=>{this.onViewUpdate()}}),r?this.anchor=r:n.defaultAnchor&&(this.anchor=n.defaultAnchor),this.texture=n,this.allowChildren=!1,this.roundPixels=i??!1,a!==void 0&&(this.width=a),s!==void 0&&(this.height=s)}static from(e,n=!1){return e instanceof ni?new jg(e):new jg(ni.from(e,n))}set texture(e){e||(e=ni.EMPTY);const n=this._texture;n!==e&&(n&&n.dynamic&&n.off("update",this.onViewUpdate,this),e.dynamic&&e.on("update",this.onViewUpdate,this),this._texture=e,this._width&&this._setWidth(this._width,this._texture.orig.width),this._height&&this._setHeight(this._height,this._texture.orig.height),this.onViewUpdate())}get texture(){return this._texture}get visualBounds(){return tJ(this._visualBounds,this._anchor,this._texture),this._visualBounds}get sourceBounds(){return Ci("8.6.1","Sprite.sourceBounds is deprecated, use visualBounds instead."),this.visualBounds}updateBounds(){const e=this._anchor,n=this._texture,r=this._bounds,{width:i,height:a}=n.orig;r.minX=-e._x*i,r.maxX=r.minX+i,r.minY=-e._y*a,r.maxY=r.minY+a}destroy(e=!1){if(super.destroy(e),typeof e=="boolean"?e:e==null?void 0:e.texture){const r=typeof e=="boolean"?e:e==null?void 0:e.textureSource;this._texture.destroy(r)}this._texture=null,this._visualBounds=null,this._bounds=null,this._anchor=null}get anchor(){return this._anchor}set anchor(e){typeof e=="number"?this._anchor.set(e):this._anchor.copyFrom(e)}get width(){return Math.abs(this.scale.x)*this._texture.orig.width}set width(e){this._setWidth(e,this._texture.orig.width),this._width=e}get height(){return Math.abs(this.scale.y)*this._texture.orig.height}set height(e){this._setHeight(e,this._texture.orig.height),this._height=e}getSize(e){return e||(e={}),e.width=Math.abs(this.scale.x)*this._texture.orig.width,e.height=Math.abs(this.scale.y)*this._texture.orig.height,e}setSize(e,n){typeof e=="object"?(n=e.height??e.width,e=e.width):n??(n=e),e!==void 0&&this._setWidth(e,this._texture.orig.width),n!==void 0&&this._setHeight(n,this._texture.orig.height)}}const qJ=new Xu;function nz(t,e,n){const r=qJ;t.measurable=!0,Z9(t,n,r),e.addBoundsMask(r),t.measurable=!1}function rz(t,e,n){const r=Jc.get();t.measurable=!0;const i=pa.get().identity(),a=iz(t,n,i);J9(t,r,a),t.measurable=!1,e.addBoundsMask(r),pa.return(i),Jc.return(r)}function iz(t,e,n){return t?(t!==e&&(iz(t.parent,e,n),t.updateLocalTransform(),n.append(t.localTransform)),n):(hc("Mask bounds, renderable is not inside the root container"),n)}class az{constructor(e){this.priority=0,this.inverse=!1,this.channel="red",this.pipe="alphaMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.renderMaskToTexture=!(e instanceof jg),this.mask.renderable=this.renderMaskToTexture,this.mask.includeInBuild=!this.renderMaskToTexture,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask=null)}addBounds(e,n){this.inverse||nz(this.mask,e,n)}addLocalBounds(e,n){rz(this.mask,e,n)}containsPoint(e,n){const r=this.mask;return n(r,e)}destroy(){this.reset()}static test(e){return e instanceof jg}}az.extension=ba.MaskEffect;class sz{constructor(e){this.priority=0,this.pipe="colorMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e}destroy(){}static test(e){return typeof e=="number"}}sz.extension=ba.MaskEffect;class oz{constructor(e){this.priority=0,this.pipe="stencilMask",e!=null&&e.mask&&this.init(e.mask)}init(e){this.mask=e,this.mask.includeInBuild=!1,this.mask.measurable=!1}reset(){this.mask!==null&&(this.mask.measurable=!0,this.mask.includeInBuild=!0,this.mask=null)}addBounds(e,n){nz(this.mask,e,n)}addLocalBounds(e,n){rz(this.mask,e,n)}containsPoint(e,n){const r=this.mask;return n(r,e)}destroy(){this.reset()}static test(e){return e instanceof q1}}oz.extension=ba.MaskEffect;const WJ={createCanvas:(t,e)=>{const n=document.createElement("canvas");return n.width=t,n.height=e,n},createImage:()=>new Image,getCanvasRenderingContext2D:()=>CanvasRenderingContext2D,getWebGLRenderingContext:()=>WebGLRenderingContext,getNavigator:()=>navigator,getBaseUrl:()=>document.baseURI??window.location.href,getFontFaceSet:()=>document.fonts,fetch:(t,e)=>fetch(t,e),parseXML:t=>new DOMParser().parseFromString(t,"text/xml")};let s8=WJ;const X4={get(){return s8},set(t){s8=t}};class cz extends hs{constructor(e){e.resource||(e.resource=X4.get().createCanvas()),e.width||(e.width=e.resource.width,e.autoDensity||(e.width/=e.resolution)),e.height||(e.height=e.resource.height,e.autoDensity||(e.height/=e.resolution)),super(e),this.uploadMethodId="image",this.autoDensity=e.autoDensity,this.resizeCanvas(),this.transparent=!!e.transparent}resizeCanvas(){this.autoDensity&&"style"in this.resource&&(this.resource.style.width=`${this.width}px`,this.resource.style.height=`${this.height}px`),(this.resource.width!==this.pixelWidth||this.resource.height!==this.pixelHeight)&&(this.resource.width=this.pixelWidth,this.resource.height=this.pixelHeight)}resize(e=this.width,n=this.height,r=this._resolution){const i=super.resize(e,n,r);return i&&this.resizeCanvas(),i}static test(e){return globalThis.HTMLCanvasElement&&e instanceof HTMLCanvasElement||globalThis.OffscreenCanvas&&e instanceof OffscreenCanvas}get context2D(){return this._context2D||(this._context2D=this.resource.getContext("2d"))}}cz.extension=ba.TextureSource;class lz extends hs{constructor(e){super(e),this.uploadMethodId="image",this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<"u"&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}}lz.extension=ba.TextureSource;var ZC=(t=>(t[t.INTERACTION=50]="INTERACTION",t[t.HIGH=25]="HIGH",t[t.NORMAL=0]="NORMAL",t[t.LOW=-25]="LOW",t[t.UTILITY=-50]="UTILITY",t))(ZC||{});class $T{constructor(e,n=null,r=0,i=!1){this.next=null,this.previous=null,this._destroyed=!1,this._fn=e,this._context=n,this.priority=r,this._once=i}match(e,n=null){return this._fn===e&&this._context===n}emit(e){this._fn&&(this._context?this._fn.call(this._context,e):this._fn(e));const n=this.next;return this._once&&this.destroy(!0),this._destroyed&&(this.next=null),n}connect(e){this.previous=e,e.next&&(e.next.previous=this),this.next=e.next,e.next=this}destroy(e=!1){this._destroyed=!0,this._fn=null,this._context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);const n=this.next;return this.next=e?null:n,this.previous=null,n}}const uz=class Ya{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new $T(null,null,1/0),this.deltaMS=1/Ya.targetFPMS,this.elapsedMS=1/Ya.targetFPMS,this._tick=e=>{this._requestId=null,this.started&&(this.update(e),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(e,n,r=ZC.NORMAL){return this._addListener(new $T(e,n,r))}addOnce(e,n,r=ZC.NORMAL){return this._addListener(new $T(e,n,r,!0))}_addListener(e){let n=this._head.next,r=this._head;if(!n)e.connect(r);else{for(;n;){if(e.priority>n.priority){e.connect(r);break}r=n,n=n.next}e.previous||e.connect(r)}return this._startIfPossible(),this}remove(e,n){let r=this._head.next;for(;r;)r.match(e,n)?r=r.destroy():r=r.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let e=0,n=this._head;for(;n=n.next;)e++;return e}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let e=this._head.next;for(;e;)e=e.destroy(!0);this._head.destroy(),this._head=null}}update(e=performance.now()){let n;if(e>this.lastTime){if(n=this.elapsedMS=e-this.lastTime,n>this._maxElapsedMS&&(n=this._maxElapsedMS),n*=this.speed,this._minElapsedMS){const a=e-this._lastFrame|0;if(a<this._minElapsedMS)return;this._lastFrame=e-a%this._minElapsedMS}this.deltaMS=n,this.deltaTime=this.deltaMS*Ya.targetFPMS;const r=this._head;let i=r.next;for(;i;)i=i.emit(this);r.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=e}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(e){const n=Math.min(Math.max(0,e)/1e3,Ya.targetFPMS);this._maxElapsedMS=1/n,this._minElapsedMS&&e>this.maxFPS&&(this.maxFPS=e)}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(e){e===0?this._minElapsedMS=0:(e<this.minFPS&&(this.minFPS=e),this._minElapsedMS=1/(e/1e3))}static get shared(){if(!Ya._shared){const e=Ya._shared=new Ya;e.autoStart=!0,e._protected=!0}return Ya._shared}static get system(){if(!Ya._system){const e=Ya._system=new Ya;e.autoStart=!0,e._protected=!0}return Ya._system}};uz.targetFPMS=.06;let nb=uz,ek;async function XJ(){return ek??(ek=(async()=>{var s;const e=X4.get().createCanvas(1,1).getContext("webgl");if(!e)return"premultiply-alpha-on-upload";const n=await new Promise(o=>{const c=document.createElement("video");c.onloadeddata=()=>o(c),c.onerror=()=>o(null),c.autoplay=!1,c.crossOrigin="anonymous",c.preload="auto",c.src="data:video/webm;base64,GkXfo59ChoEBQveBAULygQRC84EIQoKEd2VibUKHgQJChYECGFOAZwEAAAAAAAHTEU2bdLpNu4tTq4QVSalmU6yBoU27i1OrhBZUrmtTrIHGTbuMU6uEElTDZ1OsggEXTbuMU6uEHFO7a1OsggG97AEAAAAAAABZAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVSalmoCrXsYMPQkBNgIRMYXZmV0GETGF2ZkSJiEBEAAAAAAAAFlSua8yuAQAAAAAAAEPXgQFzxYgAAAAAAAAAAZyBACK1nIN1bmSIgQCGhVZfVlA5g4EBI+ODhAJiWgDglLCBArqBApqBAlPAgQFVsIRVuYEBElTDZ9Vzc9JjwItjxYgAAAAAAAAAAWfInEWjh0VOQ09ERVJEh49MYXZjIGxpYnZweC12cDlnyKJFo4hEVVJBVElPTkSHlDAwOjAwOjAwLjA0MDAwMDAwMAAAH0O2dcfngQCgwqGggQAAAIJJg0IAABAAFgA4JBwYSgAAICAAEb///4r+AAB1oZ2mm+6BAaWWgkmDQgAAEAAWADgkHBhKAAAgIABIQBxTu2uRu4+zgQC3iveBAfGCAXHwgQM=",c.load()});if(!n)return"premultiply-alpha-on-upload";const r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r);const i=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,r,0),e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),e.pixelStorei(e.UNPACK_COLORSPACE_CONVERSION_WEBGL,e.NONE),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,n);const a=new Uint8Array(4);return e.readPixels(0,0,1,1,e.RGBA,e.UNSIGNED_BYTE,a),e.deleteFramebuffer(i),e.deleteTexture(r),(s=e.getExtension("WEBGL_lose_context"))==null||s.loseContext(),a[0]<=a[3]?"premultiplied-alpha":"premultiply-alpha-on-upload"})()),ek}const Gw=class dz extends hs{constructor(e){super(e),this.isReady=!1,this.uploadMethodId="video",e={...dz.defaultOptions,...e},this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this.alphaMode=e.alphaMode??"premultiply-alpha-on-upload",this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onCanPlayThrough=this._onCanPlayThrough.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),this._onLoadedMetadata=this._onLoadedMetadata.bind(this),e.autoLoad!==!1&&this.load()}updateFrame(){if(!this.destroyed){if(this._updateFPS){const e=nb.shared.elapsedMS*this.resource.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0),this.isValid&&this.update()}}_videoFrameRequestCallback(){this.updateFrame(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback)}get isValid(){return!!this.resource.videoWidth&&!!this.resource.videoHeight}async load(){if(this._load)return this._load;const e=this.resource,n=this.options;return(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._mediaReady():(n.preload||e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlayThrough),e.addEventListener("error",this._onError,!0)),this.isValid||e.addEventListener("loadedmetadata",this._onLoadedMetadata),this.alphaMode=await XJ(),this._load=new Promise((r,i)=>{this.isValid?r(this):(this._resolve=r,this._reject=i,n.preloadTimeoutMs!==void 0&&(this._preloadTimeout=setTimeout(()=>{this._onError(new ErrorEvent(`Preload exceeded timeout of ${n.preloadTimeoutMs}ms`))})),e.load())}),this._load}_onError(e){this.resource.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=null,this._resolve=null)}_isSourcePlaying(){const e=this.resource;return!e.paused&&!e.ended}_isSourceReady(){return this.resource.readyState>2}_onPlayStart(){this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0)}_onLoadedMetadata(){this.isValid&&this._mediaReady()}_onCanPlay(){this.resource.removeEventListener("canplay",this._onCanPlay),this._mediaReady()}_onCanPlayThrough(){this.resource.removeEventListener("canplaythrough",this._onCanPlayThrough),this._preloadTimeout&&(clearTimeout(this._preloadTimeout),this._preloadTimeout=void 0),this._mediaReady()}_mediaReady(){const e=this.resource;this.isValid&&(this.isReady=!0,this.resize(e.videoWidth,e.videoHeight)),this._msToNextUpdate=0,this.updateFrame(),this._msToNextUpdate=0,this._resolve&&this.isValid&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&this.resource.play()}destroy(){this._configureAutoUpdate();const e=this.resource;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlayThrough),e.removeEventListener("loadedmetadata",this._onLoadedMetadata),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load()),super.destroy()}get autoUpdate(){return this._autoUpdate}set autoUpdate(e){e!==this._autoUpdate&&(this._autoUpdate=e,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(e){e!==this._updateFPS&&(this._updateFPS=e,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.resource.requestVideoFrameCallback?(this._isConnectedToTicker&&(nb.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.resource.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(nb.shared.add(this.updateFrame,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.resource.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(nb.shared.remove(this.updateFrame,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(e){return globalThis.HTMLVideoElement&&e instanceof HTMLVideoElement}};Gw.extension=ba.TextureSource;Gw.defaultOptions={...hs.defaultOptions,autoLoad:!0,autoPlay:!0,updateFPS:0,crossorigin:!0,loop:!1,muted:!0,playsinline:!0,preload:!1};Gw.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};let YJ=Gw;const Eh=(t,e,n=!1)=>(Array.isArray(t)||(t=[t]),e?t.map(r=>typeof r=="string"||n?e(r):r):t);class KJ{constructor(){this._parsers=[],this._cache=new Map,this._cacheMap=new Map}reset(){this._cacheMap.clear(),this._cache.clear()}has(e){return this._cache.has(e)}get(e){const n=this._cache.get(e);return n||hc(`[Assets] Asset id ${e} was not found in the Cache`),n}set(e,n){const r=Eh(e);let i;for(let c=0;c<this.parsers.length;c++){const l=this.parsers[c];if(l.test(n)){i=l.getCacheableAssets(r,n);break}}const a=new Map(Object.entries(i||{}));i||r.forEach(c=>{a.set(c,n)});const s=[...a.keys()],o={cacheKeys:s,keys:r};r.forEach(c=>{this._cacheMap.set(c,o)}),s.forEach(c=>{const l=i?i[c]:n;this._cache.has(c)&&this._cache.get(c)!==l&&hc("[Cache] already has key:",c),this._cache.set(c,a.get(c))})}remove(e){if(!this._cacheMap.has(e)){hc(`[Assets] Asset id ${e} was not found in the Cache`);return}const n=this._cacheMap.get(e);n.cacheKeys.forEach(i=>{this._cache.delete(i)}),n.keys.forEach(i=>{this._cacheMap.delete(i)})}get parsers(){return this._parsers}}const Mh=new KJ,QC=[];Rf.handleByList(ba.TextureSource,QC);function fz(t={}){const e=t&&t.resource,n=e?t.resource:t,r=e?t:{resource:t};for(let i=0;i<QC.length;i++){const a=QC[i];if(a.test(n))return new a(r)}throw new Error(`Could not find a source type for resource: ${r.resource}`)}function ZJ(t={},e=!1){const n=t&&t.resource,r=n?t.resource:t,i=n?t:{resource:t};if(!e&&Mh.has(r))return Mh.get(r);const a=new ni({source:fz(i)});return a.on("destroy",()=>{Mh.has(r)&&Mh.remove(r)}),e||Mh.set(r,a),a}function QJ(t,e=!1){return typeof t=="string"?Mh.get(t):t instanceof hs?new ni({source:t}):ZJ(t,e)}ni.from=QJ;hs.from=fz;Rf.add(az,sz,oz,YJ,lz,cz,q4);var hz=(t=>(t[t.Low=0]="Low",t[t.Normal=1]="Normal",t[t.High=2]="High",t))(hz||{});function so(t){if(typeof t!="string")throw new TypeError(`Path must be a string. Received ${JSON.stringify(t)}`)}function Jm(t){return t.split("?")[0].split("#")[0]}function JJ(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function $J(t,e,n){return t.replace(new RegExp(JJ(e),"g"),n)}function e$(t,e){let n="",r=0,i=-1,a=0,s=-1;for(let o=0;o<=t.length;++o){if(o<t.length)s=t.charCodeAt(o);else{if(s===47)break;s=47}if(s===47){if(!(i===o-1||a===1))if(i!==o-1&&a===2){if(n.length<2||r!==2||n.charCodeAt(n.length-1)!==46||n.charCodeAt(n.length-2)!==46){if(n.length>2){const c=n.lastIndexOf("/");if(c!==n.length-1){c===-1?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=o,a=0;continue}}else if(n.length===2||n.length===1){n="",r=0,i=o,a=0;continue}}}else n.length>0?n+=`/${t.slice(i+1,o)}`:n=t.slice(i+1,o),r=o-i-1;i=o,a=0}else s===46&&a!==-1?++a:a=-1}return n}const Ug={toPosix(t){return $J(t,"\\","/")},isUrl(t){return/^https?:/.test(this.toPosix(t))},isDataUrl(t){return/^data:([a-z]+\/[a-z0-9-+.]+(;[a-z0-9-.!#$%*+.{}|~`]+=[a-z0-9-.!#$%*+.{}()_|~`]+)*)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s<>]*?)$/i.test(t)},isBlobUrl(t){return t.startsWith("blob:")},hasProtocol(t){return/^[^/:]+:/.test(this.toPosix(t))},getProtocol(t){so(t),t=this.toPosix(t);const e=/^file:\/\/\//.exec(t);if(e)return e[0];const n=/^[^/:]+:\/{0,2}/.exec(t);return n?n[0]:""},toAbsolute(t,e,n){if(so(t),this.isDataUrl(t)||this.isBlobUrl(t))return t;const r=Jm(this.toPosix(e??X4.get().getBaseUrl())),i=Jm(this.toPosix(n??this.rootname(r)));return t=this.toPosix(t),t.startsWith("/")?Ug.join(i,t.slice(1)):this.isAbsolute(t)?t:this.join(r,t)},normalize(t){if(so(t),t.length===0)return".";if(this.isDataUrl(t)||this.isBlobUrl(t))return t;t=this.toPosix(t);let e="";const n=t.startsWith("/");this.hasProtocol(t)&&(e=this.rootname(t),t=t.slice(e.length));const r=t.endsWith("/");return t=e$(t),t.length>0&&r&&(t+="/"),n?`/${t}`:e+t},isAbsolute(t){return so(t),t=this.toPosix(t),this.hasProtocol(t)?!0:t.startsWith("/")},join(...t){if(t.length===0)return".";let e;for(let n=0;n<t.length;++n){const r=t[n];if(so(r),r.length>0)if(e===void 0)e=r;else{const i=t[n-1]??"";this.joinExtensions.includes(this.extname(i).toLowerCase())?e+=`/../${r}`:e+=`/${r}`}}return e===void 0?".":this.normalize(e)},dirname(t){if(so(t),t.length===0)return".";t=this.toPosix(t);let e=t.charCodeAt(0);const n=e===47;let r=-1,i=!0;const a=this.getProtocol(t),s=t;t=t.slice(a.length);for(let o=t.length-1;o>=1;--o)if(e=t.charCodeAt(o),e===47){if(!i){r=o;break}}else i=!1;return r===-1?n?"/":this.isUrl(s)?a+t:a:n&&r===1?"//":a+t.slice(0,r)},rootname(t){so(t),t=this.toPosix(t);let e="";if(t.startsWith("/")?e="/":e=this.getProtocol(t),this.isUrl(t)){const n=t.indexOf("/",e.length);n!==-1?e=t.slice(0,n):e=t,e.endsWith("/")||(e+="/")}return e},basename(t,e){so(t),e&&so(e),t=Jm(this.toPosix(t));let n=0,r=-1,i=!0,a;if(e!==void 0&&e.length>0&&e.length<=t.length){if(e.length===t.length&&e===t)return"";let s=e.length-1,o=-1;for(a=t.length-1;a>=0;--a){const c=t.charCodeAt(a);if(c===47){if(!i){n=a+1;break}}else o===-1&&(i=!1,o=a+1),s>=0&&(c===e.charCodeAt(s)?--s===-1&&(r=a):(s=-1,r=o))}return n===r?r=o:r===-1&&(r=t.length),t.slice(n,r)}for(a=t.length-1;a>=0;--a)if(t.charCodeAt(a)===47){if(!i){n=a+1;break}}else r===-1&&(i=!1,r=a+1);return r===-1?"":t.slice(n,r)},extname(t){so(t),t=Jm(this.toPosix(t));let e=-1,n=0,r=-1,i=!0,a=0;for(let s=t.length-1;s>=0;--s){const o=t.charCodeAt(s);if(o===47){if(!i){n=s+1;break}continue}r===-1&&(i=!1,r=s+1),o===46?e===-1?e=s:a!==1&&(a=1):e!==-1&&(a=-1)}return e===-1||r===-1||a===0||a===1&&e===r-1&&e===n+1?"":t.slice(e,r)},parse(t){so(t);const e={root:"",dir:"",base:"",ext:"",name:""};if(t.length===0)return e;t=Jm(this.toPosix(t));let n=t.charCodeAt(0);const r=this.isAbsolute(t);let i;e.root=this.rootname(t),r||this.hasProtocol(t)?i=1:i=0;let a=-1,s=0,o=-1,c=!0,l=t.length-1,d=0;for(;l>=i;--l){if(n=t.charCodeAt(l),n===47){if(!c){s=l+1;break}continue}o===-1&&(c=!1,o=l+1),n===46?a===-1?a=l:d!==1&&(d=1):a!==-1&&(d=-1)}return a===-1||o===-1||d===0||d===1&&a===o-1&&a===s+1?o!==-1&&(s===0&&r?e.base=e.name=t.slice(1,o):e.base=e.name=t.slice(s,o)):(s===0&&r?(e.name=t.slice(1,a),e.base=t.slice(1,o)):(e.name=t.slice(s,a),e.base=t.slice(s,o)),e.ext=t.slice(a,o)),e.dir=this.dirname(t),e},sep:"/",delimiter:":",joinExtensions:[".html"]};function pz(t,e,n,r,i){const a=e[n];for(let s=0;s<a.length;s++){const o=a[s];n<e.length-1?pz(t.replace(r[n],o),e,n+1,r,i):i.push(t.replace(r[n],o))}}function t$(t){const e=/\{(.*?)\}/g,n=t.match(e),r=[];if(n){const i=[];n.forEach(a=>{const s=a.substring(1,a.length-1).split(",");i.push(s)}),pz(t,i,0,n,r)}else r.push(t);return r}const o8=t=>!Array.isArray(t);class mz{constructor(){this._defaultBundleIdentifierOptions={connector:"-",createBundleAssetId:(e,n)=>`${e}${this._bundleIdConnector}${n}`,extractAssetIdFromBundle:(e,n)=>n.replace(`${e}${this._bundleIdConnector}`,"")},this._bundleIdConnector=this._defaultBundleIdentifierOptions.connector,this._createBundleAssetId=this._defaultBundleIdentifierOptions.createBundleAssetId,this._extractAssetIdFromBundle=this._defaultBundleIdentifierOptions.extractAssetIdFromBundle,this._assetMap={},this._preferredOrder=[],this._parsers=[],this._resolverHash={},this._bundles={}}setBundleIdentifier(e){if(this._bundleIdConnector=e.connector??this._bundleIdConnector,this._createBundleAssetId=e.createBundleAssetId??this._createBundleAssetId,this._extractAssetIdFromBundle=e.extractAssetIdFromBundle??this._extractAssetIdFromBundle,this._extractAssetIdFromBundle("foo",this._createBundleAssetId("foo","bar"))!=="bar")throw new Error("[Resolver] GenerateBundleAssetId are not working correctly")}prefer(...e){e.forEach(n=>{this._preferredOrder.push(n),n.priority||(n.priority=Object.keys(n.params))}),this._resolverHash={}}set basePath(e){this._basePath=e}get basePath(){return this._basePath}set rootPath(e){this._rootPath=e}get rootPath(){return this._rootPath}get parsers(){return this._parsers}reset(){this.setBundleIdentifier(this._defaultBundleIdentifierOptions),this._assetMap={},this._preferredOrder=[],this._resolverHash={},this._rootPath=null,this._basePath=null,this._manifest=null,this._bundles={},this._defaultSearchParams=null}setDefaultSearchParams(e){if(typeof e=="string")this._defaultSearchParams=e;else{const n=e;this._defaultSearchParams=Object.keys(n).map(r=>`${encodeURIComponent(r)}=${encodeURIComponent(n[r])}`).join("&")}}getAlias(e){const{alias:n,src:r}=e;return Eh(n||r,a=>typeof a=="string"?a:Array.isArray(a)?a.map(s=>(s==null?void 0:s.src)??s):a!=null&&a.src?a.src:a,!0)}removeAlias(e,n){this._assetMap[e]&&(n&&n!==this._resolverHash[e]||(delete this._resolverHash[e],delete this._assetMap[e]))}addManifest(e){this._manifest&&hc("[Resolver] Manifest already exists, this will be overwritten"),this._manifest=e,e.bundles.forEach(n=>{this.addBundle(n.name,n.assets)})}addBundle(e,n){const r=[];let i=n;Array.isArray(n)||(i=Object.entries(n).map(([a,s])=>typeof s=="string"||Array.isArray(s)?{alias:a,src:s}:{alias:a,...s})),i.forEach(a=>{const s=a.src,o=a.alias;let c;if(typeof o=="string"){const l=this._createBundleAssetId(e,o);r.push(l),c=[o,l]}else{const l=o.map(d=>this._createBundleAssetId(e,d));r.push(...l),c=[...o,...l]}this.add({...a,alias:c,src:s})}),this._bundles[e]=r}add(e){const n=[];Array.isArray(e)?n.push(...e):n.push(e);let r;r=a=>{this.hasKey(a)&&hc(`[Resolver] already has key: ${a} overwriting`)},Eh(n).forEach(a=>{const{src:s}=a;let{data:o,format:c,loadParser:l,parser:d}=a;const u=Eh(s).map(m=>typeof m=="string"?t$(m):Array.isArray(m)?m:[m]),h=this.getAlias(a);Array.isArray(h)?h.forEach(r):r(h);const f=[],p=m=>{const y=this._parsers.find(g=>g.test(m));return{src:m,...y==null?void 0:y.parse(m)}};u.forEach(m=>{m.forEach(y=>{let g={};if(typeof y!="object"?g=p(y):(o=y.data??o,c=y.format??c,(y.loadParser||y.parser)&&(l=y.loadParser??l,d=y.parser??d),g={...p(y.src),...y}),!h)throw new Error(`[Resolver] alias is undefined for this asset: ${g.src}`);g=this._buildResolvedAsset(g,{aliases:h,data:o,format:c,loadParser:l,parser:d,progressSize:a.progressSize}),f.push(g)})}),h.forEach(m=>{this._assetMap[m]=f})})}resolveBundle(e){const n=o8(e);e=Eh(e);const r={};return e.forEach(i=>{const a=this._bundles[i];if(a){const s=this.resolve(a),o={};for(const c in s){const l=s[c];o[this._extractAssetIdFromBundle(i,c)]=l}r[i]=o}}),n?r[e[0]]:r}resolveUrl(e){const n=this.resolve(e);if(typeof e!="string"){const r={};for(const i in n)r[i]=n[i].src;return r}return n.src}resolve(e){const n=o8(e);e=Eh(e);const r={};return e.forEach(i=>{if(!this._resolverHash[i])if(this._assetMap[i]){let a=this._assetMap[i];const s=this._getPreferredOrder(a);s==null||s.priority.forEach(o=>{s.params[o].forEach(c=>{const l=a.filter(d=>d[o]?d[o]===c:!1);l.length&&(a=l)})}),this._resolverHash[i]=a[0]}else this._resolverHash[i]=this._buildResolvedAsset({alias:[i],src:i},{});r[i]=this._resolverHash[i]}),n?r[e[0]]:r}hasKey(e){return!!this._assetMap[e]}hasBundle(e){return!!this._bundles[e]}_getPreferredOrder(e){for(let n=0;n<e.length;n++){const r=e[n],i=this._preferredOrder.find(a=>a.params.format.includes(r.format));if(i)return i}return this._preferredOrder[0]}_appendDefaultSearchParams(e){if(!this._defaultSearchParams)return e;const n=/\?/.test(e)?"&":"?";return`${e}${n}${this._defaultSearchParams}`}_buildResolvedAsset(e,n){const{aliases:r,data:i,loadParser:a,parser:s,format:o,progressSize:c}=n;return(this._basePath||this._rootPath)&&(e.src=Ug.toAbsolute(e.src,this._basePath,this._rootPath)),e.alias=r??e.alias??[e.src],e.src=this._appendDefaultSearchParams(e.src),e.data={...i||{},...e.data},e.loadParser=a??e.loadParser,e.parser=s??e.parser,e.format=o??e.format??n$(e.src),c!==void 0&&(e.progressSize=c),e}}mz.RETINA_PREFIX=/@([0-9\.]+)x/;function n$(t){return t.split(".").pop().split("?").shift().split("#").shift()}const c8=(t,e)=>{const n=e.split("?")[1];return n&&(t+=`?${n}`),t},gz=class D0{constructor(e,n){this.linkedSheets=[];let r=e;(e==null?void 0:e.source)instanceof hs&&(r={texture:e,data:n});const{texture:i,data:a,cachePrefix:s=""}=r;this.cachePrefix=s,this._texture=i instanceof ni?i:null,this.textureSource=i.source,this.textures={},this.animations={},this.data=a;const o=parseFloat(a.meta.scale);o?(this.resolution=o,i.source.resolution=this.resolution):this.resolution=i.source._resolution,this._frames=this.data.frames,this._frameKeys=Object.keys(this._frames),this._batchIndex=0,this._callback=null}parse(){return new Promise(e=>{this._callback=e,this._batchIndex=0,this._frameKeys.length<=D0.BATCH_SIZE?(this._processFrames(0),this._processAnimations(),this._parseComplete()):this._nextBatch()})}parseSync(){return this._processFrames(0,!0),this._processAnimations(),this.textures}_processFrames(e,n=!1){let r=e;const i=n?1/0:D0.BATCH_SIZE;for(;r-e<i&&r<this._frameKeys.length;){const a=this._frameKeys[r],s=this._frames[a],o=s.frame;if(o){let c=null,l=null;const d=s.trimmed!==!1&&s.sourceSize?s.sourceSize:s.frame,u=new ic(0,0,Math.floor(d.w)/this.resolution,Math.floor(d.h)/this.resolution);s.rotated?c=new ic(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.h)/this.resolution,Math.floor(o.w)/this.resolution):c=new ic(Math.floor(o.x)/this.resolution,Math.floor(o.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution),s.trimmed!==!1&&s.spriteSourceSize&&(l=new ic(Math.floor(s.spriteSourceSize.x)/this.resolution,Math.floor(s.spriteSourceSize.y)/this.resolution,Math.floor(o.w)/this.resolution,Math.floor(o.h)/this.resolution)),this.textures[a]=new ni({source:this.textureSource,frame:c,orig:u,trim:l,rotate:s.rotated?2:0,defaultAnchor:s.anchor,defaultBorders:s.borders,label:a.toString()})}r++}}_processAnimations(){const e=this.data.animations||{};for(const n in e){this.animations[n]=[];for(let r=0;r<e[n].length;r++){const i=e[n][r];this.animations[n].push(this.textures[i])}}}_parseComplete(){const e=this._callback;this._callback=null,this._batchIndex=0,e.call(this,this.textures)}_nextBatch(){this._processFrames(this._batchIndex*D0.BATCH_SIZE),this._batchIndex++,setTimeout(()=>{this._batchIndex*D0.BATCH_SIZE<this._frameKeys.length?this._nextBatch():(this._processAnimations(),this._parseComplete())},0)}destroy(e=!1){var n;for(const r in this.textures)this.textures[r].destroy();this._frames=null,this._frameKeys=null,this.data=null,this.textures=null,e&&((n=this._texture)==null||n.destroy(),this.textureSource.destroy()),this._texture=null,this.textureSource=null,this.linkedSheets=[]}};gz.BATCH_SIZE=1e3;let l8=gz;const r$=["jpg","png","jpeg","avif","webp","basis","etc2","bc7","bc6h","bc5","bc4","bc3","bc2","bc1","eac","astc"];function yz(t,e,n){const r={};if(t.forEach(i=>{r[i]=e}),Object.keys(e.textures).forEach(i=>{r[`${e.cachePrefix}${i}`]=e.textures[i]}),!n){const i=Ug.dirname(t[0]);e.linkedSheets.forEach((a,s)=>{const o=yz([`${i}/${e.data.meta.related_multi_packs[s]}`],a,!0);Object.assign(r,o)})}return r}const i$={extension:ba.Asset,cache:{test:t=>t instanceof l8,getCacheableAssets:(t,e)=>yz(t,e,!1)},resolver:{extension:{type:ba.ResolveParser,name:"resolveSpritesheet"},test:t=>{const n=t.split("?")[0].split("."),r=n.pop(),i=n.pop();return r==="json"&&r$.includes(i)},parse:t=>{var n;const e=t.split(".");return{resolution:parseFloat(((n=mz.RETINA_PREFIX.exec(t))==null?void 0:n[1])??"1"),format:e[e.length-2],src:t}}},loader:{name:"spritesheetLoader",id:"spritesheet",extension:{type:ba.LoadParser,priority:hz.Normal,name:"spritesheetLoader"},async testParse(t,e){return Ug.extname(e.src).toLowerCase()===".json"&&!!t.frames},async parse(t,e,n){var u,h;const{texture:r,imageFilename:i,textureOptions:a,cachePrefix:s}=(e==null?void 0:e.data)??{};let o=Ug.dirname(e.src);o&&o.lastIndexOf("/")!==o.length-1&&(o+="/");let c;if(r instanceof ni)c=r;else{const f=c8(o+(i??t.meta.image),e.src);c=(await n.load([{src:f,data:a}]))[f]}const l=new l8({texture:c.source,data:t,cachePrefix:s});await l.parse();const d=(u=t==null?void 0:t.meta)==null?void 0:u.related_multi_packs;if(Array.isArray(d)){const f=[];for(const m of d){if(typeof m!="string")continue;let y=o+m;(h=e.data)!=null&&h.ignoreMultiPack||(y=c8(y,e.src),f.push(n.load({src:y,data:{textureOptions:a,ignoreMultiPack:!0}})))}const p=await Promise.all(f);l.linkedSheets=p,p.forEach(m=>{m.linkedSheets=[l].concat(l.linkedSheets.filter(y=>y!==m))})}return l},async unload(t,e,n){await n.unload(t.textureSource._sourceOrigin),t.destroy(!1)}}};Rf.add(i$);Rf.add(_Q,jQ);function Hg(t,e,n){const r=e>0?e:1;return{frame:Math.round(t*n),progress:Math.min(1,Math.max(0,t/r)),timeSeconds:t}}const tk=new Map;async function Y4(t,e){var p;const n=z9(t);if(n.length)throw new Error(n.join(`
|
|
@@ -965,7 +965,7 @@ error('操作失败', {
|
|
|
965
965
|
description: '错误详情',
|
|
966
966
|
actionLabel: '重试',
|
|
967
967
|
duration: 4000,
|
|
968
|
-
});`},FAe="goxutech 是测试环境",zAe="{{seconds}} 秒后将默认跳转到 https://aixcut.cn,是否现在前往正式站?",LAe="留在当前环境",_Ae="前往 aixcut.cn",jAe={credits:"积分",balance:"余额",balanceFetchFailed:"获取余额失败"},UAe="关闭",HAe="打开项目失败",VAe={eyebrow:"浏览器兼容性",title:"当前浏览器暂不支持",description:"Aixcut 目前仅支持 Chrome 和 Microsoft Edge。请更换支持的浏览器后继续使用,以避免编辑、预览或导出功能异常。",downloadChrome:"下载 Chrome",downloadEdge:"下载 Edge",closeLabel:"关闭浏览器兼容性提示"},GAe={close:"关闭",eyebrow:"浏览器兼容性",title:"当前浏览器无法播放 MG 动画",description:"MG 播放依赖 Chrome 的 HTML in Canvas 能力。为避免编辑器卡死,当前已暂停 MG 的播放、预览、缩略图抓帧和导出。",stepsIntro:"完成下面两步后,重启 Chrome 并重新打开 Aixcut 项目。",installChrome:"安装或升级最新版 Chrome",upgradeChromeHint:"已安装 Chrome 也请先完全退出,再升级到最新版。",downloadChrome:"下载 Chrome",enableHtmlCanvas:"开启 HTML in Canvas",enableHtmlCanvasHint:"在 Chrome 地址栏打开设置地址,将选项改为 Enabled,然后重启 Chrome。",copied:"已复制",copyAddress:"复制地址",footer:"仅打开设置地址不会自动启用功能。请确认选择 Enabled,并在设置后重启 Chrome。"},qAe="当前浏览器不支持 MG 播放",WAe="查看解决方法",XAe={selectColor:"选择颜色"},YAe={loadMore:"加载更多素材",retry:"重试",remove:"移除"},KAe={width:"宽",height:"高",apply:"应用"},ZAe={allLoaded:"已加载全部项目"},QAe={brand:"Aixcut Embed",poweredBy:"技术支持",logoAlt:"嵌入式剪辑器品牌标识",title:"无法启动嵌入式剪辑器",descriptionStart:"当前 iframe 缺少安全启动参数。请通过前端 SDK",descriptionMiddle:"的",descriptionEnd:"挂载编辑器,不要直接把 Session 返回的",descriptionSuffix:"赋给"},JAe="收起",$Ae="展开",e5e="收起面板",t5e="展开面板",n5e="增大",r5e="减小",i5e={loading:kAe,back:SAe,cancel:CAe,errorBoundaryTitle:EAe,errorBoundaryUnknown:MAe,errorBoundaryRetry:AAe,retryAction:IAe,errorBoundaryDetails:DAe,notFoundTitle:PAe,notFoundDescription:NAe,notFoundBack:OAe,notFoundHome:RAe,appleToastDemo:BAe,goxutechRedirectTitle:FAe,goxutechRedirectDescription:zAe,goxutechRedirectStay:LAe,goxutechRedirectConfirm:_Ae,billing:jAe,close:UAe,projectOpenFailed:HAe,unsupportedBrowser:VAe,motionGraphBrowserSupport:GAe,motionGraphPlaybackUnavailable:qAe,viewSolution:WAe,colorPicker:XAe,media:YAe,resolution:KAe,projects:ZAe,embed:QAe,collapse:JAe,expand:$Ae,collapsePanel:e5e,expandPanel:t5e,increase:n5e,decrease:r5e},a5e="操作失败,请重试。",s5e="操作失败,请重试;若反复失败,请复制诊断信息反馈给我们。",o5e="网络不稳定,请检查网络后重试。",c5e="请求超时,请重试。",l5e="服务暂时不可用,请稍后重试。",u5e="创作环境暂时不可用,请稍后重试。",d5e="登录状态已失效,请重新登录。",f5e="没有操作权限。",h5e="积分不足,请充值后重试。",p5e="该功能需要开通会员或购买积分包后使用。",m5e="提交的内容不完整或格式不正确,请检查后重试。",g5e="目标不存在或已被删除。",y5e="内容已被修改,请刷新后重试。",b5e="这个文件的格式或编码暂不支持,建议转成 H.264/MP4 后重试。",x5e="当前环境无法解码这个文件,请更换格式或稍后重试。",v5e="文件超出大小上限,请压缩或分批导入。",w5e="浏览器没有读取该文件的权限,请重新选择文件。",T5e="选择的文件与记录不一致,请重新选择原文件。",k5e="另有 {{count}} 条提示,可复制诊断信息反馈。",S5e="复制诊断信息",C5e="诊断信息已复制",E5e="加载版本记录失败,请重试。",M5e="恢复该版本失败,请重试。",A5e="Skill 里引用了不存在的文件:{{reference}}",I5e="邮箱格式不正确,请检查后重试。",D5e="手机号格式不正确,请检查后重试。",P5e="密码格式不符合要求,请检查后重试。",N5e="两次输入的密码不一致,请重新输入。",O5e="该账号还没有设置密码,请改用验证码登录。",R5e="账号或密码不正确,请重新输入。",B5e="账号已被停用,请联系客服。",F5e="请先绑定手机号后再继续。",z5e="请先完成验证码验证。",L5e="验证码校验失败,请重新获取后重试。",_5e="微信授权失败,请重试。",j5e="该微信已绑定其他账号,请改用原来的方式登录。",U5e="该邮箱已注册,请直接登录或找回密码。",H5e="该手机号已注册,请直接登录或找回密码。",V5e="尝试过于频繁,请稍后再试。",G5e="该素材正在被使用,请先移除相关引用后再删除。",q5e="转写失败,请重试;若反复失败可更换更清晰的音源。",W5e="语音服务额度已用完,请稍后再试或联系我们。",X5e="音频内容未通过安全校验,请更换素材后重试。",Y5e="音频质量不达标,暂时无法转写,请更换更清晰的音频。",K5e="音色正在准备中,请稍后再试。",Z5e="Skill 审核未通过,请按提示修改后重新提交。",Q5e="当前套餐不可购买,请重新选择可升级的套餐。",J5e="该订单当前不可退款。",$5e="优惠码无效,请检查后重新输入。",eIe="优惠码已过期。",tIe="优惠码已被用完。",nIe="优惠码已停用。",rIe="充值卡号无效,请检查后重新输入。",iIe="该卡已过期。",aIe="该卡已停用。",sIe="该卡已被兑换。",oIe="请填写邀请码。",cIe="邀请码无效,请检查后重新输入。",lIe="邀请码已过期。",uIe="邀请码已被用完。",dIe="邀请码已停用。",fIe="这个候补链接无效,请重新申请。",hIe="这个候补链接已过期,请重新申请。",pIe="这个候补链接已被使用过了。",mIe="该账号还没有注册,请先注册。",gIe="文稿已上传,但同步到工作区失败,请重试。",yIe="上传凭证已失效,请重新选择文件。",bIe="暂不支持这种文件格式,请上传 Markdown、TXT、PDF 或 Word 文档。",xIe="文档内容无法解析,请确认文件未损坏后重试。",vIe="文档内容无法识别,请检查文件后重试。",wIe="上传的文件不可用,请重新选择文件。",TIe="文档解析服务暂时不可用,请稍后重试。",kIe={generic:a5e,genericWithDiagnostics:s5e,network:o5e,timeout:c5e,serviceUnavailable:l5e,runtimeUnavailable:u5e,authRequired:d5e,permissionDenied:f5e,insufficientBalance:h5e,paidAccessRequired:p5e,validationFailed:m5e,notFound:g5e,conflict:y5e,unsupportedFormat:b5e,decodeUnavailable:x5e,fileTooLarge:v5e,filePermissionRequired:w5e,fileMismatch:T5e,exportWarningsOther:k5e,diagnosticsCopy:S5e,diagnosticsCopied:C5e,versionsLoadFailed:E5e,versionsRestoreFailed:M5e,skillReferenceMissing:A5e,invalidEmail:I5e,invalidPhone:D5e,invalidPassword:P5e,passwordMismatch:N5e,passwordNotSet:O5e,invalidCredentials:R5e,accountDisabled:B5e,phoneBindingRequired:F5e,captchaRequired:z5e,captchaVerifyFailed:L5e,wechatAuthFailed:_5e,wechatAlreadyBound:j5e,emailAlreadyRegistered:U5e,phoneAlreadyRegistered:H5e,tooManyAttempts:V5e,mediaInUse:G5e,transcriptionFailed:q5e,speechQuotaExceeded:W5e,audioContentRejected:X5e,audioQualityRejected:Y5e,voiceNotReady:K5e,skillReviewRejected:Z5e,planUnavailable:Q5e,refundUnavailable:J5e,discountCodeInvalid:$5e,discountCodeExpired:eIe,discountCodeUsedUp:tIe,discountCodeDisabled:nIe,cardInvalid:rIe,cardExpired:iIe,cardDisabled:aIe,cardRedeemed:sIe,invitationCodeRequired:oIe,invitationCodeInvalid:cIe,invitationCodeExpired:lIe,invitationCodeUsedUp:uIe,invitationCodeDisabled:dIe,waitlistTokenInvalid:fIe,waitlistTokenExpired:hIe,waitlistTokenUsed:pIe,accountNotRegistered:mIe,documentSyncFailed:gIe,fileReselectRequired:yIe,documentFormatUnsupported:bIe,documentParseFailed:xIe,documentContentInvalid:vIe,documentUploadUnavailable:wIe,documentParserUnavailable:TIe};va.use(pQ).init({lng:"zh-CN",fallbackLng:"zh-CN",resources:{"zh-CN":{translation:{studio:FCe,timeline:g3e,previewArea:P4e,topbar:RMe,editArea:TAe,common:i5e,errors:kIe}}},interpolation:{escapeValue:!1},initImmediate:!1});const SIe=({value:t,onChange:e,autoFocus:n=!1,className:r})=>{const{t:i}=to();return E.jsxs("div",{className:`flex h-7 min-w-0 items-center gap-1.5 rounded-sm bg-[var(--studio-material-search-bg)] px-2.5 ${r??"min-w-[200px] max-w-[1200px] flex-1 self-stretch"}`,children:[E.jsx(T9,{"aria-hidden":"true",className:"size-4 shrink-0 text-[var(--studio-material-search-muted)]",strokeWidth:1.8}),E.jsx("input",{type:"search",autoFocus:n,value:t,onChange:a=>e(a.target.value),placeholder:i("studio.materialContent.searchPlaceholder"),"aria-label":i("studio.materialContent.searchPlaceholder"),className:"min-w-0 flex-1 border-0 bg-transparent p-0 text-xs text-[var(--studio-text-primary)] outline-none placeholder:text-[var(--studio-material-search-muted)]"}),t?E.jsx("button",{type:"button",onClick:()=>e(""),"aria-label":i("studio.materialContent.clearMaterialSearch"),className:"flex size-5 shrink-0 items-center justify-center rounded-sm border-0 bg-transparent text-[var(--studio-material-search-muted)] transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] hover:text-[var(--studio-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-accent-border)]",children:E.jsx(V1,{className:"size-3.5"})}):null]})},CIe={materialUploadButton:"material-upload"},EIe="rounded-sm bg-transparent",bS="inline-flex size-6 items-center justify-center rounded-sm border-0 bg-transparent transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] hover:text-[var(--studio-text-primary)] active:bg-[var(--studio-button-tool-active-bg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-line-strong)]",MIe="inline-flex size-6 items-center justify-center rounded-sm border-0 bg-transparent text-[var(--studio-text-muted)] transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] hover:text-[var(--studio-text-primary)] active:bg-[var(--studio-button-tool-active-bg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-line-strong)]",AIe=({assetViewMode:t,searchValue:e,onSearchChange:n,categoryFilter:r,onShowCards:i,onShowList:a,selectedAssetCount:s=0,retranscribeDisabled:o=!1,uploadPending:c=!1,onClearSelection:l,onSelectAll:d,selectAllDisabled:u=!1,onDeleteSelection:h,onRetranscribeSelection:f,onUploadFiles:p,onUploadFolder:m,onImportUrl:y,onMobileQrUpload:g,onUpload:b})=>{const{t:x}=to(),[v,w]=Ce.useState(()=>!!e),[T,S]=Ce.useState(!1),[k,C]=Ce.useState({top:0,left:0}),M=Ce.useId(),A=Ce.useRef(null),D=Ce.useRef(null),F=Ce.useRef(null),O=Ce.useRef(null),V=Ce.useRef(null),N=!!(p||m),Y=x(c?"studio.ai.dock.uploadingFile":"studio.materialContent.importMaterial"),j=s>0,J=x("studio.materialContent.selectionCount",{count:s}),ee=x("studio.materialContent.clearMediaSelection"),ue=x("studio.shell.timelineActions.delete"),Q=x("studio.materialContent.retranscribe"),z=x(t==="cards"?"studio.materialContent.listMode":"studio.materialContent.cardMode"),G=Ce.useCallback(()=>{V.current&&(clearTimeout(V.current),V.current=null)},[]),K=Ce.useCallback(()=>{G(),S(!1)},[G]),pe=Ce.useCallback(()=>{G(),V.current=setTimeout(()=>{var ze;V.current=null,(ze=O.current)!=null&&ze.contains(document.activeElement)||S(!1)},120)},[G]),Me=Ce.useCallback(()=>{const ze=F.current,me=O.current;if(!ze||!me)return;const $=ze.getBoundingClientRect(),fe=me.getBoundingClientRect(),B=8,ne=8;let H=$.right+ne;H+fe.width>window.innerWidth-B&&(H=$.left-fe.width-ne),H=Math.max(B,Math.min(H,window.innerWidth-fe.width-B));const Z=$.top+($.height-fe.height)/2,de=Math.max(B,Math.min(Z,window.innerHeight-fe.height-B));C({top:de,left:H})},[]);Ce.useEffect(()=>{if(!v&&!T)return;const ze=$=>{var B,ne,H,Z;const fe=$.target;fe instanceof Node&&(v&&(!((B=A.current)!=null&&B.contains(fe))||!((ne=D.current)!=null&&ne.contains(fe)))&&w(!1),T&&!((H=F.current)!=null&&H.contains(fe))&&!((Z=O.current)!=null&&Z.contains(fe))&&K())},me=$=>{var B,ne;const fe=$.target;!(fe instanceof Node)||!T||!((B=F.current)!=null&&B.contains(fe))&&!((ne=O.current)!=null&&ne.contains(fe))&&K()};return document.addEventListener("pointerdown",ze),document.addEventListener("focusin",me),()=>{document.removeEventListener("pointerdown",ze),document.removeEventListener("focusin",me)}},[K,v,T]),Ce.useEffect(()=>{if(!T)return;const ze=me=>{var ne,H,Z,de;if(me.key==="Escape"){me.preventDefault(),K(),(ne=F.current)==null||ne.focus();return}if(me.key!=="ArrowDown"&&me.key!=="ArrowUp"||!((H=O.current)!=null&&H.contains(document.activeElement))&&F.current!==document.activeElement)return;const $=(Z=O.current)==null?void 0:Z.querySelectorAll("[data-material-upload-action]");if(!($!=null&&$.length))return;me.preventDefault();const fe=Array.from($).indexOf(document.activeElement),B=fe<0?me.key==="ArrowDown"?0:$.length-1:(fe+(me.key==="ArrowDown"?1:-1)+$.length)%$.length;(de=$[B])==null||de.focus()};return document.addEventListener("keydown",ze),()=>document.removeEventListener("keydown",ze)},[K,T]),Ce.useLayoutEffect(()=>{if(T)return Me(),window.addEventListener("resize",Me),window.addEventListener("scroll",Me,!0),()=>{window.removeEventListener("resize",Me),window.removeEventListener("scroll",Me,!0)}},[Me,T]),Ce.useEffect(()=>G,[G]);const Se=[p?{key:"files",label:x("studio.materialContent.uploadFiles"),icon:PK,onSelect:p}:null,m?{key:"folder",label:x("studio.materialContent.uploadFolder"),icon:OK,onSelect:m}:null,y?{key:"url",label:x("studio.materialContent.urlImport"),icon:Gp,onSelect:y}:null,g?{key:"mobile-qr",label:x("studio.materialContent.mobileQrUpload"),icon:KK,onSelect:g}:null].filter(ze=>ze!==null),_=E.jsx("button",{ref:F,type:"button","data-studio-tour":CIe.materialUploadButton,"data-material-upload-toggle":!0,"data-state":T?"open":"closed",onMouseEnter:()=>{N&&(G(),S(!0))},onMouseLeave:()=>{N&&pe()},onClick:()=>{N?(G(),S(!0)):b==null||b()},onKeyDown:ze=>{N&&ze.key==="ArrowDown"&&(ze.preventDefault(),S(!0),window.requestAnimationFrame(()=>{var me,$;return($=(me=O.current)==null?void 0:me.querySelector("[data-material-upload-action]"))==null?void 0:$.focus()}))},className:Xr(MIe,T&&"bg-[var(--studio-button-tool-hover-bg)] text-[var(--studio-text-primary)]"),"aria-label":Y,"aria-haspopup":N?"menu":void 0,"aria-expanded":N?T:void 0,"aria-controls":N?M:void 0,children:E.jsx(QK,{"data-material-toolbar-icon":"upload",className:"size-4",strokeWidth:1.8})}),be=N?_:E.jsx(Qo,{content:Y,position:"bottom",align:"right",children:_});return E.jsxs("div",{ref:A,className:"studio-panel-header flex h-9 shrink-0 items-center justify-between gap-2 px-3",children:[E.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:j?E.jsxs(E.Fragment,{children:[l?E.jsx(Qo,{content:ee,position:"bottom",align:"left",children:E.jsx("button",{type:"button",onClick:l,className:"studio-button-tool flex size-6 shrink-0 items-center justify-center rounded-sm border-0 text-[var(--studio-text-secondary)] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-line-strong)]",title:ee,"aria-label":ee,children:E.jsx(VK,{className:"size-4",strokeWidth:2})})}):null,E.jsx("span",{className:"min-w-0 max-w-20 truncate text-xs font-normal leading-[18px] text-[var(--studio-text-secondary)]","data-material-selection-toolbar":!0,children:J}),f?E.jsxs("button",{type:"button",onClick:f,disabled:o,className:"studio-button-tool inline-flex size-6 shrink-0 items-center justify-center rounded-sm border-0 bg-transparent text-[var(--studio-text-secondary)] transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] disabled:cursor-not-allowed disabled:opacity-40",title:Q,"aria-label":Q,children:[E.jsx(WK,{className:"size-4",strokeWidth:1.8}),E.jsx("span",{className:"sr-only",children:Q})]}):null,h?E.jsxs("button",{type:"button",onClick:h,className:"studio-button-tool inline-flex size-6 shrink-0 items-center justify-center rounded-sm border-0 text-[var(--studio-danger)] transition-colors",title:ue,"aria-label":ue,children:[E.jsx(Hw,{className:"size-4",strokeWidth:1.8}),E.jsx("span",{className:"sr-only",children:ue})]}):null]}):null}),E.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[v?E.jsx("div",{ref:D,"data-material-search-box":!0,children:E.jsx(SIe,{value:e,onChange:n,autoFocus:!0,className:"w-44"})}):E.jsx(Qo,{content:x("studio.materialContent.searchPlaceholder"),position:"bottom",children:E.jsx("button",{type:"button","aria-label":x("studio.materialContent.searchPlaceholder"),title:x("studio.materialContent.searchPlaceholder"),onClick:()=>w(!0),className:bS,"data-material-search-toggle":!0,children:E.jsx(T9,{className:"size-4",strokeWidth:1.8,"aria-hidden":"true"})})}),d?E.jsx(Qo,{content:x("studio.materialContent.selectAllMedia"),position:"bottom",children:E.jsx("button",{type:"button",onClick:d,disabled:u,"aria-label":x("studio.materialContent.selectAllMedia"),title:x("studio.materialContent.selectAllMedia"),className:Xr(bS,"text-[var(--studio-text-muted)] disabled:opacity-40"),"data-material-select-all":!0,children:E.jsx(MK,{className:"size-4",strokeWidth:1.8})})}):null,r,E.jsx("div",{className:Xr("flex h-6 items-center",EIe),"data-material-view-switcher":!0,children:E.jsx(Qo,{content:z,position:"bottom",children:E.jsx("button",{type:"button",onClick:t==="cards"?a:i,className:Xr(bS,"text-[var(--studio-text-muted)]"),title:z,"aria-label":z,"data-material-view-toggle":!0,children:t==="cards"?E.jsx(LK,{"data-material-toolbar-icon":"view-toggle",className:"size-4",strokeWidth:1.8}):E.jsx(zK,{"data-material-toolbar-icon":"view-toggle",className:"size-4",strokeWidth:1.8})})})}),b||N?be:null]}),T&&N&&typeof document<"u"?pr.createPortal(E.jsx("div",{ref:O,id:M,role:"menu","aria-label":x("studio.materialContent.importMaterial"),"data-material-upload-menu":!0,onMouseEnter:G,onMouseLeave:pe,style:{position:"fixed",top:k.top,left:k.left},className:"z-[var(--studio-z-global-popover)] w-44 max-w-[calc(100vw-16px)] rounded-sm border border-[var(--studio-line-strong)] bg-[var(--studio-surface-popover)] p-1 shadow-[0_8px_24px_rgba(0,0,0,0.3)] [&_button]:h-7 [&_button]:rounded-sm [&_button]:justify-start [&_span]:whitespace-nowrap",children:Se.map(({key:ze,label:me,icon:$,onSelect:fe})=>E.jsxs("button",{type:"button",role:"menuitem","data-material-upload-action":ze,onClick:()=>{K(),fe()},className:"flex h-8 w-full items-center gap-2 rounded-sm px-2 text-left text-xs text-[var(--studio-text-primary)] outline-none transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] focus-visible:bg-[var(--studio-button-tool-hover-bg)]",children:[E.jsx($,{className:"size-3.5 shrink-0 text-[var(--studio-text-secondary)]"}),E.jsx("span",{className:"truncate",children:me})]},ze))}),document.body):null]})},M3="bg-[var(--studio-workbench-component)]",IIe="bg-[var(--studio-workbench-panel-muted)]",A3="min-h-[100px] w-full max-w-[200px]",DIe="flex flex-col overflow-hidden rounded-[var(--studio-material-card-radius)] border border-transparent bg-[var(--studio-material-card-bg)] p-0 transition-[border-color,box-shadow,scale,filter] hover:border-[var(--studio-line-strong)]",PIe="aspect-video h-auto min-h-0 w-full shrink-0 rounded-none bg-[var(--studio-material-card-thumbnail-bg)]",NIe="relative z-30 flex h-8 min-h-8 max-h-8 min-w-0 shrink-0 items-center gap-1 bg-[var(--studio-material-card-footer-bg)] px-2",I3="transition-[background-color,color]",SR="text-[var(--studio-text-disabled)] group-hover:text-[var(--studio-text-muted)]",OIe="truncate text-xs font-medium leading-4",RIe=({viewMode:t,onUploadFiles:e,onAdd:n})=>{const{t:r}=to(),i=r("studio.materialContent.addMaterialContent"),a=Xr("group relative min-w-0",M3,I3,SR,t==="cards"?Xr(A3,"h-full self-stretch rounded-[var(--studio-material-card-radius)]"):"min-h-[68px] w-full rounded-sm"),s=Xr("group relative appearance-none text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-accent-border)]",M3,I3,SR,t==="cards"?Xr(A3,"flex h-full self-stretch items-center rounded-[var(--studio-material-card-radius)] border border-dashed border-[var(--studio-line-subtle)] text-center"):"flex min-h-[68px] w-full items-center gap-2 rounded-sm px-2 py-1.5");return E.jsx("div",{"data-material-add-tile-root":"true","data-material-tile-mode":t,className:a,children:E.jsxs("button",{type:"button","data-material-add-tile":"true","data-material-tile-mode":t,onClick:()=>{var o;return(o=e??n)==null?void 0:o()},"aria-label":i,className:s,children:[E.jsx("span",{"data-material-add-glyph":"true",className:Xr("flex shrink-0 items-center justify-center text-[var(--studio-text-muted)] transition-[color,transform] group-hover:text-[var(--studio-text-secondary)]",t==="cards"?"absolute left-1/2 top-[42%] -translate-x-1/2 -translate-y-1/2 group-hover:scale-105":"h-12 w-[76px]"),children:E.jsx(Tv,{className:t==="cards"?"size-8":"size-5",strokeWidth:1.35})}),E.jsx("span",{"data-material-add-label":"true",className:Xr("min-w-0 truncate text-xs font-semibold leading-4",t==="cards"?"absolute inset-x-2 bottom-5 text-center text-[var(--studio-text-muted)] group-hover:text-[var(--studio-text-secondary)]":"block flex-1"),children:i})]})})},PG=Ce.forwardRef(({children:t,className:e,selected:n=!1,viewMode:r,...i},a)=>E.jsx("div",{ref:a,"data-material-tile":"true","data-material-tile-mode":r,"data-material-tile-selected":n?"true":"false",className:Xr("group relative min-w-0",M3,I3,r==="cards"?Xr(A3,"relative rounded-md p-1.5"):"flex min-h-15 items-center gap-2 rounded-sm px-2 py-1.5",e),...i,children:t}));PG.displayName="MaterialTileShell";const NG=Ce.forwardRef(({children:t,className:e,viewMode:n,...r},i)=>E.jsx("div",{ref:i,className:Xr("relative shrink-0 overflow-hidden rounded-sm",IIe,n==="cards"?"h-[88px] w-full":"h-12 w-[76px]",e),...r,children:t}));NG.displayName="MaterialTileThumbnailFrame";function BIe({assets:t,busy:e,onImport:n,onFiles:r,onAdd:i,onAddMany:a,onDeleteMany:s}){const[o,c]=I.useState("cards"),[l,d]=I.useState(""),[u,h]=I.useState("all"),[f,p]=I.useState(()=>new Set),[m,y]=I.useState(null),g=t.filter(v=>v.file.name.toLocaleLowerCase().includes(l.toLocaleLowerCase())&&(u==="all"||v.metadata.mediaType===u)),b=I.useMemo(()=>g.filter(v=>f.has(v.id)),[g,f]),x=(v,w)=>{if(w.shiftKey&&m){const T=g.findIndex(k=>k.id===m),S=g.findIndex(k=>k.id===v);if(T>=0&&S>=0){const k=g.slice(Math.min(T,S),Math.max(T,S)+1).map(C=>C.id);p(C=>new Set([...C,...k]));return}}if(w.metaKey||w.ctrlKey){p(T=>{const S=new Set(T);return S.has(v)?S.delete(v):S.add(v),S}),y(v);return}p(new Set([v])),y(v)};return E.jsxs("aside",{className:"studio-media-panel","aria-label":"素材库",onDragOver:v=>v.preventDefault(),onDrop:v=>{v.preventDefault(),v.dataTransfer.files.length&&r(v.dataTransfer.files)},children:[E.jsx("div",{className:"panel-heading studio-panel-header",children:E.jsx("h2",{children:"素材库"})}),E.jsx(AIe,{assetViewMode:o,onShowCards:()=>c("cards"),onShowList:()=>c("list"),searchValue:l,onSearchChange:d,uploadPending:e,selectedAssetCount:b.length,onClearSelection:()=>p(new Set),onSelectAll:()=>p(v=>new Set([...v,...g.map(w=>w.id)])),selectAllDisabled:!g.length||b.length===g.length,onDeleteSelection:()=>{s(b),p(new Set)},categoryFilter:E.jsxs("select",{"aria-label":"素材分类",className:"material-kind-select studio-control-field",value:u,onChange:v=>h(v.target.value),children:[E.jsx("option",{value:"all",children:"全部"}),E.jsx("option",{value:"video",children:"视频"}),E.jsx("option",{value:"audio",children:"音频"}),E.jsx("option",{value:"image",children:"图片"}),E.jsx("option",{value:"motion-graph",children:"动态图形"})]})}),b.length>1&&E.jsxs("button",{className:"local-material-bulk-add",onClick:()=>a(b),children:[E.jsx(Tv,{size:14}),"添加 ",b.length," 项到时间轴"]}),E.jsxs("div",{className:o==="cards"?"local-material-grid":"local-material-list","aria-label":"素材列表",children:[E.jsx(RIe,{viewMode:o,onUploadFiles:n}),g.map(v=>{const w=v.htmlSource?IK:v.metadata.mediaType==="image"?BK:v.metadata.mediaType==="audio"?vv:JK,T=v.metadata.duration??0,S=k=>{if(v.metadata.mediaType==="audio")return;const C=k.currentTarget.getBoundingClientRect(),M=C.width?Math.max(0,Math.min(1,(k.clientX-C.left)/C.width)):0;c1e(v,M*T*1e3).catch(()=>{})};return E.jsxs(PG,{viewMode:o,selected:f.has(v.id),className:o==="cards"?DIe:void 0,draggable:!0,onDragStart:k=>{k.dataTransfer.setData("application/x-vibevideo-asset",v.id),k.dataTransfer.effectAllowed="copy"},children:[E.jsxs(NG,{viewMode:o,className:o==="cards"?PIe:void 0,children:[E.jsxs("button",{className:"local-material-thumbnail","aria-label":`选择 ${v.file.name}`,"aria-pressed":f.has(v.id),onPointerEnter:S,onPointerMove:S,onPointerLeave:()=>{l1e().catch(()=>{})},onClick:k=>x(v.id,k),onDoubleClick:()=>i(v),children:[v.thumbnail?E.jsx("img",{src:v.thumbnail,alt:v.file.name,className:v.htmlSource||v.metadata.mediaType==="image"?"object-contain":"object-cover"}):E.jsx(w,{size:25,strokeWidth:1.4}),T>0&&E.jsxs("span",{className:"local-material-duration",children:[Math.floor(T/60),":",String(Math.floor(T%60)).padStart(2,"0")]})]}),E.jsx("button",{className:"local-material-quick-add",title:"添加到时间轴","aria-label":`添加 ${v.file.name} 到时间轴`,onClick:()=>i(v),children:E.jsx(Tv,{size:14})})]}),E.jsxs("div",{className:o==="cards"?NIe:"local-material-list-info",children:[E.jsx("span",{className:`${OIe} min-w-0 flex-1 text-[var(--studio-text-secondary)]`,title:v.file.name,children:v.file.name}),E.jsxs("details",{className:"local-material-menu",children:[E.jsx("summary",{className:"local-material-action","aria-label":`${v.file.name} 更多操作`,children:E.jsx(V4,{size:15})}),E.jsx("div",{children:E.jsxs("a",{href:v.url,download:v.file.name,children:[E.jsx(H4,{size:13}),"下载素材"]})})]})]})]},v.id)})]})]})}const nx=6,rx=8,CR=288,FIe=34,zIe=120,ER=t=>{t.stopPropagation()},LIe=(t,e)=>{const n=t.getBoundingClientRect(),r=Math.min(CR,e*FIe+12),i=window.innerHeight-n.bottom-rx,a=n.top-rx,s=i>=r||i>=a,o=s?i-nx:a-nx,c=Math.max(zIe,Math.min(CR,o)),l=s?n.bottom+nx:Math.max(rx,n.top-c-nx);return{left:Math.max(rx,n.left),top:l,width:n.width,maxHeight:c}},_Ie=t=>{const[e,n]=Ce.useState(!1),[r,i]=Ce.useState(null),a=Ce.useRef(null),s=Ce.useRef(null),o=Ce.useRef(null),c=Ce.useCallback(()=>{s.current&&i(LIe(s.current,t))},[t]);return Ce.useLayoutEffect(()=>{e&&c()},[e,c]),Ce.useEffect(()=>{if(!e)return;const l=u=>{var f,p;const h=u.target;(f=a.current)!=null&&f.contains(h)||(p=o.current)!=null&&p.contains(h)||n(!1)},d=u=>{u.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",d),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",d),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[e,c]),{frame:r,menuRef:o,open:e,rootRef:a,setOpen:n,triggerRef:s}},xS=({ariaLabel:t,value:e,options:n,className:r,disabled:i=!1,renderOption:a,onChange:s})=>{var b;const{frame:o,menuRef:c,open:l,rootRef:d,setOpen:u,triggerRef:h}=_Ie(n.length),f=Ce.useId(),p=n.includes(e)?e:n[0],m=p!==void 0?(a==null?void 0:a(p))??p:"-",y=i||n.length===0,g=Ce.useCallback(x=>{s(x),u(!1)},[s,u]);return E.jsxs("div",{ref:d,className:"relative",children:[E.jsx(OG,{ref:h,ariaLabel:t,listboxId:f,label:m,open:l,disabled:y,className:r,onToggle:()=>u(x=>!x)}),E.jsx(jIe,{menuRef:c,open:l,ariaLabel:t,listboxId:f,options:n,value:e,frame:o,container:(b=d.current)==null?void 0:b.closest("dialog"),renderOption:a,onSelect:g})]})},OG=Ce.forwardRef(({ariaLabel:t,listboxId:e,label:n,open:r,disabled:i,className:a,onToggle:s},o)=>E.jsxs("button",{ref:o,type:"button","aria-label":t,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?e:void 0,disabled:i,onClick:s,className:Xr("studio-control-field group flex h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm px-3 text-left text-xs","focus-visible:border-[var(--studio-accent-border)] focus-visible:shadow-[0_0_0_2px_rgba(var(--studio-accent-rgb),0.12)]",a,r&&"border-[var(--studio-accent-border)]",i&&"cursor-not-allowed opacity-50"),children:[E.jsx("span",{className:"min-w-0 flex-1 overflow-hidden",children:n}),E.jsx(x9,{className:Xr("size-3.5 shrink-0 text-[var(--studio-text-muted)] transition-transform group-hover:text-[var(--studio-text-secondary)]",r&&"rotate-180 text-[var(--studio-accent)]"),strokeWidth:1.8})]}));OG.displayName="ExportSelectTrigger";const jIe=({frame:t,menuRef:e,open:n,container:r,...i})=>!n||!t?null:pr.createPortal(E.jsx(RG,{ref:e,frame:t,...i}),r??document.body),RG=Ce.forwardRef(({ariaLabel:t,listboxId:e,options:n,value:r,frame:i,renderOption:a,onSelect:s},o)=>E.jsx("div",{ref:o,id:e,role:"listbox","aria-label":t,style:{left:i.left,top:i.top,width:i.width,maxHeight:i.maxHeight},onWheel:ER,onTouchMove:ER,className:"pointer-events-auto fixed z-[var(--studio-z-fullscreen-surface)] min-w-45 touch-pan-y overflow-y-auto overscroll-contain rounded-sm border border-[var(--studio-line-strong)] bg-[var(--studio-surface-popover)] p-1.5 shadow-[0_18px_48px_rgba(0,0,0,0.38)] backdrop-blur-xl",children:n.map(c=>E.jsx(UIe,{option:c,selected:c===r,renderOption:a,onSelect:s},c))}));RG.displayName="ExportSelectMenu";const UIe=({option:t,selected:e,renderOption:n,onSelect:r})=>E.jsxs("button",{type:"button",role:"option","aria-selected":e,onClick:()=>r(t),className:Xr("studio-button-choice flex min-h-8 w-full items-center gap-2 rounded-sm px-2.5 py-1.5 text-left text-xs font-medium transition-colors focus-visible:outline-none",e&&"studio-button-choice-selected"),children:[E.jsx("span",{className:"min-w-0 flex-1 overflow-hidden",children:(n==null?void 0:n(t))??t}),E.jsx(zC,{className:Xr("size-3.5 shrink-0 text-[var(--studio-accent)]",!e&&"opacity-0"),strokeWidth:1.9})]});async function HIe(t){const{width:e,height:n,frameRate:r,bitrate:i,signal:a}=t;if(![e,n].every(p=>Number.isSafeInteger(p)&&p>=2&&p<=8192&&p%2===0)||!Number.isFinite(r)||r<=0||r>120||!Number.isSafeInteger(i)||i<=0||i>2e8)throw new Error("HEVC 编码参数无效");a==null||a.throwIfAborted();const s=new Worker(new URL("/assets/worker-Bc-itjNu.js",import.meta.url),{type:"module"}),o=new Map;let c=0,l=!1,d=()=>{};const u=p=>{for(const m of o.values())m.reject(p);o.clear()};s.onmessage=({data:p})=>{const m=o.get(p.id);m&&(o.delete(p.id),p.error?m.reject(new Error(p.error)):m.resolve(p))},s.onerror=p=>{l=!0,a==null||a.removeEventListener("abort",d),s.terminate(),u(new Error(p.message||"HEVC Worker 失败"))};const h=(p,m,y=[])=>new Promise((g,b)=>{if(l)return b(new Error("HEVC 编码器已释放"));const x=++c;o.set(x,{resolve:g,reject:b});try{s.postMessage({id:x,type:p,...m},y)}catch(v){o.delete(x),b(v instanceof Error?v:new Error(String(v)))}}),f=(p=new Error("HEVC 编码已取消"))=>{l||(l=!0,a==null||a.removeEventListener("abort",d),s.terminate(),u(p))};d=()=>f((a==null?void 0:a.reason)instanceof Error?a.reason:new DOMException("HEVC 编码已取消","AbortError")),a==null||a.addEventListener("abort",d,{once:!0});try{a==null||a.throwIfAborted(),await h("init",{options:{width:e,height:n,frameRate:r,bitrate:i}}),a==null||a.throwIfAborted()}catch(p){throw f(),p}return{async encode(p){if(p.byteLength!==e*n*3)throw new Error("HEVC 帧尺寸不匹配");const m=p.slice(),y=await h("encode",{pixels:m.buffer},[m.buffer]);return{data:new Uint8Array(y.packet),key:!!y.key,codec:y.codec}},async encodeLinearP3(p){if(p.length!==e*n*4)throw new Error("HEVC 帧尺寸不匹配");const m=p.slice(),y=await h("encode",{pixels:m.buffer,linearP3:!0},[m.buffer]);return{data:new Uint8Array(y.packet),key:!!y.key,codec:y.codec}},dispose:f}}class VIe{create(e,n){const r=Math.round(n.start*1e3),i=Math.round((n.end-n.start)*1e3);if(!Number.isSafeInteger(r)||!Number.isSafeInteger(i))throw new RangeError("Export range exceeds timestamp precision");if(i<=0)throw new RangeError("Export range must have positive duration");const a=i/1e6,s=e.video.frameRate;if(!Number.isFinite(s)||s<=0)throw new RangeError("Export frame rate must be positive");const o=Math.max(1,Math.ceil(i*s/1e6)),c=u=>{if(!Number.isSafeInteger(u)||u<0||u>=o)throw new RangeError(`Invalid export frame index: ${u}`)},l=u=>(c(u),Math.floor(u*1e6/s));return{totalFrames:o,durationSec:a,rangeStartUs:r,rangeDurationUs:i,getTimelineTimeSec:u=>(r+l(u))/1e6,getOutputTimestampSec:u=>l(u)/1e6,getTimelineTimeUs:u=>r+l(u),getOutputTimestampUs:l,getOutputDurationUs:u=>{const h=l(u),p=Math.min(i,Math.floor((u+1)*1e6/s))-h;if(p<=0)throw new Error(`Invalid export frame duration: ${u}`);return p}}}}class GIe{constructor(e,n,r=!1){Ct(this,"source");const i=n.video;if(!i&&!r)throw new Error("视频导出缺少可用的视频编码器");this.source=new _ge({codec:r?"prores":i,...r?{fullCodecString:"ap4h"}:{},bitrate:e.video.bitrate,bitrateMode:e.video.bitrateMode,keyFrameInterval:e.video.keyFrameInterval,hardwareAcceleration:e.video.hardwareAcceleration,alpha:e.video.alpha})}async add(e){await this.source.add(e)}close(){this.source.close()}}function BG(t,e){if(t==="mp4")return new kA(e.mp4Options);if(t==="mov")return new SA(e.mp4Options);if(t==="webm")return new JE(e.webmOptions);throw new Error(`不支持的导出格式:${t}`)}async function qIe(t){if(!BG(t.format,t).getSupportedVideoCodecs().includes(t.video.codec))throw new Error("所选容器不支持该编码");const n=await Wme([t.video.codec],{width:t.video.resolution.width,height:t.video.resolution.height,bitrate:t.video.bitrate});if(!n)throw new Error("当前浏览器不支持所选编码,请更换编码或格式");const r=t.audioEnabled?await XU([t.audio.codec],{numberOfChannels:t.audio.numberOfChannels,sampleRate:t.audio.sampleRate,bitrate:t.audio.bitrate}):void 0;if(t.audioEnabled&&!r)throw new Error("当前浏览器不支持所选音频编码");return{video:n,audio:r}}class WIe{constructor(e,n){Ct(this,"target",new bg);Ct(this,"format");Ct(this,"output");Ct(this,"audioSource",null);this.config=e,this.detectedCodecs=n,this.format=BG(e.format,e),this.output=new pH({target:this.target,format:this.format})}registerVideoTrack(e,n){this.output.addVideoTrack(e.source,{frameRate:n})}registerAudioTrack(){const e=this.detectedCodecs.audio;if(!e)throw new Error("音频导出缺少可用的音频编码器");return this.audioSource=new hH({codec:e,bitrate:this.config.audio.bitrate,bitrateMode:this.config.audio.bitrateMode,transform:{numberOfChannels:this.config.audio.numberOfChannels,sampleRate:this.config.audio.sampleRate}}),this.output.addAudioTrack(this.audioSource),this.audioSource}setMetadata(){if(!this.config.metadata)return;const{metadata:e}=this.config;this.output.setMetadataTags({title:e.title,artist:e.artist,comment:e.comment,date:e.date,images:e.coverImage?[{data:e.coverImage.data,mimeType:e.coverImage.mimeType,kind:"coverFront"}]:void 0})}async start(){await this.output.start()}async finalize(){await this.output.finalize();const e=this.target.buffer;if(!e)throw new Error("导出失败:未生成输出文件");return{buffer:e,mimeType:await this.output.getMimeType(),fileExtension:this.format.fileExtension??".mp4"}}cancel(){return this.output.cancel()}getAudioSource(){return this.audioSource}}function FG(t,e,n,r){var i,a;return!!t&&(t.kind==="audio"||t.kind==="video"&&((i=t.audioState)==null?void 0:i.sourceAudioEnabled)!==!1&&!!t.mediaId&&!!((a=e.get(t.mediaId))!=null&&a.metadata.hasAudio))&&t.enabled!==!1&&t.startTime<r&&t.startTime+t.duration>n}async function XIe(t,e,n,r,i){const a=t.tracks.filter(u=>u.enabled&&!u.muteAudio).flatMap(u=>u.clipIds.map(h=>t.trackClipsMap[h])).filter(u=>FG(u,e,n,r));if(!a.length)return;const s=48e3,o=new OfflineAudioContext(2,Math.ceil((r-n)*s/1e3),s),c=new Map,l=new Map;for(const u of a){if(!u||u.kind!=="audio"&&u.kind!=="video"||!u.mediaId)continue;const h=Math.max(n,u.startTime),f=Math.min(r,u.startTime+u.duration),p=fa(u),m=(u.sourceStartTime+(h-u.startTime)*p)/1e3,y=m+(f-h)*p/1e3,g=l.get(u.mediaId);l.set(u.mediaId,{start:Math.min(m,(g==null?void 0:g.start)??m),end:Math.max(y,(g==null?void 0:g.end)??y)})}for(const u of a){if(!u||u.kind!=="audio"&&u.kind!=="video"||!u.mediaId)continue;i.throwIfAborted();const h=e.get(u.mediaId);if(!h)throw new Error(`缺少音频素材:${u.label??u.mediaId}`);let f=c.get(u.mediaId);if(!f){const M=new Bm({source:new OU(h.file),formats:gA});try{const A=await M.getPrimaryAudioTrack();if(!A)throw new Error(`素材没有音轨:${h.file.name}`);f=[];const D=l.get(u.mediaId);for await(const F of new QU(A).buffers(Math.max(0,D.start),D.end))i.throwIfAborted(),f.push(F);c.set(u.mediaId,f)}finally{M.dispose()}}const p=Math.max(n,u.startTime),m=Math.min(r,u.startTime+u.duration),y=fa(u),g=(u.sourceStartTime+(p-u.startTime)*y)/1e3,b=o.createGain();b.connect(o.destination);const x=Math.max(0,u.volume??1),v=u.audioFadeInMs??0,w=u.audioFadeOutMs??0,T=M=>x*(u.audioFadeCurve?LH(u.audioFadeCurve,M-u.startTime):Math.min(1,v>0?(M-u.startTime)/v:1,w>0?(u.startTime+u.duration-M)/w:1)),S=v>0&&w>0&&v+w>u.duration?[u.startTime+u.duration*v/(v+w)]:[],k=[p,...u.audioFadeCurve?u.audioFadeCurve.points.map(M=>u.startTime+M.timeMs):[u.startTime+v,u.startTime+u.duration-w,...S],m].filter(M=>M>=p&&M<=m).sort((M,A)=>M-A);for(const[M,A]of k.entries()){const D=Math.max(0,T(A)),F=(A-n)/1e3;M?b.gain.linearRampToValueAtTime(D,F):b.gain.setValueAtTime(D,F)}const C=g+(m-p)*y/1e3;for(const M of f){const A=Math.max(g,M.timestamp),D=Math.min(C,M.timestamp+M.duration);if(D<=A)continue;const F=o.createBufferSource();F.buffer=M.buffer,F.playbackRate.value=y,F.connect(b),F.start((p-n)/1e3+(A-g)/y,A-M.timestamp,D-A)}}const d=await o.startRendering();return i.throwIfAborted(),d}let w0;function YIe(){return w0||(w0=KIe().catch(t=>{throw w0=void 0,t}),w0)}async function KIe(){const r=new OfflineAudioContext(2,12e3,48e3),i=r.createBuffer(2,12e3,48e3),a=new Float32Array(512);let s=3647762;for(let u=0;u<512;u++)s^=s<<13,s^=s>>>17,s^=s<<5,a[u]=s&1?.6:-.6;for(let u=0;u<2;u++)i.getChannelData(u).set(a,2400);const o=new bg,c=new pH({target:o,format:new kA({fastStart:!1})}),l=new hH({codec:"aac",bitrate:256e3,transform:{sampleRate:48e3,numberOfChannels:2}});c.addAudioTrack(l);try{await c.start(),await l.add(i),l.close(),await c.finalize()}catch(u){try{await c.cancel()}catch{}throw u}if(!o.buffer)throw new Error("AAC 延迟探测失败");const d=new Bm({source:new eme(o.buffer),formats:gA});try{const u=await d.getPrimaryAudioTrack();if(!u)throw new Error("AAC 延迟探测缺少音轨");const h=new Float32Array(24e3);for await(const m of new QU(u).buffers()){const y=Math.round(m.timestamp*48e3),g=m.buffer.getChannelData(0);y>=0&&y<h.length&&h.set(g.subarray(0,Math.min(g.length,h.length-y)),y)}let f=-1/0,p=0;for(let m=0;m<=8192;m++){let y=0;for(let g=0;g<512;g++)y+=a[g]*h[2400+m+g];y>f&&(f=y,p=m)}if(f<5)throw new Error("无法确定 AAC 编码延迟");return p}finally{d.dispose()}}function ZIe(t,e,n){const r=new DataView(t),i=(D,F)=>{const O=[];for(let V=D;V<F;){if(V+8>F)throw new Error("MP4 box header is truncated");const N=r.getUint32(V),Y=String.fromCharCode(...new Uint8Array(t,V+4,4)),j=N===1?16:8;if(V+j>F)throw new Error("MP4 extended box header is truncated");const J=N===0?F-V:N===1?Number(r.getBigUint64(V+8)):N;if(!Number.isSafeInteger(J)||J<j||V+J>F)throw new Error("Unsupported MP4 box size");O.push({start:V,size:J,type:Y,header:j}),V+=J}return O},a=D=>i(D.start+D.header,D.start+D.size),s=(D,F)=>{const O=D.find(V=>V.type===F);if(!O)throw new Error(`MP4 box missing: ${F}`);return O},o=s(i(0,t.byteLength),"moov");if(o.header!==8||o.start+o.size!==t.byteLength||o.size>4294967259)throw new Error("Unsupported MP4 movie metadata layout");const c=a(o),l=s(c,"mvhd");if(l.header!==8)throw new Error("Unsupported MP4 movie header");const d=r.getUint8(l.start+8),u=r.getUint32(l.start+(d===1?28:20)),h=c.filter(D=>D.type==="trak"),f=h.find(D=>{const F=s(a(D),"mdia"),O=s(a(F),"hdlr");return String.fromCharCode(...new Uint8Array(t,O.start+16,4))==="soun"});if(!f||f.header!==8||f.size>4294967259||a(f).some(D=>D.type==="edts"))throw new Error("Unsupported MP4 audio edit structure");const p=s(a(f),"mdia"),m=s(a(p),"mdhd");if(m.header!==8)throw new Error("Unsupported MP4 media header");const y=r.getUint32(m.start+(r.getUint8(m.start+8)===1?28:20)),g=Math.round(n*u),b=Math.round(e*y/48e3);if(!Number.isSafeInteger(g)||g<=0||g>4294967295||b<0||b>2147483647)throw new Error("Unsupported MP4 edit duration");const x=new Uint8Array(36),v=new DataView(x.buffer);v.setUint32(0,36),x.set([101,100,116,115],4),v.setUint32(8,28),x.set([101,108,115,116],12),v.setUint32(20,1),v.setUint32(24,g),v.setInt32(28,b),v.setUint32(32,65536);const w=f.start+f.size,T=new Uint8Array(t.byteLength+x.length);T.set(new Uint8Array(t,0,w)),T.set(x,w),T.set(new Uint8Array(t,w),w+x.length);const S=new DataView(T.buffer);S.setUint32(o.start,o.size+x.length),S.setUint32(f.start,f.size+x.length);const k=s(a(f),"tkhd"),C=r.getUint8(k.start+8);if(k.header!==8)throw new Error("Unsupported MP4 track header");C===1?S.setBigUint64(k.start+36,BigInt(g)):S.setUint32(k.start+28,g);const M=l.start+(d===1?32:24),A=Math.max(g,...h.filter(D=>D!==f).map(D=>{const F=s(a(D),"tkhd");return r.getUint8(F.start+8)===1?Number(r.getBigUint64(F.start+36)):r.getUint32(F.start+28)}));return d===1?S.setBigUint64(M,BigInt(A)):S.setUint32(M,A),T.buffer}function QIe(t){const{width:e,height:n,frameRate:r,bitrate:i,start:a,end:s}=t;if(![e,n].every(o=>Number.isSafeInteger(o)&&o>0&&o%2===0&&o<=8192))throw new Error("输出宽高必须为 2–8192 的偶数");if(!Number.isFinite(r)||r<=0||r>120)throw new Error("无效的导出帧率");if(!Number.isFinite(i)||i<=0||i>2e8)throw new Error("无效的导出码率");if(!Number.isFinite(a)||!Number.isFinite(s)||a<0||s<=a)throw new Error("无效的导出范围");return{format:t.format==="prores4444"?"mov":t.format==="mp4-hlg"?"mp4":t.format,video:{resolution:{width:e,height:n},frameRate:r,codec:t.format==="mp4-hlg"?"hevc":t.codec,bitrate:i,keyFrameInterval:2,hardwareAcceleration:"no-preference",alpha:t.format==="prores4444"?"keep":"discard"},videoEnabled:!0,audioEnabled:!1,audio:{codec:"aac",bitrate:256e3,sampleRate:48e3,numberOfChannels:2},subtitle:{include:!0},mp4Options:{fastStart:"in-memory"},range:{start:a,end:s}}}function zG(t){return Math.max(0,...t.tracks.filter(e=>e.enabled).flatMap(e=>e.clipIds.map(n=>t.trackClipsMap[n]).filter(n=>n&&n.enabled!==!1).map(n=>n.startTime+n.duration)))}async function JIe(t,e,n,r=()=>{}){var S,k;const i=structuredClone(t),a=QIe(e);if(e.end>zG(i)+.001)throw new Error("导出结束时间超出可见时间轴");const s=new VIe().create(a,{start:e.start,end:e.end});n.throwIfAborted(),r({phase:"preparing",frame:0,totalFrames:s.totalFrames});const o=e.format==="prores4444",c=e.format==="mp4-hlg",l=i.tracks.some(C=>C.enabled&&!C.muteAudio&&C.clipIds.some(M=>FG(i.trackClipsMap[M],Ut,e.start,e.end)));a.audioEnabled=l,a.audio.codec=e.format==="webm"?"opus":"aac";const d=l&&!o&&e.format!=="webm";d&&(a.mp4Options={...a.mp4Options,fastStart:!1});const u=o?{audio:"pcm-s16"}:c?{video:"hevc",audio:l&&await XU(["aac"],{numberOfChannels:2,sampleRate:48e3,bitrate:256e3})?"aac":void 0}:await qIe(a);if(n.throwIfAborted(),l&&!u.audio)throw new Error("当前浏览器不支持所选音频编码");const h=d?await YIe():0;n.throwIfAborted();const f=new Map;for(const C of i.tracks.filter(M=>M.enabled))for(const M of C.clipIds){const A=i.trackClipsMap[M];if(!A||A.enabled===!1||A.kind==="text"||A.kind==="effect"||A.startTime>=e.end||A.startTime+A.duration<=e.start)continue;const D=Ut.get(_i(A));if(!D)throw new Error(`缺少素材:${A.label??M}`);f.set(D.id,{file:D.file,metadata:structuredClone(D.metadata),projectFiles:(S=D.sourceProject)==null?void 0:S.files,entryPath:(k=D.sourceProject)==null?void 0:k.entryPath})}const p=new Map;let m,y,g,b,x,v;const w=()=>x==null?void 0:x.dispose();n.addEventListener("abort",w,{once:!0});const T=document.createElement("canvas");T.width=e.width,T.height=e.height;try{for(const[A,D]of f){n.throwIfAborted();const F=await Yo(D.file,A,D.projectFiles,D.entryPath);F.metadata=D.metadata,p.set(A,F)}if(m=await f1e(i,p,n,{transparentBackground:o,outputViewport:{width:e.width,height:e.height}}),n.throwIfAborted(),o){const{registerProResEncoder:A}=await Af(async()=>{const{registerProResEncoder:D}=await import("./prores-encoder-mediabunny-hm5PQfLy.js");return{registerProResEncoder:D}},[]);A()}{g=new WIe(a,u),c?(x=await HIe({width:e.width,height:e.height,frameRate:e.frameRate,bitrate:e.bitrate,signal:n}),n.throwIfAborted(),v=new Bge("hevc"),g.registerVideoTrack({source:v},e.frameRate)):(y=new GIe(a,u,o),g.registerVideoTrack(y,e.frameRate));const A=l?await XIe(i,p,e.start,e.end,n):void 0,D=A?g.registerAudioTrack():void 0;await g.start(),D&&A&&(b=D.add(A).then(()=>D.close()),b.catch(()=>{}))}for(let A=0;A<s.totalFrames;A++){n.throwIfAborted();const D=s.getTimelineTimeUs(A)/1e3;if(c){const F=await m.renderLinearP3(D);n.throwIfAborted();const O=await x.encodeLinearP3(F);n.throwIfAborted(),await v.add(new Vn(O.data,O.key?"key":"delta",s.getOutputTimestampSec(A),s.getOutputDurationUs(A)/1e6,A),A===0?{decoderConfig:{codec:O.codec,codedWidth:e.width,codedHeight:e.height,colorSpace:{primaries:"bt2020",transfer:"hlg",matrix:"bt2020-ncl",fullRange:!1}}}:void 0)}else{const F=await m.render(D);n.throwIfAborted();const O=T.getContext("2d");O.clearRect(0,0,e.width,e.height),O.drawImage(F,0,0,e.width,e.height);const V=new Oa(T,{timestamp:s.getOutputTimestampSec(A),duration:s.getOutputDurationUs(A)/1e6});try{await y.add(V)}finally{V.close()}}r({phase:"video",frame:A+1,totalFrames:s.totalFrames})}y==null||y.close(),v==null||v.close(),await b,n.throwIfAborted(),r({phase:"finalizing",frame:s.totalFrames,totalFrames:s.totalFrames});const C=await g.finalize();n.throwIfAborted();const M=d?ZIe(C.buffer,h,(e.end-e.start)/1e3):C.buffer;return{...C,buffer:M,blob:new Blob([M],{type:C.mimeType})}}catch(C){try{await(g==null?void 0:g.cancel())}catch{}throw C}finally{n.removeEventListener("abort",w),x==null||x.dispose(),y==null||y.close(),await(m==null?void 0:m.dispose());for(const C of p.values())C.element instanceof HTMLMediaElement&&(C.element.pause(),C.element.removeAttribute("src"),C.element.load()),URL.revokeObjectURL(C.url);T.width=T.height=1}}function $Ie({state:t,name:e,onClose:n,onBusy:r}){const[i,a]=I.useState(()=>{const{width:v,height:w}=Fm(t);return{format:"mp4",codec:"avc",frameRate:t.meta.fps,width:v,height:w,bitrate:8e6,start:0,end:zG(t)}}),[s,o]=I.useState(null),[c,l]=I.useState(""),d=I.useRef(null),u=I.useRef(null),h=s!==null,f=i.format==="prores4444",p=i.format==="mp4-hlg";I.useEffect(()=>{var v;return(v=u.current)==null||v.showModal(),()=>{var w;(w=d.current)==null||w.abort(),r(!1)}},[]);const m=v=>a(w=>({...w,...v})),y=async()=>{const v=new AbortController;d.current=v,l(""),o({phase:"preparing",frame:0,totalFrames:0}),r(!0);try{await rs.pause();const w=await JIe(t,i,v.signal,o),T=URL.createObjectURL(w.blob),S=document.createElement("a");S.href=T,S.download=`${e.replace(/[\\/:*?"<>|]/g,"_")||"视频"}${w.fileExtension}`,S.click(),setTimeout(()=>URL.revokeObjectURL(T),6e4),n()}catch(w){v.signal.aborted||l(w instanceof Error?w.message:String(w))}finally{d.current=null,o(null),r(!1)}},g=i.format==="webm"?["vp9","vp8","av1"]:["avc","hevc","av1"],b=(v,w)=>E.jsxs("label",{className:"grid gap-2 text-xs text-[var(--studio-text-secondary)]",children:[E.jsx("span",{children:v}),w]}),x=(v,w,T,S=0,k=1)=>b(v,E.jsx("input",{"aria-label":v,className:"studio-control-field h-9 w-full rounded-sm px-3 text-xs",type:"number",min:S,step:k,disabled:h,value:w,onChange:C=>T(Number(C.target.value))}));return E.jsxs("dialog",{ref:u,className:"local-export-dialog",onCancel:v=>{var w;v.preventDefault(),h?(w=d.current)==null||w.abort():n()},"aria-label":"导出视频",children:[E.jsxs("header",{className:"flex items-center justify-between border-b border-[var(--studio-line-subtle)] px-5 py-4",children:[E.jsx("h2",{className:"text-sm font-semibold",children:"导出视频"}),E.jsx("button",{className:"studio-icon-button","aria-label":"关闭导出",disabled:h,onClick:n,children:E.jsx(V1,{size:17})})]}),E.jsxs("div",{className:"grid gap-4 p-5",children:[E.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[b("格式",E.jsx(xS,{ariaLabel:"格式",value:i.format,options:["mp4","mov","webm","prores4444","mp4-hlg"],renderOption:v=>v==="prores4444"?"ProRes 4444":v==="mp4-hlg"?"MP4 · HDR HLG":v.toUpperCase(),disabled:h,onChange:v=>m({format:v,codec:v==="webm"?"vp9":v==="mp4-hlg"?"hevc":"avc"})})),!f&&!p&&b("视频编码",E.jsx(xS,{ariaLabel:"视频编码",value:i.codec,options:g,renderOption:v=>({avc:"H.264",hevc:"H.265",vp9:"VP9",vp8:"VP8",av1:"AV1"})[v]??v,disabled:h,onChange:v=>m({codec:v})})),x("宽",i.width,v=>m({width:v}),2,2),x("高",i.height,v=>m({height:v}),2,2),b("帧率",E.jsx(xS,{ariaLabel:"帧率",value:String(i.frameRate),options:[...new Set([24,25,30,50,60,i.frameRate])].sort((v,w)=>v-w).map(String),renderOption:v=>`${v} fps`,disabled:h,onChange:v=>m({frameRate:Number(v)})})),!f&&x("码率(Mbps)",i.bitrate/1e6,v=>m({bitrate:v*1e6}),.1,.1)]}),E.jsxs("details",{className:"rounded-sm border border-[var(--studio-line-subtle)]",children:[E.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs text-[var(--studio-text-muted)]",children:"范围"}),E.jsxs("div",{className:"grid grid-cols-2 gap-3 p-3",children:[x("开始(秒)",i.start/1e3,v=>m({start:v*1e3}),0,.01),x("结束(秒)",i.end/1e3,v=>m({end:v*1e3}),.01,.01)]})]}),s&&E.jsxs("div",{role:"status",children:[E.jsxs("div",{className:"mb-2 flex justify-between text-xs text-[var(--studio-text-muted)]",children:[E.jsx("span",{children:s.phase==="preparing"?"准备素材":s.phase==="finalizing"?"封装视频":"渲染视频"}),E.jsxs("span",{children:[s.totalFrames?Math.round(s.frame/s.totalFrames*100):0,"%"]})]}),E.jsx("progress",{"aria-label":"导出进度",className:"w-full accent-[var(--studio-accent)]",max:Math.max(1,s.totalFrames),value:s.frame})]}),c&&E.jsx("p",{role:"alert",className:"text-xs text-[var(--studio-danger)]",children:c}),E.jsxs("footer",{className:"flex justify-end gap-2",children:[h?E.jsx("button",{className:"studio-button-secondary rounded-sm px-4 py-2 text-xs",onClick:()=>{var v;return(v=d.current)==null?void 0:v.abort()},children:"取消导出"}):E.jsxs("button",{className:"studio-button-primary flex items-center gap-2 rounded-sm px-4 py-2 text-xs",onClick:()=>void y(),children:[E.jsx(H4,{size:14}),"导出"]}),h&&E.jsx(wv,{size:17,className:"spin"})]})]})]})}const eDe="f36f9aa7-61eb-4f7e-a36e-27e7e40cf8f7",D3=()=>({timeline:Zn.getState().state});async function tDe(t){var e;if(t.type!=="inspect"&&await rs.pause(),["scene","object","update"].includes(t.type)){const n=Zn.getState().state.trackClipsMap[t.clipId];if(!n)throw new Error("片段不存在");if(t.type==="update"){if(!Number.isFinite(t.duration)||t.duration<=0)throw new Error("无效时长");return await Cn.updateClip(n.id,{duration:t.duration*1e3}),D3()}const r=await dy(n);if(t.type==="object"){if(!t.address||!t.transform||n.kind!=="motion-graph")throw new Error("缺少对象或修改值");const i=await r.hitTest(0,0,t.address);if(i.elementKind!=="canvas-object"||i.address!==t.address)throw new Error("对象不可编辑");const a=_u(n),s=a.objects[t.address]??{},o={...s,...t.transform};for(const c of["position","rotation","scale","material","light"])t.transform[c]&&Object.assign(o,{[c]:{...s[c],...t.transform[c]}});a.objects[t.address]=o,await Cn.updateClip(n.id,{motionGraphParams:{...n.motionGraphParams,values:{...(e=n.motionGraphParams)==null?void 0:e.values,__vibevideoSceneOverrides:JSON.stringify(a)}}}),await n5.preview.refreshPreview()}return r.hitTest(-1e3,-1e3,t.address)}if(t.type==="import"){const n=new File([t.source],t.name,{type:"text/html"});if(t.clipId){const s=Zn.getState().state.trackClipsMap[t.clipId];if(!s)throw new Error("片段不存在");return await i1e(s,n),await rs.seek(s.startTime),{clipId:s.id,replaced:!0}}const r=await Yo(n);if(!r.htmlSource)throw URL.revokeObjectURL(r.url),new Error("仅支持 HTML/JS 图形");try{await su(r)}catch(s){throw URL.revokeObjectURL(r.url),s}const i=Zn.getState().state;Object.keys(i.trackClipsMap).length||await Cn.updateTimelineMeta({width:r.metadata.videoWidth,height:r.metadata.videoHeight}),Ut.set(r.id,r),ki();let a;try{a=await Cn.appendSourceToTimeline(r.id,{primaryTrackMagnetEnabled:!0})}catch(s){throw Ut.delete(r.id),ki(),URL.revokeObjectURL(r.url),s}return await Cn.focusTimelineClip({clipId:a.id,source:"preview"}),await rs.seek(a.startTime),{clipId:a.id,assetId:r.id,duration:a.duration/1e3}}return t.type==="seek"?await rs.seek(t.seconds*1e3):t.type==="play"&&await rs.togglePlayback(),D3()}function nDe(){if(new URLSearchParams(location.search).get("agent")!=="1")return()=>{};let t=!1,e;const n=async()=>{try{const i=await tB();if(!i)return;const a={Authorization:`Bearer ${(i==null?void 0:i.token)??eDe}`,"Content-Type":"application/json"},s=await fetch("/__vibevideo/agent/next",{headers:a});if(!s.ok)throw new Error("Agent connection unavailable");const o=await s.json();if(o&&!t){let c,l=!0;try{c=await tDe(o.command)}catch(d){l=!1,c={error:d instanceof Error?d.message:String(d)}}await fetch("/__vibevideo/agent/result",{method:"POST",headers:a,body:JSON.stringify({id:o.id,ok:l,result:c,state:D3()})})}}catch(i){console.warn("Local agent bridge:",i)}t||(e=setTimeout(n,350))};return n(),()=>{t=!0,clearTimeout(e)}}const rDe="vibevideo-local-session",ym="projects",LG="last-open-project";function _G(){return new Promise((t,e)=>{const n=indexedDB.open(rDe,1);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(ym)||n.result.createObjectStore(ym)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error??new Error("无法打开本地工程恢复存储")),n.onblocked=()=>e(new Error("本地工程恢复存储正被其他页面占用"))})}async function MR(t,e,n){const r=await _G();try{const i={name:t,timeline:structuredClone(e),media:n.map(a=>{var s,o;return{id:a.id,file:a.file,projectFiles:(s=a.sourceProject)==null?void 0:s.files.map(({path:c,file:l})=>({path:c,file:l})),entryPath:(o=a.sourceProject)==null?void 0:o.entryPath,graphicContentBounds:a.graphicContentBounds??null,graphicContentBoundsKey:a.graphicContentBoundsKey}}),savedAt:Date.now()};await new Promise((a,s)=>{const o=r.transaction(ym,"readwrite");o.objectStore(ym).put(i,LG),o.oncomplete=()=>a(),o.onerror=()=>s(o.error??new Error("无法保存本地工程恢复数据")),o.onabort=()=>s(o.error??new Error("保存本地工程恢复数据已取消"))})}finally{r.close()}}async function iDe(){const t=await _G();try{return await new Promise((e,n)=>{const r=t.transaction(ym,"readonly").objectStore(ym).get(LG);r.onsuccess=()=>e(r.result??null),r.onerror=()=>n(r.error??new Error("无法读取本地工程恢复数据"))})}finally{t.close()}}const aDe=`// @vibevideo:content-bounds 120,120,1040,480
|
|
968
|
+
});`},FAe="goxutech 是测试环境",zAe="{{seconds}} 秒后将默认跳转到 https://aixcut.cn,是否现在前往正式站?",LAe="留在当前环境",_Ae="前往 aixcut.cn",jAe={credits:"积分",balance:"余额",balanceFetchFailed:"获取余额失败"},UAe="关闭",HAe="打开项目失败",VAe={eyebrow:"浏览器兼容性",title:"当前浏览器暂不支持",description:"Aixcut 目前仅支持 Chrome 和 Microsoft Edge。请更换支持的浏览器后继续使用,以避免编辑、预览或导出功能异常。",downloadChrome:"下载 Chrome",downloadEdge:"下载 Edge",closeLabel:"关闭浏览器兼容性提示"},GAe={close:"关闭",eyebrow:"浏览器兼容性",title:"当前浏览器无法播放 MG 动画",description:"MG 播放依赖 Chrome 的 HTML in Canvas 能力。为避免编辑器卡死,当前已暂停 MG 的播放、预览、缩略图抓帧和导出。",stepsIntro:"完成下面两步后,重启 Chrome 并重新打开 Aixcut 项目。",installChrome:"安装或升级最新版 Chrome",upgradeChromeHint:"已安装 Chrome 也请先完全退出,再升级到最新版。",downloadChrome:"下载 Chrome",enableHtmlCanvas:"开启 HTML in Canvas",enableHtmlCanvasHint:"在 Chrome 地址栏打开设置地址,将选项改为 Enabled,然后重启 Chrome。",copied:"已复制",copyAddress:"复制地址",footer:"仅打开设置地址不会自动启用功能。请确认选择 Enabled,并在设置后重启 Chrome。"},qAe="当前浏览器不支持 MG 播放",WAe="查看解决方法",XAe={selectColor:"选择颜色"},YAe={loadMore:"加载更多素材",retry:"重试",remove:"移除"},KAe={width:"宽",height:"高",apply:"应用"},ZAe={allLoaded:"已加载全部项目"},QAe={brand:"Aixcut Embed",poweredBy:"技术支持",logoAlt:"嵌入式剪辑器品牌标识",title:"无法启动嵌入式剪辑器",descriptionStart:"当前 iframe 缺少安全启动参数。请通过前端 SDK",descriptionMiddle:"的",descriptionEnd:"挂载编辑器,不要直接把 Session 返回的",descriptionSuffix:"赋给"},JAe="收起",$Ae="展开",e5e="收起面板",t5e="展开面板",n5e="增大",r5e="减小",i5e={loading:kAe,back:SAe,cancel:CAe,errorBoundaryTitle:EAe,errorBoundaryUnknown:MAe,errorBoundaryRetry:AAe,retryAction:IAe,errorBoundaryDetails:DAe,notFoundTitle:PAe,notFoundDescription:NAe,notFoundBack:OAe,notFoundHome:RAe,appleToastDemo:BAe,goxutechRedirectTitle:FAe,goxutechRedirectDescription:zAe,goxutechRedirectStay:LAe,goxutechRedirectConfirm:_Ae,billing:jAe,close:UAe,projectOpenFailed:HAe,unsupportedBrowser:VAe,motionGraphBrowserSupport:GAe,motionGraphPlaybackUnavailable:qAe,viewSolution:WAe,colorPicker:XAe,media:YAe,resolution:KAe,projects:ZAe,embed:QAe,collapse:JAe,expand:$Ae,collapsePanel:e5e,expandPanel:t5e,increase:n5e,decrease:r5e},a5e="操作失败,请重试。",s5e="操作失败,请重试;若反复失败,请复制诊断信息反馈给我们。",o5e="网络不稳定,请检查网络后重试。",c5e="请求超时,请重试。",l5e="服务暂时不可用,请稍后重试。",u5e="创作环境暂时不可用,请稍后重试。",d5e="登录状态已失效,请重新登录。",f5e="没有操作权限。",h5e="积分不足,请充值后重试。",p5e="该功能需要开通会员或购买积分包后使用。",m5e="提交的内容不完整或格式不正确,请检查后重试。",g5e="目标不存在或已被删除。",y5e="内容已被修改,请刷新后重试。",b5e="这个文件的格式或编码暂不支持,建议转成 H.264/MP4 后重试。",x5e="当前环境无法解码这个文件,请更换格式或稍后重试。",v5e="文件超出大小上限,请压缩或分批导入。",w5e="浏览器没有读取该文件的权限,请重新选择文件。",T5e="选择的文件与记录不一致,请重新选择原文件。",k5e="另有 {{count}} 条提示,可复制诊断信息反馈。",S5e="复制诊断信息",C5e="诊断信息已复制",E5e="加载版本记录失败,请重试。",M5e="恢复该版本失败,请重试。",A5e="Skill 里引用了不存在的文件:{{reference}}",I5e="邮箱格式不正确,请检查后重试。",D5e="手机号格式不正确,请检查后重试。",P5e="密码格式不符合要求,请检查后重试。",N5e="两次输入的密码不一致,请重新输入。",O5e="该账号还没有设置密码,请改用验证码登录。",R5e="账号或密码不正确,请重新输入。",B5e="账号已被停用,请联系客服。",F5e="请先绑定手机号后再继续。",z5e="请先完成验证码验证。",L5e="验证码校验失败,请重新获取后重试。",_5e="微信授权失败,请重试。",j5e="该微信已绑定其他账号,请改用原来的方式登录。",U5e="该邮箱已注册,请直接登录或找回密码。",H5e="该手机号已注册,请直接登录或找回密码。",V5e="尝试过于频繁,请稍后再试。",G5e="该素材正在被使用,请先移除相关引用后再删除。",q5e="转写失败,请重试;若反复失败可更换更清晰的音源。",W5e="语音服务额度已用完,请稍后再试或联系我们。",X5e="音频内容未通过安全校验,请更换素材后重试。",Y5e="音频质量不达标,暂时无法转写,请更换更清晰的音频。",K5e="音色正在准备中,请稍后再试。",Z5e="Skill 审核未通过,请按提示修改后重新提交。",Q5e="当前套餐不可购买,请重新选择可升级的套餐。",J5e="该订单当前不可退款。",$5e="优惠码无效,请检查后重新输入。",eIe="优惠码已过期。",tIe="优惠码已被用完。",nIe="优惠码已停用。",rIe="充值卡号无效,请检查后重新输入。",iIe="该卡已过期。",aIe="该卡已停用。",sIe="该卡已被兑换。",oIe="请填写邀请码。",cIe="邀请码无效,请检查后重新输入。",lIe="邀请码已过期。",uIe="邀请码已被用完。",dIe="邀请码已停用。",fIe="这个候补链接无效,请重新申请。",hIe="这个候补链接已过期,请重新申请。",pIe="这个候补链接已被使用过了。",mIe="该账号还没有注册,请先注册。",gIe="文稿已上传,但同步到工作区失败,请重试。",yIe="上传凭证已失效,请重新选择文件。",bIe="暂不支持这种文件格式,请上传 Markdown、TXT、PDF 或 Word 文档。",xIe="文档内容无法解析,请确认文件未损坏后重试。",vIe="文档内容无法识别,请检查文件后重试。",wIe="上传的文件不可用,请重新选择文件。",TIe="文档解析服务暂时不可用,请稍后重试。",kIe={generic:a5e,genericWithDiagnostics:s5e,network:o5e,timeout:c5e,serviceUnavailable:l5e,runtimeUnavailable:u5e,authRequired:d5e,permissionDenied:f5e,insufficientBalance:h5e,paidAccessRequired:p5e,validationFailed:m5e,notFound:g5e,conflict:y5e,unsupportedFormat:b5e,decodeUnavailable:x5e,fileTooLarge:v5e,filePermissionRequired:w5e,fileMismatch:T5e,exportWarningsOther:k5e,diagnosticsCopy:S5e,diagnosticsCopied:C5e,versionsLoadFailed:E5e,versionsRestoreFailed:M5e,skillReferenceMissing:A5e,invalidEmail:I5e,invalidPhone:D5e,invalidPassword:P5e,passwordMismatch:N5e,passwordNotSet:O5e,invalidCredentials:R5e,accountDisabled:B5e,phoneBindingRequired:F5e,captchaRequired:z5e,captchaVerifyFailed:L5e,wechatAuthFailed:_5e,wechatAlreadyBound:j5e,emailAlreadyRegistered:U5e,phoneAlreadyRegistered:H5e,tooManyAttempts:V5e,mediaInUse:G5e,transcriptionFailed:q5e,speechQuotaExceeded:W5e,audioContentRejected:X5e,audioQualityRejected:Y5e,voiceNotReady:K5e,skillReviewRejected:Z5e,planUnavailable:Q5e,refundUnavailable:J5e,discountCodeInvalid:$5e,discountCodeExpired:eIe,discountCodeUsedUp:tIe,discountCodeDisabled:nIe,cardInvalid:rIe,cardExpired:iIe,cardDisabled:aIe,cardRedeemed:sIe,invitationCodeRequired:oIe,invitationCodeInvalid:cIe,invitationCodeExpired:lIe,invitationCodeUsedUp:uIe,invitationCodeDisabled:dIe,waitlistTokenInvalid:fIe,waitlistTokenExpired:hIe,waitlistTokenUsed:pIe,accountNotRegistered:mIe,documentSyncFailed:gIe,fileReselectRequired:yIe,documentFormatUnsupported:bIe,documentParseFailed:xIe,documentContentInvalid:vIe,documentUploadUnavailable:wIe,documentParserUnavailable:TIe};va.use(pQ).init({lng:"zh-CN",fallbackLng:"zh-CN",resources:{"zh-CN":{translation:{studio:FCe,timeline:g3e,previewArea:P4e,topbar:RMe,editArea:TAe,common:i5e,errors:kIe}}},interpolation:{escapeValue:!1},initImmediate:!1});const SIe=({value:t,onChange:e,autoFocus:n=!1,className:r})=>{const{t:i}=to();return E.jsxs("div",{className:`flex h-7 min-w-0 items-center gap-1.5 rounded-sm bg-[var(--studio-material-search-bg)] px-2.5 ${r??"min-w-[200px] max-w-[1200px] flex-1 self-stretch"}`,children:[E.jsx(T9,{"aria-hidden":"true",className:"size-4 shrink-0 text-[var(--studio-material-search-muted)]",strokeWidth:1.8}),E.jsx("input",{type:"search",autoFocus:n,value:t,onChange:a=>e(a.target.value),placeholder:i("studio.materialContent.searchPlaceholder"),"aria-label":i("studio.materialContent.searchPlaceholder"),className:"min-w-0 flex-1 border-0 bg-transparent p-0 text-xs text-[var(--studio-text-primary)] outline-none placeholder:text-[var(--studio-material-search-muted)]"}),t?E.jsx("button",{type:"button",onClick:()=>e(""),"aria-label":i("studio.materialContent.clearMaterialSearch"),className:"flex size-5 shrink-0 items-center justify-center rounded-sm border-0 bg-transparent text-[var(--studio-material-search-muted)] transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] hover:text-[var(--studio-text-primary)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-accent-border)]",children:E.jsx(V1,{className:"size-3.5"})}):null]})},CIe={materialUploadButton:"material-upload"},EIe="rounded-sm bg-transparent",bS="inline-flex size-6 items-center justify-center rounded-sm border-0 bg-transparent transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] hover:text-[var(--studio-text-primary)] active:bg-[var(--studio-button-tool-active-bg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-line-strong)]",MIe="inline-flex size-6 items-center justify-center rounded-sm border-0 bg-transparent text-[var(--studio-text-muted)] transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] hover:text-[var(--studio-text-primary)] active:bg-[var(--studio-button-tool-active-bg)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-line-strong)]",AIe=({assetViewMode:t,searchValue:e,onSearchChange:n,categoryFilter:r,onShowCards:i,onShowList:a,selectedAssetCount:s=0,retranscribeDisabled:o=!1,uploadPending:c=!1,onClearSelection:l,onSelectAll:d,selectAllDisabled:u=!1,onDeleteSelection:h,onRetranscribeSelection:f,onUploadFiles:p,onUploadFolder:m,onImportUrl:y,onMobileQrUpload:g,onUpload:b})=>{const{t:x}=to(),[v,w]=Ce.useState(()=>!!e),[T,S]=Ce.useState(!1),[k,C]=Ce.useState({top:0,left:0}),M=Ce.useId(),A=Ce.useRef(null),D=Ce.useRef(null),F=Ce.useRef(null),O=Ce.useRef(null),V=Ce.useRef(null),N=!!(p||m),Y=x(c?"studio.ai.dock.uploadingFile":"studio.materialContent.importMaterial"),j=s>0,J=x("studio.materialContent.selectionCount",{count:s}),ee=x("studio.materialContent.clearMediaSelection"),ue=x("studio.shell.timelineActions.delete"),Q=x("studio.materialContent.retranscribe"),z=x(t==="cards"?"studio.materialContent.listMode":"studio.materialContent.cardMode"),G=Ce.useCallback(()=>{V.current&&(clearTimeout(V.current),V.current=null)},[]),K=Ce.useCallback(()=>{G(),S(!1)},[G]),pe=Ce.useCallback(()=>{G(),V.current=setTimeout(()=>{var ze;V.current=null,(ze=O.current)!=null&&ze.contains(document.activeElement)||S(!1)},120)},[G]),Me=Ce.useCallback(()=>{const ze=F.current,me=O.current;if(!ze||!me)return;const $=ze.getBoundingClientRect(),fe=me.getBoundingClientRect(),B=8,ne=8;let H=$.right+ne;H+fe.width>window.innerWidth-B&&(H=$.left-fe.width-ne),H=Math.max(B,Math.min(H,window.innerWidth-fe.width-B));const Z=$.top+($.height-fe.height)/2,de=Math.max(B,Math.min(Z,window.innerHeight-fe.height-B));C({top:de,left:H})},[]);Ce.useEffect(()=>{if(!v&&!T)return;const ze=$=>{var B,ne,H,Z;const fe=$.target;fe instanceof Node&&(v&&(!((B=A.current)!=null&&B.contains(fe))||!((ne=D.current)!=null&&ne.contains(fe)))&&w(!1),T&&!((H=F.current)!=null&&H.contains(fe))&&!((Z=O.current)!=null&&Z.contains(fe))&&K())},me=$=>{var B,ne;const fe=$.target;!(fe instanceof Node)||!T||!((B=F.current)!=null&&B.contains(fe))&&!((ne=O.current)!=null&&ne.contains(fe))&&K()};return document.addEventListener("pointerdown",ze),document.addEventListener("focusin",me),()=>{document.removeEventListener("pointerdown",ze),document.removeEventListener("focusin",me)}},[K,v,T]),Ce.useEffect(()=>{if(!T)return;const ze=me=>{var ne,H,Z,de;if(me.key==="Escape"){me.preventDefault(),K(),(ne=F.current)==null||ne.focus();return}if(me.key!=="ArrowDown"&&me.key!=="ArrowUp"||!((H=O.current)!=null&&H.contains(document.activeElement))&&F.current!==document.activeElement)return;const $=(Z=O.current)==null?void 0:Z.querySelectorAll("[data-material-upload-action]");if(!($!=null&&$.length))return;me.preventDefault();const fe=Array.from($).indexOf(document.activeElement),B=fe<0?me.key==="ArrowDown"?0:$.length-1:(fe+(me.key==="ArrowDown"?1:-1)+$.length)%$.length;(de=$[B])==null||de.focus()};return document.addEventListener("keydown",ze),()=>document.removeEventListener("keydown",ze)},[K,T]),Ce.useLayoutEffect(()=>{if(T)return Me(),window.addEventListener("resize",Me),window.addEventListener("scroll",Me,!0),()=>{window.removeEventListener("resize",Me),window.removeEventListener("scroll",Me,!0)}},[Me,T]),Ce.useEffect(()=>G,[G]);const Se=[p?{key:"files",label:x("studio.materialContent.uploadFiles"),icon:PK,onSelect:p}:null,m?{key:"folder",label:x("studio.materialContent.uploadFolder"),icon:OK,onSelect:m}:null,y?{key:"url",label:x("studio.materialContent.urlImport"),icon:Gp,onSelect:y}:null,g?{key:"mobile-qr",label:x("studio.materialContent.mobileQrUpload"),icon:KK,onSelect:g}:null].filter(ze=>ze!==null),_=E.jsx("button",{ref:F,type:"button","data-studio-tour":CIe.materialUploadButton,"data-material-upload-toggle":!0,"data-state":T?"open":"closed",onMouseEnter:()=>{N&&(G(),S(!0))},onMouseLeave:()=>{N&&pe()},onClick:()=>{N?(G(),S(!0)):b==null||b()},onKeyDown:ze=>{N&&ze.key==="ArrowDown"&&(ze.preventDefault(),S(!0),window.requestAnimationFrame(()=>{var me,$;return($=(me=O.current)==null?void 0:me.querySelector("[data-material-upload-action]"))==null?void 0:$.focus()}))},className:Xr(MIe,T&&"bg-[var(--studio-button-tool-hover-bg)] text-[var(--studio-text-primary)]"),"aria-label":Y,"aria-haspopup":N?"menu":void 0,"aria-expanded":N?T:void 0,"aria-controls":N?M:void 0,children:E.jsx(QK,{"data-material-toolbar-icon":"upload",className:"size-4",strokeWidth:1.8})}),be=N?_:E.jsx(Qo,{content:Y,position:"bottom",align:"right",children:_});return E.jsxs("div",{ref:A,className:"studio-panel-header flex h-9 shrink-0 items-center justify-between gap-2 px-3",children:[E.jsx("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 overflow-hidden",children:j?E.jsxs(E.Fragment,{children:[l?E.jsx(Qo,{content:ee,position:"bottom",align:"left",children:E.jsx("button",{type:"button",onClick:l,className:"studio-button-tool flex size-6 shrink-0 items-center justify-center rounded-sm border-0 text-[var(--studio-text-secondary)] transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-line-strong)]",title:ee,"aria-label":ee,children:E.jsx(VK,{className:"size-4",strokeWidth:2})})}):null,E.jsx("span",{className:"min-w-0 max-w-20 truncate text-xs font-normal leading-[18px] text-[var(--studio-text-secondary)]","data-material-selection-toolbar":!0,children:J}),f?E.jsxs("button",{type:"button",onClick:f,disabled:o,className:"studio-button-tool inline-flex size-6 shrink-0 items-center justify-center rounded-sm border-0 bg-transparent text-[var(--studio-text-secondary)] transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] disabled:cursor-not-allowed disabled:opacity-40",title:Q,"aria-label":Q,children:[E.jsx(WK,{className:"size-4",strokeWidth:1.8}),E.jsx("span",{className:"sr-only",children:Q})]}):null,h?E.jsxs("button",{type:"button",onClick:h,className:"studio-button-tool inline-flex size-6 shrink-0 items-center justify-center rounded-sm border-0 text-[var(--studio-danger)] transition-colors",title:ue,"aria-label":ue,children:[E.jsx(Hw,{className:"size-4",strokeWidth:1.8}),E.jsx("span",{className:"sr-only",children:ue})]}):null]}):null}),E.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[v?E.jsx("div",{ref:D,"data-material-search-box":!0,children:E.jsx(SIe,{value:e,onChange:n,autoFocus:!0,className:"w-44"})}):E.jsx(Qo,{content:x("studio.materialContent.searchPlaceholder"),position:"bottom",children:E.jsx("button",{type:"button","aria-label":x("studio.materialContent.searchPlaceholder"),title:x("studio.materialContent.searchPlaceholder"),onClick:()=>w(!0),className:bS,"data-material-search-toggle":!0,children:E.jsx(T9,{className:"size-4",strokeWidth:1.8,"aria-hidden":"true"})})}),d?E.jsx(Qo,{content:x("studio.materialContent.selectAllMedia"),position:"bottom",children:E.jsx("button",{type:"button",onClick:d,disabled:u,"aria-label":x("studio.materialContent.selectAllMedia"),title:x("studio.materialContent.selectAllMedia"),className:Xr(bS,"text-[var(--studio-text-muted)] disabled:opacity-40"),"data-material-select-all":!0,children:E.jsx(MK,{className:"size-4",strokeWidth:1.8})})}):null,r,E.jsx("div",{className:Xr("flex h-6 items-center",EIe),"data-material-view-switcher":!0,children:E.jsx(Qo,{content:z,position:"bottom",children:E.jsx("button",{type:"button",onClick:t==="cards"?a:i,className:Xr(bS,"text-[var(--studio-text-muted)]"),title:z,"aria-label":z,"data-material-view-toggle":!0,children:t==="cards"?E.jsx(LK,{"data-material-toolbar-icon":"view-toggle",className:"size-4",strokeWidth:1.8}):E.jsx(zK,{"data-material-toolbar-icon":"view-toggle",className:"size-4",strokeWidth:1.8})})})}),b||N?be:null]}),T&&N&&typeof document<"u"?pr.createPortal(E.jsx("div",{ref:O,id:M,role:"menu","aria-label":x("studio.materialContent.importMaterial"),"data-material-upload-menu":!0,onMouseEnter:G,onMouseLeave:pe,style:{position:"fixed",top:k.top,left:k.left},className:"z-[var(--studio-z-global-popover)] w-44 max-w-[calc(100vw-16px)] rounded-sm border border-[var(--studio-line-strong)] bg-[var(--studio-surface-popover)] p-1 shadow-[0_8px_24px_rgba(0,0,0,0.3)] [&_button]:h-7 [&_button]:rounded-sm [&_button]:justify-start [&_span]:whitespace-nowrap",children:Se.map(({key:ze,label:me,icon:$,onSelect:fe})=>E.jsxs("button",{type:"button",role:"menuitem","data-material-upload-action":ze,onClick:()=>{K(),fe()},className:"flex h-8 w-full items-center gap-2 rounded-sm px-2 text-left text-xs text-[var(--studio-text-primary)] outline-none transition-colors hover:bg-[var(--studio-button-tool-hover-bg)] focus-visible:bg-[var(--studio-button-tool-hover-bg)]",children:[E.jsx($,{className:"size-3.5 shrink-0 text-[var(--studio-text-secondary)]"}),E.jsx("span",{className:"truncate",children:me})]},ze))}),document.body):null]})},M3="bg-[var(--studio-workbench-component)]",IIe="bg-[var(--studio-workbench-panel-muted)]",A3="min-h-[100px] w-full max-w-[200px]",DIe="flex flex-col overflow-hidden rounded-[var(--studio-material-card-radius)] border border-transparent bg-[var(--studio-material-card-bg)] p-0 transition-[border-color,box-shadow,scale,filter] hover:border-[var(--studio-line-strong)]",PIe="aspect-video h-auto min-h-0 w-full shrink-0 rounded-none bg-[var(--studio-material-card-thumbnail-bg)]",NIe="relative z-30 flex h-8 min-h-8 max-h-8 min-w-0 shrink-0 items-center gap-1 bg-[var(--studio-material-card-footer-bg)] px-2",I3="transition-[background-color,color]",SR="text-[var(--studio-text-disabled)] group-hover:text-[var(--studio-text-muted)]",OIe="truncate text-xs font-medium leading-4",RIe=({viewMode:t,onUploadFiles:e,onAdd:n})=>{const{t:r}=to(),i=r("studio.materialContent.addMaterialContent"),a=Xr("group relative min-w-0",M3,I3,SR,t==="cards"?Xr(A3,"h-full self-stretch rounded-[var(--studio-material-card-radius)]"):"min-h-[68px] w-full rounded-sm"),s=Xr("group relative appearance-none text-left outline-none focus-visible:ring-2 focus-visible:ring-[var(--studio-accent-border)]",M3,I3,SR,t==="cards"?Xr(A3,"flex h-full self-stretch items-center rounded-[var(--studio-material-card-radius)] border border-dashed border-[var(--studio-line-subtle)] text-center"):"flex min-h-[68px] w-full items-center gap-2 rounded-sm px-2 py-1.5");return E.jsx("div",{"data-material-add-tile-root":"true","data-material-tile-mode":t,className:a,children:E.jsxs("button",{type:"button","data-material-add-tile":"true","data-material-tile-mode":t,onClick:()=>{var o;return(o=e??n)==null?void 0:o()},"aria-label":i,className:s,children:[E.jsx("span",{"data-material-add-glyph":"true",className:Xr("flex shrink-0 items-center justify-center text-[var(--studio-text-muted)] transition-[color,transform] group-hover:text-[var(--studio-text-secondary)]",t==="cards"?"absolute left-1/2 top-[42%] -translate-x-1/2 -translate-y-1/2 group-hover:scale-105":"h-12 w-[76px]"),children:E.jsx(Tv,{className:t==="cards"?"size-8":"size-5",strokeWidth:1.35})}),E.jsx("span",{"data-material-add-label":"true",className:Xr("min-w-0 truncate text-xs font-semibold leading-4",t==="cards"?"absolute inset-x-2 bottom-5 text-center text-[var(--studio-text-muted)] group-hover:text-[var(--studio-text-secondary)]":"block flex-1"),children:i})]})})},PG=Ce.forwardRef(({children:t,className:e,selected:n=!1,viewMode:r,...i},a)=>E.jsx("div",{ref:a,"data-material-tile":"true","data-material-tile-mode":r,"data-material-tile-selected":n?"true":"false",className:Xr("group relative min-w-0",M3,I3,r==="cards"?Xr(A3,"relative rounded-md p-1.5"):"flex min-h-15 items-center gap-2 rounded-sm px-2 py-1.5",e),...i,children:t}));PG.displayName="MaterialTileShell";const NG=Ce.forwardRef(({children:t,className:e,viewMode:n,...r},i)=>E.jsx("div",{ref:i,className:Xr("relative shrink-0 overflow-hidden rounded-sm",IIe,n==="cards"?"h-[88px] w-full":"h-12 w-[76px]",e),...r,children:t}));NG.displayName="MaterialTileThumbnailFrame";function BIe({assets:t,busy:e,onImport:n,onFiles:r,onAdd:i,onAddMany:a,onDeleteMany:s}){const[o,c]=I.useState("cards"),[l,d]=I.useState(""),[u,h]=I.useState("all"),[f,p]=I.useState(()=>new Set),[m,y]=I.useState(null),g=t.filter(v=>v.file.name.toLocaleLowerCase().includes(l.toLocaleLowerCase())&&(u==="all"||v.metadata.mediaType===u)),b=I.useMemo(()=>g.filter(v=>f.has(v.id)),[g,f]),x=(v,w)=>{if(w.shiftKey&&m){const T=g.findIndex(k=>k.id===m),S=g.findIndex(k=>k.id===v);if(T>=0&&S>=0){const k=g.slice(Math.min(T,S),Math.max(T,S)+1).map(C=>C.id);p(C=>new Set([...C,...k]));return}}if(w.metaKey||w.ctrlKey){p(T=>{const S=new Set(T);return S.has(v)?S.delete(v):S.add(v),S}),y(v);return}p(new Set([v])),y(v)};return E.jsxs("aside",{className:"studio-media-panel","aria-label":"素材库",onDragOver:v=>v.preventDefault(),onDrop:v=>{v.preventDefault(),v.dataTransfer.files.length&&r(v.dataTransfer.files)},children:[E.jsx("div",{className:"panel-heading studio-panel-header",children:E.jsx("h2",{children:"素材库"})}),E.jsx(AIe,{assetViewMode:o,onShowCards:()=>c("cards"),onShowList:()=>c("list"),searchValue:l,onSearchChange:d,uploadPending:e,selectedAssetCount:b.length,onClearSelection:()=>p(new Set),onSelectAll:()=>p(v=>new Set([...v,...g.map(w=>w.id)])),selectAllDisabled:!g.length||b.length===g.length,onDeleteSelection:()=>{s(b),p(new Set)},categoryFilter:E.jsxs("select",{"aria-label":"素材分类",className:"material-kind-select studio-control-field",value:u,onChange:v=>h(v.target.value),children:[E.jsx("option",{value:"all",children:"全部"}),E.jsx("option",{value:"video",children:"视频"}),E.jsx("option",{value:"audio",children:"音频"}),E.jsx("option",{value:"image",children:"图片"}),E.jsx("option",{value:"motion-graph",children:"动态图形"})]})}),b.length>1&&E.jsxs("button",{className:"local-material-bulk-add",onClick:()=>a(b),children:[E.jsx(Tv,{size:14}),"添加 ",b.length," 项到时间轴"]}),E.jsxs("div",{className:o==="cards"?"local-material-grid":"local-material-list","aria-label":"素材列表",children:[E.jsx(RIe,{viewMode:o,onUploadFiles:n}),g.map(v=>{const w=v.htmlSource?IK:v.metadata.mediaType==="image"?BK:v.metadata.mediaType==="audio"?vv:JK,T=v.metadata.duration??0,S=k=>{if(v.metadata.mediaType==="audio")return;const C=k.currentTarget.getBoundingClientRect(),M=C.width?Math.max(0,Math.min(1,(k.clientX-C.left)/C.width)):0;c1e(v,M*T*1e3).catch(()=>{})};return E.jsxs(PG,{viewMode:o,selected:f.has(v.id),className:o==="cards"?DIe:void 0,draggable:!0,onDragStart:k=>{k.dataTransfer.setData("application/x-vibevideo-asset",v.id),k.dataTransfer.effectAllowed="copy"},children:[E.jsxs(NG,{viewMode:o,className:o==="cards"?PIe:void 0,children:[E.jsxs("button",{className:"local-material-thumbnail","aria-label":`选择 ${v.file.name}`,"aria-pressed":f.has(v.id),onPointerEnter:S,onPointerMove:S,onPointerLeave:()=>{l1e().catch(()=>{})},onClick:k=>x(v.id,k),onDoubleClick:()=>i(v),children:[v.thumbnail?E.jsx("img",{src:v.thumbnail,alt:v.file.name,className:v.htmlSource||v.metadata.mediaType==="image"?"object-contain":"object-cover"}):E.jsx(w,{size:25,strokeWidth:1.4}),T>0&&E.jsxs("span",{className:"local-material-duration",children:[Math.floor(T/60),":",String(Math.floor(T%60)).padStart(2,"0")]})]}),E.jsx("button",{className:"local-material-quick-add",title:"添加到时间轴","aria-label":`添加 ${v.file.name} 到时间轴`,onClick:()=>i(v),children:E.jsx(Tv,{size:14})})]}),E.jsxs("div",{className:o==="cards"?NIe:"local-material-list-info",children:[E.jsx("span",{className:`${OIe} min-w-0 flex-1 text-[var(--studio-text-secondary)]`,title:v.file.name,children:v.file.name}),E.jsxs("details",{className:"local-material-menu",children:[E.jsx("summary",{className:"local-material-action","aria-label":`${v.file.name} 更多操作`,children:E.jsx(V4,{size:15})}),E.jsx("div",{children:E.jsxs("a",{href:v.url,download:v.file.name,children:[E.jsx(H4,{size:13}),"下载素材"]})})]})]})]},v.id)})]})]})}const nx=6,rx=8,CR=288,FIe=34,zIe=120,ER=t=>{t.stopPropagation()},LIe=(t,e)=>{const n=t.getBoundingClientRect(),r=Math.min(CR,e*FIe+12),i=window.innerHeight-n.bottom-rx,a=n.top-rx,s=i>=r||i>=a,o=s?i-nx:a-nx,c=Math.max(zIe,Math.min(CR,o)),l=s?n.bottom+nx:Math.max(rx,n.top-c-nx);return{left:Math.max(rx,n.left),top:l,width:n.width,maxHeight:c}},_Ie=t=>{const[e,n]=Ce.useState(!1),[r,i]=Ce.useState(null),a=Ce.useRef(null),s=Ce.useRef(null),o=Ce.useRef(null),c=Ce.useCallback(()=>{s.current&&i(LIe(s.current,t))},[t]);return Ce.useLayoutEffect(()=>{e&&c()},[e,c]),Ce.useEffect(()=>{if(!e)return;const l=u=>{var f,p;const h=u.target;(f=a.current)!=null&&f.contains(h)||(p=o.current)!=null&&p.contains(h)||n(!1)},d=u=>{u.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",l),document.addEventListener("keydown",d),window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{document.removeEventListener("mousedown",l),document.removeEventListener("keydown",d),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0)}},[e,c]),{frame:r,menuRef:o,open:e,rootRef:a,setOpen:n,triggerRef:s}},xS=({ariaLabel:t,value:e,options:n,className:r,disabled:i=!1,renderOption:a,onChange:s})=>{var b;const{frame:o,menuRef:c,open:l,rootRef:d,setOpen:u,triggerRef:h}=_Ie(n.length),f=Ce.useId(),p=n.includes(e)?e:n[0],m=p!==void 0?(a==null?void 0:a(p))??p:"-",y=i||n.length===0,g=Ce.useCallback(x=>{s(x),u(!1)},[s,u]);return E.jsxs("div",{ref:d,className:"relative",children:[E.jsx(OG,{ref:h,ariaLabel:t,listboxId:f,label:m,open:l,disabled:y,className:r,onToggle:()=>u(x=>!x)}),E.jsx(jIe,{menuRef:c,open:l,ariaLabel:t,listboxId:f,options:n,value:e,frame:o,container:(b=d.current)==null?void 0:b.closest("dialog"),renderOption:a,onSelect:g})]})},OG=Ce.forwardRef(({ariaLabel:t,listboxId:e,label:n,open:r,disabled:i,className:a,onToggle:s},o)=>E.jsxs("button",{ref:o,type:"button","aria-label":t,"aria-haspopup":"listbox","aria-expanded":r,"aria-controls":r?e:void 0,disabled:i,onClick:s,className:Xr("studio-control-field group flex h-9 w-full min-w-0 items-center justify-between gap-2 rounded-sm px-3 text-left text-xs","focus-visible:border-[var(--studio-accent-border)] focus-visible:shadow-[0_0_0_2px_rgba(var(--studio-accent-rgb),0.12)]",a,r&&"border-[var(--studio-accent-border)]",i&&"cursor-not-allowed opacity-50"),children:[E.jsx("span",{className:"min-w-0 flex-1 overflow-hidden",children:n}),E.jsx(x9,{className:Xr("size-3.5 shrink-0 text-[var(--studio-text-muted)] transition-transform group-hover:text-[var(--studio-text-secondary)]",r&&"rotate-180 text-[var(--studio-accent)]"),strokeWidth:1.8})]}));OG.displayName="ExportSelectTrigger";const jIe=({frame:t,menuRef:e,open:n,container:r,...i})=>!n||!t?null:pr.createPortal(E.jsx(RG,{ref:e,frame:t,...i}),r??document.body),RG=Ce.forwardRef(({ariaLabel:t,listboxId:e,options:n,value:r,frame:i,renderOption:a,onSelect:s},o)=>E.jsx("div",{ref:o,id:e,role:"listbox","aria-label":t,style:{left:i.left,top:i.top,width:i.width,maxHeight:i.maxHeight},onWheel:ER,onTouchMove:ER,className:"pointer-events-auto fixed z-[var(--studio-z-fullscreen-surface)] min-w-45 touch-pan-y overflow-y-auto overscroll-contain rounded-sm border border-[var(--studio-line-strong)] bg-[var(--studio-surface-popover)] p-1.5 shadow-[0_18px_48px_rgba(0,0,0,0.38)] backdrop-blur-xl",children:n.map(c=>E.jsx(UIe,{option:c,selected:c===r,renderOption:a,onSelect:s},c))}));RG.displayName="ExportSelectMenu";const UIe=({option:t,selected:e,renderOption:n,onSelect:r})=>E.jsxs("button",{type:"button",role:"option","aria-selected":e,onClick:()=>r(t),className:Xr("studio-button-choice flex min-h-8 w-full items-center gap-2 rounded-sm px-2.5 py-1.5 text-left text-xs font-medium transition-colors focus-visible:outline-none",e&&"studio-button-choice-selected"),children:[E.jsx("span",{className:"min-w-0 flex-1 overflow-hidden",children:(n==null?void 0:n(t))??t}),E.jsx(zC,{className:Xr("size-3.5 shrink-0 text-[var(--studio-accent)]",!e&&"opacity-0"),strokeWidth:1.9})]});async function HIe(t){const{width:e,height:n,frameRate:r,bitrate:i,signal:a}=t;if(![e,n].every(p=>Number.isSafeInteger(p)&&p>=2&&p<=8192&&p%2===0)||!Number.isFinite(r)||r<=0||r>120||!Number.isSafeInteger(i)||i<=0||i>2e8)throw new Error("HEVC 编码参数无效");a==null||a.throwIfAborted();const s=new Worker(new URL("/assets/worker-Bc-itjNu.js",import.meta.url),{type:"module"}),o=new Map;let c=0,l=!1,d=()=>{};const u=p=>{for(const m of o.values())m.reject(p);o.clear()};s.onmessage=({data:p})=>{const m=o.get(p.id);m&&(o.delete(p.id),p.error?m.reject(new Error(p.error)):m.resolve(p))},s.onerror=p=>{l=!0,a==null||a.removeEventListener("abort",d),s.terminate(),u(new Error(p.message||"HEVC Worker 失败"))};const h=(p,m,y=[])=>new Promise((g,b)=>{if(l)return b(new Error("HEVC 编码器已释放"));const x=++c;o.set(x,{resolve:g,reject:b});try{s.postMessage({id:x,type:p,...m},y)}catch(v){o.delete(x),b(v instanceof Error?v:new Error(String(v)))}}),f=(p=new Error("HEVC 编码已取消"))=>{l||(l=!0,a==null||a.removeEventListener("abort",d),s.terminate(),u(p))};d=()=>f((a==null?void 0:a.reason)instanceof Error?a.reason:new DOMException("HEVC 编码已取消","AbortError")),a==null||a.addEventListener("abort",d,{once:!0});try{a==null||a.throwIfAborted(),await h("init",{options:{width:e,height:n,frameRate:r,bitrate:i}}),a==null||a.throwIfAborted()}catch(p){throw f(),p}return{async encode(p){if(p.byteLength!==e*n*3)throw new Error("HEVC 帧尺寸不匹配");const m=p.slice(),y=await h("encode",{pixels:m.buffer},[m.buffer]);return{data:new Uint8Array(y.packet),key:!!y.key,codec:y.codec}},async encodeLinearP3(p){if(p.length!==e*n*4)throw new Error("HEVC 帧尺寸不匹配");const m=p.slice(),y=await h("encode",{pixels:m.buffer,linearP3:!0},[m.buffer]);return{data:new Uint8Array(y.packet),key:!!y.key,codec:y.codec}},dispose:f}}class VIe{create(e,n){const r=Math.round(n.start*1e3),i=Math.round((n.end-n.start)*1e3);if(!Number.isSafeInteger(r)||!Number.isSafeInteger(i))throw new RangeError("Export range exceeds timestamp precision");if(i<=0)throw new RangeError("Export range must have positive duration");const a=i/1e6,s=e.video.frameRate;if(!Number.isFinite(s)||s<=0)throw new RangeError("Export frame rate must be positive");const o=Math.max(1,Math.ceil(i*s/1e6)),c=u=>{if(!Number.isSafeInteger(u)||u<0||u>=o)throw new RangeError(`Invalid export frame index: ${u}`)},l=u=>(c(u),Math.floor(u*1e6/s));return{totalFrames:o,durationSec:a,rangeStartUs:r,rangeDurationUs:i,getTimelineTimeSec:u=>(r+l(u))/1e6,getOutputTimestampSec:u=>l(u)/1e6,getTimelineTimeUs:u=>r+l(u),getOutputTimestampUs:l,getOutputDurationUs:u=>{const h=l(u),p=Math.min(i,Math.floor((u+1)*1e6/s))-h;if(p<=0)throw new Error(`Invalid export frame duration: ${u}`);return p}}}}class GIe{constructor(e,n,r=!1){Ct(this,"source");const i=n.video;if(!i&&!r)throw new Error("视频导出缺少可用的视频编码器");this.source=new _ge({codec:r?"prores":i,...r?{fullCodecString:"ap4h"}:{},bitrate:e.video.bitrate,bitrateMode:e.video.bitrateMode,keyFrameInterval:e.video.keyFrameInterval,hardwareAcceleration:e.video.hardwareAcceleration,alpha:e.video.alpha})}async add(e){await this.source.add(e)}close(){this.source.close()}}function BG(t,e){if(t==="mp4")return new kA(e.mp4Options);if(t==="mov")return new SA(e.mp4Options);if(t==="webm")return new JE(e.webmOptions);throw new Error(`不支持的导出格式:${t}`)}async function qIe(t){if(!BG(t.format,t).getSupportedVideoCodecs().includes(t.video.codec))throw new Error("所选容器不支持该编码");const n=await Wme([t.video.codec],{width:t.video.resolution.width,height:t.video.resolution.height,bitrate:t.video.bitrate});if(!n)throw new Error("当前浏览器不支持所选编码,请更换编码或格式");const r=t.audioEnabled?await XU([t.audio.codec],{numberOfChannels:t.audio.numberOfChannels,sampleRate:t.audio.sampleRate,bitrate:t.audio.bitrate}):void 0;if(t.audioEnabled&&!r)throw new Error("当前浏览器不支持所选音频编码");return{video:n,audio:r}}class WIe{constructor(e,n){Ct(this,"target",new bg);Ct(this,"format");Ct(this,"output");Ct(this,"audioSource",null);this.config=e,this.detectedCodecs=n,this.format=BG(e.format,e),this.output=new pH({target:this.target,format:this.format})}registerVideoTrack(e,n){this.output.addVideoTrack(e.source,{frameRate:n})}registerAudioTrack(){const e=this.detectedCodecs.audio;if(!e)throw new Error("音频导出缺少可用的音频编码器");return this.audioSource=new hH({codec:e,bitrate:this.config.audio.bitrate,bitrateMode:this.config.audio.bitrateMode,transform:{numberOfChannels:this.config.audio.numberOfChannels,sampleRate:this.config.audio.sampleRate}}),this.output.addAudioTrack(this.audioSource),this.audioSource}setMetadata(){if(!this.config.metadata)return;const{metadata:e}=this.config;this.output.setMetadataTags({title:e.title,artist:e.artist,comment:e.comment,date:e.date,images:e.coverImage?[{data:e.coverImage.data,mimeType:e.coverImage.mimeType,kind:"coverFront"}]:void 0})}async start(){await this.output.start()}async finalize(){await this.output.finalize();const e=this.target.buffer;if(!e)throw new Error("导出失败:未生成输出文件");return{buffer:e,mimeType:await this.output.getMimeType(),fileExtension:this.format.fileExtension??".mp4"}}cancel(){return this.output.cancel()}getAudioSource(){return this.audioSource}}function FG(t,e,n,r){var i,a;return!!t&&(t.kind==="audio"||t.kind==="video"&&((i=t.audioState)==null?void 0:i.sourceAudioEnabled)!==!1&&!!t.mediaId&&!!((a=e.get(t.mediaId))!=null&&a.metadata.hasAudio))&&t.enabled!==!1&&t.startTime<r&&t.startTime+t.duration>n}async function XIe(t,e,n,r,i){const a=t.tracks.filter(u=>u.enabled&&!u.muteAudio).flatMap(u=>u.clipIds.map(h=>t.trackClipsMap[h])).filter(u=>FG(u,e,n,r));if(!a.length)return;const s=48e3,o=new OfflineAudioContext(2,Math.ceil((r-n)*s/1e3),s),c=new Map,l=new Map;for(const u of a){if(!u||u.kind!=="audio"&&u.kind!=="video"||!u.mediaId)continue;const h=Math.max(n,u.startTime),f=Math.min(r,u.startTime+u.duration),p=fa(u),m=(u.sourceStartTime+(h-u.startTime)*p)/1e3,y=m+(f-h)*p/1e3,g=l.get(u.mediaId);l.set(u.mediaId,{start:Math.min(m,(g==null?void 0:g.start)??m),end:Math.max(y,(g==null?void 0:g.end)??y)})}for(const u of a){if(!u||u.kind!=="audio"&&u.kind!=="video"||!u.mediaId)continue;i.throwIfAborted();const h=e.get(u.mediaId);if(!h)throw new Error(`缺少音频素材:${u.label??u.mediaId}`);let f=c.get(u.mediaId);if(!f){const M=new Bm({source:new OU(h.file),formats:gA});try{const A=await M.getPrimaryAudioTrack();if(!A)throw new Error(`素材没有音轨:${h.file.name}`);f=[];const D=l.get(u.mediaId);for await(const F of new QU(A).buffers(Math.max(0,D.start),D.end))i.throwIfAborted(),f.push(F);c.set(u.mediaId,f)}finally{M.dispose()}}const p=Math.max(n,u.startTime),m=Math.min(r,u.startTime+u.duration),y=fa(u),g=(u.sourceStartTime+(p-u.startTime)*y)/1e3,b=o.createGain();b.connect(o.destination);const x=Math.max(0,u.volume??1),v=u.audioFadeInMs??0,w=u.audioFadeOutMs??0,T=M=>x*(u.audioFadeCurve?LH(u.audioFadeCurve,M-u.startTime):Math.min(1,v>0?(M-u.startTime)/v:1,w>0?(u.startTime+u.duration-M)/w:1)),S=v>0&&w>0&&v+w>u.duration?[u.startTime+u.duration*v/(v+w)]:[],k=[p,...u.audioFadeCurve?u.audioFadeCurve.points.map(M=>u.startTime+M.timeMs):[u.startTime+v,u.startTime+u.duration-w,...S],m].filter(M=>M>=p&&M<=m).sort((M,A)=>M-A);for(const[M,A]of k.entries()){const D=Math.max(0,T(A)),F=(A-n)/1e3;M?b.gain.linearRampToValueAtTime(D,F):b.gain.setValueAtTime(D,F)}const C=g+(m-p)*y/1e3;for(const M of f){const A=Math.max(g,M.timestamp),D=Math.min(C,M.timestamp+M.duration);if(D<=A)continue;const F=o.createBufferSource();F.buffer=M.buffer,F.playbackRate.value=y,F.connect(b),F.start((p-n)/1e3+(A-g)/y,A-M.timestamp,D-A)}}const d=await o.startRendering();return i.throwIfAborted(),d}let w0;function YIe(){return w0||(w0=KIe().catch(t=>{throw w0=void 0,t}),w0)}async function KIe(){const r=new OfflineAudioContext(2,12e3,48e3),i=r.createBuffer(2,12e3,48e3),a=new Float32Array(512);let s=3647762;for(let u=0;u<512;u++)s^=s<<13,s^=s>>>17,s^=s<<5,a[u]=s&1?.6:-.6;for(let u=0;u<2;u++)i.getChannelData(u).set(a,2400);const o=new bg,c=new pH({target:o,format:new kA({fastStart:!1})}),l=new hH({codec:"aac",bitrate:256e3,transform:{sampleRate:48e3,numberOfChannels:2}});c.addAudioTrack(l);try{await c.start(),await l.add(i),l.close(),await c.finalize()}catch(u){try{await c.cancel()}catch{}throw u}if(!o.buffer)throw new Error("AAC 延迟探测失败");const d=new Bm({source:new eme(o.buffer),formats:gA});try{const u=await d.getPrimaryAudioTrack();if(!u)throw new Error("AAC 延迟探测缺少音轨");const h=new Float32Array(24e3);for await(const m of new QU(u).buffers()){const y=Math.round(m.timestamp*48e3),g=m.buffer.getChannelData(0);y>=0&&y<h.length&&h.set(g.subarray(0,Math.min(g.length,h.length-y)),y)}let f=-1/0,p=0;for(let m=0;m<=8192;m++){let y=0;for(let g=0;g<512;g++)y+=a[g]*h[2400+m+g];y>f&&(f=y,p=m)}if(f<5)throw new Error("无法确定 AAC 编码延迟");return p}finally{d.dispose()}}function ZIe(t,e,n){const r=new DataView(t),i=(D,F)=>{const O=[];for(let V=D;V<F;){if(V+8>F)throw new Error("MP4 box header is truncated");const N=r.getUint32(V),Y=String.fromCharCode(...new Uint8Array(t,V+4,4)),j=N===1?16:8;if(V+j>F)throw new Error("MP4 extended box header is truncated");const J=N===0?F-V:N===1?Number(r.getBigUint64(V+8)):N;if(!Number.isSafeInteger(J)||J<j||V+J>F)throw new Error("Unsupported MP4 box size");O.push({start:V,size:J,type:Y,header:j}),V+=J}return O},a=D=>i(D.start+D.header,D.start+D.size),s=(D,F)=>{const O=D.find(V=>V.type===F);if(!O)throw new Error(`MP4 box missing: ${F}`);return O},o=s(i(0,t.byteLength),"moov");if(o.header!==8||o.start+o.size!==t.byteLength||o.size>4294967259)throw new Error("Unsupported MP4 movie metadata layout");const c=a(o),l=s(c,"mvhd");if(l.header!==8)throw new Error("Unsupported MP4 movie header");const d=r.getUint8(l.start+8),u=r.getUint32(l.start+(d===1?28:20)),h=c.filter(D=>D.type==="trak"),f=h.find(D=>{const F=s(a(D),"mdia"),O=s(a(F),"hdlr");return String.fromCharCode(...new Uint8Array(t,O.start+16,4))==="soun"});if(!f||f.header!==8||f.size>4294967259||a(f).some(D=>D.type==="edts"))throw new Error("Unsupported MP4 audio edit structure");const p=s(a(f),"mdia"),m=s(a(p),"mdhd");if(m.header!==8)throw new Error("Unsupported MP4 media header");const y=r.getUint32(m.start+(r.getUint8(m.start+8)===1?28:20)),g=Math.round(n*u),b=Math.round(e*y/48e3);if(!Number.isSafeInteger(g)||g<=0||g>4294967295||b<0||b>2147483647)throw new Error("Unsupported MP4 edit duration");const x=new Uint8Array(36),v=new DataView(x.buffer);v.setUint32(0,36),x.set([101,100,116,115],4),v.setUint32(8,28),x.set([101,108,115,116],12),v.setUint32(20,1),v.setUint32(24,g),v.setInt32(28,b),v.setUint32(32,65536);const w=f.start+f.size,T=new Uint8Array(t.byteLength+x.length);T.set(new Uint8Array(t,0,w)),T.set(x,w),T.set(new Uint8Array(t,w),w+x.length);const S=new DataView(T.buffer);S.setUint32(o.start,o.size+x.length),S.setUint32(f.start,f.size+x.length);const k=s(a(f),"tkhd"),C=r.getUint8(k.start+8);if(k.header!==8)throw new Error("Unsupported MP4 track header");C===1?S.setBigUint64(k.start+36,BigInt(g)):S.setUint32(k.start+28,g);const M=l.start+(d===1?32:24),A=Math.max(g,...h.filter(D=>D!==f).map(D=>{const F=s(a(D),"tkhd");return r.getUint8(F.start+8)===1?Number(r.getBigUint64(F.start+36)):r.getUint32(F.start+28)}));return d===1?S.setBigUint64(M,BigInt(A)):S.setUint32(M,A),T.buffer}function QIe(t){const{width:e,height:n,frameRate:r,bitrate:i,start:a,end:s}=t;if(![e,n].every(o=>Number.isSafeInteger(o)&&o>0&&o%2===0&&o<=8192))throw new Error("输出宽高必须为 2–8192 的偶数");if(!Number.isFinite(r)||r<=0||r>120)throw new Error("无效的导出帧率");if(!Number.isFinite(i)||i<=0||i>2e8)throw new Error("无效的导出码率");if(!Number.isFinite(a)||!Number.isFinite(s)||a<0||s<=a)throw new Error("无效的导出范围");return{format:t.format==="prores4444"?"mov":t.format==="mp4-hlg"?"mp4":t.format,video:{resolution:{width:e,height:n},frameRate:r,codec:t.format==="mp4-hlg"?"hevc":t.codec,bitrate:i,keyFrameInterval:2,hardwareAcceleration:"no-preference",alpha:t.format==="prores4444"?"keep":"discard"},videoEnabled:!0,audioEnabled:!1,audio:{codec:"aac",bitrate:256e3,sampleRate:48e3,numberOfChannels:2},subtitle:{include:!0},mp4Options:{fastStart:"in-memory"},range:{start:a,end:s}}}function zG(t){return Math.max(0,...t.tracks.filter(e=>e.enabled).flatMap(e=>e.clipIds.map(n=>t.trackClipsMap[n]).filter(n=>n&&n.enabled!==!1).map(n=>n.startTime+n.duration)))}async function JIe(t,e,n,r=()=>{}){var S,k;const i=structuredClone(t),a=QIe(e);if(e.end>zG(i)+.001)throw new Error("导出结束时间超出可见时间轴");const s=new VIe().create(a,{start:e.start,end:e.end});n.throwIfAborted(),r({phase:"preparing",frame:0,totalFrames:s.totalFrames});const o=e.format==="prores4444",c=e.format==="mp4-hlg",l=i.tracks.some(C=>C.enabled&&!C.muteAudio&&C.clipIds.some(M=>FG(i.trackClipsMap[M],Ut,e.start,e.end)));a.audioEnabled=l,a.audio.codec=e.format==="webm"?"opus":"aac";const d=l&&!o&&e.format!=="webm";d&&(a.mp4Options={...a.mp4Options,fastStart:!1});const u=o?{audio:"pcm-s16"}:c?{video:"hevc",audio:l&&await XU(["aac"],{numberOfChannels:2,sampleRate:48e3,bitrate:256e3})?"aac":void 0}:await qIe(a);if(n.throwIfAborted(),l&&!u.audio)throw new Error("当前浏览器不支持所选音频编码");const h=d?await YIe():0;n.throwIfAborted();const f=new Map;for(const C of i.tracks.filter(M=>M.enabled))for(const M of C.clipIds){const A=i.trackClipsMap[M];if(!A||A.enabled===!1||A.kind==="text"||A.kind==="effect"||A.startTime>=e.end||A.startTime+A.duration<=e.start)continue;const D=Ut.get(_i(A));if(!D)throw new Error(`缺少素材:${A.label??M}`);f.set(D.id,{file:D.file,metadata:structuredClone(D.metadata),projectFiles:(S=D.sourceProject)==null?void 0:S.files,entryPath:(k=D.sourceProject)==null?void 0:k.entryPath})}const p=new Map;let m,y,g,b,x,v;const w=()=>x==null?void 0:x.dispose();n.addEventListener("abort",w,{once:!0});const T=document.createElement("canvas");T.width=e.width,T.height=e.height;try{for(const[A,D]of f){n.throwIfAborted();const F=await Yo(D.file,A,D.projectFiles,D.entryPath);F.metadata=D.metadata,p.set(A,F)}if(m=await f1e(i,p,n,{transparentBackground:o,outputViewport:{width:e.width,height:e.height}}),n.throwIfAborted(),o){const{registerProResEncoder:A}=await Af(async()=>{const{registerProResEncoder:D}=await import("./prores-encoder-mediabunny-DjdaA3bm.js");return{registerProResEncoder:D}},[]);A()}{g=new WIe(a,u),c?(x=await HIe({width:e.width,height:e.height,frameRate:e.frameRate,bitrate:e.bitrate,signal:n}),n.throwIfAborted(),v=new Bge("hevc"),g.registerVideoTrack({source:v},e.frameRate)):(y=new GIe(a,u,o),g.registerVideoTrack(y,e.frameRate));const A=l?await XIe(i,p,e.start,e.end,n):void 0,D=A?g.registerAudioTrack():void 0;await g.start(),D&&A&&(b=D.add(A).then(()=>D.close()),b.catch(()=>{}))}for(let A=0;A<s.totalFrames;A++){n.throwIfAborted();const D=s.getTimelineTimeUs(A)/1e3;if(c){const F=await m.renderLinearP3(D);n.throwIfAborted();const O=await x.encodeLinearP3(F);n.throwIfAborted(),await v.add(new Vn(O.data,O.key?"key":"delta",s.getOutputTimestampSec(A),s.getOutputDurationUs(A)/1e6,A),A===0?{decoderConfig:{codec:O.codec,codedWidth:e.width,codedHeight:e.height,colorSpace:{primaries:"bt2020",transfer:"hlg",matrix:"bt2020-ncl",fullRange:!1}}}:void 0)}else{const F=await m.render(D);n.throwIfAborted();const O=T.getContext("2d");O.clearRect(0,0,e.width,e.height),O.drawImage(F,0,0,e.width,e.height);const V=new Oa(T,{timestamp:s.getOutputTimestampSec(A),duration:s.getOutputDurationUs(A)/1e6});try{await y.add(V)}finally{V.close()}}r({phase:"video",frame:A+1,totalFrames:s.totalFrames})}y==null||y.close(),v==null||v.close(),await b,n.throwIfAborted(),r({phase:"finalizing",frame:s.totalFrames,totalFrames:s.totalFrames});const C=await g.finalize();n.throwIfAborted();const M=d?ZIe(C.buffer,h,(e.end-e.start)/1e3):C.buffer;return{...C,buffer:M,blob:new Blob([M],{type:C.mimeType})}}catch(C){try{await(g==null?void 0:g.cancel())}catch{}throw C}finally{n.removeEventListener("abort",w),x==null||x.dispose(),y==null||y.close(),await(m==null?void 0:m.dispose());for(const C of p.values())C.element instanceof HTMLMediaElement&&(C.element.pause(),C.element.removeAttribute("src"),C.element.load()),URL.revokeObjectURL(C.url);T.width=T.height=1}}function $Ie({state:t,name:e,onClose:n,onBusy:r}){const[i,a]=I.useState(()=>{const{width:v,height:w}=Fm(t);return{format:"mp4",codec:"avc",frameRate:t.meta.fps,width:v,height:w,bitrate:8e6,start:0,end:zG(t)}}),[s,o]=I.useState(null),[c,l]=I.useState(""),d=I.useRef(null),u=I.useRef(null),h=s!==null,f=i.format==="prores4444",p=i.format==="mp4-hlg";I.useEffect(()=>{var v;return(v=u.current)==null||v.showModal(),()=>{var w;(w=d.current)==null||w.abort(),r(!1)}},[]);const m=v=>a(w=>({...w,...v})),y=async()=>{const v=new AbortController;d.current=v,l(""),o({phase:"preparing",frame:0,totalFrames:0}),r(!0);try{await rs.pause();const w=await JIe(t,i,v.signal,o),T=URL.createObjectURL(w.blob),S=document.createElement("a");S.href=T,S.download=`${e.replace(/[\\/:*?"<>|]/g,"_")||"视频"}${w.fileExtension}`,S.click(),setTimeout(()=>URL.revokeObjectURL(T),6e4),n()}catch(w){v.signal.aborted||l(w instanceof Error?w.message:String(w))}finally{d.current=null,o(null),r(!1)}},g=i.format==="webm"?["vp9","vp8","av1"]:["avc","hevc","av1"],b=(v,w)=>E.jsxs("label",{className:"grid gap-2 text-xs text-[var(--studio-text-secondary)]",children:[E.jsx("span",{children:v}),w]}),x=(v,w,T,S=0,k=1)=>b(v,E.jsx("input",{"aria-label":v,className:"studio-control-field h-9 w-full rounded-sm px-3 text-xs",type:"number",min:S,step:k,disabled:h,value:w,onChange:C=>T(Number(C.target.value))}));return E.jsxs("dialog",{ref:u,className:"local-export-dialog",onCancel:v=>{var w;v.preventDefault(),h?(w=d.current)==null||w.abort():n()},"aria-label":"导出视频",children:[E.jsxs("header",{className:"flex items-center justify-between border-b border-[var(--studio-line-subtle)] px-5 py-4",children:[E.jsx("h2",{className:"text-sm font-semibold",children:"导出视频"}),E.jsx("button",{className:"studio-icon-button","aria-label":"关闭导出",disabled:h,onClick:n,children:E.jsx(V1,{size:17})})]}),E.jsxs("div",{className:"grid gap-4 p-5",children:[E.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[b("格式",E.jsx(xS,{ariaLabel:"格式",value:i.format,options:["mp4","mov","webm","prores4444","mp4-hlg"],renderOption:v=>v==="prores4444"?"ProRes 4444":v==="mp4-hlg"?"MP4 · HDR HLG":v.toUpperCase(),disabled:h,onChange:v=>m({format:v,codec:v==="webm"?"vp9":v==="mp4-hlg"?"hevc":"avc"})})),!f&&!p&&b("视频编码",E.jsx(xS,{ariaLabel:"视频编码",value:i.codec,options:g,renderOption:v=>({avc:"H.264",hevc:"H.265",vp9:"VP9",vp8:"VP8",av1:"AV1"})[v]??v,disabled:h,onChange:v=>m({codec:v})})),x("宽",i.width,v=>m({width:v}),2,2),x("高",i.height,v=>m({height:v}),2,2),b("帧率",E.jsx(xS,{ariaLabel:"帧率",value:String(i.frameRate),options:[...new Set([24,25,30,50,60,i.frameRate])].sort((v,w)=>v-w).map(String),renderOption:v=>`${v} fps`,disabled:h,onChange:v=>m({frameRate:Number(v)})})),!f&&x("码率(Mbps)",i.bitrate/1e6,v=>m({bitrate:v*1e6}),.1,.1)]}),E.jsxs("details",{className:"rounded-sm border border-[var(--studio-line-subtle)]",children:[E.jsx("summary",{className:"cursor-pointer px-3 py-2 text-xs text-[var(--studio-text-muted)]",children:"范围"}),E.jsxs("div",{className:"grid grid-cols-2 gap-3 p-3",children:[x("开始(秒)",i.start/1e3,v=>m({start:v*1e3}),0,.01),x("结束(秒)",i.end/1e3,v=>m({end:v*1e3}),.01,.01)]})]}),s&&E.jsxs("div",{role:"status",children:[E.jsxs("div",{className:"mb-2 flex justify-between text-xs text-[var(--studio-text-muted)]",children:[E.jsx("span",{children:s.phase==="preparing"?"准备素材":s.phase==="finalizing"?"封装视频":"渲染视频"}),E.jsxs("span",{children:[s.totalFrames?Math.round(s.frame/s.totalFrames*100):0,"%"]})]}),E.jsx("progress",{"aria-label":"导出进度",className:"w-full accent-[var(--studio-accent)]",max:Math.max(1,s.totalFrames),value:s.frame})]}),c&&E.jsx("p",{role:"alert",className:"text-xs text-[var(--studio-danger)]",children:c}),E.jsxs("footer",{className:"flex justify-end gap-2",children:[h?E.jsx("button",{className:"studio-button-secondary rounded-sm px-4 py-2 text-xs",onClick:()=>{var v;return(v=d.current)==null?void 0:v.abort()},children:"取消导出"}):E.jsxs("button",{className:"studio-button-primary flex items-center gap-2 rounded-sm px-4 py-2 text-xs",onClick:()=>void y(),children:[E.jsx(H4,{size:14}),"导出"]}),h&&E.jsx(wv,{size:17,className:"spin"})]})]})]})}const eDe="1726ab07-d9aa-41c3-ae35-34532e53903d",D3=()=>({timeline:Zn.getState().state});async function tDe(t){var e;if(t.type!=="inspect"&&await rs.pause(),["scene","object","update"].includes(t.type)){const n=Zn.getState().state.trackClipsMap[t.clipId];if(!n)throw new Error("片段不存在");if(t.type==="update"){if(!Number.isFinite(t.duration)||t.duration<=0)throw new Error("无效时长");return await Cn.updateClip(n.id,{duration:t.duration*1e3}),D3()}const r=await dy(n);if(t.type==="object"){if(!t.address||!t.transform||n.kind!=="motion-graph")throw new Error("缺少对象或修改值");const i=await r.hitTest(0,0,t.address);if(i.elementKind!=="canvas-object"||i.address!==t.address)throw new Error("对象不可编辑");const a=_u(n),s=a.objects[t.address]??{},o={...s,...t.transform};for(const c of["position","rotation","scale","material","light"])t.transform[c]&&Object.assign(o,{[c]:{...s[c],...t.transform[c]}});a.objects[t.address]=o,await Cn.updateClip(n.id,{motionGraphParams:{...n.motionGraphParams,values:{...(e=n.motionGraphParams)==null?void 0:e.values,__vibevideoSceneOverrides:JSON.stringify(a)}}}),await n5.preview.refreshPreview()}return r.hitTest(-1e3,-1e3,t.address)}if(t.type==="import"){const n=new File([t.source],t.name,{type:"text/html"});if(t.clipId){const s=Zn.getState().state.trackClipsMap[t.clipId];if(!s)throw new Error("片段不存在");return await i1e(s,n),await rs.seek(s.startTime),{clipId:s.id,replaced:!0}}const r=await Yo(n);if(!r.htmlSource)throw URL.revokeObjectURL(r.url),new Error("仅支持 HTML/JS 图形");try{await su(r)}catch(s){throw URL.revokeObjectURL(r.url),s}const i=Zn.getState().state;Object.keys(i.trackClipsMap).length||await Cn.updateTimelineMeta({width:r.metadata.videoWidth,height:r.metadata.videoHeight}),Ut.set(r.id,r),ki();let a;try{a=await Cn.appendSourceToTimeline(r.id,{primaryTrackMagnetEnabled:!0})}catch(s){throw Ut.delete(r.id),ki(),URL.revokeObjectURL(r.url),s}return await Cn.focusTimelineClip({clipId:a.id,source:"preview"}),await rs.seek(a.startTime),{clipId:a.id,assetId:r.id,duration:a.duration/1e3}}return t.type==="seek"?await rs.seek(t.seconds*1e3):t.type==="play"&&await rs.togglePlayback(),D3()}function nDe(){if(new URLSearchParams(location.search).get("agent")!=="1")return()=>{};let t=!1,e;const n=async()=>{try{const i=await tB();if(!i)return;const a={Authorization:`Bearer ${(i==null?void 0:i.token)??eDe}`,"Content-Type":"application/json"},s=await fetch("/__vibevideo/agent/next",{headers:a});if(!s.ok)throw new Error("Agent connection unavailable");const o=await s.json();if(o&&!t){let c,l=!0;try{c=await tDe(o.command)}catch(d){l=!1,c={error:d instanceof Error?d.message:String(d)}}await fetch("/__vibevideo/agent/result",{method:"POST",headers:a,body:JSON.stringify({id:o.id,ok:l,result:c,state:D3()})})}}catch(i){console.warn("Local agent bridge:",i)}t||(e=setTimeout(n,350))};return n(),()=>{t=!0,clearTimeout(e)}}const rDe="vibevideo-local-session",ym="projects",LG="last-open-project";function _G(){return new Promise((t,e)=>{const n=indexedDB.open(rDe,1);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(ym)||n.result.createObjectStore(ym)},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error??new Error("无法打开本地工程恢复存储")),n.onblocked=()=>e(new Error("本地工程恢复存储正被其他页面占用"))})}async function MR(t,e,n){const r=await _G();try{const i={name:t,timeline:structuredClone(e),media:n.map(a=>{var s,o;return{id:a.id,file:a.file,projectFiles:(s=a.sourceProject)==null?void 0:s.files.map(({path:c,file:l})=>({path:c,file:l})),entryPath:(o=a.sourceProject)==null?void 0:o.entryPath,graphicContentBounds:a.graphicContentBounds??null,graphicContentBoundsKey:a.graphicContentBoundsKey}}),savedAt:Date.now()};await new Promise((a,s)=>{const o=r.transaction(ym,"readwrite");o.objectStore(ym).put(i,LG),o.oncomplete=()=>a(),o.onerror=()=>s(o.error??new Error("无法保存本地工程恢复数据")),o.onabort=()=>s(o.error??new Error("保存本地工程恢复数据已取消"))})}finally{r.close()}}async function iDe(){const t=await _G();try{return await new Promise((e,n)=>{const r=t.transaction(ym,"readonly").objectStore(ym).get(LG);r.onsuccess=()=>e(r.result??null),r.onerror=()=>n(r.error??new Error("无法读取本地工程恢复数据"))})}finally{t.close()}}const aDe=`// @vibevideo:content-bounds 120,120,1040,480
|
|
969
969
|
export default async function mount({ root, viewport, modules }) {
|
|
970
970
|
const { Application, Container, Graphics, Text } = modules.PIXI;
|
|
971
971
|
const app = new Application();
|