webwallgl 1.0.0-beta1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,24 @@
1
- (()=>{var cl=(et,Ye)=>()=>{try{return Ye||et((Ye={exports:{}}).exports,Ye),Ye.exports}catch(qt){throw Ye=0,qt}};var ll=cl((wr,Wi)=>{(function(et,Ye){typeof wr=="object"&&typeof Wi<"u"?Ye(wr):typeof define=="function"&&define.amd?define(["exports"],Ye):(et=typeof globalThis<"u"?globalThis:et||self,Ye(et.WebWallGL={}))})(wr,function(et){"use strict";function Ye(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function qt(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function ro(e){const n=qt(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function Vi(e){return{cfg:{type:"canvas"},coverAlign:{x:.5,y:.5,tx:.5,ty:.5},frameMeter:{stamps:[],last:0,fps:0},disposers:[]}}(()=>{const e=n=>n.preventDefault();window.addEventListener("contextmenu",e,!0),document.addEventListener("contextmenu",e,!0),window.__blockContextMenu=n=>n.addEventListener("contextmenu",e,!0)})();function tn(e){e.wrap&&(e.wrap.innerHTML=""),e.raf!==void 0&&cancelAnimationFrame(e.raf),e.raf=void 0;for(const n of e.videoPairs??[])n.destroy();e.videoPairs=void 0,e.sceneCleanup&&e.sceneCleanup(),e.sceneCleanup=void 0,e.sceneCtl=void 0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0);for(const n of e.videoTextures??[])n.pause(),n.removeAttribute("src"),n.load(),n.remove();e.videoTextures=void 0;for(const n of e.objectUrls??[])try{URL.revokeObjectURL(n)}catch{}if(e.objectUrls=void 0,e.sceneAudio){for(const n of e.sceneAudio.audios)n.pause(),n.removeAttribute("src"),n.load();e.sceneAudio=void 0}if(e.video){e.video.pause(),e.video.removeAttribute("src");try{e.video.load()}catch{}e.video.remove()}e.video=void 0,e.img=void 0,e.iframe=void 0,e.canvas=void 0,e.ctx=void 0,e.info=void 0,so(e)}function Xi(e){tn(e);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const Hi=new TextDecoder,st=e=>Hi.decode(e).replace(/^\uFEFF/,""),oo=500;function io(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const r=n-oo;for(;t.length&&t[0]<r;)t.shift();const o=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=o>0?(t.length-1)*1e3/o:0}function so(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function Gi(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(oo,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function ae(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const r=n.mediaBase?new URL(n.mediaBase).origin:"";if(r){const o=new Image;o.src=`${r}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Mr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,Yi(e)}function Yi(e){const n=`${(e.coverAlign.x*100).toFixed(2)}% ${(e.coverAlign.y*100).toFixed(2)}%`,t=e.video??e.img;t&&t.isConnected&&(t.style.objectPosition=n)}function ao(e,n,t){const r=Ye(e,t),o=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*r)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*r));return n.width===o&&n.height===i?!1:(n.width=o,n.height=i,!0)}function qi(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<16)throw new Error("\u6587\u4EF6\u592A\u5C0F\uFF0C\u4E0D\u662F scene.pkg");const t=n.getUint32(0,!0);if(t<4||t>16)throw new Error("\u9B54\u6570\u957F\u5EA6\u5F02\u5E38: "+t);const r=co(e,4,t);if(!r.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+r);const o=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let a=0;a<o;a++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+a);const u=n.getUint32(i,!0);if(i+=4,i+u+8>e.length)throw new Error("\u5165\u53E3 "+a+" \u8D8A\u754C");const l=Ki(e,i,u);i+=u;const d=n.getUint32(i,!0);i+=4;const h=n.getUint32(i,!0);i+=4,s.push({name:l,offset:d,size:h})}const c=i;return{magic:r,version:r.slice(4),count:o,entries:s,dataStart:c,fileSize:e.length,buf:e}}function _r(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const r=e.dataStart+t.offset,o=r+t.size;if(r<0||o>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(r,o)}function Zi(e){let n=0;for(const t of e.entries)n=Math.max(n,t.offset+t.size);return{dataEnd:e.dataStart+n,fileSize:e.fileSize,ok:e.dataStart+n<=e.fileSize}}function co(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}function Ki(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return co(e,n,t)}}const Qi=Object.freeze(Object.defineProperty({__proto__:null,getEntry:_r,parsePkg:qi,verifyLayout:Zi},Symbol.toStringTag,{value:"Module"})),Ar={0:"ARGB8888",1:"RGB888",2:"RGB565",4:"DXT5",6:"DXT3",7:"DXT1",8:"RG88",9:"R8",10:"RG1616f",11:"R16f",12:"BC7",13:"RGBa1010102",14:"RGBA16161616f",15:"RGB161616f"},Nt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function Ji(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=n[0];if(e.isVideo)return{width:t.width,height:t.height,video:t.data};if(e.freeImageFormat===Nt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Nt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const r=Tr(e.format,t.data,t.width,t.height);return!e.frames?.list?.length&&(t.width!==e.width||t.height!==e.height)?{width:e.width,height:e.height,rgba:lo(r,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:r}}function es(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const r of n){if(e.freeImageFormat!==Nt.UNKNOWN){t.push({width:r.width,height:r.height,image:r.data,fif:e.freeImageFormat});continue}const o=Tr(e.format,r.data,r.width,r.height);t.push({width:r.width,height:r.height,rgba:o})}return!e.frames?.list?.length&&t.length>0&&(t[0].width!==e.width||t[0].height!==e.height)&&t[0].rgba&&(t[0]={width:e.width,height:e.height,rgba:lo(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function lo(e,n,t,r,o){const i=new Uint8Array(r*o*4);for(let s=0;s<o;s++)i.set(e.subarray(s*n*4,s*n*4+r*4),s*r*4);return i}function Tr(e,n,t,r){switch(e){case 0:return ts(n,t,r);case 1:return ns(n,t,r);case 2:return rs(n,t,r);case 4:return cs(n,t,r);case 6:return as(n,t,r);case 7:return ss(n,t,r);case 8:return os(n,t,r);case 9:return is(n,t,r);case 12:throw new Error("BC7 \u89E3\u7801\u6682\u672A\u5B9E\u73B0\uFF08format=12\uFF09");default:throw new Error("\u672A\u652F\u6301\u7684\u7EB9\u7406\u683C\u5F0F: "+(Ar[e]||e))}}function ts(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function ns(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*3],r[o*4+1]=e[o*3+1],r[o*4+2]=e[o*3+2],r[o*4+3]=255;return r}function rs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++){const i=e[o*2]|e[o*2+1]<<8,s=i>>11&31,c=i>>5&63,a=i&31;r[o*4]=s<<3|s>>2,r[o*4+1]=c<<2|c>>4,r[o*4+2]=a<<3|a>>2,r[o*4+3]=255}return r}function os(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*2+1],r[o*4+1]=e[o*2+1],r[o*4+2]=e[o*2+1],r[o*4+3]=e[o*2];return r}function is(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o],r[o*4+1]=e[o],r[o*4+2]=e[o],r[o*4+3]=255;return r}function ss(e,n,t){return Sr(e,n,t,!0,0)}function as(e,n,t){return Sr(e,n,t,!1,3)}function cs(e,n,t){return Sr(e,n,t,!1,5)}function Sr(e,n,t,r,o){const i=new Uint8Array(n*t*4),s=r?8:16,c=new Uint8Array(16);let a=0;for(let u=0;u<t;u+=4)for(let l=0;l<n;l+=4){if(a+s>e.length)return i;c.set(e.subarray(a,a+s)),a+=s;const d=ls(c,r),h=us(c,r),p=o===3?fs(c):o===5?ds(c):null;for(let w=0;w<4;w++)for(let m=0;m<4;m++){const g=l+m,v=u+w;if(g>=n||v>=t)continue;const b=w*4+m,y=(v*n+g)*4;i[y]=d[h[b]*4],i[y+1]=d[h[b]*4+1],i[y+2]=d[h[b]*4+2],i[y+3]=p!==null?p[b]:d[h[b]*4+3]}}return i}function uo(e,n){const t=e[n]|e[n+1]<<8,r=t>>11&31,o=t>>5&63,i=t&31;return[t,r<<3|r>>2,o<<2|o>>4,i<<3|i>>2]}function ls(e,n){const t=n?0:8,r=uo(e,t),o=uo(e,t+2),i=new Uint8Array(16);return i[0]=r[1],i[1]=r[2],i[2]=r[3],i[3]=255,i[4]=o[1],i[5]=o[2],i[6]=o[3],i[7]=255,n&&r[0]<=o[0]?(i[8]=r[1]+o[1]>>1,i[9]=r[2]+o[2]>>1,i[10]=r[3]+o[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*r[1]+o[1])/3),i[9]=Math.floor((2*r[2]+o[2])/3),i[10]=Math.floor((2*r[3]+o[3])/3),i[11]=255,i[12]=Math.floor((r[1]+2*o[1])/3),i[13]=Math.floor((r[2]+2*o[2])/3),i[14]=Math.floor((r[3]+2*o[3])/3),i[15]=255),i}function us(e,n){const t=n?4:12,r=new Uint8Array(16);for(let o=0;o<4;o++){const i=e[t+o];r[o*4]=i&3,r[o*4+1]=i>>2&3,r[o*4+2]=i>>4&3,r[o*4+3]=i>>6&3}return r}function fs(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const r=e[t],o=r&15,i=r&240;n[2*t]=o|o<<4,n[2*t+1]=i|i>>4}return n}function ds(e){const n=e[0],t=e[1],r=new Uint8Array(8);if(r[0]=n,r[1]=t,n<=t){for(let c=1;c<5;c++)r[1+c]=Math.floor(((5-c)*n+c*t)/5);r[6]=0,r[7]=255}else for(let c=1;c<7;c++)r[c+1]=Math.floor(((7-c)*n+c*t)/7);const o=new Uint8Array(16);let i=0;for(let c=0;c<2;c++){let a=0;for(let u=0;u<3;u++)a|=e[2+c*3+u]<<8*u;for(let u=0;u<8;u++)o[i++]=a>>3*u&7}const s=new Uint8Array(16);for(let c=0;c<16;c++)s[c]=r[o[c]];return s}function fo(e,n){const t=new Uint8Array(n);let r=0,o=0;for(;r<e.length;){const i=e[r++];let s=i>>4;if(s===15){let l;do l=e[r++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[o++]=e[r++];if(r>=e.length)break;const c=e[r]|e[r+1]<<8;r+=2;let a=4+(i&15);if((i&15)===15){let l;do l=e[r++],a+=l;while(l===255)}const u=o-c;for(let l=0;l<a;l++)t[o++]=t[u+l]}return t}function Ue(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function ho(e,n){return Ue(e,n)|0}const bn=new DataView(new ArrayBuffer(4));function Ut(e,n){return bn.setUint8(0,e[n]),bn.setUint8(1,e[n+1]),bn.setUint8(2,e[n+2]),bn.setUint8(3,e[n+3]),bn.getFloat32(0,!0)}function hs(e){let n=0;const t=Yn(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const r=Yn(e,n,9);if(n+=9,r!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+r);const o=Ue(e,n);n+=4;const i=Ue(e,n);n+=4;const s=Ue(e,n);n+=4;const c=Ue(e,n);n+=4;const a=Ue(e,n);n+=4;const u=Ue(e,n);n+=4,n+=4;const l=Yn(e,n,9);n+=9;const d=Ue(e,n);n+=4;let h=Nt.UNKNOWN,p=0;if(l==="TEXB0004\0"){h=Ue(e,n)|0,n+=4;const S=Ue(e,n);n+=4,h===Nt.UNKNOWN&&S===1&&(h=Nt.MP4),p=S===1?4:3}else if(l==="TEXB0003\0")h=Ue(e,n)|0,n+=4,p=3;else if(l==="TEXB0002\0")p=2;else if(l==="TEXB0001\0")p=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const w=(i&32)!==0||h===Nt.MP4,m=[];for(let S=0;S<d;S++){const _=Ue(e,n);n+=4;const C=[];for(let N=0;N<_;N++){if(p===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const D=Ue(e,n);n+=4;const k=Ue(e,n);n+=4;let O=0,j=0;p>=2&&(O=Ue(e,n),n+=4,j=ho(e,n),n+=4);const W=ho(e,n);if(n+=4,w){C.push({width:D,height:k,compression:0,data:e.subarray(n)}),n=e.length;continue}O===0&&(j=W);const K=e.subarray(n,n+W);n+=W;let V=K;O===1&&(V=fo(K,j)),C.push({width:D,height:k,compression:O,data:V})}m.push(C)}const g=m[0]&&m[0][0],v=g?g.width:s,b=g?g.height:c;let y=null;if(n+13<=e.length){const S=Yn(e,n,9);if(S.indexOf("TEXS")===0){let _=n+9;const C=Ue(e,_);_+=4;let N=0,D=0;S==="TEXS0003\0"&&(N=Ue(e,_),_+=4,D=Ue(e,_),_+=4);const k=e.length-_,O=C>0&&k>0&&k%C===0?k/C:0;if(C>0&&C<=4096&&O>=32){const j=[];for(let K=0;K<C;K++){const V=_+K*O;if(V+32>e.length)break;const G=Ut(e,V+8),Q=Ut(e,V+12),q=Ut(e,V+16),te=Ut(e,V+20),me=Ut(e,V+24),xe=Ut(e,V+28);j.push({imageId:Ut(e,V)|0,duration:Ut(e,V+4),x:G,y:Q,width:Math.hypot(q,te)||N,height:Math.hypot(me,xe)||D,uDir:[q,te],vDir:[me,xe],rotated:Math.abs(te)>.5||Math.abs(me)>.5})}j.length===C&&j.every(K=>{if(!(K.width>0&&K.height>0))return!1;const V=[K.x,K.x+K.uDir[0],K.x+K.vDir[0],K.x+K.uDir[0]+K.vDir[0]],G=[K.y,K.y+K.uDir[1],K.y+K.vDir[1],K.y+K.uDir[1]+K.vDir[1]];return Math.min(...V)>=-1&&Math.max(...V)<=v+1&&Math.min(...G)>=-1&&Math.max(...G)<=b+1})&&(y={magic:S,frameWidth:N,frameHeight:D,atlasWidth:v,atlasHeight:b,list:j})}}}return{format:o,formatName:Ar[o]||String(o),flags:i,textureWidth:s,textureHeight:c,width:a,height:u,freeImageFormat:h,containerMagic:l,containerVersion:p,isVideo:w,images:m,frames:y}}function Yn(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}const ms=Object.freeze(Object.defineProperty({__proto__:null,FIF:Nt,TEXTURE_FORMATS:Ar,decodeMip0:Ji,decodeMips:es,decodePixels:Tr,lz4Decompress:fo,parseTex:hs},Symbol.toStringTag,{value:"Module"}));function mo(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Er(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function ps(e,n){return qn(e)&&qn(n)?Number(e)===Number(n):String(e)===String(n)}function Pr(e){if(typeof e=="boolean")return"bool";if(typeof e=="number")return Number.isFinite(e)?"num":"other";if(typeof e=="string"){const n=e.trim().split(/\s+/);return n.length>0&&n[0]!==""&&n.every(t=>Number.isFinite(Number(t)))?"num":"text"}return"other"}function gs(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Pr(e.value)}}function po(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const r=mo(n,e.user.name);if(!r||r.value===void 0||r.value===null)return e.value;const o=r.type==="combo"?Cr(r.value,r.options):r.value;return ps(o,e.user.condition)}if(typeof e.user!="string")return e;const t=mo(n,e.user);if(!t||t.value===void 0||t.value===null)return e.value;if(t.userOverridden)return t.value;if(e.value!==null&&typeof e.value=="object")return e.value;if(e.value===void 0)return t.value;if(Pr(e.value)==="bool"&&t.type==="slider"){const r=Number(t.value);return Number.isFinite(r)?r!==0:e.value}return Pr(e.value)===gs(t)?t.value:e.value}function nn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=nn(e[r],n,t+1);return e}if(Er(e.user)){let r=po(e,n);for(let o=0;o<8&&r!==null&&typeof r=="object"&&Er(r.user);o++)r=po(r,n);return e.value=nn(r,n,t+1),e}for(const r of Object.keys(e))e[r]=nn(e[r],n,t+1);return e}function bs(e){return e?Array.isArray(e)?e.map(n=>n&&typeof n=="object"&&"value"in n?n.value:n):typeof e=="object"?Object.values(e):[]:[]}function qn(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Cr(e,n){const t=bs(n);return!(t.length>0?t.every(qn):qn(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function vs(e){const n={};if(!e||typeof e!="object")return n;for(const[t,r]of Object.entries(e))!r||typeof r!="object"||!("value"in r)||(n[t]=r.type==="combo"?Cr(r.value,r.options):r.value);return n}function pt(e){return e&&typeof e=="object"?Er(e.user):null}function ys(e,n,t){const r={};if(!t||typeof t!="object")return r;const o=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,c]of Object.entries(t)){const a=c&&typeof c=="object"&&"value"in c?c.value:c,u=o[s];if(u&&typeof u=="object"){u.value=a,u.userOverridden=!0;const l=u.type==="combo"?Cr(u.value,u.options):u.value;i[s]=l,r[s]=l}else i[s]=a,r[s]=a}return r}function rn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0,n[0]||0]:[n[0]||0,n[1]||0,n[2]||0]}function vn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0]:[n[0]||0,n[1]||0]}function Zn(e){return e==null?[1,1,1]:typeof e=="string"?rn(e):typeof e=="object"&&e!==null?rn(e.value):[1,1,1]}function Ke(e,n=!1){if(e==null)return n;if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="object"&&e!==null){const t=e.value;return typeof t=="number"?t!==0:!!t}return n}function tt(e,n){if(typeof e=="number")return e;if(e!==null&&typeof e=="object"){const t=Number(e.value);return Number.isFinite(t)?t:n}return n}function xs(e,n){const t=n&&n.general&&n.general.properties||{},r=e.objects||[];nn(r,t,0),nn(e.general||{},t,0);const o=new Map;for(const m of r)m.id!==void 0&&o.set(m.id,m);const i=r.map(m=>({id:m.id,parent:m.parent,origin:rn(m.origin||"0 0 0"),scale:rn(m.scale||"1 1 1"),angles:rn(m.angles||"0 0 0")}));for(let m=0;m<8;m++){let g=!1;for(const v of i){if(v.parent===void 0||v.parent===null||!o.get(v.parent))continue;const y=i.findIndex(G=>G.id===v.parent);if(y<0)continue;const S=i[y];if(S.parent!==void 0&&S.parent!==null)continue;const _=r[y],C=_.scale,N=C!==null&&typeof C=="object"&&(typeof C.script=="string"||C.user!==void 0),D=!_.image&&!_.model&&!_.particle&&_.text==null&&!_.size,k=N&&D?[1,1,1]:S.scale,O=S.angles[2]*Math.PI/180,j=Math.cos(O),W=Math.sin(O),K=v.origin[0]*k[0],V=v.origin[1]*k[1];v.origin[0]=S.origin[0]+K*j-V*W,v.origin[1]=S.origin[1]+K*W+V*j,v.origin[2]=S.origin[2]+v.origin[2],v.angles[2]=S.angles[2]+v.angles[2],v.scale[0]=k[0]*v.scale[0],v.scale[1]=k[1]*v.scale[1],v.scale[2]=k[2]*v.scale[2],v.parent=null,g=!0}if(!g)break}const s=r.map(m=>Ke(m.visible,!0)),c=new Map;r.forEach((m,g)=>{m.id!==void 0&&c.set(m.id,g)});const a=new Map,u=new Map;for(const m of r)if(m.parent!==void 0&&m.parent!==null){a.set(m.parent,(a.get(m.parent)||0)+1);const g=m.id!==void 0?m.id:null;if(g!==null){const v=u.get(m.parent);v?v.push(g):u.set(m.parent,[g])}}const l=r.map(()=>!0);for(let m=0;m<r.length;m++){let g=s[m],v=r[m].parent;for(let b=0;g&&v!==void 0&&v!==null&&b<64;b++){const y=c.get(v);if(y===void 0)break;s[y]||(g=!1),v=r[y].parent}l[m]=g}const d=r.map((m,g)=>{const v=i[g],b=typeof m.image=="string"&&(m.image.indexOf("models/util/projectlayer")===0||m.image.indexOf("models/util/fullscreenlayer")===0);let y=vn(m.size||"0 0"),S=v.origin;if(b){const _=(e.general||{}).orthogonalprojection,C=_&&Number(_.width),N=_&&Number(_.height);C>0&&N>0&&(y=[C,N],S=[C/2,N/2,v.origin[2]||0])}return{id:m.id!==void 0?m.id:g,name:m.name||"",visible:l[g],visibleSelf:s[g],srcObject:m,image:typeof m.image=="string"?m.image:null,model:typeof m.model=="string"?m.model:null,isSkybox:typeof m.name=="string"&&m.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof m.particle=="string"?m.particle:null,instanceoverride:m.instanceoverride||null,sound:Array.isArray(m.sound)?m.sound.filter(_=>typeof _=="string"):[],soundprops:{volume:tt(m.volume,1),playbackmode:m.playbackmode||"single",startsilent:Ke(m.startsilent,!1),maxtime:tt(m.maxtime,0),mintime:tt(m.mintime,0),spatialization:Ke(m.spatialization,!1),muteineditor:Ke(m.muteineditor,!1)},text:typeof m.text=="string"?m.text:m.text&&typeof m.text=="object"?m.text.value:null,textScript:m.text&&typeof m.text=="object"&&m.text.script||null,textScriptProps:m.text&&typeof m.text=="object"&&m.text.scriptproperties||null,component:typeof m.component=="string"?m.component:null,isText:m.text!==void 0&&m.text!==null,textFont:typeof m.font=="string"?m.font:null,textPointsize:tt(m.pointsize,24)||24,textColor:Zn(m.color),textAnchor:typeof m.anchor=="string"&&m.anchor!=="none"?m.anchor:"center",textMaxwidth:tt(m.maxwidth,0),textMaxrows:tt(m.maxrows,0),textLimitwidth:Ke(m.limitwidth,!1),textLimitrows:Ke(m.limitrows,!1),textLimituseellipsis:Ke(m.limituseellipsis,!1),textHAlign:m.horizontalalign||"center",textVAlign:m.verticalalign||"center",textSpacing:m.spacing?vn(m.spacing):[0,0],textPadding:(()=>{const _=m.padding;if(typeof _=="number")return _;const C=String(_??"").trim().split(/\s+/).map(Number).filter(N=>Number.isFinite(N));return C.length?C.reduce((N,D)=>N+D,0)/C.length:0})(),textOpaquebackground:Ke(m.opaquebackground,!1),textBackgroundcolor:Zn(m.backgroundcolor),textBackgroundbrightness:tt(m.backgroundbrightness,1),textCastshadow:Ke(m.castshadow,!1),isSound:!!(m.sound&&m.sound.length),isComponent:!!m.component,objectScripts:(()=>{const _={};for(const C of["scale","origin","color","alpha","brightness","angles","visible"]){const N=m[C];N&&typeof N=="object"&&typeof N.script=="string"&&N.script&&(_[C]={script:N.script,scriptproperties:N.scriptproperties||null,value:N.value})}return Object.keys(_).length?_:null})(),objectAnimations:(()=>{const _={};for(const C of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const N=m[C];N&&typeof N=="object"&&N.animation&&typeof N.animation=="object"&&N.animation.options&&(_[C]={animation:N.animation,value:N.value})}return Object.keys(_).length?_:null})(),animationLayers:(m.animationlayers||[]).filter(_=>_&&typeof _.animation=="number").map(_=>({animation:_.animation,visible:Ke(_.visible,!0),additive:Ke(_.additive,!1),blend:tt(_.blend,1),rate:tt(_.rate,1)})),solid:(()=>{if(typeof m.particle=="string")return!1;const _=typeof m.image=="string"?m.image:"";return _.indexOf("models/util/composelayer")===0?!1:_.indexOf("models/util/solidlayer")===0?!0:m.solid?!_||_.indexOf("models/util/")===0:!1})(),isContainer:typeof m.image=="string"&&m.image.indexOf("models/util/composelayer")===0,hasChildren:(a.get(m.id!==void 0?m.id:g)||0)>0,childIds:u.get(m.id!==void 0?m.id:g)||null,parentId:m.parent!==void 0&&m.parent!==null?m.parent:null,attachment:typeof m.attachment=="string"&&m.attachment!==""?m.attachment:null,passthrough:!!(m.config&&m.config.passthrough===!0),isPostProcess:b,origin:S,scale:v.scale,angles:v.angles,size:y,alignment:m.alignment||"center",color:Zn(m.color),alpha:tt(m.alpha,1),brightness:tt(m.brightness,1),copybackground:!!m.copybackground,colorBlendMode:m.colorBlendMode||0,parallaxDepth:m.parallaxDepth!==void 0?vn(m.parallaxDepth):null,effects:(m.effects||[]).map(_=>({file:_.file||"",name:typeof _.name=="string"?_.name:"",visible:Ke(_.visible,!0),visibleScript:_.visible&&typeof _.visible=="object"&&typeof _.visible.script=="string"&&_.visible.script?{script:_.visible.script,scriptproperties:_.visible.scriptproperties||null,value:!!_.visible.value}:null,passes:(_.passes||[]).map(C=>({combos:C.combos||{},constantshadervalues:C.constantshadervalues||{},textures:C.textures||[]}))}))}}),h=e.general||{},p=(()=>{const m={};for(const[g,v]of Object.entries(h))v&&typeof v=="object"&&typeof v.script=="string"&&v.script&&(m[g]={script:v.script,scriptproperties:v.scriptproperties||null,value:v.value});return Object.keys(m).length?m:null})(),w=(()=>{const m={};for(const[g,v]of Object.entries(h))v&&typeof v=="object"&&v.animation&&typeof v.animation=="object"&&v.animation.options&&(m[g]={animation:v.animation,value:v.value});return Object.keys(m).length?m:null})();{const m=new Map;for(const g of d)g.id!==void 0&&m.set(g.id,g);for(let g=0;g<8;g++){let v=!1;for(const b of d){if(b.parallaxDepth||b.parentId==null)continue;const y=m.get(b.parentId);!y||!y.parallaxDepth||y.image||y.particle||y.model||(b.parallaxDepth=y.parallaxDepth.slice(),v=!0)}if(!v)break}}return{camera:e.camera||null,general:h,generalScripts:p,generalAnimations:w,layers:d,properties:t}}function ws(e){if(!Array.isArray(e))return;const n=new Map;for(const t of e)t&&t.id!==void 0&&t.id!==null&&n.set(t.id,t);for(const t of e){if(!t)continue;if(t.destroyed){t.visible=!1;continue}let r=t.visibleSelf!==!1,o=t.parentId;for(let i=0;r&&o!=null&&i<64;i++){const s=n.get(o);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(r=!1),o=s.parentId}t.visible=r}}function Ms(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function _s(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?vn(e.cropoffset):null}}const As=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:Ms,parseBool:Ke,parseColor:Zn,parseNum:tt,parseScene:xs,parseVec2:vn,parseVec3:rn,recomputeLayerVisibility:ws,resolveMaterial:_s},Symbol.toStringTag,{value:"Module"}));function Ts(e,n,t){const r=_r(e,n.file);if(r===null)return;let o;try{o=JSON.parse(t(r))}catch{return}n.fbos=o.fbos||[],n.materialPasses=(o.passes||[]).map(i=>{if(!i.material)return{shader:null,copyCommand:!0,target:i.target||null,source:i.source||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const s=_r(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const c=JSON.parse(t(s)),a=c.passes&&c.passes[0]||{};return{shader:a.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:a.blending||"normal",textures:a.textures||[],combos:a.combos||{},constants:a.constantshadervalues||{}}})}const Ss={"models/util/solidlayer.json":{material:"materials/util/solidlayer.json"},"models/util/composelayer.json":{material:"materials/util/solidlayer.json"},"models/util/fullscreenlayer.json":{material:"materials/util/solidlayer.json"},"models/util/projectlayer.json":{material:"materials/util/solidlayer.json"}};function go(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function Es(e,n){return!e||!n||!n.shader||go(n.shader)||(e.effects=e.effects||[],e.effects.some(t=>t.layerMaterial))?!1:(e.effects.unshift({file:"",name:"_layerMaterial",visible:!0,layerMaterial:!0,passes:[{combos:n.combos||{},constantshadervalues:n.constantshadervalues||{},textures:n.textures||[]}],materialPasses:[{shader:n.shader,copyCommand:!1,target:null,binds:[],blending:n.blending||"normal",textures:n.textures||[],combos:n.combos||{},constants:n.constantshadervalues||{}}],fbos:[]}),!0)}const Ps=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:{"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},BUILTIN_MODELS:Ss,attachLayerMaterialEffect:Es,isBuiltinAlbedoShader:go,resolveEffectChain:Ts},Symbol.toStringTag,{value:"Module"}));function on(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function gt(e,n){const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+o]*n[r*4+s];t[r*4+o]=i}return t}function yn(e,n,t,r,o,i){const s=on();return s[0]=2/(n-e),s[5]=2/(r-t),s[10]=-2/(i-o),s[12]=-(n+e)/(n-e),s[13]=-(r+t)/(r-t),s[14]=-0/(i-o),s}function sn(e,n,t,r){return gt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,r,1]))}function Cs(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let r=0;r<4;r++)n[r*4+t]=e[t*4+r];return n}function xn(e,n,t,r){return gt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1]))}function bo(e,n){const t=Math.cos(n),r=Math.sin(n);return gt(e,new Float32Array([t,r,0,0,-r,t,0,0,0,0,1,0,0,0,0,1]))}function Rs(e,n){const t=Math.cos(n),r=Math.sin(n);return gt(e,new Float32Array([1,0,0,0,0,t,r,0,0,-r,t,0,0,0,0,1]))}function Ls(e,n){const t=Math.cos(n),r=Math.sin(n);return gt(e,new Float32Array([t,0,-r,0,0,1,0,0,r,0,t,0,0,0,0,1]))}function Fs(e,n,t,r){const o=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=o/(n||1),i[5]=o,i[10]=(r+t)/(t-r),i[11]=-1,i[14]=2*r*t/(t-r),i}function Kn(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function Ns(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:Kn(n.fov,0)>0}function Us(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function ks(e,n,t){const r=yo([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=yo(xo(t,r)),i=xo(r,o),s=new Float32Array([o[0],i[0],r[0],0,o[1],i[1],r[1],0,o[2],i[2],r[2],0,0,0,0,1]);return s[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s}function Bs(e,n,t,r){const o=e[3]*n+e[7]*t+e[11]*r+e[15];return[(e[0]*n+e[4]*t+e[8]*r+e[12])/o,(e[1]*n+e[5]*t+e[9]*r+e[13])/o,(e[2]*n+e[6]*t+e[10]*r+e[14])/o]}const Is=[[16,9],[16,10],[21,9],[32,9]];function Os(e,n,t,r,o){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(r>0))return null;const s=.02,c=t/r;if(Math.abs(i-c)<=s*c)return{viewW:t,viewH:r};for(const[a,u]of Is){const l=a/u;if(Math.abs(i-l)>s*l)continue;const d=r,h=r*l;return h>t+1e-6?{viewW:t,viewH:t/l}:{viewW:h,viewH:d}}return null}function Rr(e,n,t,r,o,i,s){const c=vo(i),a=vo(s);if(e==="cover"){const u=Os(r,o,n,t);if(u)return{offX:(n-u.viewW)*c,offY:(t-u.viewH)*a,viewW:u.viewW,viewH:u.viewH};const l=Math.max(r/n,o/t),d=r/l,h=o/l;return{offX:(n-d)*c,offY:(t-h)*a,viewW:d,viewH:h}}if(e==="contain"){const u=r/o;if(n/t>u){const p=n,w=n/u;return{offX:0,offY:(t-w)/2,viewW:p,viewH:w}}const d=t,h=t*u;return{offY:0,offX:(n-h)/2,viewW:h,viewH:d}}return{offX:0,offY:0,viewW:n,viewH:t}}function Ds(e,n,t,r,o,i){const s=e.general,c=e.camera,a=c&&c.eye?Lr(c.eye):[0,0,0],u=c&&c.center?Lr(c.center):[0,0,-1],l=c&&c.up?Lr(c.up):[0,1,0];if(Ns(e)){const y=t>0?n/t:1.7777777777777777,S=Kn(s.fov,50),_=Math.max(Kn(s.nearz,.01),1e-4),C=Math.max(Kn(s.farz,1e4),_+1),N=ks(a,u,l),D=Fs(S,y,_,C);return{view:N,projection:D,eye:a,center:u,projW:y,projH:1,offX:0,offY:0,viewW:y,viewH:1,perspective:!0}}const d=on(),h=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,p=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,w=Rr(r,h,p,n,t,o,i),m=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,g=m&&typeof m=="object"?m.value:m,v=Number(g);if(Number.isFinite(v)&&v>0&&Math.abs(v-1)>1e-6){const y=w.offX+w.viewW/2,S=w.offY+w.viewH/2,_=w.viewW/v,C=w.viewH/v;w.offX=y-_/2,w.offY=S-C/2,w.viewW=_,w.viewH=C}const b=yn(w.offX,w.offX+w.viewW,w.offY+w.viewH,w.offY,-1e4,1e4);return{view:d,projection:b,eye:a,projW:h,projH:p,offX:w.offX,offY:w.offY,viewW:w.viewW,viewH:w.viewH,perspective:!1}}function vo(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function Lr(e){return String(e).trim().split(/\s+/).map(Number)}function yo(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function xo(e,n){return[e[1]*n[2]-e[2]*n[1],e[2]*n[0]-e[0]*n[2],e[0]*n[1]-e[1]*n[0]]}function an(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function zs(e){const n=new Map,t=new Map,r=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let o;for(;(o=r.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();o[2]!==void 0?t.set(o[1],{args:o[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(o[3])}):n.set(o[1],i(o[3]))}return{defs:n,fns:t}}function $s(e,n,t,r){const o=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){o.push(e.slice(i));break}o.push(e.slice(i,s));let a=s+n.length;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]!=="("){o.push(e.slice(s,a)),i=a;continue}let u=0,l=a;for(;l<e.length;l++)if(e[l]==="(")u++;else if(e[l]===")"&&(u--,u===0))break;if(l>=e.length){o.push(e.slice(s));break}const d=e.slice(a+1,l),h=kt(d);let p=t.body;t.args.forEach((w,m)=>{const g=h[m]!==void 0?h[m].trim():"";p=wn(p,w,g)}),r>0&&(p=wo(p,r-1)),o.push("("+p+")"),i=l+1}return o.join("")}function wn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function kt(e){const n=[];let t=0,r="";for(let o=0;o<e.length;o++){const i=e[o];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(r),r=""):r+=i}return r.trim()!==""&&n.push(r),n}function wo(e,n){for(let t=0;t<12;t++){const{defs:r,fns:o}=zs(e);if(r.size===0&&o.size===0)break;const i=e.split(`
2
- `);let s=!1;for(let c=0;c<i.length;c++){const a=i[c];if(/^[ \t]*#/.test(a))continue;let u=a;for(const[l,d]of r)new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(u)&&(u=wn(u,l,d),s=!0);for(const[l,d]of o)u.includes(l)&&(u=$s(u,l,d,n),s=!0);i[c]=u}if(e=i.join(`
3
- `),!s)break}return e}function Mo(e,n,t){const r=p=>n[p]!==void 0?String(n[p]):t.has(p)?"("+t.get(p)+")":"0";let o=e.replace(/\b[A-Za-z_][A-Za-z0-9_]*\b/g,p=>r(p)),i=0;function s(){for(;i<o.length&&/\s/.test(o[i]);)i++}function c(){let p=a();for(s();o.startsWith("||",i);){i+=2;const w=a();p=p||w,s()}return p}function a(){let p=u();for(s();o.startsWith("&&",i);){i+=2;const w=u();p=p&&w,s()}return p}function u(){let p=l();for(s();o.startsWith("==",i)||o.startsWith("!=",i);){const w=o[i]==="="?"==":"!=";i+=2;const m=l();p=w==="=="?p===m:p!==m,s()}return p}function l(){let p=d();for(s();/^[<>]/.test(o[i]||"");){let w=o[i];o[i+1]==="="&&(w+="=",i++),i++;const m=d();w==="<"?p=p<m:w===">"?p=p>m:w==="<="?p=p<=m:p=p>=m,s()}return p}function d(){return s(),o[i]==="!"?(i++,!d()):h()}function h(){if(s(),o[i]==="("){i++;const w=c();return s(),i++,w}const p=/^-?\d+(\.\d+)?/.exec(o.slice(i));return p?(i+=p[0].length,Number(p[0])):!1}return c()}function _o(e){let n="",t=0;const r=e.length;for(;t<r;){const o=e[t],i=e[t+1];if(o==="/"&&i==="*"){for(t+=2;t<r&&!(e[t]==="*"&&e[t+1]==="/");)e[t]===`
1
+ (()=>{var Cl=(rt,We)=>()=>{try{return We||rt((We={exports:{}}).exports,We),We.exports}catch(Xt){throw We=0,Xt}};var Rl=Cl((_r,Ji)=>{(function(rt,We){typeof _r=="object"&&typeof Ji<"u"?We(_r):typeof define=="function"&&define.amd?define(["exports"],We):(rt=typeof globalThis<"u"?globalThis:rt||self,We(rt.WebWallGL={}))})(_r,function(rt){"use strict";function We(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function Xt(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function lo(e){const n=Xt(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function es(e){return{cfg:{type:"canvas"},coverAlign:{x:.5,y:.5,tx:.5,ty:.5},frameMeter:{stamps:[],last:0,fps:0},disposers:[]}}(()=>{const e=n=>n.preventDefault();window.addEventListener("contextmenu",e,!0),document.addEventListener("contextmenu",e,!0),window.__blockContextMenu=n=>n.addEventListener("contextmenu",e,!0)})();function en(e){e.wrap&&(e.wrap.innerHTML=""),e.raf!==void 0&&cancelAnimationFrame(e.raf),e.raf=void 0;for(const n of e.videoPairs??[])n.destroy();e.videoPairs=void 0,e.sceneCleanup&&e.sceneCleanup(),e.sceneCleanup=void 0,e.sceneCtl=void 0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0);for(const n of e.videoTextures??[])n.pause(),n.removeAttribute("src"),n.load(),n.remove();e.videoTextures=void 0;for(const n of e.objectUrls??[])try{URL.revokeObjectURL(n)}catch{}if(e.objectUrls=void 0,e.sceneAudio){for(const n of e.sceneAudio.audios)n.pause(),n.removeAttribute("src"),n.load();e.sceneAudio=void 0}if(e.video){e.video.pause(),e.video.removeAttribute("src");try{e.video.load()}catch{}e.video.remove()}e.video=void 0,e.img=void 0,e.iframe=void 0,e.canvas=void 0,e.ctx=void 0,e.info=void 0,ho(e)}function ts(e){en(e);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const ns=new TextDecoder,ct=e=>ns.decode(e).replace(/^\uFEFF/,""),uo=500;function fo(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const o=n-uo;for(;t.length&&t[0]<o;)t.shift();const r=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=r>0?(t.length-1)*1e3/r:0}function ho(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function rs(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(uo,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function re(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const o=n.mediaBase?new URL(n.mediaBase).origin:"";if(o){const r=new Image;r.src=`${o}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Tr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,os(e)}function os(e){const n=`${(e.coverAlign.x*100).toFixed(2)}% ${(e.coverAlign.y*100).toFixed(2)}%`,t=e.video??e.img;t&&t.isConnected&&(t.style.objectPosition=n)}function mo(e,n,t){const o=We(e,t),r=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*o)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*o));return n.width===r&&n.height===i?!1:(n.width=r,n.height=i,!0)}function is(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<16)throw new Error("\u6587\u4EF6\u592A\u5C0F\uFF0C\u4E0D\u662F scene.pkg");const t=n.getUint32(0,!0);if(t<4||t>16)throw new Error("\u9B54\u6570\u957F\u5EA6\u5F02\u5E38: "+t);const o=po(e,4,t);if(!o.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+o);const r=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let a=0;a<r;a++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+a);const f=n.getUint32(i,!0);if(i+=4,i+f+8>e.length)throw new Error("\u5165\u53E3 "+a+" \u8D8A\u754C");const l=as(e,i,f);i+=f;const d=n.getUint32(i,!0);i+=4;const h=n.getUint32(i,!0);i+=4,s.push({name:l,offset:d,size:h})}const c=i;return{magic:o,version:o.slice(4),count:r,entries:s,dataStart:c,fileSize:e.length,buf:e}}function Sr(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const o=e.dataStart+t.offset,r=o+t.size;if(o<0||r>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(o,r)}function ss(e){let n=0;for(const t of e.entries)n=Math.max(n,t.offset+t.size);return{dataEnd:e.dataStart+n,fileSize:e.fileSize,ok:e.dataStart+n<=e.fileSize}}function po(e,n,t){let o="";for(let r=n;r<n+t;r++)o+=String.fromCharCode(e[r]);return o}function as(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return po(e,n,t)}}const cs=Object.freeze(Object.defineProperty({__proto__:null,getEntry:Sr,parsePkg:is,verifyLayout:ss},Symbol.toStringTag,{value:"Module"})),Er={0:"ARGB8888",1:"RGB888",2:"RGB565",4:"DXT5",6:"DXT3",7:"DXT1",8:"RG88",9:"R8",10:"RG1616f",11:"R16f",12:"BC7",13:"RGBa1010102",14:"RGBA16161616f",15:"RGB161616f"},Nt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function ls(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=n[0];if(e.isVideo)return{width:t.width,height:t.height,video:t.data};if(e.freeImageFormat===Nt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Nt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const o=Pr(e.format,t.data,t.width,t.height);return!e.frames?.list?.length&&(t.width!==e.width||t.height!==e.height)?{width:e.width,height:e.height,rgba:go(o,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:o}}function us(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const o of n){if(e.freeImageFormat!==Nt.UNKNOWN){t.push({width:o.width,height:o.height,image:o.data,fif:e.freeImageFormat});continue}const r=Pr(e.format,o.data,o.width,o.height);t.push({width:o.width,height:o.height,rgba:r})}return!e.frames?.list?.length&&t.length>0&&(t[0].width!==e.width||t[0].height!==e.height)&&t[0].rgba&&(t[0]={width:e.width,height:e.height,rgba:go(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function go(e,n,t,o,r){const i=new Uint8Array(o*r*4);for(let s=0;s<r;s++)i.set(e.subarray(s*n*4,s*n*4+o*4),s*o*4);return i}function Pr(e,n,t,o){switch(e){case 0:return fs(n,t,o);case 1:return ds(n,t,o);case 2:return hs(n,t,o);case 4:return ys(n,t,o);case 6:return bs(n,t,o);case 7:return gs(n,t,o);case 8:return ms(n,t,o);case 9:return ps(n,t,o);case 12:throw new Error("BC7 \u89E3\u7801\u6682\u672A\u5B9E\u73B0\uFF08format=12\uFF09");default:throw new Error("\u672A\u652F\u6301\u7684\u7EB9\u7406\u683C\u5F0F: "+(Er[e]||e))}}function fs(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function ds(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++)o[r*4]=e[r*3],o[r*4+1]=e[r*3+1],o[r*4+2]=e[r*3+2],o[r*4+3]=255;return o}function hs(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++){const i=e[r*2]|e[r*2+1]<<8,s=i>>11&31,c=i>>5&63,a=i&31;o[r*4]=s<<3|s>>2,o[r*4+1]=c<<2|c>>4,o[r*4+2]=a<<3|a>>2,o[r*4+3]=255}return o}function ms(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++)o[r*4]=e[r*2+1],o[r*4+1]=e[r*2+1],o[r*4+2]=e[r*2+1],o[r*4+3]=e[r*2];return o}function ps(e,n,t){const o=new Uint8Array(n*t*4);for(let r=0;r<n*t;r++)o[r*4]=e[r],o[r*4+1]=e[r],o[r*4+2]=e[r],o[r*4+3]=255;return o}function gs(e,n,t){return Cr(e,n,t,!0,0)}function bs(e,n,t){return Cr(e,n,t,!1,3)}function ys(e,n,t){return Cr(e,n,t,!1,5)}function Cr(e,n,t,o,r){const i=new Uint8Array(n*t*4),s=o?8:16,c=new Uint8Array(16);let a=0;for(let f=0;f<t;f+=4)for(let l=0;l<n;l+=4){if(a+s>e.length)return i;c.set(e.subarray(a,a+s)),a+=s;const d=vs(c,o),h=xs(c,o),m=r===3?ws(c):r===5?Ms(c):null;for(let M=0;M<4;M++)for(let g=0;g<4;g++){const y=l+g,b=f+M;if(y>=n||b>=t)continue;const p=M*4+g,v=(b*n+y)*4;i[v]=d[h[p]*4],i[v+1]=d[h[p]*4+1],i[v+2]=d[h[p]*4+2],i[v+3]=m!==null?m[p]:d[h[p]*4+3]}}return i}function bo(e,n){const t=e[n]|e[n+1]<<8,o=t>>11&31,r=t>>5&63,i=t&31;return[t,o<<3|o>>2,r<<2|r>>4,i<<3|i>>2]}function vs(e,n){const t=n?0:8,o=bo(e,t),r=bo(e,t+2),i=new Uint8Array(16);return i[0]=o[1],i[1]=o[2],i[2]=o[3],i[3]=255,i[4]=r[1],i[5]=r[2],i[6]=r[3],i[7]=255,n&&o[0]<=r[0]?(i[8]=o[1]+r[1]>>1,i[9]=o[2]+r[2]>>1,i[10]=o[3]+r[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*o[1]+r[1])/3),i[9]=Math.floor((2*o[2]+r[2])/3),i[10]=Math.floor((2*o[3]+r[3])/3),i[11]=255,i[12]=Math.floor((o[1]+2*r[1])/3),i[13]=Math.floor((o[2]+2*r[2])/3),i[14]=Math.floor((o[3]+2*r[3])/3),i[15]=255),i}function xs(e,n){const t=n?4:12,o=new Uint8Array(16);for(let r=0;r<4;r++){const i=e[t+r];o[r*4]=i&3,o[r*4+1]=i>>2&3,o[r*4+2]=i>>4&3,o[r*4+3]=i>>6&3}return o}function ws(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const o=e[t],r=o&15,i=o&240;n[2*t]=r|r<<4,n[2*t+1]=i|i>>4}return n}function Ms(e){const n=e[0],t=e[1],o=new Uint8Array(8);if(o[0]=n,o[1]=t,n<=t){for(let c=1;c<5;c++)o[1+c]=Math.floor(((5-c)*n+c*t)/5);o[6]=0,o[7]=255}else for(let c=1;c<7;c++)o[c+1]=Math.floor(((7-c)*n+c*t)/7);const r=new Uint8Array(16);let i=0;for(let c=0;c<2;c++){let a=0;for(let f=0;f<3;f++)a|=e[2+c*3+f]<<8*f;for(let f=0;f<8;f++)r[i++]=a>>3*f&7}const s=new Uint8Array(16);for(let c=0;c<16;c++)s[c]=o[r[c]];return s}function yo(e,n){const t=new Uint8Array(n);let o=0,r=0;for(;o<e.length;){const i=e[o++];let s=i>>4;if(s===15){let l;do l=e[o++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[r++]=e[o++];if(o>=e.length)break;const c=e[o]|e[o+1]<<8;o+=2;let a=4+(i&15);if((i&15)===15){let l;do l=e[o++],a+=l;while(l===255)}const f=r-c;for(let l=0;l<a;l++)t[r++]=t[f+l]}return t}function Ie(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function vo(e,n){return Ie(e,n)|0}const bn=new DataView(new ArrayBuffer(4));function kt(e,n){return bn.setUint8(0,e[n]),bn.setUint8(1,e[n+1]),bn.setUint8(2,e[n+2]),bn.setUint8(3,e[n+3]),bn.getFloat32(0,!0)}function As(e){let n=0;const t=Yn(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const o=Yn(e,n,9);if(n+=9,o!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+o);const r=Ie(e,n);n+=4;const i=Ie(e,n);n+=4;const s=Ie(e,n);n+=4;const c=Ie(e,n);n+=4;const a=Ie(e,n);n+=4;const f=Ie(e,n);n+=4,n+=4;const l=Yn(e,n,9);n+=9;const d=Ie(e,n);n+=4;let h=Nt.UNKNOWN,m=0;if(l==="TEXB0004\0"){h=Ie(e,n)|0,n+=4;const _=Ie(e,n);n+=4,h===Nt.UNKNOWN&&_===1&&(h=Nt.MP4),m=_===1?4:3}else if(l==="TEXB0003\0")h=Ie(e,n)|0,n+=4,m=3;else if(l==="TEXB0002\0")m=2;else if(l==="TEXB0001\0")m=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const M=(i&32)!==0||h===Nt.MP4,g=[];for(let _=0;_<d;_++){const w=Ie(e,n);n+=4;const L=[];for(let F=0;F<w;F++){if(m===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const D=Ie(e,n);n+=4;const B=Ie(e,n);n+=4;let z=0,V=0;m>=2&&(z=Ie(e,n),n+=4,V=vo(e,n),n+=4);const Y=vo(e,n);if(n+=4,M){L.push({width:D,height:B,compression:0,data:e.subarray(n)}),n=e.length;continue}z===0&&(V=Y);const Z=e.subarray(n,n+Y);n+=Y;let X=Z;z===1&&(X=yo(Z,V)),L.push({width:D,height:B,compression:z,data:X})}g.push(L)}const y=g[0]&&g[0][0],b=y?y.width:s,p=y?y.height:c;let v=null;if(n+13<=e.length){const _=Yn(e,n,9);if(_.indexOf("TEXS")===0){let w=n+9;const L=Ie(e,w);w+=4;let F=0,D=0;_==="TEXS0003\0"&&(F=Ie(e,w),w+=4,D=Ie(e,w),w+=4);const B=e.length-w,z=L>0&&B>0&&B%L===0?B/L:0;if(L>0&&L<=4096&&z>=32){const V=[];for(let Z=0;Z<L;Z++){const X=w+Z*z;if(X+32>e.length)break;const q=kt(e,X+8),oe=kt(e,X+12),H=kt(e,X+16),j=kt(e,X+20),ee=kt(e,X+24),le=kt(e,X+28);V.push({imageId:kt(e,X)|0,duration:kt(e,X+4),x:q,y:oe,width:Math.hypot(H,j)||F,height:Math.hypot(ee,le)||D,uDir:[H,j],vDir:[ee,le],rotated:Math.abs(j)>.5||Math.abs(ee)>.5})}V.length===L&&V.every(Z=>{if(!(Z.width>0&&Z.height>0))return!1;const X=[Z.x,Z.x+Z.uDir[0],Z.x+Z.vDir[0],Z.x+Z.uDir[0]+Z.vDir[0]],q=[Z.y,Z.y+Z.uDir[1],Z.y+Z.vDir[1],Z.y+Z.uDir[1]+Z.vDir[1]];return Math.min(...X)>=-1&&Math.max(...X)<=b+1&&Math.min(...q)>=-1&&Math.max(...q)<=p+1})&&(v={magic:_,frameWidth:F,frameHeight:D,atlasWidth:b,atlasHeight:p,list:V})}}}return{format:r,formatName:Er[r]||String(r),flags:i,textureWidth:s,textureHeight:c,width:a,height:f,freeImageFormat:h,containerMagic:l,containerVersion:m,isVideo:M,images:g,frames:v}}function Yn(e,n,t){let o="";for(let r=n;r<n+t;r++)o+=String.fromCharCode(e[r]);return o}const _s=Object.freeze(Object.defineProperty({__proto__:null,FIF:Nt,TEXTURE_FORMATS:Er,decodeMip0:ls,decodeMips:us,decodePixels:Pr,lz4Decompress:yo,parseTex:As},Symbol.toStringTag,{value:"Module"}));function xo(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Rr(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function Ts(e,n){return qn(e)&&qn(n)?Number(e)===Number(n):String(e)===String(n)}function Lr(e){if(typeof e=="boolean")return"bool";if(typeof e=="number")return Number.isFinite(e)?"num":"other";if(typeof e=="string"){const n=e.trim().split(/\s+/);return n.length>0&&n[0]!==""&&n.every(t=>Number.isFinite(Number(t)))?"num":"text"}return"other"}function Ss(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Lr(e.value)}}function wo(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const o=xo(n,e.user.name);if(!o||o.value===void 0||o.value===null)return e.value;const r=o.type==="combo"?Fr(o.value,o.options):o.value;return Ts(r,e.user.condition)}if(typeof e.user!="string")return e;const t=xo(n,e.user);if(!t||t.value===void 0||t.value===null)return e.value;if(t.userOverridden)return t.value;if(e.value!==null&&typeof e.value=="object")return e.value;if(e.value===void 0)return t.value;if(Lr(e.value)==="bool"&&t.type==="slider"){const o=Number(t.value);return Number.isFinite(o)?o!==0:e.value}return Lr(e.value)===Ss(t)?t.value:e.value}function tn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let o=0;o<e.length;o++)e[o]=tn(e[o],n,t+1);return e}if(Rr(e.user)){let o=wo(e,n);for(let r=0;r<8&&o!==null&&typeof o=="object"&&Rr(o.user);r++)o=wo(o,n);return e.value=tn(o,n,t+1),e}for(const o of Object.keys(e))e[o]=tn(e[o],n,t+1);return e}function Es(e){return e?Array.isArray(e)?e.map(n=>n&&typeof n=="object"&&"value"in n?n.value:n):typeof e=="object"?Object.values(e):[]:[]}function qn(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Fr(e,n){const t=Es(n);return!(t.length>0?t.every(qn):qn(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function Ps(e){const n={};if(!e||typeof e!="object")return n;for(const[t,o]of Object.entries(e))!o||typeof o!="object"||!("value"in o)||(n[t]=o.type==="combo"?Fr(o.value,o.options):o.value);return n}function gt(e){return e&&typeof e=="object"?Rr(e.user):null}function Cs(e,n,t){const o={};if(!t||typeof t!="object")return o;const r=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,c]of Object.entries(t)){const a=c&&typeof c=="object"&&"value"in c?c.value:c,f=r[s];if(f&&typeof f=="object"){f.value=a,f.userOverridden=!0;const l=f.type==="combo"?Fr(f.value,f.options):f.value;i[s]=l,o[s]=l}else i[s]=a,o[s]=a}return o}function nn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0,n[0]||0]:[n[0]||0,n[1]||0,n[2]||0]}function yn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0]:[n[0]||0,n[1]||0]}function Zn(e){return e==null?[1,1,1]:typeof e=="string"?nn(e):typeof e=="object"&&e!==null?nn(e.value):[1,1,1]}function Ke(e,n=!1){if(e==null)return n;if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="object"&&e!==null){const t=e.value;return typeof t=="number"?t!==0:!!t}return n}function ot(e,n){if(typeof e=="number")return e;if(e!==null&&typeof e=="object"){const t=Number(e.value);return Number.isFinite(t)?t:n}return n}function Rs(e,n){const t=n&&n.general&&n.general.properties||{},o=e.objects||[];tn(o,t,0),tn(e.general||{},t,0);const r=new Map;for(const g of o)g.id!==void 0&&r.set(g.id,g);const i=o.map(g=>({id:g.id,parent:g.parent,origin:nn(g.origin||"0 0 0"),scale:nn(g.scale||"1 1 1"),angles:nn(g.angles||"0 0 0")}));for(let g=0;g<8;g++){let y=!1;for(const b of i){if(b.parent===void 0||b.parent===null||!r.get(b.parent))continue;const v=i.findIndex(q=>q.id===b.parent);if(v<0)continue;const _=i[v];if(_.parent!==void 0&&_.parent!==null)continue;const w=o[v],L=w.scale,F=L!==null&&typeof L=="object"&&(typeof L.script=="string"||L.user!==void 0),D=!w.image&&!w.model&&!w.particle&&w.text==null&&!w.size,B=F&&D?[1,1,1]:_.scale,z=_.angles[2]*Math.PI/180,V=Math.cos(z),Y=Math.sin(z),Z=b.origin[0]*B[0],X=b.origin[1]*B[1];b.origin[0]=_.origin[0]+Z*V-X*Y,b.origin[1]=_.origin[1]+Z*Y+X*V,b.origin[2]=_.origin[2]+b.origin[2],b.angles[2]=_.angles[2]+b.angles[2],b.scale[0]=B[0]*b.scale[0],b.scale[1]=B[1]*b.scale[1],b.scale[2]=B[2]*b.scale[2],b.parent=null,y=!0}if(!y)break}const s=o.map(g=>Ke(g.visible,!0)),c=new Map;o.forEach((g,y)=>{g.id!==void 0&&c.set(g.id,y)});const a=new Map,f=new Map;for(const g of o)if(g.parent!==void 0&&g.parent!==null){a.set(g.parent,(a.get(g.parent)||0)+1);const y=g.id!==void 0?g.id:null;if(y!==null){const b=f.get(g.parent);b?b.push(y):f.set(g.parent,[y])}}const l=o.map(()=>!0);for(let g=0;g<o.length;g++){let y=s[g],b=o[g].parent;for(let p=0;y&&b!==void 0&&b!==null&&p<64;p++){const v=c.get(b);if(v===void 0)break;s[v]||(y=!1),b=o[v].parent}l[g]=y}const d=o.map((g,y)=>{const b=i[y],p=typeof g.image=="string"&&(g.image.indexOf("models/util/projectlayer")===0||g.image.indexOf("models/util/fullscreenlayer")===0);let v=yn(g.size||"0 0"),_=b.origin;if(p){const w=(e.general||{}).orthogonalprojection,L=w&&Number(w.width),F=w&&Number(w.height);L>0&&F>0&&(v=[L,F],_=[L/2,F/2,b.origin[2]||0])}return{id:g.id!==void 0?g.id:y,name:g.name||"",visible:l[y],visibleSelf:s[y],srcObject:g,image:typeof g.image=="string"?g.image:null,model:typeof g.model=="string"?g.model:null,isSkybox:typeof g.name=="string"&&g.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof g.particle=="string"?g.particle:null,instanceoverride:g.instanceoverride||null,sound:Array.isArray(g.sound)?g.sound.filter(w=>typeof w=="string"):[],soundprops:{volume:ot(g.volume,1),playbackmode:g.playbackmode||"single",startsilent:Ke(g.startsilent,!1),maxtime:ot(g.maxtime,0),mintime:ot(g.mintime,0),spatialization:Ke(g.spatialization,!1),muteineditor:Ke(g.muteineditor,!1)},text:typeof g.text=="string"?g.text:g.text&&typeof g.text=="object"?g.text.value:null,textScript:g.text&&typeof g.text=="object"&&g.text.script||null,textScriptProps:g.text&&typeof g.text=="object"&&g.text.scriptproperties||null,component:typeof g.component=="string"?g.component:null,isText:g.text!==void 0&&g.text!==null,textFont:typeof g.font=="string"?g.font:null,textPointsize:ot(g.pointsize,24)||24,textColor:Zn(g.color),textAnchor:typeof g.anchor=="string"&&g.anchor!=="none"?g.anchor:"center",textMaxwidth:ot(g.maxwidth,0),textMaxrows:ot(g.maxrows,0),textLimitwidth:Ke(g.limitwidth,!1),textLimitrows:Ke(g.limitrows,!1),textLimituseellipsis:Ke(g.limituseellipsis,!1),textHAlign:g.horizontalalign||"center",textVAlign:g.verticalalign||"center",textSpacing:g.spacing?yn(g.spacing):[0,0],textPadding:(()=>{const w=g.padding;if(typeof w=="number")return w;const L=String(w??"").trim().split(/\s+/).map(Number).filter(F=>Number.isFinite(F));return L.length?L.reduce((F,D)=>F+D,0)/L.length:0})(),textOpaquebackground:Ke(g.opaquebackground,!1),textBackgroundcolor:Zn(g.backgroundcolor),textBackgroundbrightness:ot(g.backgroundbrightness,1),textCastshadow:Ke(g.castshadow,!1),isSound:!!(g.sound&&g.sound.length),isComponent:!!g.component,objectScripts:(()=>{const w={};for(const L of["scale","origin","color","alpha","brightness","angles","visible"]){const F=g[L];F&&typeof F=="object"&&typeof F.script=="string"&&F.script&&(w[L]={script:F.script,scriptproperties:F.scriptproperties||null,value:F.value})}return Object.keys(w).length?w:null})(),objectAnimations:(()=>{const w={};for(const L of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const F=g[L];F&&typeof F=="object"&&F.animation&&typeof F.animation=="object"&&F.animation.options&&(w[L]={animation:F.animation,value:F.value})}return Object.keys(w).length?w:null})(),animationLayers:(g.animationlayers||[]).filter(w=>w&&typeof w.animation=="number").map(w=>({animation:w.animation,visible:Ke(w.visible,!0),additive:Ke(w.additive,!1),blend:ot(w.blend,1),rate:ot(w.rate,1)})),solid:(()=>{if(typeof g.particle=="string")return!1;const w=typeof g.image=="string"?g.image:"";return w.indexOf("models/util/composelayer")===0?!1:w.indexOf("models/util/solidlayer")===0?!0:g.solid?!w||w.indexOf("models/util/")===0:!1})(),isContainer:typeof g.image=="string"&&g.image.indexOf("models/util/composelayer")===0,hasChildren:(a.get(g.id!==void 0?g.id:y)||0)>0,childIds:f.get(g.id!==void 0?g.id:y)||null,parentId:g.parent!==void 0&&g.parent!==null?g.parent:null,attachment:typeof g.attachment=="string"&&g.attachment!==""?g.attachment:null,passthrough:!!(g.config&&g.config.passthrough===!0),isPostProcess:p,origin:_,scale:b.scale,angles:b.angles,size:v,alignment:g.alignment||"center",color:Zn(g.color),alpha:ot(g.alpha,1),brightness:ot(g.brightness,1),copybackground:!!g.copybackground,colorBlendMode:g.colorBlendMode||0,parallaxDepth:g.parallaxDepth!==void 0?yn(g.parallaxDepth):null,effects:(g.effects||[]).map(w=>({file:w.file||"",name:typeof w.name=="string"?w.name:"",visible:Ke(w.visible,!0),visibleScript:w.visible&&typeof w.visible=="object"&&typeof w.visible.script=="string"&&w.visible.script?{script:w.visible.script,scriptproperties:w.visible.scriptproperties||null,value:!!w.visible.value}:null,passes:(w.passes||[]).map(L=>({combos:L.combos||{},constantshadervalues:L.constantshadervalues||{},textures:L.textures||[]}))}))}}),h=e.general||{},m=(()=>{const g={};for(const[y,b]of Object.entries(h))b&&typeof b=="object"&&typeof b.script=="string"&&b.script&&(g[y]={script:b.script,scriptproperties:b.scriptproperties||null,value:b.value});return Object.keys(g).length?g:null})(),M=(()=>{const g={};for(const[y,b]of Object.entries(h))b&&typeof b=="object"&&b.animation&&typeof b.animation=="object"&&b.animation.options&&(g[y]={animation:b.animation,value:b.value});return Object.keys(g).length?g:null})();{const g=new Map;for(const y of d)y.id!==void 0&&g.set(y.id,y);for(let y=0;y<8;y++){let b=!1;for(const p of d){if(p.parallaxDepth||p.parentId==null)continue;const v=g.get(p.parentId);!v||!v.parallaxDepth||v.image||v.particle||v.model||(p.parallaxDepth=v.parallaxDepth.slice(),b=!0)}if(!b)break}}return{camera:e.camera||null,general:h,generalScripts:m,generalAnimations:M,layers:d,properties:t}}function Ls(e){if(!Array.isArray(e))return;const n=new Map;for(const t of e)t&&t.id!==void 0&&t.id!==null&&n.set(t.id,t);for(const t of e){if(!t)continue;if(t.destroyed){t.visible=!1;continue}let o=t.visibleSelf!==!1,r=t.parentId;for(let i=0;o&&r!=null&&i<64;i++){const s=n.get(r);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(o=!1),r=s.parentId}t.visible=o}}function Fs(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function Ns(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?yn(e.cropoffset):null}}const ks=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:Fs,parseBool:Ke,parseColor:Zn,parseNum:ot,parseScene:Rs,parseVec2:yn,parseVec3:nn,recomputeLayerVisibility:Ls,resolveMaterial:Ns},Symbol.toStringTag,{value:"Module"}));function Us(e,n,t){const o=Sr(e,n.file);if(o===null)return;let r;try{r=JSON.parse(t(o))}catch{return}n.fbos=r.fbos||[],n.materialPasses=(r.passes||[]).map(i=>{if(!i.material)return{shader:null,copyCommand:!0,target:i.target||null,source:i.source||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const s=Sr(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const c=JSON.parse(t(s)),a=c.passes&&c.passes[0]||{};return{shader:a.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:a.blending||"normal",textures:a.textures||[],combos:a.combos||{},constants:a.constantshadervalues||{}}})}const Is={"models/util/solidlayer.json":{material:"materials/util/solidlayer.json"},"models/util/composelayer.json":{material:"materials/util/solidlayer.json"},"models/util/fullscreenlayer.json":{material:"materials/util/solidlayer.json"},"models/util/projectlayer.json":{material:"materials/util/solidlayer.json"}};function Mo(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function Bs(e,n){return!e||!n||!n.shader||Mo(n.shader)||(e.effects=e.effects||[],e.effects.some(t=>t.layerMaterial))?!1:(e.effects.unshift({file:"",name:"_layerMaterial",visible:!0,layerMaterial:!0,passes:[{combos:n.combos||{},constantshadervalues:n.constantshadervalues||{},textures:n.textures||[]}],materialPasses:[{shader:n.shader,copyCommand:!1,target:null,binds:[],blending:n.blending||"normal",textures:n.textures||[],combos:n.combos||{},constants:n.constantshadervalues||{}}],fbos:[]}),!0)}const Os=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:{"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},BUILTIN_MODELS:Is,attachLayerMaterialEffect:Bs,isBuiltinAlbedoShader:Mo,resolveEffectChain:Us},Symbol.toStringTag,{value:"Module"}));function rn(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function bt(e,n){const t=new Float32Array(16);for(let o=0;o<4;o++)for(let r=0;r<4;r++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+r]*n[o*4+s];t[o*4+r]=i}return t}function vn(e,n,t,o,r,i){const s=rn();return s[0]=2/(n-e),s[5]=2/(o-t),s[10]=-2/(i-r),s[12]=-(n+e)/(n-e),s[13]=-(o+t)/(o-t),s[14]=-0/(i-r),s}function on(e,n,t,o){return bt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,o,1]))}function Ds(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let o=0;o<4;o++)n[o*4+t]=e[t*4+o];return n}function xn(e,n,t,o){return bt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,o,0,0,0,0,1]))}function Ao(e,n){const t=Math.cos(n),o=Math.sin(n);return bt(e,new Float32Array([t,o,0,0,-o,t,0,0,0,0,1,0,0,0,0,1]))}function $s(e,n){const t=Math.cos(n),o=Math.sin(n);return bt(e,new Float32Array([1,0,0,0,0,t,o,0,0,-o,t,0,0,0,0,1]))}function zs(e,n){const t=Math.cos(n),o=Math.sin(n);return bt(e,new Float32Array([t,0,-o,0,0,1,0,0,o,0,t,0,0,0,0,1]))}function js(e,n,t,o){const r=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=r/(n||1),i[5]=r,i[10]=(o+t)/(t-o),i[11]=-1,i[14]=2*o*t/(t-o),i}function Kn(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function Vs(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:Kn(n.fov,0)>0}function Ws(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function Hs(e,n,t){const o=To([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),r=To(So(t,o)),i=So(o,r),s=new Float32Array([r[0],i[0],o[0],0,r[1],i[1],o[1],0,r[2],i[2],o[2],0,0,0,0,1]);return s[12]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s}function Xs(e,n,t,o){const r=e[3]*n+e[7]*t+e[11]*o+e[15];return[(e[0]*n+e[4]*t+e[8]*o+e[12])/r,(e[1]*n+e[5]*t+e[9]*o+e[13])/r,(e[2]*n+e[6]*t+e[10]*o+e[14])/r]}const Gs=[[16,9],[16,10],[21,9],[32,9]];function Ys(e,n,t,o,r){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(o>0))return null;const s=.02,c=t/o;if(Math.abs(i-c)<=s*c)return{viewW:t,viewH:o};for(const[a,f]of Gs){const l=a/f;if(Math.abs(i-l)>s*l)continue;const d=o,h=o*l;return h>t+1e-6?{viewW:t,viewH:t/l}:{viewW:h,viewH:d}}return null}function Nr(e,n,t,o,r,i,s){const c=_o(i),a=_o(s);if(e==="cover"){const f=Ys(o,r,n,t);if(f)return{offX:(n-f.viewW)*c,offY:(t-f.viewH)*a,viewW:f.viewW,viewH:f.viewH};const l=Math.max(o/n,r/t),d=o/l,h=r/l;return{offX:(n-d)*c,offY:(t-h)*a,viewW:d,viewH:h}}if(e==="contain"){const f=o/r;if(n/t>f){const m=n,M=n/f;return{offX:0,offY:(t-M)/2,viewW:m,viewH:M}}const d=t,h=t*f;return{offY:0,offX:(n-h)/2,viewW:h,viewH:d}}return{offX:0,offY:0,viewW:n,viewH:t}}function qs(e,n,t,o,r,i){const s=e.general,c=e.camera,a=c&&c.eye?kr(c.eye):[0,0,0],f=c&&c.center?kr(c.center):[0,0,-1],l=c&&c.up?kr(c.up):[0,1,0];if(Vs(e)){const v=t>0?n/t:1.7777777777777777,_=Kn(s.fov,50),w=Math.max(Kn(s.nearz,.01),1e-4),L=Math.max(Kn(s.farz,1e4),w+1),F=Hs(a,f,l),D=js(_,v,w,L);return{view:F,projection:D,eye:a,center:f,projW:v,projH:1,offX:0,offY:0,viewW:v,viewH:1,perspective:!0}}const d=rn(),h=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,m=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,M=Nr(o,h,m,n,t,r,i),g=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,y=g&&typeof g=="object"?g.value:g,b=Number(y);if(Number.isFinite(b)&&b>0&&Math.abs(b-1)>1e-6){const v=M.offX+M.viewW/2,_=M.offY+M.viewH/2,w=M.viewW/b,L=M.viewH/b;M.offX=v-w/2,M.offY=_-L/2,M.viewW=w,M.viewH=L}const p=vn(M.offX,M.offX+M.viewW,M.offY+M.viewH,M.offY,-1e4,1e4);return{view:d,projection:p,eye:a,projW:h,projH:m,offX:M.offX,offY:M.offY,viewW:M.viewW,viewH:M.viewH,perspective:!1}}function _o(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function kr(e){return String(e).trim().split(/\s+/).map(Number)}function To(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function So(e,n){return[e[1]*n[2]-e[2]*n[1],e[2]*n[0]-e[0]*n[2],e[0]*n[1]-e[1]*n[0]]}function sn(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function Zs(e){const n=new Map,t=new Map,o=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let r;for(;(r=o.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();r[2]!==void 0?t.set(r[1],{args:r[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(r[3])}):n.set(r[1],i(r[3]))}return{defs:n,fns:t}}function Ks(e,n,t,o){const r=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){r.push(e.slice(i));break}r.push(e.slice(i,s));let a=s+n.length;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]!=="("){r.push(e.slice(s,a)),i=a;continue}let f=0,l=a;for(;l<e.length;l++)if(e[l]==="(")f++;else if(e[l]===")"&&(f--,f===0))break;if(l>=e.length){r.push(e.slice(s));break}const d=e.slice(a+1,l),h=St(d);let m=t.body;t.args.forEach((M,g)=>{const y=h[g]!==void 0?h[g].trim():"";m=wn(m,M,y)}),o>0&&(m=Eo(m,o-1)),r.push("("+m+")"),i=l+1}return r.join("")}function wn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function St(e){const n=[];let t=0,o="";for(let r=0;r<e.length;r++){const i=e[r];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(o),o=""):o+=i}return o.trim()!==""&&n.push(o),n}function Eo(e,n){for(let t=0;t<12;t++){const{defs:o,fns:r}=Zs(e);if(o.size===0&&r.size===0)break;const i=e.split(`
2
+ `);let s=!1;for(let c=0;c<i.length;c++){const a=i[c];if(/^[ \t]*#/.test(a))continue;let f=a;for(const[l,d]of o)new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(f)&&(f=wn(f,l,d),s=!0);for(const[l,d]of r)f.includes(l)&&(f=Ks(f,l,d,n),s=!0);i[c]=f}if(e=i.join(`
3
+ `),!s)break}return e}function Po(e,n,t){const o=m=>n[m]!==void 0?String(n[m]):t.has(m)?"("+t.get(m)+")":"0";let r=e.replace(/\b[A-Za-z_][A-Za-z0-9_]*\b/g,m=>o(m)),i=0;function s(){for(;i<r.length&&/\s/.test(r[i]);)i++}function c(){let m=a();for(s();r.startsWith("||",i);){i+=2;const M=a();m=m||M,s()}return m}function a(){let m=f();for(s();r.startsWith("&&",i);){i+=2;const M=f();m=m&&M,s()}return m}function f(){let m=l();for(s();r.startsWith("==",i)||r.startsWith("!=",i);){const M=r[i]==="="?"==":"!=";i+=2;const g=l();m=M==="=="?m===g:m!==g,s()}return m}function l(){let m=d();for(s();/^[<>]/.test(r[i]||"");){let M=r[i];r[i+1]==="="&&(M+="=",i++),i++;const g=d();M==="<"?m=m<g:M===">"?m=m>g:M==="<="?m=m<=g:m=m>=g,s()}return m}function d(){return s(),r[i]==="!"?(i++,!d()):h()}function h(){if(s(),r[i]==="("){i++;const M=c();return s(),i++,M}const m=/^-?\d+(\.\d+)?/.exec(r.slice(i));return m?(i+=m[0].length,Number(m[0])):!1}return c()}function Co(e){let n="",t=0;const o=e.length;for(;t<o;){const r=e[t],i=e[t+1];if(r==="/"&&i==="*"){for(t+=2;t<o&&!(e[t]==="*"&&e[t+1]==="/");)e[t]===`
4
4
  `&&(n+=`
5
- `),t++;t+=2;continue}if(o==="/"&&i==="/"){for(;t<r&&e[t]!==`
6
- `;)t++;continue}n+=o,t++}return n}function Ao(e,n,t,r){const o=e.split(`
7
- `),i=[],s=[],c=new Map;for(let a=0;a<o.length;a++){const u=o[a],l=u.trim();if(l.startsWith("#include")){if(Mn(s)){const d=/^#include[ \t]+"([^"]+)"|^#include[ \t]+<([^>]+)>/.exec(l),h=d&&(d[1]||d[2]),p=h&&t?t(h):null;p!=null?i.push(Ao(_o(p),n,t)):i.push("// [include \u7F3A\u5931: "+h+"]")}continue}if(l.startsWith("#define")){if(Mn(s)){i.push(u);const d=/^#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\([^)]*\))?[ \t]*(.*)$/.exec(l);d&&c.set(d[1],d[2].trim())}continue}if(l.startsWith("#undef")){Mn(s)&&i.push(u);continue}if(l.startsWith("#ifdef")||l.startsWith("#ifndef")||l.startsWith("#if")){const d=Mn(s);let h=!1;if(l.startsWith("#ifdef")){const p=l.slice(6).trim().split(/\s+/)[0];h=n[p]!==void 0||c.has(p)}else if(l.startsWith("#ifndef")){const p=l.slice(7).trim().split(/\s+/)[0];h=!(n[p]!==void 0||c.has(p))}else try{h=!!Mo(l.slice(3).trim(),n,c)}catch{h=!1}s.push({parent:d,hit:h,done:h});continue}if(l.startsWith("#else")){if(s.length>0){const d=s[s.length-1];d.hit=!d.done,d.done=!0}continue}if(l.startsWith("#elif")){if(s.length>0){const d=s[s.length-1];if(d.done)d.hit=!1;else{let h=!1;try{h=!!Mo(l.slice(5).trim(),n,c)}catch{h=!1}d.hit=h,d.done=h}}continue}if(l.startsWith("#endif")){s.length>0&&s.pop();continue}l.startsWith("#")||Mn(s)&&i.push(u)}return i.join(`
8
- `)}function Mn(e){return e.every(n=>n.parent&&n.hit)}function Qn(e,n,t,r){let o=0;for(let i=n;i<e.length;i++)if(e[i]===t)o++;else if(e[i]===r&&(o--,o===0))return i;return-1}function To(e,n){return Qn(e,n,"(",")")}const js=new Set(["void","bool","int","uint","float","double","vec2","vec3","vec4","bvec2","bvec3","bvec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"]);function Ws(e,n){let t=n-1;for(;t>=0&&/[ \t]/.test(e[t]);)t--;if(t<0||t===n-1)return!1;let r=t+1;for(;t>=0&&/[A-Za-z0-9_]/.test(e[t]);)t--;const o=e.slice(t+1,r);return js.has(o)}function Be(e,n,t){let r="",o=0;for(;o<e.length;){const i=e.indexOf(n,o);if(i===-1){r+=e.slice(o);break}if(i>0&&/[A-Za-z0-9_]/.test(e[i-1])){r+=e.slice(o,i+1),o=i+1;continue}const s=i+n.length;if(s<e.length&&/[A-Za-z0-9_]/.test(e[s])){r+=e.slice(o,s),o=s;continue}if(Ws(e,i)){r+=e.slice(o,s),o=s;continue}r+=e.slice(o,i);let c=i+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){r+=e.slice(i,c),o=c;continue}const a=To(e,c);if(a===-1){r+=e.slice(i);break}const u=e.slice(c+1,a);r+=t(u,i),o=a+1}return r}function So(e,n,t,r,o){const i=e;e=_o(e);const s={},c=/\[COMBO\][^\n]*?"combo"\s*:\s*"([^"]+)"[^\n]*?"default"\s*:\s*(-?\d+)/g;let a;if(typeof o=="string"&&o){const g=new RegExp(c.source,"g");let v;for(;(v=g.exec(o))!==null;)s[v[1]]=Number(v[2])}for(;(a=c.exec(i))!==null;)s[a[1]]=Number(a[2]);const u={GLSL:1,...s,...t||{}};let l=Ao(e,u,r);l=wo(l,20),l=l.replace(/^[ \t]*#define[^\n]*\n?/gm,"");{const g=new Set,v=/\[COMBO\][^\n]*"combo"\s*:\s*"([^"]+)"/g;let b;for(;(b=v.exec(i))!==null;)g.add(b[1]);for(const y of Object.keys(u))g.add(y);g.delete("GLSL");for(const y of g){const S=u[y]!==void 0?u[y]:0;l=wn(l,y,String(S))}}l=wn(l,"sample","smp"),l=l.replace(/(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[fh]\b/g,"$1"),l=l.replace(/\bfloat4x4\b/g,"mat4").replace(/\bfloat3x3\b/g,"mat3").replace(/\bfloat2x2\b/g,"mat2").replace(/\bfloat4\b/g,"vec4").replace(/\bfloat3\b/g,"vec3").replace(/\bfloat2\b/g,"vec2").replace(/\bhalf4\b/g,"vec4").replace(/\bhalf3\b/g,"vec3").replace(/\bhalf2\b/g,"vec2").replace(/\bhalf\b/g,"float"),l=l.replace(/\btexSample2DLod\b/g,"textureLod").replace(/\btexSample2D\b/g,"texture"),l=Be(l,"saturate",g=>"clamp("+g+", 0.0, 1.0)"),l=Be(l,"CAST4",g=>"vec4("+g+")"),l=Be(l,"CAST3",g=>"vec3("+g+")"),l=Be(l,"CAST2",g=>"vec2("+g+")"),l=l.replace(/\b(max|min)\(\s*(-?\d+(?:\.\d+)?)\s*,\s*([A-Za-z_]\w*\.(rgb|xyz|rg|xy|r|x))\s*\)/g,(g,v,b,y,S)=>{const _=S.length;return v+"(vec"+_+"("+b+"), "+y+")"}),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*([A-Za-z_][A-Za-z0-9_]*)/g,"$1$2.0 $3 $4"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(\d+\.\d+)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))/g,"$1$2.0 $3 $4");{const g=new Set,v=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=Array.from(g).sort((S,_)=>_.length-S.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+y+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4")}}{const g=["smoothstep","step","mix","clamp","max","min","pow","mod","atan","sqrt","inversesqrt","exp","log","exp2","log2","abs","sign","floor","ceil","fract","length","distance","dot","reflect","refract","faceforward","normalize","cross"],v=/\b(ApplyBlending|ApplyComposite|BlendTransparency)\s*\(/;for(const b of g)l=Be(l,b,y=>{const _=kt(y).map(C=>{if(v.test(C))return C;const N=[];let D=C.replace(/\[[^\]]*\]/g,k=>(N.push(k),"\0"+(N.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,k=>(N.push(k),"\0"+(N.length-1)+"\0"));return D=D.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),D.replace(/\u0000(\d+)\u0000/g,(k,O)=>N[Number(O)])});return b+"("+_.join(",")+")"});l=Be(l,"pow",b=>{const y=kt(b);if(y.length!==2)return"pow("+b+")";const S=y[0].trim(),_=y[1].trim(),C=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(S),D=C?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[C[1]]:0,k=/\bvec[234]\s*\(/.test(_)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(_);return D>=2&&!k?"pow("+S+", vec"+D+"("+_+"))":"pow("+S+", "+_+")"})}l=l.replace(/([)\]])\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/\)\s*([+-])\s*(\d+)(?![\d.])/g,") $1 $2.0"),l=l.replace(/(^|[^\w.])(\d+)(?![.\d])\s*([+-])\s*((?:step|smoothstep|mix|mod|fract|abs|sin|cos|tan|atan|sqrt|pow|inversesqrt|floor|ceil|sign|length|normalize|distance|dot|cross|exp|log|exp2|log2|clamp|min|max)\s*\()/g,"$1$2.0 $3 $4");{const g=new Set,v=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=Array.from(g).sort((S,_)=>_.length-S.length).join("|");l=l.replace(new RegExp("\\b("+y+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const g=new Set,v=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(y,S,_)=>g.has(S)?y:"mod("+S+", "+_+".0)"),l=l.replace(/\bint\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*mod\(([^;]*)\);/g,"int $1 = int(mod($2));")}l=l.replace(/\b(vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;()\n,]+);/g,(g,v,b,y)=>{const S=y.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(S)?g:v+" "+b+" = "+v+"("+S+");"});for(const g of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=Be(l,g,v=>g+"("+v.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=Be(l,"clamp",g=>{const v=kt(g);if(v.length!==3)return"clamp("+g+")";const b=v[0].trim(),y=v[1].trim(),S=_=>/^-?\d+\.?\d*$/.test(_);return S(b)&&S(y)&&Number(b)===0&&Number(y)===1?"clamp("+v[2].trim()+", "+b+", "+y+")":"clamp("+g+")"}),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([)\]])\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=Be(l,"smoothstep",g=>{const v=kt(g);return v.length===3&&v[1].trim()==="0.0"&&v[0].trim()!=="0.0"?"(1.0 - smoothstep(0.0, "+v[0].trim()+", "+v[2].trim()+"))":"smoothstep("+g+")"});{const g=new Map,v=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let b;for(;(b=v.exec(l))!==null;)g.set(b[3],Number(b[2]));if(g.size>0){const y={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(S,_,C,N)=>{const D=g.get(C),k=g.get(N);return!D||!k||D>=k?S:_+C+" = "+N+"."+y[D]+";"})}if(g.size>0){const y=new Set,S=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let _;for(;(_=S.exec(l))!==null;)y.add(_[1]);const C="pow|saturate|clamp|smoothstep|step|abs|floor|ceil|fract|frac|sin|cos|tan|asin|acos|atan|sqrt|length|distance|dot|exp|log|sign|fmod|mod|min|max|mix|lerp",N=/^(?:length|distance|dot)$/,D=O=>{const j=O.match(new RegExp("^(?:"+C+")\\s*\\("));if(!j)return!1;let W=0;const K=j[0].length-1;let V=-1;for(let q=K;q<O.length;q++)if(O[q]==="(")W++;else if(O[q]===")"&&(W--,W===0)){V=q;break}if(V!==O.length-1)return!1;const G=j[0].replace(/\s*\($/,"");if(N.test(G))return!0;const Q=O.slice(K+1,V);if(/\bvec[234]\s*\(/.test(Q)||/\.[xyzwrgba]{2,4}\b/.test(Q))return!1;for(const q of g.keys()){const te=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+te+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(Q))return!1}return!0},k=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(O,j,W,K)=>{const V=g.get(W);if(!V)return O;const G=K.trim();if(new RegExp("^vec"+V+"\\s*\\(").test(G)||g.has(G))return O;const Q=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(G),q=y.has(G);return!Q&&!q&&!D(G)?O:(k.add(W),j+W+" = vec"+V+"("+G+");")}),k.size>0){const O=[...k].sort((j,W)=>W.length-j.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${O})\\b`,"g"),(j,W,K,V)=>g.has(W)?j:`${W} ${K} ${V}.x`),l=l.replace(new RegExp(`\\b(${O})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(j,W,K,V)=>g.has(V)?j:`${W}.x ${K} ${V}`)}}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*=\s*)(-?\d+)\s*;/g,"$1$2.0;"),l=l.replace(/\b(float|vec2|vec3|vec4)\s+([A-Za-z_]\w*)\s*=\s*(-?\d+)\s*;/g,(g,v,b,y)=>v==="float"?`${v} ${b} = ${y}.0;`:`${v} ${b} = ${v}(${y}.0);`);{const g=new Set,v=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=[...g].sort((S,_)=>_.length-S.length).join("|");l=l.replace(new RegExp(`\\b(${y})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${y})\\s*([-+*/]=)\\s*(-?\\d+)\\s*;`,"g"),"$1 $2 $3.0;")}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*[-+*/]=\s*)(-?\d+)\s*;/g,"$1$2.0;");const d="step|smoothstep|saturate|clamp|mix|lerp|frac|fract|abs|floor|ceil|min|max|pow|sqrt|length|dot|distance";l=l.replace(new RegExp(`\\bint\\s+([A-Za-z_]\\w*)\\s*=\\s*((?:${d})\\s*\\()`,"g"),"float $1 = $2");{const g=new Set,v=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=[...g].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${y})\\b`,"g"),(S,_,C)=>`${_}float(${C})`)}}{const g=new Set;for(const v of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))g.add(v[1]);if(g.size){const v=[...g].sort((C,N)=>N.length-C.length).join("|"),b=new RegExp("\\b("+v+")\\s*\\[","g");let y="",S=0,_;for(;_=b.exec(l);){const C=_.index+_[0].length-1,N=Qn(l,C,"[","]");if(N<0)break;let D=N+1;for(;D<l.length&&/[ \t]/.test(l[D]);)D++;if(l[D]!=="["){b.lastIndex=N+1;continue}const k=Qn(l,D,"[","]");if(k<0)break;const O=l.slice(C+1,N),j=l.slice(D+1,k);y+=l.slice(S,_.index),y+=_[1]+"[int(("+O+")) * 4 + int(("+j+"))]",S=k+1,b.lastIndex=S}l=y+l.slice(S)}}l=Be(l,"mix",(g,v)=>{const b=kt(g);if(b.length!==3)return"mix("+g+")";const y=D=>{const k=D.trim(),O=/\.([xyzwrgba]{1,4})\s*$/.exec(k);if(O)return O[1].length;const j=/^vec([234])\s*\(/.exec(k);if(j)return Number(j[1]);if(!/^[A-Za-z_]\w*$/.test(k))return 0;const W=new RegExp("\\b(vec([234])|float)\\s+"+k+"\\b","g");let K=0,V;for(;(V=W.exec(l))!==null&&V.index<v;)K=V[1].startsWith("vec")?Number(V[2]):1;return K},S=b[0].trim(),_=b[1].trim(),C=y(S),N=y(_);if(C>=2&&N>=2&&C!==N){const D=Math.min(C,N),k=D===2?".xy":D===3?".xyz":"";return k?"mix("+(C>D?S+k:S)+", "+(N>D?_+k:_)+", "+b[2].trim()+")":"mix("+g+")"}return"mix("+g+")"});{const g=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let v="",b=0,y;for(;y=g.exec(l);){const S=To(l,y.index+y[0].length-1);if(S<0)break;let _=S+1;for(;_<l.length&&/\s/.test(l[_]);)_++;if(l[_]!=="{")continue;const C=Qn(l,_,"{","}");if(C<0)break;const N=Number(y[2]);if(N>=4){g.lastIndex=C;continue}let D=l.slice(_+1,C);const k=new Map;for(const j of l.slice(0,y.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))k.set(j[3],Number(j[2]));for(const j of D.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))k.set(j[3],Number(j[2]));const O=N===2?"xy":"xyz";D=D.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(j,W)=>{const K=k.get(W);return K&&K>N?"return "+W+"."+O+";":j}),v+=l.slice(b,_+1)+D,b=C,g.lastIndex=C}l=v+l.slice(b)}const h=new Set,p=/\b(?:uniform\s+)?(?:mat4|mat3|mat2|float4x4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let w;for(;(w=p.exec(l))!==null;)h.add(w[1]);if(l=Be(l,"mul",g=>{const v=kt(g);if(v.length!==2)return"mul("+g+")";const b=v[0].trim(),y=v[1].trim(),S=_=>h.has(_.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(_);return S(b)&&S(y)?"(transpose("+y+") * transpose("+b+"))":S(y)?"(transpose("+y+") * "+b+")":"("+b+" * "+y+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=Be(l,"atan2",g=>"atan("+g+")"),l=Be(l,"fmod",g=>{const v=kt(g);if(v.length!==2)return"mod("+g+")";const b=v[0].trim(),y=v[1].trim();return"(("+b+") - ("+y+") * trunc(("+b+") / ("+y+")))"}),l=Be(l,"ddx",g=>"dFdx("+g+")"),l=Be(l,"ddy",g=>"dFdy("+g+")"),l=Be(l,"CAST3X3",g=>"mat3("+g+")"),n==="vert")l=l.replace(/\battribute\b/g,"in").replace(/\bvarying\b/g,"out");else{if(l=l.replace(/\bvarying\b/g,"in").replace(/\battribute\b/g,"in"),typeof o=="string"&&o){const b=new Map,y=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let S;for(;(S=y.exec(o))!==null;)b.set(S[2],S[1]);const _={float:1,vec2:2,vec3:3,vec4:4},C=new Map;if(l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(N,D,k,O,j,W)=>{const K=b.get(j);return!K||_[K]<=_[k]?N:(C.set(j,_[k]),D+K+O+j+W)}),C.size>0){const N={1:"x",2:"xy",3:"xyz"};for(const[D,k]of C){const O=N[k];O&&(l=l.split(`
9
- `).map(j=>/^\s*in\s/.test(j)?j:j.replace(new RegExp("\\b"+D+"\\b(?!\\s*[.\\w])","g"),D+"."+O)).join(`
10
- `))}}}const g=new Set,v=new Set;{const b=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let y;for(;(y=b.exec(l))!==null;)v.add(y[2])}for(const b of v)new RegExp("\\b"+b+"\\b\\s*(?:\\.[xyzwrgba]{1,4})?\\s*(?:[-+*/]?=(?!=)|\\+\\+|--)").test(l)&&g.add(b);if(g.size>0){const b=l.search(/\bvoid\s+main\s*\([^)]*\)\s*\{/);if(b!==-1){const y=l.indexOf("{",b),S=l.slice(0,y+1);let _=l.slice(y+1);const C=[];for(const N of g){const D=new RegExp("^\\s*in\\s+(?:highp|mediump|lowp\\s+)?(vec[234]|float)\\s+"+N+"\\s*;","m").exec(l),k=D?D[1]:"vec4";C.push(" "+k+" "+N+"_rw = "+N+";"),_=wn(_,N,N+"_rw")}_=`
11
- `+C.map(N=>N.replace(/= (\w+)_rw;/,"= $1;")).join(`
5
+ `),t++;t+=2;continue}if(r==="/"&&i==="/"){for(;t<o&&e[t]!==`
6
+ `;)t++;continue}n+=r,t++}return n}function Ro(e,n,t,o){const r=e.split(`
7
+ `),i=[],s=[],c=new Map;for(let a=0;a<r.length;a++){const f=r[a],l=f.trim();if(l.startsWith("#include")){if(Mn(s)){const d=/^#include[ \t]+"([^"]+)"|^#include[ \t]+<([^>]+)>/.exec(l),h=d&&(d[1]||d[2]),m=h&&t?t(h):null;m!=null?i.push(Ro(Co(m),n,t)):i.push("// [include \u7F3A\u5931: "+h+"]")}continue}if(l.startsWith("#define")){if(Mn(s)){i.push(f);const d=/^#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\([^)]*\))?[ \t]*(.*)$/.exec(l);d&&c.set(d[1],d[2].trim())}continue}if(l.startsWith("#undef")){Mn(s)&&i.push(f);continue}if(l.startsWith("#ifdef")||l.startsWith("#ifndef")||l.startsWith("#if")){const d=Mn(s);let h=!1;if(l.startsWith("#ifdef")){const m=l.slice(6).trim().split(/\s+/)[0];h=n[m]!==void 0||c.has(m)}else if(l.startsWith("#ifndef")){const m=l.slice(7).trim().split(/\s+/)[0];h=!(n[m]!==void 0||c.has(m))}else try{h=!!Po(l.slice(3).trim(),n,c)}catch{h=!1}s.push({parent:d,hit:h,done:h});continue}if(l.startsWith("#else")){if(s.length>0){const d=s[s.length-1];d.hit=!d.done,d.done=!0}continue}if(l.startsWith("#elif")){if(s.length>0){const d=s[s.length-1];if(d.done)d.hit=!1;else{let h=!1;try{h=!!Po(l.slice(5).trim(),n,c)}catch{h=!1}d.hit=h,d.done=h}}continue}if(l.startsWith("#endif")){s.length>0&&s.pop();continue}l.startsWith("#")||Mn(s)&&i.push(f)}return i.join(`
8
+ `)}function Mn(e){return e.every(n=>n.parent&&n.hit)}function Qn(e,n,t,o){let r=0;for(let i=n;i<e.length;i++)if(e[i]===t)r++;else if(e[i]===o&&(r--,r===0))return i;return-1}function Lo(e,n){return Qn(e,n,"(",")")}const Qs=new Set(["void","bool","int","uint","float","double","vec2","vec3","vec4","bvec2","bvec3","bvec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"]);function Js(e,n){let t=n-1;for(;t>=0&&/[ \t]/.test(e[t]);)t--;if(t<0||t===n-1)return!1;let o=t+1;for(;t>=0&&/[A-Za-z0-9_]/.test(e[t]);)t--;const r=e.slice(t+1,o);return Qs.has(r)}function De(e,n,t){let o="",r=0;for(;r<e.length;){const i=e.indexOf(n,r);if(i===-1){o+=e.slice(r);break}if(i>0&&/[A-Za-z0-9_]/.test(e[i-1])){o+=e.slice(r,i+1),r=i+1;continue}const s=i+n.length;if(s<e.length&&/[A-Za-z0-9_]/.test(e[s])){o+=e.slice(r,s),r=s;continue}if(Js(e,i)){o+=e.slice(r,s),r=s;continue}o+=e.slice(r,i);let c=i+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){o+=e.slice(i,c),r=c;continue}const a=Lo(e,c);if(a===-1){o+=e.slice(i);break}const f=e.slice(c+1,a);o+=t(f,i),r=a+1}return o}function Fo(e,n,t,o,r){const i=e;e=Co(e);const s={},c=/\[COMBO\][^\n]*?"combo"\s*:\s*"([^"]+)"[^\n]*?"default"\s*:\s*(-?\d+)/g;let a;if(typeof r=="string"&&r){const y=new RegExp(c.source,"g");let b;for(;(b=y.exec(r))!==null;)s[b[1]]=Number(b[2])}for(;(a=c.exec(i))!==null;)s[a[1]]=Number(a[2]);const f={GLSL:1,...s,...t||{}};let l=Ro(e,f,o);l=Eo(l,20),l=l.replace(/^[ \t]*#define[^\n]*\n?/gm,"");{const y=new Set,b=/\[COMBO\][^\n]*"combo"\s*:\s*"([^"]+)"/g;let p;for(;(p=b.exec(i))!==null;)y.add(p[1]);for(const v of Object.keys(f))y.add(v);y.delete("GLSL");for(const v of y){const _=f[v]!==void 0?f[v]:0;l=wn(l,v,String(_))}}l=wn(l,"sample","smp"),l=l.replace(/(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[fh]\b/g,"$1"),l=l.replace(/\bfloat4x4\b/g,"mat4").replace(/\bfloat3x3\b/g,"mat3").replace(/\bfloat2x2\b/g,"mat2").replace(/\bfloat4\b/g,"vec4").replace(/\bfloat3\b/g,"vec3").replace(/\bfloat2\b/g,"vec2").replace(/\bhalf4\b/g,"vec4").replace(/\bhalf3\b/g,"vec3").replace(/\bhalf2\b/g,"vec2").replace(/\bhalf\b/g,"float"),l=l.replace(/\btexSample2DLod\b/g,"textureLod").replace(/\btexSample2D\b/g,"texture"),l=De(l,"saturate",y=>"clamp("+y+", 0.0, 1.0)"),l=De(l,"CAST4",y=>"vec4("+y+")"),l=De(l,"CAST3",y=>"vec3("+y+")"),l=De(l,"CAST2",y=>"vec2("+y+")"),l=l.replace(/\b(max|min)\(\s*(-?\d+(?:\.\d+)?)\s*,\s*([A-Za-z_]\w*\.(rgb|xyz|rg|xy|r|x))\s*\)/g,(y,b,p,v,_)=>{const w=_.length;return b+"(vec"+w+"("+p+"), "+v+")"}),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*([A-Za-z_][A-Za-z0-9_]*)/g,"$1$2.0 $3 $4"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(\d+\.\d+)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))/g,"$1$2.0 $3 $4");{const y=new Set,b=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=Array.from(y).sort((_,w)=>w.length-_.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+v+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4")}}{const y=["smoothstep","step","mix","clamp","max","min","pow","mod","atan","sqrt","inversesqrt","exp","log","exp2","log2","abs","sign","floor","ceil","fract","length","distance","dot","reflect","refract","faceforward","normalize","cross"],b=/\b(ApplyBlending|ApplyComposite|BlendTransparency)\s*\(/;for(const p of y)l=De(l,p,v=>{const w=St(v).map(L=>{if(b.test(L))return L;const F=[];let D=L.replace(/\[[^\]]*\]/g,B=>(F.push(B),"\0"+(F.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,B=>(F.push(B),"\0"+(F.length-1)+"\0"));return D=D.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),D.replace(/\u0000(\d+)\u0000/g,(B,z)=>F[Number(z)])});return p+"("+w.join(",")+")"});l=De(l,"pow",p=>{const v=St(p);if(v.length!==2)return"pow("+p+")";const _=v[0].trim(),w=v[1].trim(),L=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(_),D=L?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[L[1]]:0,B=/\bvec[234]\s*\(/.test(w)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(w);return D>=2&&!B?"pow("+_+", vec"+D+"("+w+"))":"pow("+_+", "+w+")"})}l=l.replace(/([)\]])\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/\)\s*([+-])\s*(\d+)(?![\d.])/g,") $1 $2.0"),l=l.replace(/(^|[^\w.])(\d+)(?![.\d])\s*([+-])\s*((?:step|smoothstep|mix|mod|fract|abs|sin|cos|tan|atan|sqrt|pow|inversesqrt|floor|ceil|sign|length|normalize|distance|dot|cross|exp|log|exp2|log2|clamp|min|max)\s*\()/g,"$1$2.0 $3 $4");{const y=new Set,b=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=Array.from(y).sort((_,w)=>w.length-_.length).join("|");l=l.replace(new RegExp("\\b("+v+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const y=new Set,b=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(v,_,w)=>y.has(_)?v:"mod("+_+", "+w+".0)"),l=l.replace(/\bint\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*mod\(([^;]*)\);/g,"int $1 = int(mod($2));")}l=l.replace(/\b(vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;()\n,]+);/g,(y,b,p,v)=>{const _=v.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(_)?y:b+" "+p+" = "+b+"("+_+");"});for(const y of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=De(l,y,b=>y+"("+b.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=De(l,"clamp",y=>{const b=St(y);if(b.length!==3)return"clamp("+y+")";const p=b[0].trim(),v=b[1].trim(),_=w=>/^-?\d+\.?\d*$/.test(w);return _(p)&&_(v)&&Number(p)===0&&Number(v)===1?"clamp("+b[2].trim()+", "+p+", "+v+")":"clamp("+y+")"}),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([)\]])\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=De(l,"smoothstep",y=>{const b=St(y);return b.length===3&&b[1].trim()==="0.0"&&b[0].trim()!=="0.0"?"(1.0 - smoothstep(0.0, "+b[0].trim()+", "+b[2].trim()+"))":"smoothstep("+y+")"});{const y=new Map,b=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let p;for(;(p=b.exec(l))!==null;)y.set(p[3],Number(p[2]));if(y.size>0){const v={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(_,w,L,F)=>{const D=y.get(L),B=y.get(F);return!D||!B||D>=B?_:w+L+" = "+F+"."+v[D]+";"})}if(y.size>0){const v=new Set,_=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let w;for(;(w=_.exec(l))!==null;)v.add(w[1]);const L="pow|saturate|clamp|smoothstep|step|abs|floor|ceil|fract|frac|sin|cos|tan|asin|acos|atan|sqrt|length|distance|dot|exp|log|sign|fmod|mod|min|max|mix|lerp",F=/^(?:length|distance|dot)$/,D=z=>{const V=z.match(new RegExp("^(?:"+L+")\\s*\\("));if(!V)return!1;let Y=0;const Z=V[0].length-1;let X=-1;for(let H=Z;H<z.length;H++)if(z[H]==="(")Y++;else if(z[H]===")"&&(Y--,Y===0)){X=H;break}if(X!==z.length-1)return!1;const q=V[0].replace(/\s*\($/,"");if(F.test(q))return!0;const oe=z.slice(Z+1,X);if(/\bvec[234]\s*\(/.test(oe)||/\.[xyzwrgba]{2,4}\b/.test(oe))return!1;for(const H of y.keys()){const j=H.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+j+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(oe))return!1}return!0},B=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(z,V,Y,Z)=>{const X=y.get(Y);if(!X)return z;const q=Z.trim();if(new RegExp("^vec"+X+"\\s*\\(").test(q)||y.has(q))return z;const oe=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(q),H=v.has(q);return!oe&&!H&&!D(q)?z:(B.add(Y),V+Y+" = vec"+X+"("+q+");")}),B.size>0){const z=[...B].sort((V,Y)=>Y.length-V.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${z})\\b`,"g"),(V,Y,Z,X)=>y.has(Y)?V:`${Y} ${Z} ${X}.x`),l=l.replace(new RegExp(`\\b(${z})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(V,Y,Z,X)=>y.has(X)?V:`${Y}.x ${Z} ${X}`)}}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*=\s*)(-?\d+)\s*;/g,"$1$2.0;"),l=l.replace(/\b(float|vec2|vec3|vec4)\s+([A-Za-z_]\w*)\s*=\s*(-?\d+)\s*;/g,(y,b,p,v)=>b==="float"?`${b} ${p} = ${v}.0;`:`${b} ${p} = ${b}(${v}.0);`);{const y=new Set,b=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=[...y].sort((_,w)=>w.length-_.length).join("|");l=l.replace(new RegExp(`\\b(${v})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${v})\\s*([-+*/]=)\\s*(-?\\d+)\\s*;`,"g"),"$1 $2 $3.0;")}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*[-+*/]=\s*)(-?\d+)\s*;/g,"$1$2.0;");const d="step|smoothstep|saturate|clamp|mix|lerp|frac|fract|abs|floor|ceil|min|max|pow|sqrt|length|dot|distance";l=l.replace(new RegExp(`\\bint\\s+([A-Za-z_]\\w*)\\s*=\\s*((?:${d})\\s*\\()`,"g"),"float $1 = $2");{const y=new Set,b=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let p;for(;(p=b.exec(l))!==null;)y.add(p[1]);if(y.size>0){const v=[...y].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${v})\\b`,"g"),(_,w,L)=>`${w}float(${L})`)}}{const y=new Set;for(const b of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))y.add(b[1]);if(y.size){const b=[...y].sort((L,F)=>F.length-L.length).join("|"),p=new RegExp("\\b("+b+")\\s*\\[","g");let v="",_=0,w;for(;w=p.exec(l);){const L=w.index+w[0].length-1,F=Qn(l,L,"[","]");if(F<0)break;let D=F+1;for(;D<l.length&&/[ \t]/.test(l[D]);)D++;if(l[D]!=="["){p.lastIndex=F+1;continue}const B=Qn(l,D,"[","]");if(B<0)break;const z=l.slice(L+1,F),V=l.slice(D+1,B);v+=l.slice(_,w.index),v+=w[1]+"[int(("+z+")) * 4 + int(("+V+"))]",_=B+1,p.lastIndex=_}l=v+l.slice(_)}}l=De(l,"mix",(y,b)=>{const p=St(y);if(p.length!==3)return"mix("+y+")";const v=D=>{const B=D.trim(),z=/\.([xyzwrgba]{1,4})\s*$/.exec(B);if(z)return z[1].length;const V=/^vec([234])\s*\(/.exec(B);if(V)return Number(V[1]);if(!/^[A-Za-z_]\w*$/.test(B))return 0;const Y=new RegExp("\\b(vec([234])|float)\\s+"+B+"\\b","g");let Z=0,X;for(;(X=Y.exec(l))!==null&&X.index<b;)Z=X[1].startsWith("vec")?Number(X[2]):1;return Z},_=p[0].trim(),w=p[1].trim(),L=v(_),F=v(w);if(L>=2&&F>=2&&L!==F){const D=Math.min(L,F),B=D===2?".xy":D===3?".xyz":"";return B?"mix("+(L>D?_+B:_)+", "+(F>D?w+B:w)+", "+p[2].trim()+")":"mix("+y+")"}return"mix("+y+")"});{const y=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let b="",p=0,v;for(;v=y.exec(l);){const _=Lo(l,v.index+v[0].length-1);if(_<0)break;let w=_+1;for(;w<l.length&&/\s/.test(l[w]);)w++;if(l[w]!=="{")continue;const L=Qn(l,w,"{","}");if(L<0)break;const F=Number(v[2]);if(F>=4){y.lastIndex=L;continue}let D=l.slice(w+1,L);const B=new Map;for(const V of l.slice(0,v.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))B.set(V[3],Number(V[2]));for(const V of D.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))B.set(V[3],Number(V[2]));const z=F===2?"xy":"xyz";D=D.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(V,Y)=>{const Z=B.get(Y);return Z&&Z>F?"return "+Y+"."+z+";":V}),b+=l.slice(p,w+1)+D,p=L,y.lastIndex=L}l=b+l.slice(p)}const h=new Set,m=/\b(?:uniform\s+)?(?:mat4|mat3|mat2|float4x4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let M;for(;(M=m.exec(l))!==null;)h.add(M[1]);if(l=De(l,"mul",y=>{const b=St(y);if(b.length!==2)return"mul("+y+")";const p=b[0].trim(),v=b[1].trim(),_=w=>h.has(w.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(w);return _(p)&&_(v)?"(transpose("+v+") * transpose("+p+"))":_(v)?"(transpose("+v+") * "+p+")":"("+p+" * "+v+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=De(l,"atan2",y=>"atan("+y+")"),l=De(l,"fmod",y=>{const b=St(y);if(b.length!==2)return"mod("+y+")";const p=b[0].trim(),v=b[1].trim();return"(("+p+") - ("+v+") * trunc(("+p+") / ("+v+")))"}),l=De(l,"ddx",y=>"dFdx("+y+")"),l=De(l,"ddy",y=>"dFdy("+y+")"),l=De(l,"CAST3X3",y=>"mat3("+y+")"),n==="vert")l=l.replace(/\battribute\b/g,"in").replace(/\bvarying\b/g,"out");else{if(l=l.replace(/\bvarying\b/g,"in").replace(/\battribute\b/g,"in"),typeof r=="string"&&r){const p=new Map,v=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=v.exec(r))!==null;)p.set(_[2],_[1]);const w={float:1,vec2:2,vec3:3,vec4:4},L=new Map;if(l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(F,D,B,z,V,Y)=>{const Z=p.get(V);return!Z||w[Z]<=w[B]?F:(L.set(V,w[B]),D+Z+z+V+Y)}),L.size>0){const F={1:"x",2:"xy",3:"xyz"};for(const[D,B]of L){const z=F[B];z&&(l=l.split(`
9
+ `).map(V=>/^\s*in\s/.test(V)?V:V.replace(new RegExp("\\b"+D+"\\b(?!\\s*[.\\w])","g"),D+"."+z)).join(`
10
+ `))}}}{const p=new Map,v=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[34])\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=v.exec(l))!==null;)p.set(_[2],Number(_[1].slice(3)));const w=new Map(p),L=/\b(vec[34])\s+([A-Za-z_]\w*)\s*[=;]/g;for(;(_=L.exec(l))!==null;)w.has(_[2])||w.set(_[2],Number(_[1].slice(3)));if(w.size>0){const F=D=>{const B=D.trim();if(!B)return D;const z=/^([A-Za-z_]\w*)$/.exec(B);if(z&&w.has(z[1]))return z[1]+".xy";const V=/^([A-Za-z_]\w*)(\s*[+\-].+)$/.exec(B);return V&&w.has(V[1])?"("+V[1]+".xy"+V[2]+")":D};for(const D of["textureLod","texture"])l=De(l,D,B=>{const z=St(B);return z.length>=2&&(z[1]=F(z[1])),D+"("+z.join(", ")+")"})}p.size>0&&(l=l.split(`
11
+ `).map(F=>{if(!/\bvec2\s+[A-Za-z_]\w*\s*=/.test(F))return F;let D=F;for(const B of p.keys())D=D.replace(new RegExp("\\b"+B+"\\b(?!\\s*[.\\w])","g"),B+".xy");return D}).join(`
12
+ `))}const y=new Set,b=new Set;{const p=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let v;for(;(v=p.exec(l))!==null;)b.add(v[2])}for(const p of b)new RegExp("\\b"+p+"\\b\\s*(?:\\.[xyzwrgba]{1,4})?\\s*(?:[-+*/]?=(?!=)|\\+\\+|--)").test(l)&&y.add(p);if(y.size>0){const p=l.search(/\bvoid\s+main\s*\([^)]*\)\s*\{/);if(p!==-1){const v=l.indexOf("{",p),_=l.slice(0,v+1);let w=l.slice(v+1);const L=[];for(const F of y){const D=new RegExp("^\\s*in\\s+(?:highp|mediump|lowp\\s+)?(vec[234]|float)\\s+"+F+"\\s*;","m").exec(l),B=D?D[1]:"vec4";L.push(" "+B+" "+F+"_rw = "+F+";"),w=wn(w,F,F+"_rw")}w=`
13
+ `+L.map(F=>F.replace(/= (\w+)_rw;/,"= $1;")).join(`
12
14
  `)+`
13
- `+_,l=S+_}}}l=l.replace(/\[(?:unroll|loop|branch|flatten)\]\s*/g,""),l=l.replace(/\bstatic\s+/g,"");{const g=new Set;for(const v of l.matchAll(/\b(?:uniform[ \t]+)?(?:highp|mediump|lowp)?[ \t]*float[ \t]+([A-Za-z_]\w*)[ \t]*[;=]/g))g.add(v[1]);if(g.size){const v=b=>{const y=b.trim().startsWith("-"),S=b.replace(/^-\s*/,"").trim();return g.has(S)?(y?"-":"")+"int("+S+")":b};l=l.replace(/(for\s*\(\s*(?:int|uint)\s+(\w+)\s*=\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;\s*\2\s*[<>]=?\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;)/g,(b,y,S,_,C,N,D)=>y+v(_)+C+v(N)+D)}}{const g=new Set;l=l.split(`
14
- `).map(v=>{const b=/^[ \t]*uniform[ \t]+(?:highp|mediump|lowp[ \t]+)?[A-Za-z0-9_]+[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(v);if(!b)return v;const y=b[1];return g.has(y)?"":(g.add(y),v)}).join(`
15
- `)}let m=`#version 300 es
16
- `;return n==="vert"&&(m+=`precision highp float;
17
- `),n==="frag"&&(m+=`precision highp float;
18
- `,/\bgl_FragColor\b/.test(l)&&(m+=`out vec4 fragColor;
19
- `,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),m+l}const Eo={center:[.5,.5],centre:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],topleft:[0,0],topright:[1,0],bottomleft:[0,1],bottomright:[1,1]},Vs={2:"multiply",6:"additive",7:"screen",9:"additive",31:"additive"},Xs={screen:1,multiply:2},Fr=`#version 300 es
15
+ `+w,l=_+w}}}l=l.replace(/\[(?:unroll|loop|branch|flatten)\]\s*/g,""),l=l.replace(/\bstatic\s+/g,"");{const y=new Set;for(const b of l.matchAll(/\b(?:uniform[ \t]+)?(?:highp|mediump|lowp)?[ \t]*float[ \t]+([A-Za-z_]\w*)[ \t]*[;=]/g))y.add(b[1]);if(y.size){const b=p=>{const v=p.trim().startsWith("-"),_=p.replace(/^-\s*/,"").trim();return y.has(_)?(v?"-":"")+"int("+_+")":p};l=l.replace(/(for\s*\(\s*(?:int|uint)\s+(\w+)\s*=\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;\s*\2\s*[<>]=?\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;)/g,(p,v,_,w,L,F,D)=>v+b(w)+L+b(F)+D)}}{const y=new Set;l=l.split(`
16
+ `).map(b=>{const p=/^[ \t]*uniform[ \t]+(?:highp|mediump|lowp[ \t]+)?[A-Za-z0-9_]+[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(b);if(!p)return b;const v=p[1];return y.has(v)?"":(y.add(v),b)}).join(`
17
+ `)}let g=`#version 300 es
18
+ `;return n==="vert"&&(g+=`precision highp float;
19
+ `),n==="frag"&&(g+=`precision highp float;
20
+ `,/\bgl_FragColor\b/.test(l)&&(g+=`out vec4 fragColor;
21
+ `,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),g+l}const No={center:[.5,.5],centre:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],topleft:[0,0],topright:[1,0],bottomleft:[0,1],bottomright:[1,1]},ea={2:"multiply",6:"additive",7:"screen",9:"additive",31:"additive"},ta={screen:1,multiply:2},Ur=`#version 300 es
20
22
  in vec3 a_Position;
21
23
  in vec2 a_TexCoord;
22
24
  uniform mat4 u_MVP;
@@ -24,7 +26,7 @@ out vec2 v_UV;
24
26
  void main() {
25
27
  gl_Position = u_MVP * vec4(a_Position, 1.0);
26
28
  v_UV = a_TexCoord;
27
- }`,Hs=`#version 300 es
29
+ }`,na=`#version 300 es
28
30
  precision mediump float;
29
31
  in vec2 v_UV;
30
32
  uniform sampler2D u_Tex;
@@ -40,7 +42,7 @@ void main() {
40
42
  if (u_BlendPrep == 1) c.rgb *= c.a;
41
43
  else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
42
44
  fragColor = c;
43
- }`,Gs=`#version 300 es
45
+ }`,ra=`#version 300 es
44
46
  precision mediump float;
45
47
  in vec2 v_UV;
46
48
  uniform sampler2D u_Tex;
@@ -51,21 +53,22 @@ void main() {
51
53
  if (u_BlendPrep == 1) c.rgb *= c.a;
52
54
  else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
53
55
  fragColor = c;
54
- }`,Ys=`#version 300 es
56
+ }`,oa=`#version 300 es
55
57
  precision mediump float;
56
58
  in vec2 v_UV;
57
59
  uniform sampler2D u_Tex;
58
60
  out vec4 fragColor;
59
61
  void main() {
60
62
  fragColor = vec4(texture(u_Tex, v_UV).rgb, 1.0);
61
- }`;function qs(e,n){return new Float32Array([0,n,0,0,1,0,0,0,0,0,e,n,0,1,1,e,n,0,1,1,0,0,0,0,0,e,0,0,1,0])}function Zs(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,1,0,1,1,-1,-1,0,0,0,1,-1,0,1,0])}function Ks(){return new Float32Array([-.5,.5,0,0,1,-.5,-.5,0,0,0,.5,.5,0,1,1,.5,.5,0,1,1,-.5,-.5,0,0,0,.5,-.5,0,1,0])}const Qs={5126:"float",35664:"vec2",35665:"vec3",35666:"vec4",5124:"int",35667:"ivec2",35668:"ivec3",35669:"ivec4",35670:"bool",35676:"mat4",35675:"mat3"};function Jn(e,n,t){const r=Po(e,e.VERTEX_SHADER,n),o=Po(e,e.FRAGMENT_SHADER,t),i=e.createProgram();if(e.attachShader(i,r),e.attachShader(i,o),e.bindAttribLocation(i,0,"a_Position"),e.bindAttribLocation(i,1,"a_TexCoord"),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("\u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(i));return i}function Po(e,n,t){const r=e.createShader(n);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error("\u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(r));return r}function Co(e){const n=String(e).trim().split(/\s+/).map(Number);return[n[0]||0,n[1]||0,n[2]||0]}function Nr(e,n,t,r,o=null){const i=e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),o?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,n),i}function Js(e,n,t=!1){const r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);const o=n[0];if(o.bitmap)e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o.bitmap);else if(t&&o.rgba){const i=o.width*o.height,s=new Uint8Array(i*2);for(let a=0;a<i;a++)s[a*2]=o.rgba[a*4+3],s[a*2+1]=o.rgba[a*4];const c=e.getParameter(e.UNPACK_ALIGNMENT);e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG8,o.width,o.height,0,e.RG,e.UNSIGNED_BYTE,s),e.pixelStorei(e.UNPACK_ALIGNMENT,c)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,o.width,o.height,0,e.RGBA,e.UNSIGNED_BYTE,o.rgba);return e.generateMipmap(e.TEXTURE_2D),r}function Ur(e,n,t,r,o){const i=1-o;return i*i*i*e+3*i*i*o*n+3*i*o*o*t+o*o*o*r}function ea(e,n,t,r,o){if(o<=e)return 0;if(o>=r)return 1;let i=r-e>1e-9?(o-e)/(r-e):.5;for(let a=0;a<8;a++){const u=Ur(e,n,t,r,i)-o;if(Math.abs(u)<1e-6)return i;const l=1-i,d=3*l*l*(n-e)+6*l*i*(t-n)+3*i*i*(r-t);if(Math.abs(d)<1e-9)break;const h=i-u/d;if(h<0||h>1||!Number.isFinite(h))break;i=h}let s=0,c=1;for(let a=0;a<40;a++)i=(s+c)/2,Ur(e,n,t,r,i)<o?s=i:c=i;return i}function er(e,n,t){if(!e||e.length===0)return 0;if(e.length===1)return Number(e[0].value)||0;if(t&&t.length>0){const k=e[0],O=e[e.length-1],j=t.length-O.frame;if(j>1e-9&&n>O.frame&&n<=t.length)return er([{frame:0,value:O.value,front:O.front,back:O.back},{frame:j,value:k.value,front:k.front,back:k.back}],n-O.frame)}if(n<=e[0].frame)return Number(e[0].value)||0;const r=e[e.length-1];if(n>=r.frame)return Number(r.value)||0;let o=0,i=e.length-1;for(;i-o>1;){const k=o+i>>1;e[k].frame<=n?o=k:i=k}const s=e[o],c=e[i],a=s.frame,u=c.frame,l=Number(s.value)||0,d=Number(c.value)||0,h=u-a;if(h<=0)return d;const p=s.front,w=c.back,m=h/3,g=!!(p&&p.enabled),v=!!(w&&w.enabled),b=g?Math.abs(Number(p.x)||0):1,y=v?Math.abs(Number(w.x)||0):1,S=a+Math.min(b,1.5)*m,_=u-Math.min(y,1.5)*m,C=g?l+(Number(p.y)||0):l+(d-l)/3,N=v?d+(Number(w.y)||0):d-(d-l)/3,D=ea(a,S,_,u,n);return Ur(l,C,N,d,D)}function Ro(e,n,t){const r=n>0?n:1;if(t==="loop"){let o=e%r;return o<0&&(o+=r),o}if(t==="mirror"){const o=r*2;let i=e%o;return i<0&&(i+=o),i<=r?i:o-i}return Math.max(0,Math.min(r,e))}function ta(e){return Array.isArray(e)?e:typeof e=="string"?e.trim().split(/\s+/).map(Number):Number.isFinite(e)?[e]:[]}function Lo(e){const n=e&&e.options||{},t=Number(n.fps)>0?Number(n.fps):30,r=Number(n.length)>0?Number(n.length):0,o=n.mode==="loop"||n.mode==="mirror"?n.mode:"single",i=typeof n.name=="string"?n.name:"",s=!!(e&&e.relative),c=n.wraploop===!0&&o==="loop",a=[];for(let h=0;;h++){const p=e&&e["c"+h];if(!Array.isArray(p))break;a.push(p)}const u=n.startpaused!==!0,l=[],d={name:i,mode:o,fps:t,relative:s,channelCount:a.length,frame:0,rate:1,playing:u,ended:!1,get frameCount(){return r},play(){return d.playing=!0,d.ended=!1,d},pause(){return d.playing=!1,d},stop(){return d.playing=!1,d.frame=0,d.ended=!1,d},setFrame(h){const p=Number(h);return Number.isFinite(p)&&(d.frame=p),d},getFrame(){return d.frame},setRate(h){const p=Number(h);return Number.isFinite(p)&&(d.rate=p),d},addEndedCallback(h){return typeof h=="function"&&l.push(h),d},setBlend(){return d},setVisible(){return d},advance(h){if(d.playing&&(d.frame+=(Number(h)||0)*t*d.rate,o==="single"))if(d.frame>=r){if(d.frame=r,d.playing=!1,!d.ended){d.ended=!0;for(const p of l)try{p()}catch{}}}else d.frame<0&&(d.frame=0,d.playing=!1)},value(){const h=Ro(d.frame,r,o),p=c?{length:r}:void 0;if(a.length===1)return er(a[0],h,p);const w=[];for(const m of a)w.push(er(m,h,p));return w},applyTo(h){const p=d.value();if(!s)return p;const w=ta(h);return Array.isArray(p)?p.map((m,g)=>m+(Number(w[g])||0)):p+(Number(w[0])||0)}};return d}function na(){const e={name:"",mode:"single",fps:30,relative:!1,channelCount:0,frame:0,rate:1,playing:!1,ended:!1,get frameCount(){return 0},play(){return e},pause(){return e},stop(){return e},setFrame(){return e},getFrame(){return 0},setRate(){return e},addEndedCallback(){return e},setBlend(){return e},setVisible(){return e},advance(){},value(){return 0},applyTo(n){return n}};return e}const ra=Object.freeze(Object.defineProperty({__proto__:null,createAnimation:Lo,createNeutralAnimation:na,sampleChannel:er,wrapFrame:Ro},Symbol.toStringTag,{value:"Module"}));function Fo(e){const n=e&&e.puppet&&e.puppet.animBound;return n?[n.x*Math.abs(e.scale[0]),n.y*Math.abs(e.scale[1])]:[0,0]}function No(e){for(const n of e&&e.effects||[]){if(n.visible===!1)continue;const t=Math.max((n.passes||[]).length,(n.materialPasses||[]).length);for(let r=0;r<t;r++){const o=n.passes&&n.passes[r]&&n.passes[r].combos||{},i=n.materialPasses&&n.materialPasses[r]&&n.materialPasses[r].combos||{},s=o.TRANSPARENCY!==void 0?o.TRANSPARENCY:i.TRANSPARENCY;if(Number(s)===0)return!0}}return!1}function tr(e,n,t){if(t||(t=new Set),!n)return t;for(const r of e.childIds||[]){const o=n.get(r);!o||o.particle||o.isPostProcess||(t.add(r),tr(o,n,t))}return t}function kr(e){const n=Vs[e]||"translucent";return{mode:n,prep:Xs[n]||0}}function oa(e,n,t,r){const{mode:o,prep:i}=kr(e);let s=t;return i===1?s=t*r:i===2&&(s=1-r+t*r),o==="screen"?s+n*(1-s):o==="multiply"?n*s:o==="additive"?n+t*r:n*(1-r)+t*r}function Uo(e,n,t){const r=e&&Number(e.scale)||1;let o=Math.max(1,Math.round(n/r)),i=Math.max(1,Math.round(t/r));const s=e&&Number(e.fit);if(Number.isFinite(s)&&s>0){const c=Math.max(o,i);if(c>s){const a=s/c;o=Math.max(1,Math.round(o*a)),i=Math.max(1,Math.round(i*a))}}return[o,i]}function ia(e){const n=Number(e);return!Number.isFinite(n)||n<.001?999:1/n}const _n=-1;function Br(e,n){return!!n&&!e}const sa="mix(999.0, 1.0 / max(g_PointerScale, 0.001), step(0.001, g_PointerScale))";function ko(e){if(typeof e!="string"||/unprojectedUVs\s*\*=\s*mix\(999\.0,\s*1\.0\s*\/\s*max\(\s*g_PointerScale/.test(e))return e;const n=/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/.test(e),t=/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/.test(e);if(!n&&!t)return e;let r=e;/uniform\s+float\s+g_PointerScale\b/.test(r)||(r=r.replace(/void\s+main\s*\(/,`uniform float g_PointerScale;
62
- void main(`));const o=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return r.replace(o,"unprojectedUVs *= "+sa+" *")}function aa(e,n={}){const t=e.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0});if(!t)throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebGL2");const r=n.shaderResolver||(async()=>null),o=n.diag||(()=>{}),i=typeof document<"u"?document.createElement("canvas"):null;i&&(i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0");let s=!1,c=n.fboCapFactor===void 0?0:n.fboCapFactor,a=null,u=null,l=null;const d=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function h(f){l=f||null}let p=null,w=null,m=null,g=null,v=null,b=null,y=null;const S=new Map,_=new Map,C={total:0,ok:0,failed:0};function N(f,T){p=typeof f=="function"?f:null,w=T&&T.userProperties||null,m=T&&T.audioViews||null,g=T&&T.shared||null,v=T&&T.inputView||null,b=T&&T.timers||null,y=T&&typeof T.onSandbox=="function"?T.onSandbox:null,S.clear(),_.clear()}let D=!1;const k=Jn(t,Fr,Hs),O=Jn(t,Fr,Gs),j=Jn(t,Fr,Ys),W=t.createVertexArray();t.bindVertexArray(W);const K=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,K),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,2,t.FLOAT,!1,20,12),t.bindVertexArray(null);const V=new Map;let G=1;function Q(f,T,x){const M=(x||"")+"|"+f+"x"+T;if(V.has(M)){const B=V.get(M);return B.stamp=G,B}const E=t.createFramebuffer(),P=t.createTexture();t.bindTexture(t.TEXTURE_2D,P),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,f,T,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,E),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,P,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const R={fbo:E,tex:P,width:f,height:T,stamp:G};return V.set(M,R),R}function q(){for(const[f,T]of V)T.stamp!==G&&(T.fbo&&t.deleteFramebuffer(T.fbo),T.tex&&t.deleteTexture(T.tex),V.delete(f))}const te=new Map,me=new Map,xe=new Map;function We(f){const T={},x=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let M;for(;(M=x.exec(f))!==null;){const E=M[1],P=M[2],R=/"material"\s*:\s*"([^"]+)"/.exec(P);if(!R)continue;const B=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(P);T[R[1]]={uniform:E,default:B?rt(B[1]):void 0}}return T}function Ve(f){const T=new Map,x=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let M;for(;(M=x.exec(f))!==null;){const E=Number(M[1]),P=/"default"\s*:\s*"([^"]+)"/.exec(M[2]);P&&P[1]&&T.set(E,P[1])}return T}function Ee(f){const T=[],x=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let M;for(;(M=x.exec(f))!==null;){const E=/"combo"\s*:\s*"([^"]+)"/.exec(M[3]);E&&T.push({slot:Number(M[2]),name:M[1],combo:E[1]})}return T}function rt(f){if(f.startsWith('"'))return f.slice(1,-1);const T=Number(f);return Number.isFinite(T)?T:void 0}async function Xe(f,T,x){let M=xe.get(f);if(M===void 0){const R=await r("shaders/"+f+".frag")||"",B=await r("shaders/"+f+".vert")||"";M={frag:R,vert:B,texCombos:Ee(R)},xe.set(f,M)}const E={...T};for(const R of M.texCombos)x&&x[R.slot]&&E[R.combo]===void 0&&(E[R.combo]=1);const P=f+"|"+JSON.stringify(E);if(te.has(P))return te.get(P);for(let R=0;R<4;R++){const B=new Set,z=re=>me.has(re)?me.get(re):(B.add(re),null),$=ko(So(M.frag,"frag",E,z,M.vert)),J=So(M.vert,"vert",E,z,M.frag);if(B.size===0){let re;try{re=Jn(t,J,$)}catch(F){throw new Error("shader="+f+" "+(F&&F.message))}const Z=new Map,ce=t.getProgramParameter(re,t.ACTIVE_UNIFORMS);for(let F=0;F<ce;F++){const ee=t.getActiveUniform(re,F),ue=ee.name.replace(/\[0\]$/,"");Z.set(ue,{loc:t.getUniformLocation(re,ee.name),type:Qs[ee.type]||"unknown",size:ee.size})}const le={...We(M.vert),...We(M.frag)},se=new Map([...Ve(M.vert),...Ve(M.frag)]),ie={prog:re,uni:Z,matMeta:le,samplerDefaults:se,fragGlsl:$,vertGlsl:J};return te.set(P,ie),ie}await Promise.all(Array.from(B).map(async re=>{me.set(re,await r("shaders/"+re)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+f)}const Pe=Nr(t,new Uint8Array([255,255,255,255]),1,1),Ae=Nr(t,new Uint8Array([0,0,0,0]),1,1);let Ze=null;function to(f){Ze=f||null}function lt(){if(!Ze)return null;const f=typeof Ze=="function"?Ze():Ze;return f&&f.state?f.state:f}const He={x:0,y:0,sx:0,sy:0};let hr=0,$t=0,ot=0,ze=1/60,Et=-1;const kn=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,Bn=(f,T)=>{const x=f!==null&&typeof f=="object"?f.value:f;return x===!0||x===1?!0:x===!1||x===0?!1:T},In=(f,T)=>{const x=f!==null&&typeof f=="object"?f.value:f;return typeof x=="number"&&Number.isFinite(x)?x:T},mr=f=>n.fade!==!1&&Bn(f.camerafade,!1);function fn(f,T){if(!Bn(f.camerashake,!1))return null;const x=In(f.camerashakeamplitude,0);if(x===0)return null;const M=Math.max(0,Math.min(1,In(f.camerashakeroughness,0))),E=In(f.camerashakespeed,1),P=T*E,R=Math.sin(P*2.1)*Math.cos(P*.7),B=Math.cos(P*1.7)*Math.sin(P*.9),z=Math.sin(P*11.3)*Math.cos(P*7.1),$=Math.cos(P*9.7)*Math.sin(P*13.1);return{x:(R*(1-M)+z*M)*x,y:(B*(1-M)+$*M)*x}}function pr(){const f=new Date;return(f.getHours()*3600+f.getMinutes()*60+f.getSeconds())/86400}function we(f,T,x){const M=f.get(T);M&&M.loc!==null&&x(M.loc,M.type,M.size)}function Kt(f){if(typeof f=="number")return[f,f,f,f];const T=String(f).trim().split(/[\s,]+/).map(Number);return[T[0]||0,T[1]||0,T[2]||0,T[3]||0]}function vt(f,T,x){const M=f.get(T);if(!M||M.loc===null)return;const E=x&&x.value!==void 0?x.value:x,P=Kt(E);switch(M.type){case"float":t.uniform1f(M.loc,P[0]);break;case"int":case"bool":t.uniform1i(M.loc,E===!0||E===1?1:Math.round(P[0]));break;case"vec2":t.uniform2f(M.loc,P[0],P[1]);break;case"vec3":t.uniform3f(M.loc,P[0],P[1],P[2]);break;case"vec4":t.uniform4f(M.loc,P[0],P[1],P[2],P[3]);break;case"mat4":t.uniformMatrix4fv(M.loc,!1,Je);break;case"mat3":t.uniformMatrix3fv(M.loc,!1,br);break}}const On=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function gr(f,T,x,M,E,P,R,B,z,$,J){if(we(f,"g_Time",F=>t.uniform1f(F,x)),we(f,"g_Daytime",F=>t.uniform1f(F,pr())),we(f,"g_ModelViewProjectionMatrix",F=>t.uniformMatrix4fv(F,!1,P)),we(f,"g_ModelMatrix",F=>t.uniformMatrix4fv(F,!1,R)),we(f,"g_ViewProjectionMatrix",F=>t.uniformMatrix4fv(F,!1,B)),f.get("g_ModelViewProjectionMatrixInverse")){let F=null;for(const[ue,ve]of z)ue===0&&(F=ve);const ee=F&&F[0]>0&&F[1]>0?Cs(xn(on(),F[0]/2,F[1]/2,1)):Je;we(f,"g_ModelViewProjectionMatrixInverse",ue=>t.uniformMatrix4fv(ue,!1,ee))}we(f,"g_Brightness",F=>t.uniform1f(F,T.brightness)),we(f,"g_UserAlpha",F=>t.uniform1f(F,T.alpha)),we(f,"g_Alpha",F=>t.uniform1f(F,T.alpha)),we(f,"g_Color",F=>t.uniform3f(F,T.color[0],T.color[1],T.color[2])),we(f,"g_Color4",F=>t.uniform4f(F,T.color[0],T.color[1],T.color[2],1)),we(f,"g_CompositeColor",F=>t.uniform3f(F,T.color[0],T.color[1],T.color[2])),we(f,"g_TexelSize",F=>t.uniform2f(F,1/M,1/E)),we(f,"g_TexelSizeHalf",F=>t.uniform2f(F,.5/M,.5/E)),we(f,"g_TextureReductionScale",F=>t.uniform1f(F,1));const re=lt(),Z=Br(!!(re&&re.has),!!f.get("g_PointerScale"));let ce=Z?_n:re?re.u:.5,le=Z?_n:re?re.v:.5,se=Z?_n:re?re.lastU:.5,ie=Z?_n:re?re.lastV:.5;if(J&&T&&T.size&&T.size[0]>0&&T.size[1]>0){const F=Math.abs(T.size[0]*T.scale[0]),ee=Math.abs(T.size[1]*T.scale[1]);if(F>0&&ee>0){const ue=T.origin[0]-F/2,ve=J.projH-T.origin[1]-ee/2,Me=Re=>(J.offX+Re*J.viewW-ue)/F,he=Re=>(J.offY+Re*J.viewH-ve)/ee;ce=Me(ce),le=he(le),se=Me(se),ie=he(ie)}}we(f,"g_PointerPosition",F=>t.uniform2f(F,ce,le)),we(f,"g_PointerPositionLast",F=>t.uniform2f(F,se,ie)),we(f,"g_PointerState",F=>t.uniform4f(F,ce,le,re&&re.leftDown?1:0,0)),we(f,"g_ParallaxPosition",F=>t.uniform2f(F,He.sx*.5+.5,He.sy*.5+.5)),we(f,"g_Frametime",F=>t.uniform1f(F,ze)),f.get("g_EffectTextureProjectionMatrixInverse")&&we(f,"g_EffectTextureProjectionMatrixInverse",F=>t.uniformMatrix4fv(F,!1,Je));for(let F=0;F<8;F++)we(f,"g_Texture"+F,ee=>t.uniform1i(ee,F));for(const[F,ee]of z)we(f,"g_Texture"+F+"Resolution",ue=>t.uniform4f(ue,ee[0],ee[1],ee[2],ee[3]));if(l){const F=typeof l=="function"?l():l;if(F)for(const[ee,ue]of d){const ve=F[ue];ve&&we(f,ee,Me=>t.uniform1fv(Me,ve))}}}function dn(f,T,x){for(const[M,E]of Object.entries(T||{})){const P=x&&x[M];P&&vt(f,P.uniform,E)}for(const[M,E]of Object.entries(x||{}))(!T||!(M in T))&&E.default!==void 0&&vt(f,E.uniform,E.default)}function hn(f){const T=lt();Br(!!(T&&T.has),!!f.get("g_PointerScale"))&&we(f,"g_PointerScale",x=>t.uniform1f(x,0))}function ut(f,T,x,M){if(!f)return f;let E=!1;for(const R of Object.values(f))if(R!==null&&typeof R=="object"&&typeof R.script=="string"){E=!0;break}if(!E||!p)return f;const P={...f};for(const[R,B]of Object.entries(f)){if(B===null||typeof B!="object"||typeof B.script!="string")continue;const z=T+"|"+R;let $=S.get(z);if($===void 0){C.total++;try{$=p(B.script,B.scriptproperties||B.scriptProperties||null,{userProperties:w||{},audioViews:m||void 0,layer:M||null,shared:g||{},inputView:v||void 0,setTimeout:b?b.setTimeout:void 0,clearTimeout:b?b.clearTimeout:void 0,setInterval:b?b.setInterval:void 0,clearInterval:b?b.clearInterval:void 0})}catch{$=null}if($?C.ok++:C.failed++,S.set(z,$),$){const se=B.value!==void 0?B.value:B,ie=Kt(se),ee=typeof se=="number"?ie[0]:{x:ie[0],y:ie[1],z:ie[2]};$.init&&$.init(ee)}if($&&typeof $.applyUserProperties=="function")try{$.applyUserProperties(w||{})}catch{}if($&&$.hasMediaHook&&y)try{y($)}catch{}}if(!$||$.disabled||!$.hasUpdate)continue;if($.engine){$.engine.runtime=x,$.engine.frametime=ze,$.engine.timeOfDay=pr();const se=lt();se&&se.screenW&&se.screenH&&($.engine.screenResolution={x:se.screenW,y:se.screenH})}const J=Kt(B.value!==void 0?B.value:B),Z=typeof(B.value!==void 0?B.value:B)=="number"?J[0]:{x:J[0],y:J[1],z:J[2]};let ce;try{ce=$.callUpdate(Z)}catch{ce=void 0}const le=ce??Z;if(typeof le=="number"&&Number.isFinite(le))P[R]=le;else if(le&&typeof le=="object"){const se=Number(le.x),ie=Number(le.y),F=Number(le.z);Number.isFinite(se)&&Number.isFinite(ie)&&(P[R]=Number.isFinite(F)?`${se} ${ie} ${F}`:`${se} ${ie} 0`)}}return P}function Dn(f,T,x){if(!f)return f;let M=!1;for(const P of Object.values(f))if(P&&typeof P=="object"&&P.animation&&P.animation.options){M=!0;break}if(!M)return f;const E={...f};for(const[P,R]of Object.entries(f)){if(!R||typeof R!="object"||!R.animation||!R.animation.options)continue;const B=T+"|anim|"+P;let z=_.get(B);if(!z){const $=Lo(R.animation),J=R.value!==void 0?R.value:0;$.baseNumeric=Array.isArray(J)?J.slice():J,z={ctrl:$},_.set(B,z)}z.ctrl.playing&&z.ctrl.setFrame(x*z.ctrl.fps*z.ctrl.rate),E[P]=z.ctrl.applyTo(z.ctrl.baseNumeric)}return E}function Qt(f,T,x,M){return f==null||f===""?null:f.startsWith("_rt_")?f.startsWith("_rt_imageLayerComposite")?gn&&dt.has(f)?dt.get(f):T:x.has(f)?x.get(f):null:x.has(f)?x.get(f):M.get(f)||null}const it=Zs(),zn=Ks(),$n=new Map;function jt(f,T){const x=f+"x"+T;let M=$n.get(x);return M===void 0&&(M=qs(f,T),$n.set(x,M)),M}let Wt=null;function ft(f,T){Wt!==f&&(t.bindBuffer(t.ARRAY_BUFFER,K),t.bufferData(t.ARRAY_BUFFER,T,t.DYNAMIC_DRAW),Wt=f)}const _e={mvp:t.getUniformLocation(k,"u_MVP"),tex:t.getUniformLocation(k,"u_Tex"),color:t.getUniformLocation(k,"u_Color4"),frameOrigin:t.getUniformLocation(k,"u_FrameOrigin"),frameU:t.getUniformLocation(k,"u_FrameU"),frameV:t.getUniformLocation(k,"u_FrameV"),blendPrep:t.getUniformLocation(k,"u_BlendPrep")},Pt={mvp:t.getUniformLocation(O,"u_MVP"),tex:t.getUniformLocation(O,"u_Tex"),blendPrep:t.getUniformLocation(O,"u_BlendPrep")},Jt={mvp:t.getUniformLocation(j,"u_MVP"),tex:t.getUniformLocation(j,"u_Tex")},Je=on(),br=On();function yt(f){f==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):f==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let Vt=0;function Xt(f){const{mode:T,prep:x}=kr(f);Vt=x,T==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):T==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):T==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):yt("translucent")}function jn(f,T){if(T&&T.perspective)return!1;const x=f.size[0]*f.scale[0],M=f.size[1]*f.scale[1];if(x===0||M===0)return!1;let E=Math.abs(x)/2,P=Math.abs(M)/2;const R=f.angles[2];if(R!==0){const ce=Math.abs(Math.cos(R)),le=Math.abs(Math.sin(R)),se=E*ce+P*le,ie=E*le+P*ce;E=se,P=ie}const B=f.origin[0],z=T.projH-f.origin[1];let $=64;f.parallaxDepth&&($+=Math.abs(an(f.parallaxDepth[0])*$t),$+=Math.abs(an(f.parallaxDepth[1])*ot));const J=Fo(f),re=$+J[0],Z=$+J[1];return B+E+re<T.offX||B-E-re>T.offX+T.viewW||z+P+Z<T.offY||z-P-Z>T.offY+T.viewH}function vr(f,T,x){if(!f.spriteSheet)return null;const M=T&&T.frames,E=Array.isArray(M)?M:M&&M.list;if(!E||E.length===0)return null;const P=M&&M.atlasWidth||T.width||0,R=M&&M.atlasHeight||T.height||0;if(P<=0||R<=0)return null;f.spriteFrameCount=E.length;let B=0;const z=f.textureAnimation;if(z&&z.frame!==null&&z.frame!==void 0)B=Math.floor(Number(z.frame))||0,B>=0||(B=0),B>=E.length&&(B=E.length-1);else if(E.length>1){const le=z&&z.playing===!1;let se=0;for(const ie of E)se+=ie.duration>0?ie.duration:1/30;if(!le&&se>0){let ie=x%se;ie<0&&(ie+=se);for(let F=0;F<E.length;F++){const ee=E[F].duration>0?E[F].duration:.03333333333333333;if(ie<ee){B=F;break}ie-=ee,B=F}}}const $=E[B],J=$.uDir?$.uDir[0]:$.width,re=$.uDir?$.uDir[1]:0,Z=$.vDir?$.vDir[0]:0,ce=$.vDir?$.vDir[1]:$.height;return[$.x/P,$.y/R,J/P,re/R,Z/P,ce/R]}function xt(f,T){const x=f.size[0]*f.scale[0],M=f.size[1]*f.scale[1];let E=on();if(T&&T.perspective){const R=Us(f,T);E=sn(E,R[0],R[1],R[2]);const B=f.angles[0]||0,z=f.angles[1]||0;z&&(E=Ls(E,z)),B&&(E=Rs(E,B)),E=bo(E,-f.angles[2])}else{if(E=sn(E,f.origin[0],T.projH-f.origin[1],f.origin[2]),f.parallaxDepth&&($t!==0||ot!==0)){const R=an(f.parallaxDepth[0]),B=an(f.parallaxDepth[1]);E=sn(E,R*$t,B*ot,0)}E=bo(E,-f.angles[2])}const P=Eo[f.alignment]||[.5,.5];return(P[0]!==.5||P[1]!==.5)&&(E=sn(E,(.5-P[0])*x,(.5-P[1])*M,0)),{m:E,w:x,h:M}}function yr(f,T,x,M,E,P,R,B,z=!1,$=null,J=null){const re=xt(M,E);let Z=re.m;if(J){const se=(J[0]+J[2]/2)*M.scale[0],ie=(J[1]+J[3]/2)*M.scale[1];Z=sn(Z,se,-ie,0),Z=xn(Z,J[2]*M.scale[0],J[3]*M.scale[1],1)}else Z=xn(Z,re.w,re.h,1);const ce=gt(P,Z),le=f===O?Pt:_e;t.useProgram(f),z?(Vt=0,t.enable(t.BLEND),M.containerAlphaMeaningful?t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA):t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Xt(M.colorBlendMode),le.blendPrep!==null&&le.blendPrep!==void 0&&t.uniform1i(le.blendPrep,Vt),Ce?(t.bindFramebuffer(t.FRAMEBUFFER,Ce.fbo.fbo),t.viewport(0,0,Ce.w,Ce.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,R,B)),t.bindVertexArray(W),ft("local",zn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,T),t.uniform1i(le.tex,0),t.uniformMatrix4fv(le.mvp,!1,ce),le.color!==null&&le.color!==void 0&&t.uniform4f(le.color,x[0],x[1],x[2],x[3]),mn(le,$),t.drawArrays(t.TRIANGLES,0,6)}function mn(f,T){!f||f.frameOrigin===null||f.frameOrigin===void 0||(T?(t.uniform2f(f.frameOrigin,T[0],T[1]),t.uniform2f(f.frameU,T[2],T[3]),t.uniform2f(f.frameV,T[4],T[5])):(t.uniform2f(f.frameOrigin,0,0),t.uniform2f(f.frameU,1,0),t.uniform2f(f.frameV,0,1)))}let pn=null,Ce=null;const dt=new Map,Ct=new Map;let gn=!0;function Wn(f,T){const x=xt(f,T),M=T&&T.perspective?f.scale[1]:-f.scale[1],E=T&&T.perspective&&f.scale[2]||1;return xn(x.m,f.scale[0],M,E)}function Vn(f,T,x,M,E,P,R){Ce?(t.bindFramebuffer(t.FRAMEBUFFER,Ce.fbo.fbo),t.viewport(0,0,Ce.w,Ce.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,M,E));const B=gt(x,Wn(f,T));pn(f,B,{time:P,overrideTex:R||null}),Wt=null}let Ht=null;function A(f,T){return Ht===null&&(Ht=t.createTexture(),t.bindTexture(t.TEXTURE_2D,Ht),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,Ht),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,f,T,0),Ht}function L(f,T,x,M,E,P,R,B){const z=A(R,B),$=xt(f,E);let J=$.m;J=xn(J,$.w,$.h,1);const re=gt(P,J),Z=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([ee,ue])=>{const ve=Bs(re,ee,ue,0);return[ve[0]*.5+.5,ve[1]*.5+.5]}),[ce,le,se,ie]=Z,F=new Float32Array([0,M,0,ce[0],ce[1],0,0,0,se[0],se[1],x,M,0,le[0],le[1],x,M,0,le[0],le[1],0,0,0,se[0],se[1],x,0,0,ie[0],ie[1]]);t.useProgram(j),yt("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,T.fbo),t.viewport(0,0,x,M),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(W),t.bindBuffer(t.ARRAY_BUFFER,K),t.bufferData(t.ARRAY_BUFFER,F,t.DYNAMIC_DRAW),Wt=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,z),t.uniform1i(Jt.tex,0),t.uniformMatrix4fv(Jt.mvp,!1,yn(0,x,0,M,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function I(f,T,x,M,E){if(!gn||Ce)return;const P=Ct.get(f.id);if(!P||P.size===0)return;const R=Math.max(1,Math.round(Math.abs(f.size[0]*(f.scale[0]||1)))),B=Math.max(1,Math.round(Math.abs(f.size[1]*(f.scale[1]||1))));if(R<=1&&B<=1)return;const z=Q(R,B,"lc:"+f.id);L(f,z,R,B,T,x,M,E);for(const $ of P)dt.set($,z);Ct.delete(f.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,M,E)}async function U(f,T,x,M,E,P,R,B){G++,t.viewport(0,0,x,M);const z=f.general||{};if(z.clearenabled!==!1){const F=Co(z.clearcolor||"0 0 0");t.clearColor(F[0],F[1],F[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),Et>=0){const F=E-Et;ze=F>0&&F<1?F:Math.min(.1,Math.max(.001,F||1/60))}Et=E;const $=Ds(f,x,M,P,R,B);let J=gt($.projection,$.view);const re=z.cameraparallax,Z=re===!0||re!==null&&typeof re=="object"&&re.value===!0;$t=0,ot=0;const ce=lt();if(ce&&(He.x=ce.u*2-1,He.y=ce.v*2-1),!$.perspective&&n.parallax!==!1&&Z){const F=(Lt,fe)=>{const ge=Lt!==null&&typeof Lt=="object"?Lt.value:Lt;return typeof ge=="number"&&Number.isFinite(ge)?ge:fe},ee=F(z.cameraparallaxamount,0),ue=F(z.cameraparallaxmouseinfluence,1),ve=F(z.cameraparallaxdelay,1),Me=E-hr;hr=E;const he=Me>0?1-Math.exp(-Me/Math.max(.05,ve)):1;He.sx+=(He.x-He.sx)*he,He.sy+=(He.y-He.sy)*he;const Re=ee*ue,Te=60,Ge=He.sx*Re*$.viewW,wt=He.sy*Re*$.viewH,Rt=Math.max(Math.abs(Ge),Math.abs(wt))/Te,en=Rt>1?1/Rt:1;$t=-(Ge*en),ot=-(wt*en)}if(!$.perspective&&n.shake!==!1){const F=fn(z,E);if(F){const ee=F.x*$.viewW*.02,ue=F.y*$.viewH*.02;(ee!==0||ue!==0)&&(J=gt(J,sn(on(),ee,ue,0)))}}if(Ze){const F=typeof Ze=="function"?Ze():Ze;F&&typeof F.syncWorld=="function"&&F.syncWorld($,0,0)}if(!D){D=!0;const F=(f.layers||[]).filter(ve=>ve.isContainer),ee=F.filter(ve=>(ve.effects||[]).some(Me=>Me.visible)&&!ve.hasChildren),ue=ee.filter(ve=>(ve.effects||[]).some(Me=>(Me.materialPasses||[]).length>0));o(`containers total=${F.length} canvasCandidates=${ee.length} passesResolved=${ue.length} names=${ee.slice(0,4).map(ve=>ve.name||"?").join("/")}`)}await X(f,T,$,x,M,E);const le=new Map;for(const F of f.layers)F.id!==void 0&&le.set(F.id,F);const se=new Set;for(const F of f.layers)!F.visible||F.destroyed||!F.isContainer||!F.hasChildren||!(F.effects||[]).some(ue=>ue.visible)||(F.childIds||[]).length===0||tr(F,le,se);if(a)try{a()}catch(F){o("particle advance error: "+(F&&F.message))}const ie=$.perspective?f.layers.slice().sort((F,ee)=>+!!ee.isSkybox-+!!F.isSkybox):f.layers;for(const F of ie)if(!(!F.visible||F.destroyed)&&!(F.isPostProcess&&!(F.effects||[]).some(ee=>ee.visible))&&!se.has(F.id)){if(F.isContainer){if(!(F.effects||[]).some(ue=>ue.visible)){I(F,$,J,x,M);continue}if(F.hasChildren){(F.childIds||[]).length>0&&await ne(F,f,T,$,J,x,M,E);continue}}if(F.particle){if(u)try{await u(F.id,$,J,x,M)}catch(ee){o("particle render error: "+(ee&&ee.message))}continue}jn(F,$)||await Y(F,T,$,J,x,M,E)}if(mr(z)&&E<kn){const F=Math.max(0,Math.min(1,E/kn)),ee=1-F*F*(3-2*F);if(ee>.002){const ue=Co(z.clearcolor||"0 0 0");t.useProgram(k),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,x,M),t.bindVertexArray(W),ft("pass",it),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Pe),t.uniform1i(_e.tex,0),t.uniform4f(_e.color,ue[0],ue[1],ue[2],ee),mn(_e,null),_e.blendPrep!==null&&_e.blendPrep!==void 0&&t.uniform1i(_e.blendPrep,0),t.uniformMatrix4fv(_e.mvp,!1,Je),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),q()}async function X(f,T,x,M,E,P){dt.clear(),Ct.clear();const R=new Map,B=new Set;let z=null;const $=J=>{if(typeof J!="string")return;const re=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(J);if(!re)return;const Z=Number(re[1]);z!==null&&Z===z&&B.add(Z);let ce=R.get(Z);ce||(ce=new Set,R.set(Z,ce)),ce.add(J)};for(const J of f.layers||[]){z=J.id;for(const re of J.effects||[])if(re.visible){for(const Z of re.passes||[])for(const ce of Z.textures||[])$(ce);for(const Z of re.materialPasses||[]){for(const ce of Z.binds||[])$(ce&&ce.name);for(const ce of Z.textures||[])$(ce)}}}if(R.size!==0){for(const[J,re]of R){const Z=(f.layers||[]).find(Te=>Te.id===J);if(!Z||Z.particle||Z.isPostProcess||B.has(J))continue;const ce=typeof Z.image=="string"?Z.image:"";if(Z.isContainer&&!Z.hasChildren&&ce.indexOf("models/util/composelayer")===0&&!(Z.effects||[]).some(Te=>Te.visible)){Ct.set(J,re);continue}const se=Math.max(1,Math.round(Math.abs(Z.size[0]*(Z.scale[0]||1)))),ie=Math.max(1,Math.round(Math.abs(Z.size[1]*(Z.scale[1]||1))));if(se<=1&&ie<=1)continue;const F=Q(se,ie,"lc:"+J);t.bindFramebuffer(t.FRAMEBUFFER,F.fbo),t.viewport(0,0,se,ie),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const ee={view:x.view,projection:yn(0,se,0,ie,-1e4,1e4),eye:x.eye,projW:se,projH:ie,offX:0,offY:0,viewW:se,viewH:ie},ue=Ce,ve=Z.origin,Me=Z.scale,he=Z.angles,Re=Z.visible;Ce={fbo:F,w:se,h:ie},Z.origin=[se/2,ee.projH-ie/2,ve[2]],Z.scale=[Math.sign(Me[0])||1,Math.sign(Me[1])||1,Me[2]],Z.angles=[0,0,0],Z.visible=!0;try{await Y(Z,T,ee,ee.projection,se,ie,P);for(const Te of re)dt.set(Te,F)}catch(Te){o(`composite \u6E90\u5C42 ${J} \u6E32\u67D3\u5931\u8D25: ${Te&&Te.message}`)}finally{Ce=ue,Z.origin=ve,Z.scale=Me,Z.angles=he,Z.visible=Re}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,M,E)}}async function ne(f,T,x,M,E,P,R,B){const z=Math.max(1,Math.round(Math.abs(f.size[0]))),$=Math.max(1,Math.round(Math.abs(f.size[1])));if((f.childIds||[]).length===0)return;const re=new Map;for(const he of T.layers)he.id!==void 0&&re.set(he.id,he);const Z=tr(f,re),ce=T.layers.filter(he=>Z.has(he.id)&&he.visible);if(ce.length===0)return;const le=Q(z,$,"group");t.bindFramebuffer(t.FRAMEBUFFER,le.fbo),t.viewport(0,0,z,$),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const se={view:M.view,projection:yn(0,z,0,$,-1e4,1e4),eye:M.eye,projW:z,projH:$,offX:0,offY:0,viewW:z,viewH:$},ie=se.projection,F=f.scale[0]||1,ee=f.scale[1]||1,ue=f.angles[2]||0,ve=Math.cos(-ue),Me=Math.sin(-ue);Ce={fbo:le,w:z,h:$};try{for(const he of ce){if(he.isPostProcess||he.particle||he.isContainer&&(he.childIds||[]).length>0)continue;const Re=he.origin,Te=he.scale,Ge=he.angles,wt=Re[0]-f.origin[0],Rt=Re[1]-f.origin[1],en=(wt*ve-Rt*Me)/F,Lt=(wt*Me+Rt*ve)/ee;he.origin=[z/2+en,$/2+Lt,Re[2]],he.scale=[Te[0]/F,Te[1]/ee,Te[2]],he.angles=[Ge[0],Ge[1],Ge[2]-ue];try{await Y(he,x,se,ie,z,$,B)}finally{he.origin=Re,he.scale=Te,he.angles=Ge}}}finally{Ce=null}f.groupTex=le.tex,f.groupW=z,f.groupH=$;try{await Y(f,x,M,E,P,R,B)}finally{f.groupTex=null}}async function Y(f,T,x,M,E,P,R){const B=!!(f.puppet&&pn),z=!f.solid&&f.textureName?T.get(f.textureName):null;if(z&&z.video){const fe=z.video;if(fe.readyState>=2&&fe.currentTime!==z.lastUploaded){t.bindTexture(t.TEXTURE_2D,z.glTex);try{let ge=fe.videoWidth||z.width,de=fe.videoHeight||z.height;const Ne=2048,Mt=t.getParameter(t.MAX_TEXTURE_SIZE),ht=Mt>0&&Mt<4096?Math.min(Ne,Mt):Ne;let Gt=1;Math.max(ge,de)>ht&&(Gt=ht/Math.max(ge,de));const mt=Math.max(1,Math.round(ge*Gt)),$e=Math.max(1,Math.round(de*Gt));let xr=fe;if(i&&mt>0&&$e>0){(i.width!==mt||i.height!==$e)&&(i.width=mt,i.height=$e);const Ft=i.getContext("2d");Ft&&(Ft.clearRect(0,0,mt,$e),Ft.drawImage(fe,0,0,mt,$e),xr=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,xr),t.getError()!==t.NO_ERROR&&i)try{const Yt=i.getContext("2d").getImageData(0,0,i.width,i.height);for(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i.width,i.height,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(Yt.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}z.width=mt,z.height=$e,z.lastUploaded=fe.currentTime,s||(s=!0,o("video tex ready "+mt+"x"+$e+" (src "+ge+"x"+de+")"))}catch(ge){s||(s=!0,o("video upload FAIL: "+(ge&&ge.message||ge))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",ge&&ge.message,"readyState=",fe.readyState,"cur=",fe.currentTime)}}}const $=f.groupTex?f.groupTex:z&&z.glTex?z.glTex:f.solid?Pe:Ae,J=(!!f.passthrough||!!f.isPostProcess||No(f))&&!f.groupTex&&!z&&!B;let re,Z;if(f.groupTex?(re=f.groupW||f.size[0],Z=f.groupH||f.size[1]):B||!z?(re=f.size[0],Z=f.size[1]):(re=z.width,Z=z.height),!B&&z&&f.spriteSheet){const fe=z.frames,ge=Array.isArray(fe)?fe:fe&&fe.list;ge&&ge.length&&(re=ge[0].width||re,Z=ge[0].height||Z)}const ce=Math.max(1,Math.round(re)),le=Math.max(1,Math.round(Z)),se=[f.color[0]*f.brightness,f.color[1]*f.brightness,f.color[2]*f.brightness,f.alpha],ie=(f.effects||[]).filter(fe=>fe.visible);let F=ce,ee=le;if(c>0&&x.projW>0&&x.projH>0){const fe=Math.min(Math.abs(f.size[0]*f.scale[0]),x.viewW),ge=Math.min(Math.abs(f.size[1]*f.scale[1]),x.viewH),de=fe*(E/x.projW),Ne=ge*(P/x.projH);if(de>0&&Ne>0){const Mt=Math.max(64,Math.round(de*c)),ht=Math.max(64,Math.round(Ne*c));Mt<ce&&(F=Mt),ht<le&&(ee=ht)}}if(ie.length===0){B?Vn(f,x,M,E,P,R):yr(k,$,se,f,x,M,E,P,!1,vr(f,z,R));return}const ue=Q(F,ee,"ping"),ve=Q(F,ee,"pong"),Me=yn(0,F,0,ee,-1e4,1e4);if(B)t.useProgram(k),yt("normal"),t.bindFramebuffer(t.FRAMEBUFFER,ue.fbo),t.viewport(0,0,F,ee),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(W),Wt=null,ft("layer"+F+"x"+ee,jt(F,ee)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,$),t.uniform1i(_e.tex,0),t.uniform4f(_e.color,1,1,1,1),mn(_e,null),_e.blendPrep!==null&&_e.blendPrep!==void 0&&t.uniform1i(_e.blendPrep,0),t.uniformMatrix4fv(_e.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6);else if(J)L(f,ue,F,ee,x,M,E,P);else{t.useProgram(k),yt("normal"),t.bindFramebuffer(t.FRAMEBUFFER,ue.fbo),t.viewport(0,0,F,ee),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(W),ft("layer"+F+"x"+ee,jt(F,ee)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,$),t.uniform1i(_e.tex,0);const fe=ie.some(ge=>ge&&ge.layerMaterial)?[1,1,1,se[3]]:se;t.uniform4f(_e.color,fe[0],fe[1],fe[2],fe[3]),mn(_e,vr(f,z,R)),_e.blendPrep!==null&&_e.blendPrep!==void 0&&t.uniform1i(_e.blendPrep,0),t.uniformMatrix4fv(_e.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6)}let he=ue,Re=ve;const Te=new Map;let Ge=!1,wt=ue;const Rt=[],en=new Set;for(const fe of ie){for(const de of fe.fbos||[])if(!Te.has(de.name)){const[Ne,Mt]=Uo(de,F,ee),ht=de.unique?f.id+":"+de.name:de.name;Te.set(de.name,Q(Ne,Mt,ht))}const ge=fe.materialPasses||[];for(let de=0;de<ge.length;de++)Rt.push({eff:fe,mp:ge[de],ov:fe.passes&&fe.passes[de]})}const Lt=[];for(let fe=0;fe<Rt.length;fe++){const{eff:ge,mp:de,ov:Ne}=Rt[fe];if(en.has(ge))continue;const Mt={...de.combos||{},...Ne&&Ne.combos||{}},ht=de.textures||[],Gt=Ne&&Ne.textures||[],mt=[];for(let ye=0;ye<Math.max(ht.length,Gt.length);ye++)Gt[ye]!==void 0&&Gt[ye]!==null?mt[ye]=Gt[ye]:mt[ye]=ht[ye]!==void 0?ht[ye]:null;if(de.copyCommand){const ye=de.source?Te.get(de.source):null,je=de.target?Te.get(de.target):null;ye&&je&&(t.useProgram(O),yt("normal"),t.bindFramebuffer(t.FRAMEBUFFER,je.fbo),t.viewport(0,0,je.width,je.height),t.bindVertexArray(W),ft("pass",it),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,ye.tex),t.uniform1i(Pt.tex,0),Pt.blendPrep!==null&&Pt.blendPrep!==void 0&&t.uniform1i(Pt.blendPrep,0),t.uniformMatrix4fv(Pt.mvp,!1,Je),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let $e;try{$e=await Xe(de.shader,Mt,mt)}catch(ye){console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",de.shader,ye&&ye.message||ye),en.add(ge);continue}const xr=$e.prog,Ft=$e.uni;$e.fragGlsl&&Lt.push($e.fragGlsl);let Yt,Xn;de.target?(Ge||(wt=he,Ge=!0),Yt=Te.get(de.target)||he,Xn=wt):(Ge=!1,Yt=Re,Xn=he),t.useProgram(xr),yt(de.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,Yt.fbo),t.viewport(0,0,Yt.width,Yt.height),t.bindVertexArray(W),ft("pass",it);const no=de.textures||[],sl=Math.max(no.length,8),ji=new Map,al=new Set;for(let ye=0;ye<sl;ye++){let je=ye<no.length?no[ye]:null;Ne&&Ne.textures&&Ne.textures[ye]!==void 0&&Ne.textures[ye]!==null&&(je=Ne.textures[ye]);for(const Gn of de.binds||[])Gn.index===ye&&(je=Gn.name);let _t;if(ye===0&&(je==null||je===""))_t=Xn;else{if((je==null||je==="")&&$e.samplerDefaults){const Gn=$e.samplerDefaults.get(ye);Gn&&(je=Gn)}_t=Qt(je,Xn,Te,T)}je==="previous"&&(_t=Xn),_t===null&&(_t={glTex:Pe,width:1,height:1,tex:Pe});const Hn=_t.fbo?_t:{tex:_t.glTex||Pe,width:_t.width||1,height:_t.height||1};t.activeTexture(t.TEXTURE0+ye),t.bindTexture(t.TEXTURE_2D,Hn.tex),al.add(ye),ji.set(ye,[Hn.width,Hn.height,Hn.width,Hn.height])}gr(Ft,f,R,x.projW,x.projH,Je,Me,Je,ji,Me,x),dn(Ft,Dn(ut({...de.constants||{},...Ne&&Ne.constantshadervalues||{}},(f.id||f.name||"?")+"|"+(de.shader||"?")+"|"+fe,R,f),(f.id||f.name||"?")+"|"+(de.shader||"?")+"|"+fe,R),$e.matMeta),hn(Ft),t.drawArrays(t.TRIANGLES,0,6),de.target||(Re=he,he=Yt)}if(f.isContainer&&!f.groupTex&&!J&&f.containerAlphaMeaningful===void 0){let fe=!1;for(const ge of Lt){if(typeof ge!="string")continue;const de=ge.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(de&&!/^\s*scene\s*\.\s*a\s*$/.test(de[1])){fe=!0;break}}f.containerAlphaMeaningful=fe,o(`container "${f.name||"?"}" alpha ${fe?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if(B){Vn(f,x,M,E,P,R,he.tex);return}yr(O,he.tex,[1,1,1,1],f,x,M,E,P,!!f.isContainer&&!f.groupTex&&!J,null,null)}return{gl:t,render:U,getFBO:Q,getEffectProgram:Xe,progCache:te,shaderResolver:r,whiteTex:Pe,resetShaderCaches:function(){te.clear(),me.clear(),xe&&xe.clear()},setFboCapFactor:function(f){c=f},setParticleRenderer:function(f,T){a=typeof f=="function"?f:null,u=typeof T=="function"?T:null},setConstantScriptRuntime:N,applyConstUserProperties:function(f){if(f){for(const T of S.values())if(T&&typeof T.applyUserProperties=="function")try{T.applyUserProperties(f)}catch{}}},constantScriptStats:function(){return{...C,cached:S.size}},setCompositeEnabled:function(f){gn=!!f},compositeStats:function(){const f=[],T=new Uint8Array(4);for(const[x,M]of dt){let E=null;try{t.bindFramebuffer(t.FRAMEBUFFER,M.fbo),t.readPixels(M.w>>1,M.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,T),E=[T[0],T[1],T[2],T[3]]}catch{}f.push({name:x,w:M.w,h:M.h,center:E})}return t.bindFramebuffer(t.FRAMEBUFFER,null),f},setPuppetRenderer:function(f){pn=f},setAudioProvider:h,setPointerProvider:to,getParallaxOffset:function(){return{x:$t,y:ot}},dispose:function(){try{const f=t.getExtension("WEBGL_lose_context");f&&f.loseContext()}catch{}}}}const ca=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:Eo,XRAY_IDLE_SCREEN_UV:_n,applyColorBlendCPU:oa,collectGroupDescendantIds:tr,colorBlendPlan:kr,createRenderer:aa,effectFboSize:Uo,layerWantsPreserveBackdrop:No,makeTexture:Nr,makeTextureMip:Js,puppetAnimMargin:Fo,rewriteXrayFragScale:ko,xrayShouldParkPointer:Br,xrayUvScale:ia},Symbol.toStringTag,{value:"Module"}));function la(e=256,n=8){const t=e/n,r=Bo(1337),o=Bo(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let u=0;u<t*t;u++)i[u]=r(),s[u]=o();const c=new Uint8Array(e*e*4),a=n;for(let u=0;u<e;u++){const l=Math.floor(u/a),d=u%a/a,h=d*d*(3-2*d);for(let p=0;p<e;p++){const w=Math.floor(p/a),m=p%a/a,g=m*m*(3-2*m),v=w%t,b=(w+1)%t,y=l%t,S=(l+1)%t,_=i[y*t+v],C=i[y*t+b],N=i[S*t+v],D=i[S*t+b],k=s[y*t+v],O=s[y*t+b],j=s[S*t+v],W=s[S*t+b],K=_+(C-_)*g+(N-_)*h+(_-C-N+D)*g*h,V=k+(O-k)*g+(j-k)*h+(k-O-j+W)*g*h,G=(u*e+p)*4;c[G]=Math.round(K*255),c[G+1]=Math.round(V*255),c[G+2]=0,c[G+3]=255}}return c}function Bo(e){let n=e>>>0;return()=>{n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const ua=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:la},Symbol.toStringTag,{value:"Module"})),at=Math.PI*2;function Le(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function Io(e,n,t){if(e==null)return Math.random();if(n==null)return e;const r=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+r*(n-e)}function be(e,n){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e==null)return n?n.slice():[0,0,0];if(typeof e=="object")return be(e.value,n);if(typeof e=="number")return[e,e,e];const t=String(e).trim().split(/\s+/).map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function Oo(e){return e==null?null:typeof e=="number"?[e,e,e]:be(e)}function H(e,n){if(e==null)return n;if(typeof e=="object")return H(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function Ir(e,n){const t=e[0],r=e[1]>t?e[1]:t+1e-6,o=Math.min(1,Math.max(0,(n-t)/(r-t)));return o*o*(3-2*o)}function Bt(e,n,t){const r=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return r-Math.floor(r)}function fa(e,n,t){const r=Math.floor(e),o=Math.floor(n),i=Math.floor(t),s=e-r,c=n-o,a=t-i,u=s*s*(3-2*s),l=c*c*(3-2*c),d=a*a*(3-2*a),h=(v,b,y)=>v+(b-v)*y,p=h(Bt(r,o,i),Bt(r+1,o,i),u),w=h(Bt(r,o+1,i),Bt(r+1,o+1,i),u),m=h(Bt(r,o,i+1),Bt(r+1,o,i+1),u),g=h(Bt(r,o+1,i+1),Bt(r+1,o+1,i+1),u);return h(h(p,w,l),h(m,g,l),d)}function Or(e,n,t,r){let o=0,i=.5,s=1,c=0;for(let a=0;a<r;a++)o+=i*fa(e*s,n*s,t*s),c+=i,i*=.5,s*=2;return o/(c||1)}function Dr(e,n,t,r){return[Or(e,n,t,r)*2-1,Or(e+31.7,n+11.3,t+57.1,r)*2-1,Or(e+73.9,n+92.1,t+13.7,r)*2-1]}function da(e){const n=`#version 300 es
63
+ }`;function ia(e,n){return new Float32Array([0,n,0,0,1,0,0,0,0,0,e,n,0,1,1,e,n,0,1,1,0,0,0,0,0,e,0,0,1,0])}function sa(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,1,0,1,1,-1,-1,0,0,0,1,-1,0,1,0])}function aa(){return new Float32Array([-.5,.5,0,0,1,-.5,-.5,0,0,0,.5,.5,0,1,1,.5,.5,0,1,1,-.5,-.5,0,0,0,.5,-.5,0,1,0])}const ca={5126:"float",35664:"vec2",35665:"vec3",35666:"vec4",5124:"int",35667:"ivec2",35668:"ivec3",35669:"ivec4",35670:"bool",35676:"mat4",35675:"mat3"};function Jn(e,n,t){const o=ko(e,e.VERTEX_SHADER,n),r=ko(e,e.FRAGMENT_SHADER,t),i=e.createProgram();if(e.attachShader(i,o),e.attachShader(i,r),e.bindAttribLocation(i,0,"a_Position"),e.bindAttribLocation(i,1,"a_TexCoord"),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("\u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(i));return i}function ko(e,n,t){const o=e.createShader(n);if(e.shaderSource(o,t),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new Error("\u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(o));return o}function Uo(e){e!==null&&typeof e=="object"&&"value"in e&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return[n[0]||0,n[1]||0,n[2]||0]}function Ir(e,n,t,o,r=null){const i=e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),r?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,o,0,e.RGBA,e.UNSIGNED_BYTE,n),i}function la(e,n,t=!1){const o=e.createTexture();e.bindTexture(e.TEXTURE_2D,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);const r=n[0];if(r.bitmap)e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,r.bitmap);else if(t&&r.rgba){const i=r.width*r.height,s=new Uint8Array(i*2);for(let a=0;a<i;a++)s[a*2]=r.rgba[a*4+3],s[a*2+1]=r.rgba[a*4];const c=e.getParameter(e.UNPACK_ALIGNMENT);e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG8,r.width,r.height,0,e.RG,e.UNSIGNED_BYTE,s),e.pixelStorei(e.UNPACK_ALIGNMENT,c)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r.width,r.height,0,e.RGBA,e.UNSIGNED_BYTE,r.rgba);return e.generateMipmap(e.TEXTURE_2D),o}function Br(e,n,t,o,r){const i=1-r;return i*i*i*e+3*i*i*r*n+3*i*r*r*t+r*r*r*o}function ua(e,n,t,o,r){if(r<=e)return 0;if(r>=o)return 1;let i=o-e>1e-9?(r-e)/(o-e):.5;for(let a=0;a<8;a++){const f=Br(e,n,t,o,i)-r;if(Math.abs(f)<1e-6)return i;const l=1-i,d=3*l*l*(n-e)+6*l*i*(t-n)+3*i*i*(o-t);if(Math.abs(d)<1e-9)break;const h=i-f/d;if(h<0||h>1||!Number.isFinite(h))break;i=h}let s=0,c=1;for(let a=0;a<40;a++)i=(s+c)/2,Br(e,n,t,o,i)<r?s=i:c=i;return i}function er(e,n,t){if(!e||e.length===0)return 0;if(e.length===1)return Number(e[0].value)||0;if(t&&t.length>0){const B=e[0],z=e[e.length-1],V=t.length-z.frame;if(V>1e-9&&n>z.frame&&n<=t.length)return er([{frame:0,value:z.value,front:z.front,back:z.back},{frame:V,value:B.value,front:B.front,back:B.back}],n-z.frame)}if(n<=e[0].frame)return Number(e[0].value)||0;const o=e[e.length-1];if(n>=o.frame)return Number(o.value)||0;let r=0,i=e.length-1;for(;i-r>1;){const B=r+i>>1;e[B].frame<=n?r=B:i=B}const s=e[r],c=e[i],a=s.frame,f=c.frame,l=Number(s.value)||0,d=Number(c.value)||0,h=f-a;if(h<=0)return d;const m=s.front,M=c.back,g=h/3,y=!!(m&&m.enabled),b=!!(M&&M.enabled),p=y?Math.abs(Number(m.x)||0):1,v=b?Math.abs(Number(M.x)||0):1,_=a+Math.min(p,1.5)*g,w=f-Math.min(v,1.5)*g,L=y?l+(Number(m.y)||0):l+(d-l)/3,F=b?d+(Number(M.y)||0):d-(d-l)/3,D=ua(a,_,w,f,n);return Br(l,L,F,d,D)}function Io(e,n,t){const o=n>0?n:1;if(t==="loop"){let r=e%o;return r<0&&(r+=o),r}if(t==="mirror"){const r=o*2;let i=e%r;return i<0&&(i+=r),i<=o?i:r-i}return Math.max(0,Math.min(o,e))}function fa(e){return Array.isArray(e)?e:typeof e=="string"?e.trim().split(/\s+/).map(Number):Number.isFinite(e)?[e]:[]}function Bo(e){const n=e&&e.options||{},t=Number(n.fps)>0?Number(n.fps):30,o=Number(n.length)>0?Number(n.length):0,r=n.mode==="loop"||n.mode==="mirror"?n.mode:"single",i=typeof n.name=="string"?n.name:"",s=!!(e&&e.relative),c=n.wraploop===!0&&r==="loop",a=[];for(let h=0;;h++){const m=e&&e["c"+h];if(!Array.isArray(m))break;a.push(m)}const f=n.startpaused!==!0,l=[],d={name:i,mode:r,fps:t,relative:s,channelCount:a.length,frame:0,rate:1,playing:f,ended:!1,get frameCount(){return o},play(){return d.playing=!0,d.ended=!1,d},pause(){return d.playing=!1,d},stop(){return d.playing=!1,d.frame=0,d.ended=!1,d},setFrame(h){const m=Number(h);return Number.isFinite(m)&&(d.frame=m),d},getFrame(){return d.frame},setRate(h){const m=Number(h);return Number.isFinite(m)&&(d.rate=m),d},addEndedCallback(h){return typeof h=="function"&&l.push(h),d},setBlend(){return d},setVisible(){return d},advance(h){if(d.playing&&(d.frame+=(Number(h)||0)*t*d.rate,r==="single"))if(d.frame>=o){if(d.frame=o,d.playing=!1,!d.ended){d.ended=!0;for(const m of l)try{m()}catch{}}}else d.frame<0&&(d.frame=0,d.playing=!1)},value(){const h=Io(d.frame,o,r),m=c?{length:o}:void 0;if(a.length===1)return er(a[0],h,m);const M=[];for(const g of a)M.push(er(g,h,m));return M},applyTo(h){const m=d.value();if(!s)return m;const M=fa(h);return Array.isArray(m)?m.map((g,y)=>g+(Number(M[y])||0)):m+(Number(M[0])||0)}};return d}function da(){const e={name:"",mode:"single",fps:30,relative:!1,channelCount:0,frame:0,rate:1,playing:!1,ended:!1,get frameCount(){return 0},play(){return e},pause(){return e},stop(){return e},setFrame(){return e},getFrame(){return 0},setRate(){return e},addEndedCallback(){return e},setBlend(){return e},setVisible(){return e},advance(){},value(){return 0},applyTo(n){return n}};return e}const ha=Object.freeze(Object.defineProperty({__proto__:null,createAnimation:Bo,createNeutralAnimation:da,sampleChannel:er,wrapFrame:Io},Symbol.toStringTag,{value:"Module"}));function Oo(e){const n=e&&e.puppet&&e.puppet.animBound;return n?[n.x*Math.abs(e.scale[0]),n.y*Math.abs(e.scale[1])]:[0,0]}function Do(e){for(const n of e&&e.effects||[]){if(n.visible===!1)continue;const t=Math.max((n.passes||[]).length,(n.materialPasses||[]).length);for(let o=0;o<t;o++){const r=n.passes&&n.passes[o]&&n.passes[o].combos||{},i=n.materialPasses&&n.materialPasses[o]&&n.materialPasses[o].combos||{},s=r.TRANSPARENCY!==void 0?r.TRANSPARENCY:i.TRANSPARENCY;if(Number(s)===0)return!0}}return!1}function tr(e,n,t){if(t||(t=new Set),!n)return t;for(const o of e.childIds||[]){const r=n.get(o);!r||r.particle||r.isPostProcess||(t.add(o),tr(r,n,t))}return t}function Or(e){const n=ea[e]||"translucent";return{mode:n,prep:ta[n]||0}}function ma(e,n,t,o){const{mode:r,prep:i}=Or(e);let s=t;return i===1?s=t*o:i===2&&(s=1-o+t*o),r==="screen"?s+n*(1-s):r==="multiply"?n*s:r==="additive"?n+t*o:n*(1-o)+t*o}function $o(e,n,t){const o=e&&Number(e.scale)||1;let r=Math.max(1,Math.round(n/o)),i=Math.max(1,Math.round(t/o));const s=e&&Number(e.fit);if(Number.isFinite(s)&&s>0){const c=Math.max(r,i);if(c>s){const a=s/c;r=Math.max(1,Math.round(r*a)),i=Math.max(1,Math.round(i*a))}}return[r,i]}function pa(e){const n=Number(e);return!Number.isFinite(n)||n<.001?999:1/n}const An=-1;function Dr(e,n){return!!n&&!e}const ga="mix(999.0, 1.0 / max(g_PointerScale, 0.001), step(0.001, g_PointerScale))";function zo(e){if(typeof e!="string"||/unprojectedUVs\s*\*=\s*mix\(999\.0,\s*1\.0\s*\/\s*max\(\s*g_PointerScale/.test(e))return e;const n=/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/.test(e),t=/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/.test(e);if(!n&&!t)return e;let o=e;/uniform\s+float\s+g_PointerScale\b/.test(o)||(o=o.replace(/void\s+main\s*\(/,`uniform float g_PointerScale;
64
+ void main(`));const r=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return o.replace(r,"unprojectedUVs *= "+ga+" *")}function ba(e,n={}){const t=e.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0});if(!t)throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebGL2");const o=n.shaderResolver||(async()=>null),r=n.diag||(()=>{}),i=typeof document<"u"?document.createElement("canvas"):null;i&&(i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0");let s=!1,c=n.fboCapFactor===void 0?0:n.fboCapFactor,a=null,f=null,l=null;const d=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function h(u){l=u||null}let m=null,M=null,g=null,y=null,b=null,p=null,v=null;const _=new Map,w=new Map,L={total:0,ok:0,failed:0};function F(u,x){m=typeof u=="function"?u:null,M=x&&x.userProperties||null,g=x&&x.audioViews||null,y=x&&x.shared||null,b=x&&x.inputView||null,p=x&&x.timers||null,v=x&&typeof x.onSandbox=="function"?x.onSandbox:null,_.clear(),w.clear()}let D=!1;const B=Jn(t,Ur,na),z=Jn(t,Ur,ra),V=Jn(t,Ur,oa),Y=t.createVertexArray();t.bindVertexArray(Y);const Z=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,Z),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,2,t.FLOAT,!1,20,12),t.bindVertexArray(null);const X=new Map;let q=1;function oe(u,x,S){const P=(S||"")+"|"+u+"x"+x;if(X.has(P)){const $=X.get(P);return $.stamp=q,$}const I=t.createFramebuffer(),N=t.createTexture();t.bindTexture(t.TEXTURE_2D,N),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,u,x,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,I),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,N,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const E={fbo:I,tex:N,width:u,height:x,stamp:q};return X.set(P,E),E}function H(){for(const[u,x]of X)x.stamp!==q&&(x.fbo&&t.deleteFramebuffer(x.fbo),x.tex&&t.deleteTexture(x.tex),X.delete(u))}const j=new Map,ee=new Map,le=new Map;function Se(u){const x={},S=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let P;for(;(P=S.exec(u))!==null;){const I=P[1],N=P[2],E=/"material"\s*:\s*"([^"]+)"/.exec(N);if(!E)continue;const $=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(N);x[E[1]]={uniform:I,default:$?Pe($[1]):void 0}}return x}function Xe(u){const x=new Map,S=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let P;for(;(P=S.exec(u))!==null;){const I=Number(P[1]),N=/"default"\s*:\s*"([^"]+)"/.exec(P[2]);N&&N[1]&&x.set(I,N[1])}return x}function Le(u){const x=[],S=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let P;for(;(P=S.exec(u))!==null;){const I=/"combo"\s*:\s*"([^"]+)"/.exec(P[3]);I&&x.push({slot:Number(P[2]),name:P[1],combo:I[1]})}return x}function Pe(u){if(u.startsWith('"'))return u.slice(1,-1);const x=Number(u);return Number.isFinite(x)?x:void 0}async function ue(u,x,S){let P=le.get(u);if(P===void 0){const E=await o("shaders/"+u+".frag")||"",$=await o("shaders/"+u+".vert")||"";P={frag:E,vert:$,texCombos:Le(E)},le.set(u,P)}const I={...x};for(const E of P.texCombos)S&&S[E.slot]&&I[E.combo]===void 0&&(I[E.combo]=1);const N=u+"|"+JSON.stringify(I);if(j.has(N)){const E=j.get(N);if(E===null)throw new Error("shader="+u+" \u7F16\u8BD1\u5931\u8D25\uFF08\u5DF2\u7F13\u5B58\uFF09");return E}for(let E=0;E<4;E++){const $=new Set,A=k=>ee.has(k)?ee.get(k):($.add(k),null),R=zo(Fo(P.frag,"frag",I,A,P.vert)),C=Fo(P.vert,"vert",I,A,P.frag);if($.size===0){let k;try{k=Jn(t,C,R)}catch(O){throw j.set(N,null),new Error("shader="+u+" "+(O&&O.message))}const U=new Map,W=t.getProgramParameter(k,t.ACTIVE_UNIFORMS);for(let O=0;O<W;O++){const K=t.getActiveUniform(k,O),se=K.name.replace(/\[0\]$/,"");U.set(se,{loc:t.getUniformLocation(k,K.name),type:ca[K.type]||"unknown",size:K.size})}const J={...Se(P.vert),...Se(P.frag)},Q=new Map([...Xe(P.vert),...Xe(P.frag)]),te={prog:k,uni:U,matMeta:J,samplerDefaults:Q,fragGlsl:R,vertGlsl:C};return j.set(N,te),te}await Promise.all(Array.from($).map(async k=>{ee.set(k,await o("shaders/"+k)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+u)}const Fe=Ir(t,new Uint8Array([255,255,255,255]),1,1),Je=Ir(t,new Uint8Array([0,0,0,0]),1,1);let Ee=null;function xe(u){Ee=u||null}function Ne(){if(!Ee)return null;const u=typeof Ee=="function"?Ee():Ee;return u&&u.state?u.state:u}const we={x:0,y:0,sx:0,sy:0};let Ge=0,fe=0,Ye=0,$t=1/60,et=-1;const qt=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,pr=(u,x)=>{const S=u!==null&&typeof u=="object"?u.value:u;return S===!0||S===1?!0:S===!1||S===0?!1:x},Bn=(u,x)=>{const S=u!==null&&typeof u=="object"?u.value:u;return typeof S=="number"&&Number.isFinite(S)?S:x},Zt=u=>n.fade!==!1&&pr(u.camerafade,!1);function qe(u,x){if(!pr(u.camerashake,!1))return null;const S=Bn(u.camerashakeamplitude,0);if(S===0)return null;const P=Math.max(0,Math.min(1,Bn(u.camerashakeroughness,0))),I=Bn(u.camerashakespeed,1),N=x*I,E=Math.sin(N*2.1)*Math.cos(N*.7),$=Math.cos(N*1.7)*Math.sin(N*.9),A=Math.sin(N*11.3)*Math.cos(N*7.1),R=Math.cos(N*9.7)*Math.sin(N*13.1);return{x:(E*(1-P)+A*P)*S,y:($*(1-P)+R*P)*S}}function zt(){const u=new Date;return(u.getHours()*3600+u.getMinutes()*60+u.getSeconds())/86400}function ye(u,x,S){const P=u.get(x);P&&P.loc!==null&&S(P.loc,P.type,P.size)}function ln(u){if(typeof u=="number")return[u,u,u,u];const x=String(u).trim().split(/[\s,]+/).map(Number);return[x[0]||0,x[1]||0,x[2]||0,x[3]||0]}function gr(u,x,S){const P=u.get(x);if(!P||P.loc===null)return;const I=S&&S.value!==void 0?S.value:S,N=ln(I);switch(P.type){case"float":t.uniform1f(P.loc,N[0]);break;case"int":case"bool":t.uniform1i(P.loc,I===!0||I===1?1:Math.round(N[0]));break;case"vec2":t.uniform2f(P.loc,N[0],N[1]);break;case"vec3":t.uniform3f(P.loc,N[0],N[1],N[2]);break;case"vec4":t.uniform4f(P.loc,N[0],N[1],N[2],N[3]);break;case"mat4":t.uniformMatrix4fv(P.loc,!1,tt);break;case"mat3":t.uniformMatrix3fv(P.loc,!1,yr);break}}const br=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function un(u,x,S,P,I,N,E,$,A,R,C){if(ye(u,"g_Time",O=>t.uniform1f(O,S)),ye(u,"g_Daytime",O=>t.uniform1f(O,zt())),ye(u,"g_ModelViewProjectionMatrix",O=>t.uniformMatrix4fv(O,!1,N)),ye(u,"g_ModelMatrix",O=>t.uniformMatrix4fv(O,!1,E)),ye(u,"g_ViewProjectionMatrix",O=>t.uniformMatrix4fv(O,!1,$)),u.get("g_ModelViewProjectionMatrixInverse")){let O=null;for(const[se,ge]of A)se===0&&(O=ge);const K=O&&O[0]>0&&O[1]>0?Ds(xn(rn(),O[0]/2,O[1]/2,1)):tt;ye(u,"g_ModelViewProjectionMatrixInverse",se=>t.uniformMatrix4fv(se,!1,K))}ye(u,"g_Brightness",O=>t.uniform1f(O,x.brightness)),ye(u,"g_UserAlpha",O=>t.uniform1f(O,x.alpha)),ye(u,"g_Alpha",O=>t.uniform1f(O,x.alpha)),ye(u,"g_Color",O=>t.uniform3f(O,x.color[0],x.color[1],x.color[2])),ye(u,"g_Color4",O=>t.uniform4f(O,x.color[0],x.color[1],x.color[2],1)),ye(u,"g_CompositeColor",O=>t.uniform3f(O,x.color[0],x.color[1],x.color[2])),ye(u,"g_TexelSize",O=>t.uniform2f(O,1/P,1/I)),ye(u,"g_TexelSizeHalf",O=>t.uniform2f(O,.5/P,.5/I)),ye(u,"g_TextureReductionScale",O=>t.uniform1f(O,1));const k=Ne(),U=Dr(!!(k&&k.has),!!u.get("g_PointerScale"));let W=U?An:k?k.u:.5,J=U?An:k?k.v:.5,Q=U?An:k?k.lastU:.5,te=U?An:k?k.lastV:.5;if(C&&x&&x.size&&x.size[0]>0&&x.size[1]>0){const O=Math.abs(x.size[0]*x.scale[0]),K=Math.abs(x.size[1]*x.scale[1]);if(O>0&&K>0){const se=x.origin[0]-O/2,ge=C.projH-x.origin[1]-K/2,Me=Ae=>(C.offX+Ae*C.viewW-se)/O,ie=Ae=>(C.offY+Ae*C.viewH-ge)/K;W=Me(W),J=ie(J),Q=Me(Q),te=ie(te)}}ye(u,"g_PointerPosition",O=>t.uniform2f(O,W,J)),ye(u,"g_PointerPositionLast",O=>t.uniform2f(O,Q,te)),ye(u,"g_PointerState",O=>t.uniform4f(O,W,J,k&&k.leftDown?1:0,0)),ye(u,"g_ParallaxPosition",O=>t.uniform2f(O,we.sx*.5+.5,we.sy*.5+.5)),ye(u,"g_Frametime",O=>t.uniform1f(O,$t)),u.get("g_EffectTextureProjectionMatrixInverse")&&ye(u,"g_EffectTextureProjectionMatrixInverse",O=>t.uniformMatrix4fv(O,!1,tt));for(let O=0;O<8;O++)ye(u,"g_Texture"+O,K=>t.uniform1i(K,O));for(const[O,K]of A)ye(u,"g_Texture"+O+"Resolution",se=>t.uniform4f(se,K[0],K[1],K[2],K[3]));if(l){const O=typeof l=="function"?l():l;if(O)for(const[K,se]of d){const ge=O[se];ge&&ye(u,K,Me=>t.uniform1fv(Me,ge))}}}function so(u,x,S){for(const[P,I]of Object.entries(x||{})){const N=S&&S[P];N&&gr(u,N.uniform,I)}for(const[P,I]of Object.entries(S||{}))(!x||!(P in x))&&I.default!==void 0&&gr(u,I.uniform,I.default)}function On(u){const x=Ne();Dr(!!(x&&x.has),!!u.get("g_PointerScale"))&&ye(u,"g_PointerScale",S=>t.uniform1f(S,0))}function Dn(u,x,S,P){if(!u)return u;let I=!1;for(const E of Object.values(u))if(E!==null&&typeof E=="object"&&typeof E.script=="string"){I=!0;break}if(!I||!m)return u;const N={...u};for(const[E,$]of Object.entries(u)){if($===null||typeof $!="object"||typeof $.script!="string")continue;const A=x+"|"+E;let R=_.get(A);if(R===void 0){L.total++;try{R=m($.script,$.scriptproperties||$.scriptProperties||null,{userProperties:M||{},audioViews:g||void 0,layer:P||null,shared:y||{},inputView:b||void 0,setTimeout:p?p.setTimeout:void 0,clearTimeout:p?p.clearTimeout:void 0,setInterval:p?p.setInterval:void 0,clearInterval:p?p.clearInterval:void 0})}catch{R=null}if(R?L.ok++:L.failed++,_.set(A,R),R){const Q=$.value!==void 0?$.value:$,te=ln(Q),K=typeof Q=="number"?te[0]:{x:te[0],y:te[1],z:te[2]};R.init&&R.init(K)}if(R&&typeof R.applyUserProperties=="function")try{R.applyUserProperties(M||{})}catch{}if(R&&R.hasMediaHook&&v)try{v(R)}catch{}}if(!R||R.disabled||!R.hasUpdate)continue;if(R.engine){R.engine.runtime=S,R.engine.frametime=$t,R.engine.timeOfDay=zt();const Q=Ne();Q&&Q.screenW&&Q.screenH&&(R.engine.screenResolution={x:Q.screenW,y:Q.screenH})}const C=ln($.value!==void 0?$.value:$),U=typeof($.value!==void 0?$.value:$)=="number"?C[0]:{x:C[0],y:C[1],z:C[2]};let W;try{W=R.callUpdate(U)}catch{W=void 0}const J=W??U;if(typeof J=="number"&&Number.isFinite(J))N[E]=J;else if(J&&typeof J=="object"){const Q=Number(J.x),te=Number(J.y),O=Number(J.z);Number.isFinite(Q)&&Number.isFinite(te)&&(N[E]=Number.isFinite(O)?`${Q} ${te} ${O}`:`${Q} ${te} 0`)}}return N}function Ct(u,x,S){if(!u)return u;let P=!1;for(const N of Object.values(u))if(N&&typeof N=="object"&&N.animation&&N.animation.options){P=!0;break}if(!P)return u;const I={...u};for(const[N,E]of Object.entries(u)){if(!E||typeof E!="object"||!E.animation||!E.animation.options)continue;const $=x+"|anim|"+N;let A=w.get($);if(!A){const R=Bo(E.animation),C=E.value!==void 0?E.value:0;R.baseNumeric=Array.isArray(C)?C.slice():C,A={ctrl:R},w.set($,A)}A.ctrl.playing&&A.ctrl.setFrame(S*A.ctrl.fps*A.ctrl.rate),I[N]=A.ctrl.applyTo(A.ctrl.baseNumeric)}return I}function $n(u,x,S,P){return u==null||u===""?null:u.startsWith("_rt_")?u.startsWith("_rt_imageLayerComposite")?jn&&Vt.has(u)?Vt.get(u):x:S.has(u)?S.get(u):null:S.has(u)?S.get(u):P.get(u)||null}const fn=sa(),dn=aa(),Kt=new Map;function it(u,x){const S=u+"x"+x;let P=Kt.get(S);return P===void 0&&(P=ia(u,x),Kt.set(S,P)),P}let Rt=null;function st(u,x){Rt!==u&&(t.bindBuffer(t.ARRAY_BUFFER,Z),t.bufferData(t.ARRAY_BUFFER,x,t.DYNAMIC_DRAW),Rt=u)}const pe={mvp:t.getUniformLocation(B,"u_MVP"),tex:t.getUniformLocation(B,"u_Tex"),color:t.getUniformLocation(B,"u_Color4"),frameOrigin:t.getUniformLocation(B,"u_FrameOrigin"),frameU:t.getUniformLocation(B,"u_FrameU"),frameV:t.getUniformLocation(B,"u_FrameV"),blendPrep:t.getUniformLocation(B,"u_BlendPrep")},xt={mvp:t.getUniformLocation(z,"u_MVP"),tex:t.getUniformLocation(z,"u_Tex"),blendPrep:t.getUniformLocation(z,"u_BlendPrep")},zn={mvp:t.getUniformLocation(V,"u_MVP"),tex:t.getUniformLocation(V,"u_Tex")},tt=rn(),yr=br();function ft(u){u==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):u==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let Qt=0;function vr(u){const{mode:x,prep:S}=Or(u);Qt=S,x==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):x==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):x==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):ft("translucent")}function hn(u,x){if(x&&x.perspective)return!1;const S=u.size[0]*u.scale[0],P=u.size[1]*u.scale[1];if(S===0||P===0)return!1;let I=Math.abs(S)/2,N=Math.abs(P)/2;const E=u.angles[2];if(E!==0){const W=Math.abs(Math.cos(E)),J=Math.abs(Math.sin(E)),Q=I*W+N*J,te=I*J+N*W;I=Q,N=te}const $=u.origin[0],A=x.projH-u.origin[1];let R=64;u.parallaxDepth&&(R+=Math.abs(sn(u.parallaxDepth[0])*fe),R+=Math.abs(sn(u.parallaxDepth[1])*Ye));const C=Oo(u),k=R+C[0],U=R+C[1];return $+I+k<x.offX||$-I-k>x.offX+x.viewW||A+N+U<x.offY||A-N-U>x.offY+x.viewH}function jt(u,x,S){if(!u.spriteSheet)return null;const P=x&&x.frames,I=Array.isArray(P)?P:P&&P.list;if(!I||I.length===0)return null;const N=P&&P.atlasWidth||x.width||0,E=P&&P.atlasHeight||x.height||0;if(N<=0||E<=0)return null;u.spriteFrameCount=I.length;let $=0;const A=u.textureAnimation;if(A&&A.frame!==null&&A.frame!==void 0)$=Math.floor(Number(A.frame))||0,$>=0||($=0),$>=I.length&&($=I.length-1);else if(I.length>1){const J=A&&A.playing===!1;let Q=0;for(const te of I)Q+=te.duration>0?te.duration:1/30;if(!J&&Q>0){let te=S%Q;te<0&&(te+=Q);for(let O=0;O<I.length;O++){const K=I[O].duration>0?I[O].duration:.03333333333333333;if(te<K){$=O;break}te-=K,$=O}}}const R=I[$],C=R.uDir?R.uDir[0]:R.width,k=R.uDir?R.uDir[1]:0,U=R.vDir?R.vDir[0]:0,W=R.vDir?R.vDir[1]:R.height;return[R.x/N,R.y/E,C/N,k/E,U/N,W/E]}function mn(u,x){const S=u.size[0]*u.scale[0],P=u.size[1]*u.scale[1];let I=rn();if(x&&x.perspective){const E=Ws(u,x);I=on(I,E[0],E[1],E[2]);const $=u.angles[0]||0,A=u.angles[1]||0;A&&(I=zs(I,A)),$&&(I=$s(I,$)),I=Ao(I,-u.angles[2])}else{if(I=on(I,u.origin[0],x.projH-u.origin[1],u.origin[2]),u.parallaxDepth&&(fe!==0||Ye!==0)){const E=sn(u.parallaxDepth[0]),$=sn(u.parallaxDepth[1]);I=on(I,E*fe,$*Ye,0)}I=Ao(I,-u.angles[2])}const N=No[u.alignment]||[.5,.5];return(N[0]!==.5||N[1]!==.5)&&(I=on(I,(.5-N[0])*S,(.5-N[1])*P,0)),{m:I,w:S,h:P}}function pn(u,x,S,P,I,N,E,$,A=!1,R=null,C=null){const k=mn(P,I);let U=k.m;if(C){const Q=(C[0]+C[2]/2)*P.scale[0],te=(C[1]+C[3]/2)*P.scale[1];U=on(U,Q,-te,0),U=xn(U,C[2]*P.scale[0],C[3]*P.scale[1],1)}else U=xn(U,k.w,k.h,1);const W=bt(N,U),J=u===z?xt:pe;t.useProgram(u),A?(Qt=0,t.enable(t.BLEND),P.containerAlphaMeaningful?t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA):t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):vr(P.colorBlendMode),J.blendPrep!==null&&J.blendPrep!==void 0&&t.uniform1i(J.blendPrep,Qt),Oe?(t.bindFramebuffer(t.FRAMEBUFFER,Oe.fbo.fbo),t.viewport(0,0,Oe.w,Oe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,E,$)),t.bindVertexArray(Y),st("local",dn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,x),t.uniform1i(J.tex,0),t.uniformMatrix4fv(J.mvp,!1,W),J.color!==null&&J.color!==void 0&&t.uniform4f(J.color,S[0],S[1],S[2],S[3]),Lt(J,R),t.drawArrays(t.TRIANGLES,0,6)}function Lt(u,x){!u||u.frameOrigin===null||u.frameOrigin===void 0||(x?(t.uniform2f(u.frameOrigin,x[0],x[1]),t.uniform2f(u.frameU,x[2],x[3]),t.uniform2f(u.frameV,x[4],x[5])):(t.uniform2f(u.frameOrigin,0,0),t.uniform2f(u.frameU,1,0),t.uniform2f(u.frameV,0,1)))}let wt=null,Oe=null;const Vt=new Map,dt=new Map;let jn=!0;function ao(u,x){const S=mn(u,x),P=x&&x.perspective?u.scale[1]:-u.scale[1],I=x&&x.perspective&&u.scale[2]||1;return xn(S.m,u.scale[0],P,I)}function Vn(u,x,S,P,I,N,E){Oe?(t.bindFramebuffer(t.FRAMEBUFFER,Oe.fbo.fbo),t.viewport(0,0,Oe.w,Oe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,P,I));const $=bt(S,ao(u,x));wt(u,$,{time:N,overrideTex:E||null}),Rt=null}let ht=null;function gn(u,x){return ht===null&&(ht=t.createTexture(),t.bindTexture(t.TEXTURE_2D,ht),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,ht),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,u,x,0),ht}function Jt(u,x,S,P,I,N,E,$){const A=gn(E,$),R=mn(u,I);let C=R.m;C=xn(C,R.w,R.h,1);const k=bt(N,C),U=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([K,se])=>{const ge=Xs(k,K,se,0);return[ge[0]*.5+.5,ge[1]*.5+.5]}),[W,J,Q,te]=U,O=new Float32Array([0,P,0,W[0],W[1],0,0,0,Q[0],Q[1],S,P,0,J[0],J[1],S,P,0,J[0],J[1],0,0,0,Q[0],Q[1],S,0,0,te[0],te[1]]);t.useProgram(V),ft("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,x.fbo),t.viewport(0,0,S,P),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(Y),t.bindBuffer(t.ARRAY_BUFFER,Z),t.bufferData(t.ARRAY_BUFFER,O,t.DYNAMIC_DRAW),Rt=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,A),t.uniform1i(zn.tex,0),t.uniformMatrix4fv(zn.mvp,!1,vn(0,S,0,P,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function xr(u,x,S,P,I){if(!jn||Oe)return;const N=dt.get(u.id);if(!N||N.size===0)return;const E=Math.max(1,Math.round(Math.abs(u.size[0]*(u.scale[0]||1)))),$=Math.max(1,Math.round(Math.abs(u.size[1]*(u.scale[1]||1))));if(E<=1&&$<=1)return;const A=oe(E,$,"lc:"+u.id);Jt(u,A,E,$,x,S,P,I);for(const R of N)Vt.set(R,A);dt.delete(u.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,P,I)}async function Wn(u,x,S,P,I,N,E,$){q++,t.viewport(0,0,S,P);const A=u.general||{};if(A.clearenabled!==!1){const O=Uo(A.clearcolor||"0 0 0");t.clearColor(O[0],O[1],O[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),et>=0){const O=I-et;$t=O>0&&O<1?O:Math.min(.1,Math.max(.001,O||1/60))}et=I;const R=qs(u,S,P,N,E,$);let C=bt(R.projection,R.view);const k=A.cameraparallax,U=k===!0||k!==null&&typeof k=="object"&&k.value===!0;fe=0,Ye=0;const W=Ne();if(W&&(we.x=W.u*2-1,we.y=W.v*2-1),!R.perspective&&n.parallax!==!1&&U){const O=(nt,ae)=>{const de=nt!==null&&typeof nt=="object"?nt.value:nt;return typeof de=="number"&&Number.isFinite(de)?de:ae},K=O(A.cameraparallaxamount,0),se=O(A.cameraparallaxmouseinfluence,1),ge=O(A.cameraparallaxdelay,1),Me=I-Ge;Ge=I;const ie=Me>0?1-Math.exp(-Me/Math.max(.05,ge)):1;we.sx+=(we.x-we.sx)*ie,we.sy+=(we.y-we.sy)*ie;const Ae=K*se,_e=60,Ze=we.sx*Ae*R.viewW,Mt=we.sy*Ae*R.viewH,at=Math.max(Math.abs(Ze),Math.abs(Mt))/_e,At=at>1?1/at:1;fe=-(Ze*At),Ye=-(Mt*At)}if(!R.perspective&&n.shake!==!1){const O=qe(A,I);if(O){const K=O.x*R.viewW*.02,se=O.y*R.viewH*.02;(K!==0||se!==0)&&(C=bt(C,on(rn(),K,se,0)))}}if(Ee){const O=typeof Ee=="function"?Ee():Ee;O&&typeof O.syncWorld=="function"&&O.syncWorld(R,0,0)}if(!D){D=!0;const O=(u.layers||[]).filter(ge=>ge.isContainer),K=O.filter(ge=>(ge.effects||[]).some(Me=>Me.visible)&&!ge.hasChildren),se=K.filter(ge=>(ge.effects||[]).some(Me=>(Me.materialPasses||[]).length>0));r(`containers total=${O.length} canvasCandidates=${K.length} passesResolved=${se.length} names=${K.slice(0,4).map(ge=>ge.name||"?").join("/")}`)}await wr(u,x,R,S,P,I);const J=new Map;for(const O of u.layers)O.id!==void 0&&J.set(O.id,O);const Q=new Set;for(const O of u.layers)!O.visible||O.destroyed||!O.isContainer||!O.hasChildren||!(O.effects||[]).some(se=>se.visible)||(O.childIds||[]).length===0||tr(O,J,Q);if(a)try{a()}catch(O){r("particle advance error: "+(O&&O.message))}const te=R.perspective?u.layers.slice().sort((O,K)=>+!!K.isSkybox-+!!O.isSkybox):u.layers;for(const O of te)if(!(!O.visible||O.destroyed)&&!(O.isPostProcess&&!(O.effects||[]).some(K=>K.visible))&&!Q.has(O.id)){if(O.isContainer){if(!(O.effects||[]).some(se=>se.visible)){xr(O,R,C,S,P);continue}if(O.hasChildren){(O.childIds||[]).length>0&&await Mr(O,u,x,R,C,S,P,I);continue}}if(O.particle){if(f)try{await f(O.id,R,C,S,P)}catch(K){r("particle render error: "+(K&&K.message))}continue}hn(O,R)||await T(O,x,R,C,S,P,I)}if(Zt(A)&&I<qt){const O=Math.max(0,Math.min(1,I/qt)),K=1-O*O*(3-2*O);if(K>.002){const se=Uo(A.clearcolor||"0 0 0");t.useProgram(B),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,S,P),t.bindVertexArray(Y),st("pass",fn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Fe),t.uniform1i(pe.tex,0),t.uniform4f(pe.color,se[0],se[1],se[2],K),Lt(pe,null),pe.blendPrep!==null&&pe.blendPrep!==void 0&&t.uniform1i(pe.blendPrep,0),t.uniformMatrix4fv(pe.mvp,!1,tt),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),H()}async function wr(u,x,S,P,I,N){Vt.clear(),dt.clear();const E=new Map,$=new Set;let A=null;const R=C=>{if(typeof C!="string")return;const k=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(C);if(!k)return;const U=Number(k[1]);A!==null&&U===A&&$.add(U);let W=E.get(U);W||(W=new Set,E.set(U,W)),W.add(C)};for(const C of u.layers||[]){A=C.id;for(const k of C.effects||[])if(k.visible){for(const U of k.passes||[])for(const W of U.textures||[])R(W);for(const U of k.materialPasses||[]){for(const W of U.binds||[])R(W&&W.name);for(const W of U.textures||[])R(W)}}}if(E.size!==0){for(const[C,k]of E){const U=(u.layers||[]).find(_e=>_e.id===C);if(!U||U.particle||U.isPostProcess||$.has(C))continue;const W=typeof U.image=="string"?U.image:"";if(U.isContainer&&!U.hasChildren&&W.indexOf("models/util/composelayer")===0&&!(U.effects||[]).some(_e=>_e.visible)){dt.set(C,k);continue}const Q=Math.max(1,Math.round(Math.abs(U.size[0]*(U.scale[0]||1)))),te=Math.max(1,Math.round(Math.abs(U.size[1]*(U.scale[1]||1))));if(Q<=1&&te<=1)continue;const O=oe(Q,te,"lc:"+C);t.bindFramebuffer(t.FRAMEBUFFER,O.fbo),t.viewport(0,0,Q,te),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const K={view:S.view,projection:vn(0,Q,0,te,-1e4,1e4),eye:S.eye,projW:Q,projH:te,offX:0,offY:0,viewW:Q,viewH:te},se=Oe,ge=U.origin,Me=U.scale,ie=U.angles,Ae=U.visible;Oe={fbo:O,w:Q,h:te},U.origin=[Q/2,K.projH-te/2,ge[2]],U.scale=[Math.sign(Me[0])||1,Math.sign(Me[1])||1,Me[2]],U.angles=[0,0,0],U.visible=!0;try{await T(U,x,K,K.projection,Q,te,N);for(const _e of k)Vt.set(_e,O)}catch(_e){r(`composite \u6E90\u5C42 ${C} \u6E32\u67D3\u5931\u8D25: ${_e&&_e.message}`)}finally{Oe=se,U.origin=ge,U.scale=Me,U.angles=ie,U.visible=Ae}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,P,I)}}async function Mr(u,x,S,P,I,N,E,$){const A=Math.max(1,Math.round(Math.abs(u.size[0]))),R=Math.max(1,Math.round(Math.abs(u.size[1])));if((u.childIds||[]).length===0)return;const k=new Map;for(const ie of x.layers)ie.id!==void 0&&k.set(ie.id,ie);const U=tr(u,k),W=x.layers.filter(ie=>U.has(ie.id)&&ie.visible);if(W.length===0)return;const J=oe(A,R,"group");t.bindFramebuffer(t.FRAMEBUFFER,J.fbo),t.viewport(0,0,A,R),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const Q={view:P.view,projection:vn(0,A,0,R,-1e4,1e4),eye:P.eye,projW:A,projH:R,offX:0,offY:0,viewW:A,viewH:R},te=Q.projection,O=u.scale[0]||1,K=u.scale[1]||1,se=u.angles[2]||0,ge=Math.cos(-se),Me=Math.sin(-se);Oe={fbo:J,w:A,h:R};try{for(const ie of W){if(ie.isPostProcess||ie.particle||ie.isContainer&&(ie.childIds||[]).length>0)continue;const Ae=ie.origin,_e=ie.scale,Ze=ie.angles,Mt=Ae[0]-u.origin[0],at=Ae[1]-u.origin[1],At=(Mt*ge-at*Me)/O,nt=(Mt*Me+at*ge)/K;ie.origin=[A/2+At,R/2+nt,Ae[2]],ie.scale=[_e[0]/O,_e[1]/K,_e[2]],ie.angles=[Ze[0],Ze[1],Ze[2]-se];try{await T(ie,S,Q,te,A,R,$)}finally{ie.origin=Ae,ie.scale=_e,ie.angles=Ze}}}finally{Oe=null}u.groupTex=J.tex,u.groupW=A,u.groupH=R;try{await T(u,S,P,I,N,E,$)}finally{u.groupTex=null}}async function T(u,x,S,P,I,N,E){const $=!!(u.puppet&&wt),A=!u.solid&&u.textureName?x.get(u.textureName):null;if(A&&A.video){const ae=A.video;if(ae.readyState>=2&&ae.currentTime!==A.lastUploaded){t.bindTexture(t.TEXTURE_2D,A.glTex);try{let de=ae.videoWidth||A.width,ce=ae.videoHeight||A.height;const ke=2048,_t=t.getParameter(t.MAX_TEXTURE_SIZE),mt=_t>0&&_t<4096?Math.min(ke,_t):ke;let Wt=1;Math.max(de,ce)>mt&&(Wt=mt/Math.max(de,ce));const pt=Math.max(1,Math.round(de*Wt)),Ve=Math.max(1,Math.round(ce*Wt));let Ar=ae;if(i&&pt>0&&Ve>0){(i.width!==pt||i.height!==Ve)&&(i.width=pt,i.height=Ve);const Ft=i.getContext("2d");Ft&&(Ft.clearRect(0,0,pt,Ve),Ft.drawImage(ae,0,0,pt,Ve),Ar=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,Ar),t.getError()!==t.NO_ERROR&&i)try{const Ht=i.getContext("2d").getImageData(0,0,i.width,i.height);for(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i.width,i.height,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(Ht.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}A.width=pt,A.height=Ve,A.lastUploaded=ae.currentTime,s||(s=!0,r("video tex ready "+pt+"x"+Ve+" (src "+de+"x"+ce+")"))}catch(de){s||(s=!0,r("video upload FAIL: "+(de&&de.message||de))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",de&&de.message,"readyState=",ae.readyState,"cur=",ae.currentTime)}}}const R=u.groupTex?u.groupTex:A&&A.glTex?A.glTex:u.solid?Fe:Je,C=(!!u.passthrough||!!u.isPostProcess||Do(u))&&!u.groupTex&&!A&&!$;let k,U;if(u.groupTex?(k=u.groupW||u.size[0],U=u.groupH||u.size[1]):$||!A?(k=u.size[0],U=u.size[1]):(k=A.width,U=A.height),!$&&A&&u.spriteSheet){const ae=A.frames,de=Array.isArray(ae)?ae:ae&&ae.list;de&&de.length&&(k=de[0].width||k,U=de[0].height||U)}const W=Math.max(1,Math.round(k)),J=Math.max(1,Math.round(U)),Q=[u.color[0]*u.brightness,u.color[1]*u.brightness,u.color[2]*u.brightness,u.alpha],te=(u.effects||[]).filter(ae=>ae.visible);let O=W,K=J;if(c>0&&S.projW>0&&S.projH>0){const ae=Math.min(Math.abs(u.size[0]*u.scale[0]),S.viewW),de=Math.min(Math.abs(u.size[1]*u.scale[1]),S.viewH),ce=ae*(I/S.projW),ke=de*(N/S.projH);if(ce>0&&ke>0){const _t=Math.max(64,Math.round(ce*c)),mt=Math.max(64,Math.round(ke*c));_t<W&&(O=_t),mt<J&&(K=mt)}}if(te.length===0){$?Vn(u,S,P,I,N,E):pn(B,R,Q,u,S,P,I,N,!1,jt(u,A,E));return}const se=oe(O,K,"ping"),ge=oe(O,K,"pong"),Me=vn(0,O,0,K,-1e4,1e4);if($)t.useProgram(B),ft("normal"),t.bindFramebuffer(t.FRAMEBUFFER,se.fbo),t.viewport(0,0,O,K),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(Y),Rt=null,st("layer"+O+"x"+K,it(O,K)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,R),t.uniform1i(pe.tex,0),t.uniform4f(pe.color,1,1,1,1),Lt(pe,null),pe.blendPrep!==null&&pe.blendPrep!==void 0&&t.uniform1i(pe.blendPrep,0),t.uniformMatrix4fv(pe.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6);else if(C)Jt(u,se,O,K,S,P,I,N);else{t.useProgram(B),ft("normal"),t.bindFramebuffer(t.FRAMEBUFFER,se.fbo),t.viewport(0,0,O,K),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(Y),st("layer"+O+"x"+K,it(O,K)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,R),t.uniform1i(pe.tex,0);const ae=te.some(de=>de&&de.layerMaterial)?[1,1,1,Q[3]]:Q;t.uniform4f(pe.color,ae[0],ae[1],ae[2],ae[3]),Lt(pe,jt(u,A,E)),pe.blendPrep!==null&&pe.blendPrep!==void 0&&t.uniform1i(pe.blendPrep,0),t.uniformMatrix4fv(pe.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6)}let ie=se,Ae=ge;const _e=new Map;let Ze=!1,Mt=se;const at=[],At=new Set;for(const ae of te){for(const ce of ae.fbos||[])if(!_e.has(ce.name)){const[ke,_t]=$o(ce,O,K),mt=ce.unique?u.id+":"+ce.name:ce.name;_e.set(ce.name,oe(ke,_t,mt))}const de=ae.materialPasses||[];for(let ce=0;ce<de.length;ce++)at.push({eff:ae,mp:de[ce],ov:ae.passes&&ae.passes[ce]})}const nt=[];for(let ae=0;ae<at.length;ae++){const{eff:de,mp:ce,ov:ke}=at[ae];if(At.has(de))continue;const _t={...ce.combos||{},...ke&&ke.combos||{}},mt=ce.textures||[],Wt=ke&&ke.textures||[],pt=[];for(let be=0;be<Math.max(mt.length,Wt.length);be++)Wt[be]!==void 0&&Wt[be]!==null?pt[be]=Wt[be]:pt[be]=mt[be]!==void 0?mt[be]:null;if(ce.copyCommand){const be=ce.source?_e.get(ce.source):null,Ue=ce.target?_e.get(ce.target):null;be&&Ue&&(t.useProgram(z),ft("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Ue.fbo),t.viewport(0,0,Ue.width,Ue.height),t.bindVertexArray(Y),st("pass",fn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,be.tex),t.uniform1i(xt.tex,0),xt.blendPrep!==null&&xt.blendPrep!==void 0&&t.uniform1i(xt.blendPrep,0),t.uniformMatrix4fv(xt.mvp,!1,tt),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let Ve;try{Ve=await ue(ce.shader,_t,pt)}catch(be){const Ue=be&&be.message||String(be);/已缓存/.test(Ue)||console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",ce.shader,Ue),At.add(de);continue}const Ar=Ve.prog,Ft=Ve.uni;Ve.fragGlsl&&nt.push(Ve.fragGlsl);let Ht,Hn;ce.target?(Ze||(Mt=ie,Ze=!0),Ht=_e.get(ce.target)||ie,Hn=Mt):(Ze=!1,Ht=Ae,Hn=ie),t.useProgram(Ar),ft(ce.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,Ht.fbo),t.viewport(0,0,Ht.width,Ht.height),t.bindVertexArray(Y),st("pass",fn);const co=ce.textures||[],El=Math.max(co.length,8),Qi=new Map,Pl=new Set;for(let be=0;be<El;be++){let Ue=be<co.length?co[be]:null;ke&&ke.textures&&ke.textures[be]!==void 0&&ke.textures[be]!==null&&(Ue=ke.textures[be]);for(const Gn of ce.binds||[])Gn.index===be&&(Ue=Gn.name);let Tt;if(be===0&&(Ue==null||Ue===""))Tt=Hn;else{if((Ue==null||Ue==="")&&Ve.samplerDefaults){const Gn=Ve.samplerDefaults.get(be);Gn&&(Ue=Gn)}Tt=$n(Ue,Hn,_e,x)}Ue==="previous"&&(Tt=Hn),Tt===null&&(Tt={glTex:Fe,width:1,height:1,tex:Fe});const Xn=Tt.fbo?Tt:{tex:Tt.glTex||Fe,width:Tt.width||1,height:Tt.height||1};t.activeTexture(t.TEXTURE0+be),t.bindTexture(t.TEXTURE_2D,Xn.tex),Pl.add(be),Qi.set(be,[Xn.width,Xn.height,Xn.width,Xn.height])}un(Ft,u,E,S.projW,S.projH,tt,Me,tt,Qi,Me,S),so(Ft,Ct(Dn({...ce.constants||{},...ke&&ke.constantshadervalues||{}},(u.id||u.name||"?")+"|"+(ce.shader||"?")+"|"+ae,E,u),(u.id||u.name||"?")+"|"+(ce.shader||"?")+"|"+ae,E),Ve.matMeta),On(Ft),t.drawArrays(t.TRIANGLES,0,6),ce.target||(Ae=ie,ie=Ht)}if(u.isContainer&&!u.groupTex&&!C&&u.containerAlphaMeaningful===void 0){let ae=!1;for(const de of nt){if(typeof de!="string")continue;const ce=de.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(ce&&!/^\s*scene\s*\.\s*a\s*$/.test(ce[1])){ae=!0;break}}u.containerAlphaMeaningful=ae,r(`container "${u.name||"?"}" alpha ${ae?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if($){Vn(u,S,P,I,N,E,ie.tex);return}pn(z,ie.tex,[1,1,1,1],u,S,P,I,N,!!u.isContainer&&!u.groupTex&&!C,null,null)}return{gl:t,render:Wn,getFBO:oe,getEffectProgram:ue,progCache:j,shaderResolver:o,whiteTex:Fe,resetShaderCaches:function(){j.clear(),ee.clear(),le&&le.clear()},setFboCapFactor:function(u){c=u},setParticleRenderer:function(u,x){a=typeof u=="function"?u:null,f=typeof x=="function"?x:null},setConstantScriptRuntime:F,applyConstUserProperties:function(u){if(u){for(const x of _.values())if(x&&typeof x.applyUserProperties=="function")try{x.applyUserProperties(u)}catch{}}},constantScriptStats:function(){return{...L,cached:_.size}},setCompositeEnabled:function(u){jn=!!u},compositeStats:function(){const u=[],x=new Uint8Array(4);for(const[S,P]of Vt){let I=null;try{t.bindFramebuffer(t.FRAMEBUFFER,P.fbo),t.readPixels(P.w>>1,P.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,x),I=[x[0],x[1],x[2],x[3]]}catch{}u.push({name:S,w:P.w,h:P.h,center:I})}return t.bindFramebuffer(t.FRAMEBUFFER,null),u},setPuppetRenderer:function(u){wt=u},setAudioProvider:h,setPointerProvider:xe,getParallaxOffset:function(){return{x:fe,y:Ye}},dispose:function(){try{const u=t.getExtension("WEBGL_lose_context");u&&u.loseContext()}catch{}}}}const ya=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:No,XRAY_IDLE_SCREEN_UV:An,applyColorBlendCPU:ma,collectGroupDescendantIds:tr,colorBlendPlan:Or,createRenderer:ba,effectFboSize:$o,layerWantsPreserveBackdrop:Do,makeTexture:Ir,makeTextureMip:la,puppetAnimMargin:Oo,rewriteXrayFragScale:zo,xrayShouldParkPointer:Dr,xrayUvScale:pa},Symbol.toStringTag,{value:"Module"}));function va(e=256,n=8){const t=e/n,o=jo(1337),r=jo(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let f=0;f<t*t;f++)i[f]=o(),s[f]=r();const c=new Uint8Array(e*e*4),a=n;for(let f=0;f<e;f++){const l=Math.floor(f/a),d=f%a/a,h=d*d*(3-2*d);for(let m=0;m<e;m++){const M=Math.floor(m/a),g=m%a/a,y=g*g*(3-2*g),b=M%t,p=(M+1)%t,v=l%t,_=(l+1)%t,w=i[v*t+b],L=i[v*t+p],F=i[_*t+b],D=i[_*t+p],B=s[v*t+b],z=s[v*t+p],V=s[_*t+b],Y=s[_*t+p],Z=w+(L-w)*y+(F-w)*h+(w-L-F+D)*y*h,X=B+(z-B)*y+(V-B)*h+(B-z-V+Y)*y*h,q=(f*e+m)*4;c[q]=Math.round(Z*255),c[q+1]=Math.round(X*255),c[q+2]=0,c[q+3]=255}}return c}function jo(e){let n=e>>>0;return()=>{n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const xa=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:va},Symbol.toStringTag,{value:"Module"})),lt=Math.PI*2;function Ce(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function Vo(e,n,t){if(e==null)return Math.random();if(n==null)return e;const o=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+o*(n-e)}function me(e,n){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e==null)return n?n.slice():[0,0,0];if(typeof e=="object")return me(e.value,n);if(typeof e=="number")return[e,e,e];const t=String(e).trim().split(/\s+/).map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function Wo(e){return e==null?null:typeof e=="number"?[e,e,e]:me(e)}function G(e,n){if(e==null)return n;if(typeof e=="object")return G(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function $r(e,n){const t=e[0],o=e[1]>t?e[1]:t+1e-6,r=Math.min(1,Math.max(0,(n-t)/(o-t)));return r*r*(3-2*r)}function Ut(e,n,t){const o=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return o-Math.floor(o)}function wa(e,n,t){const o=Math.floor(e),r=Math.floor(n),i=Math.floor(t),s=e-o,c=n-r,a=t-i,f=s*s*(3-2*s),l=c*c*(3-2*c),d=a*a*(3-2*a),h=(b,p,v)=>b+(p-b)*v,m=h(Ut(o,r,i),Ut(o+1,r,i),f),M=h(Ut(o,r+1,i),Ut(o+1,r+1,i),f),g=h(Ut(o,r,i+1),Ut(o+1,r,i+1),f),y=h(Ut(o,r+1,i+1),Ut(o+1,r+1,i+1),f);return h(h(m,M,l),h(g,y,l),d)}function zr(e,n,t,o){let r=0,i=.5,s=1,c=0;for(let a=0;a<o;a++)r+=i*wa(e*s,n*s,t*s),c+=i,i*=.5,s*=2;return r/(c||1)}function jr(e,n,t,o){return[zr(e,n,t,o)*2-1,zr(e+31.7,n+11.3,t+57.1,o)*2-1,zr(e+73.9,n+92.1,t+13.7,o)*2-1]}function Ma(e){const n=`#version 300 es
63
65
  // \u5355\u4F4D quad\uFF08TRIANGLE_STRIP 4 \u9876\u70B9\uFF09\uFF0C\u6309\u5B9E\u4F8B\u7684 size/rot \u5C55\u5F00\u4E3A\u671D\u5C4F\u5E55\u7684\u7CBE\u7075
64
66
  layout(location=0) in vec2 a_corner; // -0.5..0.5
65
67
  layout(location=1) in vec3 a_pos; // \u5B9E\u4F8B\u4E2D\u5FC3\uFF08\u6295\u5F71\u7A7A\u95F4\u4E16\u754C\u5750\u6807\uFF09
66
68
  layout(location=2) in vec2 a_sizeRot; // x=size(\u50CF\u7D20) y=rot(\u5F27\u5EA6)
67
69
  layout(location=3) in vec4 a_color; // rgb + alpha
68
70
  layout(location=4) in vec3 a_stretchFrame; // xy=\u975E\u7B49\u6BD4\u62C9\u4F38 z=\u5E27\u5E8F\u53F7
71
+ layout(location=5) in vec2 a_vrange; // \u6BB5\u4E24\u7AEF\u6CBF\u8D34\u56FE v \u7684\u53D6\u503C\uFF08rope \u8FDE\u7EBF\u7528\uFF1B\u666E\u901A\u7CBE\u7075 0..1\uFF09
69
72
  uniform mat4 u_mvp;
70
73
  // \u5E8F\u5217\u5E27 uv \u53D8\u6362\u8868\uFF08TEXS \u5E27\u77E9\u5F62\u5F52\u4E00\u5316\u540E\u7684 offset/scale\uFF09\uFF0C\u6700\u591A 128 \u5E27
71
74
  // \uFF08matrix spritesheet 72 \u6709 71 \u5E27\uFF0C\u65E7\u4E0A\u9650 64 \u4F1A\u4E22\u672B\u5C3E\u5B57\u7B26\uFF09
@@ -83,7 +86,8 @@ void main(){
83
86
  gl_Position = u_mvp * vec4(a_pos.xy + rotated, a_pos.z, 1.0);
84
87
  // quad \u89D2 \u2192 \u8D34\u56FE uv\u3002\u4E16\u754C y \u5DF2\u7FFB\u8F6C\u5230\u6295\u5F71\u7A7A\u95F4\uFF08y \u5411\u4E0B\uFF09\uFF0C\u6545 quad \u7684 +y \u89D2
85
88
  // \u5BF9\u5E94\u5C4F\u5E55\u4E0A\u65B9\uFF0C\u5E94\u91C7\u6837\u7EB9\u7406\u9876\u884C v=1\uFF08\u4E0E renderer.js \u7684 layerQuadVerts \u540C\u7EA6\u5B9A\uFF09\u3002
86
- vec2 uv = a_corner + 0.5;
89
+ // a_vrange \u8BA9 rope \u6BB5\u4E24\u7AEF\u5404\u53D6\u81EA\u5DF1\u7684 v\uFF08\u6CBF\u7EF3\u8FDE\u7EED\u6E10\u53D8\uFF09\uFF1B\u666E\u901A\u7CBE\u7075\u662F (0,1) \u6052\u7B49\u3002
90
+ vec2 uv = vec2(a_corner.x + 0.5, mix(a_vrange.x, a_vrange.y, a_corner.y + 0.5));
87
91
  if (u_frameCount > 0) {
88
92
  // \u5E27\u77E9\u5F62\u4EE5\u5DE6\u4E0A\u4E3A\u539F\u70B9\uFF08TEXS \u662F top-down \u50CF\u7D20\u5750\u6807\uFF09\uFF0C\u6545\u5148\u628A v \u7FFB\u6210 top-down
89
93
  int fi = int(a_stretchFrame.z);
@@ -132,7 +136,7 @@ void main(){
132
136
  if (col.a < 0.004) discard;
133
137
  }
134
138
  fragColor = col;
135
- }`,r=(u,l)=>{const d=e.createShader(u);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(d));return d},o=e.createProgram();if(e.attachShader(o,r(e.VERTEX_SHADER,n)),e.attachShader(o,r(e.FRAGMENT_SHADER,t)),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(o));const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-.5,-.5,.5,-.5,-.5,.5,.5,.5]),e.STATIC_DRAW);const s=e.createBuffer(),c=e.createVertexArray();e.bindVertexArray(c),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,8,0),e.vertexAttribDivisor(0,0),e.bindBuffer(e.ARRAY_BUFFER,s);const a=48;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,a,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,a,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,a,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,a,36),e.vertexAttribDivisor(4,1),e.bindVertexArray(null),{prog:{prog:o,uniTex:e.getUniformLocation(o,"u_tex"),uniNormal:e.getUniformLocation(o,"u_normal"),uniScene:e.getUniformLocation(o,"u_scene"),uniRefract:e.getUniformLocation(o,"u_refract"),uniSampleScene:e.getUniformLocation(o,"u_sampleScene"),uniResolution:e.getUniformLocation(o,"u_resolution"),uniRefractScale:e.getUniformLocation(o,"u_refractScale"),uniMvp:e.getUniformLocation(o,"u_mvp"),uniFrameCount:e.getUniformLocation(o,"u_frameCount"),uniFrames:e.getUniformLocation(o,"u_frames")},quadBuf:i,vbuf:s,vao:c}}function Do(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function ha(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;r++}return r>0}function zo(e,n,t,r){let o=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(r)||0;return i>0&&(o=Math.max(i,o)),s>0&&(o=Math.min(s,o)),o}function $o(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function jo(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}class ma{constructor(){this.alive=!1,this.x=this.y=this.z=0,this.vx=this.vy=this.vz=0,this.bx=this.by=this.bz=0,this.age=0,this.life=1,this.size=1,this.baseSize=1,this.rot=0,this.rotVel=0,this.r=this.g=this.b=1,this.baseR=this.baseG=this.baseB=1,this.alpha=1,this.baseAlpha=1,this.seed=0,this.frame=0,this.oscPhase=0,this.oscFreq=0,this.oscAmp=0,this.oscAPhase=0,this.oscAFreq=0,this.oscSPhase=0,this.oscSFreq=0,this.turbSpeed=0,this.turbPhase=0,this.trail=null}}class pa{constructor(n,t,r,o){this.gl=n,this.model=t||{},this.override=r||{},this.layer=o||null;const i=o&&o.origin?o.origin:[0,0,0],s=o&&o.scale?o.scale:[1,1,1],c=o&&o.angles?o.angles:[0,0,0];this.originX=i[0]||0,this.originY=i[1]||0,this.originZ=i[2]||0,this.scaleX=s[0]===0?1:s[0],this.scaleY=s[1]===0?1:s[1],this.angleZ=(c[2]||0)*Math.PI/180;const a=Math.abs(this.scaleX),u=Math.abs(this.scaleY);this.sysScale=Math.min(a,u)||1,this.spriteStretchX=a/this.sysScale,this.spriteStretchY=u/this.sysScale,this.maxCount=Math.max(1,Math.min(2e4,H(this.model.maxcount,100))),this.simTime=0,this.paused=!1,this.texture=null,this.normalTex=null,this.material=null,this.blend="translucent",this.refract=!1,this.refractAmount=.04,this.opacityMul=1,this.lifetimeMul=1,this.visible=!0,this._ready=!1,this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null,this.sequenceMul=Math.max(1,Math.round(H(this.model.sequencemultiplier,1))),this.animationMode=this.model.animationmode||null,this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul,this.texAspectX=1,this.texAspectY=1,this.controlPoints=(this.model.controlpoint||[]).filter(Boolean).map(l=>({id:H(l.id,0),lockToPointer:!!l.locktopointer||(H(l.flags,0)&1)!==0,offset:be(l.offset),x:0,y:0,z:0})),this.pointer=null,this._followParent=null,this._followMode=null,this._followOffset=[0,0,0],this._ov={},this._applyOverride(),this.startTime=Math.max(0,Math.min(30,H(this.model.starttime,0))),this._warmed=!1,this._compile()}reapplyOverride(){this._applyOverride()}_applyOverride(){this._ov={},this.opacityMul=1,this.lifetimeMul=1,this.maxCount=Math.max(1,Math.min(2e4,H(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const r=n[t],o=r&&typeof r=="object"&&"value"in r?r.value:r;if(t==="count"){const i=H(this.model.maxcount,100),s=Number(o),c=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*c))),this._ov.countMul=c}else if(t==="alpha")this.opacityMul=Number(o),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=be(o);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(o)||1:t==="rate"?(this._ov.rateMul=Number(o),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(o)||1:t==="lifetime"?this.lifetimeMul=Number(o)||1:t==="brightness"?this._ov.brightness=Number(o)||1:this._ov[t]=o}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new ma)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(a=>({kind:a.name==="boxrandom"?"box":"sphere",origin:be(a.origin),directions:be(a.directions,[1,1,1]),distanceMin:Oo(a.distancemin),distanceMax:Oo(a.distancemax),sign:a.sign?be(a.sign):null,rate:H(a.rate,0),audioDriven:a.audioprocessingmode!==void 0,audioBounds:be(a.audioprocessingbounds,[0,1]),fill:a.rate===void 0&&a.instantaneous===void 0&&a.audioprocessingmode===void 0,instantaneous:H(a.instantaneous,0),speedMin:H(a.speedmin,0),speedMax:H(a.speedmax,0),controlPoint:a.controlpoint!==void 0&&a.controlpoint!==null?H(a.controlpoint,0):0,_burst:!1}));const t=n.initializer||[];this.init={life:null,size:null,color:null,alpha:null,velocity:null,rotation:null,angularVelocity:null,turbulentVelocity:null,mapAround:null};for(const a of t)switch(a.name){case"lifetimerandom":this.init.life={min:H(a.min,1),max:H(a.max,1),exp:H(a.exponent,1)};break;case"sizerandom":this.init.size={min:H(a.min,1),max:H(a.max,1),exp:H(a.exponent,1)};break;case"colorrandom":this.init.color={min:be(a.min,[255,255,255]),max:be(a.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:H(a.min,1),max:H(a.max,1)};break;case"velocityrandom":this.init.velocity={min:be(a.min),max:be(a.max)};break;case"rotationrandom":this.init.rotation={min:be(a.min),max:be(a.max,[0,0,0]),exp:H(a.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:be(a.min),max:be(a.max),exp:H(a.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,H(a.count,1)),bounds:be(a.bounds,[0,1]),speedMin:be(a.speedmin),speedMax:be(a.speedmax,[0,0,0]),cp:H(a.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:H(a.scale,.1),offset:H(a.offset,0),speedMin:H(a.speedmin,0),speedMax:H(a.speedmax,0),phaseMax:H(a.phasemax,0),timeScale:H(a.timescale,0),audioMode:H(a.audioprocessingmode,0),audioBounds:be(a.audioprocessingbounds,[0,1])};break}const r=n.operator||[];this.ops={movement:null,angularMovement:null,alphaFade:null,alphaChange:null,sizeChange:null,colorChange:null,turbulence:[],oscAlpha:null,oscSize:null,oscPos:null,attract:[],vortex:[],remap:[]};for(const a of r)switch(a.name){case"movement":this.ops.movement={gravity:be(a.gravity),drag:H(a.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:be(a.force),drag:H(a.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:H(a.fadeintime,.1),fadeOut:H(a.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:H(a.starttime,0),endTime:H(a.endtime,1),startValue:H(a.startvalue,1),endValue:H(a.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:H(a.starttime,0),endTime:H(a.endtime,1),startValue:H(a.startvalue,1),endValue:H(a.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:H(a.starttime,0),endTime:H(a.endtime,1),startValue:a.startvalue!==void 0?be(a.startvalue):null,endValue:be(a.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:H(a.scale,.01),speedMin:H(a.speedmin,0),speedMax:H(a.speedmax,0),timeScale:H(a.timescale,1),phaseMin:H(a.phasemin,0),phaseMax:H(a.phasemax,0),mask:a.mask!==void 0?be(a.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:H(a.frequencymin,H(a.frequencymax,1)),freqMax:H(a.frequencymax,1),scaleMin:H(a.scalemin,0),scaleMax:H(a.scalemax,1),phaseMax:H(a.phasemax,at)};break;case"oscillatesize":this.ops.oscSize={freqMin:H(a.frequencymin,H(a.frequencymax,1)),freqMax:H(a.frequencymax,H(a.frequencymin,1)),scaleMin:H(a.scalemin,1),scaleMax:H(a.scalemax,1),phaseMax:H(a.phasemax,at)};break;case"oscillateposition":this.ops.oscPos={freqMin:H(a.frequencymin,H(a.frequencymax,.5)),freqMax:H(a.frequencymax,.5),scaleMin:H(a.scalemin,0),scaleMax:H(a.scalemax,1),phaseMin:H(a.phasemin,0),phaseMax:H(a.phasemax,at),mask:a.mask!==void 0?be(a.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:H(a.controlpoint,0),origin:be(a.origin),scale:H(a.scale,0),threshold:H(a.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:be(a.axis,[0,0,1]),offset:be(a.offset),distanceInner:H(a.distanceinner,0),distanceOuter:H(a.distanceouter,0),speedInner:H(a.speedinner,0),speedOuter:H(a.speedouter,0),cp:a.controlpoint!==void 0&&a.controlpoint!==null?H(a.controlpoint,0):0,audioMode:H(a.audioprocessingmode,0),audioBounds:be(a.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:a.output||"velocity",rangeMin:be(a.outputrangemin),rangeMax:be(a.outputrangemax),fn:a.transformfunction||"simplexnoise",inputScale:H(a.transforminputscale,1)});break}const o=this.model.renderer,i=o==null,s=Array.isArray(o)?o:o?[o]:[];this.renderers=s.map(a=>{const u=a&&a.name||"sprite";return{kind:u,length:H(a&&a.length,u==="spritetrail"?.1:0),maxLength:H(a&&a.maxlength,0),minLength:H(a&&a.minlength,0),subdivision:H(a&&a.subdivision,1),orientation:a&&a.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,orientation:null}]);const c=this.renderers.find(a=>a.kind==="spritetrail"||a.kind==="ropetrail");if(this.trailCfg=c||null,this.trailSegments=1,c&&c.kind==="ropetrail"){const a=Math.max(2,Math.min(16,Math.round(c.maxLength||c.subdivision||6)));this.trailSegments=a;for(const u of this.pool)u.trail=new Float32Array(a*3)}}setModel(n){this.model=n,this._compile()}setMaterial(n){this.material=n;const t=n&&n.passes&&n.passes[0];this.blend=t&&t.blending||"translucent",this.refract=Do(n);const r=t&&t.constantshadervalues,o=r&&r.ui_editor_properties_refract_amount,i=Number(o);this.refractAmount=Number.isFinite(i)?Math.min(.35,Math.max(0,i)):.04}setNormalTexture(n){this.normalTex=n||null}setTexture(n){this.texture=n,this._ready=!!n;const t=n&&n.frames,r=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,o=n&&n.width||r&&(t&&t.atlasWidth||r.atlasWidth)||0,i=n&&n.height||r&&(t&&t.atlasHeight||r.atlasHeight)||0;r&&o>0&&i>0?(this.texFrames=r.map(u=>({ou:u.x/o,ov:u.y/i,su:u.width/o,sv:u.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,c=1;this.texFrames&&r?(s=r[0].width||1,c=r[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,c=n.height);const a=Math.max(s,c)||1;this.texAspectX=s/a,this.texAspectY=c/a,this._frameData=void 0}setVisible(n){this.visible=n}setPointer(n,t){const r=n-this.originX,o=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(r*i-o*s)/(this.scaleX||1),y:(r*s+o*i)/(this.scaleY||1)}}attachFollow(n,t,r){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const o=r||[0,0,0];this._followOffset=[o[0]||0,o[1]||0,o[2]||0],this._syncFollow()}leaderParticle(){const n=this.pool;for(let t=0;t<n.length;t++)if(n[t].alive)return n[t];return null}localToWorld(n,t){const r=n*this.scaleX,o=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+r*i-o*s,this.originY+r*s+o*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const r=this._followOffset;if(t==="particle"){const o=n.leaderParticle();if(!o)return;const i=n.localToWorld(o.x+r[0],o.y+r[1]);this.originX=i[0],this.originY=i[1]}else{const o=n.localToWorld(r[0],r[1]);this.originX=o[0],this.originY=o[1]}}spawn(n){const t=this.pool,r=t.length;let o=null,i=this._cursor||0;for(let d=0;d<r;d++){const h=t[(i+d)%r];if(!h.alive){o=h,this._cursor=(i+d+1)%r;break}}if(!o)return;o.alive=!0,o.age=0,o.seed=Math.random(),o.rot=0,o.rotVel=0,o.vx=o.vy=o.vz=0,o.frame=0;const s=n.origin;if(n.kind==="box"){const d=n.distanceMax||[0,0,0],h=n.distanceMin;o.x=s[0]+Le(-d[0],d[0])+(h?h[0]:0),o.y=s[1]+Le(-d[1],d[1])+(h?h[1]:0),o.z=s[2]+Le(-d[2],d[2])+(h?h[2]:0)}else{const d=n.directions,h=n.distanceMin?n.distanceMin[0]:0,p=n.distanceMax?n.distanceMax[0]:0,w=Math.random()*2-1,m=Math.random()*at,g=Math.sqrt(Math.max(0,1-w*w));let v=g*Math.cos(m),b=g*Math.sin(m),y=w;n.sign&&(n.sign[0]&&(v=Math.abs(v)*Math.sign(n.sign[0])),n.sign[1]&&(b=Math.abs(b)*Math.sign(n.sign[1])),n.sign[2]&&(y=Math.abs(y)*Math.sign(n.sign[2])));const S=Le(h,p);if(o.x=s[0]+v*S*d[0],o.y=s[1]+b*S*d[1],o.z=s[2]+y*S*d[2],n.speedMax||n.speedMin){const _=Le(n.speedMin,n.speedMax);o.vx+=v*_,o.vy+=b*_,o.vz+=y*_}}{const d=this._cpPos(n.controlPoint);if(d)o.x+=d[0],o.y+=d[1],o.z+=d[2];else{const h=this.controlPoints.find(p=>p.id===n.controlPoint);if(h&&h.lockToPointer){o.alive=!1;return}}}if(this.init.mapAround){const d=this.init.mapAround,h=this._cpPos(d.cp);if(h){const p=d.count,w=this._mapAroundSeq++,m=p>0?w%p/p:0,v=(d.bounds[0]+(d.bounds[1]-d.bounds[0])*m)*at,b=n.distanceMin?n.distanceMin[0]:0,y=n.distanceMax?n.distanceMax[0]:0,S=y>0?y:b;o.x=h[0]+Math.cos(v)*S,o.y=h[1]+Math.sin(v)*S,o.z=h[2];const _=Math.random();o.vx+=d.speedMin[0]+(d.speedMax[0]-d.speedMin[0])*_,o.vy+=d.speedMin[1]+(d.speedMax[1]-d.speedMin[1])*_,o.vz+=d.speedMin[2]+(d.speedMax[2]-d.speedMin[2])*_}}const c=this.init,a=this._ov.speed||1,u=this._ov.size||1;if(o.life=c.life?Math.max(.001,Io(c.life.min,c.life.max,c.life.exp)*this.lifetimeMul):1,o.baseSize=c.size?Io(c.size.min,c.size.max,c.size.exp)*u:u,o.size=o.baseSize,c.color){const d=c.color.min,h=c.color.max,p=Math.random();o.baseR=(d[0]+(h[0]-d[0])*p)/255,o.baseG=(d[1]+(h[1]-d[1])*p)/255,o.baseB=(d[2]+(h[2]-d[2])*p)/255}else o.baseR=o.baseG=o.baseB=1;if(this._ov.color&&(o.baseR=this._ov.color[0],o.baseG=this._ov.color[1],o.baseB=this._ov.color[2]),o.r=o.baseR,o.g=o.baseG,o.b=o.baseB,o.baseAlpha=(c.alpha?Le(c.alpha.min,c.alpha.max):1)*this.opacityMul,o.alpha=o.baseAlpha,c.velocity&&(o.vx+=Le(c.velocity.min[0],c.velocity.max[0])*a,o.vy+=Le(c.velocity.min[1],c.velocity.max[1])*a,o.vz+=Le(c.velocity.min[2],c.velocity.max[2])*a),c.turbulentVelocity){const d=c.turbulentVelocity,h=d.audioMode?Ir(d.audioBounds,this._audioLevel||0):1,p=Le(d.speedMin,d.speedMax)*a*h,w=this.simTime*(d.timeScale||0),m=Dr(o.x*d.scale+d.offset,o.y*d.scale+d.offset,w+o.seed*(d.phaseMax||0),3);o.vx+=m[0]*p,o.vy+=m[1]*p,o.vz+=m[2]*p}c.rotation&&(o.rot=Le(c.rotation.min[2],c.rotation.max[2])),c.angularVelocity&&(o.rotVel=Le(c.angularVelocity.min[2],c.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(o.oscFreq=Le(l.oscPos.freqMin,l.oscPos.freqMax),o.oscAmp=Le(l.oscPos.scaleMin,l.oscPos.scaleMax),o.oscPhase=Le(l.oscPos.phaseMin,l.oscPos.phaseMax)+o.seed*at),l.oscAlpha&&(o.oscAFreq=Le(l.oscAlpha.freqMin,l.oscAlpha.freqMax),o.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||at)),l.oscSize&&(o.oscSFreq=Le(l.oscSize.freqMin,l.oscSize.freqMax),o.oscSPhase=Math.random()*(l.oscSize.phaseMax||at)),l.turbulence.length){const d=l.turbulence[0];o.turbSpeed=Le(d.speedMin,d.speedMax),o.turbPhase=Le(d.phaseMin,d.phaseMax)}if(this.frameCount>1&&(o.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),o.bx=o.x,o.by=o.y,o.bz=o.z,o.trail)for(let d=0;d<o.trail.length;d+=3)o.trail[d]=o.x,o.trail[d+1]=o.y,o.trail[d+2]=o.z}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const r=n.age/n.life,o=this.ops;if(o.movement&&(n.vx+=o.movement.gravity[0]*t,n.vy+=o.movement.gravity[1]*t,n.vz+=o.movement.gravity[2]*t,o.movement.drag>0)){const c=Math.exp(-o.movement.drag*t);n.vx*=c,n.vy*=c,n.vz*=c}o.angularMovement&&(n.rotVel+=(o.angularMovement.force[2]||0)*t,o.angularMovement.drag>0&&(n.rotVel*=Math.exp(-o.angularMovement.drag*t)));for(const c of o.turbulence){const a=c.timeScale||1,u=Dr(n.bx*c.scale,n.by*c.scale,this.simTime*c.scale*a+n.turbPhase,3);n.vx+=u[0]*n.turbSpeed*c.mask[0]*t,n.vy+=u[1]*n.turbSpeed*c.mask[1]*t,n.vz+=u[2]*n.turbSpeed*c.mask[2]*t}for(const c of o.attract){const a=this._cpPos(c.cp);if(!a)continue;const u=a[0]+c.origin[0]-n.x,l=a[1]+c.origin[1]-n.y,d=Math.hypot(u,l);if(d<.001||c.threshold>0&&d>c.threshold)continue;const h=c.threshold>0?1-d/c.threshold:1,p=c.scale*h*t/Math.max(1,d);n.vx+=u*p,n.vy+=l*p}for(const c of o.vortex){const a=this._cpPos(c.cp)||[0,0,0],u=n.x-(a[0]+c.offset[0]),l=n.y-(a[1]+c.offset[1]),d=Math.hypot(u,l);if(d<.001)continue;const h=c.distanceOuter-c.distanceInner,p=h>0?Math.min(1,Math.max(0,(d-c.distanceInner)/h)):0,w=c.audioMode?Ir(c.audioBounds,this._audioLevel||0):1,m=c.speedInner+(c.speedOuter-c.speedInner)*p;n.vx+=-l/d*m*t*w,n.vy+=u/d*m*t*w}for(const c of o.remap){const a=c.inputScale||1,u=Dr(n.bx*.01*a,n.by*.01*a,this.simTime*.1,c.fn==="fbmnoise"?4:2);if(c.output==="velocity")for(let l=0;l<3;l++){const d=(u[l]+1)/2,h=c.rangeMin[l]+(c.rangeMax[l]-c.rangeMin[l])*d;l===0?n.vx=h:l===1?n.vy=h:n.vz=h}else if(c.output==="speed"){const l=(u[0]+1)/2,d=c.rangeMin[0]+(c.rangeMax[0]-c.rangeMin[0])*l,h=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/h*d,n.vy=n.vy/h*d}}if(n.bx+=n.vx*t,n.by+=n.vy*t,n.bz+=n.vz*t,n.rot+=n.rotVel*t,n.x=n.bx,n.y=n.by,n.z=n.bz,o.oscPos){const c=this.simTime*n.oscFreq*at+n.oscPhase,a=o.oscPos.mask;n.x+=Math.sin(c)*n.oscAmp*a[0],n.y+=Math.cos(c)*n.oscAmp*a[1],n.z+=Math.sin(c*.7)*n.oscAmp*a[2]}let i=n.baseSize;if(o.sizeChange){const c=o.sizeChange,a=c.endTime-c.startTime,u=a>0?Math.min(1,Math.max(0,(r-c.startTime)/a)):r>=c.startTime?1:0;i*=c.startValue+(c.endValue-c.startValue)*u}if(o.oscSize){const c=this.simTime*n.oscSFreq*at+n.oscSPhase,a=o.oscSize,u=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;i*=u+Math.sin(c)*l}if(n.size=i,o.colorChange){const c=o.colorChange,a=c.endTime-c.startTime,u=a>0?Math.min(1,Math.max(0,(r-c.startTime)/a)):r>=c.startTime?1:0,l=c.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(c.endValue[0]-l[0])*u,n.g=l[1]+(c.endValue[1]-l[1])*u,n.b=l[2]+(c.endValue[2]-l[2])*u}let s=n.baseAlpha;if(o.alphaFade){const c=o.alphaFade.fadeIn,a=o.alphaFade.fadeOut;c>0&&r<c&&(s*=r/c),a<1&&r>a&&(s*=Math.max(0,(1-r)/(1-a)))}else o.alphaChange||(r<.1?s*=r/.1:r>.85&&(s*=(1-r)/.15));if(o.alphaChange){const c=o.alphaChange,a=c.endTime-c.startTime,u=a>0?Math.min(1,Math.max(0,(r-c.startTime)/a)):r>=c.startTime?1:0;s*=c.startValue+(c.endValue-c.startValue)*u}if(o.oscAlpha){const c=this.simTime*n.oscAFreq*at+n.oscAPhase,a=o.oscAlpha,u=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;s*=u+Math.sin(c)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(r*this.frameCount))),n.trail){const c=n.trail;for(let a=c.length-3;a>=3;a-=3)c[a]=c[a-3],c[a+1]=c[a-2],c[a+2]=c[a-1];c[0]=n.x,c[1]=n.y,c[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(r=>r.id===n);return t?t.lockToPointer?this.pointer?[this.pointer.x+t.offset[0],this.pointer.y+t.offset[1],t.offset[2]]:null:t.offset:null}advance(n,t){if(!(this.paused||!this.visible)){if(this._syncFollow(),!this._warmed&&(this._warmed=!0,this.startTime>0)){const r=.03333333333333333,o=Math.min(900,Math.round(this.startTime/r));for(let i=0;i<o;i++)this._step(r)}this._step(n,t)}}_step(n,t){this.simTime+=n;const r=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=r;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let a=0;a<Math.min(i.instantaneous,this.maxCount);a++)this.spawn(i)}if(i.fill){const u=Math.min(this.maxCount,2048);let l=0;for(let h=0;h<this.pool.length;h++)this.pool[h].alive&&l++;let d=Math.min(u-l,512);for(;d-- >0;)this.spawn(i);continue}if(i.audioDriven){const a=Ir(i.audioBounds,r);if(i.rate>0){const u=i.rate*a*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(u>0))continue;i._accum=(i._accum||0)+u*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let d=0;d<l;d++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*a);let d=0;for(let p=0;p<this.pool.length;p++)this.pool[p].alive&&d++;let h=Math.min(l-d,256);for(;h-- >0;)this.spawn(i)}continue}const s=i.rate*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(s>0))continue;i._accum=(i._accum||0)+s*n;let c=Math.floor(i._accum);if(c>0){i._accum-=c,c>this.maxCount&&(c=this.maxCount);for(let a=0;a<c;a++)this.spawn(i)}}const o=this.pool;for(let i=0;i<o.length;i++)o[i].alive&&this.updateParticle(o[i],n)}render(n,t,r,o,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const c=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,a=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,u=jo(this.trailCfg,this.trailSegments),l=12,d=this.pool;let h=0;for(let G=0;G<d.length;G++)d[G].alive&&h++;if(h===0)return;const p=h*u,w=p*l;(!this._data||this._data.length<w)&&(this._data=new Float32Array(Math.max(w,1024)));const m=this._data;let g=0;const v=this._ov.brightness||1,b=this.sysScale,y=this.spriteStretchX*(this.texAspectX||1),S=this.spriteStretchY*(this.texAspectY||1),_=Math.cos(this.angleZ),C=Math.sin(this.angleZ),N=this.originX,D=this.originY,k=this.scaleX,O=this.scaleY,j=(G,Q)=>{const q=G*k,te=Q*O;return[N+q*_-te*C,i-(D+q*C+te*_)]};for(let G=0;G<d.length;G++){const Q=d[G];if(Q.alive)for(let q=0;q<u;q++){let te=Q.x,me=Q.y,xe=1,We=1;if(c&&Q.trail){te=Q.trail[q*3],me=Q.trail[q*3+1];const Pe=u>1?q/(u-1):0;xe=1-Pe,We=1-Pe*.55}const Ve=j(te,me);let Ee=Q.rot,rt=y,Xe=S;if(a){const Pe=j(Q.x+Q.vx,Q.y+Q.vy);Ee=$o(Pe[0]-Ve[0],Pe[1]-Ve[1]);const Ae=zo(Math.hypot(Q.vx,Q.vy),a.length,a.minLength,a.maxLength);Xe=S*Ae}m[g++]=Ve[0],m[g++]=Ve[1],m[g++]=0,m[g++]=Math.abs(Q.size)*b*We,m[g++]=Ee,m[g++]=Q.r*v,m[g++]=Q.g*v,m[g++]=Q.b*v,m[g++]=Q.alpha*xe,m[g++]=rt,m[g++]=Xe,m[g++]=Q.frame}}const W=this._prog;s.useProgram(W.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,m.subarray(0,g),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(W.uniTex,0),s.uniformMatrix4fv(W.uniMvp,!1,n);const K=this.refract&&this.normalTex&&this.normalTex.glTex;if(W.uniRefract&&s.uniform1i(W.uniRefract,K?1:0),K){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),W.uniNormal&&s.uniform1i(W.uniNormal,1);const G=this.blend!=="additive";if(W.uniSampleScene&&s.uniform1i(W.uniSampleScene,G?1:0),G){const Q=s.drawingBufferWidth||t,q=s.drawingBufferHeight||r;s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE2),this._sceneTex?s.bindTexture(s.TEXTURE_2D,this._sceneTex):(this._sceneTex=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._sceneTex),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGB8,0,0,Q,q,0),W.uniScene&&s.uniform1i(W.uniScene,2),W.uniResolution&&s.uniform2f(W.uniResolution,Q,q),W.uniRefractScale&&s.uniform1f(W.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),W.uniScene&&s.uniform1i(W.uniScene,2)}else W.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(W.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),W.uniScene&&s.uniform1i(W.uniScene,2),W.uniSampleScene&&s.uniform1i(W.uniSampleScene,0));const V=this._frameUniformData();V?(s.uniform1i(W.uniFrameCount,V.count),s.uniform4fv(W.uniFrames,V.arr)):s.uniform1i(W.uniFrameCount,0),s.enable(s.BLEND),this.blend==="additive"?s.blendFunc(s.SRC_ALPHA,s.ONE):s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.depthMask(!1),s.drawArraysInstanced(s.TRIANGLE_STRIP,0,4,p),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=da(n);this._quadBuf=t.quadBuf,this._vbuf=t.vbuf,this._vao=t.vao,this._prog=t.prog}_frameUniformData(){if(this._frameData!==void 0)return this._frameData;let n=this.texFrames;if(!n&&this.sequenceMul>1){const o=this.sequenceMul;n=[];for(let i=0;i<o;i++)for(let s=0;s<o;s++)n.push({ou:s/o,ov:i/o,su:1/o,sv:1/o})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),r=new Float32Array(t*4);for(let o=0;o<t;o++)r[o*4]=n[o].ou,r[o*4+1]=n[o].ov,r[o*4+2]=n[o].su,r[o*4+3]=n[o].sv;return this._frameData={count:t,arr:r},this._frameData}liveCount(){let n=0;for(const t of this.pool)t.alive&&n++;return n}dispose(){this.paused=!0;const n=this.gl;if(n){try{this._vbuf&&n.deleteBuffer(this._vbuf),this._quadBuf&&n.deleteBuffer(this._quadBuf),this._vao&&n.deleteVertexArray(this._vao),this._prog&&this._prog.prog&&n.deleteProgram(this._prog.prog),this._sceneTex&&n.deleteTexture(this._sceneTex)}catch{}this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null}}}const ga=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:pa,particleInstanceSegs:jo,particlePassRefract:Do,rgbaIsBlankWhite:ha,spriteTrailLengthFactor:zo,spriteTrailRotation:$o},Symbol.toStringTag,{value:"Module"})),An=new Map,zr=new Map;let nr=null;function ba(e,n){const t=String(e);zr.set(t,n),An.delete(t)}function va(e){nr=typeof e=="function"?e:null}function ya(){zr.clear(),nr=null,An.clear()}function xa(){return Object.keys(Pn)}function Se(e,n,t){e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=Math.round(Math.min(1,Math.max(0,t))*255)}function Tn(e,n){const{width:t,height:r,rgba:o}=e,i=Math.max(2,Math.round(Math.min(t,r)*.04));for(let s=0;s<r;s++)for(let c=0;c<t;c++){const a=Math.min(c,s,t-1-c,r-1-s);if(a>=i)continue;const u=a/i,l=(s*t+c)*4+3;o[l]=Math.round(o[l]*u)}if(n>0){let s=0;const c=t*r;for(let u=0;u<c;u++)s+=o[u*4+3];const a=s/c/255;if(a>n&&a>0){const u=n/a;for(let l=0;l<c;l++)o[l*4+3]=Math.round(o[l*4+3]*u)}}return e}function $r(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const cn=e=>e*e*(3-2*e),Wo=e=>e*e*e*(e*(e*6-15)+10),jr=(e,n,t)=>e+(n-e)*t,oe=(e,n)=>Math.exp(-(e*e)/(n*n));function Zt(e,n,t,r){const o=Math.min(e,n,t-1-e,t-1-n);return o>=r?1:o/r}function Sn(e,n){const t=new Uint8Array(e*e*4),r=e/2;for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-r)/r,(o+.5-r)/r);let c=0;for(let a=0;a<n.length;a++)c+=n[a].w*oe(s,n[a].r);Se(t,(o*e+i)*4,c)}return{width:e,height:e,rgba:t}}function At(e,n,t){return Sn(e,[n,t])}function Tt(e,n,t,r,o){const i=new Uint8Array(e*e*4),s=e/2,c=Math.max(2,Math.round(e*.03));for(let a=0;a<e;a++)for(let u=0;u<e;u++){const l=(u+.5-s)/s,d=(a+.5-s)/s,h=Math.hypot(l,d),p=Math.atan2(d,l),w=Math.pow(.5+.5*Math.cos(n*p),r);let m=oe(h,o)+w*oe(h,t);m*=Zt(u,a,e,c),Se(i,(a*e+u)*4,m)}return{width:e,height:e,rgba:i}}function nt(e,n,t,r,o){const i=o===void 0?.55:o,s=new Uint8Array(e*n*4);for(let c=0;c<n;c++){const a=c/(n-1),u=r?oe(a-.5,.27):cn(Math.min(1,a/.06))*Math.pow(1-a,1.35);for(let l=0;l<e;l++){const d=l/(e-1)*2-1,h=oe(d,t);Se(s,(c*e+l)*4,h*h*h*u*i)}}return{width:e,height:n,rgba:s}}function Wr(e,n,t){const r=new Uint8Array(e*e*4),o=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const c=Math.hypot((s-o)/o,(i-o)/o);Se(r,(i*e+s)*4,oe(c-n,t*.6)*Math.max(0,1-c))}return{width:e,height:e,rgba:r}}function Vo(e,n){const t={1:{r:.78,t:.048,inner:.06,hi:[[-.28,-.32,.22,.9],[.32,.36,.12,.28]]},2:{r:.7,t:.07,inner:.14,hi:[[-.2,-.28,.3,.72],[.38,.2,.14,.4]]},3:{r:.84,t:.036,inner:.04,hi:[[-.34,-.18,.16,.95],[.2,.42,.1,.22],[.04,-.08,.07,.18]]}},r=t[n]||t[1],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,u=(s+.5-i)/i,l=Math.hypot(a,u);let d=oe(l-r.r,r.t*.85)*Math.max(0,1.05-l);l<r.r&&(d+=r.inner*oe(l,.5));for(let h=0;h<r.hi.length;h++){const p=r.hi[h];d+=p[3]*oe(Math.hypot(a-p[0],u-p[1]),p[2])}Se(o,(s*e+c)*4,d)}return Tn({width:e,height:e,rgba:o},.05)}function En(e,n){const t=e>>1,r=new Uint8Array(e*e*4),o=n===1?[1,2,1,3]:n===2?[2,1,2,3]:[3,1,2,3];for(let i=0;i<2;i++)for(let s=0;s<2;s++){const c=Vo(t,o[i*2+s]);for(let a=0;a<t;a++){const u=(i*t+a)*e,l=a*t;for(let d=0;d<t;d++){const h=(u+s*t+d)*4,p=(l+d)*4;r[h]=c.rgba[p],r[h+1]=c.rgba[p+1],r[h+2]=c.rgba[p+2],r[h+3]=c.rgba[p+3]}}}return{width:e,height:e,rgba:r}}function Xo(e){const n=new Uint8Array(e*e*4),t=e/2,r=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=i>=t?1:0,c=o>=t?1:0,a=c*2+s,u=s*t+t/2,l=c*t+t/2,d=r[a][0],h=r[a][1],p=(i+.5-u)/(t*.4),w=(o+.5-l)/(t*.4),m=Math.cos(d),g=Math.sin(d);let v=p*m+w*g;const b=-p*g+w*m;v+=h*b*.18;const y=1-Math.max(0,b)*.42,S=Math.hypot(v/(.52*y),b/.92);let _=S>=1.12?0:oe(S,.48);_=Math.min(1,_+oe(v,.07)*oe(b,.65)*_*.4),Se(n,(o*e+i)*4,_)}return Tn({width:e,height:e,rgba:n},.11)}function Ie(e,n){const t={0:{rx:.36,ry:.92,wave:0,folds:0},1:{rx:.48,ry:.86,wave:.05,folds:7},2:{rx:.4,ry:.88,wave:.08,folds:5},3:{rx:.58,ry:.72,wave:0,folds:0},5:{rx:.44,ry:.8,wave:.12,folds:9},6:{rx:.52,ry:.78,wave:.07,folds:4},7:{rx:.5,ry:.9,wave:.16,folds:3},8:{rx:.38,ry:.94,wave:.2,folds:2}},r=t[n]||t[0],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,u=(s+.5-i)/i,l=Math.atan2(a,u),d=r.wave?1+r.wave*Math.sin(l*r.folds):1,h=Math.hypot(a/(r.rx*d),u/r.ry);let p=h>=1.12?0:oe(h,.5);p>0&&(p=Math.min(1,p+oe(a,.028)*oe(u,.72)*.28)),Se(o,(s*e+c)*4,p)}return Tn({width:e,height:e,rgba:o},.11)}function ct(e,n){const t=e.width,r=e.height,o=e.rgba,i=n??2.8,s=new Uint8Array(t*r*4),c=(a,u)=>{const l=a<0?0:a>=t?t-1:a,d=u<0?0:u>=r?r-1:u;return o[(d*t+l)*4+3]/255};for(let a=0;a<r;a++)for(let u=0;u<t;u++){const l=(c(u-1,a)-c(u+1,a))*i,d=(c(u,a-1)-c(u,a+1))*i,h=1/Math.hypot(l,d,1),p=(a*t+u)*4;s[p]=Math.round((l*h*.5+.5)*255),s[p+1]=Math.round((d*h*.5+.5)*255),s[p+2]=Math.round((h*.5+.5)*255),s[p+3]=255}return{width:t,height:r,rgba:s}}function Ho(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,c=Math.hypot(i,s),a=c>=1?0:Math.sqrt(Math.max(0,1-c*c)),u=oe(c-.62,.11)*.55;Se(n,(r*e+o)*4,Math.min(1,a*.85+u))}return{width:e,height:e,rgba:n}}function wa(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,c=Math.hypot(i,s),a=Math.atan2(s,i),u=oe(c,.38)*(.55+.45*Math.cos(a*3+c*6));Se(n,(r*e+o)*4,u)}return{width:e,height:e,rgba:n}}function Go(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t,a=Math.hypot(s,c),u=Math.atan2(c,s),l=cn(Math.max(0,Math.cos(u)*.55+.45)),d=oe(a-.68,.07)*l+.35*oe(a-.78,.12)*oe(u-.9,.55);Se(n,(o*e+i)*4,Math.min(1,d)*Zt(i,o,e,r))}return{width:e,height:e,rgba:n}}function Ma(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;r++}return r>0}function _a(e){return!e||!e.rgba?e:Ma(e.rgba)?ct(e,2.8):e}const Aa={"particle/drop":"particle/drop_normal","particle/water/rain_drops_sheet":"particle/water/rain_drops_sheet_normal","particle/bubbles/bubble1":"particle/bubbles/bubble1normal","particle/bubbles/bubble2":"particle/bubbles/bubble2_normal","particle/sharp_halo":"particle/sharp_halo_normal","particle/misc/wave":"particle/normal_splash","particle/halo":"particle/sharp_halo_normal"};function Ta(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:Aa[n]||n+"_normal"}function Sa(e){const n=String(e);return/(^|\/)normal_/.test(n)?null:/_normal$/i.test(n)?n.replace(/_normal$/i,""):/normal$/i.test(n)?n.replace(/normal$/i,""):null}function Ea(e){if(Pn[e])return Pn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?At(64,{r:.18,w:1},{r:.4,w:.2}):ti(e)()}function Yo(e,n,t){const r=$r(t*7919+17);let o=e;const i=[];for(let a=0;a<n;a++){const u=o*o,l=new Float32Array(u*2);for(let d=0;d<u;d++){const h=r()*Math.PI*2;l[d*2]=Math.cos(h),l[d*2+1]=Math.sin(h)}i.push({f:o,g:l,ox:a*7.31,oy:a*3.17}),o*=2}const s=(a,u,l,d,h)=>{const p=a.f,w=(u%p+p)%p,g=((l%p+p)%p*p+w)*2;return a.g[g]*d+a.g[g+1]*h},c=(a,u,l)=>{const d=(u+a.ox)*a.f,h=(l+a.oy)*a.f,p=Math.floor(d),w=Math.floor(h),m=d-p,g=h-w,v=Wo(m),b=Wo(g);return jr(jr(s(a,p,w,m,g),s(a,p+1,w,m-1,g),v),jr(s(a,p,w+1,m,g-1),s(a,p+1,w+1,m-1,g-1),v),b)};return function(u,l,d){const h=d==null?i.length:Math.min(d,i.length);let p=1,w=0,m=0;for(let g=0;g<h;g++)w+=(c(i[g],u,l)*.5+.5)*p,m+=p,p*=.55;return w/m}}function qo(e,n,t){const{width:r,height:o,rgba:i}=e;if(r===n&&o===t)return e;const s=new Uint8Array(n*t*4);for(let c=0;c<t;c++){const a=(c+.5)/t*o-.5,u=Math.max(0,Math.min(o-1,Math.floor(a))),l=Math.max(0,Math.min(o-1,u+1)),d=a-Math.floor(a);for(let h=0;h<n;h++){const p=(h+.5)/n*r-.5,w=Math.max(0,Math.min(r-1,Math.floor(p))),m=Math.max(0,Math.min(r-1,w+1)),g=p-Math.floor(p),v=i[(u*r+w)*4+3],b=i[(u*r+m)*4+3],y=i[(l*r+w)*4+3],S=i[(l*r+m)*4+3],_=(v*(1-g)+b*g)*(1-d)+(y*(1-g)+S*g)*d;Se(s,(c*n+h)*4,_/255)}}return{width:n,height:t,rgba:s}}function It(e,n,t,r,o,i,s){const c=i===void 0?1:i,a=s===void 0?200:s,u=256,l=Yo(n,t,r),d=new Uint8Array(u*u*4),h=u/2,p=u*u,w=new Float32Array(p);let m=1,g=0;for(let S=0;S<p;S++){const _=S%u,C=S/u|0,N=(_+.5)/u,D=(C+.5)/u,k=l(N+5.2,D+1.3,2)-.5,O=l(N+9.7,D+8.1,2)-.5,j=w[S]=l(N+k*.45,D+O*.45);j<m&&(m=j),j>g&&(g=j)}const v=g-m||1;for(let S=0;S<u;S++)for(let _=0;_<u;_++){const C=(w[S*u+_]-m)/v,N=Math.hypot((_+.5-h)/h,(S+.5-h)/h),D=Math.pow(Math.max(0,1-N),c);let k=Math.max(0,(C-(1-o))/(o||1));k=cn(Math.min(1,k))*D,Se(d,(S*u+_)*4,k)}let b=0;for(let S=0;S<p;S++)b=Math.max(b,d[S*4+3]);if(b>0&&b<a){const S=a/b;for(let _=0;_<p;_++)d[_*4+3]=Math.round(Math.min(255,d[_*4+3]*S))}const y={width:u,height:u,rgba:d};return u===e?y:qo(y,e,e)}function Vr(e,n){const t=e,r=Yo(3,5,n??23),o=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let c=1,a=0;for(let h=0;h<i;h++){const p=h%t,w=h/t|0,m=(p+.5)/t,g=(w+.5)/t,v=r(m+2.1,g+4.7,2)-.5,b=r(m+6.3,g+1.9,2)-.5,y=s[h]=r(m+v*.28,g+b*.55);y<c&&(c=y),y>a&&(a=y)}const u=a-c||1;for(let h=0;h<t;h++)for(let p=0;p<t;p++){const w=(h+.5)/t,m=(p+.5)/t*2-1,g=.1+.52*Math.pow(w,1.25),v=(s[h*t+p]-c)/u,b=oe(m/(g||.01),.55)*oe(w-.58,.42);let y=cn(Math.min(1,Math.max(0,(v-.18)/.72)))*b;y*=w<.06?w/.06:1,Se(o,(h*t+p)*4,y)}let l=0;for(let h=0;h<i;h++)l=Math.max(l,o[h*4+3]);if(l>0&&l<220){const h=220/l;for(let p=0;p<i;p++)o[p*4+3]=Math.round(Math.min(255,o[p*4+3]*h))}const d=Tn({width:t,height:t,rgba:o},.08);return t===e?d:qo(d,e,e)}function Xr(e,n,t,r){const o=new Uint8Array(e*n*4),i=e/t,s=n/r;for(let c=0;c<n;c++)for(let a=0;a<e;a++){const u=Math.floor(a/i),l=Math.floor(c/s),d=(a+.5-u*i)/i*2-1,h=(c+.5-l*s)/s*2-1,p=1-Math.max(0,h)*.45,w=Math.hypot(d/(.52*p),h/.8),m=w>=1.12?0:oe(w,.48);Se(o,(c*e+a)*4,m)}return{width:e,height:n,rgba:o}}function Zo(e){const n=new Uint8Array(e*e*4),t=$r(7),r=[];for(let o=0;o<11;o++)r.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5)/e,c=(o+.5)/e;let a=0;for(const u of r){const l=s-u.x,d=c-u.y,h=Math.cos(u.rot),p=Math.sin(u.rot),w=(l*h+d*p)/u.rx,m=(-l*p+d*h)/u.ry,g=oe(Math.hypot(w,m),.55);g>a&&(a=g)}Se(n,(o*e+i)*4,a)}return{width:e,height:e,rgba:n}}function rr(e,n){const t=n??19,r=$r(t),o=h=>Math.min(.86,Math.max(.14,h)),i=5+t%4,s=[];let c=o(.5+(r()-.5)*.16);for(let h=0;h<=i;h++){const p=.06+h/i*.86;h>0&&(c=o(c+(r()-.5)*.32)),s.push([c,p])}const a=[];for(let h=0;h<s.length-1;h++)a.push([s[h],s[h+1],1]);const u=1+t%2;for(let h=0;h<u;h++){const p=1+(t+h*3)%Math.max(1,s.length-2),w=s[p],m=[w];let g=w[0],v=w[1];const b=2+t%2;for(let y=0;y<b;y++)g=o(g+(r()-.5)*.36),v=Math.min(.92,v+.1+r()*.08),m.push([g,v]);for(let y=0;y<m.length-1;y++)a.push([m[y],m[y+1],.45+h*.1])}const l=new Uint8Array(e*e*4),d=Math.max(2,Math.round(e*.04));for(let h=0;h<e;h++)for(let p=0;p<e;p++){const w=(p+.5)/e,m=(h+.5)/e;let g=9,v=0;for(const[y,S,_]of a){const C=S[0]-y[0],N=S[1]-y[1],D=C*C+N*N||1e-8,k=Math.max(0,Math.min(1,((w-y[0])*C+(m-y[1])*N)/D)),O=Math.hypot(w-(y[0]+C*k),m-(y[1]+N*k));O/_<g&&(g=O/_,v=_)}const b=.95*oe(g,.012)+.3*oe(g,.05)*v;Se(l,(h*e+p)*4,Math.min(1,b)*Zt(p,h,e,d))}return{width:e,height:e,rgba:l}}function Hr(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++)for(let o=0;o<e;o++){const i=(o+.5-e/2)/(e/2),s=(r+.5-n/2)/(n/2),c=oe(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),a=Math.hypot(i/.34,(s-.42)/.3),u=a>=1?0:oe(a,.5);Se(t,(r*e+o)*4,Math.max(c,u))}return{width:e,height:n,rgba:t}}function Pa(e){return At(e,{r:.1,w:1},{r:.3,w:.16})}function Gr(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++){const o=(r+.5)/n,i=cn(Math.min(1,Math.min(o/.08,(1-o)/.08))),s=oe(o-.46,.24)*i,c=.5*(1-cn(Math.min(1,Math.max(0,(o-.42)/.5)))*.6);for(let a=0;a<e;a++){const u=(a+.5-e/2)/(e/2);Se(t,(r*e+a)*4,oe(Math.abs(u)/(c||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function Ko(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t,a=oe(Math.hypot(s,c),.42),u=oe(Math.hypot(s-.34,c),.36),l=Math.max(0,a-u*1.08)*Zt(i,o,e,r);Se(n,(o*e+i)*4,l)}return{width:e,height:e,rgba:n}}function Qo(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t;let a=oe(Math.hypot(s,c),.08);for(let u=0;u<6;u++){const l=u*Math.PI/3,d=Math.cos(l),h=Math.sin(l),p=s*d+c*h,w=-s*h+c*d;if(p<0)continue;const m=Math.max(0,1.02-p/.72);a+=oe(w,.028)*oe(p,.5)*m,a+=.55*oe(w-(p-.28)*.65,.02)*oe(p-.28,.12)*m,a+=.55*oe(w+(p-.28)*.65,.02)*oe(p-.28,.12)*m,a+=.4*oe(w-(p-.48)*.7,.016)*oe(p-.48,.08)*m,a+=.4*oe(w+(p-.48)*.7,.016)*oe(p-.48,.08)*m}Se(n,(o*e+i)*4,Math.min(1,a)*Zt(i,o,e,r))}return{width:e,height:e,rgba:n}}function Jo(e,n){const t=new Uint8Array(e*e*4),r=e/2,o=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-r)/r*1.55,u=(s+.5-r)/r*1.55,l=Math.abs(Math.abs(a)+Math.abs(u)-.55);let d=oe(l,.016);i===0?(d+=oe(a,.012)*oe(u,.38),d+=oe(u,.012)*oe(a,.38)):i===1?(d+=oe(a-u,.012)*oe(a+u,.36),d+=oe(a+u,.012)*oe(a-u,.36)):(d+=oe(Math.hypot(a,u)-.26,.014),d+=oe(a,.012)*oe(u,.22)),Se(t,(s*e+c)*4,Math.min(1,d)*Zt(c,s,e,o))}return Tn({width:e,height:e,rgba:t},.03)}function Yr(e){let n=0;const t=String(e);for(let r=0;r<t.length;r++)n=n*31+t.charCodeAt(r)|0;return n}function ei(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.03));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t,a=Math.hypot(s,c),u=oe(a,.07)+.85*oe(s,.62)*oe(c,.045)+.22*oe(s,.92)*oe(c,.018);Se(n,(o*e+i)*4,Math.min(1,u)*Zt(i,o,e,r))}return{width:e,height:e,rgba:n}}const Pn={"particle/halo_6":()=>At(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>ct(Ho(256),3.2),"particle/drop_normal":()=>ct(Gr(128,512),3.4),"particle/normal_ring_smooth":()=>ct(Wr(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>ct(wa(256),2.8),"particle/water/rain_drops_sheet_normal":()=>ct(Xr(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>ct(En(256,1),3.2),"particle/bubbles/bubble2_normal":()=>ct(En(256,2),3.2),"particle/sharp_halo_normal":()=>ct(Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>nt(128,512,.46,!0),"particle/beam/beam_1":()=>nt(128,512,.34,!0),"particle/beam/beam_2":()=>nt(128,512,.22,!0),"particle/beam/beam_2_fade":()=>nt(128,512,.24,!1),"particle/light/light_shafts_0":()=>nt(128,512,.42,!0),"particle/light/light_shafts_1":()=>nt(128,512,.3,!0),"particle/light/light_shafts_3":()=>nt(128,512,.26,!0),"particle/light/light_shafts_5":()=>nt(128,512,.23,!0),"particle/light/light_shafts_6":()=>nt(128,512,.2,!0),"particle/nature/rosepetals":()=>Xo(256),"particle/nature/leaves":()=>Ie(256,0),"particle/nature/leaves1":()=>Ie(256,1),"particle/nature/leaves2":()=>Ie(256,2),"particle/nature/leaves3":()=>Ie(256,3),"particle/nature/leaves5":()=>Ie(256,5),"particle/nature/leaves6":()=>Ie(256,6),"particle/nature/leaves7":()=>Ie(256,7),"particle/nature/leaves8":()=>Ie(256,8),"particle/nature/snow":()=>Qo(256),"particle/halo":()=>At(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>At(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>At(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>Sn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>At(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>Sn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>Pa(128),"particle/light/flare_0":()=>Tt(256,6,.58,10,.08),"particle/light/flare_1":()=>Tt(512,4,.62,14,.07),"particle/light/flare_2":()=>ei(256),"particle/drop":()=>Gr(128,512),"particle/nature/rain1":()=>nt(128,512,.16,!0,.6),"particle/nature/rain2":()=>nt(128,512,.24,!0,.55),"particle/water/rain_drops_sheet":()=>Xr(256,512,2,4),"particle/fog/fog1":()=>It(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>It(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>It(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>It(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>It(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>It(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>Wr(512,.72,.085),"particle/misc/star_0":()=>Tt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>En(256,1),"particle/bubbles/bubble2":()=>En(256,2),"particle/bubbles/bubble3":()=>En(256,3),"particle/debris/debris1":()=>Zo(128),"particle/lightning/lightning1":()=>rr(256,3),"particle/lightning/lightning2":()=>rr(256,11),"particle/lightning/lightning3":()=>rr(256,19),"particle/fire/fire1":()=>Vr(256,23),"particle/fire/fire2":()=>Vr(256,41),"particle/star":()=>Tt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>Go(256),"particle/sickle":()=>Ko(256),"particle/magic/glyph_4":()=>Jo(256,4),"@sparkle":()=>Tt(256,4,.6,16,.08),"@star":()=>Tt(256,5,.62,8,.1),"@trail":()=>Hr(128,256)};function ti(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=Sa(e);return t?()=>ct(Ea(t),2.8):()=>ct(Ho(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>Xo(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>Ie(256,8):/leaves7/.test(n)?()=>Ie(256,7):/leaves6/.test(n)?()=>Ie(256,6):/leaves5/.test(n)?()=>Ie(256,5):/leaves3/.test(n)?()=>Ie(256,3):/leaves2/.test(n)?()=>Ie(256,2):/leaves1/.test(n)?()=>Ie(256,1):()=>Ie(256,0):/circle_wind|windcircle/.test(n)?()=>Go(256):/fog|cloud|mist|vapor/.test(n)?()=>It(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>It(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>nt(128,512,.3,!0):/flare/.test(n)?()=>ei(256):/bubble/.test(n)?()=>Vo(256,1):/ring|wave/.test(n)?()=>Wr(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>Vr(256,Yr(n)):/sickle|crescent|moon/.test(n)?()=>Ko(256):/glyph|magic|rune/.test(n)?()=>Jo(256,Yr(n)):/snowflake|雪花|snow/.test(n)?()=>Qo(256):/流星|meteor|shooting/.test(n)?()=>Hr(128,256):/star|星/.test(n)?()=>Tt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>Tt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>Xr(256,512,2,4):/drop|rain/.test(n)?()=>Gr(128,512):/debris|dirt|rock/.test(n)?()=>Zo(128):/lightning|bolt|arc/.test(n)?()=>rr(256,Yr(n)):/note|music/.test(n)?()=>Tt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>Hr(128,256):()=>At(256,{r:.12,w:1},{r:.3,w:.15})}function Ca(e){if(An.has(e))return An.get(e);let n=null;const t=zr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&nr)try{n=nr(e)}catch{n=null}if(!n&&Pn[e])try{n=Pn[e]()}catch{n=null}if(!n)try{n=ti(e)()}catch{n=null}return n||(n=At(256,{r:.12,w:1},{r:.3,w:.15})),An.set(e,n),n}function Ra(e){return typeof e=="string"&&e.indexOf("particle/")===0}const La=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:Ca,isBuiltinParticleTextureName:Ra,listBuiltinParticleTextureNames:xa,particleNormalNameForAlbedo:Ta,prepareParticleNormalTexture:_a,resetParticleTextureFactories:ya,setParticleTextureFactory:ba,setParticleTextureProvider:va},Symbol.toStringTag,{value:"Module"})),ni=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Ot(e,n,t){const r=t||new Float32Array(16);for(let o=0;o<4;o++)for(let i=0;i<4;i++)r[o*4+i]=e[i]*n[o*4]+e[4+i]*n[o*4+1]+e[8+i]*n[o*4+2]+e[12+i]*n[o*4+3];return r}function ri(e){const n=[];for(let r=0;r<4;r++)n.push([e[r],e[4+r],e[8+r],e[12+r],0,0,0,0]),n[r][4+r]=1;for(let r=0;r<4;r++){let o=r;for(let c=r+1;c<4;c++)Math.abs(n[c][r])>Math.abs(n[o][r])&&(o=c);const i=n[r];n[r]=n[o],n[o]=i;const s=n[r][r];if(Math.abs(s)<1e-12)return Float32Array.from(ni);for(let c=0;c<8;c++)n[r][c]/=s;for(let c=0;c<4;c++){if(c===r)continue;const a=n[c][r];if(a!==0)for(let u=0;u<8;u++)n[c][u]-=a*n[r][u]}}const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++)t[r*4+o]=n[o][4+r];return t}function qr(e,n,t,r,o,i,s,c,a,u){const l=u||new Float32Array(16),d=Math.cos(r),h=Math.sin(r),p=Math.cos(o),w=Math.sin(o),m=Math.cos(i),g=Math.sin(i);return l[0]=m*p*s,l[1]=g*p*s,l[2]=-w*s,l[3]=0,l[4]=(m*w*h-g*d)*c,l[5]=(g*w*h+m*d)*c,l[6]=p*h*c,l[7]=0,l[8]=(m*w*d+g*h)*a,l[9]=(g*w*d-m*h)*a,l[10]=p*d*a,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function Cn(e,n){const t=[];for(;n<e.byteLength;){const o=e.getUint8(n++);if(o===0)break;t.push(o)}let r="";try{r=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{r=String.fromCharCode.apply(null,t)}return{value:r,next:n}}function or(e,n,t=0){const r=[];for(let o=0;o<n.length;o++)r.push(n.charCodeAt(o));e:for(let o=t;o<=e.length-r.length;o++){for(let i=0;i<r.length;i++)if(e[o+i]!==r[i])continue e;return o}return-1}function Fa(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode.apply(null,Array.from(e.subarray(0,8)));if(!t.startsWith("MDLV"))throw new Error("\u4E0D\u662F MDL: "+t);const r=Cn(n,21),i=parseInt(t.slice(4),10)>=23?[{lenOff:32,stride:80,uv:72,bone:40,weight:56},{lenOff:32,stride:48,uv:40,bone:-1,weight:-1}]:[{lenOff:8,stride:52,uv:44,bone:12,weight:28},{lenOff:4,stride:52,uv:44,bone:12,weight:28},{lenOff:32,stride:80,uv:72,bone:40,weight:56}];let s=null,c=0,a=0;for(const G of i){const Q=r.next+G.lenOff;if(Q+4>e.byteLength)continue;const q=n.getUint32(Q,!0);if(q>0&&q%G.stride===0&&Q+4+q<=e.byteLength){s=G,c=q,a=Q;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(G=>G.stride).join("/")+"\uFF09");const u=a+4,l=c/s.stride,d=new Float32Array(l*3),h=new Float32Array(l*2),p=new Float32Array(l*4),w=new Float32Array(l*4);for(let G=0;G<l;G++){const Q=u+G*s.stride;if(d[G*3]=n.getFloat32(Q,!0),d[G*3+1]=n.getFloat32(Q+4,!0),d[G*3+2]=n.getFloat32(Q+8,!0),h[G*2]=n.getFloat32(Q+s.uv,!0),h[G*2+1]=n.getFloat32(Q+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let q=0;q<4;q++)p[G*4+q]=n.getUint32(Q+s.bone+q*4,!0),w[G*4+q]=n.getFloat32(Q+s.weight+q*4,!0);else p[G*4]=0,w[G*4]=1}const m=n.getUint32(u+c,!0),g=u+c+4,v=l>65535&&m%4===0,b=v?m/4:m/2,y=v?new Uint32Array(b):new Uint16Array(b);if(v)for(let G=0;G<b;G++)y[G]=n.getUint32(g+G*4,!0);else for(let G=0;G<b;G++)y[G]=n.getUint16(g+G*2,!0);const S=Ua(e,n),_=ka(e,n,S.length),C=Ia(e,n,S),N=Na(e,n,S.length),D=[],k=[],O=[];if(S.length>0){const G=S.map((q,te)=>{const me=q.matrix,xe=Math.hypot(me[0],me[1]),We=Math.hypot(me[4],me[5]);return O[te]=Float32Array.from([me[12],me[13],me[14],0,0,Math.atan2(me[1],me[0]),xe||1,We||1,me[10]||1]),Float32Array.from(me)});for(let q=0;q<S.length;q++){const te=O[q],me=S[q].matrix;Math.hypot(te[0]-me[12],te[1]-me[13])>.001&&(G[q]=qr(te[0],te[1],te[2],te[3],te[4],te[5],te[6],te[7],te[8],new Float32Array(16)))}const Q=[];for(let q=0;q<S.length;q++){const te=S[q].parent;Q[q]=te>=0&&te<q?Ot(Q[te],G[q]):Float32Array.from(G[q])}for(let q=0;q<S.length;q++)D[q]=ri(Q[q]);if(C){const q=[];for(let te=0;te<S.length;te++){const me=S[te].parent;q[te]=me>=0&&me<te?Ot(q[me],C[te]):Float32Array.from(C[te])}for(let te=0;te<S.length;te++)k[te]=Ot(q[te],D[te])}}let j=1/0,W=-1/0,K=1/0,V=-1/0;for(let G=0;G<l;G++){const Q=d[G*3],q=d[G*3+1];Q<j&&(j=Q),Q>W&&(W=Q),q<K&&(K=q),q>V&&(V=q)}return{magic:t,materialPath:r.value,vertexCount:l,positions:d,uvs:h,boneIdx:p,weights:w,indexCount:b,indexType:v?"u32":"u16",indices:y,bones:S,animations:_,animBound:Ba(_,S),invBindWorld:D,bindTRS:O.length>0?O:null,attachments:N.length>0?N:null,restCorrection:k.length>0?k:null,bounds:{minX:j,maxX:W,minY:K,maxY:V}}}function Na(e,n,t){const r=or(e,"MDAT");if(r<0)return[];const o=n.getUint16(r+13,!0);if(o<=0||o>256)return[];const i=[];let s=r+15;for(let c=0;c<o&&!(s+2>e.length);c++){const a=n.getUint16(s,!0),u=Cn(n,s+2);if(u.next+64>e.length)break;const l=new Float32Array(16);for(let d=0;d<16;d++)l[d]=n.getFloat32(u.next+d*4,!0);a<t&&i.push({bone:a,name:u.value,matrix:l}),s=u.next+64}return i}function Ua(e,n){const t=or(e,"MDLS");if(t<0)return[];const r=n.getUint32(t+13,!0);if(r<=0||r>1024)return[];const o=[];let i=t+17;for(let s=0;s<r;s++){if(i+77>n.byteLength)return o;const c=n.getUint32(i+1,!0),a=n.getInt32(i+5,!0),u=new Float32Array(16);for(let d=0;d<16;d++)u[d]=n.getFloat32(i+13+d*4,!0);const l=Cn(n,i+13+64);o.push({id:c,parent:a>=0&&a<r?a:-1,matrix:u}),i=l.next}return o}function ka(e,n,t){const r=or(e,"MDLA");if(r<0)return[];let o=r+9;const i=n.getUint32(o,!0);o+=4;const s=n.getUint32(o,!0);if(o+=4,s<=0||s>256)return[];const c=[];for(let a=0;a<s&&!(o+16>n.byteLength);a++){const u=n.getUint32(o,!0);o+=8;const l=Cn(n,o);o=l.next;const d=Cn(n,o);if(o=d.next,o+16>n.byteLength)break;const h=n.getFloat32(o,!0);o+=4;const p=n.getUint32(o,!0);o+=8;const w=n.getUint32(o,!0);if(o+=4,w>1024)break;const m=[];for(let g=0;g<w&&!(o+8>n.byteLength);g++){o+=4;const v=n.getUint32(o,!0);o+=4;const b=Math.floor(v/36);if(o+v>n.byteLength)break;const y=new Float32Array(b*9);for(let S=0;S<b;S++){const _=o+S*36;for(let C=0;C<9;C++)y[S*9+C]=n.getFloat32(_+C*4,!0)}o+=v,m.push({frameCount:b,keyframes:y})}if(o+=35,m.length>0&&p>0&&h>0&&c.push({id:u,name:l.value,mode:d.value,fps:h,frameCount:p,duration:p/h,tracks:m}),o>=i)break}return c}function Ba(e,n){let t=0,r=0;for(const o of e)for(let i=0;i<o.tracks.length;i++){const s=o.tracks[i];if(!s)continue;const c=n[i],a=c?c.matrix[12]:0,u=c?c.matrix[13]:0,l=s.keyframes;for(let d=0;d<s.frameCount;d++){const h=Math.abs(l[d*9]-a),p=Math.abs(l[d*9+1]-u);h>t&&(t=h),p>r&&(r=p)}}return{x:t,y:r}}function Ia(e,n,t){if(t.length===0)return null;const r=or(e,"MDLE");if(r<0)return null;const o=r+8+1+4+4;if(o+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const c=new Float32Array(16);for(let a=0;a<16;a++)c[a]=n.getFloat32(o+s*64+a*4,!0);i.push(c)}return i}function Oa(e,n,t,r){const o=e.frameCount;if(o===0)return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=0,r[6]=1,r[7]=1,r[8]=1,r;const i=t*n.fps;let s,c,a;if(n.mode==="loop"){const p=Math.max(1,o-1),w=(i%p+p)%p;s=Math.floor(w),c=(s+1)%o,a=w-s}else if(n.mode==="mirror"){const p=Math.max(1,o-1),w=p*2;let m=(i%w+w)%w;m>p&&(m=w-m),s=Math.floor(m),c=Math.min(s+1,o-1),a=m-s}else{const p=Math.min(Math.max(i,0),o-1);s=Math.floor(p),c=Math.min(s+1,o-1),a=p-s}const u=e.keyframes,l=s*9,d=c*9,h=1-a;for(let p=0;p<9;p++)if(p>=3&&p<=5){let w=u[d+p]-u[l+p];w>Math.PI?w-=2*Math.PI:w<-Math.PI&&(w+=2*Math.PI),r[p]=u[l+p]+w*a}else r[p]=u[l+p]*h+u[d+p]*a;return r}function Da(e,n,t){const r=e.bindTRS&&e.bindTRS[n];if(r)return t.set(r),t;const o=e.bones[n].matrix;return t[0]=o[12],t[1]=o[13],t[2]=o[14],t[3]=0,t[4]=0,t[5]=Math.atan2(o[1],o[0]),t[6]=Math.hypot(o[0],o[1])||1,t[7]=Math.hypot(o[4],o[5])||1,t[8]=o[10]||1,t}function Zr(e,n,t,r){const o=e.bones,i=o.length;if(i===0)return null;const s=!!(r&&r.size>0);if(!e._skin||e._skin.length!==i*16){e._skin=new Float32Array(i*16),e._local=[],e._world=[],e._tmp=new Float32Array(16),e._tmp2=new Float32Array(16);for(let h=0;h<i;h++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const c=Array.isArray(t)&&t.length>0,a=[];if(c)for(const h of t){if(h.visible===!1||h.visible===0)continue;const p=e.animations.find(w=>w.id===h.animation);p&&a.push({anim:p,additive:!!h.additive,blend:typeof h.blend=="number"?h.blend:1,rate:typeof h.rate=="number"?h.rate:1})}if(a.length===0&&!c){const h=e.animations[0];if(h)a.push({anim:h,additive:!1,blend:1,rate:1});else if(!s)return null}const u=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),d=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let h=0;h<i;h++){Da(e,h,u),l.set(u);let p=!1,w=0;for(const g of a){const v=g.anim.tracks[h];if(!v)continue;Oa(v,g.anim,n*g.rate,d);const b=g.blend;if(g.additive){for(let y=0;y<9;y++){let S=d[y]-u[y];y>=3&&y<=5&&(S>Math.PI?S-=2*Math.PI:S<-Math.PI&&(S+=2*Math.PI)),l[y]+=S*b}w+=b}else for(let y=0;y<9;y++)l[y]=l[y]*(1-b)+d[y]*b;p=!0}if(w>1)for(let g=0;g<9;g++)l[g]=u[g]+(l[g]-u[g])/w;const m=s?r.get(h):void 0;m&&(l[0]=m[0],l[1]=m[1],l[2]=m[2],p=!0),p?qr(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[h]):qr(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],e._local[h])}for(let h=0;h<i;h++){const p=o[h].parent;p>=0&&p<h?Ot(e._world[p],e._local[h],e._world[h]):e._world[h].set(e._local[h])}for(let h=0;h<i;h++)Ot(e._world[h],e.invBindWorld[h],e._tmp),e._skin.set(e._tmp,h*16);return e._skin}function oi(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:ri(e.invBindWorld[n])}function za(e,n){return Ot(e,n)}function ii(e,n){if(!e||!e.attachments||typeof n!="string"||n===""||!e._world)return null;for(const t of e.attachments)if(t.name===n)return t.bone<0||t.bone>=e._world.length?null:Ot(e._world[t.bone],t.matrix);return null}function si(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const r=oi(e,t.bone);return r?Ot(r,t.matrix):null}return null}function Kr(e,n,t){const r=e&&e.angles&&e.angles[2]||0,o=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=r*Math.PI/180,c=Math.cos(s),a=Math.sin(s),u=n*o,l=t*i;return[u*c-l*a,u*a+l*c]}function $a(e){const n=new Map,t=new Map;for(const i of e){if(!i||i.id===void 0||i.id===null||(n.set(i.id,i),i.parentId===void 0||i.parentId===null))continue;const s=t.get(i.parentId);s?s.push(i):t.set(i.parentId,[i])}const r=(i,s)=>{const c=t.get(i.id);if(c)for(const a of c)s.push(a),r(a,s)},o=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const c=n.get(i.parentId);if(!c||!c.puppet)continue;const a=si(c.puppet,s);if(!a)continue;const u=a[12],l=a[13],d=Kr(c,u,l),h=[];r(i,h),i.origin[0]+=d[0],i.origin[1]+=d[1];for(const p of h)p.origin[0]+=d[0],p.origin[1]+=d[1];o.push({layer:i,parent:c,name:s,bindX:u,bindY:l,desc:h})}for(const i of o){i.baseX=i.layer.origin[0],i.baseY=i.layer.origin[1],i.subtree=[{layer:i.layer,x:i.layer.origin[0],y:i.layer.origin[1]}];for(const s of i.desc)i.subtree.push({layer:s,x:s.origin[0],y:s.origin[1]})}return o}function ja(e,n,t){if(!e||e.length===0)return;const r=new Set,o=[];for(const s of e){const c=s.parent&&s.parent.puppet;if(!c){o.push(null);continue}if(!r.has(c)){r.add(c);const u=typeof t=="function"?t(s.parent):null;Zr(c,n,s.parent.animationLayers,u)}const a=ii(c,s.name);if(!a){o.push(null);continue}o.push(Kr(s.parent,a[12]-s.bindX,a[13]-s.bindY))}const i=new Set;for(const s of e){const c=s.subtree||[{layer:s.layer,x:s.baseX,y:s.baseY}];for(const a of c)i.has(a.layer)||(i.add(a.layer),a.layer.origin[0]=a.x,a.layer.origin[1]=a.y)}for(let s=0;s<e.length;s++){const c=e[s],a=o[s],u=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(a)for(const l of u)l.layer.origin[0]+=a[0],l.layer.origin[1]+=a[1]}}const Wa=128,ir=24;function Va(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(ir,Math.min(Wa,t))}const Xa=e=>`#version 300 es
139
+ }`,o=(f,l)=>{const d=e.createShader(f);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(d));return d},r=e.createProgram();if(e.attachShader(r,o(e.VERTEX_SHADER,n)),e.attachShader(r,o(e.FRAGMENT_SHADER,t)),e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(r));const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-.5,-.5,.5,-.5,-.5,.5,.5,.5]),e.STATIC_DRAW);const s=e.createBuffer(),c=e.createVertexArray();e.bindVertexArray(c),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,8,0),e.vertexAttribDivisor(0,0),e.bindBuffer(e.ARRAY_BUFFER,s);const a=56;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,a,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,a,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,a,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,a,36),e.vertexAttribDivisor(4,1),e.enableVertexAttribArray(5),e.vertexAttribPointer(5,2,e.FLOAT,!1,a,48),e.vertexAttribDivisor(5,1),e.bindVertexArray(null),{prog:{prog:r,uniTex:e.getUniformLocation(r,"u_tex"),uniNormal:e.getUniformLocation(r,"u_normal"),uniScene:e.getUniformLocation(r,"u_scene"),uniRefract:e.getUniformLocation(r,"u_refract"),uniSampleScene:e.getUniformLocation(r,"u_sampleScene"),uniResolution:e.getUniformLocation(r,"u_resolution"),uniRefractScale:e.getUniformLocation(r,"u_refractScale"),uniMvp:e.getUniformLocation(r,"u_mvp"),uniFrameCount:e.getUniformLocation(r,"u_frameCount"),uniFrames:e.getUniformLocation(r,"u_frames")},quadBuf:i,vbuf:s,vao:c}}function Ho(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function Aa(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let o=0;for(let r=0;r<n;r+=t){const i=r*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;o++}return o>0}function Xo(e,n,t,o){let r=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(o)||0;return i>0&&(r=Math.max(i,r)),s>0&&(r=Math.min(s,r)),r}function Vr(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function Go(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}function Yo(e){if(!e||e.kind!=="ropetrail")return 1;const n=Math.round(Number(e.segments)||0);return n>=2?Math.min(32,n):8}function qo(e){if(!e||e.kind!=="ropetrail")return 0;const n=Number(e.length);return Number.isFinite(n)&&n>0?n:.2}function Wr(e){return e.life>0?e.age/e.life:0}class _a{constructor(){this.alive=!1,this.x=this.y=this.z=0,this.vx=this.vy=this.vz=0,this.bx=this.by=this.bz=0,this.age=0,this.life=1,this.size=1,this.baseSize=1,this.rot=0,this.rotVel=0,this.r=this.g=this.b=1,this.baseR=this.baseG=this.baseB=1,this.alpha=1,this.baseAlpha=1,this.seed=0,this.frame=0,this.oscPhase=0,this.oscFreq=0,this.oscAmp=0,this.oscAPhase=0,this.oscAFreq=0,this.oscSPhase=0,this.oscSFreq=0,this.turbSpeed=0,this.turbPhase=0,this.trail=null,this.trailClock=0,this.seq=0}}class Ta{constructor(n,t,o,r){this.gl=n,this.model=t||{},this.override=o||{},this.layer=r||null;const i=r&&r.origin?r.origin:[0,0,0],s=r&&r.scale?r.scale:[1,1,1],c=r&&r.angles?r.angles:[0,0,0];this.originX=i[0]||0,this.originY=i[1]||0,this.originZ=i[2]||0,this.scaleX=s[0]===0?1:s[0],this.scaleY=s[1]===0?1:s[1],this.angleZ=(c[2]||0)*Math.PI/180;const a=Math.abs(this.scaleX),f=Math.abs(this.scaleY);this.sysScale=Math.min(a,f)||1,this.spriteStretchX=a/this.sysScale,this.spriteStretchY=f/this.sysScale,this.maxCount=Math.max(1,Math.min(2e4,G(this.model.maxcount,100))),this.simTime=0,this.paused=!1,this.texture=null,this.normalTex=null,this.material=null,this.blend="translucent",this.refract=!1,this.refractAmount=.04,this.opacityMul=1,this.lifetimeMul=1,this.visible=!0,this._ready=!1,this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null,this.sequenceMul=Math.max(1,Math.round(G(this.model.sequencemultiplier,1))),this.animationMode=this.model.animationmode||null,this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul,this.texAspectX=1,this.texAspectY=1,this.controlPoints=(this.model.controlpoint||[]).filter(Boolean).map(l=>({id:G(l.id,0),lockToPointer:!!l.locktopointer||(G(l.flags,0)&1)!==0,offset:me(l.offset),x:0,y:0,z:0})),this.pointer=null,this._followParent=null,this._followMode=null,this._followOffset=[0,0,0],this.ropeRenderer=null,this._seq=0,this._ropeOrder=[],this._ov={},this._applyOverride(),this.startTime=Math.max(0,Math.min(30,G(this.model.starttime,0))),this._warmed=!1,this._compile()}reapplyOverride(){this._applyOverride()}_applyOverride(){this._ov={},this.opacityMul=1,this.lifetimeMul=1,this.maxCount=Math.max(1,Math.min(2e4,G(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const o=n[t],r=o&&typeof o=="object"&&"value"in o?o.value:o;if(t==="count"){const i=G(this.model.maxcount,100),s=Number(r),c=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*c))),this._ov.countMul=c}else if(t==="alpha")this.opacityMul=Number(r),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=me(r);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(r)||1:t==="rate"?(this._ov.rateMul=Number(r),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(r)||1:t==="lifetime"?this.lifetimeMul=Number(r)||1:t==="brightness"?this._ov.brightness=Number(r)||1:this._ov[t]=r}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new _a)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(a=>({kind:a.name==="boxrandom"?"box":"sphere",origin:me(a.origin),directions:me(a.directions,[1,1,1]),distanceMin:Wo(a.distancemin),distanceMax:Wo(a.distancemax),sign:a.sign?me(a.sign):null,rate:G(a.rate,0),audioDriven:a.audioprocessingmode!==void 0,audioBounds:me(a.audioprocessingbounds,[0,1]),fill:a.rate===void 0&&a.instantaneous===void 0&&a.audioprocessingmode===void 0,instantaneous:G(a.instantaneous,0),speedMin:G(a.speedmin,0),speedMax:G(a.speedmax,0),controlPoint:a.controlpoint!==void 0&&a.controlpoint!==null?G(a.controlpoint,0):0,_burst:!1}));const t=n.initializer||[];this.init={life:null,size:null,color:null,alpha:null,velocity:null,rotation:null,angularVelocity:null,turbulentVelocity:null,mapAround:null};for(const a of t)switch(a.name){case"lifetimerandom":this.init.life={min:G(a.min,1),max:G(a.max,1),exp:G(a.exponent,1)};break;case"sizerandom":this.init.size={min:G(a.min,1),max:G(a.max,1),exp:G(a.exponent,1)};break;case"colorrandom":this.init.color={min:me(a.min,[255,255,255]),max:me(a.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:G(a.min,1),max:G(a.max,1)};break;case"velocityrandom":this.init.velocity={min:me(a.min),max:me(a.max)};break;case"rotationrandom":this.init.rotation={min:me(a.min),max:me(a.max,[0,0,0]),exp:G(a.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:me(a.min),max:me(a.max),exp:G(a.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,G(a.count,1)),bounds:me(a.bounds,[0,1]),speedMin:me(a.speedmin),speedMax:me(a.speedmax,[0,0,0]),cp:G(a.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:G(a.scale,.1),offset:G(a.offset,0),speedMin:G(a.speedmin,0),speedMax:G(a.speedmax,0),phaseMax:G(a.phasemax,0),timeScale:G(a.timescale,0),audioMode:G(a.audioprocessingmode,0),audioBounds:me(a.audioprocessingbounds,[0,1])};break}const o=n.operator||[];this.ops={movement:null,angularMovement:null,alphaFade:null,alphaChange:null,sizeChange:null,colorChange:null,turbulence:[],oscAlpha:null,oscSize:null,oscPos:null,attract:[],vortex:[],remap:[]};for(const a of o)switch(a.name){case"movement":this.ops.movement={gravity:me(a.gravity),drag:G(a.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:me(a.force),drag:G(a.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:G(a.fadeintime,.1),fadeOut:G(a.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:G(a.starttime,0),endTime:G(a.endtime,1),startValue:G(a.startvalue,1),endValue:G(a.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:G(a.starttime,0),endTime:G(a.endtime,1),startValue:G(a.startvalue,1),endValue:G(a.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:G(a.starttime,0),endTime:G(a.endtime,1),startValue:a.startvalue!==void 0?me(a.startvalue):null,endValue:me(a.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:G(a.scale,.01),speedMin:G(a.speedmin,0),speedMax:G(a.speedmax,0),timeScale:G(a.timescale,1),phaseMin:G(a.phasemin,0),phaseMax:G(a.phasemax,0),mask:a.mask!==void 0?me(a.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:G(a.frequencymin,G(a.frequencymax,1)),freqMax:G(a.frequencymax,1),scaleMin:G(a.scalemin,0),scaleMax:G(a.scalemax,1),phaseMax:G(a.phasemax,lt)};break;case"oscillatesize":this.ops.oscSize={freqMin:G(a.frequencymin,G(a.frequencymax,1)),freqMax:G(a.frequencymax,G(a.frequencymin,1)),scaleMin:G(a.scalemin,1),scaleMax:G(a.scalemax,1),phaseMax:G(a.phasemax,lt)};break;case"oscillateposition":this.ops.oscPos={freqMin:G(a.frequencymin,G(a.frequencymax,.5)),freqMax:G(a.frequencymax,.5),scaleMin:G(a.scalemin,0),scaleMax:G(a.scalemax,1),phaseMin:G(a.phasemin,0),phaseMax:G(a.phasemax,lt),mask:a.mask!==void 0?me(a.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:G(a.controlpoint,0),origin:me(a.origin),scale:G(a.scale,0),threshold:G(a.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:me(a.axis,[0,0,1]),offset:me(a.offset),distanceInner:G(a.distanceinner,0),distanceOuter:G(a.distanceouter,0),speedInner:G(a.speedinner,0),speedOuter:G(a.speedouter,0),cp:a.controlpoint!==void 0&&a.controlpoint!==null?G(a.controlpoint,0):0,audioMode:G(a.audioprocessingmode,0),audioBounds:me(a.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:a.output||"velocity",rangeMin:me(a.outputrangemin),rangeMax:me(a.outputrangemax),fn:a.transformfunction||"simplexnoise",inputScale:G(a.transforminputscale,1)});break}const r=this.model.renderer,i=r==null,s=Array.isArray(r)?r:r?[r]:[];this.renderers=s.map(a=>{const f=a&&a.name||"sprite";return{kind:f,length:G(a&&a.length,f==="spritetrail"?.1:f==="ropetrail"?.2:0),maxLength:G(a&&a.maxlength,0),minLength:G(a&&a.minlength,0),subdivision:G(a&&a.subdivision,1),segments:G(a&&a.segments,0),orientation:a&&a.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,segments:0,orientation:null}]);const c=this.renderers.find(a=>a.kind==="spritetrail"||a.kind==="ropetrail");if(this.trailCfg=c||null,this.trailSegments=1,this.trailDuration=0,this.trailSampleDt=0,c&&c.kind==="ropetrail"){const a=Yo(c);this.trailSegments=a,this.trailDuration=qo(c),this.trailSampleDt=this.trailDuration/Math.max(1,a-1);for(const f of this.pool)f.trail=new Float32Array(a*3),f.trailClock=0}this.ropeRenderer=this.renderers.find(a=>a.kind==="rope")||null}setModel(n){this.model=n,this._compile()}setMaterial(n){this.material=n;const t=n&&n.passes&&n.passes[0];this.blend=t&&t.blending||"translucent",this.refract=Ho(n);const o=t&&t.constantshadervalues,r=o&&o.ui_editor_properties_refract_amount,i=Number(r);this.refractAmount=Number.isFinite(i)?Math.min(.35,Math.max(0,i)):.04}setNormalTexture(n){this.normalTex=n||null}setTexture(n){this.texture=n,this._ready=!!n;const t=n&&n.frames,o=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,r=n&&n.width||o&&(t&&t.atlasWidth||o.atlasWidth)||0,i=n&&n.height||o&&(t&&t.atlasHeight||o.atlasHeight)||0;o&&r>0&&i>0?(this.texFrames=o.map(f=>({ou:f.x/r,ov:f.y/i,su:f.width/r,sv:f.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,c=1;this.texFrames&&o?(s=o[0].width||1,c=o[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,c=n.height);const a=Math.max(s,c)||1;this.texAspectX=s/a,this.texAspectY=c/a,this._frameData=void 0}setVisible(n){this.visible=n}setPointer(n,t){const o=n-this.originX,r=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(o*i-r*s)/(this.scaleX||1),y:(o*s+r*i)/(this.scaleY||1)}}attachFollow(n,t,o){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const r=o||[0,0,0];this._followOffset=[r[0]||0,r[1]||0,r[2]||0],this._syncFollow()}leaderParticle(){const n=this.pool;for(let t=0;t<n.length;t++)if(n[t].alive)return n[t];return null}localToWorld(n,t){const o=n*this.scaleX,r=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+o*i-r*s,this.originY+o*s+r*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const o=this._followOffset;if(t==="particle"){const r=n.leaderParticle();if(!r)return;const i=n.localToWorld(r.x+o[0],r.y+o[1]);this.originX=i[0],this.originY=i[1]}else{const r=n.localToWorld(o[0],o[1]);this.originX=r[0],this.originY=r[1]}}spawn(n){const t=this.pool,o=t.length;let r=null,i=this._cursor||0;for(let d=0;d<o;d++){const h=t[(i+d)%o];if(!h.alive){r=h,this._cursor=(i+d+1)%o;break}}if(!r)return;r.alive=!0,r.age=0,r.seed=Math.random(),r.rot=0,r.rotVel=0,r.vx=r.vy=r.vz=0,r.frame=0,r.seq=this._seq++;const s=n.origin;if(n.kind==="box"){const d=n.distanceMax||[0,0,0],h=n.distanceMin;r.x=s[0]+Ce(-d[0],d[0])+(h?h[0]:0),r.y=s[1]+Ce(-d[1],d[1])+(h?h[1]:0),r.z=s[2]+Ce(-d[2],d[2])+(h?h[2]:0)}else{const d=n.directions,h=n.distanceMin?n.distanceMin[0]:0,m=n.distanceMax?n.distanceMax[0]:0,M=Math.random()*2-1,g=Math.random()*lt,y=Math.sqrt(Math.max(0,1-M*M));let b=y*Math.cos(g),p=y*Math.sin(g),v=M;n.sign&&(n.sign[0]&&(b=Math.abs(b)*Math.sign(n.sign[0])),n.sign[1]&&(p=Math.abs(p)*Math.sign(n.sign[1])),n.sign[2]&&(v=Math.abs(v)*Math.sign(n.sign[2])));const _=Ce(h,m);if(r.x=s[0]+b*_*d[0],r.y=s[1]+p*_*d[1],r.z=s[2]+v*_*d[2],n.speedMax||n.speedMin){const w=Ce(n.speedMin,n.speedMax);r.vx+=b*w,r.vy+=p*w,r.vz+=v*w}}{const d=this._cpPos(n.controlPoint);if(d)r.x+=d[0],r.y+=d[1],r.z+=d[2];else{const h=this.controlPoints.find(m=>m.id===n.controlPoint);if(h&&h.lockToPointer){r.alive=!1;return}}}if(this.init.mapAround){const d=this.init.mapAround,h=this._cpPos(d.cp);if(h){const m=d.count,M=this._mapAroundSeq++,g=m>0?M%m/m:0,b=(d.bounds[0]+(d.bounds[1]-d.bounds[0])*g)*lt,p=n.distanceMin?n.distanceMin[0]:0,v=n.distanceMax?n.distanceMax[0]:0,_=v>0?v:p;r.x=h[0]+Math.cos(b)*_,r.y=h[1]+Math.sin(b)*_,r.z=h[2];const w=Math.random();r.vx+=d.speedMin[0]+(d.speedMax[0]-d.speedMin[0])*w,r.vy+=d.speedMin[1]+(d.speedMax[1]-d.speedMin[1])*w,r.vz+=d.speedMin[2]+(d.speedMax[2]-d.speedMin[2])*w}}const c=this.init,a=this._ov.speed||1,f=this._ov.size||1;if(r.life=c.life?Math.max(.001,Vo(c.life.min,c.life.max,c.life.exp)*this.lifetimeMul):1,r.baseSize=c.size?Vo(c.size.min,c.size.max,c.size.exp)*f:f,r.size=r.baseSize,c.color){const d=c.color.min,h=c.color.max,m=Math.random();r.baseR=(d[0]+(h[0]-d[0])*m)/255,r.baseG=(d[1]+(h[1]-d[1])*m)/255,r.baseB=(d[2]+(h[2]-d[2])*m)/255}else r.baseR=r.baseG=r.baseB=1;if(this._ov.color&&(r.baseR=this._ov.color[0],r.baseG=this._ov.color[1],r.baseB=this._ov.color[2]),r.r=r.baseR,r.g=r.baseG,r.b=r.baseB,r.baseAlpha=(c.alpha?Ce(c.alpha.min,c.alpha.max):1)*this.opacityMul,r.alpha=r.baseAlpha,c.velocity&&(r.vx+=Ce(c.velocity.min[0],c.velocity.max[0])*a,r.vy+=Ce(c.velocity.min[1],c.velocity.max[1])*a,r.vz+=Ce(c.velocity.min[2],c.velocity.max[2])*a),c.turbulentVelocity){const d=c.turbulentVelocity,h=d.audioMode?$r(d.audioBounds,this._audioLevel||0):1,m=Ce(d.speedMin,d.speedMax)*a*h,M=this.simTime*(d.timeScale||0),g=jr(r.x*d.scale+d.offset,r.y*d.scale+d.offset,M+r.seed*(d.phaseMax||0),3);r.vx+=g[0]*m,r.vy+=g[1]*m,r.vz+=g[2]*m}c.rotation&&(r.rot=Ce(c.rotation.min[2],c.rotation.max[2])),c.angularVelocity&&(r.rotVel=Ce(c.angularVelocity.min[2],c.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(r.oscFreq=Ce(l.oscPos.freqMin,l.oscPos.freqMax),r.oscAmp=Ce(l.oscPos.scaleMin,l.oscPos.scaleMax),r.oscPhase=Ce(l.oscPos.phaseMin,l.oscPos.phaseMax)+r.seed*lt),l.oscAlpha&&(r.oscAFreq=Ce(l.oscAlpha.freqMin,l.oscAlpha.freqMax),r.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||lt)),l.oscSize&&(r.oscSFreq=Ce(l.oscSize.freqMin,l.oscSize.freqMax),r.oscSPhase=Math.random()*(l.oscSize.phaseMax||lt)),l.turbulence.length){const d=l.turbulence[0];r.turbSpeed=Ce(d.speedMin,d.speedMax),r.turbPhase=Ce(d.phaseMin,d.phaseMax)}if(this.frameCount>1&&(r.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),r.bx=r.x,r.by=r.y,r.bz=r.z,r.trail){for(let d=0;d<r.trail.length;d+=3)r.trail[d]=r.x,r.trail[d+1]=r.y,r.trail[d+2]=r.z;r.trailClock=0}}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const o=n.age/n.life,r=this.ops;if(r.movement&&(n.vx+=r.movement.gravity[0]*t,n.vy+=r.movement.gravity[1]*t,n.vz+=r.movement.gravity[2]*t,r.movement.drag>0)){const c=Math.exp(-r.movement.drag*t);n.vx*=c,n.vy*=c,n.vz*=c}r.angularMovement&&(n.rotVel+=(r.angularMovement.force[2]||0)*t,r.angularMovement.drag>0&&(n.rotVel*=Math.exp(-r.angularMovement.drag*t)));for(const c of r.turbulence){const a=c.timeScale||1,f=jr(n.bx*c.scale,n.by*c.scale,this.simTime*c.scale*a+n.turbPhase,3);n.vx+=f[0]*n.turbSpeed*c.mask[0]*t,n.vy+=f[1]*n.turbSpeed*c.mask[1]*t,n.vz+=f[2]*n.turbSpeed*c.mask[2]*t}for(const c of r.attract){const a=this._cpPos(c.cp);if(!a)continue;const f=a[0]+c.origin[0]-n.x,l=a[1]+c.origin[1]-n.y,d=Math.hypot(f,l);if(d<.001||c.threshold>0&&d>c.threshold)continue;const h=c.threshold>0?1-d/c.threshold:1,m=c.scale*h*t/Math.max(1,d);n.vx+=f*m,n.vy+=l*m}for(const c of r.vortex){const a=this._cpPos(c.cp)||[0,0,0],f=n.x-(a[0]+c.offset[0]),l=n.y-(a[1]+c.offset[1]),d=Math.hypot(f,l);if(d<.001)continue;const h=c.distanceOuter-c.distanceInner,m=h>0?Math.min(1,Math.max(0,(d-c.distanceInner)/h)):0,M=c.audioMode?$r(c.audioBounds,this._audioLevel||0):1,g=c.speedInner+(c.speedOuter-c.speedInner)*m;n.vx+=-l/d*g*t*M,n.vy+=f/d*g*t*M}for(const c of r.remap){const a=c.inputScale||1,f=jr(n.bx*.01*a,n.by*.01*a,this.simTime*.1,c.fn==="fbmnoise"?4:2);if(c.output==="velocity")for(let l=0;l<3;l++){const d=(f[l]+1)/2,h=c.rangeMin[l]+(c.rangeMax[l]-c.rangeMin[l])*d;l===0?n.vx=h:l===1?n.vy=h:n.vz=h}else if(c.output==="speed"){const l=(f[0]+1)/2,d=c.rangeMin[0]+(c.rangeMax[0]-c.rangeMin[0])*l,h=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/h*d,n.vy=n.vy/h*d}}if(n.bx+=n.vx*t,n.by+=n.vy*t,n.bz+=n.vz*t,n.rot+=n.rotVel*t,n.x=n.bx,n.y=n.by,n.z=n.bz,r.oscPos){const c=this.simTime*n.oscFreq*lt+n.oscPhase,a=r.oscPos.mask;n.x+=Math.sin(c)*n.oscAmp*a[0],n.y+=Math.cos(c)*n.oscAmp*a[1],n.z+=Math.sin(c*.7)*n.oscAmp*a[2]}let i=n.baseSize;if(r.sizeChange){const c=r.sizeChange,a=c.endTime-c.startTime,f=a>0?Math.min(1,Math.max(0,(o-c.startTime)/a)):o>=c.startTime?1:0;i*=c.startValue+(c.endValue-c.startValue)*f}if(r.oscSize){const c=this.simTime*n.oscSFreq*lt+n.oscSPhase,a=r.oscSize,f=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;i*=f+Math.sin(c)*l}if(n.size=i,r.colorChange){const c=r.colorChange,a=c.endTime-c.startTime,f=a>0?Math.min(1,Math.max(0,(o-c.startTime)/a)):o>=c.startTime?1:0,l=c.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(c.endValue[0]-l[0])*f,n.g=l[1]+(c.endValue[1]-l[1])*f,n.b=l[2]+(c.endValue[2]-l[2])*f}let s=n.baseAlpha;if(r.alphaFade){const c=r.alphaFade.fadeIn,a=r.alphaFade.fadeOut;c>0&&o<c&&(s*=o/c),a<1&&o>a&&(s*=Math.max(0,(1-o)/(1-a)))}else r.alphaChange||(o<.1?s*=o/.1:o>.85&&(s*=(1-o)/.15));if(r.alphaChange){const c=r.alphaChange,a=c.endTime-c.startTime,f=a>0?Math.min(1,Math.max(0,(o-c.startTime)/a)):o>=c.startTime?1:0;s*=c.startValue+(c.endValue-c.startValue)*f}if(r.oscAlpha){const c=this.simTime*n.oscAFreq*lt+n.oscAPhase,a=r.oscAlpha,f=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;s*=f+Math.sin(c)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(o*this.frameCount))),n.trail){const c=n.trail,a=this.trailSampleDt;if(a>0){n.trailClock=(n.trailClock||0)+t;let f=0;const l=this.trailSegments||8;for(;n.trailClock>=a&&f<l;){n.trailClock-=a,f++;for(let d=c.length-3;d>=3;d-=3)c[d]=c[d-3],c[d+1]=c[d-2],c[d+2]=c[d-1]}}c[0]=n.x,c[1]=n.y,c[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(o=>o.id===n);return t?t.lockToPointer?this.pointer?[this.pointer.x+t.offset[0],this.pointer.y+t.offset[1],t.offset[2]]:null:t.offset:null}advance(n,t){if(!(this.paused||!this.visible)){if(this._syncFollow(),!this._warmed&&(this._warmed=!0,this.startTime>0)){const o=.03333333333333333,r=Math.min(900,Math.round(this.startTime/o));for(let i=0;i<r;i++)this._step(o)}this._step(n,t)}}_step(n,t){this.simTime+=n;const o=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=o;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let a=0;a<Math.min(i.instantaneous,this.maxCount);a++)this.spawn(i)}if(i.fill){const f=Math.min(this.maxCount,2048);let l=0;for(let h=0;h<this.pool.length;h++)this.pool[h].alive&&l++;let d=Math.min(f-l,512);for(;d-- >0;)this.spawn(i);continue}if(i.audioDriven){const a=$r(i.audioBounds,o);if(i.rate>0){const f=i.rate*a*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(f>0))continue;i._accum=(i._accum||0)+f*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let d=0;d<l;d++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*a);let d=0;for(let m=0;m<this.pool.length;m++)this.pool[m].alive&&d++;let h=Math.min(l-d,256);for(;h-- >0;)this.spawn(i)}continue}const s=i.rate*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(s>0))continue;i._accum=(i._accum||0)+s*n;let c=Math.floor(i._accum);if(c>0){i._accum-=c,c>this.maxCount&&(c=this.maxCount);for(let a=0;a<c;a++)this.spawn(i)}}const r=this.pool;for(let i=0;i<r.length;i++)r[i].alive&&this.updateParticle(r[i],n)}render(n,t,o,r,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const c=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,a=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,f=this.ropeRenderer,l=Go(this.trailCfg,this.trailSegments),d=14,h=this.pool;let m=null;if(f){m=this._ropeOrder,m.length=0;for(let H=0;H<h.length;H++)h[H].alive&&m.push(h[H]);m.sort((H,j)=>H.seq-j.seq)}let M=0;if(m)M=m.length;else for(let H=0;H<h.length;H++)h[H].alive&&M++;if(M===0||f&&M<2)return;const g=f?M-1:M*l,y=g*d;(!this._data||this._data.length<y)&&(this._data=new Float32Array(Math.max(y,1024)));const b=this._data;let p=0;const v=this._ov.brightness||1,_=this.sysScale,w=this.spriteStretchX*(this.texAspectX||1),L=this.spriteStretchY*(this.texAspectY||1),F=Math.cos(this.angleZ),D=Math.sin(this.angleZ),B=this.originX,z=this.originY,V=this.scaleX,Y=this.scaleY,Z=(H,j)=>{const ee=H*V,le=j*Y;return[B+ee*F-le*D,i-(z+ee*D+le*F)]};if(f)for(let H=0;H+1<M;H++){const j=m[H],ee=m[H+1],le=Z(j.x,j.y),Se=Z(ee.x,ee.y),Xe=Se[0]-le[0],Le=Se[1]-le[1],Pe=Math.hypot(Xe,Le),ue=(Math.abs(j.size)+Math.abs(ee.size))*.5*_;ue>0&&(b[p++]=(le[0]+Se[0])*.5,b[p++]=(le[1]+Se[1])*.5,b[p++]=0,b[p++]=ue,b[p++]=Math.atan2(-Xe,Le),b[p++]=(j.r+ee.r)*.5*v,b[p++]=(j.g+ee.g)*.5*v,b[p++]=(j.b+ee.b)*.5*v,b[p++]=(j.alpha+ee.alpha)*.5,b[p++]=1,b[p++]=Pe/ue,b[p++]=0,b[p++]=Wr(j),b[p++]=Wr(ee))}for(let H=0;H<h.length&&!f;H++){const j=h[H];if(j.alive)for(let ee=0;ee<l;ee++){let le=j.x,Se=j.y,Xe=1,Le=1,Pe=j.rot,ue=w,Fe=L,Je,Ee;if(c&&j.trail){le=j.trail[ee*3],Se=j.trail[ee*3+1];const xe=l>1?ee/(l-1):0;Xe=1-xe,Le=1-xe*.55;let Ne=0,we=0;ee+1<l?(Ne=j.trail[ee*3]-j.trail[(ee+1)*3],we=j.trail[ee*3+1]-j.trail[(ee+1)*3+1]):ee>0?(Ne=j.trail[(ee-1)*3]-j.trail[ee*3],we=j.trail[(ee-1)*3+1]-j.trail[ee*3+1]):(Ne=j.vx,we=j.vy);const Ge=Z(le,Se),fe=Z(le-Ne,Se-we),Ye=Ge[0]-fe[0],$t=Ge[1]-fe[1],et=Math.hypot(Ye,$t),qt=Math.max(.001,Math.abs(j.size)*_*Le);et>.001?(Pe=Vr(Ye,$t),Je=(Ge[0]+fe[0])*.5,Ee=(Ge[1]+fe[1])*.5,Fe=Math.max(L,et/qt)):(Je=Ge[0],Ee=Ge[1])}else{const xe=Z(le,Se);Je=xe[0],Ee=xe[1]}if(a){const xe=Z(j.x,j.y);Je=xe[0],Ee=xe[1];const Ne=Z(j.x+j.vx,j.y+j.vy);Pe=Vr(Ne[0]-xe[0],Ne[1]-xe[1]);const we=Xo(Math.hypot(j.vx,j.vy),a.length,a.minLength,a.maxLength);Fe=L*we}b[p++]=Je,b[p++]=Ee,b[p++]=0,b[p++]=Math.abs(j.size)*_*Le,b[p++]=Pe,b[p++]=j.r*v,b[p++]=j.g*v,b[p++]=j.b*v,b[p++]=j.alpha*Xe,b[p++]=ue,b[p++]=Fe,b[p++]=j.frame,b[p++]=0,b[p++]=1}}const X=this._prog;s.useProgram(X.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,b.subarray(0,p),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(X.uniTex,0),s.uniformMatrix4fv(X.uniMvp,!1,n);const q=this.refract&&this.normalTex&&this.normalTex.glTex;if(X.uniRefract&&s.uniform1i(X.uniRefract,q?1:0),q){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),X.uniNormal&&s.uniform1i(X.uniNormal,1);const H=this.blend!=="additive";if(X.uniSampleScene&&s.uniform1i(X.uniSampleScene,H?1:0),H){const j=s.drawingBufferWidth||t,ee=s.drawingBufferHeight||o;s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE2),this._sceneTex?s.bindTexture(s.TEXTURE_2D,this._sceneTex):(this._sceneTex=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._sceneTex),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGB8,0,0,j,ee,0),X.uniScene&&s.uniform1i(X.uniScene,2),X.uniResolution&&s.uniform2f(X.uniResolution,j,ee),X.uniRefractScale&&s.uniform1f(X.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),X.uniScene&&s.uniform1i(X.uniScene,2)}else X.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(X.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),X.uniScene&&s.uniform1i(X.uniScene,2),X.uniSampleScene&&s.uniform1i(X.uniSampleScene,0));const oe=this._frameUniformData();oe?(s.uniform1i(X.uniFrameCount,oe.count),s.uniform4fv(X.uniFrames,oe.arr)):s.uniform1i(X.uniFrameCount,0),s.enable(s.BLEND),this.blend==="additive"?s.blendFunc(s.SRC_ALPHA,s.ONE):s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.depthMask(!1),s.drawArraysInstanced(s.TRIANGLE_STRIP,0,4,g),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=Ma(n);this._quadBuf=t.quadBuf,this._vbuf=t.vbuf,this._vao=t.vao,this._prog=t.prog}_frameUniformData(){if(this._frameData!==void 0)return this._frameData;let n=this.texFrames;if(!n&&this.sequenceMul>1){const r=this.sequenceMul;n=[];for(let i=0;i<r;i++)for(let s=0;s<r;s++)n.push({ou:s/r,ov:i/r,su:1/r,sv:1/r})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),o=new Float32Array(t*4);for(let r=0;r<t;r++)o[r*4]=n[r].ou,o[r*4+1]=n[r].ov,o[r*4+2]=n[r].su,o[r*4+3]=n[r].sv;return this._frameData={count:t,arr:o},this._frameData}liveCount(){let n=0;for(const t of this.pool)t.alive&&n++;return n}dispose(){this.paused=!0;const n=this.gl;if(n){try{this._vbuf&&n.deleteBuffer(this._vbuf),this._quadBuf&&n.deleteBuffer(this._quadBuf),this._vao&&n.deleteVertexArray(this._vao),this._prog&&this._prog.prog&&n.deleteProgram(this._prog.prog),this._sceneTex&&n.deleteTexture(this._sceneTex)}catch{}this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null}}}const Sa=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:Ta,particleInstanceSegs:Go,particlePassRefract:Ho,rgbaIsBlankWhite:Aa,ropeParticleV:Wr,ropeTrailDuration:qo,ropeTrailHistoryCount:Yo,spriteTrailLengthFactor:Xo,spriteTrailRotation:Vr},Symbol.toStringTag,{value:"Module"})),_n=new Map,Hr=new Map;let nr=null;function Ea(e,n){const t=String(e);Hr.set(t,n),_n.delete(t)}function Pa(e){nr=typeof e=="function"?e:null}function Ca(){Hr.clear(),nr=null,_n.clear()}function Ra(){return Object.keys(Cn)}function Te(e,n,t){e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=Math.round(Math.min(1,Math.max(0,t))*255)}function Tn(e,n){const{width:t,height:o,rgba:r}=e,i=Math.max(2,Math.round(Math.min(t,o)*.04));for(let s=0;s<o;s++)for(let c=0;c<t;c++){const a=Math.min(c,s,t-1-c,o-1-s);if(a>=i)continue;const f=a/i,l=(s*t+c)*4+3;r[l]=Math.round(r[l]*f)}if(n>0){let s=0;const c=t*o;for(let f=0;f<c;f++)s+=r[f*4+3];const a=s/c/255;if(a>n&&a>0){const f=n/a;for(let l=0;l<c;l++)r[l*4+3]=Math.round(r[l*4+3]*f)}}return e}function rr(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const an=e=>e*e*(3-2*e),Zo=e=>e*e*e*(e*(e*6-15)+10),Xr=(e,n,t)=>e+(n-e)*t,ne=(e,n)=>Math.exp(-(e*e)/(n*n));function Gt(e,n,t,o){const r=Math.min(e,n,t-1-e,t-1-n);return r>=o?1:r/o}function Sn(e,n){const t=new Uint8Array(e*e*4),o=e/2;for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-o)/o,(r+.5-o)/o);let c=0;for(let a=0;a<n.length;a++)c+=n[a].w*ne(s,n[a].r);Te(t,(r*e+i)*4,c)}return{width:e,height:e,rgba:t}}function Et(e,n,t){return Sn(e,[n,t])}function Pt(e,n,t,o,r){const i=new Uint8Array(e*e*4),s=e/2,c=Math.max(2,Math.round(e*.03));for(let a=0;a<e;a++)for(let f=0;f<e;f++){const l=(f+.5-s)/s,d=(a+.5-s)/s,h=Math.hypot(l,d),m=Math.atan2(d,l),M=Math.pow(.5+.5*Math.cos(n*m),o);let g=ne(h,r)+M*ne(h,t);g*=Gt(f,a,e,c),Te(i,(a*e+f)*4,g)}return{width:e,height:e,rgba:i}}function yt(e,n,t,o,r){const s=new Uint8Array(e*n*4);for(let c=0;c<n;c++){const a=c/(n-1),f=o?ne(a-.5,.27):an(Math.min(1,a/.06))*Math.pow(1-a,1.35);for(let l=0;l<e;l++){const d=l/(e-1)*2-1,h=ne(d,t);Te(s,(c*e+l)*4,h*h*h*f*.55)}}return{width:e,height:n,rgba:s}}const En=4;function Ko(e,n,t,o,r){const i=r===void 0?.85:r,s=new Uint8Array(e*n*4),c=n/En,a=rr(335009),f=Math.tan(t*Math.PI/180),l=e/2;for(let d=0;d<En;d++){const h=i*(.8+a()*.35),m=o*(.85+a()*.5),M=(a()-.5)*e*.12;for(let g=0;g<c;g++){const y=g/(c-1),b=l+M+(c-1)*f/2-(c-1)*f*y,p=ne(y-.5,.27);for(let v=0;v<e;v++){const _=Math.abs(v+.5-b),L=Math.exp(-(_*_)/(m*m))*p*h;L<.004||Te(s,((d*c+g)*e+v)*4,L)}}}return{width:e,height:n,rgba:s}}function La(e){if(e==="particle/nature/rain1"||e==="particle/nature/rain2"){const n=[];for(let t=0;t<En;t++)n.push({ou:0,ov:t/En,su:1,sv:1/En});return n}return null}function Gr(e,n,t){const o=new Uint8Array(e*e*4),r=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const c=Math.hypot((s-r)/r,(i-r)/r);Te(o,(i*e+s)*4,ne(c-n,t*.6)*Math.max(0,1-c))}return{width:e,height:e,rgba:o}}function Qo(e,n){const t={1:{r:.78,t:.048,inner:.06,hi:[[-.28,-.32,.22,.9],[.32,.36,.12,.28]]},2:{r:.7,t:.07,inner:.14,hi:[[-.2,-.28,.3,.72],[.38,.2,.14,.4]]},3:{r:.84,t:.036,inner:.04,hi:[[-.34,-.18,.16,.95],[.2,.42,.1,.22],[.04,-.08,.07,.18]]}},o=t[n]||t[1],r=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,f=(s+.5-i)/i,l=Math.hypot(a,f);let d=ne(l-o.r,o.t*.85)*Math.max(0,1.05-l);l<o.r&&(d+=o.inner*ne(l,.5));for(let h=0;h<o.hi.length;h++){const m=o.hi[h];d+=m[3]*ne(Math.hypot(a-m[0],f-m[1]),m[2])}Te(r,(s*e+c)*4,d)}return Tn({width:e,height:e,rgba:r},.05)}function Pn(e,n){const t=e>>1,o=new Uint8Array(e*e*4),r=n===1?[1,2,1,3]:n===2?[2,1,2,3]:[3,1,2,3];for(let i=0;i<2;i++)for(let s=0;s<2;s++){const c=Qo(t,r[i*2+s]);for(let a=0;a<t;a++){const f=(i*t+a)*e,l=a*t;for(let d=0;d<t;d++){const h=(f+s*t+d)*4,m=(l+d)*4;o[h]=c.rgba[m],o[h+1]=c.rgba[m+1],o[h+2]=c.rgba[m+2],o[h+3]=c.rgba[m+3]}}}return{width:e,height:e,rgba:o}}function Jo(e){const n=new Uint8Array(e*e*4),t=e/2,o=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=i>=t?1:0,c=r>=t?1:0,a=c*2+s,f=s*t+t/2,l=c*t+t/2,d=o[a][0],h=o[a][1],m=(i+.5-f)/(t*.4),M=(r+.5-l)/(t*.4),g=Math.cos(d),y=Math.sin(d);let b=m*g+M*y;const p=-m*y+M*g;b+=h*p*.18;const v=1-Math.max(0,p)*.42,_=Math.hypot(b/(.52*v),p/.92);let w=_>=1.12?0:ne(_,.48);w=Math.min(1,w+ne(b,.07)*ne(p,.65)*w*.4),Te(n,(r*e+i)*4,w)}return Tn({width:e,height:e,rgba:n},.11)}function $e(e,n){const t={0:{rx:.36,ry:.92,wave:0,folds:0},1:{rx:.48,ry:.86,wave:.05,folds:7},2:{rx:.4,ry:.88,wave:.08,folds:5},3:{rx:.58,ry:.72,wave:0,folds:0},5:{rx:.44,ry:.8,wave:.12,folds:9},6:{rx:.52,ry:.78,wave:.07,folds:4},7:{rx:.5,ry:.9,wave:.16,folds:3},8:{rx:.38,ry:.94,wave:.2,folds:2}},o=t[n]||t[0],r=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,f=(s+.5-i)/i,l=Math.atan2(a,f),d=o.wave?1+o.wave*Math.sin(l*o.folds):1,h=Math.hypot(a/(o.rx*d),f/o.ry);let m=h>=1.12?0:ne(h,.5);m>0&&(m=Math.min(1,m+ne(a,.028)*ne(f,.72)*.28)),Te(r,(s*e+c)*4,m)}return Tn({width:e,height:e,rgba:r},.11)}function ut(e,n){const t=e.width,o=e.height,r=e.rgba,i=n??2.8,s=new Uint8Array(t*o*4),c=(a,f)=>{const l=a<0?0:a>=t?t-1:a,d=f<0?0:f>=o?o-1:f;return r[(d*t+l)*4+3]/255};for(let a=0;a<o;a++)for(let f=0;f<t;f++){const l=(c(f-1,a)-c(f+1,a))*i,d=(c(f,a-1)-c(f,a+1))*i,h=1/Math.hypot(l,d,1),m=(a*t+f)*4;s[m]=Math.round((l*h*.5+.5)*255),s[m+1]=Math.round((d*h*.5+.5)*255),s[m+2]=Math.round((h*.5+.5)*255),s[m+3]=255}return{width:t,height:o,rgba:s}}function ei(e){const n=new Uint8Array(e*e*4),t=e/2;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=(r+.5-t)/t,s=(o+.5-t)/t,c=Math.hypot(i,s),a=c>=1?0:Math.sqrt(Math.max(0,1-c*c)),f=ne(c-.62,.11)*.55;Te(n,(o*e+r)*4,Math.min(1,a*.85+f))}return{width:e,height:e,rgba:n}}function Fa(e){const n=new Uint8Array(e*e*4),t=e/2;for(let o=0;o<e;o++)for(let r=0;r<e;r++){const i=(r+.5-t)/t,s=(o+.5-t)/t,c=Math.hypot(i,s),a=Math.atan2(s,i),f=ne(c,.38)*(.55+.45*Math.cos(a*3+c*6));Te(n,(o*e+r)*4,f)}return{width:e,height:e,rgba:n}}function ti(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.04));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t,a=Math.hypot(s,c),f=Math.atan2(c,s),l=an(Math.max(0,Math.cos(f)*.55+.45)),d=ne(a-.68,.07)*l+.35*ne(a-.78,.12)*ne(f-.9,.55);Te(n,(r*e+i)*4,Math.min(1,d)*Gt(i,r,e,o))}return{width:e,height:e,rgba:n}}function Na(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let o=0;for(let r=0;r<n;r+=t){const i=r*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;o++}return o>0}function ka(e){return!e||!e.rgba?e:Na(e.rgba)?ut(e,2.8):e}const Ua={"particle/drop":"particle/drop_normal","particle/water/rain_drops_sheet":"particle/water/rain_drops_sheet_normal","particle/bubbles/bubble1":"particle/bubbles/bubble1normal","particle/bubbles/bubble2":"particle/bubbles/bubble2_normal","particle/sharp_halo":"particle/sharp_halo_normal","particle/misc/wave":"particle/normal_splash","particle/halo":"particle/sharp_halo_normal"};function Ia(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:Ua[n]||n+"_normal"}function Ba(e){const n=String(e);return/(^|\/)normal_/.test(n)?null:/_normal$/i.test(n)?n.replace(/_normal$/i,""):/normal$/i.test(n)?n.replace(/normal$/i,""):null}function Oa(e){if(Cn[e])return Cn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?Et(64,{r:.18,w:1},{r:.4,w:.2}):li(e)()}function ni(e,n,t){const o=rr(t*7919+17);let r=e;const i=[];for(let a=0;a<n;a++){const f=r*r,l=new Float32Array(f*2);for(let d=0;d<f;d++){const h=o()*Math.PI*2;l[d*2]=Math.cos(h),l[d*2+1]=Math.sin(h)}i.push({f:r,g:l,ox:a*7.31,oy:a*3.17}),r*=2}const s=(a,f,l,d,h)=>{const m=a.f,M=(f%m+m)%m,y=((l%m+m)%m*m+M)*2;return a.g[y]*d+a.g[y+1]*h},c=(a,f,l)=>{const d=(f+a.ox)*a.f,h=(l+a.oy)*a.f,m=Math.floor(d),M=Math.floor(h),g=d-m,y=h-M,b=Zo(g),p=Zo(y);return Xr(Xr(s(a,m,M,g,y),s(a,m+1,M,g-1,y),b),Xr(s(a,m,M+1,g,y-1),s(a,m+1,M+1,g-1,y-1),b),p)};return function(f,l,d){const h=d==null?i.length:Math.min(d,i.length);let m=1,M=0,g=0;for(let y=0;y<h;y++)M+=(c(i[y],f,l)*.5+.5)*m,g+=m,m*=.55;return M/g}}function ri(e,n,t){const{width:o,height:r,rgba:i}=e;if(o===n&&r===t)return e;const s=new Uint8Array(n*t*4);for(let c=0;c<t;c++){const a=(c+.5)/t*r-.5,f=Math.max(0,Math.min(r-1,Math.floor(a))),l=Math.max(0,Math.min(r-1,f+1)),d=a-Math.floor(a);for(let h=0;h<n;h++){const m=(h+.5)/n*o-.5,M=Math.max(0,Math.min(o-1,Math.floor(m))),g=Math.max(0,Math.min(o-1,M+1)),y=m-Math.floor(m),b=i[(f*o+M)*4+3],p=i[(f*o+g)*4+3],v=i[(l*o+M)*4+3],_=i[(l*o+g)*4+3],w=(b*(1-y)+p*y)*(1-d)+(v*(1-y)+_*y)*d;Te(s,(c*n+h)*4,w/255)}}return{width:n,height:t,rgba:s}}function It(e,n,t,o,r,i,s){const c=i===void 0?1:i,a=s===void 0?200:s,f=256,l=ni(n,t,o),d=new Uint8Array(f*f*4),h=f/2,m=f*f,M=new Float32Array(m);let g=1,y=0;for(let _=0;_<m;_++){const w=_%f,L=_/f|0,F=(w+.5)/f,D=(L+.5)/f,B=l(F+5.2,D+1.3,2)-.5,z=l(F+9.7,D+8.1,2)-.5,V=M[_]=l(F+B*.45,D+z*.45);V<g&&(g=V),V>y&&(y=V)}const b=y-g||1;for(let _=0;_<f;_++)for(let w=0;w<f;w++){const L=(M[_*f+w]-g)/b,F=Math.hypot((w+.5-h)/h,(_+.5-h)/h),D=Math.pow(Math.max(0,1-F),c);let B=Math.max(0,(L-(1-r))/(r||1));B=an(Math.min(1,B))*D,Te(d,(_*f+w)*4,B)}let p=0;for(let _=0;_<m;_++)p=Math.max(p,d[_*4+3]);if(p>0&&p<a){const _=a/p;for(let w=0;w<m;w++)d[w*4+3]=Math.round(Math.min(255,d[w*4+3]*_))}const v={width:f,height:f,rgba:d};return f===e?v:ri(v,e,e)}function Yr(e,n){const t=e,o=ni(3,5,n??23),r=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let c=1,a=0;for(let h=0;h<i;h++){const m=h%t,M=h/t|0,g=(m+.5)/t,y=(M+.5)/t,b=o(g+2.1,y+4.7,2)-.5,p=o(g+6.3,y+1.9,2)-.5,v=s[h]=o(g+b*.28,y+p*.55);v<c&&(c=v),v>a&&(a=v)}const f=a-c||1;for(let h=0;h<t;h++)for(let m=0;m<t;m++){const M=(h+.5)/t,g=(m+.5)/t*2-1,y=.1+.52*Math.pow(M,1.25),b=(s[h*t+m]-c)/f,p=ne(g/(y||.01),.55)*ne(M-.58,.42);let v=an(Math.min(1,Math.max(0,(b-.18)/.72)))*p;v*=M<.06?M/.06:1,Te(r,(h*t+m)*4,v)}let l=0;for(let h=0;h<i;h++)l=Math.max(l,r[h*4+3]);if(l>0&&l<220){const h=220/l;for(let m=0;m<i;m++)r[m*4+3]=Math.round(Math.min(255,r[m*4+3]*h))}const d=Tn({width:t,height:t,rgba:r},.08);return t===e?d:ri(d,e,e)}function qr(e,n,t,o){const r=new Uint8Array(e*n*4),i=e/t,s=n/o;for(let c=0;c<n;c++)for(let a=0;a<e;a++){const f=Math.floor(a/i),l=Math.floor(c/s),d=(a+.5-f*i)/i*2-1,h=(c+.5-l*s)/s*2-1,m=1-Math.max(0,h)*.45,M=Math.hypot(d/(.52*m),h/.8),g=M>=1.12?0:ne(M,.48);Te(r,(c*e+a)*4,g)}return{width:e,height:n,rgba:r}}function oi(e){const n=new Uint8Array(e*e*4),t=rr(7),o=[];for(let r=0;r<11;r++)o.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5)/e,c=(r+.5)/e;let a=0;for(const f of o){const l=s-f.x,d=c-f.y,h=Math.cos(f.rot),m=Math.sin(f.rot),M=(l*h+d*m)/f.rx,g=(-l*m+d*h)/f.ry,y=ne(Math.hypot(M,g),.55);y>a&&(a=y)}Te(n,(r*e+i)*4,a)}return{width:e,height:e,rgba:n}}function or(e,n){const t=n??19,o=rr(t),r=h=>Math.min(.86,Math.max(.14,h)),i=5+t%4,s=[];let c=r(.5+(o()-.5)*.16);for(let h=0;h<=i;h++){const m=.06+h/i*.86;h>0&&(c=r(c+(o()-.5)*.32)),s.push([c,m])}const a=[];for(let h=0;h<s.length-1;h++)a.push([s[h],s[h+1],1]);const f=1+t%2;for(let h=0;h<f;h++){const m=1+(t+h*3)%Math.max(1,s.length-2),M=s[m],g=[M];let y=M[0],b=M[1];const p=2+t%2;for(let v=0;v<p;v++)y=r(y+(o()-.5)*.36),b=Math.min(.92,b+.1+o()*.08),g.push([y,b]);for(let v=0;v<g.length-1;v++)a.push([g[v],g[v+1],.45+h*.1])}const l=new Uint8Array(e*e*4),d=Math.max(2,Math.round(e*.04));for(let h=0;h<e;h++)for(let m=0;m<e;m++){const M=(m+.5)/e,g=(h+.5)/e;let y=9,b=0;for(const[v,_,w]of a){const L=_[0]-v[0],F=_[1]-v[1],D=L*L+F*F||1e-8,B=Math.max(0,Math.min(1,((M-v[0])*L+(g-v[1])*F)/D)),z=Math.hypot(M-(v[0]+L*B),g-(v[1]+F*B));z/w<y&&(y=z/w,b=w)}const p=.95*ne(y,.012)+.3*ne(y,.05)*b;Te(l,(h*e+m)*4,Math.min(1,p)*Gt(m,h,e,d))}return{width:e,height:e,rgba:l}}function Zr(e,n){const t=new Uint8Array(e*n*4);for(let o=0;o<n;o++)for(let r=0;r<e;r++){const i=(r+.5-e/2)/(e/2),s=(o+.5-n/2)/(n/2),c=ne(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),a=Math.hypot(i/.34,(s-.42)/.3),f=a>=1?0:ne(a,.5);Te(t,(o*e+r)*4,Math.max(c,f))}return{width:e,height:n,rgba:t}}function Da(e){return Et(e,{r:.1,w:1},{r:.3,w:.16})}function Kr(e,n){const t=new Uint8Array(e*n*4);for(let o=0;o<n;o++){const r=(o+.5)/n,i=an(Math.min(1,Math.min(r/.08,(1-r)/.08))),s=ne(r-.46,.24)*i,c=.5*(1-an(Math.min(1,Math.max(0,(r-.42)/.5)))*.6);for(let a=0;a<e;a++){const f=(a+.5-e/2)/(e/2);Te(t,(o*e+a)*4,ne(Math.abs(f)/(c||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function ii(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.04));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t,a=ne(Math.hypot(s,c),.42),f=ne(Math.hypot(s-.34,c),.36),l=Math.max(0,a-f*1.08)*Gt(i,r,e,o);Te(n,(r*e+i)*4,l)}return{width:e,height:e,rgba:n}}function si(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.04));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t;let a=ne(Math.hypot(s,c),.08);for(let f=0;f<6;f++){const l=f*Math.PI/3,d=Math.cos(l),h=Math.sin(l),m=s*d+c*h,M=-s*h+c*d;if(m<0)continue;const g=Math.max(0,1.02-m/.72);a+=ne(M,.028)*ne(m,.5)*g,a+=.55*ne(M-(m-.28)*.65,.02)*ne(m-.28,.12)*g,a+=.55*ne(M+(m-.28)*.65,.02)*ne(m-.28,.12)*g,a+=.4*ne(M-(m-.48)*.7,.016)*ne(m-.48,.08)*g,a+=.4*ne(M+(m-.48)*.7,.016)*ne(m-.48,.08)*g}Te(n,(r*e+i)*4,Math.min(1,a)*Gt(i,r,e,o))}return{width:e,height:e,rgba:n}}function ai(e,n){const t=new Uint8Array(e*e*4),o=e/2,r=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-o)/o*1.55,f=(s+.5-o)/o*1.55,l=Math.abs(Math.abs(a)+Math.abs(f)-.55);let d=ne(l,.016);i===0?(d+=ne(a,.012)*ne(f,.38),d+=ne(f,.012)*ne(a,.38)):i===1?(d+=ne(a-f,.012)*ne(a+f,.36),d+=ne(a+f,.012)*ne(a-f,.36)):(d+=ne(Math.hypot(a,f)-.26,.014),d+=ne(a,.012)*ne(f,.22)),Te(t,(s*e+c)*4,Math.min(1,d)*Gt(c,s,e,r))}return Tn({width:e,height:e,rgba:t},.03)}function Qr(e){let n=0;const t=String(e);for(let o=0;o<t.length;o++)n=n*31+t.charCodeAt(o)|0;return n}function ci(e){const n=new Uint8Array(e*e*4),t=e/2,o=Math.max(2,Math.round(e*.03));for(let r=0;r<e;r++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(r+.5-t)/t,a=Math.hypot(s,c),f=ne(a,.07)+.85*ne(s,.62)*ne(c,.045)+.22*ne(s,.92)*ne(c,.018);Te(n,(r*e+i)*4,Math.min(1,f)*Gt(i,r,e,o))}return{width:e,height:e,rgba:n}}const Cn={"particle/halo_6":()=>Et(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>ut(ei(256),3.2),"particle/drop_normal":()=>ut(Kr(128,512),3.4),"particle/normal_ring_smooth":()=>ut(Gr(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>ut(Fa(256),2.8),"particle/water/rain_drops_sheet_normal":()=>ut(qr(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>ut(Pn(256,1),3.2),"particle/bubbles/bubble2_normal":()=>ut(Pn(256,2),3.2),"particle/sharp_halo_normal":()=>ut(Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>yt(128,512,.46,!0),"particle/beam/beam_1":()=>yt(128,512,.34,!0),"particle/beam/beam_2":()=>yt(128,512,.22,!0),"particle/beam/beam_2_fade":()=>yt(128,512,.24,!1),"particle/light/light_shafts_0":()=>yt(128,512,.42,!0),"particle/light/light_shafts_1":()=>yt(128,512,.3,!0),"particle/light/light_shafts_3":()=>yt(128,512,.26,!0),"particle/light/light_shafts_5":()=>yt(128,512,.23,!0),"particle/light/light_shafts_6":()=>yt(128,512,.2,!0),"particle/nature/rosepetals":()=>Jo(256),"particle/nature/leaves":()=>$e(256,0),"particle/nature/leaves1":()=>$e(256,1),"particle/nature/leaves2":()=>$e(256,2),"particle/nature/leaves3":()=>$e(256,3),"particle/nature/leaves5":()=>$e(256,5),"particle/nature/leaves6":()=>$e(256,6),"particle/nature/leaves7":()=>$e(256,7),"particle/nature/leaves8":()=>$e(256,8),"particle/nature/snow":()=>si(256),"particle/halo":()=>Et(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>Et(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>Et(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>Sn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>Et(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>Sn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>Da(128),"particle/light/flare_0":()=>Pt(256,6,.58,10,.08),"particle/light/flare_1":()=>Pt(512,4,.62,14,.07),"particle/light/flare_2":()=>ci(256),"particle/drop":()=>Kr(128,512),"particle/nature/rain1":()=>Ko(128,512,10,1,.78),"particle/nature/rain2":()=>Ko(128,512,10,1.6,.66),"particle/water/rain_drops_sheet":()=>qr(256,512,2,4),"particle/fog/fog1":()=>It(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>It(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>It(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>It(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>It(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>It(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>Gr(512,.72,.085),"particle/misc/star_0":()=>Pt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>Pn(256,1),"particle/bubbles/bubble2":()=>Pn(256,2),"particle/bubbles/bubble3":()=>Pn(256,3),"particle/debris/debris1":()=>oi(128),"particle/lightning/lightning1":()=>or(256,3),"particle/lightning/lightning2":()=>or(256,11),"particle/lightning/lightning3":()=>or(256,19),"particle/fire/fire1":()=>Yr(256,23),"particle/fire/fire2":()=>Yr(256,41),"particle/star":()=>Pt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>ti(256),"particle/sickle":()=>ii(256),"particle/magic/glyph_4":()=>ai(256,4),"@sparkle":()=>Pt(256,4,.6,16,.08),"@star":()=>Pt(256,5,.62,8,.1),"@trail":()=>Zr(128,256)};function li(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=Ba(e);return t?()=>ut(Oa(t),2.8):()=>ut(ei(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>Jo(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>$e(256,8):/leaves7/.test(n)?()=>$e(256,7):/leaves6/.test(n)?()=>$e(256,6):/leaves5/.test(n)?()=>$e(256,5):/leaves3/.test(n)?()=>$e(256,3):/leaves2/.test(n)?()=>$e(256,2):/leaves1/.test(n)?()=>$e(256,1):()=>$e(256,0):/circle_wind|windcircle/.test(n)?()=>ti(256):/fog|cloud|mist|vapor/.test(n)?()=>It(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>It(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>yt(128,512,.3,!0):/flare/.test(n)?()=>ci(256):/bubble/.test(n)?()=>Qo(256,1):/ring|wave/.test(n)?()=>Gr(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>Yr(256,Qr(n)):/sickle|crescent|moon/.test(n)?()=>ii(256):/glyph|magic|rune/.test(n)?()=>ai(256,Qr(n)):/snowflake|雪花|snow/.test(n)?()=>si(256):/流星|meteor|shooting/.test(n)?()=>Zr(128,256):/star|星/.test(n)?()=>Pt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>Pt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>qr(256,512,2,4):/drop|rain/.test(n)?()=>Kr(128,512):/debris|dirt|rock/.test(n)?()=>oi(128):/lightning|bolt|arc/.test(n)?()=>or(256,Qr(n)):/note|music/.test(n)?()=>Pt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>Zr(128,256):()=>Et(256,{r:.12,w:1},{r:.3,w:.15})}function $a(e){if(_n.has(e))return _n.get(e);let n=null;const t=Hr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&nr)try{n=nr(e)}catch{n=null}if(!n&&Cn[e])try{n=Cn[e]()}catch{n=null}if(!n)try{n=li(e)()}catch{n=null}return n||(n=Et(256,{r:.12,w:1},{r:.3,w:.15})),_n.set(e,n),n}function za(e){return typeof e=="string"&&e.indexOf("particle/")===0}const ja=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:$a,builtinParticleFrames:La,isBuiltinParticleTextureName:za,listBuiltinParticleTextureNames:Ra,particleNormalNameForAlbedo:Ia,prepareParticleNormalTexture:ka,resetParticleTextureFactories:Ca,setParticleTextureFactory:Ea,setParticleTextureProvider:Pa},Symbol.toStringTag,{value:"Module"})),ui=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Bt(e,n,t){const o=t||new Float32Array(16);for(let r=0;r<4;r++)for(let i=0;i<4;i++)o[r*4+i]=e[i]*n[r*4]+e[4+i]*n[r*4+1]+e[8+i]*n[r*4+2]+e[12+i]*n[r*4+3];return o}function fi(e){const n=[];for(let o=0;o<4;o++)n.push([e[o],e[4+o],e[8+o],e[12+o],0,0,0,0]),n[o][4+o]=1;for(let o=0;o<4;o++){let r=o;for(let c=o+1;c<4;c++)Math.abs(n[c][o])>Math.abs(n[r][o])&&(r=c);const i=n[o];n[o]=n[r],n[r]=i;const s=n[o][o];if(Math.abs(s)<1e-12)return Float32Array.from(ui);for(let c=0;c<8;c++)n[o][c]/=s;for(let c=0;c<4;c++){if(c===o)continue;const a=n[c][o];if(a!==0)for(let f=0;f<8;f++)n[c][f]-=a*n[o][f]}}const t=new Float32Array(16);for(let o=0;o<4;o++)for(let r=0;r<4;r++)t[o*4+r]=n[r][4+o];return t}function Jr(e,n,t,o,r,i,s,c,a,f){const l=f||new Float32Array(16),d=Math.cos(o),h=Math.sin(o),m=Math.cos(r),M=Math.sin(r),g=Math.cos(i),y=Math.sin(i);return l[0]=g*m*s,l[1]=y*m*s,l[2]=-M*s,l[3]=0,l[4]=(g*M*h-y*d)*c,l[5]=(y*M*h+g*d)*c,l[6]=m*h*c,l[7]=0,l[8]=(g*M*d+y*h)*a,l[9]=(y*M*d-g*h)*a,l[10]=m*d*a,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function Rn(e,n){const t=[];for(;n<e.byteLength;){const r=e.getUint8(n++);if(r===0)break;t.push(r)}let o="";try{o=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{o=String.fromCharCode.apply(null,t)}return{value:o,next:n}}function ir(e,n,t=0){const o=[];for(let r=0;r<n.length;r++)o.push(n.charCodeAt(r));e:for(let r=t;r<=e.length-o.length;r++){for(let i=0;i<o.length;i++)if(e[r+i]!==o[i])continue e;return r}return-1}function Va(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode.apply(null,Array.from(e.subarray(0,8)));if(!t.startsWith("MDLV"))throw new Error("\u4E0D\u662F MDL: "+t);const o=Rn(n,21),i=parseInt(t.slice(4),10)>=23?[{lenOff:32,stride:80,uv:72,bone:40,weight:56},{lenOff:32,stride:48,uv:40,bone:-1,weight:-1}]:[{lenOff:8,stride:52,uv:44,bone:12,weight:28},{lenOff:4,stride:52,uv:44,bone:12,weight:28},{lenOff:32,stride:80,uv:72,bone:40,weight:56}];let s=null,c=0,a=0;for(const q of i){const oe=o.next+q.lenOff;if(oe+4>e.byteLength)continue;const H=n.getUint32(oe,!0);if(H>0&&H%q.stride===0&&oe+4+H<=e.byteLength){s=q,c=H,a=oe;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(q=>q.stride).join("/")+"\uFF09");const f=a+4,l=c/s.stride,d=new Float32Array(l*3),h=new Float32Array(l*2),m=new Float32Array(l*4),M=new Float32Array(l*4);for(let q=0;q<l;q++){const oe=f+q*s.stride;if(d[q*3]=n.getFloat32(oe,!0),d[q*3+1]=n.getFloat32(oe+4,!0),d[q*3+2]=n.getFloat32(oe+8,!0),h[q*2]=n.getFloat32(oe+s.uv,!0),h[q*2+1]=n.getFloat32(oe+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let H=0;H<4;H++)m[q*4+H]=n.getUint32(oe+s.bone+H*4,!0),M[q*4+H]=n.getFloat32(oe+s.weight+H*4,!0);else m[q*4]=0,M[q*4]=1}const g=n.getUint32(f+c,!0),y=f+c+4,b=l>65535&&g%4===0,p=b?g/4:g/2,v=b?new Uint32Array(p):new Uint16Array(p);if(b)for(let q=0;q<p;q++)v[q]=n.getUint32(y+q*4,!0);else for(let q=0;q<p;q++)v[q]=n.getUint16(y+q*2,!0);const _=Ha(e,n),w=Xa(e,n,_.length),L=Ya(e,n,_),F=Wa(e,n,_.length),D=[],B=[],z=[];if(_.length>0){const q=_.map((H,j)=>{const ee=H.matrix,le=Math.hypot(ee[0],ee[1]),Se=Math.hypot(ee[4],ee[5]);return z[j]=Float32Array.from([ee[12],ee[13],ee[14],0,0,Math.atan2(ee[1],ee[0]),le||1,Se||1,ee[10]||1]),Float32Array.from(ee)});for(let H=0;H<_.length;H++){const j=z[H],ee=_[H].matrix;Math.hypot(j[0]-ee[12],j[1]-ee[13])>.001&&(q[H]=Jr(j[0],j[1],j[2],j[3],j[4],j[5],j[6],j[7],j[8],new Float32Array(16)))}const oe=[];for(let H=0;H<_.length;H++){const j=_[H].parent;oe[H]=j>=0&&j<H?Bt(oe[j],q[H]):Float32Array.from(q[H])}for(let H=0;H<_.length;H++)D[H]=fi(oe[H]);if(L){const H=[];for(let j=0;j<_.length;j++){const ee=_[j].parent;H[j]=ee>=0&&ee<j?Bt(H[ee],L[j]):Float32Array.from(L[j])}for(let j=0;j<_.length;j++)B[j]=Bt(H[j],D[j])}}let V=1/0,Y=-1/0,Z=1/0,X=-1/0;for(let q=0;q<l;q++){const oe=d[q*3],H=d[q*3+1];oe<V&&(V=oe),oe>Y&&(Y=oe),H<Z&&(Z=H),H>X&&(X=H)}return{magic:t,materialPath:o.value,vertexCount:l,positions:d,uvs:h,boneIdx:m,weights:M,indexCount:p,indexType:b?"u32":"u16",indices:v,bones:_,animations:w,animBound:Ga(w,_),invBindWorld:D,bindTRS:z.length>0?z:null,attachments:F.length>0?F:null,restCorrection:B.length>0?B:null,bounds:{minX:V,maxX:Y,minY:Z,maxY:X}}}function Wa(e,n,t){const o=ir(e,"MDAT");if(o<0)return[];const r=n.getUint16(o+13,!0);if(r<=0||r>256)return[];const i=[];let s=o+15;for(let c=0;c<r&&!(s+2>e.length);c++){const a=n.getUint16(s,!0),f=Rn(n,s+2);if(f.next+64>e.length)break;const l=new Float32Array(16);for(let d=0;d<16;d++)l[d]=n.getFloat32(f.next+d*4,!0);a<t&&i.push({bone:a,name:f.value,matrix:l}),s=f.next+64}return i}function Ha(e,n){const t=ir(e,"MDLS");if(t<0)return[];const o=n.getUint32(t+13,!0);if(o<=0||o>1024)return[];const r=[];let i=t+17;for(let s=0;s<o;s++){if(i+77>n.byteLength)return r;const c=n.getUint32(i+1,!0),a=n.getInt32(i+5,!0),f=new Float32Array(16);for(let d=0;d<16;d++)f[d]=n.getFloat32(i+13+d*4,!0);const l=Rn(n,i+13+64);r.push({id:c,parent:a>=0&&a<o?a:-1,matrix:f}),i=l.next}return r}function Xa(e,n,t){const o=ir(e,"MDLA");if(o<0)return[];let r=o+9;const i=n.getUint32(r,!0);r+=4;const s=n.getUint32(r,!0);if(r+=4,s<=0||s>256)return[];const c=[];for(let a=0;a<s&&!(r+16>n.byteLength);a++){const f=n.getUint32(r,!0);r+=8;const l=Rn(n,r);r=l.next;const d=Rn(n,r);if(r=d.next,r+16>n.byteLength)break;const h=n.getFloat32(r,!0);r+=4;const m=n.getUint32(r,!0);r+=8;const M=n.getUint32(r,!0);if(r+=4,M>1024)break;const g=[];for(let y=0;y<M&&!(r+8>n.byteLength);y++){r+=4;const b=n.getUint32(r,!0);r+=4;const p=Math.floor(b/36);if(r+b>n.byteLength)break;const v=new Float32Array(p*9);for(let _=0;_<p;_++){const w=r+_*36;for(let L=0;L<9;L++)v[_*9+L]=n.getFloat32(w+L*4,!0)}r+=b,g.push({frameCount:p,keyframes:v})}if(r+=35,g.length>0&&m>0&&h>0&&c.push({id:f,name:l.value,mode:d.value,fps:h,frameCount:m,duration:m/h,tracks:g}),r>=i)break}return c}function Ga(e,n){let t=0,o=0;for(const r of e)for(let i=0;i<r.tracks.length;i++){const s=r.tracks[i];if(!s)continue;const c=n[i],a=c?c.matrix[12]:0,f=c?c.matrix[13]:0,l=s.keyframes;for(let d=0;d<s.frameCount;d++){const h=Math.abs(l[d*9]-a),m=Math.abs(l[d*9+1]-f);h>t&&(t=h),m>o&&(o=m)}}return{x:t,y:o}}function Ya(e,n,t){if(t.length===0)return null;const o=ir(e,"MDLE");if(o<0)return null;const r=o+8+1+4+4;if(r+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const c=new Float32Array(16);for(let a=0;a<16;a++)c[a]=n.getFloat32(r+s*64+a*4,!0);i.push(c)}return i}function qa(e,n,t,o){const r=e.frameCount;if(r===0)return o[0]=0,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=0,o[6]=1,o[7]=1,o[8]=1,o;const i=t*n.fps;let s,c,a;if(n.mode==="loop"){const m=Math.max(1,r-1),M=(i%m+m)%m;s=Math.floor(M),c=(s+1)%r,a=M-s}else if(n.mode==="mirror"){const m=Math.max(1,r-1),M=m*2;let g=(i%M+M)%M;g>m&&(g=M-g),s=Math.floor(g),c=Math.min(s+1,r-1),a=g-s}else{const m=Math.min(Math.max(i,0),r-1);s=Math.floor(m),c=Math.min(s+1,r-1),a=m-s}const f=e.keyframes,l=s*9,d=c*9,h=1-a;for(let m=0;m<9;m++)if(m>=3&&m<=5){let M=f[d+m]-f[l+m];M>Math.PI?M-=2*Math.PI:M<-Math.PI&&(M+=2*Math.PI),o[m]=f[l+m]+M*a}else o[m]=f[l+m]*h+f[d+m]*a;return o}function Za(e,n,t){const o=e.bindTRS&&e.bindTRS[n];if(o)return t.set(o),t;const r=e.bones[n].matrix;return t[0]=r[12],t[1]=r[13],t[2]=r[14],t[3]=0,t[4]=0,t[5]=Math.atan2(r[1],r[0]),t[6]=Math.hypot(r[0],r[1])||1,t[7]=Math.hypot(r[4],r[5])||1,t[8]=r[10]||1,t}function eo(e,n,t,o){const r=e.bones,i=r.length;if(i===0)return null;const s=!!(o&&o.size>0);if(!e._skin||e._skin.length!==i*16){e._skin=new Float32Array(i*16),e._local=[],e._world=[],e._tmp=new Float32Array(16),e._tmp2=new Float32Array(16);for(let h=0;h<i;h++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const c=Array.isArray(t)&&t.length>0,a=[];if(c)for(const h of t){if(h.visible===!1||h.visible===0)continue;const m=e.animations.find(M=>M.id===h.animation);m&&a.push({anim:m,additive:!!h.additive,blend:typeof h.blend=="number"?h.blend:1,rate:typeof h.rate=="number"?h.rate:1})}if(a.length===0&&!c){const h=e.animations[0];if(h)a.push({anim:h,additive:!1,blend:1,rate:1});else if(!s)return null}const f=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),d=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let h=0;h<i;h++){Za(e,h,f),l.set(f);let m=!1,M=0;for(const y of a){const b=y.anim.tracks[h];if(!b)continue;qa(b,y.anim,n*y.rate,d);const p=y.blend;if(y.additive){for(let v=0;v<9;v++){let _=d[v]-f[v];v>=3&&v<=5&&(_>Math.PI?_-=2*Math.PI:_<-Math.PI&&(_+=2*Math.PI)),l[v]+=_*p}M+=p}else for(let v=0;v<9;v++)l[v]=l[v]*(1-p)+d[v]*p;m=!0}if(M>1)for(let y=0;y<9;y++)l[y]=f[y]+(l[y]-f[y])/M;const g=s?o.get(h):void 0;g&&(l[0]=g[0],l[1]=g[1],l[2]=g[2],m=!0),m?Jr(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[h]):Jr(f[0],f[1],f[2],f[3],f[4],f[5],f[6],f[7],f[8],e._local[h])}for(let h=0;h<i;h++){const m=r[h].parent;m>=0&&m<h?Bt(e._world[m],e._local[h],e._world[h]):e._world[h].set(e._local[h])}for(let h=0;h<i;h++)Bt(e._world[h],e.invBindWorld[h],e._tmp),e._skin.set(e._tmp,h*16);return e._skin}function di(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:fi(e.invBindWorld[n])}function Ka(e,n){return Bt(e,n)}function hi(e,n){if(!e||!e.attachments||typeof n!="string"||n===""||!e._world)return null;for(const t of e.attachments)if(t.name===n)return t.bone<0||t.bone>=e._world.length?null:Bt(e._world[t.bone],t.matrix);return null}function mi(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const o=di(e,t.bone);return o?Bt(o,t.matrix):null}return null}function to(e,n,t){const o=e&&e.angles&&e.angles[2]||0,r=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=o*Math.PI/180,c=Math.cos(s),a=Math.sin(s),f=n*r,l=t*i;return[f*c-l*a,f*a+l*c]}function Qa(e){const n=new Map,t=new Map;for(const i of e){if(!i||i.id===void 0||i.id===null||(n.set(i.id,i),i.parentId===void 0||i.parentId===null))continue;const s=t.get(i.parentId);s?s.push(i):t.set(i.parentId,[i])}const o=(i,s)=>{const c=t.get(i.id);if(c)for(const a of c)s.push(a),o(a,s)},r=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const c=n.get(i.parentId);if(!c||!c.puppet)continue;const a=mi(c.puppet,s);if(!a)continue;const f=a[12],l=a[13],d=to(c,f,l),h=[];o(i,h),i.origin[0]+=d[0],i.origin[1]+=d[1];for(const m of h)m.origin[0]+=d[0],m.origin[1]+=d[1];i.parallaxDepth=c.parallaxDepth?c.parallaxDepth.slice():null;for(const m of h)m.parallaxDepth=i.parallaxDepth?i.parallaxDepth.slice():null;r.push({layer:i,parent:c,name:s,bindX:f,bindY:l,desc:h})}for(const i of r){i.baseX=i.layer.origin[0],i.baseY=i.layer.origin[1],i.subtree=[{layer:i.layer,x:i.layer.origin[0],y:i.layer.origin[1]}];for(const s of i.desc)i.subtree.push({layer:s,x:s.origin[0],y:s.origin[1]})}return r}function Ja(e,n,t){if(!e||e.length===0)return;const o=new Set,r=[];for(const s of e){const c=s.parent&&s.parent.puppet;if(!c){r.push(null);continue}if(!o.has(c)){o.add(c);const f=typeof t=="function"?t(s.parent):null;eo(c,n,s.parent.animationLayers,f)}const a=hi(c,s.name);if(!a){r.push(null);continue}r.push(to(s.parent,a[12]-s.bindX,a[13]-s.bindY))}const i=new Set;for(const s of e){const c=s.subtree||[{layer:s.layer,x:s.baseX,y:s.baseY}];for(const a of c)i.has(a.layer)||(i.add(a.layer),a.layer.origin[0]=a.x,a.layer.origin[1]=a.y)}for(let s=0;s<e.length;s++){const c=e[s],a=r[s],f=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(a)for(const l of f)l.layer.origin[0]+=a[0],l.layer.origin[1]+=a[1]}}const ec=128,sr=24;function tc(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(sr,Math.min(ec,t))}const nc=e=>`#version 300 es
136
140
  in vec3 a_pos;
137
141
  in vec2 a_uv;
138
142
  in vec4 a_bone;
@@ -158,7 +162,7 @@ void main() {
158
162
  vec4 local = total > 0.0 ? skinned / total : p;
159
163
  gl_Position = u_mvp * vec4(local.xy, 0.0, 1.0);
160
164
  v_uv = a_uv;
161
- }`,Ha=`#version 300 es
165
+ }`,rc=`#version 300 es
162
166
  precision mediump float;
163
167
  in vec2 v_uv;
164
168
  uniform sampler2D u_tex;
@@ -167,12 +171,12 @@ out vec4 fragColor;
167
171
  void main() {
168
172
  vec4 t = texture(u_tex, v_uv);
169
173
  fragColor = t * u_color;
170
- }`;function Ga(e){const n=(u,l)=>{const d=e.createShader(u);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("MDL \u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(d));return d};let t=Va(e),r=null;for(;;){const u=e.createProgram();let l=!1;try{e.attachShader(u,n(e.VERTEX_SHADER,Xa(t))),e.attachShader(u,n(e.FRAGMENT_SHADER,Ha)),e.bindAttribLocation(u,0,"a_pos"),e.bindAttribLocation(u,1,"a_uv"),e.bindAttribLocation(u,2,"a_bone"),e.bindAttribLocation(u,3,"a_weight"),e.linkProgram(u),l=!!e.getProgramParameter(u,e.LINK_STATUS)}catch{l=!1}if(l){r=u;break}if(e.deleteProgram(u),t<=ir)throw new Error("MDL \u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25\uFF08\u9AA8\u6570\u5DF2\u964D\u5230 "+ir+"\uFF09");t=Math.max(ir,t>>1)}const o=t,i={mvp:e.getUniformLocation(r,"u_mvp"),tex:e.getUniformLocation(r,"u_tex"),skin:e.getUniformLocation(r,"u_skin"),boneCount:e.getUniformLocation(r,"u_boneCount"),color:e.getUniformLocation(r,"u_color")},s=new Float32Array(o*16);for(let u=0;u<o;u++)s.set(ni,u*16);const c=new WeakMap;function a(u){let l=c.get(u);if(l)return l;const d=e.createVertexArray();e.bindVertexArray(d);const h=u.vertexCount,p=new Float32Array(h*13);for(let v=0;v<h;v++){const b=v*13;p[b]=u.positions[v*3],p[b+1]=u.positions[v*3+1],p[b+2]=u.positions[v*3+2],p[b+3]=u.uvs[v*2],p[b+4]=u.uvs[v*2+1];for(let y=0;y<4;y++)p[b+5+y]=u.boneIdx[v*4+y],p[b+9+y]=u.weights[v*4+y]}const w=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,w),e.bufferData(e.ARRAY_BUFFER,p,e.STATIC_DRAW);const m=52;e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,e.FLOAT,!1,m,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,e.FLOAT,!1,m,12),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,4,e.FLOAT,!1,m,20),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,m,36);const g=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,g),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u.indices,e.STATIC_DRAW),e.bindVertexArray(null),l={vao:d,vbuf:w,ibuf:g},c.set(u,l),l}return{gl:e,prog:r,maxBones:o,upload(u){a(u)},draw(u,l,d,h){const p=a(l);e.useProgram(r),e.bindVertexArray(p.vao),e.activeTexture(e.TEXTURE0);const w=d.overrideTex||(h&&h.glTex?h.glTex:h);e.bindTexture(e.TEXTURE_2D,w),e.uniform1i(i.tex,0),e.uniformMatrix4fv(i.mvp,!1,u);const m=d.color||[1,1,1,1];e.uniform4f(i.color,m[0],m[1],m[2],m[3]);const g=Zr(l,d.time||0,d.animLayers,d.boneOverrides),v=Math.min(l.bones.length,o);g&&v>0?(e.uniformMatrix4fv(i.skin,!1,g.subarray(0,v*16)),e.uniform1i(i.boneCount,v)):(e.uniformMatrix4fv(i.skin,!1,s),e.uniform1i(i.boneCount,0)),d.blending==="additive"?(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE)):d.blending==="normal"?e.disable(e.BLEND):(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA));const b=l.indexType==="u32"?e.UNSIGNED_INT:e.UNSIGNED_SHORT;e.drawElements(e.TRIANGLES,l.indexCount,b,0),e.bindVertexArray(null)}}}const Ya=Object.freeze(Object.defineProperty({__proto__:null,applyAttachmentBindOrigins:$a,attachmentBind:si,attachmentWorld:ii,bindWorldOf:oi,computeSkinMatrices:Zr,createMDLRenderer:Ga,followAttachments:ja,mat4MulOut:za,parentMeshToWorldDelta:Kr,parseMDL:Fa},Symbol.toStringTag,{value:"Module"}));function ai(e,n,t){const r=Math.max(0,Number(t)||0),o=Math.max(1,Number(e)||1),i=Math.max(1,Number(n)||1);return r*2>=Math.min(o,i)?0:r}function qa(e,n,t){const r=Math.max(1,n.boxW),o=Math.max(1,n.boxH),i=ai(r,o,n.padding||0),s=n.spacing||[0,0],c=Math.max(1,n.lineHeight||(n.pointsize||24)*1.25+s[1]),a=Math.max(1,r-i*2),u=n.limitwidth&&n.maxwidth>0?Math.min(n.maxwidth,a):1/0;function l(S){if(t(S)<=u)return[S];const _=[];let C="",N=-1;for(const D of S)if(C+=D,(D===" "||D===" ")&&(N=C.length),t(C)>u&&C.length>1)for(N>0?(_.push(C.slice(0,N-1)),C=C.slice(N)):(_.push(C.slice(0,-1)),C=D),N=-1;t(C)>u&&C.length>1;)_.push(C.slice(0,-1)),C=C.slice(-1);return C!==""&&_.push(C),_.length?_:[""]}let d=[];const h=String(e??"").split(`
171
- `);for(const S of h)d.push(...l(S));let p=!1;if(n.limitrows&&n.maxrows>0&&d.length>n.maxrows&&(d=d.slice(0,n.maxrows),p=!0,n.limituseellipsis)){let S=d[n.maxrows-1];for(;S.length>0&&t(S+"\u2026")>u;)S=S.slice(0,-1);d[n.maxrows-1]=S+"\u2026"}const w=d.map(S=>t(S)),m=d.length*c,g=n.halign||"center",v=n.valign||"center",b=v==="top"?i:v==="bottom"?Math.max(i,o-i-m):(o-m)/2;return{lines:d.map((S,_)=>{const C=w[_],N=g==="left"?i:g==="right"?Math.max(i,r-i-C):(r-C)/2;return{text:S,width:C,x:N,y:b+_*c}}),lineHeight:c,totalH:m,truncated:p,boxW:r,boxH:o}}function Za(e,n,t){const r=n.boxW,o=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,c=t.brightness!==void 0?t.brightness:1;e.font=t.font;try{e.letterSpacing=(t.spacing&&t.spacing[0]?t.spacing[0]:0)+"px"}catch{}if(e.textBaseline="middle",t.opaquebackground){const u=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(u[0]*255*l)},${Math.round(u[1]*255*l)},${Math.round(u[2]*255*l)},${s})`,e.fillRect(0,0,r,o)}const a=(u,l,d)=>{e.fillStyle=d;for(const h of n.lines)e.fillText(h.text,h.x+u,h.y+n.lineHeight/2+l)};if(t.castshadow){const u=Math.max(1,(t.pointsize||24)/10);a(u,u,`rgba(0,0,0,${s*.75})`)}a(0,0,`rgba(${Math.round(i[0]*255*c)},${Math.round(i[1]*255*c)},${Math.round(i[2]*255*c)},${s})`)}const ci=/^add[A-Z]/;function li(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function ui(e){return new Proxy(e,{get(n,t,r){const o=Reflect.get(n,t,r);if(o==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return o}})}function ln(e,n){return()=>{}}function fi(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||ln),e.setTimeout||(e.setTimeout=n.setTimeout||ln),e.clearTimeout||(e.clearTimeout=n.clearTimeout||(()=>{})),e.clearInterval||(e.clearInterval=n.clearInterval||(()=>{})),typeof n.openUserShortcut=="function"&&(e.openUserShortcut=n.openUserShortcut);const t=n.mediaControl||null;e.media={skipNext:()=>{if(t&&t.skipNext)return t.skipNext()},skipPrevious:()=>{if(t&&t.skipPrevious)return t.skipPrevious()},play:()=>{if(t&&t.play)return t.play()},pause:()=>{if(t&&t.pause)return t.pause()},playPause:()=>{if(t&&t.playPause)return t.playPause()},get snapshot(){return t&&t.snapshot?t.snapshot:null}};const r=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return r&&r.title?String(r.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return r&&r.app?String(r.app):""}})}class pe{constructor(n,t,r){if(n!==null&&typeof n=="object")this.x=n.x!==void 0?n.x:n.width||0,this.y=t!==void 0?t:n.y!==void 0?n.y:n.height||0,this.z=r!==void 0?r:n.z||0;else if(t===void 0&&r===void 0){const o=Number(n)||0;this.x=o,this.y=o,this.z=o}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){const t=new pe(n);return new pe(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new pe(n);return new pe(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new pe(this.x*n.x,this.y*n.y,this.z*n.z):new pe(this.x*n,this.y*n,this.z*n)}divide(n){const t=(r,o)=>o===0?0:r/o;return n&&typeof n=="object"?new pe(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new pe(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new pe(this.x,this.y,this.z)}mix(n,t){const r=new pe(n),o=Number(t),i=Number.isFinite(o)?o:0;return new pe(this.x+(r.x-this.x)*i,this.y+(r.y-this.y)*i,this.z+(r.z-this.z)*i)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const n=this.length();return n===0?new pe(0,0,0):new pe(this.x/n,this.y/n,this.z/n)}dot(n){const t=new pe(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const di=pe;function hi(e){if(e instanceof pe||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===pe.prototype)return e;try{Object.setPrototypeOf(e,pe.prototype)}catch{}return e}function mi(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new pe(0,0,0),cursorScreenPosition:new pe(0,0,0),cursorPosition:new pe(0,0,0),cursorPositionLast:new pe(0,0,0),cursorLeftDown:!1}}function Ka(e,n,t){return new pe(e||0,n||0,t||0)}function Qa(){const e={cursorWorldPosition:new pe(0,0,0),cursorScreenPosition:new pe(0,0,0),cursorPosition:new pe(0,0,0),cursorPositionLast:new pe(0,0,0),cursorLeftDown:!1};return e.update=function(n){return n&&(e.cursorWorldPosition.x=n.wx,e.cursorWorldPosition.y=n.originY!=null?n.originY:n.wy,e.cursorWorldPosition.z=0,e.cursorScreenPosition.x=n.screenX,e.cursorScreenPosition.y=n.screenY,e.cursorScreenPosition.z=0,e.cursorPosition.x=n.u,e.cursorPosition.y=n.v,e.cursorPosition.z=0,e.cursorPositionLast.x=n.lastU,e.cursorPositionLast.y=n.lastV,e.cursorPositionLast.z=0,e.cursorLeftDown=!!n.leftDown),e},e}const pi={mix:(e,n,t)=>e+(n-e)*t,lerp:(e,n,t)=>e+(n-e)*t,clamp:(e,n,t)=>Math.min(t,Math.max(n,e)),saturate:e=>Math.min(1,Math.max(0,e)),smoothstep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},smoothStep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},random:(e,n)=>e===void 0?Math.random():e+Math.random()*((n===void 0?1:n)-e),randomInt:(e,n)=>Math.floor((e||0)+Math.random()*((n===void 0?1:n)+1-(e||0))),degrees:e=>e*180/Math.PI,radians:e=>e*Math.PI/180},gi={hsv2rgb:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=((Number(n.x)||0)%1+1)%1,r=Math.min(1,Math.max(0,Number(n.y)||0)),o=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,c=o*(1-r),a=o*(1-s*r),u=o*(1-(1-s)*r),d=[[o,u,c],[a,o,c],[c,o,u],[c,a,o],[u,c,o],[o,c,a]][i%6];return{x:d[0],y:d[1],z:d[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,r=Number(n.y)||0,o=Number(n.z)||0,i=Math.max(t,r,o),s=Math.min(t,r,o),c=i-s;let a=0;return c>0&&(i===t?a=(r-o)/c/6:i===r?a=(2+(o-t)/c)/6:a=(4+(t-r)/c)/6,a<0&&(a+=1)),{x:a,y:i===0?0:c/i,z:i}}},bi={add:(e,n)=>({x:(e.x||0)+(n.x||0),y:(e.y||0)+(n.y||0),z:(e.z||0)+(n.z||0)}),subtract:(e,n)=>({x:(e.x||0)-(n.x||0),y:(e.y||0)-(n.y||0),z:(e.z||0)-(n.z||0)}),scale:(e,n)=>({x:(e.x||0)*n,y:(e.y||0)*n,z:(e.z||0)*n}),length:e=>Math.hypot(e.x||0,e.y||0,e.z||0),dot:(e,n)=>(e.x||0)*(n.x||0)+(e.y||0)*(n.y||0)+(e.z||0)*(n.z||0),normalize:e=>{const n=Math.hypot(e.x||0,e.y||0,e.z||0)||1;return{x:(e.x||0)/n,y:(e.y||0)/n,z:(e.z||0)/n}},mix:(e,n,t)=>({x:(e.x||0)+((n.x||0)-(e.x||0))*t,y:(e.y||0)+((n.y||0)-(e.y||0))*t,z:(e.z||0)+((n.z||0)-(e.z||0))*t})},vi=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),sr=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],Ja=["scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent"],ec=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${Ja.join("|")})\\b)`,"gm"),tc={WEMath:!0,WEColor:!0,WEVector:!0};function yi(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function xi(e){return yi(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,r)=>{const o=String(r);return tc[o]?t===o?"":`var ${t} = ${o};`:`var ${t} = {};`}).replace(/(^[ \t]*|;|\})[ \t]*import\s+(?:[^;'"]+\s+from\s+)?['"][^'"]*['"];?[ \t]*/gm,"$1").replace(/(^[ \t]*|;|\})[ \t]*export[ \t]+(?=(?:async[ \t]+)?function\b|(?:var|let|const)\b)/gm,"$1").replace(ec,"$1")}function Rn(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function nc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=xi(e);if(r===e&&e.indexOf("update")<0)return null;const o={};if(n&&typeof n=="object")for(const[v,b]of Object.entries(n))o[v]=Rn(b);const i=new Proxy(()=>i,{apply(){return i},get(v,b){if(b==="finish")return()=>o;if(typeof b=="string"&&ci.test(b))return y=>(y&&typeof y=="object"&&typeof y.name=="string"&&!(y.name in o)&&(o[y.name]=Rn(y.value)),i)}}),s={text:t.text!==void 0&&t.text!==null?String(t.text):"",font:t.font||"",pointsize:t.pointsize||24,color:(t.color||[1,1,1]).slice(),angles:(t.angles||[0,0,0]).slice(),scale:(t.scale||[1,1,1]).slice(),visible:t.visible!==!1,origin:Jr(t.origin||[0,0,0])},c={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:t.canvasSize||{width:1920,height:1080},screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||ln,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||ln,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};fi(c,t);const a=t.audioViews;c.registerAudioBuffers=v=>{const b=Math.max(1,Math.min(64,Math.floor(Number(v)||0)));let y=a?a.get(b):void 0;return y||(y={left:new Float32Array(b),right:new Float32Array(b),average:new Float32Array(b)},a&&a.set(b,y)),y};const u={getLayer(v){const b=t.getLayerText?t.getLayerText(String(v)):void 0;return{text:b!=null?String(b):""}},createLayer(v){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:Jr(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},d={console:li()},h=mi(t.inputView);let p;try{p=new Function("scriptProperties","engine","thisLayer","thisScene","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","MediaPlaybackEvent",`"use strict";
172
- `+r+`
173
- ;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+sr.map(b=>`${b}: typeof ${b} === "function" ? ${b} : null,`).join("")+"dummy_: 0};")(o,ui(c),s,u,pi,gi,bi,i,l,d.console,void 0,d,d,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,pe,di,h,vi)}catch(v){return t.onError&&t.onError(v,"parse"),null}const w=!!(p&&sr.some(v=>p[v])),m=!!(p&&typeof p.applyUserProperties=="function");if(!p||!p.update&&!w&&!m)return null;const g={engine:c,thisLayer:s,scriptProperties:o,hasUpdate:!!p.update,hasCursorHook:!!(p.cursorClick||p.cursorEnter||p.cursorLeave||p.cursorDown||p.cursorUp||p.cursorMove),hasMediaHook:w,hasApplyHook:m,errCount:0,disabled:!1,init(v){if(p.init)try{p.init(v)}catch(b){g.errCount++,t.onError&&t.onError(b,"init")}},applyUserProperties(v){if(p.applyUserProperties)try{p.applyUserProperties(v||{})}catch(b){g.errCount++,t.onError&&t.onError(b,"applyUserProperties")}},callUpdate(v){if(!p.update||g.disabled)return null;const b=s.text;let y;try{y=p.update(b!==""?b:v!==void 0?v:"")}catch(S){return g.errCount++,t.onError&&t.onError(S,"update"),g.errCount>=3&&(g.disabled=!0),null}return typeof y=="string"?(s.text=y,y):typeof y=="boolean"?null:y!=null?(s.text=String(y),s.text):s.text!==b?s.text:null},callCursor(v,b){if(g.disabled)return;const y=p[v];if(typeof y=="function")try{return y(b)}catch(S){g.errCount++,t.onError&&t.onError(S,v),g.errCount>=3&&(g.disabled=!0);return}},callMedia(v,b){if(g.disabled)return;const y=p[v];if(typeof y=="function")try{return y(b)}catch(S){g.errCount++,t.onError&&t.onError(S,v),g.errCount>=3&&(g.disabled=!0);return}}};return g}function Ln(){const e={play:()=>e,pause:()=>e,stop:()=>e,setFrame:()=>e,setRate:()=>e,setBlend:()=>e,setVisible:()=>e,isPlaying:Object.assign(()=>!1,{valueOf:()=>!1,toString:()=>"false"}),get frame(){return 0},get frameCount(){return 0},get rate(){return 1}};return e}function rc(e){if(!e)return Ln();if(e.textureAnimation)return e.textureAnimation.api;const n={frame:null,playing:!0,rate:1},t={play:()=>(n.playing=!0,t),pause:()=>(n.playing=!1,t),stop:()=>(n.playing=!1,t),setFrame:r=>{const o=Number(r);return n.frame=Number.isFinite(o)?o:0,t},setRate:r=>{const o=Number(r);return Number.isFinite(o)&&(n.rate=o),t},setBlend:()=>t,setVisible:r=>(e.visible=!!r,t),isPlaying:Object.assign(()=>n.playing,{valueOf:()=>n.playing,toString:()=>String(n.playing)}),get frame(){return n.frame===null?0:n.frame},get frameCount(){return e.spriteFrameCount||0},get rate(){return n.rate}};return n.api=t,e.textureAnimation=n,t}function oc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const r=n(),o=r&&typeof r.duration=="function"?r.duration():0;return Number.isFinite(o)?o:0},get rate(){const r=n(),o=r&&typeof r.getRate=="function"?r.getRate():1;return Number.isFinite(o)&&o>0?o:1},set rate(r){const o=n(),i=Number(r);o&&typeof o.setRate=="function"&&Number.isFinite(i)&&o.setRate(i)},get loop(){const r=n();return r&&typeof r.getLoop=="function"?!!r.getLoop():!0},set loop(r){const o=n();o&&typeof o.setLoop=="function"&&o.setLoop(!!r)},play:()=>{const r=n();r&&r.play&&r.play()},pause:()=>{const r=n();r&&r.pause&&r.pause()},stop:()=>{const r=n();r&&r.stop&&r.stop()},isPlaying:Object.assign(()=>{const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},{valueOf(){const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},toString(){const r=n();return String(!!(r&&typeof r.isPlaying=="function"&&r.isPlaying()))}}),getCurrentTime:()=>{const r=n(),o=r&&typeof r.getCurrentTime=="function"?r.getCurrentTime():0;return Number.isFinite(o)?o:0},setCurrentTime:r=>{const o=n(),i=Number(r);o&&typeof o.setCurrentTime=="function"&&Number.isFinite(i)&&o.setCurrentTime(i)},addEndedCallback:r=>{const o=n();typeof r=="function"&&o&&typeof o.addEndedCallback=="function"&&o.addEndedCallback(r)}};return e&&(e.videoTextureApi=t),t}function ic(){const e=new Map,n=r=>e.has(String(r))?e.get(String(r)):null,t=(r,o)=>{e.set(String(r),String(o))};return{getItem:n,setItem:t,get:n,set:t,removeItem:r=>{e.delete(String(r))},remove:r=>{e.delete(String(r))},clear:()=>{e.clear()},key:r=>Array.from(e.keys())[r]??null,get length(){return e.size}}}function sc(e,n){const t=e&&e.puppet,r=t&&t.bones||null,o=r?r.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],c=s[0]||1,a=s[1]||1,u=(w,m)=>[i[0]+w*c,i[1]-m*a],l=(w,m)=>[(w-i[0])/c,-(m-i[1])/a],d=w=>{const m=n.get(w);if(m)return[m[0],m[1],m[2]];const g=r[w].matrix;return[g[12],g[13],g[14]]},h=w=>{let m=0,g=0,v=w;for(let b=0;v>=0&&v<o&&b<64;b++){const y=d(v);m+=y[0],g+=y[1],v=r[v].parent}return u(m,g)},p=w=>{const m={translation(g){if(g===void 0){const _=h(w);return new pe(_[0],_[1],0)}const v=Dt(g);let b=0,y=0;if(r[w].parent>=0){const _=h(r[w].parent),C=l(_[0],_[1]);b=C[0],y=C[1]}const S=l(v[0],v[1]);return n.set(w,[S[0]-b,S[1]-y,0]),m},rotation(){return m},scale(){return m}};return m};return{getBoneCount:()=>o,getBoneTransform:w=>{const m=Math.floor(Number(w));if(!r||!(m>=0)||m>=o){const g={translation(v){return v===void 0?new pe(0,0,0):g},rotation(){return g},scale(){return g}};return g}return p(m)},setBoneTransform:(w,m)=>{const g=Math.floor(Number(w));!r||!(g>=0)||g>=o},applyBonePhysicsImpulse:()=>{}}}function Qr(e){return{get visible(){return e?!!e.visible:!1},set visible(n){e&&(e.visible=!!n)},get name(){return e&&e.name||""},getMaterial:()=>null}}function wi(e,n){if(e==null)return null;const t=r=>{if(!r)return null;if(n&&typeof n.getSceneLayer=="function"){const o=n.getSceneLayer(String(r));if(o)return o}return n&&n.layer&&n.layer.name===r?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function ac(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Mi(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const r=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return r?`${r[1]}/workshop/${t}/${r[2]}`:e}function cc(e){if(typeof e!="string")return null;const n=e.match(/export\s+let\s+__workshopId\s*=\s*['"](\d+)['"]/);return n?n[1]:null}function lc(e){const n=t=>ar(t||null,e);return{getLayer(t){if(e.getSceneLayer){const r=e.getSceneLayer(String(t));if(r&&!r.destroyed)return n(r)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let r=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;r=Mi(t,i)}const o=e.createSceneLayer(r);return n(o||null)},destroyLayer(t){ac(wi(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const r=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=t&&typeof t=="object"?t.name:String(t||""),i=r.findIndex(s=>s&&s.name===o);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=[];for(const o of t)o&&!o.destroyed&&r.push(n(o));return r},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const r=e.getSceneAnimation(t);if(r)return r}return Ln()},getCameraTransforms(){const t=e.cameraTransforms||{zoom:1};return{zoom:typeof t.zoom=="number"?t.zoom:1,center:t.center||null,eye:t.eye||null,parallaxAmount:typeof t.parallaxAmount=="number"?t.parallaxAmount:0}},setCameraTransforms(t){const r=e.cameraTransforms;!r||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(r.zoom=t.zoom),t.center!==void 0&&(r.center=t.center),t.eye!==void 0&&(r.eye=t.eye),typeof t.parallaxAmount=="number"&&(r.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):wi(t,e)||null}}}function ar(e,n){const t=s=>Jr(Array.isArray(s)?s:[0,0,0]),r=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,o={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:dc(e),size:t(e?e.size:[0,0,0]),color:t(e?e.color:[1,1,1])},i={get name(){return e&&e.name||""},get id(){return e&&e.id||0},get visible(){const s=n&&n.targetEffect;return s?!!s.visible:e?e.visibleSelf!==void 0?!!e.visibleSelf:!!e.visible:!1},set visible(s){const c=n&&n.targetEffect;if(c){c.visible=!!s;return}e&&(e.visibleSelf=!!s,typeof n.recomputeVisibility=="function"?n.recomputeVisibility():e.visible=!!s)},get alpha(){return e&&typeof e.alpha=="number"?e.alpha:1},set alpha(s){e&&(e.alpha=Number(s)||0)},get brightness(){return e&&typeof e.brightness=="number"?e.brightness:1},set brightness(s){e&&(e.brightness=Number(s)||0)},get text(){return e&&e.text!==void 0?String(e.text):""},set text(s){e&&typeof s!="boolean"&&(e.text=s==null?"":String(s))},get pointsize(){return e&&e.textPointsize||24},set pointsize(s){e&&(e.textPointsize=Number(s)||24)},get font(){return e&&e.textFont||""},set font(s){e&&(e.textFont=String(s||""))},get alignment(){return e&&e.alignment||"center"},set alignment(s){if(!e)return;const c=String(s||"center").toLowerCase();e.alignment=c==="centre"?"center":c},...e&&e.puppet&&r?sc(e,r):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(c){return c===void 0?new pe(0,0,0):s},rotation(){return s},scale(){return s}};return s},setBoneTransform:()=>{},applyBonePhysicsImpulse:()=>{}},getParent:()=>{if(!e||e.parentId==null)return null;const s=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById(e.parentId):null;return!s||s.destroyed?null:ar(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const c=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!c)return[];const a=[];for(const u of s){const l=c(u);l&&!l.destroyed&&a.push(ar(l,n))}return a},getAnimation:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return s==null||s===""?a[0]||Ln():c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Ln()},getAnimationLayer:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Ln()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>rc(e),play:()=>{e&&e.soundCtl&&e.soundCtl.play&&e.soundCtl.play(),e&&e.videoCtl&&e.videoCtl.play&&e.videoCtl.play()},pause:()=>{e&&e.soundCtl&&e.soundCtl.pause&&e.soundCtl.pause(),e&&e.videoCtl&&e.videoCtl.pause&&e.videoCtl.pause()},stop:()=>{e&&e.soundCtl&&e.soundCtl.stop&&e.soundCtl.stop(),e&&e.videoCtl&&e.videoCtl.stop&&e.videoCtl.stop()},isPlaying:Object.assign(()=>{const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||c))}}),get volume(){if(e&&e.soundCtl&&typeof e.soundCtl.getVolume=="function")return e.soundCtl.getVolume();const s=e&&e.soundprops&&e.soundprops.volume;return typeof s=="number"?s:1},set volume(s){const c=Number(s);if(!Number.isFinite(c)||!e)return;const a=Math.max(0,Math.min(1,c));e.soundprops&&(e.soundprops.volume=a),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(a)},getVideoTexture:()=>oc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],c=new Float32Array(16);return c[0]=1,c[5]=1,c[10]=1,c[15]=1,c[12]=s[0]||0,c[13]=s[1]||0,c[14]=s[2]||0,{m:c}},getEffect:s=>{const c=e&&e.effects||null;if(!c||c.length===0)return Qr(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return Qr(c[Number(s)]||null);const a=String(s);return Qr(c.find(u=>u&&u.name===a)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return o.angles},set(s){if(e&&Array.isArray(e.angles)){const c=_i(s);e.angles[0]=c[0],e.angles[1]=c[1],e.angles[2]=c[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){if(e&&Array.isArray(e[s])){const c=e[s];o[s].x=c[0]||0,o[s].y=c[1]||0,o[s].z=c[2]||0}return o[s]},set(c){const a=Dt(c);o[s].x=a[0],o[s].y=a[1],o[s].z=a[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=a[0],e[s][1]=a[1],e[s][2]=a[2])}});return i}function uc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=xi(e),o={};if(n&&typeof n=="object")for(const[S,_]of Object.entries(n))if(_!==null&&typeof _=="object"&&typeof _.user=="string"){const C=t.userProperties?t.userProperties[_.user]:void 0;o[S]=C!==void 0?C:Rn(_)}else o[S]=Rn(_);const i=new Proxy(()=>i,{apply(){return i},get(S,_){if(_==="finish")return()=>o;if(typeof _=="string"&&ci.test(_))return C=>(C&&typeof C=="object"&&typeof C.name=="string"&&!(C.name in o)&&(o[C.name]=Rn(C.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:t.canvasSize||{width:1920,height:1080},screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||ln,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||ln,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};fi(s,t);const c=t.audioViews;s.registerAudioBuffers=S=>{const _=Math.max(1,Math.min(64,Math.floor(Number(S)||0)));let C=c?c.get(_):void 0;return C||(C={left:new Float32Array(_),right:new Float32Array(_),average:new Float32Array(_)},c&&c.set(_,C)),C};const a=t.shared||{},u={console:li()},l=mi(t.inputView),d=t.layer||null,h=t.workshopId!=null?t.workshopId:cc(e),p=ar(d,t),w=lc({...t,workshopId:h,getWorkshopId:()=>h});let m;try{m=new Function("scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent",`"use strict";
174
- `+r+`
175
- ;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+sr.map(_=>`${_}: typeof ${_} === "function" ? ${_} : null,`).join("")+"dummy_: 0};")(o,ui(s),pi,gi,bi,i,a,u.console,void 0,u,u,u,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,pe,di,l,p,w,p,ic(),vi)}catch(S){return t.onError&&t.onError(S,"parse"),null}const g=!!(m&&(m.cursorClick||m.cursorEnter||m.cursorLeave||m.cursorDown||m.cursorUp||m.cursorMove)),v=!!(m&&sr.some(S=>m[S])),b=!!(m&&typeof m.applyUserProperties=="function");if(!m||!m.update&&!g&&!v&&!b)return null;const y={engine:s,scriptProperties:o,hasUpdate:!!m.update,hasCursorHook:g,hasApplyHook:b,errCount:0,disabled:!1,init(S){if(m.init)try{m.init(hi(S))}catch(_){y.errCount++,t.onError&&t.onError(_,"init")}},applyUserProperties(S){if(m.applyUserProperties)try{m.applyUserProperties(S||{})}catch(_){y.errCount++,t.onError&&t.onError(_,"applyUserProperties")}},callUpdate(S){if(y.disabled||!m.update)return;let _;try{_=m.update(hi(S))}catch(C){y.errCount++,t.onError&&t.onError(C,"update"),y.errCount>=3&&(y.disabled=!0);return}return _},hasCursorHook:g,callCursor(S,_){if(y.disabled)return;const C=m[S];if(typeof C=="function")try{return C(_)}catch(N){y.errCount++,t.onError&&t.onError(N,S),y.errCount>=3&&(y.disabled=!0);return}},hasMediaHook:v,callMedia(S,_){if(y.disabled)return;const C=m[S];if(typeof C=="function")try{return C(_)}catch(N){y.errCount++,t.onError&&t.onError(N,S),y.errCount>=3&&(y.disabled=!0);return}}};return y}function Jr(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},r={get x(){return t.x},set x(o){t.x=Number(o)||0},get y(){return t.y},set y(o){t.y=Number(o)||0},get z(){return t.z},set z(o){t.z=Number(o)||0},add(o){const i=Dt(o);return t.x+=i[0],t.y+=i[1],t.z+=i[2],r},subtract(o){const i=Dt(o);return t.x-=i[0],t.y-=i[1],t.z-=i[2],r},multiply(o){if(o&&typeof o=="object"){const i=Dt(o);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(o)||0;t.x*=i,t.y*=i,t.z*=i}return r},copy(){return new pe(t.x,t.y,t.z)},length(){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},toArray(){return[t.x,t.y,t.z]}};return r}function Dt(e){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e&&typeof e=="object")return[e.x||0,e.y||0,e.z||0];const n=Number(e)||0;return[n,n,n]}const cr=Math.PI/180,lr=180/Math.PI;function fc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*lr,y:(n[1]||0)*lr,z:(n[2]||0)*lr}}function _i(e){const n=Dt(e);return[n[0]*cr,n[1]*cr,n[2]*cr]}function dc(e){const n={x:0,y:1,z:2},t={add(r){const o=Dt(r);return t.x+=o[0],t.y+=o[1],t.z+=o[2],t},subtract(r){const o=Dt(r);return t.x-=o[0],t.y-=o[1],t.z-=o[2],t},multiply(r){return t.x*=r,t.y*=r,t.z*=r,t},toArray(){return[t.x,t.y,t.z]}};for(const r of["x","y","z"])Object.defineProperty(t,r,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[r]]||0)*lr},set(o){!e||!Array.isArray(e.angles)||(e.angles[n[r]]=(Number(o)||0)*cr)}});return t}function hc(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function mc(e){for(const n of e&&e.effects?e.effects:[]){if(n&&n.visible===!1)continue;if(String(n&&(n.file||n.name)||"").includes("tint"))return!0;for(const r of n&&n.passes||[])for(const o of r&&r.textures||[])if(o&&String(o).toLowerCase().includes("mask"))return!0}return!1}const pc=Object.freeze(Object.defineProperty({__proto__:null,createInputView:Qa,drawTextLayer:Za,effectiveTextPadding:ai,evalObjectScript:uc,evalTextScript:nc,layoutText:qa,makeCursorEventVec:Ka,radToScriptAngles:fc,resolveWorkshopAssetPath:Mi,rewriteComboStringEq:yi,scriptAnglesToRad:_i,textCanvasMargin:hc,textLayerHasTintMask:mc},Symbol.toStringTag,{value:"Module"}));function gc(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,r=typeof e.clearTimeout=="function"?e.clearTimeout:null,o=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,c=new Set,a=g=>{const v=Number(g);return Number.isFinite(v)&&v>0?v:0},u=g=>()=>{try{g()}catch(v){s&&s(v,"timer")}},l=(g,v)=>{const b=()=>{g.fired||(g.fired=!0,c.delete(b),v&&g.handle!=null&&v(g.handle))};return b.handle=null,b.valueOf=()=>typeof g.handle=="number"?g.handle:0,b};function d(g,v){if(typeof g!="function")return l({fired:!0,handle:null},null);const b={fired:!1,handle:null},y=l(b,r);return c.add(y),b.handle=t?t(u(()=>{b.fired=!0,c.delete(y),g()}),a(v)):null,y.handle=b.handle,y}function h(g,v){if(typeof g!="function")return l({fired:!0,handle:null},null);const b={fired:!1,handle:null},y=l(b,i);return c.add(y),b.handle=o?o(u(g),a(v)):null,y.handle=b.handle,y}function p(g){if(typeof g=="function"){g();return}r&&g!=null&&r(g)}function w(g){if(typeof g=="function"){g();return}i&&g!=null&&i(g)}function m(){for(const g of[...c])g();c.clear()}return{setTimeout:d,setInterval:h,clearTimeout:p,clearInterval:w,dispose:m,pendingCount:()=>c.size}}const bc=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:gc},Symbol.toStringTag,{value:"Module"}));function vc(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function eo(e,n){const t=Math.floor(e),r=e-t,o=s=>{const c=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(c-Math.floor(c))*2-1},i=r*r*(3-2*r);return o(t)*(1-i)+o(t+1)*i}const yc=32,Ai=60/112,xc=3.2;function wc(e){const n=new Float32Array(16),t=new Float32Array(16),r=new Float32Array(16);for(let o=0;o<16;o++)n[o]=o%4===0?1:o%4===2?.38+e()*.15:e()<.08?.5:0,t[o]=o%8===4?1:e()<.06?.6:0,r[o]=o%2===1?.5+e()*.4:o%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:r}}function Mc(e=20260830){const n=vc(e),t=wc(n),r=new Float32Array(64);for(let g=0;g<64;g++)r[g]=n()*64;const o=64,i=new Float32Array(o),s=new Float32Array(o),c=new Float32Array(o),a=new Float32Array(o),u=new Float32Array(32),l=new Float32Array(32),d=new Float32Array(16),h=new Float32Array(16),p={left64:c,right64:a,left32:u,right32:l,left16:d,right16:h,level:0,silent:!1};function w(g,v){const b=v.length/g.length;for(let y=0;y<g.length;y++){let S=0;const _=Math.floor(y*b),C=Math.floor((y+1)*b);for(let N=_;N<Math.max(_+1,C);N++)S+=v[N];g[y]=S/Math.max(1,C-_)}}function m(g){const v=g/Ai,b=v*4,y=Math.floor(b)%16,S=b-Math.floor(b),_=Math.exp(-S*Ai*14),C=g%yc,N=C>=27&&C<29,D=C>=29?(C-29)/3:0,k=C>=24&&C<27?1-(C-24)/3:0,O=N?0:D>0?D*D:k>0?0:1,j=N?0:k>0?.35:1,W=t.kick[y]*_*O,K=(t.snare[y]*_+t.hat[y]*_*.7)*O,V=t.hat[y]*_*O,G=D>0?Math.pow(D,3)*(.4+.6*Math.abs(eo(b*2,7))):0;let Q=0;for(let q=0;q<o;q++){const te=q/o,me=Math.pow(1-te*.85,1.6);let xe=j*(.5+.3*eo(v*.5+r[q]*.05,q%8));if(xe*=.35+.65*te,te<.2&&(xe+=W*(1-te/.2)),te>=.12&&te<.62){const Pe=1-Math.abs(te-.34)/.28;Pe>0&&(xe+=K*.55*Pe)}te>=.45&&(xe+=V*.5*((te-.45)/.55)),xe+=G*.5,xe*=me,xe=Math.min(1,xe*xc);const We=.06+te*.2,Ve=eo(v*.13+q*.35,11)*We;let Ee=Math.min(1,Math.max(0,xe*(1-Ve))),rt=Math.min(1,Math.max(0,xe*(1+Ve)));const Xe=N?.012:0;i[q]=Math.max(Xe,Ee),s[q]=Math.max(Xe,rt),q<48&&(Q+=(i[q]+s[q])*.5)}return c.set(i),a.set(s),w(u,i),w(l,s),w(d,i),w(h,s),p.level=Math.min(1,Q/(48*1.2)),p.silent=N,p}return{update:m,snapshot:p,bands:o}}function _c(e,n){for(const t of e.values()){Ti(t.left,n.left64),Ti(t.right,n.right64);for(let r=0;r<t.average.length;r++)t.average[r]=(t.left[r]+t.right[r])*.5}}function Ti(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let c=i;c<s;c++)o+=n[c];e[r]=o/(s-i)}}const zt={STOPPED:0,PLAYING:1,PAUSED:2};class Fe{constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new Fe(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Fe(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Fe(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Fe(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Fe(this.x/t,this.y/t,this.z/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}copy(){return new Fe(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function Ac(e,n,t){return new Fe(e,n,t)}const Tc=[{title:"\u591C\u822A\u661F",artist:"\u76F8\u4F4D\u8FC1\u79FB",album:"\u6DF1\u7A7A\u56DE\u58F0",albumArtist:"\u76F8\u4F4D\u8FC1\u79FB",duration:212,colors:{primary:[.24,.42,.86],secondary:[.12,.18,.42],tertiary:[.62,.74,.98],text:[.95,.97,1]},lyrics:[[0,"\u5728\u65E0\u5149\u7684\u822A\u9053\u4E0A"],[12,"\u6211\u4EEC\u53EA\u5E26\u8D70\u5F7C\u6B64\u7684\u540D\u5B57"],[26,"\u5F15\u64CE\u4F4E\u9E23\u50CF\u4E00\u53E5\u65E7\u8BFA\u8A00"],[41,"\u628A\u9ED1\u6697\u6298\u6210\u4E24\u534A"],[58,"\u591C\u822A\u661F\u554A"],[72,"\u522B\u5728\u4E2D\u9014\u7184\u706D"],[95,"\uFF08\u95F4\u594F\uFF09"],[126,"\u5982\u679C\u5750\u6807\u7EC8\u5C06\u5931\u6548"],[140,"\u5C31\u8BA9\u8F68\u8FF9\u81EA\u5DF1\u8BF4\u8BDD"],[158,"\u6211\u4EEC\u4E0D\u8FD4\u822A"],[176,"\u4E5F\u4E0D\u9057\u61BE"],[198,"\u2026\u2026"]]},{title:"Amber Lantern",artist:"Hollow Coast",album:"Tidewater",albumArtist:"Hollow Coast",duration:187,colors:{primary:[.93,.62,.24],secondary:[.44,.24,.1],tertiary:[.99,.82,.56],text:[1,.98,.93]},lyrics:[[0,"Salt on the window frame"],[14,"a lantern swinging slow"],[30,"you said the tide forgets"],[46,"but the harbour never does"],[63,"Amber lantern, burn a little longer"],[88,"(instrumental)"],[118,"Every rope remembers the knot"],[134,"every shore remembers the leaving"],[152,"burn a little longer"],[170,"for me"]]},{title:"\u82D4\u75D5",artist:"\u6797\u95F4\u7535\u53F0",album:"\u534A\u5C71\u96E8",albumArtist:"\u6797\u95F4\u7535\u53F0",duration:241,colors:{primary:[.3,.68,.44],secondary:[.1,.28,.2],tertiary:[.72,.92,.78],text:[.96,1,.97]},lyrics:[[0,"\u96E8\u505C\u5728\u7B2C\u4E09\u7EA7\u53F0\u9636"],[16,"\u82D4\u75D5\u722C\u6EE1\u4E86\u65E7\u95E8\u724C"],[33,"\u4F60\u8BF4\u6162\u4E00\u70B9\u4E5F\u6CA1\u5173\u7CFB"],[52,"\u5C71\u4E0D\u4F1A\u8D70"],[70,"\u800C\u6211\u4EEC\u6709\u7684\u662F\u65F6\u95F4"],[92,"\uFF08\u95F4\u594F\uFF09"],[130,"\u628A\u4F1E\u6536\u8D77\u6765\u5427"],[148,"\u8BA9\u6F6E\u6C14\u8BB0\u4F4F\u8FD9\u4E00\u523B"],[172,"\u6162\u4E00\u70B9"],[200,"\u771F\u7684\u6CA1\u5173\u7CFB"],[226,"\u2026\u2026"]]},{title:"Neon Ashes",artist:"VELVET//NULL",album:"Afterimage",albumArtist:"VELVET//NULL",duration:168,colors:{primary:[.86,.22,.58],secondary:[.3,.06,.22],tertiary:[.99,.64,.86],text:[1,.94,.98]},lyrics:[[0,"city bleeds into the lens"],[11,"we were only afterimage"],[24,"neon ashes on your coat"],[38,"nothing here stays lit"],[55,"burn out with me"],[76,"(drop)"],[104,"nothing here stays lit"],[122,"burn out with me"],[146,"\u2026"]]}],ur=3;function Si(e=20260901){const n=Tc,t=n.reduce((v,b)=>v+b.duration+ur,0),r={hasMedia:!1,state:zt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Fe(0,0,0),secondaryColor:new Fe(0,0,0),tertiaryColor:new Fe(0,0,0),textColor:new Fe(1,1,1),highContrastColor:new Fe(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let o=0,i=!1,s=0,c=0;function a(v){let b=0;const y=(v%n.length+n.length)%n.length;for(let S=0;S<y;S++)b+=n[S].duration+ur;return b}function u(v){let b=t>0?v%t:0;b<0&&(b+=t);let y=-1,S=0,_=!1;for(let j=0;j<n.length;j++){const W=n[j].duration;if(b<W){y=j,S=b;break}if(b-=W,b<ur){y=j,S=W,_=!0;break}b-=ur}y<0&&(y=n.length-1,S=n[y].duration,_=!0);const C=n[y];r.hasMedia=!0,r.trackIndex=y,r.title=C.title,r.artist=C.artist,r.album=C.album,r.albumArtist=C.albumArtist,r.duration=C.duration,r.position=S;const N=C.duration>0?S/C.duration:0;i?r.state=zt.PAUSED:_?r.state=zt.STOPPED:N>.7&&N<.76?r.state=zt.PAUSED:r.state=zt.PLAYING,r.hasThumbnail=!_;const D=C.colors;r.primaryColor=new Fe(D.primary[0],D.primary[1],D.primary[2]),r.secondaryColor=new Fe(D.secondary[0],D.secondary[1],D.secondary[2]),r.tertiaryColor=new Fe(D.tertiary[0],D.tertiary[1],D.tertiary[2]),r.textColor=new Fe(D.text[0],D.text[1],D.text[2]);const k=.2126*D.primary[0]+.7152*D.primary[1]+.0722*D.primary[2];r.highContrastColor=k>.5?new Fe(0,0,0):new Fe(1,1,1),r.lyrics=C.lyrics;let O=-1;for(let j=0;j<C.lyrics.length;j++)S>=C.lyrics[j][0]&&(O=j);return r.lyricIndex=O,r.lyricLine=O>=0?C.lyrics[O][1]:"",r}function l(v){c=Number(v)||0;const b=i?s:c+o;return u(b)}function d(v){i=!1;const b=a(v);return o=b-c,u(b)}function h(){const v=r.trackIndex<0?0:r.trackIndex+1;return d(v)}function p(){const v=r.trackIndex<0?n.length-1:r.trackIndex-1;return d(v)}function w(){return i||(s=c+o,i=!0,r.state=zt.PAUSED),r}function m(){return i?(i=!1,o=s-c,u(s)):r}function g(){return i?m():w()}return{update:l,snapshot:r,tracks:n,cycle:t,MEDIA_PLAYBACK:zt,skipNext:h,skipPrevious:p,play:m,pause:w,playPause:g}}function Sc(e,n=512){const t=Math.max(8,n|0),r=new Uint8Array(t*t*4),o=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,c]=o.primary,[a,u,l]=o.secondary,[d,h,p]=o.tertiary;for(let w=0;w<t;w++)for(let m=0;m<t;m++){const g=m/(t-1),v=w/(t-1),b=g-.5,y=v-.5,S=Math.sqrt(b*b+y*y)*2,_=.5+.5*Math.sin(S*18-1.2),C=.5+.5*Math.sin((g+v)*6),N=Math.min(1,Math.max(0,S));let D=i*(1-N)+a*N,k=s*(1-N)+u*N,O=c*(1-N)+l*N;D=D*(.72+.28*_)+d*.18*C,k=k*(.72+.28*_)+h*.18*C,O=O*(.72+.28*_)+p*.18*C;const j=1-.35*Math.min(1,S*S),W=(w*t+m)*4;r[W]=Math.max(0,Math.min(255,Math.round(D*j*255))),r[W+1]=Math.max(0,Math.min(255,Math.round(k*j*255))),r[W+2]=Math.max(0,Math.min(255,Math.round(O*j*255))),r[W+3]=255}return{width:t,height:t,rgba:r}}function Ec(e,n){const t=[];if(!n)return t;const r=!e;return(r||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(r||e.title!==n.title||e.artist!==n.artist||e.album!==n.album||e.albumArtist!==n.albumArtist)&&t.push({name:"mediaPropertiesChanged",event:{title:n.title,artist:n.artist,album:n.album,albumArtist:n.albumArtist,albumTitle:n.album,subTitle:"",trackType:"music"}}),(r||e.hasThumbnail!==n.hasThumbnail||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaThumbnailChanged",event:{hasThumbnail:n.hasThumbnail,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,tertiaryColor:n.tertiaryColor,textColor:n.textColor,highContrastColor:n.highContrastColor}}),(r||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(r||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(r||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function Pc(e){return e?{hasMedia:e.hasMedia,state:e.state,title:e.title,artist:e.artist,album:e.album,albumArtist:e.albumArtist,position:e.position,duration:e.duration,hasThumbnail:e.hasThumbnail,trackIndex:e.trackIndex,lyricIndex:e.lyricIndex,lyricLine:e.lyricLine}:null}const Cc=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:zt,cloneMediaSnapshot:Pc,createSimulatedMedia:Si,diffMediaEvents:Ec,mediaVec3:Ac,renderThumbnail:Sc},Symbol.toStringTag,{value:"Module"})),Ei=14,Fn=[{app:"Safari",title:"GitHub \xB7 we-scene-renderer",url:"https://github.com/oneincase/we-scene-renderer"},{app:"Google Chrome",title:"YouTube",url:"https://www.youtube.com/watch?v=dQw4w9WgXcQ"},{app:"Google Chrome",title:"Wallpaper Engine - Workshop",url:"https://steamcommunity.com/app/431960/workshop/"},{app:"Safari",title:"MDN Web Docs",url:"https://developer.mozilla.org/en-US/docs/Web/API"},{app:"Music",title:"\u591C\u822A\u661F \u2014 \u76F8\u4F4D\u8FC1\u79FB",url:""},{app:"Code",title:"we-scene-renderer \u2014 text.js",url:""}];function Pi(){const e={app:"",title:"",url:"",index:-1};function n(t){const r=Number(t)||0,o=Fn.length?Math.floor(r/Ei)%Fn.length:0,i=Fn[o]||Fn[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=o,e}return n(0),{update:n,snapshot:e,tabs:Fn,hold:Ei}}function Ci(e){const n={name:"",at:0};function t(r){return n.name=String(r||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function Rc(e){const n=Si(e),t=Pi(),r=Ci(null);return{media:n,windowTitle:t,shortcuts:r}}const Lc=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:Ci,createSimulatedSystem:Rc,createSimulatedWindowTitle:Pi},Symbol.toStringTag,{value:"Module"}));function Fc(e={}){const n=e.target||(typeof window<"u"?window:null),t=e.viewport||(typeof window<"u"?()=>({w:window.innerWidth||1,h:window.innerHeight||1}):null),r={u:.5,v:.5,screenX:0,screenY:0,wx:0,wy:0,originY:null,lastU:.5,lastV:.5,lastScreenX:0,lastScreenY:0,lastWx:0,lastWy:0,lastOriginY:null,leftDown:!1,has:!1,moveCount:0,downCount:0,upCount:0,lastEventTime:0,screenW:1,screenH:1};function o(){if(!t)return;const l=t();r.screenW=l.w||1,r.screenH=l.h||1}o();function i(l){o();let d=l.clientX,h=l.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const m=n.getBoundingClientRect();d-=m.left,h-=m.top}const p=d/r.screenW,w=h/r.screenH;r.has||(r.lastU=p,r.lastV=w,r.lastScreenX=d,r.lastScreenY=h),r.screenX=d,r.screenY=h,r.u=p,r.v=w,r.has=!0,r.moveCount++,r.lastEventTime=Date.now()}function s(l){l.button!==void 0&&l.button!==0||(r.leftDown=!0,r.downCount++)}function c(l){l.button!==void 0&&l.button!==0||(r.leftDown=!1,r.upCount++)}function a(){r.leftDown=!1}let u=!1;return n&&n.addEventListener&&(u=!0,n.addEventListener("mousemove",i,{passive:!0}),n.addEventListener("mousedown",s,{passive:!0}),n.addEventListener("mouseup",c,{passive:!0}),n.addEventListener("blur",a,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",a,{passive:!0})),{state:r,beginFrame(){o(),r.lastU=r.u,r.lastV=r.v,r.lastScreenX=r.screenX,r.lastScreenY=r.screenY,r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY},syncWorld(l,d=0,h=0){if(!l)return;r.wx=l.offX+r.u*l.viewW-d,r.wy=l.offY+r.v*l.viewH-h;const p=Number(l.projH);r.originY=Number.isFinite(p)?p-r.wy:r.wy,r.lastWx===0&&r.lastWy===0&&(r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY)},normalizedDelta(){const l=r.u-r.lastU,d=r.v-r.lastV;return Math.hypot(l,d)},dispose(){!u||!n||!n.removeEventListener||(u=!1,n.removeEventListener("mousemove",i),n.removeEventListener("mousedown",s),n.removeEventListener("mouseup",c),n.removeEventListener("blur",a),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",a))}}}const Nc=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:Fc},Symbol.toStringTag,{value:"Module"}));function Ri(e,n,t,r,o,i,s){const c=e.size||[0,0],a=e.scale||[1,1,1],u=c[0]*a[0],l=c[1]*a[1];if(!(u>0)||!(l>0))return null;const d=e.origin||[0,0,0];let h=d[0],p=r-d[1];if(e.parallaxDepth&&(o!==0||i!==0)){const b=e.parallaxDepth,y=an(b[0]),S=an(b[1]);h+=y*o,p+=S*i}let w=n-h,m=t-p;const g=e.angles?e.angles[2]:0;if(g){const b=Math.cos(-g),y=Math.sin(-g),S=w*b+m*y,_=-w*y+m*b;w=S,m=_}const v=s&&s[e.alignment]||[.5,.5];return(v[0]!==.5||v[1]!==.5)&&(w-=(.5-v[0])*u,m-=(.5-v[1])*l),{lx:w/u,ly:m/l,w:u,h:l}}function Uc(e,n,t,r,o={}){if(!e||e.length===0)return null;const i=o.parOffX||0,s=o.parOffY||0,c=o.alignTable,a=o.filter;for(let u=e.length-1;u>=0;u--){const l=e[u];if(!l||!l.visible||l.destroyed||a&&!a(l))continue;const d=Ri(l,n,t,r,i,s,c);if(d&&Math.abs(d.lx)<=.5&&Math.abs(d.ly)<=.5)return l}return null}const kc=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:Uc,worldToLayerLocal:Ri},Symbol.toStringTag,{value:"Module"})),Oe=e=>e,De=Oe(Qi),fr=Oe(ms),Qe=Oe(As),bt=Oe(Ps),ke=Oe(ca),Bc=Oe(ua),Ic=Oe(ga),un=Oe(La),Nn=Oe(Ya),qe=Oe(pc),Oc=Oe(bc),St=Oe(Cc),Li=Oe(Lc),Fi=Oe(ra),Dc=Oe(Nc),zc=Oe(kc);function $c(e,n,t){return{camera:null,general:{orthogonalprojection:{width:e,height:n},clearenabled:!0,clearcolor:"0 0 0"},layers:[{id:0,name:"media",visible:!0,image:t,textureName:t,particle:null,puppet:null,solid:!1,isContainer:!1,isPostProcess:!1,isText:!1,isSound:!1,isComponent:!1,sound:[],origin:[e/2,n/2,0],scale:[1,1,1],angles:[0,0,0],size:[e,n],alignment:"center",color:[1,1,1],alpha:1,brightness:1,colorBlendMode:0,copybackground:!1,parallaxDepth:null,animationLayers:[],effects:[]}],properties:{}}}async function jc(e){const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const t=new window.ImageDecoder({data:await n.arrayBuffer(),type:"image/gif"});await t.tracks.ready,await t.completed;const r=t.tracks.selectedTrack;if(!r||!r.frameCount)return null;const o=Math.min(r.frameCount,300),i=[];let s=0,c=0;for(let a=0;a<o;a++){const{image:u}=await t.decode({frameIndex:a});s=u.displayWidth,c=u.displayHeight,i.push({bitmap:await createImageBitmap(u),durationMs:u.duration?u.duration/1e3:100}),u.close()}return t.close?.(),{width:s,height:c,frames:i}}function Wc(e,n){if(tn(e),!n.src){e.fallbackPage?.();return}const t=n.type==="video",r=n.type==="gif",o=document.createElement("canvas"),i=Ye(e,n);if(o.width=Math.max(1,Math.round(innerWidth*i)),o.height=Math.max(1,Math.round(innerHeight*i)),o.style.cssText="position:absolute;inset:0;width:100%;height:100%;",!o.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){ae(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE\uFF0C\u56DE\u9000 DOM \u6E32\u67D3`),t?Vc(e,n):Xc(e,n);return}e.wrap?.appendChild(o),e.canvas=o;let c=!1;e.sceneCleanup=()=>{c=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let a,u,l=!1;e.sceneCtl={pause(){a?.()},resume(){u?.()},applyUserProperties(){}};const d=h=>{c||(c=!0,ae(e,n,`media ${n.type} \u5931\u8D25: ${h}`),e.fallbackPage?.())};(async()=>{try{const h=ke.createRenderer(o,{diag:k=>ae(e,n,`renderer: ${k}`),fboCapFactor:0});if(e.renderer=h,c)return;const p="__media",w=new Map;let m,g=0,v=0;if(t){const k=document.createElement("video");if(k.autoplay=!0,k.loop=n.loop!==!1,k.muted=n.muted!==!1,k.playsInline=!0,k.preload="metadata",k.width=o.width,k.height=o.height,k.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",k.src=n.src,document.body.appendChild(k),e.video=k,(e.videoTextures??=[]).push(k),await new Promise((O,j)=>{k.addEventListener("loadedmetadata",()=>O(),{once:!0}),k.addEventListener("error",()=>j(new Error(`video error ${k.error?.code??"?"}`)),{once:!0})}),c)return;g=k.videoWidth||o.width,v=k.videoHeight||o.height,w.set(p,{video:k,glTex:ke.makeTexture(h.gl,new Uint8Array([0,0,0,255]),1,1),width:g,height:v,rg88:!1,lastUploaded:-1}),e.paused||k.play().catch(()=>{}),ae(e,n,`media video ${g}x${v} \u2192 scene \u6E32\u67D3`)}else{let k=!1;if(r&&typeof window.ImageDecoder=="function")try{const O=await jc(n.src);if(O&&O.frames.length>1){g=O.width,v=O.height;const j=h.gl,W={glTex:ke.makeTexture(j,null,0,0,O.frames[0].bitmap),width:g,height:v,rg88:!1};w.set(p,W);let K=0,V=performance.now()+O.frames[0].durationMs;m=()=>{const Q=performance.now();if(!(Q<V)){K=(K+1)%O.frames.length,V=Q+O.frames[K].durationMs,j.bindTexture(j.TEXTURE_2D,W.glTex);try{j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,O.frames[K].bitmap)}catch{}}};const G=e.sceneCleanup;e.sceneCleanup=()=>{G?.();for(const Q of O.frames)Q.bitmap.close()},k=!0,ae(e,n,`media gif ${g}x${v} ${O.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(O){ae(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(O.message).slice(0,80)}`)}if(!k){const O=new Image;if(O.crossOrigin="anonymous",O.src=n.src,await new Promise((j,W)=>{O.addEventListener("load",()=>j(),{once:!0}),O.addEventListener("error",()=>W(new Error("image load error")),{once:!0})}),c)return;g=O.naturalWidth||1,v=O.naturalHeight||1,e.img=O,w.set(p,{glTex:ke.makeTexture(h.gl,null,0,0,O),width:g,height:v,rg88:!1}),ae(e,n,`media ${n.type} ${g}x${v} \u2192 scene \u6E32\u67D3`)}}if(c)return;const b=$c(g,v,p),y=performance.now();let S=0,_=0,C=-1/0;const N=k=>{if(c||e.paused)return;const O=e.cfg.sceneFps||60;if(k-C>=1e3/O){C=k,io(e,k),ao(e,o,e.cfg),m?.();const j=e.coverAlign;h.render(b,w,o.width,o.height,(k-y-S)/1e3,qt(e.cfg.fit),j.x,j.y).then(()=>{c||e.paused||(e.raf=requestAnimationFrame(N))}).catch(W=>d(String(W.message||W).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(N))},D=()=>{c||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(N))};a=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),_||(_=performance.now());const k=e.video;l=!!(k&&!k.paused&&!k.ended),k?.pause()},u=()=>{_&&(S+=performance.now()-_,_=0),l&&e.video?.play().catch(()=>{}),l=!1,D()},D()}catch(h){d(String(h.message||h).slice(0,200))}})()}function Vc(e,n){if(tn(e),!n.src){e.fallbackPage?.();return}const t=ro(n.fit),r=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let o=!1;const i=()=>{o||(o=!0,console.warn("video error, fallback to default wallpaper"),e.fallbackPage?.())},s=document.createElement("video");s.autoplay=!0,s.loop=n.loop!==!1,s.muted=n.muted!==!1,s.playsInline=!0,s.preload="metadata";const c=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*c)),s.height=Math.max(1,Math.round(innerHeight*c)),s.style.cssText=r,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),ae(e,n,"video mounted (single + native loop)")}function Xc(e,n){tn(e);const t=document.createElement("img"),r=ro(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${r.objectFit};object-position:50% 50%;background:${r.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const Hc=["scene.pkg","scenes/scene.pkg","gifscene.pkg"];function Ni(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(r){let o=null,i=null;for(const c of Hc){let a;try{a=await fetch(`${t}/${c}`,{...n,signal:r})}catch(u){if(r?.aborted)throw u;i=u;continue}if(!a.ok){o=a.status;continue}try{return await a.arrayBuffer()}catch(u){if(r?.aborted)throw u;const l=u instanceof Error?u.message:String(u);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(o!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${o}\uFF09`);const s=i instanceof Error?i.message:"Failed to fetch";throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08${s}\uFF09`)},async project(r){try{const o=await fetch(`${t}/project.json`,{...n,signal:r});return o.ok?await o.json():null}catch{return null}}}}function Gc(e,n){const t=e;return{key:typeof t.name=="string"?`file:${t.name}:${t.size}:${t.lastModified??0}`:void 0,scenePkg:()=>e.arrayBuffer(),project:async()=>n??null}}function Yc(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}const Ui=.5,qc=.04,ki=.08;function Zc(e,n){const t=b=>{const y=document.createElement("video");b&&(y.src=e),y.muted=n.muted,y.playsInline=!0,y.preload="metadata";const S=Math.min(window.devicePixelRatio||1,n.renderDpr||1),_=Math.max(1,Math.round(n.maxW*S)),C=Math.max(1,Math.round(n.maxH*S));return y.width=_,y.height=C,y.loop=!0,y};let r=t(!0),o=t(!1),i=!1,s=1,c=n.muted;o.muted=!0;const a=()=>{i||(o.src=e,i=!0)};let u=!1,l=!1,d=-1,h=0,p=!1;const w=()=>{if(u=!1,l=!1,!o.paused){o.pause();try{o.currentTime=0}catch{}}},m=()=>{const b=r;r=o,o=b,u=!1,l=!1,r.play().catch(()=>{}),r.muted=c,r.volume=s,b.pause();try{b.currentTime=0}catch{}b.muted=!0,d=-1,i=!0,v.onSwap?.(r)},g=()=>{if(p)return;h=requestAnimationFrame(g);const b=r.duration;if(!isFinite(b)||b<=0)return;const y=r.currentTime;if(d>=0&&y<d-.05){const _=l;w(),d=y,_||v.onFallback?.();return}d=y;const S=b-y;if(S>Ui+.5){(u||l)&&w();return}if(l){(S<=ki||y<=ki)&&m();return}if(u){o.paused?o.play().catch(()=>{}):o.currentTime>=qc*.5&&(o.pause(),u=!1,l=!0);return}if(S<=Ui&&(a(),o.readyState>=2)){try{o.currentTime=0}catch{}o.play().catch(()=>{}),u=!0}};h=requestAnimationFrame(g);const v={get active(){return r},get standby(){return o},onSwap:void 0,onFallback:void 0,setVolume(b){s=Math.max(0,Math.min(1,b)),c=b<=0,r.muted=c,r.volume=s,o.muted=!0,o.volume=s},pause(){w(),r.pause(),h&&cancelAnimationFrame(h),h=0},resume(){p||(r.play().catch(b=>{b&&b.name}),h||(h=requestAnimationFrame(g)))},destroy(){p=!0,h&&cancelAnimationFrame(h),h=0;for(const b of[r,o]){b.pause(),b.removeAttribute("src");try{b.load()}catch{}b.remove()}}};return v}const Bi=!1,Ii=!0,Oi=!1,Kc=!1,Qc=!1,Di=4,Jc={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
174
+ }`;function oc(e){const n=(f,l)=>{const d=e.createShader(f);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("MDL \u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(d));return d};let t=tc(e),o=null;for(;;){const f=e.createProgram();let l=!1;try{e.attachShader(f,n(e.VERTEX_SHADER,nc(t))),e.attachShader(f,n(e.FRAGMENT_SHADER,rc)),e.bindAttribLocation(f,0,"a_pos"),e.bindAttribLocation(f,1,"a_uv"),e.bindAttribLocation(f,2,"a_bone"),e.bindAttribLocation(f,3,"a_weight"),e.linkProgram(f),l=!!e.getProgramParameter(f,e.LINK_STATUS)}catch{l=!1}if(l){o=f;break}if(e.deleteProgram(f),t<=sr)throw new Error("MDL \u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25\uFF08\u9AA8\u6570\u5DF2\u964D\u5230 "+sr+"\uFF09");t=Math.max(sr,t>>1)}const r=t,i={mvp:e.getUniformLocation(o,"u_mvp"),tex:e.getUniformLocation(o,"u_tex"),skin:e.getUniformLocation(o,"u_skin"),boneCount:e.getUniformLocation(o,"u_boneCount"),color:e.getUniformLocation(o,"u_color")},s=new Float32Array(r*16);for(let f=0;f<r;f++)s.set(ui,f*16);const c=new WeakMap;function a(f){let l=c.get(f);if(l)return l;const d=e.createVertexArray();e.bindVertexArray(d);const h=f.vertexCount,m=new Float32Array(h*13);for(let b=0;b<h;b++){const p=b*13;m[p]=f.positions[b*3],m[p+1]=f.positions[b*3+1],m[p+2]=f.positions[b*3+2],m[p+3]=f.uvs[b*2],m[p+4]=f.uvs[b*2+1];for(let v=0;v<4;v++)m[p+5+v]=f.boneIdx[b*4+v],m[p+9+v]=f.weights[b*4+v]}const M=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,M),e.bufferData(e.ARRAY_BUFFER,m,e.STATIC_DRAW);const g=52;e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,e.FLOAT,!1,g,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,e.FLOAT,!1,g,12),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,4,e.FLOAT,!1,g,20),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,g,36);const y=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,y),e.bufferData(e.ELEMENT_ARRAY_BUFFER,f.indices,e.STATIC_DRAW),e.bindVertexArray(null),l={vao:d,vbuf:M,ibuf:y},c.set(f,l),l}return{gl:e,prog:o,maxBones:r,upload(f){a(f)},draw(f,l,d,h){const m=a(l);e.useProgram(o),e.bindVertexArray(m.vao),e.activeTexture(e.TEXTURE0);const M=d.overrideTex||(h&&h.glTex?h.glTex:h);e.bindTexture(e.TEXTURE_2D,M),e.uniform1i(i.tex,0),e.uniformMatrix4fv(i.mvp,!1,f);const g=d.color||[1,1,1,1];e.uniform4f(i.color,g[0],g[1],g[2],g[3]);const y=eo(l,d.time||0,d.animLayers,d.boneOverrides),b=Math.min(l.bones.length,r);y&&b>0?(e.uniformMatrix4fv(i.skin,!1,y.subarray(0,b*16)),e.uniform1i(i.boneCount,b)):(e.uniformMatrix4fv(i.skin,!1,s),e.uniform1i(i.boneCount,0)),d.blending==="additive"?(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE)):d.blending==="normal"?e.disable(e.BLEND):(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA));const p=l.indexType==="u32"?e.UNSIGNED_INT:e.UNSIGNED_SHORT;e.drawElements(e.TRIANGLES,l.indexCount,p,0),e.bindVertexArray(null)}}}const ic=Object.freeze(Object.defineProperty({__proto__:null,applyAttachmentBindOrigins:Qa,attachmentBind:mi,attachmentWorld:hi,bindWorldOf:di,computeSkinMatrices:eo,createMDLRenderer:oc,followAttachments:Ja,mat4MulOut:Ka,parentMeshToWorldDelta:to,parseMDL:Va},Symbol.toStringTag,{value:"Module"}));function pi(e,n,t){const o=Math.max(0,Number(t)||0),r=Math.max(1,Number(e)||1),i=Math.max(1,Number(n)||1);return o*2>=Math.min(r,i)?0:o}function sc(e,n,t){const o=Math.max(1,n.boxW),r=Math.max(1,n.boxH),i=pi(o,r,n.padding||0),s=n.spacing||[0,0],c=Math.max(1,n.lineHeight||(n.pointsize||24)*1.25+s[1]),a=Math.max(1,o-i*2),f=n.limitwidth&&n.maxwidth>0?Math.min(n.maxwidth,a):1/0;function l(L){if(t(L)<=f)return[L];const F=[];let D="",B=-1;for(const z of L)if(D+=z,(z===" "||z===" ")&&(B=D.length),t(D)>f&&D.length>1)for(B>0?(F.push(D.slice(0,B-1)),D=D.slice(B)):(F.push(D.slice(0,-1)),D=z),B=-1;t(D)>f&&D.length>1;)F.push(D.slice(0,-1)),D=D.slice(-1);return D!==""&&F.push(D),F.length?F:[""]}let d=[];const h=String(e??"").split(`
175
+ `);for(const L of h)d.push(...l(L));let m=!1;if(n.limitrows&&n.maxrows>0&&d.length>n.maxrows&&(d=d.slice(0,n.maxrows),m=!0,n.limituseellipsis)){let L=d[n.maxrows-1];for(;L.length>0&&t(L+"\u2026")>f;)L=L.slice(0,-1);d[n.maxrows-1]=L+"\u2026"}const M=d.map(L=>t(L)),g=d.length*c,y=n.halign||"center",b=n.valign||"center",p=o/2,v=r/2,_=b==="top"?v:b==="bottom"?v-g:(r-g)/2;return{lines:d.map((L,F)=>{const D=M[F],B=y==="left"?p:y==="right"?p-D:(o-D)/2;return{text:L,width:D,x:B,y:_+F*c}}),lineHeight:c,totalH:g,truncated:m,boxW:o,boxH:r}}function ac(e,n,t){const o=n.boxW,r=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,c=t.brightness!==void 0?t.brightness:1;e.font=t.font;try{e.letterSpacing=(t.spacing&&t.spacing[0]?t.spacing[0]:0)+"px"}catch{}if(e.textBaseline="middle",t.opaquebackground){const f=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(f[0]*255*l)},${Math.round(f[1]*255*l)},${Math.round(f[2]*255*l)},${s})`,e.fillRect(0,0,o,r)}const a=(f,l,d)=>{e.fillStyle=d;for(const h of n.lines)e.fillText(h.text,h.x+f,h.y+n.lineHeight/2+l)};if(t.castshadow){const f=Math.max(1,(t.pointsize||24)/10);a(f,f,`rgba(0,0,0,${s*.75})`)}a(0,0,`rgba(${Math.round(i[0]*255*c)},${Math.round(i[1]*255*c)},${Math.round(i[2]*255*c)},${s})`)}const gi=/^add[A-Z]/;function bi(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function yi(e){return new Proxy(e,{get(n,t,o){const r=Reflect.get(n,t,o);if(r==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return r}})}function cn(e,n){return()=>{}}function vi(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||cn),e.setTimeout||(e.setTimeout=n.setTimeout||cn),e.clearTimeout||(e.clearTimeout=n.clearTimeout||(()=>{})),e.clearInterval||(e.clearInterval=n.clearInterval||(()=>{})),typeof n.openUserShortcut=="function"&&(e.openUserShortcut=n.openUserShortcut);const t=n.mediaControl||null;e.media={skipNext:()=>{if(t&&t.skipNext)return t.skipNext()},skipPrevious:()=>{if(t&&t.skipPrevious)return t.skipPrevious()},play:()=>{if(t&&t.play)return t.play()},pause:()=>{if(t&&t.pause)return t.pause()},playPause:()=>{if(t&&t.playPause)return t.playPause()},get snapshot(){return t&&t.snapshot?t.snapshot:null}};const o=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return o&&o.title?String(o.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return o&&o.app?String(o.app):""}})}class he{constructor(n,t,o){if(n!==null&&typeof n=="object")this.x=n.x!==void 0?n.x:n.width||0,this.y=t!==void 0?t:n.y!==void 0?n.y:n.height||0,this.z=o!==void 0?o:n.z||0;else if(t===void 0&&o===void 0){const r=Number(n)||0;this.x=r,this.y=r,this.z=r}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(o)||0}add(n){const t=new he(n);return new he(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new he(n);return new he(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new he(this.x*n.x,this.y*n.y,this.z*n.z):new he(this.x*n,this.y*n,this.z*n)}divide(n){const t=(o,r)=>r===0?0:o/r;return n&&typeof n=="object"?new he(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new he(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new he(this.x,this.y,this.z)}mix(n,t){const o=new he(n),r=Number(t),i=Number.isFinite(r)?r:0;return new he(this.x+(o.x-this.x)*i,this.y+(o.y-this.y)*i,this.z+(o.z-this.z)*i)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const n=this.length();return n===0?new he(0,0,0):new he(this.x/n,this.y/n,this.z/n)}dot(n){const t=new he(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const xi=he;function wi(e){if(e instanceof he||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===he.prototype)return e;try{Object.setPrototypeOf(e,he.prototype)}catch{}return e}function Mi(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new he(0,0,0),cursorScreenPosition:new he(0,0,0),cursorPosition:new he(0,0,0),cursorPositionLast:new he(0,0,0),cursorLeftDown:!1}}function cc(e,n,t){return new he(e||0,n||0,t||0)}function lc(){const e={cursorWorldPosition:new he(0,0,0),cursorScreenPosition:new he(0,0,0),cursorPosition:new he(0,0,0),cursorPositionLast:new he(0,0,0),cursorLeftDown:!1};return e.update=function(n){return n&&(e.cursorWorldPosition.x=n.wx,e.cursorWorldPosition.y=n.originY!=null?n.originY:n.wy,e.cursorWorldPosition.z=0,e.cursorScreenPosition.x=n.screenX,e.cursorScreenPosition.y=n.screenY,e.cursorScreenPosition.z=0,e.cursorPosition.x=n.u,e.cursorPosition.y=n.v,e.cursorPosition.z=0,e.cursorPositionLast.x=n.lastU,e.cursorPositionLast.y=n.lastV,e.cursorPositionLast.z=0,e.cursorLeftDown=!!n.leftDown),e},e}const Ai={mix:(e,n,t)=>e+(n-e)*t,lerp:(e,n,t)=>e+(n-e)*t,clamp:(e,n,t)=>Math.min(t,Math.max(n,e)),saturate:e=>Math.min(1,Math.max(0,e)),smoothstep:(e,n,t)=>{const o=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return o*o*(3-2*o)},smoothStep:(e,n,t)=>{const o=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return o*o*(3-2*o)},random:(e,n)=>e===void 0?Math.random():e+Math.random()*((n===void 0?1:n)-e),randomInt:(e,n)=>Math.floor((e||0)+Math.random()*((n===void 0?1:n)+1-(e||0))),degrees:e=>e*180/Math.PI,radians:e=>e*Math.PI/180},_i={hsv2rgb:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=((Number(n.x)||0)%1+1)%1,o=Math.min(1,Math.max(0,Number(n.y)||0)),r=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,c=r*(1-o),a=r*(1-s*o),f=r*(1-(1-s)*o),d=[[r,f,c],[a,r,c],[c,r,f],[c,a,r],[f,c,r],[r,c,a]][i%6];return{x:d[0],y:d[1],z:d[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,o=Number(n.y)||0,r=Number(n.z)||0,i=Math.max(t,o,r),s=Math.min(t,o,r),c=i-s;let a=0;return c>0&&(i===t?a=(o-r)/c/6:i===o?a=(2+(r-t)/c)/6:a=(4+(t-o)/c)/6,a<0&&(a+=1)),{x:a,y:i===0?0:c/i,z:i}}},Ti={add:(e,n)=>({x:(e.x||0)+(n.x||0),y:(e.y||0)+(n.y||0),z:(e.z||0)+(n.z||0)}),subtract:(e,n)=>({x:(e.x||0)-(n.x||0),y:(e.y||0)-(n.y||0),z:(e.z||0)-(n.z||0)}),scale:(e,n)=>({x:(e.x||0)*n,y:(e.y||0)*n,z:(e.z||0)*n}),length:e=>Math.hypot(e.x||0,e.y||0,e.z||0),dot:(e,n)=>(e.x||0)*(n.x||0)+(e.y||0)*(n.y||0)+(e.z||0)*(n.z||0),normalize:e=>{const n=Math.hypot(e.x||0,e.y||0,e.z||0)||1;return{x:(e.x||0)/n,y:(e.y||0)/n,z:(e.z||0)/n}},mix:(e,n,t)=>({x:(e.x||0)+((n.x||0)-(e.x||0))*t,y:(e.y||0)+((n.y||0)-(e.y||0))*t,z:(e.z||0)+((n.z||0)-(e.z||0))*t})},Si=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),ar=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],uc=["scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent"],fc=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${uc.join("|")})\\b)`,"gm"),dc={WEMath:!0,WEColor:!0,WEVector:!0};function Ei(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function Pi(e){return Ei(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,o)=>{const r=String(o);return dc[r]?t===r?"":`var ${t} = ${r};`:`var ${t} = {};`}).replace(/(^[ \t]*|;|\})[ \t]*import\s+(?:[^;'"]+\s+from\s+)?['"][^'"]*['"];?[ \t]*/gm,"$1").replace(/(^[ \t]*|;|\})[ \t]*export[ \t]+(?=(?:async[ \t]+)?function\b|(?:var|let|const)\b)/gm,"$1").replace(fc,"$1")}function Ln(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Ci(e){const n=e||{width:1920,height:1080};return n.x!==void 0&&n.y!==void 0?n:{x:n.width,y:n.height,width:n.width,height:n.height}}function hc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const o=Pi(e);if(o===e&&e.indexOf("update")<0)return null;const r={};if(n&&typeof n=="object")for(const[b,p]of Object.entries(n))r[b]=Ln(p);const i=new Proxy(()=>i,{apply(){return i},get(b,p){if(p==="finish")return()=>r;if(typeof p=="string"&&gi.test(p))return v=>(v&&typeof v=="object"&&typeof v.name=="string"&&!(v.name in r)&&(r[v.name]=Ln(v.value)),i)}}),s={text:t.text!==void 0&&t.text!==null?String(t.text):"",font:t.font||"",pointsize:t.pointsize||24,color:(t.color||[1,1,1]).slice(),angles:(t.angles||[0,0,0]).slice(),scale:(t.scale||[1,1,1]).slice(),visible:t.visible!==!1,origin:ro(t.origin||[0,0,0])},c={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Ci(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||cn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||cn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};vi(c,t);const a=t.audioViews;c.registerAudioBuffers=b=>{const p=Math.max(1,Math.min(64,Math.floor(Number(b)||0)));let v=a?a.get(p):void 0;return v||(v={left:new Float32Array(p),right:new Float32Array(p),average:new Float32Array(p)},a&&a.set(p,v)),v};const f={getLayer(b){const p=t.getLayerText?t.getLayerText(String(b)):void 0;return{text:p!=null?String(p):""}},createLayer(b){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:ro(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},d={console:bi()},h=Mi(t.inputView);let m;try{m=new Function("scriptProperties","engine","thisLayer","thisScene","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","MediaPlaybackEvent",`"use strict";
176
+ `+o+`
177
+ ;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+ar.map(p=>`${p}: typeof ${p} === "function" ? ${p} : null,`).join("")+"dummy_: 0};")(r,yi(c),s,f,Ai,_i,Ti,i,l,d.console,void 0,d,d,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,he,xi,h,Si)}catch(b){return t.onError&&t.onError(b,"parse"),null}const M=!!(m&&ar.some(b=>m[b])),g=!!(m&&typeof m.applyUserProperties=="function");if(!m||!m.update&&!M&&!g)return null;const y={engine:c,thisLayer:s,scriptProperties:r,hasUpdate:!!m.update,hasCursorHook:!!(m.cursorClick||m.cursorEnter||m.cursorLeave||m.cursorDown||m.cursorUp||m.cursorMove),hasMediaHook:M,hasApplyHook:g,errCount:0,disabled:!1,init(b){if(m.init)try{m.init(b)}catch(p){y.errCount++,t.onError&&t.onError(p,"init")}},applyUserProperties(b){if(m.applyUserProperties)try{m.applyUserProperties(b||{})}catch(p){y.errCount++,t.onError&&t.onError(p,"applyUserProperties")}},callUpdate(b){if(!m.update||y.disabled)return null;const p=s.text;let v;try{v=m.update(p!==""?p:b!==void 0?b:"")}catch(_){return y.errCount++,t.onError&&t.onError(_,"update"),y.errCount>=3&&(y.disabled=!0),null}return typeof v=="string"?(s.text=v,v):typeof v=="boolean"?null:v!=null?(s.text=String(v),s.text):s.text!==p?s.text:null},callCursor(b,p){if(y.disabled)return;const v=m[b];if(typeof v=="function")try{return v(p)}catch(_){y.errCount++,t.onError&&t.onError(_,b),y.errCount>=3&&(y.disabled=!0);return}},callMedia(b,p){if(y.disabled)return;const v=m[b];if(typeof v=="function")try{return v(p)}catch(_){y.errCount++,t.onError&&t.onError(_,b),y.errCount>=3&&(y.disabled=!0);return}}};return y}function Fn(){const e={play:()=>e,pause:()=>e,stop:()=>e,setFrame:()=>e,setRate:()=>e,setBlend:()=>e,setVisible:()=>e,isPlaying:Object.assign(()=>!1,{valueOf:()=>!1,toString:()=>"false"}),get frame(){return 0},get frameCount(){return 0},get rate(){return 1}};return e}function mc(e){if(!e)return Fn();if(e.textureAnimation)return e.textureAnimation.api;const n={frame:null,playing:!0,rate:1},t={play:()=>(n.playing=!0,t),pause:()=>(n.playing=!1,t),stop:()=>(n.playing=!1,t),setFrame:o=>{const r=Number(o);return n.frame=Number.isFinite(r)?r:0,t},setRate:o=>{const r=Number(o);return Number.isFinite(r)&&(n.rate=r),t},setBlend:()=>t,setVisible:o=>(e.visible=!!o,t),isPlaying:Object.assign(()=>n.playing,{valueOf:()=>n.playing,toString:()=>String(n.playing)}),get frame(){return n.frame===null?0:n.frame},get frameCount(){return e.spriteFrameCount||0},get rate(){return n.rate}};return n.api=t,e.textureAnimation=n,t}function pc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const o=n(),r=o&&typeof o.duration=="function"?o.duration():0;return Number.isFinite(r)?r:0},get rate(){const o=n(),r=o&&typeof o.getRate=="function"?o.getRate():1;return Number.isFinite(r)&&r>0?r:1},set rate(o){const r=n(),i=Number(o);r&&typeof r.setRate=="function"&&Number.isFinite(i)&&r.setRate(i)},get loop(){const o=n();return o&&typeof o.getLoop=="function"?!!o.getLoop():!0},set loop(o){const r=n();r&&typeof r.setLoop=="function"&&r.setLoop(!!o)},play:()=>{const o=n();o&&o.play&&o.play()},pause:()=>{const o=n();o&&o.pause&&o.pause()},stop:()=>{const o=n();o&&o.stop&&o.stop()},isPlaying:Object.assign(()=>{const o=n();return!!(o&&typeof o.isPlaying=="function"&&o.isPlaying())},{valueOf(){const o=n();return!!(o&&typeof o.isPlaying=="function"&&o.isPlaying())},toString(){const o=n();return String(!!(o&&typeof o.isPlaying=="function"&&o.isPlaying()))}}),getCurrentTime:()=>{const o=n(),r=o&&typeof o.getCurrentTime=="function"?o.getCurrentTime():0;return Number.isFinite(r)?r:0},setCurrentTime:o=>{const r=n(),i=Number(o);r&&typeof r.setCurrentTime=="function"&&Number.isFinite(i)&&r.setCurrentTime(i)},addEndedCallback:o=>{const r=n();typeof o=="function"&&r&&typeof r.addEndedCallback=="function"&&r.addEndedCallback(o)}};return e&&(e.videoTextureApi=t),t}function gc(){const e=new Map,n=o=>e.has(String(o))?e.get(String(o)):null,t=(o,r)=>{e.set(String(o),String(r))};return{getItem:n,setItem:t,get:n,set:t,removeItem:o=>{e.delete(String(o))},remove:o=>{e.delete(String(o))},clear:()=>{e.clear()},key:o=>Array.from(e.keys())[o]??null,get length(){return e.size}}}function bc(e,n){const t=e&&e.puppet,o=t&&t.bones||null,r=o?o.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],c=s[0]||1,a=s[1]||1,f=(M,g)=>[i[0]+M*c,i[1]-g*a],l=(M,g)=>[(M-i[0])/c,-(g-i[1])/a],d=M=>{const g=n.get(M);if(g)return[g[0],g[1],g[2]];const y=o[M].matrix;return[y[12],y[13],y[14]]},h=M=>{let g=0,y=0,b=M;for(let p=0;b>=0&&b<r&&p<64;p++){const v=d(b);g+=v[0],y+=v[1],b=o[b].parent}return f(g,y)},m=M=>{const g={translation(y){if(y===void 0){const w=h(M);return new he(w[0],w[1],0)}const b=Ot(y);let p=0,v=0;if(o[M].parent>=0){const w=h(o[M].parent),L=l(w[0],w[1]);p=L[0],v=L[1]}const _=l(b[0],b[1]);return n.set(M,[_[0]-p,_[1]-v,0]),g},rotation(){return g},scale(){return g}};return g};return{getBoneCount:()=>r,getBoneTransform:M=>{const g=Math.floor(Number(M));if(!o||!(g>=0)||g>=r){const y={translation(b){return b===void 0?new he(0,0,0):y},rotation(){return y},scale(){return y}};return y}return m(g)},setBoneTransform:(M,g)=>{const y=Math.floor(Number(M));!o||!(y>=0)||y>=r},applyBonePhysicsImpulse:()=>{}}}function no(e){return{get visible(){return e?!!e.visible:!1},set visible(n){e&&(e.visible=!!n)},get name(){return e&&e.name||""},getMaterial:()=>null}}function Ri(e,n){if(e==null)return null;const t=o=>{if(!o)return null;if(n&&typeof n.getSceneLayer=="function"){const r=n.getSceneLayer(String(o));if(r)return r}return n&&n.layer&&n.layer.name===o?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function yc(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Li(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const o=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return o?`${o[1]}/workshop/${t}/${o[2]}`:e}function vc(e){if(typeof e!="string")return null;const n=e.match(/export\s+let\s+__workshopId\s*=\s*['"](\d+)['"]/);return n?n[1]:null}function xc(e){const n=t=>cr(t||null,e);return{getLayer(t){if(e.getSceneLayer){const o=e.getSceneLayer(String(t));if(o&&!o.destroyed)return n(o)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let o=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;o=Li(t,i)}const r=e.createSceneLayer(o);return n(r||null)},destroyLayer(t){yc(Ri(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const o=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=t&&typeof t=="object"?t.name:String(t||""),i=o.findIndex(s=>s&&s.name===r);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=[];for(const r of t)r&&!r.destroyed&&o.push(n(r));return o},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const o=e.getSceneAnimation(t);if(o)return o}return Fn()},getCameraTransforms(){const t=e.cameraTransforms||{zoom:1};return{zoom:typeof t.zoom=="number"?t.zoom:1,center:t.center||null,eye:t.eye||null,parallaxAmount:typeof t.parallaxAmount=="number"?t.parallaxAmount:0}},setCameraTransforms(t){const o=e.cameraTransforms;!o||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(o.zoom=t.zoom),t.center!==void 0&&(o.center=t.center),t.eye!==void 0&&(o.eye=t.eye),typeof t.parallaxAmount=="number"&&(o.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):Ri(t,e)||null}}}function cr(e,n){const t=s=>ro(Array.isArray(s)?s:[0,0,0]),o=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,r={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:Ac(e),size:t(e?e.size:[0,0,0]),color:t(e?e.color:[1,1,1])},i={get name(){return e&&e.name||""},get id(){return e&&e.id||0},get visible(){const s=n&&n.targetEffect;return s?!!s.visible:e?e.visibleSelf!==void 0?!!e.visibleSelf:!!e.visible:!1},set visible(s){const c=n&&n.targetEffect;if(c){c.visible=!!s;return}e&&(e.visibleSelf=!!s,typeof n.recomputeVisibility=="function"?n.recomputeVisibility():e.visible=!!s)},get alpha(){return e&&typeof e.alpha=="number"?e.alpha:1},set alpha(s){e&&(e.alpha=Number(s)||0)},get brightness(){return e&&typeof e.brightness=="number"?e.brightness:1},set brightness(s){e&&(e.brightness=Number(s)||0)},get text(){return e&&e.text!==void 0?String(e.text):""},set text(s){e&&typeof s!="boolean"&&(e.text=s==null?"":String(s))},get pointsize(){return e&&e.textPointsize||24},set pointsize(s){e&&(e.textPointsize=Number(s)||24)},get font(){return e&&e.textFont||""},set font(s){e&&(e.textFont=String(s||""))},get alignment(){return e&&e.alignment||"center"},set alignment(s){if(!e)return;const c=String(s||"center").toLowerCase();e.alignment=c==="centre"?"center":c},...e&&e.puppet&&o?bc(e,o):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(c){return c===void 0?new he(0,0,0):s},rotation(){return s},scale(){return s}};return s},setBoneTransform:()=>{},applyBonePhysicsImpulse:()=>{}},getParent:()=>{if(!e||e.parentId==null)return null;const s=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById(e.parentId):null;return!s||s.destroyed?null:cr(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const c=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!c)return[];const a=[];for(const f of s){const l=c(f);l&&!l.destroyed&&a.push(cr(l,n))}return a},getAnimation:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return s==null||s===""?a[0]||Fn():c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Fn()},getAnimationLayer:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Fn()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>mc(e),play:()=>{e&&e.soundCtl&&e.soundCtl.play&&e.soundCtl.play(),e&&e.videoCtl&&e.videoCtl.play&&e.videoCtl.play()},pause:()=>{e&&e.soundCtl&&e.soundCtl.pause&&e.soundCtl.pause(),e&&e.videoCtl&&e.videoCtl.pause&&e.videoCtl.pause()},stop:()=>{e&&e.soundCtl&&e.soundCtl.stop&&e.soundCtl.stop(),e&&e.videoCtl&&e.videoCtl.stop&&e.videoCtl.stop()},isPlaying:Object.assign(()=>{const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||c))}}),get volume(){if(e&&e.soundCtl&&typeof e.soundCtl.getVolume=="function")return e.soundCtl.getVolume();const s=e&&e.soundprops&&e.soundprops.volume;return typeof s=="number"?s:1},set volume(s){const c=Number(s);if(!Number.isFinite(c)||!e)return;const a=Math.max(0,Math.min(1,c));e.soundprops&&(e.soundprops.volume=a),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(a)},getVideoTexture:()=>pc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],c=new Float32Array(16);return c[0]=1,c[5]=1,c[10]=1,c[15]=1,c[12]=s[0]||0,c[13]=s[1]||0,c[14]=s[2]||0,{m:c}},getEffect:s=>{const c=e&&e.effects||null;if(!c||c.length===0)return no(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return no(c[Number(s)]||null);const a=String(s);return no(c.find(f=>f&&f.name===a)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return r.angles},set(s){if(e&&Array.isArray(e.angles)){const c=Fi(s);e.angles[0]=c[0],e.angles[1]=c[1],e.angles[2]=c[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){if(e&&Array.isArray(e[s])){const c=e[s];r[s].x=c[0]||0,r[s].y=c[1]||0,r[s].z=c[2]||0}return r[s]},set(c){const a=Ot(c);r[s].x=a[0],r[s].y=a[1],r[s].z=a[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=a[0],e[s][1]=a[1],e[s][2]=a[2])}});return i}function wc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const o=Pi(e),r={};if(n&&typeof n=="object")for(const[_,w]of Object.entries(n))if(w!==null&&typeof w=="object"&&typeof w.user=="string"){const L=t.userProperties?t.userProperties[w.user]:void 0;r[_]=L!==void 0?L:Ln(w)}else r[_]=Ln(w);const i=new Proxy(()=>i,{apply(){return i},get(_,w){if(w==="finish")return()=>r;if(typeof w=="string"&&gi.test(w))return L=>(L&&typeof L=="object"&&typeof L.name=="string"&&!(L.name in r)&&(r[L.name]=Ln(L.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Ci(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||cn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||cn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};vi(s,t);const c=t.audioViews;s.registerAudioBuffers=_=>{const w=Math.max(1,Math.min(64,Math.floor(Number(_)||0)));let L=c?c.get(w):void 0;return L||(L={left:new Float32Array(w),right:new Float32Array(w),average:new Float32Array(w)},c&&c.set(w,L)),L};const a=t.shared||{},f={console:bi()},l=Mi(t.inputView),d=t.layer||null,h=t.workshopId!=null?t.workshopId:vc(e),m=cr(d,t),M=xc({...t,workshopId:h,getWorkshopId:()=>h});let g;try{g=new Function("scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent",`"use strict";
178
+ `+o+`
179
+ ;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+ar.map(w=>`${w}: typeof ${w} === "function" ? ${w} : null,`).join("")+"dummy_: 0};")(r,yi(s),Ai,_i,Ti,i,a,f.console,void 0,f,f,f,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,he,xi,l,m,M,m,gc(),Si)}catch(_){return t.onError&&t.onError(_,"parse"),null}const y=!!(g&&(g.cursorClick||g.cursorEnter||g.cursorLeave||g.cursorDown||g.cursorUp||g.cursorMove)),b=!!(g&&ar.some(_=>g[_])),p=!!(g&&typeof g.applyUserProperties=="function");if(!g||!g.update&&!y&&!b&&!p)return null;const v={engine:s,scriptProperties:r,hasUpdate:!!g.update,hasCursorHook:y,hasApplyHook:p,errCount:0,disabled:!1,init(_){if(g.init)try{g.init(wi(_))}catch(w){v.errCount++,t.onError&&t.onError(w,"init")}},applyUserProperties(_){if(g.applyUserProperties)try{g.applyUserProperties(_||{})}catch(w){v.errCount++,t.onError&&t.onError(w,"applyUserProperties")}},callUpdate(_){if(v.disabled||!g.update)return;let w;try{w=g.update(wi(_))}catch(L){v.errCount++,t.onError&&t.onError(L,"update"),v.errCount>=3&&(v.disabled=!0);return}return w},hasCursorHook:y,callCursor(_,w){if(v.disabled)return;const L=g[_];if(typeof L=="function")try{return L(w)}catch(F){v.errCount++,t.onError&&t.onError(F,_),v.errCount>=3&&(v.disabled=!0);return}},hasMediaHook:b,callMedia(_,w){if(v.disabled)return;const L=g[_];if(typeof L=="function")try{return L(w)}catch(F){v.errCount++,t.onError&&t.onError(F,_),v.errCount>=3&&(v.disabled=!0);return}}};return v}function ro(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},o={get x(){return t.x},set x(r){t.x=Number(r)||0},get y(){return t.y},set y(r){t.y=Number(r)||0},get z(){return t.z},set z(r){t.z=Number(r)||0},add(r){const i=Ot(r);return t.x+=i[0],t.y+=i[1],t.z+=i[2],o},subtract(r){const i=Ot(r);return t.x-=i[0],t.y-=i[1],t.z-=i[2],o},multiply(r){if(r&&typeof r=="object"){const i=Ot(r);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(r)||0;t.x*=i,t.y*=i,t.z*=i}return o},copy(){return new he(t.x,t.y,t.z)},length(){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},toArray(){return[t.x,t.y,t.z]}};return o}function Ot(e){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e&&typeof e=="object")return[e.x||0,e.y||0,e.z||0];const n=Number(e)||0;return[n,n,n]}const lr=Math.PI/180,ur=180/Math.PI;function Mc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*ur,y:(n[1]||0)*ur,z:(n[2]||0)*ur}}function Fi(e){const n=Ot(e);return[n[0]*lr,n[1]*lr,n[2]*lr]}function Ac(e){const n={x:0,y:1,z:2},t={add(o){const r=Ot(o);return t.x+=r[0],t.y+=r[1],t.z+=r[2],t},subtract(o){const r=Ot(o);return t.x-=r[0],t.y-=r[1],t.z-=r[2],t},multiply(o){return t.x*=o,t.y*=o,t.z*=o,t},toArray(){return[t.x,t.y,t.z]}};for(const o of["x","y","z"])Object.defineProperty(t,o,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[o]]||0)*ur},set(r){!e||!Array.isArray(e.angles)||(e.angles[n[o]]=(Number(r)||0)*lr)}});return t}function _c(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function Tc(e){for(const n of e&&e.effects?e.effects:[]){if(n&&n.visible===!1)continue;if(String(n&&(n.file||n.name)||"").includes("tint"))return!0;for(const o of n&&n.passes||[])for(const r of o&&o.textures||[])if(r&&String(r).toLowerCase().includes("mask"))return!0}return!1}const Sc=Object.freeze(Object.defineProperty({__proto__:null,createInputView:lc,drawTextLayer:ac,effectiveTextPadding:pi,evalObjectScript:wc,evalTextScript:hc,layoutText:sc,makeCursorEventVec:cc,radToScriptAngles:Mc,resolveWorkshopAssetPath:Li,rewriteComboStringEq:Ei,scriptAnglesToRad:Fi,textCanvasMargin:_c,textLayerHasTintMask:Tc},Symbol.toStringTag,{value:"Module"}));function Ec(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,o=typeof e.clearTimeout=="function"?e.clearTimeout:null,r=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,c=new Set,a=y=>{const b=Number(y);return Number.isFinite(b)&&b>0?b:0},f=y=>()=>{try{y()}catch(b){s&&s(b,"timer")}},l=(y,b)=>{const p=()=>{y.fired||(y.fired=!0,c.delete(p),b&&y.handle!=null&&b(y.handle))};return p.handle=null,p.valueOf=()=>typeof y.handle=="number"?y.handle:0,p};function d(y,b){if(typeof y!="function")return l({fired:!0,handle:null},null);const p={fired:!1,handle:null},v=l(p,o);return c.add(v),p.handle=t?t(f(()=>{p.fired=!0,c.delete(v),y()}),a(b)):null,v.handle=p.handle,v}function h(y,b){if(typeof y!="function")return l({fired:!0,handle:null},null);const p={fired:!1,handle:null},v=l(p,i);return c.add(v),p.handle=r?r(f(y),a(b)):null,v.handle=p.handle,v}function m(y){if(typeof y=="function"){y();return}o&&y!=null&&o(y)}function M(y){if(typeof y=="function"){y();return}i&&y!=null&&i(y)}function g(){for(const y of[...c])y();c.clear()}return{setTimeout:d,setInterval:h,clearTimeout:m,clearInterval:M,dispose:g,pendingCount:()=>c.size}}const Pc=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:Ec},Symbol.toStringTag,{value:"Module"}));function Cc(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function oo(e,n){const t=Math.floor(e),o=e-t,r=s=>{const c=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(c-Math.floor(c))*2-1},i=o*o*(3-2*o);return r(t)*(1-i)+r(t+1)*i}const Rc=32,Ni=60/112,Lc=3.2;function Fc(e){const n=new Float32Array(16),t=new Float32Array(16),o=new Float32Array(16);for(let r=0;r<16;r++)n[r]=r%4===0?1:r%4===2?.38+e()*.15:e()<.08?.5:0,t[r]=r%8===4?1:e()<.06?.6:0,o[r]=r%2===1?.5+e()*.4:r%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:o}}function Nc(e=20260830){const n=Cc(e),t=Fc(n),o=new Float32Array(64);for(let y=0;y<64;y++)o[y]=n()*64;const r=64,i=new Float32Array(r),s=new Float32Array(r),c=new Float32Array(r),a=new Float32Array(r),f=new Float32Array(32),l=new Float32Array(32),d=new Float32Array(16),h=new Float32Array(16),m={left64:c,right64:a,left32:f,right32:l,left16:d,right16:h,level:0,silent:!1};function M(y,b){const p=b.length/y.length;for(let v=0;v<y.length;v++){let _=0;const w=Math.floor(v*p),L=Math.floor((v+1)*p);for(let F=w;F<Math.max(w+1,L);F++)_+=b[F];y[v]=_/Math.max(1,L-w)}}function g(y){const b=y/Ni,p=b*4,v=Math.floor(p)%16,_=p-Math.floor(p),w=Math.exp(-_*Ni*14),L=y%Rc,F=L>=27&&L<29,D=L>=29?(L-29)/3:0,B=L>=24&&L<27?1-(L-24)/3:0,z=F?0:D>0?D*D:B>0?0:1,V=F?0:B>0?.35:1,Y=t.kick[v]*w*z,Z=(t.snare[v]*w+t.hat[v]*w*.7)*z,X=t.hat[v]*w*z,q=D>0?Math.pow(D,3)*(.4+.6*Math.abs(oo(p*2,7))):0;let oe=0;for(let H=0;H<r;H++){const j=H/r,ee=Math.pow(1-j*.85,1.6);let le=V*(.5+.3*oo(b*.5+o[H]*.05,H%8));if(le*=.35+.65*j,j<.2&&(le+=Y*(1-j/.2)),j>=.12&&j<.62){const Fe=1-Math.abs(j-.34)/.28;Fe>0&&(le+=Z*.55*Fe)}j>=.45&&(le+=X*.5*((j-.45)/.55)),le+=q*.5,le*=ee,le=Math.min(1,le*Lc);const Se=.06+j*.2,Xe=oo(b*.13+H*.35,11)*Se;let Le=Math.min(1,Math.max(0,le*(1-Xe))),Pe=Math.min(1,Math.max(0,le*(1+Xe)));const ue=F?.012:0;i[H]=Math.max(ue,Le),s[H]=Math.max(ue,Pe),H<48&&(oe+=(i[H]+s[H])*.5)}return c.set(i),a.set(s),M(f,i),M(l,s),M(d,i),M(h,s),m.level=Math.min(1,oe/(48*1.2)),m.silent=F,m}return{update:g,snapshot:m,bands:r}}function kc(e,n){for(const t of e.values()){ki(t.left,n.left64),ki(t.right,n.right64);for(let o=0;o<t.average.length;o++)t.average[o]=(t.left[o]+t.right[o])*.5}}function ki(e,n){const t=n.length/e.length;for(let o=0;o<e.length;o++){let r=0;const i=Math.floor(o*t),s=Math.max(i+1,Math.floor((o+1)*t));for(let c=i;c<s;c++)r+=n[c];e[o]=r/(s-i)}}const Dt={STOPPED:0,PLAYING:1,PAUSED:2};class Re{constructor(n,t,o){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(o)||0}add(n){return new Re(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Re(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Re(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Re(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Re(this.x/t,this.y/t,this.z/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}copy(){return new Re(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function Uc(e,n,t){return new Re(e,n,t)}const Ic=[{title:"\u591C\u822A\u661F",artist:"\u76F8\u4F4D\u8FC1\u79FB",album:"\u6DF1\u7A7A\u56DE\u58F0",albumArtist:"\u76F8\u4F4D\u8FC1\u79FB",duration:212,colors:{primary:[.24,.42,.86],secondary:[.12,.18,.42],tertiary:[.62,.74,.98],text:[.95,.97,1]},lyrics:[[0,"\u5728\u65E0\u5149\u7684\u822A\u9053\u4E0A"],[12,"\u6211\u4EEC\u53EA\u5E26\u8D70\u5F7C\u6B64\u7684\u540D\u5B57"],[26,"\u5F15\u64CE\u4F4E\u9E23\u50CF\u4E00\u53E5\u65E7\u8BFA\u8A00"],[41,"\u628A\u9ED1\u6697\u6298\u6210\u4E24\u534A"],[58,"\u591C\u822A\u661F\u554A"],[72,"\u522B\u5728\u4E2D\u9014\u7184\u706D"],[95,"\uFF08\u95F4\u594F\uFF09"],[126,"\u5982\u679C\u5750\u6807\u7EC8\u5C06\u5931\u6548"],[140,"\u5C31\u8BA9\u8F68\u8FF9\u81EA\u5DF1\u8BF4\u8BDD"],[158,"\u6211\u4EEC\u4E0D\u8FD4\u822A"],[176,"\u4E5F\u4E0D\u9057\u61BE"],[198,"\u2026\u2026"]]},{title:"Amber Lantern",artist:"Hollow Coast",album:"Tidewater",albumArtist:"Hollow Coast",duration:187,colors:{primary:[.93,.62,.24],secondary:[.44,.24,.1],tertiary:[.99,.82,.56],text:[1,.98,.93]},lyrics:[[0,"Salt on the window frame"],[14,"a lantern swinging slow"],[30,"you said the tide forgets"],[46,"but the harbour never does"],[63,"Amber lantern, burn a little longer"],[88,"(instrumental)"],[118,"Every rope remembers the knot"],[134,"every shore remembers the leaving"],[152,"burn a little longer"],[170,"for me"]]},{title:"\u82D4\u75D5",artist:"\u6797\u95F4\u7535\u53F0",album:"\u534A\u5C71\u96E8",albumArtist:"\u6797\u95F4\u7535\u53F0",duration:241,colors:{primary:[.3,.68,.44],secondary:[.1,.28,.2],tertiary:[.72,.92,.78],text:[.96,1,.97]},lyrics:[[0,"\u96E8\u505C\u5728\u7B2C\u4E09\u7EA7\u53F0\u9636"],[16,"\u82D4\u75D5\u722C\u6EE1\u4E86\u65E7\u95E8\u724C"],[33,"\u4F60\u8BF4\u6162\u4E00\u70B9\u4E5F\u6CA1\u5173\u7CFB"],[52,"\u5C71\u4E0D\u4F1A\u8D70"],[70,"\u800C\u6211\u4EEC\u6709\u7684\u662F\u65F6\u95F4"],[92,"\uFF08\u95F4\u594F\uFF09"],[130,"\u628A\u4F1E\u6536\u8D77\u6765\u5427"],[148,"\u8BA9\u6F6E\u6C14\u8BB0\u4F4F\u8FD9\u4E00\u523B"],[172,"\u6162\u4E00\u70B9"],[200,"\u771F\u7684\u6CA1\u5173\u7CFB"],[226,"\u2026\u2026"]]},{title:"Neon Ashes",artist:"VELVET//NULL",album:"Afterimage",albumArtist:"VELVET//NULL",duration:168,colors:{primary:[.86,.22,.58],secondary:[.3,.06,.22],tertiary:[.99,.64,.86],text:[1,.94,.98]},lyrics:[[0,"city bleeds into the lens"],[11,"we were only afterimage"],[24,"neon ashes on your coat"],[38,"nothing here stays lit"],[55,"burn out with me"],[76,"(drop)"],[104,"nothing here stays lit"],[122,"burn out with me"],[146,"\u2026"]]}],fr=3;function Ui(e=20260901){const n=Ic,t=n.reduce((b,p)=>b+p.duration+fr,0),o={hasMedia:!1,state:Dt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Re(0,0,0),secondaryColor:new Re(0,0,0),tertiaryColor:new Re(0,0,0),textColor:new Re(1,1,1),highContrastColor:new Re(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let r=0,i=!1,s=0,c=0;function a(b){let p=0;const v=(b%n.length+n.length)%n.length;for(let _=0;_<v;_++)p+=n[_].duration+fr;return p}function f(b){let p=t>0?b%t:0;p<0&&(p+=t);let v=-1,_=0,w=!1;for(let V=0;V<n.length;V++){const Y=n[V].duration;if(p<Y){v=V,_=p;break}if(p-=Y,p<fr){v=V,_=Y,w=!0;break}p-=fr}v<0&&(v=n.length-1,_=n[v].duration,w=!0);const L=n[v];o.hasMedia=!0,o.trackIndex=v,o.title=L.title,o.artist=L.artist,o.album=L.album,o.albumArtist=L.albumArtist,o.duration=L.duration,o.position=_;const F=L.duration>0?_/L.duration:0;i?o.state=Dt.PAUSED:w?o.state=Dt.STOPPED:F>.7&&F<.76?o.state=Dt.PAUSED:o.state=Dt.PLAYING,o.hasThumbnail=!w;const D=L.colors;o.primaryColor=new Re(D.primary[0],D.primary[1],D.primary[2]),o.secondaryColor=new Re(D.secondary[0],D.secondary[1],D.secondary[2]),o.tertiaryColor=new Re(D.tertiary[0],D.tertiary[1],D.tertiary[2]),o.textColor=new Re(D.text[0],D.text[1],D.text[2]);const B=.2126*D.primary[0]+.7152*D.primary[1]+.0722*D.primary[2];o.highContrastColor=B>.5?new Re(0,0,0):new Re(1,1,1),o.lyrics=L.lyrics;let z=-1;for(let V=0;V<L.lyrics.length;V++)_>=L.lyrics[V][0]&&(z=V);return o.lyricIndex=z,o.lyricLine=z>=0?L.lyrics[z][1]:"",o}function l(b){c=Number(b)||0;const p=i?s:c+r;return f(p)}function d(b){i=!1;const p=a(b);return r=p-c,f(p)}function h(){const b=o.trackIndex<0?0:o.trackIndex+1;return d(b)}function m(){const b=o.trackIndex<0?n.length-1:o.trackIndex-1;return d(b)}function M(){return i||(s=c+r,i=!0,o.state=Dt.PAUSED),o}function g(){return i?(i=!1,r=s-c,f(s)):o}function y(){return i?g():M()}return{update:l,snapshot:o,tracks:n,cycle:t,MEDIA_PLAYBACK:Dt,skipNext:h,skipPrevious:m,play:g,pause:M,playPause:y}}function Bc(e,n=512){const t=Math.max(8,n|0),o=new Uint8Array(t*t*4),r=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,c]=r.primary,[a,f,l]=r.secondary,[d,h,m]=r.tertiary;for(let M=0;M<t;M++)for(let g=0;g<t;g++){const y=g/(t-1),b=M/(t-1),p=y-.5,v=b-.5,_=Math.sqrt(p*p+v*v)*2,w=.5+.5*Math.sin(_*18-1.2),L=.5+.5*Math.sin((y+b)*6),F=Math.min(1,Math.max(0,_));let D=i*(1-F)+a*F,B=s*(1-F)+f*F,z=c*(1-F)+l*F;D=D*(.72+.28*w)+d*.18*L,B=B*(.72+.28*w)+h*.18*L,z=z*(.72+.28*w)+m*.18*L;const V=1-.35*Math.min(1,_*_),Y=(M*t+g)*4;o[Y]=Math.max(0,Math.min(255,Math.round(D*V*255))),o[Y+1]=Math.max(0,Math.min(255,Math.round(B*V*255))),o[Y+2]=Math.max(0,Math.min(255,Math.round(z*V*255))),o[Y+3]=255}return{width:t,height:t,rgba:o}}function Oc(e,n){const t=[];if(!n)return t;const o=!e;return(o||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(o||e.title!==n.title||e.artist!==n.artist||e.album!==n.album||e.albumArtist!==n.albumArtist)&&t.push({name:"mediaPropertiesChanged",event:{title:n.title,artist:n.artist,album:n.album,albumArtist:n.albumArtist,albumTitle:n.album,subTitle:"",trackType:"music"}}),(o||e.hasThumbnail!==n.hasThumbnail||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaThumbnailChanged",event:{hasThumbnail:n.hasThumbnail,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,tertiaryColor:n.tertiaryColor,textColor:n.textColor,highContrastColor:n.highContrastColor}}),(o||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(o||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(o||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function Dc(e){return e?{hasMedia:e.hasMedia,state:e.state,title:e.title,artist:e.artist,album:e.album,albumArtist:e.albumArtist,position:e.position,duration:e.duration,hasThumbnail:e.hasThumbnail,trackIndex:e.trackIndex,lyricIndex:e.lyricIndex,lyricLine:e.lyricLine}:null}const $c=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:Dt,cloneMediaSnapshot:Dc,createSimulatedMedia:Ui,diffMediaEvents:Oc,mediaVec3:Uc,renderThumbnail:Bc},Symbol.toStringTag,{value:"Module"})),Ii=14,Nn=[{app:"Safari",title:"GitHub \xB7 we-scene-renderer",url:"https://github.com/oneincase/we-scene-renderer"},{app:"Google Chrome",title:"YouTube",url:"https://www.youtube.com/watch?v=dQw4w9WgXcQ"},{app:"Google Chrome",title:"Wallpaper Engine - Workshop",url:"https://steamcommunity.com/app/431960/workshop/"},{app:"Safari",title:"MDN Web Docs",url:"https://developer.mozilla.org/en-US/docs/Web/API"},{app:"Music",title:"\u591C\u822A\u661F \u2014 \u76F8\u4F4D\u8FC1\u79FB",url:""},{app:"Code",title:"we-scene-renderer \u2014 text.js",url:""}];function Bi(){const e={app:"",title:"",url:"",index:-1};function n(t){const o=Number(t)||0,r=Nn.length?Math.floor(o/Ii)%Nn.length:0,i=Nn[r]||Nn[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=r,e}return n(0),{update:n,snapshot:e,tabs:Nn,hold:Ii}}function Oi(e){const n={name:"",at:0};function t(o){return n.name=String(o||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function zc(e){const n=Ui(e),t=Bi(),o=Oi(null);return{media:n,windowTitle:t,shortcuts:o}}const jc=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:Oi,createSimulatedSystem:zc,createSimulatedWindowTitle:Bi},Symbol.toStringTag,{value:"Module"}));function Vc(e={}){const n=e.target||(typeof window<"u"?window:null),t=e.viewport||(typeof window<"u"?()=>({w:window.innerWidth||1,h:window.innerHeight||1}):null),o={u:.5,v:.5,screenX:0,screenY:0,wx:0,wy:0,originY:null,lastU:.5,lastV:.5,lastScreenX:0,lastScreenY:0,lastWx:0,lastWy:0,lastOriginY:null,leftDown:!1,has:!1,moveCount:0,downCount:0,upCount:0,lastEventTime:0,screenW:1,screenH:1};function r(){if(!t)return;const l=t();o.screenW=l.w||1,o.screenH=l.h||1}r();function i(l){r();let d=l.clientX,h=l.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const g=n.getBoundingClientRect();d-=g.left,h-=g.top}const m=d/o.screenW,M=h/o.screenH;o.has||(o.lastU=m,o.lastV=M,o.lastScreenX=d,o.lastScreenY=h),o.screenX=d,o.screenY=h,o.u=m,o.v=M,o.has=!0,o.moveCount++,o.lastEventTime=Date.now()}function s(l){l.button!==void 0&&l.button!==0||(o.leftDown=!0,o.downCount++)}function c(l){l.button!==void 0&&l.button!==0||(o.leftDown=!1,o.upCount++)}function a(){o.leftDown=!1}let f=!1;return n&&n.addEventListener&&(f=!0,n.addEventListener("mousemove",i,{passive:!0}),n.addEventListener("mousedown",s,{passive:!0}),n.addEventListener("mouseup",c,{passive:!0}),n.addEventListener("blur",a,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",a,{passive:!0})),{state:o,beginFrame(){r(),o.lastU=o.u,o.lastV=o.v,o.lastScreenX=o.screenX,o.lastScreenY=o.screenY,o.lastWx=o.wx,o.lastWy=o.wy,o.lastOriginY=o.originY},syncWorld(l,d=0,h=0){if(!l)return;o.wx=l.offX+o.u*l.viewW-d,o.wy=l.offY+o.v*l.viewH-h;const m=Number(l.projH);o.originY=Number.isFinite(m)?m-o.wy:o.wy,o.lastWx===0&&o.lastWy===0&&(o.lastWx=o.wx,o.lastWy=o.wy,o.lastOriginY=o.originY)},normalizedDelta(){const l=o.u-o.lastU,d=o.v-o.lastV;return Math.hypot(l,d)},dispose(){!f||!n||!n.removeEventListener||(f=!1,n.removeEventListener("mousemove",i),n.removeEventListener("mousedown",s),n.removeEventListener("mouseup",c),n.removeEventListener("blur",a),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",a))}}}const Wc=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:Vc},Symbol.toStringTag,{value:"Module"}));function Di(e,n,t,o,r,i,s){const c=e.size||[0,0],a=e.scale||[1,1,1],f=c[0]*a[0],l=c[1]*a[1];if(!(f>0)||!(l>0))return null;const d=e.origin||[0,0,0];let h=d[0],m=o-d[1];if(e.parallaxDepth&&(r!==0||i!==0)){const p=e.parallaxDepth,v=sn(p[0]),_=sn(p[1]);h+=v*r,m+=_*i}let M=n-h,g=t-m;const y=e.angles?e.angles[2]:0;if(y){const p=Math.cos(-y),v=Math.sin(-y),_=M*p+g*v,w=-M*v+g*p;M=_,g=w}const b=s&&s[e.alignment]||[.5,.5];return(b[0]!==.5||b[1]!==.5)&&(M-=(.5-b[0])*f,g-=(.5-b[1])*l),{lx:M/f,ly:g/l,w:f,h:l}}function Hc(e,n,t,o,r={}){if(!e||e.length===0)return null;const i=r.parOffX||0,s=r.parOffY||0,c=r.alignTable,a=r.filter;for(let f=e.length-1;f>=0;f--){const l=e[f];if(!l||!l.visible||l.destroyed||a&&!a(l))continue;const d=Di(l,n,t,o,i,s,c);if(d&&Math.abs(d.lx)<=.5&&Math.abs(d.ly)<=.5)return l}return null}const Xc=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:Hc,worldToLayerLocal:Di},Symbol.toStringTag,{value:"Module"})),ze=e=>e,je=ze(cs),dr=ze(_s),Qe=ze(ks),vt=ze(Os),Be=ze(ya),Gc=ze(xa),Yc=ze(Sa),Yt=ze(ja),kn=ze(ic),He=ze(Sc),qc=ze(Pc),ve=ze($c),$i=ze(jc),zi=ze(ha),Zc=ze(Wc),Kc=ze(Xc);function Qc(e,n,t){return{camera:null,general:{orthogonalprojection:{width:e,height:n},clearenabled:!0,clearcolor:"0 0 0"},layers:[{id:0,name:"media",visible:!0,image:t,textureName:t,particle:null,puppet:null,solid:!1,isContainer:!1,isPostProcess:!1,isText:!1,isSound:!1,isComponent:!1,sound:[],origin:[e/2,n/2,0],scale:[1,1,1],angles:[0,0,0],size:[e,n],alignment:"center",color:[1,1,1],alpha:1,brightness:1,colorBlendMode:0,copybackground:!1,parallaxDepth:null,animationLayers:[],effects:[]}],properties:{}}}async function Jc(e){const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const t=new window.ImageDecoder({data:await n.arrayBuffer(),type:"image/gif"});await t.tracks.ready,await t.completed;const o=t.tracks.selectedTrack;if(!o||!o.frameCount)return null;const r=Math.min(o.frameCount,300),i=[];let s=0,c=0;for(let a=0;a<r;a++){const{image:f}=await t.decode({frameIndex:a});s=f.displayWidth,c=f.displayHeight,i.push({bitmap:await createImageBitmap(f),durationMs:f.duration?f.duration/1e3:100}),f.close()}return t.close?.(),{width:s,height:c,frames:i}}function el(e,n){if(en(e),!n.src){e.fallbackPage?.();return}const t=n.type==="video",o=n.type==="gif",r=document.createElement("canvas"),i=We(e,n);if(r.width=Math.max(1,Math.round(innerWidth*i)),r.height=Math.max(1,Math.round(innerHeight*i)),r.style.cssText="position:absolute;inset:0;width:100%;height:100%;",!r.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){re(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE\uFF0C\u56DE\u9000 DOM \u6E32\u67D3`),t?tl(e,n):nl(e,n);return}e.wrap?.appendChild(r),e.canvas=r;let c=!1;e.sceneCleanup=()=>{c=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let a,f,l=!1;e.sceneCtl={pause(){a?.()},resume(){f?.()},applyUserProperties(){}};const d=h=>{c||(c=!0,re(e,n,`media ${n.type} \u5931\u8D25: ${h}`),e.fallbackPage?.())};(async()=>{try{const h=Be.createRenderer(r,{diag:B=>re(e,n,`renderer: ${B}`),fboCapFactor:0});if(e.renderer=h,c)return;const m="__media",M=new Map;let g,y=0,b=0;if(t){const B=document.createElement("video");if(B.autoplay=!0,B.loop=n.loop!==!1,B.muted=n.muted!==!1,B.playsInline=!0,B.preload="metadata",B.width=r.width,B.height=r.height,B.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",B.src=n.src,document.body.appendChild(B),e.video=B,(e.videoTextures??=[]).push(B),await new Promise((z,V)=>{B.addEventListener("loadedmetadata",()=>z(),{once:!0}),B.addEventListener("error",()=>V(new Error(`video error ${B.error?.code??"?"}`)),{once:!0})}),c)return;y=B.videoWidth||r.width,b=B.videoHeight||r.height,M.set(m,{video:B,glTex:Be.makeTexture(h.gl,new Uint8Array([0,0,0,255]),1,1),width:y,height:b,rg88:!1,lastUploaded:-1}),e.paused||B.play().catch(()=>{}),re(e,n,`media video ${y}x${b} \u2192 scene \u6E32\u67D3`)}else{let B=!1;if(o&&typeof window.ImageDecoder=="function")try{const z=await Jc(n.src);if(z&&z.frames.length>1){y=z.width,b=z.height;const V=h.gl,Y={glTex:Be.makeTexture(V,null,0,0,z.frames[0].bitmap),width:y,height:b,rg88:!1};M.set(m,Y);let Z=0,X=performance.now()+z.frames[0].durationMs;g=()=>{const oe=performance.now();if(!(oe<X)){Z=(Z+1)%z.frames.length,X=oe+z.frames[Z].durationMs,V.bindTexture(V.TEXTURE_2D,Y.glTex);try{V.texImage2D(V.TEXTURE_2D,0,V.RGBA,V.RGBA,V.UNSIGNED_BYTE,z.frames[Z].bitmap)}catch{}}};const q=e.sceneCleanup;e.sceneCleanup=()=>{q?.();for(const oe of z.frames)oe.bitmap.close()},B=!0,re(e,n,`media gif ${y}x${b} ${z.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(z){re(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(z.message).slice(0,80)}`)}if(!B){const z=new Image;if(z.crossOrigin="anonymous",z.src=n.src,await new Promise((V,Y)=>{z.addEventListener("load",()=>V(),{once:!0}),z.addEventListener("error",()=>Y(new Error("image load error")),{once:!0})}),c)return;y=z.naturalWidth||1,b=z.naturalHeight||1,e.img=z,M.set(m,{glTex:Be.makeTexture(h.gl,null,0,0,z),width:y,height:b,rg88:!1}),re(e,n,`media ${n.type} ${y}x${b} \u2192 scene \u6E32\u67D3`)}}if(c)return;const p=Qc(y,b,m),v=performance.now();let _=0,w=0,L=-1/0;const F=B=>{if(c||e.paused)return;const z=e.cfg.sceneFps||60;if(B-L>=1e3/z){L=B,fo(e,B),mo(e,r,e.cfg),g?.();const V=e.coverAlign;h.render(p,M,r.width,r.height,(B-v-_)/1e3,Xt(e.cfg.fit),V.x,V.y).then(()=>{c||e.paused||(e.raf=requestAnimationFrame(F))}).catch(Y=>d(String(Y.message||Y).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(F))},D=()=>{c||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(F))};a=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),w||(w=performance.now());const B=e.video;l=!!(B&&!B.paused&&!B.ended),B?.pause()},f=()=>{w&&(_+=performance.now()-w,w=0),l&&e.video?.play().catch(()=>{}),l=!1,D()},D()}catch(h){d(String(h.message||h).slice(0,200))}})()}function tl(e,n){if(en(e),!n.src){e.fallbackPage?.();return}const t=lo(n.fit),o=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let r=!1;const i=()=>{r||(r=!0,console.warn("video error, fallback to default wallpaper"),e.fallbackPage?.())},s=document.createElement("video");s.autoplay=!0,s.loop=n.loop!==!1,s.muted=n.muted!==!1,s.playsInline=!0,s.preload="metadata";const c=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*c)),s.height=Math.max(1,Math.round(innerHeight*c)),s.style.cssText=o,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),re(e,n,"video mounted (single + native loop)")}function nl(e,n){en(e);const t=document.createElement("img"),o=lo(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${o.objectFit};object-position:50% 50%;background:${o.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const rl=["scene.pkg","scenes/scene.pkg","gifscene.pkg"];function ji(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(o){let r=null,i=null;for(const c of rl){let a;try{a=await fetch(`${t}/${c}`,{...n,signal:o})}catch(f){if(o?.aborted)throw f;i=f;continue}if(!a.ok){r=a.status;continue}try{return await a.arrayBuffer()}catch(f){if(o?.aborted)throw f;const l=f instanceof Error?f.message:String(f);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(r!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${r}\uFF09`);const s=i instanceof Error?i.message:"Failed to fetch";throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08${s}\uFF09`)},async project(o){try{const r=await fetch(`${t}/project.json`,{...n,signal:o});return r.ok?await r.json():null}catch{return null}}}}function ol(e,n){const t=e;return{key:typeof t.name=="string"?`file:${t.name}:${t.size}:${t.lastModified??0}`:void 0,scenePkg:()=>e.arrayBuffer(),project:async()=>n??null}}function il(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}const Vi=.5,sl=.04,Wi=.08;function al(e,n){const t=p=>{const v=document.createElement("video");p&&(v.src=e),v.muted=n.muted,v.playsInline=!0,v.preload="metadata";const _=Math.min(window.devicePixelRatio||1,n.renderDpr||1),w=Math.max(1,Math.round(n.maxW*_)),L=Math.max(1,Math.round(n.maxH*_));return v.width=w,v.height=L,v.loop=!0,v};let o=t(!0),r=t(!1),i=!1,s=1,c=n.muted;r.muted=!0;const a=()=>{i||(r.src=e,i=!0)};let f=!1,l=!1,d=-1,h=0,m=!1;const M=()=>{if(f=!1,l=!1,!r.paused){r.pause();try{r.currentTime=0}catch{}}},g=()=>{const p=o;o=r,r=p,f=!1,l=!1,o.play().catch(()=>{}),o.muted=c,o.volume=s,p.pause();try{p.currentTime=0}catch{}p.muted=!0,d=-1,i=!0,b.onSwap?.(o)},y=()=>{if(m)return;h=requestAnimationFrame(y);const p=o.duration;if(!isFinite(p)||p<=0)return;const v=o.currentTime;if(d>=0&&v<d-.05){const w=l;M(),d=v,w||b.onFallback?.();return}d=v;const _=p-v;if(_>Vi+.5){(f||l)&&M();return}if(l){(_<=Wi||v<=Wi)&&g();return}if(f){r.paused?r.play().catch(()=>{}):r.currentTime>=sl*.5&&(r.pause(),f=!1,l=!0);return}if(_<=Vi&&(a(),r.readyState>=2)){try{r.currentTime=0}catch{}r.play().catch(()=>{}),f=!0}};h=requestAnimationFrame(y);const b={get active(){return o},get standby(){return r},onSwap:void 0,onFallback:void 0,setVolume(p){s=Math.max(0,Math.min(1,p)),c=p<=0,o.muted=c,o.volume=s,r.muted=!0,r.volume=s},pause(){M(),o.pause(),h&&cancelAnimationFrame(h),h=0},resume(){m||(o.play().catch(p=>{p&&p.name}),h||(h=requestAnimationFrame(y)))},destroy(){m=!0,h&&cancelAnimationFrame(h),h=0;for(const p of[o,r]){p.pause(),p.removeAttribute("src");try{p.load()}catch{}p.remove()}}};return b}const Hi=!1,Xi=!0,Gi=!1,cl=!1,ll=!1,Yi=4,Un=64,qi={STOPPED:0};function ul(){return{left64:new Float32Array(Un),right64:new Float32Array(Un),left32:new Float32Array(32),right32:new Float32Array(32),left16:new Float32Array(16),right16:new Float32Array(16),level:0,silent:!0}}function hr(e,n){const t=n.length/e.length;for(let o=0;o<e.length;o++){let r=0;const i=Math.floor(o*t),s=Math.max(i+1,Math.floor((o+1)*t));for(let c=i;c<s;c++)r+=n[c];e[o]=r/(s-i)}}function fl(e,n,t){const o=n.length,r=t*.5,i=20,s=Math.min(2e4,r);let c=0;for(let a=0;a<Un;a++){const f=a/Un,l=(a+1)/Un,d=i*Math.pow(s/i,f),h=i*Math.pow(s/i,l),m=Math.max(0,Math.floor(d/r*o)),M=Math.min(o,Math.max(m+1,Math.ceil(h/r*o)));let g=0;for(let b=m;b<M;b++)g+=n[b]/255;const y=Math.min(1,g/(M-m)*1.35);e.left64[a]=y,e.right64[a]=y,a<48&&(c+=y)}hr(e.left32,e.left64),hr(e.right32,e.right64),hr(e.left16,e.left64),hr(e.right16,e.right64),e.level=Math.min(1,c/(48*1.2)),e.silent=e.level<.02}function dl(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0)%360}function io(e,n,t){const o=n/100,r=t/100,i=(1-Math.abs(2*r-1))*o,s=e/60,c=i*(1-Math.abs(s%2-1));let a=0,f=0,l=0;s<1?[a,f,l]=[i,c,0]:s<2?[a,f,l]=[c,i,0]:s<3?[a,f,l]=[0,i,c]:s<4?[a,f,l]=[0,c,i]:s<5?[a,f,l]=[c,0,i]:[a,f,l]=[i,0,c];const d=r-i/2;return[a+d,f+d,l+d]}function hl(e,n){const t=dl(n||"empty"),[o,r,i]=io(t,72,48),[s,c,a]=io((t+40)%360,55,28),[f,l,d]=io((t+20)%360,70,72);e.primaryColor=ve.mediaVec3(o,r,i),e.secondaryColor=ve.mediaVec3(s,c,a),e.tertiaryColor=ve.mediaVec3(f,l,d),e.textColor=ve.mediaVec3(.98,.98,1),e.highContrastColor=ve.mediaVec3(1,1,1),e.hasThumbnail=!!n}function ml(e,n,t){const o=document.createElement("canvas");o.width=32,o.height=32;const r=o.getContext("2d",{willReadFrequently:!0});if(!r)return null;r.drawImage(e,0,0,n,t,0,0,32,32);const i=r.getImageData(0,0,32,32).data;let s=0,c=0,a=0,f=0,l=0,d=0,h=0,m=-1;for(let b=0;b<i.length;b+=4){const p=i[b]/255,v=i[b+1]/255,_=i[b+2]/255;s+=p,c+=v,a+=_,f++;const w=Math.max(p,v,_),L=Math.min(p,v,_),F=w-L,D=.2126*p+.7152*v+.0722*_,B=F*1.4+(D>.15&&D<.85?.3:0);B>m&&(m=B,l=p,d=v,h=_)}if(!f)return null;const M=[l,d,h],g=[s/f*.55,c/f*.55,a/f*.55],y=[Math.min(1,M[0]*.45+.55),Math.min(1,M[1]*.45+.55),Math.min(1,M[2]*.45+.55)];return{primary:M,secondary:g,tertiary:y}}function pl(e,n,t,o=512){const r=document.createElement("canvas");r.width=o,r.height=o;const i=r.getContext("2d"),s=Math.max(o/Math.max(1,n),o/Math.max(1,t)),c=n*s,a=t*s;i.fillStyle="#000",i.fillRect(0,0,o,o),i.drawImage(e,(o-c)/2,(o-a)/2,c,a);const f=i.getImageData(0,0,o,o);return{width:o,height:o,rgba:new Uint8Array(f.data)}}function gl(){return{hasMedia:!1,state:qi.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:ve.mediaVec3(0,0,0),secondaryColor:ve.mediaVec3(0,0,0),tertiaryColor:ve.mediaVec3(0,0,0),textColor:ve.mediaVec3(1,1,1),highContrastColor:ve.mediaVec3(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1}}async function bl(){if(!navigator.mediaDevices?.getUserMedia)return null;try{const e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1},video:!1}),n=new AudioContext,t=n.createMediaStreamSource(e),o=n.createAnalyser();return o.fftSize=2048,o.smoothingTimeConstant=.8,t.connect(o),n.state==="suspended"&&await n.resume().catch(()=>{}),{ctx:n,stream:e,analyser:o,buf:new Uint8Array(o.frequencyBinCount)}}catch{return null}}async function yl(e){const n=e?.origin??(typeof location<"u"?location.origin:""),t=e?.onArtwork,o=ul(),r=gl(),i={app:"",title:"",url:"",index:0};let s="off",c="offline",a="offline",f="",l=!1,d="";const h=await bl();h?s="mic":navigator.mediaDevices?.getUserMedia?s="denied":s="unavailable";let m=null,M=null,g=!1;const y=(w,L,F)=>{!n||!t||!l||d!==w&&(d=w,t({url:`${n}/api/system/artwork?k=${encodeURIComponent(w)}&_=${Date.now()}`,trackKey:w,title:L,artist:F}))},b=w=>{if(!w||!w.hasMedia){r.hasMedia=!1,r.state=qi.STOPPED,r.title="",r.artist="",r.album="",r.albumArtist="",r.position=0,r.duration=0,r.hasThumbnail=!1,r.trackIndex=-1,c=w?"empty":"offline",f="",l=!1,d="";return}c="live",r.hasMedia=!0,r.state=Number(w.state)===2?2:Number(w.state)===1?1:0,r.title=String(w.title??""),r.artist=String(w.artist??""),r.album=String(w.album??""),r.albumArtist=String(w.albumArtist??w.artist??""),r.position=Number(w.position)||0,r.duration=Number(w.duration)||0,l=w.hasArtwork===!0;const L=`${r.title}|${r.artist}|${r.album}`;L!==f&&(f=L,d="",r.trackIndex=r.trackIndex+1|0,hl(r,L)),y(L,r.title,r.artist)},p=w=>{if(!w){a="offline";return}i.app=String(w.app??""),i.title=String(w.title??""),i.url=String(w.url??""),a=i.app||i.title?"live":"empty"},v=async()=>{if(!(!n||g))try{const[w,L]=await Promise.all([fetch(`${n}/api/system/media`,{cache:"no-store"}),fetch(`${n}/api/system/window`,{cache:"no-store"})]);if(w.ok){const F=await w.json();b(F)}else c="offline";L.ok&&p(await L.json())}catch{c=c==="live"?"live":"offline",a=a==="live"?"live":"offline"}};if(n){await v(),M=setInterval(()=>{v()},1e3);try{m=new EventSource(`${n}/api/system/stream`),m.onmessage=w=>{if(!g)try{const L=JSON.parse(w.data);b(L.media),p(L.window)}catch{}}}catch{}}const _=w=>{!n||g||fetch(`${n}/api/system/media-control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:w})}).then(async L=>L.ok?L.json():null).then(L=>{L&&typeof L=="object"&&b(L),v()}).catch(()=>{v()})};return{audio:{snapshot:o,pump:()=>{if(!h||g){o.level=0,o.silent=!0;return}h.analyser.getByteFrequencyData(h.buf),fl(o,h.buf,h.ctx.sampleRate||48e3)}},media:{snapshot:r,pump:()=>{},skipNext:()=>_("skipNext"),skipPrevious:()=>_("skipPrevious"),play:()=>_("play"),pause:()=>_("pause"),playPause:()=>_("playPause")},windowTitle:{snapshot:i,pump:()=>{}},status:()=>({audio:s,media:c,window:a,title:r.title,artist:r.artist,app:i.app,windowTitle:i.title,hasArtwork:l}),dispose:()=>{g=!0,M&&(clearInterval(M),M=null);try{m?.close()}catch{}if(m=null,h)try{h.stream.getTracks().forEach(w=>w.stop()),h.ctx.close()}catch{}}}}const vl={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
176
180
  #define M_PI 3.14159265359
177
181
  // M_PI_2 \u662F\u300CPI \xD7 2\u300D\u800C\u4E0D\u662F\u300CPI \xF7 2\u300D\u2014\u2014 \u540D\u5B57\u6781\u6613\u8BFB\u53CD\uFF0C\u6B64\u524D\u8BEF\u5199\u6210 1.5708\uFF0C
178
182
  // \u5F71\u54CD\u5168\u5E93 142 \u4E2A\u6587\u4EF6\uFF0864 \u4E2A\u58C1\u7EB8\uFF09\u3002\u4E09\u6761\u72EC\u7ACB\u8BC1\u636E\uFF1A
@@ -419,10 +423,18 @@ mat3 squareToQuad(vec2 p0, vec2 p1, vec2 p2, vec2 p3) {
419
423
  float d = p1.y - p0.y + g * p1.y;
420
424
  float e = p3.y - p0.y + h * p3.y;
421
425
  float f = p0.y;
422
- // \u884C\u5411\u91CF\u7EA6\u5B9A\uFF1A[u v 1] * M
423
- return mat3(a, d, g,
424
- b, e, h,
425
- c, f, 1.0);
426
+ // \u8C03\u7528\u70B9\u4E00\u5F8B\u662F mul(vec3(uv,1), inverse(\u672C\u51FD\u6570\u7ED3\u679C))\uFF0Chlsl2glsl \u628A\u5B83\u8F6C\u5199\u6210
427
+ // transpose(xform) * vec3(uv,1)\u3002\u8981\u8BA9\u5C4F\u5E55\u70B9 s \u5F97\u5230 texCoord = S\u207B\xB9\xB7s\uFF08S \u4E3A
428
+ // Heckbert \u6B63\u5411\u77E9\u9635 [[a,b,c],[d,e,f],[g,h,1]]\uFF0C\u5355\u4F4D\u65B9\u2192\u56DB\u8FB9\u5F62\uFF09\uFF0C\u5FC5\u987B
429
+ // xform = inverse(\u672C\u51FD\u6570\u7ED3\u679C) \u6EE1\u8DB3 transpose(xform)\xB7s = S\u207B\xB9\xB7s\uFF0C
430
+ // \u5373\u672C\u51FD\u6570\u8FD4\u56DE S \u7684**\u8F6C\u7F6E**\uFF1Amat3 \u5217\u4E3B\u5E8F\u6784\u9020\u4E3A (a,d,g)(b,e,h)(c,f,1) \u7684\u8F6C\u7F6E
431
+ // = (a,b,c)(d,e,f)(g,h,1)\u3002\u6392\u5E03\u5DEE\u4E00\u4E2A\u8F6C\u7F6E\uFF0Cperspective/\u6C34\u6CE2\u7B49\u5168\u90E8\u9519\u4F4D\u2014\u2014
432
+ // 3174556087 \u7684\u97F3\u8C31\u67F1\u88AB\u8D34\u5230\u7A97\u6237\u4FA7\u8FB9\u7AD6\u6392\uFF08\u5E94\u4E3A\u8D34\u4E0B\u7A97\u6CBF\u6A2A\u6392\uFF09\u5B9E\u6D4B\u786E\u8BA4\u3002
433
+ // 2026-09-05 \u6570\u503C\u6A21\u62DF\uFF1A\u65E7\u6392\u5E03 transpose(S\u207B\xB9)\xB7corner \u4E0E\u6B63\u786E S\u207B\xB9\xB7corner \u9010\u9879\u4E0D\u540C\uFF0C
434
+ // \u53EF\u89C1\u533A\u584C\u7F29\u6210\u4E00\u6761\u659C\u5E26\uFF1B\u65B0\u6392\u5E03\u540E\u4E2D\u5FC3 (0.5,0.5) \u2192 (0.478,0.511) \u2208 [0,1]\xB2\u3002
435
+ return mat3(a, b, c,
436
+ d, e, f,
437
+ g, h, 1.0);
426
438
  }
427
439
  `,"common_blur.h":`// WE common_blur.h\uFF08\u91CD\u5EFA\uFF09
428
440
  uniform sampler2D g_Texture0;
@@ -495,6 +507,6 @@ vec3 DecompressNormal(vec4 tex) {
495
507
  return vec3(xy, sqrt(clamp(1.0 - dot(xy, xy), 0.0, 1.0)));
496
508
  }
497
509
  `,"common_vertex.h":`// WE common_vertex.h\uFF08\u91CD\u5EFA\uFF1A\u7A7A\u5360\u4F4D\uFF0C\u89C1 headers.ts \u6CE8\u91CA\uFF09
498
- `},el={systemfont_segoe:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",systemfont_arial:"Arial, 'Helvetica Neue', sans-serif",systemfont_verdana:"Verdana, Geneva, sans-serif",systemfont_tahoma:"Tahoma, Geneva, sans-serif",systemfont_timesnewroman:"'Times New Roman', Times, serif",systemfont_georgia:"Georgia, 'Times New Roman', serif",systemfont_couriernew:"'Courier New', Courier, monospace",systemfont_trebuchetms:"'Trebuchet MS', 'Helvetica Neue', sans-serif",systemfont_impact:"Impact, 'Arial Black', sans-serif",systemfont_comicsansms:"'Comic Sans MS', 'Comic Sans', cursive",systemfont_sylfaen:"Palatino, 'Times New Roman', serif",systemfont_calibri:"Calibri, Carlito, 'Helvetica Neue', sans-serif",systemfont_cambria:"Cambria, Georgia, serif",systemfont_consolas:"Consolas, 'Courier New', monospace",systemfont_microsoftyahei:"'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif",systemfont_simsun:"SimSun, 'Songti SC', serif",systemfont_simhei:"SimHei, 'Heiti SC', sans-serif"},zi=new Map,Un=new Map;async function tl(e,n,t,r){const o=t.key;if(o){const a=Un.get(o);if(a)return a.at=Date.now(),ae(e,n,`pkg cache hit: ${a.parsed.fileSize} bytes`),a.parsed}let i;try{i=await t.scenePkg(r)}catch(a){throw r.aborted||a instanceof Error?a:new Error(String(a))}ae(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),c=De.parsePkg(s);if(!o)return c;if(Un.set(o,{parsed:c,at:Date.now()}),Un.size>2){let a=null,u=1/0;for(const[l,d]of Un)l!==o&&d.at<u&&(u=d.at,a=l);a&&Un.delete(a)}return c}function nl(e,n){tn(e);const t=n.canvas??document.createElement("canvas"),r=Ye(e,n),o=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(o*r)),t.height=Math.max(1,Math.round(i*r)),n.canvas||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const c=new AbortController;let a;e.sceneCleanup=()=>{s=!0,c.abort(),e.sceneTextUpdate=void 0,a&&(a(),a=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let u=null,l,d,h;e.sceneCtl={pause(){d?.()},resume(){h?.()},applyUserProperties(p){l?l(p):u={...u||{},...p}}},(async()=>{try{const p=n.source??Ni(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");ae(e,n,"mountScene start");const w=await tl(e,n,p,c.signal);if(s)return;let m=null;try{m=await p.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const v=De.getEntry(w,"scene.json");if(!v)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const b=Qe.parseScene(JSON.parse(st(v)),m);{const A=b.general?.zoom,L=Number(A&&typeof A=="object"?A.value:A);b.cameraTransforms={zoom:Number.isFinite(L)&&L>0?L:1}}const y=vs(b.properties||{});e.liveUserProps=y;const S=()=>Qe.recomputeLayerVisibility(b.layers);if(e.onSceneInfo){const A=b.general?.orthogonalprojection||{},L=Number(A.width)>0?Number(A.width):t.width,I=Number(A.height)>0?Number(A.height):t.height,U=b.layers||[],X={width:L,height:I,layerCount:U.length,hasModels:U.some(Y=>!!Y.model),hasParticles:U.some(Y=>!!Y.particle),hasText:U.some(Y=>!!Y.text)},ne=e.onSceneInfo;e.onSceneInfo=void 0,ne(X)}const _=[];Ii&&(b.layers=b.layers.filter(A=>!(Ii&&A.isComponent)));const C=A=>{const L=A.startsWith("shaders/")?A:"shaders/"+A,I=A.startsWith("shaders/")?A.slice(8):A,U=De.getEntry(w,L);let X=U?st(U):Jc[I]??null;const ne=window.__shaderPatch;if(X&&ne){const Y=I.replace(/\.(frag|vert|h)$/,""),f=ne[Y]||ne[I];if(typeof f=="function")try{const T=f(X,I);typeof T=="string"&&(X=T)}catch{}}return Promise.resolve(X)},N=ke.createRenderer(t,{shaderResolver:C,diag:A=>ae(e,n,`renderer: ${A}`),fboCapFactor:0});if(e.renderer=N,s)return;const D=m?.general?.supportsaudioprocessing!==!1,k=Mc(),O={enabled:D},j=A=>new Float32Array(A),W={left16:j(16),right16:j(16),left32:j(32),right32:j(32),left64:j(64),right64:j(64),level:0,silent:!0};N.setAudioProvider(()=>O.enabled?k.snapshot:W);const K=new Map;window.__audioStats=()=>({enabled:O.enabled,level:O.enabled?Math.round(k.snapshot.level*1e3)/1e3:0,silent:O.enabled?k.snapshot.silent:!0,bass:O.enabled?Math.round(k.snapshot.left64[2]*1e3)/1e3:0}),window.__audioMute=A=>(O.enabled=!A,O.enabled),ae(e,n,`audio: simulated stream, supportsaudioprocessing=${D}`);const V=St.createSimulatedMedia(),G=Li.createSimulatedWindowTitle(),Q=Li.createShortcutHandler(A=>{ae(e,n,`openUserShortcut: ${A}`)}),q={enabled:!0,override:null},te=[];let me=null;const xe=A=>{if(!(!A||!A.hasMediaHook||te.includes(A))&&(te.push(A),!!V.snapshot.hasMedia))for(const{name:L,event:I}of St.diffMediaEvents(null,V.snapshot))try{A.callMedia(L,I)}catch{}};window.__mediaStats=()=>({enabled:q.enabled,hooks:te.length,title:V.snapshot.title,artist:V.snapshot.artist,album:V.snapshot.album,state:V.snapshot.state,position:Math.round(V.snapshot.position),duration:V.snapshot.duration,hasThumbnail:V.snapshot.hasThumbnail,lyric:V.snapshot.lyricLine,primaryColor:V.snapshot.primaryColor?[V.snapshot.primaryColor.x,V.snapshot.primaryColor.y,V.snapshot.primaryColor.z]:null}),window.__mediaSet=A=>{Object.assign(V.snapshot,A||{});const L=St.diffMediaEvents(me,V.snapshot);for(const{name:I,event:U}of L)for(const X of te)X.callMedia(I,U);return me=St.cloneMediaSnapshot(V.snapshot),window.__mediaStats()};const We=()=>{const A=St.diffMediaEvents(me,V.snapshot);for(const{name:L,event:I}of A)for(const U of te)try{U.callMedia(L,I)}catch{}me=St.cloneMediaSnapshot(V.snapshot)},Ve={snapshot:V.snapshot,skipNext:()=>(V.skipNext(),We(),V.snapshot),skipPrevious:()=>(V.skipPrevious(),We(),V.snapshot),play:()=>(V.play(),We(),V.snapshot),pause:()=>(V.pause(),We(),V.snapshot),playPause:()=>(V.playPause(),We(),V.snapshot)};window.__mediaControl=Ve,window.__system={media:Ve,windowTitle:G.snapshot,shortcuts:Q.last};const Ee=Dc.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});N.setPointerProvider(()=>Ee);{const A=a;a=()=>{A?.(),Ee.dispose()}}const rt=qe.createInputView(),Xe=Oc.createEngineTimers({setTimeout:(A,L)=>window.setTimeout(A,L),clearTimeout:A=>window.clearTimeout(A),setInterval:(A,L)=>window.setInterval(A,L),clearInterval:A=>window.clearInterval(A)},{onError:(()=>{let A=!1;return L=>{A||(A=!0,ae(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(L?.message||L).slice(0,90)}`))}})()}),Pe={setTimeout:Xe.setTimeout,clearTimeout:Xe.clearTimeout,setInterval:Xe.setInterval,clearInterval:Xe.clearInterval};{const A=a;a=()=>{A?.(),Xe.dispose()}}window.__pointerStats=()=>{const A=Ee.state,L=I=>Math.round(I*1e3)/1e3;return{normalized:{u:L(A.u),v:L(A.v)},last:{u:L(A.lastU),v:L(A.lastV)},world:{x:Math.round(A.wx),y:Math.round(A.wy)},originY:A.originY!=null?Math.round(A.originY):null,screen:{x:A.screenX,y:A.screenY,w:A.screenW,h:A.screenH},leftDown:A.leftDown,has:A.has,delta:L(Ee.normalizedDelta()),counts:{move:A.moveCount,down:A.downCount,up:A.upCount}}};const Ae=new Map;Ae.set("util/white",{glTex:ke.makeTexture(N.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),Ae.set("util/noflow",{glTex:ke.makeTexture(N.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),Ae.set("util/noise",{glTex:ke.makeTexture(N.gl,Bc.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const A=I=>{const U=St.renderThumbnail(I,512);return{glTex:ke.makeTextureMip(N.gl,[U],!1),width:U.width,height:U.height,rg88:!1,mips:[U],generated:!0}},L=V.tracks||[];L.length&&(Ae.set("$mediaThumbnail",A(L[0])),Ae.set("$mediaPreviousThumbnail",A(L[L.length-1])))}const Ze=new Map,to=async A=>{if(Ae.has(A))return Ae.get(A);const L=De.getEntry(w,`materials/${A}.tex`);if(!L){if(un.isBuiltinParticleTextureName(A)){const Y=un.buildBuiltinParticleTexture(A);if(Y){const f={glTex:ke.makeTextureMip(N.gl,[Y],!1),width:Y.width,height:Y.height,rg88:!1,mips:[Y],generated:!0};return Ae.set(A,f),f}}return null}const I=fr.parseTex(L),U=fr.decodeMip0(I),X=I.format===8;let ne=null;if(U.video!==void 0){const Y=URL.createObjectURL(new Blob([U.video],{type:"video/mp4"})),f=Zc(Y,{muted:!0,renderDpr:Ye(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const R of[f.active,f.standby])R.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(R),(e.videoTextures??=[]).push(R);(e.objectUrls??=[]).push(Y),(e.videoPairs??=[]).push(f),f.active.addEventListener("loadedmetadata",()=>{ae(e,n,`video tex '${A}': ${f.active.videoWidth}x${f.active.videoHeight}`)}),f.active.addEventListener("error",()=>{ae(e,n,`video tex '${A}' ERROR: ${f.active.error?.code}`)});const T=[],x=R=>{for(const B of T)R.addEventListener("ended",B)},M={play:()=>{s||f.resume()},pause:()=>f.pause(),stop:()=>{f.pause();try{f.active.currentTime=0}catch{}},isPlaying:()=>!f.active.paused&&!f.active.ended,duration:()=>Number.isFinite(f.active.duration)?f.active.duration:0,getCurrentTime:()=>f.active.currentTime||0,setCurrentTime:R=>{try{f.active.currentTime=R}catch{}},getRate:()=>f.active.playbackRate||1,setRate:R=>{f.active.playbackRate=R,f.standby.playbackRate=R},getLoop:()=>f.active.loop,setLoop:R=>{f.active.loop=R,f.standby.loop=R},addEndedCallback:R=>{T.push(R),f.active.addEventListener("ended",R)}},E={get video(){return f.active},glTex:ke.makeTexture(N.gl,new Uint8Array([0,0,0,0]),1,1),width:U.width,height:U.height,rg88:!1,lastUploaded:-1,videoCtl:M};let P=0;return f.onSwap=R=>{E.lastUploaded=-1,x(R),P++,(P===1||P===10||P===100)&&ae(e,n,`video tex '${A}' loop swap ok x${P}`)},f.onFallback=()=>{ae(e,n,`video tex '${A}' loop fallback (native loop used)`)},Ae.set(A,E),E}else if(U.png!==void 0||U.image!==void 0&&U.fif===fr.FIF.JPEG){const Y=new Blob([U.png||U.image],{type:U.png?"image/png":"image/jpeg"}),f=await createImageBitmap(Y);ne={glTex:ke.makeTexture(N.gl,null,0,0,f),width:f.width,height:f.height,rg88:X}}else{if(U.image!==void 0)return null;{const Y=fr.decodeMip0(I);ne={glTex:ke.makeTextureMip(N.gl,[Y],X),width:Y.width,height:Y.height,rg88:X,mips:[Y]}}}if(!ne)return null;if(I.frames?.list?.length){const Y=I.frames.list;Y.atlasWidth=ne.width,Y.atlasHeight=ne.height,ne.frames=Y}return Ae.set(A,ne),ne},lt=A=>{if(Ae.has(A))return Promise.resolve(Ae.get(A));const L=Ze.get(A);if(L)return L;const I=to(A);return Ze.set(A,I),I.finally(()=>{Ze.get(A)===I&&Ze.delete(A)}),I},He=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,hr=async A=>{for(const L of A.materialPasses||[])if(L.shader)for(const I of["frag","vert"]){const U=De.getEntry(w,`shaders/${L.shader}.${I}`);if(!U)continue;const X=st(U);He.lastIndex=0;let ne;for(;(ne=He.exec(X))!==null;){const Y=ne[1];!Y||Y.startsWith("util/")||Y.startsWith("_rt_")||Ae.has(Y)||await lt(Y)}}};let $t=0;const ot=[];for(let A=0;A<b.layers.length;A++){const L=b.layers[A];if(L.image)try{let I;if(bt.BUILTIN_MODELS[L.image])I=bt.BUILTIN_MODELS[L.image];else{const T=De.getEntry(w,L.image);if(!T)continue;I=JSON.parse(st(T))}if(Qe.applySolidFromModel(L,I),I&&typeof I=="object"&&"width"in I&&"height"in I){const T=I;(L.size?.[0]||0)===0&&(L.size?.[1]||0)===0&&T.width>0&&T.height>0&&(L.size=[T.width,T.height])}const U=Qe.resolveMaterial(I);if(!U)continue;let X;if(bt.BUILTIN_MATERIALS[U.materialPath])X=bt.BUILTIN_MATERIALS[U.materialPath];else{const T=De.getEntry(w,U.materialPath);if(T)X=JSON.parse(st(T));else if(L.solid&&bt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])X=bt.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const ne=X.passes?.[0],Y=ne?.textures||[],f=Y[0];if(ne?.combos){for(const T of Object.keys(ne.combos))if(T.toLowerCase()==="spritesheet"&&Number(ne.combos[T])===1){L.spriteSheet=!0;break}}for(let T=0;T<Y.length;T++){const x=Y[T];typeof x!="string"||!x||x.startsWith("util/")||x.startsWith("_rt_")||ot.push(lt(x).then(M=>{M&&T===0&&(L.textureName=x,$t++,M.videoCtl&&(L.videoCtl=M.videoCtl))}))}ne?.shader&&De.getEntry(w,`shaders/${ne.shader}.frag`)&&bt.attachLayerMaterialEffect(L,ne);for(const T of L.effects||[])bt.resolveEffectChain(w,T,st);for(const T of L.effects||[]){for(const x of T.passes||[])for(const M of x.textures||[])typeof M=="string"&&M!==""&&!M.startsWith("util/")&&!M.startsWith("_rt_")&&ot.push(lt(M));ot.push(hr(T))}}catch(I){console.warn(`\u56FE\u5C42 ${L.name||A} \u52A0\u8F7D\u5931\u8D25: ${I.message}`)}}if(!Oi){for(const A of b.layers)if(!(!A.isText||!(A.effects||[]).length))try{for(const L of A.effects||[])bt.resolveEffectChain(w,L,st);for(const L of A.effects||[])for(const I of L.passes||[])for(const U of I.textures||[])typeof U=="string"&&U!==""&&!U.startsWith("util/")&&!U.startsWith("_rt_")&&ot.push(lt(U))}catch(L){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${A.name} \u89E3\u6790\u5931\u8D25: ${L.message}`)}}await Promise.all(ot);for(const[A,L]of Ae){if(!L?.videoCtl)continue;b.layers.some(U=>U.textureName===A&&U.visible&&!U.destroyed)&&!e.paused&&L.videoCtl.play()}const ze=[],Et=new Map;let kn=0;const Bn=async A=>{const L=await lt(A);if(L)return L;const I=un.buildBuiltinParticleTexture(A);if(!I)return null;const U={glTex:ke.makeTextureMip(N.gl,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0};return Ae.set(A,U),kn++,U},In=A=>{if(!A)return null;const L=A.mips&&A.mips[0];if(L?.rgba&&typeof un.prepareParticleNormalTexture=="function"){const I=un.prepareParticleNormalTexture(L);if(I&&I!==L)return{glTex:ke.makeTextureMip(N.gl,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0}}return A},mr=async(A,L,I,U)=>{if(U>3)return null;const X=De.getEntry(w,A);if(!X)return ae(e,n,`particle '${A}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const ne=JSON.parse(st(X)),Y=new Ic.ParticleSystem(N.gl,ne,I,L);let f=null,T=null;if(ne.material){const P=De.getEntry(w,ne.material);if(P){const R=JSON.parse(st(P));Y.setMaterial(R);const B=R?.passes?.[0]?.textures||[];f=B[0]||null,T=B[1]||null}}const x=await Bn(f||"particle/halo");if(!x)return ae(e,n,`particle '${A}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;Y.setTexture({glTex:x.glTex,width:x.width,height:x.height,frames:x.frames});const M=T||(Y.refract?un.particleNormalNameForAlbedo(f||"particle/halo"):null);if(M){const P=In(await Bn(M));P&&Y.setNormalTexture({glTex:P.glTex,width:P.width,height:P.height})}Y.setVisible(!!L.visible),ze.push(Y);const E=L.id;if(E!==void 0){let P=Et.get(E);P||(P=[],Et.set(E,P)),P.push(Y)}for(const P of ne.children||[]){if(!P||typeof P.name!="string")continue;const R=String(P.origin??"0 0 0").trim().split(/\s+/).map(Number),B=String(P.scale??"1 1 1").trim().split(/\s+/).map(Number),z=String(P.angles??"0 0 0").trim().split(/\s+/).map(Number),$=P.type==="eventfollow"?"particle":!P.type||P.type==="static"?"origin":null,J=Y.localToWorld(R[0]||0,R[1]||0),re={...L,origin:[J[0],J[1],(L.origin?.[2]||0)+(R[2]||0)],scale:[(L.scale?.[0]??1)*(B[0]||1),(L.scale?.[1]??1)*(B[1]||1),(L.scale?.[2]??1)*(B[2]||1)],angles:[(L.angles?.[0]||0)+(z[0]||0),(L.angles?.[1]||0)+(z[1]||0),(L.angles?.[2]||0)+(z[2]||0)]},Z=await mr(P.name,re,P.instanceoverride||I,U+1);Z&&$&&Z.attachFollow(Y,$,[R[0]||0,R[1]||0,R[2]||0])}return Y};if(!Kc){for(const A of b.layers)if(A.particle)try{await mr(A.particle,A,A.instanceoverride,0)}catch(L){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`),ae(e,n,`particle '${A.name}' FAIL: ${L.message.slice(0,80)}`)}}if(ze.length>0){const A=a;a=()=>{A?.();for(const L of ze)L.dispose()}}const fn=[];for(const A of b.layers)if(!(!A.sound||!A.sound.length))try{for(const L of A.sound){const I=De.getEntry(w,L);if(!I)continue;const U=(L.split(".").pop()||"").toLowerCase(),X=U==="mp3"?"audio/mpeg":U==="ogg"?"audio/ogg":U==="flac"?"audio/flac":"audio/wav",ne=new Blob([I],{type:X}),Y=URL.createObjectURL(ne);(e.objectUrls??=[]).push(Y);const f=document.createElement("audio");f.src=Y,f.loop=A.soundprops?.playbackmode==="loop",f.volume=Math.max(0,Math.min(1,A.soundprops?.volume??1)),f.muted=n.muted!==!1,A.soundCtl={play(){if(f.ended)try{f.currentTime=0}catch{}f.play().catch(()=>{})},pause(){f.pause()},stop(){f.pause();try{f.currentTime=0}catch{}},isPlaying:()=>!f.paused&&!f.ended,getVolume:()=>f.volume,setVolume:T=>{f.volume=Math.max(0,Math.min(1,T))}},!A.soundprops?.startsilent&&!e.paused&&f.play().catch(()=>{}),fn.push(f);break}}catch(L){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`)}const pr=A=>{for(const L of fn)L.volume=Math.max(0,Math.min(1,A)),L.muted=A<=0};if(e.sceneAudio={setVolume:pr,audios:fn},s)return;let we=performance.now(),Kt=0;N.setParticleRenderer(()=>{const A=performance.now(),L=Math.min(.05,(A-we)/1e3);if(we=A,Ee.state.has){const{wx:I,wy:U,originY:X}=Ee.state,ne=X??U;for(const Y of ze)Y.setPointer(I,ne)}for(const I of ze)I.advance(L,O.enabled?k.snapshot:null);if(Kt<2&&(Kt++,Kt===2)){const I=ze.reduce((U,X)=>U+X.liveCount(),0);ae(e,n,`particles live: ${I} across ${ze.length} systems`)}},(A,L,I,U,X)=>{if(A===void 0)return;const ne=Et.get(A);if(ne)for(const Y of ne)Y.render(I,U,X,L.projW,L.projH)}),ae(e,n,`particles: ${ze.length} systems, ${kn} builtin tex generated`),window.__particleStats=()=>ze.map(A=>{let L=0,I=1/0,U=-1/0,X=1/0,ne=-1/0,Y=1/0,f=-1/0;for(const T of A.pool){if(!T.alive)continue;L++;const x=A.originX+T.x*A.scaleX,M=A.originY+T.y*A.scaleY;x<I&&(I=x),x>U&&(U=x),M<X&&(X=M),M>ne&&(ne=M);const E=Math.abs(T.size)*A.sysScale;E<Y&&(Y=E),E>f&&(f=E)}return{live:L,max:A.maxCount,blend:A.blend,renderer:A.renderers.map(T=>T.kind).join("+"),origin:[Math.round(A.originX),Math.round(A.originY)],bbox:L?[Math.round(I),Math.round(X),Math.round(U),Math.round(ne)]:null,size:L?[Math.round(Y),Math.round(f)]:null}}),window.__particleToggle=(A,L)=>{for(let I=0;I<ze.length;I++)ze[I].setVisible(L===void 0?A:I===L);return ze.length};const vt=[],On=new Map,gr=A=>{if(!A||!A.puppet)return null;let L=On.get(A);return L||(L=new Map,On.set(A,L)),L};for(const A of b.layers)if(A.image)try{if(bt.BUILTIN_MODELS[A.image])continue;const L=De.getEntry(w,A.image);if(!L)continue;const I=JSON.parse(st(L));if(!I.puppet)continue;const U=De.getEntry(w,I.puppet);if(!U)continue;const X=Nn.parseMDL(new Uint8Array(U)),ne=A.textureName?Ae.get(A.textureName):null;if(!ne){ae(e,n,`puppet '${A.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}A.puppet=X,vt.push({mdl:X,tex:ne,layer:A});const Y=X.animations[0];ae(e,n,`puppet '${A.name}' v=${X.vertexCount} bones=${X.bones.length}`+(Y?` anim='${Y.name}' ${Y.fps}fps\xD7${Y.frameCount}`:" \u65E0\u52A8\u753B"))}catch(L){console.warn(`puppet \u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`),ae(e,n,`puppet '${A.name}' \u5931\u8D25: ${L.message}`)}for(const A of b.layers)if(A.model&&!A.puppet)try{const L=De.getEntry(w,A.model);if(!L)continue;const I=Nn.parseMDL(new Uint8Array(L));let U=null;if(I.materialPath){const ne=De.getEntry(w,I.materialPath);if(ne){const f=JSON.parse(st(ne))?.passes?.[0]?.textures?.[0];typeof f=="string"&&f&&(U=f)}}U&&(await lt(U),A.textureName=U);const X=U?Ae.get(U):null;if(!X){ae(e,n,`model '${A.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}A.puppet=I,vt.push({mdl:I,tex:X,layer:A}),ae(e,n,`model '${A.name}' v=${I.vertexCount} static ${I.materialPath||""}`)}catch(L){console.warn(`model \u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`),ae(e,n,`model '${A.name}' \u5931\u8D25: ${L.message}`)}let dn=null;if(vt.length>0)try{dn=Nn.createMDLRenderer(N.gl);for(const L of vt)dn.upload(L.mdl);const A=new Map;for(const L of vt)A.set(L.layer,L);N.setPuppetRenderer((L,I,U)=>{const X=A.get(L);X&&dn.draw(I,X.mdl,{time:U.time,animLayers:L.animationLayers,boneOverrides:On.get(L),overrideTex:U.overrideTex||null,color:[L.color[0]*L.brightness,L.color[1]*L.brightness,L.color[2]*L.brightness,L.alpha]},X.tex)})}catch(A){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${A.message}`),ae(e,n,`puppet renderer \u5931\u8D25: ${A.message}`),dn=null;for(const L of vt)L.layer.puppet=null}if(s)return;ae(e,n,`puppet: ${vt.length} meshes`);const hn=Nn.applyAttachmentBindOrigins(b.layers);hn.length&&ae(e,n,`attachments: ${hn.length} hanging layers`);const ut=[],Dn=new Map,Qt={};let it=null,zn=null,$n=0;if(!Oi&&b.layers.some(A=>A.isText)){const A=b.general?.orthogonalprojection,L=A?.width||t.width,I=A?.height||t.height,U=Rr(qt(e.cfg.fit),L,I,t.width,t.height),X=Math.min(3,Math.max(.5,t.width/Math.max(1,U.viewW))),ne=new Map,Y=new Set;for(const x of b.layers)x.isText&&x.textFont&&Y.add(x.textFont);for(const x of w.entries||[])typeof x.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test(x.name)&&Y.add(x.name);for(const x of Y){const M=zi.get(`${n.src}|${x}`);if(M){ne.set(x,M);continue}const E=el[x.toLowerCase()];if(E){ne.set(x,E);continue}try{const P=De.getEntry(w,x);if(!P)continue;const R="wefont_"+x.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),B=URL.createObjectURL(new Blob([P])),z=new FontFace(R,`url(${B})`);await z.load(),document.fonts.add(z),(e.objectUrls??=[]).push(B),ne.set(x,R),zi.set(`${n.src}|${x}`,R)}catch(P){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${x}: ${P.message}`)}}it=document.createElement("canvas"),zn=it.getContext("2d");const f=2048;for(const x of b.layers)if(x.isText)try{const M={layer:x,sandbox:null,texName:"__wstext_"+x.id,entry:null,lastKey:null,quality:X};if(x.textScript&&(M.sandbox=qe.evalTextScript(x.textScript,x.textScriptProps,{text:x.text??"",font:x.textFont||"",pointsize:x.textPointsize,color:x.textColor,angles:x.angles,origin:x.origin,scale:x.scale,visible:x.visible,canvasSize:{width:L,height:I},userProperties:y,shared:Qt,audioViews:K,inputView:rt,...Pe,mediaControl:Ve,windowTitle:G.snapshot,openUserShortcut:Q.openUserShortcut,getLayerText:B=>Dn.get(B),onError:B=>{ae(e,n,`text script '${x.name}' \u5931\u8D25: ${String(B.message||B).slice(0,120)}`)}}),M.sandbox&&(_.push(M.sandbox),M.sandbox.init(),M.sandbox.applyUserProperties(y),M.sandbox.hasMediaHook&&xe(M.sandbox))),Dn.set(x.name||"",String(x.text??"")),x.textAnchor!=="center"&&x.size[0]>0&&x.size[1]>0){const B=x.size[0]*(x.scale[0]||1)/2,z=x.size[1]*(x.scale[1]||1)/2,$=x.textAnchor;$.includes("left")&&(x.origin[0]+=B),$.includes("right")&&(x.origin[0]-=B),$.includes("top")&&(x.origin[1]-=z),$.includes("bottom")&&(x.origin[1]+=z)}const E=Di*Math.max(1,x.textPointsize),P=qe.textLayerHasTintMask(x)?8:256,R=Math.min(P,qe.textCanvasMargin(E,0));M.boxW=x.size[0]>0?x.size[0]:E*4,M.boxH=x.size[1]>0?x.size[1]:E*1.6,M.margin=R,x.size=[M.boxW+R*2,M.boxH+R*2],M.entry={glTex:ke.makeTexture(N.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},Ae.set(M.texName,M.entry),x.textureName=M.texName,x.solid=!1,ut.push(M)}catch(M){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${x.name} \u521D\u59CB\u5316\u5931\u8D25: ${M.message}`)}if(ut.length>0){const x=a;a=()=>{x?.();for(const M of ut)N.gl.deleteTexture(M.entry.glTex)}}const T=x=>{if(!zn||!it)return;const M=zn;for(const E of ut){const P=E.layer;let R=String(P.text??"");if(E.sandbox&&E.sandbox.hasUpdate){E.sandbox.engine.runtime=x;const J=E.sandbox.callUpdate(R);J!=null?R=String(J):E.sandbox.thisLayer.text&&(R=String(E.sandbox.thisLayer.text))}else E.sandbox&&typeof E.sandbox.thisLayer?.text=="string"&&(R=String(E.sandbox.thisLayer.text));if(Dn.set(P.name||"",R),!P.visible)continue;const B=Math.max(1,E.sandbox?E.sandbox.thisLayer.pointsize:P.textPointsize),z=E.sandbox&&E.sandbox.thisLayer.font||P.textFont||"",$=`${R}\0${B}\0${z}\0${P.alpha}\0${P.textCastshadow}`;if(E.lastKey!==$){E.lastKey=$;try{const J=Di*B,re=E.boxW,Z=E.boxH,ce=E.margin,le=Math.abs(P.scale[0]||1),se=Math.abs(P.scale[1]||1);let ie=Math.max(1,Math.round(P.size[0]*le*E.quality)),F=Math.max(1,Math.round(P.size[1]*se*E.quality));const ee=Math.min(1,f/Math.max(ie,F));ie=Math.max(1,Math.round(ie*ee)),F=Math.max(1,Math.round(F*ee)),it.width!==ie||it.height!==F?(it.width=ie,it.height=F):(M.setTransform(1,0,0,1,0,0),M.clearRect(0,0,ie,F));const ue=Math.min(ie/P.size[0],F/P.size[1]);M.setTransform(ue,0,0,ue,0,0),M.translate(ce,ce);const ve=z&&ne.get(z)||"sans-serif";M.font=`${J}px "${ve}", sans-serif`;const Me=M.measureText(""),he=(Me.fontBoundingBoxAscent||0)+(Me.fontBoundingBoxDescent||0),Re=P.textSpacing||[0,0],Te=qe.layoutText(R,{boxW:re,boxH:Z,pointsize:J,lineHeight:(he>0?he:J*1.25)+Re[1],spacing:Re,padding:P.textPadding||0,maxwidth:P.textMaxwidth||0,limitwidth:!!P.textLimitwidth,maxrows:P.textMaxrows||0,limitrows:!!P.textLimitrows,limituseellipsis:!!P.textLimituseellipsis,halign:P.textHAlign,valign:P.textVAlign},wt=>M.measureText(wt).width);qe.drawTextLayer(M,Te,{font:M.font,color:P.textColor,alpha:P.alpha,brightness:P.brightness,spacing:Re,pointsize:J,opaquebackground:!!P.textOpaquebackground,backgroundcolor:P.textBackgroundcolor,backgroundbrightness:P.textBackgroundbrightness,castshadow:!!P.textCastshadow});const Ge=E.entry;N.gl.bindTexture(N.gl.TEXTURE_2D,Ge.glTex),N.gl.texImage2D(N.gl.TEXTURE_2D,0,N.gl.RGBA,N.gl.RGBA,N.gl.UNSIGNED_BYTE,it),Ge.width=ie,Ge.height=F}catch(J){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${P.name} \u7ED8\u5236\u5931\u8D25: ${J.message}`),E.lastKey=null}}}};e.sceneTextUpdate=T,window.__textWidgets=ut,ae(e,n,`text widgets: ${ut.length} (scripts ${ut.filter(x=>x.sandbox).length}, fonts ${ne.size}, quality ${X.toFixed(2)})`)}if(s)return;const jt=[],Wt=[],ft=[],_e={},Pt=[],Jt=[],Je=new Map,br=(A,L)=>{if(!L||typeof L.callCursor!="function"||!L.hasCursorHook)return;const I=Je.get(A);I?I.push(L):Je.set(A,[L])};for(const A of ut)A.sandbox&&br(A.layer,A.sandbox);{const A=b.general?.orthogonalprojection,L=A?.width||t.width,I=A?.height||t.height,U=y,X=(x,M)=>{const E=b.general||{};if(x==="zoom"&&typeof M=="number"&&Number.isFinite(M)&&M>0){b.cameraTransforms.zoom=M,E.zoom&&typeof E.zoom=="object"?E.zoom.value=M:E.zoom=M;return}E[x]&&typeof E[x]=="object"&&"value"in E[x]?E[x].value=M:E[x]=M};let ne=1+Math.max(0,...b.layers.map(x=>Number(x.id)||0));const Y={recomputeVisibility:S,getSceneLayer:x=>b.layers.find(M=>M.name===x&&!M.destroyed)||null,getSceneLayerById:x=>b.layers.find(M=>M.id===x&&!M.destroyed)||null,enumerateSceneLayers:()=>b.layers.filter(x=>!x.destroyed),getSceneAnimation:x=>{if(x==null||x==="")return null;if(_e[x])return _e[x];for(const M of b.layers)if(M.animations&&M.animations[x])return M.animations[x];return null},cameraTransforms:b.cameraTransforms,getInitialLayerConfig:x=>{const M=x&&typeof x=="object"?x.name:String(x||"");return b.layers.find(E=>E.name===M)||null},createSceneLayer:x=>{let M=x&&typeof x=="object"?x:null;if(typeof x=="string"){const P=x;if(M=b.layers.find(R=>R&&!R.destroyed&&R.image===P&&R.textureName)||b.layers.find(R=>R&&!R.destroyed&&R.image===P)||null,!M)return ae(e,n,`createLayer('${P}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}M||(M={});const E={...M,id:ne++,origin:Array.isArray(M.origin)?M.origin.slice():[0,0,0],scale:Array.isArray(M.scale)?M.scale.slice():[1,1,1],angles:Array.isArray(M.angles)?M.angles.slice():[0,0,0],size:Array.isArray(M.size)?M.size.slice():[0,0],color:Array.isArray(M.color)?M.color.slice():[1,1,1],childIds:null,hasChildren:!1,destroyed:!1,animations:{},animationList:[],objectScripts:null};return delete E.textureAnimation,delete E.videoTextureApi,delete E.soundCtl,delete E.videoCtl,Array.isArray(M.effects)&&(E.effects=M.effects.map(P=>({...P,passes:Array.isArray(P.passes)?P.passes.map(R=>({...R})):P.passes}))),b.layers.push(E),E},mediaControl:Ve,windowTitle:G.snapshot,openUserShortcut:Q.openUserShortcut,isScreensaver:!1};N.setConstantScriptRuntime?.(qe.evalObjectScript,{userProperties:U,audioViews:K,shared:Qt,inputView:rt,timers:Xe,...Y,onSandbox:x=>{x&&x.hasMediaHook&&xe(x)}});for(const x of b.layers){const M=x.objectAnimations;if(M){x.animations=x.animations||{},x.animationList=x.animationList||[];for(const[E,P]of Object.entries(M))try{const R=Fi.createAnimation(P.animation);R.field=E,R.baseValue=P.value;const B=x[E];R.baseNumeric=Array.isArray(B)?B.slice():B,x.animationList.push(R),R.name&&(x.animations[R.name]=R),Wt.push({layer:x,field:E,ctrl:R})}catch(R){ae(e,n,`animation '${x.name}.${E}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(R.message).slice(0,80)}`)}}}for(const x of b.layers){for(const[E,P]of(x.effects||[]).entries()){const R=P.visibleScript;if(R)try{const B=qe.evalObjectScript(R.script,R.scriptproperties,{canvasSize:{width:L,height:I},userProperties:U,audioViews:K,inputView:rt,...Pe,layer:x,targetEffect:P,...Y,shared:Qt,onError:z=>ae(e,n,`effect visible script '${x.name}#${E}' \u5931\u8D25: ${String(z.message||z).slice(0,80)}`)});if(!B)continue;_.push(B),B.init(P.visible),B.applyUserProperties(U),B.hasMediaHook&&xe(B),B.hasUpdate&&Pt.push({effect:P,sandbox:B})}catch(B){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${x.name}#${E} \u6C42\u503C\u5931\u8D25: ${B.message}`)}}const M=x.objectScripts;if(M)for(const[E,P]of Object.entries(M))try{const R=qe.evalObjectScript(P.script,P.scriptproperties,{canvasSize:{width:L,height:I},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const B=new Date;return(B.getHours()*3600+B.getMinutes()*60+B.getSeconds())/86400})(),userProperties:U,audioViews:K,inputView:rt,layer:x,...Y,getBoneOverrides:gr,shared:Qt,...Pe,onError:B=>ae(e,n,`object script '${x.name}.${E}' \u5931\u8D25: ${String(B.message||B).slice(0,90)}`)});if(R){_.push(R);const B=x[E],z=E==="angles"&&Array.isArray(B)?qe.radToScriptAngles(B):Array.isArray(B)?{x:B[0]??0,y:B[1]??0,z:B[2]??0}:B;R.init(z),R.applyUserProperties(U),br(x,R),R.hasMediaHook&&xe(R),R.hasUpdate&&jt.push({layer:x,field:E,kind:E==="visible"?"bool":E==="alpha"||E==="brightness"?"scalar":"vec3",sandbox:R})}}catch(R){console.warn(`\u5BF9\u8C61\u811A\u672C ${x.name}.${E} \u6C42\u503C\u5931\u8D25: ${R.message}`)}}const f=b.generalScripts;if(f){for(const[x,M]of Object.entries(f))try{const E=qe.evalObjectScript(M.script,M.scriptproperties,{canvasSize:{width:L,height:I},userProperties:U,audioViews:K,inputView:rt,...Pe,...Y,shared:Qt,onError:R=>ae(e,n,`general script '${x}' \u5931\u8D25: ${String(R.message||R).slice(0,80)}`)});if(!E)continue;_.push(E),E.init(M.value),E.applyUserProperties(U),E.hasMediaHook&&xe(E);const P=R=>X(x,R);E.hasUpdate&&Jt.push({field:x,sandbox:E,write:P})}catch(E){console.warn(`general \u811A\u672C ${x} \u6C42\u503C\u5931\u8D25: ${E.message}`)}Jt.length&&ae(e,n,`general scripts: ${Jt.map(x=>x.field).join(",")}`)}const T=b.generalAnimations;if(T){for(const[x,M]of Object.entries(T))try{const E=Fi.createAnimation(M.animation);E.field=x,E.baseValue=M.value,E.baseNumeric=M.value,E.name&&(_e[E.name]=E),ft.push({field:x,ctrl:E,write:P=>X(x,P)})}catch(E){ae(e,n,`general animation '${x}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(E.message).slice(0,80)}`)}ft.length&&ae(e,n,`general animations: ${ft.map(x=>x.field).join(",")}`)}}jt.length&&(ae(e,n,`object scripts: ${jt.length}`),window.__objScripts=jt),window.__mediaHooks=te,window.__compositeStats=()=>N.compositeStats?.()??null,window.__compositeEnable=A=>N.setCompositeEnabled?.(A),window.__scene=b,window.__textures=Ae;const yt=Array.from(Je.keys());yt.length&&ae(e,n,`cursor hooks: ${yt.length} layers`);let Vt=null,Xt=null,jn=!1;const vr=()=>({worldPosition:qe.makeCursorEventVec(Ee.state.wx,Ee.state.originY!=null?Ee.state.originY:Ee.state.wy,0)}),xt=(A,L,I)=>{const U=Je.get(A);if(U)for(const X of U)X.callCursor(L,I)},yr=()=>{if(yt.length===0)return;const A=Ee.state;if(!A.has)return;const L=N.getParallaxOffset?N.getParallaxOffset():{x:0,y:0},I=b.general?.orthogonalprojection?.height||t.height,U=zc.hitTestLayers(b.layers,A.wx,A.wy,I,{parOffX:L.x,parOffY:L.y,alignTable:ke.ALIGN,filter:ne=>Je.has(ne)}),X=vr();U!==Vt&&(Vt&&xt(Vt,"cursorLeave",X),Vt=U,U&&xt(U,"cursorEnter",X)),U&&xt(U,"cursorMove",X),A.leftDown&&!jn?(Xt=U,U&&xt(U,"cursorDown",X)):!A.leftDown&&jn&&(Xt&&xt(Xt,"cursorUp",X),Xt&&Xt===U&&xt(U,"cursorClick",X),Xt=null),jn=A.leftDown},mn=performance.now();let pn=0,Ce=0;const dt=[],Ct=[];let gn=-1/0;const Wn=A=>{if(s||e.paused)return;const I=1e3/(e.cfg.sceneFps||60);if(A-gn>=I){if(gn=A,io(e,A),e.onFirstFrame){const f=e.onFirstFrame;e.onFirstFrame=void 0,f()}ao(e,t,e.cfg);const U=(A-mn-pn)/1e3;if(rt.update(Ee.state),q.enabled){V.update(U);const f=St.diffMediaEvents(me,V.snapshot);if(f.length){for(const{name:T,event:x}of f)for(const M of te)M.disabled||M.callMedia(T,x);me=St.cloneMediaSnapshot(V.snapshot)}}G.update(U);for(const f of Wt){f.ctrl.advance(I/1e3);const T=f.field,x=f.ctrl.applyTo(f.ctrl.baseNumeric);if(Array.isArray(x)){const M=f.layer[T];if(Array.isArray(M))for(let E=0;E<x.length&&E<M.length;E++)M[E]=x[E]}else Number.isFinite(x)&&(T==="visible"?f.layer[T]=!!x:f.layer[T]=x)}for(const f of ft){f.ctrl.advance(I/1e3);const T=f.ctrl.applyTo(f.ctrl.baseNumeric);typeof T=="number"&&Number.isFinite(T)?f.write(T):Array.isArray(T)&&Number.isFinite(T[0])&&f.write(T[0])}for(const f of Pt){if(f.sandbox.disabled)continue;f.sandbox.engine.frametime=I/1e3,f.sandbox.engine.runtime=U;const T=f.sandbox.callUpdate(!!f.effect.visible);typeof T=="boolean"&&(f.effect.visible=T)}for(const f of Jt){if(f.sandbox.disabled)continue;f.sandbox.engine.frametime=I/1e3,f.sandbox.engine.runtime=U;const T=b.general||{},x=T[f.field]&&typeof T[f.field]=="object"&&"value"in T[f.field]?T[f.field].value:T[f.field],M=f.sandbox.callUpdate(x);M!==void 0&&f.write(M)}const X={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};let ne=!1;for(const f of jt){if(f.sandbox.disabled)continue;f.sandbox.engine.frametime=I/1e3,f.sandbox.engine.runtime=U,f.sandbox.engine.screenResolution=X;const T=f.layer[f.field];if(f.kind==="bool"){const x=f.sandbox.callUpdate(!!T);typeof x=="boolean"&&(f.field==="visible"?f.layer.visibleSelf!==x&&(f.layer.visibleSelf=x,ne=!0):f.layer[f.field]=x)}else if(f.kind==="scalar"){const x=f.sandbox.callUpdate(Number(T)||0),M=Number(x);Number.isFinite(M)&&(f.layer[f.field]=M)}else{const x=f.field==="angles"?qe.radToScriptAngles(T):{x:T[0]||0,y:T[1]||0,z:T[2]||0},M=f.sandbox.callUpdate(x),E=M&&typeof M=="object"&&"x"in M?M:x;f.layer[f.field]=f.field==="angles"?qe.scriptAnglesToRad(E):[E.x||0,E.y||0,E.z||0]}}ne&&S(),O.enabled&&(k.update(U),_c(K,k.snapshot)),hn.length&&Nn.followAttachments(hn,U,gr);const Y=e.coverAlign;N.render(b,Ae,t.width,t.height,U,qt(e.cfg.fit),Y.x,Y.y).then(()=>{if(!(s||e.paused)){try{yr()}catch{}Ee.beginFrame();try{e.sceneTextUpdate&&A>=$n&&($n=A+100,e.sceneTextUpdate(U))}catch{}e.raf=requestAnimationFrame(Wn)}}).catch(f=>{console.warn("scene render error:",f),ae(e,n,`render: ${String(f.message||f).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(Wn))},Vn=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(Wn))},Ht=A=>{if(s)return;const L=b.properties||{},I=ys(L,y,A);if(Object.keys(I).length){for(const U of b.layers){const X=U.srcObject;if(!X)continue;nn(X,L,0);const ne=pt(X.visible);ne&&ne in I&&(U.visibleSelf=Qe.parseBool(X.visible,!0));const Y=pt(X.color);Y&&Y in I&&(U.color=Qe.parseColor(X.color),U.isText&&(U.textColor=U.color));const f=pt(X.alpha);f&&f in I&&(U.alpha=Qe.parseNum(X.alpha,1));const T=pt(X.brightness);T&&T in I&&(U.brightness=Qe.parseNum(X.brightness,1));const x=pt(X.volume);if(x&&x in I){const E=Qe.parseNum(X.volume,1);U.soundprops&&(U.soundprops.volume=E),U.soundCtl?.setVolume?.(E)}for(let E=0;E<(X.animationlayers||[]).length;E++){const P=X.animationlayers[E],R=U.animationLayers?.[E];if(!P||!R)continue;const B=pt(P.visible);B&&B in I&&(R.visible=Qe.parseBool(P.visible,!0));const z=pt(P.rate);z&&z in I&&(R.rate=Qe.parseNum(P.rate,1));const $=pt(P.blend);$&&$ in I&&(R.blend=Qe.parseNum(P.blend,1))}for(let E=0;E<(X.effects||[]).length;E++){const P=X.effects[E],R=U.effects?.[E];if(!P||!R)continue;const B=pt(P.visible);B&&B in I&&!R.visibleScript&&(R.visible=Qe.parseBool(P.visible,!0))}const M=X.instanceoverride;if(M&&typeof M=="object"&&U.particle){let E=!1;for(const P of Object.keys(M)){if(P==="id")continue;const R=pt(M[P]);if(R&&R in I){E=!0;break}}if(E){const P=Et.get(U.id);if(P)for(const R of P)R.reapplyOverride?.()}}}for(const U of _)if(!(!U||U.disabled))try{U.applyUserProperties(I)}catch{}S();for(const U of b.layers){if(!U.particle)continue;const X=Et.get(U.id);if(X)for(const ne of X)ne.setVisible(!!U.visible)}N.applyConstUserProperties?.(I);for(const U of ut)U.lastKey=null;ae(e,n,`props hot: ${Object.keys(I).join(",")}`)}};d=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),Ce||(Ce=performance.now()),dt.length=0;for(const A of Ae.values())A?.videoCtl?.isPlaying?.()&&(dt.push(A.videoCtl),A.videoCtl.pause());Ct.length=0;for(const A of fn)!A.paused&&!A.ended&&(Ct.push(A),A.pause())},h=()=>{Ce&&(pn+=performance.now()-Ce,Ce=0),we=performance.now();for(const A of dt)try{A.play()}catch{}dt.length=0;for(const A of Ct)A.play().catch(()=>{});Ct.length=0,Vn()},l=Ht,u&&(Ht(u),u=null),Vn();{const A=b.general?.orthogonalprojection,L=A?.width||t.width,I=A?.height||t.height,U=qt(e.cfg.fit),X=Rr(U,L,I,t.width,t.height);ae(e,n,`fit ${U}: view ${Math.round(X.viewW)}x${Math.round(X.viewH)} scene ${L}x${I} canvas ${t.width}x${t.height}`)}ae(e,n,`renderer started: ${b.layers.length} layers`)}catch(p){if(s||p&&p.name==="AbortError")return;console.warn("scene render failed:",p);const w=p instanceof Error?p:new Error(String(p));ae(e,n,`failed: ${String(w.message||w).slice(0,200)}`),e.onError?e.onError(w):e.fallbackPage?.()}})()}function dr(e,n){(n.type==="video"||n.type==="gif"||n.type==="image")&&n.src?Wc(e,n):n.type==="scene"&&(n.source||n.src)?nl(e,n):e.onUnhandledType?.(n)}function rl(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function ol(e,n){return{type:"scene",canvas:e,source:n.source,fit:rl(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0}}function $i(e,n){const t=Vi(),r={ready:[],error:[],diagnostic:[]};let o={...n??{},source:null};const i=d=>{for(const h of r.error)try{h(d)}catch{}},s=d=>{t.onDiagnostic=(h,p)=>{try{d.onDiagnostic?.(h,p)}catch{}for(const w of r.diagnostic)try{w(h,p)}catch{}},t.onError=h=>{try{d.onError?.(h)}catch{}i(h)},t.onSceneInfo=h=>{t.info=h}},c=()=>new Promise(d=>{const h=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,h?.(),d()}}),a=()=>{let d=()=>{};return{promise:new Promise((p,w)=>{d=u.on("error",m=>w(m))}),off:d}},u={canvas:e,pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,so(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(d){t.cfg.fit=d,Mr(t)},setFps(d){t.cfg.sceneFps=d},setVolume(d){const h=Math.max(0,Math.min(1,d));t.cfg.muted=h<=0,t.sceneAudio?.setVolume(h)},setRenderDpr(d){t.cfg.renderDpr=d,dr(t,t.cfg)},setProperties(d){const h={};for(const[p,w]of Object.entries(d))h[p]={value:w};t.sceneCtl?.applyUserProperties(h)},getProperties(){return{...t.liveUserProps??{}}},async load(d){o={...o,source:d},s(o);const h={...t.cfg,type:"scene",source:d,src:void 0,mediaBase:void 0};t.cfg=h,t.paused=!1,t.info=void 0,Mr(t);const p=c(),w=a();dr(t,h);try{await Promise.race([p,w.promise])}finally{w.off()}},release(){tn(t)},restore(){dr(t,t.cfg)},destroy(){Xi(t),t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,r.ready.length=0,r.error.length=0,r.diagnostic.length=0},get stats(){return Gi(t)},get info(){return t.info??null},on(d,h){const p=r[d];return p.push(h),()=>{const w=p.indexOf(h);w>=0&&p.splice(w,1)}}},l=async d=>{o=d,s(d),t.cfg=ol(e,d),t.paused=d.autoplay===!1,t.info=void 0,Mr(t);const h=c(),p=a();dr(t,t.cfg);try{await Promise.race([h,p.promise])}finally{p.off()}(d.volume??0)>0&&u.setVolume(d.volume),d.properties&&Object.keys(d.properties).length&&u.setProperties(d.properties)};return u.__applyOptions=l,u}async function il(e,n){const t=$i(e,n);return await t.__applyOptions(n),t}et.bytesSource=Yc,et.createScene=$i,et.fileSource=Gc,et.httpSource=Ni,et.mount=il,Object.defineProperty(et,Symbol.toStringTag,{value:"Module"})})});ll();})();
510
+ `};function xl(e){if(!e||e.length<12)return e;const n=e[0],t=e[1],o=e[2],r=e[3];if(!(n===0&&t===1&&o===0&&r===0)&&!(n===79&&t===84&&o===84&&r===79))return e;const c=Uint8Array.from(e),a=new DataView(c.buffer,c.byteOffset,c.byteLength),f=a.getUint16(4);if(f<=0||12+f*16>c.length)return e;let l=-1,d=0,h=0;for(let b=0;b<f;b++){const p=12+b*16;if(String.fromCharCode(c[p],c[p+1],c[p+2],c[p+3])==="cmap"){l=p,d=a.getUint32(p+8),h=a.getUint32(p+12);break}}if(l<0||d+h>c.length)return e;let m=!1;const M=a.getUint16(d+2);for(let b=0;b<M;b++){const p=d+4+b*8,v=a.getUint32(p+4),_=d+v;if(_+14>c.length||a.getUint16(_)!==4)continue;const w=a.getUint16(_+6),L=w>>>1;if(L<1)continue;const F=2*Math.pow(2,Math.floor(Math.log2(L))),D=Math.floor(Math.log2(L)),B=w-F,z=a.getUint16(_+8),V=a.getUint16(_+10),Y=a.getUint16(_+12);z===F&&V===D&&Y===B||(a.setUint16(_+8,F),a.setUint16(_+10,D),a.setUint16(_+12,B),m=!0)}if(!m)return e;let g=0;const y=d+h;for(let b=d;b<y;b+=4){const p=c[b]||0,v=b+1<y?c[b+1]:0,_=b+2<y?c[b+2]:0,w=b+3<y?c[b+3]:0;g=g+(p<<24|v<<16|_<<8|w)>>>0}return a.setUint32(l+4,g),c}const wl={systemfont_segoe:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",systemfont_arial:"Arial, 'Helvetica Neue', sans-serif",systemfont_verdana:"Verdana, Geneva, sans-serif",systemfont_tahoma:"Tahoma, Geneva, sans-serif",systemfont_timesnewroman:"'Times New Roman', Times, serif",systemfont_georgia:"Georgia, 'Times New Roman', serif",systemfont_couriernew:"'Courier New', Courier, monospace",systemfont_trebuchetms:"'Trebuchet MS', 'Helvetica Neue', sans-serif",systemfont_impact:"Impact, 'Arial Black', sans-serif",systemfont_comicsansms:"'Comic Sans MS', 'Comic Sans', cursive",systemfont_sylfaen:"Palatino, 'Times New Roman', serif",systemfont_calibri:"Calibri, Carlito, 'Helvetica Neue', sans-serif",systemfont_cambria:"Cambria, Georgia, serif",systemfont_consolas:"Consolas, 'Courier New', monospace",systemfont_microsoftyahei:"'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif",systemfont_simsun:"SimSun, 'Songti SC', serif",systemfont_simhei:"SimHei, 'Heiti SC', sans-serif"},Zi=new Map,In=new Map;async function Ml(e,n,t,o){const r=t.key;if(r){const a=In.get(r);if(a)return a.at=Date.now(),re(e,n,`pkg cache hit: ${a.parsed.fileSize} bytes`),a.parsed}let i;try{i=await t.scenePkg(o)}catch(a){throw o.aborted||a instanceof Error?a:new Error(String(a))}re(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),c=je.parsePkg(s);if(!r)return c;if(In.set(r,{parsed:c,at:Date.now()}),In.size>2){let a=null,f=1/0;for(const[l,d]of In)l!==r&&d.at<f&&(f=d.at,a=l);a&&In.delete(a)}return c}function Al(e,n){en(e);const t=n.canvas??document.createElement("canvas"),o=We(e,n),r=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(r*o)),t.height=Math.max(1,Math.round(i*o)),n.canvas||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const c=new AbortController;let a;e.sceneCleanup=()=>{s=!0,c.abort(),e.sceneTextUpdate=void 0,a&&(a(),a=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let f=null,l,d,h;e.sceneCtl={pause(){d?.()},resume(){h?.()},applyUserProperties(m){l?l(m):f={...f||{},...m}}},(async()=>{try{const m=n.source??ji(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");re(e,n,"mountScene start");const M=await Ml(e,n,m,c.signal);if(s)return;let g=null;try{g=await m.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const b=je.getEntry(M,"scene.json");if(!b)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const p=Qe.parseScene(JSON.parse(ct(b)),g);{const T=p.general?.zoom,u=Number(T&&typeof T=="object"?T.value:T);p.cameraTransforms={zoom:Number.isFinite(u)&&u>0?u:1}}const v=Ps(p.properties||{});e.liveUserProps=v;const _=()=>Qe.recomputeLayerVisibility(p.layers);if(e.onSceneInfo){const T=p.general?.orthogonalprojection||{},u=Number(T.width)>0?Number(T.width):t.width,x=Number(T.height)>0?Number(T.height):t.height,S=p.layers||[],P={width:u,height:x,layerCount:S.length,hasModels:S.some(N=>!!N.model),hasParticles:S.some(N=>!!N.particle),hasText:S.some(N=>!!N.text)},I=e.onSceneInfo;e.onSceneInfo=void 0,I(P)}const w=[];Xi&&(p.layers=p.layers.filter(T=>!(Xi&&T.isComponent)));const L=T=>{const u=T.startsWith("shaders/")?T:"shaders/"+T,x=T.startsWith("shaders/")?T.slice(8):T,S=je.getEntry(M,u);let P=S?ct(S):vl[x]??null;const I=window.__shaderPatch;if(P&&I){const N=x.replace(/\.(frag|vert|h)$/,""),E=I[N]||I[x];if(typeof E=="function")try{const $=E(P,x);typeof $=="string"&&(P=$)}catch{}}return Promise.resolve(P)},F=Be.createRenderer(t,{shaderResolver:L,diag:T=>re(e,n,`renderer: ${T}`),fboCapFactor:0});if(e.renderer=F,s)return;const D=g?.general?.supportsaudioprocessing!==!1,B=Nc(),z=ve.createSimulatedMedia(),V=$i.createSimulatedWindowTitle();let Y=null;const Z={mediaDriver:null,lastSnap:{get:()=>null,setHasThumbnail:()=>{}}},X={current:null};let q=z,oe=V;const H={enabled:D},j=T=>new Float32Array(T),ee={left16:j(16),right16:j(16),left32:j(32),right32:j(32),left64:j(64),right64:j(64),level:0,silent:!0};F.setAudioProvider(()=>H.enabled?X.current?X.current.snapshot:B.snapshot:ee);const le=new Map;window.__audioStats=()=>({enabled:H.enabled,live:!!X.current,level:H.enabled?Math.round((X.current?X.current.snapshot:B.snapshot).level*1e3)/1e3:0,silent:H.enabled?(X.current?X.current.snapshot:B.snapshot).silent:!0,bass:H.enabled?Math.round((X.current?X.current.snapshot:B.snapshot).left64[2]*1e3)/1e3:0}),window.__audioMute=T=>(H.enabled=!T,H.enabled),re(e,n,`audio: ${X.current?"live mic":"simulated"} stream, supportsaudioprocessing=${D}`);const Se=$i.createShortcutHandler(T=>{re(e,n,`openUserShortcut: ${T}`)}),Xe={enabled:!0,override:null},Le=[];let Pe=null;Z.lastSnap={get:()=>Pe,setHasThumbnail:T=>{Pe&&(Pe.hasThumbnail=T)}};const ue=()=>q.snapshot,Fe=T=>{if(!(!T||!T.hasMediaHook||Le.includes(T))&&(Le.push(T),!!ue().hasMedia))for(const{name:u,event:x}of ve.diffMediaEvents(null,ue()))try{T.callMedia(u,x)}catch{}};window.__mediaStats=()=>({enabled:Xe.enabled,live:!!Y,hooks:Le.length,title:ue().title,artist:ue().artist,album:ue().album,state:ue().state,position:Math.round(ue().position),duration:ue().duration,hasThumbnail:ue().hasThumbnail,lyric:ue().lyricLine,primaryColor:ue().primaryColor?[ue().primaryColor.x,ue().primaryColor.y,ue().primaryColor.z]:null}),window.__mediaSet=T=>{Object.assign(ue(),T||{});const u=ve.diffMediaEvents(Pe,ue());for(const{name:x,event:S}of u)for(const P of Le)P.callMedia(x,S);return Pe=ve.cloneMediaSnapshot(ue()),window.__mediaStats()};const Je=()=>{const T=ve.diffMediaEvents(Pe,ue());for(const{name:u,event:x}of T)for(const S of Le)try{S.callMedia(u,x)}catch{}Pe=ve.cloneMediaSnapshot(ue())},Ee={get snapshot(){return ue()},skipNext:()=>(q.skipNext(),Je(),ue()),skipPrevious:()=>(q.skipPrevious(),Je(),ue()),play:()=>(q.play(),Je(),ue()),pause:()=>(q.pause(),Je(),ue()),playPause:()=>(q.playPause(),Je(),ue())};window.__mediaControl=Ee,window.__system={media:Ee,windowTitle:oe.snapshot,shortcuts:Se.last,live:null},window.__liveSystem=()=>({audio:"off",media:"offline",window:"offline"});const xe=Zc.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});F.setPointerProvider(()=>xe);{const T=a;a=()=>{T?.(),xe.dispose()}}const Ne=He.createInputView(),we=qc.createEngineTimers({setTimeout:(T,u)=>window.setTimeout(T,u),clearTimeout:T=>window.clearTimeout(T),setInterval:(T,u)=>window.setInterval(T,u),clearInterval:T=>window.clearInterval(T)},{onError:(()=>{let T=!1;return u=>{T||(T=!0,re(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(u?.message||u).slice(0,90)}`))}})()}),Ge={setTimeout:we.setTimeout,clearTimeout:we.clearTimeout,setInterval:we.setInterval,clearInterval:we.clearInterval};{const T=a;a=()=>{T?.(),we.dispose()}}window.__pointerStats=()=>{const T=xe.state,u=x=>Math.round(x*1e3)/1e3;return{normalized:{u:u(T.u),v:u(T.v)},last:{u:u(T.lastU),v:u(T.lastV)},world:{x:Math.round(T.wx),y:Math.round(T.wy)},originY:T.originY!=null?Math.round(T.originY):null,screen:{x:T.screenX,y:T.screenY,w:T.screenW,h:T.screenH},leftDown:T.leftDown,has:T.has,delta:u(xe.normalizedDelta()),counts:{move:T.moveCount,down:T.downCount,up:T.upCount}}};const fe=new Map;fe.set("util/white",{glTex:Be.makeTexture(F.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),fe.set("util/noflow",{glTex:Be.makeTexture(F.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),fe.set("util/noise",{glTex:Be.makeTexture(F.gl,Gc.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const T=x=>{const S=ve.renderThumbnail(x,512);return{glTex:Be.makeTextureMip(F.gl,[S],!1),width:S.width,height:S.height,rg88:!1,mips:[S],generated:!0}},u=z.tracks||[];u.length&&(fe.set("$mediaThumbnail",T(u[0])),fe.set("$mediaPreviousThumbnail",T(u[u.length-1])))}if(n.liveSystem)try{const T=async x=>{try{const S=await fetch(x.url,{cache:"no-store"});if(!S.ok)return;const P=await S.blob(),I=await createImageBitmap(P),N=pl(I,I.width,I.height,512),E=ml(I,I.width,I.height);I.close?.();const $=fe.get("$mediaThumbnail");$&&fe.set("$mediaPreviousThumbnail",$);const A=F.gl,R=fe.get("$mediaThumbnail");R?.glTex?(A.bindTexture(A.TEXTURE_2D,R.glTex),A.texImage2D(A.TEXTURE_2D,0,A.RGBA,N.width,N.height,0,A.RGBA,A.UNSIGNED_BYTE,N.rgba),R.width=N.width,R.height=N.height,R.mips=[N]):fe.set("$mediaThumbnail",{glTex:Be.makeTextureMip(A,[N],!1),width:N.width,height:N.height,rg88:!1,mips:[N],generated:!0});const C=q.snapshot;E&&(C.primaryColor=ve.mediaVec3(...E.primary),C.secondaryColor=ve.mediaVec3(...E.secondary),C.tertiaryColor=ve.mediaVec3(...E.tertiary),C.textColor=ve.mediaVec3(.98,.98,1),C.highContrastColor=ve.mediaVec3(1,1,1)),C.hasThumbnail=!0,Z.lastSnap.setHasThumbnail(!1),re(e,n,`liveSystem: artwork ${x.title||x.trackKey}`)}catch(S){re(e,n,`liveSystem: artwork \u5931\u8D25 (${S instanceof Error?S.message:S})`)}};if(Y=await yl({origin:location.origin,onArtwork:x=>{T(x)}}),q=Y.media,oe=Y.windowTitle,Z.mediaDriver=Y.media,Y.status().audio==="mic"&&(X.current=Y.audio),q.snapshot.hasMedia){for(const{name:x,event:S}of ve.diffMediaEvents(null,q.snapshot))for(const P of Le)try{P.callMedia(x,S)}catch{}Pe=ve.cloneMediaSnapshot(q.snapshot)}const u=Y.status();re(e,n,`liveSystem: audio=${u.audio} media=${u.media} window=${u.window}`+(u.title?` title="${u.title}"`:"")+(u.hasArtwork?" artwork=1":"")),re(e,n,`audio: ${X.current?"live mic":"simulated"} stream, supportsaudioprocessing=${D}`),window.__system={media:Ee,windowTitle:oe.snapshot,shortcuts:Se.last,live:()=>Y.status()},window.__liveSystem=()=>Y.status()}catch(T){re(e,n,`liveSystem: \u542F\u52A8\u5931\u8D25\uFF0C\u56DE\u9000\u6A21\u62DF\u6E90 (${T instanceof Error?T.message:T})`),Y=null}{const T=a;a=()=>{T?.(),Y?.dispose(),Y=null}}const Ye=new Map,$t=async T=>{if(fe.has(T))return fe.get(T);const u=je.getEntry(M,`materials/${T}.tex`);if(!u){if(Yt.isBuiltinParticleTextureName(T)){const N=Yt.buildBuiltinParticleTexture(T);if(N){const E={glTex:Be.makeTextureMip(F.gl,[N],!1),width:N.width,height:N.height,rg88:!1,mips:[N],generated:!0};return fe.set(T,E),E}}return null}const x=dr.parseTex(u),S=dr.decodeMip0(x),P=x.format===8;let I=null;if(S.video!==void 0){const N=URL.createObjectURL(new Blob([S.video],{type:"video/mp4"})),E=al(N,{muted:!0,renderDpr:We(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const U of[E.active,E.standby])U.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(U),(e.videoTextures??=[]).push(U);(e.objectUrls??=[]).push(N),(e.videoPairs??=[]).push(E),E.active.addEventListener("loadedmetadata",()=>{re(e,n,`video tex '${T}': ${E.active.videoWidth}x${E.active.videoHeight}`)}),E.active.addEventListener("error",()=>{re(e,n,`video tex '${T}' ERROR: ${E.active.error?.code}`)});const $=[],A=U=>{for(const W of $)U.addEventListener("ended",W)},R={play:()=>{s||E.resume()},pause:()=>E.pause(),stop:()=>{E.pause();try{E.active.currentTime=0}catch{}},isPlaying:()=>!E.active.paused&&!E.active.ended,duration:()=>Number.isFinite(E.active.duration)?E.active.duration:0,getCurrentTime:()=>E.active.currentTime||0,setCurrentTime:U=>{try{E.active.currentTime=U}catch{}},getRate:()=>E.active.playbackRate||1,setRate:U=>{E.active.playbackRate=U,E.standby.playbackRate=U},getLoop:()=>E.active.loop,setLoop:U=>{E.active.loop=U,E.standby.loop=U},addEndedCallback:U=>{$.push(U),E.active.addEventListener("ended",U)}},C={get video(){return E.active},glTex:Be.makeTexture(F.gl,new Uint8Array([0,0,0,0]),1,1),width:S.width,height:S.height,rg88:!1,lastUploaded:-1,videoCtl:R};let k=0;return E.onSwap=U=>{C.lastUploaded=-1,A(U),k++,(k===1||k===10||k===100)&&re(e,n,`video tex '${T}' loop swap ok x${k}`)},E.onFallback=()=>{re(e,n,`video tex '${T}' loop fallback (native loop used)`)},fe.set(T,C),C}else if(S.png!==void 0||S.image!==void 0&&S.fif===dr.FIF.JPEG){const N=new Blob([S.png||S.image],{type:S.png?"image/png":"image/jpeg"}),E=await createImageBitmap(N);I={glTex:Be.makeTexture(F.gl,null,0,0,E),width:E.width,height:E.height,rg88:P}}else{if(S.image!==void 0)return null;{const N=dr.decodeMip0(x);I={glTex:Be.makeTextureMip(F.gl,[N],P),width:N.width,height:N.height,rg88:P,mips:[N]}}}if(!I)return null;if(x.frames?.list?.length){const N=x.frames.list;N.atlasWidth=I.width,N.atlasHeight=I.height,I.frames=N}return fe.set(T,I),I},et=T=>{if(fe.has(T))return Promise.resolve(fe.get(T));const u=Ye.get(T);if(u)return u;const x=$t(T);return Ye.set(T,x),x.finally(()=>{Ye.get(T)===x&&Ye.delete(T)}),x},qt=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,pr=async T=>{for(const u of T.materialPasses||[])if(u.shader)for(const x of["frag","vert"]){const S=je.getEntry(M,`shaders/${u.shader}.${x}`);if(!S)continue;const P=ct(S);qt.lastIndex=0;let I;for(;(I=qt.exec(P))!==null;){const N=I[1];!N||N.startsWith("util/")||N.startsWith("_rt_")||fe.has(N)||await et(N)}}};let Bn=0;const Zt=[];for(let T=0;T<p.layers.length;T++){const u=p.layers[T];if(u.image)try{let x;if(vt.BUILTIN_MODELS[u.image])x=vt.BUILTIN_MODELS[u.image];else{const C=je.getEntry(M,u.image);if(!C)continue;x=JSON.parse(ct(C))}Qe.applySolidFromModel(u,x);const S=u.srcObject?.instance?.usertextures,P=S?.[0]&&typeof S[0].name=="string"&&S[0].name.startsWith("$")?S[0].name:null,I=P&&fe.has(P)?P:null;if(I&&(u.textureName=I,u.solid=!1),x&&typeof x=="object"&&"width"in x&&"height"in x){const C=x;(u.size?.[0]||0)===0&&(u.size?.[1]||0)===0&&C.width>0&&C.height>0&&(u.size=[C.width,C.height])}const N=Qe.resolveMaterial(x);if(!N)continue;let E;if(vt.BUILTIN_MATERIALS[N.materialPath])E=vt.BUILTIN_MATERIALS[N.materialPath];else{const C=je.getEntry(M,N.materialPath);if(C)E=JSON.parse(ct(C));else if(u.solid&&vt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])E=vt.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const $=E.passes?.[0],A=$?.textures||[],R=A[0];if($?.combos){for(const C of Object.keys($.combos))if(C.toLowerCase()==="spritesheet"&&Number($.combos[C])===1){u.spriteSheet=!0;break}}for(let C=0;C<A.length;C++){const k=A[C];typeof k!="string"||!k||k.startsWith("util/")||k.startsWith("_rt_")||Zt.push(et(k).then(U=>{U&&C===0&&!I&&(u.textureName=k,Bn++,U.videoCtl&&(u.videoCtl=U.videoCtl))}))}$?.shader&&je.getEntry(M,`shaders/${$.shader}.frag`)&&vt.attachLayerMaterialEffect(u,$);for(const C of u.effects||[])vt.resolveEffectChain(M,C,ct);for(const C of u.effects||[]){for(const k of C.passes||[])for(const U of k.textures||[])typeof U=="string"&&U!==""&&!U.startsWith("util/")&&!U.startsWith("_rt_")&&Zt.push(et(U));Zt.push(pr(C))}}catch(x){console.warn(`\u56FE\u5C42 ${u.name||T} \u52A0\u8F7D\u5931\u8D25: ${x.message}`)}}if(!Gi){for(const T of p.layers)if(!(!T.isText||!(T.effects||[]).length))try{for(const u of T.effects||[])vt.resolveEffectChain(M,u,ct);for(const u of T.effects||[])for(const x of u.passes||[])for(const S of x.textures||[])typeof S=="string"&&S!==""&&!S.startsWith("util/")&&!S.startsWith("_rt_")&&Zt.push(et(S))}catch(u){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${T.name} \u89E3\u6790\u5931\u8D25: ${u.message}`)}}await Promise.all(Zt);for(const[T,u]of fe){if(!u?.videoCtl)continue;p.layers.some(S=>S.textureName===T&&S.visible&&!S.destroyed)&&!e.paused&&u.videoCtl.play()}const qe=[],zt=new Map;let ye=0;const ln=async T=>{const u=await et(T);if(u)return u;const x=Yt.buildBuiltinParticleTexture(T);if(!x)return null;const S={glTex:Be.makeTextureMip(F.gl,[x],!1),width:x.width,height:x.height,rg88:!1,mips:[x],generated:!0,frames:Yt.builtinParticleFrames(T)??void 0};return fe.set(T,S),ye++,S},gr=T=>{if(!T)return null;const u=T.mips&&T.mips[0];if(u?.rgba&&typeof Yt.prepareParticleNormalTexture=="function"){const x=Yt.prepareParticleNormalTexture(u);if(x&&x!==u)return{glTex:Be.makeTextureMip(F.gl,[x],!1),width:x.width,height:x.height,rg88:!1,mips:[x],generated:!0}}return T},br=async(T,u,x,S)=>{if(S>3)return null;const P=je.getEntry(M,T);if(!P)return re(e,n,`particle '${T}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const I=JSON.parse(ct(P)),N=new Yc.ParticleSystem(F.gl,I,x,u);let E=null,$=null;if(I.material){const k=je.getEntry(M,I.material);if(k){const U=JSON.parse(ct(k));N.setMaterial(U);const W=U?.passes?.[0]?.textures||[];E=W[0]||null,$=W[1]||null}}const A=await ln(E||"particle/halo");if(!A)return re(e,n,`particle '${T}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;N.setTexture({glTex:A.glTex,width:A.width,height:A.height,frames:A.frames});const R=$||(N.refract?Yt.particleNormalNameForAlbedo(E||"particle/halo"):null);if(R){const k=gr(await ln(R));k&&N.setNormalTexture({glTex:k.glTex,width:k.width,height:k.height})}N.setVisible(!!u.visible),qe.push(N);const C=u.id;if(C!==void 0){let k=zt.get(C);k||(k=[],zt.set(C,k)),k.push(N)}for(const k of I.children||[]){if(!k||typeof k.name!="string")continue;const U=String(k.origin??"0 0 0").trim().split(/\s+/).map(Number),W=String(k.scale??"1 1 1").trim().split(/\s+/).map(Number),J=String(k.angles??"0 0 0").trim().split(/\s+/).map(Number),Q=k.type==="eventfollow"?"particle":!k.type||k.type==="static"?"origin":null,te=N.localToWorld(U[0]||0,U[1]||0),O={...u,origin:[te[0],te[1],(u.origin?.[2]||0)+(U[2]||0)],scale:[(u.scale?.[0]??1)*(W[0]||1),(u.scale?.[1]??1)*(W[1]||1),(u.scale?.[2]??1)*(W[2]||1)],angles:[(u.angles?.[0]||0)+(J[0]||0),(u.angles?.[1]||0)+(J[1]||0),(u.angles?.[2]||0)+(J[2]||0)]},K=await br(k.name,O,k.instanceoverride||x,S+1);K&&Q&&K.attachFollow(N,Q,[U[0]||0,U[1]||0,U[2]||0])}return N};if(!cl){for(const T of p.layers)if(T.particle)try{await br(T.particle,T,T.instanceoverride,0)}catch(u){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`),re(e,n,`particle '${T.name}' FAIL: ${u.message.slice(0,80)}`)}}if(qe.length>0){const T=a;a=()=>{T?.();for(const u of qe)u.dispose()}}const un=[];for(const T of p.layers)if(!(!T.sound||!T.sound.length))try{for(const u of T.sound){const x=je.getEntry(M,u);if(!x)continue;const S=(u.split(".").pop()||"").toLowerCase(),P=S==="mp3"?"audio/mpeg":S==="ogg"?"audio/ogg":S==="flac"?"audio/flac":"audio/wav",I=new Blob([x],{type:P}),N=URL.createObjectURL(I);(e.objectUrls??=[]).push(N);const E=document.createElement("audio");E.src=N,E.loop=T.soundprops?.playbackmode==="loop",E.volume=Math.max(0,Math.min(1,T.soundprops?.volume??1)),E.muted=n.muted!==!1,T.soundCtl={play(){if(E.ended)try{E.currentTime=0}catch{}E.play().catch(()=>{})},pause(){E.pause()},stop(){E.pause();try{E.currentTime=0}catch{}},isPlaying:()=>!E.paused&&!E.ended,getVolume:()=>E.volume,setVolume:$=>{E.volume=Math.max(0,Math.min(1,$))}},!T.soundprops?.startsilent&&!e.paused&&E.play().catch(()=>{}),un.push(E);break}}catch(u){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`)}const so=T=>{for(const u of un)u.volume=Math.max(0,Math.min(1,T)),u.muted=T<=0};if(e.sceneAudio={setVolume:so,audios:un},s)return;let On=performance.now(),Dn=0;F.setParticleRenderer(()=>{const T=performance.now(),u=Math.min(.05,(T-On)/1e3);if(On=T,xe.state.has){const{wx:x,wy:S,originY:P}=xe.state,I=P??S;for(const N of qe)N.setPointer(x,I)}for(const x of qe)x.advance(u,H.enabled?B.snapshot:null);if(Dn<2&&(Dn++,Dn===2)){const x=qe.reduce((S,P)=>S+P.liveCount(),0);re(e,n,`particles live: ${x} across ${qe.length} systems`)}},(T,u,x,S,P)=>{if(T===void 0)return;const I=zt.get(T);if(I)for(const N of I)N.render(x,S,P,u.projW,u.projH)}),re(e,n,`particles: ${qe.length} systems, ${ye} builtin tex generated`),window.__particleStats=()=>qe.map(T=>{let u=0,x=1/0,S=-1/0,P=1/0,I=-1/0,N=1/0,E=-1/0;for(const $ of T.pool){if(!$.alive)continue;u++;const A=T.originX+$.x*T.scaleX,R=T.originY+$.y*T.scaleY;A<x&&(x=A),A>S&&(S=A),R<P&&(P=R),R>I&&(I=R);const C=Math.abs($.size)*T.sysScale;C<N&&(N=C),C>E&&(E=C)}return{live:u,max:T.maxCount,blend:T.blend,renderer:T.renderers.map($=>$.kind).join("+"),origin:[Math.round(T.originX),Math.round(T.originY)],bbox:u?[Math.round(x),Math.round(P),Math.round(S),Math.round(I)]:null,size:u?[Math.round(N),Math.round(E)]:null}}),window.__particleToggle=(T,u)=>{for(let x=0;x<qe.length;x++)qe[x].setVisible(u===void 0?T:x===u);return qe.length};const Ct=[],$n=new Map,fn=T=>{if(!T||!T.puppet)return null;let u=$n.get(T);return u||(u=new Map,$n.set(T,u)),u};for(const T of p.layers)if(T.image)try{if(vt.BUILTIN_MODELS[T.image])continue;const u=je.getEntry(M,T.image);if(!u)continue;const x=JSON.parse(ct(u));if(!x.puppet)continue;const S=je.getEntry(M,x.puppet);if(!S)continue;const P=kn.parseMDL(new Uint8Array(S)),I=T.textureName?fe.get(T.textureName):null;if(!I){re(e,n,`puppet '${T.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}T.puppet=P,Ct.push({mdl:P,tex:I,layer:T});const N=P.animations[0];re(e,n,`puppet '${T.name}' v=${P.vertexCount} bones=${P.bones.length}`+(N?` anim='${N.name}' ${N.fps}fps\xD7${N.frameCount}`:" \u65E0\u52A8\u753B"))}catch(u){console.warn(`puppet \u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`),re(e,n,`puppet '${T.name}' \u5931\u8D25: ${u.message}`)}for(const T of p.layers)if(T.model&&!T.puppet)try{const u=je.getEntry(M,T.model);if(!u)continue;const x=kn.parseMDL(new Uint8Array(u));let S=null;if(x.materialPath){const I=je.getEntry(M,x.materialPath);if(I){const E=JSON.parse(ct(I))?.passes?.[0]?.textures?.[0];typeof E=="string"&&E&&(S=E)}}S&&(await et(S),T.textureName=S);const P=S?fe.get(S):null;if(!P){re(e,n,`model '${T.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}T.puppet=x,Ct.push({mdl:x,tex:P,layer:T}),re(e,n,`model '${T.name}' v=${x.vertexCount} static ${x.materialPath||""}`)}catch(u){console.warn(`model \u56FE\u5C42 ${T.name} \u52A0\u8F7D\u5931\u8D25: ${u.message}`),re(e,n,`model '${T.name}' \u5931\u8D25: ${u.message}`)}let dn=null;if(Ct.length>0)try{dn=kn.createMDLRenderer(F.gl);for(const u of Ct)dn.upload(u.mdl);const T=new Map;for(const u of Ct)T.set(u.layer,u);F.setPuppetRenderer((u,x,S)=>{const P=T.get(u);P&&dn.draw(x,P.mdl,{time:S.time,animLayers:u.animationLayers,boneOverrides:$n.get(u),overrideTex:S.overrideTex||null,color:[u.color[0]*u.brightness,u.color[1]*u.brightness,u.color[2]*u.brightness,u.alpha]},P.tex)})}catch(T){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${T.message}`),re(e,n,`puppet renderer \u5931\u8D25: ${T.message}`),dn=null;for(const u of Ct)u.layer.puppet=null}if(s)return;re(e,n,`puppet: ${Ct.length} meshes`);const Kt=kn.applyAttachmentBindOrigins(p.layers);Kt.length&&re(e,n,`attachments: ${Kt.length} hanging layers`);const it=[],Rt=new Map,st={};let pe=null,xt=null,zn=0;if(!Gi&&p.layers.some(T=>T.isText)){const T=p.general?.orthogonalprojection,u=T?.width||t.width,x=T?.height||t.height,S=Nr(Xt(e.cfg.fit),u,x,t.width,t.height),P=Math.min(3,Math.max(.5,t.width/Math.max(1,S.viewW))),I=new Map,N=new Set;for(const A of p.layers)A.isText&&A.textFont&&N.add(A.textFont);for(const A of M.entries||[])typeof A.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test(A.name)&&N.add(A.name);for(const A of N){const R=Zi.get(`${n.src}|${A}`);if(R){I.set(A,R);continue}const C=wl[A.toLowerCase()];if(C){I.set(A,C);continue}try{const k=je.getEntry(M,A);if(!k)continue;const U=xl(k instanceof Uint8Array?k:new Uint8Array(k)),W="wefont_"+A.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),J=URL.createObjectURL(new Blob([U])),Q=new FontFace(W,`url(${J})`);await Q.load(),document.fonts.add(Q),(e.objectUrls??=[]).push(J),I.set(A,W),Zi.set(`${n.src}|${A}`,W)}catch(k){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${A}: ${k.message}`)}}pe=document.createElement("canvas"),xt=pe.getContext("2d");const E=2048;for(const A of p.layers)if(A.isText)try{const R={layer:A,sandbox:null,texName:"__wstext_"+A.id,entry:null,lastKey:null,quality:P};if(A.textScript&&(R.sandbox=He.evalTextScript(A.textScript,A.textScriptProps,{text:A.text??"",font:A.textFont||"",pointsize:A.textPointsize,color:A.textColor,angles:A.angles,origin:A.origin,scale:A.scale,visible:A.visible,canvasSize:{width:u,height:x},userProperties:v,shared:st,audioViews:le,inputView:Ne,...Ge,mediaControl:Ee,windowTitle:oe.snapshot,openUserShortcut:Se.openUserShortcut,getLayerText:W=>Rt.get(W),onError:W=>{re(e,n,`text script '${A.name}' \u5931\u8D25: ${String(W.message||W).slice(0,120)}`)}}),R.sandbox&&(w.push(R.sandbox),R.sandbox.init(),R.sandbox.applyUserProperties(v),R.sandbox.hasMediaHook&&Fe(R.sandbox))),Rt.set(A.name||"",String(A.text??"")),A.textAnchor!=="center"&&A.size[0]>0&&A.size[1]>0){const W=A.size[0]*(A.scale[0]||1)/2,J=A.size[1]*(A.scale[1]||1)/2,Q=A.textAnchor;Q.includes("left")&&(A.origin[0]+=W),Q.includes("right")&&(A.origin[0]-=W),Q.includes("top")&&(A.origin[1]-=J),Q.includes("bottom")&&(A.origin[1]+=J)}const C=Yi*Math.max(1,A.textPointsize),k=He.textLayerHasTintMask(A)?8:256,U=Math.min(k,He.textCanvasMargin(C,0));R.boxW=A.size[0]>0?A.size[0]:C*4,R.boxH=A.size[1]>0?A.size[1]:C*1.6,R.margin=U,A.size=[R.boxW+U*2,R.boxH+U*2],R.entry={glTex:Be.makeTexture(F.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},fe.set(R.texName,R.entry),A.textureName=R.texName,A.solid=!1,it.push(R)}catch(R){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${A.name} \u521D\u59CB\u5316\u5931\u8D25: ${R.message}`)}if(it.length>0){const A=a;a=()=>{A?.();for(const R of it)F.gl.deleteTexture(R.entry.glTex)}}const $=A=>{if(!xt||!pe)return;const R=xt;for(const C of it){const k=C.layer;let U=String(k.text??"");if(C.sandbox&&C.sandbox.hasUpdate){C.sandbox.engine.runtime=A;const te=C.sandbox.callUpdate(U);te!=null?U=String(te):C.sandbox.thisLayer.text&&(U=String(C.sandbox.thisLayer.text))}else C.sandbox&&typeof C.sandbox.thisLayer?.text=="string"&&(U=String(C.sandbox.thisLayer.text));if(Rt.set(k.name||"",U),!k.visible)continue;const W=Math.max(1,C.sandbox?C.sandbox.thisLayer.pointsize:k.textPointsize),J=C.sandbox&&C.sandbox.thisLayer.font||k.textFont||"",Q=`${U}\0${W}\0${J}\0${k.alpha}\0${k.textCastshadow}`;if(C.lastKey!==Q){C.lastKey=Q;try{const te=Yi*W,O=C.boxW,K=C.boxH,se=C.margin,ge=Math.abs(k.scale[0]||1),Me=Math.abs(k.scale[1]||1);let ie=Math.max(1,Math.round(k.size[0]*ge*C.quality)),Ae=Math.max(1,Math.round(k.size[1]*Me*C.quality));const _e=Math.min(1,E/Math.max(ie,Ae));ie=Math.max(1,Math.round(ie*_e)),Ae=Math.max(1,Math.round(Ae*_e)),pe.width!==ie||pe.height!==Ae?(pe.width=ie,pe.height=Ae):(R.setTransform(1,0,0,1,0,0),R.clearRect(0,0,ie,Ae));const Ze=Math.min(ie/k.size[0],Ae/k.size[1]);R.setTransform(Ze,0,0,Ze,0,0),R.translate(se,se);const Mt=J&&I.get(J)||"sans-serif";R.font=`${te}px "${Mt}", sans-serif`;const at=R.measureText(""),At=(at.fontBoundingBoxAscent||0)+(at.fontBoundingBoxDescent||0),nt=k.textSpacing||[0,0],ae=He.layoutText(U,{boxW:O,boxH:K,pointsize:te,lineHeight:(At>0?At:te*1.25)+nt[1],spacing:nt,padding:k.textPadding||0,maxwidth:k.textMaxwidth||0,limitwidth:!!k.textLimitwidth,maxrows:k.textMaxrows||0,limitrows:!!k.textLimitrows,limituseellipsis:!!k.textLimituseellipsis,halign:k.textHAlign,valign:k.textVAlign},ce=>R.measureText(ce).width);He.drawTextLayer(R,ae,{font:R.font,color:k.textColor,alpha:k.alpha,brightness:k.brightness,spacing:nt,pointsize:te,opaquebackground:!!k.textOpaquebackground,backgroundcolor:k.textBackgroundcolor,backgroundbrightness:k.textBackgroundbrightness,castshadow:!!k.textCastshadow});const de=C.entry;F.gl.bindTexture(F.gl.TEXTURE_2D,de.glTex),F.gl.texImage2D(F.gl.TEXTURE_2D,0,F.gl.RGBA,F.gl.RGBA,F.gl.UNSIGNED_BYTE,pe),de.width=ie,de.height=Ae}catch(te){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${k.name} \u7ED8\u5236\u5931\u8D25: ${te.message}`),C.lastKey=null}}}};e.sceneTextUpdate=$,window.__textWidgets=it,re(e,n,`text widgets: ${it.length} (scripts ${it.filter(A=>A.sandbox).length}, fonts ${I.size}, quality ${P.toFixed(2)})`)}if(s)return;const tt=[],yr=[],ft=[],Qt={},vr=[],hn=[],jt=new Map,mn=(T,u)=>{if(!u||typeof u.callCursor!="function"||!u.hasCursorHook)return;const x=jt.get(T);x?x.push(u):jt.set(T,[u])};for(const T of it)T.sandbox&&mn(T.layer,T.sandbox);{const T=p.general?.orthogonalprojection,u=T?.width||t.width,x=T?.height||t.height,S=v,P=(A,R)=>{const C=p.general||{};if(A==="zoom"&&typeof R=="number"&&Number.isFinite(R)&&R>0){p.cameraTransforms.zoom=R,C.zoom&&typeof C.zoom=="object"?C.zoom.value=R:C.zoom=R;return}C[A]&&typeof C[A]=="object"&&"value"in C[A]?C[A].value=R:C[A]=R};let I=1+Math.max(0,...p.layers.map(A=>Number(A.id)||0));const N={recomputeVisibility:_,getSceneLayer:A=>p.layers.find(R=>R.name===A&&!R.destroyed)||null,getSceneLayerById:A=>p.layers.find(R=>R.id===A&&!R.destroyed)||null,enumerateSceneLayers:()=>p.layers.filter(A=>!A.destroyed),getSceneAnimation:A=>{if(A==null||A==="")return null;if(Qt[A])return Qt[A];for(const R of p.layers)if(R.animations&&R.animations[A])return R.animations[A];return null},cameraTransforms:p.cameraTransforms,getInitialLayerConfig:A=>{const R=A&&typeof A=="object"?A.name:String(A||"");return p.layers.find(C=>C.name===R)||null},createSceneLayer:A=>{let R=A&&typeof A=="object"?A:null;if(typeof A=="string"){const k=A;if(R=p.layers.find(U=>U&&!U.destroyed&&U.image===k&&U.textureName)||p.layers.find(U=>U&&!U.destroyed&&U.image===k)||null,!R)return re(e,n,`createLayer('${k}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}R||(R={});const C={...R,id:I++,origin:Array.isArray(R.origin)?R.origin.slice():[0,0,0],scale:Array.isArray(R.scale)?R.scale.slice():[1,1,1],angles:Array.isArray(R.angles)?R.angles.slice():[0,0,0],size:Array.isArray(R.size)?R.size.slice():[0,0],color:Array.isArray(R.color)?R.color.slice():[1,1,1],childIds:null,hasChildren:!1,destroyed:!1,animations:{},animationList:[],objectScripts:null};return delete C.textureAnimation,delete C.videoTextureApi,delete C.soundCtl,delete C.videoCtl,Array.isArray(R.effects)&&(C.effects=R.effects.map(k=>({...k,passes:Array.isArray(k.passes)?k.passes.map(U=>({...U})):k.passes}))),p.layers.push(C),C},mediaControl:Ee,windowTitle:oe.snapshot,openUserShortcut:Se.openUserShortcut,isScreensaver:!1};F.setConstantScriptRuntime?.(He.evalObjectScript,{userProperties:S,audioViews:le,shared:st,inputView:Ne,timers:we,...N,onSandbox:A=>{A&&A.hasMediaHook&&Fe(A)}});for(const A of p.layers){const R=A.objectAnimations;if(R){A.animations=A.animations||{},A.animationList=A.animationList||[];for(const[C,k]of Object.entries(R))try{const U=zi.createAnimation(k.animation);U.field=C,U.baseValue=k.value;const W=A[C];U.baseNumeric=Array.isArray(W)?W.slice():W,A.animationList.push(U),U.name&&(A.animations[U.name]=U),yr.push({layer:A,field:C,ctrl:U})}catch(U){re(e,n,`animation '${A.name}.${C}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(U.message).slice(0,80)}`)}}}for(const A of p.layers){for(const[C,k]of(A.effects||[]).entries()){const U=k.visibleScript;if(U)try{const W=He.evalObjectScript(U.script,U.scriptproperties,{canvasSize:{width:u,height:x},userProperties:S,audioViews:le,inputView:Ne,...Ge,layer:A,targetEffect:k,...N,shared:st,onError:J=>re(e,n,`effect visible script '${A.name}#${C}' \u5931\u8D25: ${String(J.message||J).slice(0,80)}`)});if(!W)continue;w.push(W),W.init(k.visible),W.applyUserProperties(S),W.hasMediaHook&&Fe(W),W.hasUpdate&&vr.push({effect:k,sandbox:W})}catch(W){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${A.name}#${C} \u6C42\u503C\u5931\u8D25: ${W.message}`)}}const R=A.objectScripts;if(R)for(const[C,k]of Object.entries(R))try{const U=He.evalObjectScript(k.script,k.scriptproperties,{canvasSize:{width:u,height:x},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const W=new Date;return(W.getHours()*3600+W.getMinutes()*60+W.getSeconds())/86400})(),userProperties:S,audioViews:le,inputView:Ne,layer:A,...N,getBoneOverrides:fn,shared:st,...Ge,onError:W=>re(e,n,`object script '${A.name}.${C}' \u5931\u8D25: ${String(W.message||W).slice(0,90)}`)});if(U){w.push(U);const W=A[C],J=C==="angles"&&Array.isArray(W)?He.radToScriptAngles(W):Array.isArray(W)?{x:W[0]??0,y:W[1]??0,z:W[2]??0}:W;U.init(J),U.applyUserProperties(S),mn(A,U),U.hasMediaHook&&Fe(U),U.hasUpdate&&tt.push({layer:A,field:C,kind:C==="visible"?"bool":C==="alpha"||C==="brightness"?"scalar":"vec3",sandbox:U})}}catch(U){console.warn(`\u5BF9\u8C61\u811A\u672C ${A.name}.${C} \u6C42\u503C\u5931\u8D25: ${U.message}`)}}const E=p.generalScripts;if(E){for(const[A,R]of Object.entries(E))try{const C=He.evalObjectScript(R.script,R.scriptproperties,{canvasSize:{width:u,height:x},userProperties:S,audioViews:le,inputView:Ne,...Ge,...N,shared:st,onError:U=>re(e,n,`general script '${A}' \u5931\u8D25: ${String(U.message||U).slice(0,80)}`)});if(!C)continue;w.push(C),C.init(R.value),C.applyUserProperties(S),C.hasMediaHook&&Fe(C);const k=U=>P(A,U);C.hasUpdate&&hn.push({field:A,sandbox:C,write:k})}catch(C){console.warn(`general \u811A\u672C ${A} \u6C42\u503C\u5931\u8D25: ${C.message}`)}hn.length&&re(e,n,`general scripts: ${hn.map(A=>A.field).join(",")}`)}const $=p.generalAnimations;if($){for(const[A,R]of Object.entries($))try{const C=zi.createAnimation(R.animation);C.field=A,C.baseValue=R.value,C.baseNumeric=R.value,C.name&&(Qt[C.name]=C),ft.push({field:A,ctrl:C,write:k=>P(A,k)})}catch(C){re(e,n,`general animation '${A}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(C.message).slice(0,80)}`)}ft.length&&re(e,n,`general animations: ${ft.map(A=>A.field).join(",")}`)}}tt.length&&(re(e,n,`object scripts: ${tt.length}`),window.__objScripts=tt),window.__mediaHooks=Le,window.__compositeStats=()=>F.compositeStats?.()??null,window.__compositeEnable=T=>F.setCompositeEnabled?.(T),window.__scene=p,window.__textures=fe;const pn=Array.from(jt.keys());pn.length&&re(e,n,`cursor hooks: ${pn.length} layers`);let Lt=null,wt=null,Oe=!1;const Vt=()=>({worldPosition:He.makeCursorEventVec(xe.state.wx,xe.state.originY!=null?xe.state.originY:xe.state.wy,0)}),dt=(T,u,x)=>{const S=jt.get(T);if(S)for(const P of S)P.callCursor(u,x)},jn=()=>{if(pn.length===0)return;const T=xe.state;if(!T.has)return;const u=F.getParallaxOffset?F.getParallaxOffset():{x:0,y:0},x=p.general?.orthogonalprojection?.height||t.height,S=Kc.hitTestLayers(p.layers,T.wx,T.wy,x,{parOffX:u.x,parOffY:u.y,alignTable:Be.ALIGN,filter:I=>jt.has(I)}),P=Vt();S!==Lt&&(Lt&&dt(Lt,"cursorLeave",P),Lt=S,S&&dt(S,"cursorEnter",P)),S&&dt(S,"cursorMove",P),T.leftDown&&!Oe?(wt=S,S&&dt(S,"cursorDown",P)):!T.leftDown&&Oe&&(wt&&dt(wt,"cursorUp",P),wt&&wt===S&&dt(S,"cursorClick",P),wt=null),Oe=T.leftDown},ao=performance.now();let Vn=0,ht=0;const gn=[],Jt=[];let xr=-1/0;const Wn=T=>{if(s||e.paused)return;const x=1e3/(e.cfg.sceneFps||60);if(T-xr>=x){if(xr=T,fo(e,T),e.onFirstFrame){const E=e.onFirstFrame;e.onFirstFrame=void 0,E()}mo(e,t,e.cfg);const S=(T-ao-Vn)/1e3;if(Ne.update(xe.state),Xe.enabled){Y?.media?Y.media.pump():z.update(S);const E=ue(),$=ve.diffMediaEvents(Pe,E);if($.length){for(const{name:A,event:R}of $)for(const C of Le)C.disabled||C.callMedia(A,R);Pe=ve.cloneMediaSnapshot(E)}}Y?.windowTitle?Y.windowTitle.pump():V.update(S);for(const E of yr){E.ctrl.advance(x/1e3);const $=E.field,A=E.ctrl.applyTo(E.ctrl.baseNumeric);if(Array.isArray(A)){const R=E.layer[$];if(Array.isArray(R))for(let C=0;C<A.length&&C<R.length;C++)R[C]=A[C]}else Number.isFinite(A)&&($==="visible"?E.layer[$]=!!A:E.layer[$]=A)}for(const E of ft){E.ctrl.advance(x/1e3);const $=E.ctrl.applyTo(E.ctrl.baseNumeric);typeof $=="number"&&Number.isFinite($)?E.write($):Array.isArray($)&&Number.isFinite($[0])&&E.write($[0])}for(const E of vr){if(E.sandbox.disabled)continue;E.sandbox.engine.frametime=x/1e3,E.sandbox.engine.runtime=S;const $=E.sandbox.callUpdate(!!E.effect.visible);typeof $=="boolean"&&(E.effect.visible=$)}for(const E of hn){if(E.sandbox.disabled)continue;E.sandbox.engine.frametime=x/1e3,E.sandbox.engine.runtime=S;const $=p.general||{},A=$[E.field]&&typeof $[E.field]=="object"&&"value"in $[E.field]?$[E.field].value:$[E.field],R=E.sandbox.callUpdate(A);R!==void 0&&E.write(R)}const P={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};let I=!1;for(const E of tt){if(E.sandbox.disabled)continue;E.sandbox.engine.frametime=x/1e3,E.sandbox.engine.runtime=S,E.sandbox.engine.screenResolution=P;const $=E.layer[E.field];if(E.kind==="bool"){const A=E.sandbox.callUpdate(!!$);typeof A=="boolean"&&(E.field==="visible"?E.layer.visibleSelf!==A&&(E.layer.visibleSelf=A,I=!0):E.layer[E.field]=A)}else if(E.kind==="scalar"){const A=E.sandbox.callUpdate(Number($)||0),R=Number(A);Number.isFinite(R)&&(E.layer[E.field]=R)}else{const A=E.field==="angles"?He.radToScriptAngles($):{x:$[0]||0,y:$[1]||0,z:$[2]||0},R=E.sandbox.callUpdate(A),C=R&&typeof R=="object"&&"x"in R?R:A;E.layer[E.field]=E.field==="angles"?He.scriptAnglesToRad(C):[C.x||0,C.y||0,C.z||0]}}I&&_(),H.enabled&&(X.current?X.current.pump():B.update(S),kc(le,X.current?X.current.snapshot:B.snapshot)),Kt.length&&kn.followAttachments(Kt,S,fn);const N=e.coverAlign;F.render(p,fe,t.width,t.height,S,Xt(e.cfg.fit),N.x,N.y).then(()=>{if(!(s||e.paused)){try{jn()}catch{}xe.beginFrame();try{e.sceneTextUpdate&&T>=zn&&(zn=T+100,e.sceneTextUpdate(S))}catch{}e.raf=requestAnimationFrame(Wn)}}).catch(E=>{console.warn("scene render error:",E),re(e,n,`render: ${String(E.message||E).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(Wn))},wr=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(Wn))},Mr=T=>{if(s)return;const u=p.properties||{},x=Cs(u,v,T);if(Object.keys(x).length){for(const S of p.layers){const P=S.srcObject;if(!P)continue;tn(P,u,0);const I=gt(P.visible);I&&I in x&&(S.visibleSelf=Qe.parseBool(P.visible,!0));const N=gt(P.color);N&&N in x&&(S.color=Qe.parseColor(P.color),S.isText&&(S.textColor=S.color));const E=gt(P.alpha);E&&E in x&&(S.alpha=Qe.parseNum(P.alpha,1));const $=gt(P.brightness);$&&$ in x&&(S.brightness=Qe.parseNum(P.brightness,1));const A=gt(P.volume);if(A&&A in x){const C=Qe.parseNum(P.volume,1);S.soundprops&&(S.soundprops.volume=C),S.soundCtl?.setVolume?.(C)}for(let C=0;C<(P.animationlayers||[]).length;C++){const k=P.animationlayers[C],U=S.animationLayers?.[C];if(!k||!U)continue;const W=gt(k.visible);W&&W in x&&(U.visible=Qe.parseBool(k.visible,!0));const J=gt(k.rate);J&&J in x&&(U.rate=Qe.parseNum(k.rate,1));const Q=gt(k.blend);Q&&Q in x&&(U.blend=Qe.parseNum(k.blend,1))}for(let C=0;C<(P.effects||[]).length;C++){const k=P.effects[C],U=S.effects?.[C];if(!k||!U)continue;const W=gt(k.visible);W&&W in x&&!U.visibleScript&&(U.visible=Qe.parseBool(k.visible,!0))}const R=P.instanceoverride;if(R&&typeof R=="object"&&S.particle){let C=!1;for(const k of Object.keys(R)){if(k==="id")continue;const U=gt(R[k]);if(U&&U in x){C=!0;break}}if(C){const k=zt.get(S.id);if(k)for(const U of k)U.reapplyOverride?.()}}}for(const S of w)if(!(!S||S.disabled))try{S.applyUserProperties(x)}catch{}_();for(const S of p.layers){if(!S.particle)continue;const P=zt.get(S.id);if(P)for(const I of P)I.setVisible(!!S.visible)}F.applyConstUserProperties?.(x);for(const S of it)S.lastKey=null;re(e,n,`props hot: ${Object.keys(x).join(",")}`)}};d=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),ht||(ht=performance.now()),gn.length=0;for(const T of fe.values())T?.videoCtl?.isPlaying?.()&&(gn.push(T.videoCtl),T.videoCtl.pause());Jt.length=0;for(const T of un)!T.paused&&!T.ended&&(Jt.push(T),T.pause())},h=()=>{ht&&(Vn+=performance.now()-ht,ht=0),On=performance.now();for(const T of gn)try{T.play()}catch{}gn.length=0;for(const T of Jt)T.play().catch(()=>{});Jt.length=0,wr()},l=Mr,f&&(Mr(f),f=null),wr();{const T=p.general?.orthogonalprojection,u=T?.width||t.width,x=T?.height||t.height,S=Xt(e.cfg.fit),P=Nr(S,u,x,t.width,t.height);re(e,n,`fit ${S}: view ${Math.round(P.viewW)}x${Math.round(P.viewH)} scene ${u}x${x} canvas ${t.width}x${t.height}`)}re(e,n,`renderer started: ${p.layers.length} layers`)}catch(m){if(s||m&&m.name==="AbortError")return;console.warn("scene render failed:",m);const M=m instanceof Error?m:new Error(String(m));re(e,n,`failed: ${String(M.message||M).slice(0,200)}`),e.onError?e.onError(M):e.fallbackPage?.()}})()}function mr(e,n){(n.type==="video"||n.type==="gif"||n.type==="image")&&n.src?el(e,n):n.type==="scene"&&(n.source||n.src)?Al(e,n):e.onUnhandledType?.(n)}function _l(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function Tl(e,n){return{type:"scene",canvas:e,source:n.source,fit:_l(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0}}function Ki(e,n){const t=es(),o={ready:[],error:[],diagnostic:[]};let r={...n??{},source:null};const i=d=>{for(const h of o.error)try{h(d)}catch{}},s=d=>{t.onDiagnostic=(h,m)=>{try{d.onDiagnostic?.(h,m)}catch{}for(const M of o.diagnostic)try{M(h,m)}catch{}},t.onError=h=>{try{d.onError?.(h)}catch{}i(h)},t.onSceneInfo=h=>{t.info=h}},c=()=>new Promise(d=>{const h=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,h?.(),d()}}),a=()=>{let d=()=>{};return{promise:new Promise((m,M)=>{d=f.on("error",g=>M(g))}),off:d}},f={canvas:e,pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,ho(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(d){t.cfg.fit=d,Tr(t)},setFps(d){t.cfg.sceneFps=d},setVolume(d){const h=Math.max(0,Math.min(1,d));t.cfg.muted=h<=0,t.sceneAudio?.setVolume(h)},setRenderDpr(d){t.cfg.renderDpr=d,mr(t,t.cfg)},setProperties(d){const h={};for(const[m,M]of Object.entries(d))h[m]={value:M};t.sceneCtl?.applyUserProperties(h)},getProperties(){return{...t.liveUserProps??{}}},async load(d){r={...r,source:d},s(r);const h={...t.cfg,type:"scene",source:d,src:void 0,mediaBase:void 0};t.cfg=h,t.paused=!1,t.info=void 0,Tr(t);const m=c(),M=a();mr(t,h);try{await Promise.race([m,M.promise])}finally{M.off()}},release(){en(t)},restore(){mr(t,t.cfg)},destroy(){ts(t),t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,o.ready.length=0,o.error.length=0,o.diagnostic.length=0},get stats(){return rs(t)},get info(){return t.info??null},on(d,h){const m=o[d];return m.push(h),()=>{const M=m.indexOf(h);M>=0&&m.splice(M,1)}}},l=async d=>{r=d,s(d),t.cfg=Tl(e,d),t.paused=d.autoplay===!1,t.info=void 0,Tr(t);const h=c(),m=a();mr(t,t.cfg);try{await Promise.race([h,m.promise])}finally{m.off()}(d.volume??0)>0&&f.setVolume(d.volume),d.properties&&Object.keys(d.properties).length&&f.setProperties(d.properties)};return f.__applyOptions=l,f}async function Sl(e,n){const t=Ki(e,n);return await t.__applyOptions(n),t}rt.bytesSource=il,rt.createScene=Ki,rt.fileSource=ol,rt.httpSource=ji,rt.mount=Sl,Object.defineProperty(rt,Symbol.toStringTag,{value:"Module"})})});Rl();})();
499
511
 
500
512
  //# sourceMappingURL=webwallgl.global.min.js.map