route-graphics 1.5.2 → 1.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteGraphics.js +1 -1
- package/package.json +1 -1
package/dist/RouteGraphics.js
CHANGED
|
@@ -1631,7 +1631,7 @@ void main(void)
|
|
|
1631
1631
|
`)}}return o.push(`
|
|
1632
1632
|
renderer.buffer.update(buffer);
|
|
1633
1633
|
`),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(`
|
|
1634
|
-
`))}}var l3=0,sp={textureCount:0,uboCount:0},os=class{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=l3++}systemCheck(){if(!Jf())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;let i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(sp.textureCount=0,sp.uboCount=0,this.syncUniformGroup(t.uniformGroup,sp)),s}setUniforms(t){let e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){let i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){let e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=B_(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){let i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;let s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,sp,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){let{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);let o=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;let n=this.getSignature(t,this.shader.program.uniformData,"ubo"),a=this._uboCache[n];if(a||(a=this._uboCache[n]=H_(t,this.shader.program.uniformData)),t.autoManage){let l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){let s=t.uniforms,o=[`${i}-`];for(let n in s)o.push(n),e[n]&&o.push(e[n].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){let e=this.gl,i=t.program,s=N_(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}};os.extension={type:$.RendererSystem,name:"shader"};K.add(os);var Ri=class{constructor(t){this.renderer=t}run(t){let{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}};Ri.defaultOptions={hello:!1},Ri.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"};K.add(Ri);function gF(r,t=[]){return t[J.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.ADD]=[r.ONE,r.ONE],t[J.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.NONE]=[0,0],t[J.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[J.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[J.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[J.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[J.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[J.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[J.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[J.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[J.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[J.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}var c3=0,h3=1,u3=2,d3=3,f3=4,p3=5,xF=class V_{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=J.NONE,this._blendEq=!1,this.map=[],this.map[c3]=this.setBlend,this.map[h3]=this.setOffset,this.map[u3]=this.setCullFace,this.map[d3]=this.setDepthTest,this.map[f3]=this.setFrontFace,this.map[p3]=this.setDepthMask,this.checks=[],this.defaultState=new ei,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=gF(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(V_.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(V_.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;let e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){let i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};xF.extension={type:$.RendererSystem,name:"state"};var W_=xF;K.add(W_);var jn=class extends Vs.default{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);let e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(let s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Jt(e)})}addSystem(t,e){let i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(let s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){let i=Object.keys(this._systemsHash);t.items.forEach(s=>{let o=i.find(n=>this._systemsHash[n]===s);s[t.name](e[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}};var zc=class op{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=op.defaultMaxIdle,this.checkCountMax=op.defaultCheckCountMax,this.mode=op.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==yf.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this.renderer.texture,e=t.managedTextures,i=!1;for(let s=0;s<e.length;s++){let o=e[s];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),e[s]=null,i=!0)}if(i){let s=0;for(let o=0;o<e.length;o++)e[o]!==null&&(e[s++]=e[o]);e.length=s}}unload(t){let e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};zc.defaultMode=yf.AUTO,zc.defaultMaxIdle=60*60,zc.defaultCheckCountMax=60*10,zc.extension={type:$.RendererSystem,name:"textureGC"};var si=zc;K.add(si);var eo=class{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=nt.UNSIGNED_BYTE,this.internalFormat=L.RGBA,this.samplerType=0}};function yF(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:H.FLOAT,[r.RGBA]:H.FLOAT,[r.ALPHA]:H.FLOAT,[r.LUMINANCE]:H.FLOAT,[r.LUMINANCE_ALPHA]:H.FLOAT,[r.R8]:H.FLOAT,[r.R8_SNORM]:H.FLOAT,[r.RG8]:H.FLOAT,[r.RG8_SNORM]:H.FLOAT,[r.RGB8]:H.FLOAT,[r.RGB8_SNORM]:H.FLOAT,[r.RGB565]:H.FLOAT,[r.RGBA4]:H.FLOAT,[r.RGB5_A1]:H.FLOAT,[r.RGBA8]:H.FLOAT,[r.RGBA8_SNORM]:H.FLOAT,[r.RGB10_A2]:H.FLOAT,[r.RGB10_A2UI]:H.FLOAT,[r.SRGB8]:H.FLOAT,[r.SRGB8_ALPHA8]:H.FLOAT,[r.R16F]:H.FLOAT,[r.RG16F]:H.FLOAT,[r.RGB16F]:H.FLOAT,[r.RGBA16F]:H.FLOAT,[r.R32F]:H.FLOAT,[r.RG32F]:H.FLOAT,[r.RGB32F]:H.FLOAT,[r.RGBA32F]:H.FLOAT,[r.R11F_G11F_B10F]:H.FLOAT,[r.RGB9_E5]:H.FLOAT,[r.R8I]:H.INT,[r.R8UI]:H.UINT,[r.R16I]:H.INT,[r.R16UI]:H.UINT,[r.R32I]:H.INT,[r.R32UI]:H.UINT,[r.RG8I]:H.INT,[r.RG8UI]:H.UINT,[r.RG16I]:H.INT,[r.RG16UI]:H.UINT,[r.RG32I]:H.INT,[r.RG32UI]:H.UINT,[r.RGB8I]:H.INT,[r.RGB8UI]:H.UINT,[r.RGB16I]:H.INT,[r.RGB16UI]:H.UINT,[r.RGB32I]:H.INT,[r.RGB32UI]:H.UINT,[r.RGBA8I]:H.INT,[r.RGBA8UI]:H.UINT,[r.RGBA16I]:H.INT,[r.RGBA16UI]:H.UINT,[r.RGBA32I]:H.INT,[r.RGBA32UI]:H.UINT,[r.DEPTH_COMPONENT16]:H.FLOAT,[r.DEPTH_COMPONENT24]:H.FLOAT,[r.DEPTH_COMPONENT32F]:H.FLOAT,[r.DEPTH_STENCIL]:H.FLOAT,[r.DEPTH24_STENCIL8]:H.FLOAT,[r.DEPTH32F_STENCIL8]:H.FLOAT}:t={[r.RGB]:H.FLOAT,[r.RGBA]:H.FLOAT,[r.ALPHA]:H.FLOAT,[r.LUMINANCE]:H.FLOAT,[r.LUMINANCE_ALPHA]:H.FLOAT,[r.DEPTH_STENCIL]:H.FLOAT},t}function _F(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[nt.UNSIGNED_BYTE]:{[L.RGBA]:r.RGBA8,[L.RGB]:r.RGB8,[L.RG]:r.RG8,[L.RED]:r.R8,[L.RGBA_INTEGER]:r.RGBA8UI,[L.RGB_INTEGER]:r.RGB8UI,[L.RG_INTEGER]:r.RG8UI,[L.RED_INTEGER]:r.R8UI,[L.ALPHA]:r.ALPHA,[L.LUMINANCE]:r.LUMINANCE,[L.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[nt.BYTE]:{[L.RGBA]:r.RGBA8_SNORM,[L.RGB]:r.RGB8_SNORM,[L.RG]:r.RG8_SNORM,[L.RED]:r.R8_SNORM,[L.RGBA_INTEGER]:r.RGBA8I,[L.RGB_INTEGER]:r.RGB8I,[L.RG_INTEGER]:r.RG8I,[L.RED_INTEGER]:r.R8I},[nt.UNSIGNED_SHORT]:{[L.RGBA_INTEGER]:r.RGBA16UI,[L.RGB_INTEGER]:r.RGB16UI,[L.RG_INTEGER]:r.RG16UI,[L.RED_INTEGER]:r.R16UI,[L.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[nt.SHORT]:{[L.RGBA_INTEGER]:r.RGBA16I,[L.RGB_INTEGER]:r.RGB16I,[L.RG_INTEGER]:r.RG16I,[L.RED_INTEGER]:r.R16I},[nt.UNSIGNED_INT]:{[L.RGBA_INTEGER]:r.RGBA32UI,[L.RGB_INTEGER]:r.RGB32UI,[L.RG_INTEGER]:r.RG32UI,[L.RED_INTEGER]:r.R32UI,[L.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[nt.INT]:{[L.RGBA_INTEGER]:r.RGBA32I,[L.RGB_INTEGER]:r.RGB32I,[L.RG_INTEGER]:r.RG32I,[L.RED_INTEGER]:r.R32I},[nt.FLOAT]:{[L.RGBA]:r.RGBA32F,[L.RGB]:r.RGB32F,[L.RG]:r.RG32F,[L.RED]:r.R32F,[L.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[nt.HALF_FLOAT]:{[L.RGBA]:r.RGBA16F,[L.RGB]:r.RGB16F,[L.RG]:r.RG16F,[L.RED]:r.R16F},[nt.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:r.RGB565},[nt.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:r.RGBA4},[nt.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:r.RGB5_A1},[nt.UNSIGNED_INT_2_10_10_10_REV]:{[L.RGBA]:r.RGB10_A2,[L.RGBA_INTEGER]:r.RGB10_A2UI},[nt.UNSIGNED_INT_10F_11F_11F_REV]:{[L.RGB]:r.R11F_G11F_B10F},[nt.UNSIGNED_INT_5_9_9_9_REV]:{[L.RGB]:r.RGB9_E5},[nt.UNSIGNED_INT_24_8]:{[L.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[nt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[L.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[nt.UNSIGNED_BYTE]:{[L.RGBA]:r.RGBA,[L.RGB]:r.RGB,[L.ALPHA]:r.ALPHA,[L.LUMINANCE]:r.LUMINANCE,[L.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[nt.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:r.RGB},[nt.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:r.RGBA},[nt.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:r.RGBA}},t}var Yn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new pt,this.hasIntegerTextures=!1}contextChange(){let t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=_F(t),this.samplerTypes=yF(t);let e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};let i=new eo(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new eo(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){let{gl:i}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;let s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){let{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){let{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let o=t-1;o>=0;--o){let n=e[o];n&&n._glTextures[s].samplerType!==H.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new eo(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){e.internalFormat=this.internalFormats[t.type]?.[t.format]??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??H.FLOAT,this.webGLVersion===2&&t.type===nt.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){let e=t._glTextures[this.CONTEXT_UID];if(!e)return;let i=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(i,t,e))e.samplerType!==H.FLOAT&&(this.hasIntegerTextures=!0);else{let s=t.realWidth,o=t.realHeight,n=i.gl;(e.width!==s||e.height!==o||e.dirtyId<0)&&(e.width=s,e.height=o,n.texImage2D(t.target,0,e.internalFormat,s,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){let{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){let s=this.managedTextures.indexOf(t);s!==-1&&y_(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Mr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=lc.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){let i=this.gl;if(e.mipmap&&t.mipmap!==Mr.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===xr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===xr.LINEAR){let o=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===xr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===xr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}};Yn.extension={type:$.RendererSystem,name:"texture"};K.add(Yn);var qn=class{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){let{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){let{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){let{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){let{gl:e,renderer:i,CONTEXT_UID:s}=this,o=e.createTransformFeedback();t._glTransformFeedbacks[s]=o,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,o);for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,n,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,e){let i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);let o=this.renderer.buffer;if(o)for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];if(!a)continue;let l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}};qn.extension={type:$.RendererSystem,name:"transformFeedback"};K.add(qn);var Mi=class{constructor(t){this.renderer=t}init(t){this.screen=new xt(0,0,t.width,t.height),this.element=t.view||q.ADAPTER.createCanvas(),this.resolution=t.resolution||q.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);let i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}};Mi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Mi.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"};K.add(Mi);q.PREFER_ENV=tr.WEBGL2;q.STRICT_TEXTURE_CACHE=!1;q.RENDER_OPTIONS={...Ci.defaultOptions,...Pi.defaultOptions,...Mi.defaultOptions,...Ri.defaultOptions};Object.defineProperties(q,{WRAP_MODE:{get(){return pt.defaultOptions.wrapMode},set(r){ht("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),pt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return pt.defaultOptions.scaleMode},set(r){ht("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),pt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return pt.defaultOptions.mipmap},set(r){ht("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),pt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return pt.defaultOptions.anisotropicLevel},set(r){ht("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),pt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ht("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ii.defaultResolution},set(r){ii.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ht("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ii.defaultMultisample},set(r){ii.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Ai.defaultMaxTextures},set(r){ht("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ai.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Ai.defaultBatchSize},set(r){ht("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ai.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ai.canUploadSameBuffer},set(r){ht("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ai.canUploadSameBuffer=r}},GC_MODE:{get(){return si.defaultMode},set(r){ht("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),si.defaultMode=r}},GC_MAX_IDLE:{get(){return si.defaultMaxIdle},set(r){ht("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),si.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return si.defaultCheckCountMax},set(r){ht("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),si.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return br.defaultVertexPrecision},set(r){ht("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),br.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return br.defaultFragmentPrecision},set(r){ht("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),br.defaultFragmentPrecision=r}}});var ro=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(ro||{});var Kn=class{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));let e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let e=this.next;return this.next=t?null:e,this.previous=null,e}};var bF=class or{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Kn(null,null,1/0),this.deltaMS=1/or.targetFPMS,this.elapsedMS=1/or.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ro.NORMAL){return this._addListener(new Kn(t,e,i))}addOnce(t,e,i=ro.NORMAL){return this._addListener(new Kn(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){let o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*or.targetFPMS;let i=this._head,s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,or.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{let e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!or._shared){let t=or._shared=new or;t.autoStart=!0,t._protected=!0}return or._shared}static get system(){if(!or._system){let t=or._system=new or;t.autoStart=!0,t._protected=!0}return or._system}};bF.targetFPMS=.06;var vr=bF;Object.defineProperties(q,{TARGET_FPMS:{get(){return vr.targetFPMS},set(r){ht("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),vr.targetFPMS=r}}});var $c=class{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,ro.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?vr.shared:new vr,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};$c.extension=$.Application;K.add($c);var m3=[];K.handleByList($.Renderer,m3);var Xc=class{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){let i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{let i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=At.HIGH?this.multisample=At.HIGH:e>=At.MEDIUM?this.multisample=At.MEDIUM:e>=At.LOW?this.multisample=At.LOW:this.multisample=At.NONE}destroy(){}};Xc.extension={type:$.RendererSystem,name:"_multisample"};K.add(Xc);var np=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var jc=class{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){let{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){let{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){let o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,o.buffer)}}bindBufferRange(t,e,i){let{gl:s,CONTEXT_UID:o}=this;i=i||0;let n=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}update(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{let o=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,o)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];let i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){let e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){let{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new np(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};jc.extension={type:$.RendererSystem,name:"buffer"};K.add(jc);var Yc=class{constructor(t){this.renderer=t}render(t,e){let i=this.renderer,s,o,n,a;if(e&&(s=e.renderTexture,o=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=n,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){let l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}};Yc.extension={type:$.RendererSystem,name:"objectRenderer"};K.add(Yc);var ap=class z_ extends jn{constructor(t){super(),this.type=Fy.WEBGL,t=Object.assign({},q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new sr({projectionMatrix:new Rt},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:z_.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ht("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=z_.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:g_()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ht("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ht("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ht("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ht("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};ap.extension={type:$.Renderer,priority:1},ap.__plugins={},ap.__systems={};var lp=ap;K.handleByMap($.RendererPlugin,lp.__plugins);K.handleByMap($.RendererSystem,lp.__systems);K.add(lp);var ns=class extends ir{constructor(t,e){let{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){let n=new pt;this.items.push(n),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof ir?this.addResourceAt(t[i],i):this.addResourceAt(In(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;let t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{let{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}};var qc=class extends ns{constructor(t,e){let{width:i,height:s}=e||{},o,n;Array.isArray(t)?(o=t,n=t.length):n=t,super(n,{width:i,height:s}),o&&this.initFromArray(o,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=vi.TEXTURE_2D_ARRAY}upload(t,e,i){let{length:s,itemDirtyIds:o,items:n}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){let c=n[l];o[l]<c.dirtyId&&(o[l]=c.dirtyId,c.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,c.resource.width,c.resource.height,1,e.format,i.type,c.resource.source))}return!0}};var Kc=class extends ue{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var vF=class Zc extends ns{constructor(t,e){let{width:i,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==Zc.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Zc.SIDES;a++)this.items[a].target=vi.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=n!==!1,t&&this.initFromArray(t,e),o!==!1&&this.load()}bind(t){super.bind(t),t.target=vi.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=vi.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){let s=this.itemDirtyIds;for(let o=0;o<Zc.SIDES;o++){let n=this.items[o];(s[o]<n.dirtyId||i.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,i),s[o]=n.dirtyId):s[o]<-1&&(t.gl.texImage2D(n.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Zc.SIDES}};vF.SIDES=6;var $_=vF;var Qc=class r extends ue{constructor(t,e){e=e||{};let i,s,o;typeof t=="string"?(i=r.EMPTY,s=t,o=!0):(i=t,s=null,o=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??o,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{let i=await q.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;let s=await i.blob();if(this.destroyed)return;let o=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===er.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return r._EMPTY=r._EMPTY??q.ADAPTER.createCanvas(0,0),r._EMPTY}};var X_=class cp extends ue{constructor(t,e){e=e||{},super(q.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},cp.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){let t=new Image;ue.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;let e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,o=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),o=Math.round(o);let n=this.source;n.width=s,n.height=o,n._pixiId=`canvas_${Si()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=cp.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&cp.SVG_XML.test(t)}};X_.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,X_.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var j_=X_;var hp=class extends ue{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var Y_=class q_ extends ue{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){let i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);let s=t[0].src||t[0];ue.crossOrigin(i,s,e.crossorigin);for(let o=0;o<t.length;++o){let n=document.createElement("source"),{src:a,mime:l}=t[o];if(a=a||t[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){let c=a.split("?").shift().toLowerCase(),h=c.slice(c.lastIndexOf(".")+1);l=l||q_.MIME_TYPES[h]||`video/${h}`}n.src=a,l&&(n.type=l),i.appendChild(n)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){let e=vr.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;let t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){let t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){let t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);let e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();let t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(vr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||q_.TYPES.includes(e)}};Y_.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Y_.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var K_=Y_;Sc.push(Qc,Zs,Kc,K_,hp,j_,Ws,$_,qc);var g3={vec3(r,t,e,i){(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2])&&(e[0]=i[0],e[1]=i[1],e[2]=i[2],r.uniform3f(t,i[0],i[1],i[2]))},int(r,t,e,i){r.uniform1i(t,i)},ivec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},ivec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},ivec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},uint(r,t,e,i){r.uniform1ui(t,i)},uvec2(r,t,e,i){r.uniform2ui(t,i[0],i[1])},uvec3(r,t,e,i){r.uniform3ui(t,i[0],i[1],i[2])},uvec4(r,t,e,i){r.uniform4ui(t,i[0],i[1],i[2],i[3])},bvec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},bvec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},bvec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},mat2(r,t,e,i){r.uniformMatrix2fv(t,!1,i)},mat4(r,t,e,i){r.uniformMatrix4fv(t,!1,i)}},x3={float(r,t,e,i){r.uniform1fv(t,i)},vec2(r,t,e,i){r.uniform2fv(t,i)},vec3(r,t,e,i){r.uniform3fv(t,i)},vec4(r,t,e,i){r.uniform4fv(t,i)},int(r,t,e,i){r.uniform1iv(t,i)},ivec2(r,t,e,i){r.uniform2iv(t,i)},ivec3(r,t,e,i){r.uniform3iv(t,i)},ivec4(r,t,e,i){r.uniform4iv(t,i)},uint(r,t,e,i){r.uniform1uiv(t,i)},uvec2(r,t,e,i){r.uniform2uiv(t,i)},uvec3(r,t,e,i){r.uniform3uiv(t,i)},uvec4(r,t,e,i){r.uniform4uiv(t,i)},bool(r,t,e,i){r.uniform1iv(t,i)},bvec2(r,t,e,i){r.uniform2iv(t,i)},bvec3(r,t,e,i){r.uniform3iv(t,i)},bvec4(r,t,e,i){r.uniform4iv(t,i)},sampler2D(r,t,e,i){r.uniform1iv(t,i)},samplerCube(r,t,e,i){r.uniform1iv(t,i)},sampler2DArray(r,t,e,i){r.uniform1iv(t,i)}};function TF(r,t,e,i,s){let o=0,n=null,a=null,l=s.gl;for(let c in r.uniforms){let h=t[c],u=i[c],d=e[c],f=r.uniforms[c];if(!h){f.group===!0&&s.shader.syncUniformGroup(u);continue}h.type==="float"&&h.size===1&&!h.isArray?u!==d.value&&(d.value=u,l.uniform1f(d.location,u)):h.type==="bool"&&h.size===1&&!h.isArray?u!==d.value&&(d.value=u,l.uniform1i(d.location,Number(u))):(h.type==="sampler2D"||h.type==="samplerCube"||h.type==="sampler2DArray")&&h.size===1&&!h.isArray?(s.texture.bind(u,o),d.value!==o&&(d.value=o,l.uniform1i(d.location,o)),o++):h.type==="mat3"&&h.size===1&&!h.isArray?f.a!==void 0?l.uniformMatrix3fv(d.location,!1,u.toArray(!0)):l.uniformMatrix3fv(d.location,!1,u):h.type==="vec2"&&h.size===1&&!h.isArray?f.x!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y)&&(a[0]=n.x,a[1]=n.y,l.uniform2f(d.location,n.x,n.y))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1])&&(a[0]=n[0],a[1]=n[1],l.uniform2f(d.location,n[0],n[1]))):h.type==="vec4"&&h.size===1&&!h.isArray?f.width!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y||a[2]!==n.width||a[3]!==n.height)&&(a[0]=n.x,a[1]=n.y,a[2]=n.width,a[3]=n.height,l.uniform4f(d.location,n.x,n.y,n.width,n.height))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1]||a[2]!==n[2]||a[3]!==n[3])&&(a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],l.uniform4f(d.location,n[0],n[1],n[2],n[3]))):(h.size===1&&!h.isArray?g3:x3)[h.type].call(null,l,d.location,d.value,u)}}function y3(){Object.assign(os.prototype,{systemCheck(){},syncUniforms(r,t){let{shader:e,renderer:i}=this;TF(r,e.program.uniformData,t.uniformData,r.uniforms,i)}})}y3();var Jc=new(window.AudioContext||window.webkitAudioContext),_3=(r,t)=>{let e,i=Jc.createGain();i.gain.value=t.volume??1,i.connect(Jc.destination);let s={id:r,url:t.url,loop:t.loop||!1,volume:t.volume??1};return{play:()=>{let m=ln.getAsset(s.url);if(!m){console.warn("AudioPlayer.play: Asset not found",s.url);return}e=Jc.createBufferSource(),e.buffer=m,e.loop=s.loop,i.gain.setValueAtTime(s.volume,Jc.currentTime),e.connect(i),e.start(0)},stop:()=>{e&&(e.stop(),e.disconnect(),i.disconnect(),i.connect(Jc.destination))},update:m=>{s={...s,...m}},getId:()=>s.id,getUrl:()=>s.url,getLoop:()=>s.loop,getVolume:()=>s.volume,setUrl:m=>{s.url=m},setLoop:m=>{s.loop=m},setVolume:m=>{s.volume=m,i.gain.value=m},get id(){return s.id},get url(){return s.url},get loop(){return s.loop},get volume(){return s.volume},gainNode:i}},SF=()=>{let r=[],t=[];return{add:a=>{t.push(a)},remove:a=>{t=t.filter(l=>l.id!==a)},getById:a=>t.find(l=>l.id===a),tick:()=>{for(let l of t){let c=r.find(h=>h.id===l.id);if(!c){let h=_3(l.id,{url:l.url,loop:l.loop,volume:l.volume??1});r.push(h),h.play();continue}(c.url!==l.url||c.loop!==l.loop)&&(c.stop(),c.setUrl(l.url),c.setLoop(l.loop??!1),c.play()),c.getVolume()!==(l.volume??1)&&c.setVolume(l.volume??1)}let a=[];for(let l of r)t.find(c=>c.id===l.id)||(l.stop(),a.push(l.id));r=r.filter(l=>!a.includes(l.id))},destroy:()=>{for(let a of r)a.stop();r=[],t=[]}}};var b3=({JSONObject:r,parserPlugins:t=[]})=>r.map(i=>{let s=t.find(o=>o.type===i.type);if(!s)throw new Error(`No parser plugin found for element type: ${i.type} (id: ${i.id??"unknown"})`);return s.parse({state:i,parserPlugins:t})});var Z_=b3;var wF=({type:r,parse:t})=>({type:r,parse:t});var Q_=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function J_(r,t,e,i){r.addEventListener?r.addEventListener(t,e,i):r.attachEvent&&r.attachEvent(`on${t}`,e)}function th(r,t,e,i){r&&(r.removeEventListener?r.removeEventListener(t,e,i):r.detachEvent&&r.detachEvent(`on${t}`,e))}function PF(r,t){let e=t.slice(0,t.length-1),i=[];for(let s=0;s<e.length;s++)i.push(r[e[s].toLowerCase()]);return i}function CF(r){typeof r!="string"&&(r=""),r=r.replace(/\s/g,"");let t=r.split(","),e=t.lastIndexOf("");for(;e>=0;)t[e-1]+=",",t.splice(e,1),e=t.lastIndexOf("");return t}function v3(r,t){let e=r.length>=t.length?r:t,i=r.length>=t.length?t:r,s=!0;for(let o=0;o<e.length;o++)i.indexOf(e[o])===-1&&(s=!1);return s}function RF(r){let t=r.keyCode||r.which||r.charCode;return r.code&&/^Key[A-Z]$/.test(r.code)&&(t=r.code.charCodeAt(3)),t}var ih={backspace:8,"\u232B":8,tab:9,clear:12,enter:13,"\u21A9":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\u21EA":20,",":188,".":190,"/":191,"`":192,"-":Q_?173:189,"=":Q_?61:187,";":Q_?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},kr={"\u21E7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,meta:91,command:91},eh={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Te={16:!1,18:!1,17:!1,91:!1},$t={};for(let r=1;r<20;r++)ih[`f${r}`]=111+r;var Dt=[],rh=null,MF="all",Ii=new Map,Zn=r=>ih[r.toLowerCase()]||kr[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),T3=r=>Object.keys(ih).find(t=>ih[t]===r),S3=r=>Object.keys(kr).find(t=>kr[t]===r),IF=r=>{MF=r||"all"},sh=()=>MF||"all",w3=()=>Dt.slice(0),E3=()=>Dt.map(r=>T3(r)||S3(r)||String.fromCharCode(r)),A3=()=>{let r=[];return Object.keys($t).forEach(t=>{$t[t].forEach(({key:e,scope:i,mods:s,shortcut:o})=>{r.push({scope:i,shortcut:o,mods:s,keys:e.split("+").map(n=>Zn(n))})})}),r},BF=r=>{let t=r.target||r.srcElement,{tagName:e}=t,i=!0,s=e==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(s||e==="TEXTAREA"||e==="SELECT")&&!t.readOnly)&&(i=!1),i},P3=r=>(typeof r=="string"&&(r=Zn(r)),Dt.indexOf(r)!==-1),C3=(r,t)=>{let e,i;r||(r=sh());for(let s in $t)if(Object.prototype.hasOwnProperty.call($t,s))for(e=$t[s],i=0;i<e.length;)e[i].scope===r?e.splice(i,1).forEach(({element:o})=>eb(o)):i++;sh()===r&&IF(t||"all")};function R3(r){let t=RF(r);r.key&&r.key.toLowerCase()==="capslock"&&(t=Zn(r.key));let e=Dt.indexOf(t);if(e>=0&&Dt.splice(e,1),r.key&&r.key.toLowerCase()==="meta"&&Dt.splice(0,Dt.length),(t===93||t===224)&&(t=91),t in Te){Te[t]=!1;for(let i in kr)kr[i]===t&&(nr[i]=!1)}}var FF=(r,...t)=>{if(typeof r>"u")Object.keys($t).forEach(e=>{Array.isArray($t[e])&&$t[e].forEach(i=>up(i)),delete $t[e]}),eb(null);else if(Array.isArray(r))r.forEach(e=>{e.key&&up(e)});else if(typeof r=="object")r.key&&up(r);else if(typeof r=="string"){let[e,i]=t;typeof e=="function"&&(i=e,e=""),up({key:r,scope:e,method:i,splitKey:"+"})}},up=({key:r,scope:t,method:e,splitKey:i="+"})=>{CF(r).forEach(s=>{let o=s.split(i),n=o.length,a=o[n-1],l=a==="*"?"*":Zn(a);if(!$t[l])return;t||(t=sh());let c=n>1?PF(kr,o):[],h=[];$t[l]=$t[l].filter(u=>{let d=(e?u.method===e:!0)&&u.scope===t&&v3(u.mods,c);return d&&h.push(u.element),!d}),h.forEach(u=>eb(u))})};function EF(r,t,e,i){if(t.element!==i)return;let s;if(t.scope===e||t.scope==="all"){s=t.mods.length>0;for(let o in Te)Object.prototype.hasOwnProperty.call(Te,o)&&(!Te[o]&&t.mods.indexOf(+o)>-1||Te[o]&&t.mods.indexOf(+o)===-1)&&(s=!1);(t.mods.length===0&&!Te[16]&&!Te[18]&&!Te[17]&&!Te[91]||s||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Dt),t.method(r,t)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function AF(r,t){let e=$t["*"],i=RF(r);if(r.key&&r.key.toLowerCase()==="capslock"||!(nr.filter||BF).call(this,r))return;if((i===93||i===224)&&(i=91),Dt.indexOf(i)===-1&&i!==229&&Dt.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{let l=eh[a];r[a]&&Dt.indexOf(l)===-1?Dt.push(l):!r[a]&&Dt.indexOf(l)>-1?Dt.splice(Dt.indexOf(l),1):a==="metaKey"&&r[a]&&(Dt=Dt.filter(c=>c in eh||c===i))}),i in Te){Te[i]=!0;for(let a in kr)if(Object.prototype.hasOwnProperty.call(kr,a)){let l=eh[kr[a]];nr[a]=r[l]}if(!e)return}for(let a in Te)Object.prototype.hasOwnProperty.call(Te,a)&&(Te[a]=r[eh[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Dt.indexOf(17)===-1&&Dt.push(17),Dt.indexOf(18)===-1&&Dt.push(18),Te[17]=!0,Te[18]=!0);let s=sh();if(e)for(let a=0;a<e.length;a++)e[a].scope===s&&(r.type==="keydown"&&e[a].keydown||r.type==="keyup"&&e[a].keyup)&&EF(r,e[a],s,t);if(!(i in $t))return;let o=$t[i],n=o.length;for(let a=0;a<n;a++)if((r.type==="keydown"&&o[a].keydown||r.type==="keyup"&&o[a].keyup)&&o[a].key){let l=o[a],{splitKey:c}=l,h=l.key.split(c),u=[];for(let d=0;d<h.length;d++)u.push(Zn(h[d]));u.sort().join("")===Dt.sort().join("")&&EF(r,l,s,t)}}var nr=function(r,t,e){Dt=[];let i=CF(r),s=[],o="all",n=document,a=0,l=!1,c=!0,h="+",u=!1,d=!1;if(e===void 0&&typeof t=="function"&&(e=t),Object.prototype.toString.call(t)==="[object Object]"){let f=t;f.scope&&(o=f.scope),f.element&&(n=f.element),f.keyup&&(l=f.keyup),f.keydown!==void 0&&(c=f.keydown),f.capture!==void 0&&(u=f.capture),typeof f.splitKey=="string"&&(h=f.splitKey),f.single===!0&&(d=!0)}for(typeof t=="string"&&(o=t),d&&FF(r,o);a<i.length;a++){let f=i[a].split(h);s=[],f.length>1&&(s=PF(kr,f));let p=f[f.length-1];p=p==="*"?"*":Zn(p),p in $t||($t[p]=[]),$t[p].push({keyup:l,keydown:c,scope:o,mods:s,shortcut:i[a],method:e,key:i[a],splitKey:h,element:n})}if(typeof n<"u"&&typeof window<"u"){if(!Ii.has(n)){let f=(m=window.event)=>AF(m,n),p=(m=window.event)=>{AF(m,n),R3(m)};Ii.set(n,{keydownListener:f,keyupListenr:p,capture:u}),J_(n,"keydown",f,u),J_(n,"keyup",p,u)}if(!rh){let f=()=>{Dt=[]};rh={listener:f,capture:u},J_(window,"focus",f,u)}}};function M3(r,t="all"){Object.keys($t).forEach(e=>{$t[e].filter(i=>i.scope===t&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method({},i)})})}function eb(r){let t=Object.values($t).flat();if(t.findIndex(({element:e})=>e===r)<0&&r){let{keydownListener:e,keyupListenr:i,capture:s}=Ii.get(r)||{};e&&i&&(th(r,"keyup",i,s),th(r,"keydown",e,s),Ii.delete(r))}if((t.length<=0||Ii.size<=0)&&(Array.from(Ii.keys()).forEach(e=>{let{keydownListener:i,keyupListenr:s,capture:o}=Ii.get(e)||{};i&&s&&(th(e,"keyup",s,o),th(e,"keydown",i,o),Ii.delete(e))}),Ii.clear(),Object.keys($t).forEach(e=>delete $t[e]),rh)){let{listener:e,capture:i}=rh;th(window,"focus",e,i),rh=null}}var tb={getPressedKeyString:E3,setScope:IF,getScope:sh,deleteScope:C3,getPressedKeyCodes:w3,getAllKeyCodes:A3,isPressed:P3,filter:BF,trigger:M3,unbind:FF,keyMap:ih,modifier:kr,modifierMap:eh};for(let r in tb){let t=r;Object.prototype.hasOwnProperty.call(tb,t)&&(nr[t]=tb[t])}if(typeof window<"u"){let r=window.hotkeys;nr.noConflict=t=>(t&&window.hotkeys===nr&&(window.hotkeys=r),nr),window.hotkeys=nr}var I3=Object.prototype.hasOwnProperty,kF=r=>{let t=new Map;return{registerHotkeys:(s={})=>{if(typeof s!="object"||s===null)return;let o=[],n=[],a=[];Object.keys(s).forEach(l=>{let c=t.get(l);c?gt(c.payload,s[l].payload)||(n.push(l),nr.unbind(l)):o.push(l)}),t.forEach((l,c)=>{I3.call(s,c)||a.push(c)}),a.forEach(l=>{nr.unbind(l),t.delete(l)}),[...o,...n].forEach(l=>{let h=s[l].payload??{};nr(l,()=>{r&&r("keydown",{_event:{key:l},...h})}),t.set(l,{value:l,payload:h})})},destroy:()=>{for(let s of t.keys())nr.unbind(s);t.clear()}}};var UF=(r,t)=>typeof t!="string"?t:r[t]??t,B3=(r,t,e,i)=>{let s=UF(e,t);if(typeof s=="string"){let n=r[s];return n===void 0?i:n}let o=r;for(let n of s){if(o==null)return i;o=o[n]}return o===void 0?i:o},OF=(r,t,e,i)=>{let s=UF(e,t);if(typeof s=="string")return r[s]=i,r;let o=r;for(let n=0;n<s.length-1;n++){let a=s[n];a in o||(o[a]={}),o=o[a]}return o[s[s.length-1]]=i,r},F3=(r,t,e)=>{if(!r||!Object.prototype.hasOwnProperty.call(r,t))throw new Error(`Animation "${e}" cannot auto-resolve property "${t}" from targetState.`);return r[t]},k3=(r,t,e,i,s)=>Object.entries(t).map(([o,n])=>{if(!dd[o])throw new Error(`${o} is not a supported property for animation.`);let a=B3(r,o,e,0);if(n.auto){let h=F3(i,o,s);if(a===h)return null;let u=xn([{value:a},{duration:n.auto.duration,value:h,easing:n.auto.easing}]);return{property:o,timeline:u}}let l=n.initialValue??a,c=xn([{value:l},...n.keyframes]);return{property:o,timeline:c}}).filter(Boolean),GF=()=>{let r=[],t=new Map,e=new Map,i=0,s=(S,v)=>{e.get(S)?.forEach(P=>{try{P(v)}catch{}})},o=S=>{if(s("completed",{id:S.id}),S.onComplete)try{S.onComplete()}catch{}},n=S=>{let{id:v,element:P,properties:C,targetState:A,onComplete:R,onCancel:M,propertyPathMap:I=fd}=S,k=k3(P,C,I,A,v);if(k.length===0){o({id:v,onComplete:R});return}let W={id:v,kind:"property",element:P,timelines:k,duration:tc(k),currentTime:0,stateVersion:i,targetState:A,onComplete:R,onCancel:M,applyFrame:O=>{for(let{property:z,timeline:V}of k){let G=ec(V,O);try{OF(P,z,I,G)}catch{}}},applyTargetState:()=>{if(!(!P||P.destroyed)){if(A===null){P.destroy();return}if(A)for(let[O,z]of Object.entries(A))try{OF(P,O,I,z)}catch{}}},isValid:()=>!!P&&!P.destroyed};W.applyFrame(0),t.set(v,W),s("started",{id:v})},a=S=>{let v={id:S.id,kind:"custom",duration:S.duration??0,currentTime:0,stateVersion:i,onComplete:S.onComplete,onCancel:S.onCancel,applyFrame:S.applyFrame??(()=>{}),applyTargetState:S.applyTargetState??(()=>{}),isValid:S.isValid??(()=>!0)};v.applyFrame(0),t.set(v.id,v),s("started",{id:v.id})},l=S=>{if(S.driver==="custom"){a(S);return}n(S)},c=S=>{try{S.applyTargetState?.()}catch{}if(S.onCancel)try{S.onCancel()}catch{}},h=S=>{switch(S.type){case"START":l(S.payload);break;case"CANCEL":d(S.id);break}},u=()=>{let S=r.splice(0);for(let v of S)h(v)},d=S=>{let v=t.get(S);v&&(c(v),t.delete(S),s("cancelled",{id:S}))},f=S=>{r.push(S)},p=()=>{for(let[S,v]of t)c(v),s("cancelled",{id:S});t.clear(),i++},m=S=>{u();let v=[];for(let[P,C]of t){if(C.stateVersion!==i){v.push(P);continue}if(!C.isValid()){v.push(P);continue}if(C.currentTime+=S,C.currentTime>=C.duration){C.applyFrame(C.duration),o(C),v.push(P);continue}C.applyFrame(C.currentTime)}for(let P of v)t.delete(P)},x=()=>{u()},_=(S,v)=>(e.has(S)||e.set(S,new Set),e.get(S).add(v),()=>T(S,v)),T=(S,v)=>{e.get(S)?.delete(v)};return{dispatch:f,cancelAll:p,flush:x,tick:m,on:_,off:T,getState:()=>({stateVersion:i,activeCount:t.size,animations:Array.from(t.entries()).map(([S,v])=>({id:S,currentTime:v.currentTime,duration:v.duration,progress:v.duration>0?v.currentTime/v.duration:0}))}),isAnimating:S=>t.has(S),destroy:()=>{p(),e.clear()}}};var LF=r=>{let t=0,e=0,i=null;return{reset:c=>{t>0&&i!==null&&r?.("renderComplete",{id:i,aborted:!0}),e++,t=0,i=c},track:c=>{c===e&&t++},complete:c=>{c===e&&(t--,t===0&&r?.("renderComplete",{id:i,aborted:!1}))},getVersion:()=>e,completeIfEmpty:()=>{t===0&&r?.("renderComplete",{id:i,aborted:!1})}}};var DF=new Set(["update","transition"]),O3=new Set(["alpha","x","y","scaleX","scaleY","rotation"]),U3=new Set(["translateX","translateY","alpha","scaleX","scaleY","rotation"]),NF=new Set(["single","sequence","composite"]),dp=new Set(["red","green","blue","alpha"]),HF=new Set(["max","min","multiply","add"]),WF=new Set(Vd),oi=(r,t)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`${t} must be an object.`)},io=(r,t)=>{if(typeof r!="string"||r.length===0)throw new Error(`${t} must be a non-empty string.`)},oh=(r,t)=>{if(typeof r!="number"||Number.isNaN(r))throw new Error(`${t} must be a number.`)},G3=(r,t)=>{if(oi(r,t),oh(r.duration,`${t}.duration`),r.easing!==void 0&&typeof r.easing!="string")throw new Error(`${t}.easing must be a string.`);if(r.easing!==void 0&&!WF.has(r.easing))throw new Error(`${t}.easing must be one of: ${Vd.join(", ")}.`);return{duration:r.duration,easing:r.easing??"linear"}},ib=(r,t)=>{oi(r,t);let e={};if(r.initialValue!==void 0&&(oh(r.initialValue,`${t}.initialValue`),e.initialValue=r.initialValue),!Array.isArray(r.keyframes)||r.keyframes.length===0)throw new Error(`${t}.keyframes must be a non-empty array.`);return e.keyframes=r.keyframes.map((i,s)=>{let o=`${t}.keyframes[${s}]`;if(oi(i,o),oh(i.value,`${o}.value`),oh(i.duration,`${o}.duration`),i.easing!==void 0&&typeof i.easing!="string")throw new Error(`${o}.easing must be a string.`);if(i.easing!==void 0&&!WF.has(i.easing))throw new Error(`${o}.easing must be one of: ${Vd.join(", ")}.`);if(i.relative!==void 0&&typeof i.relative!="boolean")throw new Error(`${o}.relative must be a boolean.`);return{value:i.value,duration:i.duration,easing:i.easing??"linear",...i.relative!==void 0?{relative:i.relative}:{}}}),e},L3=(r,t)=>{oi(r,t);let e=r.keyframes!==void 0,i=r.auto!==void 0;if(e&&i)throw new Error(`${t} cannot define both keyframes and auto.`);if(!e&&!i)throw new Error(`${t} must define keyframes or auto.`);if(i){if(r.initialValue!==void 0)throw new Error(`${t}.initialValue is not valid when auto is defined.`);return{auto:G3(r.auto,`${t}.auto`)}}return ib(r,t)},zF=(r,t,e,i=ib)=>{oi(r,t);let s=Object.entries(r).map(([o,n])=>{if(!e.has(o))throw new Error(`${t}.${o} is not a supported animation property.`);return[o,i(n,`${t}.${o}`)]});if(s.length===0)throw new Error(`${t} must define at least one property.`);return Object.fromEntries(s)},D3=(r,t)=>{if(oi(r,t),io(r.texture,`${t}.texture`),r.channel!==void 0&&!dp.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(dp).join(", ")}.`);if(r.invert!==void 0&&typeof r.invert!="boolean")throw new Error(`${t}.invert must be a boolean.`);return{texture:r.texture,...r.channel?{channel:r.channel}:{},...r.invert!==void 0?{invert:r.invert}:{}}},N3=(r,t)=>{if(oi(r,t),!NF.has(r.kind))throw new Error(`${t}.kind must be one of: ${Array.from(NF).join(", ")}.`);let e={kind:r.kind};if(r.channel!==void 0){if(!dp.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(dp).join(", ")}.`);e.channel=r.channel}if(r.softness!==void 0&&(oh(r.softness,`${t}.softness`),e.softness=r.softness),r.invert!==void 0){if(typeof r.invert!="boolean")throw new Error(`${t}.invert must be a boolean.`);e.invert=r.invert}if(r.progress!==void 0&&(e.progress=ib(r.progress,`${t}.progress`)),r.kind==="single"&&(io(r.texture,`${t}.texture`),e.texture=r.texture),r.kind==="sequence"){if(!Array.isArray(r.textures)||r.textures.length===0)throw new Error(`${t}.textures must be a non-empty array.`);e.textures=r.textures.map((i,s)=>(io(i,`${t}.textures[${s}]`),i)),r.sample!==void 0&&(io(r.sample,`${t}.sample`),e.sample=r.sample)}if(r.kind==="composite"){if(!HF.has(r.combine??"max"))throw new Error(`${t}.combine must be one of: ${Array.from(HF).join(", ")}.`);if(!Array.isArray(r.items)||r.items.length===0)throw new Error(`${t}.items must be a non-empty array.`);e.combine=r.combine??"max",e.items=r.items.map((i,s)=>D3(i,`${t}.items[${s}]`))}return e.progress||(e.progress={initialValue:0,keyframes:[{duration:0,value:1,easing:"linear"}]}),e},VF=(r,t)=>{if(oi(r,t),r.mask!==void 0)throw new Error(`${t}.mask is not valid. Define mask on ${t}.`);let e={};if(r.tween!==void 0&&(e.tween=zF(r.tween,`${t}.tween`,U3)),Object.keys(e).length===0)throw new Error(`${t} must define tween.`);return e},H3=(r,t)=>{let e={};if(r.shader!==void 0)throw new Error(`${t}.shader is not supported.`);if(r.prev!==void 0&&(e.prev=VF(r.prev,`${t}.prev`)),r.next!==void 0&&(e.next=VF(r.next,`${t}.next`)),r.mask!==void 0&&(e.mask=N3(r.mask,`${t}.mask`)),e.prev===void 0&&e.next===void 0&&e.mask===void 0)throw new Error(`${t} must define prev, next, or mask.`);return e},rb=(r,t,e)=>{if(r!==void 0)throw new Error(`${t} ${e}`)},$F=(r=[])=>{if(!Array.isArray(r))throw new Error("Input error: `animations` must be an array.");let t=r.map((i,s)=>{let o=`animations[${s}]`;if(oi(i,o),io(i.id,`${o}.id`),io(i.targetId,`${o}.targetId`),io(i.type,`${o}.type`),!DF.has(i.type))throw new Error(`${o}.type must be one of: ${Array.from(DF).join(", ")}.`);let n={id:i.id,targetId:i.targetId,type:i.type};if(i.complete!==void 0&&(oi(i.complete,`${o}.complete`),n.complete=i.complete),rb(i.operation,`${o}.operation`,"is no longer supported. Use `type: update | transition` instead."),rb(i.properties,`${o}.properties`,"is no longer supported. Use `tween` instead."),rb(i.subjects,`${o}.subjects`,"is no longer supported. Use `prev` / `next` instead."),i.type==="update"){if(n.tween=zF(i.tween,`${o}.tween`,O3,L3),i.replace!==void 0)throw new Error(`${o}.replace is no longer supported. Define \`prev\`, \`next\`, or \`mask\` directly on the animation.`);if(i.prev!==void 0)throw new Error(`${o}.prev is only valid for transition animations.`);if(i.next!==void 0)throw new Error(`${o}.next is only valid for transition animations.`);if(i.mask!==void 0)throw new Error(`${o}.mask is only valid for transition animations.`);if(i.shader!==void 0)throw new Error(`${o}.shader is not supported.`);return n}if(i.tween!==void 0)throw new Error(`${o}.tween is not valid for transition animations.`);if(i.replace!==void 0)throw new Error(`${o}.replace is no longer supported. Define \`prev\`, \`next\`, or \`mask\` directly on the animation.`);let a=H3(i,o);return a.prev!==void 0&&(n.prev=a.prev),a.next!==void 0&&(n.next=a.next),a.mask!==void 0&&(n.mask=a.mask),n}),e=new Map;for(let i of t){let s=e.get(i.targetId)??new Set;s.add(i.type),e.set(i.targetId,s)}for(let[i,s]of e)if(s.has("transition")&&s.size>1)throw new Error(`Animations targeting "${i}" cannot mix update and transition types in the same state.`);return t};var sb=(r={})=>{if(r===null||typeof r!="object")throw new Error("Input error: render state must be an object.");if(r.transitions!==void 0)throw new Error("Input error: `transitions` is no longer supported. Use `animations` instead.");let t={...r,elements:r.elements??[],animations:r.animations??[],audio:r.audio??[]};if(!Array.isArray(t.elements))throw new Error("Input error: `elements` must be an array.");if(!Array.isArray(t.animations))throw new Error("Input error: `animations` must be an array.");if(!Array.isArray(t.audio))throw new Error("Input error: `audio` must be an array.");return t.animations=$F(t.animations),t};var V3="0",Qn=(r,t)=>{let e=r?.[t];return typeof e=="number"?e:0},ar=r=>({value:r.element.value??"",selectionStart:Qn(r.element,"selectionStart"),selectionEnd:Qn(r.element,"selectionEnd"),focused:document.activeElement===r.element,composing:r.composing===!0}),W3=(r,t)=>!r||!t?!1:r.value===t.value&&r.selectionStart===t.selectionStart&&r.selectionEnd===t.selectionEnd&&r.focused===t.focused&&r.composing===t.composing,z3=r=>r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement,nh=r=>{r.element.style.pointerEvents="none"},ob=(r,t,e)=>{if(typeof r?.setSelectionRange=="function")try{r.setSelectionRange(t,e)}catch{}},$3=({app:r,geometry:t})=>{let e=r.canvas;if(!t||!e||t.visible===!1)return null;let i=e.getBoundingClientRect(),s=r.renderer?.width||i.width||1,o=r.renderer?.height||i.height||1,n=i.width/s,a=i.height/o,l=t.clipInsets??{top:0,right:0,bottom:0,left:0},c=i.left+(t.x+l.left)*n,h=i.top+(t.y+l.top)*a,u=i.left+(t.x+t.width-l.right)*n,d=i.top+(t.y+t.height-l.bottom)*a;return u<=c||d<=h?null:{left:c,top:h,right:u,bottom:d}},X3=({app:r,entry:t,event:e})=>{let i=t.options.getGeometry?.(),s=$3({app:r,geometry:i}),o=e.clientX,n=e.clientY;return!!s&&Number.isFinite(o)&&Number.isFinite(n)&&o>=s.left&&o<=s.right&&n>=s.top&&n<=s.bottom},XF=({app:r})=>{let t=new Map,e,i=null,s=()=>{e||(e=document.createElement("div"),e.dataset.routeGraphicsInputBridge="true",e.style.position="fixed",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",e.style.zIndex="1000",e.style.width="0",e.style.height="0");let g=r.canvas?.parentNode??document.body;e.isConnected||g.appendChild(e)},o=(g,w=g.lastSnapshot)=>{let b=ar(g);b.focused&&i!==g.id?i=g.id:!b.focused&&i===g.id&&(i=null),nh(g,i),w?.value!==b.value&&g.callbacks.onValueChange?.(b),(w?.selectionStart!==b.selectionStart||w?.selectionEnd!==b.selectionEnd||w?.focused!==b.focused||w?.composing!==b.composing)&&g.callbacks.onSelectionChange?.(b),g.lastSnapshot=b},n=g=>{let{disabled:w=!1,multiline:b=!1,maxLength:S,textStyle:v,padding:P,placeholder:C="",autocomplete:A="off",autocapitalize:R="off",spellcheck:M=!1}=g.options,{element:I}=g;I instanceof HTMLInputElement&&(I.type="text"),I.disabled=w,I.placeholder=C,I.autocomplete=A,I.autocapitalize=R,I.spellcheck=!!M,I.style.opacity=V3,I.style.color="transparent",I.style.caretColor="transparent",I.style.background="transparent",I.style.paddingTop=`${P.top}px`,I.style.paddingRight=`${P.right}px`,I.style.paddingBottom=`${P.bottom}px`,I.style.paddingLeft=`${P.left}px`,I.style.fontFamily=v?.fontFamily??"Arial",I.style.fontSize=`${v?.fontSize??16}px`,I.style.fontWeight=v?.fontWeight??"400",I.style.textAlign=v?.align??"left",I.style.lineHeight=typeof v?.lineHeight=="number"?`${v.lineHeight}px`:"normal",I.style.whiteSpace=b?"pre":"nowrap",I.style.overflowWrap="normal",I.style.resize="none",I.style.overflow="hidden",typeof S=="number"?I.maxLength=S:I.removeAttribute("maxLength"),I.tabIndex=-1,b&&I instanceof HTMLTextAreaElement&&(I.wrap="off",I.rows=1),nh(g,i)},a=g=>{s();let w=r.canvas,b=g.options.getGeometry?.();if(!w||!b||b.visible===!1){g.element.style.display="none";return}let S=w.getBoundingClientRect(),v=r.renderer?.width||S.width||1,P=r.renderer?.height||S.height||1,C=S.width/v,A=S.height/P,R=b.clipInsets??{top:0,right:0,bottom:0,left:0},M={top:R.top*A,right:R.right*C,bottom:R.bottom*A,left:R.left*C};g.element.style.display="block",g.element.style.left=`${S.left+b.x*C}px`,g.element.style.top=`${S.top+b.y*A}px`,g.element.style.width=`${b.width*C}px`,g.element.style.height=`${b.height*A}px`;let I=Object.values(M).some(k=>k>0);g.element.style.clipPath=I?`inset(${M.top}px ${M.right}px ${M.bottom}px ${M.left}px)`:"none"},l=g=>{if(!i)return;let w=t.get(i),b=g.target;!w||b===w.element||w.element.contains(b)||z3(b)&&e?.contains(b)||X3({app:r,entry:w,event:g})||w.element.blur()},c=()=>{for(let g of t.values()){if(a(g),!g.lastSnapshot){g.lastSnapshot=ar(g);continue}let w=ar(g);W3(w,g.lastSnapshot)||o(g,g.lastSnapshot)}},h=({id:g,options:w})=>{let b=w.multiline===!0?document.createElement("textarea"):document.createElement("input");return b.dataset.routeGraphicsInputId=g,b.style.position="fixed",b.style.border="none",b.style.outline="none",b.style.margin="0",b.style.boxSizing="border-box",b.style.borderRadius="0",b.style.transformOrigin="top left",b.style.appearance="none",b.style.boxShadow="none",b.style.userSelect="none",b.style.webkitUserSelect="none",b},u=g=>{let{id:w,element:b}=g,S=()=>{o(g)};b.addEventListener("focus",()=>{g.pendingBlurTimer&&(clearTimeout(g.pendingBlurTimer),g.pendingBlurTimer=null),i=w,nh(g,i);let v=ar(g);g.lastSnapshot=v,g.callbacks.onFocus?.(v),g.callbacks.onSelectionChange?.(v)}),b.addEventListener("blur",()=>{i===w&&(i=null),nh(g,i),g.pendingBlurTimer=setTimeout(()=>{g.pendingBlurTimer=null;let v=ar(g);if(v.focused){g.lastSnapshot=v;return}g.lastSnapshot=v,g.callbacks.onBlur?.(v),g.callbacks.onSelectionChange?.(v)},0)}),b.addEventListener("input",S),b.addEventListener("select",S),b.addEventListener("click",()=>queueMicrotask(S)),b.addEventListener("keyup",()=>queueMicrotask(S)),b.addEventListener("keydown",v=>{let P=v.key==="Enter"&&g.options.multiline!==!0&&!v.shiftKey,C=v.key==="Enter"&&g.options.multiline===!0&&(v.ctrlKey||v.metaKey);(P||C)&&(v.preventDefault(),g.callbacks.onSubmit?.(ar(g),v)),v.key==="Escape"&&b.blur(),queueMicrotask(S)}),b.addEventListener("compositionstart",()=>{g.composing=!0;let v=ar(g);g.lastSnapshot=v,g.callbacks.onCompositionStart?.(v),g.callbacks.onSelectionChange?.(v)}),b.addEventListener("compositionupdate",()=>{let v=ar(g);g.lastSnapshot=v,g.callbacks.onCompositionUpdate?.(v),g.callbacks.onSelectionChange?.(v)}),b.addEventListener("compositionend",()=>{g.composing=!1,S(),g.callbacks.onCompositionEnd?.(ar(g))})};document.addEventListener("pointerdown",l,!0),r.ticker?.add?.(c);let d=(g,w)=>{s();let b=t.get(g);if(b)return b.options=w,b.callbacks=w.callbacks??{},n(b),a(b),typeof w.value=="string"&&b.element.value!==w.value&&(b.element.value=w.value),b.lastSnapshot=ar(b),b.element;let S={id:g,element:h({id:g,options:w}),options:w,callbacks:w.callbacks??{},composing:!1,pendingBlurTimer:null,lastSnapshot:null};return u(S),typeof w.value=="string"&&(S.element.value=w.value),n(S),e.appendChild(S.element),t.set(g,S),a(S),S.lastSnapshot=ar(S),S.element};return{mount:d,update:(g,w)=>{let b=t.get(g);if(!b)return d(g,w);let S=w.multiline===!0!=b.element instanceof HTMLTextAreaElement;if(b.options=w,b.callbacks=w.callbacks??{},S){let v=b.element,P=document.activeElement===v,C=Qn(v,"selectionStart"),A=Qn(v,"selectionEnd");return b.element=h({id:g,options:w}),u(b),v.replaceWith(b.element),b.element.value=typeof w.value=="string"?w.value:v.value,n(b),a(b),b.lastSnapshot=ar(b),P&&!w.disabled&&queueMicrotask(()=>{b.element.focus(),ob(b.element,C,A)}),b.element}return typeof w.value=="string"&&w.value!==b.element.value&&b.composing!==!0&&(b.element.value=w.value),n(b),a(b),b.lastSnapshot=ar(b),b.element},focus:(g,{selectAll:w=!1,selectionStart:b,selectionEnd:S}={})=>{let v=t.get(g);if(!v||v.element.disabled)return;let P=document.activeElement===v.element;if(i=g,nh(v,i),P||v.element.focus(),w){v.element.select?.(),o(v,v.lastSnapshot);return}if(typeof b=="number"||typeof S=="number"){let C=typeof b=="number"?b:Qn(v.element,"selectionStart"),A=typeof S=="number"?S:typeof b=="number"?b:Qn(v.element,"selectionEnd");ob(v.element,C,A)}o(v,v.lastSnapshot)},setSelection:(g,w,b=w,{focus:S=!1}={})=>{let v=t.get(g);if(!v||v.element.disabled)return;let P=()=>{ob(v.element,w,b),o(v,v.lastSnapshot)};if(S&&document.activeElement!==v.element){v.element.focus(),P();return}P()},blur:g=>{t.get(g)?.element.blur()},unmount:g=>{let w=t.get(g);w&&(i===g&&(i=null),w.pendingBlurTimer&&(clearTimeout(w.pendingBlurTimer),w.pendingBlurTimer=null),w.element.remove(),t.delete(g),t.size===0&&e?.remove())},destroy:()=>{document.removeEventListener("pointerdown",l,!0),r.ticker?.remove?.(c);for(let g of t.values())g.pendingBlurTimer&&(clearTimeout(g.pendingBlurTimer),g.pendingBlurTimer=null),g.element.remove();t.clear(),i=null,e?.remove(),e=void 0}}};var j3=()=>{let r,t=SF(),e={elements:[],animations:[],audio:[]},i,s={animations:[],elements:[],audio:[],parsers:[]},o,n,a,l,c=!1,h,u,d,f,p=new Map,m,x=(v,P,C,A)=>{v.clear(),v.rect(0,0,P,C),v.fill(A??0)},_=v=>v?v.startsWith("audio/")?"audio":v.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(v)?"font":v.startsWith("video/")?"video":"texture":"texture",T=(v,P,{revokable:C=!1}={})=>{p.set(v,{url:P,revokable:C})},g=()=>{for(let v of p.values())v?.revokable===!0&&typeof v?.url=="string"&&URL.revokeObjectURL(v.url);p.clear()},w=(v,P,C)=>{o&&o.registerHotkeys(C?.keyboard??{}),v.renderer.events.cursorStyles||(v.renderer.events.cursorStyles={}),v.renderer.events.cursorStyles.default||(v.renderer.events.cursorStyles.default="default"),v.renderer.events.cursorStyles.hover||(v.renderer.events.cursorStyles.hover="pointer");let A=P?.cursorStyles,R=C?.cursorStyles;gt(A,R)||(R?(R.default&&(v.renderer.events.cursorStyles.default=R.default,v.canvas.style.cursor=R.default),R.hover&&(v.renderer.events.cursorStyles.hover=R.hover)):A&&(v.renderer.events.cursorStyles.default="default",v.renderer.events.cursorStyles.hover="pointer"))},b=(v,P,C,A)=>{h&&h.abort(),h=new AbortController;let R=h.signal;a.reset(C.id),w(v,e.global,C.global),n.cancelAll(),ks({app:v,parent:P,prevComputedTree:e.elements,nextComputedTree:C.elements,animations:C.animations,elementPlugins:s.elements,animationBus:n,completionTracker:a,eventHandler:A,signal:R}),n.flush(),By({app:v,prevAudioTree:e.audio,nextAudioTree:C.audio,audioPlugins:s.audio}),e=C,typeof v.render=="function"&&v.render(),a.completeIfEmpty(),c||(c=!0,l&&l())},S={rendererName:"pixi",get canvas(){return r.canvas},findElementByLabel:v=>r.stage.getChildByLabel(v,!0)??null,extractBase64:async v=>{let P=new Q(0,0,r.renderer.width,r.renderer.height);if(!v)return await r.renderer.extract.base64({target:r.stage,frame:P});let C=r.stage.getChildByLabel(v,!0);if(!C)throw new Error(`Element with label '${v}' not found`);return await r.renderer.extract.base64({target:C,frame:P})},assignStageEvent:(v,P)=>{r.stage.eventMode="static",r.stage.on(v,P)},init:async v=>{let{eventHandler:P,plugins:C,width:A,height:R,backgroundColor:M,debug:I=!1,onFirstRender:k}=v;l=k;let W=[];return C?.elements?.forEach(O=>{O?.parse&&W.push(wF({type:O.type,parse:O.parse}))}),s={animations:C?.animations??[],elements:C?.elements??[],audio:C?.audio??[],parsers:W},i=P,o=kF(P),a=LF(P),r=new Wl,r.audioStage=t,await r.init({width:A,height:R,backgroundColor:M,preference:"webgl"}),typeof r.ticker?.remove=="function"&&r.ticker.remove(r.render,r),r.debug=I,r.inputDomBridge=XF({app:r}),f=O=>{O.preventDefault()},r.canvas.addEventListener("contextmenu",f),m=new Bt,m.label="__route_graphics_background__",x(m,A,R,M),r.stage.addChild(m),r.stage.width=A,r.stage.height=R,r.ticker.add(r.audioStage.tick),n=GF(),I?(u=O=>{O?.detail?.deltaMS&&(n.tick(Number(O.detail.deltaMS)),typeof r.render=="function"&&r.render())},window.addEventListener("snapShotKeyFrame",u)):(d=O=>{n.tick(O.deltaMS),typeof r.render=="function"&&r.render()},r.ticker.add(d)),S},destroy:()=>{h&&(h.abort(),h=void 0),u&&(window.removeEventListener("snapShotKeyFrame",u),u=void 0),d&&typeof r?.ticker?.remove=="function"&&(r.ticker.remove(d),d=void 0),f&&r?.canvas&&(r.canvas.removeEventListener("contextmenu",f),f=void 0),r?.inputDomBridge?.destroy?.(),o?.destroy(),Ey(),n&&n.destroy(),r?.audioStage&&r.audioStage.destroy();let v=P=>{for(let C of P.children){let A=C.texture?.source?.resource;A instanceof HTMLVideoElement&&A.pause(),C.children&&v(C)}};r?.stage&&v(r.stage),r&&r.destroy(),m=void 0,g()},loadAssets:async v=>{if(!v)throw new Error("assetBufferMap is required");let P={audio:{},font:{},video:{},texture:{}};for(let[R,M]of Object.entries(v)){let I=_(M.type);P[I][R]=M}await Promise.all(Object.entries(P.audio).map(([R,M])=>ln.load(R,M.buffer))),await Promise.all(Object.entries(P.font).map(async([R,M])=>{let I=new Blob([M.buffer],{type:M.type}),k=URL.createObjectURL(I),W=new FontFace(R,`url(${k})`);try{await W.load(),document.fonts.add(W)}catch(O){console.error(`Failed to load font ${R}:`,O)}finally{URL.revokeObjectURL(k)}}));let C=Object.entries(P.texture).map(async([R,M])=>{if(gr.cache.has(R))return gr.cache.get(R);if(M?.source==="url"&&typeof M?.url=="string")return gr.load({alias:R,src:M.url,parser:"loadTextures"});let I=new Blob([M.buffer],{type:M.type}),k=await createImageBitmap(I),W=B.from(k);return gr.cache.set(R,W),W}),A=Object.entries(P.video).map(async([R,M])=>{let I=M?.source==="url"&&typeof M?.url=="string"?M.url:URL.createObjectURL(new Blob([M.buffer],{type:M.type})),k=M?.source!=="url";T(R,I,{revokable:k});let W={alias:R,src:I,parser:"loadVideo",data:{}};return typeof M?.type=="string"&&M.type.length>0&&(W.data.mime=M.type),gr.load(W).then(O=>O).catch(O=>{throw p.delete(R),k&&URL.revokeObjectURL(I),O})});return Promise.all([...C,...A])},loadAudioAssets:async v=>Promise.all(v.map(async P=>{let A=await(await fetch(P)).arrayBuffer();return ln.load(P,A)})),updatedBackgroundColor:v=>{r.renderer.background.color=v,m&&x(m,r.renderer.width,r.renderer.height,v),typeof r.render=="function"&&r.render()},render:v=>{let P=sb(v),C=Z_({JSONObject:P.elements,parserPlugins:s.parsers}),A={...P,elements:C};b(r,r.stage,A,i)},parse:v=>{let P=sb(v),C=Z_({JSONObject:P.elements,parserPlugins:s.parsers});return{...P,elements:C}}};return S},jF=j3;var HCt=jF;export{Wl as Application,gr as Assets,ln as AudioAsset,VG as animatedSpritePlugin,OG as containerPlugin,Jx as createAnimationPlugin,rk as createAssetBufferManager,ty as createAudioPlugin,Zt as createElementPlugin,HCt as default,fG as inputPlugin,KG as particlesPlugin,HU as rectPlugin,By as renderAudio,ks as renderElements,tG as sliderPlugin,$G as soundPlugin,VU as spritePlugin,LU as textPlugin,HG as textRevealingPlugin,WG as tweenPlugin,zU as videoPlugin};
|
|
1634
|
+
`))}}var l3=0,sp={textureCount:0,uboCount:0},os=class{constructor(t){this.destroyed=!1,this.renderer=t,this.systemCheck(),this.gl=null,this.shader=null,this.program=null,this.cache={},this._uboCache={},this.id=l3++}systemCheck(){if(!Jf())throw new Error("Current environment does not allow unsafe-eval, please use @pixi/unsafe-eval module to enable support.")}contextChange(t){this.gl=t,this.reset()}bind(t,e){t.disposeRunner.add(this),t.uniforms.globals=this.renderer.globalUniforms;let i=t.program,s=i.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==i&&(this.program=i,this.gl.useProgram(s.program)),e||(sp.textureCount=0,sp.uboCount=0,this.syncUniformGroup(t.uniformGroup,sp)),s}setUniforms(t){let e=this.shader.program,i=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(i.uniformData,t,this.renderer)}syncUniformGroup(t,e){let i=this.getGlProgram();(!t.static||t.dirtyId!==i.uniformDirtyGroups[t.id])&&(i.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,i,e))}syncUniforms(t,e,i){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,i)}createSyncGroups(t){let e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=B_(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){let i=this.getGlProgram();if(!t.static||t.dirtyId!==0||!i.uniformGroups[t.id]){t.dirtyId=0;let s=i.uniformGroups[t.id]||this.createSyncBufferGroup(t,i,e);t.buffer.update(),s(i.uniformData,t.uniforms,this.renderer,sp,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,i.uniformBufferBindings[e])}createSyncBufferGroup(t,e,i){let{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);let o=this.gl.getUniformBlockIndex(e.program,i);e.uniformBufferBindings[i]=this.shader.uniformBindCount,s.uniformBlockBinding(e.program,o,this.shader.uniformBindCount),this.shader.uniformBindCount++;let n=this.getSignature(t,this.shader.program.uniformData,"ubo"),a=this._uboCache[n];if(a||(a=this._uboCache[n]=H_(t,this.shader.program.uniformData)),t.autoManage){let l=new Float32Array(a.size/4);t.buffer.update(l)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,i){let s=t.uniforms,o=[`${i}-`];for(let n in s)o.push(n),e[n]&&o.push(e[n].type);return o.join("-")}getGlProgram(){return this.shader?this.shader.program.glPrograms[this.renderer.CONTEXT_UID]:null}generateProgram(t){let e=this.gl,i=t.program,s=N_(e,i);return i.glPrograms[this.renderer.CONTEXT_UID]=s,s}reset(){this.program=null,this.shader=null}disposeShader(t){this.shader===t&&(this.shader=null)}destroy(){this.renderer=null,this.destroyed=!0}};os.extension={type:$.RendererSystem,name:"shader"};K.add(os);var Ri=class{constructor(t){this.renderer=t}run(t){let{renderer:e}=this;e.runners.init.emit(e.options),t.hello&&console.log(`PixiJS 7.4.3 - ${e.rendererLogId} - https://pixijs.com`),e.resize(e.screen.width,e.screen.height)}destroy(){}};Ri.defaultOptions={hello:!1},Ri.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"};K.add(Ri);function gF(r,t=[]){return t[J.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.ADD]=[r.ONE,r.ONE],t[J.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.NONE]=[0,0],t[J.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[J.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[J.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[J.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[J.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[J.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[J.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[J.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[J.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[J.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[J.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}var c3=0,h3=1,u3=2,d3=3,f3=4,p3=5,xF=class V_{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=J.NONE,this._blendEq=!1,this.map=[],this.map[c3]=this.setBlend,this.map[h3]=this.setOffset,this.map[u3]=this.setCullFace,this.map[d3]=this.setDepthTest,this.map[f3]=this.setFrontFace,this.map[p3]=this.setDepthMask,this.checks=[],this.defaultState=new ei,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=gF(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,i=0;for(;e;)e&1&&this.map[i].call(this,!!(t.data&1<<i)),e=e>>1,i++;this.stateId=t.data}for(let e=0;e<this.checks.length;e++)this.checks[e](this,t)}forceState(t){t=t||this.defaultState;for(let e=0;e<this.map.length;e++)this.map[e].call(this,!!(t.data&1<<e));for(let e=0;e<this.checks.length;e++)this.checks[e](this,t);this.stateId=t.data}setBlend(t){this.updateCheck(V_.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(V_.checkPolygonOffset,t),this.gl[t?"enable":"disable"](this.gl.POLYGON_OFFSET_FILL)}setDepthTest(t){this.gl[t?"enable":"disable"](this.gl.DEPTH_TEST)}setDepthMask(t){this.gl.depthMask(t)}setCullFace(t){this.gl[t?"enable":"disable"](this.gl.CULL_FACE)}setFrontFace(t){this.gl.frontFace(this.gl[t?"CW":"CCW"])}setBlendMode(t){if(t===this.blendMode)return;this.blendMode=t;let e=this.blendModes[t],i=this.gl;e.length===2?i.blendFunc(e[0],e[1]):i.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,i.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,i.blendEquationSeparate(i.FUNC_ADD,i.FUNC_ADD))}setPolygonOffset(t,e){this.gl.polygonOffset(t,e)}reset(){this.gl.pixelStorei(this.gl.UNPACK_FLIP_Y_WEBGL,!1),this.forceState(this.defaultState),this._blendEq=!0,this.blendMode=-1,this.setBlendMode(0)}updateCheck(t,e){let i=this.checks.indexOf(t);e&&i===-1?this.checks.push(t):!e&&i!==-1&&this.checks.splice(i,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};xF.extension={type:$.RendererSystem,name:"state"};var W_=xF;K.add(W_);var jn=class extends Vs.default{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);let e=(t.priority??[]).filter(s=>t.systems[s]),i=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(let s of i)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Jt(e)})}addSystem(t,e){let i=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=i,this._systemsHash[e]=i;for(let s in this.runners)this.runners[s].add(i);return this}emitWithCustomOptions(t,e){let i=Object.keys(this._systemsHash);t.items.forEach(s=>{let o=i.find(n=>this._systemsHash[n]===s);s[t.name](e[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}};var zc=class op{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=op.defaultMaxIdle,this.checkCountMax=op.defaultCheckCountMax,this.mode=op.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==yf.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this.renderer.texture,e=t.managedTextures,i=!1;for(let s=0;s<e.length;s++){let o=e[s];o.resource&&this.count-o.touched>this.maxIdle&&(t.destroyTexture(o,!0),e[s]=null,i=!0)}if(i){let s=0;for(let o=0;o<e.length;o++)e[o]!==null&&(e[s++]=e[o]);e.length=s}}unload(t){let e=this.renderer.texture,i=t._texture;i&&!i.framebuffer&&e.destroyTexture(i);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};zc.defaultMode=yf.AUTO,zc.defaultMaxIdle=60*60,zc.defaultCheckCountMax=60*10,zc.extension={type:$.RendererSystem,name:"textureGC"};var si=zc;K.add(si);var eo=class{constructor(t){this.texture=t,this.width=-1,this.height=-1,this.dirtyId=-1,this.dirtyStyleId=-1,this.mipmap=!1,this.wrapMode=33071,this.type=nt.UNSIGNED_BYTE,this.internalFormat=L.RGBA,this.samplerType=0}};function yF(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:H.FLOAT,[r.RGBA]:H.FLOAT,[r.ALPHA]:H.FLOAT,[r.LUMINANCE]:H.FLOAT,[r.LUMINANCE_ALPHA]:H.FLOAT,[r.R8]:H.FLOAT,[r.R8_SNORM]:H.FLOAT,[r.RG8]:H.FLOAT,[r.RG8_SNORM]:H.FLOAT,[r.RGB8]:H.FLOAT,[r.RGB8_SNORM]:H.FLOAT,[r.RGB565]:H.FLOAT,[r.RGBA4]:H.FLOAT,[r.RGB5_A1]:H.FLOAT,[r.RGBA8]:H.FLOAT,[r.RGBA8_SNORM]:H.FLOAT,[r.RGB10_A2]:H.FLOAT,[r.RGB10_A2UI]:H.FLOAT,[r.SRGB8]:H.FLOAT,[r.SRGB8_ALPHA8]:H.FLOAT,[r.R16F]:H.FLOAT,[r.RG16F]:H.FLOAT,[r.RGB16F]:H.FLOAT,[r.RGBA16F]:H.FLOAT,[r.R32F]:H.FLOAT,[r.RG32F]:H.FLOAT,[r.RGB32F]:H.FLOAT,[r.RGBA32F]:H.FLOAT,[r.R11F_G11F_B10F]:H.FLOAT,[r.RGB9_E5]:H.FLOAT,[r.R8I]:H.INT,[r.R8UI]:H.UINT,[r.R16I]:H.INT,[r.R16UI]:H.UINT,[r.R32I]:H.INT,[r.R32UI]:H.UINT,[r.RG8I]:H.INT,[r.RG8UI]:H.UINT,[r.RG16I]:H.INT,[r.RG16UI]:H.UINT,[r.RG32I]:H.INT,[r.RG32UI]:H.UINT,[r.RGB8I]:H.INT,[r.RGB8UI]:H.UINT,[r.RGB16I]:H.INT,[r.RGB16UI]:H.UINT,[r.RGB32I]:H.INT,[r.RGB32UI]:H.UINT,[r.RGBA8I]:H.INT,[r.RGBA8UI]:H.UINT,[r.RGBA16I]:H.INT,[r.RGBA16UI]:H.UINT,[r.RGBA32I]:H.INT,[r.RGBA32UI]:H.UINT,[r.DEPTH_COMPONENT16]:H.FLOAT,[r.DEPTH_COMPONENT24]:H.FLOAT,[r.DEPTH_COMPONENT32F]:H.FLOAT,[r.DEPTH_STENCIL]:H.FLOAT,[r.DEPTH24_STENCIL8]:H.FLOAT,[r.DEPTH32F_STENCIL8]:H.FLOAT}:t={[r.RGB]:H.FLOAT,[r.RGBA]:H.FLOAT,[r.ALPHA]:H.FLOAT,[r.LUMINANCE]:H.FLOAT,[r.LUMINANCE_ALPHA]:H.FLOAT,[r.DEPTH_STENCIL]:H.FLOAT},t}function _F(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[nt.UNSIGNED_BYTE]:{[L.RGBA]:r.RGBA8,[L.RGB]:r.RGB8,[L.RG]:r.RG8,[L.RED]:r.R8,[L.RGBA_INTEGER]:r.RGBA8UI,[L.RGB_INTEGER]:r.RGB8UI,[L.RG_INTEGER]:r.RG8UI,[L.RED_INTEGER]:r.R8UI,[L.ALPHA]:r.ALPHA,[L.LUMINANCE]:r.LUMINANCE,[L.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[nt.BYTE]:{[L.RGBA]:r.RGBA8_SNORM,[L.RGB]:r.RGB8_SNORM,[L.RG]:r.RG8_SNORM,[L.RED]:r.R8_SNORM,[L.RGBA_INTEGER]:r.RGBA8I,[L.RGB_INTEGER]:r.RGB8I,[L.RG_INTEGER]:r.RG8I,[L.RED_INTEGER]:r.R8I},[nt.UNSIGNED_SHORT]:{[L.RGBA_INTEGER]:r.RGBA16UI,[L.RGB_INTEGER]:r.RGB16UI,[L.RG_INTEGER]:r.RG16UI,[L.RED_INTEGER]:r.R16UI,[L.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[nt.SHORT]:{[L.RGBA_INTEGER]:r.RGBA16I,[L.RGB_INTEGER]:r.RGB16I,[L.RG_INTEGER]:r.RG16I,[L.RED_INTEGER]:r.R16I},[nt.UNSIGNED_INT]:{[L.RGBA_INTEGER]:r.RGBA32UI,[L.RGB_INTEGER]:r.RGB32UI,[L.RG_INTEGER]:r.RG32UI,[L.RED_INTEGER]:r.R32UI,[L.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[nt.INT]:{[L.RGBA_INTEGER]:r.RGBA32I,[L.RGB_INTEGER]:r.RGB32I,[L.RG_INTEGER]:r.RG32I,[L.RED_INTEGER]:r.R32I},[nt.FLOAT]:{[L.RGBA]:r.RGBA32F,[L.RGB]:r.RGB32F,[L.RG]:r.RG32F,[L.RED]:r.R32F,[L.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[nt.HALF_FLOAT]:{[L.RGBA]:r.RGBA16F,[L.RGB]:r.RGB16F,[L.RG]:r.RG16F,[L.RED]:r.R16F},[nt.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:r.RGB565},[nt.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:r.RGBA4},[nt.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:r.RGB5_A1},[nt.UNSIGNED_INT_2_10_10_10_REV]:{[L.RGBA]:r.RGB10_A2,[L.RGBA_INTEGER]:r.RGB10_A2UI},[nt.UNSIGNED_INT_10F_11F_11F_REV]:{[L.RGB]:r.R11F_G11F_B10F},[nt.UNSIGNED_INT_5_9_9_9_REV]:{[L.RGB]:r.RGB9_E5},[nt.UNSIGNED_INT_24_8]:{[L.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[nt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[L.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[nt.UNSIGNED_BYTE]:{[L.RGBA]:r.RGBA,[L.RGB]:r.RGB,[L.ALPHA]:r.ALPHA,[L.LUMINANCE]:r.LUMINANCE,[L.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[nt.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:r.RGB},[nt.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:r.RGBA},[nt.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:r.RGBA}},t}var Yn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new pt,this.hasIntegerTextures=!1}contextChange(){let t=this.gl=this.renderer.gl;this.CONTEXT_UID=this.renderer.CONTEXT_UID,this.webGLVersion=this.renderer.context.webGLVersion,this.internalFormats=_F(t),this.samplerTypes=yF(t);let e=t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS);this.boundTextures.length=e;for(let s=0;s<e;s++)this.boundTextures[s]=null;this.emptyTextures={};let i=new eo(t.createTexture());t.bindTexture(t.TEXTURE_2D,i.texture),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(4)),this.emptyTextures[t.TEXTURE_2D]=i,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new eo(t.createTexture()),t.bindTexture(t.TEXTURE_CUBE_MAP,this.emptyTextures[t.TEXTURE_CUBE_MAP].texture);for(let s=0;s<6;s++)t.texImage2D(t.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,null);t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,t.LINEAR);for(let s=0;s<this.boundTextures.length;s++)this.bind(null,s)}bind(t,e=0){let{gl:i}=this;if(t=t?.castToBaseTexture(),t?.valid&&!t.parentTextureArray){t.touched=this.renderer.textureGC.count;let s=t._glTextures[this.CONTEXT_UID]||this.initTexture(t);this.boundTextures[e]!==t&&(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,i.activeTexture(i.TEXTURE0+e)),i.bindTexture(i.TEXTURE_2D,this.emptyTextures[i.TEXTURE_2D].texture),this.boundTextures[e]=null}reset(){this._unknownBoundTextures=!0,this.hasIntegerTextures=!1,this.currentLocation=-1;for(let t=0;t<this.boundTextures.length;t++)this.boundTextures[t]=this.unknownTexture}unbind(t){let{gl:e,boundTextures:i}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<i.length;s++)i[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<i.length;s++)i[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),i[s]=null)}ensureSamplerType(t){let{boundTextures:e,hasIntegerTextures:i,CONTEXT_UID:s}=this;if(i)for(let o=t-1;o>=0;--o){let n=e[o];n&&n._glTextures[s].samplerType!==H.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new eo(this.gl.createTexture());return e.dirtyId=-1,t._glTextures[this.CONTEXT_UID]=e,this.managedTextures.push(t),t.on("dispose",this.destroyTexture,this),e}initTextureType(t,e){e.internalFormat=this.internalFormats[t.type]?.[t.format]??t.format,e.samplerType=this.samplerTypes[e.internalFormat]??H.FLOAT,this.webGLVersion===2&&t.type===nt.HALF_FLOAT?e.type=this.gl.HALF_FLOAT:e.type=t.type}updateTexture(t){let e=t._glTextures[this.CONTEXT_UID];if(!e)return;let i=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(i,t,e))e.samplerType!==H.FLOAT&&(this.hasIntegerTextures=!0);else{let s=t.realWidth,o=t.realHeight,n=i.gl;(e.width!==s||e.height!==o||e.dirtyId<0)&&(e.width=s,e.height=o,n.texImage2D(t.target,0,e.internalFormat,s,o,0,t.format,e.type,null))}t.dirtyStyleId!==e.dirtyStyleId&&this.updateTextureStyle(t),e.dirtyId=t.dirtyId}destroyTexture(t,e){let{gl:i}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),i.deleteTexture(t._glTextures[this.CONTEXT_UID].texture),t.off("dispose",this.destroyTexture,this),delete t._glTextures[this.CONTEXT_UID],!e)){let s=this.managedTextures.indexOf(t);s!==-1&&y_(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Mr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=lc.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){let i=this.gl;if(e.mipmap&&t.mipmap!==Mr.ON_MANUAL&&i.generateMipmap(t.target),i.texParameteri(t.target,i.TEXTURE_WRAP_S,e.wrapMode),i.texParameteri(t.target,i.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===xr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===xr.LINEAR){let o=Math.min(t.anisotropicLevel,i.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));i.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else i.texParameteri(t.target,i.TEXTURE_MIN_FILTER,t.scaleMode===xr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===xr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}};Yn.extension={type:$.RendererSystem,name:"texture"};K.add(Yn);var qn=class{constructor(t){this.renderer=t}contextChange(){this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glTransformFeedbacks[i]||this.createGLTransformFeedback(t);e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,s)}unbind(){let{gl:t}=this;t.bindTransformFeedback(t.TRANSFORM_FEEDBACK,null)}beginTransformFeedback(t,e){let{gl:i,renderer:s}=this;e&&s.shader.bind(e),i.beginTransformFeedback(t)}endTransformFeedback(){let{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){let{gl:e,renderer:i,CONTEXT_UID:s}=this,o=e.createTransformFeedback();t._glTransformFeedbacks[s]=o,e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,o);for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];a&&(i.buffer.update(a),a._glBuffers[s].refCount++,e.bindBufferBase(e.TRANSFORM_FEEDBACK_BUFFER,n,a._glBuffers[s].buffer||null))}return e.bindTransformFeedback(e.TRANSFORM_FEEDBACK,null),t.disposeRunner.add(this),o}disposeTransformFeedback(t,e){let i=t._glTransformFeedbacks[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this);let o=this.renderer.buffer;if(o)for(let n=0;n<t.buffers.length;n++){let a=t.buffers[n];if(!a)continue;let l=a._glBuffers[this.CONTEXT_UID];l&&(l.refCount--,l.refCount===0&&!e&&o.dispose(a,e))}i&&(e||s.deleteTransformFeedback(i),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}};qn.extension={type:$.RendererSystem,name:"transformFeedback"};K.add(qn);var Mi=class{constructor(t){this.renderer=t}init(t){this.screen=new xt(0,0,t.width,t.height),this.element=t.view||q.ADAPTER.createCanvas(),this.resolution=t.resolution||q.RESOLUTION,this.autoDensity=!!t.autoDensity}resizeView(t,e){this.element.width=Math.round(t*this.resolution),this.element.height=Math.round(e*this.resolution);let i=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=i,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${i}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",i,s),this.renderer.runners.resize.emit(this.screen.width,this.screen.height)}destroy(t){t&&this.element.parentNode?.removeChild(this.element),this.renderer=null,this.element=null,this.screen=null}};Mi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},Mi.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"};K.add(Mi);q.PREFER_ENV=tr.WEBGL2;q.STRICT_TEXTURE_CACHE=!1;q.RENDER_OPTIONS={...Ci.defaultOptions,...Pi.defaultOptions,...Mi.defaultOptions,...Ri.defaultOptions};Object.defineProperties(q,{WRAP_MODE:{get(){return pt.defaultOptions.wrapMode},set(r){ht("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),pt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return pt.defaultOptions.scaleMode},set(r){ht("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),pt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return pt.defaultOptions.mipmap},set(r){ht("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),pt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return pt.defaultOptions.anisotropicLevel},set(r){ht("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),pt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ht("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),ii.defaultResolution},set(r){ii.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ht("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),ii.defaultMultisample},set(r){ii.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return Ai.defaultMaxTextures},set(r){ht("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),Ai.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return Ai.defaultBatchSize},set(r){ht("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),Ai.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return Ai.canUploadSameBuffer},set(r){ht("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),Ai.canUploadSameBuffer=r}},GC_MODE:{get(){return si.defaultMode},set(r){ht("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),si.defaultMode=r}},GC_MAX_IDLE:{get(){return si.defaultMaxIdle},set(r){ht("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),si.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return si.defaultCheckCountMax},set(r){ht("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),si.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return br.defaultVertexPrecision},set(r){ht("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),br.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return br.defaultFragmentPrecision},set(r){ht("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),br.defaultFragmentPrecision=r}}});var ro=(r=>(r[r.INTERACTION=50]="INTERACTION",r[r.HIGH=25]="HIGH",r[r.NORMAL=0]="NORMAL",r[r.LOW=-25]="LOW",r[r.UTILITY=-50]="UTILITY",r))(ro||{});var Kn=class{constructor(t,e=null,i=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=i,this.once=s}match(t,e=null){return this.fn===t&&this.context===e}emit(t){this.fn&&(this.context?this.fn.call(this.context,t):this.fn(t));let e=this.next;return this.once&&this.destroy(!0),this._destroyed&&(this.next=null),e}connect(t){this.previous=t,t.next&&(t.next.previous=this),this.next=t.next,t.next=this}destroy(t=!1){this._destroyed=!0,this.fn=null,this.context=null,this.previous&&(this.previous.next=this.next),this.next&&(this.next.previous=this.previous);let e=this.next;return this.next=t?null:e,this.previous=null,e}};var bF=class or{constructor(){this.autoStart=!1,this.deltaTime=1,this.lastTime=-1,this.speed=1,this.started=!1,this._requestId=null,this._maxElapsedMS=100,this._minElapsedMS=0,this._protected=!1,this._lastFrame=-1,this._head=new Kn(null,null,1/0),this.deltaMS=1/or.targetFPMS,this.elapsedMS=1/or.targetFPMS,this._tick=t=>{this._requestId=null,this.started&&(this.update(t),this.started&&this._requestId===null&&this._head.next&&(this._requestId=requestAnimationFrame(this._tick)))}}_requestIfNeeded(){this._requestId===null&&this._head.next&&(this.lastTime=performance.now(),this._lastFrame=this.lastTime,this._requestId=requestAnimationFrame(this._tick))}_cancelIfNeeded(){this._requestId!==null&&(cancelAnimationFrame(this._requestId),this._requestId=null)}_startIfPossible(){this.started?this._requestIfNeeded():this.autoStart&&this.start()}add(t,e,i=ro.NORMAL){return this._addListener(new Kn(t,e,i))}addOnce(t,e,i=ro.NORMAL){return this._addListener(new Kn(t,e,i,!0))}_addListener(t){let e=this._head.next,i=this._head;if(!e)t.connect(i);else{for(;e;){if(t.priority>e.priority){t.connect(i);break}i=e,e=e.next}t.previous||t.connect(i)}return this._startIfPossible(),this}remove(t,e){let i=this._head.next;for(;i;)i.match(t,e)?i=i.destroy():i=i.next;return this._head.next||this._cancelIfNeeded(),this}get count(){if(!this._head)return 0;let t=0,e=this._head;for(;e=e.next;)t++;return t}start(){this.started||(this.started=!0,this._requestIfNeeded())}stop(){this.started&&(this.started=!1,this._cancelIfNeeded())}destroy(){if(!this._protected){this.stop();let t=this._head.next;for(;t;)t=t.destroy(!0);this._head.destroy(),this._head=null}}update(t=performance.now()){let e;if(t>this.lastTime){if(e=this.elapsedMS=t-this.lastTime,e>this._maxElapsedMS&&(e=this._maxElapsedMS),e*=this.speed,this._minElapsedMS){let o=t-this._lastFrame|0;if(o<this._minElapsedMS)return;this._lastFrame=t-o%this._minElapsedMS}this.deltaMS=e,this.deltaTime=this.deltaMS*or.targetFPMS;let i=this._head,s=i.next;for(;s;)s=s.emit(this.deltaTime);i.next||this._cancelIfNeeded()}else this.deltaTime=this.deltaMS=this.elapsedMS=0;this.lastTime=t}get FPS(){return 1e3/this.elapsedMS}get minFPS(){return 1e3/this._maxElapsedMS}set minFPS(t){let e=Math.min(this.maxFPS,t),i=Math.min(Math.max(0,e)/1e3,or.targetFPMS);this._maxElapsedMS=1/i}get maxFPS(){return this._minElapsedMS?Math.round(1e3/this._minElapsedMS):0}set maxFPS(t){if(t===0)this._minElapsedMS=0;else{let e=Math.max(this.minFPS,t);this._minElapsedMS=1/(e/1e3)}}static get shared(){if(!or._shared){let t=or._shared=new or;t.autoStart=!0,t._protected=!0}return or._shared}static get system(){if(!or._system){let t=or._system=new or;t.autoStart=!0,t._protected=!0}return or._system}};bF.targetFPMS=.06;var vr=bF;Object.defineProperties(q,{TARGET_FPMS:{get(){return vr.targetFPMS},set(r){ht("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),vr.targetFPMS=r}}});var $c=class{static init(t){t=Object.assign({autoStart:!0,sharedTicker:!1},t),Object.defineProperty(this,"ticker",{set(e){this._ticker&&this._ticker.remove(this.render,this),this._ticker=e,e&&e.add(this.render,this,ro.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?vr.shared:new vr,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};$c.extension=$.Application;K.add($c);var m3=[];K.handleByList($.Renderer,m3);var Xc=class{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){let i=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,i)}else{let i=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,i)}e>=At.HIGH?this.multisample=At.HIGH:e>=At.MEDIUM?this.multisample=At.MEDIUM:e>=At.LOW?this.multisample=At.LOW:this.multisample=At.NONE}destroy(){}};Xc.extension={type:$.RendererSystem,name:"_multisample"};K.add(Xc);var np=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var jc=class{constructor(t){this.renderer=t,this.managedBuffers={},this.boundBufferBases={}}destroy(){this.renderer=null}contextChange(){this.disposeAll(!0),this.gl=this.renderer.gl,this.CONTEXT_UID=this.renderer.CONTEXT_UID}bind(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){let{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){let{gl:i,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){let o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,i.bindBufferBase(i.UNIFORM_BUFFER,e,o.buffer)}}bindBufferRange(t,e,i){let{gl:s,CONTEXT_UID:o}=this;i=i||0;let n=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,i*256,256)}update(t){let{gl:e,CONTEXT_UID:i}=this,s=t._glBuffers[i]||this.createGLBuffer(t);if(t._updateID!==s.updateID)if(s.updateID=t._updateID,e.bindBuffer(t.type,s.buffer),s.byteLength>=t.data.byteLength)e.bufferSubData(t.type,0,t.data);else{let o=t.static?e.STATIC_DRAW:e.DYNAMIC_DRAW;s.byteLength=t.data.byteLength,e.bufferData(t.type,t.data,o)}}dispose(t,e){if(!this.managedBuffers[t.id])return;delete this.managedBuffers[t.id];let i=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),i&&(e||s.deleteBuffer(i.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){let e=Object.keys(this.managedBuffers);for(let i=0;i<e.length;i++)this.dispose(this.managedBuffers[e[i]],t)}createGLBuffer(t){let{CONTEXT_UID:e,gl:i}=this;return t._glBuffers[e]=new np(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};jc.extension={type:$.RendererSystem,name:"buffer"};K.add(jc);var Yc=class{constructor(t){this.renderer=t}render(t,e){let i=this.renderer,s,o,n,a;if(e&&(s=e.renderTexture,o=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,i.runners.prerender.emit(),i.emit("prerender"),i.projection.transform=n,!i.context.isLost){if(s||(this.lastObjectRendered=t),!a){let l=t.enableTempParent();t.updateTransform(),t.disableTempParent(l)}i.renderTexture.bind(s),i.batch.currentRenderer.start(),(o??i.background.clearBeforeRender)&&i.renderTexture.clear(),t.render(i),i.batch.currentRenderer.flush(),s&&(e.blit&&i.framebuffer.blit(),s.baseTexture.update()),i.runners.postrender.emit(),i.projection.transform=null,i.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}};Yc.extension={type:$.RendererSystem,name:"objectRenderer"};K.add(Yc);var ap=class z_ extends jn{constructor(t){super(),this.type=Fy.WEBGL,t=Object.assign({},q.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new sr({projectionMatrix:new Rt},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:z_.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ht("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=z_.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:g_()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ht("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ht("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ht("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ht("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};ap.extension={type:$.Renderer,priority:1},ap.__plugins={},ap.__systems={};var lp=ap;K.handleByMap($.RendererPlugin,lp.__plugins);K.handleByMap($.RendererSystem,lp.__systems);K.add(lp);var ns=class extends ir{constructor(t,e){let{width:i,height:s}=e||{};super(i,s),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){let n=new pt;this.items.push(n),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let i=0;i<this.length;i++)t[i]&&(t[i].castToBaseTexture?this.addBaseTextureAt(t[i].castToBaseTexture(),i):t[i]instanceof ir?this.addResourceAt(t[i],i):this.addResourceAt(In(t[i],e),i))}dispose(){for(let t=0,e=this.length;t<e;t++)this.items[t].destroy();this.items=null,this.itemDirtyIds=null,this._load=null}addResourceAt(t,e){if(!this.items[e])throw new Error(`Index ${e} is out of bounds`);return t.valid&&!this.valid&&this.resize(t.width,t.height),this.items[e].setResource(t),this}bind(t){if(this.baseTexture!==null)throw new Error("Only one base texture per TextureArray is allowed");super.bind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=t,this.items[e].on("update",t.update,t)}unbind(t){super.unbind(t);for(let e=0;e<this.length;e++)this.items[e].parentTextureArray=null,this.items[e].off("update",t.update,t)}load(){if(this._load)return this._load;let t=this.items.map(e=>e.resource).filter(e=>e).map(e=>e.load());return this._load=Promise.all(t).then(()=>{let{realWidth:e,realHeight:i}=this.items[0];return this.resize(e,i),this.update(),Promise.resolve(this)}),this._load}};var qc=class extends ns{constructor(t,e){let{width:i,height:s}=e||{},o,n;Array.isArray(t)?(o=t,n=t.length):n=t,super(n,{width:i,height:s}),o&&this.initFromArray(o,e)}addBaseTextureAt(t,e){if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("ArrayResource does not support RenderTexture");return this}bind(t){super.bind(t),t.target=vi.TEXTURE_2D_ARRAY}upload(t,e,i){let{length:s,itemDirtyIds:o,items:n}=this,{gl:a}=t;i.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,i.internalFormat,this._width,this._height,s,0,e.format,i.type,null);for(let l=0;l<s;l++){let c=n[l];o[l]<c.dirtyId&&(o[l]=c.dirtyId,c.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,c.resource.width,c.resource.height,1,e.format,i.type,c.resource.source))}return!0}};var Kc=class extends ue{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var vF=class Zc extends ns{constructor(t,e){let{width:i,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==Zc.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Zc.SIDES;a++)this.items[a].target=vi.TEXTURE_CUBE_MAP_POSITIVE_X+a;this.linkBaseTexture=n!==!1,t&&this.initFromArray(t,e),o!==!1&&this.load()}bind(t){super.bind(t),t.target=vi.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,i){if(i===void 0&&(i=this.linkBaseTexture),!this.items[e])throw new Error(`Index ${e} is out of bounds`);if(!this.linkBaseTexture||t.parentTextureArray||Object.keys(t._glTextures).length>0)if(t.resource)this.addResourceAt(t.resource,e);else throw new Error("CubeResource does not support copying of renderTexture.");else t.target=vi.TEXTURE_CUBE_MAP_POSITIVE_X+e,t.parentTextureArray=this.baseTexture,this.items[e]=t;return t.valid&&!this.valid&&this.resize(t.realWidth,t.realHeight),this.items[e]=t,this}upload(t,e,i){let s=this.itemDirtyIds;for(let o=0;o<Zc.SIDES;o++){let n=this.items[o];(s[o]<n.dirtyId||i.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,i),s[o]=n.dirtyId):s[o]<-1&&(t.gl.texImage2D(n.target,0,i.internalFormat,e.realWidth,e.realHeight,0,e.format,i.type,null),s[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Zc.SIDES}};vF.SIDES=6;var $_=vF;var Qc=class r extends ue{constructor(t,e){e=e||{};let i,s,o;typeof t=="string"?(i=r.EMPTY,s=t,o=!0):(i=t,s=null,o=!1),super(i),this.url=s,this.crossOrigin=e.crossOrigin??!0,this.alphaMode=typeof e.alphaMode=="number"?e.alphaMode:null,this.ownsImageBitmap=e.ownsImageBitmap??o,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(async(t,e)=>{if(this.url===null){t(this);return}try{let i=await q.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;let s=await i.blob();if(this.destroyed)return;let o=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===er.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(i){if(this.destroyed)return;e(i),this.onError.emit(i)}}),this._load)}upload(t,e,i){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,i)):(this.load(),!1)}dispose(){this.ownsImageBitmap&&this.source instanceof ImageBitmap&&this.source.close(),super.dispose(),this._load=null}static test(t){return!!globalThis.createImageBitmap&&typeof ImageBitmap<"u"&&(typeof t=="string"||t instanceof ImageBitmap)}static get EMPTY(){return r._EMPTY=r._EMPTY??q.ADAPTER.createCanvas(0,0),r._EMPTY}};var X_=class cp extends ue{constructor(t,e){e=e||{},super(q.ADAPTER.createCanvas()),this._width=0,this._height=0,this.svg=t,this.scale=e.scale||1,this._overrideWidth=e.width,this._overrideHeight=e.height,this._resolve=null,this._crossorigin=e.crossorigin,this._load=null,e.autoLoad!==!1&&this.load()}load(){return this._load?this._load:(this._load=new Promise(t=>{if(this._resolve=()=>{this.update(),t(this)},cp.SVG_XML.test(this.svg.trim())){if(!btoa)throw new Error("Your browser doesn't support base64 conversions.");this.svg=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(this.svg)))}`}this._loadSvg()}),this._load)}_loadSvg(){let t=new Image;ue.crossOrigin(t,this.svg,this._crossorigin),t.src=this.svg,t.onerror=e=>{this._resolve&&(t.onerror=null,this.onError.emit(e))},t.onload=()=>{if(!this._resolve)return;let e=t.width,i=t.height;if(!e||!i)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,o=i*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/i*e,o=this._overrideHeight||this._overrideWidth/e*i),s=Math.round(s),o=Math.round(o);let n=this.source;n.width=s,n.height=o,n._pixiId=`canvas_${Si()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=cp.SVG_SIZE.exec(t),i={};return e&&(i[e[1]]=Math.round(parseFloat(e[3])),i[e[5]]=Math.round(parseFloat(e[7]))),i}dispose(){super.dispose(),this._resolve=null,this._crossorigin=null}static test(t,e){return e==="svg"||typeof t=="string"&&t.startsWith("data:image/svg+xml")||typeof t=="string"&&cp.SVG_XML.test(t)}};X_.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,X_.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var j_=X_;var hp=class extends ue{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var Y_=class q_ extends ue{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){let i=document.createElement("video");e.autoLoad!==!1&&i.setAttribute("preload","auto"),e.playsinline!==!1&&(i.setAttribute("webkit-playsinline",""),i.setAttribute("playsinline","")),e.muted===!0&&(i.setAttribute("muted",""),i.muted=!0),e.loop===!0&&i.setAttribute("loop",""),e.autoPlay!==!1&&i.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);let s=t[0].src||t[0];ue.crossOrigin(i,s,e.crossorigin);for(let o=0;o<t.length;++o){let n=document.createElement("source"),{src:a,mime:l}=t[o];if(a=a||t[o],a.startsWith("data:"))l=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){let c=a.split("?").shift().toLowerCase(),h=c.slice(c.lastIndexOf(".")+1);l=l||q_.MIME_TYPES[h]||`video/${h}`}n.src=a,l&&(n.type=l),i.appendChild(n)}t=i}super(t),this.noSubImage=!0,this._autoUpdate=!0,this._isConnectedToTicker=!1,this._updateFPS=e.updateFPS||0,this._msToNextUpdate=0,this.autoPlay=e.autoPlay!==!1,this._videoFrameRequestCallback=this._videoFrameRequestCallback.bind(this),this._videoFrameRequestCallbackHandle=null,this._load=null,this._resolve=null,this._reject=null,this._onCanPlay=this._onCanPlay.bind(this),this._onError=this._onError.bind(this),this._onPlayStart=this._onPlayStart.bind(this),this._onPlayStop=this._onPlayStop.bind(this),this._onSeeked=this._onSeeked.bind(this),e.autoLoad!==!1&&this.load()}update(t=0){if(!this.destroyed){if(this._updateFPS){let e=vr.shared.elapsedMS*this.source.playbackRate;this._msToNextUpdate=Math.floor(this._msToNextUpdate-e)}(!this._updateFPS||this._msToNextUpdate<=0)&&(super.update(),this._msToNextUpdate=this._updateFPS?Math.floor(1e3/this._updateFPS):0)}}_videoFrameRequestCallback(){this.update(),this.destroyed?this._videoFrameRequestCallbackHandle=null:this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)}load(){if(this._load)return this._load;let t=this.source;return(t.readyState===t.HAVE_ENOUGH_DATA||t.readyState===t.HAVE_FUTURE_DATA)&&t.width&&t.height&&(t.complete=!0),t.addEventListener("play",this._onPlayStart),t.addEventListener("pause",this._onPlayStop),t.addEventListener("seeked",this._onSeeked),this._isSourceReady()?this._onCanPlay():(t.addEventListener("canplay",this._onCanPlay),t.addEventListener("canplaythrough",this._onCanPlay),t.addEventListener("error",this._onError,!0)),this._load=new Promise((e,i)=>{this.valid?e(this):(this._resolve=e,this._reject=i,t.load())}),this._load}_onError(t){this.source.removeEventListener("error",this._onError,!0),this.onError.emit(t),this._reject&&(this._reject(t),this._reject=null,this._resolve=null)}_isSourcePlaying(){let t=this.source;return!t.paused&&!t.ended}_isSourceReady(){return this.source.readyState>2}_onPlayStart(){this.valid||this._onCanPlay(),this._configureAutoUpdate()}_onPlayStop(){this._configureAutoUpdate()}_onSeeked(){this._autoUpdate&&!this._isSourcePlaying()&&(this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0)}_onCanPlay(){let t=this.source;t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay);let e=this.valid;this._msToNextUpdate=0,this.update(),this._msToNextUpdate=0,!e&&this._resolve&&(this._resolve(this),this._resolve=null,this._reject=null),this._isSourcePlaying()?this._onPlayStart():this.autoPlay&&t.play()}dispose(){this._configureAutoUpdate();let t=this.source;t&&(t.removeEventListener("play",this._onPlayStart),t.removeEventListener("pause",this._onPlayStop),t.removeEventListener("seeked",this._onSeeked),t.removeEventListener("canplay",this._onCanPlay),t.removeEventListener("canplaythrough",this._onCanPlay),t.removeEventListener("error",this._onError,!0),t.pause(),t.src="",t.load()),super.dispose()}get autoUpdate(){return this._autoUpdate}set autoUpdate(t){t!==this._autoUpdate&&(this._autoUpdate=t,this._configureAutoUpdate())}get updateFPS(){return this._updateFPS}set updateFPS(t){t!==this._updateFPS&&(this._updateFPS=t,this._configureAutoUpdate())}_configureAutoUpdate(){this._autoUpdate&&this._isSourcePlaying()?!this._updateFPS&&this.source.requestVideoFrameCallback?(this._isConnectedToTicker&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0),this._videoFrameRequestCallbackHandle===null&&(this._videoFrameRequestCallbackHandle=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker||(vr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(vr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||q_.TYPES.includes(e)}};Y_.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Y_.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var K_=Y_;Sc.push(Qc,Zs,Kc,K_,hp,j_,Ws,$_,qc);var g3={vec3(r,t,e,i){(e[0]!==i[0]||e[1]!==i[1]||e[2]!==i[2])&&(e[0]=i[0],e[1]=i[1],e[2]=i[2],r.uniform3f(t,i[0],i[1],i[2]))},int(r,t,e,i){r.uniform1i(t,i)},ivec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},ivec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},ivec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},uint(r,t,e,i){r.uniform1ui(t,i)},uvec2(r,t,e,i){r.uniform2ui(t,i[0],i[1])},uvec3(r,t,e,i){r.uniform3ui(t,i[0],i[1],i[2])},uvec4(r,t,e,i){r.uniform4ui(t,i[0],i[1],i[2],i[3])},bvec2(r,t,e,i){r.uniform2i(t,i[0],i[1])},bvec3(r,t,e,i){r.uniform3i(t,i[0],i[1],i[2])},bvec4(r,t,e,i){r.uniform4i(t,i[0],i[1],i[2],i[3])},mat2(r,t,e,i){r.uniformMatrix2fv(t,!1,i)},mat4(r,t,e,i){r.uniformMatrix4fv(t,!1,i)}},x3={float(r,t,e,i){r.uniform1fv(t,i)},vec2(r,t,e,i){r.uniform2fv(t,i)},vec3(r,t,e,i){r.uniform3fv(t,i)},vec4(r,t,e,i){r.uniform4fv(t,i)},int(r,t,e,i){r.uniform1iv(t,i)},ivec2(r,t,e,i){r.uniform2iv(t,i)},ivec3(r,t,e,i){r.uniform3iv(t,i)},ivec4(r,t,e,i){r.uniform4iv(t,i)},uint(r,t,e,i){r.uniform1uiv(t,i)},uvec2(r,t,e,i){r.uniform2uiv(t,i)},uvec3(r,t,e,i){r.uniform3uiv(t,i)},uvec4(r,t,e,i){r.uniform4uiv(t,i)},bool(r,t,e,i){r.uniform1iv(t,i)},bvec2(r,t,e,i){r.uniform2iv(t,i)},bvec3(r,t,e,i){r.uniform3iv(t,i)},bvec4(r,t,e,i){r.uniform4iv(t,i)},sampler2D(r,t,e,i){r.uniform1iv(t,i)},samplerCube(r,t,e,i){r.uniform1iv(t,i)},sampler2DArray(r,t,e,i){r.uniform1iv(t,i)}};function TF(r,t,e,i,s){let o=0,n=null,a=null,l=s.gl;for(let c in r.uniforms){let h=t[c],u=i[c],d=e[c],f=r.uniforms[c];if(!h){f.group===!0&&s.shader.syncUniformGroup(u);continue}h.type==="float"&&h.size===1&&!h.isArray?u!==d.value&&(d.value=u,l.uniform1f(d.location,u)):h.type==="bool"&&h.size===1&&!h.isArray?u!==d.value&&(d.value=u,l.uniform1i(d.location,Number(u))):(h.type==="sampler2D"||h.type==="samplerCube"||h.type==="sampler2DArray")&&h.size===1&&!h.isArray?(s.texture.bind(u,o),d.value!==o&&(d.value=o,l.uniform1i(d.location,o)),o++):h.type==="mat3"&&h.size===1&&!h.isArray?f.a!==void 0?l.uniformMatrix3fv(d.location,!1,u.toArray(!0)):l.uniformMatrix3fv(d.location,!1,u):h.type==="vec2"&&h.size===1&&!h.isArray?f.x!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y)&&(a[0]=n.x,a[1]=n.y,l.uniform2f(d.location,n.x,n.y))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1])&&(a[0]=n[0],a[1]=n[1],l.uniform2f(d.location,n[0],n[1]))):h.type==="vec4"&&h.size===1&&!h.isArray?f.width!==void 0?(a=d.value,n=u,(a[0]!==n.x||a[1]!==n.y||a[2]!==n.width||a[3]!==n.height)&&(a[0]=n.x,a[1]=n.y,a[2]=n.width,a[3]=n.height,l.uniform4f(d.location,n.x,n.y,n.width,n.height))):(a=d.value,n=u,(a[0]!==n[0]||a[1]!==n[1]||a[2]!==n[2]||a[3]!==n[3])&&(a[0]=n[0],a[1]=n[1],a[2]=n[2],a[3]=n[3],l.uniform4f(d.location,n[0],n[1],n[2],n[3]))):(h.size===1&&!h.isArray?g3:x3)[h.type].call(null,l,d.location,d.value,u)}}function y3(){Object.assign(os.prototype,{systemCheck(){},syncUniforms(r,t){let{shader:e,renderer:i}=this;TF(r,e.program.uniformData,t.uniformData,r.uniforms,i)}})}y3();var Jc=new(window.AudioContext||window.webkitAudioContext),_3=(r,t)=>{let e,i=Jc.createGain();i.gain.value=t.volume??1,i.connect(Jc.destination);let s={id:r,url:t.url,loop:t.loop||!1,volume:t.volume??1};return{play:()=>{let m=ln.getAsset(s.url);if(!m){console.warn("AudioPlayer.play: Asset not found",s.url);return}e=Jc.createBufferSource(),e.buffer=m,e.loop=s.loop,i.gain.setValueAtTime(s.volume,Jc.currentTime),e.connect(i),e.start(0)},stop:()=>{e&&(e.stop(),e.disconnect(),i.disconnect(),i.connect(Jc.destination))},update:m=>{s={...s,...m}},getId:()=>s.id,getUrl:()=>s.url,getLoop:()=>s.loop,getVolume:()=>s.volume,setUrl:m=>{s.url=m},setLoop:m=>{s.loop=m},setVolume:m=>{s.volume=m,i.gain.value=m},get id(){return s.id},get url(){return s.url},get loop(){return s.loop},get volume(){return s.volume},gainNode:i}},SF=()=>{let r=[],t=[];return{add:a=>{t.push(a)},remove:a=>{t=t.filter(l=>l.id!==a)},getById:a=>t.find(l=>l.id===a),tick:()=>{for(let l of t){let c=r.find(h=>h.id===l.id);if(!c){let h=_3(l.id,{url:l.url,loop:l.loop,volume:l.volume??1});r.push(h),h.play();continue}(c.url!==l.url||c.loop!==l.loop)&&(c.stop(),c.setUrl(l.url),c.setLoop(l.loop??!1),c.play()),c.getVolume()!==(l.volume??1)&&c.setVolume(l.volume??1)}let a=[];for(let l of r)t.find(c=>c.id===l.id)||(l.stop(),a.push(l.id));r=r.filter(l=>!a.includes(l.id))},destroy:()=>{for(let a of r)a.stop();r=[],t=[]}}};var b3=({JSONObject:r,parserPlugins:t=[]})=>r.map(i=>{let s=t.find(o=>o.type===i.type);if(!s)throw new Error(`No parser plugin found for element type: ${i.type} (id: ${i.id??"unknown"})`);return s.parse({state:i,parserPlugins:t})});var Z_=b3;var wF=({type:r,parse:t})=>({type:r,parse:t});var Q_=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function J_(r,t,e,i){r.addEventListener?r.addEventListener(t,e,i):r.attachEvent&&r.attachEvent(`on${t}`,e)}function th(r,t,e,i){r&&(r.removeEventListener?r.removeEventListener(t,e,i):r.detachEvent&&r.detachEvent(`on${t}`,e))}function PF(r,t){let e=t.slice(0,t.length-1),i=[];for(let s=0;s<e.length;s++)i.push(r[e[s].toLowerCase()]);return i}function CF(r){typeof r!="string"&&(r=""),r=r.replace(/\s/g,"");let t=r.split(","),e=t.lastIndexOf("");for(;e>=0;)t[e-1]+=",",t.splice(e,1),e=t.lastIndexOf("");return t}function v3(r,t){let e=r.length>=t.length?r:t,i=r.length>=t.length?t:r,s=!0;for(let o=0;o<e.length;o++)i.indexOf(e[o])===-1&&(s=!1);return s}function RF(r){let t=r.keyCode||r.which||r.charCode;return r.code&&/^Key[A-Z]$/.test(r.code)&&(t=r.code.charCodeAt(3)),t}var ih={backspace:8,"\u232B":8,tab:9,clear:12,enter:13,"\u21A9":13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,arrowup:38,arrowdown:40,arrowleft:37,arrowright:39,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"\u21EA":20,",":188,".":190,"/":191,"`":192,"-":Q_?173:189,"=":Q_?61:187,";":Q_?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},kr={"\u21E7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,meta:91,command:91},eh={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Te={16:!1,18:!1,17:!1,91:!1},$t={};for(let r=1;r<20;r++)ih[`f${r}`]=111+r;var Dt=[],rh=null,MF="all",Ii=new Map,Zn=r=>ih[r.toLowerCase()]||kr[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),T3=r=>Object.keys(ih).find(t=>ih[t]===r),S3=r=>Object.keys(kr).find(t=>kr[t]===r),IF=r=>{MF=r||"all"},sh=()=>MF||"all",w3=()=>Dt.slice(0),E3=()=>Dt.map(r=>T3(r)||S3(r)||String.fromCharCode(r)),A3=()=>{let r=[];return Object.keys($t).forEach(t=>{$t[t].forEach(({key:e,scope:i,mods:s,shortcut:o})=>{r.push({scope:i,shortcut:o,mods:s,keys:e.split("+").map(n=>Zn(n))})})}),r},BF=r=>{let t=r.target||r.srcElement,{tagName:e}=t,i=!0,s=e==="INPUT"&&!["checkbox","radio","range","button","file","reset","submit","color"].includes(t.type);return(t.isContentEditable||(s||e==="TEXTAREA"||e==="SELECT")&&!t.readOnly)&&(i=!1),i},P3=r=>(typeof r=="string"&&(r=Zn(r)),Dt.indexOf(r)!==-1),C3=(r,t)=>{let e,i;r||(r=sh());for(let s in $t)if(Object.prototype.hasOwnProperty.call($t,s))for(e=$t[s],i=0;i<e.length;)e[i].scope===r?e.splice(i,1).forEach(({element:o})=>eb(o)):i++;sh()===r&&IF(t||"all")};function R3(r){let t=RF(r);r.key&&r.key.toLowerCase()==="capslock"&&(t=Zn(r.key));let e=Dt.indexOf(t);if(e>=0&&Dt.splice(e,1),r.key&&r.key.toLowerCase()==="meta"&&Dt.splice(0,Dt.length),(t===93||t===224)&&(t=91),t in Te){Te[t]=!1;for(let i in kr)kr[i]===t&&(nr[i]=!1)}}var FF=(r,...t)=>{if(typeof r>"u")Object.keys($t).forEach(e=>{Array.isArray($t[e])&&$t[e].forEach(i=>up(i)),delete $t[e]}),eb(null);else if(Array.isArray(r))r.forEach(e=>{e.key&&up(e)});else if(typeof r=="object")r.key&&up(r);else if(typeof r=="string"){let[e,i]=t;typeof e=="function"&&(i=e,e=""),up({key:r,scope:e,method:i,splitKey:"+"})}},up=({key:r,scope:t,method:e,splitKey:i="+"})=>{CF(r).forEach(s=>{let o=s.split(i),n=o.length,a=o[n-1],l=a==="*"?"*":Zn(a);if(!$t[l])return;t||(t=sh());let c=n>1?PF(kr,o):[],h=[];$t[l]=$t[l].filter(u=>{let d=(e?u.method===e:!0)&&u.scope===t&&v3(u.mods,c);return d&&h.push(u.element),!d}),h.forEach(u=>eb(u))})};function EF(r,t,e,i){if(t.element!==i)return;let s;if(t.scope===e||t.scope==="all"){s=t.mods.length>0;for(let o in Te)Object.prototype.hasOwnProperty.call(Te,o)&&(!Te[o]&&t.mods.indexOf(+o)>-1||Te[o]&&t.mods.indexOf(+o)===-1)&&(s=!1);(t.mods.length===0&&!Te[16]&&!Te[18]&&!Te[17]&&!Te[91]||s||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Dt),t.method(r,t)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function AF(r,t){let e=$t["*"],i=RF(r);if(r.key&&r.key.toLowerCase()==="capslock"||!(nr.filter||BF).call(this,r))return;if((i===93||i===224)&&(i=91),Dt.indexOf(i)===-1&&i!==229&&Dt.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{let l=eh[a];r[a]&&Dt.indexOf(l)===-1?Dt.push(l):!r[a]&&Dt.indexOf(l)>-1?Dt.splice(Dt.indexOf(l),1):a==="metaKey"&&r[a]&&(Dt=Dt.filter(c=>c in eh||c===i))}),i in Te){Te[i]=!0;for(let a in kr)if(Object.prototype.hasOwnProperty.call(kr,a)){let l=eh[kr[a]];nr[a]=r[l]}if(!e)return}for(let a in Te)Object.prototype.hasOwnProperty.call(Te,a)&&(Te[a]=r[eh[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Dt.indexOf(17)===-1&&Dt.push(17),Dt.indexOf(18)===-1&&Dt.push(18),Te[17]=!0,Te[18]=!0);let s=sh();if(e)for(let a=0;a<e.length;a++)e[a].scope===s&&(r.type==="keydown"&&e[a].keydown||r.type==="keyup"&&e[a].keyup)&&EF(r,e[a],s,t);if(!(i in $t))return;let o=$t[i],n=o.length;for(let a=0;a<n;a++)if((r.type==="keydown"&&o[a].keydown||r.type==="keyup"&&o[a].keyup)&&o[a].key){let l=o[a],{splitKey:c}=l,h=l.key.split(c),u=[];for(let d=0;d<h.length;d++)u.push(Zn(h[d]));u.sort().join("")===Dt.sort().join("")&&EF(r,l,s,t)}}var nr=function(r,t,e){Dt=[];let i=CF(r),s=[],o="all",n=document,a=0,l=!1,c=!0,h="+",u=!1,d=!1;if(e===void 0&&typeof t=="function"&&(e=t),Object.prototype.toString.call(t)==="[object Object]"){let f=t;f.scope&&(o=f.scope),f.element&&(n=f.element),f.keyup&&(l=f.keyup),f.keydown!==void 0&&(c=f.keydown),f.capture!==void 0&&(u=f.capture),typeof f.splitKey=="string"&&(h=f.splitKey),f.single===!0&&(d=!0)}for(typeof t=="string"&&(o=t),d&&FF(r,o);a<i.length;a++){let f=i[a].split(h);s=[],f.length>1&&(s=PF(kr,f));let p=f[f.length-1];p=p==="*"?"*":Zn(p),p in $t||($t[p]=[]),$t[p].push({keyup:l,keydown:c,scope:o,mods:s,shortcut:i[a],method:e,key:i[a],splitKey:h,element:n})}if(typeof n<"u"&&typeof window<"u"){if(!Ii.has(n)){let f=(m=window.event)=>AF(m,n),p=(m=window.event)=>{AF(m,n),R3(m)};Ii.set(n,{keydownListener:f,keyupListenr:p,capture:u}),J_(n,"keydown",f,u),J_(n,"keyup",p,u)}if(!rh){let f=()=>{Dt=[]};rh={listener:f,capture:u},J_(window,"focus",f,u)}}};function M3(r,t="all"){Object.keys($t).forEach(e=>{$t[e].filter(i=>i.scope===t&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method({},i)})})}function eb(r){let t=Object.values($t).flat();if(t.findIndex(({element:e})=>e===r)<0&&r){let{keydownListener:e,keyupListenr:i,capture:s}=Ii.get(r)||{};e&&i&&(th(r,"keyup",i,s),th(r,"keydown",e,s),Ii.delete(r))}if((t.length<=0||Ii.size<=0)&&(Array.from(Ii.keys()).forEach(e=>{let{keydownListener:i,keyupListenr:s,capture:o}=Ii.get(e)||{};i&&s&&(th(e,"keyup",s,o),th(e,"keydown",i,o),Ii.delete(e))}),Ii.clear(),Object.keys($t).forEach(e=>delete $t[e]),rh)){let{listener:e,capture:i}=rh;th(window,"focus",e,i),rh=null}}var tb={getPressedKeyString:E3,setScope:IF,getScope:sh,deleteScope:C3,getPressedKeyCodes:w3,getAllKeyCodes:A3,isPressed:P3,filter:BF,trigger:M3,unbind:FF,keyMap:ih,modifier:kr,modifierMap:eh};for(let r in tb){let t=r;Object.prototype.hasOwnProperty.call(tb,t)&&(nr[t]=tb[t])}if(typeof window<"u"){let r=window.hotkeys;nr.noConflict=t=>(t&&window.hotkeys===nr&&(window.hotkeys=r),nr),window.hotkeys=nr}var I3=Object.prototype.hasOwnProperty,kF=r=>{let t=new Map;return{registerHotkeys:(s={})=>{if(typeof s!="object"||s===null)return;let o=[],n=[],a=[];Object.keys(s).forEach(l=>{let c=t.get(l);c?gt(c.payload,s[l].payload)||(n.push(l),nr.unbind(l)):o.push(l)}),t.forEach((l,c)=>{I3.call(s,c)||a.push(c)}),a.forEach(l=>{nr.unbind(l),t.delete(l)}),[...o,...n].forEach(l=>{let h=s[l].payload??{};nr(l,()=>{r&&r("keydown",{_event:{key:l},...h})}),t.set(l,{value:l,payload:h})})},destroy:()=>{for(let s of t.keys())nr.unbind(s);t.clear()}}};var UF=(r,t)=>typeof t!="string"?t:r[t]??t,B3=(r,t,e,i)=>{let s=UF(e,t);if(typeof s=="string"){let n=r[s];return n===void 0?i:n}let o=r;for(let n of s){if(o==null)return i;o=o[n]}return o===void 0?i:o},OF=(r,t,e,i)=>{let s=UF(e,t);if(typeof s=="string")return r[s]=i,r;let o=r;for(let n=0;n<s.length-1;n++){let a=s[n];a in o||(o[a]={}),o=o[a]}return o[s[s.length-1]]=i,r},F3=(r,t,e)=>{if(!r||!Object.prototype.hasOwnProperty.call(r,t))throw new Error(`Animation "${e}" cannot auto-resolve property "${t}" from targetState.`);return r[t]},k3=(r,t,e,i,s)=>Object.entries(t).map(([o,n])=>{if(!dd[o])throw new Error(`${o} is not a supported property for animation.`);let a=B3(r,o,e,0);if(n.auto){let h=F3(i,o,s);if(a===h)return null;let u=xn([{value:a},{duration:n.auto.duration,value:h,easing:n.auto.easing}]);return{property:o,timeline:u}}let l=n.initialValue??a,c=xn([{value:l},...n.keyframes]);return{property:o,timeline:c}}).filter(Boolean),GF=()=>{let r=[],t=new Map,e=new Map,i=0,s=(S,v)=>{e.get(S)?.forEach(P=>{try{P(v)}catch{}})},o=S=>{if(s("completed",{id:S.id}),S.onComplete)try{S.onComplete()}catch{}},n=S=>{let{id:v,element:P,properties:C,targetState:A,onComplete:R,onCancel:M,propertyPathMap:I=fd}=S,k=k3(P,C,I,A,v);if(k.length===0){o({id:v,onComplete:R});return}let W={id:v,kind:"property",element:P,timelines:k,duration:tc(k),currentTime:0,stateVersion:i,targetState:A,onComplete:R,onCancel:M,applyFrame:O=>{for(let{property:z,timeline:V}of k){let G=ec(V,O);try{OF(P,z,I,G)}catch{}}},applyTargetState:()=>{if(!(!P||P.destroyed)){if(A===null){P.destroy();return}if(A)for(let[O,z]of Object.entries(A))try{OF(P,O,I,z)}catch{}}},isValid:()=>!!P&&!P.destroyed};W.applyFrame(0),t.set(v,W),s("started",{id:v})},a=S=>{let v={id:S.id,kind:"custom",duration:S.duration??0,currentTime:0,stateVersion:i,onComplete:S.onComplete,onCancel:S.onCancel,applyFrame:S.applyFrame??(()=>{}),applyTargetState:S.applyTargetState??(()=>{}),isValid:S.isValid??(()=>!0)};v.applyFrame(0),t.set(v.id,v),s("started",{id:v.id})},l=S=>{if(S.driver==="custom"){a(S);return}n(S)},c=S=>{try{S.applyTargetState?.()}catch{}if(S.onCancel)try{S.onCancel()}catch{}},h=S=>{switch(S.type){case"START":l(S.payload);break;case"CANCEL":d(S.id);break}},u=()=>{let S=r.splice(0);for(let v of S)h(v)},d=S=>{let v=t.get(S);v&&(c(v),t.delete(S),s("cancelled",{id:S}))},f=S=>{r.push(S)},p=()=>{for(let[S,v]of t)c(v),s("cancelled",{id:S});t.clear(),i++},m=S=>{u();let v=[];for(let[P,C]of t){if(C.stateVersion!==i){v.push(P);continue}if(!C.isValid()){v.push(P);continue}if(C.currentTime+=S,C.currentTime>=C.duration){C.applyFrame(C.duration),o(C),v.push(P);continue}C.applyFrame(C.currentTime)}for(let P of v)t.delete(P)},x=()=>{u()},_=(S,v)=>(e.has(S)||e.set(S,new Set),e.get(S).add(v),()=>T(S,v)),T=(S,v)=>{e.get(S)?.delete(v)};return{dispatch:f,cancelAll:p,flush:x,tick:m,on:_,off:T,getState:()=>({stateVersion:i,activeCount:t.size,animations:Array.from(t.entries()).map(([S,v])=>({id:S,currentTime:v.currentTime,duration:v.duration,progress:v.duration>0?v.currentTime/v.duration:0}))}),isAnimating:S=>t.has(S),destroy:()=>{p(),e.clear()}}};var LF=r=>{let t=0,e=0,i=null,s=!1,o=!1,n=d=>{o||(o=!0,r?.("renderComplete",d))};return{reset:d=>{t>0&&i!==null&&!o&&r?.("renderComplete",{id:i,aborted:!0}),e++,t=0,i=d,s=!0,o=!1},track:d=>{d===e&&t++},complete:d=>{d!==e||t===0||(t--,t===0&&!s&&n({id:i,aborted:!1}))},getVersion:()=>e,completeIfEmpty:()=>{s=!1,t===0&&n({id:i,aborted:!1})}}};var DF=new Set(["update","transition"]),O3=new Set(["alpha","x","y","scaleX","scaleY","rotation"]),U3=new Set(["translateX","translateY","alpha","scaleX","scaleY","rotation"]),NF=new Set(["single","sequence","composite"]),dp=new Set(["red","green","blue","alpha"]),HF=new Set(["max","min","multiply","add"]),WF=new Set(Vd),oi=(r,t)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`${t} must be an object.`)},io=(r,t)=>{if(typeof r!="string"||r.length===0)throw new Error(`${t} must be a non-empty string.`)},oh=(r,t)=>{if(typeof r!="number"||Number.isNaN(r))throw new Error(`${t} must be a number.`)},G3=(r,t)=>{if(oi(r,t),oh(r.duration,`${t}.duration`),r.easing!==void 0&&typeof r.easing!="string")throw new Error(`${t}.easing must be a string.`);if(r.easing!==void 0&&!WF.has(r.easing))throw new Error(`${t}.easing must be one of: ${Vd.join(", ")}.`);return{duration:r.duration,easing:r.easing??"linear"}},ib=(r,t)=>{oi(r,t);let e={};if(r.initialValue!==void 0&&(oh(r.initialValue,`${t}.initialValue`),e.initialValue=r.initialValue),!Array.isArray(r.keyframes)||r.keyframes.length===0)throw new Error(`${t}.keyframes must be a non-empty array.`);return e.keyframes=r.keyframes.map((i,s)=>{let o=`${t}.keyframes[${s}]`;if(oi(i,o),oh(i.value,`${o}.value`),oh(i.duration,`${o}.duration`),i.easing!==void 0&&typeof i.easing!="string")throw new Error(`${o}.easing must be a string.`);if(i.easing!==void 0&&!WF.has(i.easing))throw new Error(`${o}.easing must be one of: ${Vd.join(", ")}.`);if(i.relative!==void 0&&typeof i.relative!="boolean")throw new Error(`${o}.relative must be a boolean.`);return{value:i.value,duration:i.duration,easing:i.easing??"linear",...i.relative!==void 0?{relative:i.relative}:{}}}),e},L3=(r,t)=>{oi(r,t);let e=r.keyframes!==void 0,i=r.auto!==void 0;if(e&&i)throw new Error(`${t} cannot define both keyframes and auto.`);if(!e&&!i)throw new Error(`${t} must define keyframes or auto.`);if(i){if(r.initialValue!==void 0)throw new Error(`${t}.initialValue is not valid when auto is defined.`);return{auto:G3(r.auto,`${t}.auto`)}}return ib(r,t)},zF=(r,t,e,i=ib)=>{oi(r,t);let s=Object.entries(r).map(([o,n])=>{if(!e.has(o))throw new Error(`${t}.${o} is not a supported animation property.`);return[o,i(n,`${t}.${o}`)]});if(s.length===0)throw new Error(`${t} must define at least one property.`);return Object.fromEntries(s)},D3=(r,t)=>{if(oi(r,t),io(r.texture,`${t}.texture`),r.channel!==void 0&&!dp.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(dp).join(", ")}.`);if(r.invert!==void 0&&typeof r.invert!="boolean")throw new Error(`${t}.invert must be a boolean.`);return{texture:r.texture,...r.channel?{channel:r.channel}:{},...r.invert!==void 0?{invert:r.invert}:{}}},N3=(r,t)=>{if(oi(r,t),!NF.has(r.kind))throw new Error(`${t}.kind must be one of: ${Array.from(NF).join(", ")}.`);let e={kind:r.kind};if(r.channel!==void 0){if(!dp.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(dp).join(", ")}.`);e.channel=r.channel}if(r.softness!==void 0&&(oh(r.softness,`${t}.softness`),e.softness=r.softness),r.invert!==void 0){if(typeof r.invert!="boolean")throw new Error(`${t}.invert must be a boolean.`);e.invert=r.invert}if(r.progress!==void 0&&(e.progress=ib(r.progress,`${t}.progress`)),r.kind==="single"&&(io(r.texture,`${t}.texture`),e.texture=r.texture),r.kind==="sequence"){if(!Array.isArray(r.textures)||r.textures.length===0)throw new Error(`${t}.textures must be a non-empty array.`);e.textures=r.textures.map((i,s)=>(io(i,`${t}.textures[${s}]`),i)),r.sample!==void 0&&(io(r.sample,`${t}.sample`),e.sample=r.sample)}if(r.kind==="composite"){if(!HF.has(r.combine??"max"))throw new Error(`${t}.combine must be one of: ${Array.from(HF).join(", ")}.`);if(!Array.isArray(r.items)||r.items.length===0)throw new Error(`${t}.items must be a non-empty array.`);e.combine=r.combine??"max",e.items=r.items.map((i,s)=>D3(i,`${t}.items[${s}]`))}return e.progress||(e.progress={initialValue:0,keyframes:[{duration:0,value:1,easing:"linear"}]}),e},VF=(r,t)=>{if(oi(r,t),r.mask!==void 0)throw new Error(`${t}.mask is not valid. Define mask on ${t}.`);let e={};if(r.tween!==void 0&&(e.tween=zF(r.tween,`${t}.tween`,U3)),Object.keys(e).length===0)throw new Error(`${t} must define tween.`);return e},H3=(r,t)=>{let e={};if(r.shader!==void 0)throw new Error(`${t}.shader is not supported.`);if(r.prev!==void 0&&(e.prev=VF(r.prev,`${t}.prev`)),r.next!==void 0&&(e.next=VF(r.next,`${t}.next`)),r.mask!==void 0&&(e.mask=N3(r.mask,`${t}.mask`)),e.prev===void 0&&e.next===void 0&&e.mask===void 0)throw new Error(`${t} must define prev, next, or mask.`);return e},rb=(r,t,e)=>{if(r!==void 0)throw new Error(`${t} ${e}`)},$F=(r=[])=>{if(!Array.isArray(r))throw new Error("Input error: `animations` must be an array.");let t=r.map((i,s)=>{let o=`animations[${s}]`;if(oi(i,o),io(i.id,`${o}.id`),io(i.targetId,`${o}.targetId`),io(i.type,`${o}.type`),!DF.has(i.type))throw new Error(`${o}.type must be one of: ${Array.from(DF).join(", ")}.`);let n={id:i.id,targetId:i.targetId,type:i.type};if(i.complete!==void 0&&(oi(i.complete,`${o}.complete`),n.complete=i.complete),rb(i.operation,`${o}.operation`,"is no longer supported. Use `type: update | transition` instead."),rb(i.properties,`${o}.properties`,"is no longer supported. Use `tween` instead."),rb(i.subjects,`${o}.subjects`,"is no longer supported. Use `prev` / `next` instead."),i.type==="update"){if(n.tween=zF(i.tween,`${o}.tween`,O3,L3),i.replace!==void 0)throw new Error(`${o}.replace is no longer supported. Define \`prev\`, \`next\`, or \`mask\` directly on the animation.`);if(i.prev!==void 0)throw new Error(`${o}.prev is only valid for transition animations.`);if(i.next!==void 0)throw new Error(`${o}.next is only valid for transition animations.`);if(i.mask!==void 0)throw new Error(`${o}.mask is only valid for transition animations.`);if(i.shader!==void 0)throw new Error(`${o}.shader is not supported.`);return n}if(i.tween!==void 0)throw new Error(`${o}.tween is not valid for transition animations.`);if(i.replace!==void 0)throw new Error(`${o}.replace is no longer supported. Define \`prev\`, \`next\`, or \`mask\` directly on the animation.`);let a=H3(i,o);return a.prev!==void 0&&(n.prev=a.prev),a.next!==void 0&&(n.next=a.next),a.mask!==void 0&&(n.mask=a.mask),n}),e=new Map;for(let i of t){let s=e.get(i.targetId)??new Set;s.add(i.type),e.set(i.targetId,s)}for(let[i,s]of e)if(s.has("transition")&&s.size>1)throw new Error(`Animations targeting "${i}" cannot mix update and transition types in the same state.`);return t};var sb=(r={})=>{if(r===null||typeof r!="object")throw new Error("Input error: render state must be an object.");if(r.transitions!==void 0)throw new Error("Input error: `transitions` is no longer supported. Use `animations` instead.");let t={...r,elements:r.elements??[],animations:r.animations??[],audio:r.audio??[]};if(!Array.isArray(t.elements))throw new Error("Input error: `elements` must be an array.");if(!Array.isArray(t.animations))throw new Error("Input error: `animations` must be an array.");if(!Array.isArray(t.audio))throw new Error("Input error: `audio` must be an array.");return t.animations=$F(t.animations),t};var V3="0",Qn=(r,t)=>{let e=r?.[t];return typeof e=="number"?e:0},ar=r=>({value:r.element.value??"",selectionStart:Qn(r.element,"selectionStart"),selectionEnd:Qn(r.element,"selectionEnd"),focused:document.activeElement===r.element,composing:r.composing===!0}),W3=(r,t)=>!r||!t?!1:r.value===t.value&&r.selectionStart===t.selectionStart&&r.selectionEnd===t.selectionEnd&&r.focused===t.focused&&r.composing===t.composing,z3=r=>r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement,nh=r=>{r.element.style.pointerEvents="none"},ob=(r,t,e)=>{if(typeof r?.setSelectionRange=="function")try{r.setSelectionRange(t,e)}catch{}},$3=({app:r,geometry:t})=>{let e=r.canvas;if(!t||!e||t.visible===!1)return null;let i=e.getBoundingClientRect(),s=r.renderer?.width||i.width||1,o=r.renderer?.height||i.height||1,n=i.width/s,a=i.height/o,l=t.clipInsets??{top:0,right:0,bottom:0,left:0},c=i.left+(t.x+l.left)*n,h=i.top+(t.y+l.top)*a,u=i.left+(t.x+t.width-l.right)*n,d=i.top+(t.y+t.height-l.bottom)*a;return u<=c||d<=h?null:{left:c,top:h,right:u,bottom:d}},X3=({app:r,entry:t,event:e})=>{let i=t.options.getGeometry?.(),s=$3({app:r,geometry:i}),o=e.clientX,n=e.clientY;return!!s&&Number.isFinite(o)&&Number.isFinite(n)&&o>=s.left&&o<=s.right&&n>=s.top&&n<=s.bottom},XF=({app:r})=>{let t=new Map,e,i=null,s=()=>{e||(e=document.createElement("div"),e.dataset.routeGraphicsInputBridge="true",e.style.position="fixed",e.style.left="0",e.style.top="0",e.style.pointerEvents="none",e.style.zIndex="1000",e.style.width="0",e.style.height="0");let g=r.canvas?.parentNode??document.body;e.isConnected||g.appendChild(e)},o=(g,w=g.lastSnapshot)=>{let b=ar(g);b.focused&&i!==g.id?i=g.id:!b.focused&&i===g.id&&(i=null),nh(g,i),w?.value!==b.value&&g.callbacks.onValueChange?.(b),(w?.selectionStart!==b.selectionStart||w?.selectionEnd!==b.selectionEnd||w?.focused!==b.focused||w?.composing!==b.composing)&&g.callbacks.onSelectionChange?.(b),g.lastSnapshot=b},n=g=>{let{disabled:w=!1,multiline:b=!1,maxLength:S,textStyle:v,padding:P,placeholder:C="",autocomplete:A="off",autocapitalize:R="off",spellcheck:M=!1}=g.options,{element:I}=g;I instanceof HTMLInputElement&&(I.type="text"),I.disabled=w,I.placeholder=C,I.autocomplete=A,I.autocapitalize=R,I.spellcheck=!!M,I.style.opacity=V3,I.style.color="transparent",I.style.caretColor="transparent",I.style.background="transparent",I.style.paddingTop=`${P.top}px`,I.style.paddingRight=`${P.right}px`,I.style.paddingBottom=`${P.bottom}px`,I.style.paddingLeft=`${P.left}px`,I.style.fontFamily=v?.fontFamily??"Arial",I.style.fontSize=`${v?.fontSize??16}px`,I.style.fontWeight=v?.fontWeight??"400",I.style.textAlign=v?.align??"left",I.style.lineHeight=typeof v?.lineHeight=="number"?`${v.lineHeight}px`:"normal",I.style.whiteSpace=b?"pre":"nowrap",I.style.overflowWrap="normal",I.style.resize="none",I.style.overflow="hidden",typeof S=="number"?I.maxLength=S:I.removeAttribute("maxLength"),I.tabIndex=-1,b&&I instanceof HTMLTextAreaElement&&(I.wrap="off",I.rows=1),nh(g,i)},a=g=>{s();let w=r.canvas,b=g.options.getGeometry?.();if(!w||!b||b.visible===!1){g.element.style.display="none";return}let S=w.getBoundingClientRect(),v=r.renderer?.width||S.width||1,P=r.renderer?.height||S.height||1,C=S.width/v,A=S.height/P,R=b.clipInsets??{top:0,right:0,bottom:0,left:0},M={top:R.top*A,right:R.right*C,bottom:R.bottom*A,left:R.left*C};g.element.style.display="block",g.element.style.left=`${S.left+b.x*C}px`,g.element.style.top=`${S.top+b.y*A}px`,g.element.style.width=`${b.width*C}px`,g.element.style.height=`${b.height*A}px`;let I=Object.values(M).some(k=>k>0);g.element.style.clipPath=I?`inset(${M.top}px ${M.right}px ${M.bottom}px ${M.left}px)`:"none"},l=g=>{if(!i)return;let w=t.get(i),b=g.target;!w||b===w.element||w.element.contains(b)||z3(b)&&e?.contains(b)||X3({app:r,entry:w,event:g})||w.element.blur()},c=()=>{for(let g of t.values()){if(a(g),!g.lastSnapshot){g.lastSnapshot=ar(g);continue}let w=ar(g);W3(w,g.lastSnapshot)||o(g,g.lastSnapshot)}},h=({id:g,options:w})=>{let b=w.multiline===!0?document.createElement("textarea"):document.createElement("input");return b.dataset.routeGraphicsInputId=g,b.style.position="fixed",b.style.border="none",b.style.outline="none",b.style.margin="0",b.style.boxSizing="border-box",b.style.borderRadius="0",b.style.transformOrigin="top left",b.style.appearance="none",b.style.boxShadow="none",b.style.userSelect="none",b.style.webkitUserSelect="none",b},u=g=>{let{id:w,element:b}=g,S=()=>{o(g)};b.addEventListener("focus",()=>{g.pendingBlurTimer&&(clearTimeout(g.pendingBlurTimer),g.pendingBlurTimer=null),i=w,nh(g,i);let v=ar(g);g.lastSnapshot=v,g.callbacks.onFocus?.(v),g.callbacks.onSelectionChange?.(v)}),b.addEventListener("blur",()=>{i===w&&(i=null),nh(g,i),g.pendingBlurTimer=setTimeout(()=>{g.pendingBlurTimer=null;let v=ar(g);if(v.focused){g.lastSnapshot=v;return}g.lastSnapshot=v,g.callbacks.onBlur?.(v),g.callbacks.onSelectionChange?.(v)},0)}),b.addEventListener("input",S),b.addEventListener("select",S),b.addEventListener("click",()=>queueMicrotask(S)),b.addEventListener("keyup",()=>queueMicrotask(S)),b.addEventListener("keydown",v=>{let P=v.key==="Enter"&&g.options.multiline!==!0&&!v.shiftKey,C=v.key==="Enter"&&g.options.multiline===!0&&(v.ctrlKey||v.metaKey);(P||C)&&(v.preventDefault(),g.callbacks.onSubmit?.(ar(g),v)),v.key==="Escape"&&b.blur(),queueMicrotask(S)}),b.addEventListener("compositionstart",()=>{g.composing=!0;let v=ar(g);g.lastSnapshot=v,g.callbacks.onCompositionStart?.(v),g.callbacks.onSelectionChange?.(v)}),b.addEventListener("compositionupdate",()=>{let v=ar(g);g.lastSnapshot=v,g.callbacks.onCompositionUpdate?.(v),g.callbacks.onSelectionChange?.(v)}),b.addEventListener("compositionend",()=>{g.composing=!1,S(),g.callbacks.onCompositionEnd?.(ar(g))})};document.addEventListener("pointerdown",l,!0),r.ticker?.add?.(c);let d=(g,w)=>{s();let b=t.get(g);if(b)return b.options=w,b.callbacks=w.callbacks??{},n(b),a(b),typeof w.value=="string"&&b.element.value!==w.value&&(b.element.value=w.value),b.lastSnapshot=ar(b),b.element;let S={id:g,element:h({id:g,options:w}),options:w,callbacks:w.callbacks??{},composing:!1,pendingBlurTimer:null,lastSnapshot:null};return u(S),typeof w.value=="string"&&(S.element.value=w.value),n(S),e.appendChild(S.element),t.set(g,S),a(S),S.lastSnapshot=ar(S),S.element};return{mount:d,update:(g,w)=>{let b=t.get(g);if(!b)return d(g,w);let S=w.multiline===!0!=b.element instanceof HTMLTextAreaElement;if(b.options=w,b.callbacks=w.callbacks??{},S){let v=b.element,P=document.activeElement===v,C=Qn(v,"selectionStart"),A=Qn(v,"selectionEnd");return b.element=h({id:g,options:w}),u(b),v.replaceWith(b.element),b.element.value=typeof w.value=="string"?w.value:v.value,n(b),a(b),b.lastSnapshot=ar(b),P&&!w.disabled&&queueMicrotask(()=>{b.element.focus(),ob(b.element,C,A)}),b.element}return typeof w.value=="string"&&w.value!==b.element.value&&b.composing!==!0&&(b.element.value=w.value),n(b),a(b),b.lastSnapshot=ar(b),b.element},focus:(g,{selectAll:w=!1,selectionStart:b,selectionEnd:S}={})=>{let v=t.get(g);if(!v||v.element.disabled)return;let P=document.activeElement===v.element;if(i=g,nh(v,i),P||v.element.focus(),w){v.element.select?.(),o(v,v.lastSnapshot);return}if(typeof b=="number"||typeof S=="number"){let C=typeof b=="number"?b:Qn(v.element,"selectionStart"),A=typeof S=="number"?S:typeof b=="number"?b:Qn(v.element,"selectionEnd");ob(v.element,C,A)}o(v,v.lastSnapshot)},setSelection:(g,w,b=w,{focus:S=!1}={})=>{let v=t.get(g);if(!v||v.element.disabled)return;let P=()=>{ob(v.element,w,b),o(v,v.lastSnapshot)};if(S&&document.activeElement!==v.element){v.element.focus(),P();return}P()},blur:g=>{t.get(g)?.element.blur()},unmount:g=>{let w=t.get(g);w&&(i===g&&(i=null),w.pendingBlurTimer&&(clearTimeout(w.pendingBlurTimer),w.pendingBlurTimer=null),w.element.remove(),t.delete(g),t.size===0&&e?.remove())},destroy:()=>{document.removeEventListener("pointerdown",l,!0),r.ticker?.remove?.(c);for(let g of t.values())g.pendingBlurTimer&&(clearTimeout(g.pendingBlurTimer),g.pendingBlurTimer=null),g.element.remove();t.clear(),i=null,e?.remove(),e=void 0}}};var j3=()=>{let r,t=SF(),e={elements:[],animations:[],audio:[]},i,s={animations:[],elements:[],audio:[],parsers:[]},o,n,a,l,c=!1,h,u,d,f,p=new Map,m,x=(v,P,C,A)=>{v.clear(),v.rect(0,0,P,C),v.fill(A??0)},_=v=>v?v.startsWith("audio/")?"audio":v.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(v)?"font":v.startsWith("video/")?"video":"texture":"texture",T=(v,P,{revokable:C=!1}={})=>{p.set(v,{url:P,revokable:C})},g=()=>{for(let v of p.values())v?.revokable===!0&&typeof v?.url=="string"&&URL.revokeObjectURL(v.url);p.clear()},w=(v,P,C)=>{o&&o.registerHotkeys(C?.keyboard??{}),v.renderer.events.cursorStyles||(v.renderer.events.cursorStyles={}),v.renderer.events.cursorStyles.default||(v.renderer.events.cursorStyles.default="default"),v.renderer.events.cursorStyles.hover||(v.renderer.events.cursorStyles.hover="pointer");let A=P?.cursorStyles,R=C?.cursorStyles;gt(A,R)||(R?(R.default&&(v.renderer.events.cursorStyles.default=R.default,v.canvas.style.cursor=R.default),R.hover&&(v.renderer.events.cursorStyles.hover=R.hover)):A&&(v.renderer.events.cursorStyles.default="default",v.renderer.events.cursorStyles.hover="pointer"))},b=(v,P,C,A)=>{h&&h.abort(),h=new AbortController;let R=h.signal;a.reset(C.id),w(v,e.global,C.global),n.cancelAll(),ks({app:v,parent:P,prevComputedTree:e.elements,nextComputedTree:C.elements,animations:C.animations,elementPlugins:s.elements,animationBus:n,completionTracker:a,eventHandler:A,signal:R}),n.flush(),By({app:v,prevAudioTree:e.audio,nextAudioTree:C.audio,audioPlugins:s.audio}),e=C,typeof v.render=="function"&&v.render(),a.completeIfEmpty(),c||(c=!0,l&&l())},S={rendererName:"pixi",get canvas(){return r.canvas},findElementByLabel:v=>r.stage.getChildByLabel(v,!0)??null,extractBase64:async v=>{let P=new Q(0,0,r.renderer.width,r.renderer.height);if(!v)return await r.renderer.extract.base64({target:r.stage,frame:P});let C=r.stage.getChildByLabel(v,!0);if(!C)throw new Error(`Element with label '${v}' not found`);return await r.renderer.extract.base64({target:C,frame:P})},assignStageEvent:(v,P)=>{r.stage.eventMode="static",r.stage.on(v,P)},init:async v=>{let{eventHandler:P,plugins:C,width:A,height:R,backgroundColor:M,debug:I=!1,onFirstRender:k}=v;l=k;let W=[];return C?.elements?.forEach(O=>{O?.parse&&W.push(wF({type:O.type,parse:O.parse}))}),s={animations:C?.animations??[],elements:C?.elements??[],audio:C?.audio??[],parsers:W},i=P,o=kF(P),a=LF(P),r=new Wl,r.audioStage=t,await r.init({width:A,height:R,backgroundColor:M,preference:"webgl"}),typeof r.ticker?.remove=="function"&&r.ticker.remove(r.render,r),r.debug=I,r.inputDomBridge=XF({app:r}),f=O=>{O.preventDefault()},r.canvas.addEventListener("contextmenu",f),m=new Bt,m.label="__route_graphics_background__",x(m,A,R,M),r.stage.addChild(m),r.stage.width=A,r.stage.height=R,r.ticker.add(r.audioStage.tick),n=GF(),I?(u=O=>{O?.detail?.deltaMS&&(n.tick(Number(O.detail.deltaMS)),typeof r.render=="function"&&r.render())},window.addEventListener("snapShotKeyFrame",u)):(d=O=>{n.tick(O.deltaMS),typeof r.render=="function"&&r.render()},r.ticker.add(d)),S},destroy:()=>{h&&(h.abort(),h=void 0),u&&(window.removeEventListener("snapShotKeyFrame",u),u=void 0),d&&typeof r?.ticker?.remove=="function"&&(r.ticker.remove(d),d=void 0),f&&r?.canvas&&(r.canvas.removeEventListener("contextmenu",f),f=void 0),r?.inputDomBridge?.destroy?.(),o?.destroy(),Ey(),n&&n.destroy(),r?.audioStage&&r.audioStage.destroy();let v=P=>{for(let C of P.children){let A=C.texture?.source?.resource;A instanceof HTMLVideoElement&&A.pause(),C.children&&v(C)}};r?.stage&&v(r.stage),r&&r.destroy(),m=void 0,g()},loadAssets:async v=>{if(!v)throw new Error("assetBufferMap is required");let P={audio:{},font:{},video:{},texture:{}};for(let[R,M]of Object.entries(v)){let I=_(M.type);P[I][R]=M}await Promise.all(Object.entries(P.audio).map(([R,M])=>ln.load(R,M.buffer))),await Promise.all(Object.entries(P.font).map(async([R,M])=>{let I=new Blob([M.buffer],{type:M.type}),k=URL.createObjectURL(I),W=new FontFace(R,`url(${k})`);try{await W.load(),document.fonts.add(W)}catch(O){console.error(`Failed to load font ${R}:`,O)}finally{URL.revokeObjectURL(k)}}));let C=Object.entries(P.texture).map(async([R,M])=>{if(gr.cache.has(R))return gr.cache.get(R);if(M?.source==="url"&&typeof M?.url=="string")return gr.load({alias:R,src:M.url,parser:"loadTextures"});let I=new Blob([M.buffer],{type:M.type}),k=await createImageBitmap(I),W=B.from(k);return gr.cache.set(R,W),W}),A=Object.entries(P.video).map(async([R,M])=>{let I=M?.source==="url"&&typeof M?.url=="string"?M.url:URL.createObjectURL(new Blob([M.buffer],{type:M.type})),k=M?.source!=="url";T(R,I,{revokable:k});let W={alias:R,src:I,parser:"loadVideo",data:{}};return typeof M?.type=="string"&&M.type.length>0&&(W.data.mime=M.type),gr.load(W).then(O=>O).catch(O=>{throw p.delete(R),k&&URL.revokeObjectURL(I),O})});return Promise.all([...C,...A])},loadAudioAssets:async v=>Promise.all(v.map(async P=>{let A=await(await fetch(P)).arrayBuffer();return ln.load(P,A)})),updatedBackgroundColor:v=>{r.renderer.background.color=v,m&&x(m,r.renderer.width,r.renderer.height,v),typeof r.render=="function"&&r.render()},render:v=>{let P=sb(v),C=Z_({JSONObject:P.elements,parserPlugins:s.parsers}),A={...P,elements:C};b(r,r.stage,A,i)},parse:v=>{let P=sb(v),C=Z_({JSONObject:P.elements,parserPlugins:s.parsers});return{...P,elements:C}}};return S},jF=j3;var HCt=jF;export{Wl as Application,gr as Assets,ln as AudioAsset,VG as animatedSpritePlugin,OG as containerPlugin,Jx as createAnimationPlugin,rk as createAssetBufferManager,ty as createAudioPlugin,Zt as createElementPlugin,HCt as default,fG as inputPlugin,KG as particlesPlugin,HU as rectPlugin,By as renderAudio,ks as renderElements,tG as sliderPlugin,$G as soundPlugin,VU as spritePlugin,LU as textPlugin,HG as textRevealingPlugin,WG as tweenPlugin,zU as videoPlugin};
|
|
1635
1635
|
/*! Bundled license information:
|
|
1636
1636
|
|
|
1637
1637
|
punycode/punycode.js:
|