route-graphics 1.1.1 → 1.1.2

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.
@@ -1625,7 +1625,7 @@ void main(void)
1625
1625
  `)}}return o.push(`
1626
1626
  renderer.buffer.update(buffer);
1627
1627
  `),{size:s,syncFunc:new Function("ud","uv","renderer","syncData","buffer",o.join(`
1628
- `))}}var oD=0,gf={textureCount:0,uboCount:0},Xi=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=oD++}systemCheck(){if(!uf())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||(gf.textureCount=0,gf.uboCount=0,this.syncUniformGroup(t.uniformGroup,gf)),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]=By(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,gf,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]=Hy(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=Ny(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}};Xi.extension={type:X.RendererSystem,name:"shader"};Z.add(Xi);var bi=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(){}};bi.defaultOptions={hello:!1},bi.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"startup"};Z.add(bi);function HI(r,t=[]){return t[et.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.ADD]=[r.ONE,r.ONE],t[et.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.NONE]=[0,0],t[et.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[et.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[et.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[et.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[et.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[et.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[et.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[et.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[et.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[et.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}var nD=0,aD=1,lD=2,hD=3,cD=4,uD=5,VI=class Vy{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=et.NONE,this._blendEq=!1,this.map=[],this.map[nD]=this.setBlend,this.map[aD]=this.setOffset,this.map[lD]=this.setCullFace,this.map[hD]=this.setDepthTest,this.map[cD]=this.setFrontFace,this.map[uD]=this.setDepthMask,this.checks=[],this.defaultState=new qr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=HI(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(Vy.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Vy.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}};VI.extension={type:X.RendererSystem,name:"state"};var Wy=VI;Z.add(Wy);var An=class extends Ms.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 te(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 Th=class xf{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=xf.defaultMaxIdle,this.checkCountMax=xf.defaultCheckCountMax,this.mode=xf.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Rd.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}};Th.defaultMode=Rd.AUTO,Th.defaultMaxIdle=60*60,Th.defaultCheckCountMax=60*10,Th.extension={type:X.RendererSystem,name:"textureGC"};var Qr=Th;Z.add(Qr);var Ws=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=lt.UNSIGNED_BYTE,this.internalFormat=D.RGBA,this.samplerType=0}};function WI(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:W.FLOAT,[r.RGBA]:W.FLOAT,[r.ALPHA]:W.FLOAT,[r.LUMINANCE]:W.FLOAT,[r.LUMINANCE_ALPHA]:W.FLOAT,[r.R8]:W.FLOAT,[r.R8_SNORM]:W.FLOAT,[r.RG8]:W.FLOAT,[r.RG8_SNORM]:W.FLOAT,[r.RGB8]:W.FLOAT,[r.RGB8_SNORM]:W.FLOAT,[r.RGB565]:W.FLOAT,[r.RGBA4]:W.FLOAT,[r.RGB5_A1]:W.FLOAT,[r.RGBA8]:W.FLOAT,[r.RGBA8_SNORM]:W.FLOAT,[r.RGB10_A2]:W.FLOAT,[r.RGB10_A2UI]:W.FLOAT,[r.SRGB8]:W.FLOAT,[r.SRGB8_ALPHA8]:W.FLOAT,[r.R16F]:W.FLOAT,[r.RG16F]:W.FLOAT,[r.RGB16F]:W.FLOAT,[r.RGBA16F]:W.FLOAT,[r.R32F]:W.FLOAT,[r.RG32F]:W.FLOAT,[r.RGB32F]:W.FLOAT,[r.RGBA32F]:W.FLOAT,[r.R11F_G11F_B10F]:W.FLOAT,[r.RGB9_E5]:W.FLOAT,[r.R8I]:W.INT,[r.R8UI]:W.UINT,[r.R16I]:W.INT,[r.R16UI]:W.UINT,[r.R32I]:W.INT,[r.R32UI]:W.UINT,[r.RG8I]:W.INT,[r.RG8UI]:W.UINT,[r.RG16I]:W.INT,[r.RG16UI]:W.UINT,[r.RG32I]:W.INT,[r.RG32UI]:W.UINT,[r.RGB8I]:W.INT,[r.RGB8UI]:W.UINT,[r.RGB16I]:W.INT,[r.RGB16UI]:W.UINT,[r.RGB32I]:W.INT,[r.RGB32UI]:W.UINT,[r.RGBA8I]:W.INT,[r.RGBA8UI]:W.UINT,[r.RGBA16I]:W.INT,[r.RGBA16UI]:W.UINT,[r.RGBA32I]:W.INT,[r.RGBA32UI]:W.UINT,[r.DEPTH_COMPONENT16]:W.FLOAT,[r.DEPTH_COMPONENT24]:W.FLOAT,[r.DEPTH_COMPONENT32F]:W.FLOAT,[r.DEPTH_STENCIL]:W.FLOAT,[r.DEPTH24_STENCIL8]:W.FLOAT,[r.DEPTH32F_STENCIL8]:W.FLOAT}:t={[r.RGB]:W.FLOAT,[r.RGBA]:W.FLOAT,[r.ALPHA]:W.FLOAT,[r.LUMINANCE]:W.FLOAT,[r.LUMINANCE_ALPHA]:W.FLOAT,[r.DEPTH_STENCIL]:W.FLOAT},t}function zI(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[lt.UNSIGNED_BYTE]:{[D.RGBA]:r.RGBA8,[D.RGB]:r.RGB8,[D.RG]:r.RG8,[D.RED]:r.R8,[D.RGBA_INTEGER]:r.RGBA8UI,[D.RGB_INTEGER]:r.RGB8UI,[D.RG_INTEGER]:r.RG8UI,[D.RED_INTEGER]:r.R8UI,[D.ALPHA]:r.ALPHA,[D.LUMINANCE]:r.LUMINANCE,[D.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[lt.BYTE]:{[D.RGBA]:r.RGBA8_SNORM,[D.RGB]:r.RGB8_SNORM,[D.RG]:r.RG8_SNORM,[D.RED]:r.R8_SNORM,[D.RGBA_INTEGER]:r.RGBA8I,[D.RGB_INTEGER]:r.RGB8I,[D.RG_INTEGER]:r.RG8I,[D.RED_INTEGER]:r.R8I},[lt.UNSIGNED_SHORT]:{[D.RGBA_INTEGER]:r.RGBA16UI,[D.RGB_INTEGER]:r.RGB16UI,[D.RG_INTEGER]:r.RG16UI,[D.RED_INTEGER]:r.R16UI,[D.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[lt.SHORT]:{[D.RGBA_INTEGER]:r.RGBA16I,[D.RGB_INTEGER]:r.RGB16I,[D.RG_INTEGER]:r.RG16I,[D.RED_INTEGER]:r.R16I},[lt.UNSIGNED_INT]:{[D.RGBA_INTEGER]:r.RGBA32UI,[D.RGB_INTEGER]:r.RGB32UI,[D.RG_INTEGER]:r.RG32UI,[D.RED_INTEGER]:r.R32UI,[D.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[lt.INT]:{[D.RGBA_INTEGER]:r.RGBA32I,[D.RGB_INTEGER]:r.RGB32I,[D.RG_INTEGER]:r.RG32I,[D.RED_INTEGER]:r.R32I},[lt.FLOAT]:{[D.RGBA]:r.RGBA32F,[D.RGB]:r.RGB32F,[D.RG]:r.RG32F,[D.RED]:r.R32F,[D.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[lt.HALF_FLOAT]:{[D.RGBA]:r.RGBA16F,[D.RGB]:r.RGB16F,[D.RG]:r.RG16F,[D.RED]:r.R16F},[lt.UNSIGNED_SHORT_5_6_5]:{[D.RGB]:r.RGB565},[lt.UNSIGNED_SHORT_4_4_4_4]:{[D.RGBA]:r.RGBA4},[lt.UNSIGNED_SHORT_5_5_5_1]:{[D.RGBA]:r.RGB5_A1},[lt.UNSIGNED_INT_2_10_10_10_REV]:{[D.RGBA]:r.RGB10_A2,[D.RGBA_INTEGER]:r.RGB10_A2UI},[lt.UNSIGNED_INT_10F_11F_11F_REV]:{[D.RGB]:r.R11F_G11F_B10F},[lt.UNSIGNED_INT_5_9_9_9_REV]:{[D.RGB]:r.RGB9_E5},[lt.UNSIGNED_INT_24_8]:{[D.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[lt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[D.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[lt.UNSIGNED_BYTE]:{[D.RGBA]:r.RGBA,[D.RGB]:r.RGB,[D.ALPHA]:r.ALPHA,[D.LUMINANCE]:r.LUMINANCE,[D.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[lt.UNSIGNED_SHORT_5_6_5]:{[D.RGB]:r.RGB},[lt.UNSIGNED_SHORT_4_4_4_4]:{[D.RGBA]:r.RGBA},[lt.UNSIGNED_SHORT_5_5_5_1]:{[D.RGBA]:r.RGBA}},t}var Pn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new gt,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=zI(t),this.samplerTypes=WI(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 Ws(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 Ws(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!==W.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new Ws(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]??W.FLOAT,this.webGLVersion===2&&t.type===lt.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!==W.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&&yy(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ar.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Nl.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!==Ar.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===mr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===mr.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===mr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===mr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}};Pn.extension={type:X.RendererSystem,name:"texture"};Z.add(Pn);var Cn=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}};Cn.extension={type:X.RendererSystem,name:"transformFeedback"};Z.add(Cn);var vi=class{constructor(t){this.renderer=t}init(t){this.screen=new _t(0,0,t.width,t.height),this.element=t.view||K.ADAPTER.createCanvas(),this.resolution=t.resolution||K.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}};vi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},vi.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_view"};Z.add(vi);K.PREFER_ENV=Je.WEBGL2;K.STRICT_TEXTURE_CACHE=!1;K.RENDER_OPTIONS={..._i.defaultOptions,...yi.defaultOptions,...vi.defaultOptions,...bi.defaultOptions};Object.defineProperties(K,{WRAP_MODE:{get(){return gt.defaultOptions.wrapMode},set(r){ft("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),gt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return gt.defaultOptions.scaleMode},set(r){ft("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),gt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return gt.defaultOptions.mipmap},set(r){ft("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),gt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return gt.defaultOptions.anisotropicLevel},set(r){ft("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),gt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ft("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Zr.defaultResolution},set(r){Zr.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ft("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Zr.defaultMultisample},set(r){Zr.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return xi.defaultMaxTextures},set(r){ft("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),xi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return xi.defaultBatchSize},set(r){ft("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),xi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return xi.canUploadSameBuffer},set(r){ft("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),xi.canUploadSameBuffer=r}},GC_MODE:{get(){return Qr.defaultMode},set(r){ft("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Qr.defaultMode=r}},GC_MAX_IDLE:{get(){return Qr.defaultMaxIdle},set(r){ft("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Qr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Qr.defaultCheckCountMax},set(r){ft("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Qr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return yr.defaultVertexPrecision},set(r){ft("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),yr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return yr.defaultFragmentPrecision},set(r){ft("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),yr.defaultFragmentPrecision=r}}});var zs=(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))(zs||{});var Rn=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 $I=class sr{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 Rn(null,null,1/0),this.deltaMS=1/sr.targetFPMS,this.elapsedMS=1/sr.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=zs.NORMAL){return this._addListener(new Rn(t,e,i))}addOnce(t,e,i=zs.NORMAL){return this._addListener(new Rn(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*sr.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,sr.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(!sr._shared){let t=sr._shared=new sr;t.autoStart=!0,t._protected=!0}return sr._shared}static get system(){if(!sr._system){let t=sr._system=new sr;t.autoStart=!0,t._protected=!0}return sr._system}};$I.targetFPMS=.06;var _r=$I;Object.defineProperties(K,{TARGET_FPMS:{get(){return _r.targetFPMS},set(r){ft("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),_r.targetFPMS=r}}});var Sh=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,zs.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?_r.shared:new _r,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};Sh.extension=X.Application;Z.add(Sh);var dD=[];Z.handleByList(X.Renderer,dD);var wh=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>=Rt.HIGH?this.multisample=Rt.HIGH:e>=Rt.MEDIUM?this.multisample=Rt.MEDIUM:e>=Rt.LOW?this.multisample=Rt.LOW:this.multisample=Rt.NONE}destroy(){}};wh.extension={type:X.RendererSystem,name:"_multisample"};Z.add(wh);var yf=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var Eh=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 yf(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};Eh.extension={type:X.RendererSystem,name:"buffer"};Z.add(Eh);var Ah=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}};Ah.extension={type:X.RendererSystem,name:"objectRenderer"};Z.add(Ah);var _f=class zy extends An{constructor(t){super(),this.type=Fx.WEBGL,t=Object.assign({},K.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ir({projectionMatrix:new Ut},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:zy.__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&&(ft("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=zy.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:gy()}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 ft("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ft("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ft("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ft("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ft("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ft("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ft("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ft("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)}};_f.extension={type:X.Renderer,priority:1},_f.__plugins={},_f.__systems={};var bf=_f;Z.handleByMap(X.RendererPlugin,bf.__plugins);Z.handleByMap(X.RendererSystem,bf.__systems);Z.add(bf);var ji=class extends rr{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 gt;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 rr?this.addResourceAt(t[i],i):this.addResourceAt(cn(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 Ph=class extends ji{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=di.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 h=n[l];o[l]<h.dirtyId&&(o[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}};var Ch=class extends me{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var XI=class Rh extends ji{constructor(t,e){let{width:i,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==Rh.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Rh.SIDES;a++)this.items[a].target=di.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=di.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=di.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<Rh.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===Rh.SIDES}};XI.SIDES=6;var $y=XI;var Mh=class r extends me{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 K.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===tr.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??K.ADAPTER.createCanvas(0,0),r._EMPTY}};var Xy=class vf extends me{constructor(t,e){e=e||{},super(K.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)},vf.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;me.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_${pi()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=vf.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"&&vf.SVG_XML.test(t)}};Xy.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Xy.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var jy=Xy;var Tf=class extends me{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var Yy=class qy extends me{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];me.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 h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||qy.MIME_TYPES[c]||`video/${c}`}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=_r.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&&(_r.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||(_r.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(_r.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||qy.TYPES.includes(e)}};Yy.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Yy.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var Ky=Yy;eh.push(Mh,Ds,Ch,Ky,Tf,jy,Is,$y,Ph);var fD={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)}},pD={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 jI(r,t,e,i,s){let o=0,n=null,a=null,l=s.gl;for(let h in r.uniforms){let c=t[h],u=i[h],d=e[h],f=r.uniforms[h];if(!c){f.group===!0&&s.shader.syncUniformGroup(u);continue}c.type==="float"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1f(d.location,u)):c.type==="bool"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1i(d.location,Number(u))):(c.type==="sampler2D"||c.type==="samplerCube"||c.type==="sampler2DArray")&&c.size===1&&!c.isArray?(s.texture.bind(u,o),d.value!==o&&(d.value=o,l.uniform1i(d.location,o)),o++):c.type==="mat3"&&c.size===1&&!c.isArray?f.a!==void 0?l.uniformMatrix3fv(d.location,!1,u.toArray(!0)):l.uniformMatrix3fv(d.location,!1,u):c.type==="vec2"&&c.size===1&&!c.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]))):c.type==="vec4"&&c.size===1&&!c.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]))):(c.size===1&&!c.isArray?fD:pD)[c.type].call(null,l,d.location,d.value,u)}}function mD(){Object.assign(Xi.prototype,{systemCheck(){},syncUniforms(r,t){let{shader:e,renderer:i}=this;jI(r,e.program.uniformData,t.uniformData,r.uniforms,i)}})}mD();var Ih=new(window.AudioContext||window.webkitAudioContext),gD=(r,t)=>{let e,i=Ih.createGain();i.gain.value=t.volume??1,i.connect(Ih.destination);let s={id:r,url:t.url,loop:t.loop||!1,volume:t.volume??1};return{play:()=>{let g=qo.getAsset(s.url);if(!g){console.warn("AudioPlayer.play: Asset not found",s.url);return}e=Ih.createBufferSource(),e.buffer=g,e.loop=s.loop,i.gain.setValueAtTime(s.volume,Ih.currentTime),e.connect(i),e.start(0)},stop:()=>{e&&(e.stop(),e.disconnect(),i.disconnect(),i.connect(Ih.destination))},update:g=>{s={...s,...g}},getId:()=>s.id,getUrl:()=>s.url,getLoop:()=>s.loop,getVolume:()=>s.volume,setUrl:g=>{s.url=g},setLoop:g=>{s.loop=g},setVolume:g=>{s.volume=g,i.gain.value=g},get id(){return s.id},get url(){return s.url},get loop(){return s.loop},get volume(){return s.volume},gainNode:i}},YI=()=>{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 h=r.find(c=>c.id===l.id);if(!h){let c=gD(l.id,{url:l.url,loop:l.loop,volume:l.volume??1});r.push(c),c.play();continue}(h.url!==l.url||h.loop!==l.loop)&&(h.stop(),h.setUrl(l.url),h.setLoop(l.loop??!1),h.play()),h.getVolume()!==(l.volume??1)&&h.setVolume(l.volume??1)}let a=[];for(let l of r)t.find(h=>h.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 xD=({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 Zy=xD;var qI=({type:r,parse:t})=>({type:r,parse:t});var Qy=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Jy(r,t,e,i){r.addEventListener?r.addEventListener(t,e,i):r.attachEvent&&r.attachEvent(`on${t}`,e)}function Bh(r,t,e,i){r&&(r.removeEventListener?r.removeEventListener(t,e,i):r.detachEvent&&r.detachEvent(`on${t}`,e))}function QI(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 JI(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 yD(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 tB(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 Uh={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,"-":Qy?173:189,"=":Qy?61:187,";":Qy?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},Mr={"\u21E7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,meta:91,command:91},Fh={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},we={16:!1,18:!1,17:!1,91:!1},Xt={};for(let r=1;r<20;r++)Uh[`f${r}`]=111+r;var Vt=[],kh=null,eB="all",Ti=new Map,Mn=r=>Uh[r.toLowerCase()]||Mr[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),_D=r=>Object.keys(Uh).find(t=>Uh[t]===r),bD=r=>Object.keys(Mr).find(t=>Mr[t]===r),rB=r=>{eB=r||"all"},Gh=()=>eB||"all",vD=()=>Vt.slice(0),TD=()=>Vt.map(r=>_D(r)||bD(r)||String.fromCharCode(r)),SD=()=>{let r=[];return Object.keys(Xt).forEach(t=>{Xt[t].forEach(({key:e,scope:i,mods:s,shortcut:o})=>{r.push({scope:i,shortcut:o,mods:s,keys:e.split("+").map(n=>Mn(n))})})}),r},iB=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},wD=r=>(typeof r=="string"&&(r=Mn(r)),Vt.indexOf(r)!==-1),ED=(r,t)=>{let e,i;r||(r=Gh());for(let s in Xt)if(Object.prototype.hasOwnProperty.call(Xt,s))for(e=Xt[s],i=0;i<e.length;)e[i].scope===r?e.splice(i,1).forEach(({element:o})=>e_(o)):i++;Gh()===r&&rB(t||"all")};function AD(r){let t=tB(r);r.key&&r.key.toLowerCase()==="capslock"&&(t=Mn(r.key));let e=Vt.indexOf(t);if(e>=0&&Vt.splice(e,1),r.key&&r.key.toLowerCase()==="meta"&&Vt.splice(0,Vt.length),(t===93||t===224)&&(t=91),t in we){we[t]=!1;for(let i in Mr)Mr[i]===t&&(or[i]=!1)}}var sB=(r,...t)=>{if(typeof r>"u")Object.keys(Xt).forEach(e=>{Array.isArray(Xt[e])&&Xt[e].forEach(i=>Sf(i)),delete Xt[e]}),e_(null);else if(Array.isArray(r))r.forEach(e=>{e.key&&Sf(e)});else if(typeof r=="object")r.key&&Sf(r);else if(typeof r=="string"){let[e,i]=t;typeof e=="function"&&(i=e,e=""),Sf({key:r,scope:e,method:i,splitKey:"+"})}},Sf=({key:r,scope:t,method:e,splitKey:i="+"})=>{JI(r).forEach(s=>{let o=s.split(i),n=o.length,a=o[n-1],l=a==="*"?"*":Mn(a);if(!Xt[l])return;t||(t=Gh());let h=n>1?QI(Mr,o):[],c=[];Xt[l]=Xt[l].filter(u=>{let d=(e?u.method===e:!0)&&u.scope===t&&yD(u.mods,h);return d&&c.push(u.element),!d}),c.forEach(u=>e_(u))})};function KI(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 we)Object.prototype.hasOwnProperty.call(we,o)&&(!we[o]&&t.mods.indexOf(+o)>-1||we[o]&&t.mods.indexOf(+o)===-1)&&(s=!1);(t.mods.length===0&&!we[16]&&!we[18]&&!we[17]&&!we[91]||s||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Vt),t.method(r,t)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function ZI(r,t){let e=Xt["*"],i=tB(r);if(r.key&&r.key.toLowerCase()==="capslock"||!(or.filter||iB).call(this,r))return;if((i===93||i===224)&&(i=91),Vt.indexOf(i)===-1&&i!==229&&Vt.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{let l=Fh[a];r[a]&&Vt.indexOf(l)===-1?Vt.push(l):!r[a]&&Vt.indexOf(l)>-1?Vt.splice(Vt.indexOf(l),1):a==="metaKey"&&r[a]&&(Vt=Vt.filter(h=>h in Fh||h===i))}),i in we){we[i]=!0;for(let a in Mr)if(Object.prototype.hasOwnProperty.call(Mr,a)){let l=Fh[Mr[a]];or[a]=r[l]}if(!e)return}for(let a in we)Object.prototype.hasOwnProperty.call(we,a)&&(we[a]=r[Fh[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Vt.indexOf(17)===-1&&Vt.push(17),Vt.indexOf(18)===-1&&Vt.push(18),we[17]=!0,we[18]=!0);let s=Gh();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)&&KI(r,e[a],s,t);if(!(i in Xt))return;let o=Xt[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:h}=l,c=l.key.split(h),u=[];for(let d=0;d<c.length;d++)u.push(Mn(c[d]));u.sort().join("")===Vt.sort().join("")&&KI(r,l,s,t)}}var or=function(r,t,e){Vt=[];let i=JI(r),s=[],o="all",n=document,a=0,l=!1,h=!0,c="+",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&&(h=f.keydown),f.capture!==void 0&&(u=f.capture),typeof f.splitKey=="string"&&(c=f.splitKey),f.single===!0&&(d=!0)}for(typeof t=="string"&&(o=t),d&&sB(r,o);a<i.length;a++){let f=i[a].split(c);s=[],f.length>1&&(s=QI(Mr,f));let p=f[f.length-1];p=p==="*"?"*":Mn(p),p in Xt||(Xt[p]=[]),Xt[p].push({keyup:l,keydown:h,scope:o,mods:s,shortcut:i[a],method:e,key:i[a],splitKey:c,element:n})}if(typeof n<"u"&&typeof window<"u"){if(!Ti.has(n)){let f=(g=window.event)=>ZI(g,n),p=(g=window.event)=>{ZI(g,n),AD(g)};Ti.set(n,{keydownListener:f,keyupListenr:p,capture:u}),Jy(n,"keydown",f,u),Jy(n,"keyup",p,u)}if(!kh){let f=()=>{Vt=[]};kh={listener:f,capture:u},Jy(window,"focus",f,u)}}};function PD(r,t="all"){Object.keys(Xt).forEach(e=>{Xt[e].filter(i=>i.scope===t&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method({},i)})})}function e_(r){let t=Object.values(Xt).flat();if(t.findIndex(({element:e})=>e===r)<0&&r){let{keydownListener:e,keyupListenr:i,capture:s}=Ti.get(r)||{};e&&i&&(Bh(r,"keyup",i,s),Bh(r,"keydown",e,s),Ti.delete(r))}if((t.length<=0||Ti.size<=0)&&(Array.from(Ti.keys()).forEach(e=>{let{keydownListener:i,keyupListenr:s,capture:o}=Ti.get(e)||{};i&&s&&(Bh(e,"keyup",s,o),Bh(e,"keydown",i,o),Ti.delete(e))}),Ti.clear(),Object.keys(Xt).forEach(e=>delete Xt[e]),kh)){let{listener:e,capture:i}=kh;Bh(window,"focus",e,i),kh=null}}var t_={getPressedKeyString:TD,setScope:rB,getScope:Gh,deleteScope:ED,getPressedKeyCodes:vD,getAllKeyCodes:SD,isPressed:wD,filter:iB,trigger:PD,unbind:sB,keyMap:Uh,modifier:Mr,modifierMap:Fh};for(let r in t_){let t=r;Object.prototype.hasOwnProperty.call(t_,t)&&(or[t]=t_[t])}if(typeof window<"u"){let r=window.hotkeys;or.noConflict=t=>(t&&window.hotkeys===or&&(window.hotkeys=r),or),window.hotkeys=or}var CD=Object.prototype.hasOwnProperty,oB=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 h=t.get(l);h?Et(h.payload,s[l].payload)||(n.push(l),or.unbind(l)):o.push(l)}),t.forEach((l,h)=>{CD.call(s,h)||a.push(h)}),a.forEach(l=>{or.unbind(l),t.delete(l)}),[...o,...n].forEach(l=>{let c=s[l].payload??{};or(l,()=>{r&&r("keydown",{_event:{key:l},...c})}),t.set(l,{value:l,payload:c})})},destroy:()=>{for(let s of t.keys())or.unbind(s);t.clear()}}};var aB=(r,t)=>typeof t!="string"?t:r[t]??t,RD=(r,t,e,i)=>{let s=aB(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},nB=(r,t,e,i)=>{let s=aB(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},MD=(r,t,e)=>Object.entries(t).map(([i,s])=>{if(!Vu[i])throw new Error(`${i} is not a supported property for animation.`);let o=RD(r,i,e,0),n=s.initialValue??o,a=Il([{value:n},...s.keyframes]);return{property:i,timeline:a}}),lB=()=>{let r=[],t=new Map,e=new Map,i=0,s=(v,S)=>{e.get(v)?.forEach(P=>{try{P(S)}catch{}})},o=v=>{if(s("completed",{id:v.id}),v.onComplete)try{v.onComplete()}catch{}},n=v=>{let{id:S,element:P,properties:R,targetState:A,onComplete:C,onCancel:M,propertyPathMap:B=Wu}=v,k=MD(P,R,B),U={id:S,kind:"property",element:P,timelines:k,duration:Bl(k),currentTime:0,stateVersion:i,targetState:A,onComplete:C,onCancel:M,applyFrame:O=>{for(let{property:$,timeline:N}of k){let L=Fl(N,O);try{nB(P,$,B,L)}catch{}}},applyTargetState:()=>{if(!(!P||P.destroyed)){if(A===null){P.destroy();return}if(A)for(let[O,$]of Object.entries(A))try{nB(P,O,B,$)}catch{}}},isValid:()=>!!P&&!P.destroyed};U.applyFrame(0),t.set(S,U),s("started",{id:S})},a=v=>{let S={id:v.id,kind:"custom",duration:v.duration??0,currentTime:0,stateVersion:i,onComplete:v.onComplete,onCancel:v.onCancel,applyFrame:v.applyFrame??(()=>{}),applyTargetState:v.applyTargetState??(()=>{}),isValid:v.isValid??(()=>!0)};S.applyFrame(0),t.set(S.id,S),s("started",{id:S.id})},l=v=>{if(v.driver==="custom"){a(v);return}n(v)},h=v=>{try{v.applyTargetState?.()}catch{}if(v.onCancel)try{v.onCancel()}catch{}},c=v=>{switch(v.type){case"START":l(v.payload);break;case"CANCEL":d(v.id);break}},u=()=>{let v=r.splice(0);for(let S of v)c(S)},d=v=>{let S=t.get(v);S&&(h(S),t.delete(v),s("cancelled",{id:v}))},f=v=>{r.push(v)},p=()=>{for(let[v,S]of t)h(S),s("cancelled",{id:v});t.clear(),i++},g=v=>{u();let S=[];for(let[P,R]of t){if(R.stateVersion!==i){S.push(P);continue}if(!R.isValid()){S.push(P);continue}if(R.currentTime+=v,R.currentTime>=R.duration){R.applyFrame(R.duration),o(R),S.push(P);continue}R.applyFrame(R.currentTime)}for(let P of S)t.delete(P)},m=()=>{u()},_=(v,S)=>(e.has(v)||e.set(v,new Set),e.get(v).add(S),()=>b(v,S)),b=(v,S)=>{e.get(v)?.delete(S)};return{dispatch:f,cancelAll:p,flush:m,tick:g,on:_,off:b,getState:()=>({stateVersion:i,activeCount:t.size,animations:Array.from(t.entries()).map(([v,S])=>({id:v,currentTime:S.currentTime,duration:S.duration,progress:S.duration>0?S.currentTime/S.duration:0}))}),isAnimating:v=>t.has(v),destroy:()=>{p(),e.clear()}}};var hB=r=>{let t=0,e=0,i=null;return{reset:h=>{t>0&&i!==null&&r?.("renderComplete",{id:i,aborted:!0}),e++,t=0,i=h},track:h=>{h===e&&t++},complete:h=>{h===e&&(t--,t===0&&r?.("renderComplete",{id:i,aborted:!1}))},getVersion:()=>e,completeIfEmpty:()=>{t===0&&r?.("renderComplete",{id:i,aborted:!1})}}};var cB=new Set(["update","transition"]),ID=new Set(["alpha","x","y","scaleX","scaleY","rotation"]),BD=new Set(["translateX","translateY","alpha","scaleX","scaleY","rotation"]),uB=new Set(["single","sequence","composite"]),Ef=new Set(["red","green","blue","alpha"]),dB=new Set(["max","min","multiply","add"]),FD=new Set(vx),Yi=(r,t)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`${t} must be an object.`)},$s=(r,t)=>{if(typeof r!="string"||r.length===0)throw new Error(`${t} must be a non-empty string.`)},wf=(r,t)=>{if(typeof r!="number"||Number.isNaN(r))throw new Error(`${t} must be a number.`)},pB=(r,t)=>{Yi(r,t);let e={};if(r.initialValue!==void 0&&(wf(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(Yi(i,o),wf(i.value,`${o}.value`),wf(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&&!FD.has(i.easing))throw new Error(`${o}.easing must be one of: ${vx.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},mB=(r,t,e)=>{Yi(r,t);let i=Object.entries(r).map(([s,o])=>{if(!e.has(s))throw new Error(`${t}.${s} is not a supported animation property.`);return[s,pB(o,`${t}.${s}`)]});if(i.length===0)throw new Error(`${t} must define at least one property.`);return Object.fromEntries(i)},kD=(r,t)=>{if(Yi(r,t),$s(r.texture,`${t}.texture`),r.channel!==void 0&&!Ef.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(Ef).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}:{}}},UD=(r,t)=>{if(Yi(r,t),!uB.has(r.kind))throw new Error(`${t}.kind must be one of: ${Array.from(uB).join(", ")}.`);let e={kind:r.kind};if(r.channel!==void 0){if(!Ef.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(Ef).join(", ")}.`);e.channel=r.channel}if(r.softness!==void 0&&(wf(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=pB(r.progress,`${t}.progress`)),r.kind==="single"&&($s(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)=>($s(i,`${t}.textures[${s}]`),i)),r.sample!==void 0&&($s(r.sample,`${t}.sample`),e.sample=r.sample)}if(r.kind==="composite"){if(!dB.has(r.combine??"max"))throw new Error(`${t}.combine must be one of: ${Array.from(dB).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)=>kD(i,`${t}.items[${s}]`))}return e.progress||(e.progress={initialValue:0,keyframes:[{duration:0,value:1,easing:"linear"}]}),e},fB=(r,t)=>{if(Yi(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=mB(r.tween,`${t}.tween`,BD)),Object.keys(e).length===0)throw new Error(`${t} must define tween.`);return e},GD=(r,t)=>{let e={};if(r.shader!==void 0)throw new Error(`${t}.shader is not supported.`);if(r.prev!==void 0&&(e.prev=fB(r.prev,`${t}.prev`)),r.next!==void 0&&(e.next=fB(r.next,`${t}.next`)),r.mask!==void 0&&(e.mask=UD(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},r_=(r,t,e)=>{if(r!==void 0)throw new Error(`${t} ${e}`)},gB=(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(Yi(i,o),$s(i.id,`${o}.id`),$s(i.targetId,`${o}.targetId`),$s(i.type,`${o}.type`),!cB.has(i.type))throw new Error(`${o}.type must be one of: ${Array.from(cB).join(", ")}.`);let n={id:i.id,targetId:i.targetId,type:i.type};if(i.complete!==void 0&&(Yi(i.complete,`${o}.complete`),n.complete=i.complete),r_(i.operation,`${o}.operation`,"is no longer supported. Use `type: update | transition` instead."),r_(i.properties,`${o}.properties`,"is no longer supported. Use `tween` instead."),r_(i.subjects,`${o}.subjects`,"is no longer supported. Use `prev` / `next` instead."),i.type==="update"){if(n.tween=mB(i.tween,`${o}.tween`,ID),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=GD(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 i_=(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=gB(t.animations),t};var OD=()=>{let r,t=YI(),e={elements:[],animations:[],audio:[]},i,s={animations:[],elements:[],audio:[],parsers:[]},o,n,a,l,h=!1,c,u,d,f=new Map,p,g=(v,S,P,R)=>{v.clear(),v.rect(0,0,S,P),v.fill(R??0)},m=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",_=(v,S,{revokable:P=!1}={})=>{f.set(v,{url:S,revokable:P})},b=()=>{for(let v of f.values())v?.revokable===!0&&typeof v?.url=="string"&&URL.revokeObjectURL(v.url);f.clear()},y=(v,S,P)=>{o&&o.registerHotkeys(P?.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 R=S?.cursorStyles,A=P?.cursorStyles;Et(R,A)||(A?(A.default&&(v.renderer.events.cursorStyles.default=A.default,v.canvas.style.cursor=A.default),A.hover&&(v.renderer.events.cursorStyles.hover=A.hover)):R&&(v.renderer.events.cursorStyles.default="default",v.renderer.events.cursorStyles.hover="pointer"))},w=(v,S,P,R)=>{c&&c.abort(),c=new AbortController;let A=c.signal;a.reset(P.id),y(v,e.global,P.global),n.cancelAll(),Ts({app:v,parent:S,prevComputedTree:e.elements,nextComputedTree:P.elements,animations:P.animations,elementPlugins:s.elements,animationBus:n,completionTracker:a,eventHandler:R,signal:A}),n.flush(),Bx({app:v,prevAudioTree:e.audio,nextAudioTree:P.audio,audioPlugins:s.audio}),e=P,a.completeIfEmpty(),h||(h=!0,l&&l())},E={rendererName:"pixi",get canvas(){return r.canvas},findElementByLabel:v=>r.stage.getChildByLabel(v,!0)??null,extractBase64:async v=>{let S=new tt(0,0,r.renderer.width,r.renderer.height);if(!v)return await r.renderer.extract.base64({target:r.stage,frame:S});let P=r.stage.getChildByLabel(v,!0);if(!P)throw new Error(`Element with label '${v}' not found`);return await r.renderer.extract.base64({target:P,frame:S})},assignStageEvent:(v,S)=>{r.stage.eventMode="static",r.stage.on(v,S)},init:async v=>{let{eventHandler:S,plugins:P,width:R,height:A,backgroundColor:C,debug:M=!1,onFirstRender:B}=v;l=B;let k=[];return P?.elements?.forEach(U=>{U?.parse&&k.push(qI({type:U.type,parse:U.parse}))}),s={animations:P?.animations??[],elements:P?.elements??[],audio:P?.audio??[],parsers:k},i=S,o=oB(S),a=hB(S),r=new vl,r.audioStage=t,await r.init({width:R,height:A,backgroundColor:C,preference:"webgl"}),r.debug=M,d=U=>{U.preventDefault()},r.canvas.addEventListener("contextmenu",d),p=new de,p.label="__route_graphics_background__",g(p,R,A,C),r.stage.addChild(p),r.stage.width=R,r.stage.height=A,r.ticker.add(r.audioStage.tick),n=lB(),M?(u=U=>{U?.detail?.deltaMS&&n.tick(Number(U.detail.deltaMS))},window.addEventListener("snapShotKeyFrame",u)):r.ticker.add(U=>n.tick(U.deltaMS)),E},destroy:()=>{c&&(c.abort(),c=void 0),u&&(window.removeEventListener("snapShotKeyFrame",u),u=void 0),d&&r?.canvas&&(r.canvas.removeEventListener("contextmenu",d),d=void 0),o?.destroy(),Ex(),n&&n.destroy(),r?.audioStage&&r.audioStage.destroy();let v=S=>{for(let P of S.children){let R=P.texture?.source?.resource;R instanceof HTMLVideoElement&&R.pause(),P.children&&v(P)}};r?.stage&&v(r.stage),r&&r.destroy(),p=void 0,b()},loadAssets:async v=>{if(!v)throw new Error("assetBufferMap is required");let S={audio:{},font:{},video:{},texture:{}};for(let[A,C]of Object.entries(v)){let M=m(C.type);S[M][A]=C}await Promise.all(Object.entries(S.audio).map(([A,C])=>qo.load(A,C.buffer))),await Promise.all(Object.entries(S.font).map(async([A,C])=>{let M=new Blob([C.buffer],{type:C.type}),B=URL.createObjectURL(M),k=new FontFace(A,`url(${B})`);try{await k.load(),document.fonts.add(k)}catch(U){console.error(`Failed to load font ${A}:`,U)}finally{URL.revokeObjectURL(B)}}));let P=Object.entries(S.texture).map(async([A,C])=>{if(pr.cache.has(A))return pr.cache.get(A);if(C?.source==="url"&&typeof C?.url=="string")return pr.load({alias:A,src:C.url,parser:"texture"});let M=new Blob([C.buffer],{type:C.type}),B=await createImageBitmap(M),k=I.from(B);return pr.cache.set(A,k),k}),R=Object.entries(S.video).map(async([A,C])=>{let M=C?.source==="url"&&typeof C?.url=="string"?C.url:URL.createObjectURL(new Blob([C.buffer],{type:C.type})),B=C?.source!=="url";_(A,M,{revokable:B});let k={alias:A,src:M,parser:"video",data:{}};return typeof C?.type=="string"&&C.type.length>0&&(k.data.mime=C.type),pr.load(k).then(U=>U).catch(U=>{throw f.delete(A),B&&URL.revokeObjectURL(M),U})});return Promise.all([...P,...R])},loadAudioAssets:async v=>Promise.all(v.map(async S=>{let R=await(await fetch(S)).arrayBuffer();return qo.load(S,R)})),updatedBackgroundColor:v=>{r.renderer.background.color=v,p&&g(p,r.renderer.width,r.renderer.height,v)},render:v=>{let S=i_(v),P=Zy({JSONObject:S.elements,parserPlugins:s.parsers}),R={...S,elements:P};w(r,r.stage,R,i)},parse:v=>{let S=i_(v),P=Zy({JSONObject:S.elements,parserPlugins:s.parsers});return{...S,elements:P}}};return E},xB=OD;var $At=xB;export{vl as Application,pr as Assets,qo as AudioAsset,DU as animatedSpritePlugin,GU as containerPlugin,dx as createAnimationPlugin,AB as createAssetBufferManager,fx as createAudioPlugin,fe as createElementPlugin,$At as default,jU as particlesPlugin,uU as rectPlugin,Bx as renderAudio,Ts as renderElements,mU as sliderPlugin,VU as soundPlugin,dU as spritePlugin,lU as textPlugin,LU as textRevealingPlugin,NU as tweenPlugin,pU as videoPlugin};
1628
+ `))}}var oD=0,gf={textureCount:0,uboCount:0},Xi=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=oD++}systemCheck(){if(!uf())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||(gf.textureCount=0,gf.uboCount=0,this.syncUniformGroup(t.uniformGroup,gf)),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]=By(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,gf,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]=Hy(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=Ny(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}};Xi.extension={type:X.RendererSystem,name:"shader"};Z.add(Xi);var bi=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(){}};bi.defaultOptions={hello:!1},bi.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"startup"};Z.add(bi);function HI(r,t=[]){return t[et.NORMAL]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.ADD]=[r.ONE,r.ONE],t[et.MULTIPLY]=[r.DST_COLOR,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SCREEN]=[r.ONE,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.OVERLAY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.DARKEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.LIGHTEN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.COLOR_DODGE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.COLOR_BURN]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.HARD_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SOFT_LIGHT]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.DIFFERENCE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.EXCLUSION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.HUE]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SATURATION]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.COLOR]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.LUMINOSITY]=[r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.NONE]=[0,0],t[et.NORMAL_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.ADD_NPM]=[r.SRC_ALPHA,r.ONE,r.ONE,r.ONE],t[et.SCREEN_NPM]=[r.SRC_ALPHA,r.ONE_MINUS_SRC_COLOR,r.ONE,r.ONE_MINUS_SRC_ALPHA],t[et.SRC_IN]=[r.DST_ALPHA,r.ZERO],t[et.SRC_OUT]=[r.ONE_MINUS_DST_ALPHA,r.ZERO],t[et.SRC_ATOP]=[r.DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[et.DST_OVER]=[r.ONE_MINUS_DST_ALPHA,r.ONE],t[et.DST_IN]=[r.ZERO,r.SRC_ALPHA],t[et.DST_OUT]=[r.ZERO,r.ONE_MINUS_SRC_ALPHA],t[et.DST_ATOP]=[r.ONE_MINUS_DST_ALPHA,r.SRC_ALPHA],t[et.XOR]=[r.ONE_MINUS_DST_ALPHA,r.ONE_MINUS_SRC_ALPHA],t[et.SUBTRACT]=[r.ONE,r.ONE,r.ONE,r.ONE,r.FUNC_REVERSE_SUBTRACT,r.FUNC_ADD],t}var nD=0,aD=1,lD=2,hD=3,cD=4,uD=5,VI=class Vy{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=et.NONE,this._blendEq=!1,this.map=[],this.map[nD]=this.setBlend,this.map[aD]=this.setOffset,this.map[lD]=this.setCullFace,this.map[hD]=this.setDepthTest,this.map[cD]=this.setFrontFace,this.map[uD]=this.setDepthMask,this.checks=[],this.defaultState=new qr,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=HI(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(Vy.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Vy.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}};VI.extension={type:X.RendererSystem,name:"state"};var Wy=VI;Z.add(Wy);var An=class extends Ms.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 te(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 Th=class xf{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=xf.defaultMaxIdle,this.checkCountMax=xf.defaultCheckCountMax,this.mode=xf.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==Rd.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}};Th.defaultMode=Rd.AUTO,Th.defaultMaxIdle=60*60,Th.defaultCheckCountMax=60*10,Th.extension={type:X.RendererSystem,name:"textureGC"};var Qr=Th;Z.add(Qr);var Ws=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=lt.UNSIGNED_BYTE,this.internalFormat=D.RGBA,this.samplerType=0}};function WI(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[r.RGB]:W.FLOAT,[r.RGBA]:W.FLOAT,[r.ALPHA]:W.FLOAT,[r.LUMINANCE]:W.FLOAT,[r.LUMINANCE_ALPHA]:W.FLOAT,[r.R8]:W.FLOAT,[r.R8_SNORM]:W.FLOAT,[r.RG8]:W.FLOAT,[r.RG8_SNORM]:W.FLOAT,[r.RGB8]:W.FLOAT,[r.RGB8_SNORM]:W.FLOAT,[r.RGB565]:W.FLOAT,[r.RGBA4]:W.FLOAT,[r.RGB5_A1]:W.FLOAT,[r.RGBA8]:W.FLOAT,[r.RGBA8_SNORM]:W.FLOAT,[r.RGB10_A2]:W.FLOAT,[r.RGB10_A2UI]:W.FLOAT,[r.SRGB8]:W.FLOAT,[r.SRGB8_ALPHA8]:W.FLOAT,[r.R16F]:W.FLOAT,[r.RG16F]:W.FLOAT,[r.RGB16F]:W.FLOAT,[r.RGBA16F]:W.FLOAT,[r.R32F]:W.FLOAT,[r.RG32F]:W.FLOAT,[r.RGB32F]:W.FLOAT,[r.RGBA32F]:W.FLOAT,[r.R11F_G11F_B10F]:W.FLOAT,[r.RGB9_E5]:W.FLOAT,[r.R8I]:W.INT,[r.R8UI]:W.UINT,[r.R16I]:W.INT,[r.R16UI]:W.UINT,[r.R32I]:W.INT,[r.R32UI]:W.UINT,[r.RG8I]:W.INT,[r.RG8UI]:W.UINT,[r.RG16I]:W.INT,[r.RG16UI]:W.UINT,[r.RG32I]:W.INT,[r.RG32UI]:W.UINT,[r.RGB8I]:W.INT,[r.RGB8UI]:W.UINT,[r.RGB16I]:W.INT,[r.RGB16UI]:W.UINT,[r.RGB32I]:W.INT,[r.RGB32UI]:W.UINT,[r.RGBA8I]:W.INT,[r.RGBA8UI]:W.UINT,[r.RGBA16I]:W.INT,[r.RGBA16UI]:W.UINT,[r.RGBA32I]:W.INT,[r.RGBA32UI]:W.UINT,[r.DEPTH_COMPONENT16]:W.FLOAT,[r.DEPTH_COMPONENT24]:W.FLOAT,[r.DEPTH_COMPONENT32F]:W.FLOAT,[r.DEPTH_STENCIL]:W.FLOAT,[r.DEPTH24_STENCIL8]:W.FLOAT,[r.DEPTH32F_STENCIL8]:W.FLOAT}:t={[r.RGB]:W.FLOAT,[r.RGBA]:W.FLOAT,[r.ALPHA]:W.FLOAT,[r.LUMINANCE]:W.FLOAT,[r.LUMINANCE_ALPHA]:W.FLOAT,[r.DEPTH_STENCIL]:W.FLOAT},t}function zI(r){let t;return"WebGL2RenderingContext"in globalThis&&r instanceof globalThis.WebGL2RenderingContext?t={[lt.UNSIGNED_BYTE]:{[D.RGBA]:r.RGBA8,[D.RGB]:r.RGB8,[D.RG]:r.RG8,[D.RED]:r.R8,[D.RGBA_INTEGER]:r.RGBA8UI,[D.RGB_INTEGER]:r.RGB8UI,[D.RG_INTEGER]:r.RG8UI,[D.RED_INTEGER]:r.R8UI,[D.ALPHA]:r.ALPHA,[D.LUMINANCE]:r.LUMINANCE,[D.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[lt.BYTE]:{[D.RGBA]:r.RGBA8_SNORM,[D.RGB]:r.RGB8_SNORM,[D.RG]:r.RG8_SNORM,[D.RED]:r.R8_SNORM,[D.RGBA_INTEGER]:r.RGBA8I,[D.RGB_INTEGER]:r.RGB8I,[D.RG_INTEGER]:r.RG8I,[D.RED_INTEGER]:r.R8I},[lt.UNSIGNED_SHORT]:{[D.RGBA_INTEGER]:r.RGBA16UI,[D.RGB_INTEGER]:r.RGB16UI,[D.RG_INTEGER]:r.RG16UI,[D.RED_INTEGER]:r.R16UI,[D.DEPTH_COMPONENT]:r.DEPTH_COMPONENT16},[lt.SHORT]:{[D.RGBA_INTEGER]:r.RGBA16I,[D.RGB_INTEGER]:r.RGB16I,[D.RG_INTEGER]:r.RG16I,[D.RED_INTEGER]:r.R16I},[lt.UNSIGNED_INT]:{[D.RGBA_INTEGER]:r.RGBA32UI,[D.RGB_INTEGER]:r.RGB32UI,[D.RG_INTEGER]:r.RG32UI,[D.RED_INTEGER]:r.R32UI,[D.DEPTH_COMPONENT]:r.DEPTH_COMPONENT24},[lt.INT]:{[D.RGBA_INTEGER]:r.RGBA32I,[D.RGB_INTEGER]:r.RGB32I,[D.RG_INTEGER]:r.RG32I,[D.RED_INTEGER]:r.R32I},[lt.FLOAT]:{[D.RGBA]:r.RGBA32F,[D.RGB]:r.RGB32F,[D.RG]:r.RG32F,[D.RED]:r.R32F,[D.DEPTH_COMPONENT]:r.DEPTH_COMPONENT32F},[lt.HALF_FLOAT]:{[D.RGBA]:r.RGBA16F,[D.RGB]:r.RGB16F,[D.RG]:r.RG16F,[D.RED]:r.R16F},[lt.UNSIGNED_SHORT_5_6_5]:{[D.RGB]:r.RGB565},[lt.UNSIGNED_SHORT_4_4_4_4]:{[D.RGBA]:r.RGBA4},[lt.UNSIGNED_SHORT_5_5_5_1]:{[D.RGBA]:r.RGB5_A1},[lt.UNSIGNED_INT_2_10_10_10_REV]:{[D.RGBA]:r.RGB10_A2,[D.RGBA_INTEGER]:r.RGB10_A2UI},[lt.UNSIGNED_INT_10F_11F_11F_REV]:{[D.RGB]:r.R11F_G11F_B10F},[lt.UNSIGNED_INT_5_9_9_9_REV]:{[D.RGB]:r.RGB9_E5},[lt.UNSIGNED_INT_24_8]:{[D.DEPTH_STENCIL]:r.DEPTH24_STENCIL8},[lt.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[D.DEPTH_STENCIL]:r.DEPTH32F_STENCIL8}}:t={[lt.UNSIGNED_BYTE]:{[D.RGBA]:r.RGBA,[D.RGB]:r.RGB,[D.ALPHA]:r.ALPHA,[D.LUMINANCE]:r.LUMINANCE,[D.LUMINANCE_ALPHA]:r.LUMINANCE_ALPHA},[lt.UNSIGNED_SHORT_5_6_5]:{[D.RGB]:r.RGB},[lt.UNSIGNED_SHORT_4_4_4_4]:{[D.RGBA]:r.RGBA},[lt.UNSIGNED_SHORT_5_5_5_1]:{[D.RGBA]:r.RGBA}},t}var Pn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new gt,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=zI(t),this.samplerTypes=WI(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 Ws(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 Ws(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!==W.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new Ws(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]??W.FLOAT,this.webGLVersion===2&&t.type===lt.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!==W.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&&yy(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===Ar.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=Nl.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!==Ar.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===mr.LINEAR?i.LINEAR_MIPMAP_LINEAR:i.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===mr.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===mr.LINEAR?i.LINEAR:i.NEAREST);i.texParameteri(t.target,i.TEXTURE_MAG_FILTER,t.scaleMode===mr.LINEAR?i.LINEAR:i.NEAREST)}destroy(){this.renderer=null}};Pn.extension={type:X.RendererSystem,name:"texture"};Z.add(Pn);var Cn=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}};Cn.extension={type:X.RendererSystem,name:"transformFeedback"};Z.add(Cn);var vi=class{constructor(t){this.renderer=t}init(t){this.screen=new _t(0,0,t.width,t.height),this.element=t.view||K.ADAPTER.createCanvas(),this.resolution=t.resolution||K.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}};vi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},vi.extension={type:[X.RendererSystem,X.CanvasRendererSystem],name:"_view"};Z.add(vi);K.PREFER_ENV=Je.WEBGL2;K.STRICT_TEXTURE_CACHE=!1;K.RENDER_OPTIONS={..._i.defaultOptions,...yi.defaultOptions,...vi.defaultOptions,...bi.defaultOptions};Object.defineProperties(K,{WRAP_MODE:{get(){return gt.defaultOptions.wrapMode},set(r){ft("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),gt.defaultOptions.wrapMode=r}},SCALE_MODE:{get(){return gt.defaultOptions.scaleMode},set(r){ft("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),gt.defaultOptions.scaleMode=r}},MIPMAP_TEXTURES:{get(){return gt.defaultOptions.mipmap},set(r){ft("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),gt.defaultOptions.mipmap=r}},ANISOTROPIC_LEVEL:{get(){return gt.defaultOptions.anisotropicLevel},set(r){ft("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),gt.defaultOptions.anisotropicLevel=r}},FILTER_RESOLUTION:{get(){return ft("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Zr.defaultResolution},set(r){Zr.defaultResolution=r}},FILTER_MULTISAMPLE:{get(){return ft("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Zr.defaultMultisample},set(r){Zr.defaultMultisample=r}},SPRITE_MAX_TEXTURES:{get(){return xi.defaultMaxTextures},set(r){ft("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),xi.defaultMaxTextures=r}},SPRITE_BATCH_SIZE:{get(){return xi.defaultBatchSize},set(r){ft("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),xi.defaultBatchSize=r}},CAN_UPLOAD_SAME_BUFFER:{get(){return xi.canUploadSameBuffer},set(r){ft("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),xi.canUploadSameBuffer=r}},GC_MODE:{get(){return Qr.defaultMode},set(r){ft("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Qr.defaultMode=r}},GC_MAX_IDLE:{get(){return Qr.defaultMaxIdle},set(r){ft("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Qr.defaultMaxIdle=r}},GC_MAX_CHECK_COUNT:{get(){return Qr.defaultCheckCountMax},set(r){ft("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Qr.defaultCheckCountMax=r}},PRECISION_VERTEX:{get(){return yr.defaultVertexPrecision},set(r){ft("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),yr.defaultVertexPrecision=r}},PRECISION_FRAGMENT:{get(){return yr.defaultFragmentPrecision},set(r){ft("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),yr.defaultFragmentPrecision=r}}});var zs=(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))(zs||{});var Rn=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 $I=class sr{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 Rn(null,null,1/0),this.deltaMS=1/sr.targetFPMS,this.elapsedMS=1/sr.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=zs.NORMAL){return this._addListener(new Rn(t,e,i))}addOnce(t,e,i=zs.NORMAL){return this._addListener(new Rn(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*sr.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,sr.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(!sr._shared){let t=sr._shared=new sr;t.autoStart=!0,t._protected=!0}return sr._shared}static get system(){if(!sr._system){let t=sr._system=new sr;t.autoStart=!0,t._protected=!0}return sr._system}};$I.targetFPMS=.06;var _r=$I;Object.defineProperties(K,{TARGET_FPMS:{get(){return _r.targetFPMS},set(r){ft("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),_r.targetFPMS=r}}});var Sh=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,zs.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?_r.shared:new _r,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};Sh.extension=X.Application;Z.add(Sh);var dD=[];Z.handleByList(X.Renderer,dD);var wh=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>=Rt.HIGH?this.multisample=Rt.HIGH:e>=Rt.MEDIUM?this.multisample=Rt.MEDIUM:e>=Rt.LOW?this.multisample=Rt.LOW:this.multisample=Rt.NONE}destroy(){}};wh.extension={type:X.RendererSystem,name:"_multisample"};Z.add(wh);var yf=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var Eh=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 yf(i.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};Eh.extension={type:X.RendererSystem,name:"buffer"};Z.add(Eh);var Ah=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}};Ah.extension={type:X.RendererSystem,name:"objectRenderer"};Z.add(Ah);var _f=class zy extends An{constructor(t){super(),this.type=Fx.WEBGL,t=Object.assign({},K.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new ir({projectionMatrix:new Ut},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:zy.__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&&(ft("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=zy.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:gy()}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 ft("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ft("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ft("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ft("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ft("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ft("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ft("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ft("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)}};_f.extension={type:X.Renderer,priority:1},_f.__plugins={},_f.__systems={};var bf=_f;Z.handleByMap(X.RendererPlugin,bf.__plugins);Z.handleByMap(X.RendererSystem,bf.__systems);Z.add(bf);var ji=class extends rr{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 gt;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 rr?this.addResourceAt(t[i],i):this.addResourceAt(cn(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 Ph=class extends ji{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=di.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 h=n[l];o[l]<h.dirtyId&&(o[l]=h.dirtyId,h.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,l,h.resource.width,h.resource.height,1,e.format,i.type,h.resource.source))}return!0}};var Ch=class extends me{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var XI=class Rh extends ji{constructor(t,e){let{width:i,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==Rh.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:i,height:s});for(let a=0;a<Rh.SIDES;a++)this.items[a].target=di.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=di.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=di.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<Rh.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===Rh.SIDES}};XI.SIDES=6;var $y=XI;var Mh=class r extends me{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 K.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===tr.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??K.ADAPTER.createCanvas(0,0),r._EMPTY}};var Xy=class vf extends me{constructor(t,e){e=e||{},super(K.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)},vf.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;me.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_${pi()}`,n.getContext("2d").drawImage(t,0,0,e,i,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=vf.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"&&vf.SVG_XML.test(t)}};Xy.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,Xy.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var jy=Xy;var Tf=class extends me{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var Yy=class qy extends me{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];me.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 h=a.split("?").shift().toLowerCase(),c=h.slice(h.lastIndexOf(".")+1);l=l||qy.MIME_TYPES[c]||`video/${c}`}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=_r.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&&(_r.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||(_r.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(_r.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||qy.TYPES.includes(e)}};Yy.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],Yy.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var Ky=Yy;eh.push(Mh,Ds,Ch,Ky,Tf,jy,Is,$y,Ph);var fD={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)}},pD={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 jI(r,t,e,i,s){let o=0,n=null,a=null,l=s.gl;for(let h in r.uniforms){let c=t[h],u=i[h],d=e[h],f=r.uniforms[h];if(!c){f.group===!0&&s.shader.syncUniformGroup(u);continue}c.type==="float"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1f(d.location,u)):c.type==="bool"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,l.uniform1i(d.location,Number(u))):(c.type==="sampler2D"||c.type==="samplerCube"||c.type==="sampler2DArray")&&c.size===1&&!c.isArray?(s.texture.bind(u,o),d.value!==o&&(d.value=o,l.uniform1i(d.location,o)),o++):c.type==="mat3"&&c.size===1&&!c.isArray?f.a!==void 0?l.uniformMatrix3fv(d.location,!1,u.toArray(!0)):l.uniformMatrix3fv(d.location,!1,u):c.type==="vec2"&&c.size===1&&!c.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]))):c.type==="vec4"&&c.size===1&&!c.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]))):(c.size===1&&!c.isArray?fD:pD)[c.type].call(null,l,d.location,d.value,u)}}function mD(){Object.assign(Xi.prototype,{systemCheck(){},syncUniforms(r,t){let{shader:e,renderer:i}=this;jI(r,e.program.uniformData,t.uniformData,r.uniforms,i)}})}mD();var Ih=new(window.AudioContext||window.webkitAudioContext),gD=(r,t)=>{let e,i=Ih.createGain();i.gain.value=t.volume??1,i.connect(Ih.destination);let s={id:r,url:t.url,loop:t.loop||!1,volume:t.volume??1};return{play:()=>{let g=qo.getAsset(s.url);if(!g){console.warn("AudioPlayer.play: Asset not found",s.url);return}e=Ih.createBufferSource(),e.buffer=g,e.loop=s.loop,i.gain.setValueAtTime(s.volume,Ih.currentTime),e.connect(i),e.start(0)},stop:()=>{e&&(e.stop(),e.disconnect(),i.disconnect(),i.connect(Ih.destination))},update:g=>{s={...s,...g}},getId:()=>s.id,getUrl:()=>s.url,getLoop:()=>s.loop,getVolume:()=>s.volume,setUrl:g=>{s.url=g},setLoop:g=>{s.loop=g},setVolume:g=>{s.volume=g,i.gain.value=g},get id(){return s.id},get url(){return s.url},get loop(){return s.loop},get volume(){return s.volume},gainNode:i}},YI=()=>{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 h=r.find(c=>c.id===l.id);if(!h){let c=gD(l.id,{url:l.url,loop:l.loop,volume:l.volume??1});r.push(c),c.play();continue}(h.url!==l.url||h.loop!==l.loop)&&(h.stop(),h.setUrl(l.url),h.setLoop(l.loop??!1),h.play()),h.getVolume()!==(l.volume??1)&&h.setVolume(l.volume??1)}let a=[];for(let l of r)t.find(h=>h.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 xD=({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 Zy=xD;var qI=({type:r,parse:t})=>({type:r,parse:t});var Qy=typeof navigator<"u"?navigator.userAgent.toLowerCase().indexOf("firefox")>0:!1;function Jy(r,t,e,i){r.addEventListener?r.addEventListener(t,e,i):r.attachEvent&&r.attachEvent(`on${t}`,e)}function Bh(r,t,e,i){r&&(r.removeEventListener?r.removeEventListener(t,e,i):r.detachEvent&&r.detachEvent(`on${t}`,e))}function QI(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 JI(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 yD(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 tB(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 Uh={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,"-":Qy?173:189,"=":Qy?61:187,";":Qy?59:186,"'":222,"{":219,"}":221,"[":219,"]":221,"\\":220},Mr={"\u21E7":16,shift:16,"\u2325":18,alt:18,option:18,"\u2303":17,ctrl:17,control:17,"\u2318":91,cmd:91,meta:91,command:91},Fh={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},we={16:!1,18:!1,17:!1,91:!1},Xt={};for(let r=1;r<20;r++)Uh[`f${r}`]=111+r;var Vt=[],kh=null,eB="all",Ti=new Map,Mn=r=>Uh[r.toLowerCase()]||Mr[r.toLowerCase()]||r.toUpperCase().charCodeAt(0),_D=r=>Object.keys(Uh).find(t=>Uh[t]===r),bD=r=>Object.keys(Mr).find(t=>Mr[t]===r),rB=r=>{eB=r||"all"},Gh=()=>eB||"all",vD=()=>Vt.slice(0),TD=()=>Vt.map(r=>_D(r)||bD(r)||String.fromCharCode(r)),SD=()=>{let r=[];return Object.keys(Xt).forEach(t=>{Xt[t].forEach(({key:e,scope:i,mods:s,shortcut:o})=>{r.push({scope:i,shortcut:o,mods:s,keys:e.split("+").map(n=>Mn(n))})})}),r},iB=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},wD=r=>(typeof r=="string"&&(r=Mn(r)),Vt.indexOf(r)!==-1),ED=(r,t)=>{let e,i;r||(r=Gh());for(let s in Xt)if(Object.prototype.hasOwnProperty.call(Xt,s))for(e=Xt[s],i=0;i<e.length;)e[i].scope===r?e.splice(i,1).forEach(({element:o})=>e_(o)):i++;Gh()===r&&rB(t||"all")};function AD(r){let t=tB(r);r.key&&r.key.toLowerCase()==="capslock"&&(t=Mn(r.key));let e=Vt.indexOf(t);if(e>=0&&Vt.splice(e,1),r.key&&r.key.toLowerCase()==="meta"&&Vt.splice(0,Vt.length),(t===93||t===224)&&(t=91),t in we){we[t]=!1;for(let i in Mr)Mr[i]===t&&(or[i]=!1)}}var sB=(r,...t)=>{if(typeof r>"u")Object.keys(Xt).forEach(e=>{Array.isArray(Xt[e])&&Xt[e].forEach(i=>Sf(i)),delete Xt[e]}),e_(null);else if(Array.isArray(r))r.forEach(e=>{e.key&&Sf(e)});else if(typeof r=="object")r.key&&Sf(r);else if(typeof r=="string"){let[e,i]=t;typeof e=="function"&&(i=e,e=""),Sf({key:r,scope:e,method:i,splitKey:"+"})}},Sf=({key:r,scope:t,method:e,splitKey:i="+"})=>{JI(r).forEach(s=>{let o=s.split(i),n=o.length,a=o[n-1],l=a==="*"?"*":Mn(a);if(!Xt[l])return;t||(t=Gh());let h=n>1?QI(Mr,o):[],c=[];Xt[l]=Xt[l].filter(u=>{let d=(e?u.method===e:!0)&&u.scope===t&&yD(u.mods,h);return d&&c.push(u.element),!d}),c.forEach(u=>e_(u))})};function KI(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 we)Object.prototype.hasOwnProperty.call(we,o)&&(!we[o]&&t.mods.indexOf(+o)>-1||we[o]&&t.mods.indexOf(+o)===-1)&&(s=!1);(t.mods.length===0&&!we[16]&&!we[18]&&!we[17]&&!we[91]||s||t.shortcut==="*")&&(t.keys=[],t.keys=t.keys.concat(Vt),t.method(r,t)===!1&&(r.preventDefault?r.preventDefault():r.returnValue=!1,r.stopPropagation&&r.stopPropagation(),r.cancelBubble&&(r.cancelBubble=!0)))}}function ZI(r,t){let e=Xt["*"],i=tB(r);if(r.key&&r.key.toLowerCase()==="capslock"||!(or.filter||iB).call(this,r))return;if((i===93||i===224)&&(i=91),Vt.indexOf(i)===-1&&i!==229&&Vt.push(i),["metaKey","ctrlKey","altKey","shiftKey"].forEach(a=>{let l=Fh[a];r[a]&&Vt.indexOf(l)===-1?Vt.push(l):!r[a]&&Vt.indexOf(l)>-1?Vt.splice(Vt.indexOf(l),1):a==="metaKey"&&r[a]&&(Vt=Vt.filter(h=>h in Fh||h===i))}),i in we){we[i]=!0;for(let a in Mr)if(Object.prototype.hasOwnProperty.call(Mr,a)){let l=Fh[Mr[a]];or[a]=r[l]}if(!e)return}for(let a in we)Object.prototype.hasOwnProperty.call(we,a)&&(we[a]=r[Fh[a]]);r.getModifierState&&!(r.altKey&&!r.ctrlKey)&&r.getModifierState("AltGraph")&&(Vt.indexOf(17)===-1&&Vt.push(17),Vt.indexOf(18)===-1&&Vt.push(18),we[17]=!0,we[18]=!0);let s=Gh();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)&&KI(r,e[a],s,t);if(!(i in Xt))return;let o=Xt[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:h}=l,c=l.key.split(h),u=[];for(let d=0;d<c.length;d++)u.push(Mn(c[d]));u.sort().join("")===Vt.sort().join("")&&KI(r,l,s,t)}}var or=function(r,t,e){Vt=[];let i=JI(r),s=[],o="all",n=document,a=0,l=!1,h=!0,c="+",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&&(h=f.keydown),f.capture!==void 0&&(u=f.capture),typeof f.splitKey=="string"&&(c=f.splitKey),f.single===!0&&(d=!0)}for(typeof t=="string"&&(o=t),d&&sB(r,o);a<i.length;a++){let f=i[a].split(c);s=[],f.length>1&&(s=QI(Mr,f));let p=f[f.length-1];p=p==="*"?"*":Mn(p),p in Xt||(Xt[p]=[]),Xt[p].push({keyup:l,keydown:h,scope:o,mods:s,shortcut:i[a],method:e,key:i[a],splitKey:c,element:n})}if(typeof n<"u"&&typeof window<"u"){if(!Ti.has(n)){let f=(g=window.event)=>ZI(g,n),p=(g=window.event)=>{ZI(g,n),AD(g)};Ti.set(n,{keydownListener:f,keyupListenr:p,capture:u}),Jy(n,"keydown",f,u),Jy(n,"keyup",p,u)}if(!kh){let f=()=>{Vt=[]};kh={listener:f,capture:u},Jy(window,"focus",f,u)}}};function PD(r,t="all"){Object.keys(Xt).forEach(e=>{Xt[e].filter(i=>i.scope===t&&i.shortcut===r).forEach(i=>{i&&i.method&&i.method({},i)})})}function e_(r){let t=Object.values(Xt).flat();if(t.findIndex(({element:e})=>e===r)<0&&r){let{keydownListener:e,keyupListenr:i,capture:s}=Ti.get(r)||{};e&&i&&(Bh(r,"keyup",i,s),Bh(r,"keydown",e,s),Ti.delete(r))}if((t.length<=0||Ti.size<=0)&&(Array.from(Ti.keys()).forEach(e=>{let{keydownListener:i,keyupListenr:s,capture:o}=Ti.get(e)||{};i&&s&&(Bh(e,"keyup",s,o),Bh(e,"keydown",i,o),Ti.delete(e))}),Ti.clear(),Object.keys(Xt).forEach(e=>delete Xt[e]),kh)){let{listener:e,capture:i}=kh;Bh(window,"focus",e,i),kh=null}}var t_={getPressedKeyString:TD,setScope:rB,getScope:Gh,deleteScope:ED,getPressedKeyCodes:vD,getAllKeyCodes:SD,isPressed:wD,filter:iB,trigger:PD,unbind:sB,keyMap:Uh,modifier:Mr,modifierMap:Fh};for(let r in t_){let t=r;Object.prototype.hasOwnProperty.call(t_,t)&&(or[t]=t_[t])}if(typeof window<"u"){let r=window.hotkeys;or.noConflict=t=>(t&&window.hotkeys===or&&(window.hotkeys=r),or),window.hotkeys=or}var CD=Object.prototype.hasOwnProperty,oB=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 h=t.get(l);h?Et(h.payload,s[l].payload)||(n.push(l),or.unbind(l)):o.push(l)}),t.forEach((l,h)=>{CD.call(s,h)||a.push(h)}),a.forEach(l=>{or.unbind(l),t.delete(l)}),[...o,...n].forEach(l=>{let c=s[l].payload??{};or(l,()=>{r&&r("keydown",{_event:{key:l},...c})}),t.set(l,{value:l,payload:c})})},destroy:()=>{for(let s of t.keys())or.unbind(s);t.clear()}}};var aB=(r,t)=>typeof t!="string"?t:r[t]??t,RD=(r,t,e,i)=>{let s=aB(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},nB=(r,t,e,i)=>{let s=aB(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},MD=(r,t,e)=>Object.entries(t).map(([i,s])=>{if(!Vu[i])throw new Error(`${i} is not a supported property for animation.`);let o=RD(r,i,e,0),n=s.initialValue??o,a=Il([{value:n},...s.keyframes]);return{property:i,timeline:a}}),lB=()=>{let r=[],t=new Map,e=new Map,i=0,s=(v,S)=>{e.get(v)?.forEach(P=>{try{P(S)}catch{}})},o=v=>{if(s("completed",{id:v.id}),v.onComplete)try{v.onComplete()}catch{}},n=v=>{let{id:S,element:P,properties:R,targetState:A,onComplete:C,onCancel:M,propertyPathMap:B=Wu}=v,k=MD(P,R,B),U={id:S,kind:"property",element:P,timelines:k,duration:Bl(k),currentTime:0,stateVersion:i,targetState:A,onComplete:C,onCancel:M,applyFrame:O=>{for(let{property:$,timeline:N}of k){let L=Fl(N,O);try{nB(P,$,B,L)}catch{}}},applyTargetState:()=>{if(!(!P||P.destroyed)){if(A===null){P.destroy();return}if(A)for(let[O,$]of Object.entries(A))try{nB(P,O,B,$)}catch{}}},isValid:()=>!!P&&!P.destroyed};U.applyFrame(0),t.set(S,U),s("started",{id:S})},a=v=>{let S={id:v.id,kind:"custom",duration:v.duration??0,currentTime:0,stateVersion:i,onComplete:v.onComplete,onCancel:v.onCancel,applyFrame:v.applyFrame??(()=>{}),applyTargetState:v.applyTargetState??(()=>{}),isValid:v.isValid??(()=>!0)};S.applyFrame(0),t.set(S.id,S),s("started",{id:S.id})},l=v=>{if(v.driver==="custom"){a(v);return}n(v)},h=v=>{try{v.applyTargetState?.()}catch{}if(v.onCancel)try{v.onCancel()}catch{}},c=v=>{switch(v.type){case"START":l(v.payload);break;case"CANCEL":d(v.id);break}},u=()=>{let v=r.splice(0);for(let S of v)c(S)},d=v=>{let S=t.get(v);S&&(h(S),t.delete(v),s("cancelled",{id:v}))},f=v=>{r.push(v)},p=()=>{for(let[v,S]of t)h(S),s("cancelled",{id:v});t.clear(),i++},g=v=>{u();let S=[];for(let[P,R]of t){if(R.stateVersion!==i){S.push(P);continue}if(!R.isValid()){S.push(P);continue}if(R.currentTime+=v,R.currentTime>=R.duration){R.applyFrame(R.duration),o(R),S.push(P);continue}R.applyFrame(R.currentTime)}for(let P of S)t.delete(P)},m=()=>{u()},_=(v,S)=>(e.has(v)||e.set(v,new Set),e.get(v).add(S),()=>b(v,S)),b=(v,S)=>{e.get(v)?.delete(S)};return{dispatch:f,cancelAll:p,flush:m,tick:g,on:_,off:b,getState:()=>({stateVersion:i,activeCount:t.size,animations:Array.from(t.entries()).map(([v,S])=>({id:v,currentTime:S.currentTime,duration:S.duration,progress:S.duration>0?S.currentTime/S.duration:0}))}),isAnimating:v=>t.has(v),destroy:()=>{p(),e.clear()}}};var hB=r=>{let t=0,e=0,i=null;return{reset:h=>{t>0&&i!==null&&r?.("renderComplete",{id:i,aborted:!0}),e++,t=0,i=h},track:h=>{h===e&&t++},complete:h=>{h===e&&(t--,t===0&&r?.("renderComplete",{id:i,aborted:!1}))},getVersion:()=>e,completeIfEmpty:()=>{t===0&&r?.("renderComplete",{id:i,aborted:!1})}}};var cB=new Set(["update","transition"]),ID=new Set(["alpha","x","y","scaleX","scaleY","rotation"]),BD=new Set(["translateX","translateY","alpha","scaleX","scaleY","rotation"]),uB=new Set(["single","sequence","composite"]),Ef=new Set(["red","green","blue","alpha"]),dB=new Set(["max","min","multiply","add"]),FD=new Set(vx),Yi=(r,t)=>{if(!r||typeof r!="object"||Array.isArray(r))throw new Error(`${t} must be an object.`)},$s=(r,t)=>{if(typeof r!="string"||r.length===0)throw new Error(`${t} must be a non-empty string.`)},wf=(r,t)=>{if(typeof r!="number"||Number.isNaN(r))throw new Error(`${t} must be a number.`)},pB=(r,t)=>{Yi(r,t);let e={};if(r.initialValue!==void 0&&(wf(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(Yi(i,o),wf(i.value,`${o}.value`),wf(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&&!FD.has(i.easing))throw new Error(`${o}.easing must be one of: ${vx.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},mB=(r,t,e)=>{Yi(r,t);let i=Object.entries(r).map(([s,o])=>{if(!e.has(s))throw new Error(`${t}.${s} is not a supported animation property.`);return[s,pB(o,`${t}.${s}`)]});if(i.length===0)throw new Error(`${t} must define at least one property.`);return Object.fromEntries(i)},kD=(r,t)=>{if(Yi(r,t),$s(r.texture,`${t}.texture`),r.channel!==void 0&&!Ef.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(Ef).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}:{}}},UD=(r,t)=>{if(Yi(r,t),!uB.has(r.kind))throw new Error(`${t}.kind must be one of: ${Array.from(uB).join(", ")}.`);let e={kind:r.kind};if(r.channel!==void 0){if(!Ef.has(r.channel))throw new Error(`${t}.channel must be one of: ${Array.from(Ef).join(", ")}.`);e.channel=r.channel}if(r.softness!==void 0&&(wf(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=pB(r.progress,`${t}.progress`)),r.kind==="single"&&($s(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)=>($s(i,`${t}.textures[${s}]`),i)),r.sample!==void 0&&($s(r.sample,`${t}.sample`),e.sample=r.sample)}if(r.kind==="composite"){if(!dB.has(r.combine??"max"))throw new Error(`${t}.combine must be one of: ${Array.from(dB).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)=>kD(i,`${t}.items[${s}]`))}return e.progress||(e.progress={initialValue:0,keyframes:[{duration:0,value:1,easing:"linear"}]}),e},fB=(r,t)=>{if(Yi(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=mB(r.tween,`${t}.tween`,BD)),Object.keys(e).length===0)throw new Error(`${t} must define tween.`);return e},GD=(r,t)=>{let e={};if(r.shader!==void 0)throw new Error(`${t}.shader is not supported.`);if(r.prev!==void 0&&(e.prev=fB(r.prev,`${t}.prev`)),r.next!==void 0&&(e.next=fB(r.next,`${t}.next`)),r.mask!==void 0&&(e.mask=UD(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},r_=(r,t,e)=>{if(r!==void 0)throw new Error(`${t} ${e}`)},gB=(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(Yi(i,o),$s(i.id,`${o}.id`),$s(i.targetId,`${o}.targetId`),$s(i.type,`${o}.type`),!cB.has(i.type))throw new Error(`${o}.type must be one of: ${Array.from(cB).join(", ")}.`);let n={id:i.id,targetId:i.targetId,type:i.type};if(i.complete!==void 0&&(Yi(i.complete,`${o}.complete`),n.complete=i.complete),r_(i.operation,`${o}.operation`,"is no longer supported. Use `type: update | transition` instead."),r_(i.properties,`${o}.properties`,"is no longer supported. Use `tween` instead."),r_(i.subjects,`${o}.subjects`,"is no longer supported. Use `prev` / `next` instead."),i.type==="update"){if(n.tween=mB(i.tween,`${o}.tween`,ID),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=GD(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 i_=(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=gB(t.animations),t};var OD=()=>{let r,t=YI(),e={elements:[],animations:[],audio:[]},i,s={animations:[],elements:[],audio:[],parsers:[]},o,n,a,l,h=!1,c,u,d,f=new Map,p,g=(v,S,P,R)=>{v.clear(),v.rect(0,0,S,P),v.fill(R??0)},m=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",_=(v,S,{revokable:P=!1}={})=>{f.set(v,{url:S,revokable:P})},b=()=>{for(let v of f.values())v?.revokable===!0&&typeof v?.url=="string"&&URL.revokeObjectURL(v.url);f.clear()},y=(v,S,P)=>{o&&o.registerHotkeys(P?.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 R=S?.cursorStyles,A=P?.cursorStyles;Et(R,A)||(A?(A.default&&(v.renderer.events.cursorStyles.default=A.default,v.canvas.style.cursor=A.default),A.hover&&(v.renderer.events.cursorStyles.hover=A.hover)):R&&(v.renderer.events.cursorStyles.default="default",v.renderer.events.cursorStyles.hover="pointer"))},w=(v,S,P,R)=>{c&&c.abort(),c=new AbortController;let A=c.signal;a.reset(P.id),y(v,e.global,P.global),n.cancelAll(),Ts({app:v,parent:S,prevComputedTree:e.elements,nextComputedTree:P.elements,animations:P.animations,elementPlugins:s.elements,animationBus:n,completionTracker:a,eventHandler:R,signal:A}),n.flush(),Bx({app:v,prevAudioTree:e.audio,nextAudioTree:P.audio,audioPlugins:s.audio}),e=P,a.completeIfEmpty(),h||(h=!0,l&&l())},E={rendererName:"pixi",get canvas(){return r.canvas},findElementByLabel:v=>r.stage.getChildByLabel(v,!0)??null,extractBase64:async v=>{let S=new tt(0,0,r.renderer.width,r.renderer.height);if(!v)return await r.renderer.extract.base64({target:r.stage,frame:S});let P=r.stage.getChildByLabel(v,!0);if(!P)throw new Error(`Element with label '${v}' not found`);return await r.renderer.extract.base64({target:P,frame:S})},assignStageEvent:(v,S)=>{r.stage.eventMode="static",r.stage.on(v,S)},init:async v=>{let{eventHandler:S,plugins:P,width:R,height:A,backgroundColor:C,debug:M=!1,onFirstRender:B}=v;l=B;let k=[];return P?.elements?.forEach(U=>{U?.parse&&k.push(qI({type:U.type,parse:U.parse}))}),s={animations:P?.animations??[],elements:P?.elements??[],audio:P?.audio??[],parsers:k},i=S,o=oB(S),a=hB(S),r=new vl,r.audioStage=t,await r.init({width:R,height:A,backgroundColor:C,preference:"webgl"}),r.debug=M,d=U=>{U.preventDefault()},r.canvas.addEventListener("contextmenu",d),p=new de,p.label="__route_graphics_background__",g(p,R,A,C),r.stage.addChild(p),r.stage.width=R,r.stage.height=A,r.ticker.add(r.audioStage.tick),n=lB(),M?(u=U=>{U?.detail?.deltaMS&&n.tick(Number(U.detail.deltaMS))},window.addEventListener("snapShotKeyFrame",u)):r.ticker.add(U=>n.tick(U.deltaMS)),E},destroy:()=>{c&&(c.abort(),c=void 0),u&&(window.removeEventListener("snapShotKeyFrame",u),u=void 0),d&&r?.canvas&&(r.canvas.removeEventListener("contextmenu",d),d=void 0),o?.destroy(),Ex(),n&&n.destroy(),r?.audioStage&&r.audioStage.destroy();let v=S=>{for(let P of S.children){let R=P.texture?.source?.resource;R instanceof HTMLVideoElement&&R.pause(),P.children&&v(P)}};r?.stage&&v(r.stage),r&&r.destroy(),p=void 0,b()},loadAssets:async v=>{if(!v)throw new Error("assetBufferMap is required");let S={audio:{},font:{},video:{},texture:{}};for(let[A,C]of Object.entries(v)){let M=m(C.type);S[M][A]=C}await Promise.all(Object.entries(S.audio).map(([A,C])=>qo.load(A,C.buffer))),await Promise.all(Object.entries(S.font).map(async([A,C])=>{let M=new Blob([C.buffer],{type:C.type}),B=URL.createObjectURL(M),k=new FontFace(A,`url(${B})`);try{await k.load(),document.fonts.add(k)}catch(U){console.error(`Failed to load font ${A}:`,U)}finally{URL.revokeObjectURL(B)}}));let P=Object.entries(S.texture).map(async([A,C])=>{if(pr.cache.has(A))return pr.cache.get(A);if(C?.source==="url"&&typeof C?.url=="string")return pr.load({alias:A,src:C.url,parser:"loadTextures"});let M=new Blob([C.buffer],{type:C.type}),B=await createImageBitmap(M),k=I.from(B);return pr.cache.set(A,k),k}),R=Object.entries(S.video).map(async([A,C])=>{let M=C?.source==="url"&&typeof C?.url=="string"?C.url:URL.createObjectURL(new Blob([C.buffer],{type:C.type})),B=C?.source!=="url";_(A,M,{revokable:B});let k={alias:A,src:M,parser:"loadVideo",data:{}};return typeof C?.type=="string"&&C.type.length>0&&(k.data.mime=C.type),pr.load(k).then(U=>U).catch(U=>{throw f.delete(A),B&&URL.revokeObjectURL(M),U})});return Promise.all([...P,...R])},loadAudioAssets:async v=>Promise.all(v.map(async S=>{let R=await(await fetch(S)).arrayBuffer();return qo.load(S,R)})),updatedBackgroundColor:v=>{r.renderer.background.color=v,p&&g(p,r.renderer.width,r.renderer.height,v)},render:v=>{let S=i_(v),P=Zy({JSONObject:S.elements,parserPlugins:s.parsers}),R={...S,elements:P};w(r,r.stage,R,i)},parse:v=>{let S=i_(v),P=Zy({JSONObject:S.elements,parserPlugins:s.parsers});return{...S,elements:P}}};return E},xB=OD;var $At=xB;export{vl as Application,pr as Assets,qo as AudioAsset,DU as animatedSpritePlugin,GU as containerPlugin,dx as createAnimationPlugin,AB as createAssetBufferManager,fx as createAudioPlugin,fe as createElementPlugin,$At as default,jU as particlesPlugin,uU as rectPlugin,Bx as renderAudio,Ts as renderElements,mU as sliderPlugin,VU as soundPlugin,dU as spritePlugin,lU as textPlugin,LU as textRevealingPlugin,NU as tweenPlugin,pU as videoPlugin};
1629
1629
  /*! Bundled license information:
1630
1630
 
1631
1631
  punycode/punycode.js:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "route-graphics",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "A 2D graphics rendering interface that takes JSON input and renders pixels using PixiJS",
5
5
  "main": "dist/RouteGraphics.js",
6
6
  "type": "module",