route-graphics 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/RouteGraphics.js +1 -1
- package/package.json +1 -1
package/dist/RouteGraphics.js
CHANGED
|
@@ -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 L2=0,Vu={textureCount:0,uboCount:0},Ri=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=L2++}systemCheck(){if(!Ou())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 r=t.program,s=r.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==r&&(this.program=r,this.gl.useProgram(s.program)),e||(Vu.textureCount=0,Vu.uboCount=0,this.syncUniformGroup(t.uniformGroup,Vu)),s}setUniforms(t){let e=this.shader.program,r=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(r.uniformData,t,this.renderer)}syncUniformGroup(t,e){let r=this.getGlProgram();(!t.static||t.dirtyId!==r.uniformDirtyGroups[t.id])&&(r.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,r,e))}syncUniforms(t,e,r){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,r)}createSyncGroups(t){let e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Vg(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){let r=this.getGlProgram();if(!t.static||t.dirtyId!==0||!r.uniformGroups[t.id]){t.dirtyId=0;let s=r.uniformGroups[t.id]||this.createSyncBufferGroup(t,r,e);t.buffer.update(),s(r.uniformData,t.uniforms,this.renderer,Vu,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,r.uniformBufferBindings[e])}createSyncBufferGroup(t,e,r){let{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);let o=this.gl.getUniformBlockIndex(e.program,r);e.uniformBufferBindings[r]=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]=Zg(t,this.shader.program.uniformData)),t.autoManage){let h=new Float32Array(a.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,r){let s=t.uniforms,o=[`${r}-`];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,r=t.program,s=Kg(e,r);return r.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}};Ri.extension={type:$.RendererSystem,name:"shader"};Z.add(Ri);var ai=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(){}};ai.defaultOptions={hello:!1},ai.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"};Z.add(ai);function DP(i,t=[]){return t[J.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.ADD]=[i.ONE,i.ONE],t[J.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.NONE]=[0,0],t[J.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[J.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[J.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[J.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[J.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[J.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[J.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[J.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[J.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[J.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}var H2=0,V2=1,W2=2,z2=3,$2=4,X2=5,LP=class Qg{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=J.NONE,this._blendEq=!1,this.map=[],this.map[H2]=this.setBlend,this.map[V2]=this.setOffset,this.map[W2]=this.setCullFace,this.map[z2]=this.setDepthTest,this.map[$2]=this.setFrontFace,this.map[X2]=this.setDepthMask,this.checks=[],this.defaultState=new Or,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=DP(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,r=0;for(;e;)e&1&&this.map[r].call(this,!!(t.data&1<<r)),e=e>>1,r++;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(Qg.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Qg.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],r=this.gl;e.length===2?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.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 r=this.checks.indexOf(t);e&&r===-1?this.checks.push(t):!e&&r!==-1&&this.checks.splice(r,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};LP.extension={type:$.RendererSystem,name:"state"};var Jg=LP;Z.add(Jg);var en=class extends hs.default{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);let e=(t.priority??[]).filter(s=>t.systems[s]),r=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(let s of r)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Vt(e)})}addSystem(t,e){let r=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=r,this._systemsHash[e]=r;for(let s in this.runners)this.runners[s].add(r);return this}emitWithCustomOptions(t,e){let r=Object.keys(this._systemsHash);t.items.forEach(s=>{let o=r.find(n=>this._systemsHash[n]===s);s[t.name](e[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}};var kh=class Wu{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Wu.defaultMaxIdle,this.checkCountMax=Wu.defaultCheckCountMax,this.mode=Wu.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ru.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this.renderer.texture,e=t.managedTextures,r=!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,r=!0)}if(r){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,r=t._texture;r&&!r.framebuffer&&e.destroyTexture(r);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};kh.defaultMode=ru.AUTO,kh.defaultMaxIdle=60*60,kh.defaultCheckCountMax=60*10,kh.extension={type:$.RendererSystem,name:"textureGC"};var Lr=kh;Z.add(Lr);var vs=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=st.UNSIGNED_BYTE,this.internalFormat=L.RGBA,this.samplerType=0}};function HP(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[i.RGB]:V.FLOAT,[i.RGBA]:V.FLOAT,[i.ALPHA]:V.FLOAT,[i.LUMINANCE]:V.FLOAT,[i.LUMINANCE_ALPHA]:V.FLOAT,[i.R8]:V.FLOAT,[i.R8_SNORM]:V.FLOAT,[i.RG8]:V.FLOAT,[i.RG8_SNORM]:V.FLOAT,[i.RGB8]:V.FLOAT,[i.RGB8_SNORM]:V.FLOAT,[i.RGB565]:V.FLOAT,[i.RGBA4]:V.FLOAT,[i.RGB5_A1]:V.FLOAT,[i.RGBA8]:V.FLOAT,[i.RGBA8_SNORM]:V.FLOAT,[i.RGB10_A2]:V.FLOAT,[i.RGB10_A2UI]:V.FLOAT,[i.SRGB8]:V.FLOAT,[i.SRGB8_ALPHA8]:V.FLOAT,[i.R16F]:V.FLOAT,[i.RG16F]:V.FLOAT,[i.RGB16F]:V.FLOAT,[i.RGBA16F]:V.FLOAT,[i.R32F]:V.FLOAT,[i.RG32F]:V.FLOAT,[i.RGB32F]:V.FLOAT,[i.RGBA32F]:V.FLOAT,[i.R11F_G11F_B10F]:V.FLOAT,[i.RGB9_E5]:V.FLOAT,[i.R8I]:V.INT,[i.R8UI]:V.UINT,[i.R16I]:V.INT,[i.R16UI]:V.UINT,[i.R32I]:V.INT,[i.R32UI]:V.UINT,[i.RG8I]:V.INT,[i.RG8UI]:V.UINT,[i.RG16I]:V.INT,[i.RG16UI]:V.UINT,[i.RG32I]:V.INT,[i.RG32UI]:V.UINT,[i.RGB8I]:V.INT,[i.RGB8UI]:V.UINT,[i.RGB16I]:V.INT,[i.RGB16UI]:V.UINT,[i.RGB32I]:V.INT,[i.RGB32UI]:V.UINT,[i.RGBA8I]:V.INT,[i.RGBA8UI]:V.UINT,[i.RGBA16I]:V.INT,[i.RGBA16UI]:V.UINT,[i.RGBA32I]:V.INT,[i.RGBA32UI]:V.UINT,[i.DEPTH_COMPONENT16]:V.FLOAT,[i.DEPTH_COMPONENT24]:V.FLOAT,[i.DEPTH_COMPONENT32F]:V.FLOAT,[i.DEPTH_STENCIL]:V.FLOAT,[i.DEPTH24_STENCIL8]:V.FLOAT,[i.DEPTH32F_STENCIL8]:V.FLOAT}:t={[i.RGB]:V.FLOAT,[i.RGBA]:V.FLOAT,[i.ALPHA]:V.FLOAT,[i.LUMINANCE]:V.FLOAT,[i.LUMINANCE_ALPHA]:V.FLOAT,[i.DEPTH_STENCIL]:V.FLOAT},t}function VP(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[st.UNSIGNED_BYTE]:{[L.RGBA]:i.RGBA8,[L.RGB]:i.RGB8,[L.RG]:i.RG8,[L.RED]:i.R8,[L.RGBA_INTEGER]:i.RGBA8UI,[L.RGB_INTEGER]:i.RGB8UI,[L.RG_INTEGER]:i.RG8UI,[L.RED_INTEGER]:i.R8UI,[L.ALPHA]:i.ALPHA,[L.LUMINANCE]:i.LUMINANCE,[L.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[st.BYTE]:{[L.RGBA]:i.RGBA8_SNORM,[L.RGB]:i.RGB8_SNORM,[L.RG]:i.RG8_SNORM,[L.RED]:i.R8_SNORM,[L.RGBA_INTEGER]:i.RGBA8I,[L.RGB_INTEGER]:i.RGB8I,[L.RG_INTEGER]:i.RG8I,[L.RED_INTEGER]:i.R8I},[st.UNSIGNED_SHORT]:{[L.RGBA_INTEGER]:i.RGBA16UI,[L.RGB_INTEGER]:i.RGB16UI,[L.RG_INTEGER]:i.RG16UI,[L.RED_INTEGER]:i.R16UI,[L.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[st.SHORT]:{[L.RGBA_INTEGER]:i.RGBA16I,[L.RGB_INTEGER]:i.RGB16I,[L.RG_INTEGER]:i.RG16I,[L.RED_INTEGER]:i.R16I},[st.UNSIGNED_INT]:{[L.RGBA_INTEGER]:i.RGBA32UI,[L.RGB_INTEGER]:i.RGB32UI,[L.RG_INTEGER]:i.RG32UI,[L.RED_INTEGER]:i.R32UI,[L.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[st.INT]:{[L.RGBA_INTEGER]:i.RGBA32I,[L.RGB_INTEGER]:i.RGB32I,[L.RG_INTEGER]:i.RG32I,[L.RED_INTEGER]:i.R32I},[st.FLOAT]:{[L.RGBA]:i.RGBA32F,[L.RGB]:i.RGB32F,[L.RG]:i.RG32F,[L.RED]:i.R32F,[L.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[st.HALF_FLOAT]:{[L.RGBA]:i.RGBA16F,[L.RGB]:i.RGB16F,[L.RG]:i.RG16F,[L.RED]:i.R16F},[st.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:i.RGB565},[st.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:i.RGBA4},[st.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:i.RGB5_A1},[st.UNSIGNED_INT_2_10_10_10_REV]:{[L.RGBA]:i.RGB10_A2,[L.RGBA_INTEGER]:i.RGB10_A2UI},[st.UNSIGNED_INT_10F_11F_11F_REV]:{[L.RGB]:i.R11F_G11F_B10F},[st.UNSIGNED_INT_5_9_9_9_REV]:{[L.RGB]:i.RGB9_E5},[st.UNSIGNED_INT_24_8]:{[L.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[st.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[L.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[st.UNSIGNED_BYTE]:{[L.RGBA]:i.RGBA,[L.RGB]:i.RGB,[L.ALPHA]:i.ALPHA,[L.LUMINANCE]:i.LUMINANCE,[L.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[st.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:i.RGB},[st.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:i.RGBA},[st.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:i.RGBA}},t}var rn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ut,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=VP(t),this.samplerTypes=HP(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 r=new vs(t.createTexture());t.bindTexture(t.TEXTURE_2D,r.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]=r,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new vs(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:r}=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,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(r.TEXTURE_2D,this.emptyTextures[r.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:r}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<r.length;s++)r[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<r.length;s++)r[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),r[s]=null)}ensureSamplerType(t){let{boundTextures:e,hasIntegerTextures:r,CONTEXT_UID:s}=this;if(r)for(let o=t-1;o>=0;--o){let n=e[o];n&&n._glTextures[s].samplerType!==V.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new vs(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]??V.FLOAT,this.webGLVersion===2&&t.type===st.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 r=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(r,t,e))e.samplerType!==V.FLOAT&&(this.hasIntegerTextures=!0);else{let s=t.realWidth,o=t.realHeight,n=r.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:r}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),r.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&&Pg(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===xr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=th.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){let r=this.gl;if(e.mipmap&&t.mipmap!==xr.ON_MANUAL&&r.generateMipmap(t.target),r.texParameteri(t.target,r.TEXTURE_WRAP_S,e.wrapMode),r.texParameteri(t.target,r.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===or.LINEAR?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===or.LINEAR){let o=Math.min(t.anisotropicLevel,r.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));r.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===or.LINEAR?r.LINEAR:r.NEAREST);r.texParameteri(t.target,r.TEXTURE_MAG_FILTER,t.scaleMode===or.LINEAR?r.LINEAR:r.NEAREST)}destroy(){this.renderer=null}};rn.extension={type:$.RendererSystem,name:"texture"};Z.add(rn);var sn=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:r}=this,s=t._glTransformFeedbacks[r]||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:r,renderer:s}=this;e&&s.shader.bind(e),r.beginTransformFeedback(t)}endTransformFeedback(){let{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){let{gl:e,renderer:r,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&&(r.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 r=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 h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(a,e))}r&&(e||s.deleteTransformFeedback(r),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}};sn.extension={type:$.RendererSystem,name:"transformFeedback"};Z.add(sn);var hi=class{constructor(t){this.renderer=t}init(t){this.screen=new pt(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 r=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=r,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${r}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",r,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}};hi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},hi.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"};Z.add(hi);K.PREFER_ENV=We.WEBGL2;K.STRICT_TEXTURE_CACHE=!1;K.RENDER_OPTIONS={...ni.defaultOptions,...oi.defaultOptions,...hi.defaultOptions,...ai.defaultOptions};Object.defineProperties(K,{WRAP_MODE:{get(){return ut.defaultOptions.wrapMode},set(i){ht("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ut.defaultOptions.wrapMode=i}},SCALE_MODE:{get(){return ut.defaultOptions.scaleMode},set(i){ht("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ut.defaultOptions.scaleMode=i}},MIPMAP_TEXTURES:{get(){return ut.defaultOptions.mipmap},set(i){ht("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ut.defaultOptions.mipmap=i}},ANISOTROPIC_LEVEL:{get(){return ut.defaultOptions.anisotropicLevel},set(i){ht("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ut.defaultOptions.anisotropicLevel=i}},FILTER_RESOLUTION:{get(){return ht("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Dr.defaultResolution},set(i){Dr.defaultResolution=i}},FILTER_MULTISAMPLE:{get(){return ht("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Dr.defaultMultisample},set(i){Dr.defaultMultisample=i}},SPRITE_MAX_TEXTURES:{get(){return si.defaultMaxTextures},set(i){ht("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),si.defaultMaxTextures=i}},SPRITE_BATCH_SIZE:{get(){return si.defaultBatchSize},set(i){ht("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),si.defaultBatchSize=i}},CAN_UPLOAD_SAME_BUFFER:{get(){return si.canUploadSameBuffer},set(i){ht("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),si.canUploadSameBuffer=i}},GC_MODE:{get(){return Lr.defaultMode},set(i){ht("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Lr.defaultMode=i}},GC_MAX_IDLE:{get(){return Lr.defaultMaxIdle},set(i){ht("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Lr.defaultMaxIdle=i}},GC_MAX_CHECK_COUNT:{get(){return Lr.defaultCheckCountMax},set(i){ht("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Lr.defaultCheckCountMax=i}},PRECISION_VERTEX:{get(){return hr.defaultVertexPrecision},set(i){ht("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),hr.defaultVertexPrecision=i}},PRECISION_FRAGMENT:{get(){return hr.defaultFragmentPrecision},set(i){ht("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),hr.defaultFragmentPrecision=i}}});var Ts=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(Ts||{});var on=class{constructor(t,e=null,r=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=r,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 WP=class Ye{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 on(null,null,1/0),this.deltaMS=1/Ye.targetFPMS,this.elapsedMS=1/Ye.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,r=Ts.NORMAL){return this._addListener(new on(t,e,r))}addOnce(t,e,r=Ts.NORMAL){return this._addListener(new on(t,e,r,!0))}_addListener(t){let e=this._head.next,r=this._head;if(!e)t.connect(r);else{for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}return this._startIfPossible(),this}remove(t,e){let r=this._head.next;for(;r;)r.match(t,e)?r=r.destroy():r=r.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*Ye.targetFPMS;let r=this._head,s=r.next;for(;s;)s=s.emit(this.deltaTime);r.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),r=Math.min(Math.max(0,e)/1e3,Ye.targetFPMS);this._maxElapsedMS=1/r}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(!Ye._shared){let t=Ye._shared=new Ye;t.autoStart=!0,t._protected=!0}return Ye._shared}static get system(){if(!Ye._system){let t=Ye._system=new Ye;t.autoStart=!0,t._protected=!0}return Ye._system}};WP.targetFPMS=.06;var lr=WP;Object.defineProperties(K,{TARGET_FPMS:{get(){return lr.targetFPMS},set(i){ht("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),lr.targetFPMS=i}}});var Oh=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,Ts.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?lr.shared:new lr,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};Oh.extension=$.Application;Z.add(Oh);var j2=[];Z.handleByList($.Renderer,j2);var Nh=class{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){let r=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,r)}else{let r=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,r)}e>=wt.HIGH?this.multisample=wt.HIGH:e>=wt.MEDIUM?this.multisample=wt.MEDIUM:e>=wt.LOW?this.multisample=wt.LOW:this.multisample=wt.NONE}destroy(){}};Nh.extension={type:$.RendererSystem,name:"_multisample"};Z.add(Nh);var zu=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var Dh=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:r}=this,s=t._glBuffers[r]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){let{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){let{gl:r,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){let o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,r.bindBufferBase(r.UNIFORM_BUFFER,e,o.buffer)}}bindBufferRange(t,e,r){let{gl:s,CONTEXT_UID:o}=this;r=r||0;let n=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,r*256,256)}update(t){let{gl:e,CONTEXT_UID:r}=this,s=t._glBuffers[r]||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 r=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),r&&(e||s.deleteBuffer(r.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){let e=Object.keys(this.managedBuffers);for(let r=0;r<e.length;r++)this.dispose(this.managedBuffers[e[r]],t)}createGLBuffer(t){let{CONTEXT_UID:e,gl:r}=this;return t._glBuffers[e]=new zu(r.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};Dh.extension={type:$.RendererSystem,name:"buffer"};Z.add(Dh);var Lh=class{constructor(t){this.renderer=t}render(t,e){let r=this.renderer,s,o,n,a;if(e&&(s=e.renderTexture,o=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,r.runners.prerender.emit(),r.emit("prerender"),r.projection.transform=n,!r.context.isLost){if(s||(this.lastObjectRendered=t),!a){let h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}r.renderTexture.bind(s),r.batch.currentRenderer.start(),(o??r.background.clearBeforeRender)&&r.renderTexture.clear(),t.render(r),r.batch.currentRenderer.flush(),s&&(e.blit&&r.framebuffer.blit(),s.baseTexture.update()),r.runners.postrender.emit(),r.projection.transform=null,r.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}};Lh.extension={type:$.RendererSystem,name:"objectRenderer"};Z.add(Lh);var $u=class tx extends en{constructor(t){super(),this.type=Wm.WEBGL,t=Object.assign({},K.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new je({projectionMatrix:new Ct},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:tx.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ht("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=tx.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:Ag()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ht("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ht("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ht("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ht("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};$u.extension={type:$.Renderer,priority:1},$u.__plugins={},$u.__systems={};var Xu=$u;Z.handleByMap($.RendererPlugin,Xu.__plugins);Z.handleByMap($.RendererSystem,Xu.__systems);Z.add(Xu);var Mi=class extends Xe{constructor(t,e){let{width:r,height:s}=e||{};super(r,s),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){let n=new ut;this.items.push(n),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let r=0;r<this.length;r++)t[r]&&(t[r].castToBaseTexture?this.addBaseTextureAt(t[r].castToBaseTexture(),r):t[r]instanceof Xe?this.addResourceAt(t[r],r):this.addResourceAt(Do(t[r],e),r))}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:r}=this.items[0];return this.resize(e,r),this.update(),Promise.resolve(this)}),this._load}};var Hh=class extends Mi{constructor(t,e){let{width:r,height:s}=e||{},o,n;Array.isArray(t)?(o=t,n=t.length):n=t,super(n,{width:r,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=Jr.TEXTURE_2D_ARRAY}upload(t,e,r){let{length:s,itemDirtyIds:o,items:n}=this,{gl:a}=t;r.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,r.internalFormat,this._width,this._height,s,0,e.format,r.type,null);for(let h=0;h<s;h++){let l=n[h];o[h]<l.dirtyId&&(o[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,r.type,l.resource.source))}return!0}};var Vh=class extends te{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var zP=class Wh extends Mi{constructor(t,e){let{width:r,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==Wh.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:r,height:s});for(let a=0;a<Wh.SIDES;a++)this.items[a].target=Jr.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=Jr.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,r){if(r===void 0&&(r=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=Jr.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,r){let s=this.itemDirtyIds;for(let o=0;o<Wh.SIDES;o++){let n=this.items[o];(s[o]<n.dirtyId||r.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,r),s[o]=n.dirtyId):s[o]<-1&&(t.gl.texImage2D(n.target,0,r.internalFormat,e.realWidth,e.realHeight,0,e.format,r.type,null),s[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Wh.SIDES}};zP.SIDES=6;var ex=zP;var zh=class i extends te{constructor(t,e){e=e||{};let r,s,o;typeof t=="string"?(r=i.EMPTY,s=t,o=!0):(r=t,s=null,o=!1),super(r),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 r=await K.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;let s=await r.blob();if(this.destroyed)return;let o=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ze.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(r){if(this.destroyed)return;e(r),this.onError.emit(r)}}),this._load)}upload(t,e,r){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,r)):(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 i._EMPTY=i._EMPTY??K.ADAPTER.createCanvas(0,0),i._EMPTY}};var rx=class ju extends te{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)},ju.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;te.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,r=t.height;if(!e||!r)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,o=r*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/r*e,o=this._overrideHeight||this._overrideWidth/e*r),s=Math.round(s),o=Math.round(o);let n=this.source;n.width=s,n.height=o,n._pixiId=`canvas_${ei()}`,n.getContext("2d").drawImage(t,0,0,e,r,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=ju.SVG_SIZE.exec(t),r={};return e&&(r[e[1]]=Math.round(parseFloat(e[3])),r[e[5]]=Math.round(parseFloat(e[7]))),r}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"&&ju.SVG_XML.test(t)}};rx.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,rx.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var ix=rx;var Yu=class extends te{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var sx=class ox extends te{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){let r=document.createElement("video");e.autoLoad!==!1&&r.setAttribute("preload","auto"),e.playsinline!==!1&&(r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline","")),e.muted===!0&&(r.setAttribute("muted",""),r.muted=!0),e.loop===!0&&r.setAttribute("loop",""),e.autoPlay!==!1&&r.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);let s=t[0].src||t[0];te.crossOrigin(r,s,e.crossorigin);for(let o=0;o<t.length;++o){let n=document.createElement("source"),{src:a,mime:h}=t[o];if(a=a||t[o],a.startsWith("data:"))h=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){let l=a.split("?").shift().toLowerCase(),c=l.slice(l.lastIndexOf(".")+1);h=h||ox.MIME_TYPES[c]||`video/${c}`}n.src=a,h&&(n.type=h),r.appendChild(n)}t=r}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=lr.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,r)=>{this.valid?e(this):(this._resolve=e,this._reject=r,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&&(lr.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||(lr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ox.TYPES.includes(e)}};sx.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],sx.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var nx=sx;mh.push(zh,xs,Vh,nx,Yu,ix,ls,ex,Hh);var Y2={vec3(i,t,e,r){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],i.uniform3f(t,r[0],r[1],r[2]))},int(i,t,e,r){i.uniform1i(t,r)},ivec2(i,t,e,r){i.uniform2i(t,r[0],r[1])},ivec3(i,t,e,r){i.uniform3i(t,r[0],r[1],r[2])},ivec4(i,t,e,r){i.uniform4i(t,r[0],r[1],r[2],r[3])},uint(i,t,e,r){i.uniform1ui(t,r)},uvec2(i,t,e,r){i.uniform2ui(t,r[0],r[1])},uvec3(i,t,e,r){i.uniform3ui(t,r[0],r[1],r[2])},uvec4(i,t,e,r){i.uniform4ui(t,r[0],r[1],r[2],r[3])},bvec2(i,t,e,r){i.uniform2i(t,r[0],r[1])},bvec3(i,t,e,r){i.uniform3i(t,r[0],r[1],r[2])},bvec4(i,t,e,r){i.uniform4i(t,r[0],r[1],r[2],r[3])},mat2(i,t,e,r){i.uniformMatrix2fv(t,!1,r)},mat4(i,t,e,r){i.uniformMatrix4fv(t,!1,r)}},q2={float(i,t,e,r){i.uniform1fv(t,r)},vec2(i,t,e,r){i.uniform2fv(t,r)},vec3(i,t,e,r){i.uniform3fv(t,r)},vec4(i,t,e,r){i.uniform4fv(t,r)},int(i,t,e,r){i.uniform1iv(t,r)},ivec2(i,t,e,r){i.uniform2iv(t,r)},ivec3(i,t,e,r){i.uniform3iv(t,r)},ivec4(i,t,e,r){i.uniform4iv(t,r)},uint(i,t,e,r){i.uniform1uiv(t,r)},uvec2(i,t,e,r){i.uniform2uiv(t,r)},uvec3(i,t,e,r){i.uniform3uiv(t,r)},uvec4(i,t,e,r){i.uniform4uiv(t,r)},bool(i,t,e,r){i.uniform1iv(t,r)},bvec2(i,t,e,r){i.uniform2iv(t,r)},bvec3(i,t,e,r){i.uniform3iv(t,r)},bvec4(i,t,e,r){i.uniform4iv(t,r)},sampler2D(i,t,e,r){i.uniform1iv(t,r)},samplerCube(i,t,e,r){i.uniform1iv(t,r)},sampler2DArray(i,t,e,r){i.uniform1iv(t,r)}};function $P(i,t,e,r,s){let o=0,n=null,a=null,h=s.gl;for(let l in i.uniforms){let c=t[l],u=r[l],d=e[l],f=i.uniforms[l];if(!c){f.group===!0&&s.shader.syncUniformGroup(u);continue}c.type==="float"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,h.uniform1f(d.location,u)):c.type==="bool"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,h.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,h.uniform1i(d.location,o)),o++):c.type==="mat3"&&c.size===1&&!c.isArray?f.a!==void 0?h.uniformMatrix3fv(d.location,!1,u.toArray(!0)):h.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,h.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],h.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,h.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],h.uniform4f(d.location,n[0],n[1],n[2],n[3]))):(c.size===1&&!c.isArray?Y2:q2)[c.type].call(null,h,d.location,d.value,u)}}function K2(){Object.assign(Ri.prototype,{systemCheck(){},syncUniforms(i,t){let{shader:e,renderer:r}=this;$P(i,e.program.uniformData,t.uniformData,i.uniforms,r)}})}K2();var he={Add:"add",Remove:"remove",Update:"update"},qu=class{init(t){throw new Error("Method not implemented.")}render(t){throw new Error("Method not implemented.")}},Bi=class{rendererName;rendererType;add=async(t,e,r)=>{throw new Error("Method not implemented.")};remove=async(t,e,r)=>{throw new Error("Method not implemented.")};update=async(t,e,r)=>{throw new Error("Method not implemented.")}};var Ss=new(window.AudioContext||window.webkitAudioContext),nn=class i{static loadedAssets={};static load=async(t,e)=>{if(!i.loadedAssets[t]&&e.byteLength!==0)try{let r=await Ss.decodeAudioData(e);i.loadedAssets[t]=r}catch(r){console.error(`AudioAsset.load: Failed to decode ${t}:`,r)}};static getAsset=t=>i.loadedAssets[t]},ax=class{_audioSource;_gainNode;volume=1;id;url;loop=!1;constructor(t,e){this.id=t,this.url=e.url,this.loop=e.loop||!1,this.volume=e.volume??1,this._gainNode=Ss.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Ss.destination)}play=()=>{let t=nn.getAsset(this.url);if(!t){console.warn("AudioPlayer.play: Asset not found",this.url);return}this._audioSource=Ss.createBufferSource(),this._audioSource.buffer=t,this._audioSource.loop=this.loop,this._gainNode.gain.setValueAtTime(this.volume,Ss.currentTime),this._audioSource.connect(this._gainNode),this._audioSource.start(0)};stop=()=>{this._audioSource&&(this._audioSource.stop(),this._audioSource.disconnect(),this._gainNode.disconnect(),this._gainNode=Ss.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Ss.destination))}},Ku=class{audioPlayers=[];stageAudios=[];add=t=>{this.stageAudios.push(t)};remove=t=>{this.stageAudios=this.stageAudios.filter(e=>e.id!==t)};getById=t=>this.stageAudios.find(e=>e.id===t);tick=()=>{for(let e of this.stageAudios){let r=this.audioPlayers.find(s=>s.id===e.id);if(!r){let s=new ax(e.id,{url:e.url,loop:e.loop,volume:e.volume??1});this.audioPlayers.push(s),s.play();return}(r.url!==e.url||r.loop!==e.loop)&&(r.stop(),r.url=e.url,r.loop=e.loop??!1,r.play()),r.volume!==(e.volume??1)&&(r.volume=e.volume??1,r._gainNode.gain.value=r.volume)}let t=[];for(let e of this.audioPlayers)this.stageAudios.find(r=>r.id===e.id)||(e.stop(),t.push(e.id));this.audioPlayers=this.audioPlayers.filter(e=>!t.includes(e.id))};destroy=()=>{for(let t of this.audioPlayers)t.stop();this.audioPlayers=[],this.stageAudios=[]}};function Zu(i,t){let{id:e,x:r,y:s,width:o,height:n,fill:a,border:h,originX:l,originY:c,zIndex:u,rotation:d}=t,f=new Qt().rect(r,s,o,n).fill(a);h&&f.stroke({color:h.color,alpha:h.alpha,width:h.width}),f.label=e,f.zIndex=u,i.addChild(f)}function $h(i,t){let e=new gr({text:t.text,style:{fill:t.style.fill,fontFamily:t.style.fontFamily,fontSize:t.style.fontSize,wordWrap:t.style.wordWrap,breakWords:t.style.breakWords,wordWrapWidth:t.style.wordWrapWidth},label:t.id});e.x=t.x,e.y=t.y,e.zIndex=t.zIndex,i.addChild(e)}async function Qu(i,t){let{id:e,x:r,y:s,width:o,height:n,url:a,alpha:h,zIndex:l}=t,c=a?I.from(a):I.EMPTY,u=new Zt(c);u.x=r,u.y=s,u.width=o,u.height=n,u.alpha=h,u.zIndex=l,u.label=e,i.addChild(u)}function hx(i,t){let{id:e,x:r,y:s,children:o,scroll:n,zIndex:a}=t,h=new yt;h.x=r,h.y=s,h.zIndex=a,h.label=e;for(let l of o)switch(l.type){case"rect":Zu(h,l);break;case"text":$h(h,l);break;case"sprite":Qu(h,l);break;case"container":hx(h,l);break;default:throw new Error("Unkown types")}n&&Z2({container:h,element:t}),i.addChild(h)}function Z2({container:i,element:t}){let e=0,r=0;t.children.forEach(n=>{e=Math.max(n.width+n.x,e),r=Math.max(n.height+n.y,r)});let s=t.scroll&&t.height&&r>t.height,o=t.scroll&&t.width&&e>t.width;if(s||o){let n=new yt;[...i.children].forEach(f=>{n.addChild(f)}),i.addChild(n);let h=new Qt().rect(0,0,t.width||e,t.height||r).fill({color:16711680,alpha:0});i.addChild(h),n.mask=h,i.eventMode="static";let l=0,c=0,u=-(r-(t.height||r)),d=-(e-(t.width||e));i.on("wheel",f=>{if(f.preventDefault(),s&&f.deltaY!==0){let p=l-f.deltaY;p>0?l=0:p<u?l=u:l=p,n.y=l}if(o&&(f.deltaX!==0||f.shiftKey&&f.deltaY!==0)){let p=f.deltaX!==0?f.deltaX:f.deltaY,g=c-p;g>0?c=0:g<d?c=d:c=g,n.x=c}})}}function XP(i,t){let e=new Set,r=new Map,s=new Map,o=[],n=[],a=[];for(let h of i)e.add(h.id),r.set(h.id,h);for(let h of t)e.add(h.id),s.set(h.id,h);for(let h of e){let l=r.get(h),c=s.get(h);!l&&c?o.push(c):l&&!c?n.push(l):JSON.stringify(l)!==JSON.stringify(c)&&a.push({prev:l,next:c})}return{toAddElement:o,toDeleteElement:n,toUpdateElement:a}}function jP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy()}function YP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy()}function qP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy({children:!0})}function KP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy()}function ZP(i,t,e){let r=i.children.find(s=>s.label===t.id);r&&(r.clear(),r.rect(e.x,e.y,e.width,e.height).fill(e.fill),e.border&&r.stroke({color:e.border.color,alpha:e.border.alpha,width:e.border.width}),r.zIndex=e.zIndex)}function QP(i,t,e){let r=i.children.find(s=>s.label===t.id);r&&(r.text=e.text,r.style={fill:e.style.fill,fontFamily:e.style.fontFamily,fontSize:e.style.fontSize,wordWrap:e.style.wordWrap,breakWords:e.style.breakWords,wordWrapWidth:e.style.wordWrapWidth},r.x=e.x,r.y=e.y,r.zIndex=e.zIndex)}async function JP(i,t,e){let r=i.children.find(s=>s.label===t.id);if(r){if(t.url!==e.url){let s=e.url?I.from(e.url):I.EMPTY;r.texture=s}r.x=e.x,r.y=e.y,r.width=e.width,r.height=e.height,r.alpha=e.alpha,r.zIndex=e.zIndex}}function tR(i,t,e,r){let s=t.children.find(o=>o.label===e.id);s&&(s.x=r.x,s.y=r.y,s.zIndex=r.zIndex,s.label=r.id,JSON.stringify(e.children)!==JSON.stringify(r.children)&&Xh(i,s,e.children,r.children))}function Xh(i,t,e,r){let{toAddElement:s,toDeleteElement:o,toUpdateElement:n}=XP(e,r);for(let a of o)switch(a.type){case"rect":jP(t,a);break;case"text":YP(t,a);break;case"container":qP(t,a);break;case"sprite":KP(t,a);break;default:}for(let a of s)switch(a.type){case"rect":Zu(t,a);break;case"text":$h(t,a);break;case"container":hx(t,a);break;case"sprite":Qu(t,a);break;default:}for(let{prev:a,next:h}of n)switch(h.type){case"rect":ZP(t,a,h);break;case"text":QP(t,a,h);break;case"container":tR(i,t,a,h);break;case"sprite":JP(t,a,h);break;default:}Q2(t,r)}function Q2(i,t){i.children.sort((e,r)=>{let s=t.find(n=>n.id===e.label),o=t.find(n=>n.id===r.label);if(s&&o){let n=s.zIndex??0,a=o.zIndex??0;if(n!==a)return n-a;let h=t.findIndex(c=>c.id===e.label),l=t.findIndex(c=>c.id===r.label);return h-l}if(!s&&!o)return 0;if(!s)return-1;if(!o)return 1})}function eR({positionX:i=0,positionY:t=0,width:e,height:r,anchorX:s=0,anchorY:o=0}){if(typeof e!="number"||typeof r!="number")throw new Error("Input Error: Width or height is missing");let n={x:e*s,y:r*o},a=i-n.x,h=t-n.y;return{x:a,y:h,originX:n.x,originY:n.y}}function Ii(i){if(typeof i.width!="number"||typeof i.height!="number")throw new Error("Input Error: Width or height is missing");if(!["rect","text","container","sprite"].includes(i.type))throw new Error("Input Error: Type must be one of rect, text, container, sprite");if(!i.id)throw new Error("Input Error: Id is missing");let t=i.scaleX?i.scaleX*i.width:i.width,e=i.scaleY?i.scaleY*i.height:i.height;i.type==="container"&&(t=i.width,e=i.height);let{x:r,y:s,originX:o,originY:n}=eR({positionX:i.x,positionY:i.y,width:t,height:e,anchorX:i.anchorX,anchorY:i.anchorY});return{id:i.id,type:i.type,width:t,height:e,x:r,y:s,originX:o,originY:n,zIndex:i.zIndex||0}}function Ju(i){let t=Ii(i);return i.border&&(t={...t,border:{alpha:i?.border?.alpha??1,color:i?.border?.color??"black",width:i?.border?.width??0}}),{...t,cursor:i.cursor??"",fill:i.fill??"white",pointerDown:i.pointerDown??"",pointerMove:i.pointerMove??"",pointerUp:i.pointerUp??"",rotation:i.rotation??0}}function td(i){let e={...{fill:"black",fontFamily:"Arial",fontSize:16},...i.style};i.width&&(e.wordWrapWidth=i.width,e.wordWrap=!0);let{width:r,height:s}=gt.measureText(i.text,new Ht(e));return{...Ii({...i,width:r,height:s}),text:i.text??"",style:{...e}}}function ed(i){return{...Ii(i),url:i.url??"",alpha:i.alpha??1,cursor:i.cursor??"",clickUrl:i.clickUrl??"",hoverUrl:i.hoverUrl??""}}function lx(i){let t=i.direction,e=!!i.scroll,r=i.gap||0,s=i.children||[],o=[],n=0,a=0,h=0,l=0,c=0,u=0,d=0,f=0,p=0,g=0;for(let v=0;v<s.length;v++){let _=v<s.length-1?r:0,y=s[v];switch(v>0?t==="horizontal"?(y.x=h,y.y=d):t==="vertical"&&(y.x=f,y.y=l):(t==="horizontal"||t==="vertical")&&(y.x=0,y.y=0),y.type){case"rect":y=Ju(y);break;case"text":y=td(y);break;case"sprite":y=ed(y);break;case"container":y=lx(y);break;default:}t==="horizontal"?(i.width&&y.width+p>i.width&&!e?(h=0,p=0,d+=c+r,c=y.height,y.x=0,y.y=d):c=Math.max(c,y.height),h+=y.width+_,p=y.x+y.width,n=Math.max(h,n),a=Math.max(y.height+y.y,a)):t==="vertical"&&(i.height&&y.height+g>i.height&&!e?(l=0,g=0,f+=u+r,u=y.width,y.x=f,y.y=0):u=Math.max(u,y.width),l+=y.height+_,g=y.y+y.height,n=Math.max(y.width+y.x,n),a=Math.max(l,a)),o.push(y)}return{...Ii({...i,width:i.width?i.width:n,height:i.height?i.height:a}),children:o,direction:t,gap:r,scroll:e,rotation:i.rotation??0}}function jh(i){return i.map(e=>{switch(e.type){case"rect":return Ju(e);case"container":return lx(e);case"text":return td(e);case"sprite":return ed(e);default:throw new Error(`Unsupported element type: ${e.type}`)}})}var J2=i=>i.split("/").pop(),cx=class{name="advancedBufferLoader";priority=2;constructor(t){this.bufferMap=t}test(t){return!0}async load(t){let e=t.startsWith("file:")?t:J2(t),r=this.bufferMap[e];if(!r)throw new Error(`Buffer not found for key: ${e}`);return{data:r.buffer,type:r.type,metadata:null}}async testParse(t){return!0}async parse(t){if(t instanceof I)return t;let e=new Blob([t.data],{type:t.type}),r=await createImageBitmap(e);return new I.from(r)}async unload(t){t.destroy(!0)}},ux=class i extends qu{static rendererName="pixi";_app;_audioStage=new Ku;_state={elements:[],transitions:[]};_eventHandler;_plugins;_currentAbortController;_advancedLoader;get canvas(){return this._app.canvas}init=async t=>{let{eventHandler:e,plugins:r,width:s,height:o,backgroundColor:n}=t;for(let h of r)if(h.rendererName!==i.rendererName)throw new Error("Plugin does not match renderer name");this._plugins=r,this._eventHandler=e,this._app=new Za,this._app.audioStage=this._audioStage,await this._app.init({width:s,height:o,backgroundColor:n});let a=new Qt;return a.rect(0,0,s,o),a.fill(n||0),this._app.stage.addChild(a),this._app.stage.width=s,this._app.stage.height=o,this._app.ticker.add(this._app.audioStage.tick),this};destroy=()=>{this._app.audioStage.destroy(),this._app.destroy()};_classifyAsset=t=>t?t.startsWith("audio/")?"audio":t.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(t)?"font":"texture":"texture";loadAssets=async t=>{if(!t)throw new Error("assetBufferMap is required");let e={audio:{},font:{},texture:{}};for(let[s,o]of Object.entries(t)){let n=this._classifyAsset(o.type);e[n][s]=o}await Promise.all(Object.entries(e.audio).map(([s,o])=>nn.load(s,o.buffer))),await Promise.all(Object.entries(e.font).map(async([s,o])=>{let n=new Blob([o.buffer],{type:o.type}),a=URL.createObjectURL(n),h=new FontFace(s,`url(${a})`);try{await h.load(),document.fonts.add(h)}catch(l){console.error(`Failed to load font ${s}:`,l)}finally{URL.revokeObjectURL(a)}})),this._advancedLoader?Object.assign(this._advancedLoader.bufferMap,e.texture):(this._advancedLoader=new cx(e.texture),sr.loader.parsers.length=0,sr.reset(),D.add({name:"advanced-buffer-loader",extension:b.Asset,priority:se.High,loader:this._advancedLoader}),typeof sr.registerPlugin=="function"&&sr.registerPlugin(this._advancedLoader));let r=Object.keys(e.texture);return Promise.all(r.map(s=>sr.load(s)))};loadAudioAssets=async t=>Promise.all(t.map(async e=>{let s=await(await fetch(e)).arrayBuffer();return nn.load(e,s)}));updatedBackgroundColor=t=>{this._app.renderer.background.color=t};getStageElementBounds=()=>{let t={},e=r=>{if(!(!r||r.length===0))for(let s of r)t[s.label]={x:s.groupTransform.tx,y:s.groupTransform.ty,width:s.width,height:s.height},e(s.children)};return e(this._app.stage.children),t};render=t=>{let e=jh(t.elements),r={...t,elements:e};this._render(this._app,this._app.stage,this._state,r,this._eventHandler),this._state=r};_getRendererByElement=t=>{for(let e of this._plugins)if(e.rendererType===t.type)return e;throw new Error(`No renderer found for element type: ${t.type}`)};_getTransitionByType=t=>{for(let e of this._plugins)if(e.transitionType===t)return e;throw new Error(`No transition found for transition type: ${t}`)};_applyGlobalCursorStyles=(t,e,r)=>{t.renderer.events.cursorStyles||(t.renderer.events.cursorStyles={}),t.renderer.events.cursorStyles.default||(t.renderer.events.cursorStyles.default="default"),t.renderer.events.cursorStyles.hover||(t.renderer.events.cursorStyles.hover="pointer");let s=e?.cursorStyles,o=r?.cursorStyles;JSON.stringify(s)!==JSON.stringify(o)&&(o?(o.default&&(t.renderer.events.cursorStyles.default=o.default,t.canvas.style.cursor=o.default),o.hover&&(t.renderer.events.cursorStyles.hover=o.hover)):s&&(t.renderer.events.cursorStyles.default="default",t.renderer.events.cursorStyles.hover="pointer"))};_render=async(t,e,r,s,o)=>{this._applyGlobalCursorStyles(t,r.global,s.global),Xh(t,e,r.elements,s.elements),this._currentAbortController&&this._currentAbortController.abort(),this._currentAbortController=new AbortController}},rR=ux;var dx=class extends Bi{static rendererName="pixi";rendererName="pixi";rendererType="sprite";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:h,elements:l=[]}=e,c=o.url?I.from(o.url):I.EMPTY,u,d,f=o.scaleX??1,p=o.scaleY??1;o.hoverUrl&&(u=I.from(o.hoverUrl)),o.clickUrl&&(d=I.from(o.clickUrl));let g=new Zt(c);g.label=o.id,g.interactiveChildren=!1,(o.eventName||o.hoverUrl||o.clickUrl)&&(g.cursor="hover",g.eventMode="static"),o.width!==void 0?g.width=o.width*f:g.width*=f,o.height!==void 0?g.height=o.height*p:g.height*=p,o.anchorX!==void 0&&(g.pivot.x=g.width*o.anchorX),o.anchorY!==void 0&&(g.pivot.y=g.height*o.anchorY),o.rotation!==void 0&&(g.rotation=o.rotation*Math.PI/180),o.x!==void 0&&(g.x=o.x),o.y!==void 0&&(g.y=o.y),o.zIndex!==void 0&&(g.zIndex=o.zIndex),o.alpha!==void 0&&(g.alpha=o.alpha),(u||d)&&g.on("pointerup",()=>{g.texture=c}).on("pointerupoutside",()=>{g.texture=c}).on("pointerleave",()=>{g.texture=c}),d&&g.on("pointerdown",()=>{g.texture=d}),u&&g.on("pointerenter",()=>{g.texture=u}),g.on("pointerup",v=>{v.stopPropagation();let _=v.button;_===0?h&&h(o.eventName,o.eventPayload):_===2&&(o.rightClickEventName&&h?h(o.rightClickEventName):t.stage.emit("rightclick",event))});let x=[];for(let v of n)if(v.elementId===o.id&&v.event===he.Add){let _=a(v.type);if(!_)throw new Error(`Transition class not found for type ${v.type}`);x.push(_.add(t,g,v,r))}s.addChild(g),Array.isArray(l)&&l.length>0&&s.children.sort((v,_)=>{let y=l.find(E=>E.id===v.label),T=l.find(E=>E.id===_.label);if(y&&T){let E=y.zIndex??0,w=T.zIndex??0;if(E!==w)return E-w;let C=l.findIndex(P=>P.id===v.label),M=l.findIndex(P=>P.id===_.label);return C-M}if(!y&&!T)return 0;if(!y)return-1;if(!T)return 1}),await Promise.all(x)};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,h=s.getChildByName(o.id);if(!h)throw new Error(`Sprite with id ${o.id} not found`);let l=[];for(let c of n)if(c.elementId===o.id&&c.event===he.Remove){let u=a(c.type);if(!u)throw new Error(`Transition class not found for type ${c.type}`);l.push(u.remove(t,h,c,r))}await Promise.all(l),h&&h.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a},h)=>{if(h?.aborted)throw new DOMException("Operation aborted","AbortError");let l=e.getChildByName(r.id);if(!l)throw new Error(`Sprite with id ${r.id} not found`);let c=[];for(let f of o)if(f.elementId===r.id&&f.event===he.Update){let p=n(f.type);if(!p)throw new Error(`Transition class not found for type ${f.type}`);c.push(p.add(t,l,f,h))}c.length>0?(await Promise.all(c),u()):d();function u(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let x=I.from(s.url);if(l.texture=x,!r.url&&s.url)if(x.baseTexture.valid){let v=s.scaleX??1,_=s.scaleY??1;l.width=(s.width??x.width)*v,l.height=(s.height??x.height)*_}else x.baseTexture.once("loaded",()=>{let v=s.scaleX??1,_=s.scaleY??1;l.width=(s.width??x.width)*v,l.height=(s.height??x.height)*_})}let p=r.hoverUrl||r.clickUrl,g=s.hoverUrl||s.clickUrl;if(!p&&g){let x=l.texture;l.on("pointerup",()=>{l.texture=x}).on("pointerupoutside",()=>{l.texture=x}).on("pointerleave",()=>{l.texture=x})}if(s.hoverUrl){let x=I.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=x})}if(s.clickUrl){let x=I.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=x})}}(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="hover",l.eventMode="static")}function d(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let _=I.from(s.url);if(l.texture=_,!r.url&&s.url)if(_.baseTexture.valid){let y=s.scaleX??1,T=s.scaleY??1;l.width=(s.width??_.width)*y,l.height=(s.height??_.height)*T}else _.baseTexture.once("loaded",()=>{let y=s.scaleX??1,T=s.scaleY??1;l.width=(s.width??_.width)*y,l.height=(s.height??_.height)*T})}let x=r.hoverUrl||r.clickUrl,v=s.hoverUrl||s.clickUrl;if(!x&&v){let _=l.texture;l.on("pointerup",()=>{l.texture=_}).on("pointerupoutside",()=>{l.texture=_}).on("pointerleave",()=>{l.texture=_})}if(s.hoverUrl){let _=I.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=_})}if(s.clickUrl){let _=I.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=_})}}s.x!==void 0&&s.x!==r.x&&(l.x=s.x),s.y!==void 0&&s.y!==r.y&&(l.y=s.y),s.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180);let p=s.scaleX??1,g=s.scaleY??1;s.width!==void 0&&(s.width!==r.width||p!==(r.scaleX??1))&&(l.width=s.width*p),s.height!==void 0&&(s.height!==r.height||g!==(r.scaleY??1))&&(l.height=s.height*g),s.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=l.width*s.anchorX/p),s.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=l.height*s.anchorY/g),s.zIndex!==void 0&&s.zIndex!==r.zIndex&&(l.zIndex=s.zIndex),s.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="hover",l.eventMode="static")}}};var rd=i=>new Ht({wordWrap:i.wordWrap||!0,breakWords:i.breakWords||!1,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),fx=class{static rendererName="pixi";rendererName="pixi";rendererType="text";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:h}=e,l=rd(o.style),c=new gr({text:o.text,style:l}),u;o.hoverStyle&&(u=rd(o.hoverStyle));let d;if(o.clickedStyle&&(d=rd(o.clickedStyle)),(o.eventName||o.clickedStyle||o.hoverStyle)&&(c.cursor="hover",c.eventMode="static"),c.label=o.id,o.x!==void 0&&(c.x=o.x),o.y!==void 0&&(c.y=o.y),o.anchorX!==void 0&&(c.anchor.x=o.anchorX),o.anchorY!==void 0&&(c.anchor.y=o.anchorY),o.anchorX!==void 0||o.anchorY!==void 0){let p=c.getLocalBounds();c.hitArea=new rt(-p.width*c.anchor.x,-p.height*c.anchor.y,p.width,p.height)}c.on("pointerout",()=>{c.isOver=!1}).on("pointerupoutside",()=>{c.style=l}).on("pointerup",()=>{c.style=l}).on("pointerleave",()=>{c.style=l}),c.on("pointerup",p=>{o.clickSoundUrl&&t.soundStage&&t.soundStage.add({id:`${o.id}-click-${Math.random()}`,url:o.clickSoundUrl,loop:!1,volume:o.clickSoundVolume??50/100}),p.stopPropagation(),h&&h(o.eventName,o.eventPayload)}),d&&c.on("pointerdown",()=>{c.style=d}),u&&c.on("pointerenter",()=>{c.style=u,o.hoverSoundUrl&&t.soundStage&&o.hoverSoundVolume!==void 0&&t.soundStage.add({id:`${o.id}-hover-${Math.random()}`,url:o.hoverSoundUrl,loop:!1,volume:o.hoverSoundVolume/100})});let f=[];for(let p of n)if(p.elementId===o.id&&p.event===he.Add){let g=a(p.type);if(!g)throw new Error(`Transition class not found for type ${p.type}`);f.push(g.add(t,c,p,r))}s.addChild(c),await Promise.all(f)};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,h=s.getChildByName(o.id);if(!h){console.warn(`Text with id ${o.id} not found`);return}let l=[];for(let c of n)if(c.elementId===o.id&&c.event===he.Remove){let u=a(c.type);if(!u)throw new Error(`Transition class not found for type ${c.type}`);l.push(u.remove(t,h,c,r))}await Promise.all(l),h&&h.destroy()};update=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,prevElement:o,nextElement:n,transitions:a,getTransitionByType:h,eventHandler:l}=e,c=s.getChildByName(o.id);if(!c){console.warn(`Text with id ${o.id} not found`);return}if(JSON.stringify(o)!==JSON.stringify(n)){let u=[this.add(t,{parent:s,element:n,transitions:a,getTransitionByType:h,eventHandler:l},r),this.remove(t,{parent:s,element:o,transitions:a,getTransitionByType:h},r)];await Promise.all(u)}else o.text!==n.text&&(c.text=n.text),JSON.stringify(o.style)!==JSON.stringify(n.style)&&(c.style=rd(n?.style)),n.x!==void 0&&(c.x=n.x),n.y!==void 0&&(c.y=n.y)}};var ee=(i,t=!1)=>new Ht({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",whiteSpace:"pre",trim:!1,stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),px=class{static rendererName="pixi";rendererName="pixi";rendererType="text-revealing";add=async(t,{parent:e,element:r})=>{let s=r.content?.[0]?.text||"",o=ee(r.style,s),n=new gr({text:"",style:o});n.label=r.id,n.text_id=s;let a=new yt;r.x!==void 0&&(a.x=r.x),r.y!==void 0&&(a.y=r.y),a.addChild(n),a.label=r.id,e.addChild(a);let h=r.style.wordWrapWidth||500,l=r.content&&r.content.length>0?r.content.map(E=>({text:E.text.replace(/ +$/,w=>"\xA0".repeat(w.length)),style:E.style?{...r.style,...E.style}:r.style,align:E.align||r.align||"top",furigana:E.furigana})):r.segments,c=[];if(l.length===1){let E=[],w=0,C=0,M=0,P=[...l];for(;;){let S=P[0];if(!S){E.length>0&&c.push({lineParts:E,y:C});break}if(C>1e4)break;let A={...S.style,wordWrapWidth:h-w},B=gt.measureText(S.text,ee(A));B.lineHeight>M&&(M=B.lineHeight);let F=gt.measureText("a",ee(A)),z=gt.measureText("a a",ee(A)).width-F.width*2;if(B.lineWidths[0]+w>h){w=0,c.push({lineParts:E,y:C}),C+=M,M=0,E=[];continue}let k=B.lines[0];B.lines.length===1&&S.text.endsWith(" ")&&!k.endsWith(" ")&&(k+=" ");let G=B.lines.slice(1).join(" "),N={text:k,style:A,x:w,y:0,align:S.align};if(E.push(N),G&&G.length>0?S.text=G:P.shift(),!(!k||k.length===0)){if(S.furigana){let O=gt.measureText(S.furigana.text,ee(S.furigana.style)),Y={text:S.furigana.text,style:S.furigana.style,x:w+(B.width-O.width)/2,y:-10};E.push(Y)}w+=B.lineWidths[0]+z}}}else{let E=[],w=0,C=0,M=0,P=[...l],S=new WeakSet;for(;;){let A=P[0];if(!A){E.length>0&&c.push({lineParts:E,y:C});break}if(C>1e4)break;let B={...A.style,wordWrapWidth:h-w},F=gt.measureText(A.text,ee(B));F.lineHeight>M&&(M=F.lineHeight);let W=gt.measureText("a",ee(B)),k=gt.measureText("a a",ee(B)).width-W.width*2;if(F.lineWidths[0]+w>h){w=0,c.push({lineParts:E,y:C}),C+=M,M=0,E=[];continue}let G=F.lines[0];F.lines.length===1&&A.text.endsWith(" ")&&!G.endsWith(" ")&&(G+=" ");let N=F.lines.slice(1).join(" "),O={text:G,style:B,x:w,y:0,align:A.align};if(E.push(O),N&&N.length>0?A.text=N:P.shift(),!(!G||G.length===0)){if(A.furigana&&!S.has(A)){S.add(A);let Y=gt.measureText(A.furigana.text,ee(A.furigana.style)),lt={text:A.furigana.text,style:A.furigana.style,x:w+(F.lineWidths[0]-Y.width)/2,y:0,isFurigana:!0,parentAlign:A.align,parentX:w,parentWidth:F.lineWidths[0]};E.push(lt)}w+=F.lineWidths[0]}}}c.forEach(E=>{let w=new yt;w.y=E.y,w.alpha=0;let C=0;E.lineParts.forEach(P=>{let S=gt.measureText(P.text,ee(P.style));S.height>C&&(C=S.height)});let M=new Map;E.lineParts.forEach(P=>{if(!P.isFurigana){let S=gt.measureText(P.text,ee(P.style)),A=P.y,B=P.align||"top";B==="center"?A+=(C-S.height)/2:B==="bottom"&&(A+=C-S.height);let F=new gr({text:P.text,style:ee(P.style),x:P.x,y:A});w.addChild(F),M.set(P.x,{yOffset:A,height:S.height})}}),E.lineParts.forEach(P=>{if(P.isFurigana){let S=gt.measureText(P.text,ee(P.style)),A=M.get(P.parentX),B=-S.height-5;A&&(B=A.yOffset-S.height+2);let F=new gr({text:P.text,style:ee(P.style),x:P.x,y:B});w.addChild(F)}}),a.addChild(w)});let u=new Qt,d=1e3,f=h/2,p=h/2;u.fill({color:16777215,alpha:1}),u.rect(0,0,f,d);for(let E=0;E<p;E++)u.fill({color:16777215,alpha:1-E/p}),u.rect(f+E,0,f+1,d);let g=t.renderer.generateTexture(u),x=new Zt(g);x.x=-1.35*f-p,t.stage.addChild(x);let v=null,_=null;if(r.indicator?.revealing?.url){let E=I.from(r.indicator.revealing.url);v=new Zt(E),v.anchor.set(0,.5),v.visible=!1,r.indicator.revealing.width!==void 0&&(v.width=r.indicator.revealing.width),r.indicator.revealing.height!==void 0&&(v.height=r.indicator.revealing.height),a.addChild(v)}if(r.indicator?.complete?.url){let E=I.from(r.indicator.complete.url);_=new Zt(E),_.anchor.set(0,.5),_.visible=!1,r.indicator.complete.width!==void 0&&(_.width=r.indicator.complete.width),r.indicator.complete.height!==void 0&&(_.height=r.indicator.complete.height),a.addChild(_)}let y=0,T=1;if(c.length!==0){if(r.displaySpeed===100||r.hasEnded){if(a.children.forEach(E=>{t.stage.removeChild(x),E.mask=null,E.alpha=1}),_&&(_.visible=!0,c.length>0)){let E=c[c.length-1],w=0,C=E.y;E.lineParts.forEach(M=>{if(!M.isFurigana){let P=gt.measureText(M.text,ee(M.style)),S=M.x+P.width;S>w&&(w=S)}}),_.x=w+10,_.y=C+20}return}await new Promise(E=>{let w=C=>{if(T>a.children.length){if(v&&(v.visible=!1),_&&(_.visible=!0,c.length>0)){let S=c[c.length-1],A=0,B=S.y;S.lineParts.forEach(F=>{if(!F.isFurigana){let W=gt.measureText(F.text,ee(F.style)),z=F.x+W.width;z>A&&(A=z)}}),_.x=A+10,_.y=B+20}E();return}a.getChildAt(T).mask||(a.getChildAt(T).mask=x,a.getChildAt(T).alpha=1),y+=C.deltaMS;let P=(r.displaySpeed||50)/1e3;if(x.x+=P*y,v&&T<=c.length){let S=c[T-1];if(S&&(a.getChildAt(T).mask===x||T===c.length)){v.visible=!0;let B=x.x+f+p+150,F=0,W=!1,z=!0,k=0;for(let G of S.lineParts)if(!G.isFurigana){let N=gt.measureText(G.text,ee(G.style));k=Math.max(k,G.x+N.width)}for(let G of S.lineParts)if(!G.isFurigana){let N=gt.measureText(G.text,ee(G.style)),O=G.x,Y=G.x+N.width;if(Y<=B)F=Y,W=!0;else if(O<B){F=Math.max(O,B),W=!0,z=!1;break}else z=!1}B>=k&&(z=!0),W&&F>0?(v.x=F,v.y=S.y+20):T===c.length&&k>0?(v.x=k,v.y=S.y+20):v.visible=!1,_&&(_.visible=!1)}else v.visible=!1}if(x.x>=0&&(a.getChildAt(T).mask=null,x.x=-1.35*f-p,T=T+1,y=0,T===a.children.length)){if(v&&(v.visible=!1),_&&(_.visible=!0,c.length>0)){let S=c[c.length-1],A=0,B=S.y;S.lineParts.forEach(F=>{if(!F.isFurigana){let W=gt.measureText(F.text,ee(F.style)),z=F.x+W.width;z>A&&(A=z)}}),_.x=A+10,_.y=B+20}t.ticker.remove(w),E()}};t.ticker.add(w)})}};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Text with id ${s.id} not found`,{parent:r});return}let h=[];for(let l of o)if(l.elementId===s.id&&l.event===he.Remove){let c=n(l.type);if(!c)throw new Error(`Transition class not found for type ${l.type}`);h.push(c.remove(t,a,l))}await Promise.all(h),a.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o}=e;if(!r.getChildByName(s.id)){console.warn(`Text with id ${s.id} not found`,{parent:r});return}await this.remove(t,{parent:r,element:s}),await this.add(t,{parent:r,element:o})}};var iR=(i=[],t=[])=>{let e=[],r=[],s=[],o=i.filter(a=>!a.hidden),n=t.filter(a=>!a.hidden);for(let a of o){let h=n.find(l=>l.id===a.id&&l.type===a.type);h?r.push({prev:a,next:h}):e.push(a)}for(let a of n)o.find(l=>l.id===a.id&&l.type===a.type)||s.push(a);for(let a of i){let h=t.find(l=>l.id===a.id&&l.type===a.type);h&&h.hidden&&!a.hidden&&e.push(a)}return{toDeleteElements:e,toUpdateElements:r,toAddElements:s}};var mx=class{static rendererName="pixi";rendererName="pixi";rendererType="container";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,elements:n=[],transitions:a=[],getTransitionByType:h,getRendererByElement:l,eventHandler:c}=e,u=structuredClone(o),d=new yt;d.label=u.id;let f={};u.x!==void 0&&(typeof u.x=="string"&&u.x.endsWith("%")?d.x=Number(u.x.replace("%",""))*t.screen.width/100:d.x=u.x),u.y!==void 0&&(typeof u.y=="string"&&u.y.endsWith("%")?d.y=Number(u.y.replace("%",""))*t.screen.height/100:d.y=u.y),u.scaleX!==void 0&&(d.scale.x=u.scaleX),u.scaleY!==void 0&&(d.scale.y=u.scaleY),u.zIndex!==void 0&&(d.zIndex=u.zIndex),u.rotation!==void 0&&(d.rotation=u.rotation*Math.PI/180),u.propagateEvents&&(d.eventMode="static",["pointerup","pointerupoutside","pointerleave","pointerdown","pointerenter"].forEach(P=>{d.on(P,S=>{S.stopPropagation();for(let A of d.children)A.emit(P)})}));let p=u.gap||0,g=new Qt().roundRect(0,0,u.width||0,u.height||0,1).fill(u.fill?u.fill.color:"transparent"),x=[0,.5,1],v=u.anchorX??0,_=u.anchorY??0;if(!x.includes(v))throw new Error(`Invalid anchorX value: ${v}. Must be 0, 0.5, or 1`);if(!x.includes(_))throw new Error(`Invalid anchorY value: ${_}. Must be 0, 0.5, or 1`);if(u.direction){let P,S;u.direction==="horizontal"?(P=u.children.reduce((B,F,W)=>B+F.width+(W>0?p:0),0),S=u.children.reduce((B,F)=>Math.max(B,F.height||0),0)):u.direction==="vertical"&&(P=u.children.reduce((B,F)=>Math.max(B,F.width||0),0),S=u.children.reduce((B,F,W)=>B+F.height+(W>0?p:0),0));let A={x:v,y:_};u.direction==="horizontal"?this.layoutChildren({element:u,anchor:A,totalWidth:P,totalHeight:S,gap:p,direction:"horizontal",scroll:u.scroll}):u.direction==="vertical"&&this.layoutChildren({element:u,anchor:A,totalWidth:P,totalHeight:S,gap:p,direction:"vertical",scroll:u.scroll}),this.setupScrolling({container:d,element:u,totalHeight:S,totalWidth:P,eventHandler:c,sliderRef:f}),g=this.createContainerGraphic(u,P,S,A)}g.label=`${u.id}-container-background`,d.addChild(g);let y=[];(u.children||[]).forEach(P=>{let S=l(P),A=u.width||0,B=u.height||0,F=v*A,W=_*B,z={zIndex:u.zIndex,...P,x:(P.x||0)+F,y:(P.y||0)+W};y.push(S.add(t,{parent:d,element:z,elements:u.children||[],transitions:a,getTransitionByType:h,getRendererByElement:l,eventHandler:c},r))});let T=[];for(let P of a)if(P.elementId===u.id&&P.event===he.Add){let S=h(P.type);if(!S)throw new Error(`Transition class not found for type ${P.type}`);T.push(S.add(t,d,P,r))}s.addChild(d),await Promise.all([...y,...T]);let{width:E,height:w}=this.getContainerDimensions(u,d),C=v*E,M=_*w;d.pivot.x=C,d.pivot.y=M};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");console.log("remove container 11111111111");let{parent:s,element:o}=e,n=s.getChildByName(o.id);if(!n){console.warn(`Container with id ${o.id} not found`);return}n.destroy()};update=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,prevElement:o,nextElement:n,elements:a=[],getRendererByElement:h,transitions:l=[],getTransitionByType:c,eventHandler:u}=e,d=structuredClone(o),f=structuredClone(n),p=s.getChildByName(d.id);if(!p){console.warn(`Container with id ${d.id} not found`);return}f.x!==void 0&&(p.x=f.x),f.y!==void 0&&(p.y=f.y),f.rotation!==void 0&&f.rotation!==d.rotation&&(p.rotation=f.rotation*Math.PI/180);let g=[0,.5,1],x=f.anchorX??0,v=f.anchorY??0;if(!g.includes(x))throw new Error(`Invalid anchorX value: ${x}. Must be 0, 0.5, or 1`);if(!g.includes(v))throw new Error(`Invalid anchorY value: ${v}. Must be 0, 0.5, or 1`);if(f.direction){let S=f.gap||0,A,B;f.direction==="horizontal"?(A=f.children.reduce((z,k,G)=>z+k.width+(G>0?S:0),0),B=f.children.reduce((z,k)=>Math.max(z,k.height||0),0)):f.direction==="vertical"&&(A=f.children.reduce((z,k)=>Math.max(z,k.width||0),0),B=f.children.reduce((z,k,G)=>z+k.height+(G>0?S:0),0));let F={x,y:v};f.direction==="horizontal"?this.layoutChildren({element:f,anchor:F,totalWidth:A,totalHeight:B,gap:S,direction:"horizontal",scroll:f.scroll}):f.direction==="vertical"&&this.layoutChildren({element:f,anchor:F,totalWidth:A,totalHeight:B,gap:S,direction:"vertical",scroll:f.scroll});let W=p.children.find(z=>z.label===`${f.id}-container-background`);if(W){W.destroy();let z=this.createContainerGraphic(f,A,B,F);z.label=`${f.id}-container-background`,p.addChildAt(z,0)}d.scroll!==f.scroll&&this.setupScrolling({container:p,element:f,totalHeight:B,totalWidth:A,eventHandler:u,sliderRef:{}})}let _=[],{toAddElements:y,toUpdateElements:T,toDeleteElements:E}=iR(d.children,f.children);if(f.direction&&f.children){let S=new Map;f.children.forEach(A=>{S.set(A.id,{x:A.x,y:A.y})}),T.forEach(A=>{let B=S.get(A.next.id);B&&(A.next.x=B.x,A.next.y=B.y)}),y.forEach(A=>{let B=S.get(A.id);B&&(A.x=B.x,A.y=B.y)})}for(let S of E){let A=h(S);_.push(A.remove(t,{parent:p,element:S,elements:f.children||[],transitions:l,getTransitionByType:c,getRendererByElement:h,eventHandler:u},r))}for(let S of y){let A=h(S),B=f.width||0,F=f.height||0,W=x*B,z=v*F,k={...S,x:(S.x||0)+W,y:(S.y||0)+z};_.push(A.add(t,{parent:p,element:k,elements:f.children||[],transitions:l,getTransitionByType:c,getRendererByElement:h,eventHandler:u},r))}for(let S of T){let A=h(S.next),B=f.width||0,F=f.height||0,W=x*B,z=v*F,k=d.anchorX??0,G=d.anchorY??0,N=d.width||0,O=d.height||0,Y=k*N,lt=G*O,bt={...S.prev,x:(S.prev.x||0)+Y,y:(S.prev.y||0)+lt},It={...S.next,x:(S.next.x||0)+W,y:(S.next.y||0)+z};_.push(A.update(t,{parent:p,prevElement:bt,nextElement:It,elements:f.children||[],transitions:l,getTransitionByType:c,getRendererByElement:h,eventHandler:u},r))}f.children&&f.children.length>0&&p.children.sort((S,A)=>{let B=f.children.find(W=>W.id===S.label),F=f.children.find(W=>W.id===A.label);if(B&&F){let W=B.zIndex??0,z=F.zIndex??0;if(W!==z)return W-z;let k=f.children.indexOf(B),G=f.children.indexOf(F);return k-G}if(!B&&!F)return 0;if(!B)return-1;if(!F)return 1}),await Promise.all(_);let{width:w,height:C}=this.getContainerDimensions(f,p),M=x*w,P=v*C;p.pivot.x=M,p.pivot.y=P};layoutChildren({element:t,anchor:e,totalWidth:r,totalHeight:s,gap:o,direction:n,scroll:a}){let h=n==="horizontal",l=h?"x":"y",c=h?"y":"x",u=h?"width":"height",d=h?"height":"width",f=h?r:s,p=h?s:r,g=h?e.x:e.y,x=h?e.y:e.x;if(!a&&t[u]!==void 0&&t[u]<f){let _=0,y=0,T=0,E=0;(t.children||[]).forEach((w,C)=>{_>0&&_+w[u]>t[u]&&(this.alignRowElements(t.children.slice(E,C),l,g,t[u]),_=0,y+=T+o,T=0,E=C),w[l]=_,w[c]=y,_+=w[u],C<t.children.length-1&&(_+=o),T=Math.max(T,w[d]||0)}),E<t.children.length&&this.alignRowElements(t.children.slice(E),l,g,t[u])}else{if(g===0){let _=0;(t.children||[]).forEach((y,T)=>{let E=y[u]||0,w=h?y.anchorX||0:y.anchorY||0;y[l]=_+E*w,_+=E,T<t.children.length-1&&(_+=o)})}else if(g===1){let _=-f;(t.children||[]).forEach((y,T)=>{let E=y[u]||0,w=h?y.anchorX||0:y.anchorY||0;y[l]=_+E*w,_+=E,T<t.children.length-1&&(_+=o)})}else if(g===.5){let _=-f/2;(t.children||[]).forEach((y,T)=>{let E=y[u]||0,w=h?y.anchorX||0:y.anchorY||0;y[l]=_+E*w,_+=E,T<t.children.length-1&&(_+=o)})}x===0?(t.children||[]).forEach(_=>{let y=_[d]||0,T=h?_.anchorY||0:_.anchorX||0;_[c]=y*T}):x===.5?(t.children||[]).forEach(_=>{let y=_[d]||0,T=h?_.anchorY||0:_.anchorX||0;_[c]=-y/2+y*T}):x===1&&(t.children||[]).forEach(_=>{let y=_[d]||0,T=h?_.anchorY||0:_.anchorX||0;_[c]=-y+y*T})}}alignRowElements(t,e,r,s){if(!t.length)return;let o=t.reduce((n,a,h)=>n+a[e==="x"?"width":"height"]+(h>0,0),0);if(r===.5){let a=(s-o)/2;t.forEach(h=>{h[e]=a,a+=h[e==="x"?"width":"height"]+0})}else if(r===1){let a=s-o;t.forEach(h=>{h[e]=a,a+=h[e==="x"?"width":"height"]+0})}}createContainerGraphic(t,e,r,s){let o=new Qt().roundRect(0,0,e,r,1).fill(t.fill?t.fill.color:"transparent");return s.x===1&&(o.x-=t.width),s.x===.5&&(o.x-=t.width/2),s.y===1&&(o.y-=t.height),s.y===.5&&(o.y-=t.height/2),o}getContainerDimensions(t,e){let r=t.width||0,s=t.height||0;if(!t.direction&&(!t.width||!t.height)&&e.children&&e.children.length>0){let o=1/0,n=-1/0,a=1/0,h=-1/0;e.children.forEach(l=>{let c=l.x||0,u=l.y||0,d=l.width||0,f=l.height||0;o=Math.min(o,c),n=Math.max(n,c+d),a=Math.min(a,u),h=Math.max(h,u+f)}),t.width||(r=n-o,(isNaN(r)||!isFinite(r))&&(r=0)),t.height||(s=h-a,(isNaN(s)||!isFinite(s))&&(s=0))}return{width:r,height:s}}setupScrolling({container:t,element:e,totalHeight:r,totalWidth:s,eventHandler:o,sliderRef:n}){let a=e.scroll&&e.height&&r>e.height,h=e.scroll&&e.width&&s>e.width;if(a||h){let l=0,c=0,u=-r+e.height,d=-s+e.width,f=new Qt().rect(0,0,e.width||s,e.height||r).fill("red");t.mask=f,t.eventMode="static",t.addChild(f),t.on("wheel",p=>{if(a&&p.deltaY!==0&&(l-p.deltaY>0||l-p.deltaY<u||(l-=p.deltaY,t.y-=p.deltaY,f.y+=p.deltaY)),h&&(p.deltaX!==0||p.shiftKey&&p.deltaY!==0)){let g=p.deltaX!==0?p.deltaX:p.deltaY;if(c-g>0||c-g<d)return;c-=g,t.x-=g,f.x+=g}})}}};var tU={linear:i=>i},eU=(i,t,e,r)=>i+(t-i)*tU[r](e);function sR(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s of t){if(r==null)return e;r=r[s]}return r===void 0?e:r}function oR(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s=0;s<t.length-1;s++){let o=t[s];o in r||(r[o]={}),r=r[o]}return r[t[t.length-1]]=e,i}var rU=(i,t)=>{let e=[],r=0,s;i.forEach(({value:n,duration:a,easing:h,relative:l},c)=>{c===0?(s=n,e.push({time:r,value:n,easing:"linear"})):a!==void 0&&h!==void 0&&(r+=a,l?s=s+n:s=n,e.push({time:r,value:s,easing:h}))});let o=0;for(let n=0;n<e.length-1;n++){let{time:a,value:h,easing:l}=e[n],{time:c,value:u}=e[n+1];if(t>=a&&t<=c){let d=(t-a)/(c-a);o=eU(h,u,d,l);break}else t>c&&(o=u)}return o};function iU(i){return Math.max.apply(null,i)}var gx=class{static rendererName="pixi";rendererName="pixi";transitionType="keyframes";_transition=async(t,e,r,s)=>new Promise((o,n)=>{if(s?.aborted){n(new DOMException("Operation aborted","AbortError"));return}let{properties:a}=r,h=Array.isArray(a)?a:Object.entries(a).map(([x,v])=>({...v,property:x})),l=h.map(x=>x.keyframes.reduce((v,_)=>v+_.duration||0,0)),c=iU(l),u=0,d={};h.forEach(x=>{d[x.property]=sR(e,x.property)});let f=x=>{let v={};h.forEach(_=>{let y=[];_.initialValue!==void 0?y=[{value:_.initialValue,duration:0}]:y=[{value:d[_.property],duration:0}],y=y.concat(_.keyframes),oR(v,_.property,rU(y,x))}),h.forEach(_=>{let{property:y}=_;e&&!e.destroyed&&oR(e,y,sR(v,y))})},p=()=>{t.ticker.remove(g),f(c)};s&&s.addEventListener("abort",()=>{p(),n(new DOMException("Operation aborted","AbortError"))});let g=x=>{if(u+=x.deltaMS,u>=c){t.ticker.remove(g),o();return}f(u)};if(s?.aborted){p(),n(new DOMException("Operation aborted","AbortError"));return}t.ticker.add(g)});add=async(t,e,r,s)=>this._transition(t,e,r,s);remove=async(t,e,r,s)=>this._transition(t,e,r,s)};var xx=class{static rendererName="pixi";rendererName="pixi";rendererType="rect";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:h}=e,l=new Qt;l.label=o.id,l.interactiveChildren=!1,l.eventMode="none",o.x!==void 0&&(l.x=o.x),o.y!==void 0&&(l.y=o.y),o.alpha!==void 0&&(l.alpha=o.alpha),o.scaleX!==void 0&&(l.scale.x=o.scaleX),o.scaleY!==void 0&&(l.scale.y=o.scaleY),o.rotation!==void 0&&(l.rotation=o.rotation*Math.PI/180),o.cursor&&(l.cursor=o.cursor),o.pointerDown&&l.on("pointerdown",f=>{f.stopPropagation(),h&&h(o.pointerDown,{x:f.global.x,y:f.global.y})}),o.pointerUp&&l.on("pointerup",f=>{f.stopPropagation(),h&&h(o.pointerUp,{x:f.global.x,y:f.global.y})}),o.pointerMove&&l.on("pointermove",f=>{f.stopPropagation(),h&&h(o.pointerMove,{x:f.global.x,y:f.global.y})}),(o.cursor||o.pointerDown||o.pointerUp||o.pointerMove)&&(l.eventMode="static");let c=o.width,u=o.height;l.roundRect(0,0,c,u,o.radius??0),o.fill&&l.fill(o.fill),o.border&&l.stroke({width:o.border.width,color:o.border.color,alpha:o.border.alpha??1,alignment:o.border.alignment??1}),o.anchorX!==void 0&&(l.pivot.x=c*o.anchorX),o.anchorY!==void 0&&(l.pivot.y=u*o.anchorY),(o.clickEventName||o.rightClickEventName)&&h&&(l.eventMode="static",l.on("pointerup",f=>{f.stopPropagation(),f.button===0?h(o.clickEventName,o.clickEventPayload):f.button===2&&h(o.rightClickEventName,o.rightClickEventPayload)})),o.wheelEventName&&h&&(l.eventMode="static",l.on("wheel",f=>{f.stopPropagation(),h(o.wheelEventName,{deltaY:f.deltaY})}));let d=[];for(let f of n)if(f.elementId===o.id&&f.event===he.Add){let p=a(f.type);if(!p)throw new Error(`Transition class not found for type ${f.type}`);d.push(p.add(t,l,f,r))}s.addChild(l),await Promise.all(d)};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,h=s.getChildByName(o.id);if(!h)throw new Error(`Rect with id ${o.id} not found`);let l=[];for(let c of n)if(c.elementId===o.id&&c.event===he.Remove){let u=a(c.type);if(!u)throw new Error(`Transition class not found for type ${c.type}`);l.push(u.remove(t,h,c,r))}await Promise.all(l),h&&h.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a},h)=>{if(h?.aborted)throw new DOMException("Operation aborted","AbortError");let l=e.getChildByName(r.id);if(!l)throw new Error(`Rect with id ${r.id} not found`);let c=[];for(let u of o)if(u.elementId===r.id&&u.event===he.Update){let d=n(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);c.push(d.add(t,l,u,h))}if(c.length>0)await Promise.all(c),(r.width!==s.width||r.height!==s.height||r.fill!==s.fill)&&(l.clear(),l.rect(0,0,s.width,s.height),l.fill(s.fill)),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY);else{r.x!==void 0&&s.x!==r.x&&(l.x=s.x),r.y!==void 0&&s.y!==r.y&&(l.y=s.y),r.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),r.scaleX!==void 0&&s.scaleX!==r.scaleX&&(l.scale.x=s.scaleX),r.scaleY!==void 0&&s.scaleY!==r.scaleY&&(l.scale.y=s.scaleY),r.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180);let u=JSON.stringify(r.border)!==JSON.stringify(s.border);(r.width!==s.width||r.height!==s.height||r.radius!==s.radius||r.fill!==s.fill||u)&&(l.clear(),l.roundRect(0,0,s.width,s.height,s.radius??0),s.fill&&l.fill(s.fill),s.border&&l.stroke({width:s.border.width,color:s.border.color,alpha:s.border.alpha??1,alignment:s.border.alignment??1})),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY)}}};var _x=class extends Bi{static rendererName="pixi";rendererName="pixi";rendererType="slider";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o,eventHandler:n,ref:a})=>{let{direction:h,idleThumb:l,hoverThumb:c,idleBar:u,hoverBar:d,dragEndEventName:f,dragEventName:p,dragEventPayload:g,initialValue:x}=r,v={horizontal:{axis:"x",size:"width"},vertical:{axis:"y",size:"height"}},_=v[h].axis,y=v[h].size,T=I.from(l),E=I.from(c),w=I.from(u),C=I.from(d),M=new Zt({texture:w,anchor:{x:0,y:0}});M.label=r.id;let P=M[y];M.x=r.x||0,M.y=r.y||0;let S=new Zt({texture:T,anchor:{x:.5,y:.5}});if(S.y=M.height/2,S.x=M.width/2,S.eventMode="static",S.cursor="hover",M.eventMode="static",M.cursor="hover",S.on("pointerdown",F).on("pointerup",W).on("pointerupoutside",W),M.on("pointerdown",A).on("pointerup",B).on("pointerupoutside",B),M.addChild(S),x!==void 0){let G=S[y]/2;S[_]=x/100*(P-S[y])+G}function A(G){S.texture=E,M.texture=C,z(G),t.stage.eventMode="static",t.stage.addEventListener("pointermove",z)}function B(G){S.texture=T,M.texture=w,z(G),t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",z)}function F(G){G.stopPropagation(),S.texture=E,M.texture=C,t.stage.eventMode="static",t.stage.addEventListener("pointermove",z)}function W(G){if(S.texture=T,M.texture=w,t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",z),f){let N=M.toLocal(G.global)[_],O=S[y]/2;S[_]=Math.max(0+O,Math.min(N,P-O));let Y=Math.floor((S[_]-O)/(P-S[y])*100),lt=JSON.stringify(g);n&&n(f,JSON.parse(lt.replace('"{{ value }}"',String(Y))))}}function z(G){let N=M.toLocal(G.global)[_],O=S[y]/2;S[_]=Math.max(0+O,Math.min(N,P-O));let Y=Math.floor((S[_]-O)/(P-S[y])*100);if(p){let lt=JSON.stringify(g);n&&n(p,JSON.parse(lt.replace('"{{ value }}"',String(Y))))}return Y}a&&(a.current={updateValue:G=>{let N=S[y]/2;S[_]=G/100*(P-S[y])+N}});let k=[];for(let G of s)if(G.elementId===r.id&&G.event===he.Add){let N=o(G.type);if(!N)throw new Error(`Transition class not found for type ${G.type}`);k.push(N.add(t,M,G))}e.addChild(M),await Promise.all(k)};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Sprite with id ${s.id} not found`);return}let h=[];for(let l of o)if(l.elementId===s.id&&l.event===he.Remove){let c=n(l.type);if(!c)throw new Error(`Transition class not found for type ${l.type}`);h.push(c.remove(t,a,l))}await Promise.all(h),a.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>{if(!e.getChildByName(r.id)){console.warn(`Slider with id ${r.id} not found`,{parent:e});return}JSON.stringify(r)!==JSON.stringify(s)&&await Promise.all([this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n,eventHandler:a}),this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a})])}};var yx=class extends Bi{static rendererName="pixi";rendererName="pixi";rendererType="audio";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o})=>{r.delay?setTimeout(()=>{t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})},r.delay):t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})};remove=async(t,e)=>{let{element:r}=e;t.audioStage.remove(r.id)};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n})=>{if(r.url!==s.url||r.volume!==s.volume){let a=t.audioStage.getById(r.id);a&&(a.url=s.url,a.volume=s.volume??1)}}};var bx=class{constructor(){this.cache=new Map}async load(t){let e=[];for(let[r,s]of Object.entries(t))this.cache.has(r)||e.push([r,s]);e.length>0&&await Promise.all(e.map(async([r,s])=>{let a={buffer:await(await fetch(s.url)).arrayBuffer(),type:s.type};this.cache.set(r,a)}))}getBufferMap(){let t={};for(let[e,r]of this.cache.entries())t[e]=r;return t}clear(){this.cache.clear()}size(){return this.cache.size}has(t){return this.cache.has(t)}},sU=()=>new bx;var j_t=rR;export{Za as Application,sr as Assets,yx as AudioPlugin,mx as ContainerRendererPlugin,gx as KeyframeTransitionPlugin,xx as RectRendererPlugin,_x as SliderRendererPlugin,dx as SpriteRendererPlugin,fx as TextRendererPlugin,px as TextRevealingRendererPlugin,sU as createAssetBufferManager,j_t as default,jh as parse,jh as parseJSONToAST,Xh as renderApp};
|
|
1628
|
+
`))}}var L2=0,Vu={textureCount:0,uboCount:0},Ri=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=L2++}systemCheck(){if(!Ou())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 r=t.program,s=r.glPrograms[this.renderer.CONTEXT_UID]||this.generateProgram(t);return this.shader=t,this.program!==r&&(this.program=r,this.gl.useProgram(s.program)),e||(Vu.textureCount=0,Vu.uboCount=0,this.syncUniformGroup(t.uniformGroup,Vu)),s}setUniforms(t){let e=this.shader.program,r=e.glPrograms[this.renderer.CONTEXT_UID];e.syncUniforms(r.uniformData,t,this.renderer)}syncUniformGroup(t,e){let r=this.getGlProgram();(!t.static||t.dirtyId!==r.uniformDirtyGroups[t.id])&&(r.uniformDirtyGroups[t.id]=t.dirtyId,this.syncUniforms(t,r,e))}syncUniforms(t,e,r){(t.syncUniforms[this.shader.program.id]||this.createSyncGroups(t))(e.uniformData,t.uniforms,this.renderer,r)}createSyncGroups(t){let e=this.getSignature(t,this.shader.program.uniformData,"u");return this.cache[e]||(this.cache[e]=Vg(t,this.shader.program.uniformData)),t.syncUniforms[this.shader.program.id]=this.cache[e],t.syncUniforms[this.shader.program.id]}syncUniformBufferGroup(t,e){let r=this.getGlProgram();if(!t.static||t.dirtyId!==0||!r.uniformGroups[t.id]){t.dirtyId=0;let s=r.uniformGroups[t.id]||this.createSyncBufferGroup(t,r,e);t.buffer.update(),s(r.uniformData,t.uniforms,this.renderer,Vu,t.buffer)}this.renderer.buffer.bindBufferBase(t.buffer,r.uniformBufferBindings[e])}createSyncBufferGroup(t,e,r){let{gl:s}=this.renderer;this.renderer.buffer.bind(t.buffer);let o=this.gl.getUniformBlockIndex(e.program,r);e.uniformBufferBindings[r]=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]=Zg(t,this.shader.program.uniformData)),t.autoManage){let h=new Float32Array(a.size/4);t.buffer.update(h)}return e.uniformGroups[t.id]=a.syncFunc,e.uniformGroups[t.id]}getSignature(t,e,r){let s=t.uniforms,o=[`${r}-`];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,r=t.program,s=Kg(e,r);return r.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}};Ri.extension={type:$.RendererSystem,name:"shader"};Z.add(Ri);var ai=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(){}};ai.defaultOptions={hello:!1},ai.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"startup"};Z.add(ai);function DP(i,t=[]){return t[J.NORMAL]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.ADD]=[i.ONE,i.ONE],t[J.MULTIPLY]=[i.DST_COLOR,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SCREEN]=[i.ONE,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.OVERLAY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.DARKEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.LIGHTEN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.COLOR_DODGE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.COLOR_BURN]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.HARD_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SOFT_LIGHT]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.DIFFERENCE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.EXCLUSION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.HUE]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SATURATION]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.COLOR]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.LUMINOSITY]=[i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.NONE]=[0,0],t[J.NORMAL_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_ALPHA,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.ADD_NPM]=[i.SRC_ALPHA,i.ONE,i.ONE,i.ONE],t[J.SCREEN_NPM]=[i.SRC_ALPHA,i.ONE_MINUS_SRC_COLOR,i.ONE,i.ONE_MINUS_SRC_ALPHA],t[J.SRC_IN]=[i.DST_ALPHA,i.ZERO],t[J.SRC_OUT]=[i.ONE_MINUS_DST_ALPHA,i.ZERO],t[J.SRC_ATOP]=[i.DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[J.DST_OVER]=[i.ONE_MINUS_DST_ALPHA,i.ONE],t[J.DST_IN]=[i.ZERO,i.SRC_ALPHA],t[J.DST_OUT]=[i.ZERO,i.ONE_MINUS_SRC_ALPHA],t[J.DST_ATOP]=[i.ONE_MINUS_DST_ALPHA,i.SRC_ALPHA],t[J.XOR]=[i.ONE_MINUS_DST_ALPHA,i.ONE_MINUS_SRC_ALPHA],t[J.SUBTRACT]=[i.ONE,i.ONE,i.ONE,i.ONE,i.FUNC_REVERSE_SUBTRACT,i.FUNC_ADD],t}var H2=0,V2=1,W2=2,z2=3,$2=4,X2=5,LP=class Qg{constructor(){this.gl=null,this.stateId=0,this.polygonOffset=0,this.blendMode=J.NONE,this._blendEq=!1,this.map=[],this.map[H2]=this.setBlend,this.map[V2]=this.setOffset,this.map[W2]=this.setCullFace,this.map[z2]=this.setDepthTest,this.map[$2]=this.setFrontFace,this.map[X2]=this.setDepthMask,this.checks=[],this.defaultState=new Or,this.defaultState.blend=!0}contextChange(t){this.gl=t,this.blendModes=DP(t),this.set(this.defaultState),this.reset()}set(t){if(t=t||this.defaultState,this.stateId!==t.data){let e=this.stateId^t.data,r=0;for(;e;)e&1&&this.map[r].call(this,!!(t.data&1<<r)),e=e>>1,r++;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(Qg.checkBlendMode,t),this.gl[t?"enable":"disable"](this.gl.BLEND)}setOffset(t){this.updateCheck(Qg.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],r=this.gl;e.length===2?r.blendFunc(e[0],e[1]):r.blendFuncSeparate(e[0],e[1],e[2],e[3]),e.length===6?(this._blendEq=!0,r.blendEquationSeparate(e[4],e[5])):this._blendEq&&(this._blendEq=!1,r.blendEquationSeparate(r.FUNC_ADD,r.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 r=this.checks.indexOf(t);e&&r===-1?this.checks.push(t):!e&&r!==-1&&this.checks.splice(r,1)}static checkBlendMode(t,e){t.setBlendMode(e.blendMode)}static checkPolygonOffset(t,e){t.setPolygonOffset(1,e.polygonOffset)}destroy(){this.gl=null}};LP.extension={type:$.RendererSystem,name:"state"};var Jg=LP;Z.add(Jg);var en=class extends hs.default{constructor(){super(...arguments),this.runners={},this._systemsHash={}}setup(t){this.addRunners(...t.runners);let e=(t.priority??[]).filter(s=>t.systems[s]),r=[...e,...Object.keys(t.systems).filter(s=>!e.includes(s))];for(let s of r)this.addSystem(t.systems[s],s)}addRunners(...t){t.forEach(e=>{this.runners[e]=new Vt(e)})}addSystem(t,e){let r=new t(this);if(this[e])throw new Error(`Whoops! The name "${e}" is already in use`);this[e]=r,this._systemsHash[e]=r;for(let s in this.runners)this.runners[s].add(r);return this}emitWithCustomOptions(t,e){let r=Object.keys(this._systemsHash);t.items.forEach(s=>{let o=r.find(n=>this._systemsHash[n]===s);s[t.name](e[o])})}destroy(){Object.values(this.runners).forEach(t=>{t.destroy()}),this._systemsHash={}}};var kh=class Wu{constructor(t){this.renderer=t,this.count=0,this.checkCount=0,this.maxIdle=Wu.defaultMaxIdle,this.checkCountMax=Wu.defaultCheckCountMax,this.mode=Wu.defaultMode}postrender(){this.renderer.objectRenderer.renderingToScreen&&(this.count++,this.mode!==ru.MANUAL&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let t=this.renderer.texture,e=t.managedTextures,r=!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,r=!0)}if(r){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,r=t._texture;r&&!r.framebuffer&&e.destroyTexture(r);for(let s=t.children.length-1;s>=0;s--)this.unload(t.children[s])}destroy(){this.renderer=null}};kh.defaultMode=ru.AUTO,kh.defaultMaxIdle=60*60,kh.defaultCheckCountMax=60*10,kh.extension={type:$.RendererSystem,name:"textureGC"};var Lr=kh;Z.add(Lr);var vs=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=st.UNSIGNED_BYTE,this.internalFormat=L.RGBA,this.samplerType=0}};function HP(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[i.RGB]:V.FLOAT,[i.RGBA]:V.FLOAT,[i.ALPHA]:V.FLOAT,[i.LUMINANCE]:V.FLOAT,[i.LUMINANCE_ALPHA]:V.FLOAT,[i.R8]:V.FLOAT,[i.R8_SNORM]:V.FLOAT,[i.RG8]:V.FLOAT,[i.RG8_SNORM]:V.FLOAT,[i.RGB8]:V.FLOAT,[i.RGB8_SNORM]:V.FLOAT,[i.RGB565]:V.FLOAT,[i.RGBA4]:V.FLOAT,[i.RGB5_A1]:V.FLOAT,[i.RGBA8]:V.FLOAT,[i.RGBA8_SNORM]:V.FLOAT,[i.RGB10_A2]:V.FLOAT,[i.RGB10_A2UI]:V.FLOAT,[i.SRGB8]:V.FLOAT,[i.SRGB8_ALPHA8]:V.FLOAT,[i.R16F]:V.FLOAT,[i.RG16F]:V.FLOAT,[i.RGB16F]:V.FLOAT,[i.RGBA16F]:V.FLOAT,[i.R32F]:V.FLOAT,[i.RG32F]:V.FLOAT,[i.RGB32F]:V.FLOAT,[i.RGBA32F]:V.FLOAT,[i.R11F_G11F_B10F]:V.FLOAT,[i.RGB9_E5]:V.FLOAT,[i.R8I]:V.INT,[i.R8UI]:V.UINT,[i.R16I]:V.INT,[i.R16UI]:V.UINT,[i.R32I]:V.INT,[i.R32UI]:V.UINT,[i.RG8I]:V.INT,[i.RG8UI]:V.UINT,[i.RG16I]:V.INT,[i.RG16UI]:V.UINT,[i.RG32I]:V.INT,[i.RG32UI]:V.UINT,[i.RGB8I]:V.INT,[i.RGB8UI]:V.UINT,[i.RGB16I]:V.INT,[i.RGB16UI]:V.UINT,[i.RGB32I]:V.INT,[i.RGB32UI]:V.UINT,[i.RGBA8I]:V.INT,[i.RGBA8UI]:V.UINT,[i.RGBA16I]:V.INT,[i.RGBA16UI]:V.UINT,[i.RGBA32I]:V.INT,[i.RGBA32UI]:V.UINT,[i.DEPTH_COMPONENT16]:V.FLOAT,[i.DEPTH_COMPONENT24]:V.FLOAT,[i.DEPTH_COMPONENT32F]:V.FLOAT,[i.DEPTH_STENCIL]:V.FLOAT,[i.DEPTH24_STENCIL8]:V.FLOAT,[i.DEPTH32F_STENCIL8]:V.FLOAT}:t={[i.RGB]:V.FLOAT,[i.RGBA]:V.FLOAT,[i.ALPHA]:V.FLOAT,[i.LUMINANCE]:V.FLOAT,[i.LUMINANCE_ALPHA]:V.FLOAT,[i.DEPTH_STENCIL]:V.FLOAT},t}function VP(i){let t;return"WebGL2RenderingContext"in globalThis&&i instanceof globalThis.WebGL2RenderingContext?t={[st.UNSIGNED_BYTE]:{[L.RGBA]:i.RGBA8,[L.RGB]:i.RGB8,[L.RG]:i.RG8,[L.RED]:i.R8,[L.RGBA_INTEGER]:i.RGBA8UI,[L.RGB_INTEGER]:i.RGB8UI,[L.RG_INTEGER]:i.RG8UI,[L.RED_INTEGER]:i.R8UI,[L.ALPHA]:i.ALPHA,[L.LUMINANCE]:i.LUMINANCE,[L.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[st.BYTE]:{[L.RGBA]:i.RGBA8_SNORM,[L.RGB]:i.RGB8_SNORM,[L.RG]:i.RG8_SNORM,[L.RED]:i.R8_SNORM,[L.RGBA_INTEGER]:i.RGBA8I,[L.RGB_INTEGER]:i.RGB8I,[L.RG_INTEGER]:i.RG8I,[L.RED_INTEGER]:i.R8I},[st.UNSIGNED_SHORT]:{[L.RGBA_INTEGER]:i.RGBA16UI,[L.RGB_INTEGER]:i.RGB16UI,[L.RG_INTEGER]:i.RG16UI,[L.RED_INTEGER]:i.R16UI,[L.DEPTH_COMPONENT]:i.DEPTH_COMPONENT16},[st.SHORT]:{[L.RGBA_INTEGER]:i.RGBA16I,[L.RGB_INTEGER]:i.RGB16I,[L.RG_INTEGER]:i.RG16I,[L.RED_INTEGER]:i.R16I},[st.UNSIGNED_INT]:{[L.RGBA_INTEGER]:i.RGBA32UI,[L.RGB_INTEGER]:i.RGB32UI,[L.RG_INTEGER]:i.RG32UI,[L.RED_INTEGER]:i.R32UI,[L.DEPTH_COMPONENT]:i.DEPTH_COMPONENT24},[st.INT]:{[L.RGBA_INTEGER]:i.RGBA32I,[L.RGB_INTEGER]:i.RGB32I,[L.RG_INTEGER]:i.RG32I,[L.RED_INTEGER]:i.R32I},[st.FLOAT]:{[L.RGBA]:i.RGBA32F,[L.RGB]:i.RGB32F,[L.RG]:i.RG32F,[L.RED]:i.R32F,[L.DEPTH_COMPONENT]:i.DEPTH_COMPONENT32F},[st.HALF_FLOAT]:{[L.RGBA]:i.RGBA16F,[L.RGB]:i.RGB16F,[L.RG]:i.RG16F,[L.RED]:i.R16F},[st.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:i.RGB565},[st.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:i.RGBA4},[st.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:i.RGB5_A1},[st.UNSIGNED_INT_2_10_10_10_REV]:{[L.RGBA]:i.RGB10_A2,[L.RGBA_INTEGER]:i.RGB10_A2UI},[st.UNSIGNED_INT_10F_11F_11F_REV]:{[L.RGB]:i.R11F_G11F_B10F},[st.UNSIGNED_INT_5_9_9_9_REV]:{[L.RGB]:i.RGB9_E5},[st.UNSIGNED_INT_24_8]:{[L.DEPTH_STENCIL]:i.DEPTH24_STENCIL8},[st.FLOAT_32_UNSIGNED_INT_24_8_REV]:{[L.DEPTH_STENCIL]:i.DEPTH32F_STENCIL8}}:t={[st.UNSIGNED_BYTE]:{[L.RGBA]:i.RGBA,[L.RGB]:i.RGB,[L.ALPHA]:i.ALPHA,[L.LUMINANCE]:i.LUMINANCE,[L.LUMINANCE_ALPHA]:i.LUMINANCE_ALPHA},[st.UNSIGNED_SHORT_5_6_5]:{[L.RGB]:i.RGB},[st.UNSIGNED_SHORT_4_4_4_4]:{[L.RGBA]:i.RGBA},[st.UNSIGNED_SHORT_5_5_5_1]:{[L.RGBA]:i.RGBA}},t}var rn=class{constructor(t){this.renderer=t,this.boundTextures=[],this.currentLocation=-1,this.managedTextures=[],this._unknownBoundTextures=!1,this.unknownTexture=new ut,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=VP(t),this.samplerTypes=HP(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 r=new vs(t.createTexture());t.bindTexture(t.TEXTURE_2D,r.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]=r,this.emptyTextures[t.TEXTURE_CUBE_MAP]=new vs(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:r}=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,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(t.target,s.texture)),s.dirtyId!==t.dirtyId?(this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),this.updateTexture(t)):s.dirtyStyleId!==t.dirtyStyleId&&this.updateTextureStyle(t),this.boundTextures[e]=t}else this.currentLocation!==e&&(this.currentLocation=e,r.activeTexture(r.TEXTURE0+e)),r.bindTexture(r.TEXTURE_2D,this.emptyTextures[r.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:r}=this;if(this._unknownBoundTextures){this._unknownBoundTextures=!1;for(let s=0;s<r.length;s++)r[s]===this.unknownTexture&&this.bind(null,s)}for(let s=0;s<r.length;s++)r[s]===t&&(this.currentLocation!==s&&(e.activeTexture(e.TEXTURE0+s),this.currentLocation=s),e.bindTexture(t.target,this.emptyTextures[t.target].texture),r[s]=null)}ensureSamplerType(t){let{boundTextures:e,hasIntegerTextures:r,CONTEXT_UID:s}=this;if(r)for(let o=t-1;o>=0;--o){let n=e[o];n&&n._glTextures[s].samplerType!==V.FLOAT&&this.renderer.texture.unbind(n)}}initTexture(t){let e=new vs(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]??V.FLOAT,this.webGLVersion===2&&t.type===st.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 r=this.renderer;if(this.initTextureType(t,e),t.resource?.upload(r,t,e))e.samplerType!==V.FLOAT&&(this.hasIntegerTextures=!0);else{let s=t.realWidth,o=t.realHeight,n=r.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:r}=this;if(t=t.castToBaseTexture(),t._glTextures[this.CONTEXT_UID]&&(this.unbind(t),r.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&&Pg(this.managedTextures,s,1)}}updateTextureStyle(t){let e=t._glTextures[this.CONTEXT_UID];e&&((t.mipmap===xr.POW2||this.webGLVersion!==2)&&!t.isPowerOfTwo?e.mipmap=!1:e.mipmap=t.mipmap>=1,this.webGLVersion!==2&&!t.isPowerOfTwo?e.wrapMode=th.CLAMP:e.wrapMode=t.wrapMode,t.resource?.style(this.renderer,t,e)||this.setStyle(t,e),e.dirtyStyleId=t.dirtyStyleId)}setStyle(t,e){let r=this.gl;if(e.mipmap&&t.mipmap!==xr.ON_MANUAL&&r.generateMipmap(t.target),r.texParameteri(t.target,r.TEXTURE_WRAP_S,e.wrapMode),r.texParameteri(t.target,r.TEXTURE_WRAP_T,e.wrapMode),e.mipmap){r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===or.LINEAR?r.LINEAR_MIPMAP_LINEAR:r.NEAREST_MIPMAP_NEAREST);let s=this.renderer.context.extensions.anisotropicFiltering;if(s&&t.anisotropicLevel>0&&t.scaleMode===or.LINEAR){let o=Math.min(t.anisotropicLevel,r.getParameter(s.MAX_TEXTURE_MAX_ANISOTROPY_EXT));r.texParameterf(t.target,s.TEXTURE_MAX_ANISOTROPY_EXT,o)}}else r.texParameteri(t.target,r.TEXTURE_MIN_FILTER,t.scaleMode===or.LINEAR?r.LINEAR:r.NEAREST);r.texParameteri(t.target,r.TEXTURE_MAG_FILTER,t.scaleMode===or.LINEAR?r.LINEAR:r.NEAREST)}destroy(){this.renderer=null}};rn.extension={type:$.RendererSystem,name:"texture"};Z.add(rn);var sn=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:r}=this,s=t._glTransformFeedbacks[r]||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:r,renderer:s}=this;e&&s.shader.bind(e),r.beginTransformFeedback(t)}endTransformFeedback(){let{gl:t}=this;t.endTransformFeedback()}createGLTransformFeedback(t){let{gl:e,renderer:r,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&&(r.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 r=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 h=a._glBuffers[this.CONTEXT_UID];h&&(h.refCount--,h.refCount===0&&!e&&o.dispose(a,e))}r&&(e||s.deleteTransformFeedback(r),delete t._glTransformFeedbacks[this.CONTEXT_UID])}destroy(){this.renderer=null}};sn.extension={type:$.RendererSystem,name:"transformFeedback"};Z.add(sn);var hi=class{constructor(t){this.renderer=t}init(t){this.screen=new pt(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 r=this.element.width/this.resolution,s=this.element.height/this.resolution;this.screen.width=r,this.screen.height=s,this.autoDensity&&(this.element.style.width=`${r}px`,this.element.style.height=`${s}px`),this.renderer.emit("resize",r,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}};hi.defaultOptions={width:800,height:600,resolution:void 0,autoDensity:!1},hi.extension={type:[$.RendererSystem,$.CanvasRendererSystem],name:"_view"};Z.add(hi);K.PREFER_ENV=We.WEBGL2;K.STRICT_TEXTURE_CACHE=!1;K.RENDER_OPTIONS={...ni.defaultOptions,...oi.defaultOptions,...hi.defaultOptions,...ai.defaultOptions};Object.defineProperties(K,{WRAP_MODE:{get(){return ut.defaultOptions.wrapMode},set(i){ht("7.1.0","settings.WRAP_MODE is deprecated, use BaseTexture.defaultOptions.wrapMode"),ut.defaultOptions.wrapMode=i}},SCALE_MODE:{get(){return ut.defaultOptions.scaleMode},set(i){ht("7.1.0","settings.SCALE_MODE is deprecated, use BaseTexture.defaultOptions.scaleMode"),ut.defaultOptions.scaleMode=i}},MIPMAP_TEXTURES:{get(){return ut.defaultOptions.mipmap},set(i){ht("7.1.0","settings.MIPMAP_TEXTURES is deprecated, use BaseTexture.defaultOptions.mipmap"),ut.defaultOptions.mipmap=i}},ANISOTROPIC_LEVEL:{get(){return ut.defaultOptions.anisotropicLevel},set(i){ht("7.1.0","settings.ANISOTROPIC_LEVEL is deprecated, use BaseTexture.defaultOptions.anisotropicLevel"),ut.defaultOptions.anisotropicLevel=i}},FILTER_RESOLUTION:{get(){return ht("7.1.0","settings.FILTER_RESOLUTION is deprecated, use Filter.defaultResolution"),Dr.defaultResolution},set(i){Dr.defaultResolution=i}},FILTER_MULTISAMPLE:{get(){return ht("7.1.0","settings.FILTER_MULTISAMPLE is deprecated, use Filter.defaultMultisample"),Dr.defaultMultisample},set(i){Dr.defaultMultisample=i}},SPRITE_MAX_TEXTURES:{get(){return si.defaultMaxTextures},set(i){ht("7.1.0","settings.SPRITE_MAX_TEXTURES is deprecated, use BatchRenderer.defaultMaxTextures"),si.defaultMaxTextures=i}},SPRITE_BATCH_SIZE:{get(){return si.defaultBatchSize},set(i){ht("7.1.0","settings.SPRITE_BATCH_SIZE is deprecated, use BatchRenderer.defaultBatchSize"),si.defaultBatchSize=i}},CAN_UPLOAD_SAME_BUFFER:{get(){return si.canUploadSameBuffer},set(i){ht("7.1.0","settings.CAN_UPLOAD_SAME_BUFFER is deprecated, use BatchRenderer.canUploadSameBuffer"),si.canUploadSameBuffer=i}},GC_MODE:{get(){return Lr.defaultMode},set(i){ht("7.1.0","settings.GC_MODE is deprecated, use TextureGCSystem.defaultMode"),Lr.defaultMode=i}},GC_MAX_IDLE:{get(){return Lr.defaultMaxIdle},set(i){ht("7.1.0","settings.GC_MAX_IDLE is deprecated, use TextureGCSystem.defaultMaxIdle"),Lr.defaultMaxIdle=i}},GC_MAX_CHECK_COUNT:{get(){return Lr.defaultCheckCountMax},set(i){ht("7.1.0","settings.GC_MAX_CHECK_COUNT is deprecated, use TextureGCSystem.defaultCheckCountMax"),Lr.defaultCheckCountMax=i}},PRECISION_VERTEX:{get(){return hr.defaultVertexPrecision},set(i){ht("7.1.0","settings.PRECISION_VERTEX is deprecated, use Program.defaultVertexPrecision"),hr.defaultVertexPrecision=i}},PRECISION_FRAGMENT:{get(){return hr.defaultFragmentPrecision},set(i){ht("7.1.0","settings.PRECISION_FRAGMENT is deprecated, use Program.defaultFragmentPrecision"),hr.defaultFragmentPrecision=i}}});var Ts=(i=>(i[i.INTERACTION=50]="INTERACTION",i[i.HIGH=25]="HIGH",i[i.NORMAL=0]="NORMAL",i[i.LOW=-25]="LOW",i[i.UTILITY=-50]="UTILITY",i))(Ts||{});var on=class{constructor(t,e=null,r=0,s=!1){this.next=null,this.previous=null,this._destroyed=!1,this.fn=t,this.context=e,this.priority=r,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 WP=class Ye{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 on(null,null,1/0),this.deltaMS=1/Ye.targetFPMS,this.elapsedMS=1/Ye.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,r=Ts.NORMAL){return this._addListener(new on(t,e,r))}addOnce(t,e,r=Ts.NORMAL){return this._addListener(new on(t,e,r,!0))}_addListener(t){let e=this._head.next,r=this._head;if(!e)t.connect(r);else{for(;e;){if(t.priority>e.priority){t.connect(r);break}r=e,e=e.next}t.previous||t.connect(r)}return this._startIfPossible(),this}remove(t,e){let r=this._head.next;for(;r;)r.match(t,e)?r=r.destroy():r=r.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*Ye.targetFPMS;let r=this._head,s=r.next;for(;s;)s=s.emit(this.deltaTime);r.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),r=Math.min(Math.max(0,e)/1e3,Ye.targetFPMS);this._maxElapsedMS=1/r}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(!Ye._shared){let t=Ye._shared=new Ye;t.autoStart=!0,t._protected=!0}return Ye._shared}static get system(){if(!Ye._system){let t=Ye._system=new Ye;t.autoStart=!0,t._protected=!0}return Ye._system}};WP.targetFPMS=.06;var lr=WP;Object.defineProperties(K,{TARGET_FPMS:{get(){return lr.targetFPMS},set(i){ht("7.1.0","settings.TARGET_FPMS is deprecated, use Ticker.targetFPMS"),lr.targetFPMS=i}}});var Oh=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,Ts.LOW)},get(){return this._ticker}}),this.stop=()=>{this._ticker.stop()},this.start=()=>{this._ticker.start()},this._ticker=null,this.ticker=t.sharedTicker?lr.shared:new lr,t.autoStart&&this.start()}static destroy(){if(this._ticker){let t=this._ticker;this.ticker=null,t.destroy()}}};Oh.extension=$.Application;Z.add(Oh);var j2=[];Z.handleByList($.Renderer,j2);var Nh=class{constructor(t){this.renderer=t}contextChange(t){let e;if(this.renderer.context.webGLVersion===1){let r=t.getParameter(t.FRAMEBUFFER_BINDING);t.bindFramebuffer(t.FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.FRAMEBUFFER,r)}else{let r=t.getParameter(t.DRAW_FRAMEBUFFER_BINDING);t.bindFramebuffer(t.DRAW_FRAMEBUFFER,null),e=t.getParameter(t.SAMPLES),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,r)}e>=wt.HIGH?this.multisample=wt.HIGH:e>=wt.MEDIUM?this.multisample=wt.MEDIUM:e>=wt.LOW?this.multisample=wt.LOW:this.multisample=wt.NONE}destroy(){}};Nh.extension={type:$.RendererSystem,name:"_multisample"};Z.add(Nh);var zu=class{constructor(t){this.buffer=t||null,this.updateID=-1,this.byteLength=-1,this.refCount=0}};var Dh=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:r}=this,s=t._glBuffers[r]||this.createGLBuffer(t);e.bindBuffer(t.type,s.buffer)}unbind(t){let{gl:e}=this;e.bindBuffer(t,null)}bindBufferBase(t,e){let{gl:r,CONTEXT_UID:s}=this;if(this.boundBufferBases[e]!==t){let o=t._glBuffers[s]||this.createGLBuffer(t);this.boundBufferBases[e]=t,r.bindBufferBase(r.UNIFORM_BUFFER,e,o.buffer)}}bindBufferRange(t,e,r){let{gl:s,CONTEXT_UID:o}=this;r=r||0;let n=t._glBuffers[o]||this.createGLBuffer(t);s.bindBufferRange(s.UNIFORM_BUFFER,e||0,n.buffer,r*256,256)}update(t){let{gl:e,CONTEXT_UID:r}=this,s=t._glBuffers[r]||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 r=t._glBuffers[this.CONTEXT_UID],s=this.gl;t.disposeRunner.remove(this),r&&(e||s.deleteBuffer(r.buffer),delete t._glBuffers[this.CONTEXT_UID])}disposeAll(t){let e=Object.keys(this.managedBuffers);for(let r=0;r<e.length;r++)this.dispose(this.managedBuffers[e[r]],t)}createGLBuffer(t){let{CONTEXT_UID:e,gl:r}=this;return t._glBuffers[e]=new zu(r.createBuffer()),this.managedBuffers[t.id]=t,t.disposeRunner.add(this),t._glBuffers[e]}};Dh.extension={type:$.RendererSystem,name:"buffer"};Z.add(Dh);var Lh=class{constructor(t){this.renderer=t}render(t,e){let r=this.renderer,s,o,n,a;if(e&&(s=e.renderTexture,o=e.clear,n=e.transform,a=e.skipUpdateTransform),this.renderingToScreen=!s,r.runners.prerender.emit(),r.emit("prerender"),r.projection.transform=n,!r.context.isLost){if(s||(this.lastObjectRendered=t),!a){let h=t.enableTempParent();t.updateTransform(),t.disableTempParent(h)}r.renderTexture.bind(s),r.batch.currentRenderer.start(),(o??r.background.clearBeforeRender)&&r.renderTexture.clear(),t.render(r),r.batch.currentRenderer.flush(),s&&(e.blit&&r.framebuffer.blit(),s.baseTexture.update()),r.runners.postrender.emit(),r.projection.transform=null,r.emit("postrender")}}destroy(){this.renderer=null,this.lastObjectRendered=null}};Lh.extension={type:$.RendererSystem,name:"objectRenderer"};Z.add(Lh);var $u=class tx extends en{constructor(t){super(),this.type=Wm.WEBGL,t=Object.assign({},K.RENDER_OPTIONS,t),this.gl=null,this.CONTEXT_UID=0,this.globalUniforms=new je({projectionMatrix:new Ct},!0);let e={runners:["init","destroy","contextChange","resolutionChange","reset","update","postrender","prerender","resize"],systems:tx.__systems,priority:["_view","textureGenerator","background","_plugin","startup","context","state","texture","buffer","geometry","framebuffer","transformFeedback","mask","scissor","stencil","projection","textureGC","filter","renderTexture","batch","objectRenderer","_multisample"]};this.setup(e),"useContextAlpha"in t&&(ht("7.0.0","options.useContextAlpha is deprecated, use options.premultipliedAlpha and options.backgroundAlpha instead"),t.premultipliedAlpha=t.useContextAlpha&&t.useContextAlpha!=="notMultiplied",t.backgroundAlpha=t.useContextAlpha===!1?1:t.backgroundAlpha),this._plugin.rendererPlugins=tx.__plugins,this.options=t,this.startup.run(this.options)}static test(t){return t?.forceCanvas?!1:Ag()}render(t,e){this.objectRenderer.render(t,e)}resize(t,e){this._view.resizeView(t,e)}reset(){return this.runners.reset.emit(),this}clear(){this.renderTexture.bind(),this.renderTexture.clear()}destroy(t=!1){this.runners.destroy.items.reverse(),this.emitWithCustomOptions(this.runners.destroy,{_view:t}),super.destroy()}get plugins(){return this._plugin.plugins}get multisample(){return this._multisample.multisample}get width(){return this._view.element.width}get height(){return this._view.element.height}get resolution(){return this._view.resolution}set resolution(t){this._view.resolution=t,this.runners.resolutionChange.emit(t)}get autoDensity(){return this._view.autoDensity}get view(){return this._view.element}get screen(){return this._view.screen}get lastObjectRendered(){return this.objectRenderer.lastObjectRendered}get renderingToScreen(){return this.objectRenderer.renderingToScreen}get rendererLogId(){return`WebGL ${this.context.webGLVersion}`}get clearBeforeRender(){return ht("7.0.0","renderer.clearBeforeRender has been deprecated, please use renderer.background.clearBeforeRender instead."),this.background.clearBeforeRender}get useContextAlpha(){return ht("7.0.0","renderer.useContextAlpha has been deprecated, please use renderer.context.premultipliedAlpha instead."),this.context.useContextAlpha}get preserveDrawingBuffer(){return ht("7.0.0","renderer.preserveDrawingBuffer has been deprecated, we cannot truly know this unless pixi created the context"),this.context.preserveDrawingBuffer}get backgroundColor(){return ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color}set backgroundColor(t){ht("7.0.0","renderer.backgroundColor has been deprecated, use renderer.background.color instead."),this.background.color=t}get backgroundAlpha(){return ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha}set backgroundAlpha(t){ht("7.0.0","renderer.backgroundAlpha has been deprecated, use renderer.background.alpha instead."),this.background.alpha=t}get powerPreference(){return ht("7.0.0","renderer.powerPreference has been deprecated, we can only know this if pixi creates the context"),this.context.powerPreference}generateTexture(t,e){return this.textureGenerator.generateTexture(t,e)}};$u.extension={type:$.Renderer,priority:1},$u.__plugins={},$u.__systems={};var Xu=$u;Z.handleByMap($.RendererPlugin,Xu.__plugins);Z.handleByMap($.RendererSystem,Xu.__systems);Z.add(Xu);var Mi=class extends Xe{constructor(t,e){let{width:r,height:s}=e||{};super(r,s),this.items=[],this.itemDirtyIds=[];for(let o=0;o<t;o++){let n=new ut;this.items.push(n),this.itemDirtyIds.push(-2)}this.length=t,this._load=null,this.baseTexture=null}initFromArray(t,e){for(let r=0;r<this.length;r++)t[r]&&(t[r].castToBaseTexture?this.addBaseTextureAt(t[r].castToBaseTexture(),r):t[r]instanceof Xe?this.addResourceAt(t[r],r):this.addResourceAt(Do(t[r],e),r))}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:r}=this.items[0];return this.resize(e,r),this.update(),Promise.resolve(this)}),this._load}};var Hh=class extends Mi{constructor(t,e){let{width:r,height:s}=e||{},o,n;Array.isArray(t)?(o=t,n=t.length):n=t,super(n,{width:r,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=Jr.TEXTURE_2D_ARRAY}upload(t,e,r){let{length:s,itemDirtyIds:o,items:n}=this,{gl:a}=t;r.dirtyId<0&&a.texImage3D(a.TEXTURE_2D_ARRAY,0,r.internalFormat,this._width,this._height,s,0,e.format,r.type,null);for(let h=0;h<s;h++){let l=n[h];o[h]<l.dirtyId&&(o[h]=l.dirtyId,l.valid&&a.texSubImage3D(a.TEXTURE_2D_ARRAY,0,0,0,h,l.resource.width,l.resource.height,1,e.format,r.type,l.resource.source))}return!0}};var Vh=class extends te{constructor(t){super(t)}static test(t){let{OffscreenCanvas:e}=globalThis;return e&&t instanceof e?!0:globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement}};var zP=class Wh extends Mi{constructor(t,e){let{width:r,height:s,autoLoad:o,linkBaseTexture:n}=e||{};if(t&&t.length!==Wh.SIDES)throw new Error(`Invalid length. Got ${t.length}, expected 6`);super(6,{width:r,height:s});for(let a=0;a<Wh.SIDES;a++)this.items[a].target=Jr.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=Jr.TEXTURE_CUBE_MAP}addBaseTextureAt(t,e,r){if(r===void 0&&(r=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=Jr.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,r){let s=this.itemDirtyIds;for(let o=0;o<Wh.SIDES;o++){let n=this.items[o];(s[o]<n.dirtyId||r.dirtyId<e.dirtyId)&&(n.valid&&n.resource?(n.resource.upload(t,n,r),s[o]=n.dirtyId):s[o]<-1&&(t.gl.texImage2D(n.target,0,r.internalFormat,e.realWidth,e.realHeight,0,e.format,r.type,null),s[o]=-1))}return!0}static test(t){return Array.isArray(t)&&t.length===Wh.SIDES}};zP.SIDES=6;var ex=zP;var zh=class i extends te{constructor(t,e){e=e||{};let r,s,o;typeof t=="string"?(r=i.EMPTY,s=t,o=!0):(r=t,s=null,o=!1),super(r),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 r=await K.ADAPTER.fetch(this.url,{mode:this.crossOrigin?"cors":"no-cors"});if(this.destroyed)return;let s=await r.blob();if(this.destroyed)return;let o=await createImageBitmap(s,{premultiplyAlpha:this.alphaMode===null||this.alphaMode===ze.UNPACK?"premultiply":"none"});if(this.destroyed){o.close();return}this.source=o,this.update(),t(this)}catch(r){if(this.destroyed)return;e(r),this.onError.emit(r)}}),this._load)}upload(t,e,r){return this.source instanceof ImageBitmap?(typeof this.alphaMode=="number"&&(e.alphaMode=this.alphaMode),super.upload(t,e,r)):(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 i._EMPTY=i._EMPTY??K.ADAPTER.createCanvas(0,0),i._EMPTY}};var rx=class ju extends te{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)},ju.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;te.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,r=t.height;if(!e||!r)throw new Error("The SVG image must have width and height defined (in pixels), canvas API needs them.");let s=e*this.scale,o=r*this.scale;(this._overrideWidth||this._overrideHeight)&&(s=this._overrideWidth||this._overrideHeight/r*e,o=this._overrideHeight||this._overrideWidth/e*r),s=Math.round(s),o=Math.round(o);let n=this.source;n.width=s,n.height=o,n._pixiId=`canvas_${ei()}`,n.getContext("2d").drawImage(t,0,0,e,r,0,0,s,o),this._resolve(),this._resolve=null}}static getSize(t){let e=ju.SVG_SIZE.exec(t),r={};return e&&(r[e[1]]=Math.round(parseFloat(e[3])),r[e[5]]=Math.round(parseFloat(e[7]))),r}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"&&ju.SVG_XML.test(t)}};rx.SVG_XML=/^(<\?xml[^?]+\?>)?\s*(<!--[^(-->)]*-->)?\s*\<svg/m,rx.SVG_SIZE=/<svg[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*(?:\s(width|height)=('|")(\d*(?:\.\d+)?)(?:px)?('|"))[^>]*>/i;var ix=rx;var Yu=class extends te{constructor(t){super(t)}static test(t){return!!globalThis.VideoFrame&&t instanceof globalThis.VideoFrame}};var sx=class ox extends te{constructor(t,e){if(e=e||{},!(t instanceof HTMLVideoElement)){let r=document.createElement("video");e.autoLoad!==!1&&r.setAttribute("preload","auto"),e.playsinline!==!1&&(r.setAttribute("webkit-playsinline",""),r.setAttribute("playsinline","")),e.muted===!0&&(r.setAttribute("muted",""),r.muted=!0),e.loop===!0&&r.setAttribute("loop",""),e.autoPlay!==!1&&r.setAttribute("autoplay",""),typeof t=="string"&&(t=[t]);let s=t[0].src||t[0];te.crossOrigin(r,s,e.crossorigin);for(let o=0;o<t.length;++o){let n=document.createElement("source"),{src:a,mime:h}=t[o];if(a=a||t[o],a.startsWith("data:"))h=a.slice(5,a.indexOf(";"));else if(!a.startsWith("blob:")){let l=a.split("?").shift().toLowerCase(),c=l.slice(l.lastIndexOf(".")+1);h=h||ox.MIME_TYPES[c]||`video/${c}`}n.src=a,h&&(n.type=h),r.appendChild(n)}t=r}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=lr.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,r)=>{this.valid?e(this):(this._resolve=e,this._reject=r,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&&(lr.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||(lr.shared.add(this.update,this),this._isConnectedToTicker=!0,this._msToNextUpdate=0)):(this._videoFrameRequestCallbackHandle!==null&&(this.source.cancelVideoFrameCallback(this._videoFrameRequestCallbackHandle),this._videoFrameRequestCallbackHandle=null),this._isConnectedToTicker&&(lr.shared.remove(this.update,this),this._isConnectedToTicker=!1,this._msToNextUpdate=0))}static test(t,e){return globalThis.HTMLVideoElement&&t instanceof HTMLVideoElement||ox.TYPES.includes(e)}};sx.TYPES=["mp4","m4v","webm","ogg","ogv","h264","avi","mov"],sx.MIME_TYPES={ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"};var nx=sx;mh.push(zh,xs,Vh,nx,Yu,ix,ls,ex,Hh);var Y2={vec3(i,t,e,r){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],i.uniform3f(t,r[0],r[1],r[2]))},int(i,t,e,r){i.uniform1i(t,r)},ivec2(i,t,e,r){i.uniform2i(t,r[0],r[1])},ivec3(i,t,e,r){i.uniform3i(t,r[0],r[1],r[2])},ivec4(i,t,e,r){i.uniform4i(t,r[0],r[1],r[2],r[3])},uint(i,t,e,r){i.uniform1ui(t,r)},uvec2(i,t,e,r){i.uniform2ui(t,r[0],r[1])},uvec3(i,t,e,r){i.uniform3ui(t,r[0],r[1],r[2])},uvec4(i,t,e,r){i.uniform4ui(t,r[0],r[1],r[2],r[3])},bvec2(i,t,e,r){i.uniform2i(t,r[0],r[1])},bvec3(i,t,e,r){i.uniform3i(t,r[0],r[1],r[2])},bvec4(i,t,e,r){i.uniform4i(t,r[0],r[1],r[2],r[3])},mat2(i,t,e,r){i.uniformMatrix2fv(t,!1,r)},mat4(i,t,e,r){i.uniformMatrix4fv(t,!1,r)}},q2={float(i,t,e,r){i.uniform1fv(t,r)},vec2(i,t,e,r){i.uniform2fv(t,r)},vec3(i,t,e,r){i.uniform3fv(t,r)},vec4(i,t,e,r){i.uniform4fv(t,r)},int(i,t,e,r){i.uniform1iv(t,r)},ivec2(i,t,e,r){i.uniform2iv(t,r)},ivec3(i,t,e,r){i.uniform3iv(t,r)},ivec4(i,t,e,r){i.uniform4iv(t,r)},uint(i,t,e,r){i.uniform1uiv(t,r)},uvec2(i,t,e,r){i.uniform2uiv(t,r)},uvec3(i,t,e,r){i.uniform3uiv(t,r)},uvec4(i,t,e,r){i.uniform4uiv(t,r)},bool(i,t,e,r){i.uniform1iv(t,r)},bvec2(i,t,e,r){i.uniform2iv(t,r)},bvec3(i,t,e,r){i.uniform3iv(t,r)},bvec4(i,t,e,r){i.uniform4iv(t,r)},sampler2D(i,t,e,r){i.uniform1iv(t,r)},samplerCube(i,t,e,r){i.uniform1iv(t,r)},sampler2DArray(i,t,e,r){i.uniform1iv(t,r)}};function $P(i,t,e,r,s){let o=0,n=null,a=null,h=s.gl;for(let l in i.uniforms){let c=t[l],u=r[l],d=e[l],f=i.uniforms[l];if(!c){f.group===!0&&s.shader.syncUniformGroup(u);continue}c.type==="float"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,h.uniform1f(d.location,u)):c.type==="bool"&&c.size===1&&!c.isArray?u!==d.value&&(d.value=u,h.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,h.uniform1i(d.location,o)),o++):c.type==="mat3"&&c.size===1&&!c.isArray?f.a!==void 0?h.uniformMatrix3fv(d.location,!1,u.toArray(!0)):h.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,h.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],h.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,h.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],h.uniform4f(d.location,n[0],n[1],n[2],n[3]))):(c.size===1&&!c.isArray?Y2:q2)[c.type].call(null,h,d.location,d.value,u)}}function K2(){Object.assign(Ri.prototype,{systemCheck(){},syncUniforms(i,t){let{shader:e,renderer:r}=this;$P(i,e.program.uniformData,t.uniformData,i.uniforms,r)}})}K2();var he={Add:"add",Remove:"remove",Update:"update"},qu=class{init(t){throw new Error("Method not implemented.")}render(t){throw new Error("Method not implemented.")}},Bi=class{rendererName;rendererType;add=async(t,e,r)=>{throw new Error("Method not implemented.")};remove=async(t,e,r)=>{throw new Error("Method not implemented.")};update=async(t,e,r)=>{throw new Error("Method not implemented.")}};var Ss=new(window.AudioContext||window.webkitAudioContext),nn=class i{static loadedAssets={};static load=async(t,e)=>{if(!i.loadedAssets[t]&&e.byteLength!==0)try{let r=await Ss.decodeAudioData(e);i.loadedAssets[t]=r}catch(r){console.error(`AudioAsset.load: Failed to decode ${t}:`,r)}};static getAsset=t=>i.loadedAssets[t]},ax=class{_audioSource;_gainNode;volume=1;id;url;loop=!1;constructor(t,e){this.id=t,this.url=e.url,this.loop=e.loop||!1,this.volume=e.volume??1,this._gainNode=Ss.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Ss.destination)}play=()=>{let t=nn.getAsset(this.url);if(!t){console.warn("AudioPlayer.play: Asset not found",this.url);return}this._audioSource=Ss.createBufferSource(),this._audioSource.buffer=t,this._audioSource.loop=this.loop,this._gainNode.gain.setValueAtTime(this.volume,Ss.currentTime),this._audioSource.connect(this._gainNode),this._audioSource.start(0)};stop=()=>{this._audioSource&&(this._audioSource.stop(),this._audioSource.disconnect(),this._gainNode.disconnect(),this._gainNode=Ss.createGain(),this._gainNode.gain.value=this.volume,this._gainNode.connect(Ss.destination))}},Ku=class{audioPlayers=[];stageAudios=[];add=t=>{this.stageAudios.push(t)};remove=t=>{this.stageAudios=this.stageAudios.filter(e=>e.id!==t)};getById=t=>this.stageAudios.find(e=>e.id===t);tick=()=>{for(let e of this.stageAudios){let r=this.audioPlayers.find(s=>s.id===e.id);if(!r){let s=new ax(e.id,{url:e.url,loop:e.loop,volume:e.volume??1});this.audioPlayers.push(s),s.play();return}(r.url!==e.url||r.loop!==e.loop)&&(r.stop(),r.url=e.url,r.loop=e.loop??!1,r.play()),r.volume!==(e.volume??1)&&(r.volume=e.volume??1,r._gainNode.gain.value=r.volume)}let t=[];for(let e of this.audioPlayers)this.stageAudios.find(r=>r.id===e.id)||(e.stop(),t.push(e.id));this.audioPlayers=this.audioPlayers.filter(e=>!t.includes(e.id))};destroy=()=>{for(let t of this.audioPlayers)t.stop();this.audioPlayers=[],this.stageAudios=[]}};function Zu(i,t){let{id:e,x:r,y:s,width:o,height:n,fill:a,border:h,originX:l,originY:c,zIndex:u,rotation:d}=t,f=new Qt().rect(r,s,o,n).fill(a);h&&f.stroke({color:h.color,alpha:h.alpha,width:h.width}),f.label=e,f.zIndex=u,i.addChild(f)}function $h(i,t){let e=new gr({text:t.text,style:{fill:t.style.fill,fontFamily:t.style.fontFamily,fontSize:t.style.fontSize,wordWrap:t.style.wordWrap,breakWords:t.style.breakWords,wordWrapWidth:t.style.wordWrapWidth},label:t.id});e.x=t.x,e.y=t.y,e.zIndex=t.zIndex,i.addChild(e)}async function Qu(i,t){let{id:e,x:r,y:s,width:o,height:n,url:a,alpha:h,zIndex:l}=t,c=a?I.from(a):I.EMPTY,u=new Zt(c);u.x=r,u.y=s,u.width=o,u.height=n,u.alpha=h,u.zIndex=l,u.label=e,i.addChild(u)}function hx(i,t){let{id:e,x:r,y:s,children:o,scroll:n,zIndex:a}=t,h=new yt;h.x=r,h.y=s,h.zIndex=a,h.label=e;for(let l of o)switch(l.type){case"rect":Zu(h,l);break;case"text":$h(h,l);break;case"sprite":Qu(h,l);break;case"container":hx(h,l);break;default:throw new Error("Unkown types")}n&&Z2({container:h,element:t}),i.addChild(h)}function Z2({container:i,element:t}){let e=0,r=0;t.children.forEach(n=>{e=Math.max(n.width+n.x,e),r=Math.max(n.height+n.y,r)});let s=t.scroll&&t.height&&r>t.height,o=t.scroll&&t.width&&e>t.width;if(s||o){let n=new yt;[...i.children].forEach(f=>{n.addChild(f)}),i.addChild(n);let h=new Qt().rect(0,0,t.width||e,t.height||r).fill({color:16711680,alpha:0});i.addChild(h),n.mask=h,i.eventMode="static";let l=0,c=0,u=-(r-(t.height||r)),d=-(e-(t.width||e));i.on("wheel",f=>{if(f.preventDefault(),s&&f.deltaY!==0){let p=l-f.deltaY;p>0?l=0:p<u?l=u:l=p,n.y=l}if(o&&(f.deltaX!==0||f.shiftKey&&f.deltaY!==0)){let p=f.deltaX!==0?f.deltaX:f.deltaY,g=c-p;g>0?c=0:g<d?c=d:c=g,n.x=c}})}}function XP(i,t){let e=new Set,r=new Map,s=new Map,o=[],n=[],a=[];for(let h of i)e.add(h.id),r.set(h.id,h);for(let h of t)e.add(h.id),s.set(h.id,h);for(let h of e){let l=r.get(h),c=s.get(h);!l&&c?o.push(c):l&&!c?n.push(l):JSON.stringify(l)!==JSON.stringify(c)&&a.push({prev:l,next:c})}return{toAddElement:o,toDeleteElement:n,toUpdateElement:a}}function jP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy()}function YP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy()}function qP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy({children:!0})}function KP(i,t){let e=i.getChildByLabel(t.id);e&&e.destroy()}function ZP(i,t,e){let r=i.children.find(s=>s.label===t.id);r&&(r.clear(),r.rect(e.x,e.y,e.width,e.height).fill(e.fill),e.border&&r.stroke({color:e.border.color,alpha:e.border.alpha,width:e.border.width}),r.zIndex=e.zIndex)}function QP(i,t,e){let r=i.children.find(s=>s.label===t.id);r&&(r.text=e.text,r.style={fill:e.style.fill,fontFamily:e.style.fontFamily,fontSize:e.style.fontSize,wordWrap:e.style.wordWrap,breakWords:e.style.breakWords,wordWrapWidth:e.style.wordWrapWidth},r.x=e.x,r.y=e.y,r.zIndex=e.zIndex)}async function JP(i,t,e){let r=i.children.find(s=>s.label===t.id);if(r){if(t.url!==e.url){let s=e.url?I.from(e.url):I.EMPTY;r.texture=s}r.x=e.x,r.y=e.y,r.width=e.width,r.height=e.height,r.alpha=e.alpha,r.zIndex=e.zIndex}}function tR(i,t,e,r){let s=t.children.find(o=>o.label===e.id);s&&(s.x=r.x,s.y=r.y,s.zIndex=r.zIndex,s.label=r.id,JSON.stringify(e.children)!==JSON.stringify(r.children)&&Xh(i,s,e.children,r.children))}function Xh(i,t,e,r){let{toAddElement:s,toDeleteElement:o,toUpdateElement:n}=XP(e,r);for(let a of o)switch(a.type){case"rect":jP(t,a);break;case"text":YP(t,a);break;case"container":qP(t,a);break;case"sprite":KP(t,a);break;default:}for(let a of s)switch(a.type){case"rect":Zu(t,a);break;case"text":$h(t,a);break;case"container":hx(t,a);break;case"sprite":Qu(t,a);break;default:}for(let{prev:a,next:h}of n)switch(h.type){case"rect":ZP(t,a,h);break;case"text":QP(t,a,h);break;case"container":tR(i,t,a,h);break;case"sprite":JP(t,a,h);break;default:}Q2(t,r)}function Q2(i,t){i.children.sort((e,r)=>{let s=t.find(n=>n.id===e.label),o=t.find(n=>n.id===r.label);if(s&&o){let n=s.zIndex??0,a=o.zIndex??0;if(n!==a)return n-a;let h=t.findIndex(c=>c.id===e.label),l=t.findIndex(c=>c.id===r.label);return h-l}if(!s&&!o)return 0;if(!s)return-1;if(!o)return 1})}function eR({positionX:i=0,positionY:t=0,width:e,height:r,anchorX:s=0,anchorY:o=0}){if(typeof e!="number"||typeof r!="number")throw new Error("Input Error: Width or height is missing");let n={x:e*s,y:r*o},a=i-n.x,h=t-n.y;return{x:a,y:h,originX:n.x,originY:n.y}}function Ii(i){if(typeof i.width!="number"||typeof i.height!="number")throw new Error("Input Error: Width or height is missing");if(!["rect","text","container","sprite"].includes(i.type))throw new Error("Input Error: Type must be one of rect, text, container, sprite");if(!i.id)throw new Error("Input Error: Id is missing");let t=i.scaleX?i.scaleX*i.width:i.width,e=i.scaleY?i.scaleY*i.height:i.height;i.type==="container"&&(t=i.width,e=i.height);let{x:r,y:s,originX:o,originY:n}=eR({positionX:i.x,positionY:i.y,width:t,height:e,anchorX:i.anchorX,anchorY:i.anchorY});return{id:i.id,type:i.type,width:t,height:e,x:r,y:s,originX:o,originY:n,zIndex:i.zIndex||0}}function Ju(i){let t=Ii(i);return i.border&&(t={...t,border:{alpha:i?.border?.alpha??1,color:i?.border?.color??"black",width:i?.border?.width??0}}),{...t,cursor:i.cursor??"",fill:i.fill??"white",pointerDown:i.pointerDown??"",pointerMove:i.pointerMove??"",pointerUp:i.pointerUp??"",rotation:i.rotation??0}}function td(i){let e={...{fill:"black",fontFamily:"Arial",fontSize:16},...i.style};i.width&&(e.wordWrapWidth=i.width,e.wordWrap=!0);let{width:r,height:s}=gt.measureText(i.text,new Ht(e));return{...Ii({...i,width:r,height:s}),text:i.text??"",style:{...e}}}function ed(i){return{...Ii(i),url:i.url??"",alpha:i.alpha??1,cursor:i.cursor??"",clickUrl:i.clickUrl??"",hoverUrl:i.hoverUrl??""}}function lx(i){let t=i.direction,e=!!i.scroll,r=i.gap||0,s=structuredClone(i.children||[]),o=[],n=0,a=0,h=0,l=0,c=0,u=0,d=0,f=0,p=0,g=0;for(let v=0;v<s.length;v++){let _=v<s.length-1?r:0,y=s[v];switch(v>0?t==="horizontal"?(y.x=h,y.y=d):t==="vertical"&&(y.x=f,y.y=l):(t==="horizontal"||t==="vertical")&&(y.x=0,y.y=0),y.type){case"rect":y=Ju(y);break;case"text":y=td(y);break;case"sprite":y=ed(y);break;case"container":y=lx(y);break;default:}t==="horizontal"?(i.width&&y.width+p>i.width&&!e?(h=0,p=0,d+=c+r,c=y.height,y.x=0,y.y=d):c=Math.max(c,y.height),h+=y.width+_,p=y.x+y.width,n=Math.max(h,n),a=Math.max(y.height+y.y,a)):t==="vertical"&&(i.height&&y.height+g>i.height&&!e?(l=0,g=0,f+=u+r,u=y.width,y.x=f,y.y=0):u=Math.max(u,y.width),l+=y.height+_,g=y.y+y.height,n=Math.max(y.width+y.x,n),a=Math.max(l,a)),o.push(y)}return{...Ii({...i,width:i.width?i.width:n,height:i.height?i.height:a}),children:o,direction:t,gap:r,scroll:e,rotation:i.rotation??0}}function jh(i){return i.map(e=>{switch(e.type){case"rect":return Ju(e);case"container":return lx(e);case"text":return td(e);case"sprite":return ed(e);default:throw new Error(`Unsupported element type: ${e.type}`)}})}var J2=i=>i.split("/").pop(),cx=class{name="advancedBufferLoader";priority=2;constructor(t){this.bufferMap=t}test(t){return!0}async load(t){let e=t.startsWith("file:")?t:J2(t),r=this.bufferMap[e];if(!r)throw new Error(`Buffer not found for key: ${e}`);return{data:r.buffer,type:r.type,metadata:null}}async testParse(t){return!0}async parse(t){if(t instanceof I)return t;let e=new Blob([t.data],{type:t.type}),r=await createImageBitmap(e);return new I.from(r)}async unload(t){t.destroy(!0)}},ux=class i extends qu{static rendererName="pixi";_app;_audioStage=new Ku;_state={elements:[],transitions:[]};_eventHandler;_plugins;_currentAbortController;_advancedLoader;get canvas(){return this._app.canvas}init=async t=>{let{eventHandler:e,plugins:r,width:s,height:o,backgroundColor:n}=t;for(let h of r)if(h.rendererName!==i.rendererName)throw new Error("Plugin does not match renderer name");this._plugins=r,this._eventHandler=e,this._app=new Za,this._app.audioStage=this._audioStage,await this._app.init({width:s,height:o,backgroundColor:n});let a=new Qt;return a.rect(0,0,s,o),a.fill(n||0),this._app.stage.addChild(a),this._app.stage.width=s,this._app.stage.height=o,this._app.ticker.add(this._app.audioStage.tick),this};destroy=()=>{this._app.audioStage.destroy(),this._app.destroy()};_classifyAsset=t=>t?t.startsWith("audio/")?"audio":t.startsWith("font/")||["application/font-woff","application/font-woff2","application/x-font-ttf","application/x-font-otf"].includes(t)?"font":"texture":"texture";loadAssets=async t=>{if(!t)throw new Error("assetBufferMap is required");let e={audio:{},font:{},texture:{}};for(let[s,o]of Object.entries(t)){let n=this._classifyAsset(o.type);e[n][s]=o}await Promise.all(Object.entries(e.audio).map(([s,o])=>nn.load(s,o.buffer))),await Promise.all(Object.entries(e.font).map(async([s,o])=>{let n=new Blob([o.buffer],{type:o.type}),a=URL.createObjectURL(n),h=new FontFace(s,`url(${a})`);try{await h.load(),document.fonts.add(h)}catch(l){console.error(`Failed to load font ${s}:`,l)}finally{URL.revokeObjectURL(a)}})),this._advancedLoader?Object.assign(this._advancedLoader.bufferMap,e.texture):(this._advancedLoader=new cx(e.texture),sr.loader.parsers.length=0,sr.reset(),D.add({name:"advanced-buffer-loader",extension:b.Asset,priority:se.High,loader:this._advancedLoader}),typeof sr.registerPlugin=="function"&&sr.registerPlugin(this._advancedLoader));let r=Object.keys(e.texture);return Promise.all(r.map(s=>sr.load(s)))};loadAudioAssets=async t=>Promise.all(t.map(async e=>{let s=await(await fetch(e)).arrayBuffer();return nn.load(e,s)}));updatedBackgroundColor=t=>{this._app.renderer.background.color=t};getStageElementBounds=()=>{let t={},e=r=>{if(!(!r||r.length===0))for(let s of r)t[s.label]={x:s.groupTransform.tx,y:s.groupTransform.ty,width:s.width,height:s.height},e(s.children)};return e(this._app.stage.children),t};render=t=>{let e=jh(t.elements),r={...t,elements:e};this._render(this._app,this._app.stage,this._state,r,this._eventHandler),this._state=r};_getRendererByElement=t=>{for(let e of this._plugins)if(e.rendererType===t.type)return e;throw new Error(`No renderer found for element type: ${t.type}`)};_getTransitionByType=t=>{for(let e of this._plugins)if(e.transitionType===t)return e;throw new Error(`No transition found for transition type: ${t}`)};_applyGlobalCursorStyles=(t,e,r)=>{t.renderer.events.cursorStyles||(t.renderer.events.cursorStyles={}),t.renderer.events.cursorStyles.default||(t.renderer.events.cursorStyles.default="default"),t.renderer.events.cursorStyles.hover||(t.renderer.events.cursorStyles.hover="pointer");let s=e?.cursorStyles,o=r?.cursorStyles;JSON.stringify(s)!==JSON.stringify(o)&&(o?(o.default&&(t.renderer.events.cursorStyles.default=o.default,t.canvas.style.cursor=o.default),o.hover&&(t.renderer.events.cursorStyles.hover=o.hover)):s&&(t.renderer.events.cursorStyles.default="default",t.renderer.events.cursorStyles.hover="pointer"))};_render=async(t,e,r,s,o)=>{this._applyGlobalCursorStyles(t,r.global,s.global),Xh(t,e,r.elements,s.elements),this._currentAbortController&&this._currentAbortController.abort(),this._currentAbortController=new AbortController}},rR=ux;var dx=class extends Bi{static rendererName="pixi";rendererName="pixi";rendererType="sprite";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:h,elements:l=[]}=e,c=o.url?I.from(o.url):I.EMPTY,u,d,f=o.scaleX??1,p=o.scaleY??1;o.hoverUrl&&(u=I.from(o.hoverUrl)),o.clickUrl&&(d=I.from(o.clickUrl));let g=new Zt(c);g.label=o.id,g.interactiveChildren=!1,(o.eventName||o.hoverUrl||o.clickUrl)&&(g.cursor="hover",g.eventMode="static"),o.width!==void 0?g.width=o.width*f:g.width*=f,o.height!==void 0?g.height=o.height*p:g.height*=p,o.anchorX!==void 0&&(g.pivot.x=g.width*o.anchorX),o.anchorY!==void 0&&(g.pivot.y=g.height*o.anchorY),o.rotation!==void 0&&(g.rotation=o.rotation*Math.PI/180),o.x!==void 0&&(g.x=o.x),o.y!==void 0&&(g.y=o.y),o.zIndex!==void 0&&(g.zIndex=o.zIndex),o.alpha!==void 0&&(g.alpha=o.alpha),(u||d)&&g.on("pointerup",()=>{g.texture=c}).on("pointerupoutside",()=>{g.texture=c}).on("pointerleave",()=>{g.texture=c}),d&&g.on("pointerdown",()=>{g.texture=d}),u&&g.on("pointerenter",()=>{g.texture=u}),g.on("pointerup",v=>{v.stopPropagation();let _=v.button;_===0?h&&h(o.eventName,o.eventPayload):_===2&&(o.rightClickEventName&&h?h(o.rightClickEventName):t.stage.emit("rightclick",event))});let x=[];for(let v of n)if(v.elementId===o.id&&v.event===he.Add){let _=a(v.type);if(!_)throw new Error(`Transition class not found for type ${v.type}`);x.push(_.add(t,g,v,r))}s.addChild(g),Array.isArray(l)&&l.length>0&&s.children.sort((v,_)=>{let y=l.find(E=>E.id===v.label),T=l.find(E=>E.id===_.label);if(y&&T){let E=y.zIndex??0,w=T.zIndex??0;if(E!==w)return E-w;let C=l.findIndex(P=>P.id===v.label),M=l.findIndex(P=>P.id===_.label);return C-M}if(!y&&!T)return 0;if(!y)return-1;if(!T)return 1}),await Promise.all(x)};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,h=s.getChildByName(o.id);if(!h)throw new Error(`Sprite with id ${o.id} not found`);let l=[];for(let c of n)if(c.elementId===o.id&&c.event===he.Remove){let u=a(c.type);if(!u)throw new Error(`Transition class not found for type ${c.type}`);l.push(u.remove(t,h,c,r))}await Promise.all(l),h&&h.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a},h)=>{if(h?.aborted)throw new DOMException("Operation aborted","AbortError");let l=e.getChildByName(r.id);if(!l)throw new Error(`Sprite with id ${r.id} not found`);let c=[];for(let f of o)if(f.elementId===r.id&&f.event===he.Update){let p=n(f.type);if(!p)throw new Error(`Transition class not found for type ${f.type}`);c.push(p.add(t,l,f,h))}c.length>0?(await Promise.all(c),u()):d();function u(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let x=I.from(s.url);if(l.texture=x,!r.url&&s.url)if(x.baseTexture.valid){let v=s.scaleX??1,_=s.scaleY??1;l.width=(s.width??x.width)*v,l.height=(s.height??x.height)*_}else x.baseTexture.once("loaded",()=>{let v=s.scaleX??1,_=s.scaleY??1;l.width=(s.width??x.width)*v,l.height=(s.height??x.height)*_})}let p=r.hoverUrl||r.clickUrl,g=s.hoverUrl||s.clickUrl;if(!p&&g){let x=l.texture;l.on("pointerup",()=>{l.texture=x}).on("pointerupoutside",()=>{l.texture=x}).on("pointerleave",()=>{l.texture=x})}if(s.hoverUrl){let x=I.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=x})}if(s.clickUrl){let x=I.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=x})}}(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="hover",l.eventMode="static")}function d(){if(r.url!==s.url||r.hoverUrl!==s.hoverUrl||r.clickUrl!==s.clickUrl){if(s.url){let _=I.from(s.url);if(l.texture=_,!r.url&&s.url)if(_.baseTexture.valid){let y=s.scaleX??1,T=s.scaleY??1;l.width=(s.width??_.width)*y,l.height=(s.height??_.height)*T}else _.baseTexture.once("loaded",()=>{let y=s.scaleX??1,T=s.scaleY??1;l.width=(s.width??_.width)*y,l.height=(s.height??_.height)*T})}let x=r.hoverUrl||r.clickUrl,v=s.hoverUrl||s.clickUrl;if(!x&&v){let _=l.texture;l.on("pointerup",()=>{l.texture=_}).on("pointerupoutside",()=>{l.texture=_}).on("pointerleave",()=>{l.texture=_})}if(s.hoverUrl){let _=I.from(s.hoverUrl);l.off("pointerenter"),l.on("pointerenter",()=>{l.texture=_})}if(s.clickUrl){let _=I.from(s.clickUrl);l.off("pointerdown"),l.on("pointerdown",()=>{l.texture=_})}}s.x!==void 0&&s.x!==r.x&&(l.x=s.x),s.y!==void 0&&s.y!==r.y&&(l.y=s.y),s.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180);let p=s.scaleX??1,g=s.scaleY??1;s.width!==void 0&&(s.width!==r.width||p!==(r.scaleX??1))&&(l.width=s.width*p),s.height!==void 0&&(s.height!==r.height||g!==(r.scaleY??1))&&(l.height=s.height*g),s.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=l.width*s.anchorX/p),s.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=l.height*s.anchorY/g),s.zIndex!==void 0&&s.zIndex!==r.zIndex&&(l.zIndex=s.zIndex),s.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),(s.eventName||s.hoverUrl||s.clickUrl)&&(l.cursor="hover",l.eventMode="static")}}};var rd=i=>new Ht({wordWrap:i.wordWrap||!0,breakWords:i.breakWords||!1,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),fx=class{static rendererName="pixi";rendererName="pixi";rendererType="text";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:h}=e,l=rd(o.style),c=new gr({text:o.text,style:l}),u;o.hoverStyle&&(u=rd(o.hoverStyle));let d;if(o.clickedStyle&&(d=rd(o.clickedStyle)),(o.eventName||o.clickedStyle||o.hoverStyle)&&(c.cursor="hover",c.eventMode="static"),c.label=o.id,o.x!==void 0&&(c.x=o.x),o.y!==void 0&&(c.y=o.y),o.anchorX!==void 0&&(c.anchor.x=o.anchorX),o.anchorY!==void 0&&(c.anchor.y=o.anchorY),o.anchorX!==void 0||o.anchorY!==void 0){let p=c.getLocalBounds();c.hitArea=new rt(-p.width*c.anchor.x,-p.height*c.anchor.y,p.width,p.height)}c.on("pointerout",()=>{c.isOver=!1}).on("pointerupoutside",()=>{c.style=l}).on("pointerup",()=>{c.style=l}).on("pointerleave",()=>{c.style=l}),c.on("pointerup",p=>{o.clickSoundUrl&&t.soundStage&&t.soundStage.add({id:`${o.id}-click-${Math.random()}`,url:o.clickSoundUrl,loop:!1,volume:o.clickSoundVolume??50/100}),p.stopPropagation(),h&&h(o.eventName,o.eventPayload)}),d&&c.on("pointerdown",()=>{c.style=d}),u&&c.on("pointerenter",()=>{c.style=u,o.hoverSoundUrl&&t.soundStage&&o.hoverSoundVolume!==void 0&&t.soundStage.add({id:`${o.id}-hover-${Math.random()}`,url:o.hoverSoundUrl,loop:!1,volume:o.hoverSoundVolume/100})});let f=[];for(let p of n)if(p.elementId===o.id&&p.event===he.Add){let g=a(p.type);if(!g)throw new Error(`Transition class not found for type ${p.type}`);f.push(g.add(t,c,p,r))}s.addChild(c),await Promise.all(f)};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,h=s.getChildByName(o.id);if(!h){console.warn(`Text with id ${o.id} not found`);return}let l=[];for(let c of n)if(c.elementId===o.id&&c.event===he.Remove){let u=a(c.type);if(!u)throw new Error(`Transition class not found for type ${c.type}`);l.push(u.remove(t,h,c,r))}await Promise.all(l),h&&h.destroy()};update=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,prevElement:o,nextElement:n,transitions:a,getTransitionByType:h,eventHandler:l}=e,c=s.getChildByName(o.id);if(!c){console.warn(`Text with id ${o.id} not found`);return}if(JSON.stringify(o)!==JSON.stringify(n)){let u=[this.add(t,{parent:s,element:n,transitions:a,getTransitionByType:h,eventHandler:l},r),this.remove(t,{parent:s,element:o,transitions:a,getTransitionByType:h},r)];await Promise.all(u)}else o.text!==n.text&&(c.text=n.text),JSON.stringify(o.style)!==JSON.stringify(n.style)&&(c.style=rd(n?.style)),n.x!==void 0&&(c.x=n.x),n.y!==void 0&&(c.y=n.y)}};var ee=(i,t=!1)=>new Ht({wordWrap:i.wordWrap||!0,breakWords:t,align:i.align,fill:i.fill,fontSize:i.fontSize,lineHeight:i.lineHeight,wordWrapWidth:i.wordWrapWidth,fontFamily:i.fontFamily||"Roboto",whiteSpace:"pre",trim:!1,stroke:i.strokeColor?{color:i.strokeColor,width:i.strokeWidth}:void 0}),px=class{static rendererName="pixi";rendererName="pixi";rendererType="text-revealing";add=async(t,{parent:e,element:r})=>{let s=r.content?.[0]?.text||"",o=ee(r.style,s),n=new gr({text:"",style:o});n.label=r.id,n.text_id=s;let a=new yt;r.x!==void 0&&(a.x=r.x),r.y!==void 0&&(a.y=r.y),a.addChild(n),a.label=r.id,e.addChild(a);let h=r.style.wordWrapWidth||500,l=r.content&&r.content.length>0?r.content.map(E=>({text:E.text.replace(/ +$/,w=>"\xA0".repeat(w.length)),style:E.style?{...r.style,...E.style}:r.style,align:E.align||r.align||"top",furigana:E.furigana})):r.segments,c=[];if(l.length===1){let E=[],w=0,C=0,M=0,P=[...l];for(;;){let S=P[0];if(!S){E.length>0&&c.push({lineParts:E,y:C});break}if(C>1e4)break;let A={...S.style,wordWrapWidth:h-w},B=gt.measureText(S.text,ee(A));B.lineHeight>M&&(M=B.lineHeight);let F=gt.measureText("a",ee(A)),z=gt.measureText("a a",ee(A)).width-F.width*2;if(B.lineWidths[0]+w>h){w=0,c.push({lineParts:E,y:C}),C+=M,M=0,E=[];continue}let k=B.lines[0];B.lines.length===1&&S.text.endsWith(" ")&&!k.endsWith(" ")&&(k+=" ");let G=B.lines.slice(1).join(" "),N={text:k,style:A,x:w,y:0,align:S.align};if(E.push(N),G&&G.length>0?S.text=G:P.shift(),!(!k||k.length===0)){if(S.furigana){let O=gt.measureText(S.furigana.text,ee(S.furigana.style)),Y={text:S.furigana.text,style:S.furigana.style,x:w+(B.width-O.width)/2,y:-10};E.push(Y)}w+=B.lineWidths[0]+z}}}else{let E=[],w=0,C=0,M=0,P=[...l],S=new WeakSet;for(;;){let A=P[0];if(!A){E.length>0&&c.push({lineParts:E,y:C});break}if(C>1e4)break;let B={...A.style,wordWrapWidth:h-w},F=gt.measureText(A.text,ee(B));F.lineHeight>M&&(M=F.lineHeight);let W=gt.measureText("a",ee(B)),k=gt.measureText("a a",ee(B)).width-W.width*2;if(F.lineWidths[0]+w>h){w=0,c.push({lineParts:E,y:C}),C+=M,M=0,E=[];continue}let G=F.lines[0];F.lines.length===1&&A.text.endsWith(" ")&&!G.endsWith(" ")&&(G+=" ");let N=F.lines.slice(1).join(" "),O={text:G,style:B,x:w,y:0,align:A.align};if(E.push(O),N&&N.length>0?A.text=N:P.shift(),!(!G||G.length===0)){if(A.furigana&&!S.has(A)){S.add(A);let Y=gt.measureText(A.furigana.text,ee(A.furigana.style)),lt={text:A.furigana.text,style:A.furigana.style,x:w+(F.lineWidths[0]-Y.width)/2,y:0,isFurigana:!0,parentAlign:A.align,parentX:w,parentWidth:F.lineWidths[0]};E.push(lt)}w+=F.lineWidths[0]}}}c.forEach(E=>{let w=new yt;w.y=E.y,w.alpha=0;let C=0;E.lineParts.forEach(P=>{let S=gt.measureText(P.text,ee(P.style));S.height>C&&(C=S.height)});let M=new Map;E.lineParts.forEach(P=>{if(!P.isFurigana){let S=gt.measureText(P.text,ee(P.style)),A=P.y,B=P.align||"top";B==="center"?A+=(C-S.height)/2:B==="bottom"&&(A+=C-S.height);let F=new gr({text:P.text,style:ee(P.style),x:P.x,y:A});w.addChild(F),M.set(P.x,{yOffset:A,height:S.height})}}),E.lineParts.forEach(P=>{if(P.isFurigana){let S=gt.measureText(P.text,ee(P.style)),A=M.get(P.parentX),B=-S.height-5;A&&(B=A.yOffset-S.height+2);let F=new gr({text:P.text,style:ee(P.style),x:P.x,y:B});w.addChild(F)}}),a.addChild(w)});let u=new Qt,d=1e3,f=h/2,p=h/2;u.fill({color:16777215,alpha:1}),u.rect(0,0,f,d);for(let E=0;E<p;E++)u.fill({color:16777215,alpha:1-E/p}),u.rect(f+E,0,f+1,d);let g=t.renderer.generateTexture(u),x=new Zt(g);x.x=-1.35*f-p,t.stage.addChild(x);let v=null,_=null;if(r.indicator?.revealing?.url){let E=I.from(r.indicator.revealing.url);v=new Zt(E),v.anchor.set(0,.5),v.visible=!1,r.indicator.revealing.width!==void 0&&(v.width=r.indicator.revealing.width),r.indicator.revealing.height!==void 0&&(v.height=r.indicator.revealing.height),a.addChild(v)}if(r.indicator?.complete?.url){let E=I.from(r.indicator.complete.url);_=new Zt(E),_.anchor.set(0,.5),_.visible=!1,r.indicator.complete.width!==void 0&&(_.width=r.indicator.complete.width),r.indicator.complete.height!==void 0&&(_.height=r.indicator.complete.height),a.addChild(_)}let y=0,T=1;if(c.length!==0){if(r.displaySpeed===100||r.hasEnded){if(a.children.forEach(E=>{t.stage.removeChild(x),E.mask=null,E.alpha=1}),_&&(_.visible=!0,c.length>0)){let E=c[c.length-1],w=0,C=E.y;E.lineParts.forEach(M=>{if(!M.isFurigana){let P=gt.measureText(M.text,ee(M.style)),S=M.x+P.width;S>w&&(w=S)}}),_.x=w+10,_.y=C+20}return}await new Promise(E=>{let w=C=>{if(T>a.children.length){if(v&&(v.visible=!1),_&&(_.visible=!0,c.length>0)){let S=c[c.length-1],A=0,B=S.y;S.lineParts.forEach(F=>{if(!F.isFurigana){let W=gt.measureText(F.text,ee(F.style)),z=F.x+W.width;z>A&&(A=z)}}),_.x=A+10,_.y=B+20}E();return}a.getChildAt(T).mask||(a.getChildAt(T).mask=x,a.getChildAt(T).alpha=1),y+=C.deltaMS;let P=(r.displaySpeed||50)/1e3;if(x.x+=P*y,v&&T<=c.length){let S=c[T-1];if(S&&(a.getChildAt(T).mask===x||T===c.length)){v.visible=!0;let B=x.x+f+p+150,F=0,W=!1,z=!0,k=0;for(let G of S.lineParts)if(!G.isFurigana){let N=gt.measureText(G.text,ee(G.style));k=Math.max(k,G.x+N.width)}for(let G of S.lineParts)if(!G.isFurigana){let N=gt.measureText(G.text,ee(G.style)),O=G.x,Y=G.x+N.width;if(Y<=B)F=Y,W=!0;else if(O<B){F=Math.max(O,B),W=!0,z=!1;break}else z=!1}B>=k&&(z=!0),W&&F>0?(v.x=F,v.y=S.y+20):T===c.length&&k>0?(v.x=k,v.y=S.y+20):v.visible=!1,_&&(_.visible=!1)}else v.visible=!1}if(x.x>=0&&(a.getChildAt(T).mask=null,x.x=-1.35*f-p,T=T+1,y=0,T===a.children.length)){if(v&&(v.visible=!1),_&&(_.visible=!0,c.length>0)){let S=c[c.length-1],A=0,B=S.y;S.lineParts.forEach(F=>{if(!F.isFurigana){let W=gt.measureText(F.text,ee(F.style)),z=F.x+W.width;z>A&&(A=z)}}),_.x=A+10,_.y=B+20}t.ticker.remove(w),E()}};t.ticker.add(w)})}};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Text with id ${s.id} not found`,{parent:r});return}let h=[];for(let l of o)if(l.elementId===s.id&&l.event===he.Remove){let c=n(l.type);if(!c)throw new Error(`Transition class not found for type ${l.type}`);h.push(c.remove(t,a,l))}await Promise.all(h),a.destroy()};update=async(t,e)=>{let{parent:r,prevElement:s,nextElement:o}=e;if(!r.getChildByName(s.id)){console.warn(`Text with id ${s.id} not found`,{parent:r});return}await this.remove(t,{parent:r,element:s}),await this.add(t,{parent:r,element:o})}};var iR=(i=[],t=[])=>{let e=[],r=[],s=[],o=i.filter(a=>!a.hidden),n=t.filter(a=>!a.hidden);for(let a of o){let h=n.find(l=>l.id===a.id&&l.type===a.type);h?r.push({prev:a,next:h}):e.push(a)}for(let a of n)o.find(l=>l.id===a.id&&l.type===a.type)||s.push(a);for(let a of i){let h=t.find(l=>l.id===a.id&&l.type===a.type);h&&h.hidden&&!a.hidden&&e.push(a)}return{toDeleteElements:e,toUpdateElements:r,toAddElements:s}};var mx=class{static rendererName="pixi";rendererName="pixi";rendererType="container";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,elements:n=[],transitions:a=[],getTransitionByType:h,getRendererByElement:l,eventHandler:c}=e,u=structuredClone(o),d=new yt;d.label=u.id;let f={};u.x!==void 0&&(typeof u.x=="string"&&u.x.endsWith("%")?d.x=Number(u.x.replace("%",""))*t.screen.width/100:d.x=u.x),u.y!==void 0&&(typeof u.y=="string"&&u.y.endsWith("%")?d.y=Number(u.y.replace("%",""))*t.screen.height/100:d.y=u.y),u.scaleX!==void 0&&(d.scale.x=u.scaleX),u.scaleY!==void 0&&(d.scale.y=u.scaleY),u.zIndex!==void 0&&(d.zIndex=u.zIndex),u.rotation!==void 0&&(d.rotation=u.rotation*Math.PI/180),u.propagateEvents&&(d.eventMode="static",["pointerup","pointerupoutside","pointerleave","pointerdown","pointerenter"].forEach(P=>{d.on(P,S=>{S.stopPropagation();for(let A of d.children)A.emit(P)})}));let p=u.gap||0,g=new Qt().roundRect(0,0,u.width||0,u.height||0,1).fill(u.fill?u.fill.color:"transparent"),x=[0,.5,1],v=u.anchorX??0,_=u.anchorY??0;if(!x.includes(v))throw new Error(`Invalid anchorX value: ${v}. Must be 0, 0.5, or 1`);if(!x.includes(_))throw new Error(`Invalid anchorY value: ${_}. Must be 0, 0.5, or 1`);if(u.direction){let P,S;u.direction==="horizontal"?(P=u.children.reduce((B,F,W)=>B+F.width+(W>0?p:0),0),S=u.children.reduce((B,F)=>Math.max(B,F.height||0),0)):u.direction==="vertical"&&(P=u.children.reduce((B,F)=>Math.max(B,F.width||0),0),S=u.children.reduce((B,F,W)=>B+F.height+(W>0?p:0),0));let A={x:v,y:_};u.direction==="horizontal"?this.layoutChildren({element:u,anchor:A,totalWidth:P,totalHeight:S,gap:p,direction:"horizontal",scroll:u.scroll}):u.direction==="vertical"&&this.layoutChildren({element:u,anchor:A,totalWidth:P,totalHeight:S,gap:p,direction:"vertical",scroll:u.scroll}),this.setupScrolling({container:d,element:u,totalHeight:S,totalWidth:P,eventHandler:c,sliderRef:f}),g=this.createContainerGraphic(u,P,S,A)}g.label=`${u.id}-container-background`,d.addChild(g);let y=[];(u.children||[]).forEach(P=>{let S=l(P),A=u.width||0,B=u.height||0,F=v*A,W=_*B,z={zIndex:u.zIndex,...P,x:(P.x||0)+F,y:(P.y||0)+W};y.push(S.add(t,{parent:d,element:z,elements:u.children||[],transitions:a,getTransitionByType:h,getRendererByElement:l,eventHandler:c},r))});let T=[];for(let P of a)if(P.elementId===u.id&&P.event===he.Add){let S=h(P.type);if(!S)throw new Error(`Transition class not found for type ${P.type}`);T.push(S.add(t,d,P,r))}s.addChild(d),await Promise.all([...y,...T]);let{width:E,height:w}=this.getContainerDimensions(u,d),C=v*E,M=_*w;d.pivot.x=C,d.pivot.y=M};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");console.log("remove container 11111111111");let{parent:s,element:o}=e,n=s.getChildByName(o.id);if(!n){console.warn(`Container with id ${o.id} not found`);return}n.destroy()};update=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,prevElement:o,nextElement:n,elements:a=[],getRendererByElement:h,transitions:l=[],getTransitionByType:c,eventHandler:u}=e,d=structuredClone(o),f=structuredClone(n),p=s.getChildByName(d.id);if(!p){console.warn(`Container with id ${d.id} not found`);return}f.x!==void 0&&(p.x=f.x),f.y!==void 0&&(p.y=f.y),f.rotation!==void 0&&f.rotation!==d.rotation&&(p.rotation=f.rotation*Math.PI/180);let g=[0,.5,1],x=f.anchorX??0,v=f.anchorY??0;if(!g.includes(x))throw new Error(`Invalid anchorX value: ${x}. Must be 0, 0.5, or 1`);if(!g.includes(v))throw new Error(`Invalid anchorY value: ${v}. Must be 0, 0.5, or 1`);if(f.direction){let S=f.gap||0,A,B;f.direction==="horizontal"?(A=f.children.reduce((z,k,G)=>z+k.width+(G>0?S:0),0),B=f.children.reduce((z,k)=>Math.max(z,k.height||0),0)):f.direction==="vertical"&&(A=f.children.reduce((z,k)=>Math.max(z,k.width||0),0),B=f.children.reduce((z,k,G)=>z+k.height+(G>0?S:0),0));let F={x,y:v};f.direction==="horizontal"?this.layoutChildren({element:f,anchor:F,totalWidth:A,totalHeight:B,gap:S,direction:"horizontal",scroll:f.scroll}):f.direction==="vertical"&&this.layoutChildren({element:f,anchor:F,totalWidth:A,totalHeight:B,gap:S,direction:"vertical",scroll:f.scroll});let W=p.children.find(z=>z.label===`${f.id}-container-background`);if(W){W.destroy();let z=this.createContainerGraphic(f,A,B,F);z.label=`${f.id}-container-background`,p.addChildAt(z,0)}d.scroll!==f.scroll&&this.setupScrolling({container:p,element:f,totalHeight:B,totalWidth:A,eventHandler:u,sliderRef:{}})}let _=[],{toAddElements:y,toUpdateElements:T,toDeleteElements:E}=iR(d.children,f.children);if(f.direction&&f.children){let S=new Map;f.children.forEach(A=>{S.set(A.id,{x:A.x,y:A.y})}),T.forEach(A=>{let B=S.get(A.next.id);B&&(A.next.x=B.x,A.next.y=B.y)}),y.forEach(A=>{let B=S.get(A.id);B&&(A.x=B.x,A.y=B.y)})}for(let S of E){let A=h(S);_.push(A.remove(t,{parent:p,element:S,elements:f.children||[],transitions:l,getTransitionByType:c,getRendererByElement:h,eventHandler:u},r))}for(let S of y){let A=h(S),B=f.width||0,F=f.height||0,W=x*B,z=v*F,k={...S,x:(S.x||0)+W,y:(S.y||0)+z};_.push(A.add(t,{parent:p,element:k,elements:f.children||[],transitions:l,getTransitionByType:c,getRendererByElement:h,eventHandler:u},r))}for(let S of T){let A=h(S.next),B=f.width||0,F=f.height||0,W=x*B,z=v*F,k=d.anchorX??0,G=d.anchorY??0,N=d.width||0,O=d.height||0,Y=k*N,lt=G*O,bt={...S.prev,x:(S.prev.x||0)+Y,y:(S.prev.y||0)+lt},It={...S.next,x:(S.next.x||0)+W,y:(S.next.y||0)+z};_.push(A.update(t,{parent:p,prevElement:bt,nextElement:It,elements:f.children||[],transitions:l,getTransitionByType:c,getRendererByElement:h,eventHandler:u},r))}f.children&&f.children.length>0&&p.children.sort((S,A)=>{let B=f.children.find(W=>W.id===S.label),F=f.children.find(W=>W.id===A.label);if(B&&F){let W=B.zIndex??0,z=F.zIndex??0;if(W!==z)return W-z;let k=f.children.indexOf(B),G=f.children.indexOf(F);return k-G}if(!B&&!F)return 0;if(!B)return-1;if(!F)return 1}),await Promise.all(_);let{width:w,height:C}=this.getContainerDimensions(f,p),M=x*w,P=v*C;p.pivot.x=M,p.pivot.y=P};layoutChildren({element:t,anchor:e,totalWidth:r,totalHeight:s,gap:o,direction:n,scroll:a}){let h=n==="horizontal",l=h?"x":"y",c=h?"y":"x",u=h?"width":"height",d=h?"height":"width",f=h?r:s,p=h?s:r,g=h?e.x:e.y,x=h?e.y:e.x;if(!a&&t[u]!==void 0&&t[u]<f){let _=0,y=0,T=0,E=0;(t.children||[]).forEach((w,C)=>{_>0&&_+w[u]>t[u]&&(this.alignRowElements(t.children.slice(E,C),l,g,t[u]),_=0,y+=T+o,T=0,E=C),w[l]=_,w[c]=y,_+=w[u],C<t.children.length-1&&(_+=o),T=Math.max(T,w[d]||0)}),E<t.children.length&&this.alignRowElements(t.children.slice(E),l,g,t[u])}else{if(g===0){let _=0;(t.children||[]).forEach((y,T)=>{let E=y[u]||0,w=h?y.anchorX||0:y.anchorY||0;y[l]=_+E*w,_+=E,T<t.children.length-1&&(_+=o)})}else if(g===1){let _=-f;(t.children||[]).forEach((y,T)=>{let E=y[u]||0,w=h?y.anchorX||0:y.anchorY||0;y[l]=_+E*w,_+=E,T<t.children.length-1&&(_+=o)})}else if(g===.5){let _=-f/2;(t.children||[]).forEach((y,T)=>{let E=y[u]||0,w=h?y.anchorX||0:y.anchorY||0;y[l]=_+E*w,_+=E,T<t.children.length-1&&(_+=o)})}x===0?(t.children||[]).forEach(_=>{let y=_[d]||0,T=h?_.anchorY||0:_.anchorX||0;_[c]=y*T}):x===.5?(t.children||[]).forEach(_=>{let y=_[d]||0,T=h?_.anchorY||0:_.anchorX||0;_[c]=-y/2+y*T}):x===1&&(t.children||[]).forEach(_=>{let y=_[d]||0,T=h?_.anchorY||0:_.anchorX||0;_[c]=-y+y*T})}}alignRowElements(t,e,r,s){if(!t.length)return;let o=t.reduce((n,a,h)=>n+a[e==="x"?"width":"height"]+(h>0,0),0);if(r===.5){let a=(s-o)/2;t.forEach(h=>{h[e]=a,a+=h[e==="x"?"width":"height"]+0})}else if(r===1){let a=s-o;t.forEach(h=>{h[e]=a,a+=h[e==="x"?"width":"height"]+0})}}createContainerGraphic(t,e,r,s){let o=new Qt().roundRect(0,0,e,r,1).fill(t.fill?t.fill.color:"transparent");return s.x===1&&(o.x-=t.width),s.x===.5&&(o.x-=t.width/2),s.y===1&&(o.y-=t.height),s.y===.5&&(o.y-=t.height/2),o}getContainerDimensions(t,e){let r=t.width||0,s=t.height||0;if(!t.direction&&(!t.width||!t.height)&&e.children&&e.children.length>0){let o=1/0,n=-1/0,a=1/0,h=-1/0;e.children.forEach(l=>{let c=l.x||0,u=l.y||0,d=l.width||0,f=l.height||0;o=Math.min(o,c),n=Math.max(n,c+d),a=Math.min(a,u),h=Math.max(h,u+f)}),t.width||(r=n-o,(isNaN(r)||!isFinite(r))&&(r=0)),t.height||(s=h-a,(isNaN(s)||!isFinite(s))&&(s=0))}return{width:r,height:s}}setupScrolling({container:t,element:e,totalHeight:r,totalWidth:s,eventHandler:o,sliderRef:n}){let a=e.scroll&&e.height&&r>e.height,h=e.scroll&&e.width&&s>e.width;if(a||h){let l=0,c=0,u=-r+e.height,d=-s+e.width,f=new Qt().rect(0,0,e.width||s,e.height||r).fill("red");t.mask=f,t.eventMode="static",t.addChild(f),t.on("wheel",p=>{if(a&&p.deltaY!==0&&(l-p.deltaY>0||l-p.deltaY<u||(l-=p.deltaY,t.y-=p.deltaY,f.y+=p.deltaY)),h&&(p.deltaX!==0||p.shiftKey&&p.deltaY!==0)){let g=p.deltaX!==0?p.deltaX:p.deltaY;if(c-g>0||c-g<d)return;c-=g,t.x-=g,f.x+=g}})}}};var tU={linear:i=>i},eU=(i,t,e,r)=>i+(t-i)*tU[r](e);function sR(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s of t){if(r==null)return e;r=r[s]}return r===void 0?e:r}function oR(i,t,e){typeof t=="string"&&(t=t.split("."));let r=i;for(let s=0;s<t.length-1;s++){let o=t[s];o in r||(r[o]={}),r=r[o]}return r[t[t.length-1]]=e,i}var rU=(i,t)=>{let e=[],r=0,s;i.forEach(({value:n,duration:a,easing:h,relative:l},c)=>{c===0?(s=n,e.push({time:r,value:n,easing:"linear"})):a!==void 0&&h!==void 0&&(r+=a,l?s=s+n:s=n,e.push({time:r,value:s,easing:h}))});let o=0;for(let n=0;n<e.length-1;n++){let{time:a,value:h,easing:l}=e[n],{time:c,value:u}=e[n+1];if(t>=a&&t<=c){let d=(t-a)/(c-a);o=eU(h,u,d,l);break}else t>c&&(o=u)}return o};function iU(i){return Math.max.apply(null,i)}var gx=class{static rendererName="pixi";rendererName="pixi";transitionType="keyframes";_transition=async(t,e,r,s)=>new Promise((o,n)=>{if(s?.aborted){n(new DOMException("Operation aborted","AbortError"));return}let{properties:a}=r,h=Array.isArray(a)?a:Object.entries(a).map(([x,v])=>({...v,property:x})),l=h.map(x=>x.keyframes.reduce((v,_)=>v+_.duration||0,0)),c=iU(l),u=0,d={};h.forEach(x=>{d[x.property]=sR(e,x.property)});let f=x=>{let v={};h.forEach(_=>{let y=[];_.initialValue!==void 0?y=[{value:_.initialValue,duration:0}]:y=[{value:d[_.property],duration:0}],y=y.concat(_.keyframes),oR(v,_.property,rU(y,x))}),h.forEach(_=>{let{property:y}=_;e&&!e.destroyed&&oR(e,y,sR(v,y))})},p=()=>{t.ticker.remove(g),f(c)};s&&s.addEventListener("abort",()=>{p(),n(new DOMException("Operation aborted","AbortError"))});let g=x=>{if(u+=x.deltaMS,u>=c){t.ticker.remove(g),o();return}f(u)};if(s?.aborted){p(),n(new DOMException("Operation aborted","AbortError"));return}t.ticker.add(g)});add=async(t,e,r,s)=>this._transition(t,e,r,s);remove=async(t,e,r,s)=>this._transition(t,e,r,s)};var xx=class{static rendererName="pixi";rendererName="pixi";rendererType="rect";add=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a,eventHandler:h}=e,l=new Qt;l.label=o.id,l.interactiveChildren=!1,l.eventMode="none",o.x!==void 0&&(l.x=o.x),o.y!==void 0&&(l.y=o.y),o.alpha!==void 0&&(l.alpha=o.alpha),o.scaleX!==void 0&&(l.scale.x=o.scaleX),o.scaleY!==void 0&&(l.scale.y=o.scaleY),o.rotation!==void 0&&(l.rotation=o.rotation*Math.PI/180),o.cursor&&(l.cursor=o.cursor),o.pointerDown&&l.on("pointerdown",f=>{f.stopPropagation(),h&&h(o.pointerDown,{x:f.global.x,y:f.global.y})}),o.pointerUp&&l.on("pointerup",f=>{f.stopPropagation(),h&&h(o.pointerUp,{x:f.global.x,y:f.global.y})}),o.pointerMove&&l.on("pointermove",f=>{f.stopPropagation(),h&&h(o.pointerMove,{x:f.global.x,y:f.global.y})}),(o.cursor||o.pointerDown||o.pointerUp||o.pointerMove)&&(l.eventMode="static");let c=o.width,u=o.height;l.roundRect(0,0,c,u,o.radius??0),o.fill&&l.fill(o.fill),o.border&&l.stroke({width:o.border.width,color:o.border.color,alpha:o.border.alpha??1,alignment:o.border.alignment??1}),o.anchorX!==void 0&&(l.pivot.x=c*o.anchorX),o.anchorY!==void 0&&(l.pivot.y=u*o.anchorY),(o.clickEventName||o.rightClickEventName)&&h&&(l.eventMode="static",l.on("pointerup",f=>{f.stopPropagation(),f.button===0?h(o.clickEventName,o.clickEventPayload):f.button===2&&h(o.rightClickEventName,o.rightClickEventPayload)})),o.wheelEventName&&h&&(l.eventMode="static",l.on("wheel",f=>{f.stopPropagation(),h(o.wheelEventName,{deltaY:f.deltaY})}));let d=[];for(let f of n)if(f.elementId===o.id&&f.event===he.Add){let p=a(f.type);if(!p)throw new Error(`Transition class not found for type ${f.type}`);d.push(p.add(t,l,f,r))}s.addChild(l),await Promise.all(d)};remove=async(t,e,r)=>{if(r?.aborted)throw new DOMException("Operation aborted","AbortError");let{parent:s,element:o,transitions:n=[],getTransitionByType:a}=e,h=s.getChildByName(o.id);if(!h)throw new Error(`Rect with id ${o.id} not found`);let l=[];for(let c of n)if(c.elementId===o.id&&c.event===he.Remove){let u=a(c.type);if(!u)throw new Error(`Transition class not found for type ${c.type}`);l.push(u.remove(t,h,c,r))}await Promise.all(l),h&&h.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o=[],getTransitionByType:n,eventHandler:a},h)=>{if(h?.aborted)throw new DOMException("Operation aborted","AbortError");let l=e.getChildByName(r.id);if(!l)throw new Error(`Rect with id ${r.id} not found`);let c=[];for(let u of o)if(u.elementId===r.id&&u.event===he.Update){let d=n(u.type);if(!d)throw new Error(`Transition class not found for type ${u.type}`);c.push(d.add(t,l,u,h))}if(c.length>0)await Promise.all(c),(r.width!==s.width||r.height!==s.height||r.fill!==s.fill)&&(l.clear(),l.rect(0,0,s.width,s.height),l.fill(s.fill)),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY);else{r.x!==void 0&&s.x!==r.x&&(l.x=s.x),r.y!==void 0&&s.y!==r.y&&(l.y=s.y),r.alpha!==void 0&&s.alpha!==r.alpha&&(l.alpha=s.alpha),r.scaleX!==void 0&&s.scaleX!==r.scaleX&&(l.scale.x=s.scaleX),r.scaleY!==void 0&&s.scaleY!==r.scaleY&&(l.scale.y=s.scaleY),r.rotation!==void 0&&s.rotation!==r.rotation&&(l.rotation=s.rotation*Math.PI/180);let u=JSON.stringify(r.border)!==JSON.stringify(s.border);(r.width!==s.width||r.height!==s.height||r.radius!==s.radius||r.fill!==s.fill||u)&&(l.clear(),l.roundRect(0,0,s.width,s.height,s.radius??0),s.fill&&l.fill(s.fill),s.border&&l.stroke({width:s.border.width,color:s.border.color,alpha:s.border.alpha??1,alignment:s.border.alignment??1})),r.anchorX!==void 0&&s.anchorX!==r.anchorX&&(l.pivot.x=s.width*s.anchorX),r.anchorY!==void 0&&s.anchorY!==r.anchorY&&(l.pivot.y=s.height*s.anchorY)}}};var _x=class extends Bi{static rendererName="pixi";rendererName="pixi";rendererType="slider";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o,eventHandler:n,ref:a})=>{let{direction:h,idleThumb:l,hoverThumb:c,idleBar:u,hoverBar:d,dragEndEventName:f,dragEventName:p,dragEventPayload:g,initialValue:x}=r,v={horizontal:{axis:"x",size:"width"},vertical:{axis:"y",size:"height"}},_=v[h].axis,y=v[h].size,T=I.from(l),E=I.from(c),w=I.from(u),C=I.from(d),M=new Zt({texture:w,anchor:{x:0,y:0}});M.label=r.id;let P=M[y];M.x=r.x||0,M.y=r.y||0;let S=new Zt({texture:T,anchor:{x:.5,y:.5}});if(S.y=M.height/2,S.x=M.width/2,S.eventMode="static",S.cursor="hover",M.eventMode="static",M.cursor="hover",S.on("pointerdown",F).on("pointerup",W).on("pointerupoutside",W),M.on("pointerdown",A).on("pointerup",B).on("pointerupoutside",B),M.addChild(S),x!==void 0){let G=S[y]/2;S[_]=x/100*(P-S[y])+G}function A(G){S.texture=E,M.texture=C,z(G),t.stage.eventMode="static",t.stage.addEventListener("pointermove",z)}function B(G){S.texture=T,M.texture=w,z(G),t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",z)}function F(G){G.stopPropagation(),S.texture=E,M.texture=C,t.stage.eventMode="static",t.stage.addEventListener("pointermove",z)}function W(G){if(S.texture=T,M.texture=w,t.stage.eventMode="auto",t.stage.removeEventListener("pointermove",z),f){let N=M.toLocal(G.global)[_],O=S[y]/2;S[_]=Math.max(0+O,Math.min(N,P-O));let Y=Math.floor((S[_]-O)/(P-S[y])*100),lt=JSON.stringify(g);n&&n(f,JSON.parse(lt.replace('"{{ value }}"',String(Y))))}}function z(G){let N=M.toLocal(G.global)[_],O=S[y]/2;S[_]=Math.max(0+O,Math.min(N,P-O));let Y=Math.floor((S[_]-O)/(P-S[y])*100);if(p){let lt=JSON.stringify(g);n&&n(p,JSON.parse(lt.replace('"{{ value }}"',String(Y))))}return Y}a&&(a.current={updateValue:G=>{let N=S[y]/2;S[_]=G/100*(P-S[y])+N}});let k=[];for(let G of s)if(G.elementId===r.id&&G.event===he.Add){let N=o(G.type);if(!N)throw new Error(`Transition class not found for type ${G.type}`);k.push(N.add(t,M,G))}e.addChild(M),await Promise.all(k)};remove=async(t,e)=>{let{parent:r,element:s,transitions:o=[],getTransitionByType:n}=e,a=r.getChildByName(s.id);if(!a){console.warn(`Sprite with id ${s.id} not found`);return}let h=[];for(let l of o)if(l.elementId===s.id&&l.event===he.Remove){let c=n(l.type);if(!c)throw new Error(`Transition class not found for type ${l.type}`);h.push(c.remove(t,a,l))}await Promise.all(h),a.destroy()};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n,eventHandler:a})=>{if(!e.getChildByName(r.id)){console.warn(`Slider with id ${r.id} not found`,{parent:e});return}JSON.stringify(r)!==JSON.stringify(s)&&await Promise.all([this.remove(t,{parent:e,element:r,transitions:o,getTransitionByType:n,eventHandler:a}),this.add(t,{parent:e,element:s,transitions:o,getTransitionByType:n,eventHandler:a})])}};var yx=class extends Bi{static rendererName="pixi";rendererName="pixi";rendererType="audio";add=async(t,{parent:e,element:r,transitions:s=[],getTransitionByType:o})=>{r.delay?setTimeout(()=>{t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})},r.delay):t.audioStage.add({id:r.id,url:r.url,loop:r.loop??!1,volume:r.volume??1})};remove=async(t,e)=>{let{element:r}=e;t.audioStage.remove(r.id)};update=async(t,{parent:e,prevElement:r,nextElement:s,transitions:o,getTransitionByType:n})=>{if(r.url!==s.url||r.volume!==s.volume){let a=t.audioStage.getById(r.id);a&&(a.url=s.url,a.volume=s.volume??1)}}};var bx=class{constructor(){this.cache=new Map}async load(t){let e=[];for(let[r,s]of Object.entries(t))this.cache.has(r)||e.push([r,s]);e.length>0&&await Promise.all(e.map(async([r,s])=>{let a={buffer:await(await fetch(s.url)).arrayBuffer(),type:s.type};this.cache.set(r,a)}))}getBufferMap(){let t={};for(let[e,r]of this.cache.entries())t[e]=r;return t}clear(){this.cache.clear()}size(){return this.cache.size}has(t){return this.cache.has(t)}},sU=()=>new bx;var j_t=rR;export{Za as Application,sr as Assets,yx as AudioPlugin,mx as ContainerRendererPlugin,gx as KeyframeTransitionPlugin,xx as RectRendererPlugin,_x as SliderRendererPlugin,dx as SpriteRendererPlugin,fx as TextRendererPlugin,px as TextRevealingRendererPlugin,sU as createAssetBufferManager,j_t as default,jh as parse,jh as parseJSONToAST,Xh as renderApp};
|
|
1629
1629
|
/*! Bundled license information:
|
|
1630
1630
|
|
|
1631
1631
|
punycode/punycode.js:
|