"use strict";(self.webpackChunkcomputer_playground=self.webpackChunkcomputer_playground||[]).push([["271"],{1787(e,t,r){r.d(t,{R:()=>n,m:()=>i});let n={name:"texture-bit",vertex:{header:`

        struct TextureUniforms {
            uTextureMatrix:mat3x3<f32>,
        }

        @group(2) @binding(2) var<uniform> textureUniforms : TextureUniforms;
        `,main:`
            uv = (textureUniforms.uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
            @group(2) @binding(0) var uTexture: texture_2d<f32>;
            @group(2) @binding(1) var uSampler: sampler;

         
        `,main:`
            outColor = textureSample(uTexture, uSampler, vUV);
        `}},i={name:"texture-bit",vertex:{header:`
            uniform mat3 uTextureMatrix;
        `,main:`
            uv = (uTextureMatrix * vec3(uv, 1.0)).xy;
        `},fragment:{header:`
        uniform sampler2D uTexture;

         
        `,main:`
            outColor = texture(uTexture, vUV);
        `}}},2896(e,t,r){r.d(t,{q:()=>a});var n=r(6840),i=r(6782);function a(e,t){for(let r in e.attributes){let i=e.attributes[r],a=t[r];a?(i.location??(i.location=a.location),i.format??(i.format=a.format),i.offset??(i.offset=a.offset),i.instance??(i.instance=a.instance)):(0,n.R)(`Attribute ${r} is not present in the shader, but is present in the geometry. Unable to infer attribute details.`)}!function(e){let{buffers:t,attributes:r}=e,n={},a={};for(let e in t){let r=t[e];n[r.uid]=0,a[r.uid]=0}for(let e in r){let t=r[e];n[t.buffer.uid]+=(0,i.m)(t.format).stride}for(let e in r){let t=r[e];t.stride??(t.stride=n[t.buffer.uid]),t.start??(t.start=a[t.buffer.uid]),a[t.buffer.uid]+=(0,i.m)(t.format).stride}}(e)}},9392(e,t,r){r.d(t,{g:()=>i});var n=r(673);let i=[];i[n.K.NONE]=void 0,i[n.K.DISABLED]={stencilWriteMask:0,stencilReadMask:0},i[n.K.RENDERING_MASK_ADD]={stencilFront:{compare:"equal",passOp:"increment-clamp"},stencilBack:{compare:"equal",passOp:"increment-clamp"}},i[n.K.RENDERING_MASK_REMOVE]={stencilFront:{compare:"equal",passOp:"decrement-clamp"},stencilBack:{compare:"equal",passOp:"decrement-clamp"}},i[n.K.MASK_ACTIVE]={stencilWriteMask:0,stencilFront:{compare:"equal",passOp:"keep"},stencilBack:{compare:"equal",passOp:"keep"}}},6094(e,t,r){r.d(t,{l:()=>h});var n=r(6253),i=r(3203),a=r(8181),s=r(7949),o=r(40),l=r(3257),d=r(7633),u=r(209),c=r(4611);class h{constructor(e){this.rootViewPort=new i.M,this.viewport=new i.M,this.onRenderTargetChange=new s.C("onRenderTargetChange"),this.projectionMatrix=new n.u,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._renderer=e}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:r,frame:n}){let i;this._renderTargetStack.length=0,this.push(e,t,r,n),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=(i=this.rootRenderTarget.colorTexture.source.resource,globalThis.HTMLCanvasElement&&i instanceof HTMLCanvasElement&&document.body.contains(i))}bind(e,t=!0,r,n){var i,a,s;let o,l=this.getRenderTarget(e),u=this.renderTarget!==l;this.renderTarget=l,this.renderSurface=e;let c=this.getGpuRenderTarget(l);(l.pixelWidth!==c.width||l.pixelHeight!==c.height)&&(this.adaptor.resizeGpuRenderTarget(l),c.width=l.pixelWidth,c.height=l.pixelHeight);let h=l.colorTexture,p=this.viewport,f=h.pixelWidth,g=h.pixelHeight;if(!n&&e instanceof d.g&&(n=e.frame),n){let e=h._resolution;p.x=n.x*e+.5|0,p.y=n.y*e+.5|0,p.width=n.width*e+.5|0,p.height=n.height*e+.5|0}else p.x=0,p.y=0,p.width=f,p.height=g;return i=this.projectionMatrix,a=p.width/h.resolution,s=p.height/h.resolution,o=l.isRoot?-1:1,i.identity(),i.a=1/a*2,i.d=1/s*2*o,i.tx=-1-0*i.a,i.ty=-o-0*i.d,this.adaptor.startRenderPass(l,t,r,p),u&&this.onRenderTargetChange.emit(l),l}clear(e,t=a.u.ALL,r){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,r,this.viewport))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=a.u.ALL,r,n){let i=this.bind(e,t,r,n);return this._renderTargetStack.push({renderTarget:i,frame:n}),i}pop(){this._renderTargetStack.pop();let e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,r,n,i){r.x<0&&(n.width+=r.x,i.x-=r.x,r.x=0),r.y<0&&(n.height+=r.y,i.y-=r.y,r.y=0);let{pixelWidth:a,pixelHeight:s}=e;return n.width=Math.min(n.width,a-r.x),n.height=Math.min(n.height,s-r.y),this.adaptor.copyToTexture(e,t,r,n,i)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport))}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e!==t&&e.destroy()}),this._renderSurfaceToRenderTargetHash.clear(),this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;return o.q.test(e)&&(e=(0,u.c)(e)),e instanceof c.O?t=e:e instanceof l.v&&(t=new c.O({colorTextures:[e]}),o.q.test(e.source.resource)&&(t.isRoot=!0),e.once("destroy",()=>{t.destroy();let e=this._gpuRenderTargetHash[t.uid];e&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(e))})),this._renderSurfaceToRenderTargetHash.set(e,t),t}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}}},1217(e,t,r){r.d(t,{f:()=>eg,i:()=>ef});var n=r(3071);class i{constructor(e){this._renderer=e}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}function a(e,t){let r=e.instructionSet,n=r.instructions;for(let e=0;e<r.instructionSize;e++){let r=n[e];t[r.renderPipeId].execute(r)}}i.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"customRender"};class s{constructor(e){this._renderer=e}addRenderGroup(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&(this._renderer.globalUniforms.push({worldTransformMatrix:e.worldTransform,worldColor:e.worldColorAlpha}),a(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop())}destroy(){this._renderer=null}}s.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"renderGroup"};var o=r(6253);function l(e,t,r){!(e.globalDisplayStatus<7)&&e.includeInBuild&&(e.sortableChildren&&e.sortChildren(),e.isSimple?function(e,t,r){if(e.renderPipeId&&(r.blendMode.setBlendMode(e,e.groupBlendMode,t),e.didViewUpdate=!1,r[e.renderPipeId].addRenderable(e,t)),!e.isRenderGroupRoot){let n=e.children,i=n.length;for(let e=0;e<i;e++)l(n[e],t,r)}}(e,t,r):d(e,t,r,!1))}function d(e,t,r,n){if(!n&&e.isRenderGroupRoot)r.renderGroup.addRenderGroup(e.renderGroup,t);else{for(let n=0;n<e.effects.length;n++){let i=e.effects[n];r[i.pipe].push(i,e,t)}let n=e.renderPipeId;n&&(r.blendMode.setBlendMode(e,e.groupBlendMode,t),e.didViewUpdate=!1,r[n].addRenderable(e,t));let i=e.children;if(i.length)for(let e=0;e<i.length;e++)l(i[e],t,r);for(let n=e.effects.length-1;n>=0;n--){let i=e.effects[n];r[i.pipe].pop(i,e,t)}}}var u=r(1873);function c(e,t){let r,n,i;return 0xffffff===e||0xffffff===t?e+t-0xffffff:((r=e>>16&255)+((t>>16&255)-r)*.5<<16)+((n=e>>8&255)+((t>>8&255)-n)*.5<<8)+((i=255&e)+((255&t)-i)*.5)}let h=new u.mc;function p(e,t,r){if(r&u.ig){e.groupColor=c(e.localColor,t.groupColor);let r=e.localAlpha*t.groupAlpha;e.groupAlpha=r=r<0?0:r>1?1:r,e.groupColorAlpha=e.groupColor+(255*r<<24)}r&u.u&&(e.groupBlendMode="inherit"===e.localBlendMode?t.groupBlendMode:e.localBlendMode),r&u.fR&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}let f=new o.u;class g{constructor(e){this._renderer=e}render({container:e,transform:t}){e.isRenderGroup=!0;let r=e.parent,n=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let i=this._renderer,s=function e(t,r=[]){r.push(t);for(let n=0;n<t.renderGroupChildren.length;n++)e(t.renderGroupChildren[n],r);return r}(e.renderGroup,[]),o=f;t&&(o=o.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));let l=i.renderPipes;for(let e=0;e<s.length;e++){let t=s[e];t.runOnRender(),t.instructionSet.renderPipes=l,t.structureDidChange||function(e,t){let{list:r,index:n}=e.childrenRenderablesToUpdate,i=!1;for(let e=0;e<n;e++){let n=r[e];if(i=t[n.renderPipeId].validateRenderable(n))break}e.structureDidChange=i}(t,l),function e(t,r=!1){!function(e){let t,r=e.root;if(e.renderGroupParent){let n=e.renderGroupParent;e.worldTransform.appendFrom(r.relativeGroupTransform,n.worldTransform),e.worldColor=c(r.groupColor,n.worldColor),t=r.groupAlpha*n.worldAlpha}else e.worldTransform.copyFrom(r.localTransform),e.worldColor=r.localColor,t=r.localAlpha;e.worldAlpha=t=t<0?0:t>1?1:t,e.worldColorAlpha=e.worldColor+(255*t<<24)}(t);let n=t.childrenToUpdate,i=t.updateTick;for(let e in t.updateTick++,n){let t=n[e],r=t.list,a=t.index;for(let e=0;e<a;e++)!function e(t,r,n){if(r===t.updateTick)return;t.updateTick=r,t.didChange=!1;let i=t.localTransform;t.updateLocalTransform();let a=t.parent;if(a&&!a.isRenderGroupRoot?(n|=t._updateFlags,t.relativeGroupTransform.appendFrom(i,a.relativeGroupTransform),n&&p(t,a,n)):(n=t._updateFlags,t.relativeGroupTransform.copyFrom(i),n&&p(t,h,n)),!t.isRenderGroupRoot){let i=t.children,a=i.length;for(let t=0;t<a;t++)e(i[t],r,n);let s=t.renderGroup;t.renderPipeId&&!s.structureDidChange&&s.updateRenderable(t)}}(r[e],i,0);t.index=0}if(r)for(let n=0;n<t.renderGroupChildren.length;n++)e(t.renderGroupChildren[n],r)}(t),t.structureDidChange?(t.structureDidChange=!1,function(e,t){let r=e.root,n=e.instructionSet;n.reset(),t.batch.buildStart(n),t.blendMode.buildStart(),t.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),d(r,n,t,!0),t.batch.buildEnd(n),t.blendMode.buildEnd(n)}(t,l)):function(e){let{list:t,index:r}=e.childrenRenderablesToUpdate;for(let n=0;n<r;n++){let r=t[n];r.didViewUpdate&&e.updateRenderable(r)}}(t),t.childrenRenderablesToUpdate.index=0,i.renderPipes.batch.upload(t.instructionSet)}i.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),a(e.renderGroup,l),l.uniformBatch&&l.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(o),e.parent=r,e.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}}g.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem,n.Ag.CanvasSystem],name:"renderGroup"};var m=r(2078),x=r(9786);class _{constructor(e){this._gpuSpriteHash=Object.create(null),this._renderer=e}addRenderable(e,t){let r=this._getGpuSprite(e);e._didSpriteUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r)}updateRenderable(e){let t=this._gpuSpriteHash[e.uid];e._didSpriteUpdate&&this._updateBatchableSprite(e,t),t.batcher.updateElement(t)}validateRenderable(e){let t=e._texture,r=this._getGpuSprite(e);return r.texture._source!==t._source&&!r.batcher.checkAndUpdateTexture(r,t)}destroyRenderable(e){let t=this._gpuSpriteHash[e.uid];m.Z.return(t),this._gpuSpriteHash[e.uid]=null}_updateBatchableSprite(e,t){e._didSpriteUpdate=!1,t.bounds=e.bounds,t.texture=e._texture}_getGpuSprite(e){return this._gpuSpriteHash[e.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=m.Z.get(x.K);return t.renderable=e,t.texture=e._texture,t.bounds=e.bounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,this._gpuSpriteHash[e.uid]=t,e._didSpriteUpdate=!1,e.on("destroyed",()=>{this.destroyRenderable(e)}),t}destroy(){for(let e in this._gpuSpriteHash)m.Z.return(this._gpuSpriteHash[e]);this._gpuSpriteHash=null,this._renderer=null}}_.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"sprite"};var b=r(1447),v=r(8022),k=r(2825);class T{constructor(e,t){this.state=b.U.for2d(),this._batches=Object.create(null),this._geometries=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init(this)}buildStart(e){if(!this._batches[e.uid]){let t=new k.i;this._batches[e.uid]=t,this._geometries[t.uid]=new v.J}this._activeBatch=this._batches[e.uid],this._activeGeometry=this._geometries[this._activeBatch.uid],this._activeBatch.begin()}addToBatch(e){this._activeBatch.add(e)}break(e){this._activeBatch.break(e)}buildEnd(e){let t=this._activeBatch,r=this._activeGeometry;t.finish(e),r.indexBuffer.setDataWithSize(t.indexBuffer,t.indexSize,!0),r.buffers[0].setDataWithSize(t.attributeBuffer.float32View,t.attributeSize,!1)}upload(e){let t=this._batches[e.uid],r=this._geometries[t.uid];t.dirty&&(t.dirty=!1,r.buffers[0].update(4*t.attributeSize))}execute(e){if("startBatch"===e.action){let t=e.batcher,r=this._geometries[t.uid];this._adaptor.start(this,r)}this._adaptor.execute(this,e)}destroy(){for(let e in this.state=null,this.renderer=null,this._adaptor.destroy(),this._adaptor=null,this._batches)this._batches[e].destroy();for(let e in this._batches=null,this._geometries)this._geometries[e].destroy();this._geometries=null}}T.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"batch"};var M=r(3757),C=r(2378),S=r(9305),y=r(8625),P=r(9880),G=r(9270),w="struct GlobalFilterUniforms {\n  uInputSize:vec4<f32>,\n  uInputPixel:vec4<f32>,\n  uInputClamp:vec4<f32>,\n  uOutputFrame:vec4<f32>,\n  uGlobalFrame:vec4<f32>,\n  uOutputTexture:vec4<f32>,  \n};\n\nstruct MaskUniforms {\n  uFilterMatrix:mat3x3<f32>,\n  uMaskClamp:vec4<f32>,\n  uAlpha:f32,\n};\n\n\n@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;\n@group(0) @binding(1) var uTexture: texture_2d<f32>;\n@group(0) @binding(2) var uSampler : sampler;\n\n@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;\n@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;\n\nstruct VSOutput {\n    @builtin(position) position: vec4<f32>,\n    @location(0) uv : vec2<f32>,\n    @location(1) filterUv : vec2<f32>,\n  };\n\nfn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>\n{\n    var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;\n\n    position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;\n    position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;\n\n    return vec4(position, 0.0, 1.0);\n}\n\nfn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n    return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);\n}\n\nfn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>\n{\n  return  (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);  \n}\n\nfn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>\n{\n  return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;\n}\n\nfn getSize() -> vec2<f32>\n{\n\n  \n  return gfu.uGlobalFrame.zw;\n}\n  \n@vertex\nfn mainVertex(\n  @location(0) aPosition : vec2<f32>, \n) -> VSOutput {\n  return VSOutput(\n   filterVertexPosition(aPosition),\n   filterTextureCoord(aPosition),\n   getFilterCoord(aPosition)\n  );\n}\n\n@fragment\nfn mainFragment(\n  @location(0) uv: vec2<f32>,\n  @location(1) filterUv: vec2<f32>,\n  @builtin(position) position: vec4<f32>\n) -> @location(0) vec4<f32> {\n\n    var maskClamp = filterUniforms.uMaskClamp;\n\n     var clip = step(3.5,\n        step(maskClamp.x, filterUv.x) +\n        step(maskClamp.y, filterUv.y) +\n        step(filterUv.x, maskClamp.z) +\n        step(filterUv.y, maskClamp.w));\n\n    var mask = textureSample(uMaskTexture, uSampler, filterUv);\n    var source = textureSample(uTexture, uSampler, uv);\n    \n    var npmAlpha = 0.0;\n\n    var alphaMul = 1.0 - npmAlpha * (1.0 - mask.a);\n\n    var a = (alphaMul * mask.r) * clip;\n\n    return vec4(source.rgb, source.a) * a;\n}";class A extends G.d{constructor(e){const{sprite:t,...r}=e,n=new P.N(t.texture),i=new y.k({uFilterMatrix:{value:new o.u,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"}});super({...r,gpuProgram:S.B.from({vertex:{source:w,entryPoint:"mainVertex"},fragment:{source:w,entryPoint:"mainFragment"}}),glProgram:C.M.from({vertex:"in vec2 aPosition;\n\nout vec2 vTextureCoord;\nout vec2 vMaskCoord;\n\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\nuniform mat3 uFilterMatrix;\n\nvec4 filterVertexPosition(  vec2 aPosition )\n{\n    vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;\n       \n    position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;\n    position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;\n\n    return vec4(position, 0.0, 1.0);\n}\n\nvec2 filterTextureCoord(  vec2 aPosition )\n{\n    return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvec2 getFilterCoord( vec2 aPosition )\n{\n    return  ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0)  ).xy;\n}   \n\nvoid main(void)\n{\n    gl_Position = filterVertexPosition(aPosition);\n    vTextureCoord = filterTextureCoord(aPosition);\n    vMaskCoord = getFilterCoord(aPosition);\n}\n",fragment:"in vec2 vMaskCoord;\nin vec2 vTextureCoord;\n\nuniform sampler2D uTexture;\nuniform sampler2D uMaskTexture;\n\nuniform float uAlpha;\nuniform vec4 uMaskClamp;\n\nout vec4 finalColor;\n\nvoid main(void)\n{\n    float clip = step(3.5,\n        step(uMaskClamp.x, vMaskCoord.x) +\n        step(uMaskClamp.y, vMaskCoord.y) +\n        step(vMaskCoord.x, uMaskClamp.z) +\n        step(vMaskCoord.y, uMaskClamp.w));\n\n    // TODO look into why this is needed\n    float npmAlpha = uAlpha; \n    vec4 original = texture(uTexture, vTextureCoord);\n    vec4 masky = texture(uMaskTexture, vMaskCoord);\n    float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);\n\n    original *= (alphaMul * masky.r * uAlpha * clip);\n\n    finalColor = original;\n}\n",name:"mask-filter"}),resources:{filterUniforms:i,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=n}apply(e,t,r,n){this._textureMatrix.texture=this.sprite.texture,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=this.sprite.texture.source,e.applyFilter(this,t,r,n)}}var R=r(6904),B=r(2151),U=r(7088),F=r(7633),I=r(3097);let O=new R.c;class E extends M.a{constructor(){super({filters:[new A({sprite:new U.k(F.g.EMPTY)})]})}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}}class D{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,r){let n=this._renderer;if(n.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,canBundle:!1,maskedContainer:t}),e.renderMaskToTexture){let t=e.mask;t.includeInBuild=!0,l(t,r,n.renderPipes),t.includeInBuild=!1}n.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,canBundle:!1})}execute(e){let t=this._renderer,r=e.mask.renderMaskToTexture;if("pushMaskBegin"===e.action){let n=m.Z.get(E);if(r){e.mask.mask.measurable=!0;let r=(0,B.fB)(e.mask.mask,!0,O);e.mask.mask.measurable=!1,r.ceil();let i=I.W.getOptimalTexture(r.width,r.height,1,!1);t.renderTarget.push(i,!0),t.globalUniforms.push({offset:r,worldColor:0xffffffff});let a=n.sprite;a.texture=i,a.worldTransform.tx=r.minX,a.worldTransform.ty=r.minY,this._activeMaskStage.push({filterEffect:n,maskedContainer:e.maskedContainer,filterTexture:i})}else n.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:n,maskedContainer:e.maskedContainer})}else if("pushMaskEnd"===e.action){let e=this._activeMaskStage[this._activeMaskStage.length-1];r&&(t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:"filter",action:"pushFilter",container:e.maskedContainer,filterEffect:e.filterEffect,canBundle:!1})}else if("popMaskEnd"===e.action){t.filter.pop();let e=this._activeMaskStage.pop();r&&I.W.returnTexture(e.filterTexture),m.Z.return(e.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}D.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"alphaMask"};class W{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,r){this._renderer.renderPipes.batch.break(r);let n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);let n=this._colorStack;this._colorStackIndex--;let i=n[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,r.add({renderPipeId:"colorMask",colorMask:i,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._colorStack=null}}W.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"colorMask"};var H=r(8181),L=r(673);class z{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,r){var n;let i=this._renderer;i.renderPipes.batch.break(r),i.renderPipes.blendMode.setBlendMode(e.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,canBundle:!1});let a=e.mask;a.includeInBuild=!0,this._maskHash.has(e)||this._maskHash.set(e,{instructionsStart:0,instructionsLength:0});let s=this._maskHash.get(e);s.instructionsStart=r.instructionSize,l(a,r,i.renderPipes),a.includeInBuild=!1,i.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,canBundle:!1});let o=r.instructionSize-s.instructionsStart-1;s.instructionsLength=o;let d=i.renderTarget.renderTarget.uid;(n=this._maskStackHash)[d]??(n[d]=0)}pop(e,t,r){let n=this._renderer;n.renderPipes.batch.break(r),n.renderPipes.blendMode.setBlendMode(e.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",canBundle:!1});let i=this._maskHash.get(e);for(let e=0;e<i.instructionsLength;e++)r.instructions[r.instructionSize++]=r.instructions[i.instructionsStart++];r.add({renderPipeId:"stencilMask",action:"popMaskEnd",canBundle:!1})}execute(e){var t;let r=this._renderer,n=r.renderTarget.renderTarget.uid,i=(t=this._maskStackHash)[n]??(t[n]=0);"pushMaskBegin"===e.action?(r.renderTarget.ensureDepthStencil(),r.stencil.setStencilMode(L.K.RENDERING_MASK_ADD,i),i++,r.colorMask.setMask(0)):"pushMaskEnd"===e.action?(r.stencil.setStencilMode(L.K.MASK_ACTIVE,i),r.colorMask.setMask(15)):"popMaskBegin"===e.action?(r.colorMask.setMask(0),0!==i?r.stencil.setStencilMode(L.K.RENDERING_MASK_REMOVE,i):(r.renderTarget.clear(null,H.u.STENCIL),r.stencil.setStencilMode(L.K.DISABLED,i)),i--):"popMaskEnd"===e.action&&(r.stencil.setStencilMode(L.K.MASK_ACTIVE,i),r.colorMask.setMask(15)),this._maskStackHash[n]=i}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}z.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"stencilMask"};var V=r(1170);let j=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new V.Q(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...e.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};j.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem,n.Ag.CanvasSystem],name:"background",priority:0},j.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};var K=r(6840);let N={};n.XO.handle(n.Ag.BlendMode,e=>{if(!e.name)throw Error("BlendMode extension must have a name property");N[e.name]=e.ref},e=>{delete N[e.name]});class q{constructor(e){this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e}setBlendMode(e,t,r){if(this._activeBlendMode===t){this._isAdvanced&&this._renderableList.push(e);return}this._activeBlendMode=t,this._isAdvanced&&this._endAdvancedBlendMode(r),this._isAdvanced=!!N[t],this._isAdvanced&&(this._beginAdvancedBlendMode(r),this._renderableList.push(e))}_beginAdvancedBlendMode(e){this._renderer.renderPipes.batch.break(e);let t=this._activeBlendMode;if(!N[t])return void(0,K.R)(`Unable to assign BlendMode: '${t}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);this._filterHash[t]||(this._filterHash[t]=new M.a({filters:[new N[t]]}));let r={renderPipeId:"filter",action:"pushFilter",renderables:[],filterEffect:this._filterHash[t],canBundle:!1};this._renderableList=r.renderables,e.add(r)}_endAdvancedBlendMode(e){this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){for(let e in this._renderer=null,this._renderableList=null,this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}q.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"blendMode"};let $={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},Z=class e{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof u.mc||e instanceof F.g?{target:e,...t}:{...t,...e}}async image(e){let t=new Image;return t.src=await this.base64(e),t}async base64(t){let{format:r,quality:n}=t=this._normalizeOptions(t,e.defaultImageOptions),i=this.canvas(t);if(void 0!==i.toBlob)return new Promise((e,t)=>{i.toBlob(r=>{if(!r)return void t(Error("ICanvas.toBlob failed!"));let n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)},$[r],n)});if(void 0!==i.toDataURL)return i.toDataURL($[r],n);if(void 0!==i.convertToBlob){let e=await i.convertToBlob({type:$[r],quality:n});return new Promise((t,r)=>{let n=new FileReader;n.onload=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})}throw Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){let t=(e=this._normalizeOptions(e)).target,r=this._renderer;if(t instanceof F.g)return r.texture.generateCanvas(t);let n=r.textureGenerator.generateTexture(e),i=r.texture.generateCanvas(n);return n.destroy(),i}pixels(e){let t=(e=this._normalizeOptions(e)).target,r=this._renderer,n=t instanceof F.g?t:r.textureGenerator.generateTexture(e),i=r.texture.getPixels(n);return t instanceof u.mc&&n.destroy(),i}texture(e){return(e=this._normalizeOptions(e)).target instanceof F.g?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);let t=this.canvas(e),r=document.createElement("a");r.download=e.filename??"image.png",r.href=t.toDataURL("image/png"),document.body.appendChild(r),r.click(),document.body.removeChild(r)}log(e){let t=e.width??200;e=this._normalizeOptions(e);let r=this.canvas(e),n=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`),console.log("%c ",`font-size: 1px; padding: ${t}px 300px; background: url(${n}) no-repeat; background-size: contain;`)}destroy(){this._renderer=null}};Z.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem],name:"extract"},Z.defaultImageOptions={format:"png",quality:1};var J=r(3203),X=r(9625),Y=r(3257);class Q extends F.g{static create(e){return new F.g({source:new Y.v(e)})}resize(e,t,r){return this.source.resize(e,t,r),this}}let ee=new J.M,et=new R.c,er=[0,0,0,0];class en{constructor(e){this._renderer=e}generateTexture(e){e instanceof u.mc&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});let t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,n=e.target,i=e.clearColor;i=i?Array.isArray(i)&&4===i.length?i:V.Q.shared.setValue(i).toArray():er;let a=e.frame?.copyTo(ee)||(0,X.n)(n,et).rectangle;a.width=0|Math.max(a.width,1/t),a.height=0|Math.max(a.height,1/t);let s=Q.create({...e.textureSourceOptions,width:a.width,height:a.height,resolution:t,antialias:r}),l=o.u.shared.translate(-a.x,-a.y);return this._renderer.render({container:n,transform:l,target:s,clearColor:i}),s}destroy(){this._renderer=null}}en.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem],name:"textureGenerator"};var ei=r(8569),ea=r(3372),es=r(2781),eo=r(2031);class el{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:r,worldColor:n,offset:i}){let a,s=this._renderer.renderTarget.renderTarget,l=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:s,worldTransformMatrix:new o.u,worldColor:0xffffffff,offset:new ei.b},d={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||s.size,worldTransformMatrix:r||l.worldTransformMatrix,worldColor:n||l.worldColor,offset:i||l.offset,bindGroup:null},u=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(u);let c=u.uniforms;c.uProjectionMatrix=d.projectionMatrix,c.uResolution=d.resolution,c.uWorldTransformMatrix.copyFrom(d.worldTransformMatrix),c.uWorldTransformMatrix.tx-=d.offset.x,c.uWorldTransformMatrix.ty-=d.offset.y,(0,ea.V)(d.worldColor,c.uWorldColorAlpha,0),u.update(),this._renderer.renderPipes.uniformBatch?a=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(u,!1):(a=this._bindGroupPool.pop()||new es.T,this._activeBindGroups.push(a),a.setResource(u,0)),d.bindGroup=a,this._currentGlobalUniformData=d}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===eo.W.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new y.k({uProjectionMatrix:{value:new o.u,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new o.u,type:"mat3x3<f32>"},uWorldColorAlpha:{value:new Float32Array(4),type:"vec4<f32>"},uResolution:{value:[0,0],type:"vec2<f32>"}},{isStatic:!0})}destroy(){this._renderer=null}}el.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem,n.Ag.CanvasSystem],name:"globalUniforms"};var ed=r(8370);let eu=!1,ec="8.1.1";class eh{constructor(e){this._renderer=e}init(e){if(e.hello){let e=this._renderer.name;this._renderer.type===eo.W.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`);var t=e;if(!eu){if(ed.e.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){let e=[`%c  %c  %c  %c  %c PixiJS %c v${ec} (${t}) http://www.pixijs.com/

`,"background: #E72264; padding:5px 0;","background: #6CA2EA; padding:5px 0;","background: #B5D33D; padding:5px 0;","background: #FED23F; padding:5px 0;","color: #FFFFFF; background: #E72264; padding:5px 0;","color: #E72264; background: #FFFFFF; padding:5px 0;"];globalThis.console.log(...e)}else globalThis.console&&globalThis.console.log(`PixiJS ${ec} - ${t} - http://www.pixijs.com/`);eu=!0}}}}eh.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem,n.Ag.CanvasSystem],name:"hello",priority:-2},eh.defaultOptions={hello:!1};let ep=class e{constructor(e){this._renderer=e,this.count=0,this.checkCount=0}init(t){t={...e.defaultOptions,...t},this.checkCountMax=t.textureGCCheckCountMax,this.maxIdle=t.textureGCAMaxIdle,this.active=t.textureGCActive}postrender(){!this._renderer.renderingToScreen||(this.count++,this.active&&(this.checkCount++,this.checkCount>this.checkCountMax&&(this.checkCount=0,this.run())))}run(){let e=this._renderer.texture.managedTextures;for(let t=0;t<e.length;t++){let r=e[t];r.autoGarbageCollect&&r.resource&&r._touched>-1&&this.count-r._touched>this.maxIdle&&(r._touched=-1,r.unload())}}destroy(){this._renderer=null}};ep.extension={type:[n.Ag.WebGLSystem,n.Ag.WebGPUSystem],name:"textureGC"},ep.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:3600,textureGCCheckCountMax:600},n.XO.add(ep);let ef=[j,el,eh,r(2632).v,g,ep,en,Z],eg=[q,T,_,s,D,z,W,i]}}]);
//# sourceMappingURL=271.d601f1d0.js.map