vizor_2d 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[468],{6554:(e,t,r)=>{r.d(t,{d:()=>d});var n=r(9113),s=r(3012),i=r(8475),a=r(7547);const o=class e extends i.M{constructor(t){super(t={...e.defaultOptions,...t}),this.enabled=!0,this._state=a.U.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,"boolean"==typeof t.antialias?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,r,n){e.applyFilter(this,t,r,n)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(t){const{gpu:r,gl:i,...a}=t;let o,d;return r&&(o=s.B.from(r)),i&&(d=n.M.from(i)),new e({gpuProgram:o,glProgram:d,...a})}};o.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let d=o},780:(e,t,r)=>{r.d(t,{s:()=>o});var n=r(8507),s=r(7547),i=r(2043);const a=class e{constructor(e,t){this.state=s.U.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init?.(this)}static getBatcher(e){return new this._availableBatchers[e]}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new i.J({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(const e in this._activeBatches)this._activeBatches[e].begin()}addToBatch(t,r){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(r);let n=this._activeBatches[t.batcherName];n||(n=this._activeBatches[t.batcherName]=e.getBatcher(t.batcherName),n.begin()),this._activeBatch=n}this._activeBatch.add(t)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);const t=this._activeBatches;for(const e in t){const r=t[e],n=r.geometry;n.indexBuffer.setDataWithSize(r.indexBuffer,r.indexSize,!0),n.buffers[0].setDataWithSize(r.attributeBuffer.float32View,r.attributeSize,!1)}}upload(e){const t=this._batchersByInstructionSet[e.uid];for(const e in t){const r=t[e],n=r.geometry;r.dirty&&(r.dirty=!1,n.buffers[0].update(4*r.attributeSize))}}execute(e){if("startBatch"===e.action){const t=e.batcher,r=t.geometry,n=t.shader;this._adaptor.start(this,r,n)}this._adaptor.execute(this,e)}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(const e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};a.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"batch"},a._availableBatchers=Object.create(null);let o=a;n.XO.handleByMap(n.Ag.Batcher,o._availableBatchers),n.XO.add(i.J)},9824:(e,t,r)=>{r.d(t,{z:()=>k});var n=r(8507),s=r(9049),i=r(9313),a=r(9113),o=r(3012),d=r(5811),l=r(1196),u=r(6554),c="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 uInverse:f32,\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 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 var uAlpha = filterUniforms.uAlpha;\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 var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);\n\n var a: f32 = alphaMul * mask.r * uAlpha * clip;\n\n if (filterUniforms.uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n return source * a;\n}\n";class h extends u.d{constructor(e){const{sprite:t,...r}=e,n=new l.N(t.texture),s=new d.k({uFilterMatrix:{value:new i.u,type:"mat3x3<f32>"},uMaskClamp:{value:n.uClampFrame,type:"vec4<f32>"},uAlpha:{value:1,type:"f32"},uInverse:{value:e.inverse?1:0,type:"f32"}});super({...r,gpuProgram:o.B.from({vertex:{source:c,entryPoint:"mainVertex"},fragment:{source:c,entryPoint:"mainFragment"}}),glProgram:a.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;\nuniform float uInverse;\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 float a = alphaMul * masky.r * npmAlpha * clip;\n\n if (uInverse == 1.0) {\n a = 1.0 - a;\n }\n\n finalColor = original * a;\n}\n",name:"mask-filter"}),clipToViewport:!1,resources:{filterUniforms:s,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=n}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=e?1:0}get inverse(){return 1===this.resources.filterUniforms.uniforms.uInverse}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 p=r(9636),g=r(9443),f=r(0),m=r(8655),_=r(5589),x=r(2437),b=r(5099);const v=new p.c;class T extends s.a{constructor(){super(),this.filters=[new h({sprite:new f.k(_.g.EMPTY),inverse:!1,resolution:"inherit",antialias:"inherit"})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].sprite=e}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}}class k{constructor(e){this._activeMaskStage=[],this._renderer=e}push(e,t,r){const n=this._renderer;if(n.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.renderMaskToTexture){const t=e.mask;t.includeInBuild=!0,t.collectRenderables(r,n,null),t.includeInBuild=!1}n.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"pushMaskEnd",mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"alphaMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){const t=this._renderer,r=e.mask.renderMaskToTexture;if("pushMaskBegin"===e.action){const n=m.Z.get(T);if(n.inverse=e.inverse,r){e.mask.mask.measurable=!0;const r=(0,g.f)(e.mask.mask,!0,v);e.mask.mask.measurable=!1,r.ceil();const s=t.renderTarget.renderTarget.colorTexture.source,i=x.W.getOptimalTexture(r.width,r.height,s._resolution,s.antialias);t.renderTarget.push(i,!0),t.globalUniforms.push({offset:r,worldColor:4294967295});const 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){const e=this._activeMaskStage[this._activeMaskStage.length-1];r&&(t.type===b.W.WEBGL&&t.renderTarget.finishRenderPass(),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();const e=this._activeMaskStage.pop();r&&x.W.returnTexture(e.filterTexture),m.Z.return(e.filterEffect)}}destroy(){this._renderer=null,this._activeMaskStage=null}}k.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"alphaMask"}},360:(e,t,r)=>{r.d(t,{j:()=>d});var n=r(8507),s=r(9049),i=r(3284),a=r(268);const o={};n.XO.handle(n.Ag.BlendMode,(e=>{if(!e.name)throw new Error("BlendMode extension must have a name property");o[e.name]=e.ref}),(e=>{delete o[e.name]}));class d{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode="normal",this._isAdvanced=!1}pushBlendMode(e,t,r){this._blendModeStack.push(t),this.setBlendMode(e,t,r)}popBlendMode(e){this._blendModeStack.pop();const t=this._blendModeStack[this._activeBlendMode.length-1]??"normal";this.setBlendMode(null,t,e)}setBlendMode(e,t,r){const n=e instanceof i.m;this._activeBlendMode!==t?(this._isAdvanced&&this._endAdvancedBlendMode(r),this._activeBlendMode=t,e&&(this._isAdvanced=!!o[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,r))):this._isAdvanced&&e&&!n&&this._renderableList?.push(e)}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);const r=this._activeBlendMode;if(!o[r])return void(0,a.R)(`Unable to assign BlendMode: '${r}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);const n=this._ensureFilterEffect(r),s=e instanceof i.m,d={renderPipeId:"filter",action:"pushFilter",filterEffect:n,renderables:s?null:[e],container:s?e.root:null,canBundle:!1};this._renderableList=d.renderables,t.add(d)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new s.a,t.filters=[new o[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,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(){this._renderer=null,this._renderableList=null;for(const e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}}d.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"blendMode"}},279:(e,t,r)=>{r.d(t,{O:()=>o});var n=r(133),s=r(583),i=r(5589);const a=class e{constructor(t={}){if(this.uid=(0,n.L)("renderTarget"),this.colorTextures=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,t={...e.defaultOptions,...t},this.stencil=t.stencil,this.depth=t.depth,this.isRoot=t.isRoot,"number"==typeof t.colorTextures){this._managedColorTextures=!0;for(let e=0;e<t.colorTextures;e++)this.colorTextures.push(new s.v({width:t.width,height:t.height,resolution:t.resolution,antialias:t.antialias}))}else{this.colorTextures=[...t.colorTextures.map((e=>e.source))];const e=this.colorTexture.source;this.resize(e.width,e.height,e._resolution)}this.colorTexture.source.on("resize",this.onSourceResize,this),(t.depthStencilTexture||this.stencil)&&(t.depthStencilTexture instanceof i.g||t.depthStencilTexture instanceof s.v?this.depthStencilTexture=t.depthStencilTexture.source:this.ensureDepthStencilTexture())}get size(){const e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.colorTexture.source.width}get height(){return this.colorTexture.source.height}get pixelWidth(){return this.colorTexture.source.pixelWidth}get pixelHeight(){return this.colorTexture.source.pixelHeight}get resolution(){return this.colorTexture.source._resolution}get colorTexture(){return this.colorTextures[0]}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this.depthStencilTexture||(this.depthStencilTexture=new s.v({width:this.width,height:this.height,resolution:this.resolution,format:"depth24plus-stencil8",autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1}))}resize(e,t,r=this.resolution,n=!1){this.dirtyId++,this.colorTextures.forEach(((s,i)=>{n&&0===i||s.source.resize(e,t,r)})),this.depthStencilTexture&&this.depthStencilTexture.source.resize(e,t,r)}destroy(){this.colorTexture.source.off("resize",this.onSourceResize,this),this._managedColorTextures&&this.colorTextures.forEach((e=>{e.destroy()})),this.depthStencilTexture&&(this.depthStencilTexture.destroy(),delete this.depthStencilTexture)}};a.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};let o=a},7238:(e,t,r)=>{r.d(t,{l:()=>h});var n=r(9313),s=r(9252),i=r(1257);var a=r(7729),o=r(4884),d=r(583),l=r(5589),u=r(8725);var c=r(279);class h{constructor(e){this.rootViewPort=new s.M,this.viewport=new s.M,this.mipLevel=0,this.layer=0,this.onRenderTargetChange=new a.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,e.gc.addCollection(this,"_gpuRenderTargetHash","hash")}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart({target:e,clear:t,clearColor:r,frame:n,mipLevel:s,layer:i}){this._renderTargetStack.length=0,this.push(e,t,r,n,s??0,i??0),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=function(e){const t=e.colorTexture.source.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,r,n,s=0,i=0){const a=this.getRenderTarget(e),o=this.renderTarget!==a;this.renderTarget=a,this.renderSurface=e;const d=this.getGpuRenderTarget(a);a.pixelWidth===d.width&&a.pixelHeight===d.height||(this.adaptor.resizeGpuRenderTarget(a),d.width=a.pixelWidth,d.height=a.pixelHeight);const u=a.colorTexture,c=this.viewport,h=u.arrayLayerCount||1;if((0|i)!==i&&(i|=0),i<0||i>=h)throw new Error(`[RenderTargetSystem] layer ${i} is out of bounds (arrayLayerCount=${h}).`);this.mipLevel=0|s,this.layer=0|i;const p=Math.max(u.pixelWidth>>s,1),g=Math.max(u.pixelHeight>>s,1);if(!n&&e instanceof l.g&&(n=e.frame),n){const e=u._resolution,t=1<<Math.max(0|s,0),r=n.x*e+.5|0,i=n.y*e+.5|0,a=n.width*e+.5|0,o=n.height*e+.5|0;let d=Math.floor(r/t),l=Math.floor(i/t),h=Math.ceil(a/t),f=Math.ceil(o/t);d=Math.min(Math.max(d,0),p-1),l=Math.min(Math.max(l,0),g-1),h=Math.min(Math.max(h,1),p-d),f=Math.min(Math.max(f,1),g-l),c.x=d,c.y=l,c.width=h,c.height=f}else c.x=0,c.y=0,c.width=p,c.height=g;return function(e,t,r,n,s,i){const a=i?1:-1;e.identity(),e.a=1/n*2,e.d=a*(1/s*2),e.tx=-1-t*e.a,e.ty=-a-r*e.d}(this.projectionMatrix,0,0,c.width/u.resolution,c.height/u.resolution,!a.isRoot),this.adaptor.startRenderPass(a,t,r,c,s,i),o&&this.onRenderTargetChange.emit(a),a}clear(e,t=i.u.ALL,r,n=this.mipLevel,s=this.layer){t&&(e&&(e=this.getRenderTarget(e)),this.adaptor.clear(e||this.renderTarget,t,r,this.viewport,n,s))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=i.u.ALL,r,n,s=0,a=0){const o=this.bind(e,t,r,n,s,a);return this._renderTargetStack.push({renderTarget:o,frame:n,mipLevel:s,layer:a}),o}pop(){this._renderTargetStack.pop();const e=this._renderTargetStack[this._renderTargetStack.length-1];this.bind(e.renderTarget,!1,null,e.frame,e.mipLevel,e.layer)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,r,n,s){r.x<0&&(n.width+=r.x,s.x-=r.x,r.x=0),r.y<0&&(n.height+=r.y,s.y-=r.y,r.y=0);const{pixelWidth:i,pixelHeight:a}=e;return n.width=Math.min(n.width,i-r.x),n.height=Math.min(n.height,a-r.y),this.adaptor.copyToTexture(e,t,r,n,s)}ensureDepthStencil(){this.renderTarget.stencil||(this.renderTarget.stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer))}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).source),e instanceof c.O?t=e:e instanceof d.v&&(t=new c.O({colorTextures:[e]}),e.source instanceof o.q&&(t.isRoot=!0),e.once("destroy",(()=>{t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e);const r=this._gpuRenderTargetHash[t.uid];r&&(this._gpuRenderTargetHash[t.uid]=null,this.adaptor.destroyGpuRenderTarget(r))}))),this._renderSurfaceToRenderTargetHash.set(e,t),t}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this.adaptor.initGpuRenderTarget(e))}resetState(){this.renderTarget=null,this.renderSurface=null}}},381:(e,t,r)=>{r.d(t,{f:()=>xe,i:()=>_e});var n=r(594),s=r(1160),i=r(8507),a=r(9313),o=r(2437),d=r(218),l=r(9636);function u(e,t){t||(t=0);for(let r=t;r<e.length&&e[r];r++)e[r]=null}var c=r(433),h=r(5559),p=r(753);const g=new h.mc,f=h.fR|h.ig|h.u;function m(e,t=!1){!function(e){const t=e.root;let r;if(e.renderGroupParent){const n=e.renderGroupParent;e.worldTransform.appendFrom(t.relativeGroupTransform,n.worldTransform),e.worldColor=(0,p.j)(t.groupColor,n.worldColor),r=t.groupAlpha*n.worldAlpha}else e.worldTransform.copyFrom(t.localTransform),e.worldColor=t.localColor,r=t.localAlpha;r=r<0?0:r>1?1:r,e.worldAlpha=r,e.worldColorAlpha=e.worldColor+(255*r<<24)}(e);const r=e.childrenToUpdate,n=e.updateTick++;for(const t in r){const s=Number(t),i=r[t],a=i.list,o=i.index;for(let t=0;t<o;t++){const r=a[t];r.parentRenderGroup===e&&r.relativeRenderGroupDepth===s&&_(r,n,0)}u(a,o),i.index=0}if(t)for(let r=0;r<e.renderGroupChildren.length;r++)m(e.renderGroupChildren[r],t)}function _(e,t,r){if(t===e.updateTick)return;e.updateTick=t,e.didChange=!1;const n=e.localTransform;e.updateLocalTransform();const s=e.parent;if(s&&!s.renderGroup?(r|=e._updateFlags,e.relativeGroupTransform.appendFrom(n,s.relativeGroupTransform),r&f&&x(e,s,r)):(r=e._updateFlags,e.relativeGroupTransform.copyFrom(n),r&f&&x(e,g,r)),!e.renderGroup){const n=e.children,s=n.length;for(let e=0;e<s;e++)_(n[e],t,r);const i=e.parentRenderGroup,a=e;a.renderPipeId&&!i.structureDidChange&&i.updateRenderable(a)}}function x(e,t,r){if(r&h.ig){e.groupColor=(0,p.j)(e.localColor,t.groupColor);let r=e.localAlpha*t.groupAlpha;r=r<0?0:r>1?1:r,e.groupAlpha=r,e.groupColorAlpha=e.groupColor+(255*r<<24)}r&h.u&&(e.groupBlendMode="inherit"===e.localBlendMode?t.groupBlendMode:e.localBlendMode),r&h.fR&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}const b=new a.u;class v{constructor(e){this._renderer=e}render({container:e,transform:t}){const r=e.parent,n=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;const s=this._renderer,i=b;t&&(i.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));const a=s.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),s.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),(0,c.j)(e.renderGroup,a),a.uniformBatch&&a.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(i),e.parent=r,e.renderGroup.renderGroupParent=n}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let r=e.renderGroupChildren.length-1;r>=0;r--)this._updateCachedRenderGroups(e.renderGroupChildren[r],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){const t=e.root.getLocalBounds(),r=this._renderer,n=e.textureOptions.resolution||r.view.resolution,s=e.textureOptions.antialias??r.view.antialias,i=e.textureOptions.scaleMode??"linear",a=e.texture;t.ceil(),e.texture&&o.W.returnTexture(e.texture,!0);const u=o.W.getOptimalTexture(t.width,t.height,n,s);u._source.style=new d.n({scaleMode:i}),e.texture=u,e._textureBounds||(e._textureBounds=new l.c),e._textureBounds.copyFrom(t),a!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&(o.W.returnTexture(e.texture,!0),e.texture=null)}_updateRenderGroups(e){const t=this._renderer,r=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=r,e.structureDidChange?u(e.childrenRenderablesToUpdate.list,0):function(e,t){const{list:r}=e.childrenRenderablesToUpdate;let n=!1;for(let s=0;s<e.childrenRenderablesToUpdate.index;s++){const e=r[s];if(n=t[e.renderPipeId].validateRenderable(e),n)break}e.structureDidChange=n}(e,r),m(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!e.isCachedAsTexture||e.textureNeedsUpdate)for(let t=0;t<e.renderGroupChildren.length;t++)this._updateRenderGroups(e.renderGroupChildren[t])}_updateRenderables(e){const{list:t,index:r}=e.childrenRenderablesToUpdate;for(let n=0;n<r;n++){const r=t[n];r.didViewUpdate&&e.updateRenderable(r)}u(t,r)}_buildInstructions(e,t){const r=e.root,n=e.instructionSet;n.reset();const s=t.renderPipes?t:t.batch.renderer,i=s.renderPipes;i.batch.buildStart(n),i.blendMode.buildStart(),i.colorMask.buildStart(),r.sortableChildren&&r.sortChildren(),r.collectRenderablesWithEffects(n,s,null),i.batch.buildEnd(n),i.blendMode.buildEnd(n)}}v.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"renderGroup"};var T=r(3136),k=r(7073),y=r(780),C=r(9824);class M{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);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const s=this._colorStack[this._colorStackIndex];s!==this._currentColor&&(this._currentColor=s,r.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1})),this._colorStackIndex++}pop(e,t,r){this._renderer.renderPipes.batch.break(r);const n=this._colorStack;this._colorStackIndex--;const s=n[this._colorStackIndex-1];s!==this._currentColor&&(this._currentColor=s,r.add({renderPipeId:"colorMask",colorMask:s,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}}M.extension={type:[i.Ag.WebGLPipes,i.Ag.WebGPUPipes],name:"colorMask"};var S=r(1257),G=r(1957);class w{constructor(e){this._maskStackHash={},this._maskHash=new WeakMap,this._renderer=e}push(e,t,r){var n;const s=e,i=this._renderer;i.renderPipes.batch.break(r),i.renderPipes.blendMode.setBlendMode(s.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const a=s.mask;a.includeInBuild=!0,this._maskHash.has(s)||this._maskHash.set(s,{instructionsStart:0,instructionsLength:0});const o=this._maskHash.get(s);o.instructionsStart=r.instructionSize,a.collectRenderables(r,i,null),a.includeInBuild=!1,i.renderPipes.batch.break(r),r.add({renderPipeId:"stencilMask",action:"pushMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1});const d=r.instructionSize-o.instructionsStart-1;o.instructionsLength=d;const l=i.renderTarget.renderTarget.uid;(n=this._maskStackHash)[l]??(n[l]=0)}pop(e,t,r){const n=e,s=this._renderer;s.renderPipes.batch.break(r),s.renderPipes.blendMode.setBlendMode(n.mask,"none",r),r.add({renderPipeId:"stencilMask",action:"popMaskBegin",inverse:t._maskOptions.inverse,canBundle:!1});const 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;const r=this._renderer,n=r,s=r.renderTarget.renderTarget.uid;let i=(t=this._maskStackHash)[s]??(t[s]=0);"pushMaskBegin"===e.action?(n.renderTarget.ensureDepthStencil(),n.stencil.setStencilMode(G.K.RENDERING_MASK_ADD,i),i++,n.colorMask.setMask(0)):"pushMaskEnd"===e.action?(e.inverse?n.stencil.setStencilMode(G.K.INVERSE_MASK_ACTIVE,i):n.stencil.setStencilMode(G.K.MASK_ACTIVE,i),n.colorMask.setMask(15)):"popMaskBegin"===e.action?(n.colorMask.setMask(0),0!==i?n.stencil.setStencilMode(G.K.RENDERING_MASK_REMOVE,i):(n.renderTarget.clear(null,S.u.STENCIL),n.stencil.setStencilMode(G.K.DISABLED,i)),i--):"popMaskEnd"===e.action&&(e.inverse?n.stencil.setStencilMode(G.K.INVERSE_MASK_ACTIVE,i):n.stencil.setStencilMode(G.K.MASK_ACTIVE,i),n.colorMask.setMask(15)),this._maskStackHash[s]=i}destroy(){this._renderer=null,this._maskStackHash=null,this._maskHash=null}}w.extension={type:[i.Ag.WebGLPipes,i.Ag.WebGPUPipes],name:"stencilMask"};var R=r(2577),P=r(268);const A=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new R.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){R.Q.shared.setValue(e).alpha<1&&1===this._backgroundColor.alpha&&(0,P.R)("Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application."),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};A.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"background",priority:0},A.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};let B=A;var U=r(360),O=r(1761),I=r(5589);const L={png:"image/png",jpg:"image/jpeg",webp:"image/webp"},D=class e{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof h.mc||e instanceof I.g?{target:e,...t}:{...t,...e}}async image(e){const t=O.e.get().createImage();return t.src=await this.base64(e),t}async base64(t){t=this._normalizeOptions(t,e.defaultImageOptions);const{format:r,quality:n}=t,s=this.canvas(t);if(void 0!==s.toBlob)return new Promise(((e,t)=>{s.toBlob((r=>{if(!r)return void t(new Error("ICanvas.toBlob failed!"));const n=new FileReader;n.onload=()=>e(n.result),n.onerror=t,n.readAsDataURL(r)}),L[r],n)}));if(void 0!==s.toDataURL)return s.toDataURL(L[r],n);if(void 0!==s.convertToBlob){const e=await s.convertToBlob({type:L[r],quality:n});return new Promise(((t,r)=>{const n=new FileReader;n.onload=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)}))}throw new Error("Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented")}canvas(e){const t=(e=this._normalizeOptions(e)).target,r=this._renderer;if(t instanceof I.g)return r.texture.generateCanvas(t);const n=r.textureGenerator.generateTexture(e),s=r.texture.generateCanvas(n);return n.destroy(!0),s}pixels(e){const t=(e=this._normalizeOptions(e)).target,r=this._renderer,n=t instanceof I.g?t:r.textureGenerator.generateTexture(e),s=r.texture.getPixels(n);return t instanceof h.mc&&n.destroy(!0),s}texture(e){return(e=this._normalizeOptions(e)).target instanceof I.g?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);const 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){const t=e.width??200;e=this._normalizeOptions(e);const r=this.canvas(e),n=r.toDataURL();console.log(`[Pixi Texture] ${r.width}px ${r.height}px`);const s=["font-size: 1px;",`padding: ${t}px 300px;`,`background: url(${n}) no-repeat;`,"background-size: contain;"].join(" ");console.log("%c ",s)}destroy(){this._renderer=null}};D.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"extract"},D.defaultImageOptions={format:"png",quality:1};let F=D;var z=r(9252),W=r(7269),E=r(583);class H extends I.g{static create(e){const{dynamic:t,...r}=e;return new H({source:new E.v(r),dynamic:t??!1})}resize(e,t,r){return this.source.resize(e,t,r),this}}const j=new z.M,V=new l.c,N=[0,0,0,0];class q{constructor(e){this._renderer=e}generateTexture(e){e instanceof h.mc&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});const t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,n=e.target;let s=e.clearColor;if(s){s=Array.isArray(s)&&4===s.length?s:R.Q.shared.setValue(s).toArray()}else s=N;const i=e.frame?.copyTo(j)||(0,W.n)(n,V).rectangle;i.width=0|Math.max(i.width,1/t),i.height=0|Math.max(i.height,1/t);const o=H.create({...e.textureSourceOptions,width:i.width,height:i.height,resolution:t,antialias:r}),d=a.u.shared.translate(-i.x,-i.y);return this._renderer.render({container:n,transform:d,target:o,clearColor:s}),o.source.updateMipmaps(),o}destroy(){this._renderer=null}}function K(e){let t=!1;for(const r in e)if(null==e[r]){t=!0;break}if(!t)return e;const r=Object.create(null);for(const t in e){const n=e[t];n&&(r[t]=n)}return r}function $(e){let t=0;for(let r=0;r<e.length;r++)null==e[r]?t++:e[r-t]=e[r];return e.length-=t,e}q.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"textureGenerator"};const J=class e{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat((()=>{this._ready=!0}),this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat((()=>{for(const e of this._managedCollections){const{context:t,collection:r,type:n}=e;t[r]="hash"===n?K(t[r]):$(t[r])}}),this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){this._ready&&this.enabled&&(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(const r of e.renderGroupChildren)this._updateInstructionGCTick(r,t)}addCollection(e,t,r){this._managedCollections.push({context:e,collection:t,type:r})}addResource(e,t){if(-1!==e._gcLastUsed)return e._gcLastUsed=this.now,void e._onTouch?.(this.now);const r=this._managedResources.length;e._gcData={index:r,type:t},e._gcLastUsed=this.now,e._onTouch?.(this.now),e.once("unload",this.removeResource,this),this._managedResources.push(e)}removeResource(e){const t=e._gcData;if(!t)return;const r=t.index,n=this._managedResources.length-1;if(r!==n){const e=this._managedResources[n];this._managedResources[r]=e,e._gcData.index=r}this._managedResources.length--,e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,r,n=0){this._managedResourceHashes.push({context:e,hash:t,type:r,priority:n}),this._managedResourceHashes.sort(((e,t)=>e.priority-t.priority))}run(){const e=performance.now(),t=this._managedResourceHashes;for(const r of t)this.runOnHash(r,e);let r=0;for(let t=0;t<this._managedResources.length;t++){const n=this._managedResources[t];r=this.runOnResource(n,e,r)}this._managedResources.length=r}updateRenderableGCTick(e,t){const r=e.renderGroup??e.parentRenderGroup,n=r?.instructionSet?.gcTick??-1;(r?.gcTick??0)===n&&(e._gcLastUsed=t,e._onTouch?.(t))}runOnResource(e,t,r){const n=e._gcData;"renderable"===n.type&&this.updateRenderableGCTick(e,t);return t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect?(this._managedResources[r]=e,n.index=r,r++):(e.unload(),e._gcData=null,e._gcLastUsed=-1,e.off("unload",this.removeResource,this)),r}_createHashClone(e,t){const r=Object.create(null);for(const n in e){if(n===t)break;null!==e[n]&&(r[n]=e[n])}return r}runOnHash(e,t){const{context:r,hash:n,type:s}=e,i=r[n];let a=null,o=0;for(const e in i){const r=i[e];if(null===r){o++,1e4!==o||a||(a=this._createHashClone(i,e));continue}if(-1===r._gcLastUsed){r._gcLastUsed=t,r._onTouch?.(t),a&&(a[e]=r);continue}"renderable"===s&&this.updateRenderableGCTick(r,t);if(!(t-r._gcLastUsed<this.maxUnusedTime)&&r.autoGarbageCollect){if(a||(o+1!==1e4?(i[e]=null,o++):a=this._createHashClone(i,e)),"renderable"===s){const e=r,t=e.renderGroup??e.parentRenderGroup;t&&(t.structureDidChange=!0)}r.unload(),r._gcData=null,r._gcLastUsed=-1}else a&&(a[e]=r)}a&&(r[n]=a)}destroy(){this.enabled=!1,this._managedResources.forEach((e=>{e.off("unload",this.removeResource,this)})),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};J.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"gc",priority:0},J.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};let Q=J;var X=r(5101),Z=r(2760),Y=r(3513),ee=r(5099),te=r(5811);class re{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:s}){const i=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:i,worldTransformMatrix:new a.u,worldColor:4294967295,offset:new X.b},d={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||i.size,worldTransformMatrix:r||o.worldTransformMatrix,worldColor:n||o.worldColor,offset:s||o.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);const u=l.uniforms;let c;u.uProjectionMatrix=d.projectionMatrix,u.uResolution=d.resolution,u.uWorldTransformMatrix.copyFrom(d.worldTransformMatrix),u.uWorldTransformMatrix.tx-=d.offset.x,u.uWorldTransformMatrix.ty-=d.offset.y,(0,Z.V)(d.worldColor,u.uWorldColorAlpha,0),l.update(),this._renderer.renderPipes.uniformBatch?c=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(c=this._bindGroupPool.pop()||new Y.T,this._activeBindGroups.push(c),c.setResource(l,0)),d.bindGroup=c,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===ee.W.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new te.k({uProjectionMatrix:{value:new a.u,type:"mat3x3<f32>"},uWorldTransformMatrix:{value:new a.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,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}}re.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"globalUniforms"};var ne=r(7309);let se=1;class ie{constructor(){this._tasks=[],this._offset=0}init(){ne.R.system.add(this._update,this)}repeat(e,t,r=!0){const n=se++;let s=0;return r&&(this._offset+=1e3,s=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:s,last:performance.now(),repeat:!0,id:n}),n}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e)return void this._tasks.splice(t,1)}_update(){const e=performance.now();for(let t=0;t<this._tasks.length;t++){const r=this._tasks[t];if(e-r.offset-r.last>=r.duration){const t=e-r.start;r.func(t),r.last=e}}}destroy(){ne.R.system.remove(this._update,this),this._tasks.length=0}}ie.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"scheduler",priority:0};var ae=r(2571);let oe=!1;class de{constructor(e){this._renderer=e}init(e){if(e.hello){let e=this._renderer.name;this._renderer.type===ee.W.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),function(e){if(!oe){if(O.e.get().getNavigator().userAgent.toLowerCase().indexOf("chrome")>-1){const t=[`%c %c %c %c %c PixiJS %c v${ae.xv} (${e}) http://www.pixijs.com/\n\n`,"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(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${ae.xv} - ${e} - http://www.pixijs.com/`);oe=!0}}(e)}}}de.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"hello",priority:-2},de.defaultOptions={hello:!1};var le=r(4670);const ue=class e{constructor(e){this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return(0,le.t6)("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled}set enabled(e){(0,le.t6)("8.15.0","RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead."),this._renderer.gc.enabled=e}addManagedHash(e,t){(0,le.t6)("8.15.0","RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"hash")}addManagedArray(e,t){(0,le.t6)("8.15.0","RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead."),this._renderer.gc.addCollection(e,t,"array")}addRenderable(e){(0,le.t6)("8.15.0","RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead."),this._renderer.gc.addResource(e,"renderable")}run(){(0,le.t6)("8.15.0","RenderableGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};ue.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"renderableGC",priority:0},ue.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};let ce=ue;const he=class e{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){(0,le.t6)("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){(0,le.t6)("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){(0,le.t6)("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead.")}get active(){return this._renderer.gc.enabled}set active(e){(0,le.t6)("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(t){t.textureGCActive!==e.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==e.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==e.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){(0,le.t6)("8.15.0","TextureGCSystem.run is deprecated, please use the GCSystem instead."),this._renderer.gc.run()}destroy(){this._renderer=null}};he.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem],name:"textureGC"},he.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};let pe=he;var ge=r(279),fe=r(8725);const me=class e{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}init(t){(t={...e.defaultOptions,...t}).view&&((0,le.t6)(le.lj,"ViewSystem.view has been renamed to ViewSystem.canvas"),t.canvas=t.view),this.screen=new z.M(0,0,t.width,t.height),this.canvas=t.canvas||O.e.get().createCanvas(),this.antialias=!!t.antialias,this.texture=(0,fe.c)(this.canvas,t),this.renderTarget=new ge.O({colorTextures:[this.texture],depth:!!t.depth,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.resolution=t.resolution}resize(e,t,r){this.texture.source.resize(e,t,r),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){("boolean"==typeof e?e:!!e?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.destroy()}};me.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem,i.Ag.CanvasSystem],name:"view",priority:0},me.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};const _e=[B,re,de,me,v,Q,pe,q,F,k.d,ce,ie],xe=[U.j,y.s,T.k,s.a,C.z,w,M,n._]},8725:(e,t,r)=>{r.d(t,{c:()=>o});var n=r(6083),s=r(4884),i=r(5589);const a=new Map;function o(e,t){if(!a.has(e)){const r=new i.g({source:new s.q({resource:e,...t})}),n=()=>{a.get(e)===r&&a.delete(e)};r.once("destroy",n),r.source.once("destroy",n),a.set(e,r)}return a.get(e)}n.L.register(a)},594:(e,t,r)=>{r.d(t,{_:()=>s});var n=r(8507);class s{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}}s.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"customRender"}},1160:(e,t,r)=>{r.d(t,{a:()=>d});var n=r(8507),s=r(9313),i=r(8655),a=r(8422),o=r(433);class d{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&(i.Z.return(e._batchableRenderGroup),e._batchableRenderGroup=null),t.add(e)}_addRenderableCacheAsTexture(e,t){const r=e._batchableRenderGroup??(e._batchableRenderGroup=i.Z.get(a.K));r.renderable=e.root,r.transform=e.root.relativeGroupTransform,r.texture=e.texture,r.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(r,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;const t=(new s.u).translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push(e.texture,!0,null,e.texture.frame),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:4294967295,offset:{x:0,y:0}}),(0,o.j)(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}e._batchableRenderGroup._batcher.updateElement(e._batchableRenderGroup),e._batchableRenderGroup._batcher.geometry.buffers[0].update()}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),(0,o.j)(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}}d.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"renderGroup"}},433:(e,t,r)=>{function n(e,t){const r=e.instructionSet,n=r.instructions;for(let e=0;e<r.instructionSize;e++){const r=n[e];t[r.renderPipeId].execute(r)}}r.d(t,{j:()=>n})},8422:(e,t,r)=>{r.d(t,{K:()=>n});class n{constructor(){this.batcherName="default",this.topology="triangle-list",this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}}},3136:(e,t,r)=>{r.d(t,{k:()=>i});var n=r(8507),s=r(8422);class i{constructor(e){this._renderer=e}addRenderable(e,t){const r=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,r),this._renderer.renderPipes.batch.addToBatch(r,t)}updateRenderable(e){const t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){const t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){const t=new s.K;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}}i.extension={type:[n.Ag.WebGLPipes,n.Ag.WebGPUPipes,n.Ag.CanvasPipes],name:"sprite"}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[851],{6851:(e,t,n)=>{n.d(t,{CanvasRenderer:()=>se});var a=n(8507),r=n(594),o=n(1160),i=n(2079),s=n(9313),c=n(2577),l=n(1761);let h;function d(e){const t=l.e.get().createCanvas(6,1),n=t.getContext("2d");return n.fillStyle=e,n.fillRect(0,0,6,1),t}function u(){if(void 0!==h)return h;try{const e=d("#ff00ff"),t=d("#ffff00"),n=l.e.get().createCanvas(6,1).getContext("2d");n.globalCompositeOperation="multiply",n.drawImage(e,0,0),n.drawImage(t,2,0);const a=n.getImageData(2,0,1,1);if(a){const e=a.data;h=255===e[0]&&0===e[1]&&0===e[2]}else h=!1}catch(e){h=!1}return h}const p={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:u(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:e=>{const t=e.source,n=t?.resource;if(!n)return null;const a="premultiplied-alpha"===t.alphaMode,r=t.resourceWidth??t.pixelWidth,o=t.resourceHeight??t.pixelHeight,i=r!==t.pixelWidth||o!==t.pixelHeight;if(a){if((n instanceof HTMLCanvasElement||"undefined"!=typeof OffscreenCanvas&&n instanceof OffscreenCanvas)&&!i)return n;const e=p._unpremultipliedCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){const e=p._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;const a=l.e.get().createCanvas(t.pixelWidth,t.pixelHeight),r=a.getContext("2d"),o=r.createImageData(t.pixelWidth,t.pixelHeight),i=o.data,s=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if("bgra8unorm"===t.format)for(let e=0;e<i.length&&e+3<s.length;e+=4)i[e]=s[e+2],i[e+1]=s[e+1],i[e+2]=s[e],i[e+3]=s[e+3];else i.set(s.subarray(0,i.length));return r.putImageData(o,0,0),p._canvasSourceCache.set(t,{canvas:a,resourceId:t._resourceId}),a}if(a){const e=l.e.get().createCanvas(t.pixelWidth,t.pixelHeight),a=e.getContext("2d",{willReadFrequently:!0});e.width=t.pixelWidth,e.height=t.pixelHeight,a.drawImage(n,0,0);const r=a.getImageData(0,0,e.width,e.height),o=r.data;for(let e=0;e<o.length;e+=4){const t=o[e+3];if(t>0){const n=255/t;o[e]=Math.min(255,o[e]*n+.5),o[e+1]=Math.min(255,o[e+1]*n+.5),o[e+2]=Math.min(255,o[e+2]*n+.5)}}return a.putImageData(r,0,0),p._unpremultipliedCache.set(t,{canvas:e,resourceId:t._resourceId}),e}if(i){const e=p._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;const a=l.e.get().createCanvas(t.pixelWidth,t.pixelHeight),r=a.getContext("2d");return a.width=t.pixelWidth,a.height=t.pixelHeight,r.drawImage(n,0,0),p._canvasSourceCache.set(t,{canvas:a,resourceId:t._resourceId}),a}return n},getTintedCanvas:(e,t)=>{const n=e.texture,a=c.Q.shared.setValue(t).toHex(),r=n.tintCache||(n.tintCache={}),o=r[a],i=n.source._resourceId;if(o?.tintId===i)return o;const s=o&&"getContext"in o?o:l.e.get().createCanvas();if(p.tintMethod(n,t,s),s.tintId=i,p.convertTintToImage&&void 0!==s.toDataURL){const e=l.e.get().createImage();e.src=s.toDataURL(),e.tintId=i,r[a]=e}else r[a]=s;return r[a]},getTintedPattern:(e,t)=>{const n=c.Q.shared.setValue(t).toHex(),a=e.patternCache||(e.patternCache={}),r=e.source._resourceId;let o=a[n];if(o?.tintId===r)return o;p.canvas||(p.canvas=l.e.get().createCanvas()),p.tintMethod(e,t,p.canvas);return o=p.canvas.getContext("2d").createPattern(p.canvas,"repeat"),o.tintId=r,a[n]=o,o},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;const a=e;if(!a.setTransform)return;const r=globalThis.DOMMatrix;if(!r)return;const o=new r([t.a,t.b,t.c,t.d,t.tx,t.ty]);a.setTransform(n?o.inverse():o)},tintWithMultiply:(e,t,n)=>{const a=n.getContext("2d"),r=e.frame.clone(),o=e.source._resolution??e.source.resolution??1,s=e.rotate;r.x*=o,r.y*=o,r.width*=o,r.height*=o;const l=i.E.isVertical(s),h=l?r.height:r.width,d=l?r.width:r.height;n.width=Math.ceil(h),n.height=Math.ceil(d),a.save(),a.fillStyle=c.Q.shared.setValue(t).toHex(),a.fillRect(0,0,h,d),a.globalCompositeOperation="multiply";const u=p.getCanvasSource(e);u?(s&&p._applyInverseRotation(a,s,r.width,r.height),a.drawImage(u,r.x,r.y,r.width,r.height,0,0,r.width,r.height),a.globalCompositeOperation="destination-atop",a.drawImage(u,r.x,r.y,r.width,r.height,0,0,r.width,r.height),a.restore()):a.restore()},tintWithOverlay:(e,t,n)=>{const a=n.getContext("2d"),r=e.frame.clone(),o=e.source._resolution??e.source.resolution??1,s=e.rotate;r.x*=o,r.y*=o,r.width*=o,r.height*=o;const l=i.E.isVertical(s),h=l?r.height:r.width,d=l?r.width:r.height;n.width=Math.ceil(h),n.height=Math.ceil(d),a.save(),a.globalCompositeOperation="copy",a.fillStyle=c.Q.shared.setValue(t).toHex(),a.fillRect(0,0,h,d),a.globalCompositeOperation="destination-atop";const u=p.getCanvasSource(e);u?(s&&p._applyInverseRotation(a,s,r.width,r.height),a.drawImage(u,r.x,r.y,r.width,r.height,0,0,r.width,r.height),a.restore()):a.restore()},tintWithPerPixel:(e,t,n)=>{const a=n.getContext("2d"),r=e.frame.clone(),o=e.source._resolution??e.source.resolution??1,s=e.rotate;r.x*=o,r.y*=o,r.width*=o,r.height*=o;const c=i.E.isVertical(s),l=c?r.height:r.width,h=c?r.width:r.height;n.width=Math.ceil(l),n.height=Math.ceil(h),a.save(),a.globalCompositeOperation="copy";const d=p.getCanvasSource(e);if(!d)return void a.restore();s&&p._applyInverseRotation(a,s,r.width,r.height),a.drawImage(d,r.x,r.y,r.width,r.height,0,0,r.width,r.height),a.restore();const u=t>>16&255,g=t>>8&255,m=255&t,f=a.getImageData(0,0,l,h),x=f.data;for(let e=0;e<x.length;e+=4)x[e]=x[e]*u/255,x[e+1]=x[e+1]*g/255,x[e+2]=x[e+2]*m/255;a.putImageData(f,0,0)},_applyInverseRotation:(e,t,n,a)=>{const r=i.E.inv(t),o=i.E.uX(r),s=i.E.uY(r),c=i.E.vX(r),l=i.E.vY(r),h=-Math.min(0,o*n,c*a,o*n+c*a),d=-Math.min(0,s*n,l*a,s*n+l*a);e.transform(o,s,c,l,h,d)}};p.tintMethod=p.canUseMultiply?p.tintWithMultiply:p.tintWithPerPixel;var g=n(5589),m=n(198),f=n(4676),x=n(115),v=n(7276),y=n(2806),C=n(2801),_=n(2413);const w=new s.u,T=new s.u,b=new s.u,k=new s.u;function M(e,t,n){e.beginPath();for(let a=0;a<n.length;a+=3){const r=2*n[a],o=2*n[a+1],i=2*n[a+2];e.moveTo(t[r],t[r+1]),e.lineTo(t[o],t[o+1]),e.lineTo(t[i],t[i+1]),e.closePath()}e.fill()}function I(e,t){switch(t.type){case"rectangle":{const n=t;e.rect(n.x,n.y,n.width,n.height);break}case"roundedRectangle":{const n=t;!function(e,t,n,a,r,o){o=Math.max(0,Math.min(o,Math.min(a,r)/2)),e.moveTo(t+o,n),e.lineTo(t+a-o,n),e.quadraticCurveTo(t+a,n,t+a,n+o),e.lineTo(t+a,n+r-o),e.quadraticCurveTo(t+a,n+r,t+a-o,n+r),e.lineTo(t+o,n+r),e.quadraticCurveTo(t,n+r,t,n+r-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n)}(e,n.x,n.y,n.width,n.height,n.radius);break}case"circle":{const n=t;e.arc(n.x,n.y,n.radius,0,2*Math.PI);break}case"ellipse":{const n=t;e.ellipse?e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,2*Math.PI):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.arc(0,0,1,0,2*Math.PI),e.restore());break}case"triangle":{const n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{const n=t,a=n.points;if(!a?.length)break;e.moveTo(a[0],a[1]);for(let t=2;t<a.length;t+=2)e.lineTo(a[t],a[t+1]);n.closePath&&e.closePath();break}}}function P(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){const a=t[n];if(!a?.shape)continue;const r=a.transform,o=r&&!r.isIdentity();o&&(e.save(),e.transform(r.a,r.b,r.c,r.d,r.tx,r.ty)),I(e,a.shape),o&&e.restore()}return!0}function S(e,t,n,a){const r=e.fill;if(r instanceof v._){r.buildGradient();const o=r.texture;if(o){const i=p.getTintedPattern(o,t),s=n?k.copyFrom(n).scale(o.source.pixelWidth,o.source.pixelHeight):k.copyFrom(r.transform);return a&&!e.textureSpace&&s.append(a),p.applyPatternTransform(i,s),i}}if(r instanceof y.m){const e=p.getTintedPattern(r.texture,t);return p.applyPatternTransform(e,r.transform),e}const o=e.texture;if(o&&o!==g.g.WHITE){if(!o.source.resource)return"#808080";const a=p.getTintedPattern(o,t),r=n?k.copyFrom(n).scale(o.source.pixelWidth,o.source.pixelHeight):e.matrix;return p.applyPatternTransform(a,r),a}return`#${(16777215&t).toString(16).padStart(6,"0")}`}class A{constructor(){this.shader=null}contextChange(e){}execute(e,t){const n=e.renderer,a=n.canvasContext,r=a.activeContext,o=t.groupTransform,s=n.globalUniforms.globalUniformData?.worldColor??4294967295,c=t.groupColorAlpha,l=(s>>>24&255)/255*((c>>>24&255)/255)*(n.filter?.alphaMultiplier??1);if(l<=0)return;const h=16777215&s,d=16777215&c,u=(0,m.D)((0,f.u)(d,h)),v=n._roundPixels|t._roundPixels;r.save(),a.setContextTransform(o,1===v),a.setBlendMode(t.groupBlendMode);const y=t.context.instructions;for(let e=0;e<y.length;e++){const t=y[e];if("texture"===t.action){const e=t.data,n=e.image,s=n?p.getCanvasSource(n):null;if(!s)continue;const c=e.alpha*l;if(c<=0)continue;const h=(0,f.u)(e.style,u);r.globalAlpha=c;let d=s;16777215!==h&&(d=p.getTintedCanvas({texture:n},h));const g=n.frame,m=n.source._resolution??n.source.resolution??1;let x=g.x*m,y=g.y*m;const C=g.width*m,_=g.height*m;d!==s&&(x=0,y=0);const T=e.transform,b=T&&!T.isIdentity(),k=n.rotate;b||k?(w.copyFrom(o),b&&w.append(T),k&&i.E.matrixAppendRotationInv(w,k,e.dx,e.dy,e.dw,e.dh),a.setContextTransform(w,1===v)):a.setContextTransform(o,1===v),r.drawImage(d,x,y,d===s?C:d.width,d===s?_:d.height,k?0:e.dx,k?0:e.dy,e.dw,e.dh),(b||k)&&a.setContextTransform(o,1===v);continue}const n=t.data,s=n?.path?.shapePath;if(!s?.shapePrimitives?.length)continue;const c=n.style,h=(0,f.u)(c.color,u),d=c.alpha*l;if(d<=0)continue;const m="stroke"===t.action;if(r.globalAlpha=d,m){const e=c;r.lineWidth=e.width,r.lineCap=e.cap,r.lineJoin=e.join,r.miterLimit=e.miterLimit}const k=s.shapePrimitives;if(!m&&n.hole?.shapePath?.shapePrimitives?.length){k[k.length-1].holes=n.hole.shapePath.shapePrimitives}for(let e=0;e<k.length;e++){const t=k[e];if(!t?.shape)continue;const n=t.transform,a=n&&!n.isIdentity(),i=c.texture&&c.texture!==g.g.WHITE,s="global"===c.textureSpace?n:null,l=S(c,h,i?(0,_.Y)(T,c,t.shape,s):null,a?b.copyFrom(o).append(n):o);if(a&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),m){const e=c;if(.5!==e.alignment&&!e.pixelLine){const n=[],a=[],o=[],i=C.y[t.shape.type];if(i?.build(t.shape,n)){const i=t.shape.closePath??!0;(0,x.h)(n,e,!1,i,a,o),r.fillStyle=l,M(r,a,o)}else r.strokeStyle=l,r.beginPath(),I(r,t.shape),r.stroke()}else r.strokeStyle=l,r.beginPath(),I(r,t.shape),r.stroke()}else{r.fillStyle=l,r.beginPath(),I(r,t.shape);P(r,t.holes)?r.fill("evenodd"):r.fill()}a&&r.restore()}}r.restore()}destroy(){this.shader=null}}A.extension={type:[a.Ag.CanvasPipesAdaptor],name:"graphics"};var R=n(3136);const W=class e{static _getPatternRepeat(e,t){const n=e&&"clamp-to-edge"!==e,a=t&&"clamp-to-edge"!==t;return n&&a?"repeat":n?"repeat-x":a?"repeat-y":"no-repeat"}start(e,t,n){}execute(t,n){const a=n.elements;if(!a||!a.length)return;const r=t.renderer,o=r.canvasContext,s=o.activeContext;for(let t=0;t<a.length;t++){const c=a[t];if(!c.packAsQuad)continue;const l=c,h=l.texture,d=h?p.getCanvasSource(h):null;if(!d)continue;const u=h.source.style,g=o.smoothProperty,x="nearest"!==u.scaleMode;s[g]!==x&&(s[g]=x),o.setBlendMode(n.blendMode);const v=r.globalUniforms.globalUniformData?.worldColor??4294967295,y=l.color,C=(v>>>24&255)/255*((y>>>24&255)/255)*(r.filter?.alphaMultiplier??1);if(C<=0)continue;s.globalAlpha=C;const _=16777215&v,w=16777215&y,T=(0,m.D)((0,f.u)(w,_)),b=h.frame,k=u.addressModeU??u.addressMode,M=u.addressModeV??u.addressMode,I=e._getPatternRepeat(k,M),P=h.source._resolution??h.source.resolution??1,S=l.renderable?.renderGroup?.isCachedAsTexture,A=b.x*P,R=b.y*P,W=b.width*P,H=b.height*P,E=l.bounds,B=r.renderTarget.renderTarget.isRoot,O=E.minX,D=E.minY,U=E.maxX-E.minX,q=E.maxY-E.minY,F=h.rotate,V=h.uvs,G=Math.min(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),L=Math.max(V.x0,V.x1,V.x2,V.x3,V.y0,V.y1,V.y2,V.y3),X="no-repeat"!==I&&(G<0||L>1),Y=F&&!(!X&&(16777215!==T||F));Y?(e._tempPatternMatrix.copyFrom(l.transform),i.E.matrixAppendRotationInv(e._tempPatternMatrix,F,O,D,U,q),o.setContextTransform(e._tempPatternMatrix,1===l.roundPixels,void 0,S&&B)):o.setContextTransform(l.transform,1===l.roundPixels,void 0,S&&B);const Q=Y?0:O,z=Y?0:D,N=U,j=q;if(X){let t=d;const n=16777215!==T&&!F,a=b.width<=h.source.width&&b.height<=h.source.height;n&&a&&(t=p.getTintedCanvas({texture:h},T));const r=s.createPattern(t,I);if(!r)continue;const o=N,i=j;if(0===o||0===i)continue;const c=1/o,l=1/i,u=(V.x1-V.x0)*c,g=(V.y1-V.y0)*c,m=(V.x3-V.x0)*l,f=(V.y3-V.y0)*l,x=V.x0-u*Q-m*z,v=V.y0-g*Q-f*z,y=h.source.pixelWidth,C=h.source.pixelHeight;e._tempPatternMatrix.set(u*y,g*C,m*y,f*C,x*y,v*C),p.applyPatternTransform(r,e._tempPatternMatrix),s.fillStyle=r,s.fillRect(Q,z,N,j)}else{const e=16777215!==T||F?p.getTintedCanvas({texture:h},T):d,t=e!==d;s.drawImage(e,t?0:A,t?0:R,t?e.width:W,t?e.height:H,Q,z,N,j)}}}};W._tempPatternMatrix=new s.u,W.extension={type:[a.Ag.CanvasPipesAdaptor],name:"batch"};let H=W;var E=n(780),B=n(9824);class O{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,n){this._renderer.renderPipes.batch.break(n);const a=this._colorStack;a[this._colorStackIndex]=a[this._colorStackIndex-1]&e.mask;const r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,n.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);const a=this._colorStack;this._colorStackIndex--;const r=a[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,n.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}O.extension={type:[a.Ag.CanvasPipes],name:"colorMask"};var D=n(9501),U=n(268);function q(e,t){switch(t.type){case"rectangle":{const n=t;e.rect(n.x,n.y,n.width,n.height);break}case"roundedRectangle":{const n=t;!function(e,t,n,a,r,o){o=Math.max(0,Math.min(o,Math.min(a,r)/2)),e.moveTo(t+o,n),e.lineTo(t+a-o,n),e.quadraticCurveTo(t+a,n,t+a,n+o),e.lineTo(t+a,n+r-o),e.quadraticCurveTo(t+a,n+r,t+a-o,n+r),e.lineTo(t+o,n+r),e.quadraticCurveTo(t,n+r,t,n+r-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n)}(e,n.x,n.y,n.width,n.height,n.radius);break}case"circle":{const n=t;e.moveTo(n.x+n.radius,n.y),e.arc(n.x,n.y,n.radius,0,2*Math.PI);break}case"ellipse":{const n=t;e.ellipse?(e.moveTo(n.x+n.halfWidth,n.y),e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,2*Math.PI)):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.moveTo(1,0),e.arc(0,0,1,0,2*Math.PI),e.restore());break}case"triangle":{const n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{const n=t,a=n.points;if(!a?.length)break;e.moveTo(a[0],a[1]);for(let t=2;t<a.length;t+=2)e.lineTo(a[t],a[t+1]);n.closePath&&e.closePath();break}}}function F(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){const a=t[n];if(!a?.shape)continue;const r=a.transform,o=r&&!r.isIdentity();o&&(e.save(),e.transform(r.a,r.b,r.c,r.d,r.tx,r.ty)),q(e,a.shape),o&&e.restore()}return!0}class V{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if("pushMaskBegin"!==e.action&&"popMaskEnd"!==e.action)return;const t=this._renderer,n=t.canvasContext,a=n?.activeContext;if(!a)return;if("popMaskEnd"===e.action){return void(this._canvasMaskStack.pop()&&a.restore())}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const r=e.mask.mask;if(!(r instanceof D.A))return this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),void this._canvasMaskStack.push(!1);const o=r,i=o.context?.instructions;if(!i?.length)return void this._canvasMaskStack.push(!1);a.save(),n.setContextTransform(o.groupTransform,1==(t._roundPixels|o._roundPixels)),a.beginPath();let s=!1,c=!1;for(let e=0;e<i.length;e++){const t=i[e],n=t.action;if("fill"!==n&&"stroke"!==n)continue;const r=t.data,o=r?.path?.shapePath;if(!o?.shapePrimitives?.length)continue;const l=o.shapePrimitives;for(let e=0;e<l.length;e++){const t=l[e];if(!t?.shape)continue;const n=t.transform,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),q(a,t.shape),c=F(a,t.holes)||c,s=!0,r&&a.restore()}}if(!s)return a.restore(),void this._canvasMaskStack.push(!1);c?a.clip("evenodd"):a.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),(0,U.R)(t))}}V.extension={type:[a.Ag.CanvasPipes],name:"stencilMask"};var G=n(360),L=n(800),X=n(381),Y=n(5099);const Q="source-over";const z=new s.u;class N{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=function(){const e=u(),t=Object.create(null);return t.inherit=Q,t.none=Q,t.normal="source-over",t.add="lighter",t.multiply=e?"multiply":Q,t.screen=e?"screen":Q,t.overlay=e?"overlay":Q,t.darken=e?"darken":Q,t.lighten=e?"lighten":Q,t["color-dodge"]=e?"color-dodge":Q,t["color-burn"]=e?"color-burn":Q,t["hard-light"]=e?"hard-light":Q,t["soft-light"]=e?"soft-light":Q,t.difference=e?"difference":Q,t.exclusion=e?"exclusion":Q,t.saturation=e?"saturation":Q,t.color=e?"color":Q,t.luminosity=e?"luminosity":Q,t["linear-burn"]=e?"color-burn":Q,t["linear-dodge"]=e?"color-dodge":Q,t["linear-light"]=e?"hard-light":Q,t["pin-light"]=e?"hard-light":Q,t["vivid-light"]=e?"hard-light":Q,t["hard-mix"]=Q,t.negation=e?"difference":Q,t["normal-npm"]=t.normal,t["add-npm"]=t.add,t["screen-npm"]=t.screen,t.erase="destination-out",t.subtract=Q,t.divide=Q,t.min=Q,t.max=Q,t}(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":e.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":e.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":e.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,n,a){const r=a?s.u.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||s.u.IDENTITY;let o=z;o.copyFrom(r),o.append(e);const i=this._projTransform,c=this.activeResolution;if(n=n||c,i){const e=s.u.shared;e.copyFrom(o),e.prepend(i),o=e}t?this.activeContext.setTransform(o.a*n,o.b*n,o.c*n,o.d*n,o.tx*c|0,o.ty*c|0):this.activeContext.setTransform(o.a*n,o.b*n,o.c*n,o.d*n,o.tx*c,o.ty*c)}clear(e,t){const n=this.activeContext,a=this._renderer;if(n.clearRect(0,0,a.width,a.height),e){const r=c.Q.shared.setValue(e);n.globalAlpha=t??r.alpha,n.fillStyle=r.toHex(),n.fillRect(0,0,a.width,a.height),n.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t)return this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),void(this.activeContext.globalCompositeOperation="source-over");this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}N.extension={type:[a.Ag.CanvasSystem],name:"canvasContext"};class j{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}j.extension={type:[a.Ag.CanvasSystem],name:"limits"};var $=n(7238),J=n(4884);class K{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:n,context:a}=this._ensureCanvas(t);return{canvas:n,context:a,width:n.width,height:n.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:n}=this._ensureCanvas(t);n.width=e.pixelWidth,n.height=e.pixelHeight}startRenderPass(e,t,n,a){const r=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=r.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,n,a)}clear(e,t,n,a){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,o=a||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(o.x,o.y,o.width,o.height),n){const e=c.Q.shared.setValue(n);e.alpha>0&&(r.globalAlpha=e.alpha,r.fillStyle=e.toHex(),r.fillRect(o.x,o.y,o.width,o.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,n,a,r){const o=this._renderTargetSystem.getGpuRenderTarget(e).canvas,i=t.source,{context:s}=this._ensureCanvas(i),c=r?.x??0,l=r?.y??0;return s.drawImage(o,n.x,n.y,a.width,a.height,c,l,a.width,a.height),i.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;t&&J.q.test(t)||(t=l.e.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),t.width===e.pixelWidth&&t.height===e.pixelHeight||(t.width=e.pixelWidth,t.height=e.pixelHeight);const n=t.getContext("2d");return{canvas:t,context:n}}}class Z extends $.l{constructor(e){super(e),this.adaptor=new K,this.adaptor.init(e,this)}}Z.extension={type:[a.Ag.CanvasSystem],name:"renderTarget"};class ee{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=l.e.get().createCanvas(),n=t.getContext("2d"),a=p.getCanvasSource(e);if(!a)return t;const r=e.frame,o=e.source._resolution??e.source.resolution??1,i=r.x*o,s=r.y*o,c=r.width*o,h=r.height*o;return t.width=Math.ceil(c),t.height=Math.ceil(h),n.drawImage(a,i,s,c,h,0,0,c,h),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}ee.extension={type:[a.Ag.CanvasSystem],name:"texture"};const te=[...X.i,N,j,ee,Z],ne=[G.j,E.s,R.k,o.a,B.z,V,O,r._],ae=[H,A],re=[],oe=[],ie=[];a.XO.handleByNamedList(a.Ag.CanvasSystem,re),a.XO.handleByNamedList(a.Ag.CanvasPipes,oe),a.XO.handleByNamedList(a.Ag.CanvasPipesAdaptor,ie),a.XO.add(...te,...ne,...ae);class se extends L.k{constructor(){super({name:"canvas",type:Y.W.CANVAS,systems:re,renderPipes:oe,renderPipeAdaptors:ie})}}}}]);
@@ -0,0 +1 @@
1
+ (self.webpackChunkvizor_2d=self.webpackChunkvizor_2d||[]).push([[859],{6554:(e,t,r)=>{r.d(t,{d:()=>a});var i=r(9113),n=r(3012),o=r(8475),u=r(7547);const s=class e extends o.M{constructor(t){super(t={...e.defaultOptions,...t}),this.enabled=!0,this._state=u.U.for2d(),this.blendMode=t.blendMode,this.padding=t.padding,"boolean"==typeof t.antialias?this.antialias=t.antialias?"on":"off":this.antialias=t.antialias,this.resolution=t.resolution,this.blendRequired=t.blendRequired,this.clipToViewport=t.clipToViewport,this.addResource("uTexture",0,1),t.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,r,i){e.applyFilter(this,t,r,i)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(t){const{gpu:r,gl:o,...u}=t;let s,a;return r&&(s=n.B.from(r)),o&&(a=i.M.from(o)),new e({gpuProgram:s,glProgram:a,...u})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let a=s},3859:(e,t,r)=>{var i=r(8507);class n{constructor(e){this._renderer=e}push(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",canBundle:!1,action:"pushFilter",container:t,filterEffect:e})}pop(e,t,r){this._renderer.renderPipes.batch.break(r),r.add({renderPipeId:"filter",action:"popFilter",canBundle:!1})}execute(e){"pushFilter"===e.action?this._renderer.filter.push(e):"popFilter"===e.action&&this._renderer.filter.pop()}destroy(){this._renderer=null}}n.extension={type:[i.Ag.WebGLPipes,i.Ag.WebGPUPipes,i.Ag.CanvasPipes],name:"filter"};var o=r(9113),u=r(3012),s=r(6554),a="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\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\nstruct VSOutput {\n @builtin(position) position: vec4<f32>,\n @location(0) uv: 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\n@vertex\nfn mainVertex(\n @location(0) aPosition: vec2<f32>,\n) -> VSOutput {\n return VSOutput(\n filterVertexPosition(aPosition),\n filterTextureCoord(aPosition)\n );\n}\n\n@fragment\nfn mainFragment(\n @location(0) uv: vec2<f32>,\n) -> @location(0) vec4<f32> {\n return textureSample(uTexture, uSampler, uv);\n}\n";class l extends s.d{constructor(){super({gpuProgram:u.B.from({vertex:{source:a,entryPoint:"mainVertex"},fragment:{source:a,entryPoint:"mainFragment"},name:"passthrough-filter"}),glProgram:o.M.from({vertex:"in vec2 aPosition;\nout vec2 vTextureCoord;\n\nuniform vec4 uInputSize;\nuniform vec4 uOutputFrame;\nuniform vec4 uOutputTexture;\n\nvec4 filterVertexPosition( void )\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( void )\n{\n return aPosition * (uOutputFrame.zw * uInputSize.zw);\n}\n\nvoid main(void)\n{\n gl_Position = filterVertexPosition();\n vTextureCoord = filterTextureCoord();\n}\n",fragment:"in vec2 vTextureCoord;\nout vec4 finalColor;\nuniform sampler2D uTexture;\nvoid main() {\n finalColor = texture(uTexture, vTextureCoord);\n}\n",name:"passthrough-filter"})})}}var d=r(9313),c=r(3513),p=r(6011),f=r(5811),h=r(5589),g=r(2437),x=r(5099),m=r(9636);const T=new d.u;var b=r(268);const _=new p.V({attributes:{aPosition:{buffer:new Float32Array([0,0,1,0,1,1,0,1]),format:"float32x2",stride:8,offset:0}},indexBuffer:new Uint32Array([0,1,2,0,2,3])});class v{constructor(){this.skip=!1,this.inputTexture=null,this.backTexture=null,this.filters=null,this.bounds=new m.c,this.container=null,this.blendRequired=!1,this.outputRenderSurface=null,this.globalFrame={x:0,y:0,width:0,height:0},this.firstEnabledIndex=-1,this.lastEnabledIndex=-1}}class F{constructor(e){this._filterStackIndex=0,this._filterStack=[],this._filterGlobalUniforms=new f.k({uInputSize:{value:new Float32Array(4),type:"vec4<f32>"},uInputPixel:{value:new Float32Array(4),type:"vec4<f32>"},uInputClamp:{value:new Float32Array(4),type:"vec4<f32>"},uOutputFrame:{value:new Float32Array(4),type:"vec4<f32>"},uGlobalFrame:{value:new Float32Array(4),type:"vec4<f32>"},uOutputTexture:{value:new Float32Array(4),type:"vec4<f32>"}}),this._globalFilterBindGroup=new c.T({}),this.renderer=e}get activeBackTexture(){return this._activeFilterData?.backTexture}push(e){const t=this.renderer,r=e.filterEffect.filters,i=this._pushFilterData();i.skip=!1,i.filters=r,i.container=e.container,i.outputRenderSurface=t.renderTarget.renderSurface;const n=t.renderTarget.renderTarget.colorTexture.source,o=n.resolution,u=n.antialias;if(r.every((e=>!e.enabled)))return void(i.skip=!0);const s=i.bounds;if(this._calculateFilterArea(e,s),this._calculateFilterBounds(i,t.renderTarget.rootViewPort,u,o,1),i.skip)return;const a=this._getPreviousFilterData(),l=this._findFilterResolution(o);let d=0,c=0;a&&(d=a.bounds.minX,c=a.bounds.minY),this._calculateGlobalFrame(i,d,c,l,n.width,n.height),this._setupFilterTextures(i,s,t,a)}generateFilteredTexture({texture:e,filters:t}){const r=this._pushFilterData();this._activeFilterData=r,r.skip=!1,r.filters=t;const i=e.source,n=i.resolution,o=i.antialias;if(t.every((e=>!e.enabled)))return r.skip=!0,e;const u=r.bounds;if(u.addRect(e.frame),this._calculateFilterBounds(r,u.rectangle,o,n,0),r.skip)return e;const s=n;this._calculateGlobalFrame(r,0,0,s,i.width,i.height),r.outputRenderSurface=g.W.getOptimalTexture(u.width,u.height,r.resolution,r.antialias),r.backTexture=h.g.EMPTY,r.inputTexture=e;this.renderer.renderTarget.finishRenderPass(),this._applyFiltersToTexture(r,!0);const a=r.outputRenderSurface;return a.source.alphaMode="premultiplied-alpha",a}pop(){const e=this.renderer,t=this._popFilterData();t.skip||(e.globalUniforms.pop(),e.renderTarget.finishRenderPass(),this._activeFilterData=t,this._applyFiltersToTexture(t,!1),t.blendRequired&&g.W.returnTexture(t.backTexture),g.W.returnTexture(t.inputTexture))}getBackTexture(e,t,r){const i=e.colorTexture.source._resolution,n=g.W.getOptimalTexture(t.width,t.height,i,!1);let o=t.minX,u=t.minY;r&&(o-=r.minX,u-=r.minY),o=Math.floor(o*i),u=Math.floor(u*i);const s=Math.ceil(t.width*i),a=Math.ceil(t.height*i);return this.renderer.renderTarget.copyToTexture(e,n,{x:o,y:u},{width:s,height:a},{x:0,y:0}),n}applyFilter(e,t,r,i){const n=this.renderer,o=this._activeFilterData,u=o.outputRenderSurface===r,s=n.renderTarget.rootRenderTarget.colorTexture.source._resolution,a=this._findFilterResolution(s);let l=0,d=0;if(u){const e=this._findPreviousFilterOffset();l=e.x,d=e.y}this._updateFilterUniforms(t,r,o,l,d,a,u,i);const c=e.enabled?e:this._getPassthroughFilter();this._setupBindGroupsAndRender(c,t,n)}calculateSpriteMatrix(e,t){const r=this._activeFilterData,i=e.set(r.inputTexture._source.width,0,0,r.inputTexture._source.height,r.bounds.minX,r.bounds.minY),n=t.worldTransform.copyTo(d.u.shared),o=t.renderGroup||t.parentRenderGroup;return o&&o.cacheToLocalTransform&&n.prepend(o.cacheToLocalTransform),n.invert(),i.prepend(n),i.scale(1/t.texture.orig.width,1/t.texture.orig.height),i.translate(t.anchor.x,t.anchor.y),i}destroy(){this._passthroughFilter?.destroy(!0),this._passthroughFilter=null}_getPassthroughFilter(){return this._passthroughFilter??(this._passthroughFilter=new l),this._passthroughFilter}_setupBindGroupsAndRender(e,t,r){if(r.renderPipes.uniformBatch){const e=r.renderPipes.uniformBatch.getUboResource(this._filterGlobalUniforms);this._globalFilterBindGroup.setResource(e,0)}else this._globalFilterBindGroup.setResource(this._filterGlobalUniforms,0);this._globalFilterBindGroup.setResource(t.source,1),this._globalFilterBindGroup.setResource(t.source.style,2),e.groups[0]=this._globalFilterBindGroup,r.encoder.draw({geometry:_,shader:e,state:e._state,topology:"triangle-list"}),r.type===x.W.WEBGL&&r.renderTarget.finishRenderPass()}_setupFilterTextures(e,t,r,i){if(e.backTexture=h.g.EMPTY,e.inputTexture=g.W.getOptimalTexture(t.width,t.height,e.resolution,e.antialias),e.blendRequired){r.renderTarget.finishRenderPass();const n=r.renderTarget.getRenderTarget(e.outputRenderSurface);e.backTexture=this.getBackTexture(n,t,i?.bounds)}r.renderTarget.bind(e.inputTexture,!0),r.globalUniforms.push({offset:t})}_calculateGlobalFrame(e,t,r,i,n,o){const u=e.globalFrame;u.x=t*i,u.y=r*i,u.width=n*i,u.height=o*i}_updateFilterUniforms(e,t,r,i,n,o,u,s){const a=this._filterGlobalUniforms.uniforms,l=a.uOutputFrame,d=a.uInputSize,c=a.uInputPixel,p=a.uInputClamp,f=a.uGlobalFrame,g=a.uOutputTexture;u?(l[0]=r.bounds.minX-i,l[1]=r.bounds.minY-n):(l[0]=0,l[1]=0),l[2]=e.frame.width,l[3]=e.frame.height,d[0]=e.source.width,d[1]=e.source.height,d[2]=1/d[0],d[3]=1/d[1],c[0]=e.source.pixelWidth,c[1]=e.source.pixelHeight,c[2]=1/c[0],c[3]=1/c[1],p[0]=.5*c[2],p[1]=.5*c[3],p[2]=e.frame.width*d[2]-.5*c[2],p[3]=e.frame.height*d[3]-.5*c[3];const x=this.renderer.renderTarget.rootRenderTarget.colorTexture;f[0]=i*o,f[1]=n*o,f[2]=x.source.width*o,f[3]=x.source.height*o,t instanceof h.g&&(t.source.resource=null);const m=this.renderer.renderTarget.getRenderTarget(t);this.renderer.renderTarget.bind(t,!!s),t instanceof h.g?(g[0]=t.frame.width,g[1]=t.frame.height):(g[0]=m.width,g[1]=m.height),g[2]=m.isRoot?-1:1,this._filterGlobalUniforms.update()}_findFilterResolution(e){let t=this._filterStackIndex-1;for(;t>0&&this._filterStack[t].skip;)--t;return t>0&&this._filterStack[t].inputTexture?this._filterStack[t].inputTexture.source._resolution:e}_findPreviousFilterOffset(){let e=0,t=0,r=this._filterStackIndex;for(;r>0;){r--;const i=this._filterStack[r];if(!i.skip){e=i.bounds.minX,t=i.bounds.minY;break}}return{x:e,y:t}}_calculateFilterArea(e,t){if(e.renderables?function(e,t){t.clear();const r=t.matrix;for(let r=0;r<e.length;r++){const i=e[r];if(i.globalDisplayStatus<7)continue;const n=i.renderGroup??i.parentRenderGroup;t.matrix=n?.isCachedAsTexture?T.copyFrom(n.textureOffsetInverseTransform).append(i.worldTransform):n?._parentCacheAsTextureRenderGroup?T.copyFrom(n._parentCacheAsTextureRenderGroup.inverseWorldTransform).append(i.groupTransform):i.worldTransform,t.addBounds(i.bounds)}t.matrix=r}(e.renderables,t):e.filterEffect.filterArea?(t.clear(),t.addRect(e.filterEffect.filterArea),t.applyMatrix(e.container.worldTransform)):e.container.getFastGlobalBounds(!0,t),e.container){const r=(e.container.renderGroup||e.container.parentRenderGroup).cacheToLocalTransform;r&&t.applyMatrix(r)}}_applyFiltersToTexture(e,t){const r=e.inputTexture,i=e.bounds,n=e.filters,o=e.firstEnabledIndex,u=e.lastEnabledIndex;if(this._globalFilterBindGroup.setResource(r.source.style,2),this._globalFilterBindGroup.setResource(e.backTexture.source,3),o===u)n[o].apply(this,r,e.outputRenderSurface,t);else{let r=e.inputTexture;const s=g.W.getOptimalTexture(i.width,i.height,r.source._resolution,!1);let a=s;for(let e=o;e<u;e++){const t=n[e];if(!t.enabled)continue;t.apply(this,r,a,!0);const i=r;r=a,a=i}n[u].apply(this,r,e.outputRenderSurface,t),g.W.returnTexture(s)}}_calculateFilterBounds(e,t,r,i,n){const o=this.renderer,u=e.bounds,s=e.filters;let a=1/0,l=0,d=!0,c=!1,p=!1,f=!0,h=-1,g=-1;for(let e=0;e<s.length;e++){const t=s[e];if(!t.enabled)continue;-1===h&&(h=e),g=e,a=Math.min(a,"inherit"===t.resolution?i:t.resolution),l+=t.padding,"off"===t.antialias?d=!1:"inherit"===t.antialias&&d&&(d=r),t.clipToViewport||(f=!1);if(!!!(t.compatibleRenderers&o.type)){p=!1;break}if(t.blendRequired&&!(o.backBuffer?.useBackBuffer??1)){(0,b.R)("Blend filter requires backBuffer on WebGL renderer to be enabled. Set `useBackBuffer: true` in the renderer options."),p=!1;break}p=!0,c||(c=t.blendRequired)}p?(f&&u.fitBounds(0,t.width/i,0,t.height/i),u.scale(a).ceil().scale(1/a).pad((0|l)*n),u.isPositive?(e.antialias=d,e.resolution=a,e.blendRequired=c,e.firstEnabledIndex=h,e.lastEnabledIndex=g):e.skip=!0):e.skip=!0}_popFilterData(){return this._filterStackIndex--,this._filterStack[this._filterStackIndex]}_getPreviousFilterData(){let e,t=this._filterStackIndex-1;for(;t>0&&(t--,e=this._filterStack[t],e.skip););return e}_pushFilterData(){let e=this._filterStack[this._filterStackIndex];return e||(e=this._filterStack[this._filterStackIndex]=new v),this._filterStackIndex++,e}}F.extension={type:[i.Ag.WebGLSystem,i.Ag.WebGPUSystem],name:"filter"},i.XO.add(F),i.XO.add(n)}}]);